1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 20:58:30 +01:00

featurebox admin rewrite

This commit is contained in:
CaMer0n 2009-11-24 14:48:34 +00:00
parent 19e5e2c8c0
commit fb849ddc2f
4 changed files with 275 additions and 195 deletions

View File

@ -1,19 +1,21 @@
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2009 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/featurebox/admin_config.php,v $
* $Revision: 1.8 $
* $Date: 2009-11-18 01:05:36 $
* $Author: e107coders $
*/
+ ----------------------------------------------------------------------------+
| e107 website system
|
| Copyright (C) 2008-2009 e107 Inc (e107.org)
| 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/featurebox/admin_config.php,v $
| $Revision: 1.9 $
| $Date: 2009-11-24 14:48:31 $
| $Author: e107coders $
+----------------------------------------------------------------------------+
*/
require_once("../../class2.php");
if (!getperms("P") || !plugInstalled('featurebox'))
{
@ -21,188 +23,150 @@ if (!getperms("P") || !plugInstalled('featurebox'))
exit;
}
include_lan(e_PLUGIN."featurebox/languages/".e_LANGUAGE."_admin_featurebox.php");
class fb_admin extends e_admin_dispatcher
{
protected $modes = array(
'main' => array(
'controller' => 'fb_main_ui',
'path' => null,
'ui' => 'fb_admin_form_ui',
'uipath' => null
),
'cat' => array(
'controller' => 'fb_cat_ui',
'path' => null,
'ui' => 'fb_cat_form_ui',
'uipath' => null
)
);
protected $adminMenu = array(
'main/list' => array('caption'=> 'Featurebox List', 'perm' => 'P'),
'main/create' => array('caption'=> 'Create Featurebox Entry', 'perm' => 'P'),
'cat/list' => array('caption'=> 'Categories', 'perm' => 'P'),
'cat/create' => array('caption'=> "Create Category", 'perm' => 'P'),
// 'main/prefs' => array('caption'=> LAN_PREFS, 'perm' => '0'),
// 'main/custom' => array('caption'=> 'Custom Page', 'perm' => '0')
);
protected $adminMenuAliases = array(
'main/edit' => 'main/list'
);
protected $menuTitle = 'featurebox';
}
class fb_cat_ui extends e_admin_ui
{
protected $pluginTitle = 'Featurebox';
protected $pluginName = 'plugin';
protected $table = "featurebox_cat";
protected $pid = "fb_cat_id";
protected $perPage = 0; //no limit
protected $fields = array(
'checkboxes' => array('title'=> '', 'type' => null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center'),
'fb_cat_id' => array('title'=> LAN_ID, 'type' => 'number', 'width' =>'5%', 'forced'=> TRUE),
'fb_cat_title' => array('title'=> LAN_TITLE, 'type' => 'text', 'width' => 'auto', 'thclass' => 'left'),
'fb_cat_class' => array('title'=> LAN_VISIBILITY, 'type' => 'userclass', 'width' => 'auto', 'data' => 'int'),
'fb_cat_order' => array('title'=> LAN_ORDER, 'type' => 'text', 'width' => '5%', 'thclass' => 'left' ),
'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'width' => '10%', 'forced'=>TRUE, 'thclass' => 'center last', 'class' => 'center')
);
}
/*class fb_cat_form_ui extends e_admin_form_ui
{
}*/
class fb_main_ui extends e_admin_ui
{
//TODO Move to Class above.
protected $pluginTitle = 'featurebox';
protected $pluginName = 'featurebox';
protected $table = "featurebox";
protected $pid = "fb_id";
protected $perPage = 10;
protected $batchDelete = true;
protected $fields = array(
'checkboxes' => array('title'=> '', 'type' => null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center'),
'fb_id' => array('title'=> LAN_ID, 'type' => 'int', 'width' =>'5%', 'forced'=> TRUE),
'fb_title' => array('title'=> LAN_TITLE, 'type' => 'text', 'width' => 'auto', 'thclass' => 'left first'),
'fb_text' => array('title'=> "Message Text", 'type' => 'bbarea', 'width' => '30%', 'readParms' => 'expand=...&truncate=50&bb=1'), // Display name
'fb_image' => array('title'=> "Image", 'type' => 'image', 'width' => 'auto', 'thclass' => 'left first'),
'fb_imageurl' => array('title'=> "Image Link", 'type' => 'text', 'width' => 'auto', 'thclass' => 'left first'),
'fb_mode' => array('title'=> FBLAN_12, 'type' => 'dropdown', 'data'=> 'int', 'width' => '5%', 'filter'=>TRUE, 'batch'=>TRUE),
'fb_class' => array('title'=> LAN_VISIBILITY, 'type' => 'userclass', 'data' => 'int', 'width' => 'auto'), // User id
'fb_rendertype' => array('title'=> FBLAN_22, 'type' => 'dropdown', 'data'=> 'int', 'width' => 'auto', 'noedit' => TRUE),
'fb_template' => array('title'=> FBLAN_25, 'type' => 'dropdown', 'data'=> 'str', 'width' => 'auto', 'thclass' => 'center', 'class'=>'center', 'writeParms' => '', 'filter' => true, 'batch' => true), // Photo
'fb_category' => array('title'=> LAN_CATEGORY, 'type' => 'dropdown', 'data'=> 'int', 'width' => '5%', 'filter'=>TRUE, 'batch'=>TRUE),
'fb_order' => array('title'=> LAN_ORDER, 'type' => 'number', 'data'=> 'int','width' => '5%', 'thclass' => 'center' ),
'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'forced'=>TRUE, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center')
);
// protected $fieldpref = array('checkboxes', 'comment_id', 'comment_item_id', 'comment_author_id', 'comment_author_name', 'comment_subject', 'comment_comment', 'comment_type', 'options');
protected $prefs = array(
'fb_active' => array('title'=> 'Allow submitting of fbs by:', 'type'=>'userclass'),
'submit_question' => array('title'=> 'Allow submitting of Questions by:', 'type'=>'userclass'),
'classic_look' => array('title'=> 'Use Classic Layout', 'type'=>'boolean')
);
function init()
{
$templates = array();
$categories = array();
$tmp = e107::getTemplate('featurebox', 'featurebox');
foreach($tmp as $key=>$val)
{
$templates[$key] = $key; //TODO add LANS?
}
if(e107::getDb()->db_Select('featurebox_cat'))
{
while ($row = e107::getDb()->db_Fetch())
{
$id = $row['fb_cat_id'];
$categories[$id] = $row['fb_cat_title'];
}
}
$this->fields['fb_category']['writeParms'] = $categories;
$this->fields['fb_template']['writeParms'] = $templates;
$this->fields['fb_rendertype']['writeParms'] = array(FBLAN_23,FBLAN_24);
$this->fields['fb_mode']['writeParms'] = array(FBLAN_13,FBLAN_14);
$this->fields['fb_category']['readParms'] = $categories;
$this->fields['fb_template']['readParms'] = $templates;
$this->fields['fb_rendertype']['readParms'] = array(FBLAN_23,FBLAN_24);
$this->fields['fb_mode']['readParms'] = array(FBLAN_13,FBLAN_14);
}
}
class fb_admin_form_ui extends e_admin_form_ui
{
}
new fb_admin();
require_once(e_ADMIN."auth.php");
require_once(e_HANDLER."userclass_class.php");
require_once(e_HANDLER."file_class.php");
$fl = new e_file;
$templatelist = $fl->get_files(e_PLUGIN."featurebox/templates/");
if (e_QUERY)
{
$qs = explode(".", e_QUERY);
$action = varset($qs[0],FALSE);
$id = intval(varset($qs[1],0));
}
else
{
$action = FALSE;
$id = FALSE;
}
if(isset($_POST['createFB']) || isset($_POST['updateFB']))
{
if ($_POST['fb_title'] && $_POST['fb_text'])
{
$fbInfo = array();
$fbInfo['fb_title'] = $tp -> toDB($_POST['fb_title']);
$fbInfo['fb_text'] = $tp -> toDB($_POST['fb_text']);
$fbInfo['fb_mode'] = intval($_POST['fb_mode']);
$fbInfo['fb_class'] = intval($_POST['fb_class']);
$fbInfo['fb_rendertype'] = intval($_POST['fb_rendertype']);
$fbInfo['fb_template'] = $tp -> toDB($_POST['fb_template']);
if(isset($_POST['createFB']))
{
$sql->db_Insert("featurebox", $fbInfo);
$admin_log->logArrayAll('FBLAN_01',$fbInfo);
$message = FBLAN_15;
}
if(isset($_POST['updateFB']))
{
$sql->db_UpdateArray('featurebox',$fbInfo, 'WHERE `fb_id`='.intval($_POST['fb_id']));
$admin_log->logArrayAll('FBLAN_02',$fbInfo);
$message = FBLAN_16;
}
}
else
{
$message = FBLAN_17;
}
}
if (($action == "delete") && $id)
{
$sql->db_Delete("featurebox", "fb_id=".$id);
$admin_log->log_event('FBLAN_03',$id,E_LOG_INFORMATIVE,'');
$message = FBLAN_18;
}
if (isset($message))
{
$ns->tablerender("", "<div style='text-align:center'><b>".$message."</b></div>");
}
if($headline_total = $sql->db_Select("featurebox"))
{
$nfArray = $sql -> db_getList();
$text = "<div style='text-align:center'>
<table class='fborder' style='".ADMIN_WIDTH.";'>
<tr>
<td class='forumheader' style='width: 5%; text-align: center;'>ID</td>
<td class='forumheader' style='width: 50%;'>".FBLAN_07."</td>
<td class='forumheader' style='width: 10%; text-align: center;'>".FBLAN_19."</td>
</tr>\n";
foreach($nfArray as $entry)
{
$text .= "
<tr>
<td class='forumheader' style='width: 5%; text-align: center;'>".$entry['fb_id']."</td>
<td class='forumheader' style='width: 50%;'>".$entry['fb_title']."</td>
<td class='forumheader' style='width: 10%; text-align: center;'>
<a href='".e_SELF."?edit.".$entry['fb_id']."'>".FBLAN_20."</a> - <a href='".e_SELF."?delete.".$entry['fb_id']."'>".FBLAN_21."</a>
</td>
</tr>
";
}
$text .= "</table>\n</div>";
}
else
{
$text = FBLAN_05;
}
$ns->tablerender(FBLAN_06, $text);
if($action == "edit")
{
if($sql->db_Select("featurebox", "*", "fb_id=".$id))
{
$row = $sql->db_Fetch();
extract($row);
}
}
else
{
unset($fb_name, $fb_text, $fb_mode, $fb_class);
}
$text = "<div style='text-align:center'>
<form method='post' action='".e_SELF."'>\n
<table style='".ADMIN_WIDTH."' class='fborder'>
<tr>
<td style='width:50%' class='forumheader3'>".FBLAN_07."</td>
<td style='width:50%; text-align: left;' class='forumheader3'>
<input class='tbox' type='text' name='fb_title' style='width: 80%' value='{$fb_title}' maxlength='200' />
</td>
</tr>
<tr>
<td style='width:50%' class='forumheader3'>".FBLAN_08."</td>
<td style='width:50%; text-align: left;' class='forumheader3'>
<textarea class='tbox' name='fb_text' style='width: 90%' rows='6'>{$fb_text}</textarea>
</td>
</tr>
<tr>
<td style='width:50%' class='forumheader3'>".FBLAN_09."</td>
<td style='width:50%; text-align: left;' class='forumheader3'>
".r_userclass("fb_class", $fb_class, 'off', "public, guests, nobody, member, admin, classes")."
</td>
</tr>
<tr>
<td style='width:50%' class='forumheader3'>".FBLAN_12."</td>
<td style='width:50%; text-align: left;' class='forumheader3'>
<input type='radio' name='fb_mode' value='0'".(!$fb_mode ? " checked='checked'" : "")." /> ".FBLAN_13."&nbsp;<br />
<input type='radio' name='fb_mode' value='1'".($fb_mode == 1 ? " checked='checked'" : "")." /> ".FBLAN_14."
</td>
</tr>
<tr>
<td style='width:50%' class='forumheader3'>".FBLAN_22."</td>
<td style='width:50%; text-align: left;' class='forumheader3'>
<input type='radio' name='fb_rendertype' value='0'".(!$fb_rendertype ? " checked='checked'" : "")." /> ".FBLAN_23."&nbsp;<br />
<input type='radio' name='fb_rendertype' value='1'".($fb_rendertype == 1 ? " checked='checked'" : "")." /> ".FBLAN_24."
</td>
</tr>
<tr>
<td style='width:50%' class='forumheader3'>".FBLAN_25."<br /><span class='smalltext'>".FBLAN_26."</span></td>
<td style='width:50%; text-align: left;' class='forumheader3'>
<select class='tbox' name='fb_template'>
";
foreach($templatelist as $value)
{
$file = str_replace(".php", "", $value['fname']);
$text .= "<option".($file == $fb_template ? " selected='selected'" : "").">$file</option>\n";
}
$text .= "</select>
</td>
</tr>
<tr style='vertical-align:top'>
<td colspan='2' style='text-align:center' class='forumheader'>
<input class='button' type='submit' name='".($action == "edit" ? "updateFB" : "createFB")."' value='".($action == "edit" ? FBLAN_11 : FBLAN_10)."' />
</td>
</tr>
</table>
".($action == "edit" ? "<input type='hidden' name='fb_id' value='{$fb_id}' />" : "")."
</form>
</div>";
$caption = ($action == "edit" ? FBLAN_11 : FBLAN_10);
$ns->tablerender($caption, $text);
e107::getAdminUI()->runPage();
require_once(e_ADMIN."footer.php");
exit;
?>

View File

@ -0,0 +1,67 @@
<?php
/*
* e107 website system
*
* Copyright (c) 2008-2009 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Custom FAQ install/uninstall/update routines
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/featurebox/featurebox_setup.php,v $
* $Revision: 1.1 $
* $Date: 2009-11-24 14:48:34 $
* $Author: e107coders $
*
*/
class featurebox_setup
{
/*
function install_pre($var)
{
// print_a($var);
// echo "custom install 'pre' function<br /><br />";
}
*/
function install_post($var)
{
$sql = e107::getDb();
$mes = e107::getMessage();
$query = "
INSERT INTO #featurebox (`fb_id`, `fb_title`, `fb_text`, `fb_mode`, `fb_class`, `fb_rendertype`, `fb_template`, `fb_order`, `fb_image`, `fb_imageurl`, `fb_category`) VALUES
(1, 'Default Title', 'Default Message', 0, 0, 0, '0', 0, '', '', 0);
";
$query2 = "
INSERT INTO #featurebox_cat (`fb_cat_id`, `fb_cat_title`, `fb_cat_class`, `fb_cat_order`) VALUES
(1, 'General', 0, 0);
";
//FIXME - I should be able to put both INSERTs into the same $query. MySQL class issue.
$status = ($sql->db_Select_gen($query)) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
$mes->add("Adding Default table data.",$status);
$status = ($sql->db_Select_gen($query2)) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
$mes->add("Adding Default table data.",$status);
}
/*
function uninstall_options()
{
}
function uninstall_post($var)
{
// print_a($var);
}
function upgrade_post($var)
{
// $sql = e107::getDb();
}
*/
}
?>

View File

@ -6,5 +6,17 @@ CREATE TABLE featurebox (
fb_class smallint(5) unsigned NOT NULL default '0',
fb_rendertype tinyint(1) unsigned NOT NULL default '0',
fb_template varchar(50) NOT NULL default '',
fb_order tinyint(3) unsigned NOT NULL default '0',
fb_image varchar(255) NOT NULL default '',
fb_imageurl varchar(255) NOT NULL default '',
fb_category tinyint(3) unsigned NOT NULL default '0',
PRIMARY KEY (fb_id)
) TYPE=MyISAM;
CREATE TABLE featurebox_cat (
fb_cat_id int(10) unsigned NOT NULL auto_increment,
fb_cat_title varchar(200) NOT NULL default '',
fb_cat_class int(3) unsigned default '0',
fb_cat_order int(3) unsigned NOT NULL default '0',
PRIMARY KEY (fb_cat_id)
) TYPE=MyISAM;

View File

@ -0,0 +1,37 @@
<?php
/*
+ ----------------------------------------------------------------------------+
| e107 website system
|
| Copyright (c) e107 Inc. 2001-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/featurebox/templates/featurebox_template.php,v $
| $Revision: 1.1 $
| $Date: 2009-11-24 14:48:34 $
| $Author: e107coders $
+----------------------------------------------------------------------------+
*/
$FEATUREBOX_TEMPLATE['default'] = "
<div class='defaulttext'><b>$fb_title</b></div>
<hr />
$fb_text
";
$FEATUREBOX_TEMPLATE['centered'] = "
<div class='defaulttext' style='text-align: center;'><b>$fb_title</b>
<hr />
$fb_text
</div>
<br /><br />
";
?>