1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-05 22:27:34 +02:00

Preparation for Feature-box batch option.

This commit is contained in:
Cameron
2013-03-07 22:45:59 -08:00
parent ea1641a633
commit 3e66c9b08f
3 changed files with 243 additions and 17 deletions

View File

@@ -289,24 +289,39 @@ class menu_form_ui extends e_admin_form_ui
// MAIN Pages.
class page_admin_ui extends e_admin_ui
{
protected $pluginTitle = ADLAN_42;
protected $pluginName = 'core';
protected $table = "page";
protected $pluginTitle = ADLAN_42;
protected $pluginName = 'core';
protected $table = "page";
protected $listQry = "SELECT p.*,u.user_id,u.user_name FROM #page AS p LEFT JOIN #user AS u ON p.page_author = u.user_id WHERE p.page_theme = '' "; // without any Order or Limit.
protected $listQry = "SELECT p.*,u.user_id,u.user_name FROM #page AS p LEFT JOIN #user AS u ON p.page_author = u.user_id WHERE p.page_theme = '' "; // without any Order or Limit.
//protected $editQry = "SELECT * FROM #comments WHERE comment_id = {ID}";
protected $pid = "page_id";
protected $listOrder = 'p.page_order asc'; // desc would require changes to ajax sorting.
protected $perPage = 10;
protected $batchDelete = true;
protected $batchCopy = true;
protected $batchLink = true;
protected $sortField = 'page_order';
protected $orderStep = 10;
protected $pid = "page_id";
protected $listOrder = 'p.page_order asc'; // desc would require changes to ajax sorting.
protected $perPage = 10;
protected $batchDelete = true;
protected $batchCopy = true;
protected $batchLink = true;
protected $batchFeaturebox = true;
protected $sortField = 'page_order';
protected $orderStep = 10;
//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 $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');
/*
* 'fb_title' => array('title'=> LAN_TITLE, 'type' => 'text', 'inline'=>true, 'width' => 'auto', 'thclass' => 'left'),
'fb_text' => array('title'=> FBLAN_08, 'type' => 'bbarea', 'width' => '30%', 'readParms' => 'expand=...&truncate=50&bb=1','writeParms'=>'template=admin'),
//DEPRECATED 'fb_mode' => array('title'=> FBLAN_12, 'type' => 'dropdown', 'data'=> 'int', 'width' => '5%', 'filter'=>TRUE, 'batch'=>TRUE),
//DEPRECATED 'fb_rendertype' => array('title'=> FBLAN_22, 'type' => 'dropdown', 'data'=> 'int', 'width' => 'auto', 'noedit' => TRUE),
'fb_template' => array('title'=> LAN_TEMPLATE, 'type' => 'layouts', 'data'=> 'str', 'width' => 'auto', 'writeParms' => 'plugin=featurebox', 'filter' => true, 'batch' => true), // Photo
'fb_image' => array('title'=> "Image", 'type' => 'image', 'width' => 'auto', 'readParms'=>'thumb=60&thumb_urlraw=0&thumb_aw=60'),
'fb_imageurl' => array('title'=> "Image Link", 'type' => 'url', 'width' => 'auto'),
'fb_class'
*/
// protected $listSorting = true;
// PAGE LIST/EDIT and MENU EDIT modes.

View File

@@ -2368,6 +2368,12 @@ class e_admin_controller_ui extends e_admin_controller
* @var boolean
*/
protected $batchLink = false;
/**
* @var boolean
*/
protected $batchFeaturebox = false;
/**
* Could be LAN constant (mulit-language support)
*
@@ -2428,6 +2434,13 @@ class e_admin_controller_ui extends e_admin_controller
return $this->batchLink;
}
public function getBatchFeaturebox()
{
return $this->batchFeaturebox;
}
/**
* @return string
*/
@@ -2465,6 +2478,16 @@ class e_admin_controller_ui extends e_admin_controller
}
/**
* Get Featurebox Copy
* @return array
*/
public function getFeaturebox()
{
return $this->featurebox;
}
/**
* Get all field data
* @return array
@@ -4013,13 +4036,30 @@ class e_admin_ui extends e_admin_controller_ui
*/
protected function handleListUrlBatch($selected)
{
// Batch Copy
if($this->_add2nav($selected))
{
//e107::getMessage()->moveToSession();
//$this->redirect();
}
}
/** TODO
* Batch Featurebox Transfer
* @param array $selected
* @return void
*/
protected function handleListFeatureboxBatch($selected)
{
if($this->_add2featurebox($selected))
{
//e107::getMessage()->moveToSession();
//$this->redirect();
}
}
protected function _add2nav($selected)
@@ -4090,6 +4130,89 @@ class e_admin_ui extends e_admin_controller_ui
return false;
}
protected function _add2featurebox($selected)
{
if(empty($selected)) return false;// TODO warning message
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;
$scount = 0;
foreach($allData as $id => $data)
{
$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']),
);
$res = $sql->insert('featurebox', $fbArray);
// FIXME lans
if($res !== FALSE)
{
e107::getMessage()->addSuccess('Created Featurebox Item: <b>'.($name ? $name : 'n/a')."</b>");
$scount++;
}
else
{
if($sql->getLastErrorNumber())
{
e107::getMessage()->addError('SQL Featurebox Creation Error'); //TODO - Lan
e107::getMessage()->addDebug('SQL Featurebox Creation Error #'.$sql->getLastErrorNumber().': '.$sql->getLastErrorText());
}
else
{
e107::getMessage()->addError('Unknown error: <b>'.$name."</b> not added");
}
}
}
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>");
return $scount;
}
return false;
}
/**
* Batch boolean trigger
@@ -5058,7 +5181,7 @@ class e_admin_form_ui extends e_form
'fields' => $controller->getFields(), // see e_admin_ui::$fields
'fieldpref' => $controller->getFieldPref(), // see e_admin_ui::$fieldpref
'table_pre' => '', // markup to be added before opening table element
'table_post' => !$tree[$id]->isEmpty() ? $this->renderBatch($controller->getBatchDelete(),$controller->getBatchCopy(),$controller->getBatchLink()) : '',
'table_post' => !$tree[$id]->isEmpty() ? $this->renderBatch($controller->getBatchDelete(),$controller->getBatchCopy(),$controller->getBatchLink(),$controller->getBatchFeaturebox()) : '',
'fieldset_pre' => '', // markup to be added before opening fieldset element
'fieldset_post' => '', // markup to be added after closing fieldset element
'perPage' => $controller->getPerPage(), // if 0 - no next/prev navigation
@@ -5286,7 +5409,7 @@ class e_admin_form_ui extends e_form
}
// FIXME - use e_form::batchoptions(), nice way of buildig batch dropdown - news administration show_batch_options()
function renderBatch($allow_delete = false,$allow_copy= false, $allow_url=false)
function renderBatch($allow_delete = false,$allow_copy= false, $allow_url=false, $allow_featurebox=false)
{
// $allow_copy = TRUE;
@@ -5308,6 +5431,8 @@ class e_admin_form_ui extends e_form
".($allow_copy ? $this->option(LAN_COPY, 'copy', false, array('class' => 'ui-batch-option class', 'other' => 'style="padding-left: 15px"')) : '')."
".($allow_delete ? $this->option(LAN_DELETE, 'delete', false, array('class' => 'ui-batch-option class', 'other' => 'style="padding-left: 15px"')) : '')."
".($allow_url ? $this->option(LAN_UI_BATCH_CREATELINK, 'url', false, array('class' => 'ui-batch-option class', 'other' => 'style="padding-left: 15px"')) : '')."
".($allow_featurebox ? $this->option(LAN_UI_BATCH_CREATEFEATUREBOX, 'featurebox', false, array('class' => 'ui-batch-option class', 'other' => 'style="padding-left: 15px"')) : '')."
".$this->renderBatchFilter('batch')."
".$this->select_close()."
".$this->admin_button('e__execute_batch', 'e__execute_batch', 'batch e-hide-if-js', LAN_GO, array('id' => false))."

View File

@@ -528,6 +528,14 @@ class e_model extends e_object
* @var string
*/
protected $_url = array();
/**
* Current Featurebox Profile data
* Example: array('title' => 'page_title', 'text' => '');
* @var string
*/
protected $_featurebox = array();
/**
* Runtime cache of parsed from {@link _getData()} keys
@@ -609,6 +617,28 @@ class e_model extends e_object
{
return $this->_url;
}
/**
* Set model Featurebox Profile
* @param string $table
* @return e_model
*/
public function setFeaturebox($fb)
{
// if(!is_array($url)) $url = array('route' => $url);
$this->_featurebox = $fb;
return $this;
}
/**
* Get Featurebox profile
* @return array
*/
public function getFeaturebox()
{
return $this->_featurebox;
}
/**
* Generic URL assembling method
@@ -655,6 +685,29 @@ class e_model extends e_object
'description' => vartrue($urldata['description']) ? $this->get($urldata['description']) : '',
);
}
/**
* Generic Featurebox assembling method
* @return mixed URL string or extended array data
*/
public function featurebox($options = array(), $extended = false)
{
}
/**
* Get data fields array
@@ -3509,5 +3562,38 @@ 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;
}
}