- <?php
- require_once(TOOLKIT . '/class.datasource.php');
- Class datasourcecollections extends Datasource{
- public $dsParamROOTELEMENT = 'collections';
- public $dsParamORDER = 'desc';
- public $dsParamLIMIT = '20';
- public $dsParamREDIRECTONEMPTY = 'yes';
- public $dsParamPARAMOUTPUT = 'collection-products';
- public $dsParamSORT = 'system:id';
- public $dsParamSTARTPAGE = '1';
- public $dsParamASSOCIATEDENTRYCOUNTS = 'no';
- public $dsParamFILTERS = array(
- '4' => '{$collection_name}',
- '14' => 'yes',
- );
- public $dsParamINCLUDEDELEMENTS = array(
- 'collection-name',
- 'collection-short-description',
- 'collection-long-description: formatted',
- 'meta-description',
- 'collection-products',
- 'published'
- );
- public function __construct(&$parent, $env=NULL, $process_params=true){
- parent::__construct($parent, $env, $process_params);
- $this->_dependencies = array();
- ## This is where the switch happens. The 'Yes' bits are removed from the filter
- if ($this->_Parent->isLoggedIn() == 'false'){
- $this->dsParamFILTERS = array(
- '4' => '{$collection_name}',
- );
- }
- }
- public function about(){
- return array(
- 'name' => 'collections',
- 'author' => array(
- 'name' => 'Tommaso Lanza',
- 'website' => 'http://bedouinfoundry.dev',
- 'email' => 'tommasolanza@gmail.com'),
- 'version' => '1.0',
- 'release-date' => '2010-07-11T10:50:26+00:00');
- }
- public function getSource(){
- return '4';
- }
- ## This prevents the backend datasource editor from touching the file. From now on it's hand editing from source!
- public function allowEditorToParse(){
- return false;
- }
- public function grab(&$param_pool=NULL){
- $result = new XMLElement($this->dsParamROOTELEMENT);
- try{
- include(TOOLKIT . '/data-sources/datasource.section.php');
- }
- catch(FrontendPageNotFoundException $e){
- // Work around. This ensures the 404 page is displayed and
- // is not picked up by the default catch() statement below
- FrontendPageNotFoundExceptionHandler::render($e);
- }
- catch(Exception $e){
- $result->appendChild(new XMLElement('error', $e->getMessage()));
- return $result;
- }
- if($this->_force_empty_result) $result = $this->emptyXMLSet();
- return $result;
- }
- }