diff --git a/e107_admin/cpage.php b/e107_admin/cpage.php
index fa08fae7b..c53909fe1 100644
--- a/e107_admin/cpage.php
+++ b/e107_admin/cpage.php
@@ -9,8 +9,8 @@
* Custom Menus/Pages Administration
*
* $Source: /cvs_backup/e107_0.8/e107_admin/cpage.php,v $
- * $Revision: 1.29 $
- * $Date: 2009-11-25 11:54:53 $
+ * $Revision: 1.30 $
+ * $Date: 2009-11-26 09:02:29 $
* $Author: e107coders $
*
*/
@@ -307,13 +307,8 @@ class page
}
else
{
- $templates = array();
- $tmp = e107::getTemplate('page', 'page');
- foreach($tmp as $key=>$val)
- {
- $templates[$key] = $key; //TODO add LANS?
- }
-
+ $templates = e107::getTemplateList('page');
+
$text .= "
Template |
diff --git a/e107_admin/links.php b/e107_admin/links.php
index 98c55c1c6..f53e52968 100644
--- a/e107_admin/links.php
+++ b/e107_admin/links.php
@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_admin/links.php,v $
-| $Revision: 1.35 $
-| $Date: 2009-11-23 11:51:00 $
+| $Revision: 1.36 $
+| $Date: 2009-11-26 09:02:32 $
| $Author: e107coders $
+----------------------------------------------------------------------------+
*/
@@ -38,7 +38,6 @@ class links_admin extends e_admin_dispatcher
)
);
-
protected $adminMenu = array(
'main/list' => array('caption'=> LCLAN_62, '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
-{
-
- protected $pluginTitle = "Site links";
- protected $pluginName = 'core';
- protected $table = "links";
-
- /**
- * If present this array will be used to build your list query
- * 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 $pluginTitle = "Site links";
+ protected $pluginName = 'core';
+ 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;
+ protected $batchDelete = true;
protected $fields = array(
'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_id' => array('title'=> ID, 'width'=>'5%', 'forced'=> TRUE, 'primary'=>TRUE),
- 'link_name' => array('title'=> LCLAN_15, 'width'=>'auto','type'=>'text'),
- 'link_parent' => array('title'=> 'Sublink of', 'type' => 'method', 'width' => 'auto', 'batch'=>true, 'filter'=>true, 'thclass' => 'left first'),
- 'link_url' => array('title'=> LCLAN_93, 'width'=>'auto','type'=>'text'),
+ 'link_id' => array('title'=> ID, 'nolist'=>TRUE),
+ 'link_name' => array('title'=> LCLAN_15, 'width'=>'auto','type'=>'method'),
+ '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_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_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_open' => array('title'=> LCLAN_19, 'type' => 'method', 'width' => 'auto', 'batch'=>true, 'filter'=>true, 'thclass' => 'left first'),
- 'link_function' => array('title'=> 'Function', 'type' => 'method', 'data'=>'str', 'width' => 'auto', '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'),
// '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')
);
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(
'linkpage_screentip' => array('title'=>LCLAN_78, 'type'=>'boolean', 'help'=>LCLAN_79),
'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()
{
global $e107, $sql, $emessage;
@@ -213,16 +288,14 @@ class links_admin_ui extends e_admin_ui
return $sublink_type;
}
-
-
- function init()
- {
- $sql = e107::getDb();
- $mes = e107::getMessage();
+
+
+
+
- if(isset($_POST['generate_sublinks']) && isset($_POST['sublink_type']) && $_POST['sublink_parent'] != "")
- {
- $subtype = $_POST['sublink_type'];
+ function generateSublinks()
+ {
+ $subtype = $_POST['sublink_type'];
$sublink = $this->sublink_list($subtype);
$sql2 = e107::getDb('sql2');
@@ -273,85 +346,31 @@ class links_admin_ui extends e_admin_ui
{
// sitelinks_adminlog('01', $message); // 'Sublinks generated'
}
- }
- }
-
-
+ }
}
-//TODO Block and Unblock buttons, moderated links?
+
class links_admin_form_ui extends e_admin_form_ui
{
- public $linkFunctions = array();
- public $linkCategory = array();
- public $linkOpen = array();
- public $linkParent = array();
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)
- {
- if($mode == 'read')
+
+
+ function link_name($curVal,$mode,$parm)
+ {
+ //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 "
".$curVal;
}
-
- if($mode == 'write')
- {
- return $this->selectbox('link_parent',$this->linkParent,$curVal);
- }
-
else
{
- unset($this->linkParent[0]);
- return $this->linkParent;
+ return $curVal;
}
+
}
@@ -373,47 +392,6 @@ class links_admin_form_ui extends e_admin_form_ui
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;
- }
- }
-
}
diff --git a/e107_admin/sql/core_sql.php b/e107_admin/sql/core_sql.php
index 806a7ab28..9bdc1e8a3 100644
--- a/e107_admin/sql/core_sql.php
+++ b/e107_admin/sql/core_sql.php
@@ -9,8 +9,8 @@
* Core SQL
*
* $Source: /cvs_backup/e107_0.8/e107_admin/sql/core_sql.php,v $
- * $Revision: 1.41 $
- * $Date: 2009-11-20 05:01:30 $
+ * $Revision: 1.42 $
+ * $Date: 2009-11-26 09:02:32 $
* $Author: e107coders $
*/
@@ -138,7 +138,8 @@ CREATE TABLE core_media (
media_userclass varchar(255) NOT NULL default '',
media_usedby text NOT NULL,
media_tags text NOT NULL,
- PRIMARY KEY (media_id)
+ PRIMARY KEY (media_id),
+ UNIQUE KEY media_url (media_url)
) TYPE=MyISAM;
CREATE TABLE core_media_cat (
diff --git a/e107_handlers/admin_ui.php b/e107_handlers/admin_ui.php
index 33d6a591e..1cca8d577 100644
--- a/e107_handlers/admin_ui.php
+++ b/e107_handlers/admin_ui.php
@@ -2838,12 +2838,12 @@ class e_admin_controller_ui extends e_admin_controller
}
$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
$qry .= ' ORDER BY '.$this->fields[$orderField]['__tableField'].' '.($request->getQuery('asc') == 'desc' ? 'DESC' : 'ASC');
}
-
+
if($this->getPerPage() || false !== $forceTo)
{
$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;
}
+
+ /**
+ * 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
* @return e_admin_ui
diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php
index 620509643..3eada2754 100644
--- a/e107_handlers/e107_class.php
+++ b/e107_handlers/e107_class.php
@@ -9,9 +9,9 @@
* e107 Main
*
* $Source: /cvs_backup/e107_0.8/e107_handlers/e107_class.php,v $
- * $Revision: 1.84 $
- * $Date: 2009-11-24 16:41:10 $
- * $Author: secretr $
+ * $Revision: 1.85 $
+ * $Date: 2009-11-26 09:02:33 $
+ * $Author: e107coders $
*/
if (!defined('e107_INIT')) { exit; }
@@ -1164,6 +1164,47 @@ class e107
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
* internal in {@link getTemplate()} and {@link getCoreTemplate()} methods
@@ -1590,7 +1631,7 @@ class e107
//global $PLUGINS_DIRECTORY,$ADMIN_DIRECTORY, $eplug_admin;
$PLUGINS_DIRECTORY = $this->getFolder('plugins');
$ADMIN_DIRECTORY = $this->getFolder('admin');
- $eplug_admin = $GLOBALS['eplug_admin'];
+ $eplug_admin = vartrue($GLOBALS['eplug_admin']);
$page = substr(strrchr($_SERVER['PHP_SELF'], '/'), 1);
diff --git a/e107_handlers/mysql_class.php b/e107_handlers/mysql_class.php
index deeb0bdc0..dfeffede0 100644
--- a/e107_handlers/mysql_class.php
+++ b/e107_handlers/mysql_class.php
@@ -9,8 +9,8 @@
* mySQL Handler
*
* $Source: /cvs_backup/e107_0.8/e107_handlers/mysql_class.php,v $
- * $Revision: 1.64 $
- * $Date: 2009-11-20 05:01:31 $
+ * $Revision: 1.65 $
+ * $Date: 2009-11-26 09:02:34 $
* $Author: e107coders $
*/
@@ -49,7 +49,7 @@ $db_ConnectionID = NULL; // Stores ID for the first DB connection used - which s
*
* @package e107
* @category e107_handlers
- * @version $Revision: 1.64 $
+ * @version $Revision: 1.65 $
* @author $Author: e107coders $
*
*/
@@ -846,6 +846,9 @@ class e_db_mysql {
function db_Select_gen($query, $debug = FALSE, $log_type = '', $log_remark = '')
{
$this->tabset = FALSE;
+
+
+
$query .= " "; // temp fix for failing regex below, when there is no space after the table name;
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 = 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.
$query = str_replace("`#","`".$this->mySQLPrefix,$query);
diff --git a/e107_languages/English/admin/lan_e107_update.php b/e107_languages/English/admin/lan_e107_update.php
index 8d165cae3..dff78f1bb 100644
--- a/e107_languages/English/admin/lan_e107_update.php
+++ b/e107_languages/English/admin/lan_e107_update.php
@@ -1,7 +1,7 @@
\ No newline at end of file
diff --git a/e107_themes/templates/sitelinks_template.php b/e107_themes/templates/sitelinks_template.php
new file mode 100644
index 000000000..b49d79660
--- /dev/null
+++ b/e107_themes/templates/sitelinks_template.php
@@ -0,0 +1,22 @@
+
\ No newline at end of file