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
*/
2017-01-19 12:39:28 -08:00
//define('e_MINIMAL',true);
2021-01-16 13:32:35 -08:00
require_once ( __DIR__ . '/../class2.php' );
2010-01-04 21:35:38 +00:00
2016-01-13 19:17:37 -08:00
if ( ! getperms ( " 5|J " )) { e107 :: redirect ( 'admin' ); 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 }
2017-03-25 15:11:42 -07:00
td . menu - field { background - color : rgba ( 0 , 0 , 0 , 0.07 ); }
2012-08-11 11:15:05 +00:00
" );
2017-01-17 01:33:03 +01:00
e107 :: coreLan ( 'cpage' , true );
2017-01-23 09:41:23 -08:00
e107 :: includeLan ( e_LANGUAGEDIR . e_LANGUAGE . '/lan_page.php' );
2009-08-28 16:11:02 +00:00
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
),
2017-03-25 15:11:42 -07:00
'overview' => array (
'controller' => 'page_admin_ui' ,
'path' => null ,
'ui' => 'page_admin_form_ui' ,
'uipath' => null
),
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 (
2017-04-01 18:27:47 +02:00
'overview/list' => array ( 'caption' => CUSLAN_1 , 'perm' => '5|J' ),
2012-05-22 04:38:28 +00:00
'page/list' => array ( 'caption' => CUSLAN_48 , 'perm' => '5' ),
2017-03-25 15:11:42 -07: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 ),
2015-06-19 11:26:01 +03:00
'cat/list' => array ( 'caption' => CUSLAN_50 , 'perm' => '5' ), // Create Category.
'cat/create' => array ( 'caption' => CUSLAN_51 , '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
);
2016-11-01 16:42:47 -07:00
protected $adminMenuIcon = 'e-custom-24' ;
2012-04-19 03:53:58 +00:00
protected $adminMenuAliases = array (
2017-03-25 15:11:42 -07:00
'overview/edit' => 'overview/list' ,
2012-05-22 04:38:28 +00:00
'page/edit' => 'page/list' ,
2017-01-31 09:37:08 -08:00
'menu/edit' => 'menu/create' ,
2017-11-20 10:16:37 -08:00
'menu/grid' => 'menu/list' ,
2017-01-31 09:37:08 -08:00
'cat/edit' => 'cat/list'
2012-04-19 03:53:58 +00:00
);
2013-03-07 05:02:04 -08:00
protected $menuTitle = ADLAN_42 ;
2017-01-19 12:39:28 -08:00
function init ()
{
}
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' )
{
2015-02-15 02:37:36 -08:00
return null ;
2012-04-22 06:19:21 +00:00
}
if ( $mode == 'filter' )
2012-04-19 03:53:58 +00:00
{
2015-02-15 02:37:36 -08:00
return null ;
2012-04-19 03:53:58 +00:00
}
2012-04-22 06:19:21 +00:00
if ( $mode == 'batch' )
{
2015-02-15 02:37:36 -08:00
return null ;
2012-04-22 06:19:21 +00:00
}
}
2014-05-25 01:41:18 -07:00
// Override the default Options field.
function options ( $parms , $value , $id , $attributes )
{
if ( $attributes [ 'mode' ] == 'read' )
{
parse_str ( str_replace ( '&' , '&' , e_QUERY ), $query ); //FIXME - FIX THIS
$query [ 'action' ] = 'edit' ;
$query [ 'id' ] = $id ;
2018-05-04 17:57:43 -07:00
$query = http_build_query ( $query , null , '&' );
2014-05-25 01:41:18 -07:00
$text = " <a href=' " . e_SELF . " ? { $query } ' class='btn btn-default' title=' " . LAN_EDIT . " ' data-toggle='tooltip' data-placement='left'>
" .ADMIN_EDIT_ICON. " </ a > " ;
2017-03-25 15:11:42 -07:00
if ( $this -> getController () -> getMode () === 'overview' )
{
$text .= $this -> submit_image ( 'menu_delete[' . $id . ']' , $id , 'delete' , LAN_DELETE . ' [ ID: ' . $id . ' ]' , array ( 'class' => 'action delete btn btn-default' ));
}
2014-05-25 01:41:18 -07:00
return $text ;
}
}
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
{
2017-01-09 08:32:27 +01:00
protected $pluginTitle = CUSLAN_59 ;
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 ;
2017-01-27 18:02:57 -08:00
protected $batchExport = true ;
2015-04-03 21:19:43 -07:00
protected $listQry = " SELECT a. *, CASE WHEN a.chapter_parent = 0 THEN a.chapter_order ELSE b.chapter_order + (( a.chapter_order)/1000) END AS Sort FROM `#page_chapters` AS a LEFT JOIN `#page_chapters` AS b ON a.chapter_parent = b.chapter_id " ;
protected $listOrder = 'Sort,chapter_order ' ;
// 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.
2015-04-03 21:19:43 -07:00
protected $sortField = 'chapter_order' ;
protected $sortParent = 'chapter_parent' ;
2013-05-20 04:52:10 -07:00
// 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 ),
2017-11-10 14:06:30 -08:00
2015-06-19 11:26:01 +03:00
'chapter_parent' => array ( 'title' => CUSLAN_52 , 'type' => 'dropdown' , 'width' => 'auto' , 'thclass' => 'left' , 'readonly' => FALSE , 'filter' => true ),
'chapter_name' => array ( 'title' => CUSLAN_53 , 'type' => 'method' , 'width' => 'auto' , 'thclass' => 'left' , 'readonly' => FALSE , 'writeParms' => 'size=xxlarge' ),
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' => '' ),
2017-01-18 09:32:45 -08:00
'chapter_meta_description' => array ( 'title' => LAN_DESCRIPTION , 'type' => 'textarea' , 'width' => 'auto' , 'thclass' => 'left' , 'readParms' => 'expand=...&truncate=150&bb=1' , 'writeParms' => 'size=xxlarge' , 'readonly' => FALSE ),
2017-11-10 14:06:30 -08:00
'chapter_meta_keywords' => array ( 'title' => LAN_KEYWORDS , 'type' => 'tags' , 'inline' => true , 'width' => 'auto' , 'thclass' => 'left' , 'readonly' => FALSE ),
2017-04-02 11:32:32 -07:00
'chapter_sef' => array ( 'title' => LAN_SEFURL , 'type' => 'text' , 'width' => 'auto' , 'readonly' => FALSE , 'batch' => true , 'inline' => true , 'writeParms' => 'size=xxlarge&inline-empty=1&sef=chapter_name' , ), // Display name
2015-06-19 11:26:01 +03:00
'chapter_manager' => array ( 'title' => CUSLAN_55 , 'type' => 'userclass' , 'inline' => true , 'width' => 'auto' , 'data' => 'int' , 'batch' => TRUE , 'filter' => TRUE ),
2013-02-01 18:00:53 -08:00
'chapter_order' => array ( 'title' => LAN_ORDER , 'type' => 'text' , 'width' => 'auto' , 'thclass' => 'right' , 'class' => 'right' ),
2014-02-08 16:57:34 -08:00
'chapter_visibility' => array ( 'title' => LAN_VISIBILITY , 'type' => 'userclass' , 'inline' => true , 'width' => 'auto' , 'data' => 'int' , 'batch' => TRUE , 'filter' => TRUE ),
2017-01-18 17:10:12 -08:00
'chapter_fields' => array ( 'title' , 'hidden' , 'type' => 'hidden' ),
2017-11-10 14:06:30 -08:00
'chapter_image' => array ( 'title' => LAN_IMAGE , 'type' => 'image' , 'data' => 'str' , 'width' => '100px' , 'thclass' => 'center' , 'class' => 'center' , 'readParms' => 'thumb=140&thumb_urlraw=0&thumb_aw=140' , 'writeParms' => '' , 'readonly' => FALSE , 'batch' => FALSE , 'filter' => FALSE ),
2015-07-16 01:17:21 -07:00
'options' => array ( 'title' => LAN_OPTIONS , 'type' => 'method' , 'width' => '10%' , 'forced' => TRUE , 'thclass' => 'center last' , 'class' => 'left' , 'readParms' => 'sort=1' )
2012-10-11 02:24:43 +00:00
);
2012-04-19 03:53:58 +00:00
2017-03-12 10:01:19 -07:00
protected $fieldpref = array ( 'checkboxes' , 'chapter_icon' , 'chapter_id' , 'chapter_name' , 'chapter_description' , 'chapter_template' , 'chapter_visibility' , 'chapter_order' , 'options' );
2013-02-24 19:53:40 -08:00
2012-10-11 02:24:43 +00:00
protected $books = array ();
function init ()
{
2017-01-31 09:37:08 -08:00
$this -> addTitle ( CUSLAN_63 );
2017-01-25 17:57:38 -08:00
// e107::getMessage()->addWarning("Experimental: Custom Fields");
2017-04-01 18:45:46 +02:00
$this -> tabs = array ( LAN_GENERAL , CUSLAN_4 );
2017-01-25 17:57:38 -08:00
$this -> fields [ 'chapter_fields' ] = array ( 'title' => " Fields " , 'tab' => 1 , 'type' => 'method' , 'data' => 'json' , 'writeParms' => array ( 'nolabel' => 2 ));
2017-01-18 17:10:12 -08:00
2017-01-25 17:57:38 -08:00
if ( $this -> getAction () === 'list' )
2015-04-03 21:19:43 -07:00
{
2015-06-19 11:26:01 +03:00
$this -> fields [ 'chapter_parent' ][ 'title' ] = CUSLAN_56 ;
2015-04-03 21:19:43 -07:00
}
2017-01-25 17:57:38 -08:00
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}' ;
}
2015-04-03 21:19:43 -07:00
2012-10-11 02:24:43 +00:00
$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 " );
2017-04-01 18:45:46 +02:00
$this -> books [ 0 ] = CUSLAN_5 ;
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
}
2016-06-07 10:40:14 -07:00
public function beforeCreate ( $new_data , $old_data )
2012-10-11 02:24:43 +00:00
{
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 } ' " ))
{
2015-06-19 11:26:01 +03:00
e107 :: getMessage () -> addError ( CUSLAN_57 );
2013-10-28 19:40:07 -07:00
return false ;
}
2017-01-25 10:30:28 -08:00
$new_data = e107 :: getCustomFields () -> processConfigPost ( 'chapter_fields' , $new_data );
2013-10-28 19:40:07 -07:00
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
{
2017-01-18 17:10:12 -08:00
// return $this->beforeCreate($new_data);
2017-01-24 19:53:40 -08:00
$new_data = e107 :: getCustomFields () -> processConfigPost ( 'chapter_fields' , $new_data );
2017-01-18 17:10:12 -08:00
return $new_data ;
}
2017-01-24 19:53:40 -08:00
/*
2017-01-18 17:10:12 -08:00
private function processCustomFields ( $newdata )
{
if ( empty ( $newdata ))
{
return null ;
}
$new = array ();
foreach ( $newdata as $fields )
{
if ( empty ( $fields [ 'key' ]) || empty ( $fields [ 'type' ]))
{
continue ;
}
$key = $fields [ 'key' ];
unset ( $fields [ 'key' ]);
$new [ $key ] = $fields ;
}
return $new ;
2017-01-24 19:53:40 -08:00
} */
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' );
2015-04-03 21:19:43 -07:00
$level = 1 ;
2013-05-20 04:52:10 -07:00
$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' )
{
2014-01-12 08:05:12 -08:00
return $frm -> text ( 'chapter_name' , $curVal , 255 , 'size=xxlarge' );
2013-05-20 04:52:10 -07:00
}
if ( $mode == 'filter' )
{
2017-01-25 17:57:38 -08:00
return null ;
2013-05-20 04:52:10 -07:00
}
if ( $mode == 'batch' )
{
2017-01-25 17:57:38 -08:00
return null ;
2013-05-20 04:52:10 -07:00
}
}
2017-01-18 17:10:12 -08:00
function chapter_fields ( $curVal , $mode , $parm )
{
2017-01-22 13:31:03 -08:00
$fieldAmount = ( deftrue ( 'e_DEBUG' )) ? 20 : 10 ;
2017-01-18 17:10:12 -08:00
2020-12-18 19:55:12 -08:00
/*
2017-01-18 17:10:12 -08:00
if ( $mode == 'read' )
{
}
2020-12-18 19:55:12 -08:00
*/
2017-01-18 17:10:12 -08:00
if ( $mode == 'write' )
{
2017-01-24 19:53:40 -08:00
return e107 :: getCustomFields () -> loadConfig ( $curVal ) -> renderConfigForm ( 'chapter_fields' );
2017-01-18 17:10:12 -08:00
}
2020-12-18 19:55:12 -08:00
/*
2017-01-18 17:10:12 -08:00
if ( $mode == 'filter' )
{
return ;
}
if ( $mode == 'batch' )
{
return ;
}
2020-12-18 19:55:12 -08:00
*/
2017-01-18 17:10:12 -08:00
}
2017-01-22 13:31:03 -08:00
2013-05-20 04:52:10 -07:00
// 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');
2015-04-03 21:19:43 -07:00
$att [ 'readParms' ] = 'sort=1' ;
2015-07-16 01:17:21 -07:00
2013-05-20 04:52:10 -07:00
if ( $attributes [ 'mode' ] == 'read' )
{
2015-07-16 01:17:21 -07:00
$text = " <div class='btn-group'> " ;
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 " ;
2017-11-19 08:18:47 -08:00
$text .= " <a href=' " . $link . " ' class='btn btn-default' title=' " . CUSLAN_58 . " '> " . ADMIN_PAGES_ICON . " </a> " ; //
2013-05-20 04:52:10 -07:00
}
2015-07-16 01:17:21 -07:00
$text .= " </div> " ;
2013-05-20 04:52:10 -07:00
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' ;
2015-02-09 02:21:41 -08:00
protected $eventName = 'page' ;
2013-03-07 22:45:59 -08:00
protected $table = " page " ;
2012-04-19 03:53:58 +00:00
2014-07-24 18:23:50 +03:00
protected $listQry = " SELECT SQL_CALC_FOUND_ROWS
2014-07-09 19:24:07 +03:00
p .* , u . user_id , u . user_name , pch . chapter_sef , pbk . chapter_sef AS book_sef
FROM #page AS p
LEFT JOIN #user AS u ON p.page_author = u.user_id
LEFT JOIN #page_chapters AS pch ON p.page_chapter = pch.chapter_id
LEFT JOIN #page_chapters AS pbk ON pch.chapter_parent = pbk.chapter_id
2016-11-07 12:09:12 -08:00
WHERE ( p . page_title != '' OR p . page_text != '' ) " ; // 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 ;
2017-01-27 18:02:57 -08:00
protected $batchExport = true ;
protected $batchFeaturebox = true ;
2013-03-07 22:45:59 -08:00
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.
2014-07-24 17:14:24 +03:00
protected $url = array ( 'route' => 'page/view/index' , 'vars' => array ( 'id' => 'page_id' , 'name' => 'page_sef' , 'other' => 'page_sef' , 'chapter' => 'chapter_sef' , 'book' => 'book_sef' ), 'name' => 'page_title' , 'description' => '' ); // 'link' only needed if profile not provided.
2015-06-19 11:26:01 +03:00
protected $tabs = array ( CUSLAN_59 , CUSLAN_60 , CUSLAN_61 , CUSLAN_62 );
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 );
2017-11-20 10:16:37 -08:00
protected $grid = array ( 'title' => 'menu_title' , 'image' => 'menu_image' , 'body' => '' , 'class' => 'col-md-2' , 'perPage' => 12 , 'carousel' => false );
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 (
2014-06-22 00:01:14 -07:00
'checkboxes' => array ( 'title' => '' , 'type' => null , 'width' => '3%' , 'forced' => TRUE , 'thclass' => 'center' , 'class' => 'center' ),
2017-01-18 17:10:12 -08:00
'page_id' => array ( 'title' => LAN_ID , 'type' => 'text' , 'tab' => 0 , 'width' => '5%' , 'forced' => TRUE , 'readParms' => 'link=sef&target=blank' ),
2017-04-01 18:27:47 +02:00
'page_title' => array ( 'title' => CUSLAN_2 , 'tab' => 0 , 'type' => 'text' , 'data' => 'str' , 'inline' => true , 'width' => '25%' , 'writeParms' => 'size=block-level' ),
2021-01-04 12:48:37 -08:00
'page_subtitle' => array ( 'title' => CUSLAN_80 , 'tab' => 0 , 'type' => 'text' , 'data' => 'str' , 'inline' => true , 'width' => '25%' , 'writeParms' => 'size=block-level' ),
2015-06-19 11:26:01 +03:00
'page_chapter' => array ( 'title' => CUSLAN_63 , 'tab' => 0 , 'type' => 'dropdown' , 'width' => '20%' , 'filter' => true , 'batch' => true , 'inline' => true ),
2013-05-30 00:35:05 -07:00
2017-01-19 12:39:28 -08:00
'page_template' => array ( 'title' => LAN_TEMPLATE , 'tab' => 0 , 'type' => 'dropdown' , 'width' => 'auto' , 'filter' => true , 'batch' => true , 'inline' => true , 'writeParms' => array ()),
2013-05-30 14:16:49 -07:00
2015-05-23 14:49:44 +02:00
'page_author' => array ( 'title' => LAN_AUTHOR , 'tab' => 0 , 'type' => 'user' , 'inline' => true , 'data' => 'int' , 'width' => 'auto' , 'thclass' => 'left' ),
2018-08-26 12:28:52 -07:00
'page_text' => array ( 'title' => CUSLAN_9 , 'tab' => 0 , 'type' => 'bbarea' , 'data' => 'str' , 'width' => '30%' , 'readParms' => 'expand=...&truncate=50&bb=1' , 'writeParms' => array ( 'media' => 'page^' , 'template' => 'page' )),
2013-02-24 19:53:40 -08:00
2013-03-06 23:01:16 -08:00
// Options Tab.
2015-04-16 00:55:01 -07:00
'page_datestamp' => array ( 'title' => LAN_DATE , 'tab' => 1 , 'type' => 'datestamp' , 'data' => 'int' , 'width' => 'auto' , 'writeParms' => 'auto=1&type=datetime' ),
2016-05-30 15:19:19 -07:00
'page_class' => array ( 'title' => LAN_VISIBILITY , 'tab' => 1 , 'type' => 'userclass' , 'data' => 'str' , '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' ),
2015-07-07 18:02:16 -07:00
'page_comment_flag' => array ( 'title' => LAN_COMMENTS , 'tab' => 1 , 'type' => 'boolean' , 'data' => 'int' , 'width' => '5%' , 'thclass' => 'center' , 'class' => 'center' ),
2015-07-02 14:33:04 +01:00
'page_password' => array ( 'title' => LAN_PASSWORD , 'tab' => 1 , 'type' => 'text' , 'data' => 'str' , 'width' => 'auto' , 'writeParms' => array ( 'password' => 1 , 'nomask' => 1 , 'size' => 40 , 'class' => 'tbox e-password' , 'generate' => 1 , 'strength' => 1 , 'required' => 0 )),
2017-04-02 11:32:32 -07:00
'page_sef' => array ( 'title' => LAN_SEFURL , 'tab' => 1 , 'type' => 'text' , 'batch' => true , 'data' => 'str' , 'inline' => true , 'width' => 'auto' , 'writeParms' => 'size=xxlarge&sef=page_title' ),
2017-03-04 11:00:49 -08:00
'page_metakeys' => array ( 'title' => LAN_KEYWORDS , 'tab' => 1 , 'type' => 'tags' , 'data' => 'str' , 'width' => 'auto' ),
'page_metadscr' => array ( 'title' => CUSLAN_11 , 'tab' => 1 , 'type' => 'text' , 'data' => 'str' , 'width' => 'auto' , 'writeParms' => 'size=xxlarge' ),
2020-06-26 13:58:59 -07:00
'page_metarobots' => array ( 'title' => LAN_ROBOTS , 'tab' => 1 , 'type' => 'dropdown' , 'data' => 'safestr' , 'batch' => true , 'inline' => true , 'readParms' => array ( 'type' => 'checkboxes' ), 'width' => 'auto' , 'thclass' => 'left' , 'class' => 'left' , 'nosort' => false , 'filter' => true ),
2019-12-02 13:32:21 -08:00
2013-02-24 19:53:40 -08:00
'page_order' => array ( 'title' => LAN_ORDER , 'tab' => 1 , 'type' => 'number' , 'width' => 'auto' , 'inline' => true ),
2017-01-18 17:10:12 -08:00
'page_fields' => array ( 'title' => 'Custom Fields' , 'tab' => 4 , 'type' => 'hidden' , 'data' => 'json' , 'width' => 'auto' ),
2013-03-09 14:53:01 -08:00
// Menu Tab XXX 'menu_name' is 'menu_name' - not caption.
2016-05-13 07:18:57 -07:00
'menu_name' => array ( 'title' => CUSLAN_64 , '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. Must use ASCII characters only and be all lowercase. " ),
2015-06-19 11:26:01 +03:00
'menu_title' => array ( 'title' => CUSLAN_65 , 'nolist' => true , 'tab' => 2 , 'type' => 'text' , 'inline' => true , 'width' => '25%' , " help " => " Caption displayed on the menu item. " , 'writeParms' => 'size=xxlarge' ),
2018-08-26 12:28:52 -07:00
'menu_text' => array ( 'title' => CUSLAN_66 , 'nolist' => true , 'tab' => 2 , 'type' => 'bbarea' , 'data' => 'str' , 'width' => '30%' , 'readParms' => 'expand=...&truncate=50&bb=1' , 'writeParms' => 'media=page^' ),
2016-04-12 14:22:46 +03:00
'menu_template' => array ( 'title' => CUSLAN_67 , 'nolist' => true , 'tab' => 2 , 'type' => 'dropdown' , 'width' => 'auto' , 'filter' => true , 'batch' => true , 'inline' => true , 'writeParms' => '' ),
2014-06-28 18:38:15 -07:00
'menu_class' => array ( 'title' => LAN_VISIBILITY , 'tab' => 3 , 'type' => 'userclass' , 'data' => 'int' , 'inline' => true , 'width' => 'auto' , 'filter' => true , 'batch' => true ),
2015-06-19 11:26:01 +03:00
'menu_button_text' => array ( 'title' => CUSLAN_68 , 'nolist' => true , 'tab' => 3 , 'type' => 'text' , 'inline' => true , 'width' => '25%' , " help " => " Leave blank to use the default " ),
2014-06-28 18:38:15 -07:00
2015-06-19 11:26:01 +03:00
'menu_button_url' => array ( 'title' => CUSLAN_69 , 'nolist' => true , 'tab' => 3 , 'type' => 'text' , 'inline' => true , 'width' => '25%' , " help " => " Leave blank to use the corresponding page " , 'writeParms' => 'size=xxlarge' ),
2014-06-28 00:08:35 -07:00
2018-08-26 12:28:52 -07:00
'menu_icon' => array ( 'title' => CUSLAN_70 , 'nolist' => true , 'tab' => 2 , 'type' => 'icon' , 'width' => '110px' , 'thclass' => 'center' , 'class' => " center " , 'nosort' => false , 'readParms' => 'thumb=60&thumb_urlraw=0&thumb_aw=60' , 'writeParms' => 'media=page^&glyphs=1' , 'readonly' => false ),
2014-01-08 04:29:00 -08:00
2018-08-26 12:28:52 -07:00
'menu_image' => array ( 'title' => CUSLAN_71 , '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^&video=1' , '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
2017-03-25 15:11:42 -07:00
'options' => array ( 'title' => LAN_OPTIONS , 'type' => null , 'forced' => TRUE , 'width' => '10%' , 'thclass' => 'center last' , 'class' => 'center last' , 'readParms' => 'sort=1&deleteClass=e_UC_NOBODY' )
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' ),
2015-06-19 11:26:01 +03:00
'listBooks' => array ( 'title' => CUSLAN_50 , 'type' => 'boolean' ),
'listBooksTemplate' => array ( 'title' => CUSLAN_72 , 'type' => 'dropdown' ),
2017-03-25 15:11:42 -07:00
'pageCookieExpire' => array ( 'title' => CUSLAN_30 , 'type' => 'number' ), //TODO Set default value to 84600
2017-04-01 18:27:47 +02:00
'admin_page_perpage' => array ( 'title' => CUSLAN_3 , '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 ();
2015-06-19 11:26:01 +03:00
protected $cats = array ( 0 => LAN_NONE );
2013-02-06 16:11:05 -08:00
protected $templates = array ();
2017-01-18 17:10:12 -08:00
protected $chapterFields = array ();
2019-05-11 13:52:28 -07:00
protected $chapters = 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
{
2017-01-18 17:10:12 -08:00
2019-12-02 13:32:21 -08:00
$this -> fields [ 'page_metarobots' ][ 'writeParms' ][ 'optArray' ] = e107 :: getSingleton ( 'eResponse' ) -> getRobotTypes ();
$this -> fields [ 'page_metarobots' ][ 'writeParms' ][ 'title' ] = e107 :: getSingleton ( 'eResponse' ) -> getRobotDescriptions ();
$this -> fields [ 'page_metarobots' ][ 'writeParms' ][ 'multiple' ] = 1 ;
2017-11-20 10:16:37 -08:00
$mode = $this -> getMode ();
2018-07-28 16:22:46 -07:00
$this -> perPage = ( int ) e107 :: pref ( 'core' , 'admin_page_perpage' , 10 );
2017-11-20 10:16:37 -08:00
if ( $mode !== 'menu' )
{
$this -> grid = array ();
}
if ( $mode === 'overview' )
2017-03-25 15:11:42 -07:00
{
$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 " ; // without any Order or Limit.
$this -> fieldpref = array ( " page_id " , " page_title " , 'page_chapter' , 'page_template' , " menu_title " , 'menu_image' , 'menu_template' );
2017-11-04 10:12:03 -07:00
2017-03-25 15:11:42 -07:00
$this -> sortField = false ;
$this -> fields [ 'menu_title' ][ 'width' ] = 'auto' ;
2017-03-25 15:32:10 -07:00
$this -> fields [ 'menu_image' ][ 'readParms' ] = 'thumb=60x55' ;
$this -> fields [ 'menu_image' ][ 'width' ] = 'auto' ;
2017-11-04 10:12:03 -07:00
$this -> fields [ 'menu_button_text' ][ 'nolist' ] = false ;
$this -> fields [ 'menu_button_url' ][ 'nolist' ] = false ;
2017-03-25 15:11:42 -07:00
$this -> fields [ 'page_title' ][ 'width' ] = 'auto' ;
$this -> fields [ 'options' ][ 'type' ] = 'method' ;
2017-01-18 17:10:12 -08:00
2017-03-25 15:32:10 -07:00
foreach ( $this -> fieldpref as $k )
2017-03-25 15:11:42 -07:00
{
$this -> fields [ $k ][ 'nolist' ] = false ;
2017-03-25 15:32:10 -07:00
if ( $k === 'page_id' )
{
continue ;
}
2017-03-25 15:11:42 -07:00
if ( strpos ( $k , 'menu_' ) === 0 )
{
2017-12-10 13:28:22 +01:00
$this -> fields [ $k ][ 'class' ] = 'menu-field ' . varset ( $this -> fields [ $k ][ 'class' ], '' );
2017-03-25 15:11:42 -07:00
}
2017-03-25 15:32:10 -07:00
$this -> fields [ $k ][ 'width' ] = '13%' ;
2017-03-25 15:11:42 -07:00
}
}
2013-03-06 23:01:16 -08:00
2017-05-12 12:08:29 -07:00
if ( ! empty ( $_POST [ 'menu_delete' ])) // Delete a Page/Menu combination (or rather, remove it's data )
2014-05-25 01:41:18 -07:00
{
$key = key ( $_POST [ 'menu_delete' ]);
if ( $key )
{
2017-05-12 12:08:29 -07:00
//e107::getDb()->update('page',"menu_name = '' WHERE page_id=".intval($key)." LIMIT 1");
e107 :: getDb () -> delete ( 'page' , " page_id= " . intval ( $key ));
2014-05-25 01:41:18 -07:00
}
}
2014-07-09 19:24:07 +03:00
2013-03-07 16:48:35 +02:00
// USED IN Menu LIST/INLINE-EDIT MODE ONLY.
2017-11-20 10:16:37 -08:00
if ( $this -> getMode () === 'menu' && ( $this -> getAction () == 'list' || $this -> getAction () == 'inline' || $this -> getAction () == 'grid' ))
2013-03-06 23:01:16 -08:00
{
2019-06-05 21:59:03 -07:00
$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_title != '' OR p.menu_name != '' OR p.menu_image != '' OR p.menu_icon !='') " ; // without any Order or Limit.
2017-11-20 10:16:37 -08:00
// $this->gridQry = $this->listQry;
2017-01-25 17:57:38 -08:00
$this -> listOrder = 'p.page_order asc' ; // 'p.page_id desc';
2014-02-06 07:44:09 -08:00
2013-03-06 23:01:16 -08:00
$this -> batchDelete = false ;
$this -> fields = array (
2014-06-22 00:01:14 -07:00
'checkboxes' => array ( 'title' => '' , 'type' => null , 'width' => '3%' , 'forced' => TRUE , 'thclass' => 'center' , 'class' => 'center' ),
2013-03-06 23:01:16 -08:00
'page_id' => array ( 'title' => 'ID' , 'type' => 'text' , 'tab' => 0 , 'width' => '5%' , 'readParms' => '' , 'forced' => TRUE ),
2015-06-19 11:26:01 +03:00
'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 ),
2014-06-22 00:01:14 -07:00
'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 ),
2015-06-19 11:26:01 +03:00
'menu_title' => array ( 'title' => CUSLAN_65 , 'forced' => TRUE , 'type' => 'text' , 'inline' => true , 'width' => '20%' ),
2014-06-22 00:01:14 -07:00
2013-03-06 23:01:16 -08:00
2016-04-05 09:20:52 -07:00
'menu_name' => array ( 'title' => CUSLAN_64 , 'type' => 'text' , 'inline' => false , 'width' => '10%' , 'nolist' => false , " help " => " Will be listed in the Menu-Manager under this name. Must use ASCII characters only. " ),
2015-06-19 11:26:01 +03:00
'menu_template' => array ( 'title' => CUSLAN_67 , 'type' => 'dropdown' , 'width' => '15%' , 'filter' => true , 'batch' => true , 'inline' => true , 'writeParms' => '' ),
2016-05-30 15:19:19 -07:00
'menu_class' => array ( 'title' => LAN_USERCLASS , 'type' => 'userclass' , 'data' => 'str' , 'inline' => true , 'width' => 'auto' , 'filter' => true , 'batch' => true ),
2014-06-28 00:08:35 -07:00
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' ),
2014-06-22 00:01:14 -07:00
2015-06-19 11:26:01 +03:00
'page_chapter' => array ( 'title' => CUSLAN_63 , 'tab' => 0 , 'type' => 'dropdown' , 'width' => '20%' , 'filter' => true , 'batch' => true , 'inline' => true ),
2014-06-16 18:21:51 -07:00
2015-06-19 11:26:01 +03:00
'menu_text' => array ( 'title' => CUSLAN_66 , 'type' => 'bbarea' , 'data' => 'str' , 'width' => 'auto' , 'readParms' => 'expand=...&truncate=50&bb=1' , 'writeParms' => 'media=page' ),
2013-03-08 20:27:12 -08:00
2015-06-19 11:26:01 +03:00
'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 )
2013-03-06 23:01:16 -08:00
);
2014-07-24 18:23:50 +03:00
$this -> fieldpref = array ( " page_id " , " menu_name " , " menu_title " , 'menu_image' , 'menu_template' , 'menu_icon' , 'page_chapter' , 'menu_class' );
2016-06-03 19:40:17 -07:00
2017-01-21 13:42:36 -08:00
if ( deftrue ( 'e_DEBUG' ))
2016-06-03 19:40:17 -07:00
{
$this -> fields [ 'menu_name' ][ 'inline' ] = true ;
}
2017-11-20 10:16:37 -08:00
if ( $this -> getAction () == 'grid' )
{
$this -> fields [ 'menu_image' ][ 'readParms' ] = 'thumb=400x400' ;
2016-06-03 19:40:17 -07:00
2017-11-20 10:16:37 -08:00
}
2016-06-03 19:40:17 -07:00
2016-10-31 16:15:49 -07:00
2014-07-24 18:23:50 +03:00
### Parse aliases again or all filters shall fail due to the menu hack!
$this -> _alias_parsed = false ;
$this -> parseAliases ();
2013-03-06 23:01:16 -08:00
}
2017-01-18 10:25:08 -08:00
if ( $this -> getAction () == 'create' && e_DEBUG === true )
{
$tmp = e107 :: getCoreTemplate ( 'page' , 'default' );
if ( ! empty ( $tmp [ 'editor' ]))
{
$this -> fields [ 'page_text' ][ 'writeParms' ][ 'default' ] = $tmp [ 'editor' ];
}
}
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 );
2019-10-30 15:47:43 +01:00
$this -> fields [ 'menu_name' ][ 'writeParms' ] = array ( 'pattern' => '^[a-z0-9-]*' );
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 ();
2017-01-21 13:42:36 -08:00
2019-05-11 13:52:28 -07:00
$sql -> gen ( " SELECT chapter_id,chapter_name,chapter_parent, chapter_sef, chapter_fields 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
2019-05-11 13:52:28 -07:00
$chrow = $row ;
unset ( $chrow [ 'chapter_fields' ]);
$this -> chapters [ $cat ] = $chrow ;
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' ];
2017-01-18 17:10:12 -08:00
}
if ( ! empty ( $row [ 'chapter_fields' ]))
{
2017-01-24 20:31:58 -08:00
$this -> chapterFields [ $cat ] = ( $row [ 'chapter_fields' ]);
2017-01-18 17:10:12 -08:00
}
2012-10-11 02:24:43 +00:00
}
2013-02-01 18:00:53 -08:00
// asort($this->cats);
2012-10-11 02:24:43 +00:00
2015-11-20 17:10:10 -08:00
$this -> fields [ 'page_chapter' ][ 'writeParms' ][ 'optArray' ] = $this -> cats ;
$this -> fields [ 'page_chapter' ][ 'writeParms' ][ 'size' ] = 'xxlarge' ;
2012-04-19 03:53:58 +00:00
2017-01-21 13:42:36 -08:00
if ( $this -> getAction () === 'create' )
2017-01-18 17:10:12 -08:00
{
2017-01-19 12:39:28 -08:00
$this -> fields [ 'page_chapter' ][ 'writeParms' ][ 'ajax' ] = array ( 'src' => e_SELF . " ?mode=page&action=chapter-change " , 'target' => 'tabadditional' );
}
2020-12-18 19:55:12 -08:00
/*
2017-01-22 13:31:03 -08:00
if ( e_AJAX_REQUEST )
{
// @todo insert placeholder examples in params input when 'type' dropdown value is changed
}
2020-12-18 19:55:12 -08:00
*/
2017-01-22 13:31:03 -08:00
2017-01-19 12:39:28 -08:00
if ( e_AJAX_REQUEST && isset ( $_POST [ 'page_chapter' ]) ) //&& $this->getAction() === 'chapter-change'
{
2017-01-22 13:31:03 -08:00
2017-01-19 12:39:28 -08:00
$this -> initCustomFields ( $_POST [ 'page_chapter' ]);
$elid = 'core-page-create' ;
$model = $this -> getModel ();
2017-01-31 09:37:08 -08:00
$tabId = e107 :: getCustomFields () -> getTabId ();
2017-01-31 20:48:50 +01:00
$tabLabel = e107 :: getCustomFields () -> getTabLabel ();
2017-01-19 12:39:28 -08:00
$data = array (
2017-01-21 11:27:36 +01:00
'tabs' => $this -> getTabs (),
'legend' => '' ,
'fields' => $this -> getFields (),
2017-01-19 12:39:28 -08:00
);
$text = $this -> getUI () -> renderCreateFieldset ( $elid , $data , $model , $tabId );
2017-01-21 11:27:36 +01:00
$ajax = e107 :: getAjax ();
$commands = array ();
2017-01-19 12:39:28 -08:00
if ( empty ( $text ))
{
2017-01-20 21:07:13 +01:00
$text = " " ; // There are no additional fields for the selected chapter.
2017-01-21 11:27:36 +01:00
$commands [] = $ajax -> commandInvoke ( 'a[href="#tab' . $tabId . '"]' , 'fadeOut' );
}
else
{
$commands [] = $ajax -> commandInvoke ( 'a[href="#tab' . $tabId . '"]' , 'fadeInAdminTab' );
2017-01-19 12:39:28 -08:00
}
2017-01-31 20:48:50 +01:00
$commands [] = $ajax -> commandInvoke ( 'a[href="#tab' . $tabId . '"]' , 'html' , array ( $tabLabel ));
2017-01-20 21:07:13 +01:00
$commands [] = $ajax -> commandInvoke ( '#tab' . $tabId , 'html' , array ( $text ));
2017-01-19 12:39:28 -08:00
2017-01-20 19:59:16 +01:00
$ajax -> response ( $commands );
exit ;
2017-01-18 17:10:12 -08:00
}
2012-04-19 03:53:58 +00:00
}
2017-01-22 13:31:03 -08:00
/*
* @ todo Move to admin - ui ?
*/
2017-01-19 12:39:28 -08:00
private function initCustomFields ( $chap = null )
2017-01-18 17:10:12 -08:00
{
2017-01-31 11:21:42 +01:00
2017-01-18 17:10:12 -08:00
if ( ! empty ( $this -> chapterFields [ $chap ]))
{
2017-01-31 11:30:48 +01:00
e107 :: getCustomFields () -> loadConfig ( $this -> chapterFields [ $chap ]);
2017-01-19 12:39:28 -08:00
}
2017-01-20 21:07:13 +01:00
else
{
2017-01-31 09:37:08 -08:00
$tabId = e107 :: getCustomFields () -> getTabId ();
2017-01-20 21:07:13 +01:00
e107 :: css ( 'inline' , '.nav-tabs li a[href="#tab' . $tabId . '"] { display: none; }' );
}
2017-01-31 11:30:48 +01:00
e107 :: getCustomFields () -> setAdminUIConfig ( 'page_fields' , $this );
2017-01-19 12:39:28 -08:00
}
2017-01-24 20:31:58 -08:00
private function loadCustomFieldsData ()
{
$row = e107 :: getDb () -> retrieve ( 'page' , 'page_chapter, page_fields' , 'page_id=' . $this -> getId ());
$cf = e107 :: getCustomFields ();
$cf -> loadData ( $row [ 'page_fields' ]) -> setAdminUIData ( 'page_fields' , $this );
// e107::getDebug()->log($cf);
}
2017-01-19 12:39:28 -08:00
function CreateObserver ()
{
parent :: CreateObserver ();
$this -> initCustomFields ( 0 );
2017-01-18 17:10:12 -08:00
}
2017-01-19 12:39:28 -08:00
2017-01-18 17:10:12 -08:00
// Override default so we can alter the field db table data after it is loaded. .
function EditObserver ()
{
2017-01-19 12:39:28 -08:00
parent :: EditObserver ();
$row = e107 :: getDb () -> retrieve ( 'page' , 'page_chapter, page_fields' , 'page_id=' . $this -> getId ());
$chap = intval ( $row [ 'page_chapter' ]);
2017-01-24 19:53:40 -08:00
2017-01-19 12:39:28 -08:00
$this -> initCustomFields ( $chap );
2017-01-24 20:31:58 -08:00
$this -> loadCustomFieldsData ();
2017-01-18 17:10:12 -08:00
}
/**
* Filter / Process Posted page_field data ;
* @ param $new_data
* @ return null
2017-01-24 19:53:40 -08:00
*//*
2017-01-18 17:10:12 -08:00
private function processCustomFieldData ( $new_data )
{
if ( empty ( $new_data ))
{
return null ;
}
unset ( $new_data [ 'page_fields' ]); // Reset.
foreach ( $new_data as $k => $v )
{
if ( substr ( $k , 0 , 11 ) === " page_fields " )
{
list ( $tmp , $newkey ) = explode ( " __ " , $k );
$new_data [ 'page_fields' ][ $newkey ] = $v ;
unset ( $new_data [ $k ]);
}
}
return $new_data ;
}
2017-01-24 19:53:40 -08:00
*/
2017-01-22 13:31:03 -08:00
2014-07-09 19:24:07 +03:00
/**
* Overrid
*/
public function ListObserver ()
{
parent :: ListObserver ();
// fix current url config limitation
$tree = $this -> getTreeModel ();
/** @var e_admin_model $model */
foreach ( $tree -> getTree () as $id => $model )
{
2019-05-11 13:52:28 -07:00
if ( $chap = $model -> get ( 'page_chapter' ))
{
$model -> set ( 'chapter_sef' , $this -> chapters [ $chap ][ 'chapter_sef' ]);
$parent = ( int ) $this -> chapters [ $chap ][ 'chapter_parent' ];
$model -> set ( 'book_sef' , $this -> chapters [ $parent ][ 'chapter_sef' ]);
}
else
{
2014-07-09 19:24:07 +03:00
$urlData = $this -> url ;
$urlData [ 'route' ] = 'page/view/other' ;
$model -> setUrl ( $urlData );
}
2019-05-11 13:52:28 -07:00
2014-07-09 19:24:07 +03:00
}
}
2013-03-06 23:01:16 -08:00
2020-12-18 19:55:12 -08:00
function afterCreate ( $new_data , $old_data , $id )
2013-03-06 23:01:16 -08:00
{
$tp = e107 :: getParser ();
$sql = e107 :: getDb ();
$mes = e107 :: getMessage ();
2020-12-18 19:55:12 -08:00
$menu_name = $tp -> toDB ( $new_data [ '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 )
{
2015-06-19 11:26:01 +03:00
$mes -> addDebug ( CUSLAN_73 );
2013-03-06 23:01:16 -08:00
return true ;
}
}
2020-12-18 19:55:12 -08:00
return $new_data ;
2013-03-06 23:01:16 -08:00
}
2020-12-18 19:55:12 -08:00
function beforeCreate ( $new_data , $old_data )
2013-03-06 23:01:16 -08:00
{
2018-09-27 14:51:20 -07:00
2020-12-18 19:55:12 -08:00
$new_data = e107 :: getCustomFields () -> processDataPost ( 'page_fields' , $new_data );
2018-09-27 14:51:20 -07:00
2020-12-18 19:55:12 -08:00
$new_data [ 'menu_name' ] = preg_replace ( '/[^\w\-*]/' , '-' , $new_data [ 'menu_name' ]);
2016-04-01 20:29:13 -07:00
2020-12-18 19:55:12 -08:00
if ( empty ( $new_data [ 'page_sef' ]))
2013-10-28 19:40:07 -07:00
{
2020-12-18 19:55:12 -08:00
if ( ! empty ( $new_data [ 'page_title' ]))
2014-02-06 07:29:02 -08:00
{
2020-12-18 19:55:12 -08:00
$new_data [ 'page_sef' ] = eHelper :: title2sef ( $new_data [ 'page_title' ]);
2014-02-06 07:29:02 -08:00
}
2020-12-18 19:55:12 -08:00
elseif ( ! empty ( $new_data [ 'menu_name' ]))
2014-02-06 07:29:02 -08:00
{
2020-12-18 19:55:12 -08:00
$new_data [ 'page_sef' ] = eHelper :: title2sef ( $new_data [ 'menu_name' ]);
2014-02-06 07:29:02 -08:00
}
2013-10-28 19:40:07 -07:00
}
2016-04-01 20:29:13 -07:00
else
2013-10-28 19:40:07 -07:00
{
2020-12-18 19:55:12 -08:00
$new_data [ 'page_sef' ] = eHelper :: secureSef ( $new_data [ 'page_sef' ]);
2013-10-28 19:40:07 -07:00
}
2016-04-01 20:29:13 -07:00
2017-01-18 17:10:12 -08:00
2020-12-18 19:55:12 -08:00
// $new_data = $this->processCustomFieldData($new_data);
2017-01-18 17:10:12 -08:00
2020-12-18 19:55:12 -08:00
$sef = e107 :: getParser () -> toDB ( $new_data [ 'page_sef' ]);
2016-04-01 20:29:13 -07:00
2020-12-18 19:55:12 -08:00
if ( isset ( $new_data [ 'page_title' ]) && isset ( $new_data [ 'menu_name' ]) && empty ( $new_data [ 'page_title' ]) && empty ( $new_data [ 'menu_name' ]))
2016-04-01 20:29:13 -07:00
{
e107 :: getMessage () -> addError ( CUSLAN_79 );
return false ;
}
2013-10-28 19:40:07 -07:00
if ( e107 :: getDb () -> count ( 'page' , '(*)' , " page_sef=' { $sef } ' " ))
{
2015-06-19 11:26:01 +03:00
e107 :: getMessage () -> addError ( CUSLAN_57 );
2013-10-28 19:40:07 -07:00
return false ;
}
2020-12-18 19:55:12 -08:00
return $new_data ;
2013-03-06 23:01:16 -08:00
}
2020-12-18 19:55:12 -08:00
function beforeUpdate ( $new_data , $old_data , $id )
2013-03-08 21:48:49 -08:00
{
2017-01-18 17:10:12 -08:00
2020-12-18 19:55:12 -08:00
if ( isset ( $new_data [ 'page_title' ]) && isset ( $new_data [ 'menu_name' ]) && empty ( $new_data [ 'page_title' ]) && empty ( $new_data [ 'menu_name' ]))
2019-10-28 22:24:05 +03:00
{
e107 :: getMessage () -> addError ( CUSLAN_79 );
return false ;
}
2020-12-18 19:55:12 -08:00
$new_data = e107 :: getCustomFields () -> processDataPost ( 'page_fields' , $new_data );
2017-01-18 17:10:12 -08:00
2020-12-18 19:55:12 -08:00
if ( isset ( $new_data [ 'menu_name' ]))
2015-09-05 20:03:31 -07:00
{
2020-12-18 19:55:12 -08:00
$new_data [ 'menu_name' ] = preg_replace ( '/[^\w\-*]/' , '' , $new_data [ 'menu_name' ]);
2015-09-05 20:03:31 -07:00
}
2013-03-08 21:48:49 -08:00
2017-01-18 17:10:12 -08:00
2020-12-18 19:55:12 -08:00
return $new_data ;
2013-03-08 21:48:49 -08:00
}
2013-03-06 23:01:16 -08:00
// Update Menu in Menu Table
2020-12-18 19:55:12 -08:00
function afterUpdate ( $new_data , $old_data , $id )
2013-03-06 23:01:16 -08:00
{
$tp = e107 :: getParser ();
$sql = e107 :: getDb ();
$mes = e107 :: getMessage ();
2015-09-05 20:03:31 -07:00
2020-12-18 19:55:12 -08:00
if ( ! isset ( $new_data [ 'menu_name' ]))
2015-09-05 20:03:31 -07:00
{
return true ;
}
2013-10-28 19:40:07 -07:00
2020-12-18 19:55:12 -08:00
$menu_name = $tp -> toDB ( $new_data [ 'menu_name' ]); // not to be confused with menu-caption.
2013-03-06 23:01:16 -08:00
if ( $sql -> select ( 'menus' , 'menu_name' , " `menu_path` = " . $id . " LIMIT 1 " ))
{
if ( $sql -> update ( 'menus' , " menu_name=' { $menu_name } ' WHERE menu_path= " . $id . " " ) !== false )
{
2015-06-19 11:26:01 +03:00
$mes -> addDebug ( CUSLAN_74 );
2013-03-06 23:01:16 -08:00
return true ;
}
2013-12-23 03:56:25 -08:00
}
else // missing menu record so create it.
{
2015-06-19 11:26:01 +03:00
$mes -> addDebug ( CUSLAN_75 . " " . $id );
2020-12-18 19:55:12 -08:00
return $this -> afterCreate ( $new_data , $old_data , $id );
2013-12-23 03:56:25 -08:00
2013-03-06 23:01:16 -08:00
}
}
2017-01-18 17:10:12 -08:00
2015-04-09 11:25:10 -07:00
public function afterDelete ( $deleted_data , $id , $deleted_check )
2015-04-08 20:20:10 -07:00
{
2015-04-09 11:25:10 -07:00
$sql = e107 :: getDb ();
2015-04-08 20:20:10 -07:00
2015-04-09 11:25:10 -07:00
if ( $sql -> select ( 'menus' , 'menu_name' , " `menu_path` = " . $id . " LIMIT 1 " ))
{
if ( $sql -> delete ( 'menus' , " menu_path= " . intval ( $id ) . " " ) !== false )
{
2015-06-19 11:26:01 +03:00
e107 :: getMessage () -> addDebug ( CUSLAN_76 . " " . $id . " " . CUSLAN_77 );
2015-04-09 11:25:10 -07:00
return true ;
}
else
{
2015-06-19 11:26:01 +03:00
e107 :: getMessage () -> addDebug ( CUSLAN_78 . " " . $id . " . " );
2015-04-09 11:25:10 -07:00
}
}
2013-03-06 23:01:16 -08:00
2015-04-08 20:20:10 -07:00
}
2013-03-06 23:01:16 -08:00
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
2017-01-09 08:32:27 +01:00
?>