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


PHP Channel::Get方法代码示例

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


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

示例1: GetDatasource

	public static function GetDatasource($datasource,$offset=null,$limit=null,&$count=null)
	{
		// format for datasource is:
		// controller://path/path?arg1=val&q=asdads asd ad ad&arg=[123,232,123]
		// channel://channel/datasource?arg1=val&q=asdads asd ad ad&arg=[123,232,123]
		// model://profiles/profile_view?arg1!=val&q=asdads asd ad ad&arg=[123,232,123]
		
		$matches=array();
		if (preg_match_all('#^([^:]*):\/\/([^?]*)(.*)$#',$datasource,$matches))
		{
			switch($matches[1][0])
			{
				case 'controller':
					return Dispatcher::Call($matches[2][0]);
				case 'model':
					$parsed=explode('.',$matches[2][0]);
					if (count($parsed)==2)
					{
						$filter=filter($matches[2][0]);
							
						if ($offset)
							$filter->offset=$offset;
							
						if ($limit)
							$filter->limit=$limit;
							
						if ($matches[3][0]!='')
							$filter->parse(trim($matches[3][0],'?'));
	
                        if ($count==null)
    						$count=$filter->get_count();
		
                        return $filter->find(); 
					}
					
					return null;
				case 'channel':
					$parsed=explode('/',$matches[2][0]);
					$channel=Channel::Get($parsed[0]);
					$query=trim($matches[3][0],'?');
					
					$args=array();
					
					if ($query!="")
					{
						$items=explode('&',$query);
						foreach($items as $item)
						{
							$element=explode('=',$item);
							$args[trim($element[0])]=trim($element[1]);						
						}
						
					}
						
					return $channel->datasource($parsed[1],$offset,$limit,$count,$args);
					
			}
		}
	}
开发者ID:jawngee,项目名称:Thor,代码行数:59,代码来源:channel.php

示例2: get_data

 /**
  * Fetches the data
  *
  * @return mixed The data from the datasource
  */
 protected function get_data($order_by = null, $dir = 'asc')
 {
     if ($this->sortable != null) {
         $conf = Config::Get('search/sorts');
         $this->sorting = $conf->{$this->sortable};
         $this->sort_options = $this->sorting->options->items;
         if (!$this->sort_options) {
             throw new Exception("No sort options found");
         }
         $this->sortby = $this->controller->get->exists("sortby") ? $this->controller->get->get_string("sortby") : ($this->sortby = $conf->{$this->sortable}->default_option);
         $order_by = $this->sort_options[$this->sortby]->orby_by;
         $dir = $this->sort_options[$this->sortby]->direction;
     }
     if ($this->filtrable != null) {
         $conf = Config::Get('search/filters');
         $this->filtering = $conf->{$this->filtrable};
         $this->filters = $this->filtering->options->items;
         if (!$this->filters) {
             throw new Exception("No filters found");
         }
         $this->filter = $this->controller->get->exists("filter") ? $this->controller->get->get_string("filter") : ($this->filter = $this->filtering->default_option);
         $filter = $this->filters[$this->filter]->filter;
         if ($filter) {
             if (!strpos($this->datasource, '?')) {
                 $this->datasource .= '?';
             } else {
                 $this->datasource .= '&';
             }
             $this->datasource .= $this->filters[$this->filter]->filter;
         }
     }
     $rows = null;
     if ($this->channel != null) {
         user_error('Using the channel attribute on a repeater is deprecated', E_USER_WARNING);
         $channel = Channel::Get($this->channel);
         $rows = $channel->datasource($this->datasource, $this->current_page * $this->page_size, $this->page_size, $this->total_count);
     } else {
         if (gettype($this->datasource) == 'string') {
             if (strpos($this->datasource, '://') > 1) {
                 $ds = $this->datasource;
                 if ($order_by) {
                     if (!strpos($ds, '?')) {
                         $ds .= '?';
                     } else {
                         $ds .= '&';
                     }
                     $ds .= 'order by ' . $order_by . ' ' . $dir;
                 }
                 $rows = Channel::GetDatasource($ds, $this->current_page * $this->page_size, $this->page_size, $this->total_count);
             } else {
                 user_error('Using datasources on controllers is deprecated', E_USER_WARNING);
                 $rows = $this->controller->datasource($this->datasource, $this->current_page * $this->page_size, $this->page_size, $this->total_count);
             }
         } else {
             $rows = $this->datasource;
             if (is_array($rows)) {
                 if (isset($rows['total_count'])) {
                     $this->total_count = $rows['total_count'];
                 }
                 $this->count = isset($rows['count']) ? $rows['count'] : count($rows);
             }
         }
     }
     return $rows;
 }
开发者ID:jawngee,项目名称:HeavyMetal,代码行数:70,代码来源:databound_control.php


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