- Use a hook for app's custom widgets to avoid scanning filesystem

- Use new hook to load importexport's filter widget
- Remove some typos & error_log()s
This commit is contained in:
Nathan Gray 2013-11-04 17:23:58 +00:00
parent 7f50ed9f1a
commit d4be70de5a
7 changed files with 30 additions and 14 deletions

View File

@ -108,7 +108,7 @@ class etemplate_new extends etemplate_widget_template
if (!$this->rel_path) throw new egw_exception_assertion_failed("No (valid) template '$this->name' found!");
self::$request->output_mode = $output_mode; // let extensions "know" they are run eg. in a popup
self::$request->content = $content;
self::$request->content = self::$cont = $content;
self::$request->changes = $changes;
self::$request->sel_options = $sel_options ? $sel_options : array();
self::$request->readonlys = $readonlys ? $readonlys : array();
@ -586,3 +586,20 @@ foreach($files as $filename)
}
}
}
// Use hook to load custom widgets from other apps
$widgets = $GLOBALS['egw']->hooks->process('etemplate2_register_widgets');
foreach($widgets as $app => $list)
{
foreach($list as $class)
{
try
{
__autoload($class);
}
catch(Exception $e)
{
error_log($e->getMessage());
}
}
}

View File

@ -267,7 +267,7 @@ class etemplate_widget
{
if (!is_subclass_of($class, __CLASS__))
{
throw new egw_exception_wrong_parameter(__METHOD__."('$class', ".array2string($widgets).") $class is no subclass or ".__CLASS__.'!');
throw new egw_exception_wrong_parameter(__METHOD__."('$class', ".array2string($widgets).") $class is no subclass of ".__CLASS__.'!');
}
foreach((array)$widgets as $widget)
{

View File

@ -146,4 +146,12 @@ class importexport_admin_prefs_sidebox_hooks
}
if($file) display_sidebox($appname,lang('importexport'),$file);
}
/**
* Returns a list of custom widgets classes for etemplate2
*/
public static function widgets()
{
return array('importexport_widget_filter');
}
}

View File

@ -587,9 +587,7 @@ class importexport_definitions_ui
unset($content['button']);
$content['wizard_content'] = $this->wizard_content_template;
error_log('------- STARTING EXEC --------');
$this->etpl->exec(self::_appname.'.importexport_definitions_ui.wizard',$content,$sel_options,$readonlys,$preserv);
error_log('------- DONE EXEC --------');
}
else
{

View File

@ -60,7 +60,7 @@ class importexport_widget_filter extends etemplate_widget_transformer
);
return parent::beforeSendToClient($cname);
}
error_log(array2string(array_keys($fields)));
$n = 1;
foreach($fields as $lname => &$field)
{
@ -142,8 +142,6 @@ error_log('Trying to filter with unsupported field type: ' . $field['type']);
}
}
error_log($type);
$widget = self::factory($type, '<'.$type.' type="'.$type.'" id="'.self::$prefix.$lname.'"/>', self::$prefix.$lname);
if(method_exists($widget, 'beforeSendToClient'))
{
@ -159,7 +157,6 @@ error_log('Trying to filter with unsupported field type: ' . $field['type']);
}
$this->setElementAttribute($form_name, 'customfields', $fields);
$this->setElementAttribute($form_name, 'fields',array_fill_keys(array_keys($fields), true));
error_log($this);
parent::beforeSendToClient($cname);
@ -230,7 +227,6 @@ error_log('Trying to filter with unsupported field type: ' . $field['type']);
public function validate($cname, array $expand, array $content, &$validated=array())
{
$form_name = self::form_name($cname, $this->id, $expand);
error_log('Validating ' . $form_name);
if (!$this->is_readonly($cname, $form_name))
{
$value_in = self::get_array($content, $form_name);

View File

@ -269,8 +269,6 @@ class importexport_wizard_basic_export_csv
$preserv = $content;
unset ($preserv['button']);
error_log('-------');
error_log('Filter ' . array2string($content['filter']));
$content['set_filter']['fields'] = importexport_helper_functions::get_filter_fields(
$content['application'],$content['plugin'],$this
);
@ -280,8 +278,6 @@ class importexport_wizard_basic_export_csv
$content['set_filter'][$field] = $content['filter'][$field];
}
error_log('SET FILTER ' . array2string($content['set_filter']));
error_log('----------');
if(!$content['set_filter']['fields'])
{
// No fields

View File

@ -32,6 +32,7 @@ $setup_info['importexport']['note'] =
$setup_info['importexport']['hooks']['admin'] =
$setup_info['importexport']['hooks']['sidebox_menu'] = 'importexport_admin_prefs_sidebox_hooks::all_hooks';
$setup_info['importexport']['hooks']['sidebox_all'] = 'importexport_admin_prefs_sidebox_hooks::other_apps';
$setup_info['importexport']['hooks']['etemplate2_register_widgets'] = 'importexport_admin_prefs_sidebox_hooks::widgets';
/* Dependencies for this app to work */
$setup_info['importexport']['depends'][] = array(