예제 #1
0
 public function __construct($oRefAttribute, $sSuffix = '')
 {
     // In this very specific case, the code is the one of the attribute
     // (this to get a very very simple syntax upon declaration)
     $aParam = array();
     $aParam["refattribute"] = $oRefAttribute;
     parent::__construct($oRefAttribute->GetCode() . $sSuffix, $aParam);
 }
 function ReadFilter(&$sources, $Filter)
 {
     // Read filter
     // eg
     // cat:no-social.att:no-no.search:all:yorker:case
     $this->load->library('filter_uri');
     $filter_def = new FilterDefinition($this->sFilterDef);
     if (NULL === $Filter) {
         $Filter = '';
     }
     $filter = $filter_def->ReadUri($Filter);
     if (FALSE === $filter) {
         $this->messages->AddMessage('error', 'The filter text in the uri was not valid');
     } else {
         $sources->DisableGroup('hide');
         $sources->EnableGroup('show');
         $sources->EnableGroup('rsvp');
         if (array_key_exists('att', $filter)) {
             foreach ($filter['att'] as $attendence) {
                 switch ($attendence[0]) {
                     case 'no-declined':
                         $sources->DisableGroup('hide');
                         break;
                     case 'no-maybe':
                         $sources->DisableGroup('show');
                         break;
                     case 'no-accepted':
                         $sources->DisableGroup('rsvp');
                         break;
                     case 'declined':
                         $sources->EnableGroup('hide');
                         break;
                     case 'maybe':
                         $sources->EnableGroup('show');
                         break;
                     case 'accepted':
                         $sources->EnableGroup('rsvp');
                         break;
                 }
             }
         }
         if (array_key_exists('cat', $filter)) {
             $cats = array();
             foreach ($filter['cat'] as $category) {
                 $cats[] = $category[0];
             }
             foreach ($this->mCategories as $category) {
                 $negator = 'no-' . $category['name'];
                 if (in_array($negator, $cats)) {
                     $sources->DisableCategory($category['name']);
                 }
             }
         }
     }
 }