Created
September 19, 2014 09:10
-
-
Save dlenettr/ba8b0761fb456c5b3095 to your computer and use it in GitHub Desktop.
Custom için xfield parametresi (332)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dosya : engine/modules/functions.php | |
Bul : | |
----------------8<--------------------- | |
global $db, $is_logged, $member_id, $xf_inited, $cat_info, $config, $user_group, $category_id, $_TIME, $lang, $smartphone_detected, $dle_module, $allow_comments_ajax, $PHP_SELF, $news_date, $banners, $banner_in_news, $url_page, $user_query, $custom_news, $global_news_count; | |
----------------8<--------------------- | |
İle değiştir ( Yani arasına $_custom_xfield ekle ): | |
----------------8<--------------------- | |
global $db, $_custom_xfield, $is_logged, $member_id, $xf_inited, $cat_info, $config, $user_group, $category_id, $_TIME, $lang, $smartphone_detected, $dle_module, $allow_comments_ajax, $PHP_SELF, $news_date, $banners, $banner_in_news, $url_page, $user_query, $custom_news, $global_news_count; | |
----------------8<--------------------- | |
Bul : | |
----------------8<--------------------- | |
if( preg_match( "#category=['\"](.+?)['\"]#i", $param_str, $match ) ) { | |
----------------8<--------------------- | |
Üstüne Ekle : | |
----------------8<--------------------- | |
if( preg_match( "#xfield=['\"](.+?)['\"]#i", $param_str, $match ) ) { | |
if ( $match[1] == "_SEARCH_" ) { | |
$where[] = "p.xfields LIKE '%" . str_replace( ":", "|", $_custom_xfield ) . "%'"; | |
} else { | |
$_temp = explode( ",", $match[1] ); $_rules = array(); | |
foreach ( $_temp as $_temp2 ) { | |
$_rules[] = "p.xfields LIKE '%" . str_replace( ":", "|", $_temp2 ) . "%'"; | |
} | |
$where[] = implode( " AND ", $_rules ); | |
} | |
} | |
----------------8<--------------------- | |
Eğer kategori içinde böyle bir özellik isterseniz : | |
======================================= | |
Bul : | |
----------------8<--------------------- | |
$match[1] = explode (',', $match[1]); | |
----------------8<--------------------- | |
Üstüne Ekle : | |
----------------8<--------------------- | |
if ( $match[1] == "_INSIDE_" && isset( $category_id ) ) $match[1] = $category_id; | |
----------------8<--------------------- | |
======================================= | |
Dosya : engine/engine.php | |
Bul : | |
----------------8<--------------------- | |
} elseif ($do == 'xfsearch') { | |
... | |
... | |
... | |
... | |
} elseif ($do == 'userinfo') { | |
----------------8<--------------------- | |
İle Değiştir : | |
----------------8<--------------------- | |
// İlave alan çoklu arama | |
} elseif ($do == 'xfsearch') { | |
if ($cstart) { | |
$cstart = $cstart - 1; | |
$cstart = $cstart * $config['news_number']; | |
} | |
$fields = array( | |
'year' => "Yıl", | |
'country' => "Ülke", | |
'rating' => "Değerlendirme", | |
'il' => "İl", | |
'ilce' => "İlçe", // Bu alanların nasıl kullanıldığı hakkında bilgi: http://dle.net.tr/dle-eklenti/252-ilave-alanlar-icin-coklu-arama.html | |
); | |
$newsmodule = true; $stop_xf = false; | |
$xf = $_GET['xf']; | |
if ( $config['charset'] == "utf-8" AND $config['charset'] != detect_encoding($xf) ) { | |
$xf = iconv( "UTF-8", "utf-8//IGNORE", $xf ); | |
} | |
// Field Control | |
if ( strpos($xf, "|") !== false ) { $xfs = explode("|", $xf); $xfs = array_filter( $xfs ); foreach( $xfs as $xfv ) { $_tmp = explode( ":", $xfv); if (!in_array( $_tmp[0], array_keys( $fields ))) { msgbox( "Hata", "Bu alan için arama yapamazsınız." ); break; } } } | |
if ( strpos($xf, "|") !== false ) { | |
$xfs = explode("|", $xf); $xfs = array_filter( $xfs ); $_xf = array(); | |
if ( count( $xfs ) == 1 ) { $_custom_xfield = $xfs[0]; } | |
foreach( $xfs as $xfk => $xfv ) { | |
if (!empty($xfv)) { | |
$xfv = @$db->safesql ( htmlspecialchars ( strip_tags ( stripslashes ( trim ( $xfv ) ) ), ENT_QUOTES, $config['charset'] ) ); | |
$xfv = str_replace( ":", "|", $xfv ); | |
$_xf[] = "xfields LIKE '%{$xfv}%'"; | |
} | |
} | |
$_xf = implode( " AND ", $_xf ); | |
$url_page = $config['http_home_url'] . "xfsearch/" . urlencode ( str_replace("'", "'", $xf) ); | |
$user_query = "do=xfsearch&xf=" . urlencode ( str_replace("'", "'", $xf) ); | |
$sql_select = "SELECT SQL_CALC_FOUND_ROWS p.id, p.autor, p.date, p.short_story, CHAR_LENGTH(p.full_story) as full_story, p.xfields, p.title, p.category, p.alt_name, p.comm_num, p.allow_comm, p.fixed, p.tags, e.news_read, e.allow_rate, e.rating, e.vote_num, e.votes, e.view_edit, e.editdate, e.editor, e.reason FROM " . PREFIX . "_post p LEFT JOIN " . PREFIX . "_post_extras e ON (p.id=e.news_id) WHERE {$stop_list}{$_xf} AND approve=1" . $where_date . " ORDER BY " . $news_sort_by . " " . $news_direction_by . " LIMIT " . $cstart . "," . $config['news_number']; | |
$sql_count = "SELECT FOUND_ROWS() as count"; | |
$allow_active_news = true; | |
$spdbar = array(); | |
foreach ($xfs as $xfsv) { | |
$_tmp = explode( ":", $xfsv); | |
$spdbar[] = $fields[ $_tmp[0] ] . " : " . $_tmp[1]; | |
} | |
$xf = implode( " & ", $spdbar ); // Speedbar aralardaki işaret: & yani & | |
} else { | |
$xf = @$db->safesql ( htmlspecialchars ( strip_tags ( stripslashes ( trim ( $xf ) ) ), ENT_QUOTES, $config['charset'] ) ); | |
$url_page = $config['http_home_url'] . "xfsearch/" . urlencode ( str_replace("'", "'", $xf) ); | |
$user_query = "do=xfsearch&xf=" . urlencode ( str_replace("'", "'", $xf) ); | |
if (isset ( $_SESSION['dle_sort_xfsearch'] )) $news_sort_by = $_SESSION['dle_sort_xfsearch']; | |
if (isset ( $_SESSION['dle_direction_xfsearch'] )) $news_direction_by = $_SESSION['dle_direction_xfsearch']; | |
$sql_select = "SELECT SQL_CALC_FOUND_ROWS p.id, p.autor, p.date, p.short_story, CHAR_LENGTH(p.full_story) as full_story, p.xfields, p.title, p.category, p.alt_name, p.comm_num, p.allow_comm, p.fixed, p.tags, e.news_read, e.allow_rate, e.rating, e.vote_num, e.votes, e.view_edit, e.editdate, e.editor, e.reason FROM " . PREFIX . "_post p LEFT JOIN " . PREFIX . "_post_extras e ON (p.id=e.news_id) WHERE {$stop_list}xfields LIKE '%{$xf}%' AND approve=1" . $where_date . " ORDER BY " . $news_sort_by . " " . $news_direction_by . " LIMIT " . $cstart . "," . $config['news_number']; | |
$sql_count = "SELECT FOUND_ROWS() as count"; | |
$allow_active_news = true; | |
} | |
// İlave alan çoklu arama | |
----------------8<--------------------- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment