Changeset 1080:4f4478e9973d for admin/index.php
- Timestamp:
- 12/18/12 14:36:48 (13 years ago)
- Branch:
- twig
- Parents:
- 1079:e3bf3d268635 (diff), 1077:e80b1a400723 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
admin/index.php
r1077 r1080 15 15 exit; 16 16 } 17 if (!empty($_GET['tf'])) { 18 define('DC_CONTEXT_ADMIN',true); 19 require dirname(__FILE__).'/../inc/load_theme_file.php'; 20 exit; 21 } 17 22 18 23 require dirname(__FILE__).'/../inc/admin/prepend.php'; … … 43 48 $plugins_install = $core->plugins->installModules(); 44 49 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 45 77 # Check dashboard module prefs 46 78 $ws = $core->auth->user_prefs->addWorkspace('dashboard'); 79 80 # Doclinks prefs 47 81 if (!$core->auth->user_prefs->dashboard->prefExists('doclinks')) { 48 82 if (!$core->auth->user_prefs->dashboard->prefExists('doclinks',true)) { … … 51 85 $core->auth->user_prefs->dashboard->put('doclinks',true,'boolean'); 52 86 } 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 53 95 if (!$core->auth->user_prefs->dashboard->prefExists('dcnews')) { 54 96 if (!$core->auth->user_prefs->dashboard->prefExists('dcnews',true)) { … … 57 99 $core->auth->user_prefs->dashboard->put('dcnews',true,'boolean'); 58 100 } 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 59 132 if (!$core->auth->user_prefs->dashboard->prefExists('quickentry')) { 60 133 if (!$core->auth->user_prefs->dashboard->prefExists('quickentry',true)) { … … 62 135 } 63 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[] = new formSelectOption( 148 str_repeat(' ',$categories->level-1). 149 ($categories->level-1 == 0 ? '' : '• ').html::escapeHTML($categories->cat_title), 150 $categories->cat_id 151 ); 152 } 153 } 154 catch (Exception $e) { } 155 156 $form = new dcForm($core,'quickentry','post.php'); 157 $form 158 ->addField( 159 new dcFieldText('post_title','', array( 160 'size' => 20, 161 'required' => true, 162 'label' => __('Title')))) 163 ->addField( 164 new dcFieldTextArea('post_content','', array( 165 'required' => true, 166 'label' => __("Content:")))) 167 ->addField( 168 new dcFieldCombo('cat_id','',$categories_combo,array( 169 "label" => __('Category:')))) 170 ->addField( 171 new dcFieldSubmit('save',__('Save'),array( 172 'action' => 'savePost'))) 173 ->addField( 174 new dcFieldHidden ('post_status',-2)) 175 ->addField( 176 new dcFieldHidden ('post_format',$core->auth->getOption('post_format'))) 177 ->addField( 178 new dcFieldHidden ('post_excerpt','')) 179 ->addField( 180 new dcFieldHidden ('post_lang',$core->auth->getInfo('user_lang'))) 181 ->addField( 182 new dcFieldHidden ('post_notes','')) 183 ; 184 if ($core->auth->check('publish',$core->blog->id)) { 185 $form->addField( 186 new dcFieldHidden ('save-publish',__('Save and publish'))); 187 } 188 189 $_ctx->dashboard_quickentry = true; 64 190 } 65 191 … … 118 244 } 119 245 120 # Latest news for dashboard 246 # Send dashboard icons to templates 247 $icons = array(); 248 foreach ($__dashboard_icons as $i) { 249 $icons[] = array( 250 'title' => $i[0], 251 'url' => $i[1], 252 'img' => dc_admin_icon_url($i[2]) 253 ); 254 } 255 $_ctx->dashboard_icons = $icons; 256 257 # Dashboard items 121 258 $__dashboard_items = new ArrayObject(array(new ArrayObject,new ArrayObject)); 122 123 # Documentation links124 $dashboardItem = 0;125 if ($core->auth->user_prefs->dashboard->doclinks) {126 if (!empty($__resources['doc']))127 {128 $doc_links = '<h3>'.__('Documentation and support').'</h3><ul>';129 130 foreach ($__resources['doc'] as $k => $v) {131 $doc_links .= '<li><a href="'.$v.'" title="'.$k.' '.__('(external link)').'">'.$k.'</a></li>';132 }133 134 $doc_links .= '</ul>';135 $__dashboard_items[$dashboardItem][] = $doc_links;136 $dashboardItem++;137 }138 }139 140 if ($core->auth->user_prefs->dashboard->dcnews) {141 try142 {143 if (empty($__resources['rss_news'])) {144 throw new Exception();145 }146 147 $feed_reader = new feedReader;148 $feed_reader->setCacheDir(DC_TPL_CACHE);149 $feed_reader->setTimeout(2);150 $feed_reader->setUserAgent('Dotclear - http://www.dotclear.org/');151 $feed = $feed_reader->parse($__resources['rss_news']);152 if ($feed)153 {154 $latest_news = '<h3>'.__('Latest news').'</h3><dl id="news">';155 $i = 1;156 foreach ($feed->items as $item)157 {158 $dt = isset($item->link) ? '<a href="'.$item->link.'" title="'.$item->title.' '.__('(external link)').'">'.159 $item->title.'</a>' : $item->title;160 161 if ($i < 3) {162 $latest_news .=163 '<dt>'.$dt.'</dt>'.164 '<dd><p><strong>'.dt::dt2str(__('%d %B %Y:'),$item->pubdate,'Europe/Paris').'</strong> '.165 '<em>'.text::cutString(html::clean($item->content),120).'...</em></p></dd>';166 } else {167 $latest_news .=168 '<dt>'.$dt.'</dt>'.169 '<dd>'.dt::dt2str(__('%d %B %Y:'),$item->pubdate,'Europe/Paris').'</dd>';170 }171 $i++;172 if ($i > 3) { break; }173 }174 $latest_news .= '</dl>';175 $__dashboard_items[$dashboardItem][] = $latest_news;176 $dashboardItem++;177 }178 }179 catch (Exception $e) {}180 }181 182 259 $core->callBehavior('adminDashboardItems', $core, $__dashboard_items); 183 260 261 # Send dashboard items to templates 262 $items = array(); 263 foreach ($__dashboard_items as $i) { 264 if ($i->count() > 0) { 265 foreach ($i as $v) { 266 $items[] = $v; 267 } 268 } 269 } 270 $_ctx->dashboard_items = $items; 271 184 272 # Dashboard content 185 $dashboardContents = '';186 273 $__dashboard_contents = new ArrayObject(array(new ArrayObject,new ArrayObject)); 187 274 $core->callBehavior('adminDashboardContents', $core, $__dashboard_contents); 188 275 189 /* DISPLAY 190 -------------------------------------------------------- */ 191 dcPage::open(__('Dashboard'), 192 dcPage::jsToolBar(). 193 dcPage::jsLoad('js/_index.js'). 194 # --BEHAVIOR-- adminDashboardHeaders 195 $core->callBehavior('adminDashboardHeaders') 196 ); 197 198 echo '<h2>'.html::escapeHTML($core->blog->name).' › <span class="page-title">'.__('Dashboard').'</span></h2>'; 199 200 if ($core->auth->getInfo('user_default_blog') != $core->blog->id && $core->auth->blog_count > 1) { 201 echo 202 '<p><a href="index.php?default_blog=1" class="button">'.__('Make this blog my default blog').'</a></p>'; 203 } 204 276 # Send dashboard contents to templates 277 $contents = array(); 278 foreach ($__dashboard_contents as $i) { 279 if ($i->count() > 0) { 280 foreach ($i as $v) { 281 $contents[] = $v; 282 } 283 } 284 } 285 $_ctx->dashboard_contents = $contents; 286 287 # Blog status message 205 288 if ($core->blog->status == 0) { 206 echo '<p class="static-msg">'.__('This blog is offline').'</p>';289 $_ctx->addMessageStatic(__('This blog is offline')); 207 290 } elseif ($core->blog->status == -1) { 208 echo '<p class="static-msg">'.__('This blog is removed').'</p>'; 209 } 210 291 $_ctx->addMessageStatic(__('This blog is removed')); 292 } 293 294 # Config errors messages 211 295 if (!defined('DC_ADMIN_URL') || !DC_ADMIN_URL) { 212 echo 213 '<p class="static-msg">'. 214 sprintf(__('%s is not defined, you should edit your configuration file.'),'DC_ADMIN_URL'). 215 ' '.__('See <a href="http://dotclear.org/documentation/2.0/admin/config">documentation</a> for more information.'). 216 '</p>'; 217 } 218 296 $_ctx->addMessageStatic( 297 sprintf(__('%s is not defined, you should edit your configuration file.'),'DC_ADMIN_URL').' '. 298 __('See <a href="http://dotclear.org/documentation/2.0/admin/config">documentation</a> for more information.') 299 ); 300 } 219 301 if (!defined('DC_ADMIN_MAILFROM') || !DC_ADMIN_MAILFROM) { 220 echo 221 '<p class="static-msg">'. 222 sprintf(__('%s is not defined, you should edit your configuration file.'),'DC_ADMIN_MAILFROM'). 223 ' '.__('See <a href="http://dotclear.org/documentation/2.0/admin/config">documentation</a> for more information.'). 224 '</p>'; 225 } 226 227 # Plugins install messages 228 if (!empty($plugins_install['success'])) 229 { 230 echo '<div class="static-msg">'.__('Following plugins have been installed:').'<ul>'; 231 foreach ($plugins_install['success'] as $k => $v) { 232 echo '<li>'.$k.'</li>'; 233 } 234 echo '</ul></div>'; 235 } 236 if (!empty($plugins_install['failure'])) 237 { 238 echo '<div class="error">'.__('Following plugins have not been installed:').'<ul>'; 239 foreach ($plugins_install['failure'] as $k => $v) { 240 echo '<li>'.$k.' ('.$v.')</li>'; 241 } 242 echo '</ul></div>'; 243 } 244 245 # Dashboard columns (processed first, as we need to know the result before displaying the icons.) 246 $dashboardItems = ''; 247 248 # Dotclear updates notifications 249 if ($core->auth->isSuperAdmin() && is_readable(DC_DIGESTS)) 250 { 251 $updater = new dcUpdate(DC_UPDATE_URL,'dotclear',DC_UPDATE_VERSION,DC_TPL_CACHE.'/versions'); 252 $new_v = $updater->check(DC_VERSION); 253 $version_info = $new_v ? $updater->getInfoURL() : ''; 254 255 if ($updater->getNotify() && $new_v) { 256 $dashboardItems .= 257 '<div id="upg-notify" class="static-msg"><p>'.sprintf(__('Dotclear %s is available!'),$new_v).'</p> '. 258 '<ul><li><strong><a href="update.php">'.sprintf(__('Upgrade now'),$new_v).'</a></strong>'. 259 '</li><li><a href="update.php?hide_msg=1">'.__('Remind me later').'</a>'. 260 ($version_info ? ' </li><li><a href="'.$version_info.'">'.__('information about this version').'</a>' : ''). 261 '</li></ul></div>'; 262 } 263 } 264 265 # Errors modules notifications 266 if ($core->auth->isSuperAdmin()) 267 { 268 $list = array(); 269 foreach ($core->plugins->getErrors() as $k => $error) { 270 $list[] = '<li>'.$error.'</li>'; 271 } 272 273 if (count($list) > 0) { 274 $dashboardItems .= 275 '<div id="module-errors" class="error"><p>'.__('Some plugins are installed twice:').'</p> '. 276 '<ul>'.implode("\n",$list).'</ul></div>'; 277 } 278 279 } 280 281 foreach ($__dashboard_items as $i) 282 { 283 if ($i->count() > 0) 284 { 285 $dashboardItems .= '<div>'; 286 foreach ($i as $v) { 287 $dashboardItems .= $v; 288 } 289 $dashboardItems .= '</div>'; 290 } 291 } 292 293 # Dashboard icons 294 echo '<div id="dashboard-main"'.($dashboardItems ? '' : ' class="fullwidth"').'><div id="icons">'; 295 foreach ($__dashboard_icons as $i) 296 { 297 echo 298 '<p><a href="'.$i[1].'"><img src="'.dc_admin_icon_url($i[2]).'" alt="" />'. 299 '<br /><span>'.$i[0].'</span></a></p>'; 300 } 301 echo '</div>'; 302 303 if ($core->auth->user_prefs->dashboard->quickentry) { 304 if ($core->auth->check('usage,contentadmin',$core->blog->id)) 305 { 306 $categories_combo = array(' ' => ''); 307 try { 308 $categories = $core->blog->getCategories(array('post_type'=>'post')); 309 while ($categories->fetch()) { 310 $categories_combo[] = new formSelectOption( 311 str_repeat(' ',$categories->level-1). 312 ($categories->level-1 == 0 ? '' : '• ').html::escapeHTML($categories->cat_title), 313 $categories->cat_id 314 ); 315 } 316 } catch (Exception $e) { } 317 318 echo 319 '<div id="quick">'. 320 '<h3>'.__('Quick entry').'</h3>'. 321 '<form id="quick-entry" action="post.php" method="post">'. 322 '<fieldset><legend>'.__('New entry').'</legend>'. 323 '<p class="col"><label for="post_title" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Title:'). 324 form::field('post_title',20,255,'','maximal'). 325 '</label></p>'. 326 '<p class="area"><label class="required" '. 327 'for="post_content"><abbr title="'.__('Required field').'">*</abbr> '.__('Content:').'</label> '. 328 form::textarea('post_content',50,7). 329 '</p>'. 330 '<p><label for="cat_id" class="classic">'.__('Category:').' '. 331 form::combo('cat_id',$categories_combo).'</label></p>'. 332 '<p><input type="submit" value="'.__('Save').'" name="save" /> '. 333 ($core->auth->check('publish',$core->blog->id) 334 ? '<input type="hidden" value="'.__('Save and publish').'" name="save-publish" />' 335 : ''). 336 $core->formNonce(). 337 form::hidden('post_status',-2). 338 form::hidden('post_format',$core->auth->getOption('post_format')). 339 form::hidden('post_excerpt',''). 340 form::hidden('post_lang',$core->auth->getInfo('user_lang')). 341 form::hidden('post_notes',''). 342 '</p>'. 343 '</fieldset>'. 344 '</form>'. 345 '</div>'; 346 } 347 } 348 349 foreach ($__dashboard_contents as $i) 350 { 351 if ($i->count() > 0) 352 { 353 $dashboardContents .= '<div>'; 354 foreach ($i as $v) { 355 $dashboardContents .= $v; 356 } 357 $dashboardContents .= '</div>'; 358 } 359 } 360 echo ($dashboardContents ? '<div id="dashboard-contents">'.$dashboardContents.'</div>' : ''); 361 362 echo '</div>'; 363 364 echo ($dashboardItems ? '<div id="dashboard-items">'.$dashboardItems.'</div>' : ''); 365 366 dcPage::close(); 302 $_ctx->addMessageStatic( 303 sprintf(__('%s is not defined, you should edit your configuration file.'),'DC_ADMIN_MAILFROM').' '. 304 __('See <a href="http://dotclear.org/documentation/2.0/admin/config">documentation</a> for more information.') 305 ); 306 } 307 308 $_ctx->setPageTitle(__('Dashboard')); 309 $core->tpl->display('index.html.twig'); 367 310 ?>
Note: See TracChangeset
for help on using the changeset viewer.