Changeset 1413:0581a433675d
- Timestamp:
- 08/12/13 13:34:09 (10 years ago)
- Branch:
- twig
- Parents:
- 1319:32528cac0405 (diff), 1333:5e1388edd0c9 (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:
-
- 8 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
admin/index.php
r1329 r1413 4 4 # This file is part of Dotclear 2. 5 5 # 6 # Copyright (c) 2003-201 3Olivier Meunier & Association Dotclear6 # Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear 7 7 # Licensed under the GPL version 2.0 license. 8 8 # See LICENSE file or … … 13 13 if (!empty($_GET['pf'])) { 14 14 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'; 15 20 exit; 16 21 } … … 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[$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; 64 188 } 65 189 … … 118 242 } 119 243 120 # Latest news for dashboard 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 121 256 $__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 257 $core->callBehavior('adminDashboardItems', $core, $__dashboard_items); 183 258 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 184 270 # Dashboard content 185 $dashboardContents = '';186 271 $__dashboard_contents = new ArrayObject(array(new ArrayObject,new ArrayObject)); 187 272 $core->callBehavior('adminDashboardContents', $core, $__dashboard_contents); 188 273 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 dcPage::breadcrumb( 199 array( 200 '<span class="page-title">'.__('Dashboard').' : '.html::escapeHTML($core->blog->name).'</span>' => '' 201 ), 202 true); 203 204 if ($core->auth->getInfo('user_default_blog') != $core->blog->id && $core->auth->blog_count > 1) { 205 echo 206 '<p><a href="index.php?default_blog=1" class="button">'.__('Make this blog my default blog').'</a></p>'; 207 } 208 274 # Send dashboard contents to templates 275 $contents = array(); 276 foreach ($__dashboard_contents as $i) { 277 if ($i->count() > 0) { 278 foreach ($i as $v) { 279 $contents[] = $v; 280 } 281 } 282 } 283 $_ctx->dashboard_contents = $contents; 284 285 # Blog status message 209 286 if ($core->blog->status == 0) { 210 echo '<p class="static-msg">'.__('This blog is offline').'</p>';287 $_ctx->addMessageStatic(__('This blog is offline')); 211 288 } elseif ($core->blog->status == -1) { 212 echo '<p class="static-msg">'.__('This blog is removed').'</p>'; 213 } 214 289 $_ctx->addMessageStatic(__('This blog is removed')); 290 } 291 292 # Config errors messages 215 293 if (!defined('DC_ADMIN_URL') || !DC_ADMIN_URL) { 216 echo 217 '<p class="static-msg">'. 218 sprintf(__('%s is not defined, you should edit your configuration file.'),'DC_ADMIN_URL'). 219 ' '.__('See <a href="http://dotclear.org/documentation/2.0/admin/config">documentation</a> for more information.'). 220 '</p>'; 221 } 222 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 } 223 299 if (!defined('DC_ADMIN_MAILFROM') || !DC_ADMIN_MAILFROM) { 224 echo 225 '<p class="static-msg">'. 226 sprintf(__('%s is not defined, you should edit your configuration file.'),'DC_ADMIN_MAILFROM'). 227 ' '.__('See <a href="http://dotclear.org/documentation/2.0/admin/config">documentation</a> for more information.'). 228 '</p>'; 229 } 230 231 # Plugins install messages 232 if (!empty($plugins_install['success'])) 233 { 234 echo '<div class="static-msg">'.__('Following plugins have been installed:').'<ul>'; 235 foreach ($plugins_install['success'] as $k => $v) { 236 echo '<li>'.$k.'</li>'; 237 } 238 echo '</ul></div>'; 239 } 240 if (!empty($plugins_install['failure'])) 241 { 242 echo '<div class="error">'.__('Following plugins have not been installed:').'<ul>'; 243 foreach ($plugins_install['failure'] as $k => $v) { 244 echo '<li>'.$k.' ('.$v.')</li>'; 245 } 246 echo '</ul></div>'; 247 } 248 249 # Dashboard columns (processed first, as we need to know the result before displaying the icons.) 250 $dashboardItems = ''; 251 252 # Dotclear updates notifications 253 if ($core->auth->isSuperAdmin() && is_readable(DC_DIGESTS)) 254 { 255 $updater = new dcUpdate(DC_UPDATE_URL,'dotclear',DC_UPDATE_VERSION,DC_TPL_CACHE.'/versions'); 256 $new_v = $updater->check(DC_VERSION); 257 $version_info = $new_v ? $updater->getInfoURL() : ''; 258 259 if ($updater->getNotify() && $new_v) { 260 $dashboardItems .= 261 '<div id="upg-notify" class="static-msg"><p>'.sprintf(__('Dotclear %s is available!'),$new_v).'</p> '. 262 '<ul><li><strong><a href="update.php">'.sprintf(__('Upgrade now'),$new_v).'</a></strong>'. 263 '</li><li><a href="update.php?hide_msg=1">'.__('Remind me later').'</a>'. 264 ($version_info ? ' </li><li><a href="'.$version_info.'">'.__('information about this version').'</a>' : ''). 265 '</li></ul></div>'; 266 } 267 } 268 269 # Errors modules notifications 270 if ($core->auth->isSuperAdmin()) 271 { 272 $list = array(); 273 foreach ($core->plugins->getErrors() as $k => $error) { 274 $list[] = '<li>'.$error.'</li>'; 275 } 276 277 if (count($list) > 0) { 278 $dashboardItems .= 279 '<div id="module-errors" class="error"><p>'.__('Some plugins are installed twice:').'</p> '. 280 '<ul>'.implode("\n",$list).'</ul></div>'; 281 } 282 283 } 284 285 foreach ($__dashboard_items as $i) 286 { 287 if ($i->count() > 0) 288 { 289 $dashboardItems .= '<div>'; 290 foreach ($i as $v) { 291 $dashboardItems .= $v; 292 } 293 $dashboardItems .= '</div>'; 294 } 295 } 296 297 # Dashboard icons 298 echo '<div id="dashboard-main"'.($dashboardItems ? '' : ' class="fullwidth"').'><div id="icons">'; 299 foreach ($__dashboard_icons as $i) 300 { 301 echo 302 '<p><a href="'.$i[1].'"><img src="'.dc_admin_icon_url($i[2]).'" alt="" />'. 303 '<br /><span>'.$i[0].'</span></a></p>'; 304 } 305 echo '</div>'; 306 307 if ($core->auth->user_prefs->dashboard->quickentry) { 308 if ($core->auth->check('usage,contentadmin',$core->blog->id)) 309 { 310 $categories_combo = array(' ' => ''); 311 try { 312 $categories = $core->blog->getCategories(array('post_type'=>'post')); 313 while ($categories->fetch()) { 314 $categories_combo[] = new formSelectOption( 315 str_repeat(' ',$categories->level-1). 316 ($categories->level-1 == 0 ? '' : '• ').html::escapeHTML($categories->cat_title), 317 $categories->cat_id 318 ); 319 } 320 } catch (Exception $e) { } 321 322 echo 323 '<div id="quick">'. 324 '<h3>'.__('Quick entry').'</h3>'. 325 '<form id="quick-entry" action="post.php" method="post">'. 326 '<fieldset><legend>'.__('New entry').'</legend>'. 327 '<p class="col"><label for="post_title" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Title:'). 328 form::field('post_title',20,255,'','maximal'). 329 '</label></p>'. 330 '<p class="area"><label class="required" '. 331 'for="post_content"><abbr title="'.__('Required field').'">*</abbr> '.__('Content:').'</label> '. 332 form::textarea('post_content',50,7). 333 '</p>'. 334 '<p><label for="cat_id" class="classic">'.__('Category:').' '. 335 form::combo('cat_id',$categories_combo).'</label></p>'. 336 '<p><input type="submit" value="'.__('Save').'" name="save" /> '. 337 ($core->auth->check('publish',$core->blog->id) 338 ? '<input type="hidden" value="'.__('Save and publish').'" name="save-publish" />' 339 : ''). 340 $core->formNonce(). 341 form::hidden('post_status',-2). 342 form::hidden('post_format',$core->auth->getOption('post_format')). 343 form::hidden('post_excerpt',''). 344 form::hidden('post_lang',$core->auth->getInfo('user_lang')). 345 form::hidden('post_notes',''). 346 '</p>'. 347 '</fieldset>'. 348 '</form>'. 349 '</div>'; 350 } 351 } 352 353 foreach ($__dashboard_contents as $i) 354 { 355 if ($i->count() > 0) 356 { 357 $dashboardContents .= '<div>'; 358 foreach ($i as $v) { 359 $dashboardContents .= $v; 360 } 361 $dashboardContents .= '</div>'; 362 } 363 } 364 echo ($dashboardContents ? '<div id="dashboard-contents">'.$dashboardContents.'</div>' : ''); 365 366 echo '</div>'; 367 368 echo ($dashboardItems ? '<div id="dashboard-items">'.$dashboardItems.'</div>' : ''); 369 370 dcPage::close(); 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->fillPageTitle(__('Dashboard')); 307 $core->tpl->display('index.html.twig'); 371 308 ?> -
admin/plugin.php
r1332 r1413 4 4 # This file is part of Dotclear 2. 5 5 # 6 # Copyright (c) 2003-201 3Olivier Meunier & Association Dotclear6 # Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear 7 7 # Licensed under the GPL version 2.0 license. 8 8 # See LICENSE file or … … 15 15 dcPage::check('usage,contentadmin'); 16 16 17 $has_content = false; 17 18 $p_file = ''; 18 19 $p = !empty($_REQUEST['p']) ? $_REQUEST['p'] : null; 19 $popup = (integer) !empty($_REQUEST['popup']); 20 21 if ($popup) { 22 $open_f = array('dcPage','openPopup'); 23 $close_f = array('dcPage','closePopup'); 24 } else { 25 $open_f = array('dcPage','open'); 26 $close_f = array('dcPage','close'); 27 } 20 $popup = $_ctx->popup = (integer) !empty($_REQUEST['popup']); 28 21 29 22 if ($core->plugins->moduleExists($p)) { 30 23 $p_file = $core->plugins->moduleRoot($p).'/index.php'; 31 24 } 25 if (file_exists($p_file)) { 32 26 33 if (file_exists($p_file)) 34 { 35 # Loading plugin 27 //* Keep this for old style plugins using dcPage 28 if ($popup) { 29 $open_f = array('dcPage','openPopup'); 30 $close_f = array('dcPage','closePopup'); 31 } else { 32 $open_f = array('dcPage','open'); 33 $close_f = array('dcPage','close'); 34 } 35 36 36 $p_info = $core->plugins->getModules($p); 37 38 37 $p_url = 'plugin.php?p='.$p; 39 40 $p_title = 'no content - plugin'; 41 $p_head = ''; 42 $p_content = '<p>'.__('No content found on this plugin.').'</p>'; 43 38 $p_title = $p_head = $p_content = ''; 39 //*/ 40 # Get page content 44 41 ob_start(); 45 42 include $p_file; 46 43 $res = ob_get_contents(); 47 44 ob_end_clean(); 48 49 if (preg_match('|<head>(.*?)</head|ms',$res,$m)) { 50 if (preg_match('|<title>(.*?)</title>|ms',$m[1],$mt)) { 51 $p_title = $mt[1]; 52 } 45 46 # Check context and display 47 if ($_ctx->hasPageTitle() && !empty($res)) { 48 $has_content = true; 49 echo $res; 50 } 51 //* Keep this for old style plugins using dcPage 52 elseif (!$_ctx->hasPageTitle()) { 53 53 54 if (preg_match_all('|(<script.*?>.*?</script>)|ms',$m[1],$ms)) { 55 foreach ($ms[1] as $v) { 56 $p_head .= $v."\n"; 54 if (preg_match('|<head>(.*?)</head|ms',$res,$m)) { 55 if (preg_match('|<title>(.*?)</title>|ms',$m[1],$mt)) { 56 $p_title = $mt[1]; 57 } 58 59 if (preg_match_all('|(<script.*?>.*?</script>)|ms',$m[1],$ms)) { 60 foreach ($ms[1] as $v) { 61 $p_head .= $v."\n"; 62 } 63 } 64 65 if (preg_match_all('|(<style.*?>.*?</style>)|ms',$m[1],$ms)) { 66 foreach ($ms[1] as $v) { 67 $p_head .= $v."\n"; 68 } 69 } 70 71 if (preg_match_all('|(<link.*?/>)|ms',$m[1],$ms)) { 72 foreach ($ms[1] as $v) { 73 $p_head .= $v."\n"; 74 } 57 75 } 58 76 } 59 77 60 if (preg_match_all('|(<style.*?>.*?</style>)|ms',$m[1],$ms)) { 61 foreach ($ms[1] as $v) { 62 $p_head .= $v."\n"; 63 } 64 } 65 66 if (preg_match_all('|(<link.*?/>)|ms',$m[1],$ms)) { 67 foreach ($ms[1] as $v) { 68 $p_head .= $v."\n"; 69 } 78 if (preg_match('|<body.*?>(.+)</body>|ms',$res,$m)) { 79 $p_content = $m[1]; 80 81 call_user_func($open_f,$p_title,$p_head); 82 echo $p_content; 83 call_user_func($close_f); 84 85 $has_content = true; 70 86 } 71 87 } 72 73 if (preg_match('|<body.*?>(.+)</body>|ms',$res,$m)) { 74 $p_content = $m[1]; 75 } 76 77 call_user_func($open_f,$p_title,$p_head); 78 echo $p_content; 79 call_user_func($close_f); 88 //*/ 80 89 } 81 else 82 { 83 call_user_func($open_f,__('Plugin not found')); 84 85 echo dcPage::breadcrumb( 86 array( 87 __('System') => '', 88 '<span class="page-title">'.__('Plugin not found').'</span>' => '' 89 )); 90 91 echo '<p>'.__('The plugin you reached does not exist or does not have an admin page.').'</p>'; 92 93 call_user_func($close_f); 90 # No plugin or content found 91 if (!$has_content) { 92 $_ctx->fillPageTitle(__('Plugin not found')); 93 $_ctx->addError(__('The plugin you reached does not exist or does not have an admin page.')); 94 $core->tpl->display('plugin.html.twig'); 94 95 } 95 96 ?> -
admin/post.php
r1333 r1413 4 4 # This file is part of Dotclear 2. 5 5 # 6 # Copyright (c) 2003-201 3Olivier Meunier & Association Dotclear6 # Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear 7 7 # Licensed under the GPL version 2.0 license. 8 8 # See LICENSE file or … … 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->setAlert('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 dcFieldText('post_password','',array( 133 "maxlength" => 32, 134 "label" => __('Entry password:')))) 135 ->addField( 136 new dcFieldText('post_url','',array( 137 "maxlength" => 255, 138 "label" => __('Basename:')))) 139 ->addField( 140 new dcFieldHidden ('id','')) 141 ; 93 142 # Get entry informations 94 143 if (!empty($_REQUEST['id'])) … … 105 154 else 106 155 { 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; 156 $form->id = $post_id = $post->post_id; 157 $form->cat_id = $post->cat_id; 158 $form->post_dt = date('Y-m-d H:i',strtotime($post->post_dt)); 159 $form->post_format = $post->post_format; 160 $form->post_password = $post->post_password; 161 $form->post_url = $post->post_url; 162 $form->post_lang = $post->post_lang; 163 $form->post_title = $post->post_title; 164 $form->post_excerpt = $post->post_excerpt; 165 $form->post_excerpt_xhtml = $post->post_excerpt_xhtml; 166 $form->post_content = $post->post_content; 167 $form->post_content_xhtml = $post->post_content_xhtml; 168 $form->post_notes = $post->post_notes; 169 $form->post_status = $post->post_status; 170 $form->post_selected = (boolean) $post->post_selected; 171 $form->post_open_comment = (boolean) $post->post_open_comment; 172 $form->post_open_tb = (boolean) $post->post_open_tb; 173 $form->can_edit_post = $post->isEditable(); 174 $form->can_delete= $post->isDeletable(); 175 $page_title = __('Edit entry'); 176 177 } 178 } 179 if ($post_id) { 180 $_ctx->post_id = $post->post_id; 181 182 $_ctx->preview_url = 183 $core->blog->url.$core->url->getURLFor('preview',$core->auth->userID().'/'. 184 http::browserUID(DC_MASTER_KEY.$core->auth->userID().$core->auth->getInfo('user_pwd')). 185 '/'.$post->post_url); 124 186 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 } 187 188 $form_comment = new dcForm($core,'add-comment','post.php'); 189 $form_comment 190 ->addField( 191 new dcFieldText('comment_author','', array( 192 'maxlength' => 255, 193 'required' => true, 194 'label' => __('Name:')))) 195 ->addField( 196 new dcFieldText('comment_email','', array( 197 'maxlength' => 255, 198 'required' => true, 199 'label' => __('Email:')))) 200 ->addField( 201 new dcFieldText('comment_site','', array( 202 'maxlength' => 255, 203 'label' => __('Web site:')))) 204 ->addField( 205 new dcFieldTextArea('comment_content','', array( 206 'required' => true, 207 'label' => __('Comment:')))) 208 ->addField( 209 new dcFieldSubmit('add',__('Save'),array( 210 'action' => 'addComment'))) 211 ; 212 213 214 } 215 216 $form->setup(); 285 217 286 218 /* DISPLAY … … 294 226 } 295 227 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 if ($post_id) { 337 switch ($post_status) { 338 case 1: 339 $img_status = sprintf($img_status_pattern,__('published'),'check-on.png'); 340 break; 341 case 0: 342 $img_status = sprintf($img_status_pattern,__('unpublished'),'check-off.png'); 343 break; 344 case -1: 345 $img_status = sprintf($img_status_pattern,__('scheduled'),'scheduled.png'); 346 break; 347 case -2: 348 $img_status = sprintf($img_status_pattern,__('pending'),'check-wrn.png'); 349 break; 350 default: 351 $img_status = ''; 352 } 353 $edit_entry_str = __('Edit entry “%s”'); 354 $page_title_edit = sprintf($edit_entry_str, html::escapeHTML($post_title)).' '.$img_status; 355 } 356 echo dcPage::breadcrumb( 357 array( 358 html::escapeHTML($core->blog->name) => '', 359 __('Entries') => 'posts.php', 360 '<span class="page-title">'.($post_id ? $page_title_edit : $page_title).'</span>' => '' 361 )); 362 363 if ($post_id && $post->post_status == 1) { 364 echo '<p class="preview_entry"><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>'; 365 } 366 if ($post_id) 367 { 368 echo '<p class="nav_prevnext">'; 369 if ($prev_link) { echo $prev_link; } 370 if ($next_link && $prev_link) { echo ' - '; } 371 if ($next_link) { echo $next_link; } 372 373 # --BEHAVIOR-- adminPostNavLinks 374 $core->callBehavior('adminPostNavLinks',isset($post) ? $post : null); 375 376 echo '</p>'; 377 } 378 379 # Exit if we cannot view page 380 if (!$can_view_page) { 381 dcPage::helpBlock('core_post'); 382 dcPage::close(); 383 exit; 384 } 385 386 /* Post form if we can edit post 387 -------------------------------------------------------- */ 388 if ($can_edit_post) 389 { 390 echo '<div class="multi-part" title="'.($post_id ? __('Edit entry') : __('New entry')).'" id="edit-entry">'; 391 echo '<form action="post.php" method="post" id="entry-form">'; 392 echo '<div id="entry-wrapper">'; 393 echo '<div id="entry-content"><div class="constrained">'; 394 395 echo 396 '<p class="col"><label class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Title:').'</label>'. 397 form::field('post_title',20,255,html::escapeHTML($post_title),'maximal'). 398 '</p>'. 399 400 '<p class="area" id="excerpt-area"><label for="post_excerpt">'.__('Excerpt:').'</label> '. 401 form::textarea('post_excerpt',50,5,html::escapeHTML($post_excerpt)). 402 '</p>'. 403 404 '<p class="area"><label class="required" '. 405 'for="post_content"><abbr title="'.__('Required field').'">*</abbr> '.__('Content:').'</label> '. 406 form::textarea('post_content',50,$core->auth->getOption('edit_size'),html::escapeHTML($post_content)). 407 '</p>'. 408 409 '<p class="area" id="notes-area"><label for="post_notes">'.__('Personal notes:').'</label>'. 410 form::textarea('post_notes',50,5,html::escapeHTML($post_notes)). 411 '</p>'; 412 413 # --BEHAVIOR-- adminPostForm 414 $core->callBehavior('adminPostForm',isset($post) ? $post : null); 415 416 echo 417 '<p>'. 418 ($post_id ? form::hidden('id',$post_id) : ''). 419 '<input type="submit" value="'.__('Save').' (s)" '. 420 'accesskey="s" name="save" /> '; 421 if ($post_id) { 422 $preview_url = 423 $core->blog->url.$core->url->getURLFor('preview',$core->auth->userID().'/'. 424 http::browserUID(DC_MASTER_KEY.$core->auth->userID().$core->auth->getInfo('user_pwd')). 425 '/'.$post->post_url); 426 echo '<a id="post-preview" href="'.$preview_url.'" class="button" accesskey="p">'.__('Preview').' (p)'.'</a> '; 427 } else { 428 echo 429 '<a id="post-cancel" href="index.php" class="button" accesskey="c">'.__('Cancel').' (c)</a>'; 430 } 431 432 echo 433 ($can_delete ? '<input type="submit" class="delete" value="'.__('Delete').'" name="delete" />' : ''). 434 $core->formNonce(). 435 '</p>'; 436 437 echo '</div></div>'; // End #entry-content 438 echo '</div>'; // End #entry-wrapper 439 440 echo '<div id="entry-sidebar">'; 441 442 echo 443 '<p><label for="cat_id">'.__('Category:'). 444 form::combo('cat_id',$categories_combo,$cat_id,'maximal'). 445 '</label></p>'. 446 447 '<p><label for="post_status">'.__('Entry status:'). 448 form::combo('post_status',$status_combo,$post_status,'','',!$can_publish). 449 '</label></p>'. 450 451 '<p><label for="post_dt">'.__('Published on:'). 452 form::field('post_dt',16,16,$post_dt,($bad_dt ? 'invalid' : '')). 453 '</label></p>'. 454 455 '<p><label for="post_format">'.__('Text formating:'). 456 form::combo('post_format',$formaters_combo,$post_format). 457 '</label>'. 458 '</p>'. 459 '<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>'. 460 461 '<p><label for="post_open_comment" class="classic">'.form::checkbox('post_open_comment',1,$post_open_comment).' '. 462 __('Accept comments').'</label></p>'. 463 ($core->blog->settings->system->allow_comments ? 464 (isContributionAllowed($post_id,strtotime($post_dt),true) ? 465 '' : 466 '<p class="form-note warn">'.__('Warning: Comments are not more accepted for this entry.').'</p>') : 467 '<p class="form-note warn">'.__('Warning: Comments are not accepted on this blog.').'</p>'). 468 469 '<p><label for="post_open_tb" class="classic">'.form::checkbox('post_open_tb',1,$post_open_tb).' '. 470 __('Accept trackbacks').'</label></p>'. 471 ($core->blog->settings->system->allow_trackbacks ? 472 (isContributionAllowed($post_id,strtotime($post_dt),false) ? 473 '' : 474 '<p class="form-note warn">'.__('Warning: Trackbacks are not more accepted for this entry.').'</p>') : 475 '<p class="form-note warn">'.__('Warning: Trackbacks are not accepted on this blog.').'</p>'). 476 477 '<p><label for="post_selected" class="classic">'.form::checkbox('post_selected',1,$post_selected).' '. 478 __('Selected entry').'</label></p>'. 479 480 '<p><label for="post_lang">'.__('Entry lang:'). 481 form::combo('post_lang',$lang_combo,$post_lang). 482 '</label></p>'. 483 484 '<p><label for="post_password">'.__('Entry password:'). 485 form::field('post_password',10,32,html::escapeHTML($post_password),'maximal'). 486 '</label></p>'. 487 488 '<div class="lockable">'. 489 '<p><label for="post_url">'.__('Basename:'). 490 form::field('post_url',10,255,html::escapeHTML($post_url),'maximal'). 491 '</label></p>'. 492 '<p class="form-note warn">'. 493 __('Warning: If you set the URL manually, it may conflict with another entry.'). 494 '</p>'. 495 '</div>'; 496 497 # --BEHAVIOR-- adminPostFormSidebar 498 $core->callBehavior('adminPostFormSidebar',isset($post) ? $post : null); 499 500 echo '</div>'; // End #entry-sidebar 501 502 echo '</form>'; 503 504 # --BEHAVIOR-- adminPostForm 505 $core->callBehavior('adminPostAfterForm',isset($post) ? $post : null); 506 507 echo '</div>'; 508 509 if ($post_id && $post->post_status == 1) { 510 echo '<p><a href="trackbacks.php?id='.$post_id.'" class="multi-part">'. 511 __('Ping blogs').'</a></p>'; 512 } 513 514 } 515 516 517 /* Comments and trackbacks 518 -------------------------------------------------------- */ 519 if ($post_id) 520 { 521 $params = array('post_id' => $post_id, 'order' => 'comment_dt ASC'); 522 523 $comments = $core->blog->getComments(array_merge($params,array('comment_trackback'=>0))); 524 $trackbacks = $core->blog->getComments(array_merge($params,array('comment_trackback'=>1))); 525 526 # Actions combo box 527 $combo_action = array(); 528 if ($can_edit_post && $core->auth->check('publish,contentadmin',$core->blog->id)) 529 { 530 $combo_action[__('publish')] = 'publish'; 531 $combo_action[__('unpublish')] = 'unpublish'; 532 $combo_action[__('mark as pending')] = 'pending'; 533 $combo_action[__('mark as junk')] = 'junk'; 534 } 535 536 if ($can_edit_post && $core->auth->check('delete,contentadmin',$core->blog->id)) 537 { 538 $combo_action[__('Delete')] = 'delete'; 539 } 540 541 # --BEHAVIOR-- adminCommentsActionsCombo 542 $core->callBehavior('adminCommentsActionsCombo',array(&$combo_action)); 543 544 $has_action = !empty($combo_action) && (!$trackbacks->isEmpty() || !$comments->isEmpty()); 545 546 echo 547 '<div id="comments" class="multi-part" title="'.__('Comments').'">'; 548 549 if ($has_action) { 550 echo '<form action="comments_actions.php" id="form-comments" method="post">'; 551 } 552 553 echo '<h3>'.__('Trackbacks').'</h3>'; 554 555 if (!$trackbacks->isEmpty()) { 556 showComments($trackbacks,$has_action,true); 557 } else { 558 echo '<p>'.__('No trackback').'</p>'; 559 } 560 561 echo '<h3>'.__('Comments').'</h3>'; 562 if (!$comments->isEmpty()) { 563 showComments($comments,$has_action); 564 } else { 565 echo '<p>'.__('No comment').'</p>'; 566 } 567 568 if ($has_action) { 569 echo 570 '<div class="two-cols">'. 571 '<p class="col checkboxes-helpers"></p>'. 572 573 '<p class="col right"><label for="action" class="classic">'.__('Selected comments action:').'</label> '. 574 form::combo('action',$combo_action). 575 form::hidden('redir','post.php?id='.$post_id.'&co=1'). 576 $core->formNonce(). 577 '<input type="submit" value="'.__('ok').'" /></p>'. 578 '</div>'. 579 '</form>'; 580 } 581 582 echo '</div>'; 583 } 584 585 /* Add a comment 586 -------------------------------------------------------- */ 587 if ($post_id) 588 { 589 echo 590 '<div class="multi-part" id="add-comment" title="'.__('Add a comment').'">'. 591 '<h3>'.__('Add a comment').'</h3>'. 592 593 '<form action="comment.php" method="post" id="comment-form">'. 594 '<div class="constrained">'. 595 '<p><label for="comment_author" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Name:'). 596 form::field('comment_author',30,255,html::escapeHTML($core->auth->getInfo('user_cn'))). 597 '</label></p>'. 598 599 '<p><label for="comment_email">'.__('Email:'). 600 form::field('comment_email',30,255,html::escapeHTML($core->auth->getInfo('user_email'))). 601 '</label></p>'. 602 603 '<p><label for="comment_site">'.__('Web site:'). 604 form::field('comment_site',30,255,html::escapeHTML($core->auth->getInfo('user_url'))). 605 '</label></p>'. 606 607 '<p class="area"><label for="comment_content" class="required"><abbr title="'.__('Required field').'">*</abbr> '. 608 __('Comment:').'</label> '. 609 form::textarea('comment_content',50,8,html::escapeHTML('')). 610 '</p>'. 611 612 '<p>'.form::hidden('post_id',$post_id). 613 $core->formNonce(). 614 '<input type="submit" name="add" value="'.__('Save').'" /></p>'. 615 '</div>'. 616 '</form>'. 617 '</div>'; 618 } 619 620 # Controls comments or trakbacks capabilities 621 function isContributionAllowed($id,$dt,$com=true) 622 { 623 global $core; 624 625 if (!$id) { 626 return true; 627 } 628 if ($com) { 629 if (($core->blog->settings->system->comments_ttl == 0) || 630 (time() - $core->blog->settings->system->comments_ttl*86400 < $dt)) { 631 return true; 632 } 633 } else { 634 if (($core->blog->settings->system->trackbacks_ttl == 0) || 635 (time() - $core->blog->settings->system->trackbacks_ttl*86400 < $dt)) { 636 return true; 637 } 638 } 639 return false; 640 } 641 642 # Show comments or trackbacks 643 function showComments($rs,$has_action,$tb=false) 644 { 645 echo 646 '<table class="comments-list"><tr>'. 647 '<th colspan="2">'.__('Author').'</th>'. 648 '<th>'.__('Date').'</th>'. 649 '<th class="nowrap">'.__('IP address').'</th>'. 650 '<th>'.__('Status').'</th>'. 651 '<th> </th>'. 652 '</tr>'; 653 654 while($rs->fetch()) 655 { 656 $comment_url = 'comment.php?id='.$rs->comment_id; 657 658 $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; 659 switch ($rs->comment_status) { 660 case 1: 661 $img_status = sprintf($img,__('published'),'check-on.png'); 662 break; 663 case 0: 664 $img_status = sprintf($img,__('unpublished'),'check-off.png'); 665 break; 666 case -1: 667 $img_status = sprintf($img,__('pending'),'check-wrn.png'); 668 break; 669 case -2: 670 $img_status = sprintf($img,__('junk'),'junk.png'); 671 break; 672 } 673 674 echo 675 '<tr class="line'.($rs->comment_status != 1 ? ' offline' : '').'"'. 676 ' id="c'.$rs->comment_id.'">'. 677 678 '<td class="nowrap">'. 679 ($has_action ? form::checkbox(array('comments[]'),$rs->comment_id,'','','',0,'title="'.($tb ? __('select this trackback') : __('select this comment')).'"') : '').'</td>'. 680 '<td class="maximal">'.html::escapeHTML($rs->comment_author).'</td>'. 681 '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$rs->comment_dt).'</td>'. 682 '<td class="nowrap"><a href="comments.php?ip='.$rs->comment_ip.'">'.$rs->comment_ip.'</a></td>'. 683 '<td class="nowrap status">'.$img_status.'</td>'. 684 '<td class="nowrap status"><a href="'.$comment_url.'">'. 685 '<img src="images/edit-mini.png" alt="" title="'.__('Edit this comment').'" /></a></td>'. 686 687 '</tr>'; 688 } 689 690 echo '</table>'; 691 } 692 693 dcPage::helpBlock('core_post','core_wiki'); 694 dcPage::close(); 228 $_ctx 229 ->fillPageTitle(html::escapeHTML($core->blog->name)) 230 ->fillPageTitle(__('Entries'),'posts.php') 231 ->fillPageTitle($page_title) 232 ->default_tab = $default_tab; 233 234 $core->tpl->display('post.html.twig'); 695 235 ?> -
admin/posts.php
r1328 r1413 4 4 # This file is part of Dotclear 2. 5 5 # 6 # Copyright (c) 2003-201 3Olivier Meunier & Association Dotclear6 # Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear 7 7 # Licensed under the GPL version 2.0 license. 8 8 # See LICENSE file or … … 12 12 13 13 require dirname(__FILE__).'/../inc/admin/prepend.php'; 14 14 global $_ctx; 15 15 dcPage::check('usage,contentadmin'); 16 16 … … 48 48 # Filter form we'll put in html_block 49 49 $users_combo = $categories_combo = array(); 50 $users_combo['-'] = $categories_combo['-'] = '';51 50 while ($users->fetch()) 52 51 { … … 61 60 } 62 61 63 $categories_combo[__('None')] = 'NULL'; 62 63 # Getting categories 64 $categories_combo = array(); 65 try { 66 $categories = $core->blog->getCategories(array('post_type'=>'post')); 64 67 while ($categories->fetch()) { 65 $categories_combo[str_repeat(' ',$categories->level-1).($categories->level-1 == 0 ? '' : '• '). 66 html::escapeHTML($categories->cat_title). 67 ' ('.$categories->nb_post.')'] = $categories->cat_id; 68 $categories_combo[$categories->cat_id] = 69 str_repeat(' ',$categories->level-1). 70 ($categories->level-1 == 0 ? '' : '• '). 71 html::escapeHTML($categories->cat_title); 68 72 } 69 73 } catch (Exception $e) { } 70 74 $status_combo = array( 71 '-' => ''72 75 ); 73 76 foreach ($core->blog->getAllPostStatus() as $k => $v) { 74 $status_combo[ $v] = (string) $k;77 $status_combo[(string) $k] = (string)$v; 75 78 } 76 79 77 80 $selected_combo = array( 78 '-' => '', 79 __('selected') => '1', 80 __('not selected') => '0' 81 '1' => __('is selected'), 82 '0' => __('is not selected') 81 83 ); 82 84 83 85 # Months array 84 $dt_m_combo['-'] = '';85 86 while ($dates->fetch()) { 86 $dt_m_combo[ dt::str('%B %Y',$dates->ts())] = $dates->year().$dates->month();87 $dt_m_combo[$dates->year().$dates->month()] = dt::str('%B %Y',$dates->ts()); 87 88 } 88 89 89 $lang_combo['-'] = '';90 90 while ($langs->fetch()) { 91 91 $lang_combo[$langs->post_lang] = $langs->post_lang; 92 92 } 93 94 $sortby_combo = array(95 __('Date') => 'post_dt',96 __('Title') => 'post_title',97 __('Category') => 'cat_title',98 __('Author') => 'user_id',99 __('Status') => 'post_status',100 __('Selected') => 'post_selected'101 );102 103 $order_combo = array(104 __('Descending') => 'desc',105 __('Ascending') => 'asc'106 );107 93 } 94 $form = new dcForm($core,'post','post.php'); 95 108 96 109 97 # Actions combo box … … 138 126 $core->callBehavior('adminPostsActionsCombo',array(&$combo_action)); 139 127 140 /* Get posts141 -------------------------------------------------------- */142 $user_id = !empty($_GET['user_id']) ? $_GET['user_id'] : '';143 $cat_id = !empty($_GET['cat_id']) ? $_GET['cat_id'] : '';144 $status = isset($_GET['status']) ? $_GET['status'] : '';145 $selected = isset($_GET['selected']) ? $_GET['selected'] : '';146 $month = !empty($_GET['month']) ? $_GET['month'] : '';147 $lang = !empty($_GET['lang']) ? $_GET['lang'] : '';148 $sortby = !empty($_GET['sortby']) ? $_GET['sortby'] : 'post_dt';149 $order = !empty($_GET['order']) ? $_GET['order'] : 'desc';150 128 151 $show_filters = false;152 129 153 $page = !empty($_GET['page']) ? (integer) $_GET['page'] : 1; 154 $nb_per_page = 30; 155 156 if (!empty($_GET['nb']) && (integer) $_GET['nb'] > 0) { 157 if ($nb_per_page != $_GET['nb']) { 158 $show_filters = true; 130 class monthdcFilterCombo extends dcFilterCombo { 131 public function applyFilter($params) { 132 $month=$this->avalues['values'][0]; 133 $params['post_month'] = substr($month,4,2); 134 $params['post_year'] = substr($month,0,4); 159 135 } 160 $nb_per_page = (integer) $_GET['nb'];161 136 } 162 137 163 $params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page); 164 $params['no_content'] = true; 138 class PostsFetcher extends dcListFetcher { 165 139 166 # - User filter 167 if ($user_id !== '' && in_array($user_id,$users_combo)) { 168 $params['user_id'] = $user_id; 169 $show_filters = true; 170 } else { 171 $user_id=''; 172 } 140 public function getEntries($params,$offset,$limit) { 141 $params['limit'] = array($offset,$limit); 142 return $this->core->blog->getPosts($params); 143 } 173 144 174 # - Categories filter 175 if ($cat_id !== '' && in_array($cat_id,$categories_combo)) { 176 $params['cat_id'] = $cat_id; 177 $show_filters = true; 178 } else { 179 $cat_id=''; 180 } 181 182 # - Status filter 183 if ($status !== '' && in_array($status,$status_combo)) { 184 $params['post_status'] = $status; 185 $show_filters = true; 186 } else { 187 $status=''; 188 } 189 190 # - Selected filter 191 if ($selected !== '' && in_array($selected,$selected_combo)) { 192 $params['post_selected'] = $selected; 193 $show_filters = true; 194 } else { 195 $selected=''; 196 } 197 198 # - Month filter 199 if ($month !== '' && in_array($month,$dt_m_combo)) { 200 $params['post_month'] = substr($month,4,2); 201 $params['post_year'] = substr($month,0,4); 202 $show_filters = true; 203 } else { 204 $month=''; 205 } 206 207 # - Lang filter 208 if ($lang !== '' && in_array($lang,$lang_combo)) { 209 $params['post_lang'] = $lang; 210 $show_filters = true; 211 } else { 212 $lang=''; 213 } 214 215 # - Sortby and order filter 216 if ($sortby !== '' && in_array($sortby,$sortby_combo)) { 217 if ($order !== '' && in_array($order,$order_combo)) { 218 $params['order'] = $sortby.' '.$order; 219 } else { 220 $order='desc'; 145 public function getEntriesCount($params) { 146 $count = $this->core->blog->getPosts($params,true); 147 return $count->f(0); 221 148 } 222 223 if ($sortby != 'post_dt' || $order != 'desc') {224 $show_filters = true;225 }226 } else {227 $sortby='post_dt';228 $order='desc';229 }230 231 # Get posts232 try {233 $posts = $core->blog->getPosts($params);234 $counter = $core->blog->getPosts($params,true);235 $post_list = new adminPostList($core,$posts,$counter->f(0));236 } catch (Exception $e) {237 $core->error->add($e->getMessage());238 149 } 239 150 240 151 /* DISPLAY 241 152 -------------------------------------------------------- */ 242 $starting_script = dcPage::jsLoad('js/_posts_list.js'); 243 if (!$show_filters) { 244 $starting_script .= dcPage::jsLoad('js/filter-controls.js'); 245 } 153 $filterSet = new dcFilterSet($core,'fposts','posts.php'); 246 154 247 dcPage::open(__('Entries'),$starting_script); 155 $filterSet 156 ->addFilter(new dcFilterRichCombo( 157 'users',__('Author'), __('Author'), 'user_id', $users_combo,array( 158 'multiple' => true))) 159 ->addFilter(new dcFilterRichCombo( 160 'category',__('Category'), __('Category'), 'cat_id', $categories_combo)) 161 ->addFilter(new dcFilterRichCombo( 162 'post_status',__('Status'), __('Status'), 'post_status', $status_combo)) 163 ->addFilter(new dcFilterRichCombo( 164 'lang',__('Lang'), __('Lang'), 'post_lang', $lang_combo)) 165 ->addFilter(new dcFilterCombo( 166 'selected',__('Selected'), __('The post : '),'post_selected', $selected_combo)) 167 ->addFilter(new monthdcFilterCombo( 168 'month',__('Month'),__('Month'), 'post_month', $dt_m_combo,array('singleval' => 1))) 169 ->addFilter(new dcFilterText( 170 'search',__('Contains'),__('The entry contains'), 'search',20,255)); 248 171 249 if (!$core->error->flag())250 {251 echo dcPage::breadcrumb(252 array(253 html::escapeHTML($core->blog->name) => '',254 '<span class="page-title">'.__('Entries').'</span>' => ''255 ));256 172 257 echo 258 '<p class="top-add"><a class="button add" href="post.php">'.__('New entry').'</a></p>'; 259 260 if (!$show_filters) { 261 echo '<p><a id="filter-control" class="form-control" href="#">'. 262 __('Filters').'</a></p>'; 263 } 264 265 echo 266 '<form action="posts.php" method="get" id="filters-form">'. 267 '<fieldset><legend>'.__('Filters').'</legend>'. 268 '<div class="three-cols">'. 269 '<div class="col">'. 270 '<label for="user_id">'.__('Author:'). 271 form::combo('user_id',$users_combo,$user_id).'</label> '. 272 '<label for="cat_id">'.__('Category:'). 273 form::combo('cat_id',$categories_combo,$cat_id).'</label> '. 274 '<label for="status">'.__('Status:'). 275 form::combo('status',$status_combo,$status).'</label> '. 276 '</div>'. 277 278 '<div class="col">'. 279 '<label for="selected">'.__('Selected:'). 280 form::combo('selected',$selected_combo,$selected).'</label> '. 281 '<label for="month">'.__('Month:'). 282 form::combo('month',$dt_m_combo,$month).'</label> '. 283 '<label for="lang">'.__('Lang:'). 284 form::combo('lang',$lang_combo,$lang).'</label> '. 285 '</div>'. 286 287 '<div class="col">'. 288 '<p><label for="sortby">'.__('Order by:'). 289 form::combo('sortby',$sortby_combo,$sortby).'</label> '. 290 '<label for="order">'.__('Sort:'). 291 form::combo('order',$order_combo,$order).'</label></p>'. 292 '<p><label for="nb" class="classic">'. form::field('nb',3,3,$nb_per_page).' '. 293 __('Entries per page').'</label></p> '. 294 '<p><input type="submit" value="'.__('Apply filters').'" /></p>'. 295 '</div>'. 296 '</div>'. 297 '<br class="clear" />'. //Opera sucks 298 '</fieldset>'. 299 '</form>'; 300 301 # Show posts 302 $post_list->display($page,$nb_per_page, 303 '<form action="posts_actions.php" method="post" id="form-entries">'. 304 305 '%s'. 306 307 '<div class="two-cols">'. 308 '<p class="col checkboxes-helpers"></p>'. 309 310 '<p class="col right"><label for="action" class="classic">'.__('Selected entries action:').'</label> '. 311 form::combo('action',$combo_action). 312 '<input type="submit" value="'.__('ok').'" /></p>'. 313 form::hidden(array('user_id'),$user_id). 314 form::hidden(array('cat_id'),$cat_id). 315 form::hidden(array('status'),$status). 316 form::hidden(array('selected'),$selected). 317 form::hidden(array('month'),$month). 318 form::hidden(array('lang'),$lang). 319 form::hidden(array('sortby'),$sortby). 320 form::hidden(array('order'),$order). 321 form::hidden(array('page'),$page). 322 form::hidden(array('nb'),$nb_per_page). 323 $core->formNonce(). 324 '</div>'. 325 '</form>' 326 ); 327 } 173 $lfetcher = new PostsFetcher($core); 174 $lposts = new dcItemList ($core,array('lposts','form-entries'),$filterSet,$lfetcher,'posts_actions.php'); 175 $lposts->addTemplate('posts_cols.html.twig'); 328 176 329 dcPage::helpBlock('core_posts'); 330 dcPage::close(); 177 $lposts 178 ->addColumn(new dcColumn('title',__('Title'),'post_title')) 179 ->addColumn(new dcColumn('cat',__('Category'),'cat_title')) 180 ->addColumn(new dcColumn('date',__('Date'),'post_date')) 181 ->addColumn(new dcColumn('datetime',__('Date and Time'),'post_dt')) 182 ->addColumn(new dcColumn('author',__('Author'),'user_id')) 183 ->addColumn(new dcColumn('status',__('Status'),'post_status')); 184 185 186 $lposts->setup(); 187 188 $_ctx 189 ->fillPageTitle(__('Entries'),'posts.php'); 190 191 192 $core->tpl->display('posts.html.twig'); 193 194 331 195 ?> -
admin/style/default.css
r1315 r1413 17 17 } 18 18 body { 19 font: 1.2rem/1.5 Helvetica,Arial,sans-serif;19 font: 1.2rem/1.5 Arial,Helvetica,sans-serif; 20 20 color: #333; 21 21 background: #fff; … … 56 56 padding: 0 1.8rem .6rem; 57 57 margin: 0 -1.8rem 1rem; 58 background: #fff url( dc_bg_title.png) repeat-x center bottom;58 background: #fff url(bg_h2.png) repeat-x center bottom; 59 59 } 60 60 h3 { … … 93 93 #header { 94 94 background: #575859; 95 height: 3em;96 95 position: relative; 97 96 border-bottom: 4px solid #A2CBE9; 97 width: 100%; 98 98 } 99 99 #prelude { … … 124 124 width: 14.5em; 125 125 float: left; 126 line-height: 3em;127 126 } 128 127 #top h1 { … … 131 130 height: 3.6rem; 132 131 text-indent: -1000px; 133 background: #575859 url(dc_logo.png) no-repeat 0 50%;134 132 } 135 133 #top h1 a { … … 137 135 top: 0; 138 136 left: 0; 139 width: 1 4.5em;137 width: 17.4rem; 140 138 height: 3.6rem; 141 139 border: none; 142 140 color: #fff; 143 141 } 142 #top h1 a:link { 143 background: transparent url(dc_logos/b-dotclear120.png) no-repeat 0 6px; 144 } 144 145 #top h1 a:hover, #top h1 a:focus { 145 background: transparent url(dc_logo _hover.png) no-repeat 0 50%;146 background: transparent url(dc_logos/b-dotclear120.png) no-repeat 0 -94px; 146 147 } 147 148 #info-boxes { 148 background: #575859;149 149 font-size: 1em; 150 150 line-height: 3em; … … 155 155 color: #fff; 156 156 display: inline-block; 157 background: #575859;158 157 } 159 158 #info-box2 { … … 163 162 float: right; 164 163 text-align: right; 165 background: #575859;166 164 } 167 165 #info-box1 p { … … 177 175 } 178 176 #info-boxes a { 179 background: #575859;180 177 font-weight: bold; 181 178 color: #fff; … … 209 206 margin-left: -14.5em; 210 207 margin-top: 0; 211 background: #fff url( dc_bg.png);208 background: #fff url(bg_menu.png); 212 209 } 213 210 #content { … … 335 332 #search-menu { 336 333 padding: .3rem .4rem 0; 334 font-size: 100% 337 335 } 338 336 #search-menu p { 339 337 display: inline-block; 338 border: 1px solid #999; 339 border-radius: .6em; 340 position: relative; 341 height: 2rem; 342 overflow: hidden; 340 343 } 341 344 #search-menu #q { … … 343 346 border-bottom-left-radius: .6em; 344 347 border-top-left-radius: .6em; 345 border-color: #999;346 348 background: transparent url(search.png) no-repeat 4px center; 347 349 text-indent: 18px; 348 350 height: 2rem; 349 351 padding: 0 2px; 352 border: none; 350 353 } 351 354 #search-menu input[type="submit"] { 352 padding: .1rem.3rem;355 padding: 0 0.3rem; 353 356 background: #dfdfdf; 354 357 border-color: #999; … … 356 359 border-bottom-right-radius: .6em; 357 360 border-top-right-radius: .6em; 361 border-top-left-radius: 0; 362 border-bottom-left-radius: 0; 358 363 text-shadow: none; 359 height: 2.2rem; 364 height: 2rem; 365 border: none; 366 border-left: 1px solid #aaa; 360 367 font-size: 1rem; 361 margin-left: -.5em;362 368 } 363 369 #search-menu input[type="submit"]:hover, … … 386 392 margin: 0; 387 393 padding: 0 1em; 388 text-align: center;389 394 font-size: 1em; 390 }391 #footer a {392 395 } 393 396 #footer p span.credit { … … 404 407 #login-screen h1 { 405 408 text-indent: -2000px; 406 background: transparent url(d otclear-logo2.png) no-repeat top left;407 height: 50px;409 background: transparent url(dc_logos/w-dotclear240.png) no-repeat top left; 410 height: 66px; 408 411 margin-bottom: .5em; 409 412 margin-left: 0; … … 533 536 #comments { 534 537 clear: both; 538 } 539 .preview_entry a { 540 border: 1px solid #ccc; 541 padding: .2rem .5rem; 542 background: #eef; 535 543 } 536 544 /* ------------------------------------------------------------------ categories */ … … 1471 1479 ---------------------------------------------------------------------------- */ 1472 1480 @media screen and (max-width: 920px) { 1473 #top, #top h1 a {width: 42px !important;overflow:hidden;} 1481 #top, #top h1 a {width: 42px !important; height:100%; overflow: hidden;} 1482 #top h1 a:link { 1483 background: transparent url(dc_logos/b-dotclear120.png) no-repeat -180px 6px; 1484 border-right: 1px solid #ccc; 1485 } 1486 #top h1 a:hover, #top h1 a:focus { 1487 background: url(dc_logos/b-dotclear120.png) no-repeat -180px -94px; 1488 border-right: 1px solid #A2CBE9; 1489 } 1474 1490 } 1475 1491 @media screen and (max-width: 800px) { … … 1499 1515 .smallscreen {display: none;} 1500 1516 #help-button {width:20px; overflow: hidden;} 1517 #info-box1 {margin-left: 1rem;} 1501 1518 } 1502 1519 @media screen and (max-width: 492px) { 1503 #header { min-height:3.6rem;}1520 #header {height:3.6rem;} 1504 1521 #wrapper {font-size: 1.6rem;} 1505 1522 .page-title, #info-boxes, .media-item {display: inline-block;} 1506 1523 div.media-list .media-item {width: 90%; float: none} 1507 #top h1 a, #top {height: auto;}1508 1524 #info-box1 p.nomobile, label.nomobile {display: none;} 1509 1525 #help-button {height:26px; width:26px; background-color: #A2CBE9; padding: 0; margin:0;font-size: 1rem;line-height: 68px} -
inc/admin/lib.dc.page.php
r1316 r1413 4 4 # This file is part of Dotclear 2. 5 5 # 6 # Copyright (c) 2003-201 1Olivier Meunier & Association Dotclear6 # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear 7 7 # Licensed under the GPL version 2.0 license. 8 8 # See LICENSE file or … … 22 22 { 23 23 global $core; 24 24 25 25 if ($core->blog && $core->auth->check($permissions,$core->blog->id)) 26 26 { 27 27 return; 28 28 } 29 29 30 30 if (session_id()) { 31 31 $core->session->destroy(); … … 33 33 http::redirect(DC_AUTH_PAGE); 34 34 } 35 35 36 36 # Check super admin 37 37 public static function checkSuper() 38 38 { 39 39 global $core; 40 40 41 41 if (!$core->auth->isSuperAdmin()) 42 42 { … … 47 47 } 48 48 } 49 49 50 50 # Top of admin page 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->fillPageTitle($title); 58 59 ob_start(); 60 } 61 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 nomobile">'. 76 __('Blogs:').'</label> '. 77 $core->formNonce(). 78 form::combo('switchblog',$blogs,$core->blog->id). 79 '</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 ' <meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" />'."\n". 96 ' <meta name="GOOGLEBOT" content="NOSNIPPET" />'."\n". 97 ' <meta name="viewport" content="width=device-width, initial-scale=1.0" />'."\n". 98 ' <title>'.$title.' - '.html::escapeHTML($core->blog->name).' - '.html::escapeHTML(DC_VENDOR_NAME).' - '.DC_VERSION.'</title>'."\n". 99 100 101 self::jsLoadIE7(). 102 ' <link rel="stylesheet" href="style/default.css" type="text/css" media="screen" />'."\n"; 103 if (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl') { 104 echo 105 ' <link rel="stylesheet" href="style/default-rtl.css" type="text/css" media="screen" />'."\n"; 106 } 107 108 $core->auth->user_prefs->addWorkspace('interface'); 109 $user_ui_hide_std_favicon = $core->auth->user_prefs->interface->hide_std_favicon; 110 if (!$user_ui_hide_std_favicon) { 111 echo '<link rel="icon" type="image/png" href="images/favicon.png" />'; 112 } 113 114 echo 115 self::jsCommon(). 116 $head; 117 118 # --BEHAVIOR-- adminPageHTMLHead 119 $core->callBehavior('adminPageHTMLHead'); 120 121 echo 122 "</head>\n". 123 '<body id="dotclear-admin'. 124 ($safe_mode ? ' safe-mode' : ''). 125 '">'."\n". 126 127 '<div id="header">'. 128 '<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". 129 '<div id="top"><h1><a href="index.php">'.DC_VENDOR_NAME.'</a></h1></div>'."\n"; 130 131 echo 132 '<div id="info-boxes">'. 133 '<div id="info-box1">'. 134 '<form action="index.php" method="post">'. 135 $blog_box. 136 '<p class="nomobile"><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>'. 137 '</p></form>'. 138 '</div>'. 139 '<div id="info-box2">'. 140 '<a class="smallscreen'.(preg_match('/index.php$/',$_SERVER['REQUEST_URI']) ? ' active' : '').'" href="index.php">'.__('My dashboard').'</a>'. 141 '<span class="smallscreen"> | </span><a class="smallscreen'.(preg_match('/preferences.php(\?.*)?$/',$_SERVER['REQUEST_URI']) ? ' active' : '').'" href="preferences.php">'.__('My preferences').'</a>'. 142 '<span class="smallscreen"> | </span><a href="index.php?logout=1" class="logout">'.sprintf(__('Logout %s'),$core->auth->userID()).' <img src="images/logout.png" alt="" /></a>'. 143 '</div>'. 144 '</div>'. 145 '</div>'; 146 147 echo 148 '<div id="wrapper">'."\n". 149 '<div id="main">'."\n". 150 '<div id="content">'."\n"; 151 152 # Safe mode 153 if ($safe_mode) 154 { 155 echo 156 '<div class="error"><h3>'.__('Safe mode').'</h3>'. 157 '<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>'. 158 '</div>'; 159 } 160 161 if ($core->error->flag()) { 162 echo 163 '<div class="error"><p><strong>'.(count($core->error->getErrors()) > 1 ? __('Errors:') : __('Error:')).'</p></strong>'. 164 $core->error->toHTML(). 165 '</div>'; 166 } 167 } 168 62 169 public static function close() 63 170 { 64 $res = ob_get_contents(); 65 ob_end_clean(); 66 67 global $core, $_ctx; 68 171 global $core; 172 173 $menu =& $GLOBALS['_menu']; 174 175 echo 176 "</div>\n". // End of #content 177 "</div>\n". // End of #main 178 179 '<div id="main-menu">'."\n". 180 181 '<form id="search-menu" action="search.php" method="get">'. 182 '<p><label for="q" class="hidden">'.__('Search:').' </label>'.form::field('q',30,255,''). 183 '<input type="submit" value="'.__('OK').'" /></p>'. 184 '</form>'; 185 186 foreach ($menu as $k => $v) { 187 echo $menu[$k]->draw(); 188 } 189 190 $text = sprintf(__('Thank you for using %s.'),'Dotclear '.DC_VERSION); 191 192 # --BEHAVIOR-- adminPageFooter 193 $textAlt = $core->callBehavior('adminPageFooter',$core,$text); 194 if ($textAlt != '') { 195 $text = $textAlt; 196 } 197 $text = html::escapeHTML($text); 198 199 echo 200 '</div>'."\n". // End of #main-menu 201 '<div id="footer"><a href="http://dotclear.org/" title="'.$text.'"><img src="style/dc_logos/w-dotclear90.png" alt="'.$text.'" /></a></div>'."\n". 202 "</div>\n"; // End of #wrapper 203 204 if (defined('DC_DEV') && DC_DEV === true) { 205 echo self::debugInfo(); 206 } 207 208 echo 209 '</body></html>'; 210 } 211 212 public static function openPopup($title='', $head='') 213 { 214 global $core; 215 216 # Display 217 header('Content-Type: text/html; charset=UTF-8'); 218 echo 219 '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" '. 220 ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'."\n". 221 '<html xmlns="http://www.w3.org/1999/xhtml" '. 222 'xml:lang="'.$core->auth->getInfo('user_lang').'" '. 223 'lang="'.$core->auth->getInfo('user_lang').'">'."\n". 224 '<meta name="viewport" content="width=device-width, initial-scale=1.0" />'."\n". 225 "<head>\n". 226 ' <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'."\n". 227 ' <title>'.$title.' - '.html::escapeHTML($core->blog->name).' - '.html::escapeHTML(DC_VENDOR_NAME).' - '.DC_VERSION.'</title>'."\n". 228 229 ' <meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" />'."\n". 230 ' <meta name="GOOGLEBOT" content="NOSNIPPET" />'."\n". 231 232 self::jsLoadIE7(). 233 ' <link rel="stylesheet" href="style/default.css" type="text/css" media="screen" />'."\n"; 234 if (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl') { 235 echo 236 ' <link rel="stylesheet" href="style/default-rtl.css" type="text/css" media="screen" />'."\n"; 237 } 238 239 echo 240 self::jsCommon(). 241 $head; 242 243 # --BEHAVIOR-- adminPageHTMLHead 244 $core->callBehavior('adminPageHTMLHead'); 245 246 echo 247 "</head>\n". 248 '<body id="dotclear-admin" class="popup">'."\n". 249 250 '<div id="top hidden"><h1>'.DC_VENDOR_NAME.'</h1></div>'."\n"; 251 252 echo 253 '<div id="wrapper">'."\n". 254 '<div id="main">'."\n". 255 '<div id="content">'."\n"; 256 69 257 if ($core->error->flag()) { 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); 81 } 82 258 echo 259 '<div class="error"><strong>'.__('Errors:').'</strong>'. 260 $core->error->toHTML(). 261 '</div>'; 262 } 263 } 264 83 265 public static function closePopup() 84 266 { 85 self::close(); 267 echo 268 "</div>\n". // End of #content 269 "</div>\n". // End of #main 270 '<div id="footer"><p> </p></div>'."\n". 271 "</div>\n". // End of #wrapper 272 '</body></html>'; 273 } 274 275 public static function breadcrumb($elements=null,$no_home_link=false) 276 { 277 // First item of array elements should be blog's name, System or Plugins 278 $res = '<h2>'.($no_home_link ? 279 '<img src="style/dashboard-alt.png" alt="" />' : 280 '<a class="go_home" href="index.php"><img src="style/dashboard.png" alt="'.__('Go to dashboard').'" /></a>'); 281 $index = 0; 282 foreach ($elements as $element => $url) { 283 $res .= ($no_home_link ? ' ' : ($index == 1 ? ' : ' : ' › ')).($url ? '<a href="'.$url.'">' : '').$element.($url ? '</a>' : ''); 284 $index++; 285 } 286 $res .= '</h2>'; 287 return $res; 86 288 } 87 289 … … 89 291 { 90 292 global $core; 91 293 92 294 $res = ''; 93 295 if ($msg != '') { 94 296 $res = ($div ? '<div class="message">' : '').'<p'.($div ? '' : ' class="message"').'>'. 95 96 297 ($timestamp ? dt::str(__('%H:%M:%S:'),null,$core->auth->getInfo('user_tz')).' ' : '').$msg. 298 '</p>'.($div ? '</div>' : ''); 97 299 if ($echo) { 98 300 echo $res; … … 101 303 return $res; 102 304 } 103 305 306 private static function debugInfo() 307 { 308 $global_vars = implode(', ',array_keys($GLOBALS)); 309 310 $res = 311 '<div id="debug"><div>'. 312 '<p>memory usage: '.memory_get_usage().' ('.files::size(memory_get_usage()).')</p>'; 313 314 if (function_exists('xdebug_get_profiler_filename')) 315 { 316 $res .= '<p>Elapsed time: '.xdebug_time_index().' seconds</p>'; 317 318 $prof_file = xdebug_get_profiler_filename(); 319 if ($prof_file) { 320 $res .= '<p>Profiler file : '.xdebug_get_profiler_filename().'</p>'; 321 } else { 322 $prof_url = http::getSelfURI(); 323 $prof_url .= (strpos($prof_url,'?') === false) ? '?' : '&'; 324 $prof_url .= 'XDEBUG_PROFILE'; 325 $res .= '<p><a href="'.html::escapeURL($prof_url).'">Trigger profiler</a></p>'; 326 } 327 328 /* xdebug configuration: 329 zend_extension = /.../xdebug.so 330 xdebug.auto_trace = On 331 xdebug.trace_format = 0 332 xdebug.trace_options = 1 333 xdebug.show_mem_delta = On 334 xdebug.profiler_enable = 0 335 xdebug.profiler_enable_trigger = 1 336 xdebug.profiler_output_dir = /tmp 337 xdebug.profiler_append = 0 338 xdebug.profiler_output_name = timestamp 339 */ 340 } 341 342 $res .= 343 '<p>Global vars: '.$global_vars.'</p>'. 344 '</div></div>'; 345 346 return $res; 347 } 348 104 349 public static function help($page,$index='') 105 350 { 106 351 # Deprecated but we keep this for plugins. 107 352 } 108 353 109 354 public static function helpBlock() 110 355 { … … 113 358 return; 114 359 }; 115 360 116 361 global $__resources; 117 362 if (empty($__resources['help'])) { 118 363 return; 119 364 } 120 365 121 366 $content = ''; 122 367 foreach ($args as $v) … … 126 371 continue; 127 372 } 128 373 129 374 if (!isset($__resources['help'][$v])) { 130 375 continue; … … 134 379 continue; 135 380 } 136 381 137 382 $fc = file_get_contents($f); 138 383 if (preg_match('|<body[^>]*?>(.*?)</body>|ms',$fc,$matches)) { … … 142 387 } 143 388 } 144 389 145 390 if (trim($content) == '') { 146 391 return; 147 392 } 148 393 149 394 echo 150 395 '<div id="help"><hr /><div class="help-content clear"><h2>'.__('Help').'</h2>'. … … 152 397 '</div></div>'; 153 398 } 154 399 155 400 public static function jsLoad($src) 156 401 { … … 161 406 } 162 407 } 163 408 164 409 public static function jsVar($n,$v) 165 410 { 166 411 return $n." = '".html::escapeJS($v)."';\n"; 167 412 } 168 413 169 414 public static function jsCommon() 170 415 { … … 175 420 self::jsLoad('js/common.js'). 176 421 self::jsLoad('js/prelude.js'). 177 422 178 423 '<script type="text/javascript">'."\n". 179 424 "//<![CDATA[\n". 180 425 self::jsVar('dotclear.nonce',$GLOBALS['core']->getNonce()). 181 426 182 427 self::jsVar('dotclear.img_plus_src','images/expand.png'). 183 428 self::jsVar('dotclear.img_plus_alt',__('uncover')). … … 186 431 self::jsVar('dotclear.img_menu_on','images/menu_on.png'). 187 432 self::jsVar('dotclear.img_menu_off','images/menu_off.png'). 188 433 189 434 self::jsVar('dotclear.msg.help', 190 435 __('Help about this page')). … … 260 505 "</script>\n"; 261 506 } 262 507 263 508 public static function jsLoadIE7() 264 509 { … … 269 514 '<![endif]-->'."\n"; 270 515 } 271 516 272 517 public static function jsConfirmClose() 273 518 { … … 281 526 $args = ''; 282 527 } 283 528 284 529 return 285 530 self::jsLoad('js/confirm-close.js'). … … 291 536 "</script>\n"; 292 537 } 293 538 294 539 public static function jsPageTabs($default=null) 295 540 { … … 297 542 $default = "'".html::escapeJS($default)."'"; 298 543 } 299 544 300 545 return 301 546 self::jsLoad('js/jquery/jquery.pageTabs.js'). … … 303 548 "//<![CDATA[\n". 304 549 "\$(function() {\n". 305 " \$.pageTabs(".$default.");\n".306 "});\n".307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 550 " \$.pageTabs(".$default.");\n". 551 "});\n". 552 "\n//]]>\n". 553 "</script>\n"; 554 } 555 556 public static function jsModal() 557 { 558 return 559 '<link rel="stylesheet" type="text/css" href="style/modal/modal.css" />'."\n". 560 self::jsLoad('js/jquery/jquery.modal.js'). 561 '<script type="text/javascript">'."\n". 562 "//<![CDATA[\n". 563 self::jsVar('$.modal.prototype.params.loader_img','style/modal/loader.gif'). 564 self::jsVar('$.modal.prototype.params.close_img','style/modal/close.png'). 565 "\n//]]>\n". 566 "</script>\n"; 567 } 568 569 public static function jsColorPicker() 570 { 571 return 572 '<link rel="stylesheet" type="text/css" href="style/farbtastic/farbtastic.css" />'."\n". 573 self::jsLoad('js/jquery/jquery.farbtastic.js'). 574 self::jsLoad('js/color-picker.js'); 575 } 576 577 public static function jsDatePicker() 578 { 579 return 580 '<link rel="stylesheet" type="text/css" href="style/date-picker.css" />'."\n". 581 self::jsLoad('js/date-picker.js'). 582 '<script type="text/javascript">'."\n". 583 "//<![CDATA[\n". 584 585 "datePicker.prototype.months[0] = '".html::escapeJS(__('January'))."'; ". 586 "datePicker.prototype.months[1] = '".html::escapeJS(__('February'))."'; ". 587 "datePicker.prototype.months[2] = '".html::escapeJS(__('March'))."'; ". 588 "datePicker.prototype.months[3] = '".html::escapeJS(__('April'))."'; ". 589 "datePicker.prototype.months[4] = '".html::escapeJS(__('May'))."'; ". 590 "datePicker.prototype.months[5] = '".html::escapeJS(__('June'))."'; ". 591 "datePicker.prototype.months[6] = '".html::escapeJS(__('July'))."'; ". 592 "datePicker.prototype.months[7] = '".html::escapeJS(__('August'))."'; ". 593 "datePicker.prototype.months[8] = '".html::escapeJS(__('September'))."'; ". 594 "datePicker.prototype.months[9] = '".html::escapeJS(__('October'))."'; ". 595 "datePicker.prototype.months[10] = '".html::escapeJS(__('November'))."'; ". 596 "datePicker.prototype.months[11] = '".html::escapeJS(__('December'))."'; ". 597 598 "datePicker.prototype.days[0] = '".html::escapeJS(__('Monday'))."'; ". 599 "datePicker.prototype.days[1] = '".html::escapeJS(__('Tuesday'))."'; ". 600 "datePicker.prototype.days[2] = '".html::escapeJS(__('Wednesday'))."'; ". 601 "datePicker.prototype.days[3] = '".html::escapeJS(__('Thursday'))."'; ". 602 "datePicker.prototype.days[4] = '".html::escapeJS(__('Friday'))."'; ". 603 "datePicker.prototype.days[5] = '".html::escapeJS(__('Saturday'))."'; ". 604 "datePicker.prototype.days[6] = '".html::escapeJS(__('Sunday'))."'; ". 605 606 "datePicker.prototype.img_src = 'images/date-picker.png'; ". 607 608 "datePicker.prototype.close_msg = '".html::escapeJS(__('close'))."'; ". 609 "datePicker.prototype.now_msg = '".html::escapeJS(__('now'))."'; ". 610 611 "\n//]]>\n". 612 "</script>\n"; 613 } 614 615 public static function jsToolBar() 616 { 617 $res = 618 '<link rel="stylesheet" type="text/css" href="style/jsToolBar/jsToolBar.css" />'. 619 '<script type="text/javascript" src="js/jsToolBar/jsToolBar.js"></script>'; 620 621 if (isset($GLOBALS['core']->auth) && $GLOBALS['core']->auth->getOption('enable_wysiwyg')) { 622 $res .= '<script type="text/javascript" src="js/jsToolBar/jsToolBar.wysiwyg.js"></script>'; 623 } 624 625 $res .= 626 '<script type="text/javascript" src="js/jsToolBar/jsToolBar.dotclear.js"></script>'. 627 '<script type="text/javascript">'."\n". 628 "//<![CDATA[\n". 629 "jsToolBar.prototype.dialog_url = 'popup.php'; ". 630 "jsToolBar.prototype.iframe_css = '". 631 'body{'. 632 'font: 12px "DejaVu Sans","Lucida Grande","Lucida Sans Unicode",Arial,sans-serif;'. 633 'color : #000;'. 634 'background: #f9f9f9;'. 635 'margin: 0;'. 636 'padding : 2px;'. 637 'border: none;'. 638 (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl' ? 'direction:rtl;' : ''). 639 '}'. 640 'pre, code, kbd, samp {'. 641 'font-family:"Courier New",Courier,monospace;'. 642 'font-size : 1.1em;'. 643 '}'. 644 'code {'. 645 'color : #666;'. 646 'font-weight : bold;'. 647 '}'. 648 'body > p:first-child {'. 649 'margin-top: 0;'. 650 '}'. 651 "'; ". 652 "jsToolBar.prototype.base_url = '".html::escapeJS($GLOBALS['core']->blog->host)."'; ". 653 "jsToolBar.prototype.switcher_visual_title = '".html::escapeJS(__('visual'))."'; ". 654 "jsToolBar.prototype.switcher_source_title = '".html::escapeJS(__('source'))."'; ". 655 "jsToolBar.prototype.legend_msg = '". 656 html::escapeJS(__('You can use the following shortcuts to format your text.'))."'; ". 657 "jsToolBar.prototype.elements.blocks.options.none = '".html::escapeJS(__('-- none --'))."'; ". 658 "jsToolBar.prototype.elements.blocks.options.nonebis = '".html::escapeJS(__('-- block format --'))."'; ". 659 "jsToolBar.prototype.elements.blocks.options.p = '".html::escapeJS(__('Paragraph'))."'; ". 660 "jsToolBar.prototype.elements.blocks.options.h1 = '".html::escapeJS(__('Level 1 header'))."'; ". 661 "jsToolBar.prototype.elements.blocks.options.h2 = '".html::escapeJS(__('Level 2 header'))."'; ". 662 "jsToolBar.prototype.elements.blocks.options.h3 = '".html::escapeJS(__('Level 3 header'))."'; ". 663 "jsToolBar.prototype.elements.blocks.options.h4 = '".html::escapeJS(__('Level 4 header'))."'; ". 664 "jsToolBar.prototype.elements.blocks.options.h5 = '".html::escapeJS(__('Level 5 header'))."'; ". 665 "jsToolBar.prototype.elements.blocks.options.h6 = '".html::escapeJS(__('Level 6 header'))."'; ". 666 "jsToolBar.prototype.elements.strong.title = '".html::escapeJS(__('Strong emphasis'))."'; ". 667 "jsToolBar.prototype.elements.em.title = '".html::escapeJS(__('Emphasis'))."'; ". 668 "jsToolBar.prototype.elements.ins.title = '".html::escapeJS(__('Inserted'))."'; ". 669 "jsToolBar.prototype.elements.del.title = '".html::escapeJS(__('Deleted'))."'; ". 670 "jsToolBar.prototype.elements.quote.title = '".html::escapeJS(__('Inline quote'))."'; ". 671 "jsToolBar.prototype.elements.code.title = '".html::escapeJS(__('Code'))."'; ". 672 "jsToolBar.prototype.elements.br.title = '".html::escapeJS(__('Line break'))."'; ". 673 "jsToolBar.prototype.elements.blockquote.title = '".html::escapeJS(__('Blockquote'))."'; ". 674 "jsToolBar.prototype.elements.pre.title = '".html::escapeJS(__('Preformated text'))."'; ". 675 "jsToolBar.prototype.elements.ul.title = '".html::escapeJS(__('Unordered list'))."'; ". 676 "jsToolBar.prototype.elements.ol.title = '".html::escapeJS(__('Ordered list'))."'; ". 677 678 "jsToolBar.prototype.elements.link.title = '".html::escapeJS(__('Link'))."'; ". 679 "jsToolBar.prototype.elements.link.href_prompt = '".html::escapeJS(__('URL?'))."'; ". 680 "jsToolBar.prototype.elements.link.hreflang_prompt = '".html::escapeJS(__('Language?'))."'; ". 681 682 "jsToolBar.prototype.elements.img.title = '".html::escapeJS(__('External image'))."'; ". 683 "jsToolBar.prototype.elements.img.src_prompt = '".html::escapeJS(__('URL?'))."'; ". 684 685 "jsToolBar.prototype.elements.img_select.title = '".html::escapeJS(__('Media chooser'))."'; ". 686 "jsToolBar.prototype.elements.post_link.title = '".html::escapeJS(__('Link to an entry'))."'; "; 687 688 if (!$GLOBALS['core']->auth->check('media,media_admin',$GLOBALS['core']->blog->id)) { 689 $res .= "jsToolBar.prototype.elements.img_select.disabled = true;\n"; 690 } 691 692 $res .= 693 "\n//]]>\n". 694 "</script>\n"; 695 696 return $res; 697 } 698 699 public static function jsUpload($params=array(),$base_url=null) 700 { 701 if (!$base_url) { 702 $base_url = path::clean(dirname(preg_replace('/(\?.*$)?/','',$_SERVER['REQUEST_URI']))).'/'; 703 } 704 705 $params = array_merge($params,array( 706 'sess_id='.session_id(), 707 'sess_uid='.$_SESSION['sess_browser_uid'], 708 'xd_check='.$GLOBALS['core']->getNonce() 464 709 )); 465 466 return 467 '<link rel="stylesheet" type="text/css" href="style/jsUpload/style.css" />'."\n". 468 469 '<script id="template-upload" type="text/x-tmpl"> 470 {% for (var i=0, file; file=o.files[i]; i++) { %} 471 <tr class="template-upload fade"> 472 <td> 473 <span class="preview"></span> 474 </td> 475 <td> 476 <p class="name">{%=file.name%}</p> 477 {% if (file.error) { %} 478 <div><span class="label label-error">'.__('Error:').'</span> {%=file.error%}</div> 479 {% } %} 480 </td> 481 <td> 482 <p class="size">{%=o.formatFileSize(file.size)%}</p> 483 {% if (!o.files.error) { %} 484 <div class="progress progress-success progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><div class="bar" style="width:0%;"></div></div> 485 {% } %} 486 </td> 487 <td> 488 {% if (!o.files.error && !i && !o.options.autoUpload) { %} 489 <input type="submit" class="button start" value="'.__('Send').'"/> 490 {% } %} 491 </td> 492 </tr> 493 {% } %} 494 </script> 495 <!-- The template to display files available for download --> 496 <script id="template-download" type="text/x-tmpl"> 497 {% for (var i=0, file; file=o.files[i]; i++) { %} 498 <tr class="template-download fade"> 499 <td> 500 <span class="preview"> 501 {% if (file.thumbnail_url) { %} 502 <a href="{%=file.url%}" title="{%=file.name%}" data-gallery="gallery" download="{%=file.name%}"><img src="{%=file.thumbnail_url%}"></a> 503 {% } %} 504 </span> 505 </td> 506 <td> 507 <p class="name">{%=file.name%}</p> 508 {% if (file.error) { %} 509 <div><span class="label label-important">'.__('Error:').'</span> {%=file.error%}</div> 510 {% } %} 511 </td> 512 <td> 513 <span class="size">{%=o.formatFileSize(file.size)%}</span> 514 </td> 515 <td> 516 {% if (file.error) { %} 517 <span class="upload-status error"></span> 518 {% } else { %} 519 <span class="upload-status ok"></span> 520 {% } %} 521 </td> 522 </tr> 523 {% } %} 524 </script>'. 525 526 self::jsLoad('js/jsUpload/vendor/jquery.ui.widget.js'). 527 self::jsLoad('js/jsUpload/tmpl.js'). 528 self::jsLoad('js/jsUpload/load-image.js'). 529 self::jsLoad('js/jsUpload/jquery.iframe-transport.js'). 530 self::jsLoad('js/jsUpload/jquery.fileupload.js'). 531 self::jsLoad('js/jsUpload/jquery.fileupload-process.js'). 532 self::jsLoad('js/jsUpload/jquery.fileupload-resize.js'). 533 self::jsLoad('js/jsUpload/jquery.fileupload-ui.js'). 534 535 '<script type="text/javascript">'."\n". 536 "//<![CDATA[\n". 537 "dotclear.jsUpload = {};\n". 538 "dotclear.jsUpload.msg = {};\n". 539 self::jsVar('dotclear.jsUpload.msg.limit_exceeded',__('Limit exceeded.')). 540 self::jsVar('dotclear.jsUpload.msg.size_limit_exceeded',__('File size exceeds allowed limit.')). 541 self::jsVar('dotclear.jsUpload.msg.canceled',__('Canceled.')). 542 self::jsVar('dotclear.jsUpload.msg.http_error',__('HTTP Error:')). 543 self::jsVar('dotclear.jsUpload.msg.error',__('Error:')). 544 self::jsVar('dotclear.jsUpload.msg.choose_file',__('Choose file')). 545 self::jsVar('dotclear.jsUpload.msg.choose_files',__('Choose files')). 546 self::jsVar('dotclear.jsUpload.msg.cancel',__('Cancel')). 547 self::jsVar('dotclear.jsUpload.msg.clean',__('Clean')). 548 self::jsVar('dotclear.jsUpload.msg.upload',__('Upload')). 549 self::jsVar('dotclear.jsUpload.msg.no_file_in_queue',__('No file in queue.')). 550 self::jsVar('dotclear.jsUpload.msg.file_in_queue',__('1 file in queue.')). 551 self::jsVar('dotclear.jsUpload.msg.files_in_queue',__('%d files in queue.')). 552 self::jsVar('dotclear.jsUpload.msg.queue_error',__('Queue error:')). 553 self::jsVar('dotclear.jsUpload.base_url',$base_url). 554 "\n//]]>\n". 555 "</script>\n"; 556 } 557 558 public static function jsToolMan() 559 { 560 return 561 '<script type="text/javascript" src="js/tool-man/core.js"></script>'. 562 '<script type="text/javascript" src="js/tool-man/events.js"></script>'. 563 '<script type="text/javascript" src="js/tool-man/css.js"></script>'. 564 '<script type="text/javascript" src="js/tool-man/coordinates.js"></script>'. 565 '<script type="text/javascript" src="js/tool-man/drag.js"></script>'. 566 '<script type="text/javascript" src="js/tool-man/dragsort.js"></script>'. 567 '<script type="text/javascript" src="js/dragsort-tablerows.js"></script>'; 568 } 569 570 public static function jsMetaEditor() 571 { 572 return 573 '<script type="text/javascript" src="js/meta-editor.js"></script>'; 574 } 710 711 return 712 '<link rel="stylesheet" type="text/css" href="style/jsUpload/style.css" />'."\n". 713 714 '<script id="template-upload" type="text/x-tmpl"> 715 {% for (var i=0, file; file=o.files[i]; i++) { %} 716 <div class="template-upload fade"> 717 <div class="upload-file"> 718 <div class="upload-fileinfo"> 719 <span class="upload-filename">{%=file.name%}</span> 720 <span class="upload-filesize">({%=o.formatFileSize(file.size)%})</span> 721 <span class="upload-filecancel cancel">'.__('Cancel').'</span> 722 {% if (!o.files.error && !i && !o.options.autoUpload) { %} 723 <input type="submit" class="button start" value="'.__('Send').'"/> 724 {% } %} 725 <span class="upload-filemsg"></span> 726 </div> 727 {% if (!o.files.error) { %} 728 <div class="upload-progress progress progress-success progress-striped active"><div class="bar" style="width:0%;"></div></div> 729 {% } %} 730 </div> 731 {% } %} 732 </script> 733 <!-- The template to display files available for download --> 734 <script id="template-download" type="text/x-tmpl"> 735 {% for (var i=0, file; file=o.files[i]; i++) { %} 736 <div class="template-download fade"> 737 <div class="upload-file"> 738 <div class="upload-fileinfo"> 739 <span class="upload-filename">{%=file.name%}</span> 740 <span class="upload-filesize">({%=o.formatFileSize(file.size)%})</span> 741 <span class="upload-filemsg{% if (file.error) { %} upload-error{% } %}"> 742 {% if (file.error) { %} 743 '.__('Error:').' {%=file.error%} 744 {% } else { %} 745 '.__('File successfully uploaded.').' 746 {% } %} 747 </span> 748 </div> 749 <div class="upload-progress"> 750 {% if (!file.error) { %} 751 <div class="bar" style="width:100%;">100%</div> 752 {% } %} 753 </div> 754 </div> 755 {% } %} 756 </script>'. 757 758 self::jsLoad('js/jsUpload/vendor/jquery.ui.widget.js'). 759 self::jsLoad('js/jsUpload/tmpl.js'). 760 self::jsLoad('js/jsUpload/load-image.js'). 761 self::jsLoad('js/jsUpload/jquery.iframe-transport.js'). 762 self::jsLoad('js/jsUpload/jquery.fileupload.js'). 763 self::jsLoad('js/jsUpload/jquery.fileupload-process.js'). 764 self::jsLoad('js/jsUpload/jquery.fileupload-resize.js'). 765 self::jsLoad('js/jsUpload/jquery.fileupload-ui.js'). 766 767 '<script type="text/javascript">'."\n". 768 "//<![CDATA[\n". 769 "dotclear.jsUpload = {};\n". 770 "dotclear.jsUpload.msg = {};\n". 771 self::jsVar('dotclear.msg.enhanced_uploader_activate',__('Temporarily activate enhanced uploader')). 772 self::jsVar('dotclear.msg.enhanced_uploader_disable',__('Temporarily disable enhanced uploader')). 773 self::jsVar('dotclear.jsUpload.msg.limit_exceeded',__('Limit exceeded.')). 774 self::jsVar('dotclear.jsUpload.msg.size_limit_exceeded',__('File size exceeds allowed limit.')). 775 self::jsVar('dotclear.jsUpload.msg.canceled',__('Canceled.')). 776 self::jsVar('dotclear.jsUpload.msg.http_error',__('HTTP Error:')). 777 self::jsVar('dotclear.jsUpload.msg.error',__('Error:')). 778 self::jsVar('dotclear.jsUpload.msg.choose_file',__('Choose file')). 779 self::jsVar('dotclear.jsUpload.msg.choose_files',__('Choose files')). 780 self::jsVar('dotclear.jsUpload.msg.cancel',__('Cancel')). 781 self::jsVar('dotclear.jsUpload.msg.clean',__('Clean')). 782 self::jsVar('dotclear.jsUpload.msg.upload',__('Upload')). 783 self::jsVar('dotclear.jsUpload.msg.no_file_in_queue',__('No file in queue.')). 784 self::jsVar('dotclear.jsUpload.msg.file_in_queue',__('1 file in queue.')). 785 self::jsVar('dotclear.jsUpload.msg.files_in_queue',__('%d files in queue.')). 786 self::jsVar('dotclear.jsUpload.msg.queue_error',__('Queue error:')). 787 self::jsVar('dotclear.jsUpload.base_url',$base_url). 788 "\n//]]>\n". 789 "</script>\n"; 790 } 791 792 public static function jsToolMan() 793 { 794 return 795 '<script type="text/javascript" src="js/tool-man/core.js"></script>'. 796 '<script type="text/javascript" src="js/tool-man/events.js"></script>'. 797 '<script type="text/javascript" src="js/tool-man/css.js"></script>'. 798 '<script type="text/javascript" src="js/tool-man/coordinates.js"></script>'. 799 '<script type="text/javascript" src="js/tool-man/drag.js"></script>'. 800 '<script type="text/javascript" src="js/tool-man/dragsort.js"></script>'. 801 '<script type="text/javascript" src="js/dragsort-tablerows.js"></script>'; 802 } 803 804 public static function jsMetaEditor() 805 { 806 return 807 '<script type="text/javascript" src="js/meta-editor.js"></script>'; 808 } 575 809 } 576 810 ?>
Note: See TracChangeset
for help on using the changeset viewer.