Dotclear


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • admin/index.php

    r1492 r1468  
    44# This file is part of Dotclear 2. 
    55# 
    6 # Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear 
     6# Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear 
    77# Licensed under the GPL version 2.0 license. 
    88# See LICENSE file or 
     
    1313if (!empty($_GET['pf'])) { 
    1414     require dirname(__FILE__).'/../inc/load_plugin_file.php'; 
    15      exit; 
    16 } 
    17 if (!empty($_GET['tf'])) { 
    18      define('DC_CONTEXT_ADMIN',true); 
    19      require dirname(__FILE__).'/../inc/load_theme_file.php'; 
    2015     exit; 
    2116} 
     
    4843$plugins_install = $core->plugins->installModules(); 
    4944 
    50 # Send plugins install messages to templates 
    51 if (!empty($plugins_install['success'])) { 
    52      $_ctx->addMessagesList(__('Following plugins have been installed:'),$plugins_install['success']); 
    53 } 
    54 if (!empty($plugins_install['failure'])) { 
    55      $_ctx->addMessagesList(__('Following plugins have not been installed:'),$plugins_install['failure']); 
    56 } 
    57  
    58 # Send plugins errors messages to templates 
    59 $_ctx->modules_errors = $core->auth->isSuperAdmin() ? $core->plugins->getErrors() : array(); 
    60  
    61 # Send Dotclear updates notifications to tempaltes 
    62 $_ctx->updater = array(); 
    63 if ($core->auth->isSuperAdmin() && is_readable(DC_DIGESTS)) { 
    64  
    65      $updater = new dcUpdate(DC_UPDATE_URL,'dotclear',DC_UPDATE_VERSION,DC_TPL_CACHE.'/versions'); 
    66      $new_v = $updater->check(DC_VERSION); 
    67      $version_info = $new_v ? $updater->getInfoURL() : ''; 
    68       
    69      if ($updater->getNotify() && $new_v) { 
    70           $_ctx->updater = array( 
    71                'new_version'  => $new_v, 
    72                'version_info' => $version_info 
    73           ); 
    74      } 
    75 } 
    76  
    7745# Check dashboard module prefs 
    7846$ws = $core->auth->user_prefs->addWorkspace('dashboard'); 
    79  
    80 # Doclinks prefs 
    8147if (!$core->auth->user_prefs->dashboard->prefExists('doclinks')) { 
    8248     if (!$core->auth->user_prefs->dashboard->prefExists('doclinks',true)) { 
     
    8551     $core->auth->user_prefs->dashboard->put('doclinks',true,'boolean'); 
    8652} 
    87  
    88 # Send doclinks to templates 
    89 $_ctx->dashboard_doclinks = array(); 
    90 if ($core->auth->user_prefs->dashboard->doclinks && !empty($__resources['doc'])) { 
    91      $_ctx->dashboard_doclinks = $__resources['doc']; 
    92 } 
    93  
    94 # Dcnews prefs 
    9553if (!$core->auth->user_prefs->dashboard->prefExists('dcnews')) { 
    9654     if (!$core->auth->user_prefs->dashboard->prefExists('dcnews',true)) { 
     
    9957     $core->auth->user_prefs->dashboard->put('dcnews',true,'boolean'); 
    10058} 
    101  
    102 # Send dcnews to templates 
    103 $_ctx->dashboard_dcnews = array(); 
    104 if ($core->auth->user_prefs->dashboard->dcnews && !empty($__resources['rss_news'])) { 
    105      try 
    106      { 
    107           $feed_reader = new feedReader; 
    108           $feed_reader->setCacheDir(DC_TPL_CACHE); 
    109           $feed_reader->setTimeout(2); 
    110           $feed_reader->setUserAgent('Dotclear - http://www.dotclear.org/'); 
    111           $feed = $feed_reader->parse($__resources['rss_news']); 
    112           if ($feed) { 
    113                $items = array(); 
    114                $i = 1; 
    115                foreach ($feed->items as $item) { 
    116                     $items[] = array( 
    117                          'title' => $item->title, 
    118                          'link' => isset($item->link) ? $item->link : '', 
    119                          'date' => dt::dt2str(__('%d %B %Y'),$item->pubdate,'Europe/Paris'), 
    120                          'content' => html::clean($item->content) 
    121                     ); 
    122                     $i++; 
    123                     if ($i > 3) { break; } 
    124                } 
    125                $_ctx->dashboard_dcnews = $items; 
    126           } 
    127      } 
    128      catch (Exception $e) {} 
    129 } 
    130  
    131 # Quick entry prefs 
    13259if (!$core->auth->user_prefs->dashboard->prefExists('quickentry')) { 
    13360     if (!$core->auth->user_prefs->dashboard->prefExists('quickentry',true)) { 
    134           $core->auth->user_prefs->dashboard->put('quickentry',true,'boolean','',null,true); 
    135      } 
    136      $core->auth->user_prefs->dashboard->put('quickentry',true,'boolean'); 
    137 } 
    138  
    139 # Send quick entry to templates 
    140 $_ctx->dashboard_quickentry = false; 
    141 if ($core->auth->user_prefs->dashboard->quickentry &&$core->auth->check('usage,contentadmin',$core->blog->id)) 
    142 { 
    143      $categories_combo = array(' ' => ''); 
    144      try { 
    145           $categories = $core->blog->getCategories(array('post_type'=>'post')); 
    146           while ($categories->fetch()) { 
    147                $categories_combo[$categories->cat_id] =  
    148                     str_repeat('  ',$categories->level-1). 
    149                     ($categories->level-1 == 0 ? '' : '• '). 
    150                     html::escapeHTML($categories->cat_title); 
    151           } 
    152      } catch (Exception $e) { } 
    153       
    154      $form = new dcForm($core,array('quickentry','quick-entry'),'post.php'); 
    155      $form 
    156           ->addField( 
    157                new dcFieldText('post_title','', array( 
    158                     'size'         => 20, 
    159                     'required'     => true, 
    160                     'label'        => __('Title')))) 
    161           ->addField( 
    162                new dcFieldTextArea('post_content','', array( 
    163                     'required'     => true, 
    164                     'label'        => __("Content:")))) 
    165           ->addField( 
    166                new dcFieldCombo('cat_id','',$categories_combo,array( 
    167                     "label" => __('Category:')))) 
    168           ->addField( 
    169                new dcFieldSubmit('save',__('Save'),array( 
    170                     'action' => 'savePost'))) 
    171           ->addField( 
    172                new dcFieldHidden ('post_status',-2)) 
    173           ->addField( 
    174                new dcFieldHidden ('post_format',$core->auth->getOption('post_format'))) 
    175           ->addField( 
    176                new dcFieldHidden ('post_excerpt','')) 
    177           ->addField( 
    178                new dcFieldHidden ('post_lang',$core->auth->getInfo('user_lang'))) 
    179           ->addField( 
    180                new dcFieldHidden ('post_notes','')) 
    181      ; 
    182      if ($core->auth->check('publish',$core->blog->id)) { 
    183           $form->addField( 
    184                new dcFieldHidden ('save-publish',__('Save and publish'))); 
    185      } 
    186       
    187      $_ctx->dashboard_quickentry = true; 
     61          $core->auth->user_prefs->dashboard->put('quickentry',false,'boolean','',null,true); 
     62     } 
     63     $core->auth->user_prefs->dashboard->put('quickentry',false,'boolean'); 
    18864} 
    18965 
     
    242118} 
    243119 
    244 # Send dashboard icons to templates 
    245 $icons = array(); 
    246 foreach ($__dashboard_icons as $i) { 
    247      $icons[] = array( 
    248           'title'   => $i[0], 
    249           'url'     => $i[1], 
    250           'img'     => dc_admin_icon_url($i[2]) 
    251      ); 
    252 } 
    253 $_ctx->dashboard_icons = $icons; 
    254  
    255 # Dashboard items 
     120# Latest news for dashboard 
    256121$__dashboard_items = new ArrayObject(array(new ArrayObject,new ArrayObject)); 
     122 
     123$dashboardItem = 0; 
     124 
     125if ($core->auth->user_prefs->dashboard->dcnews) { 
     126     try 
     127     { 
     128          if (empty($__resources['rss_news'])) { 
     129               throw new Exception(); 
     130          } 
     131      
     132          $feed_reader = new feedReader; 
     133          $feed_reader->setCacheDir(DC_TPL_CACHE); 
     134          $feed_reader->setTimeout(2); 
     135          $feed_reader->setUserAgent('Dotclear - http://www.dotclear.org/'); 
     136          $feed = $feed_reader->parse($__resources['rss_news']); 
     137          if ($feed) 
     138          { 
     139               $latest_news = '<h3>'.__('Latest news').'</h3><dl id="news">'; 
     140               $i = 1; 
     141               foreach ($feed->items as $item) 
     142               { 
     143                    $dt = isset($item->link) ? '<a href="'.$item->link.'" title="'.$item->title.' '.__('(external link)').'">'. 
     144                         $item->title.'</a>' : $item->title; 
     145                
     146                    if ($i < 3) { 
     147                         $latest_news .= 
     148                         '<dt>'.$dt.'</dt>'. 
     149                         '<dd><p><strong>'.dt::dt2str(__('%d %B %Y:'),$item->pubdate,'Europe/Paris').'</strong> '. 
     150                         '<em>'.text::cutString(html::clean($item->content),120).'...</em></p></dd>'; 
     151                    } else { 
     152                         $latest_news .= 
     153                         '<dt>'.$dt.'</dt>'. 
     154                         '<dd>'.dt::dt2str(__('%d %B %Y:'),$item->pubdate,'Europe/Paris').'</dd>'; 
     155                    } 
     156                    $i++; 
     157                    if ($i > 3) { break; } 
     158               } 
     159               $latest_news .= '</dl>'; 
     160               $__dashboard_items[$dashboardItem][] = $latest_news; 
     161               $dashboardItem++; 
     162          } 
     163     } 
     164     catch (Exception $e) {} 
     165} 
     166 
     167# Documentation links 
     168if ($core->auth->user_prefs->dashboard->doclinks) { 
     169     if (!empty($__resources['doc'])) 
     170     { 
     171          $doc_links = '<h3>'.__('Documentation and support').'</h3><ul>'; 
     172      
     173          foreach ($__resources['doc'] as $k => $v) { 
     174               $doc_links .= '<li><a href="'.$v.'" title="'.$k.' '.__('(external link)').'">'.$k.'</a></li>'; 
     175          } 
     176      
     177          $doc_links .= '</ul>'; 
     178          $__dashboard_items[$dashboardItem][] = $doc_links; 
     179          $dashboardItem++; 
     180     } 
     181} 
     182 
    257183$core->callBehavior('adminDashboardItems', $core, $__dashboard_items); 
    258184 
    259 # Send dashboard items to templates 
    260 $items = array(); 
    261 foreach ($__dashboard_items as $i) {     
    262      if ($i->count() > 0) { 
    263           foreach ($i as $v) { 
    264                $items[] = $v; 
    265           } 
    266      } 
    267 } 
    268 $_ctx->dashboard_items = $items; 
    269  
    270185# Dashboard content 
     186$dashboardContents = ''; 
    271187$__dashboard_contents = new ArrayObject(array(new ArrayObject,new ArrayObject)); 
    272188$core->callBehavior('adminDashboardContents', $core, $__dashboard_contents); 
    273189 
    274 # Send dashboard contents to templates 
    275 $contents = array(); 
    276 foreach ($__dashboard_contents as $i) {  
    277      if ($i->count() > 0) { 
     190/* DISPLAY 
     191-------------------------------------------------------- */ 
     192dcPage::open(__('Dashboard'), 
     193     dcPage::jsToolBar(). 
     194     dcPage::jsLoad('js/_index.js'). 
     195     # --BEHAVIOR-- adminDashboardHeaders 
     196     $core->callBehavior('adminDashboardHeaders'), 
     197     dcPage::breadcrumb( 
     198          array( 
     199          '<span class="page-title">'.__('Dashboard').' : '.html::escapeHTML($core->blog->name).'</span>' => '' 
     200          ), 
     201          false) 
     202); 
     203 
     204# Dotclear updates notifications 
     205if ($core->auth->isSuperAdmin() && is_readable(DC_DIGESTS)) 
     206{ 
     207     $updater = new dcUpdate(DC_UPDATE_URL,'dotclear',DC_UPDATE_VERSION,DC_TPL_CACHE.'/versions'); 
     208     $new_v = $updater->check(DC_VERSION); 
     209     $version_info = $new_v ? $updater->getInfoURL() : ''; 
     210 
     211     if ($updater->getNotify() && $new_v) { 
     212          $message = 
     213          '<div><p>'.sprintf(__('Dotclear %s is available!'),$new_v).'</p> '. 
     214          '<ul><li><strong><a href="update.php">'.sprintf(__('Upgrade now'),$new_v).'</a></strong>'. 
     215          '</li><li><a href="update.php?hide_msg=1">'.__('Remind me later').'</a>'. 
     216          ($version_info ? ' </li><li><a href="'.$version_info.'">'.__('information about this version').'</a>' : ''). 
     217          '</li></ul></div>'; 
     218          dcPage::message($message,false,true); 
     219     } 
     220} 
     221 
     222if ($core->auth->getInfo('user_default_blog') != $core->blog->id && $core->auth->blog_count > 1) { 
     223     echo 
     224     '<p><a href="index.php?default_blog=1" class="button">'.__('Make this blog my default blog').'</a></p>'; 
     225} 
     226 
     227if ($core->blog->status == 0) { 
     228     echo '<p class="static-msg">'.__('This blog is offline').'</p>'; 
     229} elseif ($core->blog->status == -1) { 
     230     echo '<p class="static-msg">'.__('This blog is removed').'</p>'; 
     231} 
     232 
     233if (!defined('DC_ADMIN_URL') || !DC_ADMIN_URL) { 
     234     echo 
     235     '<p class="static-msg">'. 
     236     sprintf(__('%s is not defined, you should edit your configuration file.'),'DC_ADMIN_URL'). 
     237     ' '.__('See <a href="http://dotclear.org/documentation/2.0/admin/config">documentation</a> for more information.'). 
     238     '</p>'; 
     239} 
     240 
     241if (!defined('DC_ADMIN_MAILFROM') || !DC_ADMIN_MAILFROM) { 
     242     echo 
     243     '<p class="static-msg">'. 
     244     sprintf(__('%s is not defined, you should edit your configuration file.'),'DC_ADMIN_MAILFROM'). 
     245     ' '.__('See <a href="http://dotclear.org/documentation/2.0/admin/config">documentation</a> for more information.'). 
     246     '</p>'; 
     247} 
     248 
     249# Plugins install messages 
     250if (!empty($plugins_install['success'])) 
     251{ 
     252     echo '<div class="static-msg">'.__('Following plugins have been installed:').'<ul>'; 
     253     foreach ($plugins_install['success'] as $k => $v) { 
     254          echo '<li>'.$k.'</li>'; 
     255     } 
     256     echo '</ul></div>'; 
     257} 
     258if (!empty($plugins_install['failure'])) 
     259{ 
     260     echo '<div class="error">'.__('Following plugins have not been installed:').'<ul>'; 
     261     foreach ($plugins_install['failure'] as $k => $v) { 
     262          echo '<li>'.$k.' ('.$v.')</li>'; 
     263     } 
     264     echo '</ul></div>'; 
     265} 
     266 
     267# Dashboard columns (processed first, as we need to know the result before displaying the icons.) 
     268$dashboardItems = ''; 
     269 
     270# Errors modules notifications 
     271if ($core->auth->isSuperAdmin()) 
     272{ 
     273     $list = array(); 
     274     foreach ($core->plugins->getErrors() as $k => $error) { 
     275          $list[] = '<li>'.$error.'</li>'; 
     276     } 
     277      
     278     if (count($list) > 0) { 
     279          $dashboardItems .= 
     280          '<div id="module-errors" class="error"><p>'.__('Some plugins are installed twice:').'</p> '. 
     281          '<ul>'.implode("\n",$list).'</ul></div>'; 
     282     } 
     283      
     284} 
     285 
     286foreach ($__dashboard_items as $i) 
     287{     
     288     if ($i->count() > 0) 
     289     { 
     290          $dashboardItems .= '<div class="db-item">'; 
    278291          foreach ($i as $v) { 
    279                $contents[] = $v; 
    280           } 
    281      } 
    282 } 
    283 $_ctx->dashboard_contents = $contents; 
    284  
    285 # Blog status message 
    286 if ($core->blog->status == 0) { 
    287      $_ctx->addMessageStatic(__('This blog is offline')); 
    288 } elseif ($core->blog->status == -1) { 
    289      $_ctx->addMessageStatic(__('This blog is removed')); 
    290 } 
    291  
    292 # Config errors messages 
    293 if (!defined('DC_ADMIN_URL') || !DC_ADMIN_URL) { 
    294      $_ctx->addMessageStatic( 
    295           sprintf(__('%s is not defined, you should edit your configuration file.'),'DC_ADMIN_URL').' '. 
    296           __('See <a href="http://dotclear.org/documentation/2.0/admin/config">documentation</a> for more information.') 
    297      ); 
    298 } 
    299 if (!defined('DC_ADMIN_MAILFROM') || !DC_ADMIN_MAILFROM) { 
    300      $_ctx->addMessageStatic( 
    301           sprintf(__('%s is not defined, you should edit your configuration file.'),'DC_ADMIN_MAILFROM').' '. 
    302           __('See <a href="http://dotclear.org/documentation/2.0/admin/config">documentation</a> for more information.') 
    303      ); 
    304 } 
    305  
    306 $_ctx->setBreadCrumb(__('Dashboard').' : '.html::escapeHTML($core->blog->name), false); 
    307 $core->tpl->display('index.html.twig'); 
     292               $dashboardItems .= $v; 
     293          } 
     294          $dashboardItems .= '</div>'; 
     295     } 
     296} 
     297 
     298# Dashboard icons 
     299echo '<div id="dashboard-main"'.($dashboardItems ? '' : ' class="fullwidth"').'><div id="icons">'; 
     300foreach ($__dashboard_icons as $i) 
     301{ 
     302     echo 
     303     '<p><a href="'.$i[1].'"><img src="'.dc_admin_icon_url($i[2]).'" alt="" />'. 
     304     '<br /><span>'.$i[0].'</span></a></p>'; 
     305} 
     306echo '</div>'; 
     307 
     308if ($core->auth->user_prefs->dashboard->quickentry) { 
     309     if ($core->auth->check('usage,contentadmin',$core->blog->id)) 
     310     { 
     311          # Getting categories 
     312          $categories_combo = array(__('(No cat)') => ''); 
     313          try { 
     314               $categories = $core->blog->getCategories(array('post_type'=>'post')); 
     315               if (!$categories->isEmpty()) { 
     316                    while ($categories->fetch()) { 
     317                         $catparents_combo[] = $categories_combo[] = new formSelectOption( 
     318                              str_repeat('&nbsp;&nbsp;',$categories->level-1).($categories->level-1 == 0 ? '' : '&bull; ').html::escapeHTML($categories->cat_title), 
     319                              $categories->cat_id 
     320                         ); 
     321                    } 
     322               } 
     323          } catch (Exception $e) { } 
     324      
     325          echo 
     326          '<div id="quick">'. 
     327          '<h3>'.__('Quick entry').'</h3>'. 
     328          '<form id="quick-entry" action="post.php" method="post">'. 
     329          '<fieldset><legend>'.__('New entry').'</legend>'. 
     330          '<p class="col"><label for="post_title" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Title:').'</label>'. 
     331          form::field('post_title',20,255,'','maximal'). 
     332          '</p>'. 
     333          '<p class="area"><label class="required" '. 
     334          'for="post_content"><abbr title="'.__('Required field').'">*</abbr> '.__('Content:').'</label> '. 
     335          form::textarea('post_content',50,7). 
     336          '</p>'. 
     337          '<p><label for="cat_id" class="classic">'.__('Category:').' '. 
     338          form::combo('cat_id',$categories_combo).'</label></p>'. 
     339          ($core->auth->check('categories', $core->blog->id) 
     340               ? '<div>'. 
     341               '<p id="new_cat">'.__('Add a new category').'</p>'. 
     342               '<p><label for="new_cat_title">'.__('Title:').' '. 
     343               form::field('new_cat_title',30,255,'','maximal').'</label></p>'. 
     344               '<p><label for="new_cat_parent">'.__('Parent:').' '. 
     345               form::combo('new_cat_parent',$categories_combo,'','maximal'). 
     346               '</label></p>'. 
     347               '</div>' 
     348               : ''). 
     349          '<p><input type="submit" value="'.__('Save').'" name="save" /> '. 
     350          ($core->auth->check('publish',$core->blog->id) 
     351               ? '<input type="hidden" value="'.__('Save and publish').'" name="save-publish" />' 
     352               : ''). 
     353          $core->formNonce(). 
     354          form::hidden('post_status',-2). 
     355          form::hidden('post_format',$core->auth->getOption('post_format')). 
     356          form::hidden('post_excerpt',''). 
     357          form::hidden('post_lang',$core->auth->getInfo('user_lang')). 
     358          form::hidden('post_notes',''). 
     359          '</p>'. 
     360          '</fieldset>'. 
     361          '</form>'. 
     362          '</div>'; 
     363     } 
     364} 
     365 
     366foreach ($__dashboard_contents as $i) 
     367{     
     368     if ($i->count() > 0) 
     369     { 
     370          $dashboardContents .= '<div>'; 
     371          foreach ($i as $v) { 
     372               $dashboardContents .= $v; 
     373          } 
     374          $dashboardContents .= '</div>'; 
     375     } 
     376} 
     377echo ($dashboardContents ? '<div id="dashboard-contents">'.$dashboardContents.'</div>' : ''); 
     378 
     379echo '</div>'; 
     380 
     381echo ($dashboardItems ? '<div id="dashboard-items">'.$dashboardItems.'</div>' : ''); 
     382 
     383dcPage::close(); 
    308384?> 
Note: See TracChangeset for help on using the changeset viewer.

Sites map