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); }
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); }
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); }
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); } }
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); }
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); }
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); }
public function displayPublishPanel(SymphonyDOMElement $wrapper, MessageStack $errors, Entry $entry = null, $data = null) { /*if (!$errors->valid() and !is_writable(DOCROOT . $this->destination . '/')) { $errors->append( null, (object)array( 'message' => __( 'Destination folder, "%s", is not writable. Please check permissions.', array(trim($this->destination, '/')) ), 'code' => self::ERROR_INVALID ) ); }*/ $driver = Extension::load('field_upload'); $driver->addHeaders(); $handle = $this->{'element-name'}; $document = $wrapper->ownerDocument; $filepath = null; if (isset($data->path, $data->file)) { $filepath = DOCROOT . '/' . trim($data->path, '/') . '/' . $data->file; } // Preview ------------------------------------------------------------ $label = $document->createElement('div', isset($this->{'publish-label'}) && strlen(trim($this->{'publish-label'})) > 0 ? $this->{'publish-label'} : $this->name); $label->setAttribute('class', 'label'); if ($this->required != 'yes') { $label->appendChild($document->createElement('em', 'Optional')); } if (!$errors->valid() and $data->file) { $file = $document->createElement('div'); $file->setAttribute('class', 'file'); $path = substr($filepath, strlen(DOCROOT)); ### # Delegate: UploadField_PreviewFile # Description: Allow other extensions to add media previews. Extension::notify('UploadField_PreviewFile', '/publish/', array('data' => $data, 'field' => $this, 'entry' => $entry, 'wrapper' => $wrapper)); if (!is_file($filepath)) { $errors->append(null, (object) array('message' => __('Destination file could not be found.'), 'code' => self::ERROR_MISSING)); } $name = $document->createElement('p'); $link = Widget::Anchor($data->{'name'}, URL . $path); $name->appendChild($link); $file->appendChild($name); $list = $document->createElement('dl'); $list->appendChild($document->createElement('dt', __('Size:'))); $list->appendChild($document->createElement('dd', General::formatFilesize($data->size))); $list->appendChild($document->createElement('dt', __('Type:'))); $list->appendChild($document->createElement('dd', $data->type)); // Meta data: if ($meta = unserialize($data->meta) and is_array($meta)) { $meta = (object) $meta; } if (isset($meta->width, $meta->height)) { $list->appendChild($document->createElement('dt', __('Width:'))); $list->appendChild($document->createElement('dd', sprintf('%dpx', $meta->width))); $list->appendChild($document->createElement('dt', __('Height:'))); $list->appendChild($document->createElement('dd', sprintf('%dpx', $meta->height))); } $file->appendChild($list); $label->appendChild($file); } // Upload ------------------------------------------------------------- $upload = $document->createElement('div'); $upload->setAttribute('class', 'upload'); if (!is_writable(DOCROOT . $this->destination . '/')) { $upload->setValue(__('Destination folder, "%s", is not writable. Please check permissions.', array(trim($this->destination, '/')))); } else { $input = Widget::Input("fields[{$handle}]", $filepath, $filepath ? 'hidden' : 'file'); $upload->appendChild($input); } $label->appendChild($upload); if ($errors->valid()) { $label = Widget::wrapFormElementWithError($label, $errors->current()->message); } $wrapper->appendChild($label); }
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 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); }