mirror of
https://github.com/e107inc/e107.git
synced 2025-03-14 17:39:46 +01:00
Page/Menu Custom Fields.
This commit is contained in:
parent
f545a2e01d
commit
acbf93ef8a
@ -134,7 +134,7 @@ class page_admin_form_ui extends e_admin_form_ui
|
||||
$text = "<a href='".e_SELF."?{$query}' class='btn btn-default' title='".LAN_EDIT."' data-toggle='tooltip' data-placement='left'>
|
||||
".ADMIN_EDIT_ICON."</a>";
|
||||
|
||||
$text .= $this->submit_image('menu_delete['.$id.']', $id, 'delete', LAN_DELETE.' [ ID: '.$id.' ]', array('class' => 'action delete btn btn-default'.$delcls));
|
||||
$text .= $this->submit_image('menu_delete['.$id.']', $id, 'delete', LAN_DELETE.' [ ID: '.$id.' ]', array('class' => 'action delete btn btn-default'));
|
||||
|
||||
return $text;
|
||||
}
|
||||
@ -190,7 +190,7 @@ class page_chapters_ui extends e_admin_ui
|
||||
function init()
|
||||
{
|
||||
|
||||
if(e_DEBUG === true)
|
||||
// if(e_DEBUG === true)
|
||||
{
|
||||
e107::getMessage()->addWarning("Experimental: Custom Fields");
|
||||
$this->tabs = array(LAN_GENERAL,"Custom Fields");
|
||||
@ -369,17 +369,17 @@ class page_chapters_form_ui extends e_admin_form_ui
|
||||
<col style='width:40%' />
|
||||
</colgroup>
|
||||
<tbody>
|
||||
<tr><th>".LAN_NAME."</th><th>".LAN_TITLE."</th><th>".LAN_TYPE."</th><th>Params</th></tr>
|
||||
<tr><th>".LAN_NAME."</th><th>".LAN_TITLE."</th><th>".LAN_TYPE."</th><th>Params</th><th>".LAN_TOOLTIP."</th></tr>
|
||||
";
|
||||
|
||||
for ($i = 0; $i <= 10; $i++)
|
||||
for ($i = 0; $i <= 20; $i++)
|
||||
{
|
||||
$fieldName = $this->text('chapter_fields['.$i.'][key]',$value[$i]['key'],30, array('pattern'=>'^[a-z0-9-]*'));
|
||||
$fieldTitle = $this->text('chapter_fields['.$i.'][title]',$value[$i]['title'], 80);
|
||||
$fieldType = $this->select('chapter_fields['.$i.'][type]',$this->getFieldTypes(),$value[$i]['type'], 'useValues=1&default=blank');
|
||||
$fieldParms = $this->text('chapter_fields['.$i.'][writeParms]',$value[$i]['writeParams'], 80, array('size'=>'xxlarge'));
|
||||
|
||||
$text .= "<tr><td>".$fieldName."</td><td>".$fieldTitle."</td><td>".$fieldType."</td><td>".$fieldParms."</td></tr>";
|
||||
$fieldParms = $this->text('chapter_fields['.$i.'][writeParms]',$value[$i]['writeParms'], 80, array('size'=>'block-level'));
|
||||
$fieldHelp = $this->text('chapter_fields['.$i.'][help]',$value[$i]['help'], 80, array('size'=>'block-level'));
|
||||
$text .= "<tr><td>".$fieldName."</td><td>".$fieldTitle."</td><td>".$fieldType."</td><td>".$fieldParms."</td><td>".$fieldHelp."</td></tr>";
|
||||
}
|
||||
|
||||
$text .= "</tbody></table>";
|
||||
@ -702,7 +702,7 @@ class page_admin_ui extends e_admin_ui
|
||||
$this->fieldpref = array("page_id","menu_name", "menu_title", 'menu_image', 'menu_template', 'menu_icon', 'page_chapter', 'menu_class');
|
||||
|
||||
|
||||
if(e_DEBUG)
|
||||
if(deftrue('e_DEBUG'))
|
||||
{
|
||||
$this->fields['menu_name']['inline'] = true;
|
||||
}
|
||||
@ -753,7 +753,6 @@ class page_admin_ui extends e_admin_ui
|
||||
|
||||
$sql = e107::getDb();
|
||||
|
||||
$chapterFields = array();
|
||||
$sql->gen("SELECT chapter_id,chapter_name,chapter_parent, chapter_fields FROM #page_chapters ORDER BY chapter_parent asc, chapter_order");
|
||||
while($row = $sql->fetch())
|
||||
{
|
||||
@ -781,10 +780,9 @@ class page_admin_ui extends e_admin_ui
|
||||
$this->fields['page_chapter']['writeParms']['optArray'] = $this->cats;
|
||||
$this->fields['page_chapter']['writeParms']['size'] = 'xxlarge';
|
||||
|
||||
if(e_DEBUG !== false && $this->getAction() === 'create')
|
||||
if($this->getAction() === 'create')
|
||||
{
|
||||
$this->fields['page_chapter']['writeParms']['ajax'] = array('src'=>e_SELF."?mode=page&action=chapter-change",'target'=>'tabadditional');
|
||||
|
||||
}
|
||||
|
||||
if(e_AJAX_REQUEST && isset($_POST['page_chapter']) ) //&& $this->getAction() === 'chapter-change'
|
||||
@ -883,7 +881,7 @@ class page_admin_ui extends e_admin_ui
|
||||
|
||||
if(!deftrue('e_DEBUG'))
|
||||
{
|
||||
return;
|
||||
// return;
|
||||
}
|
||||
|
||||
|
||||
|
@ -606,6 +606,26 @@ class cpage_shortcodes extends e_shortcode
|
||||
}
|
||||
|
||||
|
||||
function sc_cpagefieldtitle($parm=null)
|
||||
{
|
||||
if(empty($parm['name']) || empty($this->var['page_fields']))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$chap = $this->var['page_chapter'];
|
||||
$key = $parm['name'];
|
||||
|
||||
|
||||
if(!empty($this->chapterData[$chap]['chapter_fields'][$key]['title']))
|
||||
{
|
||||
return $this->chapterData[$chap]['chapter_fields'][$key]['title'];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return raw HTML-usable values from page fields.
|
||||
* @experimental subject to change without notice.
|
||||
@ -625,23 +645,65 @@ class cpage_shortcodes extends e_shortcode
|
||||
$key = $parm['name'];
|
||||
$fields = $this->chapterData[$chap]['chapter_fields'];
|
||||
$fieldData = e107::unserialize($this->var['page_fields']);
|
||||
$type = $fields[$key]['type'];;
|
||||
|
||||
// @todo Move this part to form_handler somewhere.
|
||||
|
||||
$raw = (!empty($parm['mode']) && $parm['mode'] === 'raw') ? true : false;
|
||||
$type = (!empty($parm['type'])) ? $parm['type'] : null;
|
||||
|
||||
$fieldType = $fields[$key]['type'];
|
||||
|
||||
// @todo Move this part to form_handler or e_parse somewhere.
|
||||
|
||||
if(isset($fieldData[$key]))
|
||||
{
|
||||
$value = $fieldData[$key];
|
||||
|
||||
switch($type)
|
||||
switch($fieldType)
|
||||
{
|
||||
case "image":
|
||||
return $tp->toImage($value);
|
||||
return ($raw) ? $tp->thumbUrl($value) : $tp->toImage($value);
|
||||
break;
|
||||
|
||||
case "icon":
|
||||
return $tp->toIcon($value);
|
||||
return ($raw) ? str_replace(".glyph", '', $value) : $tp->toIcon($value);
|
||||
break;
|
||||
|
||||
case "country":
|
||||
return ($raw) ? $value : e107::getForm()->getCountry($value);
|
||||
break;
|
||||
|
||||
case "tags":
|
||||
return ($raw) ? $value : $tp->toLabel($value,$type);
|
||||
break;
|
||||
|
||||
case "lanlist":
|
||||
case "language":
|
||||
return ($raw) ? $value : e107::getLanguage()->convert($value);
|
||||
break;
|
||||
|
||||
case "datestamp":
|
||||
return ($raw) ? $value : $tp->toDate($value);
|
||||
break;
|
||||
|
||||
case "url":
|
||||
case "email":
|
||||
return ($raw) ? $value : $tp->toHtml($value);
|
||||
break;
|
||||
|
||||
case "user":
|
||||
return ($raw) ? $value : e107::getSystemUser($value,true)->getName();
|
||||
break;
|
||||
|
||||
case "userclass":
|
||||
return ($raw) ? $value : e107::getUserClass()->getName($value);
|
||||
break;
|
||||
|
||||
case "textarea":
|
||||
case "bbarea":
|
||||
return $tp->toHtml($value, true);
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
return $tp->toHtml($value);
|
||||
}
|
||||
@ -653,7 +715,29 @@ class cpage_shortcodes extends e_shortcode
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @experimental - subject to change without notice. Use at own risk.
|
||||
* @param null $parm
|
||||
* @return string
|
||||
*/
|
||||
function sc_cpagefields($parm=null)
|
||||
{
|
||||
$fieldData = e107::unserialize($this->var['page_fields']);
|
||||
|
||||
$text = '<table class="table table-bordered table-striped">
|
||||
<tr><th>Name</th><th>Title<br /><small>{CPAGEFIELDTITLE: name=x}</small></th><th>Normal<br /><small>{CPAGEFIELD: name=x}</small></th><th>Raw<br /><small>{CPAGEFIELD: name=x&mode=raw}</small></th></tr>';
|
||||
|
||||
foreach($fieldData as $ok=>$v)
|
||||
{
|
||||
|
||||
$text .= "<tr><td>".$ok."</td><td>".$this->sc_cpagefieldtitle(array('name'=>$ok))."</td><td>".$this->sc_cpagefield(array('name'=>$ok))."</td><td>".$this->sc_cpagefield(array('name'=>$ok, 'mode'=>'raw'))."</td></tr>";
|
||||
}
|
||||
|
||||
$text .= "</table>";
|
||||
|
||||
return $text;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -3641,6 +3641,38 @@ class e_parser
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $text
|
||||
* @return string
|
||||
*/
|
||||
public function toLabel($text, $type = null)
|
||||
{
|
||||
if($type === null)
|
||||
{
|
||||
$type = 'default';
|
||||
}
|
||||
|
||||
$tmp = explode(",",$text);
|
||||
|
||||
$opt = array();
|
||||
foreach($tmp as $v)
|
||||
{
|
||||
$opt[] = "<span class='label label-".$type."'>".$v."</span>";
|
||||
}
|
||||
|
||||
return implode(" ",$opt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Take a file-path and convert it to a download link.
|
||||
* @todo
|
||||
* @param $text
|
||||
* @return string
|
||||
*/
|
||||
public function toFile($text)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an avatar based on supplied user data or current user when missing.
|
||||
|
@ -4025,6 +4025,10 @@ class e_form
|
||||
// else same
|
||||
break;
|
||||
|
||||
case 'country':
|
||||
$value = $this->getCountry($value);
|
||||
break;
|
||||
|
||||
case 'ip':
|
||||
//$e107 = e107::getInstance();
|
||||
$value = "<span title='".$value."'>".e107::getIPHandler()->ipDecode($value).'</span>';;
|
||||
@ -4950,6 +4954,10 @@ class e_form
|
||||
$ret = vartrue($parms['pre']).$this->number($key, $value, $maxlength, $parms).vartrue($parms['post']);
|
||||
break;
|
||||
|
||||
case 'country':
|
||||
$ret = vartrue($parms['pre']).$this->country($key, $value).vartrue($parms['post']);
|
||||
break;
|
||||
|
||||
case 'ip':
|
||||
$ret = vartrue($parms['pre']).$this->text($key, e107::getIPHandler()->ipDecode($value), 32, $parms).vartrue($parms['post']);
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user