1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 20:00:37 +02:00

Featurebox tabbed content support added (new core 'tabs' template)

This commit is contained in:
secretr
2009-12-12 16:35:46 +00:00
parent c6ade9d33a
commit e7410e2440
6 changed files with 131 additions and 130 deletions

View File

@@ -1,7 +1,7 @@
<?php <?php
/* /*
* Copyright (c) e107 Inc 2009 - e107.org, Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt) * Copyright (c) e107 Inc 2009 - e107.org, Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id: e_shortcode.php,v 1.10 2009-12-11 14:38:26 secretr Exp $ * $Id: e_shortcode.php,v 1.11 2009-12-12 16:35:45 secretr Exp $
* *
* Featurebox shortcode batch class - shortcodes available site-wide. ie. equivalent to multiple .sc files. * Featurebox shortcode batch class - shortcodes available site-wide. ie. equivalent to multiple .sc files.
*/ */
@@ -49,10 +49,11 @@ class featurebox_shortcodes // must match the plugin's folder name. ie. [PLUGIN_
return ''; return '';
} }
$tmpl = $this->getFboxTemplate($category); $tmpl = $this->getFboxTemplate($ctemplate);
$tp = e107::getParser(); $tp = e107::getParser();
$category->updateParams($parm);
$ret = $tp->parseTemplate($tmpl['list_start'], true, $category).$this->render($category, $parm).$tp->parseTemplate($tmpl['list_end'], true, $category); $ret = $tp->parseTemplate($tmpl['list_start'], true, $category).$this->render($category, $ctemplate, $parm).$tp->parseTemplate($tmpl['list_end'], true, $category);
if(isset($parm['notablestyle'])) if(isset($parm['notablestyle']))
{ {
return $ret; return $ret;
@@ -66,7 +67,8 @@ class featurebox_shortcodes // must match the plugin's folder name. ie. [PLUGIN_
* Available parameters (GET string format) * Available parameters (GET string format)
* - loop (boolean): loop using 'nav_loop' template, default 0 * - loop (boolean): loop using 'nav_loop' template, default 0
* - base (string): template key prefix, default is 'nav'. Example: 'mynav' base key will search templates 'mynav_start', 'mynav_loop', 'mynav_end'. * - base (string): template key prefix, default is 'nav'. Example: 'mynav' base key will search templates 'mynav_start', 'mynav_loop', 'mynav_end'.
* - nolimit (boolean): ignore 'limit' field , us 'total' items number for navigation looping * - nolimit (boolean): ignore 'limit' field , use 'total' items number for navigation looping
* - uselimit (boolean): ignore 'limit' field , use 'total' items number for navigation looping
* *
* @param string $parm parameters * @param string $parm parameters
* @param string $mod category template * @param string $mod category template
@@ -99,24 +101,65 @@ class featurebox_shortcodes // must match the plugin's folder name. ie. [PLUGIN_
{ {
return ''; return '';
} }
$tmpl = $this->getFboxTemplate($ctemplate);
$tmpl = $this->getFboxTemplate($category);
if($category->get('fb_category_random')) if($category->get('fb_category_random'))
{ {
$parm['loop'] = 0; $parm['loop'] = 0;
} }
$base = vartrue($parm['base'], 'nav').'_'; $base = vartrue($parm['base'], 'nav').'_';
$tree_ids = array_keys($tree->getTree()); //all available item ids
$ret = $category->toHTML(varset($tmpl[$base.'start']), true); $ret = $category->toHTML(varset($tmpl[$base.'start']), true);
$cols = $category->getParam('cols');
if(isset($parm['loop']) && $tree->getTotal() > 0 && vartrue($tmpl[$base.'item'])) if(isset($parm['loop']) && $tree->getTotal() > 0 && vartrue($tmpl[$base.'item']))
{ {
if(isset($parm['nolimit'])) $total = $tree->getTotal(); // loop for all
else $total = ceil($tree->getTotal() / ($category->sc_featurebox_category_limit() ? intval($category->sc_featurebox_category_limit()) : $tree->getTotal()) ); if(isset($parm['nolimit']))
{
$total = $tree->getTotal();
}
// loop for limit number
elseif(isset($parm['uselimit']))
{
$total = $category->sc_featurebox_category_limit() ? intval($category->sc_featurebox_category_limit()) : $tree->getTotal();
}
// default - number based on all / limit (usefull for ajax navigation)
else
{
$total = ceil($tree->getTotal() / ($category->sc_featurebox_category_limit() ? intval($category->sc_featurebox_category_limit()) : $tree->getTotal()) );
}
if($cols > 1)
{
$total = ceil($total / $cols);
}
$model = clone $category; $model = clone $category;
$item = new plugin_featurebox_item();
$tmp = array(); $tmp = array();
for ($index = 1; $index <= $total; $index++) for ($index = 1; $index <= $total; $index++)
{ {
$nodeid = varset($tree_ids[($index - 1) * $cols], 0);
if($nodeid && $tree->hasNode($nodeid))
{
$model->setParam('counter', $index)
->setParam('total', $total)
->setParam('active', $index == varset($parm['from'], 1));
$node = $tree->getNode($nodeid);
e107::getScParser()->resetScClass('plugin_featurebox_category', $model);
$node->setCategory($model)
->setParam('counter', $index)
->setParam('total', $total)
->setParam('limit', $category->get('fb_category_limit'))
;
$tmp[] = $node->toHTML($tmpl[$base.'item'], true);
continue;
}
e107::getScParser()->resetScClass('plugin_featurebox_item', $item);
$tmp[] = $model->setParam('counter', $index) $tmp[] = $model->setParam('counter', $index)
->setParam('active', $index == varset($parm['from'], 1)) ->setParam('active', $index == varset($parm['from'], 1))
->toHTML($tmpl[$base.'item'], true); ->toHTML($tmpl[$base.'item'], true);
@@ -174,17 +217,18 @@ class featurebox_shortcodes // must match the plugin's folder name. ie. [PLUGIN_
{ {
return ''; return '';
} }
return $this->render($category, $parm); return $this->render($category, $ctemplate, $parm);
} }
/** /**
* Render featurebox list * Render featurebox list
* @param plugin_featurebox_category $category * @param plugin_featurebox_category $category
* @param string $ctemplate category template
* @param array $parm * @param array $parm
*/ */
public function render($category, $parm) public function render($category, $ctemplate, $parm)
{ {
$tmpl = $this->getFboxTemplate($category); $tmpl = $this->getFboxTemplate($ctemplate);
$cols = intval(vartrue($parm['cols'], 1)); $cols = intval(vartrue($parm['cols'], 1));
$limit = intval(varset($parm['limit'], $category->sc_featurebox_category_limit())); $limit = intval(varset($parm['limit'], $category->sc_featurebox_category_limit()));
$from = (intval(vartrue($parm['from'], 1)) - 1) * $limit; $from = (intval(vartrue($parm['from'], 1)) - 1) * $limit;
@@ -238,7 +282,7 @@ class featurebox_shortcodes // must match the plugin's folder name. ie. [PLUGIN_
$tmpl_item .= $tmpl['col_end']; $tmpl_item .= $tmpl['col_end'];
} }
// else add item separator // else add item separator
else elseif($cols != $col_counter && 1 != $col_counter)
{ {
$tmpl_item .= $tmpl['item_separator']; $tmpl_item .= $tmpl['item_separator'];
} }
@@ -292,15 +336,15 @@ class featurebox_shortcodes // must match the plugin's folder name. ie. [PLUGIN_
/** /**
* Retrieve template array by category * Retrieve template array by category
* *
* @param plugin_featurebox_category $category * @param string $ctemplate
* @return array * @return array
*/ */
public function getFboxTemplate($category) public function getFboxTemplate($ctemplate)
{ {
$tmpl = e107::getTemplate('featurebox', 'featurebox_category', $category->get('fb_category_template'), 'front'); $tmpl = e107::getTemplate('featurebox', 'featurebox_category', $ctemplate, 'front');
if(!$tmpl && e107::getTemplate('featurebox', 'featurebox_category', $category->get('fb_category_template'), false)) if(!$tmpl && e107::getTemplate('featurebox', 'featurebox_category', $ctemplate, false))
{ {
$tmpl = e107::getTemplate('featurebox', 'featurebox_category', $category->get('fb_category_template'), false); // plugin template $tmpl = e107::getTemplate('featurebox', 'featurebox_category', $ctemplate, false); // plugin template
} }
elseif(!$tmpl && e107::getTemplate('featurebox', 'featurebox_category', 'default')) elseif(!$tmpl && e107::getTemplate('featurebox', 'featurebox_category', 'default'))
{ {

View File

@@ -9,9 +9,9 @@
* Featurebox Item model * Featurebox Item model
* *
* $Source: /cvs_backup/e107_0.8/e107_plugins/featurebox/includes/item.php,v $ * $Source: /cvs_backup/e107_0.8/e107_plugins/featurebox/includes/item.php,v $
* $Revision: 1.7 $ * $Revision: 1.8 $
* $Date: 2009-12-12 10:30:33 $ * $Date: 2009-12-12 16:35:46 $
* $Author: e107coders $ * $Author: secretr $
* *
*/ */
@@ -87,10 +87,6 @@ class plugin_featurebox_item extends e_model
$src = $tp->replaceConstants($this->get('fb_image'), 'full'); $src = $tp->replaceConstants($this->get('fb_image'), 'full');
//FIXME - doesn't display anything that uses {e_MEDIA} in the path.
if(isset($parm['src'])) if(isset($parm['src']))
{ {
return $src; return $src;
@@ -192,7 +188,7 @@ class plugin_featurebox_item extends e_model
*/ */
public function __call($method, $arguments) public function __call($method, $arguments)
{ {
if (strpos($method, "sc_featurebox_category_") === 0) if (strpos($method, "sc_featurebox_") === 0)
{ {
return call_user_func_array(array($this->getCategory(), $method), $arguments); return call_user_func_array(array($this->getCategory(), $method), $arguments);
} }

View File

@@ -1,17 +1,10 @@
<?php <?php
/* /*
* e107 website system * Copyright (c) e107 Inc 2009 - e107.org, Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id: English_admin_featurebox.php,v 1.5 2009-12-12 16:35:46 secretr Exp $
* *
* Copyright (C) 2008-2009 e107 Inc (e107.org) * Featurebox back-end laguage defines
* Released under the terms and conditions of the * TODO - cleanup constants not in use
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/featurebox/languages/English_admin_featurebox.php,v $
* $Revision: 1.4 $
* $Date: 2009-12-08 17:21:34 $
* $Author: secretr $
*/ */
define("FBLAN_01", "Feature Box"); define("FBLAN_01", "Feature Box");

View File

@@ -1,17 +1,9 @@
<?php <?php
/* /*
* e107 website system * Copyright (c) e107 Inc 2009 - e107.org, Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id: English_front_featurebox.php,v 1.2 2009-12-12 16:35:46 secretr Exp $
* *
* Copyright (C) 2008-2009 e107 Inc (e107.org) * Featurebox front-end laguage defines
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/featurebox/languages/English_front_featurebox.php,v $
* $Revision: 1.1 $
* $Date: 2009-12-09 18:36:32 $
* $Author: secretr $
*/ */
define("FBLAN_01", "Feature Box"); define("FBLAN_01", "Feature Box");

View File

@@ -1,4 +1,12 @@
<?php <?php
/*
* Copyright (c) e107 Inc 2009 - e107.org, Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id: featurebox_category_template.php,v 1.5 2009-12-12 16:35:46 secretr Exp $
*
* Featurebox core category templates
*/
// TODO - list of all available shortcodes & schortcode parameters
// avoid PHP warnings // avoid PHP warnings
$FEATUREBOX_CATEGORY_TEMPLATE = array(); $FEATUREBOX_CATEGORY_TEMPLATE = array();
@@ -83,77 +91,39 @@ $FEATUREBOX_CATEGORY_TEMPLATE['dynamic']['js_inline'] = 'new Featurebox(\'featur
//TODO - tabs template. //TODO - tabs template.
$FEATUREBOX_CATEGORY_TEMPLATE['tabs']['list_start'] = ''; $FEATUREBOX_CATEGORY_TEMPLATE['tabs']['list_start'] = '
<div class="box featurebox admintabs" id="featurebox-tab-container">
$FEATUREBOX_CATEGORY_TEMPLATE['tabs']['list_end'] = ''; {FEATUREBOX_NAVIGATION|tabs=loop&uselimit}
// For Reference:
/*
<div class="admintabs" id="tab-container">
<div class="tabs">
<ul class="e-tabs e-hideme clearer" id="front-tabs">
<li id="tab-01"><a href="#tab-01-activate"><span>'.LAN_THEME_TAB_1.'</span></a></li>
<li id="tab-02"><a href="#tab-02-activate"><span>'.LAN_THEME_TAB_2.'</span></a></li>
<li id="tab-03"><a href="#tab-03-activate"><span>'.LAN_THEME_TAB_3.'</span></a></li>
<li id="tab-04"><a href="#tab-04-activate"><span>'.LAN_THEME_TAB_4.'</span></a></li>
</ul>
</div>
<div class="tab-content-wrap"> <div class="tab-content-wrap">
';
<div id="tab-01-activate"> $FEATUREBOX_CATEGORY_TEMPLATE['tabs']['list_end'] = '
<div class="tab-content">
{MENU=2}
</div> </div>
<div class="clear"><!-- --></div>
</div> </div>
';
<div id="tab-02-activate"> // no column support
$FEATUREBOX_CATEGORY_TEMPLATE['tabs']['col_start'] = '<div id="tab-{FEATUREBOX_COLSCOUNT}-activate"><div class="tab-content">';
$FEATUREBOX_CATEGORY_TEMPLATE['tabs']['col_end'] = '</div></div>';
<div class="tab-content"> // ajax navigation (unobtrusive)
$FEATUREBOX_CATEGORY_TEMPLATE['tabs']['item_start'] = '';
$FEATUREBOX_CATEGORY_TEMPLATE['tabs']['item_end'] = '';
$FEATUREBOX_CATEGORY_TEMPLATE['tabs']['item_separator'] = '<div class="clear"><!-- --></div>';
{MENU=3} // empty item - used with col templates, no shortcodes just basic markup
$FEATUREBOX_CATEGORY_TEMPLATE['tabs']['item_empty'] = '';
</div> $FEATUREBOX_CATEGORY_TEMPLATE['tabs']['nav_start'] = '<div class="tabs"><ul class="e-tabs clear" id="front-tabs">';
$FEATUREBOX_CATEGORY_TEMPLATE['tabs']['nav_item'] = '<li id="featurebox-tab-{FEATUREBOX_NAV_COUNTER}"><a href="#tab-{FEATUREBOX_NAV_COUNTER}-activate"><span>{FEATUREBOX_TITLE}</span></a></li>';
</div> $FEATUREBOX_CATEGORY_TEMPLATE['tabs']['nav_end'] = '</ul></div>';
$FEATUREBOX_CATEGORY_TEMPLATE['tabs']['nav_separator'] = '';
<div id="tab-03-activate">
<div class="tab-content">
{MENU=4}
</div>
</div>
<div id="tab-04-activate">
<div class="tab-content">
{MENU=5}
</div>
</div>
</div>
</div>
*/
// external JS, comma separated list
$FEATUREBOX_CATEGORY_TEMPLATE['tabs']['js'] = '{e_FILE}jslib/core/tabs.js';
// inline JS, without <script> tags
$FEATUREBOX_CATEGORY_TEMPLATE['tabs']['js_inline'] = 'new e107Widgets.Tabs("featurebox-tab-container", { bookmarkFix: false });';
/** /**
* Template information. * Template information.
@@ -164,9 +134,9 @@ $FEATUREBOX_CATEGORY_TEMPLATE['tabs']['list_end'] = '';
* *
* @var array * @var array
*/ */
$FEATUREBOX_CATEGORY_TEMPLATE['__INFO__'] = array( $FEATUREBOX_CATEGORY_INFO = array(
'default' => array('title' => 'Default - show by category limit'), 'default' => array('title' => 'Default (core)', 'description' => 'Flat - show by category limit'),
'dynamic' => array('title' => 'Dynamic (AJAX) loading'), 'dynamic' => array('title' => 'Dynamic (core)', 'description' => 'Load items on click (AJAX)'),
'tabs' => array('title' => 'Tabs') 'tabs' => array('title' => 'Tabs (core)' , 'description' => 'Tabbed Feature box items')
); );
?> ?>

View File

@@ -1,4 +1,11 @@
<?php <?php
/*
* Copyright (c) e107 Inc 2009 - e107.org, Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id: featurebox_template.php,v 1.6 2009-12-12 16:35:46 secretr Exp $
*
* Featurebox core item templates
*/
global $sc_style; global $sc_style;
$FEATUREBOX_TEMPLATE['default'] = ' $FEATUREBOX_TEMPLATE['default'] = '
@@ -26,10 +33,9 @@ $FEATUREBOX_TEMPLATE['image_right'] = '
</div> </div>
'; ';
$FEATUREBOX_TEMPLATE['__INFO__'] = array( $FEATUREBOX_INFO = array(
'default' => array('title' => 'Default - no image'), 'default' => array('title' => 'Default (core)', 'description' => 'Title and description - no image'),
'image_right' => array('title' => 'Image to right'), 'image_right' => array('title' => 'Right image (core)', 'description' => 'Right floated image'),
'image_left' => array('title' => 'Image to left'), 'image_left' => array('title' => 'Left image (core)' , 'description' => 'Left floated image')
); );
?> ?>