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

new featurebox - work in progress

This commit is contained in:
secretr 2009-11-26 17:15:46 +00:00
parent d61aced8d4
commit c54b2651c1
5 changed files with 187 additions and 79 deletions

View File

@ -11,9 +11,9 @@
| 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 $
| $Revision: 1.10 $
| $Date: 2009-11-26 17:15:46 $
| $Author: secretr $
+----------------------------------------------------------------------------+
*/
require_once("../../class2.php");
@ -35,8 +35,8 @@ class fb_admin extends e_admin_dispatcher
'ui' => 'fb_admin_form_ui',
'uipath' => null
),
'cat' => array(
'controller' => 'fb_cat_ui',
'category' => array(
'controller' => 'fb_category_ui',
'path' => null,
'ui' => 'fb_cat_form_ui',
'uipath' => null
@ -46,35 +46,76 @@ class fb_admin extends e_admin_dispatcher
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'),
'category/list' => array('caption'=> 'Categories', 'perm' => 'P'),
'category/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'
'main/edit' => 'main/list',
'category/edit' => 'category/list'
);
protected $menuTitle = 'featurebox';
}
class fb_cat_ui extends e_admin_ui
class fb_category_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')
);
protected $pluginTitle = 'Feature Box';
protected $pluginName = 'featurebox';
protected $table = "featurebox_category";
protected $pid = "fb_category_id";
protected $perPage = 0; //no limit
protected $fields = array(
'checkboxes' => array('title'=> '', 'type' => null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center'),
'fb_category_id' => array('title'=> LAN_ID, 'type' => 'number', 'data' => 'int', 'width' =>'5%', 'forced'=> TRUE),
'fb_category_title' => array('title'=> LAN_TITLE, 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'validate' => 'str', 'rule' => '1-200', 'error' => 'String between 1-200 characters expected', 'help' => 'up to 200 characters', 'thclass' => 'left'),
'fb_category_layout' => array('title'=> 'Layout', 'type' => 'dropdown', 'data' => 'str', 'width' => 'auto', 'thclass' => 'left', 'batch' => true, 'filter' => true),
'fb_category_random' => array('title'=> 'Random', 'type' => 'boolean', 'data' => 'int', 'width' => '5%', 'thclass' => 'center', 'class' => 'center', 'batch' => true, 'filter' => true),
'fb_category_class' => array('title'=> LAN_VISIBILITY, 'type' => 'userclass', 'data' => 'int', 'width' => 'auto'),
'fb_category_limit' => array('title'=> 'Limit', 'type' => 'number', 'data' => 'int', 'width' => '5%', 'thclass' => 'left', 'help' => 'number of items to be shown'),
'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'width' => '10%', 'forced'=>TRUE, 'thclass' => 'center last', 'class' => 'center')
);
function init()
{
// build layout dropdown params
$templates = array();
$templates['default'] = 'Default';
$tmp = e107::getFile()->get_files(e_PLUGIN.'featurebox/templates/layout');
foreach($tmp as $files)
{
$key = str_replace('_template.php', '', $files['fname']);
$templates[$key] = implode(' ', array_map('ucfirst', explode('_', $key))); //TODO add LANS?
}
// TODO we need something like getFrontTheme()/getAdminTheme() - this will fail on user theme!
$tmp = e107::getFile()->get_files(e_THEME.e107::getPref('sitetheme').'/featurebox/templates/layout');
foreach($tmp as $files)
{
$key = str_replace('_template.php', '', $files['fname']);
$templates[$key] = implode(' ', array_map('ucfirst', explode('_', $key))); //TODO add LANS?
}
$this->fields['fb_category_layout']['readParms'] = $templates;
$this->fields['fb_category_layout']['writeParms'] = $templates;
}
/**
* User defined pre-delete logic
*/
public function beforeDelete($data, $id)
{
if (e107::getDb()->db_Count('featurebox', '(*)', 'fb_category='.intval($id)))
{
$this->getTreeModel()->addMessageWarning("Can't delete <strong>{$data['fb_category_title']}</strong> - category is in use!");
return false;
}
return true;
}
}
/*class fb_cat_form_ui extends e_admin_form_ui
@ -83,38 +124,38 @@ class fb_cat_ui extends e_admin_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' ),
//TODO Move to Class above.
protected $pluginTitle = 'Feature Box';
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' => 'url', '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')
);
'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')
);
@ -132,12 +173,13 @@ class fb_main_ui extends e_admin_ui
}
if(e107::getDb()->db_Select('featurebox_cat'))
if(e107::getDb()->db_Select('featurebox_category'))
{
$categories[0] = LAN_SELECT;
while ($row = e107::getDb()->db_Fetch())
{
$id = $row['fb_cat_id'];
$categories[$id] = $row['fb_cat_title'];
$id = $row['fb_category_id'];
$categories[$id] = $row['fb_category_title'];
}
}

View File

@ -9,9 +9,9 @@
* 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 $
* $Revision: 1.2 $
* $Date: 2009-11-26 17:15:46 $
* $Author: secretr $
*
*/
@ -35,7 +35,7 @@ class featurebox_setup
";
$query2 = "
INSERT INTO #featurebox_cat (`fb_cat_id`, `fb_cat_title`, `fb_cat_class`, `fb_cat_order`) VALUES
INSERT INTO #featurebox_category (`fb_category_id`, `fb_category_title`, `fb_category_class`, `fb_category_order`) VALUES
(1, 'General', 0, 0);
";

View File

@ -1,22 +1,25 @@
CREATE TABLE featurebox (
fb_id int(10) unsigned NOT NULL auto_increment,
fb_title varchar(200) NOT NULL default '',
fb_text text NOT NULL,
fb_mode tinyint(3) unsigned NOT NULL default '0',
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)
`fb_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`fb_title` varchar(200) NOT NULL DEFAULT '',
`fb_text` text NOT NULL,
`fb_mode` tinyint(3) unsigned NOT NULL DEFAULT '0',
`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` text NOT NULL,
`fb_category` tinyint(3) unsigned NOT NULL,
PRIMARY KEY (`fb_id`),
KEY `fb_category` (`fb_category`)
) 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)
CREATE TABLE featurebox_category (
`fb_category_id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
`fb_category_title` varchar(200) NOT NULL DEFAULT '',
`fb_category_layout` varchar(50) NOT NULL DEFAULT 'default',
`fb_category_random` tinyint(1) unsigned NOT NULL DEFAULT '0',
`fb_category_class` smallint(5) unsigned NOT NULL DEFAULT '0',
`fb_category_limit` tinyint(3) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`fb_category_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/layout/default_template.php,v $
| $Revision: 1.1 $
| $Date: 2009-11-26 17:15:45 $
| $Author: secretr $
+----------------------------------------------------------------------------+
*/
$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 />
";
?>

View File

@ -360,6 +360,32 @@ input.action.edit {}
/********** Element Loading Status default style */
.element-loading-mask { background-repeat: no-repeat; background-position: 50% 50%; background-color: #f5f5f5; }
/********** Auto complete default style */
div.e-autocomplete {
position:absolute;
width:250px;
background-color:white;
border:1px solid #c0c0c0;
margin:0;
padding:0;
}
div.e-autocomplete ul {
list-style-type:none;
margin:0;
padding:0;
font-weight: bold; font-size: 11px
}
div.e-autocomplete ul li.selected { background-color: #f5f5f5;}
div.e-autocomplete ul li {
list-style-type:none;
display:block;
margin:0;
padding: 5px;
cursor:pointer;
}
div.e-autocomplete ul li span.informal { font-weight: normal; font-size: 9px}
/********** Docs */
#docs-list { padding: 10px; margin-bottom: 15px; border: 1px solid #f5f5f5; }
#docs-list .qitem { margin: 3px 0; padding-left: 10px; }