2006-12-02 04:36:16 +00:00
< ? php
/*
2008-12-29 15:23:06 +00:00
* e107 website system
*
2010-01-04 21:35:38 +00:00
* Copyright ( C ) 2008 - 2010 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
*
2011-12-09 02:08:04 +00:00
* $URL $
* $Id $
2008-12-29 15:23:06 +00:00
*
2006-12-02 04:36:16 +00:00
*/
2010-01-04 21:35:38 +00:00
/**
2010-04-17 03:17:48 +00:00
*
2010-01-04 21:35:38 +00:00
* @ package e107
* @ subpackage admin
2010-02-10 18:18:01 +00:00
* @ version $Revision $
* @ author $Author $
2006-12-02 04:36:16 +00:00
2010-01-04 21:35:38 +00:00
* Admin - related functions for custom page and menu creation
*/
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' ;
2010-01-04 21:35:38 +00:00
require_once ( e_HANDLER . 'userclass_class.php' );
require_once ( e_HANDLER . 'message_handler.php' );
require_once ( e_HANDLER . 'form_handler.php' );
2008-12-29 15:23:06 +00:00
$frm = new e_form ( true );
2012-04-19 03:53:58 +00:00
$emessage = eMessage :: getInstance ();
2012-05-31 06:07:33 +00:00
2012-04-19 03:53:58 +00:00
// $page = new page;
2008-12-29 15:23:06 +00:00
2012-04-19 03:53:58 +00:00
/*
2006-12-02 04:36:16 +00:00
if ( e_QUERY )
{
$tmp = explode ( " . " , e_QUERY );
$action = $tmp [ 0 ];
2008-12-29 15:23:06 +00:00
$sub_action = varset ( $tmp [ 1 ]);
$id = intval ( varset ( $tmp [ 2 ], 0 ));
$from = intval ( varset ( $tmp [ 3 ], 0 ));
2006-12-02 04:36:16 +00:00
}
2012-04-19 03:53:58 +00:00
*/
2006-12-02 04:36:16 +00:00
2012-04-19 03:53:58 +00:00
/*
2009-11-19 12:36:22 +00:00
if ( isset ( $_POST [ 'delete' ]) || varset ( $_POST [ 'etrigger_delete' ]))
2006-12-02 04:36:16 +00:00
{
2009-11-19 12:36:22 +00:00
if ( $_POST [ 'etrigger_delete' ])
{
2010-04-17 03:17:48 +00:00
$delArray = array_keys ( $_POST [ 'etrigger_delete' ]);
2009-11-19 12:36:22 +00:00
}
else
{
$delArray = array_keys ( $_POST [ 'delete' ]);
}
2010-04-17 03:17:48 +00:00
2009-11-19 12:36:22 +00:00
foreach ( $delArray as $pid )
2006-12-02 04:36:16 +00:00
{
2008-12-29 15:23:06 +00:00
$page -> delete_page ( $pid );
2006-12-02 04:36:16 +00:00
}
}
2012-04-19 03:53:58 +00:00
*/
2006-12-02 04:36:16 +00:00
2012-04-19 03:53:58 +00:00
/*
2006-12-02 04:36:16 +00:00
if ( ! e_QUERY )
{
2010-01-04 21:35:38 +00:00
if ( getperms ( '5' ))
2009-08-05 14:22:15 +00:00
{
$page -> showExistingPages ();
}
else
{
$page -> showExistingPages ( 'menus' );
}
2006-12-02 04:36:16 +00:00
}
2010-01-04 21:35:38 +00:00
elseif ( varset ( $_GET [ 'action' ], '' ) == 'edit' )
2009-11-19 12:36:22 +00:00
{
$action = 'create' ;
$sub_action = 'edit' ;
2009-11-25 11:54:53 +00:00
$id = intval ( $_GET [ 'id' ]);
$mod = ( vartrue ( $_GET [ 'menus' ])) ? 'menus' : " " ;
2010-04-17 03:17:48 +00:00
$page -> createPage ( $mod );
2009-11-25 11:01:12 +00:00
}
elseif ( vartrue ( $_GET [ 'menus' ]))
{
2010-04-17 03:17:48 +00:00
$page -> menusPage ();
2009-11-19 12:36:22 +00:00
}
2006-12-02 04:36:16 +00:00
else
{
2010-01-04 21:35:38 +00:00
$function = $action . 'Page' ;
2008-12-29 15:23:06 +00:00
$page -> $function ();
2006-12-02 04:36:16 +00:00
}
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 (
'controller' => 'page_admin_ui' ,
'path' => null ,
'ui' => 'page_admin_form_ui' ,
'uipath' => null
2012-05-31 06:07:33 +00:00
),
'dialog' => array (
'controller' => 'page_admin_ui' ,
'path' => null ,
'ui' => 'page_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' ),
'page/create' => array ( 'caption' => CUSLAN_12 , 'perm' => '5' ),
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
'menu/list' => array ( 'caption' => CUSLAN_49 , 'perm' => 'J' ),
2012-05-22 04:38:28 +00:00
'menu/create' => array ( 'caption' => CUSLAN_31 , 'perm' => 'J' ),
'page/options' => 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' ,
'menu/edit' => 'menu/list'
2012-04-19 03:53:58 +00:00
);
protected $menuTitle = 'Custom Pages' ;
}
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'.
2012-04-19 03:53:58 +00:00
2012-10-11 02:24:43 +00:00
class page_chapters_ui extends e_admin_ui
{
protected $pluginTitle = 'Page Chapters' ;
protected $pluginName = 'core' ;
protected $table = " page_chapters " ;
protected $pid = " chapter_id " ;
protected $perPage = 0 ; //no limit
protected $batchDelete = false ;
protected $listOrder = 'chapter_parent,chapter_order asc' ;
protected $fields = array (
'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 ),
'chapter_icon' => array ( 'title' => LAN_ICON , 'type' => 'icon' , 'data' => 'str' , 'width' => '100px' , 'thclass' => 'center' , 'class' => 'center' , 'readParms' => 'thumb=60&thumb_urlraw=0&thumb_aw=60' , 'readonly' => FALSE , 'batch' => FALSE , 'filter' => FALSE ),
'chapter_parent' => array ( 'title' => " Book " , 'type' => 'dropdown' , 'width' => 'auto' , 'thclass' => 'left' , 'readonly' => FALSE , 'filter' => true ),
'chapter_name' => array ( 'title' => " Book or Chapter Title " , 'type' => 'text' , 'width' => 'auto' , 'thclass' => 'left' , 'readonly' => FALSE ),
'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 ),
'chapter_sef' => array ( 'title' => " SEF Url String " , 'type' => 'text' , 'width' => 'auto' , 'readonly' => FALSE ), // Display name
'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' ),
'options' => array ( 'title' => LAN_OPTIONS , 'type' => null , 'width' => '10%' , 'forced' => TRUE , 'thclass' => 'center last' , 'class' => 'center' )
);
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' );
protected $books = array ();
function init ()
{
$sql = e107 :: getDb ();
$sql -> db_Select_gen ( " SELECT chapter_id,chapter_name FROM #page_chapters WHERE chapter_parent =0 " );
$this -> books [ 0 ] = " (New Book) " ;
while ( $row = $sql -> db_Fetch ())
{
$bk = $row [ 'chapter_id' ];
$this -> books [ $bk ] = $row [ 'chapter_name' ];
}
asort ( $this -> books );
$this -> fields [ 'chapter_parent' ][ 'writeParms' ] = $this -> books ;
}
// function createPage()
// {
// $this->newspost->show_categories();
// }
public function beforeCreate ( $new_data )
{
}
public function beforeUpdate ( $new_data , $old_data , $id )
{
}
}
class page_chapters_form_ui extends e_admin_form_ui
{
}
2012-04-19 03:53:58 +00:00
class page_admin_ui extends e_admin_ui
{
protected $pluginTitle = ADLAN_42 ;
protected $pluginName = 'core' ;
protected $table = " page " ;
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_theme = '' " ; // without any Order or Limit.
//protected $editQry = "SELECT * FROM #comments WHERE comment_id = {ID}";
protected $pid = " page_id " ;
2012-10-11 02:24:43 +00:00
protected $listOrder = 'p.page_order asc' ; // desc would require changes to ajax sorting.
2012-04-19 03:53:58 +00:00
protected $perPage = 10 ;
protected $batchDelete = true ;
protected $batchCopy = true ;
2012-10-11 02:24:43 +00:00
// protected $listSorting = true;
2012-04-19 03:53:58 +00:00
protected $fields = array (
'checkboxes' => array ( 'title' => '' , 'type' => null , 'width' => '5%' , 'forced' => TRUE , 'thclass' => 'center' , 'class' => 'center' ),
'page_id' => array ( 'title' => 'ID' , 'width' => '5%' , 'forced' => TRUE ),
2012-10-11 02:24:43 +00:00
'page_chapter' => array ( 'title' => 'Book/Chapter' , 'type' => 'dropdown' , 'width' => '10%' , 'filter' => true , 'batch' => true ),
'page_title' => array ( 'title' => LAN_TITLE , 'type' => 'text' , 'width' => '25%' , 'readParms' => 'link={e_BASE}page.php?[id]&dialog=1' ),
2012-04-19 03:53:58 +00:00
'page_theme' => array ( 'title' => CUSLAN_2 , 'type' => 'text' , 'width' => 'auto' , 'nolist' => true ),
2012-10-11 02:24:43 +00:00
'page_template' => array ( 'title' => 'Template' , 'type' => 'text' , 'width' => 'auto' , 'filter' => true , 'batch' => true ),
2012-04-19 03:53:58 +00:00
'page_author' => array ( 'title' => LAN_AUTHOR , 'type' => 'user' , 'width' => 'auto' , 'thclass' => 'left' ),
'page_datestamp' => array ( 'title' => LAN_DATE , 'type' => 'datestamp' , 'width' => 'auto' ),
'page_class' => array ( 'title' => LAN_USERCLASS , 'type' => 'userclass' , 'width' => 'auto' , 'filter' => true , 'batch' => true ),
2012-10-11 02:24:43 +00:00
'page_rating_flag' => array ( 'title' => LAN_RATING , 'type' => 'boolean' , 'width' => '5%' , 'thclass' => 'center' , 'class' => 'center' ),
'page_comment_flag' => array ( 'title' => ADLAN_114 , 'type' => 'boolean' , 'width' => '5%' , 'thclass' => 'center' , 'class' => 'center' ),
// 'page_password' => array('title'=> LAN_USER_05, 'type' => 'text', 'width' => 'auto'),
'page_order' => array ( 'title' => LAN_ORDER , 'type' => 'number' , 'width' => 'auto' , 'nolist' => true ),
2012-04-19 03:53:58 +00:00
// 'page_ip_restrict' => array('title'=> LAN_USER_07, 'type' => 'text', 'width' => 'auto'), // Avatar
2012-10-11 02:24:43 +00: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
);
protected $fieldpref = array ( " page_id " , " page_title " , " page_template " , " page_author " , " page_class " );
2012-10-11 02:24:43 +00:00
protected $books = array ();
protected $cats = array ();
2012-04-19 03:53:58 +00:00
function init ()
{
2012-07-22 11:14:29 +00:00
2012-10-11 02:24:43 +00:00
if ( e_AJAX_REQUEST ) // ajax sorting.
{
$sql = e107 :: getDb ();
$c = ( $_GET [ 'from' ]) ? intval ( $_GET [ 'from' ]) : 0 ;
if ( isset ( $_POST [ 'all' ]))
{
foreach ( $_POST [ 'all' ] as $row )
{
list ( $tmp , $id ) = explode ( " - " , $row );
$sql -> db_Update ( " page " , " page_order = " . intval ( $c ) . " WHERE page_id = " . intval ( $id ));
$c ++ ;
}
}
// echo "<script>alert('hello');</script>";
exit ;
}
$sql = e107 :: getDb ();
$sql -> db_Select_gen ( " SELECT chapter_id,chapter_name,chapter_parent FROM #page_chapters ORDER BY chapter_parent asc " );
while ( $row = $sql -> db_Fetch ())
{
$cat = $row [ 'chapter_id' ];
if ( $row [ 'chapter_parent' ] == 0 )
{
$this -> books [ $cat ] = $row [ 'chapter_name' ];
}
else
{
$book = $row [ 'chapter_parent' ];
$this -> cats [ $cat ] = $this -> books [ $book ] . " : " . $row [ 'chapter_name' ];
}
}
asort ( $this -> cats );
$this -> fields [ 'page_chapter' ][ 'writeParms' ] = $this -> cats ;
2012-07-22 11:14:29 +00:00
if ( varset ( $_GET [ 'mode' ]) == 'dialog' && varset ( $_GET [ 'action' ]) == 'dialog' ) // New Page bbcode in tabs.
{
$this -> dialogPage ();
}
2012-05-31 06:07:33 +00:00
if ( $this -> getQuery ( 'iframe' ) == 1 )
{
$this -> getResponse () -> setIframeMod ();
}
2012-05-22 04:38:28 +00:00
//FIXME - mode not retained after using drop-down 'filter' or 'search'.
if ( $_GET [ 'mode' ] == 'menu' )
2012-04-19 03:53:58 +00: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.page_theme != '' " ; // without any Order or Limit.
}
if ( isset ( $_POST [ 'uploadfiles' ]))
{
$this -> uploadPage ();
$id = intval ( varset ( $_POST [ 'pe_id' ], 0 ));
$sub_action = ( $_POST [ 'pe_id' ]) ? " edit " : " " ;
$this -> createPage ( $_POST [ 'mode' ]);
}
if ( isset ( $_POST [ 'saveOptions' ]))
{
$this -> saveSettings ();
}
if ( isset ( $_POST [ 'submitPage' ]))
{
$this -> submitPage ();
}
if ( isset ( $_POST [ 'submitMenu' ]))
{
$this -> submitPage ( " " , TRUE );
}
if ( isset ( $_POST [ 'updateMenu' ]))
{
$this -> submitPage ( $_POST [ 'pe_id' ], TRUE );
}
if ( isset ( $_POST [ 'updatePage' ]))
{
$this -> submitPage ( $_POST [ 'pe_id' ]);
}
}
// Create Menu Page.
function createemPage ()
{
if ( ! getperms ( " J " )){ return ; }
$this -> createPage ( 'menu' );
}
2012-05-31 06:07:33 +00:00
function dialogPage () // FIXME - remove table-rendering when using 'return' ??
{
2012-07-22 11:14:29 +00:00
$count = varset ( $_GET [ 'count' ]);
2012-05-31 06:07:33 +00:00
$frm = e107 :: getForm ();
2012-08-11 05:00:50 +00:00
$text = " <fieldset id='page_ { $count } '> \n " ;
2012-05-31 06:07:33 +00:00
$text .= " <div>Title: " . $frm -> text ( 'page_subtitle[]' , '' , 250 ) . " </div> \n " ;
2012-08-11 05:00:50 +00:00
$text .= $frm -> bbarea ( 'data_' . ( intval ( $count )), '' , 'page' , 'page' , 'large' );
2012-05-31 06:07:33 +00:00
$text .= " </fieldset> " ;
2012-08-11 05:00:50 +00:00
// $text .= 'name='.$nm."<br />page=".$page."<br />help_mode=". $help_mod."<br />htlp_tagid=".$help_tagid."<br />size=".$size;
2012-05-31 06:07:33 +00:00
echo $text ;
exit ;
// return $text;
2012-07-23 02:25:17 +00:00
/*
< div class = 'bbcode large' >
*/
2012-05-31 06:07:33 +00:00
}
2012-04-19 03:53:58 +00:00
// Create Page Page.
function createPage ( $mode = FALSE )
{
/* mode: FALSE == page, mode: TRUE == menu */
2012-05-22 04:38:28 +00:00
if ( $_GET [ 'mode' ] == 'menu' )
{
$mode = TRUE ;
}
2012-04-19 03:53:58 +00:00
global $e107 , $e_userclass , $e_event ;
$frm = e107 :: getForm ();
$sql = e107 :: getDb ();
$tp = e107 :: getParser ();
$ns = e107 :: getRender ();
$mes = e107 :: getMessage ();
$id = intval ( $_GET [ 'id' ]);
$sub_action = $_GET [ 'action' ];
$edit = ( $sub_action == 'edit' );
$caption = ( ! $mode ? ( $edit ? CUSLAN_23 : CUSLAN_24 ) : ( $edit ? CUSLAN_25 : CUSLAN_26 ));
2012-05-22 04:38:28 +00:00
if ( $_GET [ 'action' ] == " edit " && ! isset ( $_POST [ 'preview' ]) && ! isset ( $_POST [ 'submit' ]))
2012-04-19 03:53:58 +00:00
{
//$url = e107::getUrl()->sc('page/view', $row, 'allow=page_id,page_title,page_sef');
//$query = "SELECT p.*,l.link_name,m.menu_name FROM #page AS p
$query = " SELECT p.* FROM #page AS p
LEFT JOIN #menus AS m ON m.menu_path='{$id}' WHERE p.page_id ='{$id}' LIMIT 1";
// FIXME - extremely bad
//LEFT JOIN #links AS l ON l.link_url='".$url."'
if ( $sql -> db_Select_gen ( $query ))
{
$row = $sql -> db_Fetch ();
$page_class = $row [ 'page_class' ];
$page_password = $row [ 'page_password' ];
$page_title = $tp -> toForm ( $row [ 'page_title' ]);
$page_rating_flag = $row [ 'page_rating_flag' ];
$page_comment_flag = $row [ 'page_comment_flag' ];
$page_display_authordate_flag = $row [ 'page_author' ];
$page_link = varset ( $row [ 'link_name' ], '' );
$data = $tp -> toForm ( $row [ 'page_text' ]);
$edit = TRUE ;
// $menu_name = $tp->toForm($row['menu_name']);
$menu_name = $tp -> toForm ( $row [ 'page_theme' ]);
}
}
else
{
$menu_name = '' ;
$page_title = '' ;
$data = '' ;
}
$e_qry = ( $mode ) ? 'menus=1' : '' ;
$text = "
< form method = 'post' action = '".e_SELF."?".$e_qry."' id = 'dataform' enctype = 'multipart/form-data' >
< fieldset id = 'core-cpage-create-general' >
< legend " .( $mode ? " class = 'e-hideme' " : " " ). " > " .CUSLAN_47. " </ legend >
2012-11-27 14:32:40 -08:00
< table class = 'table adminform' >
2012-05-13 05:26:11 +00:00
< colgroup >
2012-04-19 03:53:58 +00:00
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
< tbody >
" ;
if ( $mode ) // menu mode.
{
$text .= "
< tr >
< td > " .CUSLAN_7. " </ td >
< td > " . $frm->text ('menu_name', $menu_name , 50). " </ td >
</ tr >
" ;
}
else
{
2012-10-11 02:24:43 +00:00
$text .= "
< tr >
< td > Chapter </ td >
< td > " . $frm->selectbox ('page_chapter', $this->cats , $row['page_chapter'] ) . " </ td >
</ tr >
" ;
2012-04-19 03:53:58 +00:00
// fixed - last parameter (allinfo) should be false as getLayout method is returning non-usable formatted array
$templates = e107 :: getLayouts ( '' , 'page' , 'front' , '' , false , false );
2012-12-16 20:59:14 -08:00
// $templates['menu'] = "Sidebar"; // ie. a MENU item. //TODO
2012-04-19 03:53:58 +00:00
$text .= "
< tr >
< td > Template </ td >
< td > " . $frm->selectbox ('page_template', $templates , $row['page_template'] ) . " </ td >
</ tr >
" ;
2012-10-11 02:24:43 +00:00
2012-04-19 03:53:58 +00:00
}
$text .= "
< tr >
< td > " .CUSLAN_8. " </ td >
< td > " . $frm->text ('page_title', $page_title , 250). " </ td >
</ tr >
" ;
if ( ! $mode )
{
$text .= "
< tr >
< td > " .CUSLAN_3. " </ td >
< td > " . $frm->text ('page_sef', $row['page_sef'] , 250). " </ td >
</ tr >
" ;
$text .= "
< tr >
< td > " .CUSLAN_32. " </ td >
< td > " . $frm->text ('page_metakeys', $row['page_metakeys'] , 250). " </ td >
</ tr >
" ;
$text .= "
< tr >
< td > " .CUSLAN_11. " </ td >
2012-05-29 08:39:19 +00:00
< td > " . $frm->textarea ('page_metadscr', $row['page_metadscr'] , 1, 80, array(), 200). " </ td >
2012-04-19 03:53:58 +00:00
</ tr >
" ;
}
$text .= "
< tr >
2012-11-30 14:28:07 -08:00
< td colspan = '2' >
2012-04-19 03:53:58 +00:00
" ;
2012-05-29 08:56:08 +00:00
2012-11-30 14:28:07 -08:00
$text .= " <div id='tab-container' class='admintabs e-tabs'>
< ul >
< li >< a href = '#cpage-body-container' > " .CUSLAN_9. " </ a ></ li >
</ ul >
< div id = 'cpage-body-container' > " ;
2012-05-29 08:39:19 +00:00
$data = $tp -> toForm ( $data , FALSE , TRUE ); // Make sure we convert HTML tags to entities
2012-04-19 03:53:58 +00:00
2012-05-29 08:39:19 +00:00
$textareaValue = ( strstr ( $data , " [img]http " ) ? $data : str_replace ( " [img]../ " , " [img] " , $data ));
2012-04-19 03:53:58 +00:00
2012-10-11 02:24:43 +00:00
// $text .= $this->bbareaMulti('data', $textareaValue, 'page','page','large');
$text .= $frm -> bbarea ( 'data' , $textareaValue , 'page' , 'page' , 'large' );
2012-11-30 14:28:07 -08:00
$text .= " </div></div> " ;
2012-05-31 06:07:33 +00:00
2012-05-29 08:39:19 +00:00
// $text .= $frm->bbarea('data', $textareaValue, 'page','help','large');
2012-04-19 03:53:58 +00:00
2012-05-31 06:07:33 +00:00
2012-04-19 03:53:58 +00:00
// $text .= "<textarea class='e-wysiwyg tbox' tabindex='".$frm->getNext()."' id='data' name='data' cols='80'{$insertjs}>".(strstr($data, "[img]http") ? $data : str_replace("[img]../", "[img]", $data))."</textarea>";
// <br />".display_help('cpage-help', 'cpage')."
2012-05-22 04:38:28 +00:00
/*
2012-04-19 03:53:58 +00:00
$text .= " </td>
</ tr >
< tr >
2012-11-26 14:41:32 -08:00
< td > " .LAN_UPLOAD_IMAGES. " </ td >
< td > " . $tp->parseTemplate ( " { UPLOADFILE = " .e_IMAGE. " custom / } " ). " </ td >
2012-04-19 03:53:58 +00:00
</ tr >
" ;
2012-05-22 04:38:28 +00:00
*/
2012-04-19 03:53:58 +00:00
if ( ! $mode )
{
$text .= "
</ tbody >
</ table >
</ fieldset >
< fieldset id = 'core-cpage-create-options' >
< legend > " .LAN_OPTIONS. " </ legend >
2012-11-30 14:28:07 -08:00
< table class = 'table adminform options' >
2012-05-13 05:26:11 +00:00
< colgroup >
2012-04-19 03:53:58 +00:00
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
< tbody >
< tr >
2012-11-26 14:41:32 -08:00
< td > " .CUSLAN_10. " </ td >
< td >
2012-04-19 03:53:58 +00:00
" . $frm->radio_switch ('page_rating_flag', $page_rating_flag ). "
</ td >
</ tr >
< tr >
2012-11-26 14:41:32 -08:00
< td > " .CUSLAN_13. " </ td >
< td >
2012-04-19 03:53:58 +00:00
" . $frm->radio_switch ('page_comment_flag', $page_comment_flag ). "
</ td >
</ tr >
< tr >
2012-11-26 14:41:32 -08:00
< td > " .CUSLAN_41. " </ td >
< td >
2012-04-19 03:53:58 +00:00
" . $frm->radio_switch ('page_display_authordate_flag', $page_display_authordate_flag ). "
</ td >
</ tr >
< tr >
2012-11-26 14:41:32 -08:00
< td > " .CUSLAN_14. " </ td >
< td >
2012-04-19 03:53:58 +00:00
" . $frm->text ('page_password', $page_password , 50). "
< div class = 'field-help' > " .CUSLAN_15. " </ div >
</ td >
</ tr >
< tr >
2012-11-26 14:41:32 -08:00
< td > " .CUSLAN_18. " </ td >
2012-04-19 03:53:58 +00:00
2012-11-26 14:41:32 -08:00
< td >
2012-04-19 03:53:58 +00:00
" . $e_userclass->uc_dropdown ('page_class', $page_class , 'public,guest,nobody,member,main,admin,classes', " tabindex = '".$frm->getNext()."' " ). "
</ td >
</ tr >
" ;
/*
< tr >
2012-11-26 14:41:32 -08:00
< td > " .CUSLAN_16. " </ td >
< td >
2012-04-19 03:53:58 +00:00
" . $frm->text ('page_link', $page_link , 50). "
< div class = 'field-help' > " .CUSLAN_17. " </ div >
</ td >
</ tr >
**/
//triggerHook
2012-11-30 20:47:26 -08:00
2012-11-30 14:28:07 -08:00
$data = array (
'method' => 'form' ,
'table' => 'page' ,
'id' => $id ,
'plugin' => 'page' ,
'function' => 'createPage'
);
2012-11-30 20:47:26 -08:00
$text .= $frm -> renderHooks ( $data );
2012-04-19 03:53:58 +00:00
}
2012-11-30 20:47:26 -08:00
2012-04-19 03:53:58 +00:00
$text .= "
</ tbody >
</ table >
< div class = 'buttons-bar center' >
" .
( ! $mode ?
( $edit ? $frm -> admin_button ( 'updatePage' , CUSLAN_19 , 'update' ) . " <input type='hidden' name='pe_id' value=' { $id } ' /> " : $frm -> admin_button ( 'submitPage' , CUSLAN_20 , 'create' )) :
( $edit ? $frm -> admin_button ( 'updateMenu' , CUSLAN_21 , 'update' ) . " <input type='hidden' name='pe_id' value=' { $id } ' /> " : $frm -> admin_button ( 'submitMenu' , CUSLAN_22 , 'create' )))
. "
< input type = 'hidden' name = 'mode' value = '{$mode}' />
</ div >
</ fieldset >
</ form >
" ;
// $ns->tablerender($caption, $text);
echo $mes -> render () . $text ;
}
2012-05-29 08:39:19 +00:00
// bbarea($name, $value, $help_mod = '', $help_tagid='', $size = 'large', $counter = false)
function bbareaMulti ( $name , $textareaValue , $help_mod = '' , $help_tagid = '' , $size = 'large' , $counter = false )
{
2012-07-09 01:54:43 +00:00
// $name = $name."[]";
2012-05-29 08:39:19 +00:00
$frm = e107 :: getForm ();
if ( ! $textareaValue )
{
2012-10-11 02:24:43 +00:00
// $textareaValue = "[newpage] ";
2012-05-29 08:39:19 +00:00
}
if ( preg_match_all ( " / \ [newpage=?(.*?) \ ]/si " , $textareaValue , $pt ))
{
}
$pages = preg_split ( " / \ [newpage(.*?) \ ]/si " , $textareaValue , - 1 , PREG_SPLIT_NO_EMPTY );
2012-08-11 05:00:50 +00:00
$c = 1 ;
2012-05-29 08:39:19 +00:00
$titles [ 0 ] = " " ;
2012-08-11 05:00:50 +00:00
2012-05-29 08:56:08 +00:00
$text .= " <ul class='e-tabs'> " ;
2012-05-29 08:39:19 +00:00
foreach ( $pages as $page )
{
$id = " #page_ " . $c ;
2012-08-11 05:00:50 +00:00
$pageCap = " Page " . ( $c );
2012-08-11 11:15:05 +00:00
$text .= " <li><a href=' { $id } ' > { $pageCap } </a></li> " ;
2012-05-29 08:39:19 +00:00
$c ++ ;
}
$text .= " </ul> " ;
2012-08-11 05:00:50 +00:00
$c = 1 ;
foreach ( $pages as $curval )
2012-05-29 08:39:19 +00:00
{
2012-08-11 05:00:50 +00:00
$titles [] = isset ( $pt [ 1 ][( $c - 1 )]) ? $pt [ 1 ][( $c - 1 )] : " " ;
2012-05-29 08:39:19 +00:00
$id = " page_ " . $c ;
2012-07-09 01:54:43 +00:00
$nm = $name . " _ " . $c ;
2012-05-29 08:56:08 +00:00
$text .= " <fieldset id=' { $id } '> \n " ;
2012-08-11 05:00:50 +00:00
$text .= " <div>Title: " . $frm -> text ( 'page_subtitle[' . $c . ']' , $titles [( $c )], 250 ) . " </div> \n " ;
$text .= $frm -> bbarea ( $nm , $curval , $help_mod , $help_tagid , $size , $counter );
2012-08-11 11:15:05 +00:00
2012-05-29 08:56:08 +00:00
$text .= " </fieldset> " ;
2012-08-11 11:15:05 +00:00
2012-08-11 05:00:50 +00:00
// $text .= 'name='.$nm."<br />page=".$page."<br />help_mode=". $help_mod."<br />htlp_tagid=".$help_tagid."<br />size=".$size;
2012-05-29 08:39:19 +00:00
$c ++ ;
}
2012-08-11 11:15:05 +00:00
$text .= " <button class='e-bb e-tabs-add' data-target=' $name ' data-url=' " . e_SELF . " ?mode=dialog&action=dialog&iframe=1' data-function='add' href='#' data-bbcode=''><span>New Page</span></button> " ;
2012-08-11 05:00:50 +00:00
$text .= " <input type='hidden' id='e-tab-count' value=' " . count ( $pages ) . " ' /> " ;
2012-05-29 08:39:19 +00:00
return $text ;
}
2012-04-19 03:53:58 +00:00
function optionsPage ()
{
global $e107 , $pref ;
$ns = e107 :: getRender ();
$mes = e107 :: getMessage ();
$frm = e107 :: getForm ();
$sql = e107 :: getDb ();
$tp = e107 :: getParser ();
if ( ! isset ( $pref [ 'pageCookieExpire' ])) $pref [ 'pageCookieExpire' ] = 84600 ;
//XXX Lan - Options
$text = "
< form method = 'post' action = '".e_SELF."?".e_QUERY."' >
< fieldset id = 'core-cpage-options' >
< legend class = 'e-hideme' > " .LAN_OPTIONS. " </ legend >
2012-11-26 14:41:32 -08:00
< table class = 'table adminform' >
2012-05-13 05:26:11 +00:00
< colgroup >
2012-04-19 03:53:58 +00:00
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
< tbody >
< tr >
2012-11-26 14:41:32 -08:00
< td > " .CUSLAN_29. " </ td >
< td >
2012-04-19 03:53:58 +00:00
" . $frm->radio_switch ('listPages', $pref['listPages'] ). "
</ td >
</ tr >
< tr >
2012-11-26 14:41:32 -08:00
< td > " .CUSLAN_30. " </ td >
< td >
2012-04-19 03:53:58 +00:00
" . $frm->text ('pageCookieExpire', $pref['pageCookieExpire'] , 10). "
</ td >
</ tr >
</ tbody >
</ table >
< div class = 'buttons-bar center' >
" . $frm->admin_button ('saveOptions', CUSLAN_40, 'submit'). "
</ div >
</ fieldset >
</ form >
" ;
//$ns->tablerender(LAN_OPTIONS, $mes->render().$text);
echo $mes -> render () . $text ;
}
function saveSettings ()
{
global $pref , $admin_log , $emessage ;
$temp [ 'listPages' ] = $_POST [ 'listPages' ];
$temp [ 'pageCookieExpire' ] = $_POST [ 'pageCookieExpire' ];
if ( $admin_log -> logArrayDiffs ( $temp , $pref , 'CPAGE_04' ))
{
save_prefs (); // Only save if changes
$emessage -> add ( LAN_SETSAVED , E_MESSAGE_SUCCESS );
}
else
{
$emessage -> add ( LAN_NOCHANGE_NOTSAVED );
}
}
// Write new/edited page/menu to the DB
// $mode - zero for new page, page id for existing
// $type = FALSE for page, TRUE for menu
function submitPage ( $mode = FALSE , $type = FALSE )
{
global $e107cache , $admin_log , $e_event ;
$frm = e107 :: getForm ();
$sql = e107 :: getDb ();
$tp = e107 :: getParser ();
$ns = e107 :: getRender ();
$mes = e107 :: getMessage ();
$page_title = $tp -> toDB ( $_POST [ 'page_title' ]);
2012-05-29 08:39:19 +00:00
2012-12-12 02:23:56 -08:00
// print_a($_POST);
2012-07-09 01:54:43 +00:00
2012-05-29 08:39:19 +00:00
// if(is_array($_POST['data']) && is_array($_POST['subtitle']))
2012-08-30 13:52:36 +00:00
$newData = array ();
2012-07-09 01:54:43 +00:00
foreach ( $_POST as $k => $v )
2012-05-29 08:39:19 +00:00
{
2012-07-23 02:25:17 +00:00
if ( substr ( $k , 0 , 4 ) == 'data' && trim ( $v ) != '' )
2012-05-29 08:39:19 +00:00
{
2012-07-09 01:54:43 +00:00
list ( $tm , $key ) = explode ( " _ " , $k );
2012-10-11 02:24:43 +00:00
if ( $mode == FALSE ) // Pages only, not menus.
2012-08-15 09:26:00 +00:00
{
2012-12-12 02:23:56 -08:00
// $newData[] = "[newpage=".$_POST['page_subtitle'][$key]."]\n";
2012-08-15 09:26:00 +00:00
}
2012-08-30 13:52:36 +00:00
$newData [] = $v ;
2012-05-29 08:39:19 +00:00
}
2012-07-09 01:54:43 +00:00
2012-05-29 08:39:19 +00:00
// return;
}
2012-07-22 11:14:29 +00:00
2012-10-11 02:24:43 +00:00
2012-08-11 05:00:50 +00:00
// return;
2012-08-30 13:52:36 +00:00
$newData = implode ( " \n \n " , $newData );
2012-10-11 02:24:43 +00:00
// echo nl2br($newData);
2012-05-29 08:39:19 +00:00
$page_text = $tp -> toDB ( $newData );
2012-04-19 03:53:58 +00:00
$pauthor = ( $_POST [ 'page_display_authordate_flag' ] ? USERID : 0 ); // Ideally, this check should be done in the front-end.
$update = 0 ; // Make sure some updates happen
$page_sef = '' ;
$page_metad = '' ;
$page_metak = '' ;
if ( ! $type )
{
if ( ! empty ( $_POST [ 'page_sef' ]))
{
$page_sef = eHelper :: secureSef ( $_POST [ 'page_sef' ]);
}
if ( empty ( $page_sef ))
{
$page_sef = eHelper :: title2sef ( $_POST [ 'page_title' ]);
}
if ( ! empty ( $_POST [ 'page_metadscr' ]))
{
$page_metad = $tp -> toDB ( eHelper :: formatMetaDescription ( $_POST [ 'page_metadscr' ]));
}
if ( ! empty ( $_POST [ 'page_metakeys' ]))
{
$page_metak = eHelper :: formatMetaKeys ( $_POST [ 'page_metakeys' ]);
}
}
if ( ! $type && ( ! $page_title || ! $page_sef ))
{
e107 :: getMessage () -> addError ( CUSLAN_34 , 'default' , true );
2012-08-19 02:33:43 +00:00
2012-04-19 03:53:58 +00:00
e107 :: getRedirect () -> redirect ( e_ADMIN_ABS . 'cpage.php' );
}
2012-08-19 02:33:43 +00:00
// FIXME Causes false positives on Update.. - what is trying to be achieved with this check?
/*
if ( ! $type && $sql -> db_Count ( 'page' , '(page_id)' , ( $mode ? " page_id != { $mode } AND " : '' ) . " page_sef != ' { $page_sef } ' " ))
2012-04-19 03:53:58 +00:00
{
e107 :: getMessage () -> addError ( CUSLAN_34 , 'default' , true );
2012-08-19 02:33:43 +00:00
e107 :: getMessage () -> addDebug ( " type= " . $type , 'default' , true );
e107 :: getMessage () -> addDebug ( " page_title= " . $page_title , 'default' , true );
e107 :: getMessage () -> addDebug ( " page_sef= " . $page_sef , 'default' , true );
e107 :: getMessage () -> addDebug ( " Mode= " . $mode , 'default' , true );
2012-04-19 03:53:58 +00:00
e107 :: getRedirect () -> redirect ( e_ADMIN_ABS . 'cpage.php' );
}
2012-08-19 02:33:43 +00:00
*/
2012-04-19 03:53:58 +00:00
if ( $type && empty ( $_POST [ 'menu_name' ]))
{
e107 :: getMessage () -> addError ( CUSLAN_36 , 'default' , true );
e107 :: getRedirect () -> redirect ( e_ADMIN_ABS . 'cpage.php' );
}
if ( $mode )
{ // Saving existing page/menu after edit
// Don't think $_POST['page_ip_restrict'] is ever set.
$menuname = ( $type && vartrue ( $_POST [ 'menu_name' ]) ? " , page_theme = ' " . $tp -> toDB ( $_POST [ 'menu_name' ]) . " ' " : " " );
2012-10-11 02:24:43 +00:00
$status = $sql -> db_Update ( " page " , " page_title=' { $page_title } ', page_sef=' { $page_sef } ', page_chapter=' " . intval ( $_POST [ 'page_chapter' ]) . " ', page_metakeys=' { $page_metak } ', page_metadscr=' { $page_metad } ', page_text=' { $page_text } ', page_datestamp=' " . time () . " ', page_author=' { $pauthor } ', page_rating_flag=' " . intval ( $_POST [ 'page_rating_flag' ]) . " ', page_comment_flag=' " . intval ( $_POST [ 'page_comment_flag' ]) . " ', page_password=' " . $_POST [ 'page_password' ] . " ', page_class=' " . $_POST [ 'page_class' ] . " ', page_ip_restrict=' " . varset ( $_POST [ 'page_ip_restrict' ], '' ) . " ', page_template=' " . $_POST [ 'page_template' ] . " ' { $menuname } WHERE page_id=' { $mode } ' " ) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR ;
2012-04-19 03:53:58 +00:00
if ( $status == E_MESSAGE_SUCCESS ) $update ++ ;
$mes -> add ( $message , $status );
$admin_log -> log_event ( 'CPAGE_02' , $mode . '[!br!]' . $page_title . '[!br!]' . $pauthor , E_LOG_INFORMATIVE , '' );
$e107cache -> clear ( " page_ { $mode } " );
$e107cache -> clear ( " page-t_ { $mode } " );
$data = array ( 'method' => 'update' , 'table' => 'page' , 'id' => $mode , 'plugin' => 'page' , 'function' => 'submitPage' );
$this -> message = $e_event -> triggerHook ( $data );
if ( $type )
{
$menu_name = $tp -> toDB ( $_POST [ 'menu_name' ]); // not to be confused with menu-caption.
// Need to check whether menu already in table, else we can't distinguish between a failed update and no update needed
if ( $sql -> db_Select ( 'menus' , 'menu_name' , " `menu_path` = ' { $mode } ' " ))
{ // Updating existing entry
if ( $sql -> db_Update ( 'menus' , " menu_name=' { $menu_name } ' WHERE menu_path=' { $mode } ' " ) !== FALSE )
{
$update ++ ;
}
}
}
//$url = e107::getUrl()->sc('page/view', array('name' => $tp->post_toForm($_POST['page_title']), 'id' => $mode));
/*
2012-05-29 08:39:19 +00:00
// Prevent links being updated in another language unless the table is present.
if ((( $pref [ 'sitelanguage' ] != $sql -> mySQLlanguage ) && ( $sql -> mySQLlanguage != '' )) && ( $sql -> db_IsLang ( " links " ) == 'links' ))
{
//echo "DISABLED LINK CREATION";
//echo ' Sitelan='.$pref['sitelanguage'];
//echo " Dblang=".$sql->mySQLlanguage;
//echo " Links=".$sql->db_IsLang("links");
return ;
}
2012-04-19 03:53:58 +00:00
if ( $_POST [ 'page_link' ])
{
// FIXME extremely ugly, just join on created link ID by new field page_link
if ( $sql -> db_Select ( " links " , " link_id " , " link_url=' " . $url . " ' && link_name!=' " . $tp -> toDB ( $_POST [ 'page_link' ]) . " ' " ))
{
$sql -> db_Update ( " links " , " link_name=' " . $tp -> toDB ( $_POST [ 'page_link' ]) . " ' WHERE link_url=' " . $url . " ' " );
$update ++ ;
$e107cache -> clear ( " sitelinks " );
}
else if ( ! $sql -> db_Select ( " links " , " link_id " , " link_url=' " . $url . " ' " ))
{
$sql -> db_Insert ( " links " , " 0, ' " . $tp -> toDB ( $_POST [ 'page_link' ]) . " ', ' " . $url . " ', '', '', 1, 0, 0, 0, " . $_POST [ 'page_class' ]);
$update ++ ;
$e107cache -> clear ( " sitelinks " );
}
} else {
if ( $sql -> db_Select ( " links " , " link_id " , " link_url=' " . $url . " ' " ))
{
$sql -> db_Delete ( " links " , " link_url=' " . $url . " ' " );
$update ++ ;
$e107cache -> clear ( " sitelinks " );
}
} */
2012-05-27 10:42:16 +00:00
$mes = e107 :: getMessage ();
2012-12-06 20:34:57 -08:00
$mes -> addAuto ( $update , 'update' , LAN_UPDATED , false , false ); // Display result of update
2012-04-19 03:53:58 +00:00
}
else
{ // New page/menu
$menuname = ( $type ? $tp -> toDB ( $_POST [ 'menu_name' ]) : " " );
$addMsg = ( $type ? CUSLAN_51 : CUSLAN_27 );
$info = array (
'page_title' => $page_title ,
'page_sef' => $page_sef ,
2012-10-11 02:24:43 +00:00
'page_chapter' => varset ( $_POST [ 'page_chapter' ], 0 ),
2012-04-19 03:53:58 +00:00
'page_metakeys' => $page_metak ,
'page_metadscr' => $page_metad ,
'page_text' => $page_text ,
'page_author' => $pauthor ,
'page_datestamp' => time (),
'page_rating_flag' => varset ( $_POST [ 'page_rating_flag' ], 0 ),
'page_comment_flag' => varset ( $_POST [ 'page_comment_flag' ], '' ),
'page_password' => varset ( $_POST [ 'page_password' ], '' ),
'page_class' => varset ( $_POST [ 'page_class' ], e_UC_PUBLIC ),
'page_ip_restrict' => '' ,
'page_theme' => $menuname ,
'page_template' => varset ( $_POST [ 'page_template' ], '' )
);
2012-12-06 20:34:57 -08:00
$pid = e107 :: getMessage () -> addAuto ( $sql -> db_Insert ( 'page' , $info ), 'insert' , $addMsg , LAN_CREATED_FAILED , false );
2012-04-19 03:53:58 +00:00
$admin_log -> log_event ( 'CPAGE_01' , $menuname . '[!br!]' . $page_title . '[!br!]' . $pauthor , E_LOG_INFORMATIVE , '' );
if ( $type )
{
$info = array (
'menu_name' => $menuname ,
'menu_location' => 0 ,
'menu_order' => 0 ,
'menu_class' => '0' ,
'menu_pages' => '' ,
'menu_path' => $pid ,
);
2012-12-06 20:34:57 -08:00
e107 :: getMessage () -> addAuto ( $sql -> db_Insert ( 'menus' , $info ), 'insert' , CUSLAN_52 , LAN_CREATED_FAILED , false );
2012-04-19 03:53:58 +00:00
}
/* if ( vartrue ( $_POST [ 'page_link' ]))
{
//$link = 'page.php?'.$pid;
$url = e107 :: getUrl () -> sc ( 'page/view' , array ( 'name' => $tp -> post_toForm ( $_POST [ 'page_title' ]), 'id' => $pid ));
if ( ! $sql -> db_Select ( " links " , " link_id " , " link_name=' " . $tp -> toDB ( $_POST [ 'page_link' ]) . " ' " ))
{
$linkname = $tp -> toDB ( $_POST [ 'page_link' ]);
$sql -> db_Insert ( " links " , " 0, ' { $linkname } ', ' { $url } ', '', '', 1, 0, 0, 0, " . $_POST [ 'page_class' ]);
$e107cache -> clear ( " sitelinks " );
}
} */
$data = array ( 'method' => 'create' , 'table' => 'page' , 'id' => $pid , 'plugin' => 'page' , 'function' => 'submitPage' );
$this -> message = $e_event -> triggerHook ( $data );
}
}
function uploadPage ()
{
global $pref ;
$pref [ 'upload_storagetype' ] = " 1 " ;
require_once ( e_HANDLER . " upload_handler.php " );
$uploaded = file_upload ( e_IMAGE . " custom/ " );
}
}
2012-04-22 06:19:21 +00:00
2012-04-19 03:53:58 +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
2011-12-09 02:08:04 +00:00
// FIXME - add page link to sitelinks is completely disabled as current implementation is not reliable (+ is obsolete and generates sql error)
2006-12-02 04:36:16 +00:00
class page
{
2009-07-08 10:31:53 +00:00
var $fields ;
2012-04-19 03:53:58 +00:00
// DEPRECATED
2009-07-08 10:31:53 +00:00
function page ()
{
global $pref , $user_pref , $admin_log ;
2009-11-05 17:32:19 +00:00
if ( isset ( $_POST [ 'etrigger_ecolumns' ]))
2009-07-08 10:31:53 +00:00
{
$user_pref [ 'admin_cpage_columns' ] = $_POST [ 'e-columns' ];
save_prefs ( 'user' );
}
$this -> fieldpref = ( varset ( $user_pref [ 'admin_cpage_columns' ])) ? $user_pref [ 'admin_cpage_columns' ] : array ( " page_id " , " page_title " , " page_theme " ); ;
$this -> fields = array (
2010-01-03 12:14:06 +00:00
'page_id' => array ( 'title' => 'ID' , 'width' => '5%' , 'forced' => TRUE ),
2012-06-09 04:44:11 +00:00
'page_title' => array ( 'title' => LAN_TITLE , 'type' => 'text' , 'width' => 'auto' ),
2009-11-19 12:36:22 +00:00
'page_theme' => array ( 'title' => CUSLAN_2 , 'type' => 'text' , 'width' => 'auto' , 'nolist' => true ),
'page_template' => array ( 'title' => 'Template' , 'type' => 'text' , 'width' => 'auto' ),
2010-04-17 03:17:48 +00:00
'page_author' => array ( 'title' => LAN_AUTHOR , 'type' => 'text' , 'width' => 'auto' , 'thclass' => 'left' ),
'page_datestamp' => array ( 'title' => LAN_DATE , 'type' => 'datestamp' , 'width' => 'auto' ),
2012-04-19 03:53:58 +00:00
'page_class' => array ( 'title' => LAN_USERCLASS , 'type' => 'userclass' , 'width' => 'auto' , 'filter' => true , 'batch' => true ,),
2010-04-17 03:17:48 +00:00
'page_rating_flag' => array ( 'title' => LAN_RATING , 'type' => 'boolean' , 'width' => '10%' , 'thclass' => 'center' , 'class' => 'center' ),
'page_comment_flag' => array ( 'title' => ADLAN_114 , 'type' => 'boolean' , 'width' => '10%' , 'thclass' => 'center' , 'class' => 'center' ),
2009-11-19 12:36:22 +00:00
// 'page_password' => array('title'=> LAN_USER_05, 'type' => 'text', 'width' => 'auto'),
2009-07-08 10:31:53 +00:00
// 'page_ip_restrict' => array('title'=> LAN_USER_07, 'type' => 'text', 'width' => 'auto'), // Avatar
2009-11-19 12:36:22 +00:00
'options' => array ( 'title' => LAN_OPTIONS , 'forced' => TRUE , 'width' => '10%' , 'thclass' => 'center last' , 'class' => 'center' )
2009-07-08 10:31:53 +00:00
);
// $this->fieldpref = array("page_id","page_title","page_author","page_class");
}
// --------------------------------------------------------------------------
2012-04-19 03:53:58 +00:00
// DEPRECATED
/*
2009-08-05 14:22:15 +00:00
function menusPage ()
2006-12-02 04:36:16 +00:00
{
2009-08-05 14:22:15 +00:00
if ( ! getperms ( " J " )){ return ; }
return $this -> showExistingPages ( 'menus' );
}
2012-04-19 03:53:58 +00:00
**/
2008-12-29 15:23:06 +00:00
2009-08-05 14:22:15 +00:00
// --------------------------------------------------------------------------
2012-04-19 03:53:58 +00:00
/*
2009-08-05 14:22:15 +00:00
function showExistingPages ( $mode = FALSE )
{
global $sql , $e107 , $emessage , $frm , $pref ;
2009-07-08 10:31:53 +00:00
2009-08-05 14:22:15 +00:00
$text = " <form method='post' action=' " . e_SELF . " ? " . e_QUERY . " '>
2009-07-08 10:31:53 +00:00
< fieldset id = 'core-cpage-list' >
< legend class = 'e-hideme' > " .CUSLAN_5. " </ legend >
2012-11-26 14:41:32 -08:00
< table class = 'table adminlist' > " .
2009-07-17 07:53:13 +00:00
$frm -> colGroup ( $this -> fields , $this -> fieldpref ) .
$frm -> thead ( $this -> fields , $this -> fieldpref ) .
" <tbody> " ;
2008-12-29 15:23:06 +00:00
2009-08-05 14:22:15 +00:00
if ( $mode == 'menus' )
{
$qry = " page_theme !='' " ;
$caption = CUSLAN_50 ;
}
else
{
if ( ! getperms ( " 5 " )){ return ; }
$qry = " page_theme ='' " ;
$caption = CUSLAN_5 ;
}
if ( ! $sql -> db_Select ( " page " , " * " , $qry . " ORDER BY page_datestamp DESC " ))
2006-12-02 04:36:16 +00:00
{
2008-12-29 15:23:06 +00:00
$text .= "
< tr >
< td colspan = '4' class = 'center middle' >
" .CUSLAN_42. "
</ td >
</ tr >
" ;
2006-12-02 04:36:16 +00:00
}
else
{
2008-12-29 15:23:06 +00:00
$pages = $sql -> db_getList ( 'ALL' , FALSE , FALSE );
2006-12-02 04:36:16 +00:00
foreach ( $pages as $pge )
{
2010-04-11 07:52:45 +00:00
$title_text = $pge [ 'page_title' ] ? $pge [ 'page_title' ] : ( $pge [ 'page_theme' ] ? CUSLAN_43 . $pge [ 'page_theme' ] : CUSLAN_44 );
2011-12-09 02:08:04 +00:00
$pge [ 'page_title' ] = " <a href=' " . ( $pge [ 'page_theme' ] ? e_ADMIN . " menus.php " : e107 :: getUrl () -> create ( 'page/view' , $pge , 'allow=page_id,page_sef' )) . " '> { $title_text } </a> " ;
2009-11-19 12:36:22 +00:00
$authorData = get_user_data ( $pge [ 'page_author' ]);
2010-01-03 12:14:06 +00:00
$pge [ 'page_author' ] = varset ( $authorData [ 'user_name' ], '?' );
2009-07-08 10:31:53 +00:00
2009-11-19 12:36:22 +00:00
$text .= $frm -> renderTableRow ( $this -> fields , $this -> fieldpref , $pge , 'page_id' );
2006-12-02 04:36:16 +00:00
}
}
$text .= "
2008-12-29 15:23:06 +00:00
</ tbody >
</ table >
</ fieldset >
</ form >
" ;
2006-12-02 04:36:16 +00:00
2009-08-05 14:22:15 +00:00
$e107 -> ns -> tablerender ( $caption , $emessage -> render () . $text );
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
2008-12-29 15:23:06 +00:00
2006-12-02 04:36:16 +00:00
2012-04-19 03:53:58 +00:00
// DEPRECATED
function delete_page ( $del_id )
2006-12-02 04:36:16 +00:00
{
2012-04-19 03:53:58 +00:00
return ;
2011-12-09 02:08:04 +00:00
2008-12-29 20:51:24 +00:00
global $sql , $e107cache , $admin_log , $e_event ;
2011-12-09 02:08:04 +00:00
//if(!$sql->db_Select('page', '*', "page_id={$del_id}")) return;
//$row = $sql->db_Fetch();
2012-12-06 20:34:57 -08:00
e107 :: getMessage () -> addAuto ( $sql -> db_Delete ( " page " , " page_id=' { $del_id } ' " ), 'delete' , CUSLAN_28 , false , false );
2010-04-17 03:17:48 +00:00
$sql -> db_Delete ( 'menus' , " menu_path=' $del_id ' " );
$e107cache -> clear_sys ( 'menus_' );
2008-12-06 16:40:37 +00:00
$admin_log -> log_event ( 'CPAGE_03' , 'ID: ' . $del_id , E_LOG_INFORMATIVE , '' );
2011-12-09 02:08:04 +00:00
/* $url = e107 :: getUrl () -> sc ( 'page/view' , $row , 'allow=page_id,page_title,page_sef' );
if ( $row [ 'page_theme' ] && $sql -> db_Select ( 'links' , 'link_id' , " link_url=' " . $url . " ' " ))
2006-12-02 04:36:16 +00:00
{
2011-12-09 02:08:04 +00:00
$tmp = $sql -> db_Fetch ();
$sql -> db_Delete ( 'links' , " link_id= " . $tmp [ 'link_id' ]);
2010-04-17 03:17:48 +00:00
$e107cache -> clear ( 'sitelinks' );
2006-12-02 04:36:16 +00:00
}
2011-12-09 02:08:04 +00:00
*/
2008-12-29 20:51:24 +00:00
$data = array ( 'method' => 'delete' , 'table' => 'page' , 'id' => $del_id , 'plugin' => 'page' , 'function' => 'delete_page' );
$this -> message = $e_event -> triggerHook ( $data );
2006-12-02 04:36:16 +00:00
}
2012-04-19 03:53:58 +00:00
/*
2006-12-02 04:36:16 +00:00
function saveSettings ()
{
2008-12-29 15:23:06 +00:00
global $pref , $admin_log , $emessage ;
2008-12-06 16:40:37 +00:00
$temp [ 'listPages' ] = $_POST [ 'listPages' ];
$temp [ 'pageCookieExpire' ] = $_POST [ 'pageCookieExpire' ];
if ( $admin_log -> logArrayDiffs ( $temp , $pref , 'CPAGE_04' ))
{
save_prefs (); // Only save if changes
2011-04-21 21:30:30 +00:00
$emessage -> add ( LAN_SETSAVED , E_MESSAGE_SUCCESS );
2008-12-06 16:40:37 +00:00
}
else
{
2011-04-21 21:30:30 +00:00
$emessage -> add ( LAN_NOCHANGE_NOTSAVED );
2008-12-06 16:40:37 +00:00
}
2006-12-02 04:36:16 +00:00
}
2008-12-06 16:40:37 +00:00
2006-12-02 04:36:16 +00:00
function show_options ( $action )
{
if ( $action == " " )
{
2009-08-05 14:22:15 +00:00
$action = ( getperms ( '5' )) ? " pages " : " menus " ;
2006-12-02 04:36:16 +00:00
}
2010-04-17 03:17:48 +00:00
2009-11-25 11:01:12 +00:00
if ( vartrue ( $_GET [ 'menus' ]))
{
$action = " menus " ;
}
2010-04-17 03:17:48 +00:00
2009-08-05 14:22:15 +00:00
$var [ 'pages' ][ 'text' ] = CUSLAN_48 ;
$var [ 'pages' ][ 'link' ] = e_SELF ;
$var [ 'pages' ][ 'perm' ] = 5 ;
$var [ 'menus' ][ 'text' ] = CUSLAN_49 ;
2009-11-25 11:01:12 +00:00
$var [ 'menus' ][ 'link' ] = e_SELF . " ?menus=1 " ;
2009-08-05 14:22:15 +00:00
$var [ 'menus' ][ 'perm' ] = " J " ;
2006-12-02 04:36:16 +00:00
$var [ 'create' ][ 'text' ] = CUSLAN_12 ;
$var [ 'create' ][ 'link' ] = e_SELF . " ?create " ;
2009-08-05 14:22:15 +00:00
$var [ 'create' ][ 'perm' ] = 5 ;
2006-12-02 04:36:16 +00:00
$var [ 'createm' ][ 'text' ] = CUSLAN_31 ;
$var [ 'createm' ][ 'link' ] = e_SELF . " ?createm " ;
2009-08-05 14:22:15 +00:00
$var [ 'createm' ][ 'perm' ] = " J " ;
2006-12-02 04:36:16 +00:00
$var [ 'options' ][ 'text' ] = LAN_OPTIONS ;
$var [ 'options' ][ 'link' ] = e_SELF . " ?options " ;
2009-08-05 14:22:15 +00:00
$var [ 'options' ][ 'perm' ] = " 0 " ;
2006-12-02 04:36:16 +00:00
2012-12-03 01:40:47 -08:00
e107 :: getNav () -> admin ( CUSLAN_33 , $action , $var );
2006-12-02 04:36:16 +00:00
}
2012-04-19 03:53:58 +00:00
*/
2006-12-02 04:36:16 +00:00
}
2012-05-23 13:59:12 +00:00
/*
2008-12-29 15:23:06 +00:00
function cpage_adminmenu ()
2008-12-06 16:40:37 +00:00
{
2006-12-02 04:36:16 +00:00
global $page ;
global $action ;
2012-05-23 13:59:12 +00:00
// $page->show_options($action);
2006-12-02 04:36:16 +00:00
}
2012-05-23 13:59:12 +00:00
*/
2006-12-02 04:36:16 +00:00
2007-09-02 11:44:00 +00:00
?>