mirror of
https://github.com/e107inc/e107.git
synced 2025-09-01 18:32:44 +02:00
featurebox front-end - done, dynamic part and cleanup in progress
This commit is contained in:
@@ -1,20 +1,18 @@
|
||||
<?php
|
||||
/*
|
||||
+ ----------------------------------------------------------------------------+
|
||||
| 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.11 $
|
||||
| $Date: 2009-11-28 15:34:46 $
|
||||
| $Author: secretr $
|
||||
+----------------------------------------------------------------------------+
|
||||
* 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)
|
||||
*
|
||||
* Featurebox administration
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_plugins/featurebox/admin_config.php,v $
|
||||
* $Revision: 1.12 $
|
||||
* $Date: 2009-12-09 18:33:40 $
|
||||
* $Author: secretr $
|
||||
*
|
||||
*/
|
||||
require_once("../../class2.php");
|
||||
if (!getperms("P") || !plugInstalled('featurebox'))
|
||||
@@ -23,7 +21,7 @@ if (!getperms("P") || !plugInstalled('featurebox'))
|
||||
exit;
|
||||
}
|
||||
|
||||
include_lan(e_PLUGIN."featurebox/languages/".e_LANGUAGE."_admin_featurebox.php");
|
||||
e107::includeLan(e_PLUGIN.'featurebox/languages/'.e_LANGUAGE.'_admin_featurebox.php');
|
||||
|
||||
class fb_admin extends e_admin_dispatcher
|
||||
{
|
||||
@@ -69,15 +67,15 @@ class fb_category_ui extends e_admin_ui
|
||||
protected $perPage = 0; //no limit
|
||||
|
||||
protected $fields = array(
|
||||
'checkboxes' => array('title'=> '', 'type' => null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center first'),
|
||||
'fb_category_id' => array('title'=> LAN_ID, 'type' => 'number', 'data' => 'int', 'width' =>'5%', 'forced'=> TRUE),
|
||||
'fb_category_icon' => array('title'=> LAN_ICON, 'type' => 'icon', 'data' => 'str', 'width' => '5%', 'thclass' => 'center', 'class'=>'center'),
|
||||
'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'=> 'Render type', 'type' => 'templates', 'data' => 'str', 'width' => 'auto', 'thclass' => 'left', 'writeParms' => 'plugin=featurebox&location=layout&default=Default', '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, 0 - show all'),
|
||||
'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'width' => '10%', 'forced'=>TRUE, 'thclass' => 'center last', 'class' => 'center')
|
||||
'checkboxes' => array('title'=> '', 'type' => null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center first'),
|
||||
'fb_category_id' => array('title'=> LAN_ID, 'type' => 'number', 'data' => 'int', 'width' =>'5%', 'forced'=> TRUE),
|
||||
'fb_category_icon' => array('title'=> LAN_ICON, 'type' => 'icon', 'data' => 'str', 'width' => '5%', 'thclass' => 'center', 'class'=>'center'),
|
||||
'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_template' => array('title'=> 'Category template', 'type' => 'layouts', 'data' => 'str', 'width' => 'auto', 'thclass' => 'left', 'writeParms' => 'plugin=featurebox&id=featurebox_category&merge=1', '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, 0 - show all'),
|
||||
'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'width' => '10%', 'forced'=>TRUE, 'thclass' => 'center last', 'class' => 'center')
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -132,9 +130,9 @@ class fb_category_ui extends e_admin_ui
|
||||
{
|
||||
if($this->getModel()->getSqlErrorNumber() == 1062)
|
||||
{
|
||||
$templates = $this->getFieldAttr('fb_category_layout', 'writeParms', array());
|
||||
$templates = $this->getFieldAttr('fb_category_template', 'writeParms', array());
|
||||
$msg = e107::getMessage();
|
||||
$msg->error('Layout <strong>'.vartrue($templates[$new_data['fb_category_layout']], 'n/a').'</strong> is in use by another category. Layout should be unique per category. ');
|
||||
$msg->error('Layout <strong>'.vartrue($templates[$new_data['fb_category_template']], 'n/a').'</strong> is in use by another category. Layout should be unique per category. ');
|
||||
$msg->error($mod == 'create' ? LAN_CREATED_FAILED : LAN_UPDATED_FAILED);
|
||||
|
||||
return (!E107_DEBUG_LEVEL); // suppress messages (TRUE) only when not in debug mod
|
||||
@@ -173,13 +171,9 @@ class fb_main_ui extends e_admin_ui
|
||||
'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 $fieldpref = array('checkboxes', 'fb_id', 'fb_category', 'fb_title', 'fb_template', 'fb_class', 'fb_order', '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')
|
||||
);
|
||||
protected $prefs = array();
|
||||
|
||||
|
||||
|
||||
@@ -188,7 +182,7 @@ class fb_main_ui extends e_admin_ui
|
||||
$categories = array();
|
||||
if(e107::getDb()->db_Select('featurebox_category'))
|
||||
{
|
||||
$categories[0] = LAN_SELECT;
|
||||
//$categories[0] = LAN_SELECT;
|
||||
while ($row = e107::getDb()->db_Fetch())
|
||||
{
|
||||
$id = $row['fb_category_id'];
|
||||
|
@@ -1,27 +1,48 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (c) e107 Inc 2009 - e107.org, Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
|
||||
* $Id: e_shortcode.php,v 1.2 2009-12-08 17:21:30 secretr Exp $
|
||||
* $Id: e_shortcode.php,v 1.3 2009-12-09 18:33:37 secretr Exp $
|
||||
*
|
||||
* Featurebox shortcode batch class - shortcodes available site-wide. ie. equivalent to multiple .sc files.
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
e107::includeLan(e_PLUGIN.'featurebox/languages/'.e_LANGUAGE.'_front_featurebox.php');
|
||||
|
||||
class featurebox_shortcodes // must match the plugin's folder name. ie. [PLUGIN_FOLDER]_shortcodes
|
||||
{
|
||||
/**
|
||||
* Available parameters (GET string format)
|
||||
* - cols (integer): number of items per column, default 1
|
||||
* - no_fill_empty (boolean): don't fill last column with empty items (if required), default 0
|
||||
* - tablestyle (string): mode to be used with <code>tablerender()</code>, default 'featurebox'
|
||||
* - notablestyle (null): if isset - disable <code>tablerender()</code>
|
||||
*
|
||||
* @param string $parm parameters
|
||||
* @param string $mod category template
|
||||
*/
|
||||
function sc_featurebox($parm, $mod = '')
|
||||
{
|
||||
// TODO cache
|
||||
if(!e107::isInstalled('featurebox')) //just in case
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
if(!$mod)
|
||||
{
|
||||
$clayout = 'default';
|
||||
$ctemplate = 'default';
|
||||
}
|
||||
else
|
||||
{
|
||||
$clayout = $mod;
|
||||
$ctemplate = $mod;
|
||||
}
|
||||
|
||||
parse_str($parm, $parm);
|
||||
|
||||
$category = new plugin_featurebox_category();
|
||||
$category->loadByLayout($clayout);
|
||||
$category->loadByTemplate($ctemplate);
|
||||
if(!$category->hasData())
|
||||
{
|
||||
return '';
|
||||
@@ -33,16 +54,15 @@ class featurebox_shortcodes // must match the plugin's folder name. ie. [PLUGIN_
|
||||
return '';
|
||||
}
|
||||
|
||||
$tmpl = e107::getTemplate('featurebox', 'layout/'.$category->get('fb_category_layout'));
|
||||
if(!$tmpl)
|
||||
{
|
||||
$tmpl = e107::getTemplate('featurebox', 'layout/default');
|
||||
}
|
||||
$tmpl = $this->getFboxTemplate($category);
|
||||
|
||||
$tp = e107::getParser();
|
||||
$ret = array();
|
||||
|
||||
$cols = intval(vartrue($parm['cols'], 1));
|
||||
$counter = 1;
|
||||
$col_counter = 1;
|
||||
$total = count($tree->getTree());
|
||||
foreach ($tree->getTree() as $id => $node)
|
||||
{
|
||||
$tmpl_item = e107::getTemplate('featurebox', 'featurebox', $node->get('fb_template'));
|
||||
@@ -51,14 +71,133 @@ class featurebox_shortcodes // must match the plugin's folder name. ie. [PLUGIN_
|
||||
$tmpl_item = e107::getTemplate('featurebox', 'featurebox', 'default');
|
||||
}
|
||||
|
||||
$ret[] = $node->setParam('counter', $counter)
|
||||
// reset column counter
|
||||
if($col_counter > $cols)
|
||||
{
|
||||
$col_counter = 1;
|
||||
}
|
||||
|
||||
// add column start
|
||||
if(1 == $col_counter && vartrue($tmpl['col_start']))
|
||||
{
|
||||
$tmpl_item = $tmpl['col_start'].$tmpl_item;
|
||||
}
|
||||
|
||||
// there is more
|
||||
if(($total - $counter) > 0)
|
||||
{
|
||||
// add column end if column end reached
|
||||
if($cols == $col_counter && vartrue($tmpl['col_end']))
|
||||
{
|
||||
$tmpl_item .= $tmpl['col_end'];
|
||||
}
|
||||
// else add item separator
|
||||
else
|
||||
{
|
||||
$tmpl_item .= $ret['item_separator'];
|
||||
}
|
||||
}
|
||||
// no more items - clean & close
|
||||
else
|
||||
{
|
||||
$empty_cnt = $cols - $col_counter;
|
||||
if($empty_cnt > 0 && !isset($parm['no_fill_empty']))
|
||||
{
|
||||
// empty items fill
|
||||
for ($index = 1; $index <= $empty_cnt; $index++)
|
||||
{
|
||||
$tmpl_item .= $ret['item_separator'].varset($ret['item_empty'], '<div><!-- --></div>');
|
||||
}
|
||||
}
|
||||
// add column end
|
||||
$tmpl_item .= varset($tmpl['col_end']);
|
||||
}
|
||||
|
||||
$ret[$counter] = $node->setParam('counter', $counter)
|
||||
->setCategory($category)
|
||||
->toHTML($tmpl_item);
|
||||
|
||||
//$ret[] = $node->toHTML($tmpl_item);
|
||||
|
||||
$counter++;
|
||||
$col_counter++;
|
||||
}
|
||||
|
||||
return $tp->parseTemplate($tmpl['list_start'], true, $category).implode($ret['item_separator'], $ret).$tp->parseTemplate($tmpl['list_end'], true, $category);
|
||||
$ret = $tp->parseTemplate($tmpl['list_start'], true, $category).implode('', $ret).$tp->parseTemplate($tmpl['list_end'], true, $category);
|
||||
if(isset($parm['notablestyle']))
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
|
||||
return e107::getRender()->tablerender(FBLAN_01, $ret, vartrue($parm['tablestyle'], 'featurebox'), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render featurebox navigation
|
||||
* Available parameters (GET string format)
|
||||
* - cols (integer): number of items per column, default 1
|
||||
* - no_fill_empty (boolean): don't fill last column with empty items (if required), default 0
|
||||
* - tablestyle (string): mode to be used with <code>tablerender()</code>, default 'featurebox'
|
||||
* - notablestyle (null): if isset - disable <code>tablerender()</code>
|
||||
*
|
||||
* @param string $parm parameters
|
||||
* @param string $mod category template
|
||||
*/
|
||||
function sc_featurebox_navigation($parm, $mod = '')
|
||||
{
|
||||
// TODO cache
|
||||
if(!e107::isInstalled('featurebox')) //just in case
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
if(!$mod)
|
||||
{
|
||||
$ctemplate = 'default';
|
||||
}
|
||||
else
|
||||
{
|
||||
$ctemplate = $mod;
|
||||
}
|
||||
|
||||
parse_str($parm, $parm);
|
||||
|
||||
$category = new plugin_featurebox_category();
|
||||
$category->loadByTemplate($ctemplate);
|
||||
if(!$category->hasData())
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
$tree = $category->getItemTree();
|
||||
if($tree->isEmpty())
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
$tmpl = $this->getFboxTemplate($category);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve template array by category
|
||||
*
|
||||
* @param plugin_featurebox_category $category
|
||||
* @return array
|
||||
*/
|
||||
public function getFboxTemplate($category)
|
||||
{
|
||||
$tmpl = e107::getTemplate('featurebox', 'featurebox_category', $category->get('fb_category_template'), 'front');
|
||||
if(!$tmpl && e107::getTemplate('featurebox', 'featurebox_category', $category->get('fb_category_template'), false))
|
||||
{
|
||||
$tmpl = e107::getTemplate('featurebox', 'featurebox_category', $category->get('fb_category_template'), false); // plugin template
|
||||
}
|
||||
elseif(!$tmpl && e107::getTemplate('featurebox', 'featurebox_category', 'default'))
|
||||
{
|
||||
$tmpl = e107::getTemplate('featurebox', 'featurebox_category', 'default'); // theme/plugin default template
|
||||
}
|
||||
elseif(!$tmpl)
|
||||
{
|
||||
$tmpl = e107::getTemplate('featurebox', 'featurebox_category', 'default', false); //plugin default
|
||||
}
|
||||
return $tmpl;
|
||||
}
|
||||
}
|
||||
|
@@ -9,8 +9,8 @@
|
||||
* Custom Featurebox install/uninstall/update routines
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_plugins/featurebox/featurebox_setup.php,v $
|
||||
* $Revision: 1.3 $
|
||||
* $Date: 2009-12-08 17:21:31 $
|
||||
* $Revision: 1.4 $
|
||||
* $Date: 2009-12-09 18:33:40 $
|
||||
* $Author: secretr $
|
||||
*
|
||||
*/
|
||||
@@ -34,7 +34,7 @@ class featurebox_setup
|
||||
$query = array();
|
||||
$query['fb_category_id'] = 0;
|
||||
$query['fb_category_title'] = 'General';
|
||||
$query['fb_category_layout'] = 'default';
|
||||
$query['fb_category_template'] = 'default';
|
||||
$query['fb_category_random'] = 0;
|
||||
$query['fb_category_class'] = e_UC_PUBLIC;
|
||||
$query['fb_category_limit'] = 1;
|
||||
@@ -55,7 +55,7 @@ class featurebox_setup
|
||||
$query['fb_template'] = 'default';
|
||||
$query['fb_order'] = 0;
|
||||
$query['fb_image'] = '';
|
||||
$query['fb_imageurl'] = 0;
|
||||
$query['fb_imageurl'] = '';
|
||||
$status = e107::getDb('sql2')->db_Insert('featurebox', $query) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
|
||||
}
|
||||
else
|
||||
|
@@ -19,10 +19,10 @@ CREATE TABLE featurebox_category (
|
||||
`fb_category_id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`fb_category_title` varchar(200) NOT NULL DEFAULT '',
|
||||
`fb_category_icon` varchar(255) NOT NULL DEFAULT '',
|
||||
`fb_category_layout` varchar(50) NOT NULL DEFAULT 'default',
|
||||
`fb_category_template` 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 '1',
|
||||
PRIMARY KEY (`fb_category_id`),
|
||||
UNIQUE KEY `fb_category_layout` (`fb_category_layout`)
|
||||
UNIQUE KEY `fb_category_template` (`fb_category_template`)
|
||||
) TYPE=MyISAM;
|
Reference in New Issue
Block a user