本文整理汇总了PHP中Channel::GetDatasource方法的典型用法代码示例。如果您正苦于以下问题:PHP Channel::GetDatasource方法的具体用法?PHP Channel::GetDatasource怎么用?PHP Channel::GetDatasource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Channel
的用法示例。
在下文中一共展示了Channel::GetDatasource方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit_value
public function edit_value($value,$field)
{
$ds=$field['datasource'];
$key=$field['key'];
$data=Channel::GetDatasource($ds);
$result="\n<select name='{$field['id']}'>\n";
foreach($data as $row)
{
$sel=($row[$key]==$value);
if ($sel)
$result.="\t<option selected='true' value='{$row[$key]}'>{$row[$field['field']]}</option>\n";
else
$result.="\t<option value='{$row[$key]}'>{$row[$field['field']]}</option>\n";
}
$result.="</select>\n";
return $result;
}
示例2: get_data
/**
* Fetches the data
*
* @return mixed The data from the datasource
*/
protected function get_data($order_by=null, $dir='asc')
{
$rows=null;
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;
}
return $rows;
}
示例3: render_filter
function render_filter($field, $section)
{
$rtn = null;
$value=$this->controller->request->input->{$field};
if(!$this->use_filter || $this->use_filter==$field)
{
switch($section->type)
{
case 'radio':
case 'direction':
if (!$section->hidden)
$rtn.=$this->templates['radio']->render(array('meta' =>$this->controller->appmeta, 'field' => $field, 'section' => $section, 'control' => $this, 'value' => $value));
break;
case 'order_by':
case 'multi':
case 'range':
case 'text':
case 'list':
case 'location':
case 'date':
if (!$section->hidden)
$rtn.=$this->templates[$section->type]->render(array('meta' =>$this->controller->appmeta, 'field' => $field, 'section' => $section, 'control' => $this, 'value' => $value));
break;
case 'lookup':
case 'lookup_select':
case 'lookup_checkbox':
if ($section->facet) {
$rows = $this->results['facet_counts'][($section->facet->field)?$section->facet->field:$section->filter];
}
else
$rows=Channel::GetDatasource($section->datasource,null,null,$count='not needed');
if (!$section->hidden)
$rtn.=$this->templates[$section->type]->render(array('meta' =>$this->controller->appmeta, 'field' => $field, 'section' => $section, 'control' => $this, 'items' => $rows, 'value' => $value));
break;
case 'grouping':
{
$rendered_subfilters = '';
if ($section->filters) {
foreach($section->filters as $subfield => $subsection)
$rendered_subfilters .= $this->render_filter($subfield, $subsection);
}
if (!$section->hidden)
$rtn.=$this->templates[$section->type]->render(array('meta' =>$this->controller->appmeta, 'field' => $field, 'section' => $section, 'control' => $this, 'value' => $value, 'facets' => $this->results['facet_counts'], 'rendered_subfilters' => $rendered_subfilters));
break;
}
}
}
else if ($this->use_filter && isset($this->templates[$this->use_filter]))
{
$rtn.=$this->templates[$this->use_filter]->render(array('meta' =>$this->controller->appmeta, 'field' => $field, 'section' => $section, 'control' => $this, 'value' => $value));
}
return $rtn;
}
示例4: 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;
}