mirror of
https://github.com/e107inc/e107.git
synced 2025-08-04 13:47:31 +02:00
Provide useful debug information to developers wishing to create custom Filter and Batch handling methods.
Media-Manager updated to use the custom batch Handler method.
This commit is contained in:
@@ -366,7 +366,7 @@ class media_form_ui extends e_admin_form_ui
|
|||||||
}
|
}
|
||||||
asort($this->cats);*/
|
asort($this->cats);*/
|
||||||
// require(e_HANDLER.'phpthumb/ThumbLib.inc.php'); // For resizing on import.
|
// require(e_HANDLER.'phpthumb/ThumbLib.inc.php'); // For resizing on import.
|
||||||
|
/*
|
||||||
if(!empty($_POST['multiselect']) && varset($_POST['e__execute_batch']) && (varset($_POST['etrigger_batch']) == 'options__rotate_cw' || varset($_POST['etrigger_batch']) == 'options__rotate_ccw'))
|
if(!empty($_POST['multiselect']) && varset($_POST['e__execute_batch']) && (varset($_POST['etrigger_batch']) == 'options__rotate_cw' || varset($_POST['etrigger_batch']) == 'options__rotate_ccw'))
|
||||||
{
|
{
|
||||||
$type = str_replace('options__','',$_POST['etrigger_batch']);
|
$type = str_replace('options__','',$_POST['etrigger_batch']);
|
||||||
@@ -390,13 +390,13 @@ class media_form_ui extends e_admin_form_ui
|
|||||||
$ids = implode(",", e107::getParser()->filter($_POST['multiselect'],'int'));
|
$ids = implode(",", e107::getParser()->filter($_POST['multiselect'],'int'));
|
||||||
$this->convertImagesToJpeg($ids);
|
$this->convertImagesToJpeg($ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!empty($_POST['multiselect']) && varset($_POST['e__execute_batch']) && (varset($_POST['etrigger_batch']) == 'options__convert_all_to_jpeg' ))
|
if(!empty($_POST['multiselect']) && varset($_POST['e__execute_batch']) && (varset($_POST['etrigger_batch']) == 'options__convert_all_to_jpeg' ))
|
||||||
{
|
{
|
||||||
// $type = str_replace('options__','',$_POST['etrigger_batch']);
|
// $type = str_replace('options__','',$_POST['etrigger_batch']);
|
||||||
$ids = implode(",", e107::getParser()->filter($_POST['multiselect'],'int'));
|
$ids = implode(",", e107::getParser()->filter($_POST['multiselect'],'int'));
|
||||||
$this->convertImagesToJpeg($ids,'all');
|
$this->convertImagesToJpeg($ids,'all');
|
||||||
}
|
}*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -543,7 +543,7 @@ class media_form_ui extends e_admin_form_ui
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function convertImagesToJpeg($ids,$mode=null)
|
public function convertImagesToJpeg($ids,$mode=null)
|
||||||
{
|
{
|
||||||
$sql = e107::getDb();
|
$sql = e107::getDb();
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
@@ -564,7 +564,7 @@ class media_form_ui extends e_admin_form_ui
|
|||||||
|
|
||||||
if($jpegFile = $mm->convertImageToJpeg($path,true))
|
if($jpegFile = $mm->convertImageToJpeg($path,true))
|
||||||
{
|
{
|
||||||
$url = $tp->createConstants($jpegFile);
|
$url = $tp->createConstants($jpegFile, 1);
|
||||||
$size = filesize($jpegFile);
|
$size = filesize($jpegFile);
|
||||||
|
|
||||||
$update = array (
|
$update = array (
|
||||||
@@ -848,9 +848,9 @@ class media_admin_ui extends e_admin_ui
|
|||||||
protected $fields = array(
|
protected $fields = array(
|
||||||
'checkboxes' => array('title'=> '', 'type' => null, 'data'=> null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center'),
|
'checkboxes' => array('title'=> '', 'type' => null, 'data'=> null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center'),
|
||||||
'media_id' => array('title'=> LAN_ID, 'type' => 'number', 'data'=> 'int', 'width' =>'5%', 'forced'=> TRUE, 'nolist'=>TRUE),
|
'media_id' => array('title'=> LAN_ID, 'type' => 'number', 'data'=> 'int', 'width' =>'5%', 'forced'=> TRUE, 'nolist'=>TRUE),
|
||||||
'media_preview' => array('title'=> LAN_PREVIEW, 'type'=>'method', 'data'=>false, 'forced'=>true, 'width' => '110px', 'thclass' => 'center', 'class'=>'center'),
|
'media_preview' => array('title'=> LAN_PREVIEW, 'type' => 'method', 'data'=>false, 'forced'=>true, 'width' => '110px', 'thclass' => 'center', 'class'=>'center'),
|
||||||
'media_url' => array('title'=> IMALAN_110, 'type' => 'text', 'data'=> 'str', 'inline'=>false, 'thclass' => 'left', 'class'=>'left', 'width' => 'auto', 'writeParms'=>'size=xxlarge'),
|
'media_url' => array('title'=> IMALAN_110, 'type' => 'text', 'data'=> 'str', 'inline'=>false, 'thclass' => 'left', 'class'=>'left', 'width' => 'auto', 'writeParms'=>'size=xxlarge'),
|
||||||
'media_category' => array('title'=> LAN_CATEGORY, 'type' => 'comma', 'inline'=>false, 'data'=> 'str', 'width' => '10%', 'filter' => true, 'batch' => true, 'class'=>'left'),
|
'media_category' => array('title'=> LAN_CATEGORY, 'type' => 'comma', 'inline'=>false, 'data'=> 'str', 'width' => '10%', 'filter' => true, 'batch' => true, 'class'=>'left'),
|
||||||
// Upload should be managed completely separately via upload-handler.
|
// Upload should be managed completely separately via upload-handler.
|
||||||
// 'media_upload' => array('title'=> "Upload File", 'type' => 'upload', 'data'=> false, 'readParms' => 'hidden', 'writeParms' => 'disable_button=1', 'width' => '10%', 'nolist' => true),
|
// 'media_upload' => array('title'=> "Upload File", 'type' => 'upload', 'data'=> false, 'readParms' => 'hidden', 'writeParms' => 'disable_button=1', 'width' => '10%', 'nolist' => true),
|
||||||
'media_name' => array('title'=> LAN_TITLE, 'type' => 'text', 'data'=> 'str', 'inline'=>true, 'width' => 'auto', 'writeParms'=>array('size'=>'xxlarge')),
|
'media_name' => array('title'=> LAN_TITLE, 'type' => 'text', 'data'=> 'str', 'inline'=>true, 'width' => 'auto', 'writeParms'=>array('size'=>'xxlarge')),
|
||||||
@@ -1177,6 +1177,45 @@ class media_admin_ui extends e_admin_ui
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle Batch options as defined in media_form_ui::options(); handle+action+field+Batch
|
||||||
|
* @param $selected
|
||||||
|
* @param $type
|
||||||
|
*/
|
||||||
|
function handleListOptionsBatch($selected, $type)
|
||||||
|
{
|
||||||
|
|
||||||
|
/** @var media_form_ui $frm */
|
||||||
|
$frm = $this->getUI();
|
||||||
|
|
||||||
|
$ids = implode(",", $selected);
|
||||||
|
|
||||||
|
switch($type)
|
||||||
|
{
|
||||||
|
case "resize_2048":
|
||||||
|
$frm->resizeImages($ids,$type);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "rotate_cw":
|
||||||
|
case "rotate_ccw":
|
||||||
|
$frm->rotateImages($ids,$type);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "convert_to_jpeg":
|
||||||
|
|
||||||
|
$frm->convertImagesToJpeg($ids);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "convert_all_to_jpeg":
|
||||||
|
$frm->convertImagesToJpeg($ids,'all');
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// code to be executed if n is different from all labels;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function navPage() // no functioning correctly - see e_AJAX_REQUEST above.
|
function navPage() // no functioning correctly - see e_AJAX_REQUEST above.
|
||||||
{
|
{
|
||||||
|
@@ -3471,7 +3471,8 @@ class e_admin_controller_ui extends e_admin_controller
|
|||||||
//something like handleListUrlTypeBatch(); for custom handling of 'url_type' field name
|
//something like handleListUrlTypeBatch(); for custom handling of 'url_type' field name
|
||||||
$method = 'handle'.$actionName.$this->getRequest()->camelize($field).'Batch';
|
$method = 'handle'.$actionName.$this->getRequest()->camelize($field).'Batch';
|
||||||
|
|
||||||
e107::getDebug()->log("Checking for batch method: ".$method);
|
e107::getMessage()->addDebug("Searching for custom batch method: ".$method."(".$selected.",".$value.")");
|
||||||
|
|
||||||
if(method_exists($this, $method)) // callback handling
|
if(method_exists($this, $method)) // callback handling
|
||||||
{
|
{
|
||||||
$this->$method($selected, $value);
|
$this->$method($selected, $value);
|
||||||
@@ -3506,7 +3507,7 @@ class e_admin_controller_ui extends e_admin_controller
|
|||||||
{
|
{
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
$filter = $tp->toDB(explode('__', $filter_value));
|
$filter = (array) $tp->toDB(explode('__', $filter_value));
|
||||||
$res = array();
|
$res = array();
|
||||||
switch($filter[0])
|
switch($filter[0])
|
||||||
{
|
{
|
||||||
@@ -3542,12 +3543,17 @@ class e_admin_controller_ui extends e_admin_controller
|
|||||||
default:
|
default:
|
||||||
//something like handleListUrlTypeFilter(); for custom handling of 'url_type' field name filters
|
//something like handleListUrlTypeFilter(); for custom handling of 'url_type' field name filters
|
||||||
$method = 'handle'.$this->getRequest()->getActionName().$this->getRequest()->camelize($filter[0]).'Filter';
|
$method = 'handle'.$this->getRequest()->getActionName().$this->getRequest()->camelize($filter[0]).'Filter';
|
||||||
|
$args = array_slice($filter, 1);
|
||||||
|
|
||||||
|
e107::getMessage()->addDebug("Searching for custom filter method: ".$method."(".implode(', ', $args).")");
|
||||||
|
|
||||||
|
|
||||||
if(method_exists($this, $method)) // callback handling
|
if(method_exists($this, $method)) // callback handling
|
||||||
{
|
{
|
||||||
//return $this->$method($filter[1], $selected); selected?
|
//return $this->$method($filter[1], $selected); selected?
|
||||||
// better approach - pass all values as method arguments
|
// better approach - pass all values as method arguments
|
||||||
// NOTE - callbacks are allowed to return QUERY as a string, it'll be added in the WHERE clause
|
// NOTE - callbacks are allowed to return QUERY as a string, it'll be added in the WHERE clause
|
||||||
$args = array_slice($filter, 1);
|
|
||||||
e107::getMessage()->addDebug('Executing filter callback <strong>'.get_class($this).'::'.$method.'('.implode(', ', $args).')</strong>');
|
e107::getMessage()->addDebug('Executing filter callback <strong>'.get_class($this).'::'.$method.'('.implode(', ', $args).')</strong>');
|
||||||
|
|
||||||
return call_user_func_array(array($this, $method), $args);
|
return call_user_func_array(array($this, $method), $args);
|
||||||
|
Reference in New Issue
Block a user