From ed85cc3ce6556dc59a7c1ff5132406d6e74d1f74 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 5 May 2014 16:05:39 +0000 Subject: [PATCH] allow apps to supply own etemplate_widget_transformer extending widgets --- etemplate/inc/class.etemplate_widget.inc.php | 6 +- ...ss.etemplate_widget_projectmanager.inc.php | 116 ------------------ 2 files changed, 5 insertions(+), 117 deletions(-) delete mode 100644 etemplate/inc/class.etemplate_widget_projectmanager.inc.php diff --git a/etemplate/inc/class.etemplate_widget.inc.php b/etemplate/inc/class.etemplate_widget.inc.php index aedd34cdf1..cff20185cb 100644 --- a/etemplate/inc/class.etemplate_widget.inc.php +++ b/etemplate/inc/class.etemplate_widget.inc.php @@ -290,7 +290,11 @@ class etemplate_widget { list($basetype) = explode('-',$type); if (!class_exists($class_name = 'etemplate_widget_'.str_replace('-','_',$type)) && - !class_exists($class_name = 'etemplate_widget_'.str_replace('-','_',$basetype))) + !class_exists($class_name = 'etemplate_widget_'.$basetype) && + // widgets supplied by application in class ${app}_widget_etemplate or ${app}_${subtype}_widget_etemplate + !(isset($GLOBALS['egw_info']['apps'][$basetype]) && + (class_exists($class_name = str_replace('-','_',$type).'_etemplate_widget') || + class_exists($class_name = $basetype.'_etemplate_widget')))) { // Try for base type, it's probably better than the root if(self::$widget_registry[$basetype] && self::$widget_registry[$basetype] != $class_name) diff --git a/etemplate/inc/class.etemplate_widget_projectmanager.inc.php b/etemplate/inc/class.etemplate_widget_projectmanager.inc.php deleted file mode 100644 index 44b114b581..0000000000 --- a/etemplate/inc/class.etemplate_widget_projectmanager.inc.php +++ /dev/null @@ -1,116 +0,0 @@ - array( - 'projectmanager-select' => 'menupopup', - 'projectmanager-pricelist' => 'menupopup', - 'projectmanager-select-erole' => 'menupopup', - ) - ); - - /** - * (Array of) comma-separated list of legacy options to automatically replace when parsing with set_attrs - * - * @var string|array - */ - protected $legacy_options = ''; - - /** - * Fill type options in self::$request->sel_options to be used on the client - * - * @param string $cname - */ - public function beforeSendToClient($cname) - { - $form_name = self::form_name($cname, $this->id); - if (!is_array(self::$request->sel_options[$form_name])) self::$request->sel_options[$form_name] = array(); - - if ($this->type) - { - $pm_widget = new projectmanager_widget(); - if($this->is_readonly($cname, $form_name)) - { - // Go direct to get full erole list - $eroles = new projectmanager_eroles_bo(); - foreach((array)$eroles->search(array(),false,'role_title ASC','','',false,'AND',false,array('pm_id'=>array(0,$eroles->pm_id))) as $erole) - { - self::$request->sel_options[$form_name][$erole['role_id']] = array( - 'label' => $erole['role_description'], - 'title' => lang('Element role title').': '.$erole['role_title'].$eroles->get_info($erole['role_id']), - ); - } - } - $cell = $this->attrs; - $cell['type']=$this->type; - $cell['readonly'] = false; - $template = self::$request; - $pm_widget->pre_process($form_name, self::get_array(self::$request->content, $form_name), - $cell, - $garbage, - $extension, - $template - ); - self::$request->sel_options[$form_name] += (array)$cell['sel_options']; - - // if no_lang was modified, forward modification to the client - if ($cell['no_lang'] != $this->attr['no_lang']) - { - self::setElementAttribute($form_name, 'no_lang', $no_lang); - } - } - - parent::beforeSendToClient($cname); - } - - /** - * Validate input - * - * @todo - * @param string $cname current namespace - * @param array $content - * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' - * @param array &$validated=array() validated content - * @return boolean true if no validation error, false otherwise - */ - public function validate($cname, array $expand, array $content, &$validated=array()) - { - $form_name = self::form_name($cname, $this->id, $expand); - - $ok = true; - if (!$this->is_readonly($cname, $form_name)) - { - $value = $value_in = self::get_array($content, $form_name); - - switch($this->type) - { - case 'projectmanager-select-erole': - $value = null; - if(is_array($value_in)) $value = implode(',',$value_in); - break; - default: - $value = $value_in; - break; - } - $valid =& self::get_array($validated, $form_name, true); - $valid = $value; - } - } -}