Changeset 1080:4f4478e9973d
- 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. - Files:
-
- 7 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 ?> -
admin/post.php
r1068 r1080 15 15 dcPage::check('usage,contentadmin'); 16 16 17 $post_id = ''; 18 $cat_id = ''; 19 $post_dt = ''; 20 $post_format = $core->auth->getOption('post_format'); 21 $post_password = ''; 22 $post_url = ''; 23 $post_lang = $core->auth->getInfo('user_lang'); 24 $post_title = ''; 25 $post_excerpt = ''; 26 $post_excerpt_xhtml = ''; 27 $post_content = ''; 28 $post_content_xhtml = ''; 29 $post_notes = ''; 30 $post_status = $core->auth->getInfo('user_post_status'); 31 $post_selected = false; 32 $post_open_comment = $core->blog->settings->system->allow_comments; 33 $post_open_tb = $core->blog->settings->system->allow_trackbacks; 17 function savePost($form) { 18 global $_ctx; 19 $_ctx->setMessage('save'); 20 21 } 22 23 function deletePost($form) { 24 print_r($form); exit; 25 } 34 26 35 27 $page_title = __('New entry'); … … 47 39 # If user can't publish 48 40 if (!$can_publish) { 49 $ post_status = -2;41 $form->post_status = -2; 50 42 } 51 43 … … 55 47 $categories = $core->blog->getCategories(array('post_type'=>'post')); 56 48 while ($categories->fetch()) { 57 $categories_combo[ ] = new formSelectOption(58 str_repeat(' ',$categories->level-1). ($categories->level-1 == 0 ? '' : '• ').html::escapeHTML($categories->cat_title),59 $categories->cat_id60 );49 $categories_combo[$categories->cat_id] = 50 str_repeat(' ',$categories->level-1). 51 ($categories->level-1 == 0 ? '' : '• '). 52 html::escapeHTML($categories->cat_title); 61 53 } 62 54 } catch (Exception $e) { } … … 64 56 # Status combo 65 57 foreach ($core->blog->getAllPostStatus() as $k => $v) { 66 $status_combo[$v] = (string) $k; 67 } 68 $img_status_pattern = '<img class="img_select_option" alt="%1$s" title="%1$s" src="images/%2$s" />'; 58 $status_combo[$k] = $v; 59 } 69 60 70 61 # Formaters combo … … 88 79 unset($rs); 89 80 90 # Validation flag 91 $bad_dt = false; 92 81 $form = new dcForm($core,'post','post.php'); 82 $form 83 ->addField( 84 new dcFieldText('post_title','', array( 85 'size' => 20, 86 'required' => true, 87 'label' => __('Title')))) 88 ->addField( 89 new dcFieldTextArea('post_excerpt','', array( 90 'cols' => 50, 91 'rows' => 5, 92 'label' => __("Excerpt:")))) 93 ->addField( 94 new dcFieldTextArea('post_content','', array( 95 'required' => true, 96 'label' => __("Content:")))) 97 ->addField( 98 new dcFieldTextArea('post_notes','', array( 99 'label' => __("Notes")))) 100 ->addField( 101 new dcFieldSubmit('save',__('Save'),array( 102 'action' => 'savePost'))) 103 ->addField( 104 new dcFieldSubmit('delete',__('Delete'),array( 105 'action' => 'deletePost'))) 106 ->addField( 107 new dcFieldCombo('post_status',$core->auth->getInfo('user_post_status'),$status_combo,array( 108 'disabled' => !$can_publish, 109 'label' => __('Entry status:')))) 110 ->addField( 111 new dcFieldCombo('cat_id','',$categories_combo,array( 112 "label" => __('Category:')))) 113 ->addField( 114 new dcFieldText('post_dt','',array( 115 "label" => __('Published on:')))) 116 ->addField( 117 new dcFieldCombo('post_format',$core->auth->getOption('post_format'),$formaters_combo,array( 118 "label" => __('Text formating:')))) 119 ->addField( 120 new dcFieldCheckbox ('post_open_comment',$core->blog->settings->system->allow_comments,array( 121 "label" => __('Accept comments')))) 122 ->addField( 123 new dcFieldCheckbox ('post_open_tb',$core->blog->settings->system->allow_trackbacks,array( 124 "label" => __('Accept trackbacks')))) 125 ->addField( 126 new dcFieldCheckbox ('post_selected',false,array( 127 "label" => __('Selected entry')))) 128 ->addField( 129 new dcFieldCombo ('post_lang',$core->auth->getInfo('user_lang'),$lang_combo, array( 130 "label" => __('Entry lang:')))) 131 ->addField( 132 new dcFieldHidden ('id','')) 133 ; 93 134 # Get entry informations 94 135 if (!empty($_REQUEST['id'])) … … 105 146 else 106 147 { 107 $post_id = $post->post_id; 108 $cat_id = $post->cat_id; 109 $post_dt = date('Y-m-d H:i',strtotime($post->post_dt)); 110 $post_format = $post->post_format; 111 $post_password = $post->post_password; 112 $post_url = $post->post_url; 113 $post_lang = $post->post_lang; 114 $post_title = $post->post_title; 115 $post_excerpt = $post->post_excerpt; 116 $post_excerpt_xhtml = $post->post_excerpt_xhtml; 117 $post_content = $post->post_content; 118 $post_content_xhtml = $post->post_content_xhtml; 119 $post_notes = $post->post_notes; 120 $post_status = $post->post_status; 121 $post_selected = (boolean) $post->post_selected; 122 $post_open_comment = (boolean) $post->post_open_comment; 123 $post_open_tb = (boolean) $post->post_open_tb; 148 $form->id = $post->post_id; 149 $form->cat_id = $post->cat_id; 150 $form->post_dt = date('Y-m-d H:i',strtotime($post->post_dt)); 151 $form->post_format = $post->post_format; 152 $form->post_password = $post->post_password; 153 $form->post_url = $post->post_url; 154 $form->post_lang = $post->post_lang; 155 $form->post_title = $post->post_title; 156 $form->post_excerpt = $post->post_excerpt; 157 $form->post_excerpt_xhtml = $post->post_excerpt_xhtml; 158 $form->post_content = $post->post_content; 159 $form->post_content_xhtml = $post->post_content_xhtml; 160 $form->post_notes = $post->post_notes; 161 $form->post_status = $post->post_status; 162 $form->post_selected = (boolean) $post->post_selected; 163 $form->post_open_comment = (boolean) $post->post_open_comment; 164 $form->post_open_tb = (boolean) $post->post_open_tb; 165 $form->can_edit_post = $post->isEditable(); 166 $form->can_delete= $post->isDeletable(); 124 167 125 $page_title = __('Edit entry'); 126 127 $can_edit_post = $post->isEditable(); 128 $can_delete= $post->isDeletable(); 129 130 $next_rs = $core->blog->getNextPost($post,1); 131 $prev_rs = $core->blog->getNextPost($post,-1); 132 133 if ($next_rs !== null) { 134 $next_link = sprintf($post_link,$next_rs->post_id, 135 html::escapeHTML($next_rs->post_title),__('next entry').' »'); 136 $next_headlink = sprintf($post_headlink,'next', 137 html::escapeHTML($next_rs->post_title),$next_rs->post_id); 138 } 139 140 if ($prev_rs !== null) { 141 $prev_link = sprintf($post_link,$prev_rs->post_id, 142 html::escapeHTML($prev_rs->post_title),'« '.__('previous entry')); 143 $prev_headlink = sprintf($post_headlink,'previous', 144 html::escapeHTML($prev_rs->post_title),$prev_rs->post_id); 145 } 146 147 try { 148 $core->media = new dcMedia($core); 149 } catch (Exception $e) {} 150 } 151 } 152 153 # Format excerpt and content 154 if (!empty($_POST) && $can_edit_post) 155 { 156 $post_format = $_POST['post_format']; 157 $post_excerpt = $_POST['post_excerpt']; 158 $post_content = $_POST['post_content']; 159 160 $post_title = $_POST['post_title']; 161 162 $cat_id = (integer) $_POST['cat_id']; 163 164 if (isset($_POST['post_status'])) { 165 $post_status = (integer) $_POST['post_status']; 166 } 167 168 if (empty($_POST['post_dt'])) { 169 $post_dt = ''; 170 } else { 171 try 172 { 173 $post_dt = strtotime($_POST['post_dt']); 174 if ($post_dt == false || $post_dt == -1) { 175 $bad_dt = true; 176 throw new Exception(__('Invalid publication date')); 177 } 178 $post_dt = date('Y-m-d H:i',$post_dt); 179 } 180 catch (Exception $e) 181 { 182 $core->error->add($e->getMessage()); 183 } 184 } 185 186 $post_open_comment = !empty($_POST['post_open_comment']); 187 $post_open_tb = !empty($_POST['post_open_tb']); 188 $post_selected = !empty($_POST['post_selected']); 189 $post_lang = $_POST['post_lang']; 190 $post_password = !empty($_POST['post_password']) ? $_POST['post_password'] : null; 191 192 $post_notes = $_POST['post_notes']; 193 194 if (isset($_POST['post_url'])) { 195 $post_url = $_POST['post_url']; 196 } 197 198 $core->blog->setPostContent( 199 $post_id,$post_format,$post_lang, 200 $post_excerpt,$post_excerpt_xhtml,$post_content,$post_content_xhtml 201 ); 202 } 203 204 # Delete post 205 if (!empty($_POST['delete']) && $can_delete) 206 { 207 try { 208 # --BEHAVIOR-- adminBeforePostDelete 209 $core->callBehavior('adminBeforePostDelete',$post_id); 210 $core->blog->delPost($post_id); 211 http::redirect('posts.php'); 212 } catch (Exception $e) { 213 $core->error->add($e->getMessage()); 214 } 215 } 216 217 # Create or update post 218 if (!empty($_POST) && !empty($_POST['save']) && $can_edit_post && !$bad_dt) 219 { 220 $cur = $core->con->openCursor($core->prefix.'post'); 221 222 $cur->post_title = $post_title; 223 $cur->cat_id = ($cat_id ? $cat_id : null); 224 $cur->post_dt = $post_dt ? date('Y-m-d H:i:00',strtotime($post_dt)) : ''; 225 $cur->post_format = $post_format; 226 $cur->post_password = $post_password; 227 $cur->post_lang = $post_lang; 228 $cur->post_title = $post_title; 229 $cur->post_excerpt = $post_excerpt; 230 $cur->post_excerpt_xhtml = $post_excerpt_xhtml; 231 $cur->post_content = $post_content; 232 $cur->post_content_xhtml = $post_content_xhtml; 233 $cur->post_notes = $post_notes; 234 $cur->post_status = $post_status; 235 $cur->post_selected = (integer) $post_selected; 236 $cur->post_open_comment = (integer) $post_open_comment; 237 $cur->post_open_tb = (integer) $post_open_tb; 238 239 if (isset($_POST['post_url'])) { 240 $cur->post_url = $post_url; 241 } 242 243 # Update post 244 if ($post_id) 245 { 246 try 247 { 248 # --BEHAVIOR-- adminBeforePostUpdate 249 $core->callBehavior('adminBeforePostUpdate',$cur,$post_id); 250 251 $core->blog->updPost($post_id,$cur); 252 253 # --BEHAVIOR-- adminAfterPostUpdate 254 $core->callBehavior('adminAfterPostUpdate',$cur,$post_id); 255 256 http::redirect('post.php?id='.$post_id.'&upd=1'); 257 } 258 catch (Exception $e) 259 { 260 $core->error->add($e->getMessage()); 261 } 262 } 263 else 264 { 265 $cur->user_id = $core->auth->userID(); 266 267 try 268 { 269 # --BEHAVIOR-- adminBeforePostCreate 270 $core->callBehavior('adminBeforePostCreate',$cur); 271 272 $return_id = $core->blog->addPost($cur); 273 274 # --BEHAVIOR-- adminAfterPostCreate 275 $core->callBehavior('adminAfterPostCreate',$cur,$return_id); 276 277 http::redirect('post.php?id='.$return_id.'&crea=1'); 278 } 279 catch (Exception $e) 280 { 281 $core->error->add($e->getMessage()); 282 } 283 } 284 } 168 } 169 } 170 171 $form->setup(); 172 173 174 175 // TODO: Do it better later, required by some javascripts 176 $some_globals = array( 177 'rtl' => l10n::getTextDirection($_lang) == 'rtl', 178 'Nonce' => $core->getNonce(), 179 'sess_id' => session_id(), 180 'sess_uid' => $_SESSION['sess_browser_uid'], 181 'media_manage' => $core->auth->check('media,media_admin',$core->blog->id), 182 'enable_wysiwyg' => isset($core->auth) && $core->auth->getOption('enable_wysiwyg'), 183 'edit_size' => $core->auth->getOption('edit_size') 184 ); 185 foreach($some_globals as $name => $value) { 186 $_ctx->$name = $value; 187 }; 188 // 189 190 285 191 286 192 /* DISPLAY … … 293 199 $default_tab = 'comments'; 294 200 } 295 296 dcPage::open($page_title.' - '.__('Entries'), 297 dcPage::jsDatePicker(). 298 dcPage::jsToolBar(). 299 dcPage::jsModal(). 300 dcPage::jsMetaEditor(). 301 dcPage::jsLoad('js/_post.js'). 302 dcPage::jsConfirmClose('entry-form','comment-form'). 303 # --BEHAVIOR-- adminPostHeaders 304 $core->callBehavior('adminPostHeaders'). 305 dcPage::jsPageTabs($default_tab). 306 $next_headlink."\n".$prev_headlink 307 ); 308 309 if (!empty($_GET['upd'])) { 310 dcPage::message(__('Entry has been successfully updated.')); 311 } 312 elseif (!empty($_GET['crea'])) { 313 dcPage::message(__('Entry has been successfully created.')); 314 } 315 elseif (!empty($_GET['attached'])) { 316 dcPage::message(__('File has been successfully attached.')); 317 } 318 elseif (!empty($_GET['rmattach'])) { 319 dcPage::message(__('Attachment has been successfully removed.')); 320 } 321 322 if (!empty($_GET['creaco'])) { 323 dcPage::message(__('Comment has been successfully created.')); 324 } 325 326 # XHTML conversion 327 if (!empty($_GET['xconv'])) 328 { 329 $post_excerpt = $post_excerpt_xhtml; 330 $post_content = $post_content_xhtml; 331 $post_format = 'xhtml'; 332 333 dcPage::message(__('Don\'t forget to validate your XHTML conversion by saving your post.')); 334 } 335 336 echo '<h2>'.html::escapeHTML($core->blog->name).' › '.'<a href="posts.php">'.__('Entries').'</a> › <span class="page-title">'.$page_title; 337 if ($post_id) { 338 switch ($post_status) { 339 case 1: 340 $img_status = sprintf($img_status_pattern,__('published'),'check-on.png'); 341 break; 342 case 0: 343 $img_status = sprintf($img_status_pattern,__('unpublished'),'check-off.png'); 344 break; 345 case -1: 346 $img_status = sprintf($img_status_pattern,__('scheduled'),'scheduled.png'); 347 break; 348 case -2: 349 $img_status = sprintf($img_status_pattern,__('pending'),'check-wrn.png'); 350 break; 351 default: 352 $img_status = ''; 353 } 354 echo ' “'.$post_title.'”'.' '.$img_status; 355 } 356 echo '</span></h2>'; 357 358 if ($post_id && $post->post_status == 1) { 359 echo '<p><a href="'.$post->getURL().'" onclick="window.open(this.href);return false;" title="'.$post_title.' ('.__('new window').')'.'">'.__('Go to this entry on the site').' <img src="images/outgoing-blue.png" alt="" /></a></p>'; 360 } 361 if ($post_id) 362 { 363 echo '<p>'; 364 if ($prev_link) { echo $prev_link; } 365 if ($next_link && $prev_link) { echo ' - '; } 366 if ($next_link) { echo $next_link; } 367 368 # --BEHAVIOR-- adminPostNavLinks 369 $core->callBehavior('adminPostNavLinks',isset($post) ? $post : null); 370 371 echo '</p>'; 372 } 373 374 # Exit if we cannot view page 375 if (!$can_view_page) { 376 dcPage::helpBlock('core_post'); 377 dcPage::close(); 378 exit; 379 } 380 381 /* Post form if we can edit post 382 -------------------------------------------------------- */ 383 if ($can_edit_post) 384 { 385 echo '<div class="multi-part" title="'.__('Edit entry').'" id="edit-entry">'; 386 echo '<form action="post.php" method="post" id="entry-form">'; 387 echo '<div id="entry-wrapper">'; 388 echo '<div id="entry-content"><div class="constrained">'; 389 390 echo 391 '<p class="col"><label class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Title:'). 392 form::field('post_title',20,255,html::escapeHTML($post_title),'maximal'). 393 '</label></p>'. 394 395 '<p class="area" id="excerpt-area"><label for="post_excerpt">'.__('Excerpt:').'</label> '. 396 form::textarea('post_excerpt',50,5,html::escapeHTML($post_excerpt)). 397 '</p>'. 398 399 '<p class="area"><label class="required" '. 400 'for="post_content"><abbr title="'.__('Required field').'">*</abbr> '.__('Content:').'</label> '. 401 form::textarea('post_content',50,$core->auth->getOption('edit_size'),html::escapeHTML($post_content)). 402 '</p>'. 403 404 '<p class="area" id="notes-area"><label for="post_notes">'.__('Notes:').'</label>'. 405 form::textarea('post_notes',50,5,html::escapeHTML($post_notes)). 406 '</p>'; 407 408 # --BEHAVIOR-- adminPostForm 409 $core->callBehavior('adminPostForm',isset($post) ? $post : null); 410 411 echo 412 '<p>'. 413 ($post_id ? form::hidden('id',$post_id) : ''). 414 '<input type="submit" value="'.__('Save').' (s)" '. 415 'accesskey="s" name="save" /> '; 416 if ($post_id) { 417 $preview_url = 418 $core->blog->url.$core->url->getURLFor('preview',$core->auth->userID().'/'. 419 http::browserUID(DC_MASTER_KEY.$core->auth->userID().$core->auth->getInfo('user_pwd')). 420 '/'.$post->post_url); 421 echo '<a id="post-preview" href="'.$preview_url.'" class="button">'.__('Preview').'</a> '; 422 } 423 echo 424 ($can_delete ? '<input type="submit" class="delete" value="'.__('Delete').'" name="delete" />' : ''). 425 $core->formNonce(). 426 '</p>'; 427 428 echo '</div></div>'; // End #entry-content 429 echo '</div>'; // End #entry-wrapper 430 431 echo '<div id="entry-sidebar">'; 432 433 echo 434 '<p><label for="cat_id">'.__('Category:'). 435 form::combo('cat_id',$categories_combo,$cat_id,'maximal'). 436 '</label></p>'. 437 438 '<p><label for="post_status">'.__('Entry status:'). 439 form::combo('post_status',$status_combo,$post_status,'','',!$can_publish). 440 '</label></p>'. 441 442 '<p><label for="post_dt">'.__('Published on:'). 443 form::field('post_dt',16,16,$post_dt,($bad_dt ? 'invalid' : '')). 444 '</label></p>'. 445 446 '<p><label for="post_format">'.__('Text formating:'). 447 form::combo('post_format',$formaters_combo,$post_format). 448 '</label>'. 449 '</p>'. 450 '<p>'.($post_id && $post_format != 'xhtml' ? '<a id="convert-xhtml" class="button" href="post.php?id='.$post_id.'&xconv=1">'.__('Convert to XHTML').'</a>' : '').'</p>'. 451 452 '<p><label for="post_open_comment" class="classic">'.form::checkbox('post_open_comment',1,$post_open_comment).' '. 453 __('Accept comments').'</label></p>'. 454 ($core->blog->settings->system->allow_comments ? 455 (isContributionAllowed($post_id,strtotime($post_dt),true) ? 456 '' : 457 '<p class="form-note warn">'.__('Warning: Comments are not more accepted for this entry.').'</p>') : 458 '<p class="form-note warn">'.__('Warning: Comments are not accepted on this blog.').'</p>'). 459 460 '<p><label for="post_open_tb" class="classic">'.form::checkbox('post_open_tb',1,$post_open_tb).' '. 461 __('Accept trackbacks').'</label></p>'. 462 ($core->blog->settings->system->allow_trackbacks ? 463 (isContributionAllowed($post_id,strtotime($post_dt),false) ? 464 '' : 465 '<p class="form-note warn">'.__('Warning: Trackbacks are not more accepted for this entry.').'</p>') : 466 '<p class="form-note warn">'.__('Warning: Trackbacks are not accepted on this blog.').'</p>'). 467 468 '<p><label for="post_selected" class="classic">'.form::checkbox('post_selected',1,$post_selected).' '. 469 __('Selected entry').'</label></p>'. 470 471 '<p><label for="post_lang">'.__('Entry lang:'). 472 form::combo('post_lang',$lang_combo,$post_lang). 473 '</label></p>'. 474 475 '<p><label for="post_password">'.__('Entry password:'). 476 form::field('post_password',10,32,html::escapeHTML($post_password),'maximal'). 477 '</label></p>'. 478 479 '<div class="lockable">'. 480 '<p><label for="post_url">'.__('Basename:'). 481 form::field('post_url',10,255,html::escapeHTML($post_url),'maximal'). 482 '</label></p>'. 483 '<p class="form-note warn">'. 484 __('Warning: If you set the URL manually, it may conflict with another entry.'). 485 '</p>'. 486 '</div>'; 487 488 # --BEHAVIOR-- adminPostFormSidebar 489 $core->callBehavior('adminPostFormSidebar',isset($post) ? $post : null); 490 491 echo '</div>'; // End #entry-sidebar 492 493 echo '</form>'; 494 495 # --BEHAVIOR-- adminPostForm 496 $core->callBehavior('adminPostAfterForm',isset($post) ? $post : null); 497 498 echo '</div>'; 499 500 if ($post_id && $post->post_status == 1) { 501 echo '<p><a href="trackbacks.php?id='.$post_id.'" class="multi-part">'. 502 __('Ping blogs').'</a></p>'; 503 } 504 505 } 506 507 508 /* Comments and trackbacks 509 -------------------------------------------------------- */ 510 if ($post_id) 511 { 512 $params = array('post_id' => $post_id, 'order' => 'comment_dt ASC'); 513 514 $comments = $core->blog->getComments(array_merge($params,array('comment_trackback'=>0))); 515 $trackbacks = $core->blog->getComments(array_merge($params,array('comment_trackback'=>1))); 516 517 # Actions combo box 518 $combo_action = array(); 519 if ($can_edit_post && $core->auth->check('publish,contentadmin',$core->blog->id)) 520 { 521 $combo_action[__('publish')] = 'publish'; 522 $combo_action[__('unpublish')] = 'unpublish'; 523 $combo_action[__('mark as pending')] = 'pending'; 524 $combo_action[__('mark as junk')] = 'junk'; 525 } 526 527 if ($can_edit_post && $core->auth->check('delete,contentadmin',$core->blog->id)) 528 { 529 $combo_action[__('Delete')] = 'delete'; 530 } 531 532 # --BEHAVIOR-- adminCommentsActionsCombo 533 $core->callBehavior('adminCommentsActionsCombo',array(&$combo_action)); 534 535 $has_action = !empty($combo_action) && (!$trackbacks->isEmpty() || !$comments->isEmpty()); 536 537 echo 538 '<div id="comments" class="multi-part" title="'.__('Comments').'">'; 539 540 if ($has_action) { 541 echo '<form action="comments_actions.php" id="form-comments" method="post">'; 542 } 543 544 echo '<h3>'.__('Trackbacks').'</h3>'; 545 546 if (!$trackbacks->isEmpty()) { 547 showComments($trackbacks,$has_action,true); 548 } else { 549 echo '<p>'.__('No trackback').'</p>'; 550 } 551 552 echo '<h3>'.__('Comments').'</h3>'; 553 if (!$comments->isEmpty()) { 554 showComments($comments,$has_action); 555 } else { 556 echo '<p>'.__('No comment').'</p>'; 557 } 558 559 if ($has_action) { 560 echo 561 '<div class="two-cols">'. 562 '<p class="col checkboxes-helpers"></p>'. 563 564 '<p class="col right"><label for="action" class="classic">'.__('Selected comments action:').'</label> '. 565 form::combo('action',$combo_action). 566 form::hidden('redir','post.php?id='.$post_id.'&co=1'). 567 $core->formNonce(). 568 '<input type="submit" value="'.__('ok').'" /></p>'. 569 '</div>'. 570 '</form>'; 571 } 572 573 echo '</div>'; 574 } 575 576 /* Add a comment 577 -------------------------------------------------------- */ 578 if ($post_id) 579 { 580 echo 581 '<div class="multi-part" id="add-comment" title="'.__('Add a comment').'">'. 582 '<h3>'.__('Add a comment').'</h3>'. 583 584 '<form action="comment.php" method="post" id="comment-form">'. 585 '<div class="constrained">'. 586 '<p><label for="comment_author" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Name:'). 587 form::field('comment_author',30,255,html::escapeHTML($core->auth->getInfo('user_cn'))). 588 '</label></p>'. 589 590 '<p><label for="comment_email">'.__('Email:'). 591 form::field('comment_email',30,255,html::escapeHTML($core->auth->getInfo('user_email'))). 592 '</label></p>'. 593 594 '<p><label for="comment_site">'.__('Web site:'). 595 form::field('comment_site',30,255,html::escapeHTML($core->auth->getInfo('user_url'))). 596 '</label></p>'. 597 598 '<p class="area"><label for="comment_content" class="required"><abbr title="'.__('Required field').'">*</abbr> '. 599 __('Comment:').'</label> '. 600 form::textarea('comment_content',50,8,html::escapeHTML('')). 601 '</p>'. 602 603 '<p>'.form::hidden('post_id',$post_id). 604 $core->formNonce(). 605 '<input type="submit" name="add" value="'.__('Save').'" /></p>'. 606 '</div>'. 607 '</form>'. 608 '</div>'; 609 } 610 611 # Controls comments or trakbacks capabilities 612 function isContributionAllowed($id,$dt,$com=true) 613 { 614 global $core; 615 616 if (!$id) { 617 return true; 618 } 619 if ($com) { 620 if (($core->blog->settings->system->comments_ttl == 0) || 621 (time() - $core->blog->settings->system->comments_ttl*86400 < $dt)) { 622 return true; 623 } 624 } else { 625 if (($core->blog->settings->system->trackbacks_ttl == 0) || 626 (time() - $core->blog->settings->system->trackbacks_ttl*86400 < $dt)) { 627 return true; 628 } 629 } 630 return false; 631 } 632 633 # Show comments or trackbacks 634 function showComments($rs,$has_action,$tb=false) 635 { 636 echo 637 '<table class="comments-list"><tr>'. 638 '<th colspan="2">'.__('Author').'</th>'. 639 '<th>'.__('Date').'</th>'. 640 '<th class="nowrap">'.__('IP address').'</th>'. 641 '<th>'.__('Status').'</th>'. 642 '<th> </th>'. 643 '</tr>'; 644 645 while($rs->fetch()) 646 { 647 $comment_url = 'comment.php?id='.$rs->comment_id; 648 649 $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; 650 switch ($rs->comment_status) { 651 case 1: 652 $img_status = sprintf($img,__('published'),'check-on.png'); 653 break; 654 case 0: 655 $img_status = sprintf($img,__('unpublished'),'check-off.png'); 656 break; 657 case -1: 658 $img_status = sprintf($img,__('pending'),'check-wrn.png'); 659 break; 660 case -2: 661 $img_status = sprintf($img,__('junk'),'junk.png'); 662 break; 663 } 664 665 echo 666 '<tr class="line'.($rs->comment_status != 1 ? ' offline' : '').'"'. 667 ' id="c'.$rs->comment_id.'">'. 668 669 '<td class="nowrap">'. 670 ($has_action ? form::checkbox(array('comments[]'),$rs->comment_id,'','','',0,'title="'.($tb ? __('select this trackback') : __('select this comment')).'"') : '').'</td>'. 671 '<td class="maximal">'.html::escapeHTML($rs->comment_author).'</td>'. 672 '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$rs->comment_dt).'</td>'. 673 '<td class="nowrap"><a href="comments.php?ip='.$rs->comment_ip.'">'.$rs->comment_ip.'</a></td>'. 674 '<td class="nowrap status">'.$img_status.'</td>'. 675 '<td class="nowrap status"><a href="'.$comment_url.'">'. 676 '<img src="images/edit-mini.png" alt="" title="'.__('Edit this comment').'" /></a></td>'. 677 678 '</tr>'; 679 } 680 681 echo '</table>'; 682 } 683 684 dcPage::helpBlock('core_post','core_wiki'); 685 dcPage::close(); 201 $_ctx->default_tab = $default_tab; 202 $_ctx->setPageTitle($page_title); 203 204 $core->tpl->display('post.html.twig'); 686 205 ?> -
inc/admin/lib.dc.page.php
r1049 r1080 49 49 50 50 # Top of admin page 51 public static function open($title='', $head='') 52 { 53 global $core; 54 55 # List of user's blogs 56 if ($core->auth->blog_count == 1 || $core->auth->blog_count > 20) 57 { 58 $blog_box = 59 '<p>'.__('Blog:').' <strong title="'.html::escapeHTML($core->blog->url).'">'. 60 html::escapeHTML($core->blog->name).'</strong>'; 61 62 if ($core->auth->blog_count > 20) { 63 $blog_box .= ' - <a href="blogs.php">'.__('Change blog').'</a>'; 64 } 65 $blog_box .= '</p>'; 66 } 67 else 68 { 69 $rs_blogs = $core->getBlogs(array('order'=>'LOWER(blog_name)','limit'=>20)); 70 $blogs = array(); 71 while ($rs_blogs->fetch()) { 72 $blogs[html::escapeHTML($rs_blogs->blog_name.' - '.$rs_blogs->blog_url)] = $rs_blogs->blog_id; 73 } 74 $blog_box = 75 '<p><label for="switchblog" class="classic">'. 76 __('Blogs:').' '. 77 $core->formNonce(). 78 form::combo('switchblog',$blogs,$core->blog->id). 79 '</label></p>'. 80 '<noscript><p><input type="submit" value="'.__('ok').'" /></p></noscript>'; 81 } 82 83 $safe_mode = isset($_SESSION['sess_safe_mode']) && $_SESSION['sess_safe_mode']; 84 85 # Display 86 header('Content-Type: text/html; charset=UTF-8'); 87 echo 88 '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" '. 89 ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'."\n". 90 '<html xmlns="http://www.w3.org/1999/xhtml" '. 91 'xml:lang="'.$core->auth->getInfo('user_lang').'" '. 92 'lang="'.$core->auth->getInfo('user_lang').'">'."\n". 93 "<head>\n". 94 ' <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'."\n". 95 ' <title>'.$title.' - '.html::escapeHTML($core->blog->name).' - '.html::escapeHTML(DC_VENDOR_NAME).' - '.DC_VERSION.'</title>'."\n". 96 97 ' <meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" />'."\n". 98 ' <meta name="GOOGLEBOT" content="NOSNIPPET" />'."\n". 99 100 self::jsLoadIE7(). 101 ' <link rel="stylesheet" href="style/default.css" type="text/css" media="screen" />'."\n"; 102 if (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl') { 103 echo 104 ' <link rel="stylesheet" href="style/default-rtl.css" type="text/css" media="screen" />'."\n"; 105 } 106 107 $core->auth->user_prefs->addWorkspace('interface'); 108 $user_ui_hide_std_favicon = $core->auth->user_prefs->interface->hide_std_favicon; 109 if (!$user_ui_hide_std_favicon) { 110 echo '<link rel="icon" type="image/png" href="images/favicon.png" />'; 111 } 112 113 echo 114 self::jsCommon(). 115 $head; 116 117 # --BEHAVIOR-- adminPageHTMLHead 118 $core->callBehavior('adminPageHTMLHead'); 119 120 echo 121 "</head>\n". 122 '<body id="dotclear-admin'. 123 ($safe_mode ? ' safe-mode' : ''). 124 '">'."\n". 125 126 '<div id="header">'. 127 '<ul id="prelude"><li><a href="#content">'.__('Go to the content').'</a></li><li><a href="#main-menu">'.__('Go to the menu').'</a></li></ul>'."\n". 128 '<div id="top"><h1><a href="index.php">'.DC_VENDOR_NAME.'</a></h1></div>'."\n"; 129 130 echo 131 '<div id="info-boxes">'. 132 '<div id="info-box1">'. 133 '<form action="index.php" method="post">'. 134 $blog_box. 135 '<p><a href="'.$core->blog->url.'" onclick="window.open(this.href);return false;" title="'.__('Go to site').' ('.__('new window').')'.'">'.__('Go to site').' <img src="images/outgoing.png" alt="" /></a>'. 136 '</p></form>'. 137 '</div>'. 138 '<div id="info-box2">'. 139 '<a'.(preg_match('/index.php$/',$_SERVER['REQUEST_URI']) ? ' class="active"' : '').' href="index.php">'.__('My dashboard').'</a>'. 140 '<span> | </span><a'.(preg_match('/preferences.php(\?.*)?$/',$_SERVER['REQUEST_URI']) ? ' class="active"' : '').' href="preferences.php">'.__('My preferences').'</a>'. 141 '<span> | </span><a href="index.php?logout=1" class="logout">'.sprintf(__('Logout %s'),$core->auth->userID()).' <img src="images/logout.png" alt="" /></a>'. 142 '</div>'. 143 '</div>'. 144 '</div>'; 145 146 echo 147 '<div id="wrapper">'."\n". 148 '<div id="main">'."\n". 149 '<div id="content">'."\n"; 150 151 # Safe mode 152 if ($safe_mode) 153 { 154 echo 155 '<div class="error"><h3>'.__('Safe mode').'</h3>'. 156 '<p>'.__('You are in safe mode. All plugins have been temporarily disabled. Remind to log out then log in again normally to get back all functionalities').'</p>'. 157 '</div>'; 158 } 51 public static function open($title='',$head='',$popup=false) 52 { 53 global $core, $_ctx; 54 55 $_ctx->popup = (boolean) $popup; 56 $_ctx->page_header = $head; 57 $_ctx->setPageTitle($title); 58 59 ob_start(); 60 } 61 62 public static function close() 63 { 64 $res = ob_get_contents(); 65 ob_end_clean(); 66 67 global $core, $_ctx; 159 68 160 69 if ($core->error->flag()) { 161 echo 162 '<div class="error"><p><strong>'.(count($core->error->getErrors()) > 1 ? __('Errors:') : __('Error:')).'</p></strong>'. 163 $core->error->toHTML(). 164 '</div>'; 165 } 166 } 167 168 public static function close() 169 { 170 global $core; 171 172 $menu =& $GLOBALS['_menu']; 173 174 echo 175 "</div>\n". // End of #content 176 "</div>\n". // End of #main 177 178 '<div id="main-menu">'."\n"; 179 180 foreach ($menu as $k => $v) { 181 echo $menu[$k]->draw(); 182 } 183 184 $text = sprintf(__('Thank you for using %s.'),'<a href="http://dotclear.org/">Dotclear '.DC_VERSION.'</a>'); 185 186 # --BEHAVIOR-- adminPageFooter 187 $textAlt = $core->callBehavior('adminPageFooter',$core,$text); 188 189 echo 190 '</div>'."\n". // End of #main-menu 191 '<div id="footer"><p>'.($textAlt != '' ? $textAlt : $text).'</p></div>'."\n". 192 "</div>\n"; // End of #wrapper 193 194 if (defined('DC_DEV') && DC_DEV === true) { 195 echo self::debugInfo(); 196 } 197 198 echo 199 '</body></html>'; 200 } 201 202 public static function openPopup($title='', $head='') 203 { 204 global $core; 205 206 # Display 207 header('Content-Type: text/html; charset=UTF-8'); 208 echo 209 '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" '. 210 ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'."\n". 211 '<html xmlns="http://www.w3.org/1999/xhtml" '. 212 'xml:lang="'.$core->auth->getInfo('user_lang').'" '. 213 'lang="'.$core->auth->getInfo('user_lang').'">'."\n". 214 "<head>\n". 215 ' <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'."\n". 216 ' <title>'.$title.' - '.html::escapeHTML($core->blog->name).' - '.html::escapeHTML(DC_VENDOR_NAME).' - '.DC_VERSION.'</title>'."\n". 217 218 ' <meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" />'."\n". 219 ' <meta name="GOOGLEBOT" content="NOSNIPPET" />'."\n". 220 221 self::jsLoadIE7(). 222 ' <link rel="stylesheet" href="style/default.css" type="text/css" media="screen" />'."\n"; 223 if (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl') { 224 echo 225 ' <link rel="stylesheet" href="style/default-rtl.css" type="text/css" media="screen" />'."\n"; 226 } 227 228 echo 229 self::jsCommon(). 230 $head; 231 232 # --BEHAVIOR-- adminPageHTMLHead 233 $core->callBehavior('adminPageHTMLHead'); 234 235 echo 236 "</head>\n". 237 '<body id="dotclear-admin" class="popup">'."\n". 238 239 '<div id="top"><h1>'.DC_VENDOR_NAME.'</h1></div>'."\n"; 240 241 echo 242 '<div id="wrapper">'."\n". 243 '<div id="main">'."\n". 244 '<div id="content">'."\n"; 245 246 if ($core->error->flag()) { 247 echo 248 '<div class="error"><strong>'.__('Errors:').'</strong>'. 249 $core->error->toHTML(). 250 '</div>'; 251 } 70 foreach($core->error->getErrors() as $e) { 71 $_ctx->addError($e); 72 } 73 } 74 $_ctx->page_content = $res; 75 $core->tpl->display('page_layout.html.twig'); 76 } 77 78 public static function openPopup($title='',$head='') 79 { 80 self::open($title,$head,true); 252 81 } 253 82 254 83 public static function closePopup() 255 84 { 256 echo 257 "</div>\n". // End of #content 258 "</div>\n". // End of #main 259 '<div id="footer"><p> </p></div>'."\n". 260 "</div>\n". // End of #wrapper 261 '</body></html>'; 85 self::close(); 262 86 } 263 87 … … 278 102 } 279 103 280 private static function debugInfo()281 {282 $global_vars = implode(', ',array_keys($GLOBALS));283 284 $res =285 '<div id="debug"><div>'.286 '<p>memory usage: '.memory_get_usage().' ('.files::size(memory_get_usage()).')</p>';287 288 if (function_exists('xdebug_get_profiler_filename'))289 {290 $res .= '<p>Elapsed time: '.xdebug_time_index().' seconds</p>';291 292 $prof_file = xdebug_get_profiler_filename();293 if ($prof_file) {294 $res .= '<p>Profiler file : '.xdebug_get_profiler_filename().'</p>';295 } else {296 $prof_url = http::getSelfURI();297 $prof_url .= (strpos($prof_url,'?') === false) ? '?' : '&';298 $prof_url .= 'XDEBUG_PROFILE';299 $res .= '<p><a href="'.html::escapeURL($prof_url).'">Trigger profiler</a></p>';300 }301 302 /* xdebug configuration:303 zend_extension = /.../xdebug.so304 xdebug.auto_trace = On305 xdebug.trace_format = 0306 xdebug.trace_options = 1307 xdebug.show_mem_delta = On308 xdebug.profiler_enable = 0309 xdebug.profiler_enable_trigger = 1310 xdebug.profiler_output_dir = /tmp311 xdebug.profiler_append = 0312 xdebug.profiler_output_name = timestamp313 */314 }315 316 $res .=317 '<p>Global vars: '.$global_vars.'</p>'.318 '</div></div>';319 320 return $res;321 }322 323 104 public static function help($page,$index='') 324 105 { … … 400 181 self::jsVar('dotclear.nonce',$GLOBALS['core']->getNonce()). 401 182 402 self::jsVar('dotclear.img_plus_src','images/ expand.png').183 self::jsVar('dotclear.img_plus_src','images/plus.png'). 403 184 self::jsVar('dotclear.img_plus_alt',__('uncover')). 404 self::jsVar('dotclear.img_minus_src','images/ hide.png').185 self::jsVar('dotclear.img_minus_src','images/minus.png'). 405 186 self::jsVar('dotclear.img_minus_alt',__('hide')). 406 187 self::jsVar('dotclear.img_menu_on','images/menu_on.png'). … … 433 214 self::jsVar('dotclear.msg.confirm_delete_post', 434 215 __("Are you sure you want to delete this entry?")). 435 self::jsVar('dotclear.msg.confirm_spam_delete',436 __('Are you sure you want to delete all spams?')).437 216 self::jsVar('dotclear.msg.confirm_delete_comments', 438 217 __('Are you sure you want to delete selected comments (%s)?')). … … 689 468 "//<![CDATA[\n". 690 469 "dotclear.candyUpload = {};\n". 691 self::jsVar('dotclear.msg.activate_enhanced_uploader',__(' Temporarily activate enhanced uploader')).692 self::jsVar('dotclear.msg.disable_enhanced_uploader',__(' Temporarily disable enhanced uploader')).470 self::jsVar('dotclear.msg.activate_enhanced_uploader',__('Activate enhanced uploader')). 471 self::jsVar('dotclear.msg.disable_enhanced_uploader',__('Disable enhanced uploader')). 693 472 self::jsVar('$._candyUpload.prototype.locales.file_uploaded',__('File successfully uploaded.')). 694 473 self::jsVar('$._candyUpload.prototype.locales.max_file_size',__('Maximum file size allowed:')). -
inc/admin/prepend.php
r1069 r1080 375 375 } 376 376 } 377 378 # Add admin default templates path 379 $core->tpl->getLoader()->addPath(dirname(__FILE__).'/default-templates'); 380 # Set admin context 381 $_ctx = new dcAdminContext($core); 382 $core->tpl->addExtension($_ctx); 383 384 # --BEHAVIOR-- adminPrepend 385 $core->callBehavior('adminPrepend',$core,$_ctx); 377 386 ?> -
inc/admin/prepend.php
r1056 r1080 11 11 # -- END LICENSE BLOCK ----------------------------------------- 12 12 13 define('DC_CONTEXT_ADMIN',true); 14 13 15 require_once dirname(__FILE__).'/../prepend.php'; 14 16 … … 19 21 // HTTP/1.0 20 22 header("Pragma: no-cache"); 21 22 define('DC_CONTEXT_ADMIN',true);23 23 24 24 function dc_valid_fav($url) { -
inc/prepend.php
r1069 r1080 12 12 13 13 /* ------------------------------------------------------------------------------------------- */ 14 # ClearBricks, DotClear classes auto-loader14 # ClearBricks, Twig, DotClear classes auto-loader 15 15 if (@is_dir('/usr/lib/clearbricks')) { 16 16 define('CLEARBRICKS_PATH','/usr/lib/clearbricks'); … … 46 46 $__autoload['dcWorkspace'] = dirname(__FILE__).'/core/class.dc.workspace.php'; 47 47 $__autoload['dcPrefs'] = dirname(__FILE__).'/core/class.dc.prefs.php'; 48 $__autoload['dcTwigPage'] = dirname(__FILE__).'/core/class.dc.twig.page.php'; 48 49 49 50 $__autoload['rsExtPost'] = dirname(__FILE__).'/core/class.dc.rs.extensions.php'; … … 52 53 $__autoload['rsExtUser'] = dirname(__FILE__).'/core/class.dc.rs.extensions.php'; 53 54 55 $__autoload['dcAdminContext'] = dirname(__FILE__).'/admin/class.dc.admincontext.php'; 54 56 $__autoload['dcMenu'] = dirname(__FILE__).'/admin/class.dc.menu.php'; 55 57 $__autoload['dcPage'] = dirname(__FILE__).'/admin/lib.dc.page.php'; … … 63 65 $__autoload['context'] = dirname(__FILE__).'/public/lib.tpl.context.php'; 64 66 $__autoload['dcUrlHandlers'] = dirname(__FILE__).'/public/lib.urlhandlers.php'; 67 $__autoload['dcForm'] = dirname(__FILE__).'/admin/class.dc.form.php'; 68 $__autoload['dcFormExtension'] = dirname(__FILE__).'/admin/class.dc.form.php'; 65 69 66 70 # Clearbricks extensions 67 71 html::$absolute_regs[] = '/(<param\s+name="movie"\s+value=")(.*?)(")/msu'; 68 72 html::$absolute_regs[] = '/(<param\s+name="FlashVars"\s+value=".*?(?:mp3|flv)=)(.*?)(&|")/msu'; 73 74 if (@is_dir('/usr/lib/twig')) { 75 define('TWIG_PATH','/usr/lib/twig'); 76 } elseif (is_dir(dirname(__FILE__).'/libs/twig')) { 77 define('TWIG_PATH',dirname(__FILE__).'/libs/twig'); 78 } elseif (isset($_SERVER['TWIG_PATH']) && is_dir($_SERVER['TWIG_PATH'])) { 79 define('TWIG_PATH',$_SERVER['TWIG_PATH']); 80 } 81 82 if (!defined('TWIG_PATH') || !is_dir(TWIG_PATH)) { 83 exit('No Twig path defined'); 84 } 85 require TWIG_PATH.'/Autoloader.php'; 86 Twig_Autoloader::register(); 87 69 88 /* ------------------------------------------------------------------------------------------- */ 70 89 -
inc/prepend.php
r1014 r1080 181 181 } catch (Exception $e) { 182 182 init_prepend_l10n(); 183 __error(__('Unable to connect to database') 184 ,$e->getCode() == 0 ? 185 sprintf(__('<p>This either means that the username and password information in '. 186 'your <strong>config.php</strong> file is incorrect or we can\'t contact '. 187 'the database server at "<em>%s</em>". This could mean your '. 188 'host\'s database server is down.</p> '. 189 '<ul><li>Are you sure you have the correct username and password?</li>'. 190 '<li>Are you sure that you have typed the correct hostname?</li>'. 191 '<li>Are you sure that the database server is running?</li></ul>'. 192 '<p>If you\'re unsure what these terms mean you should probably contact '. 193 'your host. If you still need help you can always visit the '. 194 '<a href="http://forum.dotclear.net/">Dotclear Support Forums</a>.</p>'). 195 (DC_DEBUG ? 196 __('The following error was encountered while trying to read the database:').'</p><ul><li>'.$e->getMessage().'</li></ul>' : '') 197 ,(DC_DBHOST != '' ? DC_DBHOST : 'localhost') 198 ) 199 : '' 200 ,20); 183 if (!defined('DC_CONTEXT_ADMIN')) { 184 __error(__('Site temporarily unavailable'), 185 __('<p>We apologize for this temporary unavailability.<br />'. 186 'Thank you for your understanding.</p>'), 187 20); 188 } else { 189 __error(__('Unable to connect to database') 190 ,$e->getCode() == 0 ? 191 sprintf(__('<p>This either means that the username and password information in '. 192 'your <strong>config.php</strong> file is incorrect or we can\'t contact '. 193 'the database server at "<em>%s</em>". This could mean your '. 194 'host\'s database server is down.</p> '. 195 '<ul><li>Are you sure you have the correct username and password?</li>'. 196 '<li>Are you sure that you have typed the correct hostname?</li>'. 197 '<li>Are you sure that the database server is running?</li></ul>'. 198 '<p>If you\'re unsure what these terms mean you should probably contact '. 199 'your host. If you still need help you can always visit the '. 200 '<a href="http://forum.dotclear.net/">Dotclear Support Forums</a>.</p>'). 201 (DC_DEBUG ? 202 __('The following error was encountered while trying to read the database:').'</p><ul><li>'.$e->getMessage().'</li></ul>' : '') 203 ,(DC_DBHOST != '' ? DC_DBHOST : 'localhost') 204 ) 205 : '' 206 ,20); 207 } 201 208 } 202 209
Note: See TracChangeset
for help on using the changeset viewer.