Esempio n. 1
0
	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;
	}
Esempio n. 2
0
	/**
	 * 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;
	}
Esempio n. 3
0
	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;
	}
Esempio n. 4
0
 /**
  * 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;
 }