function __switchboard($type) { $this->_page = isset($this->_context[0]) ? $this->_context[0] : 'view'; $this->_id = !empty($this->_context[1]) && is_numeric($this->_context[1]) ? $this->_context[1] : 0; $this->_flag = $this->_context[2]; // Notices if (isset($this->_flag)) { $result = null; switch ($this->_flag) { case 'edited': $result = __('Category updated at %1$s.'); break; case 'deleted': $result = __('Category deleted'); break; case 'created': $result = __('Category created at %1$s. <a href="%2$s">Create another?</a>'); break; } if ($result) { $this->pageAlert(__($result, array(DateTimeObj::get(__SYM_TIME_FORMAT__), BASE_URL . '/list/new/' . $this->_id)), Alert::SUCCESS); } } $function = ($type == 'action' ? '__action' : '__view') . ($this->_page == 'view' ? 'Index' : ucfirst($this->_page)); if (!method_exists($this, $function)) { if ($type == 'action') { return; } $this->_Parent->errorPageNotFound(); } return $this->{$function}(); }
public static function lastUpdateFilterList() { if (!file_exists(WORKSPACE . self::$file)) { return false; } return DateTimeObj::get(DateTimeObj::getSetting('datetime_format'), filemtime(WORKSPACE . self::$file)); }
/** * Initialize contextual XML (formerly params) */ public function initializeContext() { $this->View->context->register(array('system' => array('site-name' => Symphony::Configuration()->core()->symphony->sitename, 'site-url' => URL, 'admin-url' => URL . '/symphony', 'symphony-version' => Symphony::Configuration()->core()->symphony->version), 'date' => array('today' => DateTimeObj::get('Y-m-d'), 'current-time' => DateTimeObj::get('H:i'), 'this-year' => DateTimeObj::get('Y'), 'this-month' => DateTimeObj::get('m'), 'this-day' => DateTimeObj::get('d'), 'timezone' => date_default_timezone_get()))); if ($this->User) { $this->View->context->register(array('session' => self::instance()->User->fields())); } }
public function processDependencies(array $params = array()) { $datasources = $this->getDependencies(); if (!is_array($datasources) || empty($datasources)) { return; } $datasources = array_map(create_function('$a', "return str_replace('\$ds-', '', \$a);"), $datasources); $datasources = array_map(create_function('$a', "return str_replace('-', '_', \$a);"), $datasources); $env = array('today' => DateTimeObj::get('Y-m-d'), 'current-time' => DateTimeObj::get('H:i'), 'this-year' => DateTimeObj::get('Y'), 'this-month' => DateTimeObj::get('m'), 'this-day' => DateTimeObj::get('d'), 'timezone' => DateTimeObj::get('P'), 'enm-newsletter-id' => $this->newsletter_id); $this->_env['param'] = $env; $this->_env['env']['pool'] = $params; $dependencies = array(); foreach ($datasources as $handle) { $profiler = Symphony::Profiler(); $profiler->seed(); $pool[$handle] =& DatasourceManager::create($handle, NULL, false); $dependencies[$handle] = $pool[$handle]->getDependencies(); } $dsOrder = $this->__findDatasourceOrder($dependencies); foreach ($dsOrder as $handle) { $ds = $pool[$handle]; $ds->processParameters($this->_env); $ds->grab($this->_env['env']['pool']); unset($ds); } $this->processParameters($this->_env); }
function handleShutdown() { $error = error_get_last(); if ($error !== NULL && $error['type'] <= 1) { file_put_contents(DOCROOT . '/manifest/newsletter-log.txt', '[' . DateTimeObj::get('Y/m/d H:i:s') . '] pid: ' . getmypid() . ' - ' . $error['message'] . ' in file: ' . $error['file'] . ' on line ' . $error['line'] . "\r\n", FILE_APPEND); } }
public function view() { // Ensure we have been set $_POST data from Members events if (!array_key_exists('members', $_POST)) { $this->_status = AjaxPage::STATUS_BAD; return; } else { if (!is_writable(CONFIG)) { $this->_status = AjaxPage::STATUS_BAD; $this->_Result->appendChild(new XMLElement('message', __('The Symphony configuration file, <code>/manifest/config.php</code>, is not writable. You will not be able to save changes to preferences.'))); return; } } $settings = $_POST['members']; // Generate Recovery Code if (isset($settings['generate-recovery-code-template'])) { Symphony::Configuration()->set('generate-recovery-code-template', implode(',', array_filter($settings['generate-recovery-code-template'])), 'members'); } else { if ($settings['event'] == 'generate-recovery-code') { Symphony::Configuration()->remove('generate-recovery-code-template', 'members'); } } // Reset Password if (isset($settings['reset-password-template'])) { Symphony::Configuration()->set('reset-password-template', implode(',', array_filter($settings['reset-password-template'])), 'members'); } else { if ($settings['event'] == 'reset-password') { Symphony::Configuration()->remove('reset-password-template', 'members'); } } if ($settings['event'] == 'reset-password') { Symphony::Configuration()->set('reset-password-auto-login', $settings['auto-login'], 'members'); } // Regenerate Activation Code if (isset($settings['regenerate-activation-code-template'])) { Symphony::Configuration()->set('regenerate-activation-code-template', implode(',', array_filter($settings['regenerate-activation-code-template'])), 'members'); } else { if ($settings['event'] == 'regenerate-activation-code') { Symphony::Configuration()->remove('regenerate-activation-code-template', 'members'); } } // Activate Account if (isset($settings['activate-account-template'])) { Symphony::Configuration()->set('activate-account-template', implode(',', array_filter($settings['activate-account-template'])), 'members'); } else { if ($settings['event'] == 'activate-account') { Symphony::Configuration()->remove('activate-account-template', 'members'); } } if ($settings['event'] == 'activate-account') { Symphony::Configuration()->set('activate-account-auto-login', $settings['auto-login'], 'members'); } // Return successful if (Administration::instance()->saveConfig()) { $this->_status = AjaxPage::STATUS_OK; $this->_Result->appendChild(new XMLElement('message', __('Preferences saved.'))); $this->_Result->appendChild(new XMLElement('timestamp', '<![CDATA[' . DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__) . ']]>')); } }
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; }
function getValuesFromXML() { $xml_location = $this->get('xml_location'); if (General::validateURL($xml_location) != '') { // is a URL, check cache $cache_id = md5($xml_location); $cache = new Cacheable($this->_Parent->_Parent->Database); $cachedData = $cache->check($cache_id); $creation = DateTimeObj::get('c'); if (!$cachedData || time() - $cachedData['creation'] > 5 * 60) { if (Mutex::acquire($cache_id, 6, TMP)) { $ch = new Gateway(); $ch->init(); $ch->setopt('URL', $xml_location); $ch->setopt('TIMEOUT', 6); $xml = $ch->exec(); $writeToCache = true; Mutex::release($cache_id, TMP); $xml = trim($xml); if (empty($xml) && $cachedData) { $xml = $cachedData['data']; } } elseif ($cachedData) { $xml = $cachedData['data']; } } else { $xml = $cachedData['data']; } $xml = simplexml_load_string($xml); } elseif (substr($xml_location, 0, 1) == '/') { // relative to DOCROOT $xml = simplexml_load_file(DOCROOT . $this->get('xml_location')); } else { // in extension's /xml folder $xml = simplexml_load_file(EXTENSIONS . '/xml_selectbox/xml/' . $this->get('xml_location')); } if (!$xml) { return; } $items = $xml->xpath($this->get('item_xpath')); $options = array(); foreach ($items as $item) { $option = array(); $text_xpath = $item->xpath($this->get('text_xpath')); $option['text'] = General::sanitize((string) $text_xpath[0]); if ($this->get('value_xpath') != '') { $value_xpath = $item->xpath($this->get('value_xpath')); $option['value'] = General::sanitize((string) $value_xpath[0]); } if ((string) $option['value'] == '') { $option['value'] = $option['text']; } $options[] = $option; } return $options; }
public function write() { $section = $this->section->get('object'); $entry = null; $entry_data = array(); // If it's an existing entry we want to load that entry object foreach ($this->writes as $write) { $field = $write->get('object'); $field_data = $write->get('data'); if ($field == SymQuery::SYSTEM_ID) { $existing = SymQuery::$em->fetch($field_data, $section->get('id')); if (is_array($existing) && !empty($existing)) { $entry = current($existing); break; } } } // If $entry is null, then it's a new entry, so fill it with some default metadata if (is_null($entry)) { $entry = SymQuery::$em->create(); $author = SymQuery::$symphony->Author; // Build default entry data: $entry->set('section_id', $section->get('id')); if (is_object($author)) { $entry->set('author_id', $author->get('id')); } $entry->set('creation_date', DateTimeObj::get('Y-m-d H:i:s')); $entry->set('creation_date_gmt', DateTimeObj::getGMT('Y-m-d H:i:s')); } foreach ($this->writes as $write) { $field = $write->get('object'); $field_data = $write->get('data'); if ($field instanceof Field) { $field_handle = $field->get('element_name'); $entry_data[$field_handle] = $field_data; } } if (__ENTRY_FIELD_ERROR__ == $entry->checkPostData($entry_data, $errors, $entry->get('id') ? true : false)) { $validation_errors = array(); foreach ($errors as $field_id => $message) { if (!in_array($field_id, SymQuery::$field_cache)) { SymQuery::$field_cache[$field_id] = SymQuery::$fm->fetch($field_id, $section->get('id')); } $validation_errors[$field_id] = array('field' => SymQuery::$field_cache[$field_id], 'error' => $message); } $error = new SymWriteException('Unable to validate entry.'); $error->setValidationErrors($validation_errors); throw $error; } if (__ENTRY_OK__ != $entry->setDataFromPost($entry_data, $error, false, $entry->get('id') ? true : false)) { throw new SymQueryException(sprintf('Unable to save entry: %s', $error)); } $entry->commit(); return $entry; }
public function appendScriptToHead($context) { $this->static_section_name = ''; $entryManager = new EntryManager($this->_Parent); $sections = $this->_Parent->Database->fetch("SELECT section_id AS id, handle FROM tbl_fields_static_section LEFT JOIN tbl_sections ON tbl_fields_static_section.section_id = tbl_sections.id"); $this->section_data = array('handles' => array(), 'entries' => array()); foreach ($sections as $key => $value) { $this->section_data['handles'][] = $value['handle']; $result = $entryManager->fetch(NULL, $value['id'], NULL, NULL, NULL, NULL, false, false); if (count($result) > 0) { $this->section_data['entries'][] = $result[0]['id']; } else { $this->section_data['entries'][] = NULL; } } $this->_page = Administration::instance()->Page; $section_handle = $this->_page->_context['section_handle']; $context = $this->_page->_context['page']; $url_entry = $this->_page->_context['entry_id']; $flag = $this->_page->_context['flag']; if (isset($section_handle)) { $section = $this->_Parent->Database->fetchRow(0, "SELECT id, name FROM tbl_sections WHERE handle='{$section_handle}'"); $field = $this->_Parent->Database->fetchRow(0, "SELECT id FROM tbl_fields_static_section WHERE section_id=" . $section['id']); if ($field) { $entry = $this->getSectionEntry($section_handle); if ($context == 'new' && $entry) { redirect(URL . '/symphony/publish/' . $section_handle . '/edit/' . $entry . '/'); } if ($context == 'index') { if ($entry) { redirect(URL . '/symphony/publish/' . $section_handle . '/edit/' . $entry . '/'); } else { redirect(URL . '/symphony/publish/' . $section_handle . '/new/'); } } if ($context == 'edit') { if (!$entry) { redirect(URL . '/symphony/publish/' . $section_handle . '/new/'); } if ($url_entry != $entry) { redirect(URL . '/symphony/publish/' . $section_handle . '/edit/' . $entry . '/'); } } if ($flag == 'saved' || $flag == 'created') { $flag_msg = 'Entry updated at %1$s.'; if ($flag == 'created') { $flag_msg = 'Entry created at %1$s.'; } $this->_page->pageAlert(__($flag_msg, array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__))), Alert::SUCCESS); } $this->static_section_name = $section['name']; } } }
private function parseDate($row) { $fieldname = $this->getFieldName(); if (!empty($row) && isset($row[$fieldname])) { $value = $row[$fieldname] . ' Etc/UTC'; } else { $value = DateTimeObj::getGMT('Y-m-d H:i:s') . ' Etc/UTC'; } $date = DateTimeObj::parse($value); return $date; }
public static function getMetaInfo($file, $type) { $meta = array(); if (!file_exists($file) || !is_readable($file)) { return $meta; } $meta['creation'] = DateTimeObj::get('c', filemtime($file)); if (General::in_iarray($type, fieldUpload::$imageMimeTypes) && ($array = @getimagesize($file))) { $meta['width'] = $array[0]; $meta['height'] = $array[1]; } return $meta; }
public function view() { $this->setPageType('table'); $this->setTitle('Symphony – Cron'); $this->appendSubheading('Cron Tasks', [Widget::Anchor(__('Create New'), Administration::instance()->getCurrentPageURL() . 'new/', __('Create a cron task'), 'create button', null, ['accesskey' => 'c'])]); Extension_Cron::init(); $iterator = new Lib\CronTaskIterator(realpath(MANIFEST . '/cron'), Symphony::Database()); $aTableHead = [['Name', 'col'], ['Description', 'col'], ['Enabled', 'col'], ['Last Executed', 'col'], ['Next Execution', 'col'], ['Last Output', 'col']]; $aTableBody = []; if ($iterator->count() == 0) { $aTableBody = [Widget::TableRow([Widget::TableData(__('None found.'), 'inactive', null, count($aTableHead))], 'odd')]; } else { foreach ($iterator as $ii => $task) { $td1 = Widget::TableData(Widget::Anchor($task->name, sprintf('%sedit/%s/', Administration::instance()->getCurrentPageURL(), $task->filename))); $td1->appendChild(Widget::Label(__('Select Task %s', [$task->filename]), null, 'accessible', null, array('for' => 'task-' . $ii))); $td1->appendChild(Widget::Input('items[' . $task->filename . ']', 'on', 'checkbox', array('id' => 'task-' . $ii))); $td2 = Widget::TableData(is_null($task->description) ? 'None' : $task->description); if (is_null($task->description)) { $td2->setAttribute('class', 'inactive'); } $td3 = Widget::TableData($task->enabledReal() == true ? 'Yes' : 'No'); if ($task->enabled == false) { $td3->setAttribute('class', 'inactive'); } $td4 = Widget::TableData(!is_null($task->getLastExecutionTimestamp()) ? DateTimeObj::get(__SYM_DATETIME_FORMAT__, $task->getLastExecutionTimestamp()) : 'Unknown'); if (is_null($task->getLastExecutionTimestamp())) { $td4->setAttribute('class', 'inactive'); } $td5 = Widget::TableData(!is_null($task->nextExecution()) ? self::__minutesToHumanReadable(ceil($task->nextExecution() * (1 / 60))) : 'Unknown'); if (is_null($task->nextExecution()) || $task->enabledReal() == false) { $td5->setAttribute('class', 'inactive'); } if (is_null($task->getLog())) { $td6 = Widget::TableData('None', 'inactive'); } else { $td6 = Widget::TableData(Widget::Anchor('view', sprintf('%slog/%s/', Administration::instance()->getCurrentPageURL(), $task->filename))); } $aTableBody[] = Widget::TableRow(array($td1, $td2, $td3, $td4, $td5, $td6)); } } $table = Widget::Table(Widget::TableHead($aTableHead), null, Widget::TableBody($aTableBody), 'selectable', null, array('role' => 'directory', 'aria-labelledby' => 'symphony-subheading', 'data-interactive' => 'data-interactive')); $this->Form->appendChild($table); $tableActions = new XMLElement('div'); $tableActions->setAttribute('class', 'actions'); $options = [[null, false, __('With Selected...')], ['enable', false, __('Enable')], ['disable', false, __('Disable')], ['delete', false, __('Delete'), 'confirm', null, ['data-message' => __('Are you sure you want to delete the selected tasks?')]]]; $tableActions->appendChild(Widget::Apply($options)); $this->Form->appendChild($tableActions); }
function __construct(&$parent) { $this->_Parent = $parent; $this->_fields = array(); $this->_required = false; $this->_showcolumn = true; $this->_handle = strtolower(get_class($this)) == 'field' ? 'field' : strtolower(substr(get_class($this), 5)); if (class_exists('Administration')) { $this->_engine = Administration::instance(); } elseif (class_exists('Frontend')) { $this->_engine = Frontend::instance(); } else { trigger_error(__('No suitable engine object found'), E_USER_ERROR); } $this->creationDate = DateTimeObj::getGMT('c'); $this->Database = Symphony::Database(); }
/** * Overload the Symphony::login function to bypass some code that * forces use of the Administration class (which of course is not * available in Shell). Hopefully this is fixed in the core Symphony code * */ public static function login($username, $password, $isHash = false) { $username = self::Database()->cleanValue($username); $password = self::Database()->cleanValue($password); if (strlen(trim($username)) > 0 && strlen(trim($password)) > 0) { $author = \AuthorManager::fetch('id', 'ASC', 1, null, sprintf("\n `username` = '%s'\n ", $username)); if (!empty($author) && \Cryptography::compare($password, current($author)->get('password'), $isHash)) { self::$Author = current($author); // Only migrate hashes if there is no update available as the update might change the tbl_authors table. if (\Cryptography::requiresMigration(self::$Author->get('password'))) { throw new ShellException('User details require updating. Please login to the admin interface.'); } self::$Cookie->set('username', $username); self::$Cookie->set('pass', self::$Author->get('password')); self::Database()->update(array('last_seen' => \DateTimeObj::get('Y-m-d H:i:s')), 'tbl_authors', sprintf(" `id` = %d", self::$Author->get('id'))); return true; } } return false; }
function grab(&$param_pool) { $result = NULL; $Forum = $this->_Parent->ExtensionManager->create('forum'); $members = $this->_Parent->ExtensionManager->create('members'); $members->initialiseCookie(); if (!$members->isLoggedIn() || !isset($param_pool['ds-forum-discussions']) || empty($param_pool['ds-forum-discussions'])) { $result = $this->emptyXMLSet(); } else { if (!$members->Member) { $members->initialiseMemberObject(); } $member_id = $members->Member->get('id'); $member_read_cutoff_date = Symphony::Database()->fetchVar('local', 0, sprintf("SELECT `local` FROM `tbl_entries_data_%d` WHERE `entry_id` = %d LIMIT 1", Discussion::getUnreadCutoffField(), $member_id)); if (is_null($member_read_cutoff_date)) { $member_read_cutoff_date = strtotime(Symphony::Database()->fetchVar('creation_date', 0, "SELECT `creation_date` FROM `tbl_entries` WHERE `id` = {$member_id} LIMIT 1")); } $discussion_last_active_field = Symphony::Configuration()->get('discussion-last-active-field', 'forum'); $pre_dated_discussions = Symphony::Database()->fetchCol('entry_id', sprintf("SELECT `entry_id` \n\t\t\t\t\t\tFROM `tbl_entries_data_%d` \n\t\t\t\t\t\tWHERE `entry_id` IN (" . @implode(',', $param_pool['ds-forum-discussions']) . ") \n\t\t\t\t\t\tAND `local` <= '%s'", $discussion_last_active_field, $member_read_cutoff_date)); $read_discussions = @implode(',', array_diff($param_pool['ds-forum-discussions'], $pre_dated_discussions)); if (empty($read_discussions)) { $read_discussions = 0; } $read = $this->_Parent->Database->fetch(sprintf("SELECT * FROM `tbl_forum_read_discussions` \n\t\t\t\t\t\tWHERE `member_id` = {$member_id} \n\t\t\t\t\t\tAND `discussion_id` IN (%s)", $read_discussions)); if (empty($read) && empty($pre_dated_discussions)) { $result = $this->emptyXMLSet(); } else { $result = new XMLElement($this->dsParamROOTELEMENT); foreach ($read as $r) { $result->appendChild(new XMLElement('discussion', NULL, array('id' => $r['discussion_id'], 'comments' => $r['comments'], 'last-viewed' => DateTimeObj::get('c', $r['last_viewed'])))); if (isset($pre_dated_discussions[$r['discussion_id']])) { unset($pre_dated_discussions[$r['discussion_id']]); } } foreach ($pre_dated_discussions as $id) { $result->appendChild(new XMLElement('discussion', NULL, array('id' => $id, 'comments' => '100000', 'last-viewed' => DateTimeObj::get('c', strtotime($member_registration_date))))); } } } return $result; }
function __construct(&$parent) { $this->_Parent = $parent; $this->_fields = array(); $this->_required = false; $this->_showcolumn = true; $this->_handle = strtolower(get_class($this)) == 'field' ? 'field' : strtolower(substr(get_class($this), 5)); ## Since we are not sure where the Admin object is, inspect ## all the parent objects $this->catalogueParentObjects(); if (class_exists('Administration')) { $this->_engine = Administration::instance(); } elseif (class_exists('Frontend')) { $this->_engine = Frontend::instance(); } else { trigger_error(__('No suitable engine object found'), E_USER_ERROR); } $this->creationDate = DateTimeObj::getGMT('c'); //$this->_engine->getDateObj(); $this->Database = $this->_engine->Database; }
public function __actionIndex() { $sections_post = @$_POST['sections']; if (empty($this->_driver)) { $this->_driver = $this->_Parent->ExtensionManager->create('section_schemas'); } if (@isset($_POST['action']['save'])) { $blueprint = new contentBlueprintsDatasources(); $sm = new SectionManager($this->_Parent); $sections = $sm->fetch(); foreach ($sections as $section) { $file = DATASOURCES . '/data.section_schema_' . str_replace('-', '_', $section->_data['handle']) . '.php'; General::deleteFile($file); if (in_array($section->_data['handle'], $sections_post)) { $dsShell = file_get_contents(TEMPLATE . '/datasource.tpl'); $dsShell = str_replace("require_once(TOOLKIT . '/class.datasource.php');", "require_once(TOOLKIT . '/class.datasource.php');\n\trequire_once(TOOLKIT . '/class.sectionmanager.php');\n\trequire_once(TOOLKIT . '/class.fieldmanager.php');\n\trequire_once(TOOLKIT . '/class.entrymanager.php');", $dsShell); $dsShell = str_replace('<!-- CLASS NAME -->', 'section_schema_' . str_replace('-', '_', $section->_data['handle']), $dsShell); $dsShell = str_replace('<!-- FILTERS -->', '', $dsShell); $dsShell = str_replace('<!-- INCLUDED ELEMENTS -->', '', $dsShell); $dsShell = str_replace('<!-- DS DEPENDANCY LIST -->', '""', $dsShell); $params['rootelement'] = 'section-schema'; $blueprint->__injectVarList($dsShell, $params); $about = array('name' => 'Section Schema: ' . $section->_data['name'], 'version' => '1.0', 'release date' => DateTimeObj::getGMT('c'), 'author name' => $this->_Parent->Author->getFullName(), 'author website' => URL, 'author email' => $this->_Parent->Author->get('email')); $blueprint->__injectAboutInformation($dsShell, $about); $dsShell = str_replace('<!-- SOURCE -->', $section->_data['id'], $dsShell); $dsShell = str_replace('return true;', 'return false;', $dsShell); $dsShell = str_replace('<!-- GRAB -->', "\$extension = \$this->_Parent->ExtensionManager->create('section_schemas');" . self::CRLF . "\t\t\t\t\$extension->getSectionSchema(\$result, \$this->getSource());", $dsShell); $dsShell = str_replace('<!-- EXTRAS -->', '', $dsShell); if (!is_writable(dirname($file)) || !($write = General::writeFile($file, $dsShell, $this->_Parent->Configuration->get('write_mode', 'file')))) { $this->pageAlert(__('Failed to write data sources to <code>%s</code>. Please check permissions.', array(DATASOURCES)), Alert::ERROR); } else { $this->pageAlert('Section Schema data sources saved.', Alert::SUCCESS); } } } } }
public function grab(&$param_pool = NULL) { $result = new XMLElement($this->dsParamROOTELEMENT); $param_output = array(); $filters = array(); if (!empty($this->dsParamSECTIONS)) { $filters['item_type'] = $this->dsParamSECTIONS; } else { $filters['item_type'] = 'REGEXP "[[:digit:]]+"'; } if (!empty($this->dsParamACTIONS)) { $filters['action_type'] = $this->dsParamACTIONS; } // Fetch the activity $activities = Tracker::fetchActivities($filters, $this->dsParamLIMIT, 0, $this->dsParamSORT, $this->dsParamORDER); // Build the XML foreach ($activities as $activity) { // Capture the section and entry ID for output params $param_output[$activity['item_type']][] = $activity['item_id']; // Break the fallback description into useful bits $activity['fallback_description'] = explode(':::', $activity['fallback_description']); // Build the <activity> element $item = new XMLElement('activity', NULL, array('type' => $activity['action_type'], 'entry-id' => $activity['item_id'])); // Append Section info $item->appendChild(new XMLElement('section', $activity['fallback_description'][1], array('id' => $activity['item_type']))); // Append Author info $item->appendChild(new XMLElement('author', $activity['fallback_username'], array('id' => $activity['user_id']))); // Append Date info $item->appendChild(new XMLElement('date', DateTimeObj::get('Y-m-d', strtotime($activity['timestamp'] . ' GMT')), array('time' => DateTimeObj::get('H:i', strtotime($activity['timestamp'] . ' GMT')), 'weekday' => DateTimeObj::get('N', strtotime($activity['timestamp'] . ' GMT'))))); $result->appendChild($item); } // Build output params foreach ($param_output as $section => $ids) { $param_pool['ds-' . $this->dsParamROOTELEMENT . '-' . $section] = implode(', ', $ids); } return $result; }
public function generate() { if ($this->_useTemplate !== false) { $template = $this->viewDir . '/' . (empty($this->_useTemplate) ? $this->_getTemplate($this->_type, $this->_function) : $this->_useTemplate . '.xsl'); if (file_exists($template)) { $current_path = explode(dirname($_SERVER['SCRIPT_NAME']), $_SERVER['REQUEST_URI'], 2); $current_path = '/' . ltrim(end($current_path), '/'); $params = array('today' => DateTimeObj::get('Y-m-d'), 'current-time' => DateTimeObj::get('H:i'), 'this-year' => DateTimeObj::get('Y'), 'this-month' => DateTimeObj::get('m'), 'this-day' => DateTimeObj::get('d'), 'timezone' => DateTimeObj::get('P'), 'website-name' => Symphony::Configuration()->get('sitename', 'general'), 'root' => URL, 'symphony-url' => SYMPHONY_URL, 'workspace' => URL . '/workspace', 'current-page' => strtolower($this->_type) . ucfirst($this->_function), 'current-path' => $current_path, 'current-url' => URL . $current_path, 'upload-limit' => min($upload_size_php, $upload_size_sym), 'symphony-version' => Symphony::Configuration()->get('version', 'symphony')); $html = $this->_XSLTProc->process($this->_XML->generate(), file_get_contents($template), $params); if ($this->_XSLTProc->isErrors()) { $errstr = NULL; while (list($key, $val) = $this->_XSLTProc->getError()) { $errstr .= 'Line: ' . $val['line'] . ' - ' . $val['message'] . self::CRLF; } throw new SymphonyErrorPage(trim($errstr), NULL, 'xslt-error', array('proc' => clone $this->_XSLTProc)); } } else { Administration::instance()->errorPageNotFound(); } $this->Form = NULL; $this->Contents->setValue($html); } return parent::generate(); }
/** * Format date * * @param string $date * date * @param int $time * if set to 1, add time * @param string $scheme * date and time scheme * @param boolean $json * if set to true, return JSON formatted result * @return * returns either an array or JSON object with the status and the parsed value of the given date */ public static function formatDate($date = NULL, $time = 1, $scheme = NULL, $json = false) { // Get scheme if (empty($scheme)) { $scheme = __SYM_DATE_FORMAT__; if ($time == 1) { $scheme = __SYM_DATETIME_FORMAT__; } } // Get current time if (empty($date)) { $timestamp = time(); } elseif (ctype_digit($date)) { // Switch between milliseconds and seconds if (strlen($date) > 10) { $date = substr($date, 0, -3); } $timestamp = $date; } else { $timestamp = $date; } // Parse date $timestamp = DateTimeObj::format($timestamp, 'U', false); // Invalid date if ($timestamp === false) { $result = array('status' => 'invalid', 'date' => $date, 'timestamp' => false); } else { $result = array('status' => 'valid', 'date' => DateTimeObj::format($timestamp, $scheme, true, date_default_timezone_get()), 'timestamp' => number_format($timestamp * 1000, 0, '', '')); } // Return result if ($json) { return json_encode($result); } else { return $result; } }
protected function viewConfiguration() { /* ----------------------------------------------- * Populating fields array * ----------------------------------------------- */ $fields = isset($_POST['fields']) ? $_POST['fields'] : $this->_params['default-config']; /* ----------------------------------------------- * Welcome * ----------------------------------------------- */ $div = new XMLElement('div'); $div->appendChild(new XMLElement('h2', __('Find something sturdy to hold on to because things are about to get awesome.'))); $div->appendChild(new XMLElement('p', __('Think of this as a pre-game warm up. You know you’re going to kick-ass, so you’re savouring every moment before the show. Welcome to the Symphony install page.'))); $this->Form->appendChild($div); if (!empty($this->_params['errors'])) { $this->Form->appendChild(Widget::Error(new XMLElement('p'), __('Oops, a minor hurdle on your path to glory! There appears to be something wrong with the details entered below.'))); } /* ----------------------------------------------- * Environment settings * ----------------------------------------------- */ $fieldset = new XMLElement('fieldset'); $div = new XMLElement('div'); $this->__appendError(array('no-write-permission-root', 'no-write-permission-workspace'), $div); if ($div->getNumberOfChildren() > 0) { $fieldset->appendChild($div); $this->Form->appendChild($fieldset); } /* ----------------------------------------------- * Website & Locale settings * ----------------------------------------------- */ $Environment = new XMLElement('fieldset'); $Environment->appendChild(new XMLElement('legend', __('Website Preferences'))); $label = Widget::Label(__('Name'), Widget::Input('fields[general][sitename]', $fields['general']['sitename'])); $this->__appendError(array('general-no-sitename'), $label); $Environment->appendChild($label); $label = Widget::Label(__('Admin Path'), Widget::Input('fields[symphony][admin-path]', $fields['symphony']['admin-path'])); $this->__appendError(array('no-symphony-path'), $label); $Environment->appendChild($label); $Fieldset = new XMLElement('fieldset', null, array('class' => 'frame')); $Fieldset->appendChild(new XMLElement('legend', __('Date and Time'))); $Fieldset->appendChild(new XMLElement('p', __('Customise how Date and Time values are displayed throughout the Administration interface.'))); // Timezones $options = DateTimeObj::getTimezonesSelectOptions(isset($fields['region']['timezone']) && !empty($fields['region']['timezone']) ? $fields['region']['timezone'] : date_default_timezone_get()); $Fieldset->appendChild(Widget::Label(__('Region'), Widget::Select('fields[region][timezone]', $options))); // Date formats $options = DateTimeObj::getDateFormatsSelectOptions($fields['region']['date_format']); $Fieldset->appendChild(Widget::Label(__('Date Format'), Widget::Select('fields[region][date_format]', $options))); // Time formats $options = DateTimeObj::getTimeFormatsSelectOptions($fields['region']['time_format']); $Fieldset->appendChild(Widget::Label(__('Time Format'), Widget::Select('fields[region][time_format]', $options))); $Environment->appendChild($Fieldset); $this->Form->appendChild($Environment); /* ----------------------------------------------- * Database settings * ----------------------------------------------- */ $Database = new XMLElement('fieldset'); $Database->appendChild(new XMLElement('legend', __('Database Connection'))); $Database->appendChild(new XMLElement('p', __('Please provide Symphony with access to a database.'))); // Database name $label = Widget::Label(__('Database'), Widget::Input('fields[database][db]', $fields['database']['db'])); $this->__appendError(array('database-incorrect-version', 'unknown-database'), $label); $Database->appendChild($label); // Database credentials $Div = new XMLElement('div', null, array('class' => 'two columns')); $Div->appendChild(Widget::Label(__('Username'), Widget::Input('fields[database][user]', $fields['database']['user']), 'column')); $Div->appendChild(Widget::Label(__('Password'), Widget::Input('fields[database][password]', $fields['database']['password'], 'password'), 'column')); $this->__appendError(array('database-invalid-credentials'), $Div); $Database->appendChild($Div); // Advanced configuration $Fieldset = new XMLElement('fieldset', null, array('class' => 'frame')); $Fieldset->appendChild(new XMLElement('legend', __('Advanced Configuration'))); $Fieldset->appendChild(new XMLElement('p', __('Leave these fields unless you are sure they need to be changed.'))); // Advanced configuration: Host, Port $Div = new XMLElement('div', null, array('class' => 'two columns')); $Div->appendChild(Widget::Label(__('Host'), Widget::Input('fields[database][host]', $fields['database']['host']), 'column')); $Div->appendChild(Widget::Label(__('Port'), Widget::Input('fields[database][port]', $fields['database']['port']), 'column')); $this->__appendError(array('no-database-connection'), $Div); $Fieldset->appendChild($Div); // Advanced configuration: Table Prefix $label = Widget::Label(__('Table Prefix'), Widget::Input('fields[database][tbl_prefix]', $fields['database']['tbl_prefix'])); $this->__appendError(array('database-table-prefix'), $label); $Fieldset->appendChild($label); $Database->appendChild($Fieldset); $this->Form->appendChild($Database); /* ----------------------------------------------- * Permission settings * ----------------------------------------------- */ $Permissions = new XMLElement('fieldset'); $Permissions->appendChild(new XMLElement('legend', __('Permission Settings'))); $Permissions->appendChild(new XMLElement('p', __('Set the permissions Symphony uses when saving files/directories.'))); $Div = new XMLElement('div', null, array('class' => 'two columns')); $Div->appendChild(Widget::Label(__('Files'), Widget::Input('fields[file][write_mode]', $fields['file']['write_mode']), 'column')); $Div->appendChild(Widget::Label(__('Directories'), Widget::Input('fields[directory][write_mode]', $fields['directory']['write_mode']), 'column')); $Permissions->appendChild($Div); $this->Form->appendChild($Permissions); /* ----------------------------------------------- * User settings * ----------------------------------------------- */ $User = new XMLElement('fieldset'); $User->appendChild(new XMLElement('legend', __('User Information'))); $User->appendChild(new XMLElement('p', __('Once installation is complete, you will be able to log in to the Symphony admin area with these user details.'))); // Username $label = Widget::Label(__('Username'), Widget::Input('fields[user][username]', $fields['user']['username'])); $this->__appendError(array('user-no-username'), $label); $User->appendChild($label); // Password $Div = new XMLElement('div', null, array('class' => 'two columns')); $Div->appendChild(Widget::Label(__('Password'), Widget::Input('fields[user][password]', $fields['user']['password'], 'password'), 'column')); $Div->appendChild(Widget::Label(__('Confirm Password'), Widget::Input('fields[user][confirm-password]', $fields['user']['confirm-password'], 'password'), 'column')); $this->__appendError(array('user-no-password', 'user-password-mismatch'), $Div); $User->appendChild($Div); // Personal information $Fieldset = new XMLElement('fieldset', null, array('class' => 'frame')); $Fieldset->appendChild(new XMLElement('legend', __('Personal Information'))); $Fieldset->appendChild(new XMLElement('p', __('Please add the following personal details for this user.'))); // Personal information: First Name, Last Name $Div = new XMLElement('div', null, array('class' => 'two columns')); $Div->appendChild(Widget::Label(__('First Name'), Widget::Input('fields[user][firstname]', $fields['user']['firstname']), 'column')); $Div->appendChild(Widget::Label(__('Last Name'), Widget::Input('fields[user][lastname]', $fields['user']['lastname']), 'column')); $this->__appendError(array('user-no-name'), $Div); $Fieldset->appendChild($Div); // Personal information: Email Address $label = Widget::Label(__('Email Address'), Widget::Input('fields[user][email]', $fields['user']['email'])); $this->__appendError(array('user-invalid-email'), $label); $Fieldset->appendChild($label); $User->appendChild($Fieldset); $this->Form->appendChild($User); /* ----------------------------------------------- * Submit area * ----------------------------------------------- */ $this->Form->appendChild(new XMLElement('h2', __('Install Symphony'))); $this->Form->appendChild(new XMLElement('p', __('The installation process goes by really quickly. Make sure to take a deep breath before you press that sweet button.', array('<code>' . basename(INSTALL_URL) . '</code>')))); $Submit = new XMLElement('div', null, array('class' => 'submit')); $Submit->appendChild(Widget::Input('lang', Lang::get(), 'hidden')); $Submit->appendChild(Widget::Input('action[install]', __('Install Symphony'), 'submit')); $this->Form->appendChild($Submit); }
public function login($username, $password, $isHash = false) { if (strlen(trim($username)) > 0 && strlen(trim($password)) > 0) { if (!$isHash) { $password = md5($password); } $result = Symphony::Database()->query("\n\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\tu.id\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\ttbl_users AS u\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\tu.username = '******'\n\t\t\t\t\t\t\tAND u.password = '******'\n\t\t\t\t\t\tLIMIT 1\n\t\t\t\t\t", array($username, $password)); if ($result->valid()) { $this->_user_id = $result->current()->id; $this->User = User::load($this->_user_id); $this->Cookie->set('username', $username); $this->Cookie->set('pass', $password); Symphony::Database()->update('tbl_users', array('last_seen' => DateTimeObj::get('Y-m-d H:i:s')), array($this->_user_id), "`id` = '%d'"); $this->reloadLangFromUserPreference(); return true; } } return false; }
public function __viewEdit() { $this->setPageType('form'); $fields = array(); // Verify page exists: if ($this->_context[0] == 'edit') { if (!($page_id = $this->_context[1])) { redirect(URL . '/symphony/blueprints/pages/'); } $existing = $this->_Parent->Database->fetchRow(0, "\n\t\t\t\t\tSELECT\n\t\t\t\t\t\tp.*\n\t\t\t\t\tFROM\n\t\t\t\t\t\t`tbl_pages` AS p\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tp.id = '{$page_id}'\n\t\t\t\t\tLIMIT 1\n\t\t\t\t"); if (!$existing) { $this->_Parent->customError(E_USER_ERROR, __('Page not found'), __('The page you requested to edit does not exist.'), false, true, 'error', array('header' => 'HTTP/1.0 404 Not Found')); } } // Status message: if (isset($this->_context[2])) { $this->pageAlert(__('%s %s at %s. <a href="%s">Create another?</a> <a href="%s">View all %s</a>', array(__('Page'), $this->_context[2] == 'saved' ? 'updated' : 'created', DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), URL . '/symphony/blueprints/pages/new/', URL . '/symphony/blueprints/pages/', __('Pages'))), Alert::SUCCESS); } // Find values: if (isset($_POST['fields'])) { $fields = $_POST['fields']; } else { if ($this->_context[0] == 'edit') { $fields = $existing; $types = $this->_Parent->Database->fetchCol('type', "\n\t\t\t\t\tSELECT\n\t\t\t\t\t\tp.type\n\t\t\t\t\tFROM\n\t\t\t\t\t\t`tbl_pages_types` AS p\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tp.page_id = '{$page_id}'\n\t\t\t\t\tORDER BY\n\t\t\t\t\t\tp.type ASC\n\t\t\t\t"); $fields['type'] = @implode(', ', $types); $fields['data_sources'] = preg_split('/,/i', $fields['data_sources'], -1, PREG_SPLIT_NO_EMPTY); $fields['events'] = preg_split('/,/i', $fields['events'], -1, PREG_SPLIT_NO_EMPTY); } } $title = $fields['title']; if (trim($title) == '') { $title = $existing['title']; } $this->setTitle(__($title ? '%1$s – %2$s – %3$s' : '%1$s – %2$s', array(__('Symphony'), __('Pages'), $title))); $this->appendSubheading($title ? $title : __('Untitled')); // Title -------------------------------------------------------------- $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'settings'); $fieldset->appendChild(new XMLElement('legend', __('Page Settings'))); $label = Widget::Label(__('Title')); $label->appendChild(Widget::Input('fields[title]', General::sanitize($fields['title']))); if (isset($this->_errors['title'])) { $label = $this->wrapFormElementWithError($label, $this->_errors['title']); } $fieldset->appendChild($label); // Handle ------------------------------------------------------------- $group = new XMLElement('div'); $group->setAttribute('class', 'group'); $column = new XMLElement('div'); $label = Widget::Label(__('URL Handle')); $label->appendChild(Widget::Input('fields[handle]', $fields['handle'])); if (isset($this->_errors['handle'])) { $label = $this->wrapFormElementWithError($label, $this->_errors['handle']); } $column->appendChild($label); // Parent --------------------------------------------------------- $label = Widget::Label(__('Parent Page')); $pages = $this->_Parent->Database->fetch("\n\t\t\t\tSELECT\n\t\t\t\t\tp.*\n\t\t\t\tFROM\n\t\t\t\t\t`tbl_pages` AS p\n\t\t\t\tWHERE\n\t\t\t\t\tp.id != '{$page_id}'\n\t\t\t\tORDER BY\n\t\t\t\t\tp.title ASC\n\t\t\t"); $options = array(array('', false, '/')); if (is_array($pages) && !empty($pages)) { if (!function_exists('__compare_pages')) { function __compare_pages($a, $b) { return strnatcasecmp($a[2], $b[2]); } } foreach ($pages as $page) { $options[] = array($page['id'], $fields['parent'] == $page['id'], '/' . $this->_Parent->resolvePagePath($page['id'])); } usort($options, '__compare_pages'); } $label->appendChild(Widget::Select('fields[parent]', $options)); $column->appendChild($label); $group->appendChild($column); // Parameters --------------------------------------------------------- $column = new XMLElement('div'); $label = Widget::Label(__('URL Parameters')); $label->appendChild(Widget::Input('fields[params]', $fields['params'])); $column->appendChild($label); // Type ----------------------------------------------------------- $label = Widget::Label(__('Page Type')); $label->appendChild(Widget::Input('fields[type]', $fields['type'])); if (isset($this->_errors['type'])) { $label = $this->wrapFormElementWithError($label, $this->_errors['type']); } $column->appendChild($label); $tags = new XMLElement('ul'); $tags->setAttribute('class', 'tags'); if ($types = $this->__fetchAvailablePageTypes()) { foreach ($types as $type) { $tags->appendChild(new XMLElement('li', $type)); } } $column->appendChild($tags); $group->appendChild($column); $fieldset->appendChild($group); $this->Form->appendChild($fieldset); // Events ------------------------------------------------------------- $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'settings'); $fieldset->appendChild(new XMLElement('legend', __('Page Resources'))); $group = new XMLElement('div'); $group->setAttribute('class', 'group'); $label = Widget::Label(__('Events')); $manager = new EventManager($this->_Parent); $events = $manager->listAll(); $options = array(); if (is_array($events) && !empty($events)) { foreach ($events as $name => $about) { $options[] = array($name, @in_array($name, $fields['events']), $about['name']); } } $label->appendChild(Widget::Select('fields[events][]', $options, array('multiple' => 'multiple'))); $group->appendChild($label); // Data Sources ------------------------------------------------------- $label = Widget::Label(__('Data Sources')); $manager = new DatasourceManager($this->_Parent); $datasources = $manager->listAll(); $options = array(); if (is_array($datasources) && !empty($datasources)) { foreach ($datasources as $name => $about) { $options[] = array($name, @in_array($name, $fields['data_sources']), $about['name']); } } $label->appendChild(Widget::Select('fields[data_sources][]', $options, array('multiple' => 'multiple'))); $group->appendChild($label); $fieldset->appendChild($group); $this->Form->appendChild($fieldset); // Controls ----------------------------------------------------------- $div = new XMLElement('div'); $div->setAttribute('class', 'actions'); $div->appendChild(Widget::Input('action[save]', $this->_context[0] == 'edit' ? __('Save Changes') : __('Create Page'), 'submit', array('accesskey' => 's'))); if ($this->_context[0] == 'edit') { $button = new XMLElement('button', __('Delete')); $button->setAttributeArray(array('name' => 'action[delete]', 'class' => 'confirm delete', 'title' => __('Delete this page'))); $div->appendChild($button); } $this->Form->appendChild($div); }
public function execute(array &$param_pool = null) { $result = new XMLElement($this->dsParamROOTELEMENT); $this->dsParamURL = $this->parseParamURL($this->dsParamURL); if (isset($this->dsParamXPATH)) { $this->dsParamXPATH = $this->__processParametersInString($this->dsParamXPATH, $this->_env); } $stylesheet = new XMLElement('xsl:stylesheet'); $stylesheet->setAttributeArray(array('version' => '1.0', 'xmlns:xsl' => 'http://www.w3.org/1999/XSL/Transform')); $output = new XMLElement('xsl:output'); $output->setAttributeArray(array('method' => 'xml', 'version' => '1.0', 'encoding' => 'utf-8', 'indent' => 'yes', 'omit-xml-declaration' => 'yes')); $stylesheet->appendChild($output); $template = new XMLElement('xsl:template'); $template->setAttribute('match', '/'); $instruction = new XMLElement('xsl:copy-of'); // Namespaces if (isset($this->dsParamFILTERS) && is_array($this->dsParamFILTERS)) { foreach ($this->dsParamFILTERS as $name => $uri) { $instruction->setAttribute('xmlns' . ($name ? ":{$name}" : null), $uri); } } // XPath $instruction->setAttribute('select', $this->dsParamXPATH); $template->appendChild($instruction); $stylesheet->appendChild($template); $stylesheet->setIncludeHeader(true); $xsl = $stylesheet->generate(true); $cache_id = md5($this->dsParamURL . serialize($this->dsParamFILTERS) . $this->dsParamXPATH); $cache = new Cacheable(Symphony::Database()); $cachedData = $cache->read($cache_id); $writeToCache = false; $valid = true; $creation = DateTimeObj::get('c'); $timeout = isset($this->dsParamTIMEOUT) ? (int) max(1, $this->dsParamTIMEOUT) : 6; // Execute if the cache doesn't exist, or if it is old. if (!is_array($cachedData) || empty($cachedData) || time() - $cachedData['creation'] > $this->dsParamCACHE * 60) { if (Mutex::acquire($cache_id, $timeout, TMP)) { $ch = new Gateway(); $ch->init($this->dsParamURL); $ch->setopt('TIMEOUT', $timeout); $ch->setopt('HTTPHEADER', array('Accept: text/xml, */*')); $data = $ch->exec(); $info = $ch->getInfoLast(); Mutex::release($cache_id, TMP); $data = trim($data); $writeToCache = true; // Handle any response that is not a 200, or the content type does not include XML, plain or text if ((int) $info['http_code'] !== 200 || !preg_match('/(xml|plain|text)/i', $info['content_type'])) { $writeToCache = false; $result->setAttribute('valid', 'false'); // 28 is CURLE_OPERATION_TIMEOUTED if ($info['curl_error'] == 28) { $result->appendChild(new XMLElement('error', sprintf('Request timed out. %d second limit reached.', $timeout))); } else { $result->appendChild(new XMLElement('error', sprintf('Status code %d was returned. Content-type: %s', $info['http_code'], $info['content_type']))); } return $result; // Handle where there is `$data` } elseif (strlen($data) > 0) { // If the XML doesn't validate.. if (!General::validateXML($data, $errors, false, new XsltProcess())) { $writeToCache = false; } // If the `$data` is invalid, return a result explaining why if ($writeToCache === false) { $element = new XMLElement('errors'); $result->setAttribute('valid', 'false'); $result->appendChild(new XMLElement('error', __('Data returned is invalid.'))); foreach ($errors as $e) { if (strlen(trim($e['message'])) == 0) { continue; } $element->appendChild(new XMLElement('item', General::sanitize($e['message']))); } $result->appendChild($element); return $result; } // If `$data` is empty, set the `force_empty_result` to true. } elseif (strlen($data) == 0) { $this->_force_empty_result = true; } // Failed to acquire a lock } else { $result->appendChild(new XMLElement('error', __('The %s class failed to acquire a lock, check that %s exists and is writable.', array('<code>Mutex</code>', '<code>' . TMP . '</code>')))); } // The cache is good, use it! } else { $data = trim($cachedData['data']); $creation = DateTimeObj::get('c', $cachedData['creation']); } // If `$writeToCache` is set to false, invalidate the old cache if it existed. if (is_array($cachedData) && !empty($cachedData) && $writeToCache === false) { $data = trim($cachedData['data']); $valid = false; $creation = DateTimeObj::get('c', $cachedData['creation']); if (empty($data)) { $this->_force_empty_result = true; } } // If `force_empty_result` is false and `$result` is an instance of // XMLElement, build the `$result`. if (!$this->_force_empty_result && is_object($result)) { $proc = new XsltProcess(); $ret = $proc->process($data, $xsl); if ($proc->isErrors()) { $result->setAttribute('valid', 'false'); $error = new XMLElement('error', __('Transformed XML is invalid.')); $result->appendChild($error); $element = new XMLElement('errors'); foreach ($proc->getError() as $e) { if (strlen(trim($e['message'])) == 0) { continue; } $element->appendChild(new XMLElement('item', General::sanitize($e['message']))); } $result->appendChild($element); } elseif (strlen(trim($ret)) == 0) { $this->_force_empty_result = true; } else { if ($writeToCache) { $cache->write($cache_id, $data, $this->dsParamCACHE); } $result->setValue(PHP_EOL . str_repeat("\t", 2) . preg_replace('/([\\r\\n]+)/', "\$1\t", $ret)); $result->setAttribute('status', $valid === true ? 'fresh' : 'stale'); $result->setAttribute('creation', $creation); } } return $result; }
public function __viewEdit() { $section_id = $this->_context[1]; $sectionManager = new SectionManager($this->_Parent); if (!($section = $sectionManager->fetch($section_id))) { $this->_Parent->customError(E_USER_ERROR, __('Unknown Section'), __('The Section you are looking for could not be found.'), false, true); } $meta = $section->get(); $fieldManager = new FieldManager($this->_Parent); $types = array(); $formHasErrors = is_array($this->_errors) && !empty($this->_errors); if ($formHasErrors) { $this->pageAlert(__('An error occurred while processing this form. <a href="#error">See below for details.</a>'), Alert::ERROR); } if (isset($this->_context[2])) { switch ($this->_context[2]) { case 'saved': $this->pageAlert(__('Section updated at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all Sections</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), URL . '/symphony/blueprints/sections/new/', URL . '/symphony/blueprints/sections/')), Alert::SUCCESS); break; case 'created': $this->pageAlert(__('Section created at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all Sections</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), URL . '/symphony/blueprints/sections/new/', URL . '/symphony/blueprints/sections/')), Alert::SUCCESS); break; } } if (isset($_POST['fields'])) { $fields = array(); if (is_array($_POST['fields']) && !empty($_POST['fields'])) { foreach ($_POST['fields'] as $position => $data) { if ($fields[$position] = $fieldManager->create($data['type'])) { $fields[$position]->setArray($data); $fields[$position]->set('sortorder', $position); } } } } else { $fields = $fieldManager->fetch(NULL, $section_id); } $meta['subsection'] = $meta['subsection'] == 'yes' ? 1 : 0; $meta['entry_order'] = isset($meta['entry_order']) ? $meta['entry_order'] : 'date'; if (isset($_POST['meta'])) { $meta = $_POST['meta']; $meta['hidden'] = isset($meta['hidden']) ? 'yes' : 'no'; if ($meta['name'] == '') { $meta['name'] = $section->get('name'); } } $this->setPageType('form'); $this->setTitle(__('%1$s – %2$s – %3$s', array(__('Symphony'), __('Sections'), $meta['name']))); $this->appendSubheading($meta['name']); $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'settings'); $fieldset->appendChild(new XMLElement('legend', __('Essentials'))); $div = new XMLElement('div', NULL, array('class' => 'group')); $namediv = new XMLElement('div', NULL); $label = Widget::Label('Name'); $label->appendChild(Widget::Input('meta[name]', $meta['name'])); if (isset($this->_errors['name'])) { $namediv->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['name'])); } else { $namediv->appendChild($label); } $label = Widget::Label(); $input = Widget::Input('meta[hidden]', 'yes', 'checkbox', $meta['hidden'] == 'yes' ? array('checked' => 'checked') : NULL); $label->setValue(__('%s Hide this section from the Publish menu', array($input->generate(false)))); $namediv->appendChild($label); $div->appendChild($namediv); $navgroupdiv = new XMLElement('div', NULL); $sectionManager = new SectionManager($this->_Parent); $sections = $sectionManager->fetch(NULL, 'ASC', 'sortorder'); $label = Widget::Label(__('Navigation Group') . ' <i>' . __('Choose only one. Created if does not exist') . '</i>'); $label->appendChild(Widget::Input('meta[navigation_group]', $meta['navigation_group'])); if (isset($this->_errors['navigation_group'])) { $navgroupdiv->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['navigation_group'])); } else { $navgroupdiv->appendChild($label); } if (is_array($sections) && !empty($sections)) { $ul = new XMLElement('ul', NULL, array('class' => 'tags singular')); $groups = array(); foreach ($sections as $s) { if (in_array($s->get('navigation_group'), $groups)) { continue; } $ul->appendChild(new XMLElement('li', $s->get('navigation_group'))); $groups[] = $s->get('navigation_group'); } $navgroupdiv->appendChild($ul); } $div->appendChild($navgroupdiv); $fieldset->appendChild($div); $this->Form->appendChild($fieldset); $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'settings'); $fieldset->appendChild(new XMLElement('legend', __('Fields'))); $div = new XMLElement('div'); $h3 = new XMLElement('h3', __('Fields')); $h3->setAttribute('class', 'label'); $div->appendChild($h3); $ol = new XMLElement('ol'); $ol->setAttribute('id', 'fields-duplicator'); if (is_array($fields) && !empty($fields)) { foreach ($fields as $position => $field) { $wrapper = new XMLElement('li'); $field->set('sortorder', $position); $field->displaySettingsPanel($wrapper, isset($this->_errors[$position]) ? $this->_errors[$position] : NULL); $ol->appendChild($wrapper); } } foreach ($fieldManager->fetchTypes() as $type) { if ($type = $fieldManager->create($type)) { array_push($types, $type); } } uasort($types, create_function('$a, $b', 'return strnatcasecmp($a->_name, $b->_name);')); foreach ($types as $type) { $defaults = array(); $type->findDefaults($defaults); $type->setArray($defaults); $wrapper = new XMLElement('li'); $wrapper->setAttribute('class', 'template'); $type->set('sortorder', '-1'); $type->displaySettingsPanel($wrapper); $ol->appendChild($wrapper); } $div->appendChild($ol); $fieldset->appendChild($div); $this->Form->appendChild($fieldset); $div = new XMLElement('div'); $div->setAttribute('class', 'actions'); $div->appendChild(Widget::Input('action[save]', __('Save Changes'), 'submit', array('accesskey' => 's'))); $button = new XMLElement('button', __('Delete')); $button->setAttributeArray(array('name' => 'action[delete]', 'class' => 'confirm delete', 'title' => __('Delete this section'), 'type' => 'submit')); $div->appendChild($button); $this->Form->appendChild($div); }
public function buildFilterQuery($filter, &$joins, array &$where, Register $parameter_output = null) { $filter = $this->processFilter($filter); $db = Symphony::Database(); $statements = array(); if (!is_array($values)) { $values = array(); } // Exact matches: switch ($filter->type) { case 'is': $operator = '='; break; case 'is-not': $operator = '!='; break; case 'earlier-than': $operator = '>'; break; case 'earlier-than-or-equal': $operator = '>='; break; case 'later-than': $operator = '<'; break; case 'later-than-or-equal': $operator = '<='; break; } if (empty($this->last_handle)) { $this->join_handle = $this->buildFilterJoin($joins); } $handle = $this->join_handle; $value = DataSource::replaceParametersInString(trim($filter->value), $parameter_output); if ($filter->gmt == 'yes') { $value = strtotime($value); } else { $value = DateTimeObj::fromGMT($value); } $value = date('Y-m-d H:i:s', $value); $statements[] = $db->prepareQuery("'%s' {$operator} {$handle}.value", array($value)); if (empty($statements)) { return true; } if ($filter_join == DataSource::FILTER_OR) { $statement = "(\n\t" . implode("\n\tOR ", $statements) . "\n)"; } else { $statement = "(\n\t" . implode("\n\tAND ", $statements) . "\n)"; } $where[] = $statement; return true; }
/** * This function determines whether an there is a currently logged in * Author for Symphony by using the `$Cookie`'s username * and password. If an Author is found, they will be logged in, otherwise * the `$Cookie` will be destroyed. * * @see core.Cookie#expire() */ public function isLoggedIn() { // Ensures that we're in the real world.. Also reduces three queries from database // We must return true otherwise exceptions are not shown if (is_null(self::$_instance)) { return true; } if ($this->Author) { return true; } else { $username = self::Database()->cleanValue($this->Cookie->get('username')); $password = self::Database()->cleanValue($this->Cookie->get('pass')); if (strlen(trim($username)) > 0 && strlen(trim($password)) > 0) { $author = AuthorManager::fetch('id', 'ASC', 1, null, sprintf("\n\t\t\t\t\t\t\t`username` = '%s'\n\t\t\t\t\t\t", $username)); if (!empty($author) && Cryptography::compare($password, current($author)->get('password'), true)) { $this->Author = current($author); self::Database()->update(array('last_seen' => DateTimeObj::get('Y-m-d H:i:s')), 'tbl_authors', sprintf(" `id` = %d", $this->Author->get('id'))); // Only set custom author language in the backend if (class_exists('Administration')) { Lang::set($this->Author->get('language')); } return true; } } $this->Cookie->expire(); return false; } }
public function sendBatch($pauth) { if ($this->getPAuth() != $pauth) { $this->setStatus('error'); throw new EmailNewsletterException('Incorrect Process Auth used. This usually means there is more than one process running. Aborting.'); } $this->_completed = explode(', ', $this->getCompletedRecipientGroups()); $recipients = $this->_getRecipients($this->limit); if (count($recipients) > 0) { try { $template = $this->getTemplate(); $sender = $this->getSender(); $about = $sender->about(); $additional_headers = $sender->additional_headers; if (is_array($about['smtp'])) { $email = Email::create('smtp'); $email->setSenderName($about['smtp']['from_name']); $email->setSenderEmailAddress($about['smtp']['from_address']); $email->setHost($about['smtp']['host']); $email->setPort($about['smtp']['port']); $email->setSecure($about['smtp']['secure']); if ($about['smtp']['auth'] == 1) { $email->setAuth(true); $email->setUser($about['smtp']['username']); $email->setPass($about['smtp']['password']); } } elseif (is_array($about['amazon_ses'])) { $email = Email::create('amazon_ses'); $email->setSenderName($about['amazon_ses']['from_name']); $email->setSenderEmailAddress($about['amazon_ses']['from_address']); $email->setAwsKey($about['amazon_ses']['aws_key']); $email->setAwsSecretKey($about['amazon_ses']['aws_secret_key']); $email->setFallback($about['amazon_ses']['fallback']); $email->setReturnPath($about['amazon_ses']['return_path']); } elseif (is_array($about['sendmail'])) { $email = Email::create('sendmail'); $email->setSenderName($about['sendmail']['from_name']); $email->setSenderEmailAddress($about['sendmail']['from_address']); } else { throw new EmailNewsletterException('Currently only sendmail and SMTP are supported. This will be fixed when the API supports it.'); } } catch (Exception $e) { file_put_contents(DOCROOT . '/manifest/newsletter-log.txt', '[' . DateTimeObj::get('Y/m/d H:i:s') . '] newsletter-id: ' . $this->getId() . ' - ' . $e->getMessage() . "\r\n", FILE_APPEND); return false; } $email->openConnection(); foreach ($recipients as $recipient) { try { /** * @delegate PreEmailGenerate */ Symphony::ExtensionManager()->notifyMembers('PreEmailGenerate', '/extension/email_newsletter_manager/', array('newsletter' => &$this, 'email' => &$email, 'template' => &$template, 'recipient' => &$recipient)); $email->setRecipients(array($recipient['name'] => $recipient['email'])); $template->recipients = '"' . $recipient['name'] . '" <' . $recipient['email'] . '>'; $template->addParams(array('etm-recipient' => $recipient['email'])); $email->setReplyToName($about['reply-to-name']); $template->reply_to_name = $about['reply-to-name']; $template->addParams(array('etm-reply-to-name' => $about['reply-to-name'])); $email->setReplyToEmailAddress($about['reply-to-email']); $template->reply_to_email_address = $about['reply-to-email']; $template->addParams(array('etm-reply-to-email-address' => $about['reply-to-email'])); if (!empty($additional_headers)) { foreach ($additional_headers as $name => $body) { $email->appendHeaderField($name, $body); } } $template->addParams(array('enm-newsletter-id' => $this->getId())); // add root and workspace parameters $pseudo_root = $this->getPseudoRoot(); $template->addParams(array('root' => !empty($pseudo_root) ? $pseudo_root : NULL, 'workspace' => !empty($pseudo_root) ? $pseudo_root . '/workspace' : NULL)); $xml = $template->processDatasources(); $template->setXML($xml->generate()); $content = $template->render(); if (empty($content)) { throw new EmailNewsletterException("ETM template could not be rendered"); } if (!empty($content['subject'])) { $email->subject = $content['subject']; } else { throw new EmailNewsletterException("Can not send emails without a subject"); } if (isset($content['plain'])) { $email->text_plain = $content['plain']; } if (isset($content['html'])) { $email->text_html = $content['html']; } /** * @delegate PreEmailSend */ Symphony::ExtensionManager()->notifyMembers('PreEmailSend', '/extension/email_newsletter_manager/', array('newsletter' => &$this, 'email' => &$email, 'template' => &$template, 'recipient' => $recipient)); $email->send(); /** * @delegate PostEmailSend */ Symphony::ExtensionManager()->notifyMembers('PostEmailSend', '/extension/email_newsletter_manager/', array('newsletter' => &$this, 'email' => &$email, 'template' => &$template, 'recipient' => $recipient)); $this->_markRecipient($recipient['email'], 'sent'); } catch (Exception $e) { file_put_contents(DOCROOT . '/manifest/newsletter-log.txt', '[' . DateTimeObj::get('Y/m/d H:i:s') . '] newsletter-id: ' . $this->getId() . ' - ' . $e->getMessage() . "\r\n", FILE_APPEND); $this->_markRecipient($recipient['email'], 'failed'); continue; } } $email->closeConnection(); } //To prevent timing problems, the completed recipient groups should only be marked as complete when the emails are actually sent. Symphony::Database()->update(array('completed_recipients' => implode(', ', $this->_completed)), 'tbl_email_newsletters', 'id = ' . $this->getId()); if (count($recipients) == 0) { Symphony::Database()->query('DROP TABLE IF EXISTS `tbl_tmp_email_newsletters_sent_' . $this->getId() . '`'); $this->setStatus('completed'); Symphony::Database()->update(array('completed_on' => date('Y-m-d H:i:s', time())), 'tbl_email_newsletters', 'id = ' . $this->getId()); return 'completed'; } return 'sent'; }
function __formAction() { $fields = $_POST['fields']; $this->_errors = array(); if (trim($fields['name']) == '') { $this->_errors['name'] = __('This is a required field'); } if ($fields['source'] == 'static_xml') { if (trim($fields['static_xml']) == '') { $this->_errors['static_xml'] = __('This is a required field'); } else { $xml_errors = NULL; include_once TOOLKIT . '/class.xsltprocess.php'; General::validateXML($fields['static_xml'], $xml_errors, false, new XsltProcess()); if (!empty($xml_errors)) { $this->_errors['static_xml'] = __('XML is invalid'); } } } elseif ($fields['source'] == 'dynamic_xml') { if (trim($fields['dynamic_xml']['url']) == '') { $this->_errors['dynamic_xml']['url'] = __('This is a required field'); } if (trim($fields['dynamic_xml']['xpath']) == '') { $this->_errors['dynamic_xml']['xpath'] = __('This is a required field'); } if (!is_numeric($fields['dynamic_xml']['cache'])) { $this->_errors['dynamic_xml']['cache'] = __('Must be a valid number'); } elseif ($fields['dynamic_xml']['cache'] < 1) { $this->_errors['dynamic_xml']['cache'] = __('Must be greater than zero'); } } else { if ($fields['source'] != 'navigation') { if (strlen(trim($fields['max_records'])) == 0 || is_numeric($fields['max_records']) && $fields['max_records'] < 1) { $this->_errors['max_records'] = __('A result limit must be set'); } elseif (!self::__isValidPageString($fields['max_records'])) { $this->_errors['max_records'] = __('Must be a valid number or parameter'); } if (strlen(trim($fields['page_number'])) == 0 || is_numeric($fields['page_number']) && $fields['page_number'] < 1) { $this->_errors['page_number'] = __('A page number must be set'); } elseif (!self::__isValidPageString($fields['page_number'])) { $this->_errors['page_number'] = __('Must be a valid number or parameter'); } } } $classname = Lang::createHandle($fields['name'], NULL, '_', false, true, array('@^[^a-z]+@i' => '', '/[^\\w-\\.]/i' => '')); $rootelement = str_replace('_', '-', $classname); $file = DATASOURCES . '/data.' . $classname . '.php'; $isDuplicate = false; $queueForDeletion = NULL; if ($this->_context[0] == 'new' && @is_file($file)) { $isDuplicate = true; } elseif ($this->_context[0] == 'edit') { $existing_handle = $this->_context[1]; if ($classname != $existing_handle && @is_file($file)) { $isDuplicate = true; } elseif ($classname != $existing_handle) { $queueForDeletion = DATASOURCES . '/data.' . $existing_handle . '.php'; } } ##Duplicate if ($isDuplicate) { $this->_errors['name'] = __('A Data source with the name <code>%s</code> name already exists', array($classname)); } if (empty($this->_errors)) { $dsShell = file_get_contents(TEMPLATE . '/datasource.tpl'); //$oDate = $this->_Parent->getDateObj(); $params = array('rootelement' => $rootelement); $about = array('name' => $fields['name'], 'version' => '1.0', 'release date' => DateTimeObj::getGMT('c'), 'author name' => $this->_Parent->Author->getFullName(), 'author website' => URL, 'author email' => $this->_Parent->Author->get('email')); $source = $fields['source']; $filter = NULL; $elements = NULL; switch ($source) { case 'authors': $filters = $fields['filter']['author']; $elements = $fields['xml_elements']; $params['order'] = $fields['order']; $params['limit'] = $fields['max_records']; $params['redirectonempty'] = isset($fields['redirect_on_empty']) ? 'yes' : 'no'; $params['requiredparam'] = $fields['required_url_param']; $params['paramoutput'] = $fields['param']; $params['sort'] = $fields['sort']; $params['startpage'] = $fields['page_number']; $dsShell = str_replace('<!-- GRAB -->', "include(TOOLKIT . '/data-sources/datasource.author.php');", $dsShell); break; case 'navigation': $filters = $fields['filter']['navigation']; $params['order'] = $fields['order']; $params['redirectonempty'] = isset($fields['redirect_on_empty']) ? 'yes' : 'no'; $params['requiredparam'] = $fields['required_url_param']; $dsShell = str_replace('<!-- GRAB -->', "include(TOOLKIT . '/data-sources/datasource.navigation.php');", $dsShell); break; case 'dynamic_xml': $namespaces = $fields['dynamic_xml']['namespace']; $filters = array(); for ($ii = 0; $ii < count($namespaces['name']); $ii++) { $filters[$namespaces['name'][$ii]] = $namespaces['uri'][$ii]; } $params['url'] = $fields['dynamic_xml']['url']; $params['xpath'] = $fields['dynamic_xml']['xpath']; $params['cache'] = $fields['dynamic_xml']['cache']; $dsShell = str_replace('<!-- GRAB -->', "include(TOOLKIT . '/data-sources/datasource.dynamic_xml.php');", $dsShell); break; case 'static_xml': $value = sprintf('$result = "%s";', addslashes($fields['static_xml'])); $dsShell = str_replace('<!-- GRAB -->', $value, $dsShell); break; default: $elements = $fields['xml_elements']; if (is_array($fields['filter']) && !empty($fields['filter'])) { $filters = array(); foreach ($fields['filter'] as $f) { foreach ($f as $key => $val) { $filters[$key] = $val; } } } $params['order'] = $fields['order']; $params['group'] = $fields['group']; $params['limit'] = $fields['max_records']; $params['redirectonempty'] = isset($fields['redirect_on_empty']) ? 'yes' : 'no'; $params['requiredparam'] = $fields['required_url_param']; $params['paramoutput'] = $fields['param']; $params['sort'] = $fields['sort']; $params['startpage'] = $fields['page_number']; $params['htmlencode'] = $fields['html_encode']; $dsShell = str_replace('<!-- GRAB -->', "include(TOOLKIT . '/data-sources/datasource.section.php');", $dsShell); break; } $this->__injectVarList($dsShell, $params); $this->__injectAboutInformation($dsShell, $about); $this->__injectIncludedElements($dsShell, $elements); $this->__injectFilters($dsShell, $filters); $dsShell = str_replace('<!-- CLASS NAME -->', $classname, $dsShell); $dsShell = str_replace('<!-- SOURCE -->', $source, $dsShell); if (preg_match_all('@{(\\$ds-[^}]+)}@i', $dsShell, $matches)) { $dependancies = array(); foreach ($matches[1] as $match) { if (preg_match_all('/(\\$ds-[^:]+)/i', $match, $inner_matches)) { $dependancies = array_merge($dependancies, $inner_matches[1]); } } $dependancies = General::array_remove_duplicates($dependancies); $dsShell = str_replace('<!-- DS DEPENDANCY LIST -->', "'" . implode("', '", $dependancies) . "'", $dsShell); } ## Remove left over placeholders $dsShell = preg_replace(array('/<!--[\\w ]++-->/', '/(\\r\\n){2,}/', '/(\\t+[\\r\\n]){2,}/'), '', $dsShell); ##Write the file if (!is_writable(dirname($file)) || !($write = General::writeFile($file, $dsShell, $this->_Parent->Configuration->get('write_mode', 'file')))) { $this->pageAlert(__('Failed to write Data source to <code>%s</code>. Please check permissions.', array(DATASOURCES)), Alert::ERROR); } else { if ($queueForDeletion) { General::deleteFile($queueForDeletion); ## Update pages that use this DS $sql = "SELECT * FROM `tbl_pages` WHERE `data_sources` REGEXP '[[:<:]]" . $existing_handle . "[[:>:]]' "; $pages = $this->_Parent->Database->fetch($sql); if (is_array($pages) && !empty($pages)) { foreach ($pages as $page) { $page['data_sources'] = preg_replace('/\\b' . $existing_handle . '\\b/i', $classname, $page['data_sources']); $this->_Parent->Database->update($page, 'tbl_pages', "`id` = '" . $page['id'] . "'"); } } } ### TODO: Fix me ### # Delegate: Create # Description: After saving the datasource, the file path is provided and an array # of variables set by the editor #$ExtensionManager->notifyMembers('Create', getCurrentPage(), array('file' => $file, 'defines' => $defines, 'var' => $var)); redirect(URL . '/symphony/blueprints/datasources/edit/' . $classname . '/' . ($this->_context[0] == 'new' ? 'created' : 'saved') . '/'); } } }