Changeset 2715:a87ddf7dbfb5 for admin/index.php
- Timestamp:
- 05/20/14 08:39:33 (11 years ago)
- Branch:
- twig
- Parents:
- 2683:fb8aa74332f1 (diff), 2714:eed2e5727277 (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
r2708 r2715 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)) { 61 $core->auth->user_prefs->dashboard->put('quickentry',false,'boolean','',null,true); 62 } 63 $core->auth->user_prefs->dashboard->put('quickentry',false,'boolean'); 64 } 65 66 // Handle folded/unfolded sections in admin from user preferences 67 $ws = $core->auth->user_prefs->addWorkspace('toggles'); 68 if (!$core->auth->user_prefs->toggles->prefExists('unfolded_sections')) { 69 $core->auth->user_prefs->toggles->put('unfolded_sections','','string','Folded sections in admin',null,true); 70 } 71 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; 188 } 72 189 73 190 # Dashboard icons … … 76 193 $favs = $core->favs->getUserFavorites(); 77 194 $core->favs->appendDashboardIcons($__dashboard_icons); 195 78 196 79 197 # Check plugins and themes update from repository … … 101 219 102 220 $dashboardItem = 0; 221 103 222 104 223 if ($core->auth->user_prefs->dashboard->dcnews) { … … 168 287 $core->callBehavior('adminDashboardContents', $core, $__dashboard_contents); 169 288 170 /* DISPLAY 171 -------------------------------------------------------- */ 172 dcPage::open(__('Dashboard'), 173 dcPage::jsLoad('js/_index.js'). 174 $core->callBehavior('adminPostEditor'). 175 # --BEHAVIOR-- adminDashboardHeaders 176 $core->callBehavior('adminDashboardHeaders'), 177 dcPage::breadcrumb( 178 array( 179 __('Dashboard').' : '.html::escapeHTML($core->blog->name) => '' 180 ), 181 array('home_link' =>false) 182 ) 183 ); 184 185 # Dotclear updates notifications 186 if ($core->auth->isSuperAdmin() && is_readable(DC_DIGESTS)) 187 { 188 $updater = new dcUpdate(DC_UPDATE_URL,'dotclear',DC_UPDATE_VERSION,DC_TPL_CACHE.'/versions'); 189 $new_v = $updater->check(DC_VERSION); 190 $version_info = $new_v ? $updater->getInfoURL() : ''; 191 192 if ($updater->getNotify() && $new_v) { 193 echo 194 '<div class="dc-update"><h3>'.sprintf(__('Dotclear %s is available!'),$new_v).'</h3> '. 195 '<p><a class="button submit" href="update.php">'.sprintf(__('Upgrade now'),$new_v).'</a> '. 196 '<a class="button" href="update.php?hide_msg=1">'.__('Remind me later').'</a>'. 197 ($version_info ? ' </p>'. 198 '<p class="updt-info"><a href="'.$version_info.'">'.__('Information about this version').'</a>' : '').'</p>'. 199 '</div>'; 200 } 201 } 202 203 if ($core->auth->getInfo('user_default_blog') != $core->blog->id && $core->auth->getBlogCount() > 1) { 204 echo 205 '<p><a href="index.php?default_blog=1" class="button">'.__('Make this blog my default blog').'</a></p>'; 206 } 207 289 # Blog status message 208 290 if ($core->blog->status == 0) { 209 echo '<p class="static-msg">'.__('This blog is offline').'.</p>';291 $_ctx->addMessageStatic(__('This blog is offline')); 210 292 } elseif ($core->blog->status == -1) { 211 echo '<p class="static-msg">'.__('This blog is removed').'.</p>'; 212 } 213 293 $_ctx->addMessageStatic(__('This blog is removed')); 294 } 295 296 # Config errors messages 214 297 if (!defined('DC_ADMIN_URL') || !DC_ADMIN_URL) { 215 echo 216 '<p class="static-msg">'. 217 sprintf(__('%s is not defined, you should edit your configuration file.'),'DC_ADMIN_URL'). 218 ' '.__('See <a href="http://dotclear.org/documentation/2.0/admin/config">documentation</a> for more information.'). 219 '</p>'; 220 } 221 298 $_ctx->addMessageStatic( 299 sprintf(__('%s is not defined, you should edit your configuration file.'),'DC_ADMIN_URL').' '. 300 __('See <a href="http://dotclear.org/documentation/2.0/admin/config">documentation</a> for more information.') 301 ); 302 } 222 303 if (!defined('DC_ADMIN_MAILFROM') || !DC_ADMIN_MAILFROM) { 223 echo 224 '<p class="static-msg">'. 225 sprintf(__('%s is not defined, you should edit your configuration file.'),'DC_ADMIN_MAILFROM'). 226 ' '.__('See <a href="http://dotclear.org/documentation/2.0/admin/config">documentation</a> for more information.'). 227 '</p>'; 228 } 229 230 $err = array(); 231 232 # Check cache directory 233 if ( $core->auth->isSuperAdmin() ) { 234 if (!is_dir(DC_TPL_CACHE) || !is_writable(DC_TPL_CACHE)) { 235 $err[] = '<p>'.__("The cache directory does not exist or is not writable. You must create this directory with sufficient rights and affect this location to \"DC_TPL_CACHE\" in inc/config.php file.").'</p>'; 236 } 237 } else { 238 if (!is_dir(DC_TPL_CACHE) || !is_writable(DC_TPL_CACHE)) { 239 $err[] = '<p>'.__("The cache directory does not exist or is not writable. You should contact your administrator.").'</p>'; 240 } 241 } 242 243 # Check public directory 244 if ( $core->auth->isSuperAdmin() ) { 245 if (!is_dir($core->blog->public_path) || !is_writable($core->blog->public_path)) { 246 $err[] = '<p>'.__("There is no writable directory /public/ at the location set in about:config \"public_path\". You must create this directory with sufficient rights (or change this setting).").'</p>'; 247 } 248 } else { 249 if (!is_dir($core->blog->public_path) || !is_writable($core->blog->public_path)) { 250 $err[] = '<p>'.__("There is no writable root directory for the media manager. You should contact your administrator.").'</p>'; 251 } 252 } 253 254 # Error list 255 if (count($err) > 0) { 256 echo '<div class="error"><p><strong>'.__('Error:').'</strong></p>'. 257 '<ul><li>'.implode("</li><li>",$err).'</li></ul></div>'; 258 } 259 260 # Plugins install messages 261 if (!empty($plugins_install['success'])) 262 { 263 echo '<div class="success">'.__('Following plugins have been installed:').'<ul>'; 264 foreach ($plugins_install['success'] as $k => $v) { 265 echo '<li>'.$k.'</li>'; 266 } 267 echo '</ul></div>'; 268 } 269 if (!empty($plugins_install['failure'])) 270 { 271 echo '<div class="error">'.__('Following plugins have not been installed:').'<ul>'; 272 foreach ($plugins_install['failure'] as $k => $v) { 273 echo '<li>'.$k.' ('.$v.')</li>'; 274 } 275 echo '</ul></div>'; 276 } 277 # Errors modules notifications 278 if ($core->auth->isSuperAdmin()) 279 { 280 $list = $core->plugins->getErrors(); 281 if (!empty($list)) { 282 echo 283 '<div class="error" id="module-errors" class="error"><p>'.__('Errors have occured with following plugins:').'</p> '. 284 '<ul><li>'.implode("</li>\n<li>", $list).'</li></ul></div>'; 285 } 286 } 287 288 # Dashboard columns (processed first, as we need to know the result before displaying the icons.) 289 $dashboardItems = ''; 290 291 foreach ($__dashboard_items as $i) 292 { 293 if ($i->count() > 0) 294 { 295 $dashboardItems .= ''; 296 foreach ($i as $v) { 297 $dashboardItems .= $v; 298 } 299 $dashboardItems .= ''; 300 } 301 } 302 303 # Dashboard elements 304 echo '<div id="dashboard-main">'; 305 306 # Dashboard icons 307 echo '<div id="icons">'; 308 foreach ($__dashboard_icons as $i) 309 { 310 echo 311 '<p><a href="'.$i[1].'"><img src="'.dc_admin_icon_url($i[2]).'" alt="" />'. 312 '<br /><span>'.$i[0].'</span></a></p>'; 313 } 314 echo '</div>'; 315 316 if ($core->auth->user_prefs->dashboard->quickentry) { 317 if ($core->auth->check('usage,contentadmin',$core->blog->id)) 318 { 319 # Getting categories 320 $categories_combo = dcAdminCombos::getCategoriesCombo( 321 $core->blog->getCategories(array('post_type'=>'post')) 322 ); 323 324 echo 325 '<div id="quick">'. 326 '<h3>'.__('Quick entry').'</h3>'. 327 '<form id="quick-entry" action="'.$core->adminurl->get('admin.post').'" method="post" class="fieldset">'. 328 '<h4>'.__('New entry').'</h4>'. 329 '<p class="col"><label for="post_title" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Title:').'</label>'. 330 form::field('post_title',20,255,'','maximal'). 331 '</p>'. 332 '<p class="area"><label class="required" '. 333 'for="post_content"><abbr title="'.__('Required field').'">*</abbr> '.__('Content:').'</label> '. 334 form::textarea('post_content',50,10). 335 '</p>'. 336 '<p><label for="cat_id" class="classic">'.__('Category:').'</label> '. 337 form::combo('cat_id',$categories_combo).'</p>'. 338 ($core->auth->check('categories', $core->blog->id) 339 ? '<div>'. 340 '<p id="new_cat" class="q-cat">'.__('Add a new category').'</p>'. 341 '<p class="q-cat"><label for="new_cat_title">'.__('Title:').'</label> '. 342 form::field('new_cat_title',30,255,'','').'</p>'. 343 '<p class="q-cat"><label for="new_cat_parent">'.__('Parent:').'</label> '. 344 form::combo('new_cat_parent',$categories_combo,'',''). 345 '</p>'. 346 '<p class="form-note info clear">'.__('This category will be created when you will save your post.').'</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 '</form>'. 361 '</div>'; 362 } 363 } 364 365 foreach ($__dashboard_contents as $i) 366 { 367 if ($i->count() > 0) 368 { 369 $dashboardContents .= ''; 370 foreach ($i as $v) { 371 $dashboardContents .= $v; 372 } 373 $dashboardContents .= ''; 374 } 375 } 376 377 if ($dashboardContents != '' || $dashboardItems != '') { 378 echo 379 '<div id="dashboard-boxes">'. 380 '<div class="db-items">'.$dashboardItems.$dashboardContents.'</div>'. 381 '</div>'; 382 } 383 384 echo '</div>'; #end dashboard-main 385 dcPage::helpBlock('core_dashboard'); 386 dcPage::close(); 304 $_ctx->addMessageStatic( 305 sprintf(__('%s is not defined, you should edit your configuration file.'),'DC_ADMIN_MAILFROM').' '. 306 __('See <a href="http://dotclear.org/documentation/2.0/admin/config">documentation</a> for more information.') 307 ); 308 } 309 $_ctx->dashboard_icons = $__dashboard_icons; 310 //print_r($__dashboard_icons);exit; 311 $_ctx->setBreadCrumb(__('Dashboard').' : '.html::escapeHTML($core->blog->name), false); 312 $core->tpl->display('index.html.twig'); 313 ?>
Note: See TracChangeset
for help on using the changeset viewer.