/**
  * AccessTableData constructor
  *
  * @param Schema $schema Which schema to access
  * @param string $pid The page of which the data is for
  * @param int $ts Time at which the data should be read or written, 0 for now
  */
 public function __construct(Schema $schema, $pid, $ts = 0)
 {
     parent::__construct($schema, $pid, $ts);
     if ($this->schema->isLookup()) {
         throw new StructException('wrong schema type. use factory methods!');
     }
 }
 /**
  * Replaces placeholders in the given filter value by the proper value
  *
  * @param string $filter
  * @return string|string[] Result may be an array when a multi column placeholder is used
  */
 protected function applyFilterVars($filter)
 {
     global $ID;
     // apply inexpensive filters first
     $filter = str_replace(array('$ID$', '$NS$', '$PAGE$', '$USER$', '$TODAY$'), array($ID, getNS($ID), noNS($ID), isset($_SERVER['REMOTE_USER']) ? $_SERVER['REMOTE_USER'] : '', date('Y-m-d')), $filter);
     // apply struct column placeholder (we support only one!)
     if (preg_match('/^(.*?)(?:\\$STRUCT\\.(.*?)\\$)(.*?)$/', $filter, $match)) {
         $key = $match[2];
         // we try to resolve the key via current schema aliases first, otherwise take it literally
         $column = $this->findColumn($key);
         if ($column) {
             $label = $column->getLabel();
             $table = $column->getTable();
         } else {
             list($table, $label) = explode('.', $key);
         }
         // get the data from the current page
         if ($table && $label) {
             $schemaData = AccessTable::byTableName($table, $ID, 0);
             $data = $schemaData->getDataArray();
             $value = $data[$label];
             if (is_array($value) && !count($value)) {
                 $value = '';
             }
         } else {
             $value = '';
         }
         // apply any pre and postfixes, even when multi value
         if (is_array($value)) {
             $filter = array();
             foreach ($value as $item) {
                 $filter[] = $match[1] . $item . $match[3];
             }
         } else {
             $filter = $match[1] . $value . $match[3];
         }
     }
     return $filter;
 }
 /**
  * Saves the data
  *
  * This saves no matter what. You have to chcek validation results and changes on your own!
  *
  * @param int $ts the timestamp to use when saving the data
  * @return bool
  */
 public function saveData($ts = 0)
 {
     $this->access->setTimestamp($ts);
     return $this->access->saveData($this->data);
 }