diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php index 09fe58352..e31c9dac0 100644 --- a/e107_handlers/e107_class.php +++ b/e107_handlers/e107_class.php @@ -9,8 +9,8 @@ * e107 Main * * $Source: /cvs_backup/e107_0.8/e107_handlers/e107_class.php,v $ - * $Revision: 1.88 $ - * $Date: 2009-12-02 16:51:02 $ + * $Revision: 1.89 $ + * $Date: 2009-12-08 17:21:32 $ * $Author: secretr $ */ @@ -1221,7 +1221,7 @@ class e107 { $reg_path = 'core/e107/templates/'.$id.($override ? '/ext' : ''); $path = self::coreTemplatePath($id, $override); - + $id = str_replace('/', '_', $id); return self::_getTemplate($id, $key, $reg_path, $path); } @@ -1254,7 +1254,7 @@ class e107 { $reg_path = 'plugin/'.$plug_name.'/templates/'.$id.($override ? '/ext' : ''); $path = self::templatePath($plug_name, $id, $override); - + $id = str_replace('/', '_', $id); return self::_getTemplate($id, $key, $reg_path, $path); } @@ -1277,8 +1277,8 @@ class e107 $tmp = self::getTemplate($plugin_name, $id, null, $where); } - $templates = array(); - $filter_mask = explode($filter_mask); + $templates = array(); + $filter_mask = $filter_mask ? explode(',', $filter_mask) : array(); foreach($tmp as $key => $val) { // Special key INFO in format aray('layout' => array(info)) @@ -1289,7 +1289,7 @@ class e107 $match = true; if($filter_mask) { - $match = false; + $match = false; foreach ($filter_mask as $mask) { if(strpos($key, $mask) === 0) //e.g. retrieve only keys starting with 'layout_' @@ -1325,7 +1325,7 @@ class e107 { $regPath = $reg_path; $var = strtoupper($id).'_TEMPLATE'; - + if(null === self::getRegistry($regPath)) { (deftrue('E107_DEBUG_LEVEL') ? include_once($path) : @include_once($path)); diff --git a/e107_handlers/model_class.php b/e107_handlers/model_class.php index 5b9fddc49..97bdf3c06 100644 --- a/e107_handlers/model_class.php +++ b/e107_handlers/model_class.php @@ -9,8 +9,8 @@ * e107 Base Model * * $Source: /cvs_backup/e107_0.8/e107_handlers/model_class.php,v $ - * $Revision: 1.46 $ - * $Date: 2009-11-28 15:34:46 $ + * $Revision: 1.47 $ + * $Date: 2009-12-08 17:21:33 $ * $Author: secretr $ */ @@ -850,7 +850,7 @@ class e_model */ public function load($id, $force = false) { - if(!$force && $this->hasData()) + if(!$force && $this->getId()) { return $this; } @@ -868,12 +868,18 @@ class e_model SELECT * FROM #'.$this->getModelTable().' WHERE '.$this->getFieldIdName().'='.$id.' '; } - //TODO - error reporting + $sql = e107::getDb(); if($sql->db_Select_gen($qry)) { $this->setData($sql->db_Fetch()); } + + if($sql->getLastErrorNumber()) + { + $this->addMessageDebug('SQL error #'.$sql->getLastErrorNumber().': '.$sql->getLastErrorText()); + } + return $this; } diff --git a/e107_plugins/banner/languages/English_admin_banner.php b/e107_plugins/banner/languages/English_admin_banner.php index 4c72198bb..695078e32 100644 --- a/e107_plugins/banner/languages/English_admin_banner.php +++ b/e107_plugins/banner/languages/English_admin_banner.php @@ -1,7 +1,7 @@ \ No newline at end of file diff --git a/e107_plugins/banner/plugin.xml b/e107_plugins/banner/plugin.xml index bc136c16b..d6482ba51 100644 --- a/e107_plugins/banner/plugin.xml +++ b/e107_plugins/banner/plugin.xml @@ -1,12 +1,13 @@ - + - FBLAN_02 + BNRLAN_100 + content Copyright e107 Inc e107.org, Licensed under GPL (http://www.gnu.org/licenses/gpl.txt) diff --git a/e107_plugins/featurebox/e_shortcode.php b/e107_plugins/featurebox/e_shortcode.php index d13467972..1b83f4a7f 100644 --- a/e107_plugins/featurebox/e_shortcode.php +++ b/e107_plugins/featurebox/e_shortcode.php @@ -1,16 +1,64 @@ loadByLayout($clayout); + if(!$category->hasData()) + { + return ''; + } + + $tree = $category->getItemTree(); + if($tree->isEmpty()) + { + return ''; + } + + $tmpl = e107::getTemplate('featurebox', 'layout/'.$category->get('fb_category_layout')); + if(!$tmpl) + { + $tmpl = e107::getTemplate('featurebox', 'layout/default'); + } + + $tp = e107::getParser(); + $ret = array(); + + $counter = 1; + foreach ($tree->getTree() as $id => $node) + { + $tmpl_item = e107::getTemplate('featurebox', 'featurebox', $node->get('fb_template')); + if(!$tmpl_item) + { + $tmpl_item = e107::getTemplate('featurebox', 'featurebox', 'default'); + } + + $ret[] = $node->setParam('counter', $counter) + ->setCategory($category) + ->toHTML($tmpl_item); + + //$ret[] = $node->toHTML($tmpl_item); + $counter++; + } + + return $tp->parseTemplate($tmpl['list_start'], true, $category).implode($ret['item_separator'], $ret).$tp->parseTemplate($tmpl['list_end'], true, $category); } } -?> \ No newline at end of file diff --git a/e107_plugins/featurebox/featurebox_setup.php b/e107_plugins/featurebox/featurebox_setup.php index d0eb19e4d..9431c3346 100644 --- a/e107_plugins/featurebox/featurebox_setup.php +++ b/e107_plugins/featurebox/featurebox_setup.php @@ -6,15 +6,17 @@ * 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 +* Custom Featurebox install/uninstall/update routines * * $Source: /cvs_backup/e107_0.8/e107_plugins/featurebox/featurebox_setup.php,v $ -* $Revision: 1.2 $ -* $Date: 2009-11-26 17:15:46 $ +* $Revision: 1.3 $ +* $Date: 2009-12-08 17:21:31 $ * $Author: secretr $ * */ +if (!defined('e107_INIT')) { exit; } + class featurebox_setup { /* @@ -26,25 +28,41 @@ class featurebox_setup */ function install_post($var) { - $sql = e107::getDb(); + e107::includeLan(e_PLUGIN.'featurebox/languages/'.e_LANGUAGE.'_admin_featurebox.php'); $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); - "; + $query = array(); + $query['fb_category_id'] = 0; + $query['fb_category_title'] = 'General'; + $query['fb_category_layout'] = 'default'; + $query['fb_category_random'] = 0; + $query['fb_category_class'] = e_UC_PUBLIC; + $query['fb_category_limit'] = 1; + $inserted = e107::getDb()->db_Insert('featurebox_category', $query); + $status = $inserted ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR; + $mes->add(FBLAN_INSTALL_01, $status); - $query2 = " - INSERT INTO #featurebox_category (`fb_category_id`, `fb_category_title`, `fb_category_class`, `fb_category_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); + if($inserted) + { + $query = array(); + $query['fb_id'] = 0; + $query['fb_category'] = $inserted; + $query['fb_title'] = 'Default Title'; + $query['fb_text'] = 'Default Message'; + $query['fb_mode'] = 0; + $query['fb_class'] = e_UC_PUBLIC; + $query['fb_rendertype'] = 0; + $query['fb_template'] = 'default'; + $query['fb_order'] = 0; + $query['fb_image'] = ''; + $query['fb_imageurl'] = 0; + $status = e107::getDb('sql2')->db_Insert('featurebox', $query) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR; + } + else + { + $status = E_MESSAGE_ERROR; + } + $mes->add(FBLAN_INSTALL_02, $status); } /* function uninstall_options() diff --git a/e107_plugins/featurebox/featurebox_sql.php b/e107_plugins/featurebox/featurebox_sql.php index 43004ab97..3c7c3ad13 100644 --- a/e107_plugins/featurebox/featurebox_sql.php +++ b/e107_plugins/featurebox/featurebox_sql.php @@ -1,3 +1,4 @@ + CREATE TABLE featurebox ( `fb_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `fb_title` varchar(200) NOT NULL DEFAULT '', diff --git a/e107_plugins/featurebox/includes/category.php b/e107_plugins/featurebox/includes/category.php index b3f85c535..a7e087d60 100644 --- a/e107_plugins/featurebox/includes/category.php +++ b/e107_plugins/featurebox/includes/category.php @@ -9,27 +9,97 @@ * Featurebox Category model * * $Source: /cvs_backup/e107_0.8/e107_plugins/featurebox/includes/category.php,v $ -* $Revision: 1.1 $ -* $Date: 2009-12-04 18:52:19 $ +* $Revision: 1.2 $ +* $Date: 2009-12-08 17:21:31 $ * $Author: secretr $ * */ +if (!defined('e107_INIT')) { exit; } + class plugin_featurebox_category extends e_model { /** * @var plugin_featurebox_tree */ protected $_tree = null; + + /** + * Data loaded check + * @var boolean + */ + protected $_loaded_data = null; + + /** + * @see e_model::_field_id + * @var string + */ + protected $_field_id = 'fb_category_id'; + + /** + * @see e_model::_db_table + * @var string + */ + protected $_db_table = 'featurebox_category'; + + /** + * Parameter (single string format): + * - alt: return title as tag attribute text + * @param string $parm + * @return string + */ + public function sc_featurebox_category_title($parm) + { + return ($parm == 'alt' ? e107::getParser()->toAttribute($this->get('fb_category_title')) : e107::getParser()->toHTML($this->get('fb_category_title'), false, 'TITLE')); + } + + /** + * Parameter (single string format): + * - src: return image src URL only + * + * @param string $parm + * @return string + */ + public function sc_featurebox_category_icon($parm) + { + if(!$this->get('fb_category_icon')) + { + return ''; + } + $tp = e107::getParser(); + + $src = $tp->replaceConstants($this->get('fb_category_icon'), 'full'); + if($parm == 'src') + { + return $src; + } + return ''.$tp->toAttribute($this->get('fb_category_title')).''; + } + + public function sc_featurebox_category_layout() + { + return $this->get('fb_category_layout'); + } /** * Load category data by layout + * TODO - system cache * * @param string $layout * @param boolean $force + * @return plugin_featurebox_category */ public function loadByLayout($layout, $force = false) { - //TODO + if($force || null === $this->_loaded_data) + { + if(e107::getDb()->db_Select('featurebox_category', '*', 'fb_category_class IN ('.USERCLASS_LIST.') AND fb_category_layout=\''.e107::getParser()->toDB($layout).'\'')) + { + $this->setData(e107::getDb()->db_Fetch()); + $this->_loaded_data = true; + } + } + $this->_loaded_data = false; + return $this; } /** @@ -39,12 +109,15 @@ class plugin_featurebox_category extends e_model * @param boolean $force * @return plugin_featurebox_tree */ - public function getTree($force = false) + public function getItemTree($force = false) { if($force || null === $this->_tree) { $this->_tree = new plugin_featurebox_tree(); - $options = array(); // TODO options + $options = array( + 'limit' => $this->getParam('limit', $this->get('fb_category_limit')), + 'random' => $this->getParam('random', $this->get('fb_category_random')) + ); $this->_tree->load($this->getId(), $options, $force); } @@ -54,12 +127,12 @@ class plugin_featurebox_category extends e_model /** * Set item tree * - * @param plugin_featurebox_tree $category_tree + * @param plugin_featurebox_tree $item_tree * @return plugin_featurebox_category */ - public function setTree($category_tree) + public function setItemTree($item_tree) { - $this->_tree = $category_tree; + $this->_tree = $item_tree; return $this; } } \ No newline at end of file diff --git a/e107_plugins/featurebox/includes/item.php b/e107_plugins/featurebox/includes/item.php index 957c1d187..f995dd1ef 100644 --- a/e107_plugins/featurebox/includes/item.php +++ b/e107_plugins/featurebox/includes/item.php @@ -9,14 +9,139 @@ * Featurebox Item model * * $Source: /cvs_backup/e107_0.8/e107_plugins/featurebox/includes/item.php,v $ -* $Revision: 1.1 $ -* $Date: 2009-12-04 18:52:19 $ +* $Revision: 1.2 $ +* $Date: 2009-12-08 17:21:32 $ * $Author: secretr $ * */ +if (!defined('e107_INIT')) { exit; } + // TODO - sc_* methods class plugin_featurebox_item extends e_model { + /** + * @see e_model::_field_id + * @var string + */ + protected $_field_id = 'fb_id'; -} \ No newline at end of file + /** + * @see e_model::_db_table + * @var string + */ + protected $_db_table = 'featurebox'; + + /** + * @var plugin_featurebox_category + */ + protected $_category = null; + + /** + * Parameter list (GET string format): + * - alt: return title as tag attribute text + * - url: add url tag to the output (only if 'fb_imageurl' is available) + * + * @param string $parm + * @return string + */ + public function sc_featurebox_title($parm = '') + { + parse_str($parm, $parm); + $tp = e107::getParser(); + if(isset($parm['alt'])) + { + return $tp->toAttribute($this->get('fb_title')); + } + + $ret = $tp->toHTML($this->get('fb_title'), false, 'TITLE'); + if(isset($parm['url']) && $this->get('fb_imageurl')) + { + return 'getId().' href="'.$tp->replaceConstants($this->get('fb_imageurl'), 'full').'" title="'.$tp->toAttribute($this->get('fb_title')).'" rel="'.$tp->toAttribute(vartrue($parm['rel'], 'external')).'">'.$ret.''; + } + + return $ret; + } + + public function sc_featurebox_text() + { + return e107::getParser()->toHTML($this->get('fb_text'), true, 'BODY'); + } + + /** + * Parameter list (GET string format): + * - src: return image src URL only + * - nourl: force no url tag + * + * @param string $parm + * @return string + */ + public function sc_featurebox_image($parm = '') + { + if(!$this->get('fb_image')) + { + return ''; + } + parse_str($parm, $parm); + $tp = e107::getParser(); + + $src = $tp->replaceConstants($this->get('fb_image'), 'full'); + if(isset($parm['src'])) + { + return $src; + } + $tag = 'getId().' src="'.$src.'" alt="'.$tp->toAttribute($this->get('fb_title')).'" class="featurebox" />'; + if(isset($parm['nourl']) || !$this->get('fb_imageurl')) + { + return $tag; + } + return 'getId().' href="'.$tp->replaceConstants($this->get('fb_imageurl'), 'full').'" title="'.$tp->toAttribute($this->get('fb_title')).'" rel="'.$tp->toAttribute(vartrue($parm['rel'], 'external')).'">'.$tag.''; + } + + public function sc_featurebox_counter() + { + return $this->getParam('counter', 1); + } + + /** + * Set current category + * @param plugin_featurebox_category $category + * @return plugin_featurebox_item + */ + public function setCategory($category) + { + $this->_category = $category; + return $this; + } + + /** + * Get Category model instance + * @return plugin_featurebox_category + */ + public function getCategory() + { + if(null === $this->_category) + { + $this->_category = new plugin_featurebox_category(); + $this->_category->load($this->get('fb_category')); + } + return $this->_category; + } + + /** + * Magic call - category shortcodes + * + * @param string $method + * @param array $arguments + */ + public function __call($method, $arguments) + { + if (strpos($method, "sc_featurebox_category_") === 0) + { + return call_user_func_array(array($this->getCategory(), $method), $arguments); + } + } +} + + + diff --git a/e107_plugins/featurebox/includes/tree.php b/e107_plugins/featurebox/includes/tree.php index 7e7db703f..eb349b319 100644 --- a/e107_plugins/featurebox/includes/tree.php +++ b/e107_plugins/featurebox/includes/tree.php @@ -9,14 +9,17 @@ * Featurebox Category Tree model * * $Source: /cvs_backup/e107_0.8/e107_plugins/featurebox/includes/tree.php,v $ -* $Revision: 1.1 $ -* $Date: 2009-12-04 18:52:19 $ +* $Revision: 1.2 $ +* $Date: 2009-12-08 17:21:32 $ * $Author: secretr $ * */ +if (!defined('e107_INIT')) { exit; } + class plugin_featurebox_tree extends e_tree_model { + protected $_field_id = 'fb_id'; /** * Load tree data * TODO - system cache @@ -32,13 +35,16 @@ class plugin_featurebox_tree extends e_tree_model { return $this; } + + $this->setParam('model_class', 'plugin_featurebox_item') + ->setParam('model_message_stack', 'featurebox'); + + $this->updateParams($options); - $this->setParams(array( - 'model_class' => 'plugin_featurebox_item', - 'model_message_stack' => 'featurebox' - )); - - // TODO - options -> limit, random; set param 'db_query' + $order = $this->getParam('random') ? ' ORDER BY rand()' : ' ORDER BY fb_order ASC'; + $limit = $this->getParam('limit') ? ' LIMIT 0,'.intval($this->getParam('limit')) : ''; + $qry = 'SELECT SQL_CALC_FOUND_ROWS * FROM #featurebox WHERE fb_category='.intval($category_id).' AND fb_class IN('.USERCLASS_LIST.')'.$order.$limit; + $this->setParam('db_query', $qry); parent::load($force); diff --git a/e107_plugins/featurebox/languages/English_admin_featurebox.php b/e107_plugins/featurebox/languages/English_admin_featurebox.php index f5158d3d7..438a35a6f 100644 --- a/e107_plugins/featurebox/languages/English_admin_featurebox.php +++ b/e107_plugins/featurebox/languages/English_admin_featurebox.php @@ -9,9 +9,9 @@ * * * $Source: /cvs_backup/e107_0.8/e107_plugins/featurebox/languages/English_admin_featurebox.php,v $ - * $Revision: 1.3 $ - * $Date: 2009-11-18 01:05:36 $ - * $Author: e107coders $ + * $Revision: 1.4 $ + * $Date: 2009-12-08 17:21:34 $ + * $Author: secretr $ */ define("FBLAN_01", "Feature Box"); @@ -46,5 +46,7 @@ define('LAN_AL_FBLAN_01', 'Featurebox created'); define('LAN_AL_FBLAN_02', 'Featurebox updated'); define('LAN_AL_FBLAN_03', 'Featurebox deleted'); - +// Install/uninstall messages +define('FBLAN_INSTALL_01', 'Adding Default category table data.'); +define('FBLAN_INSTALL_02', 'Adding Default table data.'); ?> \ No newline at end of file diff --git a/e107_plugins/featurebox/plugin.xml b/e107_plugins/featurebox/plugin.xml index 63550e916..15e1a3e80 100644 --- a/e107_plugins/featurebox/plugin.xml +++ b/e107_plugins/featurebox/plugin.xml @@ -1,18 +1,23 @@ - + - + FBLAN_02 content + + Configure feature box + Manage Items + Create Item + Manage Categories + Create Category + Copyright e107 Inc e107.org, Licensed under GPL (http://www.gnu.org/licenses/gpl.txt) + - - Configure feature box - 1 diff --git a/e107_plugins/featurebox/templates/featurebox_template.php b/e107_plugins/featurebox/templates/featurebox_template.php index 7c773ac3f..99daa44b6 100644 --- a/e107_plugins/featurebox/templates/featurebox_template.php +++ b/e107_plugins/featurebox/templates/featurebox_template.php @@ -1,37 +1,33 @@ $fb_title -
-$fb_text -"; - - - -$FEATUREBOX_TEMPLATE['centered'] = " -
$fb_title -
-$fb_text +$FEATUREBOX_TEMPLATE['default'] = ' +
+

{FEATUREBOX_TITLE|default}

+
{FEATUREBOX_TEXT|default}
-

-"; +'; +$sc_style['FEATUREBOX_IMAGE|image_left']['pre'] = '
'; +$sc_style['FEATUREBOX_IMAGE|image_left']['post'] = '
'; +$FEATUREBOX_TEMPLATE['image_right'] = ' +
+
{FEATUREBOX_IMAGE|image_left}

{FEATUREBOX_TITLE|image_left}

{FEATUREBOX_TEXT|image_left}
+
+'; + +$sc_style['FEATUREBOX_IMAGE|image_right']['pre'] = '
'; +$sc_style['FEATUREBOX_IMAGE|image_right']['post'] = '
'; +$FEATUREBOX_TEMPLATE['image_right'] = ' +
+
{FEATUREBOX_IMAGE|image_right}

{FEATUREBOX_TITLE|image_right}

{FEATUREBOX_TEXT|image_right}
+
+'; + +$FEATUREBOX_TEMPLATE['__INFO__'] = array( + 'deafult' => array('title' => 'Default - no image'), + 'image_right' => array('title' => 'Image to right'), + 'image_left' => array('title' => 'Image to left'), +); ?> \ 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 index 0d1f8f235..cc9cf7e77 100644 --- a/e107_plugins/featurebox/templates/layout/default_template.php +++ b/e107_plugins/featurebox/templates/layout/default_template.php @@ -1,37 +1,19 @@ +

{FEATUREBOX_CATEGORY_ICON}{FEATUREBOX_CATEGORY_TITLE}

+
+'; -$FEATUREBOX_TEMPLATE['default'] = " -
$fb_title
-
-$fb_text -"; - - - -$FEATUREBOX_TEMPLATE['centered'] = " -
$fb_title -
-$fb_text +$LAYOUT_DEFAULT_TEMPLATE['list_end'] = ' +
-

-"; +'; + +$LAYOUT_DEFAULT_TEMPLATE['item_start'] = ''; +$LAYOUT_DEFAULT_TEMPLATE['item_end'] = ''; +$LAYOUT_DEFAULT_TEMPLATE['item_separator'] = ''; ?> \ No newline at end of file diff --git a/e107_themes/jayya/theme.php b/e107_themes/jayya/theme.php index f05a6751c..2b535a1e9 100644 --- a/e107_themes/jayya/theme.php +++ b/e107_themes/jayya/theme.php @@ -9,9 +9,9 @@ * * * $Source: /cvs_backup/e107_0.8/e107_themes/jayya/theme.php,v $ - * $Revision: 1.11 $ - * $Date: 2009-11-18 01:06:02 $ - * $Author: e107coders $ + * $Revision: 1.12 $ + * $Date: 2009-12-08 17:21:35 $ + * $Author: secretr $ */ // Protect the file from direct access @@ -73,6 +73,7 @@ $HEADER['3_column'] = "
{SETSTYLE=default} +{FEATUREBOX|default} {WMESSAGE} ";