1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-13 18:14:26 +02:00

Custom Field Fixes. Theme pref default fix. Shortcode updated: {CHAPTER_MENUS: name=chapter-sef-url}

This commit is contained in:
Cameron
2017-01-25 17:57:38 -08:00
parent 01801d6b94
commit 5c3ce83168
6 changed files with 63 additions and 23 deletions

View File

@@ -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_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_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_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_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), '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() function init()
{ {
// if(e_DEBUG === true) // e107::getMessage()->addWarning("Experimental: Custom Fields");
{ $this->tabs = array(LAN_GENERAL,"Custom Fields");
e107::getMessage()->addWarning("Experimental: Custom Fields"); $this->fields['chapter_fields'] = array('title'=>"Fields", 'tab'=>1, 'type'=>'method', 'data'=>'json', 'writeParms'=>array('nolabel'=>2));
$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; $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 = e107::getDb();
$sql->gen("SELECT chapter_id,chapter_name FROM #page_chapters WHERE chapter_parent =0"); $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') if($mode == 'filter')
{ {
return; return null;
} }
if($mode == 'batch') 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')) 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->batchDelete = false;
$this->fields = array( $this->fields = array(

View File

@@ -461,6 +461,15 @@ class cpage_shortcodes extends e_shortcode
return $tp->toHtml($row['chapter_name'], false, 'TITLE'); 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} * @example {CHAPTER_ANCHOR}

View File

@@ -1117,7 +1117,7 @@ class e107
$legacy_pref_name = ($pref_name) ? $pref_name = '/'.$pref_name : ''; $legacy_pref_name = ($pref_name) ? $pref_name = '/'.$pref_name : '';
$tprefs = self::getConfig()->getPref('sitetheme_pref'.$legacy_pref_name, $default, $index); $tprefs = self::getConfig()->getPref('sitetheme_pref'.$legacy_pref_name, $default, $index);
return !empty($tprefs) ? $tprefs : array(); return !empty($tprefs) ? $tprefs : $default;
} }

View File

@@ -47,13 +47,24 @@
*/ */
public function loadConfig($data) public function loadConfig($data)
{ {
if(empty($data))
{
return $this;
}
if(is_array($data)) if(is_array($data))
{ {
$this->_config = $data; $this->_config = $data;
return $this; return $this;
} }
$this->_config = e107::unserialize($data); $tp = e107::getParser();
if($arr = $tp->isJSON($data))
{
$this->_config = $arr;
}
// e107::getDebug()->log($this->_config); // e107::getDebug()->log($this->_config);
@@ -401,7 +412,7 @@
} }
$postData[$fieldname] = $new; $postData[$fieldname] = empty($new) ? null : $new;
return $postData; return $postData;
@@ -439,6 +450,11 @@
} }
if(empty($new_data[$fieldname]))
{
// $new_data[$fieldname] = array();
}
return $new_data; return $new_data;
} }

View File

@@ -2660,6 +2660,10 @@ class e_front_model extends e_model
break; break;
case 'json': case 'json':
if(empty($value))
{
return null;
}
return e107::serialize($value,'json'); return e107::serialize($value,'json');
break; break;

View File

@@ -132,36 +132,47 @@ class page_shortcodes extends e_shortcode
/** /**
* Render All visible Menus from a specific chapter. * Render All visible Menus from a specific chapter.
* @param null $parm * @param null $parm
* @example {CHAPTER_MENUS: id=chapter-sef-url} * @example {CHAPTER_MENUS: name=chapter-sef-url}
* @return string * @return string
*/ */
function sc_chapter_menus($parm=null) function sc_chapter_menus($parm=null)
{ {
$tp = e107::getParser(); $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 = ''; $text = '';
if(!$pageArray = e107::getDb()->retrieve($query, true)) if(!$pageArray = e107::getDb()->retrieve($query, true))
{ {
e107::getDebug()->log('{CHAPTER_MENUS: id='.$parm['id'].'} failed.<br />Query: '.$query); e107::getDebug()->log('{CHAPTER_MENUS: name='.$parm['name'].'} failed.<br />Query: '.$query);
return null; return null;
} }
$template = e107::getCoreTemplate('menu',null,true,true); $template = e107::getCoreTemplate('menu',null,true,true);
$sc = e107::getScBatch('page', null, 'cpage'); $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) foreach($pageArray as $row)
{ {
$tpl = varset($row['menu_template'],'default'); $tpl = varset($row['menu_template'],'default');
$sc->setVars($row); $sc->setVars($row);
$text .= $tp->parseTemplate($template[$tpl]['start'],true,$sc);
$text .= $tp->parseTemplate($template[$tpl]['body'],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;
}
} }
} }