本文整理汇总了PHP中XMLElement::generate方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLElement::generate方法的具体用法?PHP XMLElement::generate怎么用?PHP XMLElement::generate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLElement
的用法示例。
在下文中一共展示了XMLElement::generate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
/**
* The generate functions outputs the correct headers for
* this `XMLPage`, adds `$this->getHttpStatusCode()` code to the root attribute
* before calling the parent generate function and generating
* the `$this->_Result` XMLElement
*
* @param null $page
* @return string
*/
public function generate($page = null)
{
// Set the actual status code in the xml response
$this->_Result->setAttribute('status', $this->getHttpStatusCode());
parent::generate($page);
return $this->_Result->generate(true);
}
示例2: view
public function view()
{
header('Content-Type: text/xml');
$response = new XMLElement('response');
$id = $_GET['id'];
$version = Symphony::Configuration()->get('version', 'symphony');
// remove text followed by numbers e.g. 2.3beta2 or 2.3rc1
$version = preg_replace("/[a-z]+[0-9]+/i", '', $version);
// remove text e.g. 2.3beta
$version = preg_replace("/[a-z]+/i", '', $version);
$symphony_version = self::normaliseVersionNumber($version);
$response->setAttribute('symphony-version', $symphony_version);
if (empty($id)) {
$response->setAttribute('error', '404');
echo $response->generate();
die;
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, sprintf('http://symphonyextensions.com/api/extensions/%s/', $id));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, 'extension_status; Symphony ' . Symphony::Configuration()->get('version', 'symphony'));
curl_setopt($ch, CURLOPT_REFERER, URL);
$xml = curl_exec($ch);
if (!$xml) {
$response->setAttribute('error', '404');
echo $response->generate();
die;
}
$extension = simplexml_load_string($xml);
$compatibility = $extension->xpath("//compatibility/symphony[@version='" . $symphony_version . "']");
$extensions = ExtensionManager::fetch();
$current_version = $extensions[$id]['version'];
$response->setAttribute('current-local-version', $current_version);
if (count($compatibility) == 0) {
$response->setAttribute('compatible-version-exists', 'no');
} else {
$latest_version = $compatibility[0]->attributes()->use;
$github_url = $extension->xpath("//link[@rel='github:page']/@href");
$extension_url = $extension->xpath("//link[@rel='site:extension']/@href");
$response->setAttribute('compatible-version-exists', 'yes');
$response->setAttribute('latest-url', (string) $github_url[0] . '/tree/' . $latest_version);
$response->setAttribute('latest', $latest_version);
$response->setAttribute('can-update', version_compare($latest_version, $current_version, '>') ? 'yes' : 'no');
$response->setAttribute('extension-url', 'http://symphonyextensions.com' . (string) $extension_url[0]);
}
echo $response->generate();
die;
}
示例3: transform
public function transform($data)
{
$txtElement = new XMLElement('data');
$txtElement->setValue(General::wrapInCDATA($data));
$data = $txtElement->generate();
return $data;
}
示例4: getXPath
public function getXPath($entry)
{
$entry_xml = new XMLElement('entry');
$section_id = $entry->_fields['section_id'];
$data = $entry->getData();
$fields = array();
$entry_xml->setAttribute('id', $entry->get('id'));
$associated = $entry->fetchAllAssociatedEntryCounts();
if (is_array($associated) and !empty($associated)) {
foreach ($associated as $section => $count) {
$handle = $this->_Parent->Database->fetchVar('handle', 0, "\n\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\ts.handle\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t`tbl_sections` AS s\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\ts.id = '{$section}'\n\t\t\t\t\t\tLIMIT 1\n\t\t\t\t\t");
$entry_xml->setAttribute($handle, (string) $count);
}
}
// Add fields:
foreach ($data as $field_id => $values) {
if (empty($field_id)) {
continue;
}
$field =& $entry->_Parent->fieldManager->fetch($field_id);
$field->appendFormattedElement($entry_xml, $values, false);
}
$xml = new XMLElement('data');
$xml->appendChild($entry_xml);
$dom = new DOMDocument();
$dom->loadXML($xml->generate(true));
return new DOMXPath($dom);
}
示例5: getXPath
public function getXPath($entry)
{
$fieldManager = new FieldManager(Symphony::Engine());
$entry_xml = new XMLElement('entry');
$section_id = $entry->get('section_id');
$data = $entry->getData();
$fields = array();
$entry_xml->setAttribute('id', $entry->get('id'));
$associated = $entry->fetchAllAssociatedEntryCounts();
if (is_array($associated) and !empty($associated)) {
foreach ($associated as $section => $count) {
$handle = Symphony::Database()->fetchVar('handle', 0, "\n\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\ts.handle\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t`tbl_sections` AS s\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\ts.id = '{$section}'\n\t\t\t\t\t\tLIMIT 1\n\t\t\t\t\t");
$entry_xml->setAttribute($handle, (string) $count);
}
}
// Add fields:
foreach ($data as $field_id => $values) {
if (empty($field_id)) {
continue;
}
$field = $fieldManager->fetch($field_id);
$field->appendFormattedElement($entry_xml, $values, false, null);
}
$xml = new XMLElement('data');
$xml->appendChild($entry_xml);
$dom = new DOMDocument();
$dom->strictErrorChecking = false;
$dom->loadXML($xml->generate(true));
$xpath = new DOMXPath($dom);
if (version_compare(phpversion(), '5.3', '>=')) {
$xpath->registerPhpFunctions();
}
return $xpath;
}
示例6: notify
function notify($context)
{
var_dump($context);
include_once TOOLKIT . '/class.gateway.php';
$ch = new Gateway();
$ch->init();
$ch->setopt('URL', 'http://rpc.pingomatic.com/');
$ch->setopt('POST', 1);
$ch->setopt('CONTENTTYPE', 'text/xml');
$ch->setopt('HTTPVERSION', '1.0');
##Create the XML request
$xml = new XMLElement('methodCall');
$xml->appendChild(new XMLElement('methodName', 'weblogUpdates.ping'));
$params = new XMLElement('params');
$param = new XMLElement('param');
$param->appendChild(new XMLElement('value', $this->_Parent->Configuration->get('sitename', 'general')));
$params->appendChild($param);
$param = new XMLElement('param');
$param->appendChild(new XMLElement('value', URL));
$params->appendChild($param);
$xml->appendChild($params);
####
$ch->setopt('POSTFIELDS', $xml->generate(true, 0));
//Attempt the ping
$ch->exec(GATEWAY_FORCE_SOCKET);
}
示例7: documentation
public static function documentation()
{
// Fetch all the Email Templates available and add to the end of the documentation
$templates = extension_Members::fetchEmailTemplates();
$div = new XMLElement('div');
if (!empty($templates)) {
$label = new XMLElement('label', __('Regenerate Activation Code Email Template'));
$regenerate_activation_code_templates = extension_Members::setActiveTemplate($templates, 'regenerate-activation-code-template');
$label->appendChild(Widget::Select('members[regenerate-activation-code-template][]', $regenerate_activation_code_templates, array('multiple' => 'multiple')));
$div->appendChild($label);
$div->appendChild(Widget::Input('members[event]', 'reset-password', 'hidden'));
$div->appendChild(Widget::Input(null, __('Save Changes'), 'submit', array('accesskey' => 's')));
}
return '
<p>This event will regenerate an activation code for a user and is useful if their current
activation code has expired. The activation code can be sent to a Member\'s email after
this event has executed.</p>
<h3>Example Front-end Form Markup</h3>
<p>This is an example of the form markup you can use on your front end. An input field
accepts either the member\'s email address or username.</p>
<pre class="XML"><code>
<form method="post">
<label>Username: <input name="fields[username]" type="text" value="{$username}"/></label>
or
<label>Email: <input name="fields[email]" type="text" value="{$email}"/></label>
<input type="submit" name="action[' . self::ROOTELEMENT . ']" value="Regenerate Activation Code"/>
<input type="hidden" name="redirect" value="{$root}/"/>
</form>
</code></pre>
<h3>More Information</h3>
<p>For further information about this event, including response and error XML, please refer to the
<a href="https://github.com/symphonycms/members/wiki/Members%3A-Regenerate-Activation-Code">wiki</a>.</p>
' . $div->generate() . '
';
}
示例8: prepareTableValue
public function prepareTableValue($data, XMLElement $link = NULL)
{
$value = $data['value'];
if ($link) {
$link->setValue($value);
return $link->generate();
} else {
return $value;
}
}
示例9: documentation
public static function documentation()
{
// Fetch all the Email Templates available and add to the end of the documentation
$templates = extension_Members::fetchEmailTemplates();
$div = new XMLElement('div');
if (!empty($templates)) {
//Template
$label = new XMLElement('label', __('Reset Password Email Template'));
$reset_password_templates = extension_Members::setActiveTemplate($templates, 'reset-password-template');
$label->appendChild(Widget::Select('members[reset-password-template][]', $reset_password_templates, array('multiple' => 'multiple')));
$div->appendChild($label);
}
// Auto Login
$div->appendChild(Widget::Input("members[auto-login]", 'no', 'hidden'));
$label = new XMLElement('label');
$input = Widget::Input("members[auto-login]", 'yes', 'checkbox');
if (extension_Members::getSetting('reset-password-auto-login') == 'yes') {
$input->setAttribute('checked', 'checked');
}
$label->setValue(__('%s Automatically log the member in after changing their password', array($input->generate())));
$div->appendChild($label);
$div->appendChild(Widget::Input('members[event]', 'reset-password', 'hidden'));
$div->appendChild(Widget::Input('action[save]', __('Save Changes'), 'submit', array('accesskey' => 's')));
return '
<p>This event requires the user to enter their recovery code and then their new password. Should the recovery code
be correct and the new password validate, the member\'s password will be changed to their new password.</p><p>
A recovery code is available by including the
Member: Password field in a data source on the same page as this event, or by using
the event\'s result.</p>
<h3>Example Front-end Form Markup</h3>
<p>This is an example of the form markup you can use on your front end. An input field
accepts the member\'s recovery code, either the member\'s email address or username and two password
fields (one for password, one to confirm) will allow the member to change their password.</p>
<pre class="XML"><code>
<form method="post">
<label>Username: <input name="fields[username]" type="text" value="{$username}"/></label>
or
<label>Email: <input name="fields[email]" type="text" value="{$email}"/></label>
<label>Recovery Code: <input name="fields[password][recovery-code]" type="text" value="{$code}"/></label>
<label>Password: <input name="fields[password][password]" type="password" /></label>
<label>Confirm Password: <input name="fields[password][confirm]" type="password" /></label>
<input type="hidden" name="members-section-id" value="{$your-section-id}"/>
<input type="submit" name="action[' . self::ROOTELEMENT . ']" value="Recover Account"/>
<input type="hidden" name="redirect" value="{$root}/"/>
</form>
</code></pre>
<h3>More Information</h3>
<p>For further information about this event, including response and error XML, please refer to the
<a href="https://github.com/symphonycms/members/wiki/Members%3A-Reset-Password">wiki</a>.</p>
' . $div->generate() . '
';
}
示例10: grab
function grab($param = array())
{
extract($this->_env, EXTR_PREFIX_ALL, 'env');
include_once TOOLKIT . '/class.entrymanager.php';
$entryManager = new EntryManager($this->_parent);
$section_id = $entryManager->fetchSectionIDFromHandle($this->__resolveDefine("dsFilterPARENTSECTION"));
$schema = $entryManager->fetchEntryFieldSchema($section_id, NULL, $this->_dsFilterCUSTOMFIELD);
$schema = $schema[0];
##Check the cache
$hash_id = md5(get_class($this));
if ($param['caching'] && ($cache = $this->check_cache($hash_id))) {
return $cache;
exit;
}
##------------------------------
##Create the XML container
$xml = new XMLElement("categories-list");
$xml->setAttribute("section", "customfield");
##Populate the XML
if (empty($schema) || !is_array($schema)) {
$xml->addChild(new XMLElement("error", "No Records Found."));
return $xml;
} else {
$ops = preg_split('/,/', $schema['values'], -1, PREG_SPLIT_NO_EMPTY);
$ops = array_map("trim", $ops);
$xml->addChild(new XMLElement("name", $schema['name']));
$xml->setAttribute("handle", $schema['handle']);
$options = new XMLElement("options");
foreach ($ops as $o) {
if ($schema['type'] == 'multiselect') {
$table = 'tbl_entries2customfields_list';
} else {
$table = 'tbl_entries2customfields';
}
$count = $this->_db->fetchVar('count', 0, "SELECT count(id) AS `count` FROM `{$table}` WHERE `field_id` = '" . $schema['id'] . "' AND value_raw = '{$o}' ");
$xO = new XMLElement("option", $o);
$xO->setAttribute('entry-count', $count);
$xO->setAttribute('handle', Lang::createHandle($o, $this->_parent->getConfigVar('handle_length', 'admin')));
$options->addChild($xO);
}
$xml->addChild($options);
}
##------------------------------
##Write To Cache
if ($param['caching']) {
$result = $xml->generate($param['indent'], $param['indent-depth']);
$this->write_to_cache($hash_id, $result, $this->_cache_sections);
return $result;
}
return $xml;
}
示例11: preview
function preview()
{
$xml = new XMLElement("post-comment");
$xml->addChild(new XMLElement("notice", "Missing Author Name"));
$code = $xml->generate(true);
$xml = new XMLElement("post-comment");
$cookie = new XMLElement("cookie");
$cookie->addChild(new XMLElement("name", "fred"));
$cookie->addChild(new XMLElement("email", "fred@email.com"));
$cookie->addChild(new XMLElement("url", "http://www.fred.com"));
$xml->addChild($cookie);
$code .= CRLF . $xml->generate(true);
return $code;
}
示例12: view
function view()
{
$vimeo_videos = array();
$mode = 'view';
if (isset($_POST['update'])) {
$mode = 'update';
}
try {
$vimeo_fields = $this->Database()->query("SELECT field_id FROM tbl_fields_vimeo_video");
foreach ($vimeo_fields as $field) {
$videos = $this->Database()->query(sprintf("SELECT entry_id, clip_id, title, caption, plays, user_name, user_url, thumbnail_url FROM tbl_entries_data_%d", $field->field_id));
foreach ($videos as $video) {
if ($mode == 'update') {
VimeoHelper::updateClipInfo($video->clip_id, $field->field_id, $video->entry_id, $this->Database());
} else {
array_push($vimeo_videos, $video);
}
}
}
} catch (Exception $e) {
print_r($this->Database()->lastError());
die;
}
if ($mode == 'update') {
header('location: ' . URL . '/symphony/extension/vimeo_videos/videos/');
}
usort($vimeo_videos, array($this, 'comparePlays'));
$this->setPageType('table');
$this->addStylesheetToHead(URL . '/extensions/vimeo_videos/assets/vimeo_video.css', 'screen', 190);
$update = new XMLElement('span', '<input type="submit" value="Update video info" name="update" />');
$update->setAttribute('id', 'update');
$heading = new XMLElement('h2', $update->generate() . 'Vimeo Videos (ordered by most plays)');
$this->Form->appendChild($heading);
$aTableHead = array(array('', 'col'), array('Plays', 'col'), array('Description', 'col'), array('User', 'col'));
$aTableBody = array();
if (count($vimeo_videos) == 0) {
$aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None Found.'), 'inactive', NULL, count($aTableHead)))));
} else {
foreach ($vimeo_videos as $video) {
$thumbnail = Widget::TableData(Widget::Anchor('<img src="' . URL . '/image/2/75/75/5/1/' . str_replace('http://', '', $video->thumbnail_url) . '" alt="' . $video->title . '" width="75" height="75"/>', "http://vimeo.com/{$video->clip_id}/", 'View video'));
$description = Widget::TableData("<strong>" . $video->title . "</strong><br />" . $video->caption);
$user = Widget::TableData(Widget::Anchor($video->user_name, $video->user_url, 'View user profile'));
$plays = Widget::TableData($video->plays);
$aTableBody[] = Widget::TableRow(array($thumbnail, $plays, $description, $user));
}
}
$table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody));
$this->Form->appendChild($table);
}
示例13: documentation
public static function documentation()
{
// Fetch all the Email Templates available and add to the end of the documentation
$templates = extension_Members::fetchEmailTemplates();
$div = new XMLElement('div');
if (!empty($templates)) {
// Template
$label = new XMLElement('label', __('Activate Account Email Template'));
$activate_account_templates = extension_Members::setActiveTemplate($templates, 'activate-account-template');
$label->appendChild(Widget::Select('members[activate-account-template][]', $activate_account_templates, array('multiple' => 'multiple')));
$div->appendChild($label);
}
// Auto Login
$div->appendChild(Widget::Input("members[auto-login]", 'no', 'hidden'));
$label = new XMLElement('label');
$input = Widget::Input("members[auto-login]", 'yes', 'checkbox');
if (extension_Members::getSetting('activate-account-auto-login') == 'yes') {
$input->setAttribute('checked', 'checked');
}
$label->setValue(__('%s Automatically log the member in after activation', array($input->generate())));
$div->appendChild($label);
// Add Save Changes
$div->appendChild(Widget::Input('members[event]', 'activate-account', 'hidden'));
$div->appendChild(Widget::Input('action[save]', __('Save Changes'), 'submit', array('accesskey' => 's')));
return '
<p>This event takes an activation code and an identifier for the Member (either Email or Username) to activate their account.
An activation code is available by including the Members: Activation field in a data source on the same page as this event, or by using
the event\'s result.</p>
<h3>Example Front-end Form Markup</h3>
<p>This is an example of the form markup you can use on your front end. An input field
accepts the member\'s activation code and either the member\'s email address or username.</p>
<pre class="XML"><code>
<form method="post">
<label>Username: <input name="fields[username]" type="text" value="{$username}"/></label>
or
<label>Email: <input name="fields[email]" type="text" value="{$email}"/></label>
<label>Activation: <input name="fields[activation]" type="text" value="{$code}"/></label>
<input type="hidden" name="members-section-id" value="{$your-section-id}"/>
<input type="submit" name="action[' . self::ROOTELEMENT . ']" value="Activate Account"/>
<input type="hidden" name="redirect" value="{$root}/"/>
</form>
</code></pre>
<h3>More Information</h3>
<p>For further information about this event, including response and error XML, please refer to the
<a href="https://github.com/symphonycms/members/wiki/Members%3A-Activate-Account">wiki</a>.</p>
' . $div->generate() . '
';
}
示例14: generate
/**
* The generate functions outputs the correct headers for
* this AJAXPage, adds `$this->_status` code to the root attribute
* before calling the parent generate function and generating
* the `$this->_Result` XMLElement
*
* @return string
*/
public function generate()
{
switch ($this->_status) {
case self::STATUS_OK:
$status_message = '200 OK';
break;
case self::STATUS_BAD:
case self::STATUS_ERROR:
$status_message = '400 Bad Request';
break;
case self::STATUS_UNAUTHORISED:
$status_message = '401 Unauthorized';
break;
}
$this->addHeaderToPage('HTTP/1.0 ' . $status_message);
$this->_Result->setAttribute('status', $this->_status);
parent::generate();
return $this->_Result->generate(true);
}
示例15: notify
public function notify($context)
{
include_once TOOLKIT . '/class.gateway.php';
$ch = new Gateway();
$ch->init();
$ch->setopt('URL', 'http://rpc.pingomatic.com/');
$ch->setopt('POST', 1);
$ch->setopt('CONTENTTYPE', 'text/xml');
$xml = new XMLElement('methodCall');
$xml->appendChild(new XMLElement('methodName', 'weblogUpdates.ping'));
$params = new XMLElement('params');
$param = new XMLElement('param');
$param->appendChild(new XMLElement('value', Symphony::Configuration()->get('sitename', 'general')));
$params->appendChild($param);
$param = new XMLElement('param');
$param->appendChild(new XMLElement('value', URL));
$params->appendChild($param);
$xml->appendChild($params);
$ch->setopt('POSTFIELDS', $xml->generate(true, 0));
$ch->exec(GATEWAY_FORCE_SOCKET);
}