diff --git a/e107_admin/cpage.php b/e107_admin/cpage.php
index 56f81f560..89746a993 100644
--- a/e107_admin/cpage.php
+++ b/e107_admin/cpage.php
@@ -174,7 +174,7 @@ class page_chapters_ui extends e_admin_ui
'chapter_meta_description' => array('title'=> LAN_DESCRIPTION, 'type' => 'textarea', 'width' => 'auto', 'thclass' => 'left','readParms' => 'expand=...&truncate=150&bb=1', 'writeParms'=>'size=xxlarge', 'readonly'=>FALSE),
'chapter_meta_keywords' => array('title'=> LAN_KEYWORDS, 'type' => 'tags', 'inline'=>true, 'width' => 'auto', 'thclass' => 'left', 'readonly'=>FALSE),
- 'chapter_sef' => array('title'=> LAN_SEFURL, 'type' => 'text', 'width' => 'auto', 'readonly'=>FALSE, 'inline'=>true, 'writeParms'=>'size=xxlarge&inline-empty=1&sef=chapter_name'), // Display name
+ 'chapter_sef' => array('title'=> LAN_SEFURL, 'type' => 'text', 'width' => 'auto', 'readonly'=>FALSE, 'inline'=>true, 'writeParms'=>'size=xxlarge&inline-empty=1&sef=chapter_name', ), // Display name
'chapter_manager' => array('title'=> CUSLAN_55, 'type' => 'userclass', 'inline'=>true, 'width' => 'auto', 'data' => 'int','batch'=>TRUE, 'filter'=>TRUE),
'chapter_order' => array('title'=> LAN_ORDER, 'type' => 'text', 'width' => 'auto', 'thclass' => 'right', 'class'=> 'right' ),
'chapter_visibility' => array('title'=> LAN_VISIBILITY, 'type' => 'userclass', 'inline'=>true, 'width' => 'auto', 'data' => 'int','batch'=>TRUE, 'filter'=>TRUE),
@@ -190,19 +190,19 @@ class page_chapters_ui extends e_admin_ui
function init()
{
- // if(e_DEBUG === true)
- {
- e107::getMessage()->addWarning("Experimental: Custom Fields");
- $this->tabs = array(LAN_GENERAL,"Custom Fields");
- $this->fields['chapter_fields'] = array('title'=>"Fields", 'tab'=>1, 'type'=>'method', 'data'=>'json', 'writeParms'=>array('nolabel'=>2));
- }
+ // e107::getMessage()->addWarning("Experimental: Custom Fields");
+ $this->tabs = array(LAN_GENERAL,"Custom Fields");
+ $this->fields['chapter_fields'] = array('title'=>"Fields", 'tab'=>1, 'type'=>'method', 'data'=>'json', 'writeParms'=>array('nolabel'=>2));
-
-
- if($this->getAction() == 'list')
+ if($this->getAction() === 'list')
{
$this->fields['chapter_parent']['title'] = CUSLAN_56;
}
+ elseif(deftrue('e_DEBUG'))
+ {
+ $this->fields['chapter_sef']['title'] = LAN_SEFURL.' / '.LAN_NAME;
+ $this->fields['chapter_sef']['help'] = 'May also be used in shortcode {CHAPTER_MENUS: name=x}';
+ }
$sql = e107::getDb();
$sql->gen("SELECT chapter_id,chapter_name FROM #page_chapters WHERE chapter_parent =0");
@@ -326,11 +326,11 @@ class page_chapters_form_ui extends e_admin_form_ui
if($mode == 'filter')
{
- return;
+ return null;
}
if($mode == 'batch')
{
- return;
+ return null;
}
}
@@ -631,9 +631,9 @@ class page_admin_ui extends e_admin_ui
if($this->getMode() == 'menu' && ($this->getAction() == 'list' || $this->getAction() == 'inline'))
{
- $this->listQry = "SELECT SQL_CALC_FOUND_ROWS p.*,u.user_id,u.user_name FROM #page AS p LEFT JOIN #user AS u ON p.page_author = u.user_id WHERE p.menu_name != '' "; // without any Order or Limit.
+ $this->listQry = "SELECT SQL_CALC_FOUND_ROWS p.*,u.user_id,u.user_name FROM #page AS p LEFT JOIN #user AS u ON p.page_author = u.user_id WHERE (p.menu_name != '' OR p.menu_image != '' OR p.menu_icon !='') "; // without any Order or Limit.
- $this->listOrder = 'p.page_id desc';
+ $this->listOrder = 'p.page_order asc'; // 'p.page_id desc';
$this->batchDelete = false;
$this->fields = array(
diff --git a/e107_core/shortcodes/batch/page_shortcodes.php b/e107_core/shortcodes/batch/page_shortcodes.php
index c9d841dab..4d61f86b6 100644
--- a/e107_core/shortcodes/batch/page_shortcodes.php
+++ b/e107_core/shortcodes/batch/page_shortcodes.php
@@ -461,6 +461,15 @@ class cpage_shortcodes extends e_shortcode
return $tp->toHtml($row['chapter_name'], false, 'TITLE');
}
+ /**
+ * Alias for {CHAPTER_NAME}
+ * @example {CHAPTER_TITLE}
+ */
+ function sc_chapter_title()
+ {
+ return $this->sc_chapter_name();
+ }
+
/**
* @example {CHAPTER_ANCHOR}
diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php
index 1d94dc084..d5dd14655 100644
--- a/e107_handlers/e107_class.php
+++ b/e107_handlers/e107_class.php
@@ -1117,7 +1117,7 @@ class e107
$legacy_pref_name = ($pref_name) ? $pref_name = '/'.$pref_name : '';
$tprefs = self::getConfig()->getPref('sitetheme_pref'.$legacy_pref_name, $default, $index);
- return !empty($tprefs) ? $tprefs : array();
+ return !empty($tprefs) ? $tprefs : $default;
}
diff --git a/e107_handlers/e_customfields_class.php b/e107_handlers/e_customfields_class.php
index b6368fda9..8b07d3d94 100644
--- a/e107_handlers/e_customfields_class.php
+++ b/e107_handlers/e_customfields_class.php
@@ -47,13 +47,24 @@
*/
public function loadConfig($data)
{
+ if(empty($data))
+ {
+ return $this;
+ }
+
if(is_array($data))
{
$this->_config = $data;
return $this;
}
- $this->_config = e107::unserialize($data);
+ $tp = e107::getParser();
+
+ if($arr = $tp->isJSON($data))
+ {
+ $this->_config = $arr;
+ }
+
// e107::getDebug()->log($this->_config);
@@ -401,7 +412,7 @@
}
- $postData[$fieldname] = $new;
+ $postData[$fieldname] = empty($new) ? null : $new;
return $postData;
@@ -439,6 +450,11 @@
}
+ if(empty($new_data[$fieldname]))
+ {
+ // $new_data[$fieldname] = array();
+ }
+
return $new_data;
}
diff --git a/e107_handlers/model_class.php b/e107_handlers/model_class.php
index 781b3c711..2331be6c2 100644
--- a/e107_handlers/model_class.php
+++ b/e107_handlers/model_class.php
@@ -2660,6 +2660,10 @@ class e_front_model extends e_model
break;
case 'json':
+ if(empty($value))
+ {
+ return null;
+ }
return e107::serialize($value,'json');
break;
diff --git a/e107_plugins/page/e_shortcode.php b/e107_plugins/page/e_shortcode.php
index f8ca91dc8..68145a6b6 100644
--- a/e107_plugins/page/e_shortcode.php
+++ b/e107_plugins/page/e_shortcode.php
@@ -132,36 +132,47 @@ class page_shortcodes extends e_shortcode
/**
* Render All visible Menus from a specific chapter.
* @param null $parm
- * @example {CHAPTER_MENUS: id=chapter-sef-url}
+ * @example {CHAPTER_MENUS: name=chapter-sef-url}
* @return string
*/
function sc_chapter_menus($parm=null)
{
$tp = e107::getParser();
- $query = "SELECT * FROM #page AS p LEFT JOIN #page_chapters as ch ON p.page_chapter=ch.chapter_id WHERE ch.chapter_visibility IN (" . USERCLASS_LIST . ") AND ch.chapter_sef = '" . $tp->filter($parm['id'],'str') . "' ORDER BY p.page_order DESC ";
+ $query = "SELECT * FROM #page AS p LEFT JOIN #page_chapters as ch ON p.page_chapter=ch.chapter_id WHERE ch.chapter_visibility IN (" . USERCLASS_LIST . ") AND ch.chapter_sef = '" . $tp->filter($parm['name'],'str') . "' ORDER BY p.page_order ASC ";
$text = '';
if(!$pageArray = e107::getDb()->retrieve($query, true))
{
- e107::getDebug()->log('{CHAPTER_MENUS: id='.$parm['id'].'} failed.
Query: '.$query);
+ e107::getDebug()->log('{CHAPTER_MENUS: name='.$parm['name'].'} failed.
Query: '.$query);
return null;
}
$template = e107::getCoreTemplate('menu',null,true,true);
$sc = e107::getScBatch('page', null, 'cpage');
+ $sc->setVars($pageArray[0]);
+ $tpl = varset($pageArray[0]['menu_template'],'default'); // use start template from first row.
+
+ $start = $tp->parseTemplate($template[$tpl]['start'],true,$sc);
foreach($pageArray as $row)
{
$tpl = varset($row['menu_template'],'default');
$sc->setVars($row);
- $text .= $tp->parseTemplate($template[$tpl]['start'],true,$sc);
+
$text .= $tp->parseTemplate($template[$tpl]['body'],true,$sc);
- $text .= $tp->parseTemplate($template[$tpl]['end'],true,$sc);
+
}
- return $text;
+ $end = $tp->parseTemplate($template[$tpl]['end'],true,$sc);
+
+ if(!empty($text))
+ {
+ return $start . $text . $end;
+ }
+
+
}
}