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


PHP ArrayHelper::toObject方法代码示例

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


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

示例1:

 /**
  * Method to get an object.
  *
  * @param   integer  $id  The id of the object to get.
  *
  * @return  mixed    Object on success, false on failure.
  */
 public function &getData($id = null)
 {
     if ($this->_item === null) {
         $this->_item = false;
         if (empty($id)) {
             $id = $this->getState('course.id');
         }
         // Get a level row instance.
         $table = $this->getTable();
         // Attempt to load the row.
         if ($table->load($id)) {
             // Check published state.
             if ($published = $this->getState('filter.published')) {
                 if ($table->state != $published) {
                     return $this->_item;
                 }
             }
             // Convert the JTable to a clean JObject.
             $properties = $table->getProperties(1);
             $this->_item = ArrayHelper::toObject($properties, 'JObject');
         }
     }
     if (isset($this->_item->created_by)) {
         $this->_item->created_by_name = JFactory::getUser($this->_item->created_by)->name;
     }
     return $this->_item;
 }
开发者ID:rutvikd,项目名称:ak-recipes,代码行数:34,代码来源:course.php

示例2: onCanEdit

 /**
  * Can the row be edited
  *
  * @param   object  $row  Current row to test
  *
  * @return boolean
  */
 public function onCanEdit($row)
 {
     $params = $this->getParams();
     // If $row is null, we were called from the list's canEdit() in a per-table rather than per-row context,
     // and we don't have an opinion on per-table edit permissions, so just return true.
     if (is_null($row) || is_null($row[0])) {
         return true;
     }
     if (is_array($row[0])) {
         $data = ArrayHelper::toObject($row[0]);
     } else {
         $data = $row[0];
     }
     /**
      * If __pk_val is not set or empty, then we've probably been called from somewhere in form processing,
      * and this is a new row.  In which case this plugin cannot offer any opinion!
      */
     if (!isset($data->__pk_val) || empty($data->__pk_val)) {
         return true;
     }
     $field = str_replace('.', '___', $params->get('caneditrow_field'));
     // If they provided some PHP to eval, we ignore the other settings and just run their code
     $caneditrow_eval = $params->get('caneditrow_eval', '');
     // $$$ rob if no can edit field selected in admin return true
     if (trim($field) == '' && trim($caneditrow_eval) == '') {
         $this->acl[$data->__pk_val] = true;
         return true;
     }
     if (!empty($caneditrow_eval)) {
         $w = new FabrikWorker();
         $data = ArrayHelper::fromObject($data);
         $caneditrow_eval = $w->parseMessageForPlaceHolder($caneditrow_eval, $data);
         FabrikWorker::clearEval();
         $caneditrow_eval = @eval($caneditrow_eval);
         FabrikWorker::logEval($caneditrow_eval, 'Caught exception on eval in can edit row : %s');
         $this->acl[$data['__pk_val']] = $caneditrow_eval;
         return $caneditrow_eval;
     } else {
         // No PHP given, so just do a simple match on the specified element and value settings.
         if ($params->get('caneditrow_useraw', '0') == '1') {
             $field .= '_raw';
         }
         $value = $params->get('caneditrow_value');
         $operator = $params->get('operator', '=');
         if (is_object($data->{$field})) {
             $data->{$field} = ArrayHelper::fromObject($data->{$field});
         }
         switch ($operator) {
             case '=':
             default:
                 $return = is_array($data->{$field}) ? in_array($value, $data->{$field}) : $data->{$field} == $value;
                 break;
             case "!=":
                 $return = is_array($data->{$field}) ? !in_array($value, $data->{$field}) : $data->{$field} != $value;
                 break;
         }
         $this->acl[$data->__pk_val] = $return;
         return $return;
     }
 }
开发者ID:jfquestiaux,项目名称:fabrik,代码行数:67,代码来源:caneditrow.php

示例3: getItem

 /**
  * Method to get an object.
  *
  * @param   integer  $id  The id of the object to get.
  *
  * @return  mixed  Object on success, false on failure.
  */
 public function getItem($id = null)
 {
     if ($this->_item === null) {
         $this->_item = false;
         if (empty($id)) {
             $id = $this->getState('weblink.id');
         }
         // Get a level row instance.
         $table = JTable::getInstance('Weblink', 'WeblinksTable');
         // Attempt to load the row.
         if ($table->load($id)) {
             // Check published state.
             if ($published = $this->getState('filter.published')) {
                 if ($table->state != $published) {
                     return $this->_item;
                 }
             }
             // Convert the JTable to a clean JObject.
             $properties = $table->getProperties(1);
             $this->_item = ArrayHelper::toObject($properties, 'JObject');
         } elseif ($error = $table->getError()) {
             $this->setError($error);
         }
     }
     return $this->_item;
 }
开发者ID:rdeutz,项目名称:weblinks,代码行数:33,代码来源:weblink.php

示例4: getItem

 /**
  * Method to get article data.
  *
  * @param   integer  $itemId  The id of the article.
  *
  * @return  mixed  Content item data object on success, false on failure.
  */
 public function getItem($itemId = null)
 {
     $itemId = (int) (!empty($itemId)) ? $itemId : $this->getState('article.id');
     // Get a row instance.
     $table = $this->getTable();
     // Attempt to load the row.
     $return = $table->load($itemId);
     // Check for a table object error.
     if ($return === false && $table->getError()) {
         $this->setError($table->getError());
         return false;
     }
     $properties = $table->getProperties(1);
     $value = ArrayHelper::toObject($properties, 'JObject');
     // Convert attrib field to Registry.
     $value->params = new Registry();
     $value->params->loadString($value->attribs);
     // Compute selected asset permissions.
     $user = JFactory::getUser();
     $userId = $user->get('id');
     $asset = 'com_content.article.' . $value->id;
     // Check general edit permission first.
     if ($user->authorise('core.edit', $asset)) {
         $value->params->set('access-edit', true);
     } elseif (!empty($userId) && $user->authorise('core.edit.own', $asset)) {
         // Check for a valid user and that they are the owner.
         if ($userId == $value->created_by) {
             $value->params->set('access-edit', true);
         }
     }
     // Check edit state permission.
     if ($itemId) {
         // Existing item
         $value->params->set('access-change', $user->authorise('core.edit.state', $asset));
     } else {
         // New item.
         $catId = (int) $this->getState('article.catid');
         if ($catId) {
             $value->params->set('access-change', $user->authorise('core.edit.state', 'com_content.category.' . $catId));
             $value->catid = $catId;
         } else {
             $value->params->set('access-change', $user->authorise('core.edit.state', 'com_content'));
         }
     }
     $value->articletext = $value->introtext;
     if (!empty($value->fulltext)) {
         $value->articletext .= '<hr id="system-readmore" />' . $value->fulltext;
     }
     // Convert the metadata field to an array.
     $registry = new Registry();
     $registry->loadString($value->metadata);
     $value->metadata = $registry->toArray();
     if ($itemId) {
         $value->tags = new JHelperTags();
         $value->tags->getTagIds($value->id, 'com_content.article');
         $value->metadata['tags'] = $value->tags;
     }
     return $value;
 }
开发者ID:adjaika,项目名称:J3Base,代码行数:66,代码来源:form.php

示例5: getInput

 /**
  * Method to get the field input markup.
  *
  * @return	string	The field input markup.
  */
 protected function getInput()
 {
     JText::script('COM_FABRIK_SUBOPTS_VALUES_ERROR');
     $default = new stdClass();
     $default->sub_values = array();
     $default->sub_labels = array();
     $default->sub_initial_selection = array();
     $opts = $this->value == '' ? $default : ArrayHelper::toObject($this->value);
     $j3 = FabrikWorker::j3();
     if ($j3) {
         $delButton = '<div class="btn-group">';
         $delButton .= '<a class="btn btn-success" href="#" data-button="addSuboption"><i class="icon-plus"></i> </a>';
         $delButton .= '<a class="btn btn-danger" href="#" data-button="deleteSuboption"><i class="icon-minus"></i> </a>';
         $delButton .= '</div>';
     } else {
         $delButton = '<a class="removeButton" href="#"><i class="icon-minus"></i> ' . FText::_('COM_FABRIK_DELETE') . '</a>';
     }
     if (is_array($opts)) {
         $opts['delButton'] = $delButton;
     } else {
         $opts->delButton = $delButton;
     }
     $opts->id = $this->id;
     $opts->j3 = $j3;
     $opts->defaultMax = (int) $this->getAttribute('default_max', 0);
     $opts = json_encode($opts);
     $script[] = "window.addEvent('domready', function () {";
     $script[] = "\tnew Suboptions('{$this->name}', {$opts});";
     $script[] = "});";
     FabrikHelperHTML::script('administrator/components/com_fabrik/models/fields/suboptions.js', implode("\n", $script));
     $html = array();
     if (!$j3) {
         $html[] = '<div style="float:left;width:100%">';
     }
     $html[] = '<table class="table table-striped" style="width: 100%" id="' . $this->id . '">';
     $html[] = '<thead>';
     $html[] = '<tr style="text-align:left">';
     $html[] = '<th style="width: 5%"></th>';
     $html[] = '<th style="width: 30%">' . FText::_('COM_FABRIK_VALUE') . '</th>';
     $html[] = '<th style="width: 30%">' . FText::_('COM_FABRIK_LABEL') . '</th>';
     $html[] = '<th style="width: 10%">' . FText::_('COM_FABRIK_DEFAULT') . '</th>';
     if ($j3) {
         $html[] = '<th style="width: 20%"><a class="btn btn-success" href="#" data-button="addSuboption"><i class="icon-plus"></i> </a></th>';
     }
     $html[] = '</tr>';
     $html[] = '</thead>';
     $html[] = '<tbody></tbody>';
     $html[] = '</table>';
     if (!$j3) {
         $html[] = '<ul id="sub_subElementBody" class="subelements">';
         $html[] = '<li></li>';
         $html[] = '</ul>';
         $html[] = '<a class="addButton" href="#" id="addSuboption"><i class="icon-plus"></i> ' . FText::_('COM_FABRIK_ADD') . '</a></div>';
     }
     FabrikHelperHTML::framework();
     FabrikHelperHTML::iniRequireJS();
     return implode("\n", $html);
 }
开发者ID:glauberm,项目名称:cinevi,代码行数:63,代码来源:suboptions.php

示例6: toObject

 /**
  * Utility function to map an array to a stdClass object.
  *
  * @param   array    &$array     The array to map.
  * @param   string   $class      Name of the class to create
  * @param   boolean  $recursive  Convert also any array inside the main array
  *
  * @return  object   The object mapped from the given array
  *
  * @since   11.1
  * @deprecated  4.0 Use Joomla\Utilities\ArrayHelper::toObject instead
  */
 public static function toObject(&$array, $class = 'stdClass', $recursive = true)
 {
     $obj = null;
     if (is_array($array)) {
         $obj = ArrayHelper::toObject($array, $class, $recursive);
     } else {
         JLog::add('This method is typehinted to be an array in \\Joomla\\Utilities\\ArrayHelper::toObject.', JLog::WARNING, 'deprecated');
     }
     return $obj;
 }
开发者ID:joomla-projects,项目名称:media-manager-improvement,代码行数:22,代码来源:arrayhelper.php

示例7: setup

 /**
  * Method to setup the configuration file
  *
  * @param   array  $options  The session options
  *
  * @return  boolean  True on success
  *
  * @since   3.1
  */
 public function setup($options)
 {
     // Get the options as an object for easier handling.
     $options = ArrayHelper::toObject($options);
     // Attempt to create the root user.
     if (!$this->createConfiguration($options)) {
         return false;
     }
     // Attempt to create the root user.
     if (!$this->createRootUser($options)) {
         return false;
     }
     return true;
 }
开发者ID:kshitijSharma2014,项目名称:joomla-cms,代码行数:23,代码来源:configuration.php

示例8: onCanDelete

 /**
  * Can the row be deleted
  *
  * @param   object  $row  Current row to test
  *
  * @return boolean
  */
 public function onCanDelete($row)
 {
     $params = $this->getParams();
     // If $row is null, we were called from the table's canEdit() in a per-table rather than per-row context,
     // and we don't have an opinion on per-table delete permissions, so just return true.
     if (is_null($row) || is_null($row[0])) {
         return true;
     }
     if (is_array($row[0])) {
         $data = ArrayHelper::toObject($row[0]);
     } else {
         $data = $row[0];
     }
     $field = str_replace('.', '___', $params->get('candeleterow_field'));
     // If they provided some PHP to eval, we ignore the other settings and just run their code
     $canDeleteRowEval = $params->get('candeleterow_eval', '');
     // $$$ rob if no can delete field selected in admin return true
     if (trim($field) == '' && trim($canDeleteRowEval) == '') {
         return true;
     }
     if (!empty($canDeleteRowEval)) {
         $w = new FabrikWorker();
         $data = ArrayHelper::fromObject($data);
         $canDeleteRowEval = $w->parseMessageForPlaceHolder($canDeleteRowEval, $data);
         FabrikWorker::clearEval();
         $canDeleteRowEval = @eval($canDeleteRowEval);
         FabrikWorker::logEval($canDeleteRowEval, 'Caught exception on eval in can delete row : %s');
         return $canDeleteRowEval;
     } else {
         // No PHP given, so just do a simple match on the specified element and value settings.
         if ($params->get('candeleterow_useraw', '0') == '1') {
             $field .= '_raw';
         }
         $value = $params->get('candeleterow_value');
         $operator = $params->get('operator', '=');
         if (!isset($data->{$field})) {
             return false;
         }
         switch ($operator) {
             case '=':
             default:
                 return $data->{$field} == $value;
                 break;
             case "!=":
                 return $data->{$field} != $value;
                 break;
         }
     }
 }
开发者ID:jfquestiaux,项目名称:fabrik,代码行数:56,代码来源:candeleterow.php

示例9: getCanonicalLink

 /**
  * Set the canonical link - this is the definitive URL that Google et all, will use
  * to determine if duplicate URLs are the same content
  *
  * @return  string
  */
 public function getCanonicalLink()
 {
     $url = '';
     if (!$this->app->isAdmin() && !$this->isMambot) {
         /** @var FabrikFEModelForm $model */
         $model = $this->getModel();
         $data = $model->getData();
         $formId = $model->getId();
         $slug = $model->getListModel()->getSlug(ArrayHelper::toObject($data));
         $rowId = $slug === '' ? $model->getRowId() : $slug;
         $view = $model->isEditable() ? 'form' : 'details';
         $url = JRoute::_('index.php?option=com_' . $this->package . '&view=' . $view . '&formid=' . $formId . '&rowid=' . $rowId);
     }
     return $url;
 }
开发者ID:glauberm,项目名称:cinevi,代码行数:21,代码来源:view.html.php

示例10: getItem

 /**
  * Method to get a single record.
  *
  * @param   integer  $pk  The id of the primary key.
  *
  * @return  mixed    Object on success, false on failure.
  */
 public function getItem($pk = null)
 {
     $pk = !empty($pk) ? $pk : $this->state->get($this->getName() . '.id');
     $table = $this->getTable();
     if ($pk > 0) {
         // Attempt to load the row.
         $table->load($pk);
     }
     // Convert to the JObject before adding other data.
     $properties = $table->getProperties(1);
     $item = ArrayHelper::toObject($properties, 'stdClass');
     if (!$item) {
         return $item;
     }
     if (property_exists($item, 'params')) {
         $registry = new \JRegistry();
         $registry->loadString($item->params);
         $item->params = $registry->toArray();
     }
     $this->postGetItem($item);
     return $item;
 }
开发者ID:Biromain,项目名称:windwalker-joomla-rad,代码行数:29,代码来源:ItemModel.php

示例11: getItem

 /**
  * Method to get an object.
  *
  * @param    int  $id  The id of the object to get.
  * @param    int  $userId  User ID.
  *
  * @return    mixed    Object on success, false on failure.
  */
 public function getItem($id, $userId)
 {
     // If missing ID, I have to return null, because there is no item.
     if (!$id or !$userId) {
         return null;
     }
     $storedId = $this->getStoreId($id);
     if (!isset($this->item[$storedId])) {
         $this->item[$storedId] = null;
         // Get a level row instance.
         $table = JTable::getInstance('Notification', 'GamificationTable');
         /** @var $table GamificationTableNotification */
         $keys = array("id" => $id, "user_id" => $userId);
         // Attempt to load the row.
         if ($table->load($keys)) {
             $properties = $table->getProperties();
             $properties = ArrayHelper::toObject($properties);
             $this->item[$storedId] = $properties;
         }
     }
     return !isset($this->item[$storedId]) ? null : $this->item[$storedId];
 }
开发者ID:bellodox,项目名称:GamificationPlatform,代码行数:30,代码来源:notification.php

示例12: verifyFtpSettings

 /**
  * Verify the FTP settings as being functional and correct.
  *
  * @param   array  $options  Configuration options.
  *
  * @return  mixed  FTP root for given FTP user, or boolean false if not found.
  *
  * @since   3.1
  */
 public function verifyFtpSettings($options)
 {
     // Get the options as a object for easier handling.
     $options = ArrayHelper::toObject($options);
     // Connect and login to the FTP server.
     @($ftp = JClientFtp::getInstance($options->get('ftp_host'), $options->get('ftp_port')));
     // Check to make sure FTP is connected and authenticated.
     if (!$ftp->isConnected()) {
         JFactory::getApplication()->enqueueMessage(JText::_('INSTL_FTP_NOCONNECT'), 'error');
         return false;
     }
     if (!$ftp->login($options->get('ftp_user'), $options->get('ftp_pass'))) {
         $ftp->quit();
         JFactory::getApplication()->enqueueMessage(JText::_('INSTL_FTP_NOLOGIN'), 'error');
         return false;
     }
     // Since the root path will be trimmed when it gets saved to configuration.php,
     // we want to test with the same value as well.
     $root = rtrim($options->get('ftp_root'), '/');
     // Verify PWD function.
     if ($ftp->pwd() === false) {
         $ftp->quit();
         JFactory::getApplication()->enqueueMessage(JText::_('INSTL_FTP_NOPWD'), 'error');
         return false;
     }
     // Verify root path exists.
     if (!$ftp->chdir($root)) {
         $ftp->quit();
         JFactory::getApplication()->enqueueMessage(JText::_('INSTL_FTP_NOROOT'), 'error');
         return false;
     }
     // Verify NLST function.
     if (($rootList = $ftp->listNames()) === false) {
         $ftp->quit();
         JFactory::getApplication()->enqueueMessage(JText::_('INSTL_FTP_NONLST'), 'error');
         return false;
     }
     // Verify LIST function.
     if ($ftp->listDetails() === false) {
         $ftp->quit();
         JFactory::getApplication()->enqueueMessage(JText::_('INSTL_FTP_NOLIST'), 'error');
         return false;
     }
     // Verify SYST function.
     if ($ftp->syst() === false) {
         $ftp->quit();
         JFactory::getApplication()->enqueueMessage(JText::_('INSTL_FTP_NOSYST'), 'error');
         return false;
     }
     // Verify valid root path, part one.
     $checkList = array('robots.txt', 'index.php');
     if (count(array_diff($checkList, $rootList))) {
         $ftp->quit();
         JFactory::getApplication()->enqueueMessage(JText::_('INSTL_FTP_INVALIDROOT'), 'error');
         return false;
     }
     // Verify RETR function
     $buffer = null;
     if ($ftp->read($root . '/libraries/cms/version/version.php', $buffer) === false) {
         $ftp->quit();
         JFactory::getApplication()->enqueueMessage(JText::_('INSTL_FTP_NORETR'), 'error');
         return false;
     }
     // Verify valid root path, part two.
     $checkValue = file_get_contents(JPATH_ROOT . '/libraries/cms/version/version.php');
     if ($buffer !== $checkValue) {
         $ftp->quit();
         JFactory::getApplication()->enqueueMessage(JText::_('INSTL_FTP_INVALIDROOT'), 'error');
         return false;
     }
     // Verify STOR function.
     if ($ftp->create($root . '/ftp_testfile') === false) {
         $ftp->quit();
         JFactory::getApplication()->enqueueMessage(JText::_('INSTL_FTP_NOSTOR'), 'error');
         return false;
     }
     // Verify DELE function.
     if ($ftp->delete($root . '/ftp_testfile') === false) {
         $ftp->quit();
         JFactory::getApplication()->enqueueMessage(JText::_('INSTL_FTP_NODELE'), 'error');
         return false;
     }
     // Verify MKD function.
     if ($ftp->mkdir($root . '/ftp_testdir') === false) {
         $ftp->quit();
         JFactory::getApplication()->enqueueMessage(JText::_('INSTL_FTP_NOMKD'), 'error');
         return false;
     }
     // Verify RMD function.
     if ($ftp->delete($root . '/ftp_testdir') === false) {
         $ftp->quit();
//.........这里部分代码省略.........
开发者ID:joomla-projects,项目名称:media-manager-improvement,代码行数:101,代码来源:ftp.php

示例13: installSampleData

 /**
  * Method to install the sample data.
  *
  * @param   array  $options  The options array.
  *
  * @return  boolean  True on success.
  *
  * @since   3.1
  */
 public function installSampleData($options)
 {
     if (!isset($options['db_created']) || !$options['db_created']) {
         return $this->createDatabase($options);
     }
     if (!($db = $this->initialise($options))) {
         return false;
     }
     // Get the options as an object for easier handling.
     $options = ArrayHelper::toObject($options);
     // Build the path to the sample data file.
     $type = $options->db_type;
     if ($type == 'mysqli' || $type == 'pdomysql') {
         $type = 'mysql';
     } elseif ($type == 'sqlsrv') {
         $type = 'sqlazure';
     }
     $data = JPATH_INSTALLATION . '/sql/' . $type . '/' . $options->sample_file;
     // Attempt to import the database schema if one is chosen.
     if ($options->sample_file != '') {
         if (!file_exists($data)) {
             JFactory::getApplication()->enqueueMessage(JText::sprintf('INSTL_DATABASE_FILE_DOES_NOT_EXIST', $data), 'error');
             return false;
         } elseif (!$this->populateDatabase($db, $data)) {
             return false;
         }
         $this->postInstallSampleData($db);
     }
     return true;
 }
开发者ID:eshiol,项目名称:joomla-cms,代码行数:39,代码来源:database.php

示例14: getRow

 /**
  * Get a row of data from the table
  *
  * @param   int   $id        Id
  * @param   bool  $format    The data
  * @param   bool  $loadJoin  Load the rows joined data @since 2.0.5 (used in J Content plugin)
  *
  * @return  object	Row
  */
 public function getRow($id, $format = false, $loadJoin = false)
 {
     if (is_null($this->rows)) {
         $this->rows = array();
     }
     $sig = $id . '.' . $format . '.' . $loadJoin;
     if (array_key_exists($sig, $this->rows)) {
         return $this->rows[$sig];
     }
     $fabrikDb = $this->getDb();
     $formModel = $this->getFormModel();
     $formModel->reset();
     $this->reset();
     $formModel->rowId = $id;
     $sql = $formModel->buildQuery();
     $fabrikDb->setQuery($sql);
     if (!$loadJoin) {
         if ($format == true) {
             $row = $fabrikDb->loadObject();
             $row = array($row);
             $this->formatData($row);
             /* $$$ hugh - if table is grouped, formatData will have turned $row into an
              * assoc array, so can't assume 0 is first key.
              * $this->rows[$sig] = $row[0][0];
              */
             $row = FArrayHelper::getValue($row, FArrayHelper::firstKey($row), array());
             $this->rows[$sig] = FArrayHelper::getValue($row, 0, new stdClass());
         } else {
             $this->rows[$sig] = $fabrikDb->loadObject();
         }
     } else {
         $rows = $fabrikDb->loadObjectList();
         $formModel->setJoinData($rows);
         if ($format == true) {
             $rows = array(ArrayHelper::toObject($rows));
             $this->formatData($rows);
             $rows = $rows[0];
             /* $$$ hugh - if list is grouped, formatData will have re-index as assoc array,
             			 /* so can't assume 0 is first key.
             			*/
             $this->rows[$sig] = FArrayHelper::getValue($rows, FArrayHelper::firstKey($rows), array());
         } else {
             // Content plugin - rows is 1 dimensional array
             $this->rows[$sig] = $rows;
         }
     }
     if (is_array($this->rows[$sig])) {
         $this->rows[$sig] = ArrayHelper::toObject($this->rows[$sig]);
     }
     return $this->rows[$sig];
 }
开发者ID:pascal26,项目名称:fabrik,代码行数:60,代码来源:list.php

示例15: explode

 /**
  * Method to get an object.
  *
  * @param   integer  $id  The id of the object to get.
  *
  * @return  mixed    Object on success, false on failure.
  */
 public function &getData($id = null)
 {
     if ($this->_item === null) {
         $this->_item = false;
         if (empty($id)) {
             $id = $this->getState('recipe.id');
         }
         // Get a level row instance.
         $table = $this->getTable();
         // Attempt to load the row.
         if ($table->load($id)) {
             // Check published state.
             if ($published = $this->getState('filter.published')) {
                 if ($table->state != $published) {
                     return $this->_item;
                 }
             }
             // Convert the JTable to a clean JObject.
             $properties = $table->getProperties(1);
             $this->_item = ArrayHelper::toObject($properties, 'JObject');
         }
     }
     if (isset($this->_item->tags)) {
         // Catch the item tags (string with ',' coma glue)
         $tags = explode(",", $this->_item->tags);
         $db = JFactory::getDbo();
         $namedTags = array();
         // Cleaning and initalization of named tags array
         // Get the tag names of each tag id
         foreach ($tags as $tag) {
             $query = $db->getQuery(true);
             $query->select("title");
             $query->from('`#__tags`');
             $query->where("id=" . intval($tag));
             $db->setQuery($query);
             $row = $db->loadObjectList();
             // Read the row and get the tag name (title)
             if (!is_null($row)) {
                 foreach ($row as $value) {
                     if ($value && isset($value->title)) {
                         $namedTags[] = trim($value->title);
                     }
                 }
             }
         }
         // Finally replace the data object with proper information
         if (!empty($namedTags)) {
             $this->_item->tags = implode(', ', $namedTags);
         } else {
             $this->_item->tags = !empty($this->_item->my_tags) ? $this->_item->my_tags : "";
         }
     }
     if (isset($this->_item->cuisines_id) && $this->_item->cuisines_id != '') {
         if (is_object($this->_item->cuisines_id)) {
             $this->_item->cuisines_id = JArrayHelper::fromObject($this->_item->cuisines_id);
         }
         $values = is_array($this->_item->cuisines_id) ? $this->_item->cuisines_id : explode(',', $this->_item->cuisines_id);
         $textValue = array();
         foreach ($values as $value) {
             $db = JFactory::getDbo();
             $query = $db->getQuery(true);
             $query->select('name')->from('`#__akrecipes_cuisines`')->where('id = ' . $db->quote($db->escape($value)));
             $db->setQuery($query);
             $results = $db->loadObject();
             if ($results) {
                 $textValue[] = $results->name;
             }
         }
         $this->_item->cuisines_id = !empty($textValue) ? implode(', ', $textValue) : $this->_item->cuisines_id;
     }
     if (isset($this->_item->meal_course_id) && $this->_item->meal_course_id != '') {
         if (is_object($this->_item->meal_course_id)) {
             $this->_item->meal_course_id = JArrayHelper::fromObject($this->_item->meal_course_id);
         }
         $values = is_array($this->_item->meal_course_id) ? $this->_item->meal_course_id : explode(',', $this->_item->meal_course_id);
         $textValue = array();
         foreach ($values as $value) {
             $db = JFactory::getDbo();
             $query = $db->getQuery(true);
             $query->select('name')->from('`#__akrecipes_meal_course`')->where('id = ' . $db->quote($db->escape($value)));
             $db->setQuery($query);
             $results = $db->loadObject();
             if ($results) {
                 $textValue[] = $results->name;
             }
         }
         $this->_item->meal_course_id = !empty($textValue) ? implode(', ', $textValue) : $this->_item->meal_course_id;
     }
     if (isset($this->_item->created_by)) {
         $this->_item->created_by_name = JFactory::getUser($this->_item->created_by)->name;
     }
     if (isset($this->_item->modified_by)) {
         $this->_item->modified_by_name = JFactory::getUser($this->_item->modified_by)->name;
//.........这里部分代码省略.........
开发者ID:rutvikd,项目名称:ak-recipes,代码行数:101,代码来源:recipe.php


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