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


PHP KHelperArray::merge方法代码示例

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


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

示例1: pagination

 /**
  * Render item pagination
  *
  * @param	array $config	Configuration array
  * @return	string	Html
  * @see  	http://developer.yahoo.com/ypatterns/navigation/pagination/
  */
 public function pagination($config = array())
 {
     $config = new KConfig($config);
     $config->append(array('total' => 0, 'display' => 5, 'ajax' => false, 'name' => $this->name));
     $this->_ajax = (bool) $config->ajax;
     if (is_string($config->ajax)) {
         $this->_ajax_layout = $config->ajax;
     }
     KFactory::get('admin::com.ninja.helper.default')->css('/pagination.css');
     // Paginator object
     $paginator = KFactory::tmp('lib.koowa.model.paginator')->setData(array('total' => $config->total, 'offset' => $config->offset, 'limit' => $config->limit, 'dispay' => $config->display));
     $view = $config->name;
     $items = (int) $config->total === 1 ? KInflector::singularize($view) : $view;
     if ($config->total <= 10) {
         return '<div class="pagination"><div class="limit">' . sprintf(JText::_('Listing %s ' . KInflector::humanize($items)), $config->total) . '</div></div>';
     }
     // Get the paginator data
     $list = $paginator->getList();
     $limitlist = $config->total > 10 ? $this->limit($config->toArray()) : $config->total;
     $html = '<div class="pagination">';
     $html .= '<div class="limit">' . sprintf(JText::_('Listing %s ' . KInflector::humanize($items)), $limitlist) . '</div>';
     $html .= $this->pages($list);
     $html .= '<div class="count"> ' . JText::_('Pages') . ' ' . $paginator->current . ' ' . JText::_('of') . ' ' . $paginator->count . '</div>';
     $html .= '</div>';
     if ($this->_ajax) {
         jimport('joomla.environment.browser');
         $uagent = JBrowser::getInstance()->getAgentString();
         $windoze = strpos($uagent, 'Windows') ? true : false;
         $url = clone KRequest::url();
         $url->fragment = 'offset=@{offset}';
         $formid = KFactory::tmp('admin::com.ninja.helper.default')->formid();
         $cookie = KRequest::get('cookie.' . $formid, 'string', false);
         $states = array('total' => $total, 'offset' => $offset, 'limit' => $limit, 'display' => $display);
         if ($cookie) {
             $merge = KHelperArray::merge(json_decode($cookie, true), $states);
             KRequest::set('cookie.' . $formid, json_encode($merge), 'string');
         }
         //Temp fix
         $cookie = false;
         $states = $cookie ? array() : array('state' => $states);
         KFactory::get('admin::com.ninja.helper.default')->js('/pagination.js');
         KFactory::get('admin::com.ninja.helper.default')->js('window.addEvent(\'domready\', function(){ $$(\'div.pagination\')[0].paginator(' . json_encode(array_merge(array('identificator' => $formid, 'text' => array('count' => sprintf(JText::_('Pages %s of %s'), '@{current}', '@{total}'), 'first' => sprintf(JText::_('%s First'), $windoze ? '<<' : '&#10094;&#10094;'), 'previous' => sprintf(JText::_('%s Previous'), $windoze ? '<' : '&#10094;'), 'next' => sprintf(JText::_('Next %s'), $windoze ? '>' : '&#10095;'), 'last' => sprintf(JText::_('Last %s'), $windoze ? '>>' : '&#10095;&#10095;'))), $states)) . '); });');
     }
     return $html;
 }
开发者ID:ravenlife,项目名称:Ninja-Framework,代码行数:52,代码来源:paginator.php

示例2: set

 /**
  * Set a variable in the request. Cookies and session data are stored persistently.
  *
  * @param   mixed   Variable identifier, prefixed by hash name eg post.foo.bar
  * @param   mixed   Variable value
  */
 public static function set($identifier, $value)
 {
     list($hash, $keys) = self::_parseIdentifier($identifier);
     // Add to _REQUEST hash if original hash is get, post, or cookies
     if (in_array($hash, array('GET', 'POST', 'COOKIE'))) {
         self::set('request.' . implode('.', $keys), $value);
     }
     // Store cookies persistently
     if ($hash == 'COOKIE' && strpos(KRequest::protocol(), 'http') !== false) {
         // rewrite the $keys as foo[bar][bar]
         $ckeys = $keys;
         // get a copy
         $name = array_shift($ckeys);
         foreach ($ckeys as $ckey) {
             $name .= '[' . $ckey . ']';
         }
         if (!setcookie($name, $value)) {
             throw new KRequestException("Couldn't set cookie, headers already sent.");
         }
     }
     // Store in $GLOBALS
     foreach (array_reverse($keys, true) as $key) {
         $value = array($key => $value);
     }
     // Add the global if it's doesn't exist
     if (!isset($GLOBALS['_' . $hash])) {
         $GLOBALS['_' . $hash] = array();
     }
     $GLOBALS['_' . $hash] = KHelperArray::merge($GLOBALS['_' . $hash], $value);
 }
开发者ID:janssit,项目名称:www.marlinfishingcanaria.com,代码行数:36,代码来源:request.php


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