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


PHP FArrayHelper::toObject方法代码示例

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


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

示例1: getData

 /**
  * Main method to get the data to insert into the form
  *
  * @return  array  Form's data
  */
 public function getData()
 {
     // If already set return it. If not was causing issues with the juser form plugin
     // when it tried to modify the form->data info, from within its onLoad method, when sync user option turned on.
     if (isset($this->data)) {
         return $this->data;
     }
     $this->getRowId();
     $input = $this->app->input;
     $profiler = JProfiler::getInstance('Application');
     JDEBUG ? $profiler->mark('formmodel getData: start') : null;
     $this->data = array();
     $f = JFilterInput::getInstance();
     /*
      * $$$ hugh - we need to remove any elements from the query string,
      * if the user doesn't have access, otherwise ACL's on elements can
      * be bypassed by just setting value on form load query string!
      */
     $clean_request = $f->clean($_REQUEST, 'array');
     foreach ($clean_request as $key => $value) {
         $test_key = FabrikString::rtrimword($key, '_raw');
         $elementModel = $this->getElement($test_key, false, false);
         if ($elementModel !== false) {
             if (!$elementModel->canUse()) {
                 unset($clean_request[$key]);
             }
         }
     }
     $data = $clean_request;
     $form = $this->getForm();
     $this->getGroupsHiarachy();
     JDEBUG ? $profiler->mark('formmodel getData: groups loaded') : null;
     if (!$form->record_in_database) {
         FabrikHelperHTML::debug($data, 'form:getData from $_REQUEST');
         $data = $f->clean($_REQUEST, 'array');
     } else {
         JDEBUG ? $profiler->mark('formmodel getData: start get list model') : null;
         $listModel = $this->getListModel();
         JDEBUG ? $profiler->mark('formmodel getData: end get list model') : null;
         $fabrikDb = $listModel->getDb();
         JDEBUG ? $profiler->mark('formmodel getData: db created') : null;
         $listModel->getTable();
         JDEBUG ? $profiler->mark('formmodel getData: table row loaded') : null;
         $this->aJoinObjs = $listModel->getJoins();
         JDEBUG ? $profiler->mark('formmodel getData: joins loaded') : null;
         if ($this->hasErrors()) {
             // $$$ hugh - if we're a mambot, reload the form session state we saved in
             // process() when it banged out.
             if ($this->isMambot) {
                 $sessionRow = $this->getSessionData();
                 $this->sessionModel->last_page = 0;
                 if ($sessionRow->data != '') {
                     $sData = unserialize($sessionRow->data);
                     $data = FArrayHelper::toObject($sData, 'stdClass', false);
                     JFilterOutput::objectHTMLSafe($data);
                     $data = array($data);
                     FabrikHelperHTML::debug($data, 'form:getData from session (form in Mambot and errors)');
                 }
             } else {
                 // $$$ rob - use setFormData rather than $_GET
                 // as it applies correct input filtering to data as defined in article manager parameters
                 $data = $this->setFormData();
                 $data = FArrayHelper::toObject($data, 'stdClass', false);
                 // $$$rob ensure "<tags>text</tags>" that are entered into plain text areas are shown correctly
                 JFilterOutput::objectHTMLSafe($data);
                 $data = ArrayHelper::fromObject($data);
                 FabrikHelperHTML::debug($data, 'form:getData from POST (form not in Mambot and errors)');
             }
         } else {
             $sessionLoaded = false;
             // Test if its a resumed paged form
             if ($this->saveMultiPage()) {
                 $sessionRow = $this->getSessionData();
                 JDEBUG ? $profiler->mark('formmodel getData: session data loaded') : null;
                 if ($sessionRow->data != '') {
                     $sessionLoaded = true;
                     /*
                      * $$$ hugh - this chunk should probably go in setFormData, but don't want to risk any side effects just now
                      * problem is that later failed validation, non-repeat join element data is not formatted as arrays,
                      * but from this point on, code is expecting even non-repeat join data to be arrays.
                      */
                     $tmp_data = unserialize($sessionRow->data);
                     $groups = $this->getGroupsHiarachy();
                     foreach ($groups as $groupModel) {
                         if ($groupModel->isJoin() && !$groupModel->canRepeat()) {
                             foreach ($tmp_data['join'][$groupModel->getJoinId()] as &$el) {
                                 $el = array($el);
                             }
                         }
                     }
                     $bits = $data;
                     $bits = array_merge($tmp_data, $bits);
                     //$data = array(FArrayHelper::toObject($bits));
                     $data = $bits;
                     FabrikHelperHTML::debug($data, 'form:getData from session (form not in Mambot and no errors');
//.........这里部分代码省略.........
开发者ID:glauberm,项目名称:cinevi,代码行数:101,代码来源:form.php

示例2: getData

 /**
  * main method to get the data to insert into the form
  * @return	array	form's data
  */
 function getData()
 {
     //if already set return it. If not was causing issues with the juser form plugin
     // when it tried to modify the form->_data info, from within its onLoad method, when sync user option turned on.
     if (isset($this->_data)) {
         return $this->_data;
     }
     $profiler = JProfiler::getInstance('Application');
     $this->_data = array();
     $data = array(FArrayHelper::toObject(JRequest::get('request')));
     $form = $this->getForm();
     $aGroups = $this->getGroupsHiarachy();
     JDEBUG ? $profiler->mark('formmodel getData: groups loaded') : null;
     if (!$form->record_in_database) {
         FabrikHelperHTML::debug($data, 'form:getData from $_REQUEST');
         $data = JRequest::get('request');
     } else {
         $listModel = $this->getListModel();
         $fabrikDb = $listModel->getDb();
         JDEBUG ? $profiler->mark('formmodel getData: db created') : null;
         $item = $listModel->getTable();
         JDEBUG ? $profiler->mark('formmodel getData: table row loaded') : null;
         $this->_aJoinObjs =& $listModel->getJoins();
         JDEBUG ? $profiler->mark('formmodel getData: joins loaded') : null;
         if (!empty($this->_arErrors)) {
             // $$$ hugh - if we're a mambot, reload the form session state we saved in
             // process() when it banged out.
             if ($this->isMambot) {
                 $srow = $this->getSessionData();
                 $this->sessionModel->last_page = 0;
                 if ($srow->data != '') {
                     $data = FArrayHelper::toObject(unserialize($srow->data), 'stdClass', false);
                     JFilterOutput::objectHTMLSafe($data);
                     $data = array($data);
                     FabrikHelperHTML::debug($data, 'form:getData from session (form in Mambot and errors)');
                 }
             } else {
                 // $$$ rob - use setFormData rather than JRequest::get()
                 //as it applies correct input filtering to data as defined in article manager parameters
                 $data = $this->setFormData();
                 $data = FArrayHelper::toObject($data, 'stdClass', false);
                 //$$$rob ensure "<tags>text</tags>" that are entered into plain text areas are shown correctly
                 JFilterOutput::objectHTMLSafe($data);
                 $data = array($data);
                 FabrikHelperHTML::debug($data, 'form:getData from POST (form not in Mambot and errors)');
             }
         } else {
             //test if its a resumed paged form
             $srow = $this->getSessionData();
             JDEBUG ? $profiler->mark('formmodel getData: session data loaded') : null;
             if ($this->saveMultiPage() && $srow->data != '') {
                 $data = array(FArrayHelper::toObject(array_merge(unserialize($srow->data), JArrayHelper::fromObject($data[0]))));
                 FabrikHelperHTML::debug($data, 'form:getData from session (form not in Mambot and no errors');
             } else {
                 // only try and get the row data if its an active record
                 //use !== 0 as rowid may be alphanumeric
                 // $$$ hugh - when 'usekey', rowid can actually be 0 (like if using userid and this is guest access)
                 // so go ahead and try and load the row, if it doesn't exist, we'll supress the warning
                 $usekey = FabrikWorker::getMenuOrRequestVar('usekey', '', $this->isMambot);
                 if (!empty($usekey) || (int) $this->_rowId !== 0 || !is_numeric($this->_rowId) && $this->_rowId != '') {
                     // $$$ hugh - once we have a few join elements, our select statements are
                     // getting big enough to hit default select length max in MySQL.
                     $listModel->setBigSelects();
                     //otherwise lets get the table record
                     $sql = $this->_buildQuery();
                     $fabrikDb->setQuery($sql);
                     FabrikHelperHTML::debug($fabrikDb->getQuery(), 'form:render');
                     $rows = $fabrikDb->loadObjectList();
                     if (is_null($rows)) {
                         JError::raiseWarning(500, $fabrikDb->getErrorMsg());
                     }
                     JDEBUG ? $profiler->mark('formmodel getData: rows data loaded') : null;
                     //$$$ rob Ack above didnt work for joined data where there would be n rows rerutned frho "this rowid = $this->_rowId  \n";
                     if (!empty($rows)) {
                         // only do this if the query returned some rows (it wont if usekey on and userid = 0 for example)
                         $data = array();
                         foreach ($rows as &$row) {
                             if (empty($data)) {
                                 //if loading in a rowid=-1 set the row id to the actual row id
                                 $this->_rowId = isset($row->__pk_val) ? $row->__pk_val : $this->_rowId;
                             }
                             $row = empty($row) ? array() : JArrayHelper::fromObject($row);
                             $data[] = FArrayHelper::toObject(array_merge($row, JRequest::get('request')));
                         }
                     }
                     FabrikHelperHTML::debug($data, 'form:getData from querying rowid= ' . $this->_rowId . ' (form not in Mambot and no errors)');
                     // if empty data return and trying to edit a record then show error
                     //occurs if user trying to edit a record forbidden by a prefilter rull
                     if (empty($data) && $this->_rowId != '') {
                         // $$$ hugh - special case when using -1, if user doesn't have a record yet
                         if (FabrikWorker::getMenuOrRequestVar('rowid', '', $this->isMambot) == '-1') {
                             return;
                         } else {
                             // if no key found set rowid to 0 so we can insert a new record.
                             if (empty($usekey) && !$this->isMambot) {
                                 $this->_rowId = 0;
//.........这里部分代码省略.........
开发者ID:rhotog,项目名称:fabrik,代码行数:101,代码来源:form.php

示例3: getEmailValue

 /**
  * Used to format the data when shown in the form's email
  *
  * @param   mixed $value         Element's data
  * @param   array $data          Form records data
  * @param   int   $repeatCounter Repeat group counter
  *
  * @return  string    Formatted value
  */
 public function getEmailValue($value, $data = array(), $repeatCounter = 0)
 {
     $tmp = $this->_getOptions($data, $repeatCounter);
     // $$$ hugh - PLEASE LEAVE.  No, we don't use $name, but I'm in here xdebug'ing stuff frequently, I use it as a time saver.
     $name = $this->getFullName(false, true);
     if ($this->isJoin()) {
         /**
          * $$$ hugh - if it's a repeat element, we need to render it as
          * a single entity
          * $$$ hugh - sometimes it's empty, not an array, so check just to
          * stop PHP whining about it.
          */
         if (is_array($value)) {
             foreach ($value as &$v2) {
                 foreach ($tmp as $v) {
                     if ($v->value == $v2) {
                         $v2 = $v->text;
                         break;
                     }
                 }
             }
         }
         $oData = FArrayHelper::toObject($data);
         $val = $this->renderListData($value, $oData);
     } else {
         if (is_array($value)) {
             foreach ($value as &$v2) {
                 foreach ($tmp as $v) {
                     if ($v->value == $v2) {
                         $v2 = $v->text;
                         break;
                     }
                 }
             }
             $oData = FArrayHelper::toObject($data);
             $val = $this->renderListData($value, $oData);
         } else {
             foreach ($tmp as $v) {
                 if ($v->value == $value) {
                     $value = $v->text;
                     break;
                 }
             }
             $val = $this->renderListData($value, new stdClass());
         }
     }
     if ($val === $this->_getSelectLabel()) {
         $val = '';
     }
     return $val;
 }
开发者ID:glauberm,项目名称:cinevi,代码行数:60,代码来源:databasejoin.php


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