public function appendFormattedElement(&$wrapper, $data, $encode = false, $mode = null)
 {
     $element = new XMLElement($this->get('element_name'));
     $element->setAttribute('hash', @dechex($data['value']));
     $element->setValue(@$data['value'] ? $data['value'] : '0');
     $wrapper->appendChild($element);
 }
 /**
  * Appends the show_created input.
  *
  * @param XMLElement $wrapper
  */
 public function generateShowCreated(XMLElement &$wrapper)
 {
     $div = new XMLElement('span', null, array('class' => 'hide-others'));
     $input = Widget::Input('show_created', null, 'checkbox');
     $div->setValue(__('%s hide others', array($input->generate())));
     $wrapper->appendChild($div);
 }
 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(&$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);
     }
 }
Beispiel #5
0
 public function grab(&$param_pool)
 {
     $result = new XMLElement($this->dsParamROOTELEMENT);
     foreach ($this->_env as $key => $value) {
         switch ($key) {
             case 'param':
                 //$group = new XMLElement('params');
                 foreach ($this->_env[$key] as $key => $value) {
                     $param = new XMLElement($key, General::sanitize($value));
                     $result->appendChild($param);
                 }
                 //$result->appendChild($group);
                 break;
             case 'env':
                 //$group = new XMLElement('pool');
                 foreach ($this->_env[$key]['pool'] as $key => $value) {
                     $param = new XMLElement($key);
                     if (is_array($value)) {
                         $param->setAttribute('count', count($value));
                         foreach ($value as $key => $value) {
                             $item = new XMLElement('item', General::sanitize($value));
                             $item->setAttribute('handle', Lang::createHandle($value));
                             $param->appendChild($item);
                         }
                     } else {
                         $param->setValue(General::sanitize($value));
                     }
                     $result->appendChild($param);
                 }
                 //$result->appendChild($group);
                 break;
         }
     }
     return $result;
 }
 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 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);
 }
Beispiel #8
0
 public function transform($data)
 {
     $txtElement = new XMLElement('data');
     $txtElement->setValue(General::wrapInCDATA($data));
     $data = $txtElement->generate();
     return $data;
 }
 public function prepareTableValue($data, XMLElement $link = NULL)
 {
     $value = $data['value'];
     if ($link) {
         $link->setValue($value);
         return $link->generate();
     } else {
         return $value;
     }
 }
 function displayPublishPanel(&$wrapper, $data = NULL, $flagWithError = NULL, $fieldnamePrefix = NULL, $fieldnamePostfix = NULL)
 {
     if ($this->get('show_in_publish') == 'no') {
         return;
     }
     $callback = Administration::instance()->getPageCallback();
     $entry_id = $callback['context']['entry_id'];
     $viewing_version = $_GET['version'];
     $container = new XMLElement('div', null, array('class' => 'container'));
     if (!$entry_id) {
         $container->appendChild(new XMLElement('p', 'Version 1 will be created when you save.'));
         $wrapper->appendChild($container);
         return;
     }
     $label = new XMLElement('label');
     $minor_edit_attributes = array('checked' => 'checked');
     if (isset($viewing_version)) {
         $minor_edit_attributes = array('disabled' => 'disabled', 'checked' => 'checked');
     }
     $input = Widget::Input('fields' . $fieldnamePrefix . '[' . $this->get('element_name') . ']' . $fieldnamePostfix, 'yes', 'checkbox', $minor_edit_attributes);
     $label->setValue($input->generate(false) . ' Create new version (major edit)');
     if (isset($viewing_version)) {
         $label->appendChild(Widget::Input('fields' . $fieldnamePrefix . '[' . $this->get('element_name') . ']' . $fieldnamePostfix, 'yes', 'hidden'));
     }
     $revision_history = new XMLElement('ol');
     $revision_history->setAttribute('class', 'revisions');
     $i = 0;
     $entries = EntryVersionsManager::entryHistory($entry_id);
     foreach ($entries as $entry) {
         $meta = $entry->documentElement;
         $href = '/symphony' . $callback['pageroot'] . $callback['context']['page'] . '/' . $entry_id;
         if ($i != 0) {
             $href .= '/?version=' . $meta->getAttribute('version');
         }
         $dom_revision = new XMLElement('a', 'Version ' . $meta->getAttribute('version'), array('href' => $href));
         $timestamp = strtotime($meta->getAttribute('created-date') . ' ' . $meta->getAttribute('created-time'));
         $dom_created = new XMLElement('span', 'on ' . DateTimeObj::get(__SYM_DATE_FORMAT__, $timestamp) . ' ' . DateTimeObj::get(__SYM_TIME_FORMAT__, $timestamp), array('class' => 'date'));
         $dom_author = new XMLElement('span', 'by ' . $meta->getAttribute('created-by'), array('class' => 'author'));
         $dom_li = new XMLElement('li');
         if (!isset($viewing_version) && $i == 0) {
             $dom_li->setAttribute('class', 'viewing');
         }
         if (isset($viewing_version) && (int) $viewing_version == (int) $meta->getAttribute('version')) {
             $dom_li->setAttribute('class', 'viewing');
         }
         $dom_li->appendChild($dom_revision);
         $dom_li->appendChild($dom_author);
         $dom_li->appendChild($dom_created);
         $revision_history->appendChild($dom_li);
         $i++;
     }
     $container->appendChild($label);
     $container->appendChild($revision_history);
     $wrapper->appendChild($container);
 }
 public function displaySettingsPanel(XMLElement &$wrapper, $errors = null)
 {
     parent::displaySettingsPanel($wrapper, $errors);
     $label = new XMLElement('label');
     $input = Widget::Input("fields[{$this->get('sortorder')}][override]", 'yes', 'checkbox');
     if ($this->get('override') == 'yes') {
         $input->setAttribute('checked', 'checked');
     }
     $label->setValue(__('%s Allow overriding of upload directory in entries', array($input->generate())));
     $wrapper->appendChild($label);
 }
 public function grab(&$param_pool)
 {
     $result = new XMLElement($this->dsParamROOTELEMENT);
     $driver = Frontend::instance()->ExtensionManager->create('iplocation_lookup');
     $location = extension_IPLocation_Lookup::lookup();
     if (is_null($location)) {
         $result->appendChild(new XMLElement('error', 'unknown location'));
     } else {
         $result->setValue($location);
     }
     return $result;
 }
    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>
				&lt;form method="post"&gt;
					&lt;label&gt;Username: &lt;input name="fields[username]" type="text" value="{$username}"/&gt;&lt;/label&gt;
					or
					&lt;label&gt;Email: &lt;input name="fields[email]" type="text" value="{$email}"/&gt;&lt;/label&gt;
					&lt;label&gt;Recovery Code: &lt;input name="fields[password][recovery-code]" type="text" value="{$code}"/&gt;&lt;/label&gt;
					&lt;label&gt;Password: &lt;input name="fields[password][password]" type="password" /&gt;&lt;/label&gt;
					&lt;label&gt;Confirm Password: &lt;input name="fields[password][confirm]" type="password" /&gt;&lt;/label&gt;
					&lt;input type="hidden" name="members-section-id" value="{$your-section-id}"/&gt;
					&lt;input type="submit" name="action[' . self::ROOTELEMENT . ']" value="Recover Account"/&gt;
					&lt;input type="hidden" name="redirect" value="{$root}/"/&gt;
				&lt;/form&gt;
				</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() . '
			';
    }
 public function view()
 {
     // Determine which formatter to use
     // The textarea keeps this info in its class attribute, but sometimes there might be additional classes.
     // We'll grab one that matches the installed formatters.
     $fM = new TextformatterManager($this);
     $formatter_handle = array_pop(array_intersect(array_keys($fM->listAll()), explode(' ', $_POST['formatter'])));
     // We pass the full formatter name back for use in the preview display
     $format_name = new XMLElement('formatter');
     $preview = new XMLElement('preview');
     if (empty($formatter_handle)) {
         $format_name->setValue('None');
         $preview->setValue($_POST['formatText']);
     } else {
         $formatter = $fM->create($formatter_handle);
         $formatter_about = $formatter->about();
         $format_name->setValue($formatter_about['name']);
         $preview->setValue($formatter->run($_POST['formatText']));
     }
     $this->_Result->appendChild($format_name);
     $this->_Result->appendChild($preview);
 }
 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 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>
				&lt;form method="post"&gt;
					&lt;label&gt;Username: &lt;input name="fields[username]" type="text" value="{$username}"/&gt;&lt;/label&gt;
					or
					&lt;label&gt;Email: &lt;input name="fields[email]" type="text" value="{$email}"/&gt;&lt;/label&gt;
					&lt;label&gt;Activation: &lt;input name="fields[activation]" type="text" value="{$code}"/&gt;&lt;/label&gt;
					&lt;input type="hidden" name="members-section-id" value="{$your-section-id}"/&gt;
					&lt;input type="submit" name="action[' . self::ROOTELEMENT . ']" value="Activate Account"/&gt;
					&lt;input type="hidden" name="redirect" value="{$root}/"/&gt;
				&lt;/form&gt;
				</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() . '
			';
    }
 function grab(&$param_pool)
 {
     $xml = new XMLElement($this->dsParamROOTELEMENT);
     $discussion_id = (int) $this->dsParamFILTERS['discussion-id'];
     /* Grab field IDs from configuration settings */
     $comment_discussion_link_field = (int) Symphony::Configuration()->get('comment-discussion-link-field', 'forum');
     $comment_field = (int) Symphony::Configuration()->get('comment-field', 'forum');
     $comment_id = $this->_Parent->Database->fetchVar('entry_id', 0, "SELECT `entry_id` FROM `tbl_entries_data_" . $comment_discussion_link_field . "` 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_" . $comment_field . "` 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;
 }
 function grab(&$param_pool)
 {
     $discussionID = (int) $this->_Parent->Database->fetchVar('relation_id', 0, "SELECT `relation_id` FROM `tbl_entries_data_18` WHERE `entry_id` = " . (int) $this->dsParamFILTERS['id'] . " LIMIT 1");
     $xml = new XMLElement($this->dsParamROOTELEMENT);
     $xml->setAttribute('id', (int) $this->dsParamFILTERS['id']);
     $xml->setAttribute('discussion-id', $discussionID);
     $body = $this->_Parent->Database->fetchVar('value', 0, "SELECT `value` FROM `tbl_entries_data_17` WHERE `entry_id` = " . (int) $this->dsParamFILTERS['id'] . " LIMIT 1");
     if (is_null($body) || strlen(trim($body)) == 0) {
         return $this->emptyXMLSet();
     }
     $xml->setValue(General::sanitize($body));
     return $xml;
     //$result = NULL;
     //include(TOOLKIT . '/data-sources/datasource.section.php');
     //if($this->_force_empty_result) $result = $this->emptyXMLSet();
     //return $result;
 }
 /**
  * Add parent pages including current to XML output.
  *
  * @param array      $pages   - contains all pages data
  * @param int        $page_id - current page id
  * @param array      $langs   - all supported language codes
  * @param XMLElement $result  - resulting XML
  *
  * @return XMLElement - a pages XML ouput
  */
 private function appendPage(array $pages, $page_id, array $langs, XMLElement $result)
 {
     $page = $pages[$page_id];
     if ($page['parent'] !== null) {
         $result = $this->appendPage($pages, $page['parent'], $langs, $result);
     }
     $page_xml = new XMLElement('page');
     $page_xml->setAttribute('handle', $page['handle']);
     $page_xml->setAttribute('id', $page_id);
     foreach ($langs as $lc) {
         $item_xml = new XMLElement('item');
         $item_xml->setValue(General::sanitize($page["plh_t-{$lc}"]));
         $item_xml->setAttribute('lang', $lc);
         $item_xml->setAttribute('handle', $page["plh_h-{$lc}"]);
         $page_xml->prependChild($item_xml);
     }
     $result->appendChild($page_xml);
     return $page_xml;
 }
 protected function __buildPagination($pagination)
 {
     $ul = new XMLElement('ul');
     $ul->setAttribute('class', 'page');
     // first
     $li = new XMLElement('li');
     if ($pagination->{'current-page'} > 1) {
         $li->appendChild(Widget::Anchor(__('First'), $this->__buildURL(array('pagination->current-page' => 1))));
     } else {
         $li->setValue(__('First'));
     }
     $ul->appendChild($li);
     // previous
     $li = new XMLElement('li');
     if ($pagination->{'current-page'} > 1) {
         $li->appendChild(Widget::Anchor(__('&larr; Previous'), $this->__buildURL(array('pagination->current-page' => $pagination->{'current-page'} - 1))));
     } else {
         $li->setValue('&larr; ' . __('Previous'));
     }
     $ul->appendChild($li);
     // summary
     $li = new XMLElement('li', __('Page %1$s of %2$s', array($pagination->{'current-page'}, max($pagination->{'current-page'}, $pagination->{'total-pages'}))));
     $li->setAttribute('title', __('Viewing %1$s - %2$s of %3$s entries', array($pagination->start, $pagination->end, $pagination->{'total-entries'})));
     $ul->appendChild($li);
     // next
     $li = new XMLElement('li');
     if ($pagination->{'current-page'} < $pagination->{'total-pages'}) {
         $li->appendChild(Widget::Anchor(__('Next &rarr;'), $this->__buildURL(array('pagination->current-page' => $pagination->{'current-page'} + 1))));
     } else {
         $li->setValue(__('Next') . ' &rarr;');
     }
     $ul->appendChild($li);
     // last
     $li = new XMLElement('li');
     if ($pagination->{'current-page'} < $pagination->{'total-pages'}) {
         $li->appendChild(Widget::Anchor(__('Last'), $this->__buildURL(array('pagination->current-page' => $pagination->{'total-pages'}))));
     } else {
         $li->setValue(__('Last'));
     }
     $ul->appendChild($li);
     return $ul;
 }
 function grab(&$param_pool)
 {
     /* Grab field IDs from configuration settings */
     $comment_discussion_link_field = (int) Symphony::Configuration()->get('comment-discussion-link-field', 'forum');
     $comment_field = (int) Symphony::Configuration()->get('comment-field', 'forum');
     $discussionID = (int) $this->_Parent->Database->fetchVar('relation_id', 0, "SELECT `relation_id` FROM `tbl_entries_data_" . $comment_discussion_link_field . "` WHERE `entry_id` = " . (int) $this->dsParamFILTERS['id'] . " LIMIT 1");
     $xml = new XMLElement($this->dsParamROOTELEMENT);
     $xml->setAttribute('id', (int) $this->dsParamFILTERS['id']);
     $xml->setAttribute('discussion-id', $discussionID);
     $body = $this->_Parent->Database->fetchVar('value', 0, "SELECT `value` FROM `tbl_entries_data_" . $comment_field . "` WHERE `entry_id` = " . (int) $this->dsParamFILTERS['id'] . " LIMIT 1");
     if (is_null($body) || strlen(trim($body)) == 0) {
         return $this->emptyXMLSet();
     }
     $xml->setValue(General::sanitize($body));
     return $xml;
     //$result = NULL;
     //include(TOOLKIT . '/data-sources/datasource.section.php');
     //if($this->_force_empty_result) $result = $this->emptyXMLSet();
     //return $result;
 }
 public function execute(array &$param_pool = null)
 {
     include_once TOOLKIT . '/class.xsltprocess.php';
     $result = new XMLElement($this->dsParamROOTELEMENT);
     $this->dsParamSTATIC = stripslashes($this->dsParamSTATIC);
     if (!General::validateXML($this->dsParamSTATIC, $errors, false, new XsltProcess())) {
         $result->appendChild(new XMLElement('error', __('XML is invalid.')));
         $element = new XMLElement('errors');
         foreach ($errors as $e) {
             if (strlen(trim($e['message'])) == 0) {
                 continue;
             }
             $element->appendChild(new XMLElement('item', General::sanitize($e['message'])));
         }
         $result->appendChild($element);
     } else {
         $result->setValue($this->dsParamSTATIC);
     }
     return $result;
 }
 public function __viewIndex()
 {
     $this->addStylesheetToHead(URL . '/extensions/activitylog/assets/view.css', 'screen', 1000);
     $this->setPageType('form');
     $this->setTitle(__('Symphony &ndash; Activity Log'));
     $this->appendSubheading(__('Activity Log'));
     $driver = $this->_Parent->ExtensionManager->create('activitylog');
     $items = $driver->readLog();
     $table = new XMLElement('table');
     foreach ($items as $item) {
         $row = new XMLElement('tr');
         $cell = new XMLElement('td');
         $cell->setValue($item->message);
         $row->appendChild($cell);
         $cell = new XMLElement('td');
         $cell->setValue($this->getTime($item->timestamp));
         $row->appendChild($cell);
         $table->appendChild($row);
     }
     $this->Form->appendChild($table);
 }
 protected function buildContent($wrapper)
 {
     $this->addStylesheetToHead(URL . '/extensions/logsdevkit/assets/devkit.css', 'screen', 1032340);
     if (array_key_exists($this->_view, $this->_files)) {
         $table = new XMLElement('table');
         foreach ($this->__parseLog($this->_path . $this->_view) as $item) {
             // Flag notices:
             $item->message = preg_replace('%^NOTICE: .*%', '<span class="notice">\\0</span>', $item->message);
             // Hilight files:
             $item->message = preg_replace('%((/\\S+)( on )(line [0-9]+))%', '<span class="file">\\2</span>\\3<span class="line">\\4</span>', $item->message);
             $row = new XMLElement('tr');
             $cell = new XMLElement('td');
             $cell->setValue($item->message);
             $row->appendChild($cell);
             $cell = new XMLElement('th');
             $cell->setValue($item->timestamp);
             $row->appendChild($cell);
             $table->appendChild($row);
         }
         $wrapper->appendChild($table);
     }
 }
 public function displayPublishPanel(&$wrapper, $data = null, $error = null, $prefix = null, $postfix = null, $entry_id = null)
 {
     $this->_driver->addHeaders($this->_engine->Page);
     $handle = $this->get('element_name');
     $fieldname = "fields{$prefix}[{$handle}]{$postfix}";
     // Defaults -----------------------------------------------------------
     $wrapper->appendChild(Widget::Input("fields{$prefix}[{$handle}][is_cased]{$postfix}", 'no', 'hidden'));
     $wrapper->appendChild(Widget::Input("fields{$prefix}[{$handle}][is_regexp]{$postfix}", 'no', 'hidden'));
     // Expression ---------------------------------------------------------
     $label = Widget::Label(__('Expression'));
     $label->appendChild(Widget::Input("fields{$prefix}[{$handle}][value]{$postfix}", General::sanitize($data['value'])));
     if (isset($error)) {
         $label = Widget::wrapFormElementWithError($label, $error);
     }
     $wrapper->appendChild($label);
     $help = new XMLElement('p');
     $help->setAttribute('class', 'help');
     $help->setValue('Use <code>*</code> as a wild-card unless regular expressions are enabled.');
     $wrapper->appendChild($help);
     // Cased? -------------------------------------------------------------
     $settings = new XMLElement('div');
     $input = Widget::Input("fields{$prefix}[{$handle}][is_cased]{$postfix}", 'yes', 'checkbox', $data['is_cased'] == 'yes' ? array('checked' => 'checked') : null);
     $label = Widget::Label(__('%s Case sensetive?', array($input->generate())));
     $settings->appendChild($label);
     $help = new XMLElement('p');
     $help->setAttribute('class', 'help');
     $help->setValue(__('Treat upper case and lower case letters differently.'));
     $settings->appendChild($help);
     // Regexp? ------------------------------------------------------------
     $input = Widget::Input("fields{$prefix}[{$handle}][is_regexp]{$postfix}", 'yes', 'checkbox', $data['is_regexp'] == 'yes' ? array('checked' => 'checked') : null);
     $label = Widget::Label(__('%s Regular expressions?', array($input->generate())));
     $settings->appendChild($label);
     $help = new XMLElement('p');
     $help->setAttribute('class', 'help');
     $help->setValue(__('Advanced matching with <a href="%s">Perl compatible regular expressions</a>.', array(URL . '/symphony/extension/expressionfield/documentation/')));
     $settings->appendChild($help);
     $wrapper->appendChild($settings);
 }
 public function initaliseAdminPageHead($context)
 {
     $page = Administration::instance()->Page;
     $includes = $editors = array();
     $position = 29751000;
     foreach ($this->getFormatters('name', 'asc', 1, 10000, true) as $formatter) {
         $class = $formatter['about']['handle'];
         $editor = $formatter['options']['editor_name'];
         $editors[$class] = $editor;
         if (is_null($editor) or $editor == 'none') {
             continue;
         }
         $includes[] = $editor;
     }
     $includes = array_unique($includes);
     $script = new XMLElement('script');
     $script->setAttribute('type', 'text/javascript');
     $script->setValue(sprintf('var HTMLFormatterEditors = %s;', json_encode($editors)));
     foreach ($includes as $index => $include) {
         switch ($include) {
             case 'ckeditor':
                 $page->addScriptToHead(URL . '/extensions/htmlformatter/editors/ckeditor/ckeditor.js', $position++);
                 break;
             case 'jwysiwyg':
                 $page->addScriptToHead(URL . '/extensions/htmlformatter/editors/jwysiwyg/jquery.wysiwyg.js', $position++);
                 $page->addStylesheetToHead(URL . '/extensions/htmlformatter/editors/jwysiwyg/jquery.wysiwyg.css', 'screen', $position++);
                 break;
             case 'snicked':
                 $page->addScriptToHead(URL . '/extensions/htmlformatter/editors/snicked/assets/jquery.snickedCore.js', $position++);
                 $page->addScriptToHead(URL . '/extensions/htmlformatter/editors/snicked/assets/jquery.snicked.js', $position++);
                 break;
         }
     }
     $page->addElementToHead($script, $position++);
     $page->addScriptToHead(URL . '/extensions/htmlformatter/assets/editors.js', $position++);
     $page->addStylesheetToHead(URL . '/extensions/htmlformatter/assets/editors.css', 'screen', 40);
 }
 protected function __trigger()
 {
     $r = new XMLElement($this->getRootElement());
     try {
         if ($this->isValid()) {
             if ($this->__sendEmail()) {
                 $r->setAttribute('success', 'yes');
             } else {
                 throw new EmailEventException('Error sending email');
             }
         } else {
             throw new EmailEventException('Form is invalid');
         }
     } catch (Exception $ex) {
         $xmlEx = new XMLElement('error');
         $showMsg = $ex instanceof EmailEventException || Symphony::Engine()->isLoggedIn();
         $errorMessage = $showMsg ? $ex->getMessage() : __('A Fatal error occured');
         $xmlEx->setValue($errorMessage);
         $r->appendChild($xmlEx);
         $r->setAttribute('success', 'no');
         Symphony::Log()->pushExceptionToLog($ex, true);
     }
     return $r;
 }
Beispiel #28
0
 public function prepareTableValue($data, XMLElement $link = null, $entry_id = null)
 {
     if (empty($data) or strlen(trim($data['value'])) == 0) {
         $value = __('None');
     } else {
         $max_length = (int) $this->get('column_length');
         $max_length = $max_length ? $max_length : 75;
         $value = strip_tags(isset($data['value_formatted']) ? $data['value_formatted'] : $data['value']);
         if ($max_length < strlen($value)) {
             $lines = explode("\n", wordwrap($value, $max_length - 1, "\n"));
             $value = array_shift($lines);
             $value = rtrim($value, "\n\t !?.,:;");
             $value .= '...';
         }
         if ($max_length > 75) {
             $value = wordwrap($value, 75, '<br />');
         }
     }
     if ($link) {
         $link->setValue($value);
         return $link->generate();
     }
     return $value;
 }
Beispiel #29
0
 /**
  * Format this field value for display in the publish index tables. By default,
  * Symphony will truncate the value to the configuration setting `cell_truncation_length`.
  * This function will attempt to use PHP's `mbstring` functions if they are available.
  *
  * @param array $data
  *	an associative array of data for this string. At minimum this requires a
  *  key of 'value'.
  * @param XMLElement $link (optional)
  *	an XML link structure to append the content of this to provided it is not
  *	null. it defaults to null.
  * @param integer $entry_id (optional)
  *  An option entry ID for more intelligent processing. defaults to null
  * @return string
  *	the formatted string summary of the values of this field instance.
  */
 public function prepareTableValue($data, XMLElement $link = null, $entry_id = null)
 {
     $max_length = Symphony::Configuration()->get('cell_truncation_length', 'symphony');
     $max_length = $max_length ? $max_length : 75;
     $value = strip_tags($data['value']);
     if (function_exists('mb_substr') && function_exists('mb_strlen')) {
         $value = mb_strlen($value, 'utf-8') <= $max_length ? $value : mb_substr($value, 0, $max_length, 'utf-8') . '…';
     } else {
         $value = strlen($value) <= $max_length ? $value : substr($value, 0, $max_length) . '…';
     }
     if (strlen($value) == 0) {
         $value = __('None');
     }
     if ($link) {
         $link->setValue($value);
         return $link->generate();
     }
     return $value;
 }
Beispiel #30
0
 public function prepareTableValue($data, XMLElement $link = NULL)
 {
     $max_length = $this->_engine->Configuration->get('cell_truncation_length', 'symphony');
     $max_length = $max_length ? $max_length : 75;
     $value = strip_tags($data['value']);
     $value = strlen($value) <= $max_length ? $value : substr($value, 0, $max_length) . '...';
     if (strlen($value) == 0) {
         $value = __('None');
     }
     if ($link) {
         $link->setValue($value);
         return $link->generate();
     }
     return $value;
 }