当前位置: 首页>>代码示例>>PHP>>正文


PHP Symphony::Author方法代码示例

本文整理汇总了PHP中Symphony::Author方法的典型用法代码示例。如果您正苦于以下问题:PHP Symphony::Author方法的具体用法?PHP Symphony::Author怎么用?PHP Symphony::Author使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symphony的用法示例。


在下文中一共展示了Symphony::Author方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: start

 public function start()
 {
     if (!is_object($this->getTemplate())) {
         $this->setStatus('error-template');
         return;
     }
     if (!is_object($this->getSender())) {
         $this->setStatus('error-sender');
         return;
     }
     if (empty($this->_recipientgroups)) {
         $this->setStatus('error-recipients');
         return;
     }
     // Never start if the newsletter is sending or completed
     if ($this->getStatus() == 'sending' || $this->getStatus() == 'completed') {
         return;
     }
     $this->generatePAuth();
     Symphony::Database()->query("CREATE TABLE IF NOT EXISTS `tbl_tmp_email_newsletters_sent_" . $this->getId() . "` (\n          `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n          `email` varchar(255),\n          `result` varchar(255),\n          PRIMARY KEY (`id`),\n          KEY `email` (`email`)\n        ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
     Symphony::Database()->query('DELETE FROM `tbl_tmp_email_newsletters_sent_' . $this->getId() . '` WHERE `result` = \'idle\'');
     $this->setStatus('sending');
     $author_id = 0;
     if (Symphony::Engine() instanceof Administration) {
         $author_id = Symphony::Author()->get('id');
     } elseif (Symphony::Engine() instanceof Frontend && Symphony::ExtensionManager()->fetchStatus('members') == EXTENSION_ENABLED) {
         $Members = Symphony::ExtensionManager()->create('members');
         $author_id = $Members->getMemberDriver()->getMemberID();
     }
     Symphony::Database()->update(array('started_on' => date('Y-m-d H:i:s', time()), 'started_by' => $author_id), 'tbl_email_newsletters', 'id = ' . $this->getId());
     EmailBackgroundProcess::spawnProcess($this->getId(), $this->getPAuth());
 }
开发者ID:MST-SymphonyCMS,项目名称:email_newsletter_manager,代码行数:32,代码来源:class.emailnewsletter.php

示例2: __trigger

 protected function __trigger()
 {
     // Cookies only show up on page refresh.
     // This flag helps in making sure the correct XML is being set
     $loggedin = false;
     if (isset($_REQUEST['action']['login'])) {
         $username = $_REQUEST['username'];
         $password = $_REQUEST['password'];
         $loggedin = Frontend::instance()->login($username, $password);
     } else {
         $loggedin = Frontend::instance()->isLoggedIn();
     }
     if ($loggedin) {
         $result = new XMLElement('login-info');
         $result->setAttribute('logged-in', 'true');
         $author = null;
         if (is_callable(array('Symphony', 'Author'))) {
             $author = Symphony::Author();
         } else {
             $author = Frontend::instance()->Author;
         }
         $result->setAttributeArray(array('id' => $author->get('id'), 'user-type' => $author->get('user_type'), 'primary-account' => $author->get('primary')));
         $fields = array('name' => new XMLElement('name', $author->getFullName()), 'username' => new XMLElement('username', $author->get('username')), 'email' => new XMLElement('email', $author->get('email')));
         if ($author->isTokenActive()) {
             $fields['author-token'] = new XMLElement('author-token', $author->createAuthToken());
         }
         // Section
         if ($section = Symphony::Database()->fetchRow(0, "SELECT `id`, `handle`, `name` FROM `tbl_sections` WHERE `id` = '" . $author->get('default_area') . "' LIMIT 1")) {
             $default_area = new XMLElement('default-area', $section['name']);
             $default_area->setAttributeArray(array('id' => $section['id'], 'handle' => $section['handle'], 'type' => 'section'));
             $fields['default-area'] = $default_area;
         } else {
             $default_area = new XMLElement('default-area', $author->get('default_area'));
             $default_area->setAttribute('type', 'page');
             $fields['default-area'] = $default_area;
         }
         foreach ($fields as $f) {
             $result->appendChild($f);
         }
     } else {
         $result = new XMLElement('user');
         $result->setAttribute('logged-in', 'false');
     }
     // param output
     Frontend::Page()->_param['login'] = $loggedin ? 'yes' : 'no';
     Frontend::Page()->_param['login-filter'] = $loggedin ? 'yes,no' : 'yes';
     return $result;
 }
开发者ID:BloodBrother,项目名称:symphony-2-template,代码行数:48,代码来源:event.login.php

示例3: stopRestartNewsletter

 public function stopRestartNewsletter(&$context)
 {
     if (substr($_POST['action']['save'], 0, 12) == 'enm-restart:') {
         $vars = explode(":", $_POST['action']['save']);
         $field_id = $vars[1];
         $entry_id = $context['entry']->get('id');
         $data = $this->_getEntryData($field_id, $entry_id);
         if (!empty($data)) {
             try {
                 $newsletter = EmailNewsletterManager::create($data['newsletter_id']);
                 $array = array('template' => is_object($newsletter->getTemplate()) ? $newsletter->getTemplate()->getHandle() : NULL, 'sender' => is_object($newsletter->getSender()) ? $newsletter->getSender()->getHandle() : NULL, 'recipients' => implode(', ', $newsletter->getRecipientGroups(false, true)));
                 $news = EmailNewsletterManager::save($array);
                 $context['entry']->setData($field_id, array('author_id' => Symphony::Author()->get('id'), 'entry_id' => $entry_id, 'newsletter_id' => $news->getId()));
                 //$news->start();
             } catch (Exception $e) {
                 Administration::instance()->throwCustomError(__('Error restarting email newsletter'), __($e->getMessage()));
             }
         }
     }
     if (substr($_POST['action']['save'], 0, 9) == 'enm-stop:') {
         $vars = explode(":", $_POST['action']['save']);
         $field_id = $vars[1];
         $entry_id = $context['entry']->get('id');
         $data = $this->_getEntryData($field_id, $entry_id);
         if (!empty($data)) {
             try {
                 $newsletter = EmailNewsletterManager::create($data['newsletter_id']);
                 $newsletter->stop();
             } catch (Exception $e) {
                 Administration::instance()->throwCustomError(__('Error stopping email newsletter'), __($e->getMessage()));
             }
         }
     }
     if (substr($_POST['action']['save'], 0, 10) == 'enm-pause:') {
         $vars = explode(":", $_POST['action']['save']);
         $field_id = $vars[1];
         $entry_id = $context['entry']->get('id');
         $data = $this->_getEntryData($field_id, $entry_id);
         if (!empty($data)) {
             try {
                 $newsletter = EmailNewsletterManager::create($data['newsletter_id']);
                 $newsletter->pause();
             } catch (Exception $e) {
                 Administration::instance()->throwCustomError(__('Error pausing email newsletter'), __($e->getMessage()));
             }
         }
     }
 }
开发者ID:MST-SymphonyCMS,项目名称:email_newsletter_manager,代码行数:48,代码来源:extension.driver.php

示例4: appendAlert

 public function appendAlert($context)
 {
     if (!is_null($context['alert'])) {
         return;
     }
     // https://github.com/symphonycms/symphony-2/wiki/Migration-Guide-to-2.5-for-Developers#properties
     if (is_callable(array('Symphony', 'Author'))) {
         $author = Symphony::Author();
     } else {
         $author = Administration::instance()->Author;
     }
     if ($this->__filesNewer() && ($author instanceof Author && $author->isDeveloper()) ? true : false) {
         $files = implode(__(" and "), array_map('__', array_map('ucfirst', $this->__filesNewer())));
         if (count($this->__filesNewer()) == 1) {
             $message = __('The database file for your %s is newer than your last sync. ', array($files));
         } else {
             $message = __('The database files for both your %s is newer than your last sync. ', array($files));
         }
         $message .= __('It\'s recommended to <a href="%s">sync your database now.</a>', array(URL . '/symphony/system/preferences/#dump-actions'));
         Administration::instance()->Page->pageAlert($message);
     }
 }
开发者ID:nils-werner,项目名称:dump_db,代码行数:22,代码来源:extension.driver.php

示例5: getAuthorID

 public function getAuthorID()
 {
     return Symphony::Author()->get('id');
 }
开发者ID:symphonists,项目名称:tracker,代码行数:4,代码来源:extension.driver.php

示例6: view

 public function view()
 {
     if (isset($this->_context[0]) && in_array(strlen($this->_context[0]), array(6, 8, 16))) {
         if (!$this->__loginFromToken($this->_context[0])) {
             if (Administration::instance()->isLoggedIn()) {
                 // Redirect to the Author's profile. RE: #1801
                 redirect(SYMPHONY_URL . '/system/authors/edit/' . Symphony::Author()->get('id') . '/reset-password/');
             }
         }
     }
     $this->Form = Widget::Form(SYMPHONY_URL . '/login/', 'post');
     $this->Form->setAttribute('class', 'frame');
     $this->Form->appendChild(new XMLElement('h1', Symphony::Configuration()->get('sitename', 'general')));
     $fieldset = new XMLElement('fieldset');
     // Display retrieve password UI
     if (isset($this->_context[0]) && $this->_context[0] == 'retrieve-password') {
         $this->Form->setAttribute('action', SYMPHONY_URL . '/login/retrieve-password/');
         // Successful reset
         if (isset($this->_email_sent) && $this->_email_sent) {
             $fieldset->appendChild(new XMLElement('p', __('An email containing a customised login link has been sent to %s. It will expire in 2 hours.', array('<code>' . $this->_email_sent_to . '</code>'))));
             $fieldset->appendChild(new XMLElement('p', Widget::Anchor(__('Login'), SYMPHONY_URL . '/login/', null)));
             $this->Form->appendChild($fieldset);
             // Default, get the email address for reset
         } else {
             $fieldset->appendChild(new XMLElement('p', __('Enter your email address or username to be sent further instructions for logging in.')));
             $label = Widget::Label(__('Email Address or Username'));
             $label->appendChild(Widget::Input('email', General::sanitize($_POST['email']), 'text', array('autofocus' => 'autofocus')));
             if (isset($this->_email_sent) && !$this->_email_sent) {
                 $label = Widget::Error($label, __('Unfortunately no account was found using this information.'));
             } else {
                 // Email exception
                 if (isset($this->_email_error) && $this->_email_error) {
                     $label = Widget::Error($label, __('This Symphony instance has not been set up for emailing, %s', array('<code>' . $this->_email_error . '</code>')));
                 }
             }
             $fieldset->appendChild($label);
             $this->Form->appendChild($fieldset);
             $div = new XMLElement('div', null, array('class' => 'actions'));
             $div->appendChild(new XMLElement('button', __('Send Email'), array('name' => 'action[reset]', 'type' => 'submit', 'accesskey' => 's')));
             $div->appendChild(Widget::Anchor(__('Cancel'), SYMPHONY_URL . '/login/', null, 'action-link'));
             $this->Form->appendChild($div);
         }
         // Normal login
     } else {
         $fieldset->appendChild(new XMLElement('legend', __('Login'), array('role' => 'heading')));
         // Display error message
         if ($this->failedLoginAttempt) {
             $p = new XMLElement('p');
             $p = Widget::Error($p, __('The login details provided are incorrect.'));
             $fieldset->appendChild($p);
         }
         // Username
         $label = Widget::Label(__('Username'));
         $username = Widget::Input('username', isset($_POST['username']) ? General::sanitize($_POST['username']) : null);
         if (!$this->failedLoginAttempt) {
             $username->setAttribute('autofocus', 'autofocus');
         }
         $label->appendChild($username);
         if (isset($_POST['action'], $_POST['action']['login']) && empty($_POST['username'])) {
             $username->setAttribute('autofocus', 'autofocus');
             $label = Widget::Error($label, __('No username was entered.'));
         }
         $fieldset->appendChild($label);
         // Password
         $label = Widget::Label(__('Password'));
         $password = Widget::Input('password', null, 'password');
         $label->appendChild($password);
         if (isset($_POST['action'], $_POST['action']['login']) && empty($_POST['password'])) {
             $password->setAttribute('autofocus', 'autofocus');
             $label = Widget::Error($label, __('No password was entered.'));
         } elseif ($this->failedLoginAttempt) {
             $password->setAttribute('autofocus', 'autofocus');
         }
         $fieldset->appendChild($label);
         $this->Form->appendChild($fieldset);
         // Actions
         $div = new XMLElement('div', null, array('class' => 'actions'));
         $div->appendChild(new XMLElement('button', __('Login'), array('name' => 'action[login]', 'type' => 'submit', 'accesskey' => 'l')));
         $div->appendChild(Widget::Anchor(__('Retrieve password?'), SYMPHONY_URL . '/login/retrieve-password/', null, 'action-link'));
         $this->Form->appendChild($div);
         if (isset($this->_context['redirect'])) {
             $this->Form->appendChild(Widget::Input('redirect', SYMPHONY_URL . General::sanitize($this->_context['redirect']), 'hidden'));
         }
     }
     $this->Body->appendChild($this->Form);
 }
开发者ID:valery,项目名称:symphony-2,代码行数:86,代码来源:content.login.php

示例7: __canAccessAlerts

 /**
  * This function determines whether an administrative alert can be
  * displayed on the current page. It ensures that the page exists,
  * and the user is logged in and a developer
  *
  * @since Symphony 2.2
  * @return boolean
  */
 private function __canAccessAlerts()
 {
     if ($this->Page instanceof AdministrationPage && $this->isLoggedIn() && Symphony::Author()->isDeveloper()) {
         return true;
     }
     return false;
 }
开发者ID:valery,项目名称:symphony-2,代码行数:15,代码来源:class.administration.php

示例8: __formAction

 public function __formAction()
 {
     $fields = $_POST['fields'];
     $this->_errors = array();
     $providers = Symphony::ExtensionManager()->getProvidersOf(iProvider::DATASOURCE);
     $providerClass = null;
     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 (is_numeric($fields['source'])) {
         if (strlen(trim($fields['max_records'])) == 0 || is_numeric($fields['max_records']) && $fields['max_records'] < 1) {
             if ($fields['paginate_results'] === 'yes') {
                 $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) {
             if ($fields['paginate_results'] === 'yes') {
                 $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');
         }
         // See if a Provided Datasource is saved
     } elseif (!empty($providers)) {
         foreach ($providers as $providerClass => $provider) {
             if ($fields['source'] == call_user_func(array($providerClass, 'getSource'))) {
                 call_user_func_array(array($providerClass, 'validate'), array(&$fields, &$this->_errors));
                 break;
             }
             unset($providerClass);
         }
     }
     $classname = Lang::createHandle($fields['name'], 255, '_', false, true, array('@^[^a-z\\d]+@i' => '', '/[^\\w-\\.]/i' => ''));
     $rootelement = str_replace('_', '-', $classname);
     // Check to make sure the classname is not empty after handlisation.
     if (empty($classname) && !isset($this->_errors['name'])) {
         $this->_errors['name'] = __('Please ensure name contains at least one Latin-based character.', array($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 %s already exists', array('<code>' . $classname . '</code>'));
     }
     if (empty($this->_errors)) {
         $filters = array();
         $elements = null;
         $source = $fields['source'];
         $params = array('rootelement' => $rootelement);
         $about = array('name' => $fields['name'], 'version' => 'Symphony ' . Symphony::Configuration()->get('version', 'symphony'), 'release date' => DateTimeObj::getGMT('c'), 'author name' => Symphony::Author()->getFullName(), 'author website' => URL, 'author email' => Symphony::Author()->get('email'));
         // If there is a provider, get their template
         if ($providerClass) {
             $dsShell = file_get_contents(call_user_func(array($providerClass, 'getTemplate')));
         } else {
             $dsShell = file_get_contents($this->getTemplate('blueprints.datasource'));
         }
         // Author metadata
         self::injectAboutInformation($dsShell, $about);
         // Do dependencies, the template file must have <!-- CLASS NAME -->
         $dsShell = str_replace('<!-- CLASS NAME -->', $classname, $dsShell);
         // If there is a provider, let them do the prepartion work
         if ($providerClass) {
             $dsShell = call_user_func(array($providerClass, 'prepare'), $fields, $params, $dsShell);
         } else {
             switch ($source) {
                 case 'authors':
                     $extends = 'AuthorDatasource';
                     if (isset($fields['filter']['author'])) {
                         $filters = $fields['filter']['author'];
                     }
                     $elements = $fields['xml_elements'];
                     $params['order'] = $fields['order'];
                     $params['redirectonempty'] = $fields['redirect_on_empty'];
                     $params['redirectonforbidden'] = $fields['redirect_on_forbidden'];
                     $params['redirectonrequired'] = $fields['redirect_on_required'];
                     $params['requiredparam'] = trim($fields['required_url_param']);
//.........这里部分代码省略.........
开发者ID:jurajkapsz,项目名称:symphony-2,代码行数:101,代码来源:content.blueprintsdatasources.php

示例9: __viewEdit

 public function __viewEdit()
 {
     if (!($section_id = SectionManager::fetchIDFromHandle($this->_context['section_handle']))) {
         Administration::instance()->throwCustomError(__('The Section, %s, could not be found.', array('<code>' . $this->_context['section_handle'] . '</code>')), __('Unknown Section'), Page::HTTP_STATUS_NOT_FOUND);
     }
     $section = SectionManager::fetch($section_id);
     $entry_id = intval($this->_context['entry_id']);
     $base = '/publish/' . $this->_context['section_handle'] . '/';
     $new_link = $base . 'new/';
     $filter_link = $base;
     EntryManager::setFetchSorting('id', 'DESC');
     if (!($existingEntry = EntryManager::fetch($entry_id))) {
         Administration::instance()->throwCustomError(__('Unknown Entry'), __('The Entry, %s, could not be found.', array($entry_id)), Page::HTTP_STATUS_NOT_FOUND);
     }
     $existingEntry = $existingEntry[0];
     // If there is post data floating around, due to errors, create an entry object
     if (isset($_POST['fields'])) {
         $fields = $_POST['fields'];
         $entry = EntryManager::create();
         $entry->set('id', $entry_id);
         $entry->set('author_id', $existingEntry->get('author_id'));
         $entry->set('section_id', $existingEntry->get('section_id'));
         $entry->set('creation_date', $existingEntry->get('creation_date'));
         $entry->set('modification_date', $existingEntry->get('modification_date'));
         $entry->setDataFromPost($fields, $errors, true);
         // Editing an entry, so need to create some various objects
     } else {
         $entry = $existingEntry;
         $fields = array();
         if (!$section) {
             $section = SectionManager::fetch($entry->get('section_id'));
         }
     }
     /**
      * Just prior to rendering of an Entry edit form.
      *
      * @delegate EntryPreRender
      * @param string $context
      * '/publish/edit/'
      * @param Section $section
      * @param Entry $entry
      * @param array $fields
      */
     Symphony::ExtensionManager()->notifyMembers('EntryPreRender', '/publish/edit/', array('section' => $section, 'entry' => &$entry, 'fields' => $fields));
     // Iterate over the `prepopulate` parameters to build a URL
     // to remember this state for Create New, View all Entries and
     // Breadcrumb links. If `prepopulate` doesn't exist, this will
     // just use the standard pages (ie. no filtering)
     if (isset($_REQUEST['prepopulate'])) {
         $new_link .= $this->getPrepopulateString();
         $filter_link .= $this->getFilterString();
     }
     if (isset($this->_context['flag'])) {
         // These flags are only relevant if there are no errors
         if (empty($this->_errors)) {
             $time = Widget::Time();
             switch ($this->_context['flag']) {
                 case 'saved':
                     $message = __('Entry updated at %s.', array($time->generate()));
                     break;
                 case 'created':
                     $message = __('Entry created at %s.', array($time->generate()));
             }
             $this->pageAlert($message . ' <a href="' . SYMPHONY_URL . $new_link . '" accesskey="c">' . __('Create another?') . '</a> <a href="' . SYMPHONY_URL . $filter_link . '" accesskey="a">' . __('View all Entries') . '</a>', Alert::SUCCESS);
         }
     }
     // Determine the page title
     $field_id = Symphony::Database()->fetchVar('id', 0, sprintf("\n            SELECT `id`\n            FROM `tbl_fields`\n            WHERE `parent_section` = %d\n            ORDER BY `sortorder` LIMIT 1", $section->get('id')));
     if (!is_null($field_id)) {
         $field = FieldManager::fetch($field_id);
     }
     if ($field) {
         $title = $field->prepareReadableValue($existingEntry->getData($field->get('id')), $entry_id, true);
     } else {
         $title = '';
     }
     if (trim($title) == '') {
         $title = __('Untitled');
     }
     // Check if there is a field to prepopulate
     if (isset($_REQUEST['prepopulate'])) {
         foreach ($_REQUEST['prepopulate'] as $field_id => $value) {
             $this->Form->prependChild(Widget::Input("prepopulate[{$field_id}]", rawurlencode($value), 'hidden'));
         }
     }
     $this->setPageType('form');
     $this->Form->setAttribute('enctype', 'multipart/form-data');
     $this->setTitle(__('%1$s &ndash; %2$s &ndash; %3$s', array($title, $section->get('name'), __('Symphony'))));
     $sidebar_fields = $section->fetchFields(null, 'sidebar');
     $main_fields = $section->fetchFields(null, 'main');
     if (!empty($sidebar_fields) && !empty($main_fields)) {
         $this->Form->setAttribute('class', 'two columns');
     } else {
         $this->Form->setAttribute('class', 'columns');
     }
     // Only show the Edit Section button if the Author is a developer. #938 ^BA
     if (Symphony::Author()->isDeveloper()) {
         $this->appendSubheading($title, Widget::Anchor(__('Edit Section'), SYMPHONY_URL . '/blueprints/sections/edit/' . $section_id . '/', __('Edit Section Configuration'), 'button'));
     } else {
         $this->appendSubheading($title);
//.........这里部分代码省略.........
开发者ID:rc1,项目名称:WebAppsWithCmsStartHere,代码行数:101,代码来源:content.publish.php

示例10: save

 public function save()
 {
     $about = array();
     if ($this->_context[0] && !is_object($this->formatter)) {
         $this->formatter = TextformatterManager::create($this->_context[0]);
     }
     if (is_object($this->formatter)) {
         $about = TextformatterManager::about($this->_context[0]);
     }
     $fields = $_POST['fields'];
     $driverAbout = ExtensionManager::about('templatedtextformatters');
     $types = $this->_driver->listTypes();
     if (strlen(trim($fields['name'])) < 1) {
         $this->_errors['name'] = __('You have to specify name for text formatter');
         return;
     }
     if ($about['templatedtextformatters-type'] && $about['templatedtextformatters-type'] != $fields['type']) {
         $this->_errors['type'] = __('Changing type of already existing formatter is not allowed');
         return;
     }
     if (!$fields['type'] || !is_array($types[$fields['type']]) || !isset($types[$fields['type']]['path'])) {
         $this->_errors['type'] = __('There is no <code>%s</code> type available', array($fields['type']));
         return;
     }
     $tplfile = $types[$fields['type']]['path'] . '/formatter.' . $fields['type'] . '.tpl';
     if (!@is_file($tplfile)) {
         $this->_errors['type'] = __('Wrong type of text formatter');
         return;
     }
     $classname = 'ttf_' . Lang::createHandle(trim($fields['name']), NULL, '_', false, true, array('@^[^a-z]+@i' => '', '/[^\\w-\\.]/i' => ''));
     $file = TEXTFORMATTERS . '/formatter.' . $classname . '.php';
     $isDuplicate = false;
     $queueForDeletion = NULL;
     if (!$about['handle'] && @is_file($file)) {
         $isDuplicate = true;
     } else {
         if ($about['handle']) {
             if ($classname != $about['handle'] && @is_file($file)) {
                 $isDuplicate = true;
             } elseif ($classname != $about['handle']) {
                 $queueForDeletion = TEXTFORMATTERS . '/formatter.' . $about['handle'] . '.php';
             }
         }
     }
     // Duplicate
     if ($isDuplicate) {
         $this->_errors['name'] = __('Text formatter with the name <code>%s</code> already exists', array($classname));
     }
     if (!empty($this->_errors)) {
         return;
     }
     $description = trim($fields['description']);
     if (empty($description)) {
         $description = __('N/A');
     }
     // https://github.com/symphonycms/symphony-2/wiki/Migration-Guide-to-2.5-for-Developers#properties
     if (is_callable(array('Symphony', 'Author'))) {
         $author = Symphony::Author();
     } else {
         $author = Administration::instance()->Author;
     }
     $tokens = array('___' . $fields['type'] . '/* CLASS NAME */' => $classname, '/* NAME */' => preg_replace('/[^\\w\\s\\.-_\\&\\;]/i', '', trim($fields['name'])), '/* AUTHOR NAME */' => self::cleanupString($author->getFullName()), '/* AUTHOR WEBSITE */' => self::cleanupString(URL), '/* AUTHOR EMAIL */' => self::cleanupString($author->get('email')), '/* RELEASE DATE */' => DateTimeObj::getGMT('c'), '/* DESCRIPTION */' => self::cleanupString($description), '/* TEMPLATEDTEXTFORMATTERS VERSION */' => $driverAbout['version'], '/* TEMPLATEDTEXTFORMATTERS TYPE */' => $fields['type']);
     if (!is_object($this->formatter)) {
         include_once $tplfile;
         $temp = 'formatter___' . $fields['type'];
         $temp = new $temp();
         if (method_exists($temp, 'ttf_tokens')) {
             $tokens = array_merge($tokens, $temp->ttf_tokens());
         }
     } else {
         if (method_exists($this->formatter, 'ttf_tokens')) {
             $tokens = array_merge($tokens, $this->formatter->ttf_tokens());
         }
     }
     $ttfShell = file_get_contents($tplfile);
     $ttfShell = str_replace(array_keys($tokens), $tokens, $ttfShell);
     $ttfShell = str_replace('/* CLASS NAME */', $classname, $ttfShell);
     // Write the file
     if (!is_writable(dirname($file)) || !($write = General::writeFile($file, $ttfShell, Symphony::Configuration()->get('write_mode', 'file')))) {
         $this->pageAlert(__('Failed to write Text Formatter source to <code>%s</code>. Please check permissions.', array($file)), Alert::ERROR);
     } else {
         if ($queueForDeletion || !$about['name']) {
             if ($queueForDeletion) {
                 General::deleteFile($queueForDeletion);
             }
             // TODO: Find a way to make formatted fields update their content
             $_SESSION['templatedtextformatters-alert'] = 'created';
             redirect(URL . '/symphony/extension/templatedtextformatters/edit/' . $classname);
         } else {
             // Update current data
             $_SESSION['templatedtextformatters-alert'] = 'saved';
             $_POST['fields']['name'] = $tokens['/* NAME */'];
             $_POST['fields']['description'] = $tokens['/* DESCRIPTION */'];
         }
     }
 }
开发者ID:ahwayakchih,项目名称:templatedtextformatters,代码行数:96,代码来源:content.edit.php

示例11: __appendAlert

 /**
  * Append notice that the site is currently in maintenance mode offering a link
  * to switch to live mode if no other alert is set.
  *
  * @param array $context
  *  delegate context
  */
 public function __appendAlert($context)
 {
     $author = null;
     if (is_callable(array('Symphony', 'Author'))) {
         $author = Symphony::Author();
     } else {
         $author = Administration::instance()->Author;
     }
     // Site in maintenance mode
     if (Symphony::Configuration()->get('enabled', 'maintenance_mode') == 'yes') {
         if ($author != null && $author->isDeveloper()) {
             Administration::instance()->Page->pageAlert(__('This site is currently in maintenance mode.') . ' <a href="' . SYMPHONY_URL . '/system/preferences/?action=toggle-maintenance-mode&amp;redirect=' . getCurrentPage() . '">' . __('Restore?') . '</a>', Alert::NOTICE);
         } else {
             Administration::instance()->Page->pageAlert(__('This site is currently in maintenance mode.'), Alert::NOTICE);
         }
     }
 }
开发者ID:hotdoy,项目名称:EDclock,代码行数:24,代码来源:extension.driver.php

示例12: processRawFieldData

 /**
  * Prepares field values for database.
  */
 public function processRawFieldData($data, &$status, &$message = NULL, $simulate = false, $entry_id = NULL)
 {
     $status = self::__OK__;
     if (empty($data)) {
         return NULL;
     }
     $entry_data = array();
     if ($entry_id) {
         // grab existing entry data
         $entry_data = Symphony::Database()->fetchRow(0, sprintf("SELECT *\n                 FROM `tbl_entries_data_%d`\n                 WHERE `entry_id` = %d\n                 LIMIT 1", $this->get('id'), $entry_id));
     }
     if (!is_array($data['recipient_groups'])) {
         $data['recipient_groups'] = array();
     }
     // Prevent DOM hacking: When saving newsletter data, we __must__
     // check if properties are valid (i.e. configured in the section
     // editor); otherwise it would be super-simple to send with
     // unwanted or invalid properties;
     $template = NULL;
     if (in_array($data['template'], explode(',', $this->get('templates')))) {
         $template = $data['template'];
     }
     $sender = NULL;
     if (in_array($data['sender'], explode(',', $this->get('senders')))) {
         $sender = $data['sender'];
     }
     $recipient_groups = array();
     foreach ($data['recipient_groups'] as $group) {
         if (in_array($group, explode(',', $this->get('recipient_groups')))) {
             $recipient_groups[] = $group;
         }
     }
     // save
     $author_id = 0;
     if (Symphony::Engine() instanceof Administration) {
         $author_id = Symphony::Author()->get('id');
     } elseif (Symphony::Engine() instanceof Frontend && Symphony::ExtensionManager()->fetchStatus('members') == EXTENSION_ENABLED) {
         $Members = Symphony::ExtensionManager()->create('members');
         $author_id = $Members->getMemberDriver()->getMemberID();
     }
     $newsletter = EmailNewsletterManager::save(array('id' => $entry_data['newsletter_id'], 'template' => $template, 'recipients' => implode(', ', $recipient_groups), 'sender' => $sender, 'pseudo_root' => URL));
     $result = array('author_id' => $author_id, 'newsletter_id' => $newsletter->getId());
     return $result;
 }
开发者ID:MST-SymphonyCMS,项目名称:email_newsletter_manager,代码行数:47,代码来源:field.email_newsletter_manager.php

示例13: appendUserLinks

 /**
  * Creates the Symphony footer for an Administration page. By default
  * this includes the installed Symphony version and the currently logged
  * in Author. A delegate is provided to allow extensions to manipulate the
  * footer HTML, which is an XMLElement of a `<ul>` element.
  * Since Symphony 2.3, it no longer uses the `AddElementToFooter` delegate.
  */
 public function appendUserLinks()
 {
     $ul = new XMLElement('ul', null, array('id' => 'session'));
     $li = new XMLElement('li');
     $li->appendChild(Widget::Anchor(Symphony::Author()->getFullName(), SYMPHONY_URL . '/system/authors/edit/' . Symphony::Author()->get('id') . '/'));
     $ul->appendChild($li);
     $li = new XMLElement('li');
     $li->appendChild(Widget::Anchor(__('Log out'), SYMPHONY_URL . '/logout/', null, null, null, array('accesskey' => 'l')));
     $ul->appendChild($li);
     $this->Header->appendChild($ul);
 }
开发者ID:roshinebagha,项目名称:Symphony-Test,代码行数:18,代码来源:class.administrationpage.php

示例14: isLoggedIn

 /**
  * 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 static 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 (self::$Author) {
         return true;
     } else {
         $username = self::Database()->cleanValue(self::$Cookie->get('username'));
         $password = self::Database()->cleanValue(self::$Cookie->get('pass'));
         if (strlen(trim($username)) > 0 && strlen(trim($password)) > 0) {
             $author = AuthorManager::fetch('id', 'ASC', 1, null, sprintf("`username` = '%s'", $username));
             if (!empty($author) && Cryptography::compare($password, current($author)->get('password'), true)) {
                 self::$Author = current($author);
                 self::Database()->update(array('last_seen' => DateTimeObj::get('Y-m-d H:i:s')), 'tbl_authors', sprintf(" `id` = %d", self::$Author->get('id')));
                 // Only set custom author language in the backend
                 if (class_exists('Administration')) {
                     Lang::set(self::$Author->get('language'));
                 }
                 return true;
             }
         }
         return false;
     }
 }
开发者ID:valery,项目名称:symphony-2,代码行数:35,代码来源:class.symphony.php

示例15: __viewIndex

 public function __viewIndex()
 {
     $this->setPageType('form');
     $this->setTitle(__('Symphony') . ' &ndash; ' . __('Dashboard'));
     $this->addScriptToHead(URL . '/extensions/dashboard/assets/jquery-ui-1.11.4.custom.min.js', 29421);
     $this->addStylesheetToHead(URL . '/extensions/dashboard/assets/dashboard.index.css', 'screen', 29422);
     $this->addScriptToHead(URL . '/extensions/dashboard/assets/dashboard.index.js', 29423);
     // https://github.com/symphonycms/symphony-2/wiki/Migration-Guide-to-2.5-for-Developers#properties
     $author = null;
     if (is_callable(array('Symphony', 'Author'))) {
         $author = Symphony::Author();
     } else {
         $author = Administration::instance()->Author;
     }
     // Add welcome message
     $hour = date('H');
     $welcome = __('Nice to meet you');
     if ($author->get('last_see') != NULL) {
         if ($hour < 10) {
             $welcome = __('Good morning');
         } elseif ($hour < 17) {
             $welcome = __('Welcome back');
         } else {
             $welcome = __('Good evening');
         }
     }
     $panel_types = array();
     /**
      * Ask panel extensions to list their panel types.
      *
      * @delegate DashboardPanelTypes
      * @param string $context
      * '/backend/'
      * @param array $types
      */
     Symphony::ExtensionManager()->notifyMembers('DashboardPanelTypes', '/backend/', array('types' => &$panel_types));
     if ($author->isDeveloper()) {
         $panel_types_options = array(array('', FALSE, __('New Panel')));
         natsort($panel_types);
         foreach ($panel_types as $handle => $name) {
             $panel_types_options[] = array($handle, false, $name);
         }
         $actions = array();
         $actions[] = Widget::Select('panel-type', $panel_types_options);
         $actions[] = Widget::Anchor(__('Enable Editing'), '#', __('Disable Editing'), 'edit-mode button');
     }
     $this->Form->setAttribute('class', 'two columns');
     $this->appendSubheading($welcome . ', ' . $author->get('first_name'), $actions);
     $this->insertDrawer(Widget::Drawer('dashboard', 'Dashboard', new XMLElement('span', ''), 'closed', time()), 'horizontal', FALSE);
     $container = new XMLElement('div', NULL, array('id' => 'dashboard'));
     $primary = new XMLElement('div', NULL, array('class' => 'primary column sortable-container'));
     $secondary = new XMLElement('div', NULL, array('class' => 'secondary column sortable-container'));
     $panels = Extension_Dashboard::getPanels();
     foreach ($panels as $p) {
         $html = Extension_Dashboard::buildPanelHTML($p);
         switch ($p['placement']) {
             case 'primary':
                 $primary->appendChild($html);
                 break;
             case 'secondary':
                 $secondary->appendChild($html);
                 break;
         }
     }
     $container->appendChild($primary);
     $container->appendChild($secondary);
     $this->Form->appendChild($container);
 }
开发者ID:korelogic,项目名称:dashboard,代码行数:68,代码来源:content.index.php


注:本文中的Symphony::Author方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。