Beispiel #1
0
 /**
  * Get all default select fields. It excludes BLOBS and TEXT fields.
  * This function is used by find.
  *
  * @param boolean $single
  * @param string $tableAlias
  * @return string
  */
 public function getDefaultFindSelectFields($single = false, $tableAlias = 't')
 {
     //when upgrading we must refresh columns
     if (Columns::$forceLoad) {
         $this->columns = Columns::getColumns($this);
     }
     if ($single) {
         return $tableAlias . '.*';
     }
     foreach ($this->columns as $name => $attr) {
         if (isset($attr['gotype']) && $attr['gotype'] != 'blob' && $attr['gotype'] != 'textarea' && $attr['gotype'] != 'html') {
             $fields[] = $name;
         }
     }
     return "`{$tableAlias}`.`" . implode('`, `' . $tableAlias . '`.`', $fields) . "`";
 }
 /**
  * Returns all custom fields for this link type
  * 
  * @param int $linkType
  * @return PDOStatement 
  */
 private function _getAllFields()
 {
     //cache is cleared when a field is saved or deleted in Field::AfterSave and afterdelete
     if (!isset(self::$cacheColumns[$this->extendsModel()])) {
         $cacheKey = $this->getCacheKey();
         if ($cached = \GO::cache()->get($cacheKey)) {
             self::$attributeLabels[$this->extendsModel()] = $cached['attributeLabels'];
             self::$cacheColumns[$this->extendsModel()] = $cached['columns'];
         } else {
             $findParams = \GO\Base\Db\FindParams::newInstance()->select('t.*')->ignoreAcl()->joinRelation('category');
             $findParams->getCriteria()->addCondition('extends_model', $this->extendsModel(), '=', 'category');
             $stmt = \GO\Customfields\Model\Field::model()->find($findParams);
             self::$cacheColumns[$this->extendsModel()] = \GO\Base\Db\Columns::getColumns($this);
             self::$attributeLabels[$this->extendsModel()] = array();
             while ($field = $stmt->fetch()) {
                 self::$attributeLabels[$this->extendsModel()][$field->columnName()] = $field->category->name . ':' . $field->name;
                 self::$cacheColumns[$this->extendsModel()][$field->columnName()]['customfield'] = $field;
                 self::$cacheColumns[$this->extendsModel()][$field->columnName()]['regex'] = $field->validation_regex;
                 self::$cacheColumns[$this->extendsModel()][$field->columnName()]['gotype'] = 'customfield';
                 self::$cacheColumns[$this->extendsModel()][$field->columnName()]['unique'] = $field->unique_values;
                 //Don't validate required on the server side because customfields tabs can be disabled.
                 //self::$cacheColumns[$this->extendsModel()][$field->columnName()]['required']=$field->required;
             }
             \GO::cache()->set($cacheKey, array('attributeLabels' => self::$attributeLabels[$this->extendsModel()], 'columns' => self::$cacheColumns[$this->extendsModel()]));
         }
     }
     $this->columns = self::$cacheColumns[$this->extendsModel()];
 }