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


PHP XMLElement::setAttributeArray方法代码示例

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


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

示例1: appendFormattedElement

 function appendFormattedElement(&$wrapper, $data)
 {
     if (!is_array($data) || empty($data)) {
         return;
     }
     // If cache has expired refresh the data array from parsing the API XML
     if (time() - $data['last_updated'] > $this->_fields['refresh'] * 60) {
         $data = VimeoHelper::updateClipInfo($data['clip_id'], $this->_fields['id'], $wrapper->getAttribute('id'), $this->Database);
     }
     $video = new XMLElement($this->get('element_name'));
     $video->setAttributeArray(array('clip-id' => $data['clip_id'], 'width' => $data['width'], 'height' => $data['height'], 'duration' => $data['duration'], 'plays' => $data['plays']));
     $video->appendChild(new XMLElement('title', General::sanitize($data['title'])));
     $video->appendChild(new XMLElement('caption', General::sanitize($data['caption'])));
     $user = new XMLElement('user');
     $user->appendChild(new XMLElement('name', $data['user_name']));
     $user->appendChild(new XMLElement('url', $data['user_url']));
     $thumbnail = new XMLElement('thumbnail');
     $thumbnail->setAttributeArray(array('width' => $data['thumbnail_width'], 'height' => $data['thumbnail_height'], 'size' => 'large'));
     $thumbnail->appendChild(new XMLElement('url', $data['thumbnail_url']));
     $video->appendChild($thumbnail);
     $thumbnail = new XMLElement('thumbnail');
     $thumbnail->setAttributeArray(array('width' => $data['thumbnail_medium_width'], 'height' => $data['thumbnail_medium_height'], 'size' => 'medium'));
     $thumbnail->appendChild(new XMLElement('url', $data['thumbnail_medium_url']));
     $video->appendChild($thumbnail);
     $thumbnail = new XMLElement('thumbnail');
     $thumbnail->setAttributeArray(array('width' => $data['thumbnail_small_width'], 'height' => $data['thumbnail_small_height'], 'size' => 'small'));
     $thumbnail->appendChild(new XMLElement('url', $data['thumbnail_small_url']));
     $video->appendChild($thumbnail);
     $video->appendChild($user);
     $wrapper->appendChild($video);
 }
开发者ID:nickdunn,项目名称:vimeo_videos,代码行数:31,代码来源:field.vimeo_video.php

示例2: __trigger

 protected function __trigger()
 {
     ## Cookies only show up on page refresh. This flag helps in making sure the correct XML is being set
     $loggedin = false;
     if (isset($_REQUEST['action']['login'])) {
         $username = $_REQUEST['username'];
         $password = $_REQUEST['password'];
         $loggedin = $this->_Parent->login($username, $password);
     } else {
         $loggedin = $this->_Parent->isLoggedIn();
     }
     if ($loggedin) {
         $result = new XMLElement('login-info');
         $result->setAttribute('logged-in', 'true');
         $author = $this->_Parent->Author;
         $result->setAttributeArray(array('id' => $author->get('id'), 'user-type' => $author->get('user_type'), 'primary-account' => $author->get('primary')));
         $fields = array('name' => new XMLElement('name', $author->getFullName()), 'username' => new XMLElement('username', $author->get('username')), 'email' => new XMLElement('email', $author->get('email')));
         if ($author->isTokenActive()) {
             $fields['author-token'] = new XMLElement('author-token', $author->createAuthToken());
         }
         if ($section = $this->_Parent->Database->fetchRow(0, "SELECT `id`, `handle`, `name` FROM `tbl_sections` WHERE `id` = '" . $author->get('default_section') . "' LIMIT 1")) {
             $default_section = new XMLElement('default-section', $section['name']);
             $default_section->setAttributeArray(array('id' => $section['id'], 'handle' => $section['handle']));
             $fields['default-section'] = $default_section;
         }
         foreach ($fields as $f) {
             $result->appendChild($f);
         }
     } else {
         $result = new XMLElement('user');
         $result->setAttribute('logged-in', 'false');
     }
     return $result;
 }
开发者ID:shobhalakshminarayana,项目名称:Bugaroo,代码行数:34,代码来源:event.login.php

示例3: buildFilterElement

 /**
  * This method will construct XML that represents the result of
  * an Event filter.
  *
  * @param string $name
  *  The name of the filter
  * @param string $status
  *  The status of the filter, either passed or failed.
  * @param XMLElement|string $message
  *  Optionally, an XMLElement or string to be appended to this
  *  `<filter>` element. XMLElement allows for more complex return
  *  types.
  * @param array $attributes
  *  An associative array of additional attributes to add to this
  *  `<filter>` element
  * @return XMLElement
  */
 public static function buildFilterElement($name, $status, $message = null, array $attributes = null)
 {
     $filter = new XMLElement('filter', !$message || is_object($message) ? null : $message, array('name' => $name, 'status' => $status));
     if ($message instanceof XMLElement) {
         $filter->appendChild($message);
     }
     if (is_array($attributes)) {
         $filter->setAttributeArray($attributes);
     }
     return $filter;
 }
开发者ID:nils-werner,项目名称:symphony-2,代码行数:28,代码来源:class.event.section.php

示例4: buildFilterElement

 public function buildFilterElement($name, $status, $message = null, array $attr = null)
 {
     $ret = new XMLElement('filter', !$message || is_object($message) ? null : $message, array('name' => $name, 'status' => $status));
     if (is_object($message)) {
         $ret->appendChild($message);
     }
     if (is_array($attr)) {
         $ret->setAttributeArray($attr);
     }
     return $ret;
 }
开发者ID:readona,项目名称:symphonyno5,代码行数:11,代码来源:class.event.section.php

示例5: grab

 function grab(&$param_pool)
 {
     $tag_list_id = "38";
     $result = new XMLElement("tag-cloud");
     $tags = $this->_Parent->Database->fetch("SELECT DISTINCT(handle), COUNT(handle) AS count, value FROM sym_entries_data_{$tag_list_id} GROUP BY handle ORDER BY handle ASC");
     foreach ($tags as $tag) {
         $tag_node = new XMLElement("tag", $tag["value"]);
         $tag_node->setAttributeArray(array("handle" => $tag["handle"], "count" => $tag["count"]));
         $result->appendChild($tag_node);
     }
     return $result;
 }
开发者ID:bauhouse,项目名称:sym-designprojectx,代码行数:12,代码来源:data.tag_cloud.php

示例6: view

 function view()
 {
     $this->setPageType('table');
     $this->setTitle(__('%1$s &ndash; %2$s', array(__('Symphony'), __('Translation Manager'))));
     $this->appendSubheading(__('Languages'), Widget::Anchor(__('Create New'), $this->_Parent->getCurrentPageURL() . 'edit/', __('Create new translation'), 'create button'));
     $link = new XMLElement('link');
     $link->setAttributeArray(array('rel' => 'stylesheet', 'type' => 'text/css', 'media' => 'screen', 'href' => URL . '/extensions/translationmanager/assets/admin.css'));
     $this->addElementToHead($link, 500);
     $this->addScriptToHead(URL . '/extensions/translationmanager/assets/admin.js', 501);
     $default = $this->_tm->defaultDictionary();
     $translations = $this->_tm->listAll();
     $allextensions = $this->_Parent->ExtensionManager->listAll();
     $current = $this->_Parent->Configuration->get('lang', 'symphony');
     $warnings = array_shift($default);
     $allnames = array('symphony' => __('Symphony'));
     foreach ($allextensions as $extension => $about) {
         $allnames[$extension] = $about['name'];
     }
     $aTableHead = array(array(__('Name'), 'col'), array(__('Code'), 'col'), array(__('Extensions*'), 'col', array('title' => __('Out of %s (including Symphony)', array(count($allextensions) + 1)))), array(__('Translated*'), 'col', array('title' => __('Out of %1$s (with %2$s parser warnings)', array(count($default), count($warnings) > 0 ? count($warnings) : __('no'))))), array(__('Obsolete'), 'col'), array(__('Current'), 'col'));
     $aTableBody = array();
     if (!is_array($translations) || empty($translations)) {
         $aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None Found.'), 'inactive', NULL, count($aTableHead)))));
     } else {
         foreach ($translations as $lang => $extensions) {
             $language = $this->_tm->get($lang);
             $translated = array_intersect_key(array_filter($language['dictionary'], 'trim'), $default);
             $obsolete = array_diff_key($language['dictionary'], $default);
             $names = array_intersect_key($allnames, array_fill_keys($extensions, true));
             if (!$language['about']['name']) {
                 $language['about']['name'] = $lang;
             }
             $td1 = Widget::TableData(Widget::Anchor($language['about']['name'], $this->_Parent->getCurrentPageURL() . 'edit/' . $lang . '/', $lang));
             $td2 = Widget::TableData($lang);
             $td3 = Widget::TableData((string) count($extensions), NULL, NULL, NULL, array('title' => implode(', ', $names)));
             $td4 = Widget::TableData(count($translated) . ' <small>(' . floor(count($translated) / count($default) * 100) . '%)</small>');
             $td5 = Widget::TableData((string) count($obsolete));
             $td6 = Widget::TableData($lang == $current ? __('Yes') : __('No'));
             $td1->appendChild(Widget::Input('item', $lang, 'radio'));
             ## Add a row to the body array, assigning each cell to the row
             $aTableBody[] = Widget::TableRow(array($td1, $td2, $td3, $td4, $td5, $td6), 'single' . ($lang == $this->_Parent->Configuration->get('lang', 'symphony') ? ' current' : ''));
         }
     }
     $table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody), 'languages');
     $this->Form->appendChild($table);
     $div = new XMLElement('div');
     $div->setAttribute('class', 'actions');
     $options = array(array(NULL, false, __('With Selected...')), array('delete', false, __('Delete')), array('switch', false, __('Make it current')), array('export', false, __('Export ZIP')));
     $div->appendChild(Widget::Select('with-selected', $options));
     $div->appendChild(Widget::Input('action[apply]', __('Apply'), 'submit'));
     $this->Form->appendChild($div);
 }
开发者ID:bauhouse,项目名称:sym-extensions,代码行数:51,代码来源:content.index.php

示例7: XMLElement

 function __viewEdit()
 {
     $link = new XMLElement('link');
     $link->setAttributeArray(array('rel' => 'stylesheet', 'type' => 'text/css', 'media' => 'screen', 'href' => URL . '/extensions/configuration/assets/configuration.css'));
     $this->addElementToHead($link, 500);
     $this->setTitle('Symphony &ndash; Configuration Settings');
     $this->setPageType('table');
     $this->appendSubheading('Configuration Settings');
     ## Table Headings
     $aTableHead = array(array('Group', 'col'), array('Setting', 'col'), array('Value', 'col'));
     ## Get Configuration Settings and display as a table list
     $config_settings = $this->_Parent->Configuration->get();
     $tableData = array();
     $count = 0;
     foreach ($config_settings as $key => $groups) {
         foreach ($groups as $name => $value) {
             $setting_group = $key;
             $setting_name = $name;
             $setting_value = $value;
             $setting_group_data = '<input name="settings[' . $count . '][group]" type="hidden" value="' . $setting_group . '" />' . $setting_group;
             $setting_name_data = '<input name="settings[' . $count . '][name]" type="hidden" value="' . $setting_name . '" />' . $setting_name;
             $tableData[] = Widget::TableData($setting_group_data);
             $tableData[] = Widget::TableData($setting_name_data);
             $tableData[] = Widget::TableData(Widget::Input('settings[' . $count . '][value]', $setting_value, 'text'));
             $count++;
             $aTableBody[] = Widget::TableRow($tableData, $bEven ? 'even' : NULL);
             $bEven = !$bEven;
             unset($tableData);
         }
     }
     $table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody));
     $this->Form->appendChild($table);
     ## Save Button
     $div = new XMLElement('div');
     $div->setAttribute('class', 'actions');
     $div->appendChild(Widget::Input('action[save]', 'Save Settings', 'submit', array('accesskey' => 's')));
     $this->Form->appendChild($div);
     ## Notice Messages
     if (isset($this->_flag)) {
         switch ($this->_flag) {
             case 'saved':
                 $this->pageAlert('Configuration Settings updated successfully.', AdministrationPage::PAGE_ALERT_NOTICE);
                 break;
             case 'error':
                 $this->pageAlert('An error occurred.', AdministrationPage::PAGE_ALERT_NOTICE);
                 break;
         }
     }
 }
开发者ID:bauhouse,项目名称:sym-extensions,代码行数:49,代码来源:content.settings.php

示例8: __trigger

 protected function __trigger()
 {
     // Cookies only show up on page refresh.
     // This flag helps in making sure the correct XML is being set
     $loggedin = false;
     if (isset($_REQUEST['action']['login'])) {
         $username = $_REQUEST['username'];
         $password = $_REQUEST['password'];
         $loggedin = Frontend::instance()->login($username, $password);
     } else {
         $loggedin = Frontend::instance()->isLoggedIn();
     }
     if ($loggedin) {
         $result = new XMLElement('login-info');
         $result->setAttribute('logged-in', 'true');
         $author = null;
         if (is_callable(array('Symphony', 'Author'))) {
             $author = Symphony::Author();
         } else {
             $author = Frontend::instance()->Author;
         }
         $result->setAttributeArray(array('id' => $author->get('id'), 'user-type' => $author->get('user_type'), 'primary-account' => $author->get('primary')));
         $fields = array('name' => new XMLElement('name', $author->getFullName()), 'username' => new XMLElement('username', $author->get('username')), 'email' => new XMLElement('email', $author->get('email')));
         if ($author->isTokenActive()) {
             $fields['author-token'] = new XMLElement('author-token', $author->createAuthToken());
         }
         // Section
         if ($section = Symphony::Database()->fetchRow(0, "SELECT `id`, `handle`, `name` FROM `tbl_sections` WHERE `id` = '" . $author->get('default_area') . "' LIMIT 1")) {
             $default_area = new XMLElement('default-area', $section['name']);
             $default_area->setAttributeArray(array('id' => $section['id'], 'handle' => $section['handle'], 'type' => 'section'));
             $fields['default-area'] = $default_area;
         } else {
             $default_area = new XMLElement('default-area', $author->get('default_area'));
             $default_area->setAttribute('type', 'page');
             $fields['default-area'] = $default_area;
         }
         foreach ($fields as $f) {
             $result->appendChild($f);
         }
     } else {
         $result = new XMLElement('user');
         $result->setAttribute('logged-in', 'false');
     }
     // param output
     Frontend::Page()->_param['login'] = $loggedin ? 'yes' : 'no';
     Frontend::Page()->_param['login-filter'] = $loggedin ? 'yes,no' : 'yes';
     return $result;
 }
开发者ID:BloodBrother,项目名称:symphony-2-template,代码行数:48,代码来源:event.login.php

示例9: grab

 public function grab(&$param_pool)
 {
     $s = $_SESSION[__SYM_COOKIE_PREFIX_ . 'cart'];
     $xml = new XMLElement('shopping-cart');
     if (!is_array($s) || empty($s)) {
         $xml->appendChild(new XMLElement('empty'));
         return $xml;
     }
     $param_pool['ds-shopping-cart'] = implode(',', array_keys($s));
     $total = null;
     foreach ($s as $key => $value) {
         $item = new XMLElement('item', null, array('id' => $key, 'num' => $value['num'], 'sum' => $value['sum']));
         $xml->appendChild($item);
         $total = $total + $value['sum'];
     }
     $xml->setAttributeArray(array('items' => count($s), 'total' => $total));
     return $xml;
 }
开发者ID:TwistedInteractive,项目名称:shopping_cart,代码行数:18,代码来源:data.shopping_cart.php

示例10: appendFormattedElement

 public function appendFormattedElement(&$wrapper, $data, $encode = false)
 {
     if (!is_array($data) || empty($data)) {
         return;
     }
     if (!is_array($data['file'])) {
         if (!$data['file']) {
             return;
         }
         $data = array('file' => array($data['file']));
     }
     $item = new XMLElement($this->get('element_name'));
     $path = DOCROOT;
     $item->setAttributeArray(array('path' => str_replace(WORKSPACE, '', $path)));
     foreach ($data['file'] as $index => $file) {
         $item->appendChild(new XMLElement('item', General::sanitize($file), array('size' => General::formatFilesize(filesize($path . $file)))));
     }
     $wrapper->appendChild($item);
 }
开发者ID:symphonists,项目名称:uploadselectboxfield,代码行数:19,代码来源:field.uploadselectbox.php

示例11: execute

 public function execute(array &$param_pool = null)
 {
     $result = new XMLElement($this->dsParamROOTELEMENT);
     // When DS is called out of the Frontend context, this will enable
     // {$root} and {$workspace} parameters to be evaluated
     if (empty($this->_env)) {
         $this->_env['env']['pool'] = array('root' => URL, 'workspace' => WORKSPACE);
     }
     try {
         require_once TOOLKIT . '/class.gateway.php';
         require_once TOOLKIT . '/class.xsltprocess.php';
         require_once CORE . '/class.cacheable.php';
         $this->dsParamURL = $this->parseParamURL($this->dsParamURL);
         if (isset($this->dsParamXPATH)) {
             $this->dsParamXPATH = $this->__processParametersInString(stripslashes($this->dsParamXPATH), $this->_env);
         }
         // Builds a Default Stylesheet to transform the resulting XML with
         $stylesheet = new XMLElement('xsl:stylesheet');
         $stylesheet->setAttributeArray(array('version' => '1.0', 'xmlns:xsl' => 'http://www.w3.org/1999/XSL/Transform'));
         $output = new XMLElement('xsl:output');
         $output->setAttributeArray(array('method' => 'xml', 'version' => '1.0', 'encoding' => 'utf-8', 'indent' => 'yes', 'omit-xml-declaration' => 'yes'));
         $stylesheet->appendChild($output);
         $template = new XMLElement('xsl:template');
         $template->setAttribute('match', '/');
         $instruction = new XMLElement('xsl:copy-of');
         // Namespaces
         if (isset($this->dsParamNAMESPACES) && is_array($this->dsParamNAMESPACES)) {
             foreach ($this->dsParamNAMESPACES as $name => $uri) {
                 $instruction->setAttribute('xmlns' . ($name ? ":{$name}" : null), $uri);
             }
         }
         // XPath
         $instruction->setAttribute('select', $this->dsParamXPATH);
         $template->appendChild($instruction);
         $stylesheet->appendChild($template);
         $stylesheet->setIncludeHeader(true);
         $xsl = $stylesheet->generate(true);
         // Check for an existing Cache for this Datasource
         $cache_id = self::buildCacheID($this);
         $cache = Symphony::ExtensionManager()->getCacheProvider('remotedatasource');
         $cachedData = $cache->check($cache_id);
         $writeToCache = null;
         $isCacheValid = true;
         $creation = DateTimeObj::get('c');
         // Execute if the cache doesn't exist, or if it is old.
         if (!is_array($cachedData) || empty($cachedData) || time() - $cachedData['creation'] > $this->dsParamCACHE * 60) {
             if (Mutex::acquire($cache_id, $this->dsParamTIMEOUT, TMP)) {
                 $ch = new Gateway();
                 $ch->init($this->dsParamURL);
                 $ch->setopt('TIMEOUT', $this->dsParamTIMEOUT);
                 // Set the approtiate Accept: headers depending on the format of the URL.
                 if ($this->dsParamFORMAT == 'xml') {
                     $ch->setopt('HTTPHEADER', array('Accept: text/xml, */*'));
                 } elseif ($this->dsParamFORMAT == 'json') {
                     $ch->setopt('HTTPHEADER', array('Accept: application/json, */*'));
                 } elseif ($this->dsParamFORMAT == 'csv') {
                     $ch->setopt('HTTPHEADER', array('Accept: text/csv, */*'));
                 }
                 self::prepareGateway($ch);
                 $data = $ch->exec();
                 $info = $ch->getInfoLast();
                 Mutex::release($cache_id, TMP);
                 $data = trim($data);
                 $writeToCache = true;
                 // Handle any response that is not a 200, or the content type does not include XML, JSON, plain or text
                 if ((int) $info['http_code'] != 200 || !preg_match('/(xml|json|csv|plain|text)/i', $info['content_type'])) {
                     $writeToCache = false;
                     $result->setAttribute('valid', 'false');
                     // 28 is CURLE_OPERATION_TIMEOUTED
                     if ($info['curl_error'] == 28) {
                         $result->appendChild(new XMLElement('error', sprintf('Request timed out. %d second limit reached.', $timeout)));
                     } else {
                         $result->appendChild(new XMLElement('error', sprintf('Status code %d was returned. Content-type: %s', $info['http_code'], $info['content_type'])));
                     }
                     return $result;
                 } else {
                     if (strlen($data) > 0) {
                         // Handle where there is `$data`
                         // If it's JSON, convert it to XML
                         if ($this->dsParamFORMAT == 'json') {
                             try {
                                 require_once TOOLKIT . '/class.json.php';
                                 $data = JSON::convertToXML($data);
                             } catch (Exception $ex) {
                                 $writeToCache = false;
                                 $errors = array(array('message' => $ex->getMessage()));
                             }
                         } elseif ($this->dsParamFORMAT == 'csv') {
                             try {
                                 require_once EXTENSIONS . '/remote_datasource/lib/class.csv.php';
                                 $data = CSV::convertToXML($data);
                             } catch (Exception $ex) {
                                 $writeToCache = false;
                                 $errors = array(array('message' => $ex->getMessage()));
                             }
                         } elseif ($this->dsParamFORMAT == 'txt') {
                             $txtElement = new XMLElement('entry');
                             $txtElement->setValue(General::wrapInCDATA($data));
                             $data = $txtElement->generate();
                             $txtElement = null;
//.........这里部分代码省略.........
开发者ID:beaubbe,项目名称:remote_datasource,代码行数:101,代码来源:datasource.remote.php

示例12: XMLElement

<?php

require_once TOOLKIT . '/class.gateway.php';
require_once TOOLKIT . '/class.xsltprocess.php';
require_once CORE . '/class.cacheable.php';
if (isset($this->dsParamURL)) {
    $this->dsParamURL = $this->__processParametersInString($this->dsParamURL, $this->_env, true, true);
}
if (isset($this->dsParamXPATH)) {
    $this->dsParamXPATH = $this->__processParametersInString($this->dsParamXPATH, $this->_env);
}
$stylesheet = new XMLElement('xsl:stylesheet');
$stylesheet->setAttributeArray(array('version' => '1.0', 'xmlns:xsl' => 'http://www.w3.org/1999/XSL/Transform'));
$output = new XMLElement('xsl:output');
$output->setAttributeArray(array('method' => 'xml', 'version' => '1.0', 'encoding' => 'utf-8', 'indent' => 'yes', 'omit-xml-declaration' => 'yes'));
$stylesheet->appendChild($output);
$template = new XMLElement('xsl:template');
$template->setAttribute('match', '/');
$instruction = new XMLElement('xsl:copy-of');
## Namespaces
foreach ($this->dsParamFILTERS as $name => $uri) {
    $instruction->setAttribute('xmlns' . ($name ? ":{$name}" : NULL), $uri);
}
## XPath
$instruction->setAttribute('select', $this->dsParamXPATH);
$template->appendChild($instruction);
$stylesheet->appendChild($template);
$stylesheet->setIncludeHeader(true);
$xsl = $stylesheet->generate(true);
$proc =& new XsltProcess();
$cache_id = md5($this->dsParamURL . serialize($this->dsParamFILTERS) . $this->dsParamXPATH);
开发者ID:bauhouse,项目名称:sym-fluidgrids,代码行数:31,代码来源:datasource.dynamic_xml.php

示例13: wrapFormElementWithError

 function wrapFormElementWithError($element, $message)
 {
     $div = new XMLElement('div');
     $div->setAttributeArray(array('id' => 'error', 'class' => 'invalid'));
     $div->appendChild($element);
     $div->appendChild(new XMLElement('p', $message));
     return $div;
 }
开发者ID:bauhouse,项目名称:sym-fluidgrids,代码行数:8,代码来源:class.widget.php

示例14: __form


//.........这里部分代码省略.........
          * Allows adding of new filter rules to the Event filter rule select box
          *
          * @delegate AppendEventFilter
          * @param string $context
          * '/blueprints/events/(edit|new|info)/'
          * @param array $selected
          *  An array of all the selected filters for this Event
          * @param array $options
          *  An array of all the filters that are available, passed by reference
          */
         Symphony::ExtensionManager()->notifyMembers('AppendEventFilter', '/blueprints/events/' . $this->_context[0] . '/', array('selected' => $filters, 'options' => &$options));
         $fieldset->appendChild(Widget::Select('fields[filters][]', $options, array('multiple' => 'multiple', 'id' => 'event-filters')));
         $this->Form->appendChild($fieldset);
         // Connections
         $fieldset = new XMLElement('fieldset');
         $fieldset->setAttribute('class', 'settings');
         $fieldset->appendChild(new XMLElement('legend', __('Attach to Pages')));
         $p = new XMLElement('p', __('The event will only be available on the selected pages.'));
         $p->setAttribute('class', 'help');
         $fieldset->appendChild($p);
         $div = new XMLElement('div');
         $label = Widget::Label(__('Pages'));
         $pages = PageManager::fetch();
         $event_handle = str_replace('-', '_', Lang::createHandle($fields['name']));
         $connections = ResourceManager::getAttachedPages(RESOURCE_TYPE_EVENT, $event_handle);
         $selected = array();
         foreach ($connections as $connection) {
             $selected[] = $connection['id'];
         }
         $options = array();
         foreach ($pages as $page) {
             $options[] = array($page['id'], in_array($page['id'], $selected), PageManager::resolvePageTitle($page['id']));
         }
         $label->appendChild(Widget::Select('fields[connections][]', $options, array('multiple' => 'multiple')));
         $div->appendChild($label);
         $fieldset->appendChild($div);
         $this->Form->appendChild($fieldset);
         // Providers
         if (!empty($providers)) {
             foreach ($providers as $providerClass => $provider) {
                 if ($isEditing && $fields['source'] !== call_user_func(array($providerClass, 'getSource'))) {
                     continue;
                 }
                 call_user_func_array(array($providerClass, 'buildEditor'), array($this->Form, &$this->_errors, $fields, $handle));
             }
         }
     } else {
         // Author
         if (isset($about['author']['website'])) {
             $link = Widget::Anchor($about['author']['name'], General::validateURL($about['author']['website']));
         } elseif (isset($about['author']['email'])) {
             $link = Widget::Anchor($about['author']['name'], 'mailto:' . $about['author']['email']);
         } else {
             $link = $about['author']['name'];
         }
         if ($link) {
             $fieldset = new XMLElement('fieldset');
             $fieldset->setAttribute('class', 'settings');
             $fieldset->appendChild(new XMLElement('legend', __('Author')));
             $fieldset->appendChild(new XMLElement('p', $link->generate(false)));
             $this->Form->appendChild($fieldset);
         }
         // Version
         $fieldset = new XMLElement('fieldset');
         $fieldset->setAttribute('class', 'settings');
         $fieldset->appendChild(new XMLElement('legend', __('Version')));
         $version = array_key_exists('version', $about) ? $about['version'] : null;
         $release_date = array_key_exists('release-date', $about) ? $about['release-date'] : filemtime(EventManager::__getDriverPath($handle));
         if (preg_match('/^\\d+(\\.\\d+)*$/', $version)) {
             $fieldset->appendChild(new XMLElement('p', __('%1$s released on %2$s', array($version, DateTimeObj::format($release_date, __SYM_DATE_FORMAT__)))));
         } elseif (!is_null($version)) {
             $fieldset->appendChild(new XMLElement('p', __('Created by %1$s at %2$s', array($version, DateTimeObj::format($release_date, __SYM_DATE_FORMAT__)))));
         } else {
             $fieldset->appendChild(new XMLElement('p', __('Last modified on %s', array(DateTimeObj::format($release_date, __SYM_DATE_FORMAT__)))));
         }
         $this->Form->appendChild($fieldset);
     }
     // If we are editing an event, it assumed that the event has documentation
     $fieldset = new XMLElement('fieldset');
     $fieldset->setAttribute('id', 'event-documentation');
     $fieldset->setAttribute('class', 'settings');
     if ($isEditing && method_exists($existing, 'documentation')) {
         $doc = $existing->documentation();
         if ($doc) {
             $fieldset->setValue('<legend>' . __('Documentation') . '</legend>' . PHP_EOL . General::tabsToSpaces(is_object($doc) ? $doc->generate(true, 4) : $doc));
         }
     }
     $this->Form->appendChild($fieldset);
     $div = new XMLElement('div');
     $div->setAttribute('class', 'actions');
     $div->appendChild(Widget::Input('action[save]', $isEditing ? __('Save Changes') : __('Create Event'), 'submit', array('accesskey' => 's')));
     if ($isEditing) {
         $button = new XMLElement('button', __('Delete'));
         $button->setAttributeArray(array('name' => 'action[delete]', 'class' => 'button confirm delete', 'title' => __('Delete this event'), 'type' => 'submit', 'accesskey' => 'd', 'data-message' => __('Are you sure you want to delete this event?')));
         $div->appendChild($button);
     }
     if (!$readonly) {
         $this->Form->appendChild($div);
     }
 }
开发者ID:valery,项目名称:symphony-2,代码行数:101,代码来源:content.blueprintsevents.php

示例15: view

    function view()
    {
        $this->_existing_file = isset($this->_context[1]) ? $this->_context[1] . '.xsl' : NULL;
        ## Handle unknown context
        if (!in_array($this->_context[0], array('new', 'edit'))) {
            $this->_Parent->errorPageNotFound();
        }
        ## Edit Utility context
        if ($this->_context[0] == 'edit') {
            $file_abs = UTILITIES . '/' . $this->_existing_file;
            $filename = $this->_existing_file;
            if (!@is_file($file_abs)) {
                redirect(URL . '/symphony/blueprints/utilities/new/');
            }
            $fields['name'] = $filename;
            $fields['body'] = @file_get_contents($file_abs);
            $this->Form->setAttribute('action', URL . '/symphony/blueprints/utilities/edit/' . $this->_context[1] . '/');
        } else {
            $fields['body'] = '<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template name="">

</xsl:template>

</xsl:stylesheet>';
        }
        $formHasErrors = is_array($this->_errors) && !empty($this->_errors);
        if ($formHasErrors) {
            $this->pageAlert(__('An error occurred while processing this form. <a href="#error">See below for details.</a>'), Alert::ERROR);
        }
        if (isset($this->_context[2])) {
            switch ($this->_context[2]) {
                case 'saved':
                    $this->pageAlert(__('Utility updated at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all Utilities</a>', array(DateTimeObj::get(__SYM_TIME_FORMAT__), URL . '/symphony/blueprints/utilities/new/', URL . '/symphony/blueprints/components/')), Alert::SUCCESS);
                    break;
                case 'created':
                    $this->pageAlert(__('Utility created at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all Utilities</a>', array(DateTimeObj::get(__SYM_TIME_FORMAT__), URL . '/symphony/blueprints/utilities/new/', URL . '/symphony/blueprints/components/')), Alert::SUCCESS);
                    break;
            }
        }
        $this->setTitle(__($this->_context[0] == 'new' ? '%1$s &ndash; %2$s' : '%1$s &ndash; %2$s &ndash; %3$s', array(__('Symphony'), __('Utilities'), $filename)));
        $this->appendSubheading($this->_context[0] == 'new' ? __('Untitled') : $filename);
        if (!empty($_POST)) {
            $fields = $_POST['fields'];
        }
        $fields['body'] = General::sanitize($fields['body']);
        $fieldset = new XMLElement('fieldset');
        $fieldset->setAttribute('class', 'primary');
        $label = Widget::Label(__('Name'));
        $label->appendChild(Widget::Input('fields[name]', $fields['name']));
        $fieldset->appendChild(isset($this->_errors['name']) ? $this->wrapFormElementWithError($label, $this->_errors['name']) : $label);
        $label = Widget::Label(__('Body'));
        $label->appendChild(Widget::Textarea('fields[body]', 30, 80, $fields['body'], array('class' => 'code')));
        $fieldset->appendChild(isset($this->_errors['body']) ? $this->wrapFormElementWithError($label, $this->_errors['body']) : $label);
        $this->Form->appendChild($fieldset);
        $utilities = General::listStructure(UTILITIES, array('xsl'), false, 'asc', UTILITIES);
        $utilities = $utilities['filelist'];
        if (is_array($utilities) && !empty($utilities)) {
            $div = new XMLElement('div');
            $div->setAttribute('class', 'secondary');
            $h3 = new XMLElement('h3', __('Utilities'));
            $h3->setAttribute('class', 'label');
            $div->appendChild($h3);
            $ul = new XMLElement('ul');
            $ul->setAttribute('id', 'utilities');
            $i = 0;
            foreach ($utilities as $util) {
                $li = new XMLElement('li');
                if ($i++ % 2 != 1) {
                    $li->setAttribute('class', 'odd');
                }
                $li->appendChild(Widget::Anchor($util, URL . '/symphony/blueprints/utilities/edit/' . str_replace('.xsl', '', $util) . '/', NULL));
                $ul->appendChild($li);
            }
            $div->appendChild($ul);
            $this->Form->appendChild($div);
        }
        $div = new XMLElement('div');
        $div->setAttribute('class', 'actions');
        $div->appendChild(Widget::Input('action[save]', $this->_context[0] == 'edit' ? __('Save Changes') : __('Create Utility'), 'submit', array('accesskey' => 's')));
        if ($this->_context[0] == 'edit') {
            $button = new XMLElement('button', __('Delete'));
            $button->setAttributeArray(array('name' => 'action[delete]', 'class' => 'confirm delete', 'title' => __('Delete this utility')));
            $div->appendChild($button);
        }
        $this->Form->appendChild($div);
    }
开发者ID:bauhouse,项目名称:sym-fluidgrids,代码行数:89,代码来源:content.blueprintsutilities.php


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