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


PHP JArrayHelper类代码示例

本文整理汇总了PHP中JArrayHelper的典型用法代码示例。如果您正苦于以下问题:PHP JArrayHelper类的具体用法?PHP JArrayHelper怎么用?PHP JArrayHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: featured

 /**
  * Method to toggle the featured setting of a list of articles.
  *
  * @return	void
  * @since	1.6
  */
 function featured()
 {
     // Check for request forgeries
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     // Initialise variables.
     $user = JFactory::getUser();
     $ids = JRequest::getVar('cid', array(), '', 'array');
     $values = array('featured' => 1, 'unfeatured' => 0);
     $task = $this->getTask();
     $value = JArrayHelper::getValue($values, $task, 0, 'int');
     // Access checks.
     foreach ($ids as $i => $id) {
         if (!$user->authorise('core.edit.state', 'com_content.article.' . (int) $id)) {
             // Prune items that you can't change.
             unset($ids[$i]);
             JError::raiseNotice(403, JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
         }
     }
     if (empty($ids)) {
         JError::raiseWarning(500, JText::_('JERROR_NO_ITEMS_SELECTED'));
     } else {
         // Get the model.
         $model = $this->getModel();
         // Publish the items.
         if (!$model->featured($ids, $value)) {
             JError::raiseWarning(500, $model->getError());
         }
     }
     $this->setRedirect('index.php?option=com_content&view=articles');
 }
开发者ID:joomline,项目名称:Joomla2.5.999,代码行数:36,代码来源:articles.php

示例2: getInput

 /**
  * Method to get the field input markup.
  *
  * @return	string	The field input markup.
  * @since	1.6
  */
 protected function getInput()
 {
     // Initialise variables.
     $html = array();
     $recordId = (int) $this->form->getValue('id');
     $size = ($v = $this->element['size']) ? ' size="' . $v . '"' : '';
     $class = ($v = $this->element['class']) ? ' class="' . $v . '"' : 'class="text_area"';
     // Get a reverse lookup of the base link URL to Title
     $model = JModel::getInstance('menutypes', 'menusModel');
     $rlu = $model->getReverseLookup();
     switch ($this->value) {
         case 'url':
             $value = JText::_('COM_MENUS_TYPE_EXTERNAL_URL');
             break;
         case 'alias':
             $value = JText::_('COM_MENUS_TYPE_ALIAS');
             break;
         case 'separator':
             $value = JText::_('COM_MENUS_TYPE_SEPARATOR');
             break;
         default:
             $link = $this->form->getValue('link');
             // Clean the link back to the option, view and layout
             $value = JText::_(JArrayHelper::getValue($rlu, MenusHelper::getLinkKey($link)));
             break;
     }
     // Load the javascript and css
     JHtml::_('behavior.framework');
     JHtml::_('behavior.modal');
     $html[] = '<input type="text" readonly="readonly" disabled="disabled" value="' . $value . '"' . $size . $class . ' />';
     $html[] = '<input type="button" value="' . JText::_('JSELECT') . '" onclick="SqueezeBox.fromElement(this, {handler:\'iframe\', size: {x: 600, y: 450}, url:\'' . JRoute::_('index.php?option=com_menus&view=menutypes&tmpl=component&recordId=' . $recordId) . '\'})" />';
     $html[] = '<input type="hidden" name="' . $this->name . '" value="' . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '" />';
     return implode("\n", $html);
 }
开发者ID:laiello,项目名称:senluonirvana,代码行数:40,代码来源:menutype.php

示例3: delete

 public function delete()
 {
     // Check for request forgeries
     JSession::checkToken() or die(JText::_('JINVALID_TOKEN'));
     // Get items to remove from the request.
     $cid = JFactory::getApplication()->input->get('cid', array(), 'array');
     if (!is_array($cid) || count($cid) < 1) {
         JLog::add(JText::_($this->text_prefix . '_NO_ITEM_SELECTED'), JLog::WARNING, 'jerror');
     } else {
         // Get the model.
         $model = $this->getModel();
         // Make sure the item ids are integers
         jimport('joomla.utilities.arrayhelper');
         JArrayHelper::toInteger($cid);
         // Remove the items.
         if ($model->delete($cid)) {
             $this->setMessage(JText::plural($this->text_prefix . '_N_ITEMS_DELETED', count($cid)));
         } else {
             $this->setMessage($model->getError());
         }
     }
     $version = new JVersion();
     if ($version->isCompatible('3.0')) {
         // Invoke the postDelete method to allow for the child class to access the model.
         $this->postDeleteHook($model, $cid);
     }
     $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false));
 }
开发者ID:AndreKoepke,项目名称:Einsatzkomponente,代码行数:28,代码来源:alarmierungsarten.php

示例4: featured

 /**
  * Method to toggle the featured setting of a list of teamids.
  *
  * @return	void
  * 
  */
 public function featured()
 {
     // Check for request forgeries
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $user = JFactory::getUser();
     $ids = $this->input->getVar('cid', array(), 'array');
     $values = array('featured' => 1, 'unfeatured' => 0);
     $task = $this->getTask();
     $value = JArrayHelper::getValue($values, $task, 0, 'int');
     // Get the model.
     $model = $this->getModel();
     // Access checks.
     foreach ($ids as $i => $id) {
         $item = $model->getItem($id);
         if (!$user->authorise('core.edit.state', 'com_knvbapi2.teamid.' . $id)) {
             // Prune items that you can't change.
             unset($ids[$i]);
             JError::raiseNotice(403, JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
         }
     }
     if (empty($ids)) {
         JError::raiseWarning(500, JText::_('COM_KNVBAPI2_TEAMIDS_NO_ITEM_SELECTED'));
     } else {
         // Publish the items.
         if (!$model->featured($ids, $value)) {
             JError::raiseWarning(500, $model->getError());
         }
         if ($value == 1) {
             $message = JText::plural('COM_KNVBAPI2_TEAMIDS_N_ITEMS_FEATURED', count($ids));
         } else {
             $message = JText::plural('COM_KNVBAPI2_TEAMIDS_N_ITEMS_UNFEATURED', count($ids));
         }
     }
     $this->setRedirect(JRoute::_('index.php?option=com_knvbapi2&view=teamids', false), $message);
 }
开发者ID:esorone,项目名称:efcpw,代码行数:41,代码来源:teamids.php

示例5: _getList

 /**
  * Returns an object list
  *
  * @param	string The query
  * @param	int Offset
  * @param	int The number of records
  * @return	array
  */
 protected function _getList($query, $limitstart = 0, $limit = 0)
 {
     $ordering = $this->getState('list.ordering');
     $search = $this->getState('filter.search');
     // Replace slashes so preg_match will work
     $search = str_replace('/', ' ', $search);
     $db = $this->getDbo();
     if ($ordering == 'name' || !empty($search) && stripos($search, 'id:') !== 0) {
         $db->setQuery($query);
         $result = $db->loadObjectList();
         $lang = JFactory::getLanguage();
         $this->translate($result);
         if (!empty($search)) {
             foreach ($result as $i => $item) {
                 if (!preg_match("/{$search}/i", $item->name)) {
                     unset($result[$i]);
                 }
             }
         }
         JArrayHelper::sortObjects($result, $this->getState('list.ordering'), $this->getState('list.direction') == 'desc' ? -1 : 1, true, $lang->getLocale());
         $total = count($result);
         $this->cache[$this->getStoreId('getTotal')] = $total;
         if ($total < $limitstart) {
             $limitstart = 0;
             $this->setState('list.start', 0);
         }
         return array_slice($result, $limitstart, $limit ? $limit : null);
     } else {
         $query->order($db->quoteName($ordering) . ' ' . $this->getState('list.direction'));
         $result = parent::_getList($query, $limitstart, $limit);
         $this->translate($result);
         return $result;
     }
 }
开发者ID:acculitx,项目名称:fleetmatrixsite,代码行数:42,代码来源:extension.php

示例6: link

 static function link($url, $text, $attribs = null)
 {
     if (is_array($attribs)) {
         $attribs = JArrayHelper::toString($attribs);
     }
     return "<a href='" . $url . "' " . $attribs . ">" . $text . "</a>";
 }
开发者ID:ranrolls,项目名称:ras-full-portal,代码行数:7,代码来源:statistic.php

示例7: multipleSanitised

 /**
  * Function to convert a string or array into a single string
  *
  * @param   mixed   $values        Array or string to use as values
  * @param   string  $filter        Filter to apply to the values to quote or (int) them
  * @param   array   $removeValues  Items to remove/filter from the source array
  *
  * @return  string
  */
 public static function multipleSanitised($values, $filter = 'integer', $removeValues = array(''))
 {
     $db = JFactory::getDbo();
     // Extra verification to avoid null values
     if (is_null($values)) {
         return false;
     }
     if (!is_array($values)) {
         // Convert comma separated values to arrays
         $values = (array) explode(',', $values);
     }
     // If all is selected remove filter
     if (in_array('*', $values)) {
         return null;
     }
     // Remove undesired source values
     if (!empty($removeValues)) {
         $values = array_diff($values, $removeValues);
     }
     // Filter to sanitise data
     switch ($filter) {
         case 'integer':
             JArrayHelper::toInteger($values);
             break;
         default:
             $values = array_map(array($db, 'quote'), $values);
             break;
     }
     return $values;
 }
开发者ID:thangredweb,项目名称:redCORE,代码行数:39,代码来源:string.php

示例8: getItem

 public function getItem($pk = null)
 {
     // Initialise variables.
     $pk = !empty($pk) ? $pk : (int) $this->getState($this->getName() . '.id');
     $table = $this->getTable();
     if ($pk > 0) {
         // Attempt to load the row.
         $return = $table->load($pk);
         // Check for a table object error.
         if ($return === false && $table->getError()) {
             $this->setError($table->getError());
             return false;
         }
     }
     // Convert to the JObject before adding other data.
     $properties = $table->getProperties(1);
     $item = JArrayHelper::toObject($properties, 'JObject');
     $item->title = htmlspecialchars(strip_tags($item->title));
     if (property_exists($item, 'params')) {
         $registry = new JRegistry();
         $registry->loadString($item->params);
         $item->params = $registry->toArray();
     }
     if ($item) {
         $arr = str_replace('[', '', $item->value);
         $arr = str_replace(']', '', $arr);
         if (preg_match('/.*\\},{\\.*?/s', $arr, $match)) {
             //var_dump($match);
             $values = str_replace('},', '}///', $arr);
             $values = explode('///', $values);
         } else {
             $values = (array) $arr;
         }
         //            $artOptFields   = $this -> _checkArticleFields($item -> id);
         if (count($values) > 0) {
             $list = array();
             $i = 0;
             foreach ($values as $value) {
                 $list[$i] = new stdClass();
                 $param = new JRegistry($value);
                 $list[$i]->type = $item->type;
                 if (!empty($item->default_value)) {
                     $list[$i]->default_value = explode(',', $item->default_value);
                 } else {
                     $list[$i]->default_value = array();
                 }
                 $list[$i]->name = $param->get('name');
                 $list[$i]->value = $param->get('value');
                 $list[$i]->target = $param->get('target');
                 $list[$i]->editor = $param->get('editor');
                 $list[$i]->image = $param->get('image');
                 $list[$i]->ordering = $param->get('ordering');
                 $i++;
             }
             $item->defvalue = $list;
         }
         $item->groups = $this->getGroups();
     }
     return $item;
 }
开发者ID:Glonum,项目名称:tz_portfolio,代码行数:60,代码来源:field.php

示例9: populateState

 /**
  * Method to auto-populate the model state.
  *
  * Note. Calling getState in this method will result in recursion.
  *
  * @return  void
  *
  * @since   1.6
  */
 protected function populateState($ordering = null, $direction = null)
 {
     $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.
     $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
     $this->setState('filter.search', $search);
     $active = $this->getUserStateFromRequest($this->context . '.filter.active', 'filter_active');
     $this->setState('filter.active', $active);
     $state = $this->getUserStateFromRequest($this->context . '.filter.state', 'filter_state');
     $this->setState('filter.state', $state);
     $groupId = $this->getUserStateFromRequest($this->context . '.filter.group', 'filter_group_id', null, 'int');
     $this->setState('filter.group_id', $groupId);
     $range = $this->getUserStateFromRequest($this->context . '.filter.range', 'filter_range');
     $this->setState('filter.range', $range);
     $groups = json_decode(base64_decode($app->input->get('groups', '', 'BASE64')));
     if (isset($groups)) {
         JArrayHelper::toInteger($groups);
     }
     $this->setState('filter.groups', $groups);
     $excluded = json_decode(base64_decode($app->input->get('excluded', '', 'BASE64')));
     if (isset($excluded)) {
         JArrayHelper::toInteger($excluded);
     }
     $this->setState('filter.excluded', $excluded);
     // Load the parameters.
     $params = JComponentHelper::getParams('com_users');
     $this->setState('params', $params);
     // List state information.
     parent::populateState('a.name', 'asc');
 }
开发者ID:densem-2013,项目名称:exikom,代码行数:43,代码来源:users.php

示例10: 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 optional array of primary key values to update.  If not
  *					          set the instance property value is used.
  * @param   integer  $state   The publishing state. eg. [0 = unpublished, 1 = published]
  * @param   integer  $userId  The user id of the user performing the operation.
  *
  * @return  boolean  True on success.
  *
  * @since   1.6
  */
 public function publish($pks = null, $state = 1, $userId = 0)
 {
     $k = $this->_tbl_key;
     // Sanitize input.
     JArrayHelper::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 . ' IN (' . implode(',', $pks) . ')';
     // Update the publishing state for rows with the given primary keys.
     $this->_db->setQuery('UPDATE ' . $this->_db->quoteName($this->_tbl) . ' SET ' . $this->_db->quoteName('state') . ' = ' . (int) $state . ' WHERE (' . $where . ')');
     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,代码行数:46,代码来源:message.php

示例11: savesetting

 function savesetting()
 {
     $juser =& JFactory::getUser();
     if ($juser->guest) {
         $error = 'Bạn phải đăng nhập để thực hiện chức năng này';
         $this->setError($error);
         return false;
     }
     $post = JRequest::get('post');
     JArrayHelper::toInteger($post);
     $data = array();
     $data['user_id'] = $juser->id;
     $data['show_counter'] = $post['show_counter'] == 0 ? 0 : 1;
     $data['email_subscribe'] = $post['email_subscribe'] == 0 ? 0 : 1;
     $data['email_notify'] = $post['email_notify'] == 0 ? 0 : 1;
     $data['pre_check'] = $post['pre_check'] == 0 ? 0 : 1;
     $row =& $this->getTable('users');
     if (!$row->bind($data)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     if (!$row->store()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     return true;
 }
开发者ID:ngxuanmui,项目名称:hanhphuc.vn,代码行数:27,代码来源:profile.php

示例12: returnQuestion

 /** this function returns math expression into your form, the parameter is optional
  * quite simmilar to insertQuestion, but returns the output as a text instead of echoing
  */
 public static function returnQuestion($attributes = array(), $suffix = '')
 {
     //default prime is 37, you can change it when specifying the different parameter
     $a = rand() % 10;
     // generates the random number
     $b = rand() % 10;
     // generates the random number
     $code = $a + $b;
     if (!is_array($attributes)) {
         $attributes = array();
     }
     if (!isset($attributes['name'])) {
         $suffix = $suffix . rand(1, 99999);
         $attributes['name'] = 'captcha_code' . $suffix;
     }
     if (!isset($attributes['id'])) {
         $attributes['id'] = $attributes['name'];
     }
     if (!isset($attributes['size'])) {
         $attributes['size'] = '2';
     }
     if (!isset($attributes['class'])) {
         $attributes['class'] = 'inputbox mathguard-answer required';
     }
     $session =& JFactory::getSession();
     $session->set($attributes['name'], $code);
     return $a . ' + ' . $b . ' = ' . '<input type="text" ' . JArrayHelper::toString($attributes) . ' />';
 }
开发者ID:jmangarret,项目名称:webtuagencia24,代码行数:31,代码来源:mathGuard.class.php

示例13: execute

 /**
  * Execute the controller.
  *
  * @return  void
  *
  * @since   3.1
  */
 public function execute()
 {
     // Get the application
     /* @var InstallationApplicationWeb $app */
     $app = $this->getApplication();
     // Check for request forgeries.
     JSession::checkToken() or $app->sendJsonResponse(new Exception(JText::_('JINVALID_TOKEN'), 403));
     // Get array of selected languages
     $lids = $this->input->get('cid', array(), 'array');
     JArrayHelper::toInteger($lids, array());
     // Get the languages model.
     $model = new InstallationModelLanguages();
     if (!$lids) {
         // No languages have been selected
         $app->enqueueMessage(JText::_('INSTL_LANGUAGES_NO_LANGUAGE_SELECTED'), 'warning');
     } else {
         // Install selected languages
         $model->install($lids);
         // Publish the Content Languages.
         $model->publishContentLanguages();
         $app->enqueueMessage(JText::_('INSTL_LANGUAGES_MORE_LANGUAGES'), 'notice');
     }
     // Redirect to the page.
     $r = new stdClass();
     $r->view = 'defaultlanguage';
     $app->sendJsonResponse($r);
 }
开发者ID:eshiol,项目名称:joomla-cms,代码行数:34,代码来源:languages.php

示例14: render

 /**
  * Render the profiler log data, and echo it..
  *
  * @param   string   $namespace The JProfiler instance ID. Default is the core profiler "Application".
  * @param   boolean  $asString  Return as string.
  *
  * @return  string
  */
 public static function render($namespace = 'Windwalker', $asString = false)
 {
     $app = Container::getInstance()->get('app');
     if ($namespace == 'core' || !$namespace) {
         $namespace = 'Application';
     }
     $buffer = 'No Profiler data.';
     if (isset(self::$profiler[$namespace])) {
         $_PROFILER = self::$profiler[$namespace];
         $buffer = $_PROFILER->getBuffer();
         $buffer = implode("\n<br />\n", $buffer);
     } else {
         $buffer = $app->getUserState('windwalker.system.profiler.' . $namespace);
         $buffer = $buffer ? implode("\n<br />\n", $buffer) : '';
     }
     $buffer = $buffer ? $buffer : 'No Profiler data.';
     // Get last page logs
     $state_buffer = \JArrayHelper::getValue(self::$stateBuffer, $namespace);
     if ($state_buffer) {
         $state_buffer = implode("\n<br />\n", $state_buffer);
         $buffer = $state_buffer . "\n<br />---------<br />\n" . $buffer;
     }
     // Render
     $buffer = "<pre><h3>WindWalker Debug [namespace: {$namespace}]: </h3>" . $buffer . '</pre>';
     $app->setUserState('windwalker.system.profiler.' . $namespace, '');
     if ($asString) {
         return $buffer;
     }
     echo $buffer;
     return '';
 }
开发者ID:beingsane,项目名称:quickcontent,代码行数:39,代码来源:ProfilerHelper.php

示例15:

 /**
  * Method to get an ojbect.
  *
  * @param	integer	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 = JArrayHelper::toObject($properties, 'JObject');
         } else {
             if ($error = $table->getError()) {
                 $this->setError($error);
             }
         }
     }
     return $this->_item;
 }
开发者ID:akksi,项目名称:jcg,代码行数:35,代码来源:weblink.php


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