2006-12-02 04:36:16 +00:00
< ? php
/*
2008-12-29 15:23:06 +00:00
* e107 website system
*
2013-02-24 19:53:40 -08:00
* Copyright ( C ) 2008 - 2013 e107 Inc ( e107 . org )
2008-12-29 15:23:06 +00:00
* Released under the terms and conditions of the
* GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
* Custom Menus / Pages Administration
2013-02-24 19:53:40 -08:00
* Admin - related functions for custom page and menu creation
2010-01-04 21:35:38 +00:00
*/
2013-02-24 20:23:26 -08:00
define ( 'e_MINIMAL' , true );
2010-01-04 21:35:38 +00:00
require_once ( '../class2.php' );
2012-06-07 00:33:10 +00:00
if ( ! getperms ( " 5|J " )) { header ( 'location:' . e_ADMIN . 'admin.php' ); exit ; }
2006-12-02 04:36:16 +00:00
2012-08-11 11:15:05 +00:00
e107 :: css ( 'inline' , "
. e - wysiwyg { height : 400 px }
" );
2009-08-28 16:11:02 +00:00
include_lan ( e_LANGUAGEDIR . e_LANGUAGE . '/admin/lan_' . e_PAGE );
2006-12-02 04:36:16 +00:00
$e_sub_cat = 'custom' ;
2012-04-19 03:53:58 +00:00
class page_admin extends e_admin_dispatcher
{
protected $modes = array (
2012-05-22 04:38:28 +00:00
'page' => array (
2012-04-19 03:53:58 +00:00
'controller' => 'page_admin_ui' ,
'path' => null ,
'ui' => 'page_admin_form_ui' ,
'uipath' => null
2012-05-22 04:38:28 +00:00
),
2012-10-11 02:24:43 +00:00
'cat' => array (
'controller' => 'page_chapters_ui' ,
'path' => null ,
'ui' => 'page_chapters_form_ui' ,
'uipath' => null
),
2012-05-22 04:38:28 +00:00
'menu' => array (
2013-03-06 23:01:16 -08:00
'controller' => 'page_admin_ui' ,
2012-05-22 04:38:28 +00:00
'path' => null ,
2013-03-06 23:01:16 -08:00
'ui' => 'page_admin_form_ui' ,
2012-05-31 06:07:33 +00:00
'uipath' => null
2013-03-02 01:02:49 -08:00
),
'dialog' => array (
'controller' => 'menu_admin_ui' ,
'path' => null ,
'ui' => 'menu_admin_form_ui' ,
'uipath' => null
)
2012-04-19 03:53:58 +00:00
);
2012-05-22 04:38:28 +00:00
2012-04-19 03:53:58 +00:00
protected $adminMenu = array (
2012-05-22 04:38:28 +00:00
'page/list' => array ( 'caption' => CUSLAN_48 , 'perm' => '5' ),
2013-03-07 05:02:04 -08:00
'menu/list' => array ( 'caption' => CUSLAN_49 , 'perm' => 'J' , 'tab' => 2 ),
2012-05-22 04:38:28 +00:00
'page/create' => array ( 'caption' => CUSLAN_12 , 'perm' => '5' ),
2013-03-07 05:02:04 -08:00
'other' => array ( 'divider' => true ),
2012-10-11 02:24:43 +00:00
'cat/list' => array ( 'caption' => " List Books/Chapters " , 'perm' => '5' ), // Create Category.
'cat/create' => array ( 'caption' => " Add Book/Chapter " , 'perm' => '5' ), // Category List
2013-03-07 05:02:04 -08:00
'other2' => array ( 'divider' => true ),
2013-03-07 04:29:49 -08:00
// 'menu/create' => array('caption'=> CUSLAN_31, 'perm' => 'J', 'tab' => 2),
2013-02-24 19:53:40 -08:00
'page/prefs' => array ( 'caption' => LAN_OPTIONS , 'perm' => '0' )
2012-04-19 03:53:58 +00:00
);
protected $adminMenuAliases = array (
2012-05-22 04:38:28 +00:00
'page/edit' => 'page/list' ,
2013-03-06 23:01:16 -08:00
'menu/edit' => 'menu/create'
2012-04-19 03:53:58 +00:00
);
2013-03-07 05:02:04 -08:00
protected $menuTitle = ADLAN_42 ;
2012-04-19 03:53:58 +00:00
}
class page_admin_form_ui extends e_admin_form_ui
{
2012-04-22 06:19:21 +00:00
function page_title ( $curVal , $mode , $parm )
2012-04-19 03:53:58 +00:00
{
2012-04-29 08:51:03 +00:00
if ( $mode == 'read' )
2012-04-22 06:19:21 +00:00
{
2012-04-29 08:51:03 +00:00
$id = $this -> getController () -> getListModel () -> get ( 'page_id' );
return " <a href=' " . e_BASE . " page.php? " . $id . " ' > " . $curVal . " </a> " ;
2012-04-22 06:19:21 +00:00
}
if ( $mode == 'write' )
{
return ;
}
if ( $mode == 'filter' )
2012-04-19 03:53:58 +00:00
{
2012-04-22 06:19:21 +00:00
return ;
2012-04-19 03:53:58 +00:00
}
2012-04-22 06:19:21 +00:00
if ( $mode == 'batch' )
{
return ;
}
}
2012-04-19 03:53:58 +00:00
}
2012-10-11 02:24:43 +00:00
//FIXME - needs a layout similar to the admin sitelinks page. ie. showing chapters as we would 'sublinks'.
2013-02-24 19:53:40 -08:00
// BOOKS & CHAPTERS
2012-10-11 02:24:43 +00:00
class page_chapters_ui extends e_admin_ui
{
2013-02-22 21:34:06 -08:00
protected $pluginTitle = 'Page' ;
2012-10-11 02:24:43 +00:00
protected $pluginName = 'core' ;
protected $table = " page_chapters " ;
protected $pid = " chapter_id " ;
2013-05-20 04:52:10 -07:00
protected $perPage = 0 ; //no limit
protected $batchDelete = false ;
2013-06-14 13:42:11 -07:00
protected $batchCopy = true ;
2013-05-20 04:52:10 -07:00
protected $batchLink = true ;
protected $listOrder = ' COALESCE(NULLIF(chapter_parent,0), chapter_id), chapter_parent > 0, chapter_order ' ; //FIXME works with parent/child but doesn't respect parent order.
2013-06-14 17:00:41 -07:00
protected $url = array ( 'route' => 'page/chapter/index' , 'vars' => array ( 'id' => 'chapter_id' , 'name' => 'chapter_sef' ), 'name' => 'chapter_name' , 'description' => '' ); // 'link' only needed if profile not provided.
2013-05-20 04:52:10 -07:00
// protected $sortField = 'chapter_order';
// protected $orderStep = 10;
2012-10-11 02:24:43 +00:00
protected $fields = array (
2013-02-01 18:00:53 -08:00
'checkboxes' => array ( 'title' => '' , 'type' => null , 'width' => '5%' , 'forced' => TRUE , 'thclass' => 'center' , 'class' => 'center' ),
'chapter_id' => array ( 'title' => LAN_ID , 'type' => 'number' , 'width' => '5%' , 'forced' => TRUE , 'readonly' => TRUE ),
2013-07-12 09:07:56 -07:00
'chapter_icon' => array ( 'title' => LAN_ICON , 'type' => 'icon' , 'data' => 'str' , 'width' => '100px' , 'thclass' => 'center' , 'class' => 'center' , 'writeParms' => 'glyphs=1' , 'readonly' => FALSE , 'batch' => FALSE , 'filter' => FALSE ),
2013-02-01 18:00:53 -08:00
'chapter_parent' => array ( 'title' => " Book " , 'type' => 'dropdown' , 'width' => 'auto' , 'thclass' => 'left' , 'readonly' => FALSE , 'filter' => true ),
2013-05-20 04:52:10 -07:00
'chapter_name' => array ( 'title' => " Book or Chapter Title " , 'type' => 'method' , 'width' => 'auto' , 'thclass' => 'left' , 'readonly' => FALSE ),
2013-05-29 23:00:55 -07:00
'chapter_template' => array ( 'title' => LAN_TEMPLATE , 'type' => 'dropdown' , 'width' => 'auto' , 'filter' => true , 'batch' => true , 'inline' => true , 'writeParms' => '' ),
2013-02-01 18:00:53 -08:00
'chapter_meta_description' => array ( 'title' => LAN_DESCRIPTION , 'type' => 'textarea' , 'width' => 'auto' , 'thclass' => 'left' , 'readParms' => 'expand=...&truncate=150&bb=1' , 'readonly' => FALSE ),
'chapter_meta_keywords' => array ( 'title' => " Meta Keywords " , 'type' => 'text' , 'width' => 'auto' , 'thclass' => 'left' , 'readonly' => FALSE ),
2013-10-28 19:40:07 -07:00
'chapter_sef' => array ( 'title' => " SEF Url String " , 'type' => 'text' , 'width' => 'auto' , 'readonly' => FALSE , 'inline' => true ), // Display name
2013-02-01 18:00:53 -08:00
'chapter_manager' => array ( 'title' => " Can be edited by " , 'type' => 'userclass' , 'width' => 'auto' , 'data' => 'int' , 'batch' => TRUE , 'filter' => TRUE ),
'chapter_order' => array ( 'title' => LAN_ORDER , 'type' => 'text' , 'width' => 'auto' , 'thclass' => 'right' , 'class' => 'right' ),
2013-05-29 23:00:55 -07:00
2013-05-20 04:52:10 -07:00
'options' => array ( 'title' => LAN_OPTIONS , 'type' => 'method' , 'width' => '10%' , 'forced' => TRUE , 'thclass' => 'left last' , 'class' => 'left' , 'readParms' => 'sort=1' )
2012-10-11 02:24:43 +00:00
);
2012-04-19 03:53:58 +00:00
2012-10-11 02:24:43 +00:00
protected $fieldpref = array ( 'checkboxes' , 'chapter_icon' , 'chapter_id' , 'chapter_name' , 'chapter_description' , 'chapter_manager' , 'chapter_order' , 'options' );
2013-02-24 19:53:40 -08:00
2012-10-11 02:24:43 +00:00
protected $books = array ();
function init ()
{
$sql = e107 :: getDb ();
2013-02-24 19:53:40 -08:00
$sql -> gen ( " SELECT chapter_id,chapter_name FROM #page_chapters WHERE chapter_parent =0 " );
2012-10-11 02:24:43 +00:00
$this -> books [ 0 ] = " (New Book) " ;
2013-05-20 04:52:10 -07:00
2013-02-24 19:53:40 -08:00
while ( $row = $sql -> fetch ())
2012-10-11 02:24:43 +00:00
{
$bk = $row [ 'chapter_id' ];
$this -> books [ $bk ] = $row [ 'chapter_name' ];
}
2013-05-20 04:52:10 -07:00
2013-05-29 23:00:55 -07:00
asort ( $this -> books );
2012-10-11 02:24:43 +00:00
$this -> fields [ 'chapter_parent' ][ 'writeParms' ] = $this -> books ;
2013-05-29 23:00:55 -07:00
$tmp = e107 :: getLayouts ( '' , 'chapter' , 'front' , '' , true , false );
$tmpl = array ();
foreach ( $tmp as $key => $val )
{
if ( substr ( $key , 0 , 3 ) != 'nav' )
{
$tmpl [ $key ] = $val ;
}
}
$this -> fields [ 'chapter_template' ][ 'writeParms' ] = $tmpl ; // e107::getLayouts('', 'chapter', 'front', '', true, false); // e107::getLayouts('', 'page', 'books', 'front', true, false);
2012-10-11 02:24:43 +00:00
}
public function beforeCreate ( $new_data )
{
2013-10-28 19:40:07 -07:00
if ( empty ( $new_data [ 'chapter_sef' ]))
{
$new_data [ 'chapter_sef' ] = eHelper :: title2sef ( $new_data [ 'chapter_name' ]);
}
else
{
$new_data [ 'chapter_sef' ] = eHelper :: secureSef ( $new_data [ 'chapter_sef' ]);
}
$sef = e107 :: getParser () -> toDB ( $new_data [ 'chapter_sef' ]);
if ( e107 :: getDb () -> count ( 'page_chapters' , '(*)' , " chapter_sef=' { $sef } ' " ))
{
e107 :: getMessage () -> addError ( 'Please choose unique SEF URL string for this entry.' );
return false ;
}
return $new_data ;
2012-10-11 02:24:43 +00:00
}
public function beforeUpdate ( $new_data , $old_data , $id )
2013-10-28 19:40:07 -07:00
{
2013-10-28 21:28:21 -07:00
// return $this->beforeCreate($new_data);
2012-10-11 02:24:43 +00:00
}
}
2013-02-24 19:53:40 -08:00
2012-10-11 02:24:43 +00:00
class page_chapters_form_ui extends e_admin_form_ui
{
2013-05-20 04:52:10 -07:00
function chapter_name ( $curVal , $mode , $parm )
{
2013-05-27 00:45:43 -07:00
$frm = e107 :: getForm ();
2013-05-20 04:52:10 -07:00
if ( $mode == 'read' )
{
$parent = $this -> getController () -> getListModel () -> get ( 'chapter_parent' );
$id = $this -> getController () -> getListModel () -> get ( 'chapter_id' );
$linkQ = e_SELF . " ?searchquery=&filter_options=page_chapter__ " . $id . " &mode=page&action=list " ;
$level_image = $parent ? '<img src="' . e_IMAGE_ABS . 'generic/branchbottom.gif" class="icon" alt="" style="margin-left: ' . ( $level * 20 ) . 'px" /> ' : '' ;
return ( $parent ) ? $level_image . " <a href=' " . $linkQ . " ' > " . $curVal . " </a> " : $curVal ;
}
if ( $mode == 'write' )
{
2013-05-27 00:45:43 -07:00
return $frm -> text ( 'chapter_name' , $curVal );
2013-05-20 04:52:10 -07:00
}
if ( $mode == 'filter' )
{
return ;
}
if ( $mode == 'batch' )
{
return ;
}
}
// Override the default Options field.
function options ( $parms , $value , $id , $attributes )
{
//$id = $this->getController()->getListModel()->get('page_id');
// return "<a href='".e_BASE."page.php?".$id."' >".$curVal."</a>";
$parent = $this -> getController () -> getListModel () -> get ( 'chapter_parent' );
// $id = $this->getController()->getListModel()->get('chapter_id');
// $att['readParms'] = 'sort=1';
$text = " " ;
if ( $attributes [ 'mode' ] == 'read' )
{
2012-10-11 02:24:43 +00:00
2013-05-20 04:52:10 -07:00
$text .= $this -> renderValue ( 'options' , $value , $att , $id );
if ( $parent != 0 )
{
$link = e_SELF . " ?searchquery=&filter_options=page_chapter__ " . $id . " &mode=page&action=list " ;
$text .= " <a href=' " . $link . " ' class='btn' title='View Pages in this chapter'> " . E_32_CUST . " </a> " ;
}
return $text ;
}
}
2012-10-11 02:24:43 +00:00
}
2012-04-19 03:53:58 +00:00
2013-02-24 19:53:40 -08:00
// Menu Area.
2013-03-06 23:01:16 -08:00
/*
2013-02-24 19:53:40 -08:00
class menu_admin_ui extends e_admin_ui
{
protected $pluginTitle = ADLAN_42 ;
protected $pluginName = 'core' ;
protected $table = " page " ;
2013-03-09 14:53:01 -08:00
protected $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.menu_name != '' " ; // without any Order or Limit.
2013-02-24 19:53:40 -08:00
//protected $editQry = "SELECT * FROM #comments WHERE comment_id = {ID}";
protected $pid = " page_id " ;
protected $listOrder = 'p.page_order asc' ; // desc would require changes to ajax sorting.
protected $perPage = 10 ;
protected $batchDelete = true ;
protected $batchCopy = true ;
// protected $sortField = 'page_order';
protected $orderStep = 10 ;
protected $fields = array (
'checkboxes' => array ( 'title' => '' , 'type' => null , 'width' => '5%' , 'forced' => TRUE , 'thclass' => 'center' , 'class' => 'center' ),
2013-03-02 01:02:49 -08:00
'page_id' => array ( 'title' => 'ID' , 'type' => 'text' , 'tab' => 0 , 'width' => '5%' , 'readParms' => '' , 'forced' => TRUE ),
2013-03-09 14:53:01 -08:00
'menu_name' => array ( 'title' => " Menu Name " , 'tab' => 0 , 'type' => 'text' , 'width' => 'auto' , 'nolist' => true ),
2013-02-24 19:53:40 -08:00
2013-03-06 23:01:16 -08:00
'page_title' => array ( 'title' => LAN_TITLE , 'tab' => 0 , 'type' => 'text' , 'width' => '25%' , 'inline' => true ),
2013-02-24 19:53:40 -08:00
// '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' ),
2013-03-06 23:01:16 -08:00
'options' => array ( 'title' => LAN_OPTIONS , 'type' => null , 'forced' => TRUE , 'width' => '10%' , 'thclass' => 'center last' , 'class' => 'center'
2013-02-24 19:53:40 -08:00
);
2013-03-09 14:53:01 -08:00
protected $fieldpref = array ( " page_id " , " menu_name " , " page_title " , " page_text " );
2013-02-24 19:53:40 -08:00
2013-03-02 01:02:49 -08:00
function init ()
{
$this -> fields [ 'page_id' ][ 'readParms' ] = array ( 'link' => e_SELF . " ?mode=dialog&action=preview&id=[id] " , 'target' => 'modal' , 'iframe' => true );
if ( E107_DEBUG_LEVEL > 0 && e_AJAX_REQUEST )
{
echo " REQUEST = " . e_REQUEST_SELF ; //XXX Why no Query String ?? FIXME
// $this->getAction()
}
if ( $this -> getMode () == 'dialog' )
{
$this -> getRequest () -> setAction ( 'preview' );
// $this->setDefaultAction('previewPage');
// echo "ACTIOn = ".$this->getAction();
define ( 'e_IFRAME' , TRUE );
// return;
};
}
function CreateHeader ()
{
2013-03-02 12:14:06 -08:00
// e107::css('inline',' body { background-color: green } ');
2013-03-02 01:02:49 -08:00
}
// Create Menu in Menu Table
2013-03-06 23:01:16 -08:00
2013-03-02 01:02:49 -08:00
function previewPage () //XXX FIXME Doesn't work when in Ajax mode.. why???
{
print_a ( $_GET );
// $id = $this->getListModel()->get('page_id');
$tp = e107 :: getParser ();
}
2013-02-24 19:53:40 -08:00
}
//TODO XXX FIXME // Hooks!
$hooks = array (
'method' => 'form' ,
'table' => 'page' ,
'id' => $id ,
'plugin' => 'page' ,
'function' => 'createPage'
);
// $text .= $frm->renderHooks($hooks);
class menu_form_ui extends e_admin_form_ui
{
}
2013-03-06 23:01:16 -08:00
*/
2013-02-24 19:53:40 -08:00
// MAIN Pages.
2012-04-19 03:53:58 +00:00
class page_admin_ui extends e_admin_ui
{
2013-03-07 22:45:59 -08:00
protected $pluginTitle = ADLAN_42 ;
protected $pluginName = 'core' ;
protected $table = " page " ;
2012-04-19 03:53:58 +00:00
2013-03-09 14:21:46 -08:00
protected $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_title != '' " ; // without any Order or Limit.
2012-04-19 03:53:58 +00:00
//protected $editQry = "SELECT * FROM #comments WHERE comment_id = {ID}";
2013-03-07 22:45:59 -08:00
protected $pid = " page_id " ;
protected $listOrder = 'p.page_order asc' ; // desc would require changes to ajax sorting.
protected $perPage = 10 ;
protected $batchDelete = true ;
protected $batchCopy = true ;
protected $batchLink = true ;
protected $batchFeaturebox = true ;
protected $sortField = 'page_order' ;
protected $orderStep = 10 ;
2013-02-27 19:36:53 +02:00
//protected $url = array('profile'=>'page/view', 'name' => 'page_title', 'description' => '', 'link'=>'{e_BASE}page.php?id=[id]'); // 'link' only needed if profile not provided.
2013-04-29 14:27:57 +03:00
protected $url = array ( 'route' => 'page/view/index' , 'vars' => array ( 'id' => 'page_id' , 'name' => 'page_sef' ), 'name' => 'page_title' , 'description' => '' ); // 'link' only needed if profile not provided.
2013-03-07 22:45:59 -08:00
protected $tabs = array ( " Page " , " Page Options " , " Menu " );
2013-03-13 09:47:48 +02:00
protected $featurebox = array ( 'name' => 'page_title' , 'description' => 'page_text' , 'image' => 'menu_image' , 'visibility' => 'page_class' , 'url' => true );
2013-03-07 22:45:59 -08:00
/*
* 'fb_title' => array ( 'title' => LAN_TITLE , 'type' => 'text' , 'inline' => true , 'width' => 'auto' , 'thclass' => 'left' ),
'fb_text' => array ( 'title' => FBLAN_08 , 'type' => 'bbarea' , 'width' => '30%' , 'readParms' => 'expand=...&truncate=50&bb=1' , 'writeParms' => 'template=admin' ),
//DEPRECATED 'fb_mode' => array('title'=> FBLAN_12, 'type' => 'dropdown', 'data'=> 'int', 'width' => '5%', 'filter'=>TRUE, 'batch'=>TRUE),
//DEPRECATED 'fb_rendertype' => array('title'=> FBLAN_22, 'type' => 'dropdown', 'data'=> 'int', 'width' => 'auto', 'noedit' => TRUE),
'fb_template' => array ( 'title' => LAN_TEMPLATE , 'type' => 'layouts' , 'data' => 'str' , 'width' => 'auto' , 'writeParms' => 'plugin=featurebox' , 'filter' => true , 'batch' => true ), // Photo
'fb_image' => array ( 'title' => " Image " , 'type' => 'image' , 'width' => 'auto' , 'readParms' => 'thumb=60&thumb_urlraw=0&thumb_aw=60' ),
'fb_imageurl' => array ( 'title' => " Image Link " , 'type' => 'url' , 'width' => 'auto' ),
'fb_class'
*/
2012-10-11 02:24:43 +00:00
// protected $listSorting = true;
2013-02-24 19:53:40 -08:00
2013-03-06 23:01:16 -08:00
// PAGE LIST/EDIT and MENU EDIT modes.
2012-04-19 03:53:58 +00:00
protected $fields = array (
'checkboxes' => array ( 'title' => '' , 'type' => null , 'width' => '5%' , 'forced' => TRUE , 'thclass' => 'center' , 'class' => 'center' ),
2013-02-26 16:08:08 -08:00
'page_id' => array ( 'title' => LAN_ID , 'type' => 'text' , 'tab' => 0 , 'width' => '5%' , 'forced' => TRUE , 'readParms' => 'link=sef&target=dialog' ),
2013-10-28 11:52:54 -07:00
'page_title' => array ( 'title' => LAN_TITLE , 'tab' => 0 , 'type' => 'text' , 'inline' => true , 'width' => '25%' , 'writeParms' => 'size=block-level' ),
2013-06-10 17:55:43 +03:00
'page_chapter' => array ( 'title' => 'Book/Chapter' , 'tab' => 0 , 'type' => 'dropdown' , 'width' => '20%' , 'filter' => true , 'batch' => true , 'inline' => true ),
2013-05-30 00:35:05 -07:00
2013-02-24 19:53:40 -08:00
'page_template' => array ( 'title' => LAN_TEMPLATE , 'tab' => 0 , 'type' => 'dropdown' , 'width' => 'auto' , 'filter' => true , 'batch' => true , 'inline' => true , 'writeParms' => '' ),
2013-05-30 14:16:49 -07:00
2013-02-24 19:53:40 -08:00
'page_author' => array ( 'title' => LAN_AUTHOR , 'tab' => 0 , 'type' => 'user' , 'data' => 'int' , 'width' => 'auto' , 'thclass' => 'left' ),
2013-05-31 13:52:56 -07:00
'page_text' => array ( 'title' => CUSLAN_9 , 'tab' => 0 , 'type' => 'bbarea' , 'data' => 'str' , 'width' => '30%' , 'readParms' => 'expand=...&truncate=50&bb=1' , 'writeParms' => 'media=page&template=page' ),
2013-02-24 19:53:40 -08:00
2013-03-06 23:01:16 -08:00
// Options Tab.
2013-02-24 19:53:40 -08:00
'page_datestamp' => array ( 'title' => LAN_DATE , 'tab' => 1 , 'type' => 'datestamp' , 'data' => 'int' , 'width' => 'auto' , 'writeParms' => 'auto=1' ),
2013-02-26 16:08:08 -08:00
'page_class' => array ( 'title' => LAN_USERCLASS , 'tab' => 1 , 'type' => 'userclass' , 'data' => 'int' , 'inline' => true , 'width' => 'auto' , 'filter' => true , 'batch' => true ),
2013-02-24 19:53:40 -08:00
'page_rating_flag' => array ( 'title' => LAN_RATING , 'tab' => 1 , 'type' => 'boolean' , 'data' => 'int' , 'width' => '5%' , 'thclass' => 'center' , 'class' => 'center' ),
'page_comment_flag' => array ( 'title' => ADLAN_114 , 'tab' => 1 , 'type' => 'boolean' , 'data' => 'int' , 'width' => '5%' , 'thclass' => 'center' , 'class' => 'center' ),
// 'page_password' => array('title'=> LXAN_USER_05, 'type' => 'text', 'width' => 'auto'),
2013-04-29 14:27:57 +03:00
'page_sef' => array ( 'title' => LAN_SEFURL , 'tab' => 1 , 'type' => 'text' , 'inline' => true , 'width' => 'auto' ),
2013-03-17 14:59:19 -07:00
'page_metakeys' => array ( 'title' => LAN_KEYWORDS , 'tab' => 1 , 'type' => 'tags' , 'width' => 'auto' ),
'page_metadscr' => array ( 'title' => CUSLAN_11 , 'tab' => 1 , 'type' => 'text' , 'width' => 'auto' , 'writeParms' => 'size=xxlarge' ),
2013-02-24 19:53:40 -08:00
'page_order' => array ( 'title' => LAN_ORDER , 'tab' => 1 , 'type' => 'number' , 'width' => 'auto' , 'inline' => true ),
2013-03-06 23:01:16 -08:00
2013-03-09 14:53:01 -08:00
// Menu Tab XXX 'menu_name' is 'menu_name' - not caption.
2013-04-14 12:53:20 -07:00
'menu_name' => array ( 'title' => " Menu Name " , 'tab' => 2 , 'type' => 'text' , 'width' => 'auto' , 'nolist' => true , " help " => " Will be listed in the Menu-Manager under this name or may be called using { CMENU=name} in your theme. " ),
2013-03-06 23:01:16 -08:00
'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_template' => array ( 'title' => " Menu Template " , 'nolist' => true , 'tab' => 2 , 'type' => 'dropdown' , 'width' => 'auto' , 'filter' => true , 'batch' => true , 'inline' => true , 'writeParms' => '' ),
2013-03-08 20:27:12 -08:00
2013-03-09 20:30:37 -08:00
'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' , 'writeParms' => 'media=page' , 'readonly' => false ),
2013-03-08 20:27:12 -08:00
2013-03-06 23:01:16 -08:00
2013-02-24 19:53:40 -08:00
// 'page_ip_restrict' => array('title'=> LXXAN_USER_07, 'type' => 'text', 'width' => 'auto'), // Avatar
2012-04-19 03:53:58 +00:00
2013-03-06 23:01:16 -08:00
'options' => array ( 'title' => LAN_OPTIONS , 'type' => null , 'forced' => TRUE , 'width' => '10%' , 'thclass' => 'center last' , 'class' => 'center' , 'readParms' => 'sort=1' )
2012-04-19 03:53:58 +00:00
);
2012-12-19 02:03:34 -08:00
protected $fieldpref = array ( " page_id " , " page_title " , " page_chapter " , " page_template " , " page_author " , " page_class " );
2012-04-19 03:53:58 +00:00
2013-02-24 19:53:40 -08:00
protected $prefs = array (
2013-05-31 13:52:56 -07:00
'listPages' => array ( 'title' => CUSLAN_29 , 'type' => 'boolean' ),
'listBooks' => array ( 'title' => 'List Books/Chapters' , 'type' => 'boolean' ),
'listBooksTemplate' => array ( 'title' => 'List Books/Chapters Template' , 'type' => 'dropdown' ),
'pageCookieExpire' => array ( 'title' => CUSLAN_30 , 'type' => 'number' ) //TODO Set default value to 84600
2013-02-24 19:53:40 -08:00
);
2012-04-19 03:53:58 +00:00
2012-10-11 02:24:43 +00:00
protected $books = array ();
2013-03-18 05:04:35 -07:00
protected $cats = array ( 0 => 'None' );
2013-02-06 16:11:05 -08:00
protected $templates = array ();
2012-10-11 02:24:43 +00:00
2012-04-19 03:53:58 +00:00
function init ()
2013-03-06 23:01:16 -08:00
{
2013-03-07 16:48:35 +02:00
// USED IN Menu LIST/INLINE-EDIT MODE ONLY.
if ( $this -> getMode () == 'menu' && ( $this -> getACtion () == 'list' || $this -> getACtion () == 'inline' ))
2013-03-06 23:01:16 -08:00
{
2013-03-09 14:53:01 -08:00
$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.menu_name != '' " ; // without any Order or Limit.
2013-03-06 23:01:16 -08:00
$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 ),
2013-03-09 20:30:37 -08:00
'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 ),
2013-03-06 23:01:16 -08:00
2013-03-09 14:53:01 -08:00
'menu_name' => array ( 'title' => " Menu Name " , 'type' => 'text' , 'inline' => true , 'width' => 'auto' , 'nolist' => false , " help " => " Will be listed in the Menu-Manager under this name " ),
2013-03-08 20:27:12 -08:00
'menu_template' => array ( 'title' => " Menu Template " , 'type' => 'dropdown' , 'width' => 'auto' , 'filter' => true , 'batch' => true , 'inline' => true , 'writeParms' => '' ),
2013-03-06 23:01:16 -08:00
// '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' ),
2013-03-08 20:27:12 -08:00
2013-03-07 00:11:31 -08:00
'options' => array ( 'title' => LAN_OPTIONS , 'type' => null , 'noselector' => true , 'forced' => TRUE , 'width' => '10%' , 'thclass' => 'center last' , 'class' => 'center' , 'readParms' => 'deleteClass=252' )
2013-03-06 23:01:16 -08:00
);
2013-03-09 14:53:01 -08:00
$this -> fieldpref = array ( " page_id " , " menu_name " , " menu_title " , " menu_text " , 'menu_image' , 'menu_template' );
2013-03-06 23:01:16 -08:00
}
2013-03-02 01:02:49 -08:00
2013-05-29 17:45:11 -07:00
$this -> templates = e107 :: getLayouts ( '' , 'page' , 'front' , '' , true , false );
2013-03-06 23:01:16 -08:00
unset ( $this -> templates [ 'panel' ], $this -> templates [ 'nav' ]);
$this -> fields [ 'page_template' ][ 'writeParms' ] = $this -> templates ;
2013-03-08 21:48:49 -08:00
$this -> fields [ 'menu_template' ][ 'writeParms' ] = e107 :: getLayouts ( '' , 'menu' , 'front' , '' , true , false );
2012-10-11 02:24:43 +00:00
2013-05-30 14:16:49 -07:00
$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 ;
2012-10-11 02:24:43 +00:00
$sql = e107 :: getDb ();
2013-03-18 05:04:35 -07:00
2013-05-30 14:16:49 -07:00
$sql -> gen ( " SELECT chapter_id,chapter_name,chapter_parent FROM #page_chapters ORDER BY chapter_parent asc, chapter_order " );
2013-02-24 19:53:40 -08:00
while ( $row = $sql -> fetch ())
2012-10-11 02:24:43 +00:00
{
$cat = $row [ 'chapter_id' ];
2013-02-24 19:53:40 -08:00
2012-10-11 02:24:43 +00:00
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' ];
}
}
2013-02-01 18:00:53 -08:00
// asort($this->cats);
2012-10-11 02:24:43 +00:00
$this -> fields [ 'page_chapter' ][ 'writeParms' ] = $this -> cats ;
2012-04-19 03:53:58 +00:00
}
2013-03-06 23:01:16 -08:00
function afterCreate ( $newdata , $olddata , $id )
{
$tp = e107 :: getParser ();
$sql = e107 :: getDb ();
$mes = e107 :: getMessage ();
2013-03-09 14:53:01 -08:00
$menu_name = $tp -> toDB ( $newdata [ 'menu_name' ]); // not to be confused with menu-caption.
2013-03-06 23:01:16 -08:00
$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 )
{
2013-03-09 14:53:01 -08:00
$newdata [ 'menu_name' ] = preg_replace ( '/[^\w-*]/' , '' , $newdata [ 'menu_name' ]);
2013-11-04 13:07:26 +02:00
if ( empty ( $newdata [ 'page_sef' ]))
2013-10-28 19:40:07 -07:00
{
2013-11-04 13:07:26 +02:00
$newdata [ 'page_sef' ] = eHelper :: title2sef ( $newdata [ 'page_title' ]);
2013-10-28 19:40:07 -07:00
}
else
{
2013-11-04 13:07:26 +02:00
$newdata [ 'page_sef' ] = eHelper :: secureSef ( $newdata [ 'page_sef' ]);
2013-10-28 19:40:07 -07:00
}
2013-11-04 13:07:26 +02:00
$sef = e107 :: getParser () -> toDB ( $newdata [ 'page_sef' ]);
2013-10-28 19:40:07 -07:00
if ( e107 :: getDb () -> count ( 'page' , '(*)' , " page_sef=' { $sef } ' " ))
{
e107 :: getMessage () -> addError ( 'Please choose unique SEF URL string for this entry.' );
return false ;
}
2013-03-06 23:01:16 -08:00
return $newdata ;
}
2013-03-08 21:48:49 -08:00
function beforeUpdate ( $newdata , $olddata )
{
2013-03-09 14:53:01 -08:00
$newdata [ 'menu_name' ] = preg_replace ( '/[^\w-*]/' , '' , $newdata [ 'menu_name' ]);
2013-03-08 21:48:49 -08:00
return $newdata ;
}
2013-03-06 23:01:16 -08:00
// Update Menu in Menu Table
function afterUpdate ( $newdata , $olddata , $id )
{
$tp = e107 :: getParser ();
$sql = e107 :: getDb ();
$mes = e107 :: getMessage ();
2013-10-28 19:40:07 -07:00
2013-03-06 23:01:16 -08:00
$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 ;
}
}
}
2012-04-19 03:53:58 +00:00
}
2012-04-22 06:19:21 +00:00
2012-05-23 13:59:12 +00:00
new page_admin ();
require_once ( 'auth.php' );
2012-04-19 03:53:58 +00:00
e107 :: getAdminUI () -> runPage ();
2006-12-02 04:36:16 +00:00
2010-01-04 21:35:38 +00:00
require_once ( e_ADMIN . 'footer.php' );
2006-12-02 04:36:16 +00:00
2012-04-19 03:53:58 +00:00
2008-12-06 16:40:37 +00:00
2010-04-17 03:17:48 +00:00
2006-12-02 04:36:16 +00:00
2007-09-02 11:44:00 +00:00
?>