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


PHP General::getPostData方法代码示例

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


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

示例1: getXML

 private function getXML($position = 0, $entry_id = NULL)
 {
     // Cache stuff that can be reused between filter fields and entries
     static $post;
     static $postValues;
     // Remember if $post contains multiple entries or not
     static $expectMultiple;
     $xml = new XMLElement('data');
     // Get post values
     if (empty($postValues) || $position > 0) {
         // TODO: handle post of multiple entries at the same time
         if (empty($post)) {
             $post = General::getPostData();
             // Check if post contains multiple entries or not
             // TODO: make some hidden field required for post, so we can check for sure
             //       if $post['fields'][0]['conditionalizer'] exists?
             $expectMultiple = is_array($post['fields']) && is_array($post['fields'][0]) ? true : false;
         }
         if (!empty($post['fields']) && is_array($post['fields'])) {
             $postValues = new XMLElement('post');
             if ($expectMultiple == true) {
                 if (!empty($entry_id) && isset($post['id'])) {
                     // $entry_id overrides $position
                     foreach ($post['id'] as $pos => $id) {
                         if ($id == $entry_id) {
                             $position = $pos;
                             break;
                         }
                     }
                 } else {
                     if (isset($post['id'][$position]) && is_numeric($post['id'][$position])) {
                         $entry_id = $post['id'][$position];
                     }
                 }
                 $postValues->setAttribute('position', $position);
                 General::array_to_xml($postValues, $post['fields'][$position], false);
             } else {
                 if ($position < 1) {
                     if (empty($entry_id) && isset($post['id']) && is_numeric($post['id'])) {
                         $entry_id = $post['id'];
                     }
                     General::array_to_xml($postValues, $post['fields'], false);
                 } else {
                     // TODO: add error element?
                 }
             }
         }
     }
     if (!empty($postValues)) {
         $xml->appendChild($postValues);
     }
     // Get old entry
     $entry = NULL;
     if (!class_exists('EntryManager')) {
         include_once TOOLKIT . '/class.entrymanager.php';
     }
     if (!empty($entry_id)) {
         $entry = EntryManager::fetch($entry_id);
         $entry = $entry[0];
         if (is_object($entry)) {
             $entry_xml = new XMLElement('old-entry');
             $entry_xml->setAttribute('position', $position);
             $this->appendEntryXML($entry_xml, $entry);
             $xml->appendChild($entry_xml);
         } else {
             $entry = NULL;
         }
     } else {
         $entry = EntryManager::create();
         $entry->set('section_id', $this->get('parent_section'));
     }
     // Set new entry data. Code found in event.section.php:
     // https://github.com/symphonycms/symphony-2/blob/29244318e4de294df780513ee027edda767dd75a/symphony/lib/toolkit/events/event.section.php#L99
     if (is_object($entry)) {
         self::$recursion = true;
         if (__ENTRY_FIELD_ERROR__ == $entry->checkPostData($expectMultiple ? $post['fields'][$position] : $post['fields'], $errors, $entry->get('id') ? true : false)) {
             // Return early - other fields will mark their errors
             self::$recursion = false;
             return self::__OK__;
         } else {
             if (__ENTRY_OK__ != $entry->setDataFromPost($expectMultiple ? $post['fields'][$position] : $post['fields'], $errors, true, $entry->get('id') ? true : false)) {
                 // Return early - other fields will mark their errors.
                 self::$recursion = false;
                 return self::__OK__;
             }
         }
         self::$recursion = false;
         $entry_xml = new XMLElement('entry');
         $entry_xml->setAttribute('position', $position);
         $this->appendEntryXML($entry_xml, $entry);
         $xml->appendChild($entry_xml);
     }
     // Get author
     if ($temp = Symphony::Engine()->Author) {
         $author = new XMLElement('author');
         $author->setAttribute('id', $temp->get('id'));
         $author->setAttribute('user_type', $temp->get('user_type'));
         $author->setAttribute('primary', $temp->get('primary'));
         $author->setAttribute('username', $temp->get('username'));
         $author->setAttribute('first_name', $temp->get('first_name'));
//.........这里部分代码省略.........
开发者ID:ahwayakchih,项目名称:conditionalizer,代码行数:101,代码来源:field.conditionalizer.php

示例2: execute

 public function execute()
 {
     if (!isset($this->eParamFILTERS) || !is_array($this->eParamFILTERS)) {
         $this->eParamFILTERS = array();
     }
     $result = new XMLElement($this->ROOTELEMENT);
     if (in_array('admin-only', $this->eParamFILTERS) && !Symphony::Engine()->isLoggedIn()) {
         $result->setAttribute('result', 'error');
         $result->appendChild(new XMLElement('message', __('Entry encountered errors when saving.')));
         $result->appendChild($this->buildFilterElement('admin-only', 'failed'));
         return $result;
     }
     $entry_id = $position = $fields = null;
     $post = General::getPostData();
     $success = true;
     if (in_array('expect-multiple', $this->eParamFILTERS)) {
         if (is_array($post['fields'])) {
             foreach ($post['fields'] as $position => $fields) {
                 if (isset($post['id'][$position]) && is_numeric($post['id'][$position])) {
                     $entry_id = $post['id'][$position];
                 } else {
                     $entry_id = null;
                 }
                 $entry = new XMLElement('entry', null, array('position' => $position));
                 $ret = $this->__doit($fields, $entry, $position, $entry_id);
                 if (!$ret) {
                     $success = false;
                 }
                 $result->appendChild($entry);
             }
         }
     } else {
         $fields = $post['fields'];
         $entry_id = null;
         if (isset($post['id']) && is_numeric($post['id'])) {
             $entry_id = $post['id'];
         }
         $success = $this->__doit($fields, $result, null, $entry_id);
     }
     if ($success && isset($_REQUEST['redirect'])) {
         redirect($_REQUEST['redirect']);
     }
     return $result;
 }
开发者ID:readona,项目名称:symphonyno5,代码行数:44,代码来源:class.event.section.php

示例3: __actionEdit

 public function __actionEdit()
 {
     $callback = Administration::instance()->getPageCallback();
     $entry_id = (int) $callback['context']['entry_id'];
     if (@array_key_exists('save', $_POST['action']) || @array_key_exists("done", $_POST['action'])) {
         $entry = Entry::loadFromID($entry_id);
         $post = General::getPostData();
         $fields = array();
         if (isset($post['fields']) and !empty($post['fields'])) {
             $fields = $post['fields'];
         }
         $entry->setFieldDataFromFormArray($fields);
         ###
         # Delegate: EntryPreEdit
         # Description: Just prior to editing of an Entry.
         Extension::notify('EntryPreEdit', '/publish/edit/', array('entry' => &$entry));
         $this->errors->flush();
         $status = Entry::save($entry, $this->errors);
         if ($status == Entry::STATUS_OK) {
             // Check if there is a field to prepopulate
             if (isset($_REQUEST['prepopulate']) && strlen(trim($_REQUEST['prepopulate'])) > 0) {
                 $field_handle = key($_REQUEST['prepopulate']);
                 $value = stripslashes(rawurldecode($_REQUEST['prepopulate'][$field_handle]));
                 $prepopulate_filter = "?prepopulate[{$field_handle}]=" . rawurlencode($value);
             } else {
                 $prepopulate_filter = null;
             }
             ###
             # Delegate: EntryPostEdit
             # Description: Editing an entry. Entry object is provided.
             Extension::notify('EntryPostEdit', '/publish/edit/', array('entry' => $entry));
             ## WOOT
             redirect(sprintf('%s/symphony/publish/%s/edit/%d/:saved/%s', URL, $entry->section, $entry->id, $prepopulate_filter));
         }
         // Oh dear
         $this->entry = $entry;
         $this->alerts()->append(__('An error occurred while processing this form. <a href="#error">See below for details.</a> <a class="more">Show a list of errors.</a>'), AlertStack::ERROR);
         return;
     } elseif (@array_key_exists('delete', $_POST['action']) && is_numeric($entry_id)) {
         $callback = Administration::instance()->getPageCallback();
         ###
         # Delegate: Delete
         # Description: Prior to deleting an entry. Entry ID is provided, as an
         # array to remain compatible with other Delete delegate call
         Extension::notify('Delete', '/publish/', array('entry_id' => $entry_id));
         Entry::delete($entry_id);
         redirect(ADMIN_URL . '/publish/' . $callback['context']['section_handle'] . '/');
     }
 }
开发者ID:pointybeard,项目名称:symphony-3,代码行数:49,代码来源:content.publish.php

示例4: __actionEdit

 public function __actionEdit()
 {
     $entry_id = intval($this->_context['entry_id']);
     if (@array_key_exists('save', $_POST['action']) || @array_key_exists("done", $_POST['action'])) {
         if (!($ret = EntryManager::fetch($entry_id))) {
             Administration::instance()->customError(__('Unknown Entry'), __('The entry you are looking for could not be found.'));
         }
         $entry = $ret[0];
         $section = SectionManager::fetch($entry->get('section_id'));
         $post = General::getPostData();
         $fields = $post['fields'];
         // 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 editing of an Entry.
                  *
                  * @delegate EntryPreEdit
                  * @param string $context
                  * '/publish/edit/'
                  * @param Section $section
                  * @param Entry $entry
                  * @param array $fields
                  */
                 Symphony::ExtensionManager()->notifyMembers('EntryPreEdit', '/publish/edit/', 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 {
                     /**
                      * Just after the editing of an Entry
                      *
                      * @delegate EntryPostEdit
                      * @param string $context
                      * '/publish/edit/'
                      * @param Section $section
                      * @param Entry $entry
                      * @param array $fields
                      */
                     Symphony::ExtensionManager()->notifyMembers('EntryPostEdit', '/publish/edit/', 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, $value);
                         }
                         $prepopulate_querystring = trim($prepopulate_querystring, '&');
                     }
                     redirect(sprintf('%s/publish/%s/edit/%d/saved/%s', SYMPHONY_URL, $this->_context['section_handle'], $entry->get('id'), !empty($prepopulate_querystring) ? "?" . $prepopulate_querystring : NULL));
                 }
             }
         }
     } else {
         if (@array_key_exists('delete', $_POST['action']) && is_numeric($entry_id)) {
             /**
              * Prior to deletion of entries. An array of Entry ID's is provided which
              * can be manipulated. This delegate was renamed from `Delete` to `EntryPreDelete`
              * in Symphony 2.3.
              *
              * @delegate EntryPreDelete
              * @param string $context
              * '/publish/'
              * @param array $entry_id
              *	An array of Entry ID's passed by reference
              */
             $checked = array($entry_id);
             Symphony::ExtensionManager()->notifyMembers('EntryPreDelete', '/publish/', array('entry_id' => &$checked));
             EntryManager::delete($checked);
             /**
              * After the deletion of entries, this delegate provides an array of Entry ID's
              * that were deleted.
              *
              * @since Symphony 2.3
              * @delegate EntryPostDelete
              * @param string $context
              * '/publish/'
              * @param array $entry_id
              *  An array of Entry ID's that were deleted.
              */
             Symphony::ExtensionManager()->notifyMembers('EntryPostDelete', '/publish/', array('entry_id' => $checked));
             redirect(SYMPHONY_URL . '/publish/' . $this->_context['section_handle'] . '/');
         }
     }
 }
开发者ID:nickdunn,项目名称:elasticsearch-surfin-shakespeare,代码行数:90,代码来源:content.publish.php

示例5: __actionEdit

 public function __actionEdit()
 {
     $entry_id = intval($this->_context['entry_id']);
     if (@array_key_exists('save', $_POST['action']) || @array_key_exists("done", $_POST['action'])) {
         $entryManager = new EntryManager($this->_Parent);
         if (!($ret = $entryManager->fetch($entry_id))) {
             Administration::instance()->customError(__('Unknown Entry'), __('The entry you are looking for could not be found.'));
         }
         $entry = $ret[0];
         $sectionManager = new SectionManager($this->_Parent);
         $section = $sectionManager->fetch($entry->get('section_id'));
         $post = General::getPostData();
         $fields = $post['fields'];
         if (__ENTRY_FIELD_ERROR__ == $entry->checkPostData($fields, $this->_errors)) {
             $this->pageAlert(__('Some errors were encountered while attempting to save.'), Alert::ERROR);
         } elseif (__ENTRY_OK__ != $entry->setDataFromPost($fields, $error)) {
             $this->pageAlert($error['message'], Alert::ERROR);
         } else {
             /**
              * Just prior to editing of an Entry.
              *
              * @delegate EntryPreEdit
              * @param string $context
              * '/publish/edit/'
              * @param Section $section
              * @param Entry $entry
              * @param array $fields
              */
             Symphony::ExtensionManager()->notifyMembers('EntryPreEdit', '/publish/edit/', array('section' => $section, 'entry' => &$entry, 'fields' => $fields));
             if (!$entry->commit()) {
                 define_safe('__SYM_DB_INSERT_FAILED__', true);
                 $this->pageAlert(NULL, Alert::ERROR);
             } else {
                 /**
                  * Just after the editing of an Entry
                  *
                  * @delegate EntryPostEdit
                  * @param string $context
                  * '/publish/edit/'
                  * @param Section $section
                  * @param Entry $entry
                  * @param array $fields
                  */
                 Symphony::ExtensionManager()->notifyMembers('EntryPostEdit', '/publish/edit/', array('section' => $section, 'entry' => $entry, 'fields' => $fields));
                 $prepopulate_field_id = $prepopulate_value = NULL;
                 if (isset($_POST['prepopulate'])) {
                     $prepopulate_field_id = array_shift(array_keys($_POST['prepopulate']));
                     $prepopulate_value = stripslashes(rawurldecode(array_shift($_POST['prepopulate'])));
                 }
                 redirect(sprintf('%s/publish/%s/edit/%d/saved%s/', SYMPHONY_URL, $this->_context['section_handle'], $entry->get('id'), !is_null($prepopulate_field_id) ? ":{$prepopulate_field_id}:{$prepopulate_value}" : NULL));
             }
         }
     } elseif (@array_key_exists('delete', $_POST['action']) && is_numeric($entry_id)) {
         /**
          * Prior to deletion of entries. Array of Entry ID's is provided.
          * The array can be manipulated
          *
          * @delegate Delete
          * @param string $context
          * '/publish/'
          * @param array $checked
          *  An array of Entry ID's passed by reference
          */
         Symphony::ExtensionManager()->notifyMembers('Delete', '/publish/', array('entry_id' => $entry_id));
         $entryManager = new EntryManager($this->_Parent);
         $entryManager->delete($entry_id);
         redirect(SYMPHONY_URL . '/publish/' . $this->_context['section_handle'] . '/');
     }
 }
开发者ID:ahwayakchih,项目名称:symphony-2,代码行数:69,代码来源:content.publish.php

示例6: render

 public function render(Register $Parameters, XMLDocument &$Document = NULL, DocumentHeaders &$Headers = NULL)
 {
     $ParameterOutput = new Register();
     if (!is_null($Headers)) {
         $Headers->append('Content-Type', $this->{'content-type'});
     } else {
         header('Content-Type: ' . $this->{'content-type'});
     }
     if (is_null($Document)) {
         $Document = new XMLDocument();
         $Document->appendChild($Document->createElement('data'));
     }
     $root = $Document->documentElement;
     $datasources = $events = array();
     $events_wrapper = $Document->createElement('events');
     $root->appendChild($events_wrapper);
     if (is_array($this->about()->{'events'}) && !empty($this->about()->{'events'})) {
         $events = $this->about()->{'events'};
     }
     if (is_array($this->about()->{'data-sources'}) && !empty($this->about()->{'data-sources'})) {
         $datasources = $this->about()->{'data-sources'};
     }
     ####
     # Delegate: FrontendEventsAppend
     # Description: Append additional Events.
     # Global: Yes
     Extension::notify('FrontendEventsAppend', '/frontend/', array('events' => &$events));
     if (!empty($events)) {
         $postdata = General::getPostData();
         $events_ordered = array();
         foreach ($events as $handle) {
             $events_ordered[] = Event::loadFromHandle($handle);
         }
         uasort($events_ordered, array($this, '__cbSortEventsByPriority'));
         foreach ($events_ordered as $e) {
             if (!$e->canTrigger($postdata)) {
                 continue;
             }
             $fragment = $e->trigger($ParameterOutput, $postdata);
             if ($fragment instanceof DOMDocument && !is_null($fragment->documentElement)) {
                 $node = $Document->importNode($fragment->documentElement, true);
                 $events_wrapper->appendChild($node);
             }
         }
     }
     ####
     # Delegate: FrontendDataSourceAppend
     # Description: Append additional DataSources.
     # Global: Yes
     Extension::notify('FrontendDataSourcesAppend', '/frontend/', array('datasources' => &$datasources));
     //	Find dependancies and order accordingly
     $datasource_pool = array();
     $dependency_list = array();
     $datasources_ordered = array();
     $all_dependencies = array();
     foreach ($datasources as $handle) {
         $datasource_pool[$handle] = Datasource::loadFromHandle($handle);
         $dependency_list[$handle] = $datasource_pool[$handle]->parameters()->dependencies;
     }
     $datasources_ordered = $this->__sortByDependencies($dependency_list);
     if (!empty($datasources_ordered)) {
         foreach ($datasources_ordered as $handle) {
             $ds = $datasource_pool[$handle];
             try {
                 $fragment = $ds->render($ParameterOutput);
             } catch (FrontendPageNotFoundException $e) {
                 FrontendPageNotFoundExceptionHandler::render($e);
             }
             if ($fragment instanceof DOMDocument && !is_null($fragment->documentElement)) {
                 $node = $Document->importNode($fragment->documentElement, true);
                 $root->appendChild($node);
             }
         }
     }
     if ($ParameterOutput->length() > 0) {
         foreach ($ParameterOutput as $p) {
             $Parameters->{$p->key} = $p->value;
         }
     }
     ####
     # Delegate: FrontendParamsPostResolve
     # Description: Access to the resolved param pool, including additional parameters provided by Data Source outputs
     # Global: Yes
     Extension::notify('FrontendParamsPostResolve', '/frontend/', array('params' => $Parameters));
     $element = $Document->createElement('parameters');
     $root->appendChild($element);
     foreach ($Parameters as $key => $parameter) {
         if (is_array($parameter->value) && count($parameter->value) > 1) {
             $p = $Document->createElement($key);
             $p->setAttribute('value', (string) $parameter);
             foreach ($parameter->value as $v) {
                 $p->appendChild($Document->createElement('item', (string) $v));
             }
             $element->appendChild($p);
         } else {
             $element->appendChild($Document->createElement($key, (string) $parameter));
         }
     }
     $template = $this->template;
     ####
//.........这里部分代码省略.........
开发者ID:plasticine,项目名称:symphony-3,代码行数:101,代码来源:class.view.php

示例7: __actionEdit

 function __actionEdit()
 {
     $entry_id = intval($this->_context['entry_id']);
     if (@array_key_exists('save', $_POST['action']) || @array_key_exists("done", $_POST['action'])) {
         $entryManager = new EntryManager($this->_Parent);
         if (!($ret = $entryManager->fetch($entry_id))) {
             $this->_Parent->customError(E_USER_ERROR, __('Unknown Entry'), __('The entry you are looking for could not be found.'), false, true);
         }
         $entry = $ret[0];
         $sectionManager = new SectionManager($this->_Parent);
         $section = $sectionManager->fetch($entry->get('section_id'));
         $post = General::getPostData();
         $fields = $post['fields'];
         if (__ENTRY_FIELD_ERROR__ == $entry->checkPostData($fields, $this->_errors)) {
             $this->pageAlert(__('Some errors were encountered while attempting to save.'), Alert::ERROR);
         } elseif (__ENTRY_OK__ != $entry->setDataFromPost($fields, $error)) {
             $this->pageAlert($error['message'], Alert::ERROR);
         } else {
             ###
             # Delegate: EntryPreEdit
             # Description: Just prior to editing of an Entry.
             $this->_Parent->ExtensionManager->notifyMembers('EntryPreEdit', '/publish/edit/', array('section' => $section, 'entry' => &$entry, 'fields' => $fields));
             if (!$entry->commit()) {
                 define_safe('__SYM_DB_INSERT_FAILED__', true);
                 $this->pageAlert(NULL, Alert::ERROR);
             } else {
                 ###
                 # Delegate: EntryPostEdit
                 # Description: Editing an entry. Entry object is provided.
                 $this->_Parent->ExtensionManager->notifyMembers('EntryPostEdit', '/publish/edit/', array('section' => $section, 'entry' => $entry, 'fields' => $fields));
                 $prepopulate_field_id = $prepopulate_value = NULL;
                 if (isset($_POST['prepopulate'])) {
                     $prepopulate_field_id = array_shift(array_keys($_POST['prepopulate']));
                     $prepopulate_value = stripslashes(rawurldecode(array_shift($_POST['prepopulate'])));
                 }
                 //redirect(URL . '/symphony/publish/' . $this->_context['section_handle'] . '/edit/' . $entry_id . '/saved/');
                 redirect(sprintf('%s/symphony/publish/%s/edit/%d/saved%s/', URL, $this->_context['section_handle'], $entry->get('id'), !is_null($prepopulate_field_id) ? ":{$prepopulate_field_id}:{$prepopulate_value}" : NULL));
             }
         }
     } elseif (@array_key_exists('delete', $_POST['action']) && is_numeric($entry_id)) {
         ###
         # Delegate: Delete
         # Description: Prior to deleting an entry. Entry ID is provided, as an array to remain compatible with other Delete delegate call
         Administration::instance()->ExtensionManager->notifyMembers('Delete', '/publish/', array('entry_id' => $entry_id));
         $entryManager = new EntryManager($this->_Parent);
         $entryManager->delete($entry_id);
         redirect(URL . '/symphony/publish/' . $this->_context['section_handle'] . '/');
     }
 }
开发者ID:klaftertief,项目名称:sym-forum,代码行数:49,代码来源:content.publish.php

示例8: array

        }
        return true;
    }
}
if (!isset($this->eParamFILTERS) || !is_array($this->eParamFILTERS)) {
    $this->eParamFILTERS = array();
}
$result = new XMLElement(self::ROOTELEMENT);
if (in_array('admin-only', $this->eParamFILTERS) && !Symphony::Engine()->isLoggedIn()) {
    $result->setAttribute('result', 'error');
    $result->appendChild(new XMLElement('message', __('Entry encountered errors when saving.')));
    $result->appendChild(buildFilterElement('admin-only', 'failed'));
    return $result;
}
$entry_id = $position = $fields = NULL;
$post = General::getPostData();
$success = true;
if (in_array('expect-multiple', $this->eParamFILTERS)) {
    if (is_array($post['fields']) && isset($post['fields'][0])) {
        foreach ($post['fields'] as $position => $fields) {
            if (isset($post['id'][$position]) && is_numeric($post['id'][$position])) {
                $entry_id = $post['id'][$position];
            }
            $entry = new XMLElement('entry', NULL, array('position' => $position));
            $ret = __doit(self::getSource(), $fields, $entry, $this, $this->eParamFILTERS, $position, $entry_id);
            if (!$ret) {
                $success = false;
            }
            $result->appendChild($entry);
        }
    }
开发者ID:rainerborene,项目名称:symphony-2,代码行数:31,代码来源:event.section.php

示例9: appendLoginStatusToEventXML

 public function appendLoginStatusToEventXML(array $context = null)
 {
     $result = new XMLElement('member-login-info');
     if ($this->isLoggedIn()) {
         $result->setAttributearray(array('logged-in' => 'yes', 'id' => $this->getMemberID(), 'result' => 'success'));
     } else {
         $result->setAttribute('logged-in', 'no');
         // Append error messages
         if (is_array(extension_Members::$_errors) && !empty(extension_Members::$_errors)) {
             foreach (extension_Members::$_errors as $type => $error) {
                 $result->appendChild(new XMLElement($type, null, array('type' => $error['type'], 'message' => $error['message'], 'label' => General::sanitize($error['label']))));
             }
         }
         // Append post values to simulate a real Symphony event
         if (extension_Members::$_failed_login_attempt) {
             $result->setAttribute('result', 'error');
             $post_values = new XMLElement('post-values');
             $post = General::getPostData();
             // Create the post data cookie element
             if (is_array($post['fields']) && !empty($post['fields'])) {
                 General::array_to_xml($post_values, $post['fields'], true);
                 $result->appendChild($post_values);
             }
         }
     }
     $context['wrapper']->appendChild($result);
 }
开发者ID:brendo,项目名称:members,代码行数:27,代码来源:class.members.php

示例10: __actionEdit

 public function __actionEdit()
 {
     $entry_id = intval($this->_context['entry_id']);
     if (@array_key_exists('save', $_POST['action']) || @array_key_exists("done", $_POST['action'])) {
         if (!($ret = EntryManager::fetch($entry_id))) {
             Administration::instance()->throwCustomError(__('The Entry, %s, could not be found.', array($entry_id)), __('Unknown Entry'), Page::HTTP_STATUS_NOT_FOUND);
         }
         $entry = $ret[0];
         $section = SectionManager::fetch($entry->get('section_id'));
         $post = General::getPostData();
         $fields = $post['fields'];
         // Initial checks to see if the Entry is ok
         if (Entry::__ENTRY_FIELD_ERROR__ == $entry->checkPostData($fields, $this->_errors)) {
             $this->pageAlert(__('Some errors were encountered while attempting to save.'), Alert::ERROR);
             // Secondary checks, this will actually process the data and attempt to save
         } elseif (Entry::__ENTRY_OK__ != $entry->setDataFromPost($fields, $errors)) {
             foreach ($errors as $field_id => $message) {
                 $this->pageAlert($message, Alert::ERROR);
             }
             // Everything is awesome. Dance.
         } else {
             /**
              * Just prior to editing of an Entry.
              *
              * @delegate EntryPreEdit
              * @param string $context
              * '/publish/edit/'
              * @param Section $section
              * @param Entry $entry
              * @param array $fields
              */
             Symphony::ExtensionManager()->notifyMembers('EntryPreEdit', '/publish/edit/', array('section' => $section, 'entry' => &$entry, 'fields' => $fields));
             // Check to see if the dancing was premature
             if (!$entry->commit()) {
                 $this->pageAlert(null, Alert::ERROR);
             } else {
                 /**
                  * Just after the editing of an Entry
                  *
                  * @delegate EntryPostEdit
                  * @param string $context
                  * '/publish/edit/'
                  * @param Section $section
                  * @param Entry $entry
                  * @param array $fields
                  */
                 Symphony::ExtensionManager()->notifyMembers('EntryPostEdit', '/publish/edit/', array('section' => $section, 'entry' => $entry, 'fields' => $fields));
                 redirect(sprintf('%s/publish/%s/edit/%d/saved/%s', SYMPHONY_URL, $this->_context['section_handle'], $entry->get('id'), $this->getPrepopulateString()));
             }
         }
     } elseif (@array_key_exists('delete', $_POST['action']) && is_numeric($entry_id)) {
         /**
          * Prior to deletion of entries. An array of Entry ID's is provided which
          * can be manipulated. This delegate was renamed from `Delete` to `EntryPreDelete`
          * in Symphony 2.3.
          *
          * @delegate EntryPreDelete
          * @param string $context
          * '/publish/'
          * @param array $entry_id
          *    An array of Entry ID's passed by reference
          */
         $checked = array($entry_id);
         Symphony::ExtensionManager()->notifyMembers('EntryPreDelete', '/publish/', array('entry_id' => &$checked));
         EntryManager::delete($checked);
         /**
          * After the deletion of entries, this delegate provides an array of Entry ID's
          * that were deleted.
          *
          * @since Symphony 2.3
          * @delegate EntryPostDelete
          * @param string $context
          * '/publish/'
          * @param array $entry_id
          *  An array of Entry ID's that were deleted.
          */
         Symphony::ExtensionManager()->notifyMembers('EntryPostDelete', '/publish/', array('entry_id' => $checked));
         redirect(SYMPHONY_URL . '/publish/' . $this->_context['section_handle'] . '/');
     }
 }
开发者ID:jurajkapsz,项目名称:symphony-2,代码行数:80,代码来源:content.publish.php

示例11: __doit

 function __doit($source, $fields, &$result, &$obj, &$event, $filters, $position = NULL, $entry_id = NULL)
 {
     $post_values = new XMLElement('post-values');
     $post = General::getPostData();
     $filter_results = array();
     ## Create the post data cookie element
     if (is_array($post) && !empty($post)) {
         General::array_to_xml($post_values, $fields, true);
     }
     ###
     # Delegate: EventPreSaveFilter
     # Description: Prior to saving entry from the front-end. This delegate will force the Event to terminate if it populates the error
     #              array reference. Provided with references to this object, the POST data and also the error array
     $obj->ExtensionManager->notifyMembers('EventPreSaveFilter', '/frontend/', array('fields' => $fields, 'event' => &$event, 'messages' => &$filter_results, 'post_values' => &$post_values));
     if (is_array($filter_results) && !empty($filter_results)) {
         foreach ($filter_results as $fr) {
             list($type, $status, $message) = $fr;
             $result->appendChild(buildFilterElement($type, $status ? 'passed' : 'failed', $message));
             if (!$status) {
                 $result->appendChild($post_values);
                 $result->setAttribute('result', 'error');
                 $result->appendChild(new XMLElement('message', __('Entry encountered errors when saving.')));
                 return false;
             }
         }
     }
     include_once TOOLKIT . '/class.sectionmanager.php';
     include_once TOOLKIT . '/class.entrymanager.php';
     $sectionManager = new SectionManager($obj);
     if (!($section = $sectionManager->fetch($source))) {
         $result->setAttribute('result', 'error');
         $result->appendChild(new XMLElement('message', __('Section is invalid')));
         return false;
     }
     $entryManager = new EntryManager($obj);
     if (isset($entry_id) && $entry_id != NULL) {
         $entry =& $entryManager->fetch($entry_id);
         $entry = $entry[0];
         if (!is_object($entry)) {
             $result->setAttribute('result', 'error');
             $result->appendChild(new XMLElement('message', __('Invalid Entry ID specified. Could not create Entry object.')));
             return false;
         }
     } else {
         $entry =& $entryManager->create();
         $entry->set('section_id', $source);
     }
     $filter_errors = array();
     if (__ENTRY_FIELD_ERROR__ == $entry->checkPostData($fields, $errors, $entry->get('id') ? true : false)) {
         $result->setAttribute('result', 'error');
         $result->appendChild(new XMLElement('message', __('Entry encountered errors when saving.')));
         foreach ($errors as $field_id => $message) {
             $field = $entryManager->fieldManager->fetch($field_id);
             $result->appendChild(new XMLElement($field->get('element_name'), NULL, array('type' => $fields[$field->get('element_name')] == '' ? 'missing' : 'invalid', 'message' => General::sanitize($message))));
         }
         if (isset($post_values) && is_object($post_values)) {
             $result->appendChild($post_values);
         }
         return false;
     } elseif (__ENTRY_OK__ != $entry->setDataFromPost($fields, $errors, false, $entry->get('id') ? true : false)) {
         $result->setAttribute('result', 'error');
         $result->appendChild(new XMLElement('message', __('Entry encountered errors when saving.')));
         if (isset($errors['field_id'])) {
             $errors = array($errors);
         }
         foreach ($errors as $err) {
             $field = $entryManager->fieldManager->fetch($err['field_id']);
             $result->appendChild(new XMLElement($field->get('element_name'), NULL, array('type' => 'invalid')));
         }
         if (isset($post_values) && is_object($post_values)) {
             $result->appendChild($post_values);
         }
         return false;
     } else {
         if (!$entry->commit()) {
             $result->setAttribute('result', 'error');
             $result->appendChild(new XMLElement('message', __('Unknown errors where encountered when saving.')));
             if (isset($post_values) && is_object($post_values)) {
                 $result->appendChild($post_values);
             }
             return false;
         }
         $result->setAttribute('id', $entry->get('id'));
     }
     ## PASSIVE FILTERS ONLY AT THIS STAGE. ENTRY HAS ALREADY BEEN CREATED.
     if (@in_array('send-email', $filters) && !@in_array('expect-multiple', $filters)) {
         if (!function_exists('__sendEmailFindFormValue')) {
             function __sendEmailFindFormValue($needle, $haystack, $discard_field_name = true, $default = NULL, $collapse = true)
             {
                 if (preg_match('/^(fields\\[[^\\]]+\\],?)+$/i', $needle)) {
                     $parts = preg_split('/\\,/i', $needle, -1, PREG_SPLIT_NO_EMPTY);
                     $parts = array_map('trim', $parts);
                     $stack = array();
                     foreach ($parts as $p) {
                         $field = str_replace(array('fields[', ']'), '', $p);
                         $discard_field_name ? $stack[] = $haystack[$field] : ($stack[$field] = $haystack[$field]);
                     }
                     if (is_array($stack) && !empty($stack)) {
                         return $collapse ? implode(' ', $stack) : $stack;
                     } else {
//.........这里部分代码省略.........
开发者ID:bauhouse,项目名称:sym-calendar,代码行数:101,代码来源:event.section.php

示例12: execute

 /**
  * This function will process the core Filters, Admin Only and Expect
  * Multiple, before invoking the `__doit` function, which actually
  * processes the Event. Once the Event has executed, this function will
  * determine if the user should be redirected to a URL, or to just return
  * the XML.
  *
  * @throws Exception
  * @return XMLElement|void
  *  If `$_REQUEST{'redirect']` is set, and the Event executed successfully,
  *  the user will be redirected to the given location. If `$_REQUEST['redirect']`
  *  is not set, or the Event encountered errors, an XMLElement of the Event
  *  result will be returned.
  */
 public function execute()
 {
     if (!isset($this->eParamFILTERS) || !is_array($this->eParamFILTERS)) {
         $this->eParamFILTERS = array();
     }
     $result = new XMLElement($this->ROOTELEMENT);
     if (in_array('admin-only', $this->eParamFILTERS) && !Symphony::Engine()->isLoggedIn()) {
         $result->setAttribute('result', 'error');
         $result->appendChild(new XMLElement('message', __('Entry encountered errors when saving.'), array('message-id' => EventMessages::ENTRY_ERRORS)));
         $result->appendChild(self::buildFilterElement('admin-only', 'failed'));
         return $result;
     }
     $entry_id = $position = $fields = null;
     $post = General::getPostData();
     $success = true;
     if (!is_array($post['fields'])) {
         $post['fields'] = array();
     }
     if (in_array('expect-multiple', $this->eParamFILTERS)) {
         foreach ($post['fields'] as $position => $fields) {
             if (isset($post['id'][$position]) && is_numeric($post['id'][$position])) {
                 $entry_id = $post['id'][$position];
             } else {
                 $entry_id = null;
             }
             $entry = new XMLElement('entry', null, array('position' => $position));
             // Reset errors for each entry execution
             $this->filter_results = $this->filter_errors = array();
             // Ensure that we are always dealing with an array.
             if (!is_array($fields)) {
                 $fields = array();
             }
             // Execute the event for this entry
             if (!$this->__doit($fields, $entry, $position, $entry_id)) {
                 $success = false;
             }
             $result->appendChild($entry);
         }
     } else {
         $fields = $post['fields'];
         if (isset($post['id']) && is_numeric($post['id'])) {
             $entry_id = $post['id'];
         }
         $success = $this->__doit($fields, $result, null, $entry_id);
     }
     if ($success && isset($_REQUEST['redirect'])) {
         redirect($_REQUEST['redirect']);
     }
     return $result;
 }
开发者ID:jurajkapsz,项目名称:symphony-2,代码行数:64,代码来源:class.event.section.php

示例13: buildOutput

 public function buildOutput()
 {
     $ParameterOutput = new Register();
     $root = $this->document->documentElement;
     $this->buildContextXML($root);
     $datasources = $events = array();
     $events_wrapper = $this->document->createElement('events');
     $root->appendChild($events_wrapper);
     if (is_array($this->about()->{'events'}) && !empty($this->about()->{'events'})) {
         $events = $this->about()->{'events'};
     }
     if (is_array($this->about()->{'data-sources'}) && !empty($this->about()->{'data-sources'})) {
         $datasources = $this->about()->{'data-sources'};
     }
     ####
     # Delegate: FrontendEventsAppend
     # Description: Append additional Events.
     # Global: Yes
     Extension::notify('FrontendEventsAppend', '/frontend/', array('events' => &$events));
     if (!empty($events)) {
         $postdata = General::getPostData();
         $events_ordered = array();
         foreach ($events as $handle) {
             $events_ordered[] = Event::loadFromHandle($handle);
         }
         uasort($events_ordered, array($this, '__cbSortEventsByPriority'));
         foreach ($events_ordered as $e) {
             if (!$e->canTrigger($postdata)) {
                 continue;
             }
             $fragment = $e->trigger($ParameterOutput, $postdata);
             if ($fragment instanceof DOMDocument && !is_null($fragment->documentElement)) {
                 $node = $this->document->importNode($fragment->documentElement, true);
                 $events_wrapper->appendChild($node);
             }
         }
     }
     ####
     # Delegate: FrontendDataSourceAppend
     # Description: Append additional DataSources.
     # Global: Yes
     Extension::notify('FrontendDataSourcesAppend', '/frontend/', array('datasources' => &$datasources));
     //	Find dependancies and order accordingly
     $datasource_pool = array();
     $dependency_list = array();
     $datasources_ordered = array();
     $all_dependencies = array();
     foreach ($datasources as $handle) {
         $datasource_pool[$handle] = Datasource::loadFromHandle($handle);
         $dependency_list[$handle] = $datasource_pool[$handle]->parameters()->dependencies;
     }
     $datasources_ordered = General::dependenciesSort($dependency_list);
     $data = $this->document->createElement('data');
     if (!empty($datasources_ordered)) {
         foreach ($datasources_ordered as $handle) {
             $ds = $datasource_pool[$handle];
             try {
                 $fragment = $ds->render($ParameterOutput);
             } catch (FrontendPageNotFoundException $e) {
                 FrontendPageNotFoundExceptionHandler::render($e);
             }
             if ($fragment instanceof DOMDocument && !is_null($fragment->documentElement)) {
                 $node = $this->document->importNode($fragment->documentElement, true);
                 $data->appendChild($node);
             }
         }
     }
     $root->appendChild($data);
     /*
     			if($ParameterOutput->length() > 0){
     				foreach($ParameterOutput as $p){
     					$Parameters->{$p->key} = $p->value;
     				}
     			}
     
     			####
     			# Delegate: FrontendParamsPostResolve
     			# Description: Access to the resolved param pool, including additional parameters provided by Data Source outputs
     			# Global: Yes
     			Extension::notify('FrontendParamsPostResolve', '/frontend/', array('params' => $Parameters));
     
     
     			####
     			# Delegate: FrontendTemplatePreRender
     			# Description: Access to the template source, before it is rendered.
     			# Global: Yes
     			Extension::notify(
     				'FrontendTemplatePreRender', '/frontend/', array(
     					'document'	=> $Document,
     					'template'	=> &$template
     				)
     			);
     */
     return $this->transform();
 }
开发者ID:symphonycms,项目名称:symphony-3,代码行数:95,代码来源:class.frontendview.php


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