コード例 #1
0
 public function grab(array &$param_pool = NULL)
 {
     // remove placeholder elements
     unset($this->dsParamINCLUDEDELEMENTS);
     // fill with all included elements if none are set
     if (is_null(REST_Entries::getDatasourceParam('included_elements'))) {
         // get all fields in this section
         $fields = FieldManager::fetchFieldsSchema(REST_Entries::getSectionId());
         // add them to the data source
         foreach ($fields as $field) {
             $this->dsParamINCLUDEDELEMENTS[] = $field['element_name'];
         }
         // also add pagination
         $this->dsParamINCLUDEDELEMENTS[] = 'system:pagination';
     } else {
         $this->dsParamINCLUDEDELEMENTS = explode(',', REST_Entries::getDatasourceParam('included_elements'));
     }
     // fill the other parameters
     if (!is_null(REST_Entries::getDatasourceParam('limit'))) {
         $this->dsParamLIMIT = REST_Entries::getDatasourceParam('limit');
     }
     if (!is_null(REST_Entries::getDatasourceParam('page'))) {
         $this->dsParamSTARTPAGE = REST_Entries::getDatasourceParam('page');
     }
     if (!is_null(REST_Entries::getDatasourceParam('sort'))) {
         $this->dsParamSORT = REST_Entries::getDatasourceParam('sort');
     }
     if (!is_null(REST_Entries::getDatasourceParam('order'))) {
         $this->dsParamORDER = REST_Entries::getDatasourceParam('order');
     }
     // Do grouping
     if (!is_null(REST_Entries::getDatasourceParam('groupby'))) {
         $field_id = FieldManager::fetchFieldIDFromElementName(REST_Entries::getDatasourceParam('groupby'), REST_Entries::getSectionId());
         if ($field_id) {
             $this->dsParamGROUP = $field_id;
         }
     }
     // if API is calling a known entry, filter on System ID only
     if (!is_null(REST_Entries::getEntryId())) {
         $this->dsParamFILTERS['id'] = REST_Entries::getEntryId();
     } elseif (REST_Entries::getDatasourceParam('filters')) {
         foreach (REST_Entries::getDatasourceParam('filters') as $field_handle => $filter_value) {
             $filter_value = rawurldecode($filter_value);
             $field_id = FieldManager::fetchFieldIDFromElementName($field_handle, REST_Entries::getSectionId());
             if (is_numeric($field_id)) {
                 $this->dsParamFILTERS[$field_id] = $filter_value;
             }
         }
     }
     return $this->execute($param_pool);
 }
コード例 #2
0
 public static function getSource()
 {
     return REST_Entries::getSectionId();
 }