Changeset 12896

Show
Ignore:
Timestamp:
10/19/07 11:06:49 (1 year ago)
Author:
bergie
Message:

New feature: include required metadata fields to all schemas

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midcom/midcom.helper.datamanager2/config/config.inc

    r6060 r12896  
    99'tinymce_use_compressor' => false, 
    1010//'tinymce_default_config_snippet' => "{$GLOBALS['midcom_config']['midcom_sgconfig_basedir']}/midcom.helper.datamanager2/tinymce", 
     11 
     12'include_metadata_required' => false, 
  • trunk/midcom/midcom.helper.datamanager2/schema.php

    r10966 r12896  
    120120 
    121121    /** 
     122     * The schema database path as read by the system. 
     123     * 
     124     * @access private 
     125     * @var Array 
     126     */ 
     127    var $_schemadb_path = null; 
     128 
     129    /** 
    122130     * A simple array holding the fields in the order they should be rendered identified 
    123131     * by their name. 
     
    172180     * @see midcom_get_snippet_content() 
    173181     */ 
    174     function midcom_helper_datamanager2_schema($schemadb, $name = null) 
    175     { 
    176          $this->_component = 'midcom.helper.datamanager2'; 
    177          parent::midcom_baseclasses_components_purecode(); 
     182    function midcom_helper_datamanager2_schema($schemadb, $name = null, $schemadb_path = null) 
     183    { 
     184        $this->_component = 'midcom.helper.datamanager2'; 
     185        parent::midcom_baseclasses_components_purecode(); 
     186        $this->_schemadb_path = $schemadb_path; 
    178187 
    179188        $this->_load_schemadb($schemadb); 
     
    278287            $data['name'] = $name; 
    279288            $this->append_field($name, $data); 
     289        } 
     290         
     291        if (   $this->_config->get('include_metadata_required') 
     292            && $this->_schemadb_path 
     293            && $this->_schemadb_path != $GLOBALS['midcom_config']['metadata_schema']) 
     294        { 
     295            // Include required fields from metadata schema to the schema 
     296            $metadata_schema = midcom_helper_datamanager2_schema::load_database($GLOBALS['midcom_config']['metadata_schema']); 
     297            if (isset($metadata_schema['metadata'])) 
     298            { 
     299                $prepended = false; 
     300                foreach ($metadata_schema['metadata']->fields as $name => $field) 
     301                { 
     302 
     303                    if ($field['required']) 
     304                    { 
     305                        if (!$prepended) 
     306                        {    
     307                            $field['static_prepend'] = "<h3 style='clear: left;'>" . $_MIDCOM->i18n->get_string('metadata', 'midcom') . "</h3>\n" . $field['static_prepend']; 
     308                            $prepended = true; 
     309                        } 
     310                        $this->append_field($name, $field); 
     311                    } 
     312                } 
     313            } 
    280314        } 
    281315    } 
     
    513547    function load_database($raw_db) 
    514548    { 
     549        $path = null; 
    515550        if (is_string($raw_db)) 
    516551        { 
     552            $path = $raw_db; 
    517553            $data = midcom_get_snippet_content($raw_db); 
    518554            $result = eval ("\$raw_db = Array ( {$data}\n );"); 
     
    529565        foreach ($raw_db as $name => $raw_schema) 
    530566        { 
    531             $schemadb[$name] = new midcom_helper_datamanager2_schema($raw_db, $name); 
     567            $schemadb[$name] = new midcom_helper_datamanager2_schema($raw_db, $name, $path); 
    532568        } 
    533569        return $schemadb;