Ejemplo n.º 1
0
 public function displayPublishPanel(SymphonyDOMElement $wrapper, MessageStack $errors, Entry $entry = null, $data = null)
 {
     // Not sure if we need a publish panel
     return;
     $document = $wrapper->ownerDocument;
     $label = Widget::Label(isset($this->{'publish-label'}) && strlen(trim($this->{'publish-label'})) > 0 ? $this->{'publish-label'} : $this->name);
     $count = $document->createElement('p');
     $count->appendChild($this->prepareTableValue($data, NULL, $entry));
     $label->appendChild($count);
     $wrapper->appendChild($label);
 }
Ejemplo n.º 2
0
 public function appendTo(SymphonyDOMElement $wrapper)
 {
     $this->layout->setAttribute('class', $this->class);
     ###
     # Delegate: LayoutPreGenerate
     # Description: Allows developers to access the layout content
     #			   before it is appended to the page.
     Extension::notify('LayoutPreGenerate', '/administration/', $this->layout);
     if ($wrapper->tagName == 'form') {
         $this->layout->setAttribute('id', 'layout');
     }
     $wrapper->appendChild($this->layout);
 }
Ejemplo n.º 3
0
 public function displayPublishPanel(SymphonyDOMElement $wrapper, MessageStack $errors, Entry $entry = NULL, $data = NULL)
 {
     $document = $wrapper->ownerDocument;
     $sortorder = $this->{'sortorder'};
     $element_name = $this->{'element-name'};
     $label = Widget::Label(isset($this->{'publish-label'}) && strlen(trim($this->{'publish-label'})) > 0 ? $this->{'publish-label'} : $this->name);
     // Input box:
     $input = Widget::Input("fields[{$element_name}]", $data->value);
     $label->appendChild($input);
     if ($errors->valid()) {
         $label = Widget::wrapFormElementWithError($label, $errors->current()->message);
     }
     $wrapper->appendChild($label);
 }
Ejemplo n.º 4
0
 public function displayPublishPanel(SymphonyDOMElement $wrapper, MessageStack $errors, Entry $entry = null, $data = null)
 {
     if (is_null($entry->id) && $this->{'default-state'} == 'on') {
         $value = 'yes';
     } else {
         if (is_null($data) && $this->{'required'} == 'yes') {
             $value = null;
         } else {
             if (is_null($data)) {
                 ## TODO: Don't rely on $_POST
                 if (isset($_POST) && !empty($_POST)) {
                     $value = 'no';
                 } elseif ($this->{'default-state'} == 'on') {
                     $value = 'yes';
                 } else {
                     $value = 'no';
                 }
             } else {
                 $value = $data->value == 'yes' ? 'yes' : 'no';
             }
         }
     }
     $label = Widget::Label();
     $input = Widget::Input('fields[' . $this->{'element-name'} . ']', 'yes', 'checkbox', $value == 'yes' ? array('checked' => 'checked') : array());
     $label->appendChild($input);
     $label->appendChild(new DOMText(isset($this->{'publish-label'}) && strlen(trim($this->{'publish-label'})) > 0 ? $this->{'publish-label'} : $this->{'name'}));
     if ($errors->valid()) {
         $label = Widget::wrapFormElementWithError($label, $errors->current()->message);
     }
     $wrapper->appendChild($label);
 }
Ejemplo n.º 5
0
 public function appendTo(SymphonyDOMElement $wrapper)
 {
     $document = $wrapper->ownerDocument;
     $list = $document->createElement('ol');
     $list->setAttribute('class', 'error-list');
     foreach ($this as $key => $message) {
         if (!is_numeric($key)) {
             $key = $key . ': ';
         } else {
             $key = '';
         }
         if ($message instanceof MessageStack) {
             $item = $document->createElement('li', $key);
             $message->appendTo($item);
         } else {
             if (is_array($message)) {
                 $item = $document->createElement('li', $key . array_shift($message));
             } else {
                 if ($message instanceof STDClass) {
                     $message = (array) $message;
                     $item = $document->createElement('li', $key . array_shift($message));
                 } elseif ($message instanceof DOMDocumentFragment) {
                     $fragment = Administration::instance()->Page->createDocumentFragment();
                     $fragment->appendChild(new DOMText());
                     $item = $document->createElement('li');
                     $item->appendChild($fragment);
                 } else {
                     $item = $document->createElement('li', $key . $message);
                 }
             }
         }
         $list->appendChild($item);
     }
     $wrapper->appendChild($list);
 }
Ejemplo n.º 6
0
 public function displayPublishPanel(SymphonyDOMElement $wrapper, MessageStack $errors, Entry $entry = NULL, $data = NULL)
 {
     $driver = Extension::load('members');
     $document = $wrapper->ownerDocument;
     $sortorder = $this->{'sortorder'};
     $element_name = $this->{'element-name'};
     // Include CSS:
     $document->insertNodeIntoHead($document->createStylesheetElement(URL . '/extensions/members/assets/publish.css'));
     $document->insertNodeIntoHead($document->createScriptElement(URL . '/extensions/members/assets/publish.js'));
     $name = isset($this->{'publish-label'}) && strlen(trim($this->{'publish-label'})) > 0 ? $this->{'publish-label'} : $this->name;
     $label = $document->createElement('div');
     $label->addClass('label');
     $label->setValue($name);
     $group = $document->createElement('div');
     $group->addClass('group');
     if ($entry->id and $data->code) {
         $input = Widget::Input("fields[{$element_name}][validate][optional]", $driver->createToken($data->code, 'validate'), 'hidden');
         $wrapper->appendChild($input);
         $input = Widget::Input("fields[{$element_name}][change][optional]", $driver->createToken($data->code, 'change'), 'hidden');
         $wrapper->appendChild($input);
     }
     // Enter password:
     $div = $document->createElement('div');
     $input = Widget::Input("fields[{$element_name}][change][password]", isset($data->change->password) ? $data->change->password : null);
     $input->setAttribute('placeholder', __('Enter new password…'));
     $div->appendChild($input);
     if ($errors->valid() and isset($errors->{'change-password'})) {
         $div = Widget::wrapFormElementWithError($div, $errors->{'change-password'}->message);
     }
     $group->appendChild($div);
     // Confirm password:
     $div = $document->createElement('div');
     $input = Widget::Input("fields[{$element_name}][change][confirm]", isset($data->change->confirm) ? $data->change->confirm : null);
     $input->setAttribute('placeholder', __('Confirm new password…'));
     $div->appendChild($input);
     if ($errors->valid() and isset($errors->{'change-confirm'})) {
         $div = Widget::wrapFormElementWithError($div, $errors->{'change-confirm'}->message);
     }
     $group->appendChild($div);
     $label->appendChild($group);
     if ($errors->valid()) {
         $label = Widget::wrapFormElementWithError($label, null);
     }
     $wrapper->appendChild($label);
 }
Ejemplo n.º 7
0
 public function displayPublishPanel(SymphonyDOMElement $wrapper, MessageStack $errors, Entry $entry = NULL, $data = NULL)
 {
     $document = $wrapper->ownerDocument;
     $sortorder = $this->{'sortorder'};
     $element_name = $this->{'element-name'};
     $classes = array();
     $label = Widget::Label(isset($this->{'publish-label'}) && strlen(trim($this->{'publish-label'})) > 0 ? $this->{'publish-label'} : $this->name);
     if ($optional) {
         $label->appendChild($wrapper->ownerDocument->createElement('em', __('Optional')));
     }
     // Input box:
     $input = Widget::Input("fields[{$element_name}]", $data->value);
     // Add classes:
     if ($this->{'text-formatter'} != 'none') {
         $classes[] = $this->{'text-formatter'};
     }
     $input->setAttribute('class', implode(' ', $classes));
     $input->setAttribute('length', (int) $this->{'text-length'});
     $label->appendChild($input);
     if ($errors->valid()) {
         $label = Widget::wrapFormElementWithError($label, $errors->current()->message);
     }
     $wrapper->appendChild($label);
 }
Ejemplo n.º 8
0
 public static function array_to_xml(SymphonyDOMElement $parent, array $data, $validate = false)
 {
     foreach ($data as $element_name => $value) {
         if (empty($value)) {
             continue;
         }
         if (is_int($element_name)) {
             $child = Symphony::Parent()->Page->createElement('item');
             $child->setAttribute('index', $element_name + 1);
         } else {
             $child = Symphony::Parent()->Page->createElement($element_name);
         }
         if (is_array($value)) {
             self::array_to_xml($child, $value);
         } elseif ($validate == true && !self::validateXML(self::sanitize($value), $errors)) {
             return;
         } else {
             $child->setValue(self::sanitize($value));
         }
         $parent->appendChild($child);
     }
 }
Ejemplo n.º 9
0
 public function displayPublishPanel(SymphonyDOMElement $wrapper, MessageStack $errors, Entry $entry = NULL, $data = NULL)
 {
     $document = $wrapper->ownerDocument;
     $driver = Extension::load('field_textbox');
     $driver->addPublishHeaders($document);
     $sortorder = $this->{'sortorder'};
     $element_name = $this->{'element-name'};
     $classes = array();
     $label = Widget::Label(isset($this->{'publish-label'}) && strlen(trim($this->{'publish-label'})) > 0 ? $this->{'publish-label'} : $this->name);
     $optional = '';
     if ($this->{'required'} != 'yes') {
         if ((int) $this->{'text-length'} > 0) {
             $optional = $document->createDocumentFragment();
             $optional->appendChild($document->createTextNode(__('$1 of $2 remaining') . ' '));
             $optional->appendChild($document->createEntityReference('ndash'));
             $optional->appendChild($document->createTextNode(' ' . __('Optional')));
         } else {
             $optional = __('Optional');
         }
     } else {
         if ((int) $this->{'text-length'} > 0) {
             $optional = __('$1 of $2 remaining');
         }
     }
     if ($optional) {
         $label->appendChild($wrapper->ownerDocument->createElement('em', $optional));
     }
     // Input box:
     if ($this->{'text-size'} == 'single') {
         $input = Widget::Input("fields[{$element_name}]", $data->value);
         ###
         # Delegate: ModifyTextBoxInlineFieldPublishWidget
         # Description: Allows developers modify the textbox before it is rendered in the publish forms
         $delegate = 'ModifyTextBoxInlineFieldPublishWidget';
     } else {
         $input = Widget::Textarea("fields[{$element_name}]", $data->value, array('rows' => 20, 'cols' => 50));
         ###
         # Delegate: ModifyTextBoxFullFieldPublishWidget
         # Description: Allows developers modify the textbox before it is rendered in the publish forms
         $delegate = 'ModifyTextBoxFullFieldPublishWidget';
     }
     // Add classes:
     $classes[] = 'size-' . $this->{'text-size'};
     if ($this->{'text-formatter'} != 'none') {
         $classes[] = $this->{'text-formatter'};
     }
     $input->setAttribute('class', implode(' ', $classes));
     $input->setAttribute('length', (int) $this->{'text-length'});
     Extension::notify($delegate, '/administration/', array('field' => &$this, 'label' => &$label, 'input' => &$input));
     if (is_null($label)) {
         return;
     }
     $label->appendChild($input);
     if ($errors->valid()) {
         $label = Widget::wrapFormElementWithError($label, $errors->current()->message);
     }
     $wrapper->appendChild($label);
 }
Ejemplo n.º 10
0
 public function displayPublishPanel(SymphonyDOMElement $wrapper, MessageStack $errors, Entry $entry = null, $data = null)
 {
     if (!is_array($data)) {
         $data = array($data);
     }
     $selected = array();
     foreach ($data as $d) {
         if (!$d instanceof StdClass || !isset($d->value)) {
             continue;
         }
         $selected[] = $d->value;
     }
     $states = $this->getToggleStates();
     natsort($states);
     $options = array();
     if ($this->{'required'} == 'yes') {
         $options[] = array(null, false);
     }
     foreach ($states as $handle => $v) {
         $options[] = array($v, in_array($v, $selected), $v);
     }
     $fieldname = 'fields[' . $this->{'element-name'} . ']';
     if ($this->{'allow-multiple-selection'} == 'yes') {
         $fieldname .= '[]';
     }
     $label = Widget::Label(isset($this->{'publish-label'}) && strlen(trim($this->{'publish-label'})) > 0 ? $this->{'publish-label'} : $this->name);
     $label->appendChild(Widget::Select($fieldname, $options, $this->{'allow-multiple-selection'} == 'yes' ? array('multiple' => 'multiple') : array()));
     if ($errors->valid()) {
         $label = Widget::wrapFormElementWithError($label, $errors->current()->message);
     }
     $wrapper->appendChild($label);
 }
Ejemplo n.º 11
0
 public function displayPublishPanel(SymphonyDOMElement $wrapper, MessageStack $errors, Entry $entry = null, $data = null)
 {
     if (!is_array($data)) {
         $data = array($data);
     }
     $selected = array();
     foreach ($data as $d) {
         if (!$d instanceof StdClass || !isset($d->user_id)) {
             continue;
         }
         $selected[] = $d->user_id;
     }
     //$callback = Administration::instance()->getPageCallback();
     if ($this->{'default-to-current-user'} == 'yes' && is_null($data)) {
         $selected[] = Administration::instance()->User->id;
     }
     $users = new UserIterator();
     $options = array();
     if ($this->{'required'} == 'yes') {
         $options[] = array(null, false);
     }
     foreach ($users as $u) {
         $options[] = array($u->id, in_array($u->id, $selected), General::sanitize($u->getFullName()));
     }
     $fieldname = 'fields[' . $this->{'element-name'} . ']';
     if ($this->{'allow-multiple-selection'} == 'yes') {
         $fieldname .= '[]';
     }
     $label = Widget::Label(isset($this->{'publish-label'}) && strlen(trim($this->{'publish-label'})) > 0 ? $this->{'publish-label'} : $this->name);
     $label->appendChild(Widget::Select($fieldname, $options, $this->{'allow-multiple-selection'} == 'yes' ? array('multiple' => 'multiple') : array()));
     if ($errors->valid()) {
         $label = Widget::wrapFormElementWithError($label, $errors->current()->message);
     }
     $wrapper->appendChild($label);
 }
 public function appendField(SymphonyDOMElement $wrapper, Field $field)
 {
     $document = $wrapper->ownerDocument;
     $item = $document->createElement('li');
     $item->setAttribute('class', 'field');
     $name = $document->createElement('span', $field->name);
     $name->setAttribute('class', 'name');
     $name->appendChild($document->createElement('em', $field->name()));
     $item->appendChild($name);
     $input = Widget::Input('name', $field->{'element-name'}, 'hidden');
     $item->appendChild($input);
     $wrapper->appendChild($item);
 }
Ejemplo n.º 13
0
 public function displayPublishPanel(SymphonyDOMElement $wrapper, MessageStack $errors, Entry $entry = null, $data = null)
 {
     $joined = null;
     $document = $wrapper->ownerDocument;
     $xpath = new DOMXPath($document);
     $driver = Extension::load('field_join');
     $driver->addPublishHeaders($document);
     $sortorder = $this->{'sortorder'};
     $element_name = $this->{'element-name'};
     $wrapper->setAttribute('data-label', $this->{'publish-label'});
     $wrapper->setAttribute('data-show-header', $this->{'show-header'});
     if ($this->{'required'} != 'yes') {
         $wrapper->setAttribute('data-optional', __('Choose a section...'));
     }
     //var_dump($data); exit;
     if (isset($data->joined_id)) {
         $joined = Entry::loadFromId($data->joined_id);
     }
     // Use existing entry:
     if ($joined instanceof Entry) {
         $section = Section::loadFromHandle($joined->section);
         $context = $document->createElement('div');
         $context->setAttribute('data-handle', $section->handle);
         $context->setAttribute('data-name', $section->name);
         $context->addClass('context');
         $fields = array();
         foreach ($section->fields as $index => $instance) {
             $fields[$instance->{'element-name'}] = $instance;
         }
         $this->displayJoinedPublishPanel($context, $section, $fields, $errors, $joined);
         // Replace field names:
         foreach ($xpath->query('.//*[starts-with(@name, "fields[")]', $context) as $node) {
             $name = $node->getAttribute('name');
             $name = sprintf('fields[%s][%s]%s', $this->{'element-name'}, $joined->id, preg_replace('%^fields%', null, $name));
             $node->setAttribute('name', $name);
         }
         $wrapper->appendChild($context);
     } else {
         foreach ($this->{'joinable-sections'} as $handle) {
             try {
                 $section = Section::loadFromHandle($handle);
             } catch (Exception $e) {
                 continue;
             }
             $context = $document->createElement('div');
             $context->setAttribute('data-handle', $section->handle);
             $context->setAttribute('data-name', $section->name);
             $context->addClass('context');
             $fields = $values = array();
             $joined = new Entry();
             //var_dump($data);
             if (isset($data[$section->handle])) {
                 $values = $data[$section->handle];
             }
             foreach ($section->fields as $index => $instance) {
                 $handle = $instance->{'element-name'};
                 $fields[$handle] = $instance;
                 if (isset($values[$handle])) {
                     $joined->data()->{$handle} = $values[$handle];
                 }
             }
             $this->displayJoinedPublishPanel($context, $section, $fields, $errors, $joined);
             // Replace field names:
             foreach ($xpath->query('.//*[starts-with(@name, "fields[")]', $context) as $node) {
                 $name = $node->getAttribute('name');
                 $name = sprintf('fields[%s][%s]%s', $this->{'element-name'}, $section->handle, preg_replace('%^fields%', null, $name));
                 $node->setAttribute('name', $name);
             }
             $wrapper->appendChild($context);
         }
     }
 }
Ejemplo n.º 14
0
 public function displayDatasourceFilterPanel(SymphonyDOMElement $wrapper, $data = NULL, MessageStack $errors = NULL)
 {
     $data = $this->processFilter($data);
     $document = $wrapper->ownerDocument;
     $type_label = Widget::Label(__('Type'));
     $type_label->setAttribute('class', 'small');
     $type_label->appendChild(Widget::Select(sprintf('type', $this->{'element-name'}), $this->getFilterTypes($data)));
     $wrapper->appendChild($type_label);
     $label = Widget::Label(__('Value'));
     $label->appendChild(Widget::Input(sprintf('value', $this->{'element-name'}), $data->value));
     $label->appendChild(Widget::Input('element-name', $this->{'element-name'}, 'hidden'));
     $wrapper->appendChild(Widget::Group($type_label, $label));
 }
 /**
  * Build XML for actions and append it to the root element
  *
  * @param SymphonyDOMElement $root
  */
 public function buildActionsXML($root)
 {
     /*  SAMPLE $actions array:
     
     				array(
     					array(
     						'name'	=> 'Create New',
     						'type'	=> 'new',
     						'callback'	=> $this->path . '/new'
     					),
     					array(
     						'name'	=> 'Etc'
     					),
     				);
     
     				Need to think this through a little better (ability to
     				set classes, IDs, and other kinds of stuff)
     			*/
     $actions = $this->document->createElement('actions');
     foreach ($this->actions as $node) {
         $action = $this->document->createElement('action');
         foreach ($node as $name => $text) {
             $action->appendChild($this->document->createElement($name, $text));
         }
         $actions->appendChild($action);
     }
     $root->appendChild($actions);
 }
Ejemplo n.º 16
0
 public function appendFormattedElement(SymphonyDOMElement $wrapper, $data, $encode = false, $mode = null, Entry $entry = null)
 {
     if (!$this->sanitizeDataArray($data)) {
         return null;
     }
     $document = $wrapper->ownerDocument;
     $meta = unserialize($data->meta);
     if (!is_array($meta)) {
         $meta = array();
     }
     $meta['size'] = General::formatFilesize($data->size);
     $meta['type'] = $data->type;
     ksort($meta);
     $field = $document->createElement($this->{'element-name'});
     $field->appendChild($document->createElement('file', $data->name, array('path' => trim($data->path, '/'), 'name' => $data->file)));
     $element = $document->createElement('meta');
     foreach ($meta as $key => $value) {
         if ($key == 'creation' or $key == 'type') {
             $element->setAttribute($key, $value);
         } else {
             if ($key == 'size') {
                 $bits = explode(' ', $value);
                 if (count($bits) != 2) {
                     continue;
                 }
                 $element->appendChild($document->createElement('size', $bits[0], array('unit' => $bits[1])));
             } else {
                 if (is_array($value)) {
                     $element->appendChild($document->createElement($key, null, $value));
                 } else {
                     $element->appendChild($document->createElement($key, (string) $value));
                 }
             }
         }
     }
     $field->appendChild($element);
     ###
     # Delegate: UploadField_AppendFormattedElement
     # Description: Allow other extensions to add media previews.
     Extension::notify('UploadField_AppendFormattedElement', '/publish/', array('data' => $data, 'entry' => $entry, 'field' => $this, 'wrapper' => $field));
     $wrapper->appendChild($field);
 }
Ejemplo n.º 17
0
 public function appendTo(SymphonyDOMElement $wrapper)
 {
     $wrapper->appendChild($this->duplicator);
 }
Ejemplo n.º 18
0
 public function displayPublishPanel(SymphonyDOMElement $wrapper, MessageStack $errors, Entry $entry = null, $data = null)
 {
     if (!is_array($data)) {
         $data = array($data);
     }
     $selected = array();
     foreach ($data as $d) {
         if (!$d instanceof StdClass || !isset($d->relation_id)) {
             continue;
         }
         if (!is_array($d->relation_id)) {
             $selected[] = $d->relation_id;
         } else {
             $selected = array_merge($d->relation_id, $selected);
         }
     }
     $states = $this->findOptions($selected);
     $options = array();
     if ($this->{'required'} != 'yes') {
         $options[] = array(NULL, false, NULL);
     }
     if (!empty($states)) {
         foreach ($states as $s) {
             $group = array('label' => $s['name'], 'options' => array());
             foreach ($s['values'] as $id => $v) {
                 $group['options'][] = array($id, in_array($id, $selected), $v);
             }
             $options[] = $group;
         }
     }
     $fieldname = 'fields[' . $this->{'element-name'} . ']';
     if ($this->{'allow-multiple-selection'} == 'yes') {
         $fieldname .= '[]';
     }
     $label = Widget::Label(isset($this->{'publish-label'}) && strlen(trim($this->{'publish-label'})) > 0 ? $this->{'publish-label'} : $this->name);
     $label->appendChild(Widget::Select($fieldname, $options, $this->{'allow-multiple-selection'} == 'yes' ? array('multiple' => 'multiple') : array()));
     if ($errors->valid()) {
         $label = Widget::wrapFormElementWithError($label, $errors->current()->message);
     }
     $wrapper->appendChild($label);
 }
Ejemplo n.º 19
0
 public function appendTo(SymphonyDOMElement $parent)
 {
     $document = $parent->ownerDocument;
     $list = $document->createElement('ol');
     $list->setAttribute('id', 'alerts');
     foreach ($this as $alert) {
         $item = $document->createElement('li');
         $item->setAttribute('class', $alert->type);
         $message = $document->createElement('div');
         $message->setAttribute('class', 'message');
         $fragment = $document->createDocumentFragment();
         $fragment->appendXML($alert->message);
         $message->appendChild($fragment);
         $item->appendChild($message);
         if ($alert->info instanceof DOMElement) {
             $info = $document->createElement('div', $alert->info);
         } else {
             if ($alert->info instanceof Exception) {
                 $info = $document->createElement('div');
                 $header = $document->createElement('h3');
                 $header->setValue($alert->info->getMessage());
                 $info->appendChild($header);
                 $paragraph = $document->createElement('p');
                 $fragment = $document->createDocumentFragment();
                 $fragment->appendXML(__('An error occurred in <code>%s</code> around line <code>%d</code>', array($alert->info->getFile(), $alert->info->getLine())));
                 $paragraph->appendChild($fragment);
                 $info->appendChild($paragraph);
                 $ul = $document->createElement('ol');
                 $ul->setAttribute('class', 'trace-list');
                 foreach ($alert->info->getTrace() as $trace) {
                     $li = $document->createElement('li');
                     $code = $document->createElement('code');
                     $strong = $document->createElement('strong');
                     $called = array();
                     if (isset($trace['class']) and !empty($trace['class'])) {
                         $called[] = $trace['class'];
                     }
                     if (isset($trace['type']) and !empty($trace['type'])) {
                         $called[] = $trace['type'];
                     }
                     if (isset($trace['function']) and !empty($trace['function'])) {
                         $called[] = $trace['function'];
                     }
                     $code->setValue($trace['file'] . ':' . $trace['line']);
                     $strong->setValue(implode('', $called));
                     $code->appendChild($strong);
                     $li->appendChild($code);
                     $ul->appendChild($li);
                 }
                 $info->appendChild($ul);
             } else {
                 if ($alert->info instanceof MessageStack) {
                     $info = $document->createElement('div');
                     $alert->info->appendTo($info);
                 } else {
                     if (is_string($alert->info)) {
                         $fragment = $document->createDocumentFragment();
                         $fragment->appendXML($alert->info);
                         $info = $document->createElement('div', $fragment);
                     }
                 }
             }
         }
         if (isset($info)) {
             $info->setAttribute('class', 'info');
             $item->appendChild($info);
         }
         $list->appendChild($item);
     }
     $parent->appendChild($list);
 }
Ejemplo n.º 20
0
 public function displayPublishPanel(SymphonyDOMElement $wrapper, MessageStack $errors, Entry $entry = null, $data = null)
 {
     $name = $this->{'element-name'};
     $value = null;
     // New entry:
     if (is_null($data) && $this->{'pre-populate'} == 'yes') {
         $value = DateTimeObj::get(__SYM_DATETIME_FORMAT__, null);
     } else {
         if (isset($data->value) && !is_null($data->value)) {
             $timestamp = DateTimeObj::toGMT($data->value);
             $value = DateTimeObj::get(__SYM_DATETIME_FORMAT__, $timestamp);
         }
     }
     $label = Widget::Label(isset($this->{'publish-label'}) && strlen(trim($this->{'publish-label'})) > 0 ? $this->{'publish-label'} : $this->name, Widget::Input("fields[{$name}]", $value), array('class' => 'date'));
     if ($errors->valid()) {
         $label = Widget::wrapFormElementWithError($label, $errors->current()->message);
     }
     $wrapper->appendChild($label);
 }
Ejemplo n.º 21
0
 public function displayPublishPanel(SymphonyDOMElement $wrapper, MessageStack $errors, Entry $entry = null, $data = null)
 {
     if (is_array($data)) {
         $values = array();
         foreach ($data as $d) {
             $values[] = $d->value;
         }
         $data = (object) array('value' => $this->__tagArrayToString($values));
         unset($values);
     }
     if (!isset($data->value)) {
         $data->value = NULL;
     }
     $label = Widget::Label(isset($this->{'publish-label'}) && strlen(trim($this->{'publish-label'})) > 0 ? $this->{'publish-label'} : $this->name);
     $label->appendChild(Widget::Input('fields[' . $this->{'element-name'} . ']', $data->value));
     if ($errors->valid()) {
         $label = Widget::wrapFormElementWithError($label, $errors->current()->message);
     }
     $wrapper->appendChild($label);
     if (!is_null($this->{'suggestion-list-source'})) {
         $this->prepopulateSource($wrapper);
     }
 }