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


PHP DateTimeObj::getGMT方法代码示例

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


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

示例1: processRawFieldData

 function processRawFieldData($data, &$status, $simulate = false, $entry_id = NULL)
 {
     $status = self::__OK__;
     $timestamp = NULL;
     if ($data != '') {
         $timestamp = strtotime($data);
     }
     return array('value' => DateTimeObj::get('c', $timestamp), 'local' => strtotime(DateTimeObj::get('c', $timestamp)), 'gmt' => strtotime(DateTimeObj::getGMT('c', $timestamp)));
 }
开发者ID:bauhouse,项目名称:sym-fluid960gs,代码行数:9,代码来源:field.date.php

示例2: write

 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;
 }
开发者ID:brendo,项目名称:symquery,代码行数:55,代码来源:class.symwrite.php

示例3: parseDate

 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;
 }
开发者ID:twiro,项目名称:system_date_fields,代码行数:11,代码来源:class.systemdate.php

示例4: processRawFieldData

 public function processRawFieldData($data, &$status, $simulate = false, $entry_id = NULL)
 {
     $status = self::__OK__;
     $timestamp = null;
     if (is_null($data) || $data == '') {
         if ($this->get('pre_populate') == 'yes') {
             $timestamp = strtotime(DateTimeObj::get(__SYM_DATETIME_FORMAT__, null));
         }
     } else {
         $timestamp = strtotime($data);
     }
     if (!is_null($timestamp)) {
         return array('value' => DateTimeObj::get('c', $timestamp), 'local' => strtotime(DateTimeObj::get('c', $timestamp)), 'gmt' => strtotime(DateTimeObj::getGMT('c', $timestamp)));
     }
     return array('value' => null, 'local' => null, 'gmt' => null);
 }
开发者ID:bauhouse,项目名称:sym-fluidgrids,代码行数:16,代码来源:field.date.php

示例5: __construct

 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();
 }
开发者ID:njmcgee,项目名称:njmcgee2,代码行数:17,代码来源:class.field.php

示例6: __construct

 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;
 }
开发者ID:bauhouse,项目名称:sym-spectrum,代码行数:21,代码来源:class.field.php

示例7: __actionIndex

 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);
                 }
             }
         }
     }
 }
开发者ID:bauhouse,项目名称:sym-extensions,代码行数:37,代码来源:content.list.php

示例8: loginFromToken

 /**
  * Symphony allows Authors to login via the use of tokens instead of
  * a username and password. A token is derived from concatenating the
  * Author's username and password and applying the sha1 hash to
  * it, from this, a portion of the hash is used as the token. This is a useful
  * feature often used when setting up other Authors accounts or if an
  * Author forgets their password.
  *
  * @param string $token
  *  The Author token, which is a portion of the hashed string concatenation
  *  of the Author's username and password
  * @return boolean
  *  True if the Author is logged in, false otherwise
  */
 public function loginFromToken($token)
 {
     $token = self::Database()->cleanValue($token);
     if (strlen(trim($token)) == 0) {
         return false;
     }
     if (strlen($token) == 6) {
         $row = self::Database()->fetchRow(0, sprintf("\n\t\t\t\t\t\tSELECT `a`.`id`, `a`.`username`, `a`.`password`\n\t\t\t\t\t\tFROM `tbl_authors` AS `a`, `tbl_forgotpass` AS `f`\n\t\t\t\t\t\tWHERE `a`.`id` = `f`.`author_id`\n\t\t\t\t\t\tAND `f`.`expiry` > '%s'\n\t\t\t\t\t\tAND `f`.`token` = '%s'\n\t\t\t\t\t\tLIMIT 1\n\t\t\t\t\t", DateTimeObj::getGMT('c'), $token));
         self::Database()->delete('tbl_forgotpass', " `token` = '{$token}' ");
     } else {
         $row = self::Database()->fetchRow(0, sprintf("SELECT `id`, `username`, `password`\n\t\t\t\t\tFROM `tbl_authors`\n\t\t\t\t\tWHERE SUBSTR(%s(CONCAT(`username`, `password`)), 1, 8) = '%s'\n\t\t\t\t\tAND `auth_token_active` = 'yes'\n\t\t\t\t\tLIMIT 1", 'SHA1', $token));
     }
     if ($row) {
         $this->Author = AuthorManager::fetchByID($row['id']);
         $this->Cookie->set('username', $row['username']);
         $this->Cookie->set('pass', $row['password']);
         self::Database()->update(array('last_seen' => DateTimeObj::getGMT('Y-m-d H:i:s')), 'tbl_authors', " `id` = '{$id}'");
         return true;
     }
     return false;
 }
开发者ID:readona,项目名称:symphonyno5,代码行数:35,代码来源:class.symphony.php

示例9: __actionNew

 public function __actionNew()
 {
     if (array_key_exists('save', $_POST['action']) || array_key_exists("done", $_POST['action'])) {
         $section_id = SectionManager::fetchIDFromHandle($this->_context['section_handle']);
         if (!($section = SectionManager::fetch($section_id))) {
             Administration::instance()->customError(__('Unknown Section'), __('The Section you are looking for, %s, could not be found.', array('<code>' . $this->_context['section_handle'] . '</code>')));
         }
         $entry =& EntryManager::create();
         $entry->set('section_id', $section_id);
         $entry->set('author_id', Administration::instance()->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'));
         $fields = $_POST['fields'];
         // Combine FILES and POST arrays, indexed by their custom field handles
         if (isset($_FILES['fields'])) {
             $filedata = General::processFilePostData($_FILES['fields']);
             foreach ($filedata as $handle => $data) {
                 if (!isset($fields[$handle])) {
                     $fields[$handle] = $data;
                 } elseif (isset($data['error']) && $data['error'] == 4) {
                     $fields['handle'] = NULL;
                 } else {
                     foreach ($data as $ii => $d) {
                         if (isset($d['error']) && $d['error'] == 4) {
                             $fields[$handle][$ii] = NULL;
                         } elseif (is_array($d) && !empty($d)) {
                             foreach ($d as $key => $val) {
                                 $fields[$handle][$ii][$key] = $val;
                             }
                         }
                     }
                 }
             }
         }
         // Initial checks to see if the Entry is ok
         if (__ENTRY_FIELD_ERROR__ == $entry->checkPostData($fields, $this->_errors)) {
             $this->pageAlert(__('Some errors were encountered while attempting to save.'), Alert::ERROR);
         } else {
             if (__ENTRY_OK__ != $entry->setDataFromPost($fields, $errors)) {
                 foreach ($errors as $field_id => $message) {
                     $this->pageAlert($message, Alert::ERROR);
                 }
             } else {
                 /**
                  * Just prior to creation of an Entry
                  *
                  * @delegate EntryPreCreate
                  * @param string $context
                  * '/publish/new/'
                  * @param Section $section
                  * @param Entry $entry
                  * @param array $fields
                  */
                 Symphony::ExtensionManager()->notifyMembers('EntryPreCreate', '/publish/new/', array('section' => $section, 'entry' => &$entry, 'fields' => &$fields));
                 // Check to see if the dancing was premature
                 if (!$entry->commit()) {
                     define_safe('__SYM_DB_INSERT_FAILED__', true);
                     $this->pageAlert(NULL, Alert::ERROR);
                 } else {
                     /**
                      * Creation of an Entry. New Entry object is provided.
                      *
                      * @delegate EntryPostCreate
                      * @param string $context
                      * '/publish/new/'
                      * @param Section $section
                      * @param Entry $entry
                      * @param array $fields
                      */
                     Symphony::ExtensionManager()->notifyMembers('EntryPostCreate', '/publish/new/', array('section' => $section, 'entry' => $entry, 'fields' => $fields));
                     $prepopulate_querystring = '';
                     if (isset($_POST['prepopulate'])) {
                         foreach ($_POST['prepopulate'] as $field_id => $value) {
                             $prepopulate_querystring .= sprintf("prepopulate[%s]=%s&", $field_id, rawurldecode($value));
                         }
                         $prepopulate_querystring = trim($prepopulate_querystring, '&');
                     }
                     redirect(sprintf('%s/publish/%s/edit/%d/created/%s', SYMPHONY_URL, $this->_context['section_handle'], $entry->get('id'), !empty($prepopulate_querystring) ? "?" . $prepopulate_querystring : NULL));
                 }
             }
         }
     }
 }
开发者ID:nickdunn,项目名称:elasticsearch-surfin-shakespeare,代码行数:83,代码来源:content.publish.php

示例10: action

 public function action()
 {
     if (isset($_POST['action'])) {
         $actionParts = array_keys($_POST['action']);
         $action = end($actionParts);
         // Login Attempted
         if ($action == 'login') {
             if (empty($_POST['username']) || empty($_POST['password']) || !Administration::instance()->login($_POST['username'], $_POST['password'])) {
                 /**
                  * A failed login attempt into the Symphony backend
                  *
                  * @delegate AuthorLoginFailure
                  * @since Symphony 2.2
                  * @param string $context
                  * '/login/'
                  * @param string $username
                  *  The username of the Author who attempted to login.
                  */
                 Symphony::ExtensionManager()->notifyMembers('AuthorLoginFailure', '/login/', array('username' => Symphony::Database()->cleanValue($_POST['username'])));
                 $this->failedLoginAttempt = true;
             } else {
                 /**
                  * A successful login attempt into the Symphony backend
                  *
                  * @delegate AuthorLoginSuccess
                  * @since Symphony 2.2
                  * @param string $context
                  * '/login/'
                  * @param string $username
                  *  The username of the Author who logged in.
                  */
                 Symphony::ExtensionManager()->notifyMembers('AuthorLoginSuccess', '/login/', array('username' => Symphony::Database()->cleanValue($_POST['username'])));
                 isset($_POST['redirect']) ? redirect($_POST['redirect']) : redirect(SYMPHONY_URL . '/');
             }
             // Reset of password requested
         } elseif ($action == 'reset') {
             $author = Symphony::Database()->fetchRow(0, sprintf("\n                        SELECT `id`, `email`, `first_name`\n                        FROM `tbl_authors`\n                        WHERE `email` = '%1\$s' OR `username` = '%1\$s'\n                    ", Symphony::Database()->cleanValue($_POST['email'])));
             if (!empty($author)) {
                 Symphony::Database()->delete('tbl_forgotpass', sprintf("\n                        `expiry` < %d", DateTimeObj::getGMT('c')));
                 if (!($token = Symphony::Database()->fetchVar('token', 0, "SELECT `token` FROM `tbl_forgotpass` WHERE `expiry` > '" . DateTimeObj::getGMT('c') . "' AND `author_id` = " . $author['id']))) {
                     // More secure password token generation
                     if (function_exists('openssl_random_pseudo_bytes')) {
                         $seed = openssl_random_pseudo_bytes(16);
                     } else {
                         $seed = mt_rand();
                     }
                     $token = substr(SHA1::hash($seed), 0, 16);
                     Symphony::Database()->insert(array('author_id' => $author['id'], 'token' => $token, 'expiry' => DateTimeObj::getGMT('c', time() + 120 * 60)), 'tbl_forgotpass');
                 }
                 try {
                     $email = Email::create();
                     $email->recipients = $author['email'];
                     $email->subject = __('New Symphony Account Password');
                     $email->text_plain = __('Hi %s,', array($author['first_name'])) . PHP_EOL . __('A new password has been requested for your account. Login using the following link, and change your password via the Authors area:') . PHP_EOL . PHP_EOL . '    ' . SYMPHONY_URL . "/login/{$token}/" . PHP_EOL . PHP_EOL . __('It will expire in 2 hours. If you did not ask for a new password, please disregard this email.') . PHP_EOL . PHP_EOL . __('Best Regards,') . PHP_EOL . __('The Symphony Team');
                     $email->send();
                     $this->_email_sent = true;
                     $this->_email_sent_to = $author['email'];
                     // Set this so we can display a customised message
                 } catch (Exception $e) {
                     $this->_email_error = General::unwrapCDATA($e->getMessage());
                     Symphony::Log()->pushExceptionToLog($e, true);
                 }
                 /**
                  * When a password reset has occurred and after the Password
                  * Reset email has been sent.
                  *
                  * @delegate AuthorPostPasswordResetSuccess
                  * @since Symphony 2.2
                  * @param string $context
                  * '/login/'
                  * @param integer $author_id
                  *  The ID of the Author who requested the password reset
                  */
                 Symphony::ExtensionManager()->notifyMembers('AuthorPostPasswordResetSuccess', '/login/', array('author_id' => $author['id']));
             } else {
                 /**
                  * When a password reset has been attempted, but Symphony doesn't
                  * recognise the credentials the user has given.
                  *
                  * @delegate AuthorPostPasswordResetFailure
                  * @since Symphony 2.2
                  * @param string $context
                  * '/login/'
                  * @param string $email
                  *  The sanitised Email of the Author who tried to request the password reset
                  */
                 Symphony::ExtensionManager()->notifyMembers('AuthorPostPasswordResetFailure', '/login/', array('email' => Symphony::Database()->cleanValue($_POST['email'])));
                 $this->_email_sent = false;
             }
         }
     }
 }
开发者ID:valery,项目名称:symphony-2,代码行数:92,代码来源:content.login.php

示例11: __formAction

    public function __formAction()
    {
        $fields = $_POST['fields'];
        $this->_errors = array();
        if (trim($fields['name']) == '') {
            $this->_errors['name'] = __('This is a required field');
        }
        if (trim($fields['source']) == '') {
            $this->_errors['source'] = __('This is a required field');
        }
        $filters = is_array($fields['filters']) ? $fields['filters'] : array();
        $classname = Lang::createHandle($fields['name'], NULL, '_', false, true, array('@^[^a-z]+@i' => '', '/[^\\w-\\.]/i' => ''));
        $rootelement = str_replace('_', '-', $classname);
        $file = EVENTS . '/event.' . $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 = EVENTS . '/event.' . $existing_handle . '.php';
            }
        }
        ##Duplicate
        if ($isDuplicate) {
            $this->_errors['name'] = __('An Event with the name <code>%s</code> name already exists', array($classname));
        }
        if (empty($this->_errors)) {
            $multiple = in_array('expect-multiple', $filters);
            $eventShell = file_get_contents(TEMPLATE . '/event.tpl');
            $about = array('name' => $fields['name'], 'version' => '1.0', 'release date' => DateTimeObj::getGMT('c'), 'author name' => Administration::instance()->Author->getFullName(), 'author website' => URL, 'author email' => Administration::instance()->Author->get('email'), 'trigger condition' => $rootelement);
            $source = $fields['source'];
            $filter = NULL;
            $elements = NULL;
            $this->__injectAboutInformation($eventShell, $about);
            $this->__injectFilters($eventShell, $filters);
            $documentation = NULL;
            $documentation_parts = array();
            $documentation_parts[] = new XMLElement('h3', __('Success and Failure XML Examples'));
            $documentation_parts[] = new XMLElement('p', __('When saved successfully, the following XML will be returned:'));
            if ($multiple) {
                $code = new XMLElement($rootelement);
                $entry = new XMLElement('entry', NULL, array('index' => '0', 'result' => 'success', 'type' => 'create | edit'));
                $entry->appendChild(new XMLElement('message', __('Entry [created | edited] successfully.')));
                $code->appendChild($entry);
            } else {
                $code = new XMLElement($rootelement, NULL, array('result' => 'success', 'type' => 'create | edit'));
                $code->appendChild(new XMLElement('message', __('Entry [created | edited] successfully.')));
            }
            $documentation_parts[] = self::processDocumentationCode($code);
            ###
            $documentation_parts[] = new XMLElement('p', __('When an error occurs during saving, due to either missing or invalid fields, the following XML will be returned') . ($multiple ? __(' (<b>Notice that it is possible to get mixtures of success and failure messages when using the "Allow Multiple" option</b>)') : NULL) . ':');
            if ($multiple) {
                $code = new XMLElement($rootelement);
                $entry = new XMLElement('entry', NULL, array('index' => '0', 'result' => 'error'));
                $entry->appendChild(new XMLElement('message', __('Entry encountered errors when saving.')));
                $entry->appendChild(new XMLElement('field-name', NULL, array('type' => 'invalid | missing')));
                $code->appendChild($entry);
                $entry = new XMLElement('entry', NULL, array('index' => '1', 'result' => 'success', 'type' => 'create | edit'));
                $entry->appendChild(new XMLElement('message', __('Entry [created | edited] successfully.')));
                $code->appendChild($entry);
            } else {
                $code = new XMLElement($rootelement, NULL, array('result' => 'error'));
                $code->appendChild(new XMLElement('message', __('Entry encountered errors when saving.')));
                $code->appendChild(new XMLElement('field-name', NULL, array('type' => 'invalid | missing')));
            }
            $code->setValue('...', false);
            $documentation_parts[] = self::processDocumentationCode($code);
            ###
            if (is_array($filters) && !empty($filters)) {
                $documentation_parts[] = new XMLElement('p', __('The following is an example of what is returned if any options return an error:'));
                $code = new XMLElement($rootelement, NULL, array('result' => 'error'));
                $code->appendChild(new XMLElement('message', __('Entry encountered errors when saving.')));
                $code->appendChild(new XMLElement('filter', NULL, array('name' => 'admin-only', 'status' => 'failed')));
                $code->appendChild(new XMLElement('filter', __('Recipient not found'), array('name' => 'send-email', 'status' => 'failed')));
                $code->setValue('...', false);
                $documentation_parts[] = self::processDocumentationCode($code);
            }
            ###
            $documentation_parts[] = new XMLElement('h3', __('Example Front-end Form Markup'));
            $documentation_parts[] = new XMLElement('p', __('This is an example of the form markup you can use on your frontend:'));
            $container = new XMLElement('form', NULL, array('method' => 'post', 'action' => '', 'enctype' => 'multipart/form-data'));
            $container->appendChild(Widget::Input('MAX_FILE_SIZE', Symphony::Configuration()->get('max_upload_size', 'admin'), 'hidden'));
            $sectionManager = new SectionManager($this->_Parent);
            $section = $sectionManager->fetch($fields['source']);
            $section_fields = $section->fetchFields();
            if (is_array($section_fields) && !empty($section_fields)) {
                foreach ($section_fields as $f) {
                    if ($f->getExampleFormMarkup() instanceof XMLElement) {
                        $container->appendChild($f->getExampleFormMarkup());
                    }
                }
            }
            $container->appendChild(Widget::Input('action[' . $rootelement . ']', __('Submit'), 'submit'));
            $code = $container->generate(true);
            $documentation_parts[] = self::processDocumentationCode($multiple ? str_replace('fields[', 'fields[0][', $code) : $code);
            $documentation_parts[] = new XMLElement('p', __('To edit an existing entry, include the entry ID value of the entry in the form. This is best as a hidden field like so:'));
//.........这里部分代码省略.........
开发者ID:scottkf,项目名称:keepflippin--on-symphony,代码行数:101,代码来源:content.blueprintsevents.php

示例12: __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

示例13: action

 function action()
 {
     if (isset($_POST['action'])) {
         $actionParts = array_keys($_POST['action']);
         $action = end($actionParts);
         ##Login Attempted
         if ($action == 'login') {
             if (empty($_POST['username']) || empty($_POST['password']) || !$this->_Parent->login($_POST['username'], $_POST['password'])) {
                 ## TODO: Fix Me
                 ###
                 # Delegate: LoginFailure
                 # Description: Failed login attempt. Username is provided.
                 //$ExtensionManager->notifyMembers('LoginFailure', getCurrentPage(), array('username' => $_POST['username']));
                 //$this->Body->appendChild(new XMLElement('p', 'Login invalid. <a href="'.URL.'/symphony/?forgot">Forgot your password?</a>'));
                 //$this->_alert = 'Login invalid. <a href="'.URL.'/symphony/?forgot">Forgot your password?</a>';
                 $this->_invalidPassword = true;
             } else {
                 ## TODO: Fix Me
                 ###
                 # Delegate: LoginSuccess
                 # Description: Successful login attempt. Username is provided.
                 //$ExtensionManager->notifyMembers('LoginSuccess', getCurrentPage(), array('username' => $_POST['username']));
                 if (isset($_POST['redirect'])) {
                     redirect(URL . str_replace(parse_url(URL, PHP_URL_PATH), '', $_POST['redirect']));
                 }
                 redirect(URL . '/symphony/');
             }
             ##Reset of password requested
         } elseif ($action == 'reset') {
             $author = $this->_Parent->Database->fetchRow(0, "SELECT `id`, `email`, `first_name` FROM `tbl_authors` WHERE `email` = '" . $_POST['email'] . "'");
             if (!empty($author)) {
                 $this->_Parent->Database->delete('tbl_forgotpass', " `expiry` < '" . DateTimeObj::getGMT('c') . "' ");
                 if (!($token = $this->_Parent->Database->fetchVar('token', 0, "SELECT `token` FROM `tbl_forgotpass` WHERE `expiry` > '" . DateTimeObj::getGMT('c') . "' AND `author_id` = " . $author['id']))) {
                     $token = substr(md5(time() . rand(0, 200)), 0, 6);
                     $this->_Parent->Database->insert(array('author_id' => $author['id'], 'token' => $token, 'expiry' => DateTimeObj::getGMT('c', time() + 120 * 60)), 'tbl_forgotpass');
                 }
                 $this->_email_sent = General::sendEmail($author['email'], $this->_Parent->Database->fetchVar('email', 0, "SELECT `email` FROM `tbl_authors` ORDER BY `id` ASC LIMIT 1"), __('Symphony Concierge'), __('New Symphony Account Password'), __('Hi %s,', array($author['first_name'])) . self::CRLF . __('A new password has been requested for your account. Login using the following link, and change your password via the Authors area:') . self::CRLF . self::CRLF . '	' . URL . "/symphony/login/{$token}/" . self::CRLF . self::CRLF . __('It will expire in 2 hours. If you did not ask for a new password, please disregard this email.') . self::CRLF . self::CRLF . __('Best Regards,') . self::CRLF . __('The Symphony Team'));
                 ## TODO: Fix Me
                 ###
                 # Delegate: PasswordResetSuccess
                 # Description: A successful password reset has taken place. Author ID is provided
                 //$ExtensionManager->notifyMembers('PasswordResetSuccess', getCurrentPage(), array('author_id' => $author['id']));
             } else {
                 ## TODO: Fix Me
                 ###
                 # Delegate: PasswordResetFailure
                 # Description: A failed password reset has taken place. Author ID is provided
                 //$ExtensionManager->notifyMembers('PasswordResetFailure', getCurrentPage(), array('author_id' => $author['id']));
                 $this->_email_sent = false;
             }
             ##Change of password requested
         } elseif ($action == 'change' && $this->_Parent->isLoggedIn()) {
             if (empty($_POST['password']) || empty($_POST['password-confirmation']) || $_POST['password'] != $_POST['password-confirmation']) {
                 $this->_mismatchedPassword = true;
             } else {
                 $author_id = $this->_Parent->Author->get('id');
                 require_once TOOLKIT . '/class.authormanager.php';
                 $authorManager = new AuthorManager($this->_Parent);
                 $author = $authorManager->fetchByID($author_id);
                 $author->set('password', md5($this->_Parent->Database->cleanValue($_POST['password'])));
                 if (!$author->commit() || !$this->_Parent->login($author->get('username'), $_POST['password'])) {
                     redirect(URL . "symphony/system/authors/edit/{$author_id}/error/");
                 }
                 ## TODO: Fix me
                 ###
                 # Delegate: PasswordChanged
                 # Description: After editing an author. ID of the author is provided.
                 //$ExtensionManager->notifyMembers('PasswordChanged', getCurrentPage(), array('author_id' => $author_id));
                 redirect(URL . '/symphony/');
             }
         }
     } elseif ($_REQUEST['action'] == 'resetpass' && isset($_REQUEST['token'])) {
         $sql = "SELECT t1.`id`, t1.`email`, t1.`first_name` \n\t\t\t\t\t    FROM `tbl_authors` as t1, `tbl_forgotpass` as t2\n\t\t\t\t\t \tWHERE t2.`token` = '" . $_REQUEST['token'] . "' AND t1.`id` = t2.`author_id`\n\t\t\t\t\t \tLIMIT 1";
         $author = $this->_Parent->Database->fetchRow(0, $sql);
         if (!empty($author)) {
             $newpass = General::generatePassword();
             General::sendEmail($author['email'], 'DONOTREPLY@symphony21.com', 'Symphony Concierge', 'RE: New Symphony Account Password', 'Hi ' . $author['first_name'] . ',' . self::CRLF . "As requested, here is your new Symphony Author Password for '" . URL . "'" . self::CRLF . "\t{$newpass}" . self::CRLF . self::CRLF . 'Best Regards,' . self::CRLF . 'The Symphony Team');
             $this->_Parent->Database->update(array('password' => md5($newpass)), 'tbl_authors', " `id` = '" . $author['id'] . "' LIMIT 1");
             $this->_Parent->Database->delete('tbl_forgotpass', " `author_id` = '" . $author['id'] . "'");
             ## TODO: Fix Me
             ###
             # Delegate: PasswordResetRequest
             # Description: User has requested a password reset. Author ID is provided.
             //$ExtensionManager->notifyMembers('PasswordResetRequest', getCurrentPage(), array('author_id' => $author['id']));
             $this->_alert = 'Password reset. Check your email';
         }
     }
 }
开发者ID:bauhouse,项目名称:sym-fluidgrids,代码行数:88,代码来源:content.login.php

示例14: checkPostFieldData

 public function checkPostFieldData($data, &$error = null, $entry_id = null)
 {
     if (isset($data['entry']) and is_array($data['entry'])) {
         $entryManager = new EntryManager(Symphony::Engine());
         $fieldManager = new FieldManager(Symphony::Engine());
         $field = $fieldManager->fetch($this->get('linked_field_id'));
         $field_id = $this->get('id');
         $status = self::__OK__;
         $handled_entries = array();
         self::$errors[$field_id] = array();
         self::$entries[$field_id] = array();
         // Create:
         foreach ($data['entry'] as $index => $entry_data) {
             $existing_id = null;
             // Find existing entry:
             if ((int) $data['entry_id'][$index] > 0) {
                 $entries = $entryManager->fetch((int) $data['entry_id'][$index], $this->get('linked_section_id'));
                 if (isset($entries[0])) {
                     $entry = $entries[0];
                     $existing_id = $entry->get('id');
                 }
             }
             // Skip duplicate entries:
             if ($existing_id != null && in_array($existing_id, $handled_entries)) {
                 continue;
             }
             // Create a new entry:
             if ($existing_id == null) {
                 $entry = $entryManager->create();
                 $entry->set('section_id', $this->get('linked_section_id'));
                 $entry->set('author_id', isset(Symphony::Engine()->Author) ? Symphony::Engine()->Author->get('id') : 1);
                 $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'));
                 $entry->assignEntryId();
             }
             // Append correct linked data:
             $existing_data = $entry->getData($this->get('linked_field_id'));
             $existing_entries = array();
             if (isset($existing_data['linked_entry_id'])) {
                 if (!is_array($existing_data['linked_entry_id'])) {
                     $existing_entries[] = $existing_data['linked_entry_id'];
                 } else {
                     foreach ($existing_data['linked_entry_id'] as $linked_entry_id) {
                         $existing_entries[] = $linked_entry_id;
                     }
                 }
             }
             if (!in_array($entry_id, $existing_entries)) {
                 $existing_entries[] = $entry_id;
             }
             $entry_data[$field->get('element_name')] = $existing_entries;
             // Validate:
             if (__ENTRY_FIELD_ERROR__ == $entry->checkPostData($entry_data, $errors)) {
                 self::$errors[$field_id][$index] = $errors;
                 $status = self::__INVALID_FIELDS__;
             }
             if (__ENTRY_OK__ != $entry->setDataFromPost($entry_data, $error)) {
                 $status = self::__INVALID_FIELDS__;
             }
             // Cleanup dud entry:
             if ($existing_id == null and $status != self::__OK__) {
                 $existing_id = $entry->get('id');
                 $entry->set('id', 0);
                 Symphony::Database()->delete('tbl_entries', " `id` = '{$existing_id}' ");
             }
             self::$entries[$field_id][$index] = $entry;
             $handled_entries[] = $entry->get('id');
         }
         return $status;
     }
     return parent::checkPostFieldData($data, $error, $entry_id);
 }
开发者ID:symphonists,项目名称:bilinkfield,代码行数:72,代码来源:field.bilink.php

示例15: processRawFieldData

 public function processRawFieldData($data, &$status, &$message = null, $simulate = false, $entry_id = null)
 {
     $status = self::__OK__;
     $timestamp = null;
     if (is_null($data) || $data == '') {
         $timestamp = strtotime(Lang::standardizeDate(DateTimeObj::get(__SYM_DATETIME_FORMAT__, null)));
     } else {
         $timestamp = strtotime(Lang::standardizeDate($data));
     }
     if (!is_null($timestamp)) {
         return array('value' => DateTimeObj::get('c', $timestamp), 'date' => DateTimeObj::getGMT('Y-m-d H:i:s', $timestamp));
     }
     return array('value' => null, 'date' => null);
 }
开发者ID:symphonists,项目名称:datemodified,代码行数:14,代码来源:field.datemodified.php


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