From c54b2651c184647d4b2fa1c36c0773075722c479 Mon Sep 17 00:00:00 2001 From: secretr Date: Thu, 26 Nov 2009 17:15:46 +0000 Subject: [PATCH] new featurebox - work in progress --- e107_plugins/featurebox/admin_config.php | 156 +++++++++++------- e107_plugins/featurebox/featurebox_setup.php | 8 +- e107_plugins/featurebox/featurebox_sql.php | 39 +++-- .../templates/layout/default_template.php | 37 +++++ e107_themes/_blank/admin_style.css | 26 +++ 5 files changed, 187 insertions(+), 79 deletions(-) create mode 100644 e107_plugins/featurebox/templates/layout/default_template.php diff --git a/e107_plugins/featurebox/admin_config.php b/e107_plugins/featurebox/admin_config.php index 6625e9f51..aac1edfca 100644 --- a/e107_plugins/featurebox/admin_config.php +++ b/e107_plugins/featurebox/admin_config.php @@ -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 {$data['fb_category_title']} - 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']; } } diff --git a/e107_plugins/featurebox/featurebox_setup.php b/e107_plugins/featurebox/featurebox_setup.php index bbd357747..d0eb19e4d 100644 --- a/e107_plugins/featurebox/featurebox_setup.php +++ b/e107_plugins/featurebox/featurebox_setup.php @@ -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); "; diff --git a/e107_plugins/featurebox/featurebox_sql.php b/e107_plugins/featurebox/featurebox_sql.php index f12fbf99c..45dc23068 100644 --- a/e107_plugins/featurebox/featurebox_sql.php +++ b/e107_plugins/featurebox/featurebox_sql.php @@ -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; \ No newline at end of file diff --git a/e107_plugins/featurebox/templates/layout/default_template.php b/e107_plugins/featurebox/templates/layout/default_template.php new file mode 100644 index 000000000..0d1f8f235 --- /dev/null +++ b/e107_plugins/featurebox/templates/layout/default_template.php @@ -0,0 +1,37 @@ +$fb_title +
+$fb_text +"; + + + +$FEATUREBOX_TEMPLATE['centered'] = " +
$fb_title +
+$fb_text +
+

+"; + + +?> \ No newline at end of file diff --git a/e107_themes/_blank/admin_style.css b/e107_themes/_blank/admin_style.css index 3b0e098fc..5b0bc27be 100644 --- a/e107_themes/_blank/admin_style.css +++ b/e107_themes/_blank/admin_style.css @@ -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; }