1
0
mirror of https://github.com/e107inc/e107.git synced 2025-03-14 01:19:44 +01:00

Fixes #835 and brings Pages search routine up to v2.x standards.

This commit is contained in:
Cameron 2015-01-27 19:06:12 -08:00
parent 4c897c905d
commit 543c296442
11 changed files with 209 additions and 39 deletions

View File

@ -1161,8 +1161,8 @@ class system_tools
$tp = e107::getParser();
$pref = e107::getPref();
$config = ($type == 'core') ? e107::getConfig('core') : e107::getPlugConfig($type);
$config = ($type == 'core' || $type == 'search' ) ? e107::getConfig($type) : e107::getPlugConfig($type);
$spref = $config->getPref();
ksort($spref);
@ -1173,7 +1173,8 @@ class system_tools
<legend class='e-hideme'>".DBLAN_20."</legend>";
$text .= "<select class='tbox' name='type_select' onchange='urljump(this.options[selectedIndex].value)' >
<option value='".e_ADMIN."db.php?mode=".$_GET['mode']."&amp;type=core'>Core</option>\n";
<option value='".e_ADMIN."db.php?mode=".$_GET['mode']."&amp;type=core'>Core</option>\n
<option value='".e_ADMIN."db.php?mode=".$_GET['mode']."&amp;type=search'>Search</option>\n";
// e107::getConfig($type)->aliases

View File

@ -34,11 +34,13 @@ $query = explode('.', e_QUERY);
$search_prefs = $sysprefs -> getArray('search_prefs');
//$search_handlers['news'] = ADLAN_0;
//$search_handlers['news'] = ADLAN_0; // Moved to Plugin
$search_handlers['comments'] = ADLAN_114;
$search_handlers['users'] = SEALAN_7;
//$search_handlers['downloads'] = ADLAN_24;
$search_handlers['pages'] = SEALAN_39;
//$search_handlers['downloads'] = ADLAN_24; // Moved to Plugin
// $search_handlers['pages'] = SEALAN_39; // Moved to Plugin
foreach($pref['e_search_list'] as $file)

View File

@ -1580,7 +1580,34 @@ function update_706_to_800($type='')
$log->addDebug("Icon category added");
}
// Search Clean up ----------------------------------
$searchPref = e107::getConfig('search');
if($searchPref->getPref('core_handlers/news'))
{
if ($just_check) return update_needed('Core search handlers need to be updated.');
$searchPref->removePref('core_handlers/news')->save(false,true,false);
}
if($searchPref->getPref('core_handlers/downloads'))
{
if ($just_check) return update_needed('Core search handlers need to be updated.');
$searchPref->removePref('core_handlers/downloads')->save(false,true,false);
}
if($searchPref->getPref('core_handlers/pages'))
{
if ($just_check) return update_needed('Core search handlers need to be updated.');
$searchPref->removePref('core_handlers/pages')->save(false,true,false);
}
// Any other images should be imported manually via Media Manager batch-import.
// ------------------------------------------------------------------

View File

@ -413,15 +413,7 @@ City, State, Country
),
)]]></search>
<search name="core_handlers"><![CDATA[array (
'news' =>
array (
'class' => '0',
'pre_title' => '0',
'pre_title_alt' => '',
'chars' => '150',
'results' => '10',
'order' => '1',
),
'comments' =>
array (
'class' => '0',
@ -440,24 +432,7 @@ City, State, Country
'results' => '10',
'order' => '3',
),
'downloads' =>
array (
'class' => '0',
'pre_title' => '1',
'pre_title_alt' => '',
'chars' => '150',
'results' => '10',
'order' => '4',
),
'pages' =>
array (
'class' => '0',
'chars' => '150',
'results' => '10',
'pre_title' => '0',
'pre_title_alt' => '',
'order' => '5',
),
)]]></search>
<search name="google">0</search>
<search name="multisearch">1</search>

View File

@ -15,7 +15,7 @@
*/
if (!defined('e107_INIT')) { exit; }
/*
$advanced['cat']['type'] = 'dropdown';
$advanced['cat']['text'] = LAN_SEARCH_63.':';
$advanced['cat']['list'][] = array('id' => 'all', 'title' => LAN_SEARCH_51);
@ -40,5 +40,6 @@ $advanced['match']['type'] = 'dropdown';
$advanced['match']['text'] = LAN_SEARCH_52.':';
$advanced['match']['list'][] = array('id' => 0, 'title' => LAN_SEARCH_67);
$advanced['match']['list'][] = array('id' => 1, 'title' => LAN_SEARCH_54);
*/
?>

View File

@ -15,7 +15,7 @@
*/
if (!defined('e107_INIT')) { exit; }
/*
$advanced['cat']['type'] = 'dropdown';
$advanced['cat']['text'] = LAN_SEARCH_55.':';
$advanced['cat']['list'][] = array('id' => 'all', 'title' => LAN_SEARCH_51);
@ -37,5 +37,6 @@ $advanced['match']['type'] = 'dropdown';
$advanced['match']['text'] = LAN_SEARCH_52.':';
$advanced['match']['list'][] = array('id' => 0, 'title' => LAN_SEARCH_53);
$advanced['match']['list'][] = array('id' => 1, 'title' => LAN_SEARCH_54);
*/
?>

View File

@ -15,8 +15,8 @@
*/
if (!defined('e107_INIT')) { exit; }
/*
$advanced['date']['type'] = 'date';
$advanced['date']['text'] = LAN_SEARCH_68.':';
*/
?>

View File

@ -17,6 +17,7 @@
if (!defined('e107_INIT')) { exit; }
// advanced
/*
$advanced_where = "";
if (isset($_GET['cat']) && is_numeric($_GET['cat'])) {
$advanced_where .= " d.download_category='".$_GET['cat']."' AND";
@ -59,5 +60,5 @@ function search_downloads($row) {
$res['detail'] = LAN_SEARCH_15." ".$row['download_author']." | ".LAN_SEARCH_66.": ".$datestamp;
return $res;
}
*/
?>

View File

@ -13,6 +13,7 @@
if (!defined('e107_INIT')) { exit; }
// advanced
/*
$advanced_where = "";
if (isset($_GET['cat']) && $_GET['cat'] != 'all') {
$advanced_where .= " c.category_id='".intval($_GET['cat'])."' AND";
@ -51,5 +52,5 @@ function search_news($row) {
$res['detail'] = LAN_SEARCH_3.$con -> convert_date($row['news_datestamp'], "long");
return $res;
}
*/
?>

View File

@ -13,6 +13,7 @@
if (!defined('e107_INIT')) { exit; }
// advanced
/*
$advanced_where = "";
if (isset($_GET['time']) && is_numeric($_GET['time'])) {
$advanced_where .= " page_datestamp ".($_GET['on'] == 'new' ? '>=' : '<=')." '".(time() - $_GET['time'])."' AND";
@ -41,5 +42,6 @@ function search_pages($row) {
$res['detail'] = LAN_SEARCH_3.$con -> convert_date($row['page_datestamp'], "long");
return $res;
}
*/
?>

View File

@ -0,0 +1,159 @@
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2015 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Pages e_search addon
*/
if (!defined('e107_INIT')) { exit; }
// v2 e_search addon.
// Removes the need for search_parser.php, search_advanced.php and in most cases search language files.
class page_search extends e_search // include plugin-folder in the name.
{
private $catList = array();
function __construct()
{
$sql = e107::getDb();
$books = $sql->retrieve("SELECT chapter_id,chapter_sef,chapter_parent, chapter_name FROM #page_chapters WHERE chapter_visibility IN (".USERCLASS_LIST.") ORDER BY chapter_parent, chapter_order ASC" , true);
foreach($books as $row)
{
$id = $row['chapter_id'];
$this->catList[$id] = $row;
}
}
private function getName($chapter)
{
return varset($this->catList[$chapter]['chapter_name'], false);
}
private function getSef($chapter)
{
return vartrue($this->catList[$chapter]['chapter_sef'],'--sef-not-assigned--');
}
private function getParent($chapter)
{
return varset($this->catList[$chapter]['chapter_parent'], false);
}
function config()
{
$sql = e107::getDb();
$catList = array();
$catList[] = array('id' => 'all', 'title' => LAN_SEARCH_51);
foreach($this->catList as $key=>$row)
{
if(!empty($row['chapter_parent']))
{
$catList[] = array('id' => $key, 'title' => $this->getName($row['chapter_parent'])." - ".$row['chapter_name']);
}
}
$search = array(
'name' => "Pages",
'table' => 'page',
'advanced' => array(
'cat' => array('type' => 'dropdown', 'text' => "Search in Book/Chapter", 'list'=>$catList),
// 'date'=> array('type' => 'date', 'text' => LAN_SEARCH_50),
// 'match'=> array('type' => 'dropdown', 'text' => LAN_SEARCH_52, 'list'=>$matchList)
),
'return_fields' => array('page_id', 'page_title', 'page_sef', 'page_text', 'page_chapter', 'page_datestamp', 'menu_image'),
'search_fields' => array('page_title' => '1.2', 'page_text' => '0.6', 'page_metakeys'=> '1.0'), // fields and their weights.
'order' => array('page_datestamp' => DESC),
'refpage' => 'page.php'
);
return $search;
}
/* Compile Database data for output */
function compile($row)
{
$tp = e107::getParser();
$book = $this->getParent($row['page_chapter']);
$row['chapter_sef'] = $this->getSef($row['page_chapter']);
$row['book_sef'] = $this->getSef($book);
if(!vartrue($row['page_sef']))
{
$row['page_sef'] = '--sef-not-assigned--';
}
$res = array();
$res['link'] = e107::getUrl()->create('page/view', $row, array('allow' => 'page_sef,page_title,page_id,chapter_sef,book_sef'));
$res['pre_title'] = $tp->toHtml($this->getName($book),false,'TITLE').' - '. $tp->toHtml($this->getName($row['page_chapter']),false,'TITLE'). " | ";
$res['title'] = $tp->toHtml($row['page_title'], false, 'TITLE');
$res['summary'] = (!empty($row['page_metadscr'])) ? $row['page_metadscr'] : $row['page_text'];
$res['detail'] = LAN_SEARCH_3.$tp->toDate($row['page_datestamp'], "long");
$res['image'] = $row['menu_image'];
return $res;
}
/**
* Optional - Advanced Where
* @param $parm - data returned from $parm (ie. advanced fields included. in this case 'cat' )
*/
function where($parm='')
{
$tp = e107::getParser();
$time = time();
$qry = " page_class IN (".USERCLASS_LIST.") AND `menu_name` = '' AND ";
if(!empty($parm['cat']) && $parm['cat'] != 'all')
{
$qry .= " page_chapter='".intval($parm['cat'])."' AND";
}
return $qry;
/*
if (isset($parm['time']) && is_numeric($parm['time'])) {
$qry .= " n.news_datestamp ".($parm['on'] == 'new' ? '>=' : '<=')." '".(time() - $parm['time'])."' AND";
}
return $qry;
*/
}
}
?>