mirror of
https://github.com/e107inc/e107.git
synced 2025-08-12 01:25:01 +02:00
featurebox front-end - work in progress
This commit is contained in:
@@ -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 '<img src="'.$src.'" alt="'.$tp->toAttribute($this->get('fb_category_title')).'" class="icon" />';
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user