protected function __trigger() { $result = null; $actionName = $this->getActionName(); $requestMethod = $this->getRequestMethod(); $requestArray = $this->getRequestArray(); if ($_SERVER['REQUEST_METHOD'] == $requestMethod && isset($requestArray[$actionName])) { $result = new XMLElement($actionName); $r = new XMLElement('result'); $id = intval($_POST['id']); try { $this->validate(); $entry = $this->createEntryFromPost($id); $this->visitEntry($entry); $r->setAttribute('success', 'yes'); $r->setAttribute('id', $entry->get('id')); } catch (Exception $ex) { $xmlEx = new XMLElement('error'); $showMsg = $ex instanceof InsertSectionException || Symphony::Engine()->isLoggedIn(); $errorMessage = $showMsg ? $ex->getMessage() : __('A Fatal error occured'); $xmlEx->setValue($errorMessage); $result->appendChild($xmlEx); $r->setAttribute('success', 'no'); Symphony::Log()->pushExceptionToLog($ex, true); } $result->appendChild($r); } else { throw new FrontendPageNotFoundException(); } return $result; }
public function response() { $result = new XMLElement($this->_event_name); $post_values = new XMLElement('post-values'); $fields = $_POST['fields']; if (!empty($fields)) { General::array_to_xml($post_values, $fields, true); } if (!empty($this->_error_array)) { $result->appendChild($post_values); $result->setAttribute('result', 'error'); $result->appendChild(new XMLElement('message', __('Entry encountered errors when saving.'))); foreach ($this->_error_array as $field => $message) { $type = $fields[$field] == '' ? 'missing' : 'invalid'; $field = new XMLElement($field); $field->setAttribute('type', $type); $field->setAttribute('message', $message); $result->appendChild($field); } } else { $result->setAttribute('result', 'success'); $result->appendChild(new XMLElement('message', __('Entry created successfully.'))); } return $result; }
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); }
protected function __trigger() { $result = new XMLElement(self::ROOTELEMENT); $success = false; self::__init(); $db = ASDCLoader::instance(); $Members = $this->_Parent->ExtensionManager->create('members'); $Members->initialiseCookie(); if ($Members->isLoggedIn() !== true) { $result->appendChild(new XMLElement('error', 'Must be logged in.')); $result->setAttribute('status', 'error'); return $result; } $Members->initialiseMemberObject(); // Make sure we dont accidently use an expired code extension_Members::purgeCodes(); $em = new EntryManager($this->_Parent); $entry = end($em->fetch((int) $Members->Member->get('id'))); $email = $entry->getData(self::findFieldID('email-address', 'members')); $name = $entry->getData(self::findFieldID('name', 'members')); $success = $Members->emailNewMember(array('section' => $Members->memberSectionHandle(), 'entry' => $entry, 'fields' => array('username-and-password' => $entry->getData(self::findFieldID('username-and-password', 'members')), 'name' => $name['value'], 'email-address' => $email['value']))); if ($success == true && isset($_REQUEST['redirect'])) { redirect($_REQUEST['redirect']); } $result->setAttribute('status', $success === true ? 'success' : 'error'); return $result; }
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; }
function grab() { include_once EXTENSIONS . '/nested_cats/extension.driver.php'; $driver = $this->_Parent->ExtensionManager->create('nested_cats'); $xml = new XMLElement('nested-cats'); $data = $driver->getTree('lft', 0); $right = array($data[0]['rgt']); array_shift($data); if (!$data) { $error = new XMLElement('error', 'No data received.'); $xml->appendChild($error); return $xml; } foreach ($data as $d) { if (count($right) > 0) { while ($right[count($right) - 1] < $d['rgt']) { array_pop($right); } } $item = new XMLElement('item', $d['title']); $item->setAttribute('id', $d['id']); $item->setAttribute('parent-id', $d['parent']); $item->setAttribute('level', count($right)); $item->setAttribute('handle', $d['handle']); $xml->appendChild($item); $right[] = $d['rgt']; } return $xml; }
public function __buildPageXML($page, $page_types, $qf) { $lang_code = FLang::getLangCode(); $oPage = new XMLElement('page'); $oPage->setAttribute('handle', $page['handle']); $oPage->setAttribute('id', $page['id']); // keep current first $oPage->appendChild(new XMLElement('item', General::sanitize($page['plh_t-' . $lang_code]), array('lang' => $lang_code, 'handle' => $page['plh_h-' . $lang_code]))); // add others foreach (FLang::getLangs() as $lc) { if ($lang_code != $lc) { $oPage->appendChild(new XMLElement('item', General::sanitize($page['plh_t-' . $lc]), array('lang' => $lc, 'handle' => $page['plh_h-' . $lc]))); } } if (in_array($page['id'], array_keys($page_types))) { $xTypes = new XMLElement('types'); foreach ($page_types[$page['id']] as $type) { $xTypes->appendChild(new XMLElement('type', $type)); } $oPage->appendChild($xTypes); } if ($page['children'] != '0') { if ($children = PageManager::fetch(false, array($qf . 'id, handle, title'), array(sprintf('`parent` = %d', $page['id'])))) { foreach ($children as $c) { $oPage->appendChild($this->__buildPageXML($c, $page_types, $qf)); } } } return $oPage; }
/** * 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); }
function processRecordGroup(&$wrapper, $element, $group, $ds, &$Parent, &$entryManager, &$fieldPool, &$param_pool, $param_output_only = false) { $xGroup = new XMLElement($element, NULL, $group['attr']); $key = 'ds-' . $ds->dsParamROOTELEMENT; if (is_array($group['records']) && !empty($group['records'])) { foreach ($group['records'] as $entry) { $data = $entry->getData(); $fields = array(); $xEntry = new XMLElement('entry'); $xEntry->setAttribute('id', $entry->get('id')); $associated_entry_counts = $entry->fetchAllAssociatedEntryCounts(); if (is_array($associated_entry_counts) && !empty($associated_entry_counts)) { foreach ($associated_entry_counts as $section_id => $count) { $section_handle = $Parent->Database->fetchVar('handle', 0, "SELECT `handle` FROM `tbl_sections` WHERE `id` = '{$section_id}' LIMIT 1"); $xEntry->setAttribute($section_handle, '' . $count . ''); } } if (isset($ds->dsParamPARAMOUTPUT)) { if ($ds->dsParamPARAMOUTPUT == 'system:id') { $param_pool[$key][] = $entry->get('id'); } elseif ($ds->dsParamPARAMOUTPUT == 'system:date') { $param_pool[$key][] = DateTimeObj::get('c', strtotime($entry->creationDate)); } elseif ($ds->dsParamPARAMOUTPUT == 'system:author') { $param_pool[$key][] = $entry->get('author_id'); } } foreach ($data as $field_id => $values) { if (!isset($fieldPool[$field_id]) || !is_object($fieldPool[$field_id])) { $fieldPool[$field_id] =& $entryManager->fieldManager->fetch($field_id); } if (isset($ds->dsParamPARAMOUTPUT) && $ds->dsParamPARAMOUTPUT == $fieldPool[$field_id]->get('element_name')) { $param_pool[$key][] = $fieldPool[$field_id]->getParameterPoolValue($values); } if (!$param_output_only) { foreach ($ds->dsParamINCLUDEDELEMENTS as $handle) { list($handle, $mode) = preg_split('/\\s*:\\s*/', $handle, 2); if ($fieldPool[$field_id]->get('element_name') == $handle) { $fieldPool[$field_id]->appendFormattedElement($xEntry, $values, $ds->dsParamHTMLENCODE ? true : false, $mode); } } } } if (!$param_output_only) { $xGroup->appendChild($xEntry); } } } if (is_array($group['groups']) && !empty($group['groups'])) { foreach ($group['groups'] as $element => $group) { foreach ($group as $g) { processRecordGroup($xGroup, $element, $g, $ds, $Parent, $entryManager, $fieldPool, $param_pool, $param_output_only); } } } if (!$param_output_only) { $wrapper->appendChild($xGroup); } return; }
protected function __trigger() { $result = new XMLElement(self::ROOTELEMENT); $result->setAttribute('visits', $this->_driver->updateVisits()); $result->setAttribute('threshold', $this->_driver->getThreshold()); $result->appendChild(new XMLElement('message', $this->_driver->getMessage())); return $result; }
public static function formToken() { // <input type="hidden" name="xsrf" value=" . self::getToken() . " /> $obj = new XMLElement("input"); $obj->setAttribute("type", "hidden"); $obj->setAttribute("name", "xsrf"); $obj->setAttribute("value", self::getToken()); return $obj; }
public function asXML() { $p = new XMLElement('p', $this->message); $p->setAttribute('id', 'notice'); if ($this->type != self::NOTICE) { $p->setAttribute('class', $this->type); } return $p; }
public function appendOrderFieldId($context) { if ($this->active_field) { $span = new XMLElement("span", $this->active_field["id"]); $span->setAttribute("id", "order_number_field"); $span->setAttribute("class", $this->active_field["force_sort"]); $span->setAttribute("style", "display:none;"); $context["parent"]->Page->Form->appendChild($span); } }
function grab(&$param_pool) { $result = new XMLElement($this->dsParamROOTELEMENT); foreach ($this->_env["env"]["pool"][$this->ds_comments] as $email) { $gravatar = new XMLElement("gravatar"); $gravatar->setAttribute("email", $email); $gravatar->setAttribute("url", "http://www.gravatar.com/avatar/" . md5(strtolower($email)) . "?s=" . $size . $this->size . "&d=" . $this->_env["param"]["root"] . "/extensions/gravatar/assets/default.gif"); $result->appendChild($gravatar); } return $result; }
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; }
function grab(&$param_pool) { $xml = new XMLElement($this->dsParamROOTELEMENT); $discussion_id = (int) $this->dsParamFILTERS['discussion-id']; $comment_id = $this->_Parent->Database->fetchVar('entry_id', 0, "SELECT `entry_id` FROM `tbl_entries_data_18` WHERE `relation_id` = {$discussion_id} ORDER BY `entry_id` ASC LIMIT 1"); $xml->setAttribute('comment-id', $comment_id); $xml->setAttribute('discussion-id', $discussion_id); $body = $this->_Parent->Database->fetchVar('value', 0, "SELECT `value` FROM `tbl_entries_data_17` WHERE `entry_id` = {$comment_id} LIMIT 1"); if (is_null($body) || strlen(trim($body)) == 0) { return $this->emptyXMLSet(); } $xml->setValue(General::sanitize($body)); return $xml; }
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; }
function displayPublishPanel(&$wrapper, $data = NULL, $flagWithError = NULL, $fieldnamePrefix = NULL, $fieldnamePostfix = NULL) { $value = NULL; if (isset($data['value'])) { $value = is_array($data['value']) ? self::__tagArrayToString($data['value']) : $data['value']; } $label = Widget::Label($this->get('label')); $label->appendChild(Widget::Input('fields' . $fieldnamePrefix . '[' . $this->get('element_name') . ']' . $fieldnamePostfix, strlen($value) != 0 ? $value : NULL)); if ($flagWithError != NULL) { $wrapper->appendChild(Widget::wrapFormElementWithError($label, $flagWithError)); } else { $wrapper->appendChild($label); } if ($this->get('pre_populate_source') != NULL) { $existing_tags = $this->findAllTags(); if (is_array($existing_tags) && !empty($existing_tags)) { $taglist = new XMLElement('ul'); $taglist->setAttribute('class', 'tags'); foreach ($existing_tags as $tag) { $taglist->appendChild(new XMLElement('li', $tag)); } $wrapper->appendChild($taglist); } } }
function trigger() { $username = $_POST['username']; $password = md5($_POST['password']); if (isset($_COOKIE[__SYM_COOKIE__]) && !isset($_POST['action']['login'])) { $args = unserialize(base64_decode($_COOKIE[__SYM_COOKIE_SAFE__])); $username = $args['username']; $password = $args['password']; } $sql = "SELECT *\n\t\t\t\t\tFROM `tbl_authors`\n\t\t\t\t\tWHERE `username` = '" . addslashes($username) . "'\n\t\t\t\t\tAND `password` = '" . $password . "'"; $row = $this->_db->fetchRow(0, $sql); if (!empty($row) && is_array($row)) { $sql = "UPDATE `tbl_authors` SET `lastvisit` = UNIX_TIMESTAMP() WHERE `id` = '" . $row['id'] . "'"; $this->_db->query($sql); setcookie(__SYM_COOKIE__, serialize($row), time() + 31536000, $this->_parent->getCookieDomain()); setcookie(__SYM_COOKIE_SAFE__, base64_encode(serialize($row)), time() + 31536000, $this->_parent->getCookieDomain()); $status = 'Author'; if ($row['owner'] == 1) { $status = 'Owner'; } elseif ($row['superuser'] == 1) { $status = 'Administrator'; } $result = new XMLElement("user"); $result->setAttribute("logged-in", "true"); $result->addChild(new XMLElement("username", $row['username'])); $result->addChild(new XMLElement("first-name", $row['firstname'])); $result->addChild(new XMLElement("last-name", $row['lastname'])); $result->addChild(new XMLElement("email", $row['email'])); $result->addChild(new XMLElement("account-type", $status)); } else { $result = new XMLElement("user"); $result->setAttribute("logged-in", "false"); } return $result; }
public function view() { $this->setPageType('table'); $this->appendSubheading(__('Templated Text Formatters'), Widget::Anchor(__('Create New'), URL . '/symphony/extension/templatedtextformatters/edit/', __('Create a new hub'), 'create button')); $aTableHead = array(array(__('Title'), 'col'), array(__('Type'), 'col'), array(__('Description'), 'col')); $aTableBody = array(); $formatters = $this->_driver->listAll(); if (!is_array($formatters) || empty($formatters)) { $aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None found.'), 'inactive', NULL, count($aTableHead))))); } else { $tfm = new TextformatterManager($this->_Parent); foreach ($formatters as $id => $data) { $formatter = $tfm->create($id); $about = $formatter->about(); $td1 = Widget::TableData(Widget::Anchor($about['name'], URL . "/symphony/extension/templatedtextformatters/edit/{$id}/", $about['name'])); $td2 = Widget::TableData($about['templatedtextformatters-type']); $td3 = Widget::TableData($about['description']); $td1->appendChild(Widget::Input('items[' . $id . ']', NULL, 'checkbox')); // Add a row to the body array, assigning each cell to the row $aTableBody[] = Widget::TableRow(array($td1, $td2, $td3)); } } $table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody)); $this->Form->appendChild($table); $div = new XMLElement('div'); $div->setAttribute('class', 'actions'); $options = array(array(NULL, false, __('With Selected...')), array('delete', false, __('Delete'))); $div->appendChild(Widget::Select('with-selected', $options)); $div->appendChild(Widget::Input('action[apply]', __('Apply'), 'submit')); $this->Form->appendChild($div); }
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); } } }
public function append_preferences($context) { # Add new fieldset $group = new XMLElement('fieldset'); $group->setAttribute('class', 'settings'); $group->appendChild(new XMLElement('legend', 'PayPal Payments')); # Add Merchant Email field $label = Widget::Label('Merchant Email/Account ID'); $label->appendChild(Widget::Input('settings[paypal-payments][business]', General::Sanitize($this->_get_paypal_business()))); $group->appendChild($label); $group->appendChild(new XMLElement('p', 'The merchant email address or account ID of the payment recipient.', array('class' => 'help'))); # Country <select> $countries = array('Australia', 'United Kingdom', 'United States'); $selected_country = $this->_get_country(); foreach ($countries as $country) { $selected = $country == $selected_country ? TRUE : FALSE; $options[] = array($country, $selected); } $label = Widget::Label(); $select = Widget::Select('settings[paypal-payments][country]', $options); $label->setValue('PayPal Country' . $select->generate()); $group->appendChild($label); $group->appendChild(new XMLElement('p', 'Country you want to target.', array('class' => 'help'))); # Sandbox $label = Widget::Label(); $input = Widget::Input('settings[paypal-payments][sandbox]', 'yes', 'checkbox'); if ($this->_Parent->Configuration->get('sandbox', 'paypal-payments') == 'yes') { $input->setAttribute('checked', 'checked'); } $label->setValue($input->generate() . ' Enable testing mode'); $group->appendChild($label); $group->appendChild(new XMLElement('p', 'Directs payments to PayPal’s Sandbox: <code>http://www.sandbox.paypal.com/</code>', array('class' => 'help'))); $context['wrapper']->appendChild($group); }
/** * Append maintenance mode preferences * * @param array $context * delegate context */ public function appendPreferences($context) { // Create preference group $group = new XMLElement('fieldset'); $group->setAttribute('class', 'settings'); $group->appendChild(new XMLElement('legend', __('Maintenance Mode'))); // Append settings $label = Widget::Label(); $input = Widget::Input('settings[maintenance_mode][enabled]', 'yes', 'checkbox'); if (Symphony::Configuration()->get('enabled', 'maintenance_mode') === 'yes') { $input->setAttribute('checked', 'checked'); } $label->setValue($input->generate() . ' ' . __('Enable maintenance mode')); $group->appendChild($label); // Append help $group->appendChild(new XMLElement('p', __('Maintenance mode will redirect all visitors, other than developers, to the specified maintenance page. To specify a maintenance page, give a page a type of <code>maintenance</code>'), array('class' => 'help'))); // IP White list $label = Widget::Label(__('IP Whitelist')); $label->appendChild(Widget::Input('settings[maintenance_mode][ip_whitelist]', Symphony::Configuration()->get('ip_whitelist', 'maintenance_mode'))); $group->appendChild($label); // Append help $group->appendChild(new XMLElement('p', __('Any user that has an IP listed above will be granted access. This eliminates the need to allow a user backend access. Separate each with a space.'), array('class' => 'help'))); // Useragent White list $label = Widget::Label(__('Useragent Whitelist')); $whitelist = json_decode(Symphony::Configuration()->get('useragent_whitelist', 'maintenance_mode')); if (is_array($whitelist) && !empty($whitelist)) { $useragent = implode("\r\n", $whitelist); } $label->appendChild(Widget::Textarea('settings[maintenance_mode][useragent_whitelist]', 5, 50, $useragent)); $group->appendChild($label); // Append help $group->appendChild(new XMLElement('p', __('Any useragent that listed above will be granted access. This eliminates the need to allow a user backend access, useful when third party services need to access your site prior to launch. Insert in json array format eg ["useragent1","useragent2"].'), array('class' => 'help'))); // Append new preference group $context['wrapper']->appendChild($group); }
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; }
public static function get() { $response = new XMLElement('response'); foreach (self::$_sections as $section) { $section_xml = new XMLElement('section'); $meta = $section->get(); foreach ($meta as $key => $value) { $section_xml->setAttribute(Lang::createHandle($key), $value); } $fields = $section->fetchFields(); foreach ($fields as $field) { $meta = $field->get(); unset($meta['field_id']); $field_xml = new XMLElement($meta['element_name'], null); foreach (self::$_field_attributes as $attr) { $field_xml->setAttribute(Lang::createHandle($attr), $meta[$attr]); } foreach ($meta as $key => $value) { if (in_array($key, self::$_field_attributes)) { continue; } $value = General::sanitize($value); if ($value != '') { $field_xml->appendChild(new XMLElement(Lang::createHandle($key), General::sanitize($value))); } } $section_xml->appendChild($field_xml); } $response->appendChild($section_xml); } REST_API::sendOutput($response); }
public function view() { $this->appendSubheading(__('Preferences')); $bIsWritable = true; $formHasErrors = is_array($this->_errors) && !empty($this->_errors); if (!is_writable(CONFIG)) { $this->pageAlert(__('The Symphony configuration file, <code>/manifest/config.php</code>, is not writable. You will not be able to save changes to preferences.'), Alert::ERROR); $bIsWritable = false; } else { if ($formHasErrors) { $this->pageAlert(__('An error occurred while processing this form. <a href="#error">See below for details.</a>'), Alert::ERROR); } else { if (isset($this->_context[0]) && $this->_context[0] == 'success') { $this->pageAlert(__('Preferences saved.'), Alert::SUCCESS); } } } ### # Delegate: AddCustomPreferenceFieldsets # Description: Add Extension custom preferences. Use the $wrapper reference to append objects. $this->_Parent->ExtensionManager->notifyMembers('AddCustomPreferenceFieldsets', '/system/preferences/', array('wrapper' => &$this->Form)); $div = new XMLElement('div'); $div->setAttribute('class', 'actions'); $attr = array('accesskey' => 's'); if (!$bIsWritable) { $attr['disabled'] = 'disabled'; } $div->appendChild(Widget::Input('action[save]', __('Save Changes'), 'submit', $attr)); $this->Form->appendChild($div); }
public function __viewIndex() { $this->_driver = $this->_Parent->ExtensionManager->create('section_schemas'); $this->setPageType('form'); $this->setTitle('Symphony – Section Schema data sources'); $this->appendSubheading('Section Schema data sources'); $container = new XMLElement('fieldset'); $container->setAttribute('class', 'settings'); $container->appendChild(new XMLElement('legend', 'Sections')); $group = new XMLElement('div'); $group->setAttribute('class', 'group'); $sm = new SectionManager($this->_Parent); $sections = $sm->fetch(); $options = array(); $dsm = new DatasourceManager($this->_Parent); $datasources = $dsm->listAll(); foreach ($sections as $section) { $selected = in_array('section_schema_' . str_replace('-', '_', $section->_data['handle']), array_keys($datasources)); $options[] = array($section->_data['handle'], $selected, $section->_data['name']); } $section = Widget::Label('Create data sources for these sections:'); $section->appendChild(Widget::Select('sections[]', $options, array('multiple' => 'multiple'))); $group->appendChild($section); $container->appendChild($group); $this->Form->appendChild($container); //--------------------------------------------------------------------- $div = new XMLElement('div'); $div->setAttribute('class', 'actions'); $attr = array('accesskey' => 's'); $div->appendChild(Widget::Input('action[save]', 'Save Changes', 'submit', $attr)); $this->Form->appendChild($div); }
public function getEntryLink(Entry $entry) { $section = $this->getSection($entry->get('section_id')); $link = new XMLElement('a'); $link->setAttribute('href', sprintf('%s/symphony/publish/%s/edit/%d/', URL, $section->get('handle'), $entry->get('id'))); return $link; }
function grab($param = array()) { $xml = new XMLElement('translations'); $tm = new TranslationManager($this->_Parent); foreach ($tm->listAll() as $lang => $extensions) { $temp = $tm->get($lang, $extensions[0]); $item = new XMLElement('language'); $item->setAttribute('handle', $lang); $item->setAttribute('name', $temp['about']['name']); foreach ($extensions as $extension) { $item->appendChild(new XMLElement('extension', NULL, array('handle' => $extension))); } $xml->appendChild($item); } return $xml; }
private function __indexPage() { // Create the XML for the page: $xml = new XMLElement('data'); $sectionsNode = new XMLElement('sections'); $sm = new SectionManager($this); $sections = $sm->fetch(); foreach ($sections as $section) { $sectionsNode->appendChild(new XMLElement('section', $section->get('name'), array('id' => $section->get('id')))); } $xml->appendChild($sectionsNode); // Check if the multilingual-field extension is installed: if (in_array('multilingual_field', ExtensionManager::listInstalledHandles())) { $xml->setAttribute('multilanguage', 'yes'); // Get all the multilanguage fields: $fm = new FieldManager($this); $fields = $fm->fetch(null, null, 'ASC', 'sortorder', 'multilingual'); $multilanguage = new XMLElement('multilanguage'); foreach ($fields as $field) { $sectionID = $field->get('parent_section'); $section = $sm->fetch($sectionID); $id = $field->get('id'); $label = $section->get('name') . ' : ' . $field->get('label'); $multilanguage->appendChild(new XMLElement('field', $label, array('id' => $id))); } $xml->appendChild($multilanguage); } // Generate the HTML: $xslt = new XSLTPage(); $xslt->setXML($xml->generate()); $xslt->setXSL(EXTENSIONS . '/importcsv/content/index.xsl', true); $this->Form->setValue($xslt->generate()); $this->Form->setAttribute('enctype', 'multipart/form-data'); }