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


PHP ArrayHelper::toInteger方法代码示例

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


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

示例1: association

 /**
  * Render the list of associated items
  *
  * @param   integer  $catid      Category identifier to search its associations
  * @param   string   $extension  Category Extension
  *
  * @return  string   The language HTML
  *
  * @since   3.2
  * @throws  Exception
  */
 public static function association($catid, $extension = 'com_content')
 {
     // Defaults
     $html = '';
     // Get the associations
     if ($associations = CategoriesHelper::getAssociations($catid, $extension)) {
         $associations = ArrayHelper::toInteger($associations);
         // Get the associated categories
         $db = JFactory::getDbo();
         $query = $db->getQuery(true)->select('c.id, c.title')->select('l.sef as lang_sef')->select('l.lang_code')->from('#__categories as c')->where('c.id IN (' . implode(',', array_values($associations)) . ')')->join('LEFT', '#__languages as l ON c.language=l.lang_code')->select('l.image')->select('l.title as language_title');
         $db->setQuery($query);
         try {
             $items = $db->loadObjectList('id');
         } catch (RuntimeException $e) {
             throw new Exception($e->getMessage(), 500, $e);
         }
         if ($items) {
             foreach ($items as &$item) {
                 $text = $item->lang_sef ? strtoupper($item->lang_sef) : 'XX';
                 $url = JRoute::_('index.php?option=com_categories&task=category.edit&id=' . (int) $item->id . '&extension=' . $extension);
                 $classes = 'hasPopover label label-association label-' . $item->lang_sef;
                 $item->link = '<a href="' . $url . '" title="' . $item->language_title . '" class="' . $classes . '" data-content="' . $item->title . '" data-placement="top">' . $text . '</a>';
             }
         }
         JHtml::_('bootstrap.popover');
         $html = JLayoutHelper::render('joomla.content.associations', $items);
     }
     return $html;
 }
开发者ID:eshiol,项目名称:joomla-cms,代码行数:40,代码来源:categoriesadministrator.php

示例2: populateState

 /**
  * Method to auto-populate the model state.
  *
  * Note. Calling getState in this method will result in recursion.
  *
  * @param   string  $ordering   An optional ordering field.
  * @param   string  $direction  An optional direction (asc|desc).
  *
  * @return  void
  *
  * @since   1.6
  */
 protected function populateState($ordering = 'a.name', $direction = 'asc')
 {
     $app = JFactory::getApplication('administrator');
     // Adjust the context to support modal layouts.
     if ($layout = $app->input->get('layout', 'default', 'cmd')) {
         $this->context .= '.' . $layout;
     }
     // Load the filter state.
     $this->setState('filter.search', $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', '', 'string'));
     $this->setState('filter.active', $this->getUserStateFromRequest($this->context . '.filter.active', 'filter_active', '', 'cmd'));
     $this->setState('filter.state', $this->getUserStateFromRequest($this->context . '.filter.state', 'filter_state', '', 'cmd'));
     $this->setState('filter.group_id', $this->getUserStateFromRequest($this->context . '.filter.group_id', 'filter_group_id', null, 'int'));
     $this->setState('filter.range', $this->getUserStateFromRequest($this->context . '.filter.range', 'filter_range', '', 'cmd'));
     $this->setState('filter.lastvisitrange', $this->getUserStateFromRequest($this->context . '.filter.lastvisitrange', 'filter_lastvisitrange', '', 'cmd'));
     $groups = json_decode(base64_decode($app->input->get('groups', '', 'BASE64')));
     if (isset($groups)) {
         $groups = ArrayHelper::toInteger($groups);
     }
     $this->setState('filter.groups', $groups);
     $excluded = json_decode(base64_decode($app->input->get('excluded', '', 'BASE64')));
     if (isset($excluded)) {
         $excluded = ArrayHelper::toInteger($excluded);
     }
     $this->setState('filter.excluded', $excluded);
     // Load the parameters.
     $params = JComponentHelper::getParams('com_users');
     $this->setState('params', $params);
     // List state information.
     parent::populateState($ordering, $direction);
 }
开发者ID:adjaika,项目名称:J3Base,代码行数:42,代码来源:users.php

示例3: load

 /**
  * Load locations data by ID from database.
  *
  * <code>
  * $options = array(
  *     "ids" => array(1,2,3,4,5), // Load locations by IDs.
  *     "search" => "London" // It is a phrase for searching.
  * );
  *
  * $locations   = new Socialcommunity\Locations(JFactory::getDbo());
  * $locations->load($options);
  *
  * foreach($locations as $location) {
  *   echo $location["name"];
  *   echo $location["country_code"];
  * }
  * </code>
  *
  * @param array $options
  */
 public function load(array $options = array())
 {
     $ids = ArrayHelper::getValue($options, 'ids', array(), 'array');
     $search = ArrayHelper::getValue($options, 'search', '', 'string');
     $countryId = ArrayHelper::getValue($options, 'country_id', 0, 'int');
     ArrayHelper::toInteger($ids);
     $query = $this->db->getQuery(true);
     $query->select('a.id, a.name, a.latitude, a.longitude, a.country_code, a.state_code, a.timezone, a.published')->from($this->db->quoteName('#__itpsc_locations', 'a'));
     if (count($ids) > 0) {
         $query->where('a.id IN ( ' . implode(',', $ids) . ' )');
     }
     // Filter by country ID ( use subquery to get country code ).
     if ($countryId > 0) {
         $subQuery = $this->db->getQuery(true);
         $subQuery->select('sqc.code')->from($this->db->quoteName('#__itpsc_countries', 'sqc'))->where('sqc.id = ' . (int) $countryId);
         $query->where('a.country_code = ( ' . $subQuery . ' )');
     }
     if ($query !== null and $query !== '') {
         $escaped = $this->db->escape($search, true);
         $quoted = $this->db->quote('%' . $escaped . '%', false);
         $query->where('a.name LIKE ' . $quoted);
     }
     $this->db->setQuery($query);
     $this->items = (array) $this->db->loadAssocList('id');
 }
开发者ID:ITPrism,项目名称:SocialCommunityDistribution,代码行数:45,代码来源:Locations.php

示例4: delete

 /**
  * Remove an item.
  *
  * @return  void
  *
  * @since   1.6
  */
 public function delete()
 {
     // Check for request forgeries
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $user = JFactory::getUser();
     $app = JFactory::getApplication();
     $cids = (array) $this->input->get('cid', array(), 'array');
     if (count($cids) < 1) {
         $app->enqueueMessage(JText::_('COM_MENUS_NO_MENUS_SELECTED'), 'notice');
     } else {
         // Access checks.
         foreach ($cids as $i => $id) {
             if (!$user->authorise('core.delete', 'com_menus.menu.' . (int) $id)) {
                 // Prune items that you can't change.
                 unset($cids[$i]);
                 $app->enqueueMessage(JText::_('JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED'), 'error');
             }
         }
         if (count($cids) > 0) {
             // Get the model.
             $model = $this->getModel();
             // Make sure the item ids are integers
             $cids = ArrayHelper::toInteger($cids);
             // Remove the items.
             if (!$model->delete($cids)) {
                 $this->setMessage($model->getError());
             } else {
                 $this->setMessage(JText::plural('COM_MENUS_N_MENUS_DELETED', count($cids)));
             }
         }
     }
     $this->setRedirect('index.php?option=com_menus&view=menus');
 }
开发者ID:adjaika,项目名称:J3Base,代码行数:40,代码来源:menus.php

示例5: update

 /**
  * Update a set of extensions.
  *
  * @return  void
  *
  * @since   1.6
  */
 public function update()
 {
     // Check for request forgeries.
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     /** @var InstallerModelUpdate $model */
     $model = $this->getModel('update');
     $uid = $this->input->get('cid', array(), 'array');
     $uid = ArrayHelper::toInteger($uid, array());
     // Get the minimum stability.
     $component = JComponentHelper::getComponent('com_installer');
     $params = $component->params;
     $minimum_stability = $params->get('minimum_stability', JUpdater::STABILITY_STABLE, 'int');
     $model->update($uid, $minimum_stability);
     if ($model->getState('result', false)) {
         JFactory::getCache('mod_menu')->clean();
     }
     $app = JFactory::getApplication();
     $redirect_url = $app->getUserState('com_installer.redirect_url');
     // Don't redirect to an external URL.
     if (!JUri::isInternal($redirect_url)) {
         $redirect_url = '';
     }
     if (empty($redirect_url)) {
         $redirect_url = JRoute::_('index.php?option=com_installer&view=update', false);
     } else {
         // Wipe out the user state when we're going to redirect.
         $app->setUserState('com_installer.redirect_url', '');
         $app->setUserState('com_installer.message', '');
         $app->setUserState('com_installer.extension_message', '');
     }
     $this->setRedirect($redirect_url);
 }
开发者ID:eshiol,项目名称:joomla-cms,代码行数:39,代码来源:update.php

示例6: load

 /**
  * Load transactions from database.
  *
  * <code>
  * $options = array(
  *     "ids" => array(1,2,3),
  *     "txn_status" => "completed"
  * );
  *
  * $transactions    = new Crowdfunding\Transactions(\JFactory::getDbo());
  * $transactions->load($options);
  *
  * foreach($transactions as $transaction) {
  *   echo $transaction->txn_id;
  *   echo $transaction->txn_amount;
  * }
  *
  * </code>
  *
  * @param array $options
  *
  * @throws \UnexpectedValueException
  */
 public function load($options = array())
 {
     $ids = !array_key_exists('ids', $options) ? array() : (array) $options['ids'];
     $ids = ArrayHelper::toInteger($ids);
     $results = array();
     if (count($ids) > 0) {
         // Load project data
         $query = $this->db->getQuery(true);
         $query->select('a.id, a.txn_date, a.txn_id, a.txn_amount, a.txn_currency, a.txn_status, ' . 'a.extra_data, a.status_reason, a.project_id, a.reward_id, a.investor_id, ' . 'a.receiver_id, a.service_provider, a.service_alias, a.reward_state')->from($this->db->quoteName('#__crowdf_transactions', 'a'))->where('a.id IN ( ' . implode(',', $ids) . ' )');
         // Filter by status.
         $status = ArrayHelper::getValue($options, 'txn_status', null, 'cmd');
         if ($status !== null) {
             $query->where('a.txn_status = ' . $this->db->quote($status));
         }
         $this->db->setQuery($query);
         $results = (array) $this->db->loadAssocList();
         // Convert JSON string into an array.
         if (count($results) > 0) {
             foreach ($results as $key => &$result) {
                 if (!empty($result['extra_data'])) {
                     $result['extra_data'] = json_decode($result['extra_data'], true);
                 }
             }
             unset($result);
         }
     }
     $this->items = $results;
 }
开发者ID:bellodox,项目名称:CrowdFunding,代码行数:51,代码来源:Transactions.php

示例7: getListQuery

 /**
  * Method to get a JDatabaseQuery object for retrieving the data set from a database.
  *
  * @return  JDatabaseQuery   A JDatabaseQuery object to retrieve the data set.
  */
 protected function getListQuery()
 {
     // Create a new query object.
     $db = $this->getDbo();
     $query = $db->getQuery(true);
     $subQuery = $db->getQuery(true);
     $includeRaw = $this->state->params->get('include_issues', null);
     $excludeRaw = $this->state->params->get('exclude_issues', null);
     $includeArray = explode(',', $includeRaw);
     $excludeArray = explode(',', $excludeRaw);
     $includeArray = ArrayHelper::toInteger($includeArray);
     $excludeArray = ArrayHelper::toInteger($excludeArray);
     $subQuery->select('it.issue_id AS issue_id, it.tag_id AS tag_id, t.tag AS tag')->join('LEFT', '#__code_tags AS t ON t.tag_id = it.tag_id')->from('#__code_tracker_issue_tag_map AS it')->where('it.tag_id IN (6,10,16,20,24,26,28,51,52,55,62,65,67,74,75,78,79,82,83,87,92,93,105,107,112,115)')->group('it.issue_id, it.tag_id, t.tag');
     // Select required fields from the categories.
     $query->select('CASE WHEN ISNULL(m.tag) THEN ' . $db->quote('None') . ' ELSE m.tag END as category');
     $query->select('i.title, i.jc_issue_id, i.close_date');
     $query->from('#__code_tracker_issues AS i');
     $query->join('LEFT', '(' . (string) $subQuery . ') AS m ON i.jc_issue_id = m.issue_id');
     $query->where('((DATE(close_date) BETWEEN ' . $db->quote(substr($this->state->params->get('start_date'), 0, 10)) . ' AND ' . $db->quote(substr($this->state->params->get('end_date'), 0, 10)) . ')' . ' OR (i.jc_issue_id IN (' . implode(',', $includeArray) . ')))');
     // Join the status table to get the status name
     $query->select('s.title AS status_name');
     $query->join('LEFT', '#__code_tracker_status AS s ON i.status = s.jc_status_id');
     // Filter on merged items from the trackers
     $query->where('(s.title LIKE ' . $db->quote('%Fixed in SVN%') . ' OR s.title LIKE ' . $db->quote('%Implemented in trunk%') . ')');
     // Exclude explicitly listed trackers
     $query->where('i.jc_issue_id NOT IN (' . implode(',', $excludeArray) . ')');
     if ($this->state->get('list.filter')) {
         $query->where('i.title LIKE ' . $db->quote('%' . $this->state->get('list.filter') . '%'));
     }
     $query->order('CASE WHEN ISNULL(m.tag) THEN ' . $db->quote('None') . ' ELSE m.tag END ASC');
     $query->order('i.jc_issue_id ASC');
     return $query;
 }
开发者ID:joomla-projects,项目名称:com_trackerstats,代码行数:38,代码来源:releasenotes.php

示例8: array

 /**
  * Get the lists that contain events
  *
  * @return array
  */
 public function &getEventLists()
 {
     if (is_null($this->eventLists)) {
         $this->eventLists = array();
         $db = FabrikWorker::getDbo(true);
         $params = $this->getParams();
         $lists = (array) $params->get('calendar_table');
         $lists = ArrayHelper::toInteger($lists);
         $dateFields = (array) $params->get('calendar_startdate_element');
         $dateFields2 = (array) $params->get('calendar_enddate_element');
         $labels = (array) $params->get('calendar_label_element');
         $stati = (array) $params->get('status_element');
         $colours = (array) $params->get('colour');
         $query = $db->getQuery(true);
         $query->select('id AS value, label AS text')->from('#__{package}_lists')->where('id IN (' . implode(',', $lists) . ')');
         $db->setQuery($query);
         $rows = $db->loadObjectList();
         for ($i = 0; $i < count($rows); $i++) {
             if (!isset($colours[$i])) {
                 $colours[$i] = '';
             }
             if (!isset($stati[$i])) {
                 $stati[$i] = '';
             }
             $rows[$i]->startdate_element = $dateFields[$i];
             $rows[$i]->enddate_element = FArrayHelper::getValue($dateFields2, $i);
             $rows[$i]->label_element = $labels[$i];
             $rows[$i]->status = FArrayHelper::getValue($stati, $i, '');
             $rows[$i]->colour = $colours[$i];
         }
         $this->eventLists = $rows;
     }
     return $this->eventLists;
 }
开发者ID:glauberm,项目名称:cinevi,代码行数:39,代码来源:calendar.php

示例9: load

 /**
  * Load transactions from database.
  *
  * <code>
  * $options = array(
  *     "ids" => array(1,2,3),
  *     "txn_status" => "completed"
  * );
  *
  * $transactions    = new Crowdfunding\Transactions(\JFactory::getDbo());
  * $transactions->load($options);
  *
  * foreach($transactions as $transaction) {
  *   echo $transaction->txn_id;
  *   echo $transaction->txn_amount;
  * }
  *
  * </code>
  *
  * @param array $options
  *
  * @throws \UnexpectedValueException
  */
 public function load($options = array())
 {
     $ids = !isset($options["ids"]) ? null : (array) $options["ids"];
     if (!is_array($ids) or !$ids) {
         return;
     }
     ArrayHelper::toInteger($ids);
     // Load project data
     $query = $this->db->getQuery(true);
     $query->select("a.id, a.txn_date, a.txn_id, a.txn_amount, a.txn_currency, a.txn_status, " . "a.extra_data, a.status_reason, a.project_id, a.reward_id, a.investor_id, " . "a.receiver_id, a.service_provider, a.reward_state")->from($this->db->quoteName("#__crowdf_transactions", "a"))->where("a.id IN ( " . implode(",", $ids) . " )");
     // Filter by status.
     $status = ArrayHelper::getValue($options, "txn_status", null, "cmd");
     if (!empty($status)) {
         $query->where("a.txn_status = " . $this->db->quote($status));
     }
     $this->db->setQuery($query);
     $results = $this->db->loadObjectList();
     // Convert JSON string into an array.
     if (!empty($results)) {
         foreach ($results as $key => $result) {
             if (!empty($result->extra_data)) {
                 $result->extra_data = json_decode($result->extra_data, true);
                 $results[$key] = $result;
             }
         }
     } else {
         $results = array();
     }
     $this->items = $results;
 }
开发者ID:bharatthakkar,项目名称:CrowdFunding,代码行数:53,代码来源:Transactions.php

示例10: setFieldSets

 /**
  * Set which fieldsets should be used
  *
  * @since   3.0.7
  *
  * @return  array  fieldset names
  */
 private function setFieldSets()
 {
     $input = $this->app->input;
     // From list data view in admin
     $id = $input->getInt('listid', 0);
     // From list of lists checkbox selection
     $cid = $input->get('cid', array(0), 'array');
     $cid = ArrayHelper::toInteger($cid);
     if ($id === 0) {
         $id = $cid[0];
     }
     if ($id !== 0) {
         $db = FabrikWorker::getDbo();
         $query = $db->getQuery(true);
         $query->select('label')->from('#__{package}_lists')->where('id = ' . $id);
         $db->setQuery($query);
         $this->listName = $db->loadResult();
     }
     $fieldsets = array('details');
     if ($this->model->canEmpty()) {
         $fieldsets[] = 'drop';
     }
     $fieldsets[] = $id === 0 ? 'creation' : 'append';
     $fieldsets[] = 'format';
     return $fieldsets;
 }
开发者ID:glauberm,项目名称:cinevi,代码行数:33,代码来源:view.html.php

示例11: publish

 /**
  * Method to set the publishing state for a row or list of rows in the database
  * table. The method respects checked out rows by other users and will attempt
  * to checkin rows that it can after adjustments are made.
  *
  * @param   mixed    $pks     An array of primary key values to update.  If not
  *                            set the instance property value is used. [optional]
  * @param   integer  $state   The publishing state. eg. [0 = unpublished, 1 = published] [optional]
  * @param   integer  $userId  The user id of the user performing the operation. [optional]
  *
  * @return  boolean  True on success.
  *
  * @since   2.5
  */
 public function publish($pks = null, $state = 1, $userId = 0)
 {
     $k = $this->_tbl_key;
     // Sanitize input.
     $pks = ArrayHelper::toInteger($pks);
     $state = (int) $state;
     // If there are no primary keys set check to see if the instance key is set.
     if (empty($pks)) {
         if ($this->{$k}) {
             $pks = array($this->{$k});
         } else {
             $this->setError(JText::_('JLIB_DATABASE_ERROR_NO_ROWS_SELECTED'));
             return false;
         }
     }
     // Build the WHERE clause for the primary keys.
     $where = $k . '=' . implode(' OR ' . $k . '=', $pks);
     // Update the publishing state for rows with the given primary keys.
     $query = $this->_db->getQuery(true)->update($this->_db->quoteName($this->_tbl))->set($this->_db->quoteName('state') . ' = ' . (int) $state)->where($where);
     $this->_db->setQuery($query);
     try {
         $this->_db->execute();
     } catch (RuntimeException $e) {
         $this->setError($e->getMessage());
         return false;
     }
     // If the JTable instance value is in the list of primary keys that were set, set the instance.
     if (in_array($this->{$k}, $pks)) {
         $this->state = $state;
     }
     $this->setError('');
     return true;
 }
开发者ID:adjaika,项目名称:J3Base,代码行数:47,代码来源:map.php

示例12: read

 public function read()
 {
     // Check for request forgeries
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     // Get items to publish from the request.
     $cid = $this->input->get('cid', array(), 'array');
     $data = array('read' => 1, 'notread' => 0);
     $task = $this->getTask();
     $value = ArrayHelper::getValue($data, $task, 0, 'int');
     $redirectOptions = array("view" => "notifications");
     // Make sure the item ids are integers
     ArrayHelper::toInteger($cid);
     if (empty($cid)) {
         $this->displayNotice(JText::_($this->text_prefix . '_NO_ITEM_SELECTED'), $redirectOptions);
         return;
     }
     try {
         $model = $this->getModel();
         $model->read($cid, $value);
     } catch (RuntimeException $e) {
         $this->displayWarning($e->getMessage(), $redirectOptions);
         return;
     } catch (Exception $e) {
         JLog::add($e->getMessage());
         throw new Exception(JText::_('COM_GAMIFICATION_ERROR_SYSTEM'));
     }
     if ($value == 1) {
         $msg = $this->text_prefix . '_N_ITEMS_READ';
     } else {
         $msg = $this->text_prefix . '_N_ITEMS_NOT_READ';
     }
     $this->displayMessage(JText::plural($msg, count($cid)), $redirectOptions);
 }
开发者ID:bellodox,项目名称:GamificationPlatform,代码行数:33,代码来源:notifications.php

示例13: association

 /**
  * Render the list of associated items
  *
  * @param   integer  $catid      Category identifier to search its associations
  * @param   string   $extension  Category Extension
  *
  * @return  string   The language HTML
  *
  * @since   3.2
  * @throws  Exception
  */
 public static function association($catid, $extension = 'com_content')
 {
     // Defaults
     $html = '';
     // Get the associations
     if ($associations = CategoriesHelper::getAssociations($catid, $extension)) {
         $associations = ArrayHelper::toInteger($associations);
         // Get the associated categories
         $db = JFactory::getDbo();
         $query = $db->getQuery(true)->select('c.id, c.title')->select('l.sef as lang_sef')->from('#__categories as c')->where('c.id IN (' . implode(',', array_values($associations)) . ')')->join('LEFT', '#__languages as l ON c.language=l.lang_code')->select('l.image')->select('l.title as language_title');
         $db->setQuery($query);
         try {
             $items = $db->loadObjectList('id');
         } catch (RuntimeException $e) {
             throw new Exception($e->getMessage(), 500, $e);
         }
         if ($items) {
             foreach ($items as &$item) {
                 $text = strtoupper($item->lang_sef);
                 $url = JRoute::_('index.php?option=com_categories&task=category.edit&id=' . (int) $item->id . '&extension=' . $extension);
                 $tooltipParts = array(JHtml::_('image', 'mod_languages/' . $item->image . '.gif', $item->language_title, array('title' => $item->language_title), true), $item->title);
                 $item->link = JHtml::_('tooltip', implode(' ', $tooltipParts), null, null, $text, $url, null, 'hasTooltip label label-association label-' . $item->lang_sef);
             }
         }
         $html = JLayoutHelper::render('joomla.content.associations', $items);
     }
     return $html;
 }
开发者ID:SysBind,项目名称:joomla-cms,代码行数:39,代码来源:categoriesadministrator.php

示例14: getItemTags

 /**
  * Method to get a list of tags for an item, optionally with the tag data.
  *
  * <code>
  * $keys = array(1,2,3,4);
  *
  * $options = array(
  *     'content_type' => 'com_userideas.item',
  *     'access_groups' => \JFactory::getUser()->getAuthorisedViewLevels(),
  *     'language' => 'en_GB',
  *     'get_tag_data' => true
  * );
  *
  * $tagHelper = new TagHelper($keys, $options);
  * </code>
  *
  * @param   int|array  $keys
  * @param   array  $options
  *
  * @return  array    Array of tag objects
  */
 public function getItemTags($keys, array $options = array())
 {
     $contentType = JArrayHelper::getValue($options, 'content_type');
     if (!$contentType) {
         throw new \InvalidArgumentException(\JText::_('LIB_PRISM_ERROR_INVALID_CONTENT_TYPE'));
     }
     if (is_array($keys)) {
         $keys = JArrayHelper::toInteger($keys);
         $keys = array_filter(array_unique($keys));
         $hash = md5(implode(',', $keys) . '_' . $contentType);
     } else {
         $keys = (int) $keys;
         $hash = md5($keys . '_' . $contentType);
     }
     if (!$keys) {
         throw new \InvalidArgumentException(\JText::_('LIB_PRISM_ERROR_INVALID_KEYS'));
     }
     if (!array_key_exists($hash, $this->itemTags)) {
         $this->itemTags[$hash] = array();
         $groups = JArrayHelper::getValue($options, 'access_groups', array(), 'array');
         if (!$groups) {
             throw new \InvalidArgumentException(\JText::_('LIB_PRISM_ERROR_INVALID_ACCESS_GROUPS'));
         }
         // Initialize some variables.
         $db = \JFactory::getDbo();
         $query = $db->getQuery(true);
         $query->select('m.tag_id, m.content_item_id')->from($db->quoteName('#__contentitem_tag_map', 'm'))->where($db->quoteName('m.type_alias') . ' = ' . $db->quote($contentType));
         if (is_array($keys)) {
             $query->where($db->quoteName('m.content_item_id') . ' IN (' . implode(',', $keys) . ')');
         } else {
             $query->where($db->quoteName('m.content_item_id') . ' = ' . (int) $keys);
         }
         $query->where($db->quoteName('t.published') . ' = ' . Constants::PUBLISHED);
         $query->where('t.access IN (' . implode(',', $groups) . ')');
         // Optionally filter on language
         $language = JArrayHelper::getValue($options, 'language', 'all', 'string');
         if ($language !== 'all') {
             if ($language === 'current_language') {
                 $language = $this->getCurrentLanguage();
             }
             $query->where($db->quoteName('language') . ' IN (' . $db->quote($language) . ', ' . $db->quote('*') . ')');
         }
         $getTagData = JArrayHelper::getValue($options, 'get_tag_data', true, 'bool');
         if ($getTagData) {
             $query->select($db->quoteName('t') . '.*');
         }
         $query->join('INNER', $db->quoteName('#__tags', 't') . ' ON ' . $db->quoteName('m.tag_id') . ' = ' . $db->quoteName('t.id'));
         $db->setQuery($query);
         $tags = $db->loadObjectList();
         foreach ($tags as $value) {
             $this->itemTags[$hash][$value->content_item_id][] = $value;
         }
     }
     return $this->itemTags[$hash];
 }
开发者ID:ITPrism,项目名称:CrowdfundingDistribution,代码行数:76,代码来源:TagHelper.php

示例15: load

 /**
  * Load users data from database.
  *
  * <code>
  * $options = array(
  *      "ids" => array(1,2,3,4,5)
  * );
  *
  * $users   = new Crowdfunding\Users(\JFactory::getDbo());
  * $users->load($options);
  *
  * foreach($users as $user) {
  *   echo $user["id"];
  *   echo $user["name"];
  * }
  * </code>
  *
  * @param array $options
  */
 public function load($options = array())
 {
     // Filter by users IDs.
     $ids = ArrayHelper::getValue($options, "ids", array(), "array");
     ArrayHelper::toInteger($ids);
     if (!empty($ids)) {
         $query = $this->db->getQuery(true);
         $query->select("a.id, a.name, a.email")->from($this->db->quoteName("#__users", "a"));
         $query->where("a.id IN (" . implode(",", $ids) . ")");
         $this->db->setQuery($query);
         $this->items = (array) $this->db->loadAssocList();
     }
 }
开发者ID:Eautentik,项目名称:CrowdFunding,代码行数:32,代码来源:Users.php


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