1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-02 04:40:44 +02:00

custompage work and some code cleanup

This commit is contained in:
CaMer0n
2009-11-19 12:36:22 +00:00
parent 8986a5d01e
commit c321774aa6
5 changed files with 123 additions and 59 deletions

View File

@@ -9,8 +9,8 @@
* Custom Menus/Pages Administration * Custom Menus/Pages Administration
* *
* $Source: /cvs_backup/e107_0.8/e107_admin/cpage.php,v $ * $Source: /cvs_backup/e107_0.8/e107_admin/cpage.php,v $
* $Revision: 1.26 $ * $Revision: 1.27 $
* $Date: 2009-11-18 01:04:25 $ * $Date: 2009-11-19 12:35:33 $
* $Author: e107coders $ * $Author: e107coders $
* *
*/ */
@@ -69,9 +69,18 @@ if(isset($_POST['updatePage']))
$page->submitPage($_POST['pe_id']); $page->submitPage($_POST['pe_id']);
} }
if(isset($_POST['delete'])) if(isset($_POST['delete']) || varset($_POST['etrigger_delete']))
{ {
foreach(array_keys($_POST['delete']) as $pid) if($_POST['etrigger_delete'])
{
$delArray = array_keys($_POST['etrigger_delete']);
}
else
{
$delArray = array_keys($_POST['delete']);
}
foreach($delArray as $pid)
{ {
$page->delete_page($pid); $page->delete_page($pid);
} }
@@ -94,6 +103,13 @@ if(!e_QUERY)
} }
} }
elseif($_GET['action']=='edit')
{
$action = 'create';
$sub_action = 'edit';
$id = ($_GET['id']);
$page->createPage();
}
else else
{ {
$function = $action."Page"; $function = $action."Page";
@@ -119,19 +135,20 @@ class page
$this->fieldpref = (varset($user_pref['admin_cpage_columns'])) ? $user_pref['admin_cpage_columns'] : array("page_id","page_title","page_theme"); ; $this->fieldpref = (varset($user_pref['admin_cpage_columns'])) ? $user_pref['admin_cpage_columns'] : array("page_id","page_title","page_theme"); ;
$this->fields = array( $this->fields = array(
'page_id' => array('title'=> ID, 'width'=>'5%', 'forced'=> TRUE), 'page_id' => array('title'=> ID, 'width'=>'5%', 'forced'=> TRUE),
'page_title' => array('title'=> CUSLAN_1, 'width'=>'auto'), 'page_title' => array('title'=> CUSLAN_1, 'type' => 'text', 'width'=>'auto'),
'page_theme' => array('title'=> CUSLAN_2, 'type' => 'text', 'width' => 'auto'), 'page_theme' => array('title'=> CUSLAN_2, 'type' => 'text', 'width' => 'auto','nolist'=>true),
'page_author' => array('title'=> LAN_AUTHOR, 'type' => 'text', 'width' => 'auto', 'thclass' => 'left first'), // Display name 'page_template' => array('title'=> 'Template', 'type' => 'text', 'width' => 'auto'),
'page_datestamp' => array('title'=> LAN_DATE, 'type' => 'text', 'width' => 'auto'), // User name 'page_author' => array('title'=> LAN_AUTHOR, 'type' => 'text', 'width' => 'auto', 'thclass' => 'left'),
'page_class' => array('title'=> LAN_USERCLASS, 'type' => 'text', 'width' => 'auto'), // Photo 'page_datestamp' => array('title'=> LAN_DATE, 'type' => 'datestamp', 'width' => 'auto'),
'page_rating_flag' => array('title'=> LAN_RATING, 'type' => 'text', 'width' => '10%', 'thclass' => 'center' ), // Real name (no real vetting) 'page_class' => array('title'=> LAN_USERCLASS, 'type' => 'userclass', 'width' => 'auto'),
'page_comment_flag' => array('title'=> ADLAN_114, 'type' => 'text', 'width' => '10%', 'thclass' => 'center' ), // No real vetting 'page_rating_flag' => array('title'=> LAN_RATING, 'type' => 'boolean', 'width' => '10%', 'thclass' => 'center', 'class' => 'center' ),
// 'page_password' => array('title'=> LAN_USER_05, 'type' => 'text', 'width' => 'auto'), 'page_comment_flag' => array('title'=> ADLAN_114, 'type' => 'boolean', 'width' => '10%', 'thclass' => 'center', 'class' => 'center' ),
// 'page_password' => array('title'=> LAN_USER_05, 'type' => 'text', 'width' => 'auto'),
// 'page_ip_restrict' => array('title'=> LAN_USER_07, 'type' => 'text', 'width' => 'auto'), // Avatar // 'page_ip_restrict' => array('title'=> LAN_USER_07, 'type' => 'text', 'width' => 'auto'), // Avatar
'options' => array('title'=> LAN_OPTIONS, 'forced'=>TRUE, 'width' => '10%', 'thclass' => 'center last') 'options' => array('title'=> LAN_OPTIONS, 'forced'=>TRUE, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center')
); );
// $this->fieldpref = array("page_id","page_title","page_author","page_class"); // $this->fieldpref = array("page_id","page_title","page_author","page_class");
@@ -189,29 +206,11 @@ class page
foreach($pages as $pge) foreach($pages as $pge)
{ {
//title='".LAN_DELETE."' $pge['page_title'] = $pge['page_title'] ? $pge['page_title'] : ($pge['page_theme'] ? CUSLAN_43.$pge['page_theme'] : CUSLAN_44);
$title_text = $pge['page_title'] ? $pge['page_title'] : ($pge['page_theme'] ? CUSLAN_43.$pge['page_theme'] : CUSLAN_44); $authorData = get_user_data($pge['page_author']);
$author = get_user_data($pge['page_author']); $pge['page_author'] = $authorData['user_name'];
$text .= $frm->renderTableRow($this->fields,$this->fieldpref,$pge,'page_id');
$text .= "
<tr>
<td>{$pge['page_id']}</td>";
$text .= (in_array("page_title",$this->fieldpref)) ? "<td><a href='".($pge['page_theme'] ? e_ADMIN."menus.php" : e_BASE."page.php?{$pge['page_id']}" )."'>{$title_text}</a></td>" : "";
$text .= (in_array("page_theme",$this->fieldpref)) ? "<td>".($pge['page_theme'] ? "menu" : "page")."</td>" : "";
$text .= (in_array("page_author",$this->fieldpref)) ? "<td>".($author['user_name'])."</td>" : "";
$text .= (in_array("page_datestamp",$this->fieldpref)) ? "<td>".strftime($pref['shortdate'],$pge['page_datestamp'])."</td>" : "";
$text .= (in_array("page_class",$this->fieldpref)) ? "<td>".(r_userclass_name($pge['page_class']))."</td>" : "";
$text .= (in_array("page_rating_flag",$this->fieldpref)) ? "<td class='center'>".($pge['page_rating_flag'] ? ADMIN_TRUE_ICON : "&nbsp;")."</td>" : "";
$text .= (in_array("page_comment_flag",$this->fieldpref)) ? "<td class='center'>".($pge['page_comment_flag'] ? ADMIN_TRUE_ICON : "&nbsp;")."</td>" : "";
$text .= "<td class='center'>
<a class='action edit' href='".e_SELF."?".($pge['page_theme'] ? "createm": "create").".edit.{$pge['page_id']}'>".ADMIN_EDIT_ICON."</a>
<input type='image' class='action delete' name='delete[{$pge['page_id']}]' src='".ADMIN_DELETE_ICON_PATH."' title='".CUSLAN_4." [ ID: {$pge['page_id']} ]' />
</td>
</tr>
";
} }
} }
@@ -245,7 +244,12 @@ class page
{ {
/* mode: FALSE == page, mode: TRUE == menu */ /* mode: FALSE == page, mode: TRUE == menu */
global $sql, $tp, $e107, $sub_action, $id, $frm, $e_userclass, $e_event; global $e107, $sub_action, $id, $e_userclass, $e_event;
$frm = e107::getForm();
$sql = e107::getDb();
$tp = e107::getParser();
$edit = ($sub_action == 'edit'); $edit = ($sub_action == 'edit');
$caption =(!$mode ? ($edit ? CUSLAN_23 : CUSLAN_24) : ($edit ? CUSLAN_25 : CUSLAN_26)); $caption =(!$mode ? ($edit ? CUSLAN_23 : CUSLAN_24) : ($edit ? CUSLAN_25 : CUSLAN_26));
@@ -288,34 +292,62 @@ class page
{ {
$text .= " $text .= "
<tr> <tr>
<td class='label'>".CUSLAN_7."</td> <td>".CUSLAN_7."</td>
<td class='control'> <td>
".$frm->text('menu_name', $menu_name, 50)." ".$frm->text('menu_name', $menu_name, 50)."
</td> </td>
</tr> </tr>
"; ";
} }
else
{
$templates = array();
$tmp = e107::getTemplate('page', 'page');
foreach($tmp as $key=>$val)
{
$templates[$key] = $key; //TODO add LANS?
}
$text .= "
<tr>
<td>Template</td>
<td>
". $frm->selectbox('page_template',$templates,$row['page_template']) ."
</td>
</tr>
";
}
$text .= " $text .= "
<tr> <tr>
<td class='label'>".CUSLAN_8."</td> <td>".CUSLAN_8."</td>
<td class='control'> <td>
".$frm->text('page_title', $page_title, 250)." ".$frm->text('page_title', $page_title, 250)."
</td> </td>
</tr> </tr>
<tr> <tr>
<td class='label'>".CUSLAN_9."</td> <td>".CUSLAN_9."</td>
<td class='control'> <td>
"; ";
require_once(e_HANDLER."ren_help.php"); // require_once(e_HANDLER."ren_help.php");
$insertjs = (!e_WYSIWYG)? " rows='15' onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);' style='width:95%'": "rows='25' style='width:100%' ";
// $insertjs = (!e_WYSIWYG)? " rows='15' onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);' style='width:95%'": "rows='25' style='width:100%' ";
$data = $tp->toForm($data,FALSE,TRUE); // Make sure we convert HTML tags to entities $data = $tp->toForm($data,FALSE,TRUE); // Make sure we convert HTML tags to entities
$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>";
$textareaValue = (strstr($data, "[img]http") ? $data : str_replace("[img]../", "[img]", $data));
$text .= " // $text .= $frm->textarea('data', $textareaValue);
<br />".display_help('cpage-help', 'cpage')." $text .= $frm->bbarea('data', $textareaValue, 'data', 'cpage-help');
</td>
// $text .= "<textarea class='e-wysiwyg tbox' tabindex='".$frm->getNext()."' id='data' name='data' cols='80'{$insertjs}>".(strstr($data, "[img]http") ? $data : str_replace("[img]../", "[img]", $data))."</textarea>";
// <br />".display_help('cpage-help', 'cpage')."
$text .= "</td>
</tr> </tr>
<tr> <tr>
<td class='label'>".LAN_UPLOAD_IMAGES."</td> <td class='label'>".LAN_UPLOAD_IMAGES."</td>
@@ -440,13 +472,14 @@ class page
$page_title = $tp->toDB($_POST['page_title']); $page_title = $tp->toDB($_POST['page_title']);
$page_text = $tp->toDB($_POST['data']); $page_text = $tp->toDB($_POST['data']);
$pauthor = ($_POST['page_display_authordate_flag'] ? USERID : 0); // $pauthor = ($_POST['page_display_authordate_flag'] ? USERID : 0); // this check should be done in the front-end.
$pauthor = USERID;
if($mode) if($mode)
{ // Saving existing page/menu after edit { // Saving existing page/menu after edit
// Don't think $_POST['page_ip_restrict'] is ever set. // Don't think $_POST['page_ip_restrict'] is ever set.
$menuname = ($type ? ", page_theme = '".$tp -> toDB($_POST['menu_name'])."'" : ""); $menuname = ($type ? ", page_theme = '".$tp -> toDB($_POST['menu_name'])."'" : "");
$update = $sql -> db_Update("page", "page_title='{$page_title}', 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'],'')."'{$menuname} WHERE page_id='{$mode}'"); $update = $sql -> db_Update("page", "page_title='{$page_title}', 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}'");
$admin_log->log_event('CPAGE_02',$mode.'[!br!]'.$page_title.'[!br!]'.$pauthor,E_LOG_INFORMATIVE,''); $admin_log->log_event('CPAGE_02',$mode.'[!br!]'.$page_title.'[!br!]'.$pauthor,E_LOG_INFORMATIVE,'');
$e107cache->clear("page_{$mode}"); $e107cache->clear("page_{$mode}");
$e107cache->clear("page-t_{$mode}"); $e107cache->clear("page-t_{$mode}");
@@ -495,7 +528,7 @@ class page
{ // New page/menu { // New page/menu
$menuname = ($type ? $tp->toDB($_POST['menu_name']) : ""); $menuname = ($type ? $tp->toDB($_POST['menu_name']) : "");
$pid = admin_update($sql->db_Insert("page", "0, '{$page_title}', '{$page_text}', '{$pauthor}', '".time()."', '".intval($_POST['page_rating_flag'])."', '".intval($_POST['page_comment_flag'])."', '".$_POST['page_password']."', '".$_POST['page_class']."', '', '".$menuname."'"), 'insert', CUSLAN_27, LAN_CREATED_FAILED, false); $pid = admin_update($sql->db_Insert("page", "0, '{$page_title}', '{$page_text}', '{$pauthor}', '".time()."', '".intval($_POST['page_rating_flag'])."', '".intval($_POST['page_comment_flag'])."', '".$_POST['page_password']."', '".$_POST['page_class']."', '', '".$menuname."', '".$_POST['page_template']."'"), 'insert', CUSLAN_27, LAN_CREATED_FAILED, false);
$admin_log->log_event('CPAGE_01',$menuname.'[!br!]'.$page_title.'[!br!]'.$pauthor,E_LOG_INFORMATIVE,''); $admin_log->log_event('CPAGE_01',$menuname.'[!br!]'.$page_title.'[!br!]'.$pauthor,E_LOG_INFORMATIVE,'');
if($type) if($type)

View File

@@ -9,8 +9,8 @@
* Core SQL * Core SQL
* *
* $Source: /cvs_backup/e107_0.8/e107_admin/sql/core_sql.php,v $ * $Source: /cvs_backup/e107_0.8/e107_admin/sql/core_sql.php,v $
* $Revision: 1.39 $ * $Revision: 1.40 $
* $Date: 2009-11-18 10:05:53 $ * $Date: 2009-11-19 12:35:33 $
* $Author: e107coders $ * $Author: e107coders $
*/ */
@@ -370,6 +370,7 @@ CREATE TABLE page (
page_class varchar(250) NOT NULL default '', page_class varchar(250) NOT NULL default '',
page_ip_restrict text NOT NULL, page_ip_restrict text NOT NULL,
page_theme varchar(50) NOT NULL default '', page_theme varchar(50) NOT NULL default '',
page_template varchar(50) NOT NULL default '',
PRIMARY KEY (page_id) PRIMARY KEY (page_id)
) TYPE=MyISAM; ) TYPE=MyISAM;
# -------------------------------------------------------- # --------------------------------------------------------

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_admin/update_routines.php,v $ | $Source: /cvs_backup/e107_0.8/e107_admin/update_routines.php,v $
| $Revision: 1.61 $ | $Revision: 1.62 $
| $Date: 2009-11-19 10:07:29 $ | $Date: 2009-11-19 12:35:33 $
| $Author: e107coders $ | $Author: e107coders $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -263,7 +263,7 @@ function update_706_to_800($type='')
// List of changed DB tables (defined in core_sql.php) // List of changed DB tables (defined in core_sql.php)
// (primarily those which have changed significantly; for the odd field write some explicit code - it'll run faster) // (primarily those which have changed significantly; for the odd field write some explicit code - it'll run faster)
$changed_tables = array('user', 'dblog','admin_log', 'userclass_classes', 'banlist', 'menus', $changed_tables = array('user', 'dblog','admin_log', 'userclass_classes', 'banlist', 'menus',
'plugin', 'news', 'news_category','online'); 'plugin', 'news', 'news_category','online', 'page');
// List of changed DB tables from core plugins (defined in pluginname_sql.php file) // List of changed DB tables from core plugins (defined in pluginname_sql.php file)

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Id: plugin.xml,v 1.1 2009-11-19 12:36:22 e107coders Exp $ -->
<e107Plugin name="Pages" version="1.0" compatibility="0.8" installRequired="false" >
<category>menu</category>
</e107Plugin>

View File

@@ -0,0 +1,25 @@
<?php
/*
+ ----------------------------------------------------------------------------+
| e107 website system
|
| Copyright (c) e107 Inc. 2008-2009
| http://e107.org
|
| Released under the terms and conditions of the
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/page/templates/page_template.php,v $
| $Revision: 1.1 $
| $Date: 2009-11-19 12:36:22 $
| $Author: e107coders $
+----------------------------------------------------------------------------+
*/
$PAGE_TEMPLATE['default'] = "<!-- Default -->";
$PAGE_TEMPLATE['other1'] = "<!-- Other -->";
$PAGE_TEMPLATE['other2'] = "<!-- Other2 -->";
?>