本文整理匯總了PHP中e107::getLayouts方法的典型用法代碼示例。如果您正苦於以下問題:PHP e107::getLayouts方法的具體用法?PHP e107::getLayouts怎麽用?PHP e107::getLayouts使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類e107
的用法示例。
在下文中一共展示了e107::getLayouts方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: createPage
function createPage($mode = FALSE)
{
/* mode: FALSE == page, mode: TRUE == menu */
if ($_GET['mode'] == 'menu') {
$mode = TRUE;
}
global $e107, $e_userclass, $e_event;
$frm = e107::getForm();
$sql = e107::getDb();
$tp = e107::getParser();
$ns = e107::getRender();
$mes = e107::getMessage();
$id = intval($_GET['id']);
$sub_action = $_GET['action'];
$edit = $sub_action == 'edit';
$caption = !$mode ? $edit ? CUSLAN_23 : CUSLAN_24 : ($edit ? CUSLAN_25 : CUSLAN_26);
if ($_GET['action'] == "edit" && !isset($_POST['preview']) && !isset($_POST['submit'])) {
//$url = e107::getUrl()->sc('page/view', $row, 'allow=page_id,page_title,page_sef');
//$query = "SELECT p.*,l.link_name,m.menu_name FROM #page AS p
$query = "SELECT p.* FROM #page AS p\n\t\t\t\tLEFT JOIN #menus AS m ON m.menu_path='{$id}' WHERE p.page_id ='{$id}' LIMIT 1";
// FIXME - extremely bad
//LEFT JOIN #links AS l ON l.link_url='".$url."'
if ($sql->db_Select_gen($query)) {
$row = $sql->db_Fetch();
$page_class = $row['page_class'];
$page_password = $row['page_password'];
$page_title = $tp->toForm($row['page_title']);
$page_rating_flag = $row['page_rating_flag'];
$page_comment_flag = $row['page_comment_flag'];
$page_display_authordate_flag = $row['page_author'];
$page_link = varset($row['link_name'], '');
$data = $tp->toForm($row['page_text']);
$edit = TRUE;
// $menu_name = $tp->toForm($row['menu_name']);
$menu_name = $tp->toForm($row['page_theme']);
}
} else {
$menu_name = '';
$page_title = '';
$data = '';
}
$e_qry = $mode ? 'menus=1' : '';
$text = "\n\t\t\t\t<form method='post' action='" . e_SELF . "?" . $e_qry . "' id='dataform' enctype='multipart/form-data'>\n\t\t\t\t\t<fieldset id='core-cpage-create-general'>\n\t\t\t\t\t\t<legend" . ($mode ? " class='e-hideme'" : "") . ">" . CUSLAN_47 . "</legend>\n\t\t\t\t\t\t<table class='table adminform'>\n\t\t\t\t\t\t\t<colgroup>\n\t\t\t\t\t\t\t\t<col class='col-label' />\n\t\t\t\t\t\t\t\t<col class='col-control' />\n\t\t\t\t\t\t\t</colgroup>\n\t\t\t\t\t\t\t<tbody>\n\t\t\t";
if ($mode) {
$text .= "\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>" . CUSLAN_7 . "</td>\n\t\t\t\t\t\t<td>" . $frm->text('menu_name', $menu_name, 50) . "</td>\n\t\t\t\t\t</tr>\n\t\t\t\t";
} else {
$text .= "\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>Chapter</td>\n\t\t\t\t\t\t<td>" . $frm->selectbox('page_chapter', $this->cats, $row['page_chapter']) . "</td>\n\t\t\t\t\t</tr>\n\t\t\t\t";
// fixed - last parameter (allinfo) should be false as getLayout method is returning non-usable formatted array
$templates = e107::getLayouts('', 'page', 'front', '', false, false);
$templates['menu'] = "Sidebar";
// ie. a MENU item. //TODO
$text .= "\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>Template</td>\n\t\t\t\t\t\t<td>" . $frm->selectbox('page_template', $templates, $row['page_template']) . "</td>\n\t\t\t\t\t</tr>\n\t\t\t\t";
}
$text .= "\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>" . CUSLAN_8 . "</td>\n\t\t\t\t\t\t<td>" . $frm->text('page_title', $page_title, 250) . "</td>\n\t\t\t\t\t</tr>\n\t\t\t";
if (!$mode) {
$text .= "\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>" . CUSLAN_3 . "</td>\n\t\t\t\t\t\t\t<td>" . $frm->text('page_sef', $row['page_sef'], 250) . "</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t";
$text .= "\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>" . CUSLAN_32 . "</td>\n\t\t\t\t\t\t\t<td>" . $frm->text('page_metakeys', $row['page_metakeys'], 250) . "</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t";
$text .= "\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>" . CUSLAN_11 . "</td>\n\t\t\t\t\t\t\t<td>" . $frm->textarea('page_metadscr', $row['page_metadscr'], 1, 80, array(), 200) . "</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t";
}
$text .= "\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>" . CUSLAN_9 . "</td>\n\t\t\t\t\t\t\t<td>\n\t\t\t";
$text .= "<div id='tab-container' class='admintabs e-tabs'>";
$data = $tp->toForm($data, FALSE, TRUE);
// Make sure we convert HTML tags to entities
$textareaValue = strstr($data, "[img]http") ? $data : str_replace("[img]../", "[img]", $data);
// $text .= $this->bbareaMulti('data', $textareaValue, 'page','page','large');
$text .= $frm->bbarea('data', $textareaValue, 'page', 'page', 'large');
$text .= "</div>";
// $text .= $frm->bbarea('data', $textareaValue, 'page','help','large');
// $text .= "<textarea class='e-wysiwyg tbox' tabindex='".$frm->getNext()."' id='data' name='data' cols='80'{$insertjs}>".(strstr($data, "[img]http") ? $data : str_replace("[img]../", "[img]", $data))."</textarea>";
// <br />".display_help('cpage-help', 'cpage')."
/*
$text .= "</td>
</tr>
<tr>
<td>".LAN_UPLOAD_IMAGES."</td>
<td>".$tp->parseTemplate("{UPLOADFILE=".e_IMAGE."custom/}")."</td>
</tr>
";
*/
if (!$mode) {
$text .= "\n\t\t\t\t\t\t\t</tbody>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t</fieldset>\n\t\t\t\t\t<fieldset id='core-cpage-create-options'>\n\t\t\t\t\t\t<legend>" . LAN_OPTIONS . "</legend>\n\t\t\t\t\t\t<table class='adminedit options'>\n\t\t\t\t\t\t\t<colgroup>\n\t\t\t\t\t\t\t\t<col class='col-label' />\n\t\t\t\t\t\t\t\t<col class='col-control' />\n\t\t\t\t\t\t\t</colgroup>\n\t\t\t\t\t\t\t<tbody>\n\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t<td>" . CUSLAN_10 . "</td>\n\t\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t\t" . $frm->radio_switch('page_rating_flag', $page_rating_flag) . "\n\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t<td>" . CUSLAN_13 . "</td>\n\t\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t\t" . $frm->radio_switch('page_comment_flag', $page_comment_flag) . "\n\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t<td>" . CUSLAN_41 . "</td>\n\t\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t\t" . $frm->radio_switch('page_display_authordate_flag', $page_display_authordate_flag) . "\n\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t<td>" . CUSLAN_14 . "</td>\n\t\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t\t" . $frm->text('page_password', $page_password, 50) . "\n\t\t\t\t\t\t\t\t\t\t<div class='field-help'>" . CUSLAN_15 . "</div>\n\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t</tr>\n\t\n\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t<td>" . CUSLAN_18 . "</td>\n\t\n\t\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t\t" . $e_userclass->uc_dropdown('page_class', $page_class, 'public,guest,nobody,member,main,admin,classes', "tabindex='" . $frm->getNext() . "'") . "\n\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t";
/*
<tr>
<td>".CUSLAN_16."</td>
<td>
".$frm->text('page_link', $page_link, 50)."
<div class='field-help'>".CUSLAN_17."</div>
</td>
</tr>
**/
//triggerHook
$data = array('method' => 'form', 'table' => 'page', 'id' => $id, 'plugin' => 'page', 'function' => 'createPage');
$hooks = $e_event->triggerHook($data);
if (!empty($hooks)) {
$text .= "\n\t\t\t\t\t</tbody>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t</fieldset>\n\t\t\t\t\t<fieldset id='core-cpage-create-hooks'>\n\t\t\t\t\t\t<legend>" . LAN_HOOKS . "</legend>\n\t\t\t\t\t\t<table class='adminform options'>\n\t\t\t\t\t\t\t<colgroup>\n\t\t\t\t\t\t\t\t<col class='col-label' />\n\t\t\t\t\t\t\t\t<col class='col-control' />\n\t\t\t\t\t\t\t</colgroup>\n\t\t\t\t\t\t\t<tbody>";
foreach ($hooks as $hook) {
if (!empty($hook)) {
$text .= "\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td>" . $hook['caption'] . "</td>\n\t\t\t\t\t\t\t\t<td>" . $hook['text'] . "</td>\n\t\t\t\t\t\t\t</tr>";
//.........這裏部分代碼省略.........
示例2: renderElement
//.........這裏部分代碼省略.........
$label = varset($parms['label'], 'LAN_EDIT');
$ajax = varset($parms['ajax'], true) ? true : false;
unset($parms['label'], $parms['ajax']);
$ret = $this->iconpicker($key, $value, defset($label, $label), $parms, $ajax);
break;
case 'date':
// date will show the datepicker but won't convert the value to unix. ie. string value will be saved. (or may be processed manually with beforeCreate() etc. Format may be determined by $parm.
// date will show the datepicker but won't convert the value to unix. ie. string value will be saved. (or may be processed manually with beforeCreate() etc. Format may be determined by $parm.
case 'datestamp':
// If hidden, value is updated regardless. eg. a 'last updated' field.
// If not hidden, and there is a value, it is retained. eg. during the update of an existing record.
// otherwise it is added. eg. during the creation of a new record.
if (vartrue($parms['auto']) && ($value == null || vartrue($parms['hidden']))) {
$value = time();
}
if (vartrue($parms['readonly'])) {
$ret = $this->renderValue($key, $value, $attributes) . $this->hidden($key, $value);
} elseif (vartrue($parms['hidden'])) {
$ret = $this->hidden($key, $value);
} else {
$ret = $this->datepicker($key, $value, $parms);
}
break;
case 'layouts':
//to do - exclude param (exact match)
$location = varset($parms['plugin']);
// empty - core
$ilocation = vartrue($parms['id'], $location);
// omit if same as plugin name
$where = vartrue($parms['area'], 'front');
//default is 'front'
$filter = varset($parms['filter']);
$merge = vartrue($parms['merge']) ? true : false;
$layouts = e107::getLayouts($location, $ilocation, $where, $filter, $merge, true);
if (varset($parms['default']) && !isset($layouts[0]['default'])) {
$layouts[0] = array('default' => $parms['default']) + $layouts[0];
}
$info = array();
if ($layouts[1]) {
foreach ($layouts[1] as $k => $info_array) {
if (isset($info_array['description'])) {
$info[$k] = defset($info_array['description'], $info_array['description']);
}
}
}
//$this->selectbox($key, $layouts, $value)
$ret = vartrue($parms['raw']) ? $layouts[0] : $this->radio_multi($key, $layouts[0], $value, array('sep' => "<br />"), $info);
break;
case 'templates':
//to do - exclude param (exact match)
$templates = array();
if (varset($parms['default'])) {
$templates['default'] = defset($parms['default'], $parms['default']);
}
$location = vartrue($parms['plugin']) ? e_PLUGIN . $parms['plugin'] . '/' : e_THEME;
$ilocation = vartrue($parms['location']);
$tmp = e107::getFile()->get_files($location . 'templates/' . $ilocation, vartrue($parms['fmask'], '_template\\.php$'), vartrue($parms['omit'], 'standard'), vartrue($parms['recurse_level'], 0));
foreach ($tmp as $files) {
$k = str_replace('_template.php', '', $files['fname']);
$templates[$k] = implode(' ', array_map('ucfirst', explode('_', $k)));
//TODO add LANS?
}
// override
$where = vartrue($parms['area'], 'front');
$location = vartrue($parms['plugin']) ? $parms['plugin'] . '/' : '';
$tmp = e107::getFile()->get_files(e107::getThemeInfo($where, 'rel') . 'templates/' . $location . $ilocation, vartrue($parms['fmask']), vartrue($parms['omit'], 'standard'), vartrue($parms['recurse_level'], 0));
示例3: init
function init()
{
if (vartrue($_POST['menu_delete'])) {
$key = key($_POST['menu_delete']);
if ($key) {
e107::getDb()->update('page', "menu_name = '' WHERE page_id=" . intval($key) . " LIMIT 1");
}
}
// USED IN Menu LIST/INLINE-EDIT MODE ONLY.
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->listOrder = 'p.page_id desc';
$this->batchDelete = false;
$this->fields = array('checkboxes' => array('title' => '', 'type' => null, 'width' => '3%', 'forced' => TRUE, 'thclass' => 'center', 'class' => 'center'), 'page_id' => array('title' => 'ID', 'type' => 'text', 'tab' => 0, 'width' => '5%', 'readParms' => '', 'forced' => TRUE), 'menu_image' => array('title' => CUSLAN_71, 'type' => 'image', 'width' => '110px', 'thclass' => 'left', 'class' => "left", 'nosort' => false, 'readParms' => 'thumb=140&thumb_urlraw=0&thumb_aw=140', 'readonly' => false), 'menu_icon' => array('title' => LAN_ICON, 'type' => 'icon', 'width' => '80px', 'thclass' => 'center', 'class' => "center", 'nosort' => false, 'readParms' => 'thumb=80&thumb_urlraw=0&thumb_aw=80', 'readonly' => false), 'menu_title' => array('title' => CUSLAN_65, 'forced' => TRUE, 'type' => 'text', 'inline' => true, 'width' => '20%'), 'menu_name' => array('title' => CUSLAN_64, 'type' => 'text', 'inline' => true, 'width' => '10%', 'nolist' => false, "help" => "Will be listed in the Menu-Manager under this name. Must use ASCII characters only."), 'menu_template' => array('title' => CUSLAN_67, 'type' => 'dropdown', 'width' => '15%', 'filter' => true, 'batch' => true, 'inline' => true, 'writeParms' => ''), 'menu_class' => array('title' => LAN_USERCLASS, 'type' => 'userclass', 'data' => 'int', 'inline' => true, 'width' => 'auto', 'filter' => true, 'batch' => true), 'page_datestamp' => array('title' => LAN_DATE, 'type' => 'datestamp', 'data' => 'int', 'width' => 'auto', 'writeParms' => 'auto=1&readonly=1'), 'page_chapter' => array('title' => CUSLAN_63, 'tab' => 0, 'type' => 'dropdown', 'width' => '20%', 'filter' => true, 'batch' => true, 'inline' => true), 'menu_text' => array('title' => CUSLAN_66, 'type' => 'bbarea', 'data' => 'str', 'width' => 'auto', 'readParms' => 'expand=...&truncate=50&bb=1', 'writeParms' => 'media=page'), 'options' => array('title' => LAN_OPTIONS, 'type' => 'method', 'noselector' => true, 'forced' => TRUE, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center', 'readParms' => 'delete=0&deleteClass=' . e_UC_NOBODY));
$this->fieldpref = array("page_id", "menu_name", "menu_title", 'menu_image', 'menu_template', 'menu_icon', 'page_chapter', 'menu_class');
### Parse aliases again or all filters shall fail due to the menu hack!
$this->_alias_parsed = false;
$this->parseAliases();
}
$this->templates = e107::getLayouts('', 'page', 'front', '', true, false);
unset($this->templates['panel'], $this->templates['nav']);
$this->fields['page_template']['writeParms'] = $this->templates;
$this->fields['menu_template']['writeParms'] = e107::getLayouts('', 'menu', 'front', '', true, false);
$this->fields['menu_name']['writeParms'] = array('pattern' => '^[\\w-]*');
$tmp = e107::getLayouts('', 'chapter', 'front', '', true, false);
$tmpl = array();
foreach ($tmp as $key => $val) {
if (substr($key, 0, 3) != 'nav') {
$tmpl[$key] = $val;
}
}
$this->prefs['listBooksTemplate']['writeParms'] = $tmpl;
$sql = e107::getDb();
$sql->gen("SELECT chapter_id,chapter_name,chapter_parent FROM #page_chapters ORDER BY chapter_parent asc, chapter_order");
while ($row = $sql->fetch()) {
$cat = $row['chapter_id'];
if ($row['chapter_parent'] == 0) {
$this->books[$cat] = $row['chapter_name'];
} else {
$book = $row['chapter_parent'];
$this->cats[$cat] = $this->books[$book] . " : " . $row['chapter_name'];
}
}
// asort($this->cats);
$this->fields['page_chapter']['writeParms']['optArray'] = $this->cats;
$this->fields['page_chapter']['writeParms']['size'] = 'xxlarge';
}
示例4: _handleUnique
/**
* Provide user friendly message on mysql duplicate entry error #1062
* No need of beforeCreate callback and additional SQL query - mysql error number give us
* enough info
* @return boolean true - suppress model errors
*/
protected function _handleUnique($new_data, $mod)
{
if ($this->getModel()->getSqlErrorNumber() == 1062) {
$templates = e107::getLayouts('featurebox', 'featurebox_category', 'front', '', true, false);
$msg = e107::getMessage();
$msg->error('Layout <strong>' . vartrue($templates[$new_data['fb_category_template']], 'n/a') . '</strong> is in use by another category. Layout should be unique per category. ');
$msg->error($mod == 'create' ? LAN_CREATED_FAILED : LAN_UPDATED_FAILED);
return !E107_DEBUG_LEVEL;
// suppress messages (TRUE) only when not in debug mod
}
return false;
}
示例5: renderElement
//.........這裏部分代碼省略.........
break;
case 'icon':
$label = varset($parms['label'], 'LAN_EDIT');
$ajax = varset($parms['ajax'], true) ? true : false;
unset($parms['label'], $parms['ajax']);
$ret = $this->iconpicker($key, $value, defset($label, $label), $parms, $ajax);
break;
case 'date':
// date will show the datepicker but won't convert the value to unix. ie. string value will be saved. (or may be processed manually with beforeCreate() etc. Format may be determined by $parm.
// date will show the datepicker but won't convert the value to unix. ie. string value will be saved. (or may be processed manually with beforeCreate() etc. Format may be determined by $parm.
case 'datestamp':
// If hidden, value is updated regardless. eg. a 'last updated' field.
// If not hidden, and there is a value, it is retained. eg. during the update of an existing record.
// otherwise it is added. eg. during the creation of a new record.
if (vartrue($parms['auto']) && ($value == null || vartrue($parms['hidden']))) {
$value = time();
}
if (vartrue($parms['hidden'])) {
$ret = $this->hidden($key, $value);
} else {
$ret = $this->datepicker($key, $value, $parms);
}
break;
case 'layouts':
//to do - exclude param (exact match)
$location = varset($parms['plugin']);
// empty - core
$ilocation = vartrue($parms['id'], $location);
// omit if same as plugin name
$where = vartrue($parms['area'], 'front');
//default is 'front'
$filter = varset($parms['filter']);
$merge = vartrue($parms['merge']) ? true : false;
$layouts = e107::getLayouts($location, $ilocation, $where, $filter, $merge, true);
if (varset($parms['default']) && !isset($layouts[0]['default'])) {
$layouts[0] = array('default' => $parms['default']) + $layouts[0];
}
$info = array();
if ($layouts[1]) {
foreach ($layouts[1] as $k => $info_array) {
if (isset($info_array['description'])) {
$info[$k] = defset($info_array['description'], $info_array['description']);
}
}
}
//$this->selectbox($key, $layouts, $value)
$ret = vartrue($parms['raw']) ? $layouts[0] : $this->radio_multi($key, $layouts[0], $value, true, $info);
break;
case 'templates':
//to do - exclude param (exact match)
$templates = array();
if (varset($parms['default'])) {
$templates['default'] = defset($parms['default'], $parms['default']);
}
$location = vartrue($parms['plugin']) ? e_PLUGIN . $parms['plugin'] . '/' : e_THEME;
$ilocation = vartrue($parms['location']);
$tmp = e107::getFile()->get_files($location . 'templates/' . $ilocation, vartrue($parms['fmask'], '_template\\.php$'), vartrue($parms['omit'], 'standard'), vartrue($parms['recurse_level'], 0));
foreach ($tmp as $files) {
$k = str_replace('_template.php', '', $files['fname']);
$templates[$k] = implode(' ', array_map('ucfirst', explode('_', $k)));
//TODO add LANS?
}
// override
$where = vartrue($parms['area'], 'front');
$location = vartrue($parms['plugin']) ? $parms['plugin'] . '/' : '';
$tmp = e107::getFile()->get_files(e107::getThemeInfo($where, 'rel') . 'templates/' . $location . $ilocation, vartrue($parms['fmask']), vartrue($parms['omit'], 'standard'), vartrue($parms['recurse_level'], 0));