1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-29 09:10:23 +02:00

CustomPages work (chapters, books) and admin-> newspost - news_rendertype (start toward multiple templates per item)

This commit is contained in:
CaMer0n
2012-10-11 02:24:43 +00:00
parent ce30681cc3
commit ebe5cd2948
5 changed files with 203 additions and 39 deletions

View File

@@ -124,6 +124,12 @@ class page_admin extends e_admin_dispatcher
'ui' => 'page_admin_form_ui',
'uipath' => null
),
'cat' => array(
'controller' => 'page_chapters_ui',
'path' => null,
'ui' => 'page_chapters_form_ui',
'uipath' => null
),
'menu' => array(
'controller' => 'page_admin_ui',
'path' => null,
@@ -140,8 +146,11 @@ class page_admin extends e_admin_dispatcher
protected $adminMenu = array(
'page/list' => array('caption'=> CUSLAN_48, 'perm' => '5'),
'menu/list' => array('caption'=> CUSLAN_49, 'perm' => 'J'),
'page/create' => array('caption'=> CUSLAN_12, 'perm' => '5'),
'cat/list' => array('caption'=> "List Books/Chapters", 'perm' => '5'), // Create Category.
'cat/create' => array('caption'=> "Add Book/Chapter", 'perm' => '5'), // Category List
'menu/list' => array('caption'=> CUSLAN_49, 'perm' => 'J'),
'menu/create' => array('caption'=> CUSLAN_31, 'perm' => 'J'),
'page/options' => array('caption'=> LAN_OPTIONS, 'perm' => '0')
);
@@ -185,8 +194,74 @@ class page_admin_form_ui extends e_admin_form_ui
}
//FIXME - needs a layout similar to the admin sitelinks page. ie. showing chapters as we would 'sublinks'.
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')
);
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
{
}
class page_admin_ui extends e_admin_ui
@@ -199,35 +274,86 @@ class page_admin_ui extends e_admin_ui
//protected $editQry = "SELECT * FROM #comments WHERE comment_id = {ID}";
protected $pid = "page_id";
protected $listOrder = 'p.page_id desc';
protected $listOrder = 'p.page_order asc'; // desc would require changes to ajax sorting.
protected $perPage = 10;
protected $batchDelete = true;
protected $batchCopy = true;
// protected $listSorting = true;
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),
'page_title' => array('title'=> LAN_TITLE, 'type' => 'text', 'width'=>'auto','readParms'=>'link={e_BASE}page.php?[id]&dialog=1'),
'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'),
'page_theme' => array('title'=> CUSLAN_2, 'type' => 'text', 'width' => 'auto','nolist'=>true),
'page_template' => array('title'=> 'Template', 'type' => 'text', 'width' => 'auto'),
'page_template' => array('title'=> 'Template', 'type' => 'text', 'width' => 'auto','filter' => true, 'batch'=>true),
'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),
'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' ),
// 'page_password' => array('title'=> LAN_USER_05, 'type' => 'text', 'width' => 'auto'),
'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),
// 'page_ip_restrict' => array('title'=> LAN_USER_07, 'type' => 'text', 'width' => 'auto'), // Avatar
'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'forced'=>TRUE, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center')
'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'forced'=>TRUE, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center','readParms'=>'sort=1')
);
protected $fieldpref = array("page_id","page_title","page_template","page_author","page_class");
protected $books = array();
protected $cats = array();
function init()
{
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;
if(varset($_GET['mode'])=='dialog' && varset($_GET['action'])=='dialog') // New Page bbcode in tabs.
{
$this->dialogPage();
@@ -393,8 +519,18 @@ class page_admin_ui extends e_admin_ui
}
else
{
$text .= "
<tr>
<td>Chapter</td>
<td>". $frm->selectbox('page_chapter',$this->cats, $row['page_chapter']) ."</td>
</tr>
";
// fixed - last parameter (allinfo) should be false as getLayout method is returning non-usable formatted array
$templates = e107::getLayouts('', 'page', 'front', '', false, false);
$templates['menu'] = "Sidebar"; // ie. a MENU item. //TODO
$text .= "
<tr>
@@ -402,6 +538,8 @@ class page_admin_ui extends e_admin_ui
<td>". $frm->selectbox('page_template',$templates,$row['page_template']) ."</td>
</tr>
";
}
$text .= "
<tr>
@@ -446,7 +584,8 @@ class page_admin_ui extends e_admin_ui
$textareaValue = (strstr($data, "[img]http") ? $data : str_replace("[img]../", "[img]", $data));
$text .= $this->bbareaMulti('data', $textareaValue, 'page','page','large');
// $text .= $this->bbareaMulti('data', $textareaValue, 'page','page','large');
$text .= $frm->bbarea('data', $textareaValue, 'page','page','large');
$text .= "</div>";
// $text .= $frm->bbarea('data', $textareaValue, 'page','help','large');
@@ -589,7 +728,7 @@ class page_admin_ui extends e_admin_ui
if(!$textareaValue)
{
$textareaValue = "[newpage] ";
// $textareaValue = "[newpage] ";
}
@@ -734,9 +873,9 @@ class page_admin_ui extends e_admin_ui
{
list($tm,$key) = explode("_",$k);
if($mode === FALSE) // Pages only, not menus.
if($mode == FALSE) // Pages only, not menus.
{
$newData .= "[newpage=".$_POST['page_subtitle'][$key]."]\n";
$newData[] = "[newpage=".$_POST['page_subtitle'][$key]."]\n";
}
$newData[] = $v;
}
@@ -744,9 +883,12 @@ class page_admin_ui extends e_admin_ui
// return;
}
// echo nl2br($newData);
// return;
$newData = implode("\n\n", $newData);
// echo nl2br($newData);
$page_text = $tp->toDB($newData);
$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
@@ -815,7 +957,7 @@ class page_admin_ui extends e_admin_ui
$menuname = ($type && vartrue($_POST['menu_name']) ? ", page_theme = '".$tp -> toDB($_POST['menu_name'])."'" : "");
$status = $sql -> db_Update("page", "page_title='{$page_title}', page_sef='{$page_sef}', 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;
$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;
if ($status == E_MESSAGE_SUCCESS) $update++;
@@ -892,6 +1034,7 @@ class page_admin_ui extends e_admin_ui
$info = array(
'page_title' => $page_title,
'page_sef' => $page_sef,
'page_chapter' => varset($_POST['page_chapter'],0),
'page_metakeys' => $page_metak,
'page_metadscr' => $page_metad,
'page_text' => $page_text,