| 1 | <?php | 
|---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- | 
|---|
| 3 | # | 
|---|
| 4 | # This file is part of Dotclear 2. | 
|---|
| 5 | # | 
|---|
| 6 | # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear | 
|---|
| 7 | # Licensed under the GPL version 2.0 license. | 
|---|
| 8 | # See LICENSE file or | 
|---|
| 9 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html | 
|---|
| 10 | # | 
|---|
| 11 | # -- END LICENSE BLOCK ----------------------------------------- | 
|---|
| 12 | if (!defined('DC_RC_PATH')) { return; } | 
|---|
| 13 |  | 
|---|
| 14 | define('DC_AUTH_PAGE','auth.php'); | 
|---|
| 15 |  | 
|---|
| 16 | class dcPage | 
|---|
| 17 | { | 
|---|
| 18 | private static $loaded_js=array(); | 
|---|
| 19 |  | 
|---|
| 20 | # Auth check | 
|---|
| 21 | public static function check($permissions) | 
|---|
| 22 | { | 
|---|
| 23 | global $core; | 
|---|
| 24 |  | 
|---|
| 25 | if ($core->blog && $core->auth->check($permissions,$core->blog->id)) | 
|---|
| 26 | { | 
|---|
| 27 | return; | 
|---|
| 28 | } | 
|---|
| 29 |  | 
|---|
| 30 | if (session_id()) { | 
|---|
| 31 | $core->session->destroy(); | 
|---|
| 32 | } | 
|---|
| 33 | http::redirect(DC_AUTH_PAGE); | 
|---|
| 34 | } | 
|---|
| 35 |  | 
|---|
| 36 | # Check super admin | 
|---|
| 37 | public static function checkSuper() | 
|---|
| 38 | { | 
|---|
| 39 | global $core; | 
|---|
| 40 |  | 
|---|
| 41 | if (!$core->auth->isSuperAdmin()) | 
|---|
| 42 | { | 
|---|
| 43 | if (session_id()) { | 
|---|
| 44 | $core->session->destroy(); | 
|---|
| 45 | } | 
|---|
| 46 | http::redirect(DC_AUTH_PAGE); | 
|---|
| 47 | } | 
|---|
| 48 | } | 
|---|
| 49 |  | 
|---|
| 50 | # Top of admin page | 
|---|
| 51 | public static function open($title='',$head='',$breadcrumb='') | 
|---|
| 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 | self::jsToggles(). | 
|---|
| 117 | $head; | 
|---|
| 118 |  | 
|---|
| 119 | # --BEHAVIOR-- adminPageHTMLHead | 
|---|
| 120 | $core->callBehavior('adminPageHTMLHead'); | 
|---|
| 121 |  | 
|---|
| 122 | echo | 
|---|
| 123 | "</head>\n". | 
|---|
| 124 | '<body id="dotclear-admin'. | 
|---|
| 125 | ($safe_mode ? ' safe-mode' : '').'" class="no-js">'."\n". | 
|---|
| 126 |  | 
|---|
| 127 | '<div id="header">'. | 
|---|
| 128 | '<ul id="prelude">'. | 
|---|
| 129 | '<li><a href="#content">'.__('Go to the content').'</a></li>'. | 
|---|
| 130 | '<li><a href="#main-menu">'.__('Go to the menu').'</a></li>'. | 
|---|
| 131 | '<li><a href="#qx">'.__('Go to search').'</a></li>'. | 
|---|
| 132 | '</ul>'."\n". | 
|---|
| 133 | '<div id="top"><h1><a href="index.php">'.DC_VENDOR_NAME.'</a></h1></div>'."\n"; | 
|---|
| 134 |  | 
|---|
| 135 | echo | 
|---|
| 136 | '<div id="info-boxes">'. | 
|---|
| 137 | '<div id="info-box1">'. | 
|---|
| 138 | '<form action="index.php" method="post">'. | 
|---|
| 139 | $blog_box. | 
|---|
| 140 | '<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>'. | 
|---|
| 141 | '</p></form>'. | 
|---|
| 142 | '</div>'. | 
|---|
| 143 | '<div id="info-box2">'. | 
|---|
| 144 | '<a class="smallscreen'.(preg_match('/index.php$/',$_SERVER['REQUEST_URI']) ? ' active' : '').'" href="index.php">'.__('My dashboard').'</a>'. | 
|---|
| 145 | '<span class="smallscreen"> | </span><a class="smallscreen'.(preg_match('/preferences.php(\?.*)?$/',$_SERVER['REQUEST_URI']) ? ' active' : '').'" href="preferences.php">'.__('My preferences').'</a>'. | 
|---|
| 146 | '<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>'. | 
|---|
| 147 | '</div>'. | 
|---|
| 148 | '</div>'. | 
|---|
| 149 | '</div>'; | 
|---|
| 150 |  | 
|---|
| 151 | echo | 
|---|
| 152 | '<div id="wrapper" class="clearfix">'."\n". | 
|---|
| 153 | '<div class="hidden-if-no-js collapser-box"><a href="#" id="collapser">'. | 
|---|
| 154 | '<img class="collapse-mm" src="images/collapser-hide.png" alt="'.__('Hide main menu').'" />'. | 
|---|
| 155 | '<img class="expand-mm" src="images/collapser-show.png" alt="'.__('Show main menu').'" />'. | 
|---|
| 156 | '</a></div>'. | 
|---|
| 157 | '<div id="main">'."\n". | 
|---|
| 158 | '<div id="content" class="clearfix">'."\n"; | 
|---|
| 159 |  | 
|---|
| 160 | # Safe mode | 
|---|
| 161 | if ($safe_mode) | 
|---|
| 162 | { | 
|---|
| 163 | echo | 
|---|
| 164 | '<div class="error"><h3>'.__('Safe mode').'</h3>'. | 
|---|
| 165 | '<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>'. | 
|---|
| 166 | '</div>'; | 
|---|
| 167 | } | 
|---|
| 168 |  | 
|---|
| 169 | // Display breadcrumb (if given) before any error message | 
|---|
| 170 | echo $breadcrumb; | 
|---|
| 171 |  | 
|---|
| 172 | if ($core->error->flag()) { | 
|---|
| 173 | echo | 
|---|
| 174 | '<div class="error"><p><strong>'.(count($core->error->getErrors()) > 1 ? __('Errors:') : __('Error:')).'</strong></p>'. | 
|---|
| 175 | $core->error->toHTML(). | 
|---|
| 176 | '</div>'; | 
|---|
| 177 | } | 
|---|
| 178 | } | 
|---|
| 179 |  | 
|---|
| 180 | public static function close() | 
|---|
| 181 | { | 
|---|
| 182 | global $core; | 
|---|
| 183 |  | 
|---|
| 184 | if (!$GLOBALS['__resources']['ctxhelp']) { | 
|---|
| 185 | // Displau global help link in any contextual help displayed | 
|---|
| 186 | echo | 
|---|
| 187 | '<p id="help-button"><a href="help.php">'.__('Need help?').'</a></p>'; | 
|---|
| 188 | } | 
|---|
| 189 |  | 
|---|
| 190 | $menu =& $GLOBALS['_menu']; | 
|---|
| 191 |  | 
|---|
| 192 | echo | 
|---|
| 193 | "</div>\n".         // End of #content | 
|---|
| 194 | "</div>\n".         // End of #main | 
|---|
| 195 |  | 
|---|
| 196 | '<div id="main-menu">'."\n". | 
|---|
| 197 |  | 
|---|
| 198 | '<form id="search-menu" action="search.php" method="get">'. | 
|---|
| 199 | '<p><label for="qx" class="hidden">'.__('Search:').' </label>'.form::field('qx',30,255,''). | 
|---|
| 200 | '<input type="submit" value="'.__('OK').'" /></p>'. | 
|---|
| 201 | '</form>'; | 
|---|
| 202 |  | 
|---|
| 203 | foreach ($menu as $k => $v) { | 
|---|
| 204 | echo $menu[$k]->draw(); | 
|---|
| 205 | } | 
|---|
| 206 |  | 
|---|
| 207 | $text = sprintf(__('Thank you for using %s.'),'Dotclear '.DC_VERSION); | 
|---|
| 208 |  | 
|---|
| 209 | # --BEHAVIOR-- adminPageFooter | 
|---|
| 210 | $textAlt = $core->callBehavior('adminPageFooter',$core,$text); | 
|---|
| 211 | if ($textAlt != '') { | 
|---|
| 212 | $text = $textAlt; | 
|---|
| 213 | } | 
|---|
| 214 | $text = html::escapeHTML($text); | 
|---|
| 215 |  | 
|---|
| 216 | echo | 
|---|
| 217 | '</div>'."\n".      // End of #main-menu | 
|---|
| 218 | "</div>\n";         // End of #wrapper | 
|---|
| 219 |  | 
|---|
| 220 | echo | 
|---|
| 221 | '<div id="footer">'. | 
|---|
| 222 | '<a href="http://dotclear.org/" title="'.$text.'"><img src="style/dc_logos/w-dotclear90.png" alt="'.$text.'" /></a></div>'."\n". | 
|---|
| 223 | '<!-- '."\n". | 
|---|
| 224 | '                  .'."\n". | 
|---|
| 225 | '               ,;:\'`\'::'."\n". | 
|---|
| 226 | '            __||'."\n". | 
|---|
| 227 | '      _____/LLLL\_'."\n". | 
|---|
| 228 | '      \__________"|'."\n". | 
|---|
| 229 | '    ~^~^~^~^~^~^~^~^~^~'."\n". | 
|---|
| 230 | ' -->'."\n"; | 
|---|
| 231 |  | 
|---|
| 232 | if (defined('DC_DEV') && DC_DEV === true) { | 
|---|
| 233 | echo self::debugInfo(); | 
|---|
| 234 | } | 
|---|
| 235 |  | 
|---|
| 236 | echo | 
|---|
| 237 | '</body></html>'; | 
|---|
| 238 | } | 
|---|
| 239 |  | 
|---|
| 240 | public static function openPopup($title='',$head='',$breadcrumb='') | 
|---|
| 241 | { | 
|---|
| 242 | global $core; | 
|---|
| 243 |  | 
|---|
| 244 | # Display | 
|---|
| 245 | header('Content-Type: text/html; charset=UTF-8'); | 
|---|
| 246 | echo | 
|---|
| 247 | '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" '. | 
|---|
| 248 | ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'."\n". | 
|---|
| 249 | '<html xmlns="http://www.w3.org/1999/xhtml" '. | 
|---|
| 250 | 'xml:lang="'.$core->auth->getInfo('user_lang').'" '. | 
|---|
| 251 | 'lang="'.$core->auth->getInfo('user_lang').'">'."\n". | 
|---|
| 252 | '<meta name="viewport" content="width=device-width, initial-scale=1.0" />'."\n". | 
|---|
| 253 | "<head>\n". | 
|---|
| 254 | '  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'."\n". | 
|---|
| 255 | '  <title>'.$title.' - '.html::escapeHTML($core->blog->name).' - '.html::escapeHTML(DC_VENDOR_NAME).' - '.DC_VERSION.'</title>'."\n". | 
|---|
| 256 |  | 
|---|
| 257 | '  <meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" />'."\n". | 
|---|
| 258 | '  <meta name="GOOGLEBOT" content="NOSNIPPET" />'."\n". | 
|---|
| 259 |  | 
|---|
| 260 | self::jsLoadIE7(). | 
|---|
| 261 | '    <link rel="stylesheet" href="style/default.css" type="text/css" media="screen" />'."\n"; | 
|---|
| 262 | if (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl') { | 
|---|
| 263 | echo | 
|---|
| 264 | '    <link rel="stylesheet" href="style/default-rtl.css" type="text/css" media="screen" />'."\n"; | 
|---|
| 265 | } | 
|---|
| 266 |  | 
|---|
| 267 | echo | 
|---|
| 268 | self::jsCommon(). | 
|---|
| 269 | self::jsToggles(). | 
|---|
| 270 | $head; | 
|---|
| 271 |  | 
|---|
| 272 | # --BEHAVIOR-- adminPageHTMLHead | 
|---|
| 273 | $core->callBehavior('adminPageHTMLHead'); | 
|---|
| 274 |  | 
|---|
| 275 | echo | 
|---|
| 276 | "</head>\n". | 
|---|
| 277 | '<body id="dotclear-admin" class="popup">'."\n". | 
|---|
| 278 |  | 
|---|
| 279 | '<div id="top hidden"><h1>'.DC_VENDOR_NAME.'</h1></div>'."\n"; | 
|---|
| 280 |  | 
|---|
| 281 | echo | 
|---|
| 282 | '<div id="wrapper">'."\n". | 
|---|
| 283 | '<div id="main">'."\n". | 
|---|
| 284 | '<div id="content">'."\n"; | 
|---|
| 285 |  | 
|---|
| 286 | // display breadcrumb if given | 
|---|
| 287 | echo $breadcrumb; | 
|---|
| 288 |  | 
|---|
| 289 | if ($core->error->flag()) { | 
|---|
| 290 | echo | 
|---|
| 291 | '<div class="error"><strong>'.__('Errors:').'</strong>'. | 
|---|
| 292 | $core->error->toHTML(). | 
|---|
| 293 | '</div>'; | 
|---|
| 294 | } | 
|---|
| 295 | } | 
|---|
| 296 |  | 
|---|
| 297 | public static function closePopup() | 
|---|
| 298 | { | 
|---|
| 299 | echo | 
|---|
| 300 | "</div>\n".         // End of #content | 
|---|
| 301 | "</div>\n".         // End of #main | 
|---|
| 302 | '<div id="footer"><p> </p></div>'."\n". | 
|---|
| 303 | "</div>\n".         // End of #wrapper | 
|---|
| 304 | '</body></html>'; | 
|---|
| 305 | } | 
|---|
| 306 |  | 
|---|
| 307 | public static function breadcrumb($elements=null,$with_home_link=true,$echo=false) | 
|---|
| 308 | { | 
|---|
| 309 | // First item of array elements should be blog's name, System or Plugins | 
|---|
| 310 | $res = '<h2>'.($with_home_link ? | 
|---|
| 311 | '<a class="go_home" href="index.php"><img src="style/dashboard.png" alt="'.__('Go to dashboard').'" /></a>' : | 
|---|
| 312 | '<img src="style/dashboard-alt.png" alt="" />'); | 
|---|
| 313 | $index = 0; | 
|---|
| 314 | foreach ($elements as $element => $url) { | 
|---|
| 315 | $res .= ($with_home_link ? ($index == 1 ? ' : ' : ' › ') : ($index == 0 ? ' ' : ' › ')). | 
|---|
| 316 | ($url ? '<a href="'.$url.'">' : '').$element.($url ? '</a>' : ''); | 
|---|
| 317 | $index++; | 
|---|
| 318 | } | 
|---|
| 319 | $res .= '</h2>'; | 
|---|
| 320 | if ($echo) { | 
|---|
| 321 | echo $res; | 
|---|
| 322 | } | 
|---|
| 323 | return $res; | 
|---|
| 324 | } | 
|---|
| 325 |  | 
|---|
| 326 | public static function message($msg,$timestamp=true,$div=false,$echo=true,$class='message') | 
|---|
| 327 | { | 
|---|
| 328 | global $core; | 
|---|
| 329 |  | 
|---|
| 330 | $res = ''; | 
|---|
| 331 | if ($msg != '') { | 
|---|
| 332 | $res = ($div ? '<div class="'.$class.'">' : '').'<p'.($div ? '' : ' class="'.$class.'"').'>'. | 
|---|
| 333 | ($timestamp ? dt::str(__('%H:%M:%S:'),null,$core->auth->getInfo('user_tz')).' ' : '').$msg. | 
|---|
| 334 | '</p>'.($div ? '</div>' : ''); | 
|---|
| 335 | if ($echo) { | 
|---|
| 336 | echo $res; | 
|---|
| 337 | } | 
|---|
| 338 | } | 
|---|
| 339 | return $res; | 
|---|
| 340 | } | 
|---|
| 341 |  | 
|---|
| 342 | public static function success($msg,$timestamp=true,$div=false,$echo=true) | 
|---|
| 343 | { | 
|---|
| 344 | return self::message($msg,$timestamp,$div,$echo,"success"); | 
|---|
| 345 | } | 
|---|
| 346 |  | 
|---|
| 347 | public static function warning($msg,$timestamp=true,$div=false,$echo=true) | 
|---|
| 348 | { | 
|---|
| 349 | return self::message($msg,$timestamp,$div,$echo,"warning-msg"); | 
|---|
| 350 | } | 
|---|
| 351 |  | 
|---|
| 352 | private static function debugInfo() | 
|---|
| 353 | { | 
|---|
| 354 | $global_vars = implode(', ',array_keys($GLOBALS)); | 
|---|
| 355 |  | 
|---|
| 356 | $res = | 
|---|
| 357 | '<div id="debug"><div>'. | 
|---|
| 358 | '<p>memory usage: '.memory_get_usage().' ('.files::size(memory_get_usage()).')</p>'; | 
|---|
| 359 |  | 
|---|
| 360 | if (function_exists('xdebug_get_profiler_filename')) | 
|---|
| 361 | { | 
|---|
| 362 | $res .= '<p>Elapsed time: '.xdebug_time_index().' seconds</p>'; | 
|---|
| 363 |  | 
|---|
| 364 | $prof_file = xdebug_get_profiler_filename(); | 
|---|
| 365 | if ($prof_file) { | 
|---|
| 366 | $res .= '<p>Profiler file : '.xdebug_get_profiler_filename().'</p>'; | 
|---|
| 367 | } else { | 
|---|
| 368 | $prof_url = http::getSelfURI(); | 
|---|
| 369 | $prof_url .= (strpos($prof_url,'?') === false) ? '?' : '&'; | 
|---|
| 370 | $prof_url .= 'XDEBUG_PROFILE'; | 
|---|
| 371 | $res .= '<p><a href="'.html::escapeURL($prof_url).'">Trigger profiler</a></p>'; | 
|---|
| 372 | } | 
|---|
| 373 |  | 
|---|
| 374 | /* xdebug configuration: | 
|---|
| 375 | zend_extension = /.../xdebug.so | 
|---|
| 376 | xdebug.auto_trace = On | 
|---|
| 377 | xdebug.trace_format = 0 | 
|---|
| 378 | xdebug.trace_options = 1 | 
|---|
| 379 | xdebug.show_mem_delta = On | 
|---|
| 380 | xdebug.profiler_enable = 0 | 
|---|
| 381 | xdebug.profiler_enable_trigger = 1 | 
|---|
| 382 | xdebug.profiler_output_dir = /tmp | 
|---|
| 383 | xdebug.profiler_append = 0 | 
|---|
| 384 | xdebug.profiler_output_name = timestamp | 
|---|
| 385 | */ | 
|---|
| 386 | } | 
|---|
| 387 |  | 
|---|
| 388 | $res .= | 
|---|
| 389 | '<p>Global vars: '.$global_vars.'</p>'. | 
|---|
| 390 | '</div></div>'; | 
|---|
| 391 |  | 
|---|
| 392 | return $res; | 
|---|
| 393 | } | 
|---|
| 394 |  | 
|---|
| 395 | public static function help($page,$index='') | 
|---|
| 396 | { | 
|---|
| 397 | # Deprecated but we keep this for plugins. | 
|---|
| 398 | } | 
|---|
| 399 |  | 
|---|
| 400 | public static function helpBlock() | 
|---|
| 401 | { | 
|---|
| 402 | $args = func_get_args(); | 
|---|
| 403 |  | 
|---|
| 404 | $args = new ArrayObject($args); | 
|---|
| 405 |  | 
|---|
| 406 | # --BEHAVIOR-- adminPageHelpBlock | 
|---|
| 407 | $GLOBALS['core']->callBehavior('adminPageHelpBlock',$args); | 
|---|
| 408 |  | 
|---|
| 409 | if (empty($args)) { | 
|---|
| 410 | return; | 
|---|
| 411 | }; | 
|---|
| 412 |  | 
|---|
| 413 | global $__resources; | 
|---|
| 414 | if (empty($__resources['help'])) { | 
|---|
| 415 | return; | 
|---|
| 416 | } | 
|---|
| 417 |  | 
|---|
| 418 | $content = ''; | 
|---|
| 419 | foreach ($args as $v) | 
|---|
| 420 | { | 
|---|
| 421 | if (is_object($v) && isset($v->content)) { | 
|---|
| 422 | $content .= $v->content; | 
|---|
| 423 | continue; | 
|---|
| 424 | } | 
|---|
| 425 |  | 
|---|
| 426 | if (!isset($__resources['help'][$v])) { | 
|---|
| 427 | continue; | 
|---|
| 428 | } | 
|---|
| 429 | $f = $__resources['help'][$v]; | 
|---|
| 430 | if (!file_exists($f) || !is_readable($f)) { | 
|---|
| 431 | continue; | 
|---|
| 432 | } | 
|---|
| 433 |  | 
|---|
| 434 | $fc = file_get_contents($f); | 
|---|
| 435 | if (preg_match('|<body[^>]*?>(.*?)</body>|ms',$fc,$matches)) { | 
|---|
| 436 | $content .= $matches[1]; | 
|---|
| 437 | } else { | 
|---|
| 438 | $content .= $fc; | 
|---|
| 439 | } | 
|---|
| 440 | } | 
|---|
| 441 |  | 
|---|
| 442 | if (trim($content) == '') { | 
|---|
| 443 | return; | 
|---|
| 444 | } | 
|---|
| 445 |  | 
|---|
| 446 | // Set contextual help global flag | 
|---|
| 447 | $GLOBALS['__resources']['ctxhelp'] = true; | 
|---|
| 448 |  | 
|---|
| 449 | echo | 
|---|
| 450 | '<div id="help"><hr /><div class="help-content clear"><h3>'.__('Help about this page').'</h3>'. | 
|---|
| 451 | $content. | 
|---|
| 452 | '</div>'. | 
|---|
| 453 | '<div id="helplink"><hr />'. | 
|---|
| 454 | '<p>'. | 
|---|
| 455 | sprintf(__('See also %s'),sprintf('<a href="help.php">%s</a>',__('the global help'))). | 
|---|
| 456 | '</p>'. | 
|---|
| 457 | '</div></div>'; | 
|---|
| 458 | } | 
|---|
| 459 |  | 
|---|
| 460 | public static function jsLoad($src) | 
|---|
| 461 | { | 
|---|
| 462 | $escaped_src = html::escapeHTML($src); | 
|---|
| 463 | if (!isset(self::$loaded_js[$escaped_src])) { | 
|---|
| 464 | self::$loaded_js[$escaped_src]=true; | 
|---|
| 465 | return '<script type="text/javascript" src="'.$escaped_src.'"></script>'."\n"; | 
|---|
| 466 | } | 
|---|
| 467 | } | 
|---|
| 468 |  | 
|---|
| 469 | public static function jsVar($n,$v) | 
|---|
| 470 | { | 
|---|
| 471 | return $n." = '".html::escapeJS($v)."';\n"; | 
|---|
| 472 | } | 
|---|
| 473 |  | 
|---|
| 474 | public static function jsToggles() | 
|---|
| 475 | { | 
|---|
| 476 | if($GLOBALS['core']->auth->user_prefs->toggles) { | 
|---|
| 477 | $unfolded_sections = explode(',',$GLOBALS['core']->auth->user_prefs->toggles->unfolded_sections); | 
|---|
| 478 | foreach ($unfolded_sections as $k=>&$v) { | 
|---|
| 479 | if ($v == '') { | 
|---|
| 480 | unset($unfolded_sections[$k]); | 
|---|
| 481 | } else { | 
|---|
| 482 | $v = "'".html::escapeJS($v)."':true"; | 
|---|
| 483 | } | 
|---|
| 484 | } | 
|---|
| 485 | } else { | 
|---|
| 486 | $unfolded_sections=array(); | 
|---|
| 487 | } | 
|---|
| 488 | return '<script type="text/javascript">'."\n". | 
|---|
| 489 | "//<![CDATA[\n". | 
|---|
| 490 | 'dotclear.unfolded_sections = {'.join(",",$unfolded_sections)."};\n". | 
|---|
| 491 | "\n//]]>\n". | 
|---|
| 492 | "</script>\n"; | 
|---|
| 493 | } | 
|---|
| 494 |  | 
|---|
| 495 | public static function jsCommon() | 
|---|
| 496 | { | 
|---|
| 497 | $mute_or_no = ''; | 
|---|
| 498 | if (empty($GLOBALS['core']->blog) || $GLOBALS['core']->blog->settings->system->jquery_migrate_mute) { | 
|---|
| 499 | $mute_or_no .= | 
|---|
| 500 | '<script type="text/javascript">'."\n". | 
|---|
| 501 | "//<![CDATA[\n". | 
|---|
| 502 | 'jQuery.migrateMute = true;'. | 
|---|
| 503 | "\n//]]>\n". | 
|---|
| 504 | "</script>\n"; | 
|---|
| 505 | } | 
|---|
| 506 |  | 
|---|
| 507 | return | 
|---|
| 508 | self::jsLoad('js/jquery/jquery.js'). | 
|---|
| 509 | $mute_or_no. | 
|---|
| 510 | self::jsLoad('js/jquery/jquery-migrate-1.2.1.js'). | 
|---|
| 511 | self::jsLoad('js/jquery/jquery.biscuit.js'). | 
|---|
| 512 | self::jsLoad('js/jquery/jquery.bgFade.js'). | 
|---|
| 513 | self::jsLoad('js/common.js'). | 
|---|
| 514 | self::jsLoad('js/prelude.js'). | 
|---|
| 515 |  | 
|---|
| 516 | '<script type="text/javascript">'."\n". | 
|---|
| 517 | "//<![CDATA[\n". | 
|---|
| 518 | self::jsVar('dotclear.nonce',$GLOBALS['core']->getNonce()). | 
|---|
| 519 | self::jsVar('dotclear.img_plus_src','images/expand.png'). | 
|---|
| 520 | self::jsVar('dotclear.img_plus_alt',__('uncover')). | 
|---|
| 521 | self::jsVar('dotclear.img_minus_src','images/hide.png'). | 
|---|
| 522 | self::jsVar('dotclear.img_minus_alt',__('hide')). | 
|---|
| 523 | self::jsVar('dotclear.img_menu_on','images/menu_on.png'). | 
|---|
| 524 | self::jsVar('dotclear.img_menu_off','images/menu_off.png'). | 
|---|
| 525 |  | 
|---|
| 526 | self::jsVar('dotclear.msg.help', | 
|---|
| 527 | __('Need help?')). | 
|---|
| 528 | self::jsVar('dotclear.msg.help_hide', | 
|---|
| 529 | __('Hide')). | 
|---|
| 530 | self::jsVar('dotclear.msg.to_select', | 
|---|
| 531 | __('Select:')). | 
|---|
| 532 | self::jsVar('dotclear.msg.no_selection', | 
|---|
| 533 | __('no selection')). | 
|---|
| 534 | self::jsVar('dotclear.msg.select_all', | 
|---|
| 535 | __('select all')). | 
|---|
| 536 | self::jsVar('dotclear.msg.invert_sel', | 
|---|
| 537 | __('Invert selection')). | 
|---|
| 538 | self::jsVar('dotclear.msg.website', | 
|---|
| 539 | __('Web site:')). | 
|---|
| 540 | self::jsVar('dotclear.msg.email', | 
|---|
| 541 | __('Email:')). | 
|---|
| 542 | self::jsVar('dotclear.msg.ip_address', | 
|---|
| 543 | __('IP address:')). | 
|---|
| 544 | self::jsVar('dotclear.msg.error', | 
|---|
| 545 | __('Error:')). | 
|---|
| 546 | self::jsVar('dotclear.msg.entry_created', | 
|---|
| 547 | __('Entry has been successfully created.')). | 
|---|
| 548 | self::jsVar('dotclear.msg.edit_entry', | 
|---|
| 549 | __('Edit entry')). | 
|---|
| 550 | self::jsVar('dotclear.msg.view_entry', | 
|---|
| 551 | __('view entry')). | 
|---|
| 552 | self::jsVar('dotclear.msg.confirm_delete_posts', | 
|---|
| 553 | __("Are you sure you want to delete selected entries (%s)?")). | 
|---|
| 554 | self::jsVar('dotclear.msg.confirm_delete_categories', | 
|---|
| 555 | __("Are you sure you want to delete selected categories (%s)?")). | 
|---|
| 556 | self::jsVar('dotclear.msg.confirm_delete_post', | 
|---|
| 557 | __("Are you sure you want to delete this entry?")). | 
|---|
| 558 | self::jsVar('dotclear.msg.click_to_unlock', | 
|---|
| 559 | __("Click here to unlock the field")). | 
|---|
| 560 | self::jsVar('dotclear.msg.confirm_spam_delete', | 
|---|
| 561 | __('Are you sure you want to delete all spams?')). | 
|---|
| 562 | self::jsVar('dotclear.msg.confirm_delete_comments', | 
|---|
| 563 | __('Are you sure you want to delete selected comments (%s)?')). | 
|---|
| 564 | self::jsVar('dotclear.msg.confirm_delete_comment', | 
|---|
| 565 | __('Are you sure you want to delete this comment?')). | 
|---|
| 566 | self::jsVar('dotclear.msg.cannot_delete_users', | 
|---|
| 567 | __('Users with posts cannot be deleted.')). | 
|---|
| 568 | self::jsVar('dotclear.msg.confirm_delete_user', | 
|---|
| 569 | __('Are you sure you want to delete selected users (%s)?')). | 
|---|
| 570 | self::jsVar('dotclear.msg.confirm_delete_category', | 
|---|
| 571 | __('Are you sure you want to delete category "%s"?')). | 
|---|
| 572 | self::jsVar('dotclear.msg.confirm_reorder_categories', | 
|---|
| 573 | __('Are you sure you want to reorder all categories?')). | 
|---|
| 574 | self::jsVar('dotclear.msg.confirm_delete_media', | 
|---|
| 575 | __('Are you sure you want to remove media "%s"?')). | 
|---|
| 576 | self::jsVar('dotclear.msg.confirm_extract_current', | 
|---|
| 577 | __('Are you sure you want to extract archive in current directory?')). | 
|---|
| 578 | self::jsVar('dotclear.msg.confirm_remove_attachment', | 
|---|
| 579 | __('Are you sure you want to remove attachment "%s"?')). | 
|---|
| 580 | self::jsVar('dotclear.msg.confirm_delete_lang', | 
|---|
| 581 | __('Are you sure you want to delete "%s" language?')). | 
|---|
| 582 | self::jsVar('dotclear.msg.confirm_delete_plugin', | 
|---|
| 583 | __('Are you sure you want to delete "%s" plugin?')). | 
|---|
| 584 | self::jsVar('dotclear.msg.use_this_theme', | 
|---|
| 585 | __('Use this theme')). | 
|---|
| 586 | self::jsVar('dotclear.msg.remove_this_theme', | 
|---|
| 587 | __('Remove this theme')). | 
|---|
| 588 | self::jsVar('dotclear.msg.confirm_delete_theme', | 
|---|
| 589 | __('Are you sure you want to delete "%s" theme?')). | 
|---|
| 590 | self::jsVar('dotclear.msg.confirm_delete_backup', | 
|---|
| 591 | __('Are you sure you want to delete this backup?')). | 
|---|
| 592 | self::jsVar('dotclear.msg.zip_file_content', | 
|---|
| 593 | __('Zip file content')). | 
|---|
| 594 | self::jsVar('dotclear.msg.xhtml_validator', | 
|---|
| 595 | __('XHTML markup validator')). | 
|---|
| 596 | self::jsVar('dotclear.msg.xhtml_valid', | 
|---|
| 597 | __('XHTML content is valid.')). | 
|---|
| 598 | self::jsVar('dotclear.msg.xhtml_not_valid', | 
|---|
| 599 | __('There are XHTML markup errors.')). | 
|---|
| 600 | self::jsVar('dotclear.msg.warning_validate_no_save_content', | 
|---|
| 601 | __('Attention: an audit of a content not yet registered.')). | 
|---|
| 602 | self::jsVar('dotclear.msg.confirm_change_post_format', | 
|---|
| 603 | __('You have unsaved changes. Switch post format will loose these changes. Proceed anyway?')). | 
|---|
| 604 | self::jsVar('dotclear.msg.confirm_change_post_format_noconvert', | 
|---|
| 605 | __("Warning: post format change will not convert existing content. You will need to apply new format by yourself. Proceed anyway?")). | 
|---|
| 606 | self::jsVar('dotclear.msg.load_enhanced_uploader', | 
|---|
| 607 | __('Loading enhanced uploader, please wait.')). | 
|---|
| 608 | "\n//]]>\n". | 
|---|
| 609 | "</script>\n"; | 
|---|
| 610 | } | 
|---|
| 611 |  | 
|---|
| 612 | public static function jsLoadIE7() | 
|---|
| 613 | { | 
|---|
| 614 | return | 
|---|
| 615 | '<!--[if lt IE 9]>'."\n". | 
|---|
| 616 | self::jsLoad('js/ie7/IE9.js'). | 
|---|
| 617 | '<link rel="stylesheet" type="text/css" href="style/iesucks.css" />'."\n". | 
|---|
| 618 | '<![endif]-->'."\n"; | 
|---|
| 619 | } | 
|---|
| 620 |  | 
|---|
| 621 | public static function jsConfirmClose() | 
|---|
| 622 | { | 
|---|
| 623 | $args = func_get_args(); | 
|---|
| 624 | if (count($args) > 0) { | 
|---|
| 625 | foreach ($args as $k => $v) { | 
|---|
| 626 | $args[$k] = "'".html::escapeJS($v)."'"; | 
|---|
| 627 | } | 
|---|
| 628 | $args = implode(',',$args); | 
|---|
| 629 | } else { | 
|---|
| 630 | $args = ''; | 
|---|
| 631 | } | 
|---|
| 632 |  | 
|---|
| 633 | return | 
|---|
| 634 | self::jsLoad('js/confirm-close.js'). | 
|---|
| 635 | '<script type="text/javascript">'."\n". | 
|---|
| 636 | "//<![CDATA[\n". | 
|---|
| 637 | "confirmClosePage = new confirmClose(".$args."); ". | 
|---|
| 638 | "confirmClose.prototype.prompt = '".html::escapeJS(__('You have unsaved changes.'))."'; ". | 
|---|
| 639 | "\n//]]>\n". | 
|---|
| 640 | "</script>\n"; | 
|---|
| 641 | } | 
|---|
| 642 |  | 
|---|
| 643 | public static function jsPageTabs($default=null) | 
|---|
| 644 | { | 
|---|
| 645 | if ($default) { | 
|---|
| 646 | $default = "'".html::escapeJS($default)."'"; | 
|---|
| 647 | } | 
|---|
| 648 |  | 
|---|
| 649 | return | 
|---|
| 650 | self::jsLoad('js/jquery/jquery.pageTabs.js'). | 
|---|
| 651 | '<script type="text/javascript">'."\n". | 
|---|
| 652 | "//<![CDATA[\n". | 
|---|
| 653 | "\$(function() {\n". | 
|---|
| 654 | "    pagetabs = \$.pageTabs(".$default.");\n". | 
|---|
| 655 | "});\n". | 
|---|
| 656 | "\n//]]>\n". | 
|---|
| 657 | "</script>\n". | 
|---|
| 658 | "<!--[if lt IE 8]>\n". | 
|---|
| 659 | self::jsLoad('js/ie7/ie7-hashchange.js'). | 
|---|
| 660 | '<script type="text/javascript">'."\n". | 
|---|
| 661 | "//<![CDATA[\n". | 
|---|
| 662 | "\$(function() {". | 
|---|
| 663 | "\$(window).hashchange( function(){". | 
|---|
| 664 | "pagetabs.showDiv(document.location.hash.split('#').join(''));". | 
|---|
| 665 | "});". | 
|---|
| 666 | "});". | 
|---|
| 667 | "\n//]]>\n". | 
|---|
| 668 | "</script>\n". | 
|---|
| 669 | "<![endif]-->\n"; | 
|---|
| 670 | } | 
|---|
| 671 |  | 
|---|
| 672 | public static function jsModal() | 
|---|
| 673 | { | 
|---|
| 674 | return | 
|---|
| 675 | '<link rel="stylesheet" type="text/css" href="style/modal/modal.css" />'."\n". | 
|---|
| 676 | self::jsLoad('js/jquery/jquery.modal.js'). | 
|---|
| 677 | '<script type="text/javascript">'."\n". | 
|---|
| 678 | "//<![CDATA[\n". | 
|---|
| 679 | self::jsVar('$.modal.prototype.params.loader_img','style/modal/loader.gif'). | 
|---|
| 680 | self::jsVar('$.modal.prototype.params.close_img','style/modal/close.png'). | 
|---|
| 681 | "\n//]]>\n". | 
|---|
| 682 | "</script>\n"; | 
|---|
| 683 | } | 
|---|
| 684 |  | 
|---|
| 685 | public static function jsColorPicker() | 
|---|
| 686 | { | 
|---|
| 687 | return | 
|---|
| 688 | '<link rel="stylesheet" type="text/css" href="style/farbtastic/farbtastic.css" />'."\n". | 
|---|
| 689 | self::jsLoad('js/jquery/jquery.farbtastic.js'). | 
|---|
| 690 | self::jsLoad('js/color-picker.js'); | 
|---|
| 691 | } | 
|---|
| 692 |  | 
|---|
| 693 | public static function jsDatePicker() | 
|---|
| 694 | { | 
|---|
| 695 | return | 
|---|
| 696 | '<link rel="stylesheet" type="text/css" href="style/date-picker.css" />'."\n". | 
|---|
| 697 | self::jsLoad('js/date-picker.js'). | 
|---|
| 698 | '<script type="text/javascript">'."\n". | 
|---|
| 699 | "//<![CDATA[\n". | 
|---|
| 700 |  | 
|---|
| 701 | "datePicker.prototype.months[0] = '".html::escapeJS(__('January'))."'; ". | 
|---|
| 702 | "datePicker.prototype.months[1] = '".html::escapeJS(__('February'))."'; ". | 
|---|
| 703 | "datePicker.prototype.months[2] = '".html::escapeJS(__('March'))."'; ". | 
|---|
| 704 | "datePicker.prototype.months[3] = '".html::escapeJS(__('April'))."'; ". | 
|---|
| 705 | "datePicker.prototype.months[4] = '".html::escapeJS(__('May'))."'; ". | 
|---|
| 706 | "datePicker.prototype.months[5] = '".html::escapeJS(__('June'))."'; ". | 
|---|
| 707 | "datePicker.prototype.months[6] = '".html::escapeJS(__('July'))."'; ". | 
|---|
| 708 | "datePicker.prototype.months[7] = '".html::escapeJS(__('August'))."'; ". | 
|---|
| 709 | "datePicker.prototype.months[8] = '".html::escapeJS(__('September'))."'; ". | 
|---|
| 710 | "datePicker.prototype.months[9] = '".html::escapeJS(__('October'))."'; ". | 
|---|
| 711 | "datePicker.prototype.months[10] = '".html::escapeJS(__('November'))."'; ". | 
|---|
| 712 | "datePicker.prototype.months[11] = '".html::escapeJS(__('December'))."'; ". | 
|---|
| 713 |  | 
|---|
| 714 | "datePicker.prototype.days[0] = '".html::escapeJS(__('Monday'))."'; ". | 
|---|
| 715 | "datePicker.prototype.days[1] = '".html::escapeJS(__('Tuesday'))."'; ". | 
|---|
| 716 | "datePicker.prototype.days[2] = '".html::escapeJS(__('Wednesday'))."'; ". | 
|---|
| 717 | "datePicker.prototype.days[3] = '".html::escapeJS(__('Thursday'))."'; ". | 
|---|
| 718 | "datePicker.prototype.days[4] = '".html::escapeJS(__('Friday'))."'; ". | 
|---|
| 719 | "datePicker.prototype.days[5] = '".html::escapeJS(__('Saturday'))."'; ". | 
|---|
| 720 | "datePicker.prototype.days[6] = '".html::escapeJS(__('Sunday'))."'; ". | 
|---|
| 721 |  | 
|---|
| 722 | "datePicker.prototype.img_src = 'images/date-picker.png'; ". | 
|---|
| 723 |  | 
|---|
| 724 | "datePicker.prototype.close_msg = '".html::escapeJS(__('close'))."'; ". | 
|---|
| 725 | "datePicker.prototype.now_msg = '".html::escapeJS(__('now'))."'; ". | 
|---|
| 726 |  | 
|---|
| 727 | "\n//]]>\n". | 
|---|
| 728 | "</script>\n"; | 
|---|
| 729 | } | 
|---|
| 730 |  | 
|---|
| 731 | public static function jsToolBar() | 
|---|
| 732 | { | 
|---|
| 733 | $res = | 
|---|
| 734 | '<link rel="stylesheet" type="text/css" href="style/jsToolBar/jsToolBar.css" />'. | 
|---|
| 735 | '<script type="text/javascript" src="js/jsToolBar/jsToolBar.js"></script>'; | 
|---|
| 736 |  | 
|---|
| 737 | if (isset($GLOBALS['core']->auth) && $GLOBALS['core']->auth->getOption('enable_wysiwyg')) { | 
|---|
| 738 | $res .= '<script type="text/javascript" src="js/jsToolBar/jsToolBar.wysiwyg.js"></script>'; | 
|---|
| 739 | } | 
|---|
| 740 |  | 
|---|
| 741 | $res .= | 
|---|
| 742 | '<script type="text/javascript" src="js/jsToolBar/jsToolBar.dotclear.js"></script>'. | 
|---|
| 743 | '<script type="text/javascript">'."\n". | 
|---|
| 744 | "//<![CDATA[\n". | 
|---|
| 745 | "jsToolBar.prototype.dialog_url = 'popup.php'; ". | 
|---|
| 746 | "jsToolBar.prototype.iframe_css = '". | 
|---|
| 747 | 'body{'. | 
|---|
| 748 | 'font: 12px "DejaVu Sans","Lucida Grande","Lucida Sans Unicode",Arial,sans-serif;'. | 
|---|
| 749 | 'color : #000;'. | 
|---|
| 750 | 'background: #f9f9f9;'. | 
|---|
| 751 | 'margin: 0;'. | 
|---|
| 752 | 'padding : 2px;'. | 
|---|
| 753 | 'border: none;'. | 
|---|
| 754 | (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl' ? 'direction:rtl;' : ''). | 
|---|
| 755 | '}'. | 
|---|
| 756 | 'pre, code, kbd, samp {'. | 
|---|
| 757 | 'font-family:"Courier New",Courier,monospace;'. | 
|---|
| 758 | 'font-size : 1.1em;'. | 
|---|
| 759 | '}'. | 
|---|
| 760 | 'code {'. | 
|---|
| 761 | 'color : #666;'. | 
|---|
| 762 | 'font-weight : bold;'. | 
|---|
| 763 | '}'. | 
|---|
| 764 | 'body > p:first-child {'. | 
|---|
| 765 | 'margin-top: 0;'. | 
|---|
| 766 | '}'. | 
|---|
| 767 | "'; ". | 
|---|
| 768 | "jsToolBar.prototype.base_url = '".html::escapeJS($GLOBALS['core']->blog->host)."'; ". | 
|---|
| 769 | "jsToolBar.prototype.switcher_visual_title = '".html::escapeJS(__('visual'))."'; ". | 
|---|
| 770 | "jsToolBar.prototype.switcher_source_title = '".html::escapeJS(__('source'))."'; ". | 
|---|
| 771 | "jsToolBar.prototype.legend_msg = '". | 
|---|
| 772 | html::escapeJS(__('You can use the following shortcuts to format your text.'))."'; ". | 
|---|
| 773 | "jsToolBar.prototype.elements.blocks.options.none = '".html::escapeJS(__('-- none --'))."'; ". | 
|---|
| 774 | "jsToolBar.prototype.elements.blocks.options.nonebis = '".html::escapeJS(__('-- block format --'))."'; ". | 
|---|
| 775 | "jsToolBar.prototype.elements.blocks.options.p = '".html::escapeJS(__('Paragraph'))."'; ". | 
|---|
| 776 | "jsToolBar.prototype.elements.blocks.options.h1 = '".html::escapeJS(__('Level 1 header'))."'; ". | 
|---|
| 777 | "jsToolBar.prototype.elements.blocks.options.h2 = '".html::escapeJS(__('Level 2 header'))."'; ". | 
|---|
| 778 | "jsToolBar.prototype.elements.blocks.options.h3 = '".html::escapeJS(__('Level 3 header'))."'; ". | 
|---|
| 779 | "jsToolBar.prototype.elements.blocks.options.h4 = '".html::escapeJS(__('Level 4 header'))."'; ". | 
|---|
| 780 | "jsToolBar.prototype.elements.blocks.options.h5 = '".html::escapeJS(__('Level 5 header'))."'; ". | 
|---|
| 781 | "jsToolBar.prototype.elements.blocks.options.h6 = '".html::escapeJS(__('Level 6 header'))."'; ". | 
|---|
| 782 | "jsToolBar.prototype.elements.strong.title = '".html::escapeJS(__('Strong emphasis'))."'; ". | 
|---|
| 783 | "jsToolBar.prototype.elements.em.title = '".html::escapeJS(__('Emphasis'))."'; ". | 
|---|
| 784 | "jsToolBar.prototype.elements.ins.title = '".html::escapeJS(__('Inserted'))."'; ". | 
|---|
| 785 | "jsToolBar.prototype.elements.del.title = '".html::escapeJS(__('Deleted'))."'; ". | 
|---|
| 786 | "jsToolBar.prototype.elements.quote.title = '".html::escapeJS(__('Inline quote'))."'; ". | 
|---|
| 787 | "jsToolBar.prototype.elements.code.title = '".html::escapeJS(__('Code'))."'; ". | 
|---|
| 788 | "jsToolBar.prototype.elements.br.title = '".html::escapeJS(__('Line break'))."'; ". | 
|---|
| 789 | "jsToolBar.prototype.elements.blockquote.title = '".html::escapeJS(__('Blockquote'))."'; ". | 
|---|
| 790 | "jsToolBar.prototype.elements.pre.title = '".html::escapeJS(__('Preformated text'))."'; ". | 
|---|
| 791 | "jsToolBar.prototype.elements.ul.title = '".html::escapeJS(__('Unordered list'))."'; ". | 
|---|
| 792 | "jsToolBar.prototype.elements.ol.title = '".html::escapeJS(__('Ordered list'))."'; ". | 
|---|
| 793 |  | 
|---|
| 794 | "jsToolBar.prototype.elements.link.title = '".html::escapeJS(__('Link'))."'; ". | 
|---|
| 795 | "jsToolBar.prototype.elements.link.href_prompt = '".html::escapeJS(__('URL?'))."'; ". | 
|---|
| 796 | "jsToolBar.prototype.elements.link.hreflang_prompt = '".html::escapeJS(__('Language?'))."'; ". | 
|---|
| 797 |  | 
|---|
| 798 | "jsToolBar.prototype.elements.img.title = '".html::escapeJS(__('External image'))."'; ". | 
|---|
| 799 | "jsToolBar.prototype.elements.img.src_prompt = '".html::escapeJS(__('URL?'))."'; ". | 
|---|
| 800 |  | 
|---|
| 801 | "jsToolBar.prototype.elements.img_select.title = '".html::escapeJS(__('Media chooser'))."'; ". | 
|---|
| 802 | "jsToolBar.prototype.elements.post_link.title = '".html::escapeJS(__('Link to an entry'))."'; "; | 
|---|
| 803 |  | 
|---|
| 804 | if (!$GLOBALS['core']->auth->check('media,media_admin',$GLOBALS['core']->blog->id)) { | 
|---|
| 805 | $res .= "jsToolBar.prototype.elements.img_select.disabled = true;\n"; | 
|---|
| 806 | } | 
|---|
| 807 |  | 
|---|
| 808 | $res .= | 
|---|
| 809 | "\n//]]>\n". | 
|---|
| 810 | "</script>\n"; | 
|---|
| 811 |  | 
|---|
| 812 | return $res; | 
|---|
| 813 | } | 
|---|
| 814 |  | 
|---|
| 815 | public static function jsUpload($params=array(),$base_url=null) | 
|---|
| 816 | { | 
|---|
| 817 | if (!$base_url) { | 
|---|
| 818 | $base_url = path::clean(dirname(preg_replace('/(\?.*$)?/','',$_SERVER['REQUEST_URI']))).'/'; | 
|---|
| 819 | } | 
|---|
| 820 |  | 
|---|
| 821 | $params = array_merge($params,array( | 
|---|
| 822 | 'sess_id='.session_id(), | 
|---|
| 823 | 'sess_uid='.$_SESSION['sess_browser_uid'], | 
|---|
| 824 | 'xd_check='.$GLOBALS['core']->getNonce() | 
|---|
| 825 | )); | 
|---|
| 826 |  | 
|---|
| 827 | return | 
|---|
| 828 | '<script type="text/javascript">'."\n". | 
|---|
| 829 | "//<![CDATA[\n". | 
|---|
| 830 | "dotclear.jsUpload = {};\n". | 
|---|
| 831 | "dotclear.jsUpload.msg = {};\n". | 
|---|
| 832 | self::jsVar('dotclear.msg.enhanced_uploader_activate',__('Temporarily activate enhanced uploader')). | 
|---|
| 833 | self::jsVar('dotclear.msg.enhanced_uploader_disable',__('Temporarily disable enhanced uploader')). | 
|---|
| 834 | self::jsVar('dotclear.jsUpload.msg.limit_exceeded',__('Limit exceeded.')). | 
|---|
| 835 | self::jsVar('dotclear.jsUpload.msg.size_limit_exceeded',__('File size exceeds allowed limit.')). | 
|---|
| 836 | self::jsVar('dotclear.jsUpload.msg.canceled',__('Canceled.')). | 
|---|
| 837 | self::jsVar('dotclear.jsUpload.msg.http_error',__('HTTP Error:')). | 
|---|
| 838 | self::jsVar('dotclear.jsUpload.msg.error',__('Error:')). | 
|---|
| 839 | self::jsVar('dotclear.jsUpload.msg.choose_file',__('Choose file')). | 
|---|
| 840 | self::jsVar('dotclear.jsUpload.msg.choose_files',__('Choose files')). | 
|---|
| 841 | self::jsVar('dotclear.jsUpload.msg.cancel',__('Cancel')). | 
|---|
| 842 | self::jsVar('dotclear.jsUpload.msg.clean',__('Clean')). | 
|---|
| 843 | self::jsVar('dotclear.jsUpload.msg.upload',__('Upload')). | 
|---|
| 844 | self::jsVar('dotclear.jsUpload.msg.send',__('Send')). | 
|---|
| 845 | self::jsVar('dotclear.jsUpload.msg.file_successfully_uploaded',__('File successfully uploaded.')). | 
|---|
| 846 | self::jsVar('dotclear.jsUpload.msg.no_file_in_queue',__('No file in queue.')). | 
|---|
| 847 | self::jsVar('dotclear.jsUpload.msg.file_in_queue',__('1 file in queue.')). | 
|---|
| 848 | self::jsVar('dotclear.jsUpload.msg.files_in_queue',__('%d files in queue.')). | 
|---|
| 849 | self::jsVar('dotclear.jsUpload.msg.queue_error',__('Queue error:')). | 
|---|
| 850 | self::jsVar('dotclear.jsUpload.base_url',$base_url). | 
|---|
| 851 | "\n//]]>\n". | 
|---|
| 852 | "</script>\n". | 
|---|
| 853 |  | 
|---|
| 854 | self::jsLoad('js/jsUpload/vendor/jquery.ui.widget.js'). | 
|---|
| 855 | self::jsLoad('js/jsUpload/tmpl.js'). | 
|---|
| 856 | self::jsLoad('js/jsUpload/template-upload.js'). | 
|---|
| 857 | self::jsLoad('js/jsUpload/template-download.js'). | 
|---|
| 858 | self::jsLoad('js/jsUpload/load-image.js'). | 
|---|
| 859 | self::jsLoad('js/jsUpload/jquery.iframe-transport.js'). | 
|---|
| 860 | self::jsLoad('js/jsUpload/jquery.fileupload.js'). | 
|---|
| 861 | self::jsLoad('js/jsUpload/jquery.fileupload-process.js'). | 
|---|
| 862 | self::jsLoad('js/jsUpload/jquery.fileupload-resize.js'). | 
|---|
| 863 | self::jsLoad('js/jsUpload/jquery.fileupload-ui.js'); | 
|---|
| 864 | } | 
|---|
| 865 |  | 
|---|
| 866 | public static function jsToolMan() | 
|---|
| 867 | { | 
|---|
| 868 | return | 
|---|
| 869 | '<script type="text/javascript" src="js/tool-man/core.js"></script>'. | 
|---|
| 870 | '<script type="text/javascript" src="js/tool-man/events.js"></script>'. | 
|---|
| 871 | '<script type="text/javascript" src="js/tool-man/css.js"></script>'. | 
|---|
| 872 | '<script type="text/javascript" src="js/tool-man/coordinates.js"></script>'. | 
|---|
| 873 | '<script type="text/javascript" src="js/tool-man/drag.js"></script>'. | 
|---|
| 874 | '<script type="text/javascript" src="js/tool-man/dragsort.js"></script>'. | 
|---|
| 875 | '<script type="text/javascript" src="js/dragsort-tablerows.js"></script>'; | 
|---|
| 876 | } | 
|---|
| 877 |  | 
|---|
| 878 | public static function jsMetaEditor() | 
|---|
| 879 | { | 
|---|
| 880 | return | 
|---|
| 881 | '<script type="text/javascript" src="js/meta-editor.js"></script>'; | 
|---|
| 882 | } | 
|---|
| 883 | } | 
|---|
| 884 | ?> | 
|---|