Changeset 26343


Ignore:
Timestamp:
06/12/10 22:05:19 (7 years ago)
Author:
rambo
Message:

CRUD baseclass and url handling for entities, utility class

Location:
branches/ragnaroek/midcom/net.hurttakallio.library
Files:
6 added
7 edited
4 copied

Legend:

Unmodified
Added
Removed
  • branches/ragnaroek/midcom/net.hurttakallio.library/config/config.inc

    r26342 r26343  
    11// <?php // hack to trigger syntax-highlighting
    22/* The schema database to use */
    3 'schemadb' => 'file:/net/hurttakallio/library/config/schemadb_items_default.inc',
     3'schemadb_items' => 'file:/net/hurttakallio/library/config/schemadb_items_default.inc',
    44'schemadb_entities' => 'file:/net/hurttakallio/library/config/schemadb_entities_default.inc',
    55'schemadb_config' => 'file:/net/hurttakallio/library/config/config_schemadb.inc',
  • branches/ragnaroek/midcom/net.hurttakallio.library/config/mgdschema.xml

    r26338 r26343  
    154154            </description>
    155155        </property>
     156
     157        <property name="uri" type="string">
     158            <description>
     159                External full uri, just in case it's needed
     160            </description>
     161        </property>
    156162    </type>
    157163
  • branches/ragnaroek/midcom/net.hurttakallio.library/config/midcom_dba_classes.inc

    r26332 r26343  
    33    'midcom_class_name' => 'net_hurttakallio_library_item_dba'
    44),
     5array(
     6    'mgdschema_class_name' => 'net_hurttakallio_library_entity',
     7    'midcom_class_name' => 'net_hurttakallio_library_entity_dba'
     8),
     9array(
     10    'mgdschema_class_name' => 'net_hurttakallio_library_entity_link',
     11    'midcom_class_name' => 'net_hurttakallio_library_entity_link_dba'
     12),
  • branches/ragnaroek/midcom/net.hurttakallio.library/config/schemadb_items_default.inc

    r26342 r26343  
    3535            'widget' => 'select',
    3636        ),
     37        'author' => net_hurttakallio_library_utilities::dm2_field_entities('author(s)', 'person', 'full name'),
    3738    ),
    3839),
     
    7576            'widget' => 'select',
    7677        ),
     78        'artist' => net_hurttakallio_library_utilities::dm2_field_entities('single artist', 'person', 'full name'),
     79        'group' => net_hurttakallio_library_utilities::dm2_field_entities('band', 'group', 'name'),
    7780    ),
    7881),
     
    114117            'widget' => 'select',
    115118        ),
     119        'director' => net_hurttakallio_library_utilities::dm2_field_entities('director(s)', 'person', 'full name'),
    116120    ),
    117121),
  • branches/ragnaroek/midcom/net.hurttakallio.library/handler/item.php

    r26341 r26343  
    3434    }
    3535
     36    public function _load_schemadb()
     37    {
     38        $this->_schemadb =& $this->_request_data['schemadb_items'];
     39    }
     40
    3641    public function _handler_callback($handler_id, $args, &$data)
    3742    {
     
    6469    {
    6570        $indexer = $_MIDCOM->get_service('indexer');
    66         net_hurttakallio_library_viewer::index($dm, $indexer, $this->_content_topic);
     71        net_hurttakallio_library_viewer::index_item($dm, $indexer, $this->_content_topic);
    6772    }
    6873
     
    159164    }
    160165}
     166?>
  • branches/ragnaroek/midcom/net.hurttakallio.library/style/nhl-show-dm2form.php

    r26341 r26343  
    1414        $title = sprintf($l10n_midcom->get(sprintf('%s %%s', $data['mode'])), $dm->types['title']->convert_to_html());
    1515}
    16 echo "DEBUG: " . sprintf('%s %%s', $data['mode']) . "<br>\n";
    1716echo "<h2>{$title}</h2>\n";
    1817$ctrl->display_form();
  • branches/ragnaroek/midcom/net.hurttakallio.library/viewer.php

    r26341 r26343  
    4545        );
    4646
    47         // Handle /item/xxx
    48         $this->_request_switch['view-item'] = array
    49         (
    50             'handler' => array('net_hurttakallio_library_handler_item', 'read'),
    51             'fixed_args' => array('item'),
    52             'variable_args' => 1,
    53         );
    54 
    55         // Handle /item/edit/xxx
    56         $this->_request_switch['edit-item'] = array
    57         (
    58             'handler' => array('net_hurttakallio_library_handler_item', 'update'),
    59             'fixed_args' => array('item', 'edit'),
    60             'variable_args' => 1,
    61         );
    62 
    63         // Handle /item/delete/xxx
    64         $this->_request_switch['delete-item'] = array
    65         (
    66             'handler' => array('net_hurttakallio_library_handler_item', 'delete'),
    67             'fixed_args' => array('item', 'delete'),
    68             'variable_args' => 1,
    69         );
    70 
    71         // Handle /item/create/<schemaname>
    72         $this->_request_switch['edit-item'] = array
    73         (
    74             'handler' => array('net_hurttakallio_library_handler_item', 'create'),
    75             'fixed_args' => array('item', 'create'),
    76             'variable_args' => 1,
    77         );
     47        // Standard crud handlers for the our main object types
     48        foreach(array('item', 'entity') as $type)
     49        {
     50            // Handle /{$type}/xxx
     51            $this->_request_switch["view-{$type}"] = array
     52            (
     53                'handler' => array("net_hurttakallio_library_handler_{$type}", 'read'),
     54                'fixed_args' => array($type),
     55                'variable_args' => 1,
     56            );
     57   
     58            // Handle /{$type}/edit/xxx
     59            $this->_request_switch["edit-{$type}"] = array
     60            (
     61                'handler' => array("net_hurttakallio_library_handler_{$type}", 'update'),
     62                'fixed_args' => array($type, 'edit'),
     63                'variable_args' => 1,
     64            );
     65   
     66            // Handle /{$type}/delete/xxx
     67            $this->_request_switch["delete-{$type}"] = array
     68            (
     69                'handler' => array("net_hurttakallio_library_handler_{$type}", 'delete'),
     70                'fixed_args' => array($type, 'delete'),
     71                'variable_args' => 1,
     72            );
     73   
     74            // Handle /{$type}/create/<schemaname>
     75            $this->_request_switch["create-{$type}"] = array
     76            (
     77                'handler' => array("net_hurttakallio_library_handler_{$type}", 'create'),
     78                'fixed_args' => array($type, 'create'),
     79                'variable_args' => 1,
     80            );
     81        }
    7882
    7983
     
    9094     *     tries to load a new topic instance from the database identified by this parameter.
    9195     */
    92     function index(&$dm, &$indexer, $topic)
     96    function index_item(&$dm, &$indexer, $topic)
    9397    {
    9498        if (!is_object($topic))
     
    144148        if ($this->_topic->can_do('midgard:create'))
    145149        {
    146             foreach (array_keys($this->_request_data['schemadb']) as $name)
     150            foreach (array_keys($this->_request_data['schemadb_items']) as $name)
    147151            {
    148152                $this->_node_toolbar->add_item
     
    154158                        (
    155159                            $this->_l10n_midcom->get('create %s'),
    156                             $this->_request_data['schemadb'][$name]->description
     160                            $this->_request_data['schemadb_items'][$name]->description
     161                        ),
     162                        MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/new-text.png',
     163                    )
     164                );
     165            }
     166            foreach (array_keys($this->_request_data['schemadb_entities']) as $name)
     167            {
     168                $this->_node_toolbar->add_item
     169                (
     170                    array
     171                    (
     172                        MIDCOM_TOOLBAR_URL => "entity/create/{$name}/",
     173                        MIDCOM_TOOLBAR_LABEL => sprintf
     174                        (
     175                            $this->_l10n->get('create %s entity'),
     176                            $this->_request_data['schemadb_entities'][$name]->description
    157177                        ),
    158178                        MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/new-text.png',
     
    183203    function _on_handle($handler, $args)
    184204    {
    185         $this->_request_data['schemadb'] = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb'));
     205        $this->_request_data['schemadb_items'] = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb_items'));
     206        $this->_request_data['schemadb_entities'] = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb_entities'));
    186207
    187208        $this->_populate_node_toolbar();
Note: See TracChangeset for help on using the changeset viewer.