Basics of infolog-value and tracker-value widgets

This commit is contained in:
Nathan Gray 2014-09-30 22:08:57 +00:00
parent aa6c36ba3f
commit 6ee7f3f219
3 changed files with 27 additions and 6 deletions

View File

@ -68,6 +68,9 @@ abstract class etemplate_widget_entry extends etemplate_widget_transformer
$form_name = self::form_name($cname, $this->id); $form_name = self::form_name($cname, $this->id);
$data_id = $this->value ? self::form_name($cname, $this->value) : self::form_name($cname, self::ID_PREFIX . $this->id); $data_id = $this->value ? self::form_name($cname, $this->value) : self::form_name($cname, self::ID_PREFIX . $this->id);
// No need to proceed
if(!$this->id) return;
// Find out which record to load // Find out which record to load
$value = self::get_array(self::$request->content, $form_name, false, true); $value = self::get_array(self::$request->content, $form_name, false, true);

View File

@ -93,11 +93,11 @@ var et2_entry = et2_valueWidget.extend(
} }
var attrs = { var attrs = {
id: this.options.field, id: this.options.field,
type: entry.type, type: entry.type || 'label',
readonly: this.options.readonly readonly: this.options.readonly
}; };
var widget = et2_createWidget(attrs.type, attrs, this); var widget = et2_createWidget(attrs.type, attrs, this);
} }
}); });
et2_register_widget(et2_entry, ["entry", 'contact-value', 'contact-account', 'contact-template']); et2_register_widget(et2_entry, ["entry", 'contact-value', 'contact-account', 'contact-template', 'infolog-value','tracker-value']);

View File

@ -21,7 +21,7 @@
* 3) colon (:) separted list of alternative fields: the first non-empty one is used if the selected value is empty * 3) colon (:) separted list of alternative fields: the first non-empty one is used if the selected value is empty
* There's a special field "sum" in 1), which sums up all fields given in alternatives. * There's a special field "sum" in 1), which sums up all fields given in alternatives.
*/ */
class infolog_widget class infolog_widget extends etemplate_widget_entry
{ {
/** /**
* exported methods of this class * exported methods of this class
@ -56,14 +56,29 @@ class infolog_widget
/** /**
* Constructor of the extension * Constructor of the extension
* *
* @param string $ui '' for html
*/ */
function __construct($ui) function __construct($xml)
{ {
$this->ui = $ui; parent::__construct($xml);
$this->infolog = new infolog_bo(); $this->infolog = new infolog_bo();
} }
public function get_entry($value, array $attrs)
{
// Already done
if (is_array($value) && !(array_key_exists('app',$value) && array_key_exists('id', $value))) return $value;
// Link entry, already in array format
if(is_array($value) && array_key_exists('app', $value) && array_key_exists('id', $value)) $value = $value['id'];
// Link entry, in string format
if (substr($value,0,8) == 'infolog:') $value = substr($value,8);
if($value)
{
return $this->infolog->read($value);
}
return array();
}
/** /**
* pre-processing of the extension * pre-processing of the extension
* *
@ -258,3 +273,6 @@ class infolog_widget
return $fields; return $fields;
} }
} }
// register widgets for etemplate2
etemplate_widget::registerWidget('infolog_widget',array('infolog-value', 'infolog-fields'));