Dotclear


Ignore:
Timestamp:
12/10/12 05:32:40 (13 years ago)
Author:
JcDenis
Branch:
twig
Message:
  • Still play with the main layout
File:
1 edited

Legend:

Unmodified
Added
Removed
  • inc/admin/class.dc.admincontext.php

    r1056 r1060  
    4141                
    4242               'version'           => DC_VERSION, 
    43                'vendor_name'  => DC_VENDOR_NAME, 
    44                 
    45                # Blogs list (not available yet) 
    46                'blogs' => array(), 
    47                 
    48                # Current blog (not available yet and never available in auth.php) 
    49                'blog' => array( 
    50                     'id'      => '', 
    51                     'host'    => '', 
    52                     'url'     => '', 
    53                     'name'    => '' 
    54                ) 
     43               'vendor_name'  => DC_VENDOR_NAME 
    5544          ); 
    5645     } 
     
    140129     public function getGlobals() 
    141130     { 
    142           # Blogs list 
    143           if ($this->core->auth->blog_count > 1 && $this->core->auth->blog_count < 20) { 
    144                $rs_blogs = $core->getBlogs(array('order'=>'LOWER(blog_name)','limit'=>20)); 
    145                while ($rs_blogs->fetch()) { 
    146                     $this->protected_globals['blogs'][html::escapeHTML($rs_blogs->blog_name.' - '.$rs_blogs->blog_url)] = $rs_blogs->blog_id; 
    147                } 
    148           } 
    149           # Current blog 
    150           if ($this->core->auth->blog_count) { 
    151                $this->protected_globals['blog'] = array( 
    152                     'id'      => $this->core->blog->id, 
    153                     'host'    => $this->core->blog->host, 
    154                     'url'     => $this->core->blog->url, 
    155                     'name'    => $this->core->blog->name 
    156                ); 
    157           } 
     131          $this->getBlogs(); 
     132          $this->getCurrentBlog(); 
     133          $this->getCurrentUser(); 
     134           
     135          # Additional globals 
     136          $p = path::info($_SERVER['REQUEST_URI']); 
     137          $this->protected_globals['current_page'] = $p['base']; 
     138          $this->protected_globals['blog_count'] = $this->core->auth->blog_count; 
     139           
    158140          # Keep protected globals safe 
    159141          return array_merge($this->globals,$this->protected_globals); 
     
    222204          } 
    223205     } 
     206      
     207     /** 
     208      * Get list of blogs 
     209      */ 
     210     protected function getBlogs() 
     211     { 
     212          # Blogs list 
     213          $blogs = array(); 
     214          if ($this->core->auth->blog_count > 1 && $this->core->auth->blog_count < 20) { 
     215               $rs_blogs = $this->core->getBlogs(array('order'=>'LOWER(blog_name)','limit'=>20)); 
     216               while ($rs_blogs->fetch()) { 
     217                    $blogs[$rs_blogs->blog_id] = $rs_blogs->blog_name.' - '.$rs_blogs->blog_url; 
     218                    $this->protected_globals['blogs'][$rs_blogs->blog_id] = array( 
     219                         'id'      => $rs_blogs->blog_id, 
     220                         'name'    => $rs_blogs->blog_name, 
     221                         'desc'    => $rs_blogs->blog_desc, 
     222                         'url'     => $rs_blogs->blog_url, 
     223                         'creadt'  => $rs_blogs->blog_creadt, 
     224                         'upddt'   => $rs_blogs->blog_upddt 
     225                    ); 
     226               } 
     227          } 
     228           
     229          # Switch blog form 
     230          $form = new dcForm($this->core,'switchblog_menu','index.php'); 
     231          $form 
     232               ->addField( 
     233                    new dcFieldCombo('switchblog',$this->core->blog->id,$blogs,array( 
     234                    'label' => __('Blogs:')))) 
     235               ->addField( 
     236                    new dcFieldSubmit('switchblog_submit',__('ok'),array( 
     237                    'action' => 'switchblog'))) 
     238               ->setup(); 
     239     } 
     240      
     241     /** 
     242      * Get current blog information 
     243      */ 
     244     protected function getCurrentBlog() 
     245     { 
     246          $this->protected_globals['current_blog'] = $this->core->auth->blog_count ? 
     247               array( 
     248                    'id'      => $this->core->blog->id, 
     249                    'name'    => $this->core->blog->name, 
     250                    'desc'    => $this->core->blog->desc, 
     251                    'url'     => $this->core->blog->url, 
     252                    'host'    => $this->core->blog->host, 
     253                    'creadt'  => $this->core->blog->creadt, 
     254                    'upddt'   => $this->core->blog->upddt 
     255               ) : array( 
     256                    'id'      => '', 
     257                    'name'    => '', 
     258                    'desc'    => '', 
     259                    'url'     => '', 
     260                    'host'    => '', 
     261                    'creadt'  => '', 
     262                    'upddt'   => '' 
     263               ); 
     264     } 
     265      
     266     /** 
     267      * Get current user information 
     268      */ 
     269     protected function getCurrentUser() 
     270     { 
     271          $this->protected_globals['current_user'] = $this->core->auth->userID() ? 
     272               array( 
     273                    'id'      => $this->core->auth->userID(), 
     274                    'admin'   => $this->core->auth->getInfo('user_admin'), 
     275                    'name'    => $this->core->auth->getInfo('user_name'), 
     276                    'firstname'    => $this->core->auth->getInfo('user_firstname'), 
     277                    'displayname'  => $this->core->auth->getInfo('user_displayname'), 
     278                    'url'     => $this->core->auth->getInfo('user_url'), 
     279                    'blog'    => $this->core->auth->getInfo('user_default_blog'), 
     280                    'lang'    => $this->core->auth->getInfo('user_lang'), 
     281                    'tz'      => $this->core->auth->getInfo('user_tz'), 
     282                    'creadt'  => $this->core->auth->getInfo('user_creadt'), 
     283                    'cn'      => $this->core->auth->getInfo('user_cn') 
     284               ) : 
     285               array( 
     286                    'id'      => '', 
     287                    'admin'   => '', 
     288                    'name'    => '', 
     289                    'firstname'    => '', 
     290                    'displayname'  => '', 
     291                    'url'     => '', 
     292                    'blog'    => '', 
     293                    'lang'    => 'en', 
     294                    'tz'      => '', 
     295                    'creadt'  => '', 
     296                    'cn'      => '', 
     297               ); 
     298     } 
    224299} 
    225300?> 
Note: See TracChangeset for help on using the changeset viewer.

Sites map