Changeset 12851

Show
Ignore:
Timestamp:
10/17/07 14:12:03 (1 year ago)
Author:
bergie
Message:

More navigation display options

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midcom/net.nemein.calendar/config/config.inc

    r12832 r12851  
    1616'archive_enable' => true, 
    1717'archive_year_order'   => 'ASC',  // Order for years in archive welcome page 
     18'archive_in_navigation' => false, 
     19'archive_years_in_navigation' => true, 
    1820 
    1921'show_navigation_pseudo_leaves' => true,   // Set this to false if you want to hide archive navigation items 
    2022 
    2123'categories' => '', 
     24'categories_in_navigation' => false, 
    2225 
    2326'rss_subscription_enable' => false, 
  • trunk/midcom/net.nemein.calendar/handler/list.php

    r12845 r12851  
    207207    { 
    208208        $this->_load_datamanager(); 
    209          
    210         if ($handler_id == 'archive-between') 
    211         { 
    212             if (!$this->_config->get('archive_enable')) 
    213             { 
    214                 return false; 
    215             }         
    216             $this->_request_data['archive_mode'] = true; 
    217             $this->_component_data['active_leaf'] = "{$data['content_topic']->id}_ARCHIVE"; 
    218         } 
    219         else 
    220         { 
    221             $this->_request_data['archive_mode'] = false;             
    222         } 
    223          
     209 
    224210        // Get the requested date range 
    225211        // TODO: Check format as YYYY-MM-DD via regexp 
     
    232218            return false; 
    233219        } 
     220         
     221        if ($handler_id == 'archive-between') 
     222        { 
     223            if (!$this->_config->get('archive_enable')) 
     224            { 
     225                return false; 
     226            }         
     227            $this->_request_data['archive_mode'] = true; 
     228             
     229            if ($this->_config->get('archive_in_navigation')) 
     230            { 
     231                $this->_component_data['active_leaf'] = "{$data['content_topic']->id}_ARCHIVE"; 
     232            } 
     233            else 
     234            { 
     235                $this->_component_data['active_leaf'] = "{$data['content_topic']->id}_ARCHIVE_" . date('Y', $start); 
     236            } 
     237        } 
     238        else 
     239        { 
     240            $this->_request_data['archive_mode'] = false;             
     241        } 
     242         
     243 
    234244 
    235245        $this->_request_data['start'] = $start; 
  • trunk/midcom/net.nemein.calendar/navigation.php

    r12045 r12851  
    1717{ 
    1818    /** 
     19     * The topic in which to look for articles. This defaults to the current content topic 
     20     * unless overridden by the symlink topic feature. 
     21     * 
     22     * @var midcom_db_topic 
     23     * @access private 
     24     */ 
     25    var $_content_topic = null; 
     26     
     27    /** 
    1928     * Simple constructor, calls base class. 
    2029     */ 
     
    3241         
    3342        if (   $this->_config->get('archive_enable') 
     43            && $this->_config->get('archive_in_navigation') 
    3444            && $this->_config->get('show_navigation_pseudo_leaves')) 
    3545        { 
     
    5060         
    5161        if (   $this->_config->get('show_navigation_pseudo_leaves') 
     62            && $this->_config->get('categories_in_navigation') 
    5263            && $this->_config->get('categories') != '') 
    5364        { 
     
    7182        } 
    7283         
     84        if (   $this->_config->get('show_navigation_pseudo_leaves') 
     85            && $this->_config->get('archive_years_in_navigation')) 
     86        { 
     87            // Check for symlink 
     88            if (!$this->_content_topic) 
     89            { 
     90                $this->_determine_content_topic(); 
     91            } 
     92 
     93            $qb = net_nemein_calendar_event_dba::new_query_builder();     
     94            $qb->add_constraint('node', '=', $this->_content_topic->id); 
     95            $qb->add_order('start'); 
     96            $qb->set_limit(1); 
     97            $result = $qb->execute_unchecked(); 
     98            $first_year = (int) date('Y', strtotime($result[0]->start)); 
     99            $year = $first_year; 
     100            $this_year = (int) date('Y', time()); 
     101            while ($year <= $this_year) 
     102            { 
     103                $next_year = $year + 1; 
     104                $leaves["{$this->_topic->id}_ARCHIVE_{$year}"] = array 
     105                ( 
     106                    MIDCOM_NAV_SITE => Array 
     107                    ( 
     108                        MIDCOM_NAV_URL => "archive/between/{$year}-01-01/{$next_year}-01-01/", 
     109                        MIDCOM_NAV_NAME => $year, 
     110                    ), 
     111                    MIDCOM_NAV_ADMIN => null, 
     112                    MIDCOM_META_CREATOR => $this->_topic->metadata->creator, 
     113                    MIDCOM_META_EDITOR => $this->_topic->metadata->revisor, 
     114                    MIDCOM_META_CREATED => $this->_topic->metadata->created, 
     115                    MIDCOM_META_EDITED => $this->_topic->metadata->revised, 
     116                ); 
     117                $year = $next_year; 
     118            } 
     119        } 
     120         
    73121        return $leaves; 
    74122    } 
    75 } // navigation 
     123     
     124    /** 
     125     * Set the content topic to use. This will check against the configuration setting 'symlink_topic'. 
     126     * We don't do sanity checking here for performance reasons, it is done when accessing the topic, 
     127     * that should be enough. 
     128     * 
     129     * @access protected 
     130     */ 
     131    function _determine_content_topic() 
     132    { 
     133 
     134        $guid = $this->_config->get('symlink_topic'); 
     135        if (is_null($guid)) 
     136        { 
     137            // No symlink topic 
     138            // Workaround, we should talk to an DBA object automatically here in fact. 
     139            $this->_content_topic = new midcom_db_topic($this->_topic->id); 
     140            debug_pop(); 
     141            return; 
     142        } 
     143 
     144        $this->_content_topic = new midcom_db_topic($guid); 
     145 
     146        if (! $this->_content_topic) 
     147        { 
     148            debug_push_class(__CLASS__, __FUNCTION__); 
     149            debug_add('Failed to open symlink content topic, (might also be an invalid object) last Midgard Error: ' . mgd_errstr(), 
     150                MIDCOM_LOG_ERROR); 
     151            debug_pop(); 
     152            $_MIDCOM->generate_error('Failed to open symlink content topic.'); 
     153            // This will exit. 
     154        } 
     155 
     156    } 
     157
    76158 
    77159?>