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

Reworked storage of custom menus.

This commit is contained in:
Cameron
2013-03-06 23:01:16 -08:00
parent 3d26475d97
commit 8895d48dd1
11 changed files with 321 additions and 111 deletions

View File

@@ -41,9 +41,9 @@ class page_admin extends e_admin_dispatcher
'uipath' => null
),
'menu' => array(
'controller' => 'menu_admin_ui',
'controller' => 'page_admin_ui',
'path' => null,
'ui' => 'menu_admin_form_ui',
'ui' => 'page_admin_form_ui',
'uipath' => null
),
'dialog' => array(
@@ -61,15 +61,15 @@ class page_admin extends e_admin_dispatcher
'cat/list' => array('caption'=> "List Books/Chapters", 'perm' => '5'), // Create Category.
'cat/create' => array('caption'=> "Add Book/Chapter", 'perm' => '5'), // Category List
'menu/list' => array('caption'=> CUSLAN_49, 'perm' => 'J'),
'menu/create' => array('caption'=> CUSLAN_31, 'perm' => 'J'),
'menu/list' => array('caption'=> CUSLAN_49, 'perm' => 'J', 'tab' => 2),
'menu/create' => array('caption'=> CUSLAN_31, 'perm' => 'J', 'tab' => 2),
'page/prefs' => array('caption'=> LAN_OPTIONS, 'perm' => '0')
);
protected $adminMenuAliases = array(
'page/edit' => 'page/list',
'menu/edit' => 'menu/list'
'menu/edit' => 'menu/create'
);
protected $menuTitle = 'Custom Pages';
@@ -173,6 +173,7 @@ class page_chapters_form_ui extends e_admin_form_ui
// Menu Area.
/*
class menu_admin_ui extends e_admin_ui
{
protected $pluginTitle = ADLAN_42;
@@ -195,13 +196,13 @@ class menu_admin_ui extends e_admin_ui
'page_id' => array('title'=> 'ID', 'type'=>'text', 'tab' => 0, 'width'=>'5%', 'readParms'=>'','forced'=> TRUE),
'page_theme' => array('title'=> "Menu Name", 'tab' => 0, 'type' => 'text', 'width' => 'auto','nolist'=>true),
'page_title' => array('title'=> LAN_TITLE, 'tab' => 0, 'type' => 'text', 'width'=>'25%', 'inline'=>true,/*'readParms'=>'link={e_BASE}page.php?[id]&dialog=1'*/),
'page_title' => array('title'=> LAN_TITLE, 'tab' => 0, 'type' => 'text', 'width'=>'25%', 'inline'=>true),
// 'page_template' => array('title'=> 'Template', 'tab' => 0, 'type' => 'dropdown', 'width' => 'auto','filter' => true, 'batch'=>true, 'inline'=>true, 'writeParms'=>''),
// 'page_author' => array('title'=> LAN_AUTHOR, 'tab' => 0, 'type' => 'user', 'data'=>'int','width' => 'auto', 'thclass' => 'left'),
'page_text' => array('title'=> CUSLAN_9, 'type' => 'bbarea', 'data'=>'str', 'width' => '30%', 'readParms' => 'expand=...&truncate=50&bb=1'),
'page_datestamp' => array('title'=> LAN_DATE, 'type' => 'datestamp', 'data'=>'int', 'width' => 'auto','writeParms'=>'auto=1&readonly=1'),
'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'forced'=>TRUE, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center'/*,'readParms'=>'sort=1'*/)
'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'forced'=>TRUE, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center'
);
protected $fieldpref = array("page_id","page_theme", "page_title", "page_text");
@@ -243,47 +244,7 @@ class menu_admin_ui extends e_admin_ui
}
// Create Menu in Menu Table
function afterCreate($newdata,$olddata, $id)
{
$tp = e107::getParser();
$sql = e107::getDb();
$mes = e107::getMessage();
$menu_name = $tp->toDB($newdata['page_theme']); // not to be confused with menu-caption.
$menu_path = intval($id);
if (!$sql->select('menus', 'menu_name', "`menu_path` = ".$menu_path." LIMIT 1"))
{
$insert = array('menu_name' => $menu_name, 'menu_path' => $menu_path);
if($sql->insert('menus', $insert) !== false)
{
$mes->addDebug("Menu Created");
return true;
}
}
}
// Update Menu in Menu Table
function afterUpdate($newdata,$olddata,$id)
{
$tp = e107::getParser();
$sql = e107::getDb();
$mes = e107::getMessage();
$menu_name = $tp->toDB($newdata['page_theme']); // not to be confused with menu-caption.
if ($sql->select('menus', 'menu_name', "`menu_path` = ".$id." LIMIT 1"))
{
if($sql->update('menus', "menu_name='{$menu_name}' WHERE menu_path=".$id." LIMIT 1") !== false)
{
$mes->addDebug("Menu Updated");
return true;
}
}
}
function previewPage() //XXX FIXME Doesn't work when in Ajax mode.. why???
@@ -318,7 +279,7 @@ class menu_form_ui extends e_admin_form_ui
{
}
*/
@@ -343,21 +304,22 @@ class page_admin_ui extends e_admin_ui
protected $orderStep = 10;
//protected $url = array('profile'=>'page/view', 'name' => 'page_title', 'description' => '', 'link'=>'{e_BASE}page.php?id=[id]'); // 'link' only needed if profile not provided.
protected $url = array('route'=>'page/view/index', 'vars' => array('id' => 'page_id', 'sef' => 'page_sef'), 'name' => 'page_title', 'description' => ''); // 'link' only needed if profile not provided.
protected $tabs = array("Main","Advanced");
protected $tabs = array("Page","Page Options","Menu");
// protected $listSorting = true;
// PAGE LIST/EDIT and MENU EDIT modes.
protected $fields = array(
'checkboxes' => array('title'=> '', 'type' => null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center'),
'page_id' => array('title'=> LAN_ID, 'type' => 'text', 'tab' => 0, 'width'=>'5%', 'forced'=> TRUE, 'readParms'=>'link=sef&target=dialog'),
'page_chapter' => array('title'=> 'Book/Chapter', 'tab' => 0, 'type' => 'dropdown', 'width' => '20%', 'filter' => true, 'batch'=>true, 'inline'=>true),
'page_title' => array('title'=> LAN_TITLE, 'tab' => 0, 'type' => 'text', 'inline'=>true, 'width'=>'25%'),
'page_theme' => array('title'=> LAN_TYPE, 'tab' => 0, 'type' => 'text', 'width' => 'auto','nolist'=>true, 'noedit'=>true),
'page_template' => array('title'=> LAN_TEMPLATE, 'tab' => 0, 'type' => 'dropdown', 'width' => 'auto','filter' => true, 'batch'=>true, 'inline'=>true, 'writeParms'=>''),
'page_author' => array('title'=> LAN_AUTHOR, 'tab' => 0, 'type' => 'user', 'data'=>'int','width' => 'auto', 'thclass' => 'left'),
'page_text' => array('title'=> CUSLAN_9, 'tab' => 0, 'type' => 'bbarea', 'data'=>'str', 'width' => '30%', 'readParms' => 'expand=...&truncate=50&bb=1', 'writeParms'=>'media=page'),
// Options Tab.
'page_datestamp' => array('title'=> LAN_DATE, 'tab' => 1, 'type' => 'datestamp', 'data'=>'int', 'width' => 'auto','writeParms'=>'auto=1'),
'page_class' => array('title'=> LAN_USERCLASS, 'tab' => 1, 'type' => 'userclass', 'data'=>'int', 'inline'=>true, 'width' => 'auto', 'filter' => true, 'batch' => true),
'page_rating_flag' => array('title'=> LAN_RATING, 'tab' => 1, 'type' => 'boolean', 'data'=>'int', 'width' => '5%', 'thclass' => 'center', 'class' => 'center' ),
@@ -368,9 +330,19 @@ class page_admin_ui extends e_admin_ui
'page_metadscr' => array('title'=> CUSLAN_11, 'tab' => 1, 'type' => 'text', 'width' => 'auto'),
'page_order' => array('title'=> LAN_ORDER, 'tab' => 1, 'type' => 'number', 'width' => 'auto', 'inline'=>true),
// Menu Tab XXX 'page_theme' is 'menu_name' - not caption.
'page_theme' => array('title'=> "Menu Name", 'tab' => 2, 'type' => 'text', 'width' => 'auto','nolist'=>true, "help"=>"Will be listed in the Menu-Manager under this name"),
'menu_title' => array('title'=> "Menu Title", 'nolist'=>true, 'tab' => 2, 'type' => 'text', 'inline'=>true, 'width'=>'25%', "help"=>"Caption displayed on the menu item."),
'menu_text' => array('title'=> "Menu Body", 'nolist'=>true, 'tab' => 2, 'type' => 'bbarea', 'data'=>'str', 'width' => '30%', 'readParms' => 'expand=...&truncate=50&bb=1', 'writeParms'=>'media=page' ),
'menu_image' => array('title' =>"Menu Image", 'nolist'=>true, 'tab' => 2, 'type' => 'image', 'width' => '110px', 'thclass' => 'center', 'class' => "center", 'nosort' => false, 'readParms'=>'thumb=60&thumb_urlraw=0&thumb_aw=60','readonly'=>false),
'menu_template' => array('title'=> "Menu Template", 'nolist'=>true, 'tab' => 2, 'type' => 'dropdown', 'width' => 'auto','filter' => true, 'batch'=>true, 'inline'=>true, 'writeParms'=>''),
// 'page_ip_restrict' => array('title'=> LXXAN_USER_07, 'type' => 'text', 'width' => 'auto'), // Avatar
'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'forced'=>TRUE, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center','readParms'=>'sort=1')
'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'forced'=>TRUE, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center','readParms'=>'sort=1')
);
protected $fieldpref = array("page_id","page_title","page_chapter","page_template","page_author","page_class");
@@ -385,10 +357,43 @@ class page_admin_ui extends e_admin_ui
protected $templates = array();
function init()
{
{
// USED IN Menu LIST-MODE ONLY.
if($this->getMode() == 'menu' && $this->getACtion() == 'list')
{
$this->listQry = "SELECT 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.page_theme != '' "; // without any Order or Limit.
$this->batchDelete = false;
$this->fields = array(
'checkboxes' => array('title'=> '', 'type' => null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center'),
'page_id' => array('title'=> 'ID', 'type'=>'text', 'tab' => 0, 'width'=>'5%', 'readParms'=>'','forced'=> TRUE),
'menu_image' => array('title' =>"Menu Image", 'type' => 'image', 'width' => '110px', 'thclass' => 'left', 'class' => "left", 'nosort' => false, 'readParms'=>'thumb=80&thumb_urlraw=0&thumb_aw=80','readonly'=>false),
'page_theme' => array('title'=> "Menu Name", 'type' => 'text', 'width' => 'auto','nolist'=>true, "help"=>"Will be listed in the Menu-Manager under this name"),
// 'page_author' => array('title'=> LAN_AUTHOR, 'tab' => 0, 'type' => 'user', 'data'=>'int','width' => 'auto', 'thclass' => 'left'),
'page_datestamp' => array('title'=> LAN_DATE, 'type' => 'datestamp', 'data'=>'int', 'width' => 'auto','writeParms'=>'auto=1&readonly=1'),
'menu_title' => array('title'=> "Menu Title", 'forced'=> TRUE, 'type' => 'text', 'inline'=>true, 'width'=>'25%'),
'menu_text' => array('title'=> "Menu Body", 'type' => 'bbarea', 'data'=>'str', 'width' => 'auto', 'readParms' => 'expand=...&truncate=50&bb=1', 'writeParms'=>'media=page'),
'menu_template' => array('title'=> "Menu Template", 'type' => 'dropdown', 'width' => 'auto', 'filter' => true, 'batch'=>true, 'inline'=>true, 'writeParms'=>''),
'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'noselector' => true, 'forced'=>TRUE, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center'/*,'readParms'=>'sort=1'*/)
);
$this->fieldpref = array("page_id","page_theme", "menu_title", "menu_text", 'menu_image', 'menu_template');
}
$this->templates = e107::getLayouts('', 'page', 'front', '', false, false);
$this->fields['page_template']['writeParms'] = $this->templates;
unset($this->templates['panel'], $this->templates['nav']);
$this->fields['page_template']['writeParms'] = $this->templates;
$this->fields['menu_template']['writeParms'] = e107::getLayouts('', 'menu', 'front', '', false, false);
$sql = e107::getDb();
$sql->gen("SELECT chapter_id,chapter_name,chapter_parent FROM #page_chapters ORDER BY chapter_parent asc, chapter_order");
@@ -412,6 +417,66 @@ class page_admin_ui extends e_admin_ui
}
function afterCreate($newdata,$olddata, $id)
{
$tp = e107::getParser();
$sql = e107::getDb();
$mes = e107::getMessage();
$menu_name = $tp->toDB($newdata['page_theme']); // not to be confused with menu-caption.
$menu_path = intval($id);
if (!$sql->select('menus', 'menu_name', "`menu_path` = ".$menu_path." LIMIT 1"))
{
$insert = array('menu_name' => $menu_name, 'menu_path' => $menu_path);
if($sql->insert('menus', $insert) !== false)
{
$mes->addDebug("Menu Created");
return true;
}
}
return $newdata;
}
function beforeCreate($newdata,$olddata)
{
return $newdata;
}
// Update Menu in Menu Table
function afterUpdate($newdata,$olddata,$id)
{
$tp = e107::getParser();
$sql = e107::getDb();
$mes = e107::getMessage();
$menu_name = $tp->toDB($newdata['menu_title']); // not to be confused with menu-caption.
if ($sql->select('menus', 'menu_name', "`menu_path` = ".$id." LIMIT 1"))
{
if($sql->update('menus', "menu_name='{$menu_name}' WHERE menu_path=".$id." ") !== false)
{
$mes->addDebug("Menu Updated");
return true;
}
}
}
}