1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-01 12:20:44 +02:00

Fixes - sitelinks, mysql, custompages

This commit is contained in:
CaMer0n
2009-11-26 09:02:46 +00:00
parent 949e0ceb2a
commit f78445421c
8 changed files with 237 additions and 182 deletions

View File

@@ -9,8 +9,8 @@
* Custom Menus/Pages Administration * Custom Menus/Pages Administration
* *
* $Source: /cvs_backup/e107_0.8/e107_admin/cpage.php,v $ * $Source: /cvs_backup/e107_0.8/e107_admin/cpage.php,v $
* $Revision: 1.29 $ * $Revision: 1.30 $
* $Date: 2009-11-25 11:54:53 $ * $Date: 2009-11-26 09:02:29 $
* $Author: e107coders $ * $Author: e107coders $
* *
*/ */
@@ -307,13 +307,8 @@ class page
} }
else else
{ {
$templates = array(); $templates = e107::getTemplateList('page');
$tmp = e107::getTemplate('page', 'page');
foreach($tmp as $key=>$val)
{
$templates[$key] = $key; //TODO add LANS?
}
$text .= " $text .= "
<tr> <tr>
<td>Template</td> <td>Template</td>

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_admin/links.php,v $ | $Source: /cvs_backup/e107_0.8/e107_admin/links.php,v $
| $Revision: 1.35 $ | $Revision: 1.36 $
| $Date: 2009-11-23 11:51:00 $ | $Date: 2009-11-26 09:02:32 $
| $Author: e107coders $ | $Author: e107coders $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -38,7 +38,6 @@ class links_admin extends e_admin_dispatcher
) )
); );
protected $adminMenu = array( protected $adminMenu = array(
'main/list' => array('caption'=> LCLAN_62, 'perm' => 'I'), 'main/list' => array('caption'=> LCLAN_62, 'perm' => 'I'),
'main/create' => array('caption'=> LCLAN_63, 'perm' => 'I'), 'main/create' => array('caption'=> LCLAN_63, 'perm' => 'I'),
@@ -54,64 +53,140 @@ class links_admin extends e_admin_dispatcher
} }
class links_admin_ui extends e_admin_ui class links_admin_ui extends e_admin_ui
{ {
protected $pluginTitle = "Site links";
protected $pluginTitle = "Site links"; protected $pluginName = 'core';
protected $pluginName = 'core'; protected $table = "links";
protected $table = "links"; protected $listQry = "SELECT * FROM #links ORDER BY link_category,link_order, link_id ASC"; // without any Order or Limit.
protected $pid = "link_id";
/** protected $perPage = 15;
* If present this array will be used to build your list query protected $batchDelete = true;
* You can link fileds from $field array with 'table' parameter, which should equal to a key (table) from this array
* 'leftField', 'rightField' and 'fields' attributes here are required, the rest is optional
*
* @var array [optional]
*/
protected $tableJoin = array (
// 'u.user' => array('leftField' => 'comment_author_id', 'rightField' => 'user_id', 'fields' => '*'/*, 'leftTable' => '', 'joinType' => 'LEFT JOIN', 'whereJoin' => 'AND u.user_ban=0', 'where' => ''*/)
);
//protected $listQry = "SELECT SQL_CALC_FOUND_ROWS * FROM #links"; // without any Order or Limit.
//protected $editQry = "SELECT * FROM #links WHERE comment_id = {ID}";
protected $pid = "link_id";
protected $perPage = 15;
protected $batchDelete = true;
protected $fields = array( protected $fields = array(
'checkboxes' => array('title'=> '', 'width' => '3%','forced' => true,'thclass' => 'center first','class' => 'center first'), 'checkboxes' => array('title'=> '', 'width' => '3%','forced' => true,'thclass' => 'center first','class' => 'center first'),
'link_button' => array('title'=> LAN_ICON, 'type'=>'icon', 'width'=>'5%', 'thclass' => 'center', 'class'=>'center'), 'link_button' => array('title'=> LAN_ICON, 'type'=>'icon', 'width'=>'5%', 'thclass' => 'center', 'class'=>'center'),
'link_id' => array('title'=> ID, 'width'=>'5%', 'forced'=> TRUE, 'primary'=>TRUE), 'link_id' => array('title'=> ID, 'nolist'=>TRUE),
'link_name' => array('title'=> LCLAN_15, 'width'=>'auto','type'=>'text'), 'link_name' => array('title'=> LCLAN_15, 'width'=>'auto','type'=>'method'),
'link_parent' => array('title'=> 'Sublink of', 'type' => 'method', 'width' => 'auto', 'batch'=>true, 'filter'=>true, 'thclass' => 'left first'), 'link_parent' => array('title'=> 'Sublink of', 'type' => 'dropdown', 'width' => 'auto', 'batch'=>true, 'filter'=>true, 'thclass' => 'left first'),
'link_url' => array('title'=> LCLAN_93, 'width'=>'auto','type'=>'text'), 'link_url' => array('title'=> LCLAN_93, 'width'=>'auto', 'type'=>'text'),
'link_class' => array('title'=> LAN_USERCLASS, 'type' => 'userclass', 'batch'=>true, 'filter'=>true, 'width' => 'auto'), 'link_class' => array('title'=> LAN_USERCLASS, 'type' => 'userclass', 'batch'=>true, 'filter'=>true, 'width' => 'auto'),
'link_description' => array('title'=> LCLAN_17, 'type' => 'bbarea', 'method'=>'tinymce_plugins', 'width' => 'auto'), 'link_description' => array('title'=> LCLAN_17, 'type' => 'bbarea', 'method'=>'tinymce_plugins', 'width' => 'auto'),
'link_category' => array('title'=> LCLAN_12, 'type' => 'method', 'batch'=>true, 'filter'=>true, 'width' => 'auto'), 'link_category' => array('title'=> LCLAN_12, 'type' => 'dropdown', 'batch'=>true, 'filter'=>true, 'width' => 'auto'),
'link_order' => array('title'=> LAN_ORDER, 'type' => 'text', 'width' => 'auto'), 'link_order' => array('title'=> LAN_ORDER, 'type' => 'text', 'width' => 'auto'),
'link_open' => array('title'=> LCLAN_19, 'type' => 'method', 'width' => 'auto', 'batch'=>true, 'filter'=>true, 'thclass' => 'left first'), 'link_open' => array('title'=> LCLAN_19, 'type' => 'dropdown', 'width' => 'auto', 'batch'=>true, 'filter'=>true, 'thclass' => 'left first'),
'link_function' => array('title'=> 'Function', 'type' => 'method', 'data'=>'str', 'width' => 'auto', 'thclass' => 'left first'), 'link_function' => array('title'=> 'Function', 'type' => 'method', 'data'=>'str', 'width' => 'auto', 'thclass' => 'left first'),
// 'increment' => array('title'=> LCLAN_91, 'width' => '3%','forced' => true,'thclass' => 'center'), // 'increment' => array('title'=> LCLAN_91, 'width' => '3%','forced' => true,'thclass' => 'center'),
'options' => array('title'=> LAN_OPTIONS, 'forced'=>TRUE, 'width' => '10%', 'thclass' => 'center last', 'class'=>'center') 'options' => array('title'=> LAN_OPTIONS, 'forced'=>TRUE, 'width' => '10%', 'thclass' => 'center last', 'class'=>'center')
); );
protected $fieldpref = array('checkboxes','link_id','link_name','link_class','link_order','options'); protected $fieldpref = array('checkboxes','link_id','link_name','link_class','link_order','options');
//required (but should be optional) - default column user prefs
// protected $fieldpref = array('checkboxes', 'comment_id', 'comment_item_id', 'comment_author_id', 'comment_author_name', 'comment_subject', 'comment_comment', 'comment_type', 'options');
// optional, if $pluginName == 'core', core prefs will be used, else e107::getPluginConfig($pluginName);
protected $prefs = array( protected $prefs = array(
'linkpage_screentip' => array('title'=>LCLAN_78, 'type'=>'boolean', 'help'=>LCLAN_79), 'linkpage_screentip' => array('title'=>LCLAN_78, 'type'=>'boolean', 'help'=>LCLAN_79),
'sitelinks_expandsub' => array('title'=>LCLAN_80, 'type'=>'boolean', 'help'=>LCLAN_81) 'sitelinks_expandsub' => array('title'=>LCLAN_80, 'type'=>'boolean', 'help'=>LCLAN_81)
); );
//FIXME - need to use linkArray data instead of $listQry-returned data
protected $linkArray = array();
function init()
{
$sql = e107::getDb();
$mes = e107::getMessage();
$this->getLinks();
$query = "SELECT link_id,link_name FROM #links ORDER BY link_name";
$this->linkParent[0] = '-';
$sql->db_Select_gen($query);
while($row = $sql->db_Fetch())
{
$id = $row['link_id'];
$this->linkParent[$id] = $row['link_name'];
}
$tmp = e107::getAddonConfig('e_sitelink','sitelinks');
foreach($tmp as $cat=> $array)
{
$func = array();
foreach($array as $val)
{
$newkey = $cat.'::'.$val['function'];
$func[$newkey] = $val['name'];
}
$this->linkFunctions[$cat] = $func;
}
$this->linkCategory = array(
1 => "1 - Main",
2 => "2 - Alt",
3 => "3 - Alt",
4 => "4 - Alt",
5 => "5 - Alt",
6 => "6 - Alt",
7 => "7 - Alt",
8 => "8 - Alt",
9 => "9 - Alt",
10 => "10 - Alt"
);
$this->linkOpen = array(
0 => LCLAN_20, // 0 = same window
1 => LCLAN_23, // new window
4 => LCLAN_24, // 4 = miniwindow 600x400
5 => LINKLAN_1 // 5 = miniwindow 800x600
);
$sitelinksTemplates = e107::getCoreTemplateList('sitelinks');
//TODO review.
$this->setDropDown('link_parent',$this->linkParent);
$this->setDropDown('link_category',$this->linkCategory);
$this->setDropDown('link_open',$this->linkOpen);
// $this->setDropDown('link_function',$this->linkFunctions);
// $this->setDropDown('link_template',$sitelinksTemplates);
if(isset($_POST['generate_sublinks']) && isset($_POST['sublink_type']) && $_POST['sublink_parent'] != "")
{
$this->generateSublinks();
}
}
/**
* Get linklist in it's proper order.
* @return
*/
function getLinks()
{
$sql = e107::getDb();
if($this->link_total = $sql->db_Select("links", "*", "ORDER BY link_category,link_order, link_id ASC", "nowhere"))
{
while($row = $sql->db_Fetch())
{
$ret[$row['link_parent']][] = $row;
}
}
$this->linkArray = $ret;
// print_a($this->linkArray);
}
function sublinksPage() function sublinksPage()
{ {
global $e107, $sql, $emessage; global $e107, $sql, $emessage;
@@ -213,16 +288,14 @@ class links_admin_ui extends e_admin_ui
return $sublink_type; return $sublink_type;
} }
function init()
{
$sql = e107::getDb();
$mes = e107::getMessage();
if(isset($_POST['generate_sublinks']) && isset($_POST['sublink_type']) && $_POST['sublink_parent'] != "") function generateSublinks()
{ {
$subtype = $_POST['sublink_type']; $subtype = $_POST['sublink_type'];
$sublink = $this->sublink_list($subtype); $sublink = $this->sublink_list($subtype);
$sql2 = e107::getDb('sql2'); $sql2 = e107::getDb('sql2');
@@ -273,85 +346,31 @@ class links_admin_ui extends e_admin_ui
{ {
// sitelinks_adminlog('01', $message); // 'Sublinks generated' // sitelinks_adminlog('01', $message); // 'Sublinks generated'
} }
} }
}
} }
//TODO Block and Unblock buttons, moderated links?
class links_admin_form_ui extends e_admin_form_ui class links_admin_form_ui extends e_admin_form_ui
{ {
public $linkFunctions = array();
public $linkCategory = array();
public $linkOpen = array();
public $linkParent = array();
function init() function init()
{ {
$sql = e107::getDb();
$query = "SELECT link_id,link_name FROM #links ORDER BY link_name";
$this->linkParent[0] = '-';
$sql->db_Select_gen($query);
while($row = $sql->db_Fetch())
{
$id = $row['link_id'];
$this->linkParent[$id] = $row['link_name'];
}
$tmp = e107::getAddonConfig('e_sitelink','sitelinks');
// $this->linkFunctions[0] = "(".LAN_OPTIONAL.")";
foreach($tmp as $cat=> $array)
{
$func = array();
foreach($array as $val)
{
$newkey = $cat.'::'.$val['function'];
$func[$newkey] = $val['name'];
}
$this->linkFunctions[$cat] = $func;
}
$this->linkCategory = array(
1 => "1 - Main",
2 => "2 - Alt",
3 => "3 - Alt",
4 => "4 - Alt",
5 => "5 - Alt",
6 => "6 - Alt",
7 => "7 - Alt",
8 => "8 - Alt",
9 => "9 - Alt",
10 => "10 - Alt"
);
$this->linkOpen = array(
0 => LCLAN_20, // 0 = same window
1 => LCLAN_23, // new window
4 => LCLAN_24, // 4 = miniwindow 600x400
5 => LINKLAN_1 // 5 = miniwindow 800x600
);
} }
function link_parent($curVal,$mode)
{ function link_name($curVal,$mode,$parm)
if($mode == 'read') {
//FIXME - I need access to the full array of $row, so I can check for the value of $link_parent;
if($mode == "read")
{ {
return $this->linkParent[$curVal]; return "<img src='".e_IMAGE."generic/branchbottom.gif' alt='' />".$curVal;
} }
if($mode == 'write')
{
return $this->selectbox('link_parent',$this->linkParent,$curVal);
}
else else
{ {
unset($this->linkParent[0]); return $curVal;
return $this->linkParent;
} }
} }
@@ -373,47 +392,6 @@ class links_admin_form_ui extends e_admin_form_ui
return $this->linkFunctions; return $this->linkFunctions;
} }
} }
function link_category($curVal,$mode)
{
if($mode == 'read')
{
return $this->linkCategory[$curVal];
}
if($mode == 'write')
{
return $this->selectbox('link_category',$this->linkCategory,$curVal);
}
else
{
return $this->linkCategory;
}
}
function link_open($curVal,$mode) // not really necessary since we can use 'dropdown' - but just an example of a custom function.
{
if($mode == 'read')
{
return $this->linkOpen[$curVal];
}
if($mode == 'write')
{
$options['default'] = LAN_OPTIONAL;
return $this->selectbox('link_open',$this->linkOpen,$curVal);
}
if($mode == 'filter' || $mode == 'batch') // Custom Filter List for release_type
{
return $this->linkOpen;
}
}
} }

View File

@@ -9,8 +9,8 @@
* Core SQL * Core SQL
* *
* $Source: /cvs_backup/e107_0.8/e107_admin/sql/core_sql.php,v $ * $Source: /cvs_backup/e107_0.8/e107_admin/sql/core_sql.php,v $
* $Revision: 1.41 $ * $Revision: 1.42 $
* $Date: 2009-11-20 05:01:30 $ * $Date: 2009-11-26 09:02:32 $
* $Author: e107coders $ * $Author: e107coders $
*/ */
@@ -138,7 +138,8 @@ CREATE TABLE core_media (
media_userclass varchar(255) NOT NULL default '', media_userclass varchar(255) NOT NULL default '',
media_usedby text NOT NULL, media_usedby text NOT NULL,
media_tags text NOT NULL, media_tags text NOT NULL,
PRIMARY KEY (media_id) PRIMARY KEY (media_id),
UNIQUE KEY media_url (media_url)
) TYPE=MyISAM; ) TYPE=MyISAM;
CREATE TABLE core_media_cat ( CREATE TABLE core_media_cat (

View File

@@ -2838,12 +2838,12 @@ class e_admin_controller_ui extends e_admin_controller
} }
$orderField = $request->getQuery('field', $this->getPrimaryName()); $orderField = $request->getQuery('field', $this->getPrimaryName());
if(isset($this->fields[$orderField])) if(isset($this->fields[$orderField]) && strpos($this->listQry,'ORDER BY')==FALSE) //override ORDER using listQry (admin->sitelinks)
{ {
// no need of sanitize - it's found in field array // no need of sanitize - it's found in field array
$qry .= ' ORDER BY '.$this->fields[$orderField]['__tableField'].' '.($request->getQuery('asc') == 'desc' ? 'DESC' : 'ASC'); $qry .= ' ORDER BY '.$this->fields[$orderField]['__tableField'].' '.($request->getQuery('asc') == 'desc' ? 'DESC' : 'ASC');
} }
if($this->getPerPage() || false !== $forceTo) if($this->getPerPage() || false !== $forceTo)
{ {
$from = false === $forceFrom ? intval($request->getQuery('from', 0)) : intval($forceFrom); $from = false === $forceFrom ? intval($request->getQuery('from', 0)) : intval($forceFrom);
@@ -3348,6 +3348,20 @@ class e_admin_ui extends e_admin_controller_ui
return $this->dataFields; return $this->dataFields;
} }
/**
* Set read and write parms with drop-down-list array data (ie. type='dropdown')
* @param str $field
* @param array $array [optional]
* @return
*/
public function setDropDown($field,$array) //TODO Have Miro check this.
{
$this->fields[$field]['readParms'] = $array;
$this->fields[$field]['writeParms'] = $array;
}
/** /**
* Set Config object * Set Config object
* @return e_admin_ui * @return e_admin_ui

View File

@@ -9,9 +9,9 @@
* e107 Main * e107 Main
* *
* $Source: /cvs_backup/e107_0.8/e107_handlers/e107_class.php,v $ * $Source: /cvs_backup/e107_0.8/e107_handlers/e107_class.php,v $
* $Revision: 1.84 $ * $Revision: 1.85 $
* $Date: 2009-11-24 16:41:10 $ * $Date: 2009-11-26 09:02:33 $
* $Author: secretr $ * $Author: e107coders $
*/ */
if (!defined('e107_INIT')) { exit; } if (!defined('e107_INIT')) { exit; }
@@ -1164,6 +1164,47 @@ class e107
return e107::_getTemplate($id, $key, $reg_path, $path); return e107::_getTemplate($id, $key, $reg_path, $path);
} }
/**
* Return a list of available template IDs (eg. $MYTEMPLATE['id'])
* @param str $plugin_name
* @param str $var [optional] if different from $plugin_name;
* @return array
*/
public static function getCoreTemplateList($plugin_name,$var= null)
{
$id = (!$var) ? $plugin_name : $var;
$tmp = e107::getCoreTemplate($plugin_name, $id);
$templates = array();
foreach($tmp as $key=>$val)
{
$templates[$key] = $key; //TODO add LANS?
}
return $templates;
}
/**
* Return a list of available template IDs for a plugin(eg. $MYTEMPLATE['id'])
* @param str $plugin_name
* @param str $var [optional] if different from $plugin_name;
* @return array
*/
public static function getTemplateList($plugin_name,$var= '')
{
$id = (!$var) ? $plugin_name : $var;
$tmp = e107::getTemplate($plugin_name, $id);
$templates = array();
foreach($tmp as $key=>$val)
{
$templates[$key] = $key; //TODO add LANS?
}
return $templates;
}
/** /**
* More abstsract template loader, used * More abstsract template loader, used
* internal in {@link getTemplate()} and {@link getCoreTemplate()} methods * internal in {@link getTemplate()} and {@link getCoreTemplate()} methods
@@ -1590,7 +1631,7 @@ class e107
//global $PLUGINS_DIRECTORY,$ADMIN_DIRECTORY, $eplug_admin; //global $PLUGINS_DIRECTORY,$ADMIN_DIRECTORY, $eplug_admin;
$PLUGINS_DIRECTORY = $this->getFolder('plugins'); $PLUGINS_DIRECTORY = $this->getFolder('plugins');
$ADMIN_DIRECTORY = $this->getFolder('admin'); $ADMIN_DIRECTORY = $this->getFolder('admin');
$eplug_admin = $GLOBALS['eplug_admin']; $eplug_admin = vartrue($GLOBALS['eplug_admin']);
$page = substr(strrchr($_SERVER['PHP_SELF'], '/'), 1); $page = substr(strrchr($_SERVER['PHP_SELF'], '/'), 1);

View File

@@ -9,8 +9,8 @@
* mySQL Handler * mySQL Handler
* *
* $Source: /cvs_backup/e107_0.8/e107_handlers/mysql_class.php,v $ * $Source: /cvs_backup/e107_0.8/e107_handlers/mysql_class.php,v $
* $Revision: 1.64 $ * $Revision: 1.65 $
* $Date: 2009-11-20 05:01:31 $ * $Date: 2009-11-26 09:02:34 $
* $Author: e107coders $ * $Author: e107coders $
*/ */
@@ -49,7 +49,7 @@ $db_ConnectionID = NULL; // Stores ID for the first DB connection used - which s
* *
* @package e107 * @package e107
* @category e107_handlers * @category e107_handlers
* @version $Revision: 1.64 $ * @version $Revision: 1.65 $
* @author $Author: e107coders $ * @author $Author: e107coders $
* *
*/ */
@@ -846,6 +846,9 @@ class e_db_mysql {
function db_Select_gen($query, $debug = FALSE, $log_type = '', $log_remark = '') function db_Select_gen($query, $debug = FALSE, $log_type = '', $log_remark = '')
{ {
$this->tabset = FALSE; $this->tabset = FALSE;
$query .= " "; // temp fix for failing regex below, when there is no space after the table name; $query .= " "; // temp fix for failing regex below, when there is no space after the table name;
if(strpos($query,'`#') !== FALSE) if(strpos($query,'`#') !== FALSE)
@@ -857,6 +860,7 @@ class e_db_mysql {
$query = preg_replace_callback("/\s#([\w]*?)\W/", array($this, 'ml_check'), $query); $query = preg_replace_callback("/\s#([\w]*?)\W/", array($this, 'ml_check'), $query);
} }
$query = str_replace("#",$this->mySQLPrefix,$query); //FIXME - quick fix for those that slip-thru
//FIXME - this is a quick Fix for REGEXP queries, as used in admin_ui. //FIXME - this is a quick Fix for REGEXP queries, as used in admin_ui.
$query = str_replace("`#","`".$this->mySQLPrefix,$query); $query = str_replace("`#","`".$this->mySQLPrefix,$query);

View File

@@ -1,7 +1,7 @@
<?php <?php
/* /*
* Copyright e107 Inc e107.org, Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt) * Copyright e107 Inc e107.org, Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id: lan_e107_update.php,v 1.10 2009-11-08 09:14:39 e107coders Exp $ * $Id: lan_e107_update.php,v 1.11 2009-11-26 09:02:39 e107coders Exp $
* *
* Administration Language File * Administration Language File
* *
@@ -53,7 +53,7 @@ define('LAN_UPDATE_54', 'Missing table --TABLE-- - cannot add index --INDEX--');
define('LAN_UPDATE_55', 'Description'); define('LAN_UPDATE_55', 'Description');
define('LAN_UPDATE_56', 'System Update'); define('LAN_UPDATE_56', 'System Update');
// define('LAN_UPDATE_CAPTION_PLUGIN', 'Plugin Updates'); // Unused define('LAN_UPDATE_CAPTION_PLUGIN', 'Plugin Updates'); // Unused
// define('LAN_UPDATE_CAPTION_CORE', 'Core Updates'); // Unused define('LAN_UPDATE_CAPTION_CORE', 'Core Updates'); // Unused
?> ?>

View File

@@ -0,0 +1,22 @@
<?php
/*
+ ----------------------------------------------------------------------------+
| e107 website system
|
| Copyright (c) e107 Inc. 2008-2009
| http://e107.org
|
| Released under the terms and conditions of the
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_themes/templates/sitelinks_template.php,v $
| $Revision: 1.1 $
| $Date: 2009-11-26 09:02:46 $
| $Author: e107coders $
+----------------------------------------------------------------------------+
*/
$SITELINKS_TEMPLATE['default'] = "";
?>