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);
 }
Esempio n. 2
0
 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);
 }
Esempio n. 3
0
 /**
  * Add site preferences
  */
 public function __addPreferences($context)
 {
     // Get selected languages
     $selection = Symphony::Configuration()->get('datetime');
     if (empty($selection)) {
         $selection = array();
     }
     // Build default options
     $options = array();
     foreach ($this->languages as $name => $codes) {
         $options[$name] = array($name . '::' . $codes, array_key_exists($name, $selection) ? true : false, __(ucfirst($name)));
     }
     // Add custom options
     foreach (array_diff_key($selection, $this->languages) as $name => $codes) {
         $options[$name] = array($name . '::' . $codes, true, __(ucfirst($name)));
     }
     // Sort options
     ksort($options);
     // Add fieldset
     $group = new XMLElement('fieldset', '<legend>' . __('Date and Time') . '</legend>', array('class' => 'settings'));
     $select = Widget::Select('settings[datetime][]', $options, array('multiple' => 'multiple'));
     $label = Widget::Label('Languages included in the Date and Time Data Source', $select);
     $group->appendChild($label);
     $help = new XMLElement('p', __('You can add more languages in you configuration file.'), array('class' => 'help'));
     $group->appendChild($help);
     $context['wrapper']->appendChild($group);
 }
Esempio n. 4
0
 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;
 }
Esempio n. 5
0
 /**
  * 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);
 }
 private function __buildFormContent()
 {
     $fieldset = new XMLElement('fieldset');
     // email was not send
     // or first time here (email_sent == NULL)
     if ($this->_email_sent !== true) {
         $fieldset->appendChild(new XMLElement('p', __('Enter your email address to be sent a remote unban link with further instructions.')));
         $label = Widget::Label(__('Email Address'));
         $label->appendChild(Widget::Input('email', $_POST['email'], 'text', array('autofocus', 'autofocus')));
     }
     if (isset($this->_email_sent)) {
         if ($this->_email_sent) {
             $div = new XMLElement('div', __('Email sent. Follow the instruction in it.'));
             $fieldset->appendChild($div);
         } else {
             $div = new XMLElement('div', NULL, array('class' => 'invalid'));
             $div->appendChild($label);
             $div->appendChild(new XMLElement('p', __('There was a problem locating your account. Please check that you are using the correct email address.')));
             $fieldset->appendChild($div);
         }
     } else {
         $fieldset->appendChild($label);
     }
     $this->Form->appendChild($fieldset);
     if ($this->_email_sent !== true) {
         $div = new XMLElement('div', NULL, array('class' => 'actions'));
         $div->appendChild(new XMLElement('button', __('Send Email'), array('name' => 'action[send-email]', 'type' => 'submit')));
         $this->Form->appendChild($div);
     }
 }
 public static function lookup($ip)
 {
     $ch = curl_init();
     // Notice: the request back to the service API includes your domain name
     // and the version of Symphony that you're using
     $version = Symphony::Configuration()->get('version', 'symphony');
     $domain = $_SERVER[SERVER_NAME];
     curl_setopt($ch, CURLOPT_URL, "http://api.josephdenne.com/_geoloc/array/?symphony=" . $version . "&domain=" . $domain . "&ip=" . $ip);
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     $geoinfo = curl_exec($ch);
     $info = curl_getinfo($ch);
     curl_close($ch);
     if ($geoinfo === false || $info['http_code'] != 200) {
         return;
     } else {
         $geoinfo = explode(',', $geoinfo);
     }
     $result = new XMLElement("geolocation");
     $included = array('id', 'lookups', 'country', 'region', 'city', 'lat', 'lon', 'error');
     $i = 0;
     foreach ($included as $geoloc) {
         $result->appendChild(new XMLElement($geoloc, $geoinfo[$i]));
         $i++;
     }
     return $result;
 }
 public function displayPublishPanel(&$wrapper, $data = null, $error = null, $prefix = null, $postfix = null, $entry_id = null)
 {
     $sortorder = $this->get('sortorder');
     $element_name = $this->get('element_name');
     $classes = array();
     $label = Widget::Label($this->get('label'));
     $message = new XMLElement('span');
     switch ($data['handle']) {
         case 'none':
         case 'completed':
             return;
             break;
         case 'failed':
             $value = __('Video failed to upload.');
             break;
         case 'queued':
             $value = __('Video is waiting in queue.');
             break;
         case 'encoding':
             $value = __('Video is being encoded.');
             break;
         case 'uploading':
             $value = __('Video is being uploaded.');
             break;
     }
     if (isset($value)) {
         $message->setValue($value);
         $label->appendChild($message);
         $wrapper->appendChild($label);
     }
 }
Esempio n. 9
0
 public function view()
 {
     $this->setTitle(__('Symphony &ndash; Indecent Filter'));
     $this->setPageType('form');
     $this->Form->setAttribute('enctype', 'multipart/form-data');
     $this->appendSubheading(__('Indecent Filter'));
     $words = extension_indecent::processFilterList(true);
     // Word List
     $container = new XMLElement('fieldset');
     $container->setAttribute('class', 'settings');
     $container->appendChild(new XMLElement('legend', __('Word Blacklist')));
     $p = new XMLElement('p', __('Enter each of the terms on a new line.'), array('class' => 'help'));
     $container->appendChild($p);
     // Add last saved timestamp
     if (!empty($words)) {
         $p->setValue($p->getValue() . '<br / >' . __('Last updated: %s', array(extension_indecent::lastUpdateFilterList())));
     }
     $container->appendChild(Widget::Textarea('fields[words]', 30, 30, $words));
     $this->Form->appendChild($container);
     // Actions
     $div = new XMLElement('div');
     $div->setAttribute('class', 'actions');
     $div->appendChild(Widget::Input('action[save]', 'Save', 'submit', array('accesskey' => 's')));
     $this->Form->appendChild($div);
 }
 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('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('result', $success === true ? 'success' : 'error');
     return $result;
 }
 public function ttf_form(&$form, &$page)
 {
     $p = new XMLElement('p', __('Wrap patterns with slashes, e.g., "/pattern_here/". You can use backreferences in replacement. Syntax for pattern and replacement is exactly the same as in <a href="http://www.php.net/manual/en/function.preg-replace.php" target="_blank">preg_replace()</a> PHP function.'));
     $p->setAttribute('class', 'help');
     $form->appendChild($p);
     $subsection = new XMLElement('div');
     $subsection->setAttribute('class', 'frame templatedtextformatter-duplicator');
     $ol = new XMLElement('ol');
     $ol->setAttribute('data-add', __('Add regex'));
     $ol->setAttribute('data-remove', __('Remove regex'));
     $temp = $this->_patterns;
     $temp[''] = '';
     foreach ($temp as $pattern => $replacement) {
         $li = new XMLElement('li');
         $li->setAttribute('class', $pattern ? 'field-regex' : 'template field-regex');
         $li->setAttribute('data-type', 'regex');
         $header = new XMLElement('header');
         $header->appendChild(new XMLElement('h4', '<strong>' . __('Replace') . '</strong> <span class="type">' . __('regex') . '</span>'));
         $li->appendChild($header);
         $div = new XMLElement('div');
         $div->setAttribute('class', 'two columns');
         $label = Widget::Label(__('Find with pattern'));
         $label->setAttribute('class', 'column');
         $label->appendChild(Widget::Input('fields[patterns][]', htmlentities($pattern, ENT_QUOTES, 'UTF-8')));
         $div->appendChild($label);
         $label = Widget::Label(__('Replace with'));
         $label->setAttribute('class', 'column');
         $label->appendChild(Widget::Input('fields[replacements][]', htmlentities($replacement, ENT_QUOTES, 'UTF-8')));
         $div->appendChild($label);
         $li->appendChild($div);
         $ol->appendChild($li);
     }
     $subsection->appendChild($ol);
     $form->appendChild($subsection);
 }
 public function execute(array &$param_pool = null)
 {
     $result = new XMLElement('se-permissions');
     $result->appendChild($this->buildActions());
     $result->appendChild($this->buildLevels());
     return $result;
 }
 protected function decode(XMLElement &$result, array $json)
 {
     $result = new XMLElement($this->dsParamROOTELEMENT);
     $result->appendChild(new XMLElement('name', $json['name']));
     $result->appendChild(new XMLElement('version', $json['version']));
     return $result;
 }
Esempio n. 14
0
 /**
  * Instantiates Services_Gnip_Publisher with current class data values
  *
  * @access    public
  * @param     XMLElement               $xml      XML Publisher
  * @return    Services_Gnip_Publisher            Services_Gnip_Publisher object
  */
 function fromXML($xml)
 {
     if ($xml->getName() != "publisher") {
         throw new Exception("expected publisher");
     }
     return new Services_Gnip_Publisher($xml["name"]);
 }
Esempio n. 15
0
 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);
 }
 public function grab(&$param_pool)
 {
     self::__init();
     $result = new XMLElement($this->dsParamROOTELEMENT);
     $rows = Symphony::Database()->fetch("SELECT *\n\t\t\t\tFROM `tbl_sessions` \n\t\t\t\tWHERE `session_data` != 'sym-|a:0:{}sym-members|a:0:{}' \n\t\t\t\tAND `session_data` REGEXP 'sym-members'\n\t\t\t\tAND `session_expires` > (UNIX_TIMESTAMP() - " . self::AGE . ") \n\t\t\t\tORDER BY `session_expires` DESC");
     $added = array();
     if (count($rows) > 0) {
         foreach ($rows as $r) {
             $raw = $r['session_data'];
             $data = self::session_real_decode($raw);
             if (!isset($data['sym-members'])) {
                 continue;
             }
             $record = ASDCLoader::instance()->query(sprintf("SELECT\n\t\t\t\t\t\t\t\temail.value AS `email`,\n\t\t\t\t\t\t\t\tMD5(email.value) AS `hash`,\n\t\t\t\t\t\t\t\tcreated_by.username AS `username`\n\t\t\t\t\t\t\n\t\t\t\t\t\t\tFROM `tbl_entries_data_%d` AS `created_by`\n\t\t\t\t\t\t\tLEFT JOIN `tbl_entries_data_%d` AS `email` ON created_by.member_id = email.entry_id\n\t\t\t\t\t\t\tWHERE `created_by`.username = '******'\n\t\t\t\t\t\t\tLIMIT 1", self::findFieldID('created-by', 'comments'), self::findFieldID('email-address', 'members'), ASDCLoader::instance()->escape($data['sym-members']['username'])));
             if ($record->length() == 0) {
                 continue;
             }
             $member = $record->current();
             // This is so we dont end up with accidental duplicates. No way to select
             // distinct via the SQL since we grab raw session data
             if (in_array($member->username, $added)) {
                 continue;
             }
             $added[] = $member->username;
             $result->appendChild(new XMLElement('member', General::sanitize($member->username), array('email-hash' => $member->hash)));
         }
     } else {
         $result->setValue('No Records Found.');
         //This should never happen!
     }
     return $result;
 }
 public function displayPublishPanel(XMLElement &$wrapper, $data = null, $flagWithError = null, $fieldnamePrefix = null, $fieldnamePostfix = null, $entry_id = null)
 {
     // Check 'mode' exists; otherwise set manually from 'editable'
     $mode = $this->get('mode');
     if (!$mode) {
         if ($this->get('editable') == 'yes') {
             $mode = 'normal';
         } else {
             $mode = 'hidden';
         }
     }
     // Render the field only if it's not hidden
     if ($mode != 'hidden') {
         $name = $this->get('element_name');
         $edited_local = DateTimeObj::get(__SYM_DATETIME_FORMAT__, $data['local']);
         $current_local = DateTimeObj::get(__SYM_DATETIME_FORMAT__, null);
         $label = Widget::Label($this->get('label'));
         if ($mode == 'disabled') {
             $input = Widget::Input("{$name}-display", $edited_local);
             $input->setAttribute('disabled', 'disabled');
         } else {
             $note = new XMLElement('i', __('Previous value: %s', array($edited_local)));
             $label->appendChild($note);
             $input = Widget::Input("fields{$fieldnamePrefix}[{$name}]", $current_local);
         }
         $label->appendChild($input);
         $label->setAttribute('class', 'date');
         if (!is_null($flagWithError)) {
             $label = Widget::Error($label, $error);
         }
         $wrapper->appendChild($label);
     }
 }
 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 AddElementToFooter($context)
 {
     $ul =& $context['wrapper'];
     $li = new XMLElement('li');
     $li->setValue("<a href=\"http://symphony-cms.com/\">Symphony CMS Version <strong>" . Administration::instance()->Configuration->get('version', 'symphony') . "</strong></a>");
     $ul->prependChild($li);
 }
 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);
 }
Esempio n. 21
0
 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);
 }
Esempio n. 22
0
 public function transform($data)
 {
     $txtElement = new XMLElement('data');
     $txtElement->setValue(General::wrapInCDATA($data));
     $data = $txtElement->generate();
     return $data;
 }
Esempio n. 23
0
 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);
         }
     }
 }
 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;
 }
 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;
 }
Esempio n. 26
0
 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;
 }
Esempio n. 27
0
 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);
 }
Esempio n. 28
0
 /**
  * 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);
 }
 public function execute(&$param_pool)
 {
     $result = new XMLElement($this->dsParamROOTELEMENT);
     $type_sql = $parent_sql = null;
     if (trim($this->dsParamFILTERS['type']) != '') {
         $type_sql = $this->__processNavigationTypeFilter($this->dsParamFILTERS['type'], $this->__determineFilterType($this->dsParamFILTERS['type']));
     }
     if (trim($this->dsParamFILTERS['parent']) != '') {
         $parent_sql = $this->__processNavigationParentFilter($this->dsParamFILTERS['parent']);
     }
     // Build the Query appending the Parent and/or Type WHERE clauses
     $pages = Symphony::Database()->fetch(sprintf("\n\t\t\t\t\tSELECT DISTINCT p.id, p.title, p.handle, (SELECT COUNT(id) FROM `tbl_pages` WHERE parent = p.id) AS children\n\t\t\t\t\tFROM `tbl_pages` AS p\n\t\t\t\t\tLEFT JOIN `tbl_pages_types` AS pt ON (p.id = pt.page_id)\n\t\t\t\t\tWHERE 1 = 1\n\t\t\t\t\t%s\n\t\t\t\t\t%s\n\t\t\t\t\tORDER BY p.`sortorder` ASC\n\t\t\t\t", !is_null($parent_sql) ? $parent_sql : " AND p.parent IS NULL ", !is_null($type_sql) ? $type_sql : ""));
     if (!is_array($pages) || empty($pages)) {
         if ($this->dsParamREDIRECTONEMPTY == 'yes') {
             throw new FrontendPageNotFoundException();
         }
         $result->appendChild($this->__noRecordsFound());
     } else {
         // Build an array of all the types so that the page's don't have to do
         // individual lookups.
         $page_types = PageManager::fetchAllPagesPageTypes();
         foreach ($pages as $page) {
             $result->appendChild($this->__buildPageXML($page, $page_types));
         }
     }
     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;
 }