当前位置: 首页>>代码示例>>PHP>>正文


PHP XMLElement::getAttribute方法代码示例

本文整理汇总了PHP中XMLElement::getAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLElement::getAttribute方法的具体用法?PHP XMLElement::getAttribute怎么用?PHP XMLElement::getAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XMLElement的用法示例。


在下文中一共展示了XMLElement::getAttribute方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: displayPublishPanel

 function displayPublishPanel(XMLElement &$wrapper, $data = null, $flagWithError = null, $fieldnamePrefix = null, $fieldnamePostfix = null, $entry_id = null)
 {
     $note = isset($data['value']) ? $data['value'] : $this->get('note');
     $editable = $this->get('editable');
     # Add <div>
     $div = new XMLElement("div", $note, array("id" => Lang::createHandle($this->get('label')), "class" => "publishnotes-note"));
     $wrapper->appendChild($div);
     # Editable
     if (isset($editable) && $editable) {
         $wrapper->setAttribute('class', $wrapper->getAttribute('class') . " editable");
         $edit = new XMLElement("a", __("Edit note"), array("class" => "publishnotes-edit", "href" => "#edit"));
         $wrapper->appendChild($edit);
         # Add <textarea>
         $label = Widget::Label("Edit: " . $this->get('label'), NULL, Lang::createHandle($this->get('label')));
         $textarea = Widget::Textarea('fields' . $fieldnamePrefix . '[' . $this->get('element_name') . ']' . $fieldnamePostfix, 8, 50, strlen($note) != 0 ? General::sanitize($note) : NULL);
         $label->appendChild($textarea);
         $control = new XMLElement("div", '<input type="submit" value="Change note"/> or <a href="#">cancel</a>', array("class" => "control"));
         $label->appendChild($control);
         if ($flagWithError != NULL) {
             $wrapper->appendChild(Widget::Error($label, $flagWithError));
         } else {
             $wrapper->appendChild($label);
         }
     }
 }
开发者ID:hotdoy,项目名称:EDclock,代码行数:25,代码来源:field.publishnotes.php

示例2: appendFormattedElement

 /**
  * Generate data source output.
  *
  * @param XMLElement $wrapper
  * @param array $data
  * @param boolean $encode
  * @param string $mode
  */
 public function appendFormattedElement(&$wrapper, $data, $encode = false)
 {
     // unify data
     if (!is_array($data['relation_id'])) {
         $data['relation_id'] = array($data['relation_id']);
     }
     // create Mediathek element
     $mediathek = new XMLElement($this->get('element_name'));
     // check for included fields
     if ($this->get('included_fields') == '') {
         $error = new XMLElement('error', 'No fields for output defined.');
         $mediathek->appendChild($error);
         $wrapper->appendChild($mediathek);
         return;
     }
     // fetch field data
     $entryManager = new EntryManager($this->_engine);
     $entries = $entryManager->fetch($data['relation_id'], $this->get('related_section_id'));
     // sort entries
     $order = $this->_Parent->_Parent->Database->fetchVar('order', 0, "SELECT `order`\n\t\t\t\tFROM `tbl_fields_mediathek_sorting`\n\t\t\t\tWHERE `entry_id` = " . $wrapper->getAttribute('id') . "\n\t\t\t\tAND `field_id` = " . $this->get('id') . "\n\t\t\t\tLIMIT 1");
     $sorted_ids = explode(',', $order);
     $sorted_entries = array();
     if (!empty($sorted_ids) && $sorted_ids[0] != 0) {
         foreach ($sorted_ids as $id) {
             foreach ($entries as $entry) {
                 if ($entry->get('id') == $id) {
                     $sorted_entries[] = $entry;
                 }
             }
         }
     } else {
         $sorted_entries = $entries;
     }
     // build XML
     $count = 1;
     foreach ($sorted_entries as $entry) {
         // fetch entry data
         $entry_data = $entry->getData();
         // create entry element
         $item = new XMLElement('item');
         // populate entry element
         $included_fields = explode(',', $this->get('included_fields'));
         foreach ($entry_data as $field_id => $values) {
             // only append if field is listed or if list empty
             if (in_array($field_id, $included_fields) || empty($included_fields[0])) {
                 $field =& $entryManager->fieldManager->fetch($field_id);
                 $field->appendFormattedElement($item, $values, false);
             }
         }
         // append entry element
         $mediathek->appendChild($item);
         $mediathek->setAttribute('items', $count);
         $count++;
     }
     // append Mediathek to data source
     $wrapper->appendChild($mediathek);
 }
开发者ID:bitfyre,项目名称:mediathek,代码行数:65,代码来源:field.mediathek.php

示例3: prepareTableValue

 public function prepareTableValue($data, XMLElement $link = null, $entry_id = null)
 {
     if (empty($data)) {
         return;
     }
     $zoom = (int) $data['zoom'] - 2;
     if ($zoom < 1) {
         $zoom = 1;
     }
     $thumbnail = sprintf("<img src='http://maps.google.com/maps/api/staticmap?center=%s&zoom=%d&size=160x90&sensor=false&markers=color:red|size:small|%s' alt=''/>", $data['centre'], $zoom, implode(',', array($data['latitude'], $data['longitude'])));
     if (null !== $link) {
         return sprintf('<a href="%s">%s</a>', $link->getAttribute('href'), $thumbnail);
     }
     return $thumbnail;
 }
开发者ID:stuartgpalmer,项目名称:maplocationfield,代码行数:15,代码来源:field.maplocation.php

示例4: prepareTableValue

 /**
  * @see http://symphony-cms.com/learn/api/2.3/toolkit/field/#prepareTableValue
  */
 function prepareTableValue($data, XMLElement $link = null)
 {
     if (empty($data['relation_id'])) {
         return null;
     }
     // Single select
     if ($this->get('allow_multiple') == 0 || count($data['relation_id']) === 1) {
         $subsection = new SubsectionManager();
         $content = $subsection->generate($this->get('id'), $this->get('subsection_id'), $data, $this->get('recursion_levels'), SubsectionManager::GETPREVIEW);
         // Link?
         if ($link) {
             $href = $link->getAttribute('href');
             $item = '<a href="' . $href . '">' . $content['preview'] . '</a>';
         } else {
             $item = $content['preview'];
         }
         return '<div class="subsectionmanager">' . $item . '</div>';
     } else {
         $count = count($data['relation_id']);
         return parent::prepareTableValue(array('value' => $count > 1 ? $count . ' ' . __('items') : $count . ' ' . __('item')), $link);
     }
 }
开发者ID:symphonists,项目名称:subsectionmanager,代码行数:25,代码来源:field.subsectionmanager.php

示例5: insertDrawer

 /**
  * Allows a Drawer element to added to the backend page in one of three
  * positions, `horizontal`, `vertical-left` or `vertical-right`. The button
  * to trigger the visibility of the drawer will be added after existing
  * actions by default.
  *
  * @since Symphony 2.3
  * @see core.Widget#Drawer
  * @param XMLElement $drawer
  *  An XMLElement representing the drawer, use `Widget::Drawer` to construct
  * @param string $position
  *  Where `$position` can be `horizontal`, `vertical-left` or
  *  `vertical-right`. Defaults to `horizontal`.
  * @param string $button
  *  If not passed, a button to open/close the drawer will not be added
  *  to the interface. Accepts 'prepend' or 'append' values, which will
  *  add the button before or after existing buttons. Defaults to `prepend`.
  *  If any other value is passed, no button will be added.
  */
 public function insertDrawer(XMLElement $drawer, $position = 'horizontal', $button = 'append')
 {
     $drawer->addClass($position);
     $drawer->setAttribute('data-position', $position);
     $this->Drawer[$position][] = $drawer;
     if (in_array($button, array('prepend', 'append'))) {
         $this->insertAction(Widget::Anchor($drawer->getAttribute('data-label'), '#' . $drawer->getAttribute('id'), null, 'button drawer ' . $position), $button === 'append' ? true : false);
     }
 }
开发者ID:nickdunn,项目名称:elasticsearch-surfin-shakespeare,代码行数:28,代码来源:class.administrationpage.php

示例6: getChildrenWithClass

 private function getChildrenWithClass(XMLElement &$rootElement, $className, $tagName = null)
 {
     if ($rootElement == null) {
         return null;
     }
     // contains the right css class and the right node name (if any)
     // TODO: Use word bondaries instead of strpos
     if ((!$className || strpos($rootElement->getAttribute('class'), $className) > -1) && (!$tagName || $rootElement->getName() == $tagName)) {
         return $rootElement;
     }
     // recursive search in child elements
     foreach ($rootElement->getChildren() as $key => $child) {
         if (!$child instanceof XMLElement) {
             continue;
         }
         $res = $this->getChildrenWithClass($child, $className, $tagName);
         if ($res != null) {
             return $res;
         }
     }
     return null;
 }
开发者ID:hotdoy,项目名称:EDclock,代码行数:22,代码来源:field.image_upload.php

示例7: prepareTableValue

 /**
  * @see http://symphony-cms.com/learn/api/2.2/toolkit/field/#prepareTableValue
  */
 function prepareTableValue($data, XMLElement $link = NULL)
 {
     if (!is_array($data['start'])) {
         $data['start'] = array($data['start']);
     }
     if (!is_array($data['end'])) {
         $data['end'] = array($data['end']);
     }
     // Handle empty dates
     if (empty($data['start'][0])) {
         if ($link) {
             $href = $link->getAttribute('href');
             return '<a href="' . $href . '">' . __('No Date') . '</a>';
         } else {
             return __('No Date');
         }
     }
     // Get schema
     if ($this->get('time') == 1) {
         $scheme = __SYM_DATETIME_FORMAT__;
     } else {
         $scheme = __SYM_DATE_FORMAT__;
     }
     // Parse dates
     $value = array();
     for ($i = 0; $i < count($data['start']); $i++) {
         $start = new DateTime($data['start'][$i]);
         $separator = ' &#8211; ';
         // Date range
         if ($data['end'][$i] != $data['start'][$i]) {
             $end = new DateTime($data['end'][$i]);
             // Different start and end days
             if ($start->format('D-M-Y') != $end->format('D-M-Y')) {
                 $value[] = LANG::localizeDate($start->format($scheme) . $separator . $end->format($scheme));
             } else {
                 // Show time
                 if ($this->get('time') == 1) {
                     // Adjust separator
                     if (Symphony::Configuration()->get('time_format', 'region') == 'H:i') {
                         $separator = '&#8211;';
                     }
                     $value[] = LANG::localizeDate($start->format($scheme) . $separator . $end->format(Symphony::Configuration()->get('time_format', 'region')));
                 } else {
                     $value[] = LANG::localizeDate($start->format($scheme));
                 }
             }
         } else {
             $value[] = LANG::localizeDate($start->format($scheme));
         }
     }
     // Link?
     if ($link) {
         $href = $link->getAttribute('href');
         return '<a href="' . $href . '">' . implode($value, ', <br />') . '</a>';
     } else {
         return implode($value, ', <br />');
     }
 }
开发者ID:brendo,项目名称:datetime,代码行数:61,代码来源:field.datetime.php

示例8: displayPublishPanel

 public function displayPublishPanel(XMLElement &$wrapper, $data = NULL, $flagWithError = NULL, $fieldnamePrefix = NULL, $fieldnamePostfix = NULL)
 {
     $wrapper->setAttribute('class', $wrapper->getAttribute('class') . ' field-multilingual');
     $container = new XMLElement('div', null, array('class' => 'container'));
     /* Label */
     $label = Widget::Label($this->get('label'));
     $class = 'file';
     $label->setAttribute('class', $class);
     if ($this->get('required') != 'yes') {
         $label->appendChild(new XMLElement('i', __('Optional')));
     }
     $container->appendChild($label);
     $reference_language = FLang::instance()->referenceLanguage();
     $all_languages = FLang::instance()->ld()->allLanguages();
     $language_codes = FLang::instance()->ld()->languageCodes();
     /* Tabs */
     $ul = new XMLElement('ul');
     $ul->setAttribute('class', 'tabs');
     foreach ($language_codes as $language_code) {
         $class = $language_code . ($language_code == $reference_language ? ' active' : '');
         $li = new XMLElement('li', $all_languages[$language_code] ? $all_languages[$language_code] : __('Unknown language'));
         $li->setAttribute('class', $class);
         // to use this, Multilingual Text must depend on Frontend Localisation so UX is consistent regarding Language Tabs
         //				if( $language_code == $reference_language ){
         //					$ul->prependChild($li);
         //				}
         //				else{
         $ul->appendChild($li);
         //				}
     }
     $container->appendChild($ul);
     /* Inputs */
     foreach ($language_codes as $language_code) {
         $div = new XMLElement('div', NULL, array('class' => 'file tab-panel tab-' . $language_code));
         $file = 'file-' . $language_code;
         if ($data[$file]) {
             $div->appendChild(Widget::Anchor('/workspace' . $data[$file], URL . '/workspace' . $data[$file]));
         }
         $div->appendChild(Widget::Input('fields' . $fieldnamePrefix . '[' . $this->get('element_name') . '][' . $language_code . ']' . $fieldnamePostfix, $data[$file], $data[$file] ? 'hidden' : 'file'));
         $container->appendChild($div);
     }
     /* Directory check */
     if (!is_dir(DOCROOT . $this->get('destination') . '/')) {
         $flagWithError = __('The destination directory, <code>%s</code>, does not exist.', array($this->get('destination')));
     } elseif (!$flagWithError && !is_writable(DOCROOT . $this->get('destination') . '/')) {
         $flagWithError = __('Destination folder, <code>%s</code>, is not writable. Please check permissions.', array($this->get('destination')));
     }
     if ($flagWithError != NULL) {
         $wrapper->appendChild(Widget::wrapFormElementWithError($container, $flagWithError));
     } else {
         $wrapper->appendChild($container);
     }
 }
开发者ID:nanymor,项目名称:multilingual_upload_field,代码行数:53,代码来源:field.multilingualupload.php

示例9: appendFormattedElement

 /**
  * Generate data source output.
  *
  * @param XMLElement $wrapper
  * @param array $data
  * @param boolean $encode
  * @param string $mode
  */
 public function appendFormattedElement(&$wrapper, $data, $encode = false, $mode = "entries")
 {
     // unify data
     if (!is_array($data['relation_id'])) {
         $data['relation_id'] = array($data['relation_id']);
     }
     // create Subsection Manager element
     $subsectionmanager = new XMLElement($this->get('element_name'));
     // check for included fields
     if ($this->get('included_fields') == '') {
         $error = new XMLElement('error', 'No fields for output defined.');
         $subsectionmanager->appendChild($error);
         $wrapper->appendChild($subsectionmanager);
         return;
     }
     // fetch field data
     $entries = self::$em->fetch($data['relation_id'], $this->get('subsection_id'));
     $subsectionmanager->setAttribute('entries', count($entries));
     if ($mode == "entries") {
         // sort entries
         $order = self::$db->fetchVar('order', 0, sprintf("\n\t\t\t\t\t\t\tSELECT `order`\n\t\t\t\t\t\t\tFROM `tbl_fields_subsectionmanager_sorting`\n\t\t\t\t\t\t\tWHERE `entry_id` = %d\n\t\t\t\t\t\t\tAND `field_id` = %d\n\t\t\t\t\t\t\tLIMIT 1\n\t\t\t\t\t\t", $wrapper->getAttribute('id'), $this->get('id')));
         $sorted_ids = explode(',', $order);
         $sorted_entries = array();
         if (!empty($sorted_ids) && $sorted_ids[0] != 0 && !empty($sorted_ids[0])) {
             foreach ($sorted_ids as $id) {
                 foreach ($entries as $entry) {
                     if ($entry->get('id') == $id) {
                         $sorted_entries[] = $entry;
                     }
                 }
             }
         } else {
             $sorted_entries = $entries;
         }
         // build XML
         $included_fields = explode(',', $this->get('included_fields'));
         foreach ($sorted_entries as $entry) {
             // fetch entry data
             $entry_data = $entry->getData();
             // create entry element
             $item = new XMLElement('entry');
             $item->setAttribute('id', $entry->get('id'));
             // populate entry element
             foreach ($entry_data as $field_id => $values) {
                 // only append if field is listed or if list empty
                 if (in_array($field_id, $included_fields) || empty($included_fields[0])) {
                     $field = self::$fm->fetch($field_id);
                     $field->appendFormattedElement($item, $values, false);
                 }
             }
             // append entry element
             $subsectionmanager->appendChild($item);
         }
     }
     // append Subsection Manager to data source
     $wrapper->appendChild($subsectionmanager);
 }
开发者ID:brendo,项目名称:subsectionmanager,代码行数:65,代码来源:field.subsectionmanager.php

示例10: prepareTableValue

 /**
  *
  * Build the UI for the table view
  * @param Array $data
  * @param XMLElement $link
  * @param int $entry_id
  * @return string - the html of the link
  */
 public function prepareTableValue($data, XMLElement $link = NULL, $entry_id = NULL)
 {
     $url = $data['url'];
     $thumb = $data['thumbnail_url'];
     $textValue = $this->prepareTextValue($data, $entry_id);
     $value = NULL;
     // no url = early exit
     if (strlen($url) == 0) {
         return NULL;
     }
     // no thumbnail or the parameter is not set ?
     if (empty($thumb) || $this->get('thumbs') != 'yes') {
         // if not use the title or the url as value
         $value = $textValue;
     } else {
         // create a image
         $thumb = ServiceDriver::removeHTTPProtocol($thumb);
         $thumb = ServiceDriver::removeRelativeProtocol($thumb);
         $img_path = URL . '/image/1/0/40/1/' . $thumb;
         $value = '<img src="' . $img_path . '" alt="' . General::sanitize($data['title']) . '" height="40" />';
     }
     // does this cell serve as a link ?
     if (!!$link) {
         // if so, set our html as the link's value
         $link->setValue($value);
         $link->setAttribute('title', $textValue . ' | ' . $link->getAttribute('title'));
     } else {
         // if not, wrap our html with a external link to the resource url
         $link = new XMLElement('a', $value, array('href' => $url, 'target' => '_blank', 'title' => $textValue));
     }
     // returns the link's html code
     return $link->generate();
 }
开发者ID:justinjaywang,项目名称:oembed_field,代码行数:41,代码来源:field.oembed.php


注:本文中的XMLElement::getAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。