Example #1
0
 public function __construct(&$schemadb)
 {
     if (!$schemadb instanceof midcom_helper_datamanager_schema) {
         try {
             $this->schemadb = midcom_helper_datamanager_schema::load_database($schemadb);
         } catch (Exception $e) {
             throw new midcom_helper_datamanager_exception_schema("given schema {$schemadb} is not instance of datamanager schema or a valid schema path");
         }
         return;
     }
     $this->schemadb =& $schemadb;
 }
Example #2
0
 public function testLoad()
 {
     if (MIDCOM_TESTS_ENABLE_OUTPUT) {
         echo __FUNCTION__ . "\n";
         echo "Loading schema\n\n";
     }
     if (MIDCOM_TESTS_ENABLE_OUTPUT) {
         echo "\n";
     }
     $schemas = midcom_helper_datamanager_schema::load_database('file:/net_nemein_news/configuration/schema.yml');
     $this->assertTrue(is_array($schemas));
 }
Example #3
0
 /**
  * This function parses the schema and populates all members with the corresponding
  * information, completing defaults where necessary.
  *
  * @param string $name The name of the schema to load.
  */
 private function load_schema($name)
 {
     // Setup the raw schema reference
     if (!isset($this->raw_schemadb[$name])) {
         throw new midcom_helper_datamanager_exception_schema("The schema {$name} was not found in the schema database.");
         // This will exit.
     }
     $this->raw_schema =& $this->raw_schemadb[$name];
     /*
      * NOT JUST YET 
     // Populate the l10n_schema member
     if (array_key_exists('l10n_db', $this->raw_schema))
     {
         $l10n_name = $this->raw_schema['l10n_db'];
     }
     else
     {
         $l10n_name = $_MIDCOM->get_context_data(MIDCOM_CONTEXT_COMPONENT);
     }
     $this->_l10n_schema = $_MIDCOM->i18n->get_l10n($l10n_name);
     */
     if (array_key_exists('operations', $this->raw_schema)) {
         $this->operations = $this->raw_schema['operations'];
     }
     if (array_key_exists('customdata', $this->raw_schema)) {
         $this->customdata = $this->raw_schema['customdata'];
     }
     if (array_key_exists('validation', $this->raw_schema)) {
         $this->validation = $this->raw_schema['validation'];
     }
     if (array_key_exists('filters', $this->raw_schema)) {
         $this->filters = $this->raw_schema['filters'];
     }
     $this->description = $this->raw_schema['description'];
     $this->name = $name;
     foreach ($this->raw_schema['fields'] as $name => $data) {
         $data['name'] = $name;
         $this->append_field($name, $data);
     }
     if ($this->configuration->get('include_metadata_required') && $this->schemadb_path && $this->schemadb_path != $_MIDCOM->configuration->get('metadata_schema')) {
         // Include required fields from metadata schema to the schema
         $metadata_schema = midcom_helper_datamanager_schema::load_database($_MIDCOM->configuration->get('metadata_schema'));
         if (isset($metadata_schema['metadata'])) {
             $prepended = false;
             foreach ($metadata_schema['metadata']->fields as $name => $field) {
                 if ($field['required']) {
                     $this->append_field($name, $field);
                 }
             }
         }
     }
 }