diff --git a/e107_admin/cpage.php b/e107_admin/cpage.php
index a699dc292..34f5e84c0 100644
--- a/e107_admin/cpage.php
+++ b/e107_admin/cpage.php
@@ -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('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 $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'),
diff --git a/e107_handlers/admin_ui.php b/e107_handlers/admin_ui.php
index 3265f25c7..c87d57dd0 100644
--- a/e107_handlers/admin_ui.php
+++ b/e107_handlers/admin_ui.php
@@ -2342,6 +2342,13 @@ class e_admin_controller_ui extends e_admin_controller
* @var array edit/create form tabs
*/
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
@@ -4038,8 +4045,8 @@ class e_admin_ui extends e_admin_controller_ui
{
if($this->_add2nav($selected))
{
- //e107::getMessage()->moveToSession();
- //$this->redirect();
+ e107::getMessage()->moveToSession();
+ $this->redirect();
}
}
@@ -4053,14 +4060,10 @@ class e_admin_ui extends e_admin_controller_ui
{
if($this->_add2featurebox($selected))
{
- //e107::getMessage()->moveToSession();
- //$this->redirect();
+ e107::getMessage()->moveToSession();
+ $this->redirect();
}
}
-
-
-
-
protected function _add2nav($selected)
{
@@ -4131,52 +4134,56 @@ class e_admin_ui extends e_admin_controller_ui
}
-
-
-
-
-
-
protected function _add2featurebox($selected)
{
if(empty($selected)) return false;// TODO warning message
- if(!is_array($selected)) $selected = array($selected);
+ if(!is_array($selected)) $selected = array($selected);
$sql = e107::getDb();
- //$allData = $this->getFeaturebox();
- $allData = $this->getTreeModel()->featurebox($selected, array('sc' => true), true);
-
- e107::getMessage()->addDebug('Using Featurebox Info:'.print_a($data,true));
-
-
- // print_a($allData);
- echo "EXIT";
- exit;
-
+ $tree = $this->getTreeModel();
+ $urlData = $this->getTreeModel()->url($selected, array('sc' => true), false);
+ $data = $this->featurebox;
$scount = 0;
- foreach($allData as $id => $data)
+ foreach($selected as $id)
{
- $name = $data['name'];
- $desc = $data['text'];
-
- $fbArray = array(
- 'fb_title' => varset($data['name']),
- 'fb_text' => varset($data['text']),
- 'fb_image' => varset($data['image']),
- 'fb_imageurl' => varset($data['url']),
+ if(!$tree->hasNode($id))
+ {
+ e107::getMessage()->addError('Item #ID '.htmlspecialchars($id).' not found.');
+ continue; // TODO message
+ }
+
+ $model = $tree->getNode($id);
+ if($data['url'] === true)
+ {
+ $url = $urlData[$id];
+ }
+ 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);
-
+
// FIXME lans
if($res !== FALSE)
{
e107::getMessage()->addSuccess('Created Featurebox Item: '.($name ? $name : 'n/a')."");
$scount++;
}
- else
+ else
{
if($sql->getLastErrorNumber())
{
@@ -4193,7 +4200,7 @@ class e_admin_ui extends e_admin_controller_ui
if($scount > 0)
{
- e107::getMessage()->addSuccess("
{$scount} new sitelinks were added but are currently unassigned. You should now modify these links to your liking.
Modify Links");
+ e107::getMessage()->addSuccess("
{$scount} new featurebox items were added but are currently unassigned. You should now modify these items to your liking.
Modify Featurebox Items");
return $scount;
}
diff --git a/e107_handlers/model_class.php b/e107_handlers/model_class.php
index 202ad8d60..9414fa6b1 100644
--- a/e107_handlers/model_class.php
+++ b/e107_handlers/model_class.php
@@ -3561,38 +3561,4 @@ class e_admin_tree_model extends e_front_tree_model
}
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;
- }
-
}
\ No newline at end of file
diff --git a/e107_handlers/pref_class.php b/e107_handlers/pref_class.php
index 6196a8e5d..81606b6b1 100644
--- a/e107_handlers/pref_class.php
+++ b/e107_handlers/pref_class.php
@@ -78,7 +78,7 @@ class e_pref extends e_front_model
require_once(e_HANDLER.'cache_handler.php');
$this->prefid = preg_replace('/[^\w\-]/', '', $prefid);
- e107::getMessage()->setUnique($this->prefid); // attempt to fix
+
if(empty($alias))
{
$alias = $prefid;
@@ -502,7 +502,8 @@ class e_pref extends e_front_model
{
return false;
}
-
+ e107::getMessage()->setUnique($this->prefid); // attempt to fix
+
if($from_post)
{
$this->mergePostedData(); //all posted data is sanitized and filtered vs preferences/_data_fields array
diff --git a/e107_plugins/featurebox/admin_config.php b/e107_plugins/featurebox/admin_config.php
index 495eaadf2..13637cca7 100644
--- a/e107_plugins/featurebox/admin_config.php
+++ b/e107_plugins/featurebox/admin_config.php
@@ -77,13 +77,46 @@ class fb_category_ui extends e_admin_ui
'fb_category_parms' => array('title'=> 'Parameters (optional)', 'type' => 'textarea', 'data' => 'str', 'width' => 'auto', 'thclass' => 'left', 'class' => 'left','writeParms' => 'expand=Advanced&help=Optional Javascript Parameters (format subject to change)'),
'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("".FBLAN_INSTALL_03." 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
*/
public function beforeDelete($data, $id)
{
+ // FIXME lan
+ if($data['fb_category_template'] === 'unassigned')
+ {
+ $this->getTreeModel()->addMessageError("".FBLAN_INSTALL_03." is system category and can't be deleted.");
+ return false;
+ }
if (e107::getDb()->db_Count('featurebox', '(*)', 'fb_category='.intval($id)))
{
$this->getTreeModel()->addMessageWarning("Can't delete {$data['fb_category_title']} - category is in use!");
@@ -105,7 +138,7 @@ class fb_category_ui extends e_admin_ui
if(!varset($new_data['fb_category_template']))
{
$new_data['fb_category_template'] = 'default';
- }
+ }var_dump($new_data);
return $new_data;
}
@@ -168,7 +201,10 @@ class fb_main_ui extends e_admin_ui
protected $pid = "fb_id";
protected $perPage = 10;
protected $batchDelete = true;
- protected $batchCopy = true;
+ protected $batchCopy = true;
+ protected $sortField = 'fb_order';
+ protected $orderStep = 1;
+ protected $listOrder = 'fb_order asc';
protected $fields = array(
'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_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%' ),
- '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');
diff --git a/e107_plugins/featurebox/featurebox_setup.php b/e107_plugins/featurebox/featurebox_setup.php
index 3d33dd838..0a5f3f056 100644
--- a/e107_plugins/featurebox/featurebox_setup.php
+++ b/e107_plugins/featurebox/featurebox_setup.php
@@ -33,13 +33,21 @@ class featurebox_setup
$query = array();
$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_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;
+
+ $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);
if($inserted)
@@ -75,11 +83,28 @@ class featurebox_setup
{
// print_a($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().'
'.$sql->getLastQuery().''); + } + } } -*/ } -?> \ No newline at end of file diff --git a/e107_plugins/featurebox/languages/English_global.php b/e107_plugins/featurebox/languages/English_global.php index 169f655cc..4153a6b9b 100644 --- a/e107_plugins/featurebox/languages/English_global.php +++ b/e107_plugins/featurebox/languages/English_global.php @@ -14,7 +14,5 @@ define("LAN_PLUGIN_FEATUREBOX_BATCH", "Create Featurebox Item"); // Install/uninstall messages define('FBLAN_INSTALL_01', 'Adding Default category table data.'); //XXX Use Generic define('FBLAN_INSTALL_02', 'Adding Default table data.'); //XXX Use Generic - - - -?> \ No newline at end of file +define('FBLAN_INSTALL_03', 'Unassigned'); +define('FBLAN_INSTALL_04', 'General'); diff --git a/e107_plugins/featurebox/plugin.xml b/e107_plugins/featurebox/plugin.xml index 87c646e62..72f7705bb 100644 --- a/e107_plugins/featurebox/plugin.xml +++ b/e107_plugins/featurebox/plugin.xml @@ -1,6 +1,6 @@ -