Пример #1
0
 public function __construct($name = 'div', $child_name = 'div')
 {
     $this->child_name = $child_name;
     $this->class = 'columns type-';
     $this->page = Symphony::Parent()->Page;
     $this->layout = $this->page->createElement($name);
 }
Пример #2
0
 public function __construct($add, $orderable = true)
 {
     $this->child_name = $child_name;
     $this->page = Symphony::Parent()->Page;
     $this->duplicator = $this->page->createElement('div');
     $this->duplicator->addClass('duplicator-widget');
     $controls = $this->page->createElement('ol');
     $controls->addClass('controls');
     $this->duplicator->appendChild($controls);
     $add_item = $this->page->createElement('li', $add);
     $add_item->addClass('add');
     $controls->appendChild($add_item);
     $this->templates = $this->page->createElement('ol');
     $this->templates->setAttribute('class', 'templates');
     $this->duplicator->appendChild($this->templates);
     $content = $this->page->createElement('div');
     $content->addClass('content');
     $this->duplicator->appendChild($content);
     $this->tabs = $this->page->createElement('ol');
     $this->tabs->addClass('tabs');
     $content->appendChild($this->tabs);
     if ($orderable) {
         $this->duplicator->addClass('orderable-widget');
     }
     $this->instances = $this->page->createElement('ol');
     $this->instances->addClass('instances');
     $content->appendChild($this->instances);
     $this->reflection = new ReflectionObject($this->duplicator);
 }
Пример #3
0
 public function addHeaders()
 {
     $page = Symphony::Parent()->Page;
     if (!$this->addedHeaders) {
         $page->insertNodeIntoHead($page->createStylesheetElement(URL . '/extensions/field_upload/assets/publish.css'));
         $page->insertNodeIntoHead($page->createScriptElement(URL . '/extensions/field_upload/assets/publish.js'));
         $this->addedHeaders = true;
     }
 }
Пример #4
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);
     }
 }
Пример #5
0
 public function prepareTableValue($data, DOMElement $link = NULL)
 {
     if (!is_array($data)) {
         $data = array($data);
     }
     $values = array();
     foreach ($data as $d) {
         $values[] = $d->user_id;
     }
     $fragment = Symphony::Parent()->Page->createDocumentFragment();
     foreach ($values as $user_id) {
         if (is_null($user_id)) {
             continue;
         }
         $user = User::load($user_id);
         if ($user instanceof User) {
             if ($fragment->hasChildNodes()) {
                 $fragment->appendChild(new DOMText(', '));
             }
             if (is_null($link)) {
                 $fragment->appendChild(Widget::Anchor(General::sanitize($user->getFullName()), ADMIN_URL . '/system/users/edit/' . $user->id . '/'));
             } else {
                 $link->setValue($user->getFullName());
                 $fragment->appendChild($link);
             }
         }
     }
     return !$fragment->hasChildNodes() ? __('None') : $fragment;
 }
Пример #6
0
 public function view(SymphonyDOMElement $wrapper, MessageStack $errors)
 {
     $page = $wrapper->ownerDocument;
     $page->insertNodeIntoHead($page->createScriptElement(URL . '/extensions/ds_sections/assets/view.js'), 55533140);
     $layout = new Layout();
     $left = $layout->createColumn(Layout::SMALL);
     $right = $layout->createColumn(Layout::LARGE);
     //	Essentials --------------------------------------------------------
     $fieldset = Widget::Fieldset(__('Essentials'));
     // Name:
     $label = Widget::Label(__('Name'));
     $input = Widget::Input('fields[about][name]', General::sanitize($this->about()->name));
     $label->appendChild($input);
     if (isset($errors->{'about::name'})) {
         $label = Widget::wrapFormElementWithError($label, $errors->{'about::name'});
     }
     $fieldset->appendChild($label);
     //	Source ------------------------------------------------------------
     $label = Widget::Label(__('Source URL'));
     $label->appendChild(Widget::Input('fields[url]', General::sanitize($this->parameters()->url)));
     if (isset($errors->url)) {
         $label = Widget::wrapFormElementWithError($label, $errors->url);
     }
     $fieldset->appendChild($label);
     $fragment = $page->createDocumentFragment();
     $fragment->appendXML(__('Use <code>{$param}</code> syntax to specify dynamic portions of the URL.'));
     $fieldset->appendChild($page->createElement('p', $fragment, array('class' => 'help')));
     $left->appendChild($fieldset);
     //	Timeouts ------------------------------------------------------------
     $fieldset = Widget::Fieldset(__('Time Limits'));
     $label = Widget::Label(__('Cache Limit'));
     $label->appendChild(Widget::Input('fields[cache-lifetime]', max(0, intval($this->parameters()->{'cache-lifetime'}))));
     if (isset($errors->{'cache-lifetime'})) {
         $label = Widget::wrapFormElementWithError($label, $errors->{'cache-lifetime'});
     }
     $fieldset->appendChild($label);
     $fragment = $page->createDocumentFragment();
     $fragment->appendXML(__('How often to refresh the cache.'));
     $fieldset->appendChild($page->createElement('p', $fragment, array('class' => 'help')));
     $label = Widget::Label(__('Gateway Timeout'));
     $label->appendChild(Widget::Input('fields[timeout]', max(1, intval($this->parameters()->{'timeout'}))));
     if (isset($errors->{'timeout'})) {
         $label = Widget::wrapFormElementWithError($label, $errors->{'timeout'});
     }
     $fieldset->appendChild($label);
     $fragment = $page->createDocumentFragment();
     $fragment->appendXML(__('How long to wait for a response.'));
     $fieldset->appendChild($page->createElement('p', $fragment, array('class' => 'help')));
     $left->appendChild($fieldset);
     //	Included Elements
     $fieldset = Widget::Fieldset(__('XML Processing'));
     $label = Widget::Label(__('Included Elements'));
     $label->appendChild(Widget::Input('fields[xpath]', General::sanitize($this->parameters()->xpath)));
     if (isset($errors->xpath)) {
         $label = Widget::wrapFormElementWithError($label, $errors->xpath);
     }
     $fieldset->appendChild($label);
     $help = Symphony::Parent()->Page->createElement('p');
     $help->setAttribute('class', 'help');
     $help->setValue(__('Use an XPath expression to select which elements from the source XML to include.'));
     $fieldset->appendChild($help);
     $right->appendChild($fieldset);
     //	Namespace Declarations
     $fieldset = Widget::Fieldset(__('Namespace Declarations'), $page->createElement('em', 'Optional'));
     $duplicator = new Duplicator(__('Add Namespace'));
     $this->appendNamespace($duplicator);
     if (is_array($this->parameters()->namespaces)) {
         foreach ($this->parameters()->namespaces as $index => $namespace) {
             $this->appendNamespace($duplicator, $namespace);
         }
     }
     $duplicator->appendTo($fieldset);
     $right->appendChild($fieldset);
     $layout->appendTo($wrapper);
 }
Пример #7
0
 public function adminPagePreGenerate()
 {
     $page = Symphony::Parent()->Page;
     $page->insertNodeIntoHead($page->createStylesheetElement(URL . '/extensions/upload_progress/assets/publish.css'));
     $page->insertNodeIntoHead($page->createScriptElement(URL . '/extensions/upload_progress/assets/publish.js'));
 }