mirror of
https://github.com/e107inc/e107.git
synced 2025-08-04 13:47:31 +02:00
- Featurebox batch copy feature added (example implementation - page administration), plugin upgrade required
- Lost admin UI messages issue solved - Featurebox list items view now sortable
This commit is contained in:
@@ -308,7 +308,7 @@ class page_admin_ui extends e_admin_ui
|
|||||||
//protected $url = array('profile'=>'page/view', 'name' => 'page_title', 'description' => '', 'link'=>'{e_BASE}page.php?id=[id]'); // 'link' only needed if profile not provided.
|
//protected $url = array('profile'=>'page/view', 'name' => 'page_title', 'description' => '', 'link'=>'{e_BASE}page.php?id=[id]'); // 'link' only needed if profile not provided.
|
||||||
protected $url = array('route'=>'page/view/index', 'vars' => array('id' => 'page_id', 'sef' => 'page_sef'), 'name' => 'page_title', 'description' => ''); // 'link' only needed if profile not provided.
|
protected $url = array('route'=>'page/view/index', 'vars' => array('id' => 'page_id', 'sef' => 'page_sef'), 'name' => 'page_title', 'description' => ''); // 'link' only needed if profile not provided.
|
||||||
protected $tabs = array("Page","Page Options","Menu");
|
protected $tabs = array("Page","Page Options","Menu");
|
||||||
protected $featurebox = array('title'=>'page_title', 'text'=>'page_text');
|
protected $featurebox = array('name'=>'page_title', 'description'=>'page_text', 'image' => 'menu_image', 'visibility' => 'page_class', 'url' => true);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 'fb_title' => array('title'=> LAN_TITLE, 'type' => 'text', 'inline'=>true, 'width' => 'auto', 'thclass' => 'left'),
|
* 'fb_title' => array('title'=> LAN_TITLE, 'type' => 'text', 'inline'=>true, 'width' => 'auto', 'thclass' => 'left'),
|
||||||
|
@@ -2343,6 +2343,13 @@ class e_admin_controller_ui extends e_admin_controller
|
|||||||
*/
|
*/
|
||||||
protected $url = array();
|
protected $url = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO Example:
|
||||||
|
* Contains required data for mapping featurebox fields
|
||||||
|
* @var array edit/create form tabs
|
||||||
|
*/
|
||||||
|
protected $featurebox = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Structure same as TreeModel parameters used for building the load() SQL
|
* Structure same as TreeModel parameters used for building the load() SQL
|
||||||
* @var additional SQL to be applied when auto-building the list query
|
* @var additional SQL to be applied when auto-building the list query
|
||||||
@@ -4038,8 +4045,8 @@ class e_admin_ui extends e_admin_controller_ui
|
|||||||
{
|
{
|
||||||
if($this->_add2nav($selected))
|
if($this->_add2nav($selected))
|
||||||
{
|
{
|
||||||
//e107::getMessage()->moveToSession();
|
e107::getMessage()->moveToSession();
|
||||||
//$this->redirect();
|
$this->redirect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4053,15 +4060,11 @@ class e_admin_ui extends e_admin_controller_ui
|
|||||||
{
|
{
|
||||||
if($this->_add2featurebox($selected))
|
if($this->_add2featurebox($selected))
|
||||||
{
|
{
|
||||||
//e107::getMessage()->moveToSession();
|
e107::getMessage()->moveToSession();
|
||||||
//$this->redirect();
|
$this->redirect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected function _add2nav($selected)
|
protected function _add2nav($selected)
|
||||||
{
|
{
|
||||||
if(empty($selected)) return false;// TODO warning message
|
if(empty($selected)) return false;// TODO warning message
|
||||||
@@ -4131,12 +4134,6 @@ class e_admin_ui extends e_admin_controller_ui
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected function _add2featurebox($selected)
|
protected function _add2featurebox($selected)
|
||||||
{
|
{
|
||||||
if(empty($selected)) return false;// TODO warning message
|
if(empty($selected)) return false;// TODO warning message
|
||||||
@@ -4144,28 +4141,38 @@ class e_admin_ui extends e_admin_controller_ui
|
|||||||
if(!is_array($selected)) $selected = array($selected);
|
if(!is_array($selected)) $selected = array($selected);
|
||||||
|
|
||||||
$sql = e107::getDb();
|
$sql = e107::getDb();
|
||||||
//$allData = $this->getFeaturebox();
|
$tree = $this->getTreeModel();
|
||||||
$allData = $this->getTreeModel()->featurebox($selected, array('sc' => true), true);
|
$urlData = $this->getTreeModel()->url($selected, array('sc' => true), false);
|
||||||
|
$data = $this->featurebox;
|
||||||
e107::getMessage()->addDebug('Using Featurebox Info:'.print_a($data,true));
|
|
||||||
|
|
||||||
|
|
||||||
// print_a($allData);
|
|
||||||
echo "EXIT";
|
|
||||||
exit;
|
|
||||||
|
|
||||||
|
|
||||||
$scount = 0;
|
$scount = 0;
|
||||||
foreach($allData as $id => $data)
|
foreach($selected as $id)
|
||||||
{
|
{
|
||||||
$name = $data['name'];
|
if(!$tree->hasNode($id))
|
||||||
$desc = $data['text'];
|
{
|
||||||
|
e107::getMessage()->addError('Item #ID '.htmlspecialchars($id).' not found.');
|
||||||
|
continue; // TODO message
|
||||||
|
}
|
||||||
|
|
||||||
$fbArray = array(
|
$model = $tree->getNode($id);
|
||||||
'fb_title' => varset($data['name']),
|
if($data['url'] === true)
|
||||||
'fb_text' => varset($data['text']),
|
{
|
||||||
'fb_image' => varset($data['image']),
|
$url = $urlData[$id];
|
||||||
'fb_imageurl' => varset($data['url']),
|
}
|
||||||
|
else $url = $model->get($data['url']);
|
||||||
|
$name = $model->get($data['name']);
|
||||||
|
|
||||||
|
$category = e107::getDb()->retrieve('featurebox_category', 'fb_category_id', "fb_category_template='unassigned'");
|
||||||
|
|
||||||
|
$fbArray = array (
|
||||||
|
'fb_title' => $name,
|
||||||
|
'fb_text' => $model->get($data['description']),
|
||||||
|
'fb_image' => vartrue($data['image']) ? $model->get($data['image']) : '',
|
||||||
|
'fb_imageurl' => $url,
|
||||||
|
'fb_class' => isset($data['visibility']) && $data['visibility'] !== false ? $model->get($data['visibility']) : e_UC_ADMIN,
|
||||||
|
'fb_template' => 'default',
|
||||||
|
'fb_category' => $category, // TODO popup - choose category
|
||||||
|
'fb_order' => $scount,
|
||||||
);
|
);
|
||||||
|
|
||||||
$res = $sql->insert('featurebox', $fbArray);
|
$res = $sql->insert('featurebox', $fbArray);
|
||||||
@@ -4193,7 +4200,7 @@ class e_admin_ui extends e_admin_controller_ui
|
|||||||
|
|
||||||
if($scount > 0)
|
if($scount > 0)
|
||||||
{
|
{
|
||||||
e107::getMessage()->addSuccess("<br /><strong>{$scount}</strong> new sitelinks were added but are currently unassigned. You should now modify these links to your liking.<br /><br /><a class='btn btn-small btn-primary' href='".e_ADMIN_ABS."links.php?searchquery=&filter_options=link_category__255'>Modify Links</a>");
|
e107::getMessage()->addSuccess("<br /><strong>{$scount}</strong> new featurebox items were added but are currently unassigned. You should now modify these items to your liking.<br /><br /><a class='btn btn-small btn-primary' href='".e_PLUGIN_ABS."featurebox/admin_config.php?searchquery=&filter_options=fb_category__{$category}'>Modify Featurebox Items</a>");
|
||||||
return $scount;
|
return $scount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3561,38 +3561,4 @@ class e_admin_tree_model extends e_front_tree_model
|
|||||||
}
|
}
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get urls/url data for given nodes
|
|
||||||
*/
|
|
||||||
public function featurebox($ids, $options = array(), $extended = false)
|
|
||||||
{
|
|
||||||
$ret = array();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
foreach ($ids as $id)
|
|
||||||
{
|
|
||||||
|
|
||||||
// print_a($this->getData());
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(!$this->hasNode($id)) continue;
|
|
||||||
|
|
||||||
$model = $this->getNode($id);
|
|
||||||
;
|
|
||||||
print_a($this->getData());
|
|
||||||
|
|
||||||
|
|
||||||
// if($this->getFeaturebox()) $model->setFeaturebox($this->getFeaturebox()); // copy url config data if available
|
|
||||||
// $ret[$id] = $model->featurebox($options, $extended);
|
|
||||||
// print_a($ret);
|
|
||||||
}
|
|
||||||
return $ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@@ -78,7 +78,7 @@ class e_pref extends e_front_model
|
|||||||
require_once(e_HANDLER.'cache_handler.php');
|
require_once(e_HANDLER.'cache_handler.php');
|
||||||
|
|
||||||
$this->prefid = preg_replace('/[^\w\-]/', '', $prefid);
|
$this->prefid = preg_replace('/[^\w\-]/', '', $prefid);
|
||||||
e107::getMessage()->setUnique($this->prefid); // attempt to fix
|
|
||||||
if(empty($alias))
|
if(empty($alias))
|
||||||
{
|
{
|
||||||
$alias = $prefid;
|
$alias = $prefid;
|
||||||
@@ -502,6 +502,7 @@ class e_pref extends e_front_model
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
e107::getMessage()->setUnique($this->prefid); // attempt to fix
|
||||||
|
|
||||||
if($from_post)
|
if($from_post)
|
||||||
{
|
{
|
||||||
|
@@ -79,11 +79,44 @@ class fb_category_ui extends e_admin_ui
|
|||||||
'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'width' => '10%', 'forced'=>TRUE, 'thclass' => 'center last', 'class' => 'center')
|
'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'width' => '10%', 'forced'=>TRUE, 'thclass' => 'center last', 'class' => 'center')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
public function init()
|
||||||
|
{
|
||||||
|
### Prevent modification of the 'unassigned' system category
|
||||||
|
if($this->getAction() == 'edit')
|
||||||
|
{
|
||||||
|
$this->getModel()->load((int) $this->getId());
|
||||||
|
|
||||||
|
// FIXME lan
|
||||||
|
if($this->getModel()->get('fb_category_template') === 'unassigned')
|
||||||
|
{
|
||||||
|
e107::getMessage()->addError("<strong>".FBLAN_INSTALL_03."</strong> is system category and can't be modified.", 'default', true);
|
||||||
|
$this->redirect('list');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif($this->getAction() == 'inline')
|
||||||
|
{
|
||||||
|
$this->getModel()->load((int) $this->getId());
|
||||||
|
if($this->getModel()->get('fb_category_template') === 'unassigned')
|
||||||
|
{
|
||||||
|
$protocol = (isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0');
|
||||||
|
header($protocol.': 403 Forbidden', true, 403);
|
||||||
|
echo "'".FBLAN_INSTALL_03."' is system category and can't be modified.";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prevent deletion of categories in use
|
* Prevent deletion of categories in use
|
||||||
*/
|
*/
|
||||||
public function beforeDelete($data, $id)
|
public function beforeDelete($data, $id)
|
||||||
{
|
{
|
||||||
|
// FIXME lan
|
||||||
|
if($data['fb_category_template'] === 'unassigned')
|
||||||
|
{
|
||||||
|
$this->getTreeModel()->addMessageError("<strong>".FBLAN_INSTALL_03."</strong> is system category and can't be deleted.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (e107::getDb()->db_Count('featurebox', '(*)', 'fb_category='.intval($id)))
|
if (e107::getDb()->db_Count('featurebox', '(*)', 'fb_category='.intval($id)))
|
||||||
{
|
{
|
||||||
$this->getTreeModel()->addMessageWarning("Can't delete <strong>{$data['fb_category_title']}</strong> - category is in use!");
|
$this->getTreeModel()->addMessageWarning("Can't delete <strong>{$data['fb_category_title']}</strong> - category is in use!");
|
||||||
@@ -105,7 +138,7 @@ class fb_category_ui extends e_admin_ui
|
|||||||
if(!varset($new_data['fb_category_template']))
|
if(!varset($new_data['fb_category_template']))
|
||||||
{
|
{
|
||||||
$new_data['fb_category_template'] = 'default';
|
$new_data['fb_category_template'] = 'default';
|
||||||
}
|
}var_dump($new_data);
|
||||||
return $new_data;
|
return $new_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,6 +202,9 @@ class fb_main_ui extends e_admin_ui
|
|||||||
protected $perPage = 10;
|
protected $perPage = 10;
|
||||||
protected $batchDelete = true;
|
protected $batchDelete = true;
|
||||||
protected $batchCopy = true;
|
protected $batchCopy = true;
|
||||||
|
protected $sortField = 'fb_order';
|
||||||
|
protected $orderStep = 1;
|
||||||
|
protected $listOrder = 'fb_order asc';
|
||||||
|
|
||||||
protected $fields = array(
|
protected $fields = array(
|
||||||
'checkboxes' => array('title'=> '', 'type' => null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center first', 'class'=>'center'),
|
'checkboxes' => array('title'=> '', 'type' => null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center first', 'class'=>'center'),
|
||||||
@@ -183,7 +219,7 @@ class fb_main_ui extends e_admin_ui
|
|||||||
'fb_imageurl' => array('title'=> "Image Link", 'type' => 'url', 'width' => 'auto'),
|
'fb_imageurl' => array('title'=> "Image Link", 'type' => 'url', 'width' => 'auto'),
|
||||||
'fb_class' => array('title'=> LAN_VISIBILITY, 'type' => 'userclass', 'data' => 'int', 'inline'=>true, 'width' => 'auto', 'filter' => true, 'batch' => true), // User id
|
'fb_class' => array('title'=> LAN_VISIBILITY, 'type' => 'userclass', 'data' => 'int', 'inline'=>true, 'width' => 'auto', 'filter' => true, 'batch' => true), // User id
|
||||||
'fb_order' => array('title'=> LAN_ORDER, 'type' => 'number', 'data'=> 'int','width' => '5%' ),
|
'fb_order' => array('title'=> LAN_ORDER, 'type' => 'number', 'data'=> 'int','width' => '5%' ),
|
||||||
'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'forced'=>TRUE, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center')
|
'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'forced'=>TRUE, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center', 'readParms'=>'sort=1')
|
||||||
);
|
);
|
||||||
|
|
||||||
protected $fieldpref = array('checkboxes', 'fb_id', 'fb_category', 'fb_title', 'fb_template', 'fb_class', 'fb_order', 'options');
|
protected $fieldpref = array('checkboxes', 'fb_id', 'fb_category', 'fb_title', 'fb_template', 'fb_class', 'fb_order', 'options');
|
||||||
|
@@ -33,13 +33,21 @@ class featurebox_setup
|
|||||||
|
|
||||||
$query = array();
|
$query = array();
|
||||||
$query['fb_category_id'] = 0;
|
$query['fb_category_id'] = 0;
|
||||||
$query['fb_category_title'] = 'General';
|
$query['fb_category_title'] = FBLAN_INSTALL_04;
|
||||||
$query['fb_category_template'] = 'default';
|
$query['fb_category_template'] = 'default';
|
||||||
$query['fb_category_random'] = 0;
|
$query['fb_category_random'] = 0;
|
||||||
$query['fb_category_class'] = e_UC_PUBLIC;
|
$query['fb_category_class'] = e_UC_PUBLIC;
|
||||||
$query['fb_category_limit'] = 1;
|
$query['fb_category_limit'] = 1;
|
||||||
$inserted = e107::getDb()->db_Insert('featurebox_category', $query);
|
$inserted = e107::getDb()->db_Insert('featurebox_category', $query);
|
||||||
$status = $inserted ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
|
|
||||||
|
$query['fb_category_id'] = 0;
|
||||||
|
$query['fb_category_title'] = FBLAN_INSTALL_03;
|
||||||
|
$query['fb_category_template'] = 'unassigned';
|
||||||
|
$query['fb_category_random'] = 0;
|
||||||
|
$query['fb_category_class'] = e_UC_NOBODY;
|
||||||
|
$query['fb_category_limit'] = 0;
|
||||||
|
$inserted1 = e107::getDb()->db_Insert('featurebox_category', $query);
|
||||||
|
$status = $inserted && $inserted1 ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
|
||||||
$mes->add(FBLAN_INSTALL_01, $status);
|
$mes->add(FBLAN_INSTALL_01, $status);
|
||||||
|
|
||||||
if($inserted)
|
if($inserted)
|
||||||
@@ -75,11 +83,28 @@ class featurebox_setup
|
|||||||
{
|
{
|
||||||
// print_a($var);
|
// print_a($var);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
function upgrade_post($var)
|
function upgrade_post($var)
|
||||||
{
|
{
|
||||||
// $sql = e107::getDb();
|
$sql = e107::getDb();
|
||||||
|
$currentVersion = $var->current_plug['plugin_version'];
|
||||||
|
//$newVersion = $var->plug_vars['@attributes']['version'];
|
||||||
|
if($currentVersion == '1.0')
|
||||||
|
{
|
||||||
|
$query = array();
|
||||||
|
$query['fb_category_id'] = 0;
|
||||||
|
$query['fb_category_title'] = FBLAN_INSTALL_03;
|
||||||
|
$query['fb_category_template'] = 'unassigned';
|
||||||
|
$query['fb_category_random'] = 0;
|
||||||
|
$query['fb_category_class'] = e_UC_NOBODY;
|
||||||
|
$query['fb_category_limit'] = 0;
|
||||||
|
$inserted = $sql->db_Insert('featurebox_category', $query);
|
||||||
|
$status = $inserted ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
|
||||||
|
e107::getMessage()->add(FBLAN_INSTALL_01, $status);
|
||||||
|
if($sql->getLastErrorNumber())
|
||||||
|
{
|
||||||
|
e107::getMessage()->addDebug($sql->getLastErrorText().'<br /><pre>'.$sql->getLastQuery().'</pre>');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
?>
|
|
@@ -14,7 +14,5 @@ define("LAN_PLUGIN_FEATUREBOX_BATCH", "Create Featurebox Item");
|
|||||||
// Install/uninstall messages
|
// Install/uninstall messages
|
||||||
define('FBLAN_INSTALL_01', 'Adding Default category table data.'); //XXX Use Generic
|
define('FBLAN_INSTALL_01', 'Adding Default category table data.'); //XXX Use Generic
|
||||||
define('FBLAN_INSTALL_02', 'Adding Default table data.'); //XXX Use Generic
|
define('FBLAN_INSTALL_02', 'Adding Default table data.'); //XXX Use Generic
|
||||||
|
define('FBLAN_INSTALL_03', 'Unassigned');
|
||||||
|
define('FBLAN_INSTALL_04', 'General');
|
||||||
|
|
||||||
?>
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!-- $Id: plugin.xml,v 1.9 2009-12-08 17:21:31 secretr Exp $ -->
|
<!-- $Id: plugin.xml,v 1.9 2009-12-08 17:21:31 secretr Exp $ -->
|
||||||
<e107Plugin name="Featurebox" lan="LAN_PLUGIN_FEATUREBOX_NAME" version="1.0" date="2012-08-01" compatibility="2.0" installRequired="true">
|
<e107Plugin name="Featurebox" lan="LAN_PLUGIN_FEATUREBOX_NAME" version="1.1" date="2012-08-01" compatibility="2.0" installRequired="true">
|
||||||
<author name="e107 Inc." url="http://e107.org" />
|
<author name="e107 Inc." url="http://e107.org" />
|
||||||
<description lan="LAN_PLUGIN_FEATUREBOX_DESCRIPTION">Displays an animated area on the top of your page with news-items and other content you would like to feature.</description>
|
<description lan="LAN_PLUGIN_FEATUREBOX_DESCRIPTION">Displays an animated area on the top of your page with news-items and other content you would like to feature.</description>
|
||||||
<category>content</category>
|
<category>content</category>
|
||||||
|
Reference in New Issue
Block a user