/**
  * @param Schema $schema
  * @param int|string $pid
  * @param int $ts
  * @return meta\AccessTableLookup|AccessTableData
  */
 public static function bySchema(Schema $schema, $pid, $ts = 0)
 {
     if ($schema->isLookup()) {
         return new meta\AccessTableLookup($schema, $pid, $ts);
         // FIXME not mocked, yet
     } else {
         return new AccessTableData($schema, $pid, $ts);
     }
 }
 /**
  * Add a schema to be searched
  *
  * Call multiple times for multiple schemas.
  *
  * @param string $table
  * @param string $alias
  */
 public function addSchema($table, $alias = '')
 {
     $schema = new Schema($table);
     if (!$schema->getId()) {
         throw new StructException('schema missing', $table);
     }
     if ($this->schemas && ($schema->isLookup() || reset($this->schemas)->isLookup())) {
         throw new StructException('nolookupmix');
     }
     $this->schemas[$table] = $schema;
     if ($alias) {
         $this->aliases[$alias] = $table;
     }
 }
 /**
  * Form for handling import/export from/to JSON
  *
  * @param Schema $schema
  * @return string
  */
 protected function html_json(Schema $schema)
 {
     $form = new Form(array('enctype' => 'multipart/form-data', 'id' => 'plugin__struct_json'));
     $form->setHiddenField('do', 'admin');
     $form->setHiddenField('page', 'struct_schemas');
     $form->setHiddenField('table', $schema->getTable());
     $form->setHiddenField('lookup', $schema->isLookup());
     $form->addFieldsetOpen($this->getLang('export'));
     $form->addButton('export', $this->getLang('btn_export'));
     $form->addFieldsetClose();
     $form->addFieldsetOpen($this->getLang('import'));
     $form->addElement(new \dokuwiki\Form\InputElement('file', 'schemafile'));
     $form->addButton('import', $this->getLang('btn_import'));
     $form->addHTML('<p>' . $this->getLang('import_warning') . '</p>');
     $form->addFieldsetClose();
     return $form->toHTML();
 }