Changeset 3709:c88e69474c34
- Timestamp:
- 02/18/18 18:16:29 (7 years ago)
- Branch:
- default
- Files:
-
- 12 added
- 9 deleted
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
inc/admin/lib.dc.page.php
r3685 r3709 10 10 # 11 11 # -- END LICENSE BLOCK ----------------------------------------- 12 if (!defined('DC_RC_PATH')) { return;}13 14 define('DC_AUTH_PAGE', 'auth.php');12 if (!defined('DC_RC_PATH')) {return;} 13 14 define('DC_AUTH_PAGE', 'auth.php'); 15 15 16 16 class dcPage 17 17 { 18 private static $loaded_js = array(); 19 private static $loaded_css = array(); 20 private static $xframe_loaded = false; 21 private static $N_TYPES = array( 22 "success" => "success", 23 "warning" => "warning-msg", 24 "error" => "error", 25 "message" => "message", 26 "static" => "static-msg"); 27 28 # Auth check 29 public static function check($permissions) 30 { 31 global $core; 32 33 if ($core->blog && $core->auth->check($permissions,$core->blog->id)) { 34 return; 35 } 36 37 if (session_id()) { 38 $core->session->destroy(); 39 } 40 http::redirect(DC_AUTH_PAGE); 41 } 42 43 # Check super admin 44 public static function checkSuper() 45 { 46 global $core; 47 48 if (!$core->auth->isSuperAdmin()) 49 { 50 if (session_id()) { 51 $core->session->destroy(); 52 } 53 http::redirect(DC_AUTH_PAGE); 54 } 55 } 56 57 # Top of admin page 58 public static function open($title='',$head='',$breadcrumb='',$options=array()) 59 { 60 global $core; 61 62 # List of user's blogs 63 if ($core->auth->getBlogCount() == 1 || $core->auth->getBlogCount() > 20) 64 { 65 $blog_box = 66 '<p>'.__('Blog:').' <strong title="'.html::escapeHTML($core->blog->url).'">'. 67 html::escapeHTML($core->blog->name).'</strong>'; 68 69 if ($core->auth->getBlogCount() > 20) { 70 $blog_box .= ' - <a href="'.$core->adminurl->get("admin.blogs").'">'.__('Change blog').'</a>'; 71 } 72 $blog_box .= '</p>'; 73 } 74 else 75 { 76 $rs_blogs = $core->getBlogs(array('order'=>'LOWER(blog_name)','limit'=>20)); 77 $blogs = array(); 78 while ($rs_blogs->fetch()) { 79 $blogs[html::escapeHTML($rs_blogs->blog_name.' - '.$rs_blogs->blog_url)] = $rs_blogs->blog_id; 80 } 81 $blog_box = 82 '<p><label for="switchblog" class="classic">'. 83 __('Blogs:').'</label> '. 84 $core->formNonce(). 85 form::combo('switchblog',$blogs,$core->blog->id). 86 '<input type="submit" value="'.__('ok').'" class="hidden-if-js" /></p>'; 87 } 88 89 $safe_mode = isset($_SESSION['sess_safe_mode']) && $_SESSION['sess_safe_mode']; 90 91 # Display 92 $headers = new ArrayObject(array()); 93 94 # Content-Type 95 $headers['content-type'] = 'Content-Type: text/html; charset=UTF-8'; 96 97 # Referrer Policy for admin pages 98 $headers['referrer'] = 'Referrer-Policy: strict-origin'; 99 100 # Prevents Clickjacking as far as possible 101 if (isset($options['x-frame-allow'])) { 102 self::setXFrameOptions($headers,$options['x-frame-allow']); 103 } else { 104 self::setXFrameOptions($headers); 105 } 106 107 # Content-Security-Policy (only if safe mode if not active, it may help) 108 if (!$safe_mode && $core->blog->settings->system->csp_admin_on) { 109 // Get directives from settings if exist, else set defaults 110 $csp = new ArrayObject(array()); 111 112 // SQlite Clearbricks driver does not allow using single quote at beginning or end of a field value 113 // so we have to use neutral values (localhost and 127.0.0.1) for some CSP directives 114 $csp_prefix = $core->con->driver() == 'sqlite' ? 'localhost ' : ''; // Hack for SQlite Clearbricks driver 115 $csp_suffix = $core->con->driver() == 'sqlite' ? ' 127.0.0.1' : ''; // Hack for SQlite Clearbricks driver 116 117 $csp['default-src'] = $core->blog->settings->system->csp_admin_default ?: 118 $csp_prefix."'self'".$csp_suffix; 119 $csp['script-src'] = $core->blog->settings->system->csp_admin_script ?: 120 $csp_prefix."'self' 'unsafe-inline' 'unsafe-eval'".$csp_suffix; 121 $csp['style-src'] = $core->blog->settings->system->csp_admin_style ?: 122 $csp_prefix."'self' 'unsafe-inline'".$csp_suffix; 123 $csp['img-src'] = $core->blog->settings->system->csp_admin_img ?: 124 $csp_prefix."'self' data: http://media.dotaddict.org blob:"; 125 126 # Cope with blog post preview (via public URL in iframe) 127 if (!is_null($core->blog->host)) { 128 $csp['default-src'] .= ' '.parse_url($core->blog->host,PHP_URL_HOST); 129 $csp['script-src'] .= ' '.parse_url($core->blog->host,PHP_URL_HOST); 130 $csp['style-src'] .= ' '.parse_url($core->blog->host,PHP_URL_HOST); 131 } 132 # Cope with media display in media manager (via public URL) 133 if (!is_null($core->media)) { 134 $csp['img-src'] .= ' '.parse_url($core->media->root_url,PHP_URL_HOST); 135 } 136 # Allow everything in iframe (used by editors to preview public content) 137 $csp['child-src'] = "*"; 138 139 # --BEHAVIOR-- adminPageHTTPHeaderCSP 140 $core->callBehavior('adminPageHTTPHeaderCSP',$csp); 141 142 // Construct CSP header 143 $directives = array(); 144 foreach ($csp as $key => $value) { 145 if ($value) { 146 $directives[] = $key.' '.$value; 147 } 148 } 149 if (count($directives)) { 150 if (version_compare(phpversion(),'5.4','>=')) { 151 // csp_report.php needs PHP ≥ 5.4 152 $directives[] = "report-uri ".DC_ADMIN_URL."csp_report.php"; 153 } 154 $report_only = ($core->blog->settings->system->csp_admin_report_only) ? '-Report-Only' : ''; 155 $headers['csp'] = "Content-Security-Policy".$report_only.": ".implode(" ; ",$directives); 156 } 157 } 158 159 # --BEHAVIOR-- adminPageHTTPHeaders 160 $core->callBehavior('adminPageHTTPHeaders',$headers); 161 foreach ($headers as $key => $value) { 162 header($value); 163 } 164 165 echo 166 '<!DOCTYPE html>'. 167 '<html lang="'.$core->auth->getInfo('user_lang').'">'."\n". 168 "<head>\n". 169 ' <meta charset="UTF-8" />'."\n". 170 ' <meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" />'."\n". 171 ' <meta name="GOOGLEBOT" content="NOSNIPPET" />'."\n". 172 ' <meta name="viewport" content="width=device-width, initial-scale=1.0" />'."\n". 173 ' <title>'.$title.' - '.html::escapeHTML($core->blog->name).' - '.html::escapeHTML(DC_VENDOR_NAME).' - '.DC_VERSION.'</title>'."\n". 174 175 176 self::cssLoad('style/default.css'); 177 if (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl') { 178 echo self::cssLoad('style/default-rtl.css'); 179 } 180 181 $core->auth->user_prefs->addWorkspace('interface'); 182 if (!$core->auth->user_prefs->interface->hide_std_favicon) { 183 echo 184 '<link rel="icon" type="image/png" href="images/favicon96-login.png" />'."\n". 185 '<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />'."\n"; 186 } 187 188 if ($core->auth->user_prefs->interface->htmlfontsize) { 189 echo 190 '<script type="text/javascript">'."\n". 191 self::jsVar('dotclear_htmlFontSize',$core->auth->user_prefs->interface->htmlfontsize)."\n". 192 "</script>\n"; 193 } 194 195 echo 196 self::jsCommon(). 197 self::jsToggles(). 198 $head; 199 200 if ($core->auth->user_prefs->interface->hidemoreinfo) { 201 echo 202 '<script type="text/javascript">'."\n". 203 'dotclear.hideMoreInfo = true;'."\n". 204 "</script>\n"; 205 } 206 if ($core->auth->user_prefs->interface->showajaxloader) { 207 echo 208 '<script type="text/javascript">'."\n". 209 'dotclear.showAjaxLoader = true;'."\n". 210 "</script>\n"; 211 } 212 213 # --BEHAVIOR-- adminPageHTMLHead 214 $core->callBehavior('adminPageHTMLHead'); 215 216 echo 217 "</head>\n". 218 '<body id="dotclear-admin'. 219 ($safe_mode ? ' safe-mode' : '').'" class="no-js'. 220 ($core->auth->user_prefs->interface->dynfontsize ? ' responsive-font' : '').'">'."\n". 221 222 '<ul id="prelude">'. 223 '<li><a href="#content">'.__('Go to the content').'</a></li>'. 224 '<li><a href="#main-menu">'.__('Go to the menu').'</a></li>'. 225 '<li><a href="#qx">'.__('Go to search').'</a></li>'. 226 '<li><a href="#help">'.__('Go to help').'</a></li>'. 227 '</ul>'."\n". 228 '<div id="header" role="banner">'. 229 '<h1><a href="'.$core->adminurl->get("admin.home").'"><span class="hidden">'.DC_VENDOR_NAME.'</span></a></h1>'."\n"; 230 231 echo 232 '<form action="'.$core->adminurl->get("admin.home").'" method="post" id="top-info-blog">'. 233 $blog_box. 234 '<p><a href="'.$core->blog->url.'" class="outgoing" title="'.__('Go to site'). 235 '">'.__('Go to site').'<img src="images/outgoing.png" alt="" /></a>'. 236 '</p></form>'. 237 '<ul id="top-info-user">'. 238 '<li><a class="'.(preg_match('/'.preg_quote($core->adminurl->get('admin.home')).'$/',$_SERVER['REQUEST_URI']) ? ' active' : '').'" href="'.$core->adminurl->get("admin.home").'">'.__('My dashboard').'</a></li>'. 239 '<li><a class="smallscreen'.(preg_match('/'.preg_quote($core->adminurl->get('admin.user.preferences')).'(\?.*)?$/',$_SERVER['REQUEST_URI']) ? ' active' : ''). 240 '" href="'.$core->adminurl->get("admin.user.preferences").'">'.__('My preferences').'</a></li>'. 241 '<li><a href="'.$core->adminurl->get("admin.home",array('logout' => 1)).'" class="logout"><span class="nomobile">'.sprintf(__('Logout %s'),$core->auth->userID()). 242 '</span><img src="images/logout.png" alt="" /></a></li>'. 243 '</ul>'. 244 '</div>'; // end header 245 246 echo 247 '<div id="wrapper" class="clearfix">'."\n". 248 '<div class="hidden-if-no-js collapser-box"><button type="button" id="collapser" class="void-btn">'. 249 '<img class="collapse-mm visually-hidden" src="images/collapser-hide.png" alt="'.__('Hide main menu').'" />'. 250 '<img class="expand-mm visually-hidden" src="images/collapser-show.png" alt="'.__('Show main menu').'" />'. 251 '</button></div>'. 252 '<div id="main" role="main">'."\n". 253 '<div id="content" class="clearfix">'."\n"; 254 255 # Safe mode 256 if ($safe_mode) 257 { 258 echo 259 '<div class="warning" role="alert"><h3>'.__('Safe mode').'</h3>'. 260 '<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>'. 261 '</div>'; 262 } 263 264 // Display breadcrumb (if given) before any error messages 265 echo $breadcrumb; 266 267 // Display notices and errors 268 echo self::notices(); 269 } 270 271 public static function notices() 272 { 273 global $core; 274 static $error_displayed = false; 275 276 $res = ''; 277 278 // return error messages if any 279 if ($core->error->flag() && !$error_displayed) { 280 281 # --BEHAVIOR-- adminPageNotificationError 282 $notice_error = $core->callBehavior('adminPageNotificationError',$core,$core->error); 283 284 if (isset($notice_error) && !empty($notice_error)) { 285 $res .= $notice_error; 286 } else { 287 $res .= '<div class="error"><p>'. 288 '<strong>'.(count($core->error->getErrors()) > 1 ? __('Errors:') : __('Error:')).'</strong>'. 289 '</p>'.$core->error->toHTML().'</div>'; 290 } 291 $error_displayed = true; 292 } 293 294 // return notices if any 295 if (isset($_SESSION['notifications'])) { 296 foreach ($_SESSION['notifications'] as $notification) { 297 298 # --BEHAVIOR-- adminPageNotification 299 $notice = $core->callBehavior('adminPageNotification',$core,$notification); 300 301 $res .= (isset($notice) && !empty($notice) ? $notice : self::getNotification($notification)); 302 } 303 unset($_SESSION['notifications']); 304 } 305 return $res; 306 } 307 308 public static function addNotice($type,$message,$options=array()) 309 { 310 if (isset(self::$N_TYPES[$type])){ 311 $class = self::$N_TYPES[$type]; 312 } else { 313 $class=$type; 314 } 315 if (isset($_SESSION['notifications']) && is_array($_SESSION['notifications'])) { 316 $notifications = $_SESSION['notifications']; 317 } else { 318 $notifications = array(); 319 } 320 321 $n = array_merge($options,array('class' => $class,'ts' => time(), 'text' => $message)); 322 if ($type != "static") { 323 $notifications[] = $n; 324 } else { 325 array_unshift($notifications, $n); 326 } 327 $_SESSION['notifications'] = $notifications; 328 } 329 330 public static function addSuccessNotice($message,$options=array()) 331 { 332 self::addNotice("success",$message,$options); 333 } 334 335 public static function addWarningNotice($message,$options=array()) 336 { 337 self::addNotice("warning",$message,$options); 338 } 339 340 public static function addErrorNotice($message,$options=array()) 341 { 342 self::addNotice("error",$message,$options); 343 } 344 345 protected static function getNotification($n) 346 { 347 global $core; 348 $tag = (isset($n['divtag']) && $n['divtag']) ? 'div' : 'p'; 349 $ts = ''; 350 if (!isset($n['with_ts']) || ($n['with_ts'] == true)) { 351 $ts = dt::str(__('[%H:%M:%S]'),$n['ts'],$core->auth->getInfo('user_tz')).' '; 352 } 353 $res = '<'.$tag.' class="'.$n['class'].'" role="alert">'.$ts.$n['text'].'</'.$tag.'>'; 354 return $res; 355 } 356 357 public static function close() 358 { 359 global $core; 360 361 if (!$GLOBALS['__resources']['ctxhelp']) { 362 if (!$core->auth->user_prefs->interface->hidehelpbutton) { 363 echo 364 '<p id="help-button"><a href="'.$core->adminurl->get("admin.help").'" class="outgoing" title="'. 365 __('Global help').'">'.__('Global help').'</a></p>'; 366 } 367 } 368 369 $menu =& $GLOBALS['_menu']; 370 371 echo 372 "</div>\n". // End of #content 373 "</div>\n". // End of #main 374 375 '<div id="main-menu" role="navigation">'."\n". 376 377 '<form id="search-menu" action="'.$core->adminurl->get("admin.search").'" method="get" role="search">'. 378 '<p><label for="qx" class="hidden">'.__('Search:').' </label>'.form::field('qx',30,255,''). 379 '<input type="submit" value="'.__('OK').'" /></p>'. 380 '</form>'; 381 382 foreach ($menu as $k => $v) { 383 echo $menu[$k]->draw(); 384 } 385 386 $text = sprintf(__('Thank you for using %s.'),'Dotclear '.DC_VERSION); 387 388 # --BEHAVIOR-- adminPageFooter 389 $textAlt = $core->callBehavior('adminPageFooter',$core,$text); 390 if ($textAlt != '') { 391 $text = $textAlt; 392 } 393 $text = html::escapeHTML($text); 394 395 echo 396 '</div>'."\n". // End of #main-menu 397 "</div>\n"; // End of #wrapper 398 399 echo '<p id="gototop"><a href="#wrapper">'.__('Page top').'</a></p>'."\n"; 400 401 $figure = " 18 private static $loaded_js = array(); 19 private static $loaded_css = array(); 20 private static $xframe_loaded = false; 21 private static $N_TYPES = array( 22 "success" => "success", 23 "warning" => "warning-msg", 24 "error" => "error", 25 "message" => "message", 26 "static" => "static-msg"); 27 28 # Auth check 29 public static function check($permissions) 30 { 31 global $core; 32 33 if ($core->blog && $core->auth->check($permissions, $core->blog->id)) { 34 return; 35 } 36 37 if (session_id()) { 38 $core->session->destroy(); 39 } 40 http::redirect(DC_AUTH_PAGE); 41 } 42 43 # Check super admin 44 public static function checkSuper() 45 { 46 global $core; 47 48 if (!$core->auth->isSuperAdmin()) { 49 if (session_id()) { 50 $core->session->destroy(); 51 } 52 http::redirect(DC_AUTH_PAGE); 53 } 54 } 55 56 # Top of admin page 57 public static function open($title = '', $head = '', $breadcrumb = '', $options = array()) 58 { 59 global $core; 60 61 # List of user's blogs 62 if ($core->auth->getBlogCount() == 1 || $core->auth->getBlogCount() > 20) { 63 $blog_box = 64 '<p>' . __('Blog:') . ' <strong title="' . html::escapeHTML($core->blog->url) . '">' . 65 html::escapeHTML($core->blog->name) . '</strong>'; 66 67 if ($core->auth->getBlogCount() > 20) { 68 $blog_box .= ' - <a href="' . $core->adminurl->get("admin.blogs") . '">' . __('Change blog') . '</a>'; 69 } 70 $blog_box .= '</p>'; 71 } else { 72 $rs_blogs = $core->getBlogs(array('order' => 'LOWER(blog_name)', 'limit' => 20)); 73 $blogs = array(); 74 while ($rs_blogs->fetch()) { 75 $blogs[html::escapeHTML($rs_blogs->blog_name . ' - ' . $rs_blogs->blog_url)] = $rs_blogs->blog_id; 76 } 77 $blog_box = 78 '<p><label for="switchblog" class="classic">' . 79 __('Blogs:') . '</label> ' . 80 $core->formNonce() . 81 form::combo('switchblog', $blogs, $core->blog->id) . 82 '<input type="submit" value="' . __('ok') . '" class="hidden-if-js" /></p>'; 83 } 84 85 $safe_mode = isset($_SESSION['sess_safe_mode']) && $_SESSION['sess_safe_mode']; 86 87 # Display 88 $headers = new ArrayObject(array()); 89 90 # Content-Type 91 $headers['content-type'] = 'Content-Type: text/html; charset=UTF-8'; 92 93 # Referrer Policy for admin pages 94 $headers['referrer'] = 'Referrer-Policy: strict-origin'; 95 96 # Prevents Clickjacking as far as possible 97 if (isset($options['x-frame-allow'])) { 98 self::setXFrameOptions($headers, $options['x-frame-allow']); 99 } else { 100 self::setXFrameOptions($headers); 101 } 102 103 # Content-Security-Policy (only if safe mode if not active, it may help) 104 if (!$safe_mode && $core->blog->settings->system->csp_admin_on) { 105 // Get directives from settings if exist, else set defaults 106 $csp = new ArrayObject(array()); 107 108 // SQlite Clearbricks driver does not allow using single quote at beginning or end of a field value 109 // so we have to use neutral values (localhost and 127.0.0.1) for some CSP directives 110 $csp_prefix = $core->con->driver() == 'sqlite' ? 'localhost ' : ''; // Hack for SQlite Clearbricks driver 111 $csp_suffix = $core->con->driver() == 'sqlite' ? ' 127.0.0.1' : ''; // Hack for SQlite Clearbricks driver 112 113 $csp['default-src'] = $core->blog->settings->system->csp_admin_default ?: 114 $csp_prefix . "'self'" . $csp_suffix; 115 $csp['script-src'] = $core->blog->settings->system->csp_admin_script ?: 116 $csp_prefix . "'self' 'unsafe-inline' 'unsafe-eval'" . $csp_suffix; 117 $csp['style-src'] = $core->blog->settings->system->csp_admin_style ?: 118 $csp_prefix . "'self' 'unsafe-inline'" . $csp_suffix; 119 $csp['img-src'] = $core->blog->settings->system->csp_admin_img ?: 120 $csp_prefix . "'self' data: http://media.dotaddict.org blob:"; 121 122 # Cope with blog post preview (via public URL in iframe) 123 if (!is_null($core->blog->host)) { 124 $csp['default-src'] .= ' ' . parse_url($core->blog->host, PHP_URL_HOST); 125 $csp['script-src'] .= ' ' . parse_url($core->blog->host, PHP_URL_HOST); 126 $csp['style-src'] .= ' ' . parse_url($core->blog->host, PHP_URL_HOST); 127 } 128 # Cope with media display in media manager (via public URL) 129 if (!is_null($core->media)) { 130 $csp['img-src'] .= ' ' . parse_url($core->media->root_url, PHP_URL_HOST); 131 } 132 # Allow everything in iframe (used by editors to preview public content) 133 $csp['child-src'] = "*"; 134 135 # --BEHAVIOR-- adminPageHTTPHeaderCSP 136 $core->callBehavior('adminPageHTTPHeaderCSP', $csp); 137 138 // Construct CSP header 139 $directives = array(); 140 foreach ($csp as $key => $value) { 141 if ($value) { 142 $directives[] = $key . ' ' . $value; 143 } 144 } 145 if (count($directives)) { 146 if (version_compare(phpversion(), '5.4', '>=')) { 147 // csp_report.php needs PHP ≥ 5.4 148 $directives[] = "report-uri " . DC_ADMIN_URL . "csp_report.php"; 149 } 150 $report_only = ($core->blog->settings->system->csp_admin_report_only) ? '-Report-Only' : ''; 151 $headers['csp'] = "Content-Security-Policy" . $report_only . ": " . implode(" ; ", $directives); 152 } 153 } 154 155 # --BEHAVIOR-- adminPageHTTPHeaders 156 $core->callBehavior('adminPageHTTPHeaders', $headers); 157 foreach ($headers as $key => $value) { 158 header($value); 159 } 160 161 echo 162 '<!DOCTYPE html>' . 163 '<html lang="' . $core->auth->getInfo('user_lang') . '">' . "\n" . 164 "<head>\n" . 165 ' <meta charset="UTF-8" />' . "\n" . 166 ' <meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" />' . "\n" . 167 ' <meta name="GOOGLEBOT" content="NOSNIPPET" />' . "\n" . 168 ' <meta name="viewport" content="width=device-width, initial-scale=1.0" />' . "\n" . 169 ' <title>' . $title . ' - ' . html::escapeHTML($core->blog->name) . ' - ' . html::escapeHTML(DC_VENDOR_NAME) . ' - ' . DC_VERSION . '</title>' . "\n" . 170 171 self::cssLoad('style/default.css'); 172 if (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl') { 173 echo self::cssLoad('style/default-rtl.css'); 174 } 175 176 $core->auth->user_prefs->addWorkspace('interface'); 177 if (!$core->auth->user_prefs->interface->hide_std_favicon) { 178 echo 179 '<link rel="icon" type="image/png" href="images/favicon96-login.png" />' . "\n" . 180 '<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />' . "\n"; 181 } 182 183 if ($core->auth->user_prefs->interface->htmlfontsize) { 184 echo 185 '<script type="text/javascript">' . "\n" . 186 self::jsVar('dotclear_htmlFontSize', $core->auth->user_prefs->interface->htmlfontsize) . "\n" . 187 "</script>\n"; 188 } 189 190 echo 191 self::jsCommon() . 192 self::jsToggles() . 193 $head; 194 195 if ($core->auth->user_prefs->interface->hidemoreinfo) { 196 echo 197 '<script type="text/javascript">' . "\n" . 198 'dotclear.hideMoreInfo = true;' . "\n" . 199 "</script>\n"; 200 } 201 if ($core->auth->user_prefs->interface->showajaxloader) { 202 echo 203 '<script type="text/javascript">' . "\n" . 204 'dotclear.showAjaxLoader = true;' . "\n" . 205 "</script>\n"; 206 } 207 208 # --BEHAVIOR-- adminPageHTMLHead 209 $core->callBehavior('adminPageHTMLHead'); 210 211 echo 212 "</head>\n" . 213 '<body id="dotclear-admin' . 214 ($safe_mode ? ' safe-mode' : '') . '" class="no-js' . 215 ($core->auth->user_prefs->interface->dynfontsize ? ' responsive-font' : '') . '">' . "\n" . 216 217 '<ul id="prelude">' . 218 '<li><a href="#content">' . __('Go to the content') . '</a></li>' . 219 '<li><a href="#main-menu">' . __('Go to the menu') . '</a></li>' . 220 '<li><a href="#qx">' . __('Go to search') . '</a></li>' . 221 '<li><a href="#help">' . __('Go to help') . '</a></li>' . 222 '</ul>' . "\n" . 223 '<div id="header" role="banner">' . 224 '<h1><a href="' . $core->adminurl->get("admin.home") . '"><span class="hidden">' . DC_VENDOR_NAME . '</span></a></h1>' . "\n"; 225 226 echo 227 '<form action="' . $core->adminurl->get("admin.home") . '" method="post" id="top-info-blog">' . 228 $blog_box . 229 '<p><a href="' . $core->blog->url . '" class="outgoing" title="' . __('Go to site') . 230 '">' . __('Go to site') . '<img src="images/outgoing.png" alt="" /></a>' . 231 '</p></form>' . 232 '<ul id="top-info-user">' . 233 '<li><a class="' . (preg_match('/' . preg_quote($core->adminurl->get('admin.home')) . '$/', $_SERVER['REQUEST_URI']) ? ' active' : '') . '" href="' . $core->adminurl->get("admin.home") . '">' . __('My dashboard') . '</a></li>' . 234 '<li><a class="smallscreen' . (preg_match('/' . preg_quote($core->adminurl->get('admin.user.preferences')) . '(\?.*)?$/', $_SERVER['REQUEST_URI']) ? ' active' : '') . 235 '" href="' . $core->adminurl->get("admin.user.preferences") . '">' . __('My preferences') . '</a></li>' . 236 '<li><a href="' . $core->adminurl->get("admin.home", array('logout' => 1)) . '" class="logout"><span class="nomobile">' . sprintf(__('Logout %s'), $core->auth->userID()) . 237 '</span><img src="images/logout.png" alt="" /></a></li>' . 238 '</ul>' . 239 '</div>'; // end header 240 241 echo 242 '<div id="wrapper" class="clearfix">' . "\n" . 243 '<div class="hidden-if-no-js collapser-box"><button type="button" id="collapser" class="void-btn">' . 244 '<img class="collapse-mm visually-hidden" src="images/collapser-hide.png" alt="' . __('Hide main menu') . '" />' . 245 '<img class="expand-mm visually-hidden" src="images/collapser-show.png" alt="' . __('Show main menu') . '" />' . 246 '</button></div>' . 247 '<div id="main" role="main">' . "\n" . 248 '<div id="content" class="clearfix">' . "\n"; 249 250 # Safe mode 251 if ($safe_mode) { 252 echo 253 '<div class="warning" role="alert"><h3>' . __('Safe mode') . '</h3>' . 254 '<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>' . 255 '</div>'; 256 } 257 258 // Display breadcrumb (if given) before any error messages 259 echo $breadcrumb; 260 261 // Display notices and errors 262 echo self::notices(); 263 } 264 265 public static function notices() 266 { 267 global $core; 268 static $error_displayed = false; 269 270 $res = ''; 271 272 // return error messages if any 273 if ($core->error->flag() && !$error_displayed) { 274 275 # --BEHAVIOR-- adminPageNotificationError 276 $notice_error = $core->callBehavior('adminPageNotificationError', $core, $core->error); 277 278 if (isset($notice_error) && !empty($notice_error)) { 279 $res .= $notice_error; 280 } else { 281 $res .= '<div class="error"><p>' . 282 '<strong>' . (count($core->error->getErrors()) > 1 ? __('Errors:') : __('Error:')) . '</strong>' . 283 '</p>' . $core->error->toHTML() . '</div>'; 284 } 285 $error_displayed = true; 286 } 287 288 // return notices if any 289 if (isset($_SESSION['notifications'])) { 290 foreach ($_SESSION['notifications'] as $notification) { 291 292 # --BEHAVIOR-- adminPageNotification 293 $notice = $core->callBehavior('adminPageNotification', $core, $notification); 294 295 $res .= (isset($notice) && !empty($notice) ? $notice : self::getNotification($notification)); 296 } 297 unset($_SESSION['notifications']); 298 } 299 return $res; 300 } 301 302 public static function addNotice($type, $message, $options = array()) 303 { 304 if (isset(self::$N_TYPES[$type])) { 305 $class = self::$N_TYPES[$type]; 306 } else { 307 $class = $type; 308 } 309 if (isset($_SESSION['notifications']) && is_array($_SESSION['notifications'])) { 310 $notifications = $_SESSION['notifications']; 311 } else { 312 $notifications = array(); 313 } 314 315 $n = array_merge($options, array('class' => $class, 'ts' => time(), 'text' => $message)); 316 if ($type != "static") { 317 $notifications[] = $n; 318 } else { 319 array_unshift($notifications, $n); 320 } 321 $_SESSION['notifications'] = $notifications; 322 } 323 324 public static function addSuccessNotice($message, $options = array()) 325 { 326 self::addNotice("success", $message, $options); 327 } 328 329 public static function addWarningNotice($message, $options = array()) 330 { 331 self::addNotice("warning", $message, $options); 332 } 333 334 public static function addErrorNotice($message, $options = array()) 335 { 336 self::addNotice("error", $message, $options); 337 } 338 339 protected static function getNotification($n) 340 { 341 global $core; 342 $tag = (isset($n['divtag']) && $n['divtag']) ? 'div' : 'p'; 343 $ts = ''; 344 if (!isset($n['with_ts']) || ($n['with_ts'] == true)) { 345 $ts = dt::str(__('[%H:%M:%S]'), $n['ts'], $core->auth->getInfo('user_tz')) . ' '; 346 } 347 $res = '<' . $tag . ' class="' . $n['class'] . '" role="alert">' . $ts . $n['text'] . '</' . $tag . '>'; 348 return $res; 349 } 350 351 public static function close() 352 { 353 global $core; 354 355 if (!$GLOBALS['__resources']['ctxhelp']) { 356 if (!$core->auth->user_prefs->interface->hidehelpbutton) { 357 echo 358 '<p id="help-button"><a href="' . $core->adminurl->get("admin.help") . '" class="outgoing" title="' . 359 __('Global help') . '">' . __('Global help') . '</a></p>'; 360 } 361 } 362 363 $menu = &$GLOBALS['_menu']; 364 365 echo 366 "</div>\n" . // End of #content 367 "</div>\n" . // End of #main 368 369 '<div id="main-menu" role="navigation">' . "\n" . 370 371 '<form id="search-menu" action="' . $core->adminurl->get("admin.search") . '" method="get" role="search">' . 372 '<p><label for="qx" class="hidden">' . __('Search:') . ' </label>' . form::field('qx', 30, 255, '') . 373 '<input type="submit" value="' . __('OK') . '" /></p>' . 374 '</form>'; 375 376 foreach ($menu as $k => $v) { 377 echo $menu[$k]->draw(); 378 } 379 380 $text = sprintf(__('Thank you for using %s.'), 'Dotclear ' . DC_VERSION); 381 382 # --BEHAVIOR-- adminPageFooter 383 $textAlt = $core->callBehavior('adminPageFooter', $core, $text); 384 if ($textAlt != '') { 385 $text = $textAlt; 386 } 387 $text = html::escapeHTML($text); 388 389 echo 390 '</div>' . "\n" . // End of #main-menu 391 "</div>\n"; // End of #wrapper 392 393 echo '<p id="gototop"><a href="#wrapper">' . __('Page top') . '</a></p>' . "\n"; 394 395 $figure = " 402 396 /\_/\ 403 397 (='.'=) 404 398 (\")-(\")"; 405 399 406 echo 407 '<div id="footer" role="contentinfo">'. 408 '<a href="http://dotclear.org/" title="'.$text.'">'. 409 '<img src="style/dc_logos/w-dotclear90.png" alt="'.$text.'" /></a></div>'."\n". 410 "<!-- "."\n". 411 $figure. 412 " -->"."\n"; 413 414 if (defined('DC_DEV') && DC_DEV === true) { 415 echo self::debugInfo(); 416 } 417 418 echo 419 '</body></html>'; 420 } 421 422 public static function openPopup($title='',$head='',$breadcrumb='') 423 { 424 global $core; 425 426 # Display 427 header('Content-Type: text/html; charset=UTF-8'); 428 429 # Referrer Policy for admin pages 430 header('Referrer-Policy: strict-origin'); 431 432 # Prevents Clickjacking as far as possible 433 header('X-Frame-Options: SAMEORIGIN'); // FF 3.6.9+ Chrome 4.1+ IE 8+ Safari 4+ Opera 10.5+ 434 435 echo 436 '<!DOCTYPE html>'. 437 '<html lang="'.$core->auth->getInfo('user_lang').'">'."\n". 438 "<head>\n". 439 ' <meta charset="UTF-8" />'."\n". 440 ' <meta name="viewport" content="width=device-width, initial-scale=1.0" />'."\n". 441 ' <title>'.$title.' - '.html::escapeHTML($core->blog->name).' - '.html::escapeHTML(DC_VENDOR_NAME).' - '.DC_VERSION.'</title>'."\n". 442 443 ' <meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" />'."\n". 444 ' <meta name="GOOGLEBOT" content="NOSNIPPET" />'."\n". 445 446 self::cssLoad('style/default.css'); 447 if (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl') { 448 echo self::cssLoad('style/default-rtl.css'); 449 } 450 451 $core->auth->user_prefs->addWorkspace('interface'); 452 if ($core->auth->user_prefs->interface->htmlfontsize) { 453 echo 454 '<script type="text/javascript">'."\n". 455 self::jsVar('dotclear_htmlFontSize',$core->auth->user_prefs->interface->htmlfontsize)."\n". 456 "</script>\n"; 457 } 458 459 echo 460 self::jsCommon(). 461 self::jsToggles(). 462 $head; 463 464 if ($core->auth->user_prefs->interface->hidemoreinfo) { 465 echo 466 '<script type="text/javascript">'."\n". 467 'dotclear.hideMoreInfo = true;'."\n". 468 "</script>\n"; 469 } 470 if ($core->auth->user_prefs->interface->showajaxloader) { 471 echo 472 '<script type="text/javascript">'."\n". 473 'dotclear.showAjaxLoader = true;'."\n". 474 "</script>\n"; 475 } 476 477 # --BEHAVIOR-- adminPageHTMLHead 478 $core->callBehavior('adminPageHTMLHead'); 479 480 echo 481 "</head>\n". 482 '<body id="dotclear-admin" class="popup'. 483 ($core->auth->user_prefs->interface->dynfontsize ? ' responsive-font' : '').'">'."\n". 484 485 '<h1>'.DC_VENDOR_NAME.'</h1>'."\n"; 486 487 echo 488 '<div id="wrapper">'."\n". 489 '<div id="main" role="main">'."\n". 490 '<div id="content">'."\n"; 491 492 // display breadcrumb if given 493 echo $breadcrumb; 494 495 // Display notices and errors 496 echo self::notices(); 497 } 498 499 public static function closePopup() 500 { 501 echo 502 "</div>\n". // End of #content 503 "</div>\n". // End of #main 504 "</div>\n". // End of #wrapper 505 506 '<p id="gototop"><a href="#wrapper">'.__('Page top').'</a></p>'."\n". 507 508 '<div id="footer" role="contentinfo"><p> </p></div>'."\n". 509 '</body></html>'; 510 } 511 512 public static function breadcrumb($elements=null,$options=array()) 513 { 514 global $core; 515 $with_home_link = isset($options['home_link']) ? $options['home_link'] : true; 516 $hl = isset($options['hl']) ? $options['hl'] : true; 517 $hl_pos = isset($options['hl_pos']) ? $options['hl_pos'] : -1; 518 // First item of array elements should be blog's name, System or Plugins 519 $res = '<h2>'.($with_home_link ? 520 '<a class="go_home" href="'.$core->adminurl->get("admin.home").'"><img src="style/dashboard.png" alt="'.__('Go to dashboard').'" /></a>' : 521 '<img src="style/dashboard-alt.png" alt="" />'); 522 $index = 0; 523 if ($hl_pos < 0) { 524 $hl_pos = count($elements)+$hl_pos; 525 } 526 foreach ($elements as $element => $url) { 527 if ($hl && $index == $hl_pos) { 528 $element = sprintf('<span class="page-title">%s</span>',$element); 529 } 530 $res .= ($with_home_link ? ($index == 1 ? ' : ' : ' › ') : ($index == 0 ? ' ' : ' › ')). 531 ($url ? '<a href="'.$url.'">' : '').$element.($url ? '</a>' : ''); 532 $index++; 533 } 534 $res .= '</h2>'; 535 return $res; 536 } 537 538 public static function message($msg,$timestamp=true,$div=false,$echo=true,$class='message') 539 { 540 global $core; 541 542 $res = ''; 543 if ($msg != '') { 544 $res = ($div ? '<div class="'.$class.'">' : '').'<p'.($div ? '' : ' class="'.$class.'"').'>'. 545 ($timestamp ? dt::str(__('[%H:%M:%S]'),null,$core->auth->getInfo('user_tz')).' ' : '').$msg. 546 '</p>'.($div ? '</div>' : ''); 547 if ($echo) { 548 echo $res; 549 } 550 } 551 return $res; 552 } 553 554 public static function success($msg,$timestamp=true,$div=false,$echo=true) 555 { 556 return self::message($msg,$timestamp,$div,$echo,"success"); 557 } 558 559 public static function warning($msg,$timestamp=true,$div=false,$echo=true) 560 { 561 return self::message($msg,$timestamp,$div,$echo,"warning-msg"); 562 } 563 564 private static function debugInfo() 565 { 566 $global_vars = implode(', ',array_keys($GLOBALS)); 567 568 $res = 569 '<div id="debug"><div>'. 570 '<p>memory usage: '.memory_get_usage().' ('.files::size(memory_get_usage()).')</p>'; 571 572 if (function_exists('xdebug_get_profiler_filename')) 573 { 574 $res .= '<p>Elapsed time: '.xdebug_time_index().' seconds</p>'; 575 576 $prof_file = xdebug_get_profiler_filename(); 577 if ($prof_file) { 578 $res .= '<p>Profiler file : '.xdebug_get_profiler_filename().'</p>'; 579 } else { 580 $prof_url = http::getSelfURI(); 581 $prof_url .= (strpos($prof_url,'?') === false) ? '?' : '&'; 582 $prof_url .= 'XDEBUG_PROFILE'; 583 $res .= '<p><a href="'.html::escapeURL($prof_url).'">Trigger profiler</a></p>'; 584 } 585 586 /* xdebug configuration: 587 zend_extension = /.../xdebug.so 588 xdebug.auto_trace = On 589 xdebug.trace_format = 0 590 xdebug.trace_options = 1 591 xdebug.show_mem_delta = On 592 xdebug.profiler_enable = 0 593 xdebug.profiler_enable_trigger = 1 594 xdebug.profiler_output_dir = /tmp 595 xdebug.profiler_append = 0 596 xdebug.profiler_output_name = timestamp 597 */ 598 } 599 600 $res .= 601 '<p>Global vars: '.$global_vars.'</p>'. 602 '</div></div>'; 603 604 return $res; 605 } 606 607 public static function help($page,$index='') 608 { 609 # Deprecated but we keep this for plugins. 610 } 611 612 public static function helpBlock() 613 { 614 global $core; 615 616 if ($core->auth->user_prefs->interface->hidehelpbutton) { 617 return; 618 } 619 620 $args = func_get_args(); 621 $args = new ArrayObject($args); 622 623 # --BEHAVIOR-- adminPageHelpBlock 624 $GLOBALS['core']->callBehavior('adminPageHelpBlock',$args); 625 626 if (empty($args)) { 627 return; 628 }; 629 630 global $__resources; 631 if (empty($__resources['help'])) { 632 return; 633 } 634 635 $content = ''; 636 foreach ($args as $v) 637 { 638 if (is_object($v) && isset($v->content)) { 639 $content .= $v->content; 640 continue; 641 } 642 643 if (!isset($__resources['help'][$v])) { 644 continue; 645 } 646 $f = $__resources['help'][$v]; 647 if (!file_exists($f) || !is_readable($f)) { 648 continue; 649 } 650 651 $fc = file_get_contents($f); 652 if (preg_match('|<body[^>]*?>(.*?)</body>|ms',$fc,$matches)) { 653 $content .= $matches[1]; 654 } else { 655 $content .= $fc; 656 } 657 } 658 659 if (trim($content) == '') { 660 return; 661 } 662 663 // Set contextual help global flag 664 $GLOBALS['__resources']['ctxhelp'] = true; 665 666 echo 667 '<div id="help"><hr /><div class="help-content clear"><h3>'.__('Help about this page').'</h3>'. 668 $content. 669 '</div>'. 670 '<div id="helplink"><hr />'. 671 '<p>'. 672 sprintf(__('See also %s'),sprintf('<a href="'.$core->adminurl->get("admin.help").'">%s</a>',__('the global help'))). 673 '.</p>'. 674 '</div></div>'; 675 } 676 677 public static function cssLoad($src,$media='screen',$v='') 678 { 679 $escaped_src = html::escapeHTML($src); 680 if (!isset(self::$loaded_css[$escaped_src])) { 681 self::$loaded_css[$escaped_src] = true; 682 $escaped_src = self::appendVersion($escaped_src,$v); 683 684 return '<link rel="stylesheet" href="'.$escaped_src.'" type="text/css" media="'.$media.'" />'."\n"; 685 } 686 } 687 688 public static function jsLoad($src,$v='') 689 { 690 $escaped_src = html::escapeHTML($src); 691 if (!isset(self::$loaded_js[$escaped_src])) { 692 self::$loaded_js[$escaped_src] = true; 693 $escaped_src = self::appendVersion($escaped_src,$v); 694 return '<script type="text/javascript" src="'.$escaped_src.'"></script>'."\n"; 695 } 696 } 697 698 private static function appendVersion($src,$v='') 699 { 700 $src .= (strpos($src,'?') === false ? '?' : '&').'v='; 701 if (defined('DC_DEV') && DC_DEV === true) { 702 $src .= md5(uniqid()); 703 } else { 704 $src .= ($v === '' ? DC_VERSION : $v); 705 } 706 return $src; 707 } 708 709 public static function jsVar($n,$v) 710 { 711 return $n." = '".html::escapeJS($v)."';\n"; 712 } 713 714 public static function jsToggles() 715 { 716 if($GLOBALS['core']->auth->user_prefs->toggles) { 717 $unfolded_sections = explode(',',$GLOBALS['core']->auth->user_prefs->toggles->unfolded_sections); 718 foreach ($unfolded_sections as $k=>&$v) { 719 if ($v == '') { 720 unset($unfolded_sections[$k]); 721 } else { 722 $v = "'".html::escapeJS($v)."':true"; 723 } 724 } 725 } else { 726 $unfolded_sections=array(); 727 } 728 return '<script type="text/javascript">'."\n". 729 'dotclear.unfolded_sections = {'.join(",",$unfolded_sections)."};\n". 730 "</script>\n"; 731 } 732 733 public static function jsCommon() 734 { 735 $mute_or_no = ''; 736 if (empty($GLOBALS['core']->blog) || $GLOBALS['core']->blog->settings->system->jquery_migrate_mute) { 737 $mute_or_no .= 738 '<script type="text/javascript">'."\n". 739 'jQuery.migrateMute = true;'."\n". 740 "</script>\n"; 741 } 742 743 return 744 self::jsLoad('js/jquery/jquery.js'). 745 $mute_or_no. 746 self::jsLoad('js/jquery/jquery-migrate.js'). 747 self::jsLoad('js/jquery/jquery.biscuit.js'). 748 self::jsLoad('js/common.js'). 749 self::jsLoad('js/prelude.js'). 750 751 '<script type="text/javascript">'."\n". 752 'jsToolBar = {}, jsToolBar.prototype = { elements : {} };'."\n". 753 754 self::jsVar('dotclear.nonce',$GLOBALS['core']->getNonce()). 755 756 self::jsVar('dotclear.img_plus_src','images/expand.png'). 757 self::jsVar('dotclear.img_plus_alt',__('uncover')). 758 self::jsVar('dotclear.img_minus_src','images/hide.png'). 759 self::jsVar('dotclear.img_minus_alt',__('hide')). 760 self::jsVar('dotclear.img_menu_on','images/menu_on.png'). 761 self::jsVar('dotclear.img_menu_off','images/menu_off.png'). 762 763 self::jsVar('dotclear.img_plus_theme_src','images/plus-theme.png'). 764 self::jsVar('dotclear.img_plus_theme_alt',__('uncover')). 765 self::jsVar('dotclear.img_minus_theme_src','images/minus-theme.png'). 766 self::jsVar('dotclear.img_minus_theme_alt',__('hide')). 767 768 self::jsVar('dotclear.msg.help', 769 __('Need help?')). 770 self::jsVar('dotclear.msg.new_window', 771 __('new window')). 772 self::jsVar('dotclear.msg.help_hide', 773 __('Hide')). 774 self::jsVar('dotclear.msg.to_select', 775 __('Select:')). 776 self::jsVar('dotclear.msg.no_selection', 777 __('no selection')). 778 self::jsVar('dotclear.msg.select_all', 779 __('select all')). 780 self::jsVar('dotclear.msg.invert_sel', 781 __('Invert selection')). 782 self::jsVar('dotclear.msg.website', 783 __('Web site:')). 784 self::jsVar('dotclear.msg.email', 785 __('Email:')). 786 self::jsVar('dotclear.msg.ip_address', 787 __('IP address:')). 788 self::jsVar('dotclear.msg.error', 789 __('Error:')). 790 self::jsVar('dotclear.msg.entry_created', 791 __('Entry has been successfully created.')). 792 self::jsVar('dotclear.msg.edit_entry', 793 __('Edit entry')). 794 self::jsVar('dotclear.msg.view_entry', 795 __('view entry')). 796 self::jsVar('dotclear.msg.confirm_delete_posts', 797 __("Are you sure you want to delete selected entries (%s)?")). 798 self::jsVar('dotclear.msg.confirm_delete_medias', 799 __("Are you sure you want to delete selected medias (%d)?")). 800 self::jsVar('dotclear.msg.confirm_delete_categories', 801 __("Are you sure you want to delete selected categories (%s)?")). 802 self::jsVar('dotclear.msg.confirm_delete_post', 803 __("Are you sure you want to delete this entry?")). 804 self::jsVar('dotclear.msg.click_to_unlock', 805 __("Click here to unlock the field")). 806 self::jsVar('dotclear.msg.confirm_spam_delete', 807 __('Are you sure you want to delete all spams?')). 808 self::jsVar('dotclear.msg.confirm_delete_comments', 809 __('Are you sure you want to delete selected comments (%s)?')). 810 self::jsVar('dotclear.msg.confirm_delete_comment', 811 __('Are you sure you want to delete this comment?')). 812 self::jsVar('dotclear.msg.cannot_delete_users', 813 __('Users with posts cannot be deleted.')). 814 self::jsVar('dotclear.msg.confirm_delete_user', 815 __('Are you sure you want to delete selected users (%s)?')). 816 self::jsVar('dotclear.msg.confirm_delete_blog', 817 __('Are you sure you want to delete selected blogs (%s)?')). 818 self::jsVar('dotclear.msg.confirm_delete_category', 819 __('Are you sure you want to delete category "%s"?')). 820 self::jsVar('dotclear.msg.confirm_reorder_categories', 821 __('Are you sure you want to reorder all categories?')). 822 self::jsVar('dotclear.msg.confirm_delete_media', 823 __('Are you sure you want to remove media "%s"?')). 824 self::jsVar('dotclear.msg.confirm_delete_directory', 825 __('Are you sure you want to remove directory "%s"?')). 826 self::jsVar('dotclear.msg.confirm_extract_current', 827 __('Are you sure you want to extract archive in current directory?')). 828 self::jsVar('dotclear.msg.confirm_remove_attachment', 829 __('Are you sure you want to remove attachment "%s"?')). 830 self::jsVar('dotclear.msg.confirm_delete_lang', 831 __('Are you sure you want to delete "%s" language?')). 832 self::jsVar('dotclear.msg.confirm_delete_plugin', 833 __('Are you sure you want to delete "%s" plugin?')). 834 self::jsVar('dotclear.msg.confirm_delete_plugins', 835 __('Are you sure you want to delete selected plugins?')). 836 self::jsVar('dotclear.msg.use_this_theme', 837 __('Use this theme')). 838 self::jsVar('dotclear.msg.remove_this_theme', 839 __('Remove this theme')). 840 self::jsVar('dotclear.msg.confirm_delete_theme', 841 __('Are you sure you want to delete "%s" theme?')). 842 self::jsVar('dotclear.msg.confirm_delete_themes', 843 __('Are you sure you want to delete selected themes?')). 844 self::jsVar('dotclear.msg.confirm_delete_backup', 845 __('Are you sure you want to delete this backup?')). 846 self::jsVar('dotclear.msg.confirm_revert_backup', 847 __('Are you sure you want to revert to this backup?')). 848 self::jsVar('dotclear.msg.zip_file_content', 849 __('Zip file content')). 850 self::jsVar('dotclear.msg.xhtml_validator', 851 __('XHTML markup validator')). 852 self::jsVar('dotclear.msg.xhtml_valid', 853 __('XHTML content is valid.')). 854 self::jsVar('dotclear.msg.xhtml_not_valid', 855 __('There are XHTML markup errors.')). 856 self::jsVar('dotclear.msg.warning_validate_no_save_content', 857 __('Attention: an audit of a content not yet registered.')). 858 self::jsVar('dotclear.msg.confirm_change_post_format', 859 __('You have unsaved changes. Switch post format will loose these changes. Proceed anyway?')). 860 self::jsVar('dotclear.msg.confirm_change_post_format_noconvert', 861 __("Warning: post format change will not convert existing content. You will need to apply new format by yourself. Proceed anyway?")). 862 self::jsVar('dotclear.msg.load_enhanced_uploader', 863 __('Loading enhanced uploader, please wait.')). 864 865 self::jsVar('dotclear.msg.module_author', 866 __('Author:')). 867 self::jsVar('dotclear.msg.module_details', 868 __('Details')). 869 self::jsVar('dotclear.msg.module_support', 870 __('Support')). 871 self::jsVar('dotclear.msg.module_help', 872 __('Help:')). 873 self::jsVar('dotclear.msg.module_section', 874 __('Section:')). 875 self::jsVar('dotclear.msg.module_tags', 876 __('Tags:')). 877 878 self::jsVar('dotclear.msg.close_notice', 879 __('Hide this notice')). 880 881 "\n". 882 "</script>\n"; 883 } 884 885 /** 886 @deprecated since version 2.11 887 */ 888 public static function jsLoadIE7() 889 { 890 return ''; 891 } 892 893 public static function jsConfirmClose() 894 { 895 $args = func_get_args(); 896 if (count($args) > 0) { 897 foreach ($args as $k => $v) { 898 $args[$k] = "'".html::escapeJS($v)."'"; 899 } 900 $args = implode(',',$args); 901 } else { 902 $args = ''; 903 } 904 905 return 906 self::jsLoad('js/confirm-close.js'). 907 '<script type="text/javascript">'."\n". 908 "confirmClosePage = new confirmClose(".$args."); ". 909 "confirmClose.prototype.prompt = '".html::escapeJS(__('You have unsaved changes.'))."'; ". 910 "</script>\n"; 911 } 912 913 public static function jsPageTabs($default=null) 914 { 915 if ($default) { 916 $default = "'".html::escapeJS($default)."'"; 917 } 918 919 return 920 self::jsLoad('js/jquery/jquery.pageTabs.js'). 921 '<script type="text/javascript">'."\n". 922 '$(function() {'."\n". 923 ' $.pageTabs('.$default.');'."\n". 924 '});'. 925 "</script>\n"; 926 } 927 928 public static function jsModal() 929 { 930 return 931 self::jsLoad('js/jquery/jquery.magnific-popup.js'); 932 } 933 934 public static function jsColorPicker() 935 { 936 return 937 self::cssLoad('style/farbtastic/farbtastic.css'). 938 self::jsLoad('js/jquery/jquery.farbtastic.js'). 939 self::jsLoad('js/color-picker.js'); 940 } 941 942 public static function jsDatePicker() 943 { 944 return 945 self::cssLoad('style/date-picker.css'). 946 self::jsLoad('js/date-picker.js'). 947 '<script type="text/javascript">'."\n". 948 949 "datePicker.prototype.months[0] = '".html::escapeJS(__('January'))."'; ". 950 "datePicker.prototype.months[1] = '".html::escapeJS(__('February'))."'; ". 951 "datePicker.prototype.months[2] = '".html::escapeJS(__('March'))."'; ". 952 "datePicker.prototype.months[3] = '".html::escapeJS(__('April'))."'; ". 953 "datePicker.prototype.months[4] = '".html::escapeJS(__('May'))."'; ". 954 "datePicker.prototype.months[5] = '".html::escapeJS(__('June'))."'; ". 955 "datePicker.prototype.months[6] = '".html::escapeJS(__('July'))."'; ". 956 "datePicker.prototype.months[7] = '".html::escapeJS(__('August'))."'; ". 957 "datePicker.prototype.months[8] = '".html::escapeJS(__('September'))."'; ". 958 "datePicker.prototype.months[9] = '".html::escapeJS(__('October'))."'; ". 959 "datePicker.prototype.months[10] = '".html::escapeJS(__('November'))."'; ". 960 "datePicker.prototype.months[11] = '".html::escapeJS(__('December'))."'; ". 961 962 "datePicker.prototype.days[0] = '".html::escapeJS(__('Monday'))."'; ". 963 "datePicker.prototype.days[1] = '".html::escapeJS(__('Tuesday'))."'; ". 964 "datePicker.prototype.days[2] = '".html::escapeJS(__('Wednesday'))."'; ". 965 "datePicker.prototype.days[3] = '".html::escapeJS(__('Thursday'))."'; ". 966 "datePicker.prototype.days[4] = '".html::escapeJS(__('Friday'))."'; ". 967 "datePicker.prototype.days[5] = '".html::escapeJS(__('Saturday'))."'; ". 968 "datePicker.prototype.days[6] = '".html::escapeJS(__('Sunday'))."'; ". 969 970 "datePicker.prototype.img_src = 'images/date-picker.png'; ". 971 "datePicker.prototype.img_alt = '".html::escapeJS(__('Choose date'))."'; ". 972 973 "datePicker.prototype.close_msg = '".html::escapeJS(__('close'))."'; ". 974 "datePicker.prototype.now_msg = '".html::escapeJS(__('now'))."'; ". 975 976 "</script>\n"; 977 } 978 979 980 public static function jsToolBar() 981 { 982 # Deprecated but we keep this for plugins. 983 } 984 985 public static function jsUpload($params=array(),$base_url=null) 986 { 987 if (!$base_url) { 988 $base_url = path::clean(dirname(preg_replace('/(\?.*$)?/','',$_SERVER['REQUEST_URI']))).'/'; 989 } 990 991 $params = array_merge($params,array( 992 'sess_id='.session_id(), 993 'sess_uid='.$_SESSION['sess_browser_uid'], 994 'xd_check='.$GLOBALS['core']->getNonce() 995 )); 996 997 return 998 '<script type="text/javascript">'."\n". 999 "dotclear.jsUpload = {};\n". 1000 "dotclear.jsUpload.msg = {};\n". 1001 self::jsVar('dotclear.msg.enhanced_uploader_activate',__('Temporarily activate enhanced uploader')). 1002 self::jsVar('dotclear.msg.enhanced_uploader_disable',__('Temporarily disable enhanced uploader')). 1003 self::jsVar('dotclear.jsUpload.msg.limit_exceeded',__('Limit exceeded.')). 1004 self::jsVar('dotclear.jsUpload.msg.size_limit_exceeded',__('File size exceeds allowed limit.')). 1005 self::jsVar('dotclear.jsUpload.msg.canceled',__('Canceled.')). 1006 self::jsVar('dotclear.jsUpload.msg.http_error',__('HTTP Error:')). 1007 self::jsVar('dotclear.jsUpload.msg.error',__('Error:')). 1008 self::jsVar('dotclear.jsUpload.msg.choose_file',__('Choose file')). 1009 self::jsVar('dotclear.jsUpload.msg.choose_files',__('Choose files')). 1010 self::jsVar('dotclear.jsUpload.msg.cancel',__('Cancel')). 1011 self::jsVar('dotclear.jsUpload.msg.clean',__('Clean')). 1012 self::jsVar('dotclear.jsUpload.msg.upload',__('Upload')). 1013 self::jsVar('dotclear.jsUpload.msg.send',__('Send')). 1014 self::jsVar('dotclear.jsUpload.msg.file_successfully_uploaded',__('File successfully uploaded.')). 1015 self::jsVar('dotclear.jsUpload.msg.no_file_in_queue',__('No file in queue.')). 1016 self::jsVar('dotclear.jsUpload.msg.file_in_queue',__('1 file in queue.')). 1017 self::jsVar('dotclear.jsUpload.msg.files_in_queue',__('%d files in queue.')). 1018 self::jsVar('dotclear.jsUpload.msg.queue_error',__('Queue error:')). 1019 self::jsVar('dotclear.jsUpload.base_url',$base_url). 1020 "</script>\n". 1021 1022 self::jsLoad('js/jquery/jquery-ui.custom.js'). 1023 self::jsLoad('js/jsUpload/tmpl.js'). 1024 self::jsLoad('js/jsUpload/template-upload.js'). 1025 self::jsLoad('js/jsUpload/template-download.js'). 1026 self::jsLoad('js/jsUpload/load-image.js'). 1027 self::jsLoad('js/jsUpload/jquery.iframe-transport.js'). 1028 self::jsLoad('js/jsUpload/jquery.fileupload.js'). 1029 self::jsLoad('js/jsUpload/jquery.fileupload-process.js'). 1030 self::jsLoad('js/jsUpload/jquery.fileupload-resize.js'). 1031 self::jsLoad('js/jsUpload/jquery.fileupload-ui.js'); 1032 } 1033 1034 public static function jsMetaEditor() 1035 { 1036 return self::jsLoad('js/meta-editor.js'); 1037 } 1038 1039 public static function jsFilterControl($show=true) 1040 { 1041 return 1042 self::jsLoad('js/filter-controls.js'). 1043 '<script type="text/javascript">'."\n". 1044 self::jsVar('dotclear.msg.show_filters', $show ? 'true':'false')."\n". 1045 self::jsVar('dotclear.msg.filter_posts_list',__('Show filters and display options'))."\n". 1046 self::jsVar('dotclear.msg.cancel_the_filter',__('Cancel filters and display options'))."\n". 1047 "</script>"; 1048 } 1049 1050 public static function jsLoadCodeMirror($theme = '',$multi = true,$modes = array('css','htmlmixed','javascript','php','xml')) 1051 { 1052 $ret = 1053 self::cssLoad('js/codemirror/lib/codemirror.css'). 1054 self::jsLoad('js/codemirror/lib/codemirror.js'); 1055 if ($multi) { 1056 $ret .= self::jsLoad('js/codemirror/addon/mode/multiplex.js'); 1057 } 1058 foreach ($modes as $mode) { 1059 $ret .= self::jsLoad('js/codemirror/mode/'.$mode.'/'.$mode.'.js'); 1060 } 1061 $ret .= 1062 self::jsLoad('js/codemirror/addon/edit/closebrackets.js'). 1063 self::jsLoad('js/codemirror/addon/edit/matchbrackets.js'). 1064 self::cssLoad('js/codemirror/addon/display/fullscreen.css'). 1065 self::jsLoad('js/codemirror/addon/display/fullscreen.js'); 1066 if ($theme != '') { 1067 $ret .= self::cssLoad('js/codemirror/theme/'.$theme.'.css'); 1068 } 1069 return $ret; 1070 } 1071 1072 public static function jsRunCodeMirror($name,$id,$mode,$theme = '') 1073 { 1074 $ret = 1075 '<script type="text/javascript">'."\n". 1076 'var '.$name.' = CodeMirror.fromTextArea('.$id.',{'."\n". 1077 ' mode: "'.$mode.'",'."\n". 1078 ' tabMode: "indent",'."\n". 1079 ' lineWrapping: 1,'."\n". 1080 ' lineNumbers: 1,'."\n". 1081 ' matchBrackets: 1,'."\n". 1082 ' autoCloseBrackets: 1,'."\n". 1083 ' extraKeys: {"F11": function(cm) {cm.setOption("fullScreen",!cm.getOption("fullScreen"));}}'; 1084 if ($theme) { 1085 $ret .= 1086 ','."\n". 1087 ' theme: "'.$theme.'"'; 1088 } 1089 $ret .= "\n". 1090 '});'."\n". 1091 '</script>'; 1092 return $ret; 1093 } 1094 1095 public static function getCodeMirrorThemes() 1096 { 1097 $themes = array(); 1098 $themes_root = dirname(__FILE__).'/../../admin'.'/js/codemirror/theme/'; 1099 if (is_dir($themes_root) && is_readable($themes_root)) { 1100 if (($d = @dir($themes_root)) !== false) { 1101 while (($entry = $d->read()) !== false) { 1102 if ($entry != '.' && $entry != '..' && substr($entry, 0, 1) != '.' && is_readable($themes_root.'/'.$entry)) { 1103 $themes[] = substr($entry,0,-4); // remove .css extension 1104 } 1105 } 1106 sort($themes); 1107 } 1108 } 1109 return $themes; 1110 } 1111 1112 public static function getPF($file) 1113 { 1114 return $GLOBALS['core']->adminurl->get('load.plugin.file',array('pf' => $file)); 1115 } 1116 1117 public static function getVF($file) 1118 { 1119 return $GLOBALS['core']->adminurl->get('load.var.file',array('vf' => $file)); 1120 } 1121 1122 public static function setXFrameOptions($headers,$origin = null) 1123 { 1124 if (self::$xframe_loaded) { 1125 return; 1126 } 1127 1128 if ($origin !== null) { 1129 $url = parse_url($origin); 1130 $headers['x-frame-options'] = sprintf('X-Frame-Options: %s',is_array($url) && isset($url['host']) ? 1131 ("ALLOW-FROM ".(isset($url['scheme']) ? $url['scheme'].':' : '' ).'//'.$url['host']) : 1132 'SAMEORIGIN'); 1133 } else { 1134 $headers['x-frame-options'] = 'X-Frame-Options: SAMEORIGIN'; // FF 3.6.9+ Chrome 4.1+ IE 8+ Safari 4+ Opera 10.5+ 1135 } 1136 self::$xframe_loaded = true; 1137 } 400 echo 401 '<div id="footer" role="contentinfo">' . 402 '<a href="http://dotclear.org/" title="' . $text . '">' . 403 '<img src="style/dc_logos/w-dotclear90.png" alt="' . $text . '" /></a></div>' . "\n" . 404 "<!-- " . "\n" . 405 $figure . 406 " -->" . "\n"; 407 408 if (defined('DC_DEV') && DC_DEV === true) { 409 echo self::debugInfo(); 410 } 411 412 echo 413 '</body></html>'; 414 } 415 416 public static function openPopup($title = '', $head = '', $breadcrumb = '') 417 { 418 global $core; 419 420 # Display 421 header('Content-Type: text/html; charset=UTF-8'); 422 423 # Referrer Policy for admin pages 424 header('Referrer-Policy: strict-origin'); 425 426 # Prevents Clickjacking as far as possible 427 header('X-Frame-Options: SAMEORIGIN'); // FF 3.6.9+ Chrome 4.1+ IE 8+ Safari 4+ Opera 10.5+ 428 429 echo 430 '<!DOCTYPE html>' . 431 '<html lang="' . $core->auth->getInfo('user_lang') . '">' . "\n" . 432 "<head>\n" . 433 ' <meta charset="UTF-8" />' . "\n" . 434 ' <meta name="viewport" content="width=device-width, initial-scale=1.0" />' . "\n" . 435 ' <title>' . $title . ' - ' . html::escapeHTML($core->blog->name) . ' - ' . html::escapeHTML(DC_VENDOR_NAME) . ' - ' . DC_VERSION . '</title>' . "\n" . 436 437 ' <meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" />' . "\n" . 438 ' <meta name="GOOGLEBOT" content="NOSNIPPET" />' . "\n" . 439 440 self::cssLoad('style/default.css'); 441 if (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl') { 442 echo self::cssLoad('style/default-rtl.css'); 443 } 444 445 $core->auth->user_prefs->addWorkspace('interface'); 446 if ($core->auth->user_prefs->interface->htmlfontsize) { 447 echo 448 '<script type="text/javascript">' . "\n" . 449 self::jsVar('dotclear_htmlFontSize', $core->auth->user_prefs->interface->htmlfontsize) . "\n" . 450 "</script>\n"; 451 } 452 453 echo 454 self::jsCommon() . 455 self::jsToggles() . 456 $head; 457 458 if ($core->auth->user_prefs->interface->hidemoreinfo) { 459 echo 460 '<script type="text/javascript">' . "\n" . 461 'dotclear.hideMoreInfo = true;' . "\n" . 462 "</script>\n"; 463 } 464 if ($core->auth->user_prefs->interface->showajaxloader) { 465 echo 466 '<script type="text/javascript">' . "\n" . 467 'dotclear.showAjaxLoader = true;' . "\n" . 468 "</script>\n"; 469 } 470 471 # --BEHAVIOR-- adminPageHTMLHead 472 $core->callBehavior('adminPageHTMLHead'); 473 474 echo 475 "</head>\n" . 476 '<body id="dotclear-admin" class="popup' . 477 ($core->auth->user_prefs->interface->dynfontsize ? ' responsive-font' : '') . '">' . "\n" . 478 479 '<h1>' . DC_VENDOR_NAME . '</h1>' . "\n"; 480 481 echo 482 '<div id="wrapper">' . "\n" . 483 '<div id="main" role="main">' . "\n" . 484 '<div id="content">' . "\n"; 485 486 // display breadcrumb if given 487 echo $breadcrumb; 488 489 // Display notices and errors 490 echo self::notices(); 491 } 492 493 public static function closePopup() 494 { 495 echo 496 "</div>\n" . // End of #content 497 "</div>\n" . // End of #main 498 "</div>\n" . // End of #wrapper 499 500 '<p id="gototop"><a href="#wrapper">' . __('Page top') . '</a></p>' . "\n" . 501 502 '<div id="footer" role="contentinfo"><p> </p></div>' . "\n" . 503 '</body></html>'; 504 } 505 506 public static function breadcrumb($elements = null, $options = array()) 507 { 508 global $core; 509 $with_home_link = isset($options['home_link']) ? $options['home_link'] : true; 510 $hl = isset($options['hl']) ? $options['hl'] : true; 511 $hl_pos = isset($options['hl_pos']) ? $options['hl_pos'] : -1; 512 // First item of array elements should be blog's name, System or Plugins 513 $res = '<h2>' . ($with_home_link ? 514 '<a class="go_home" href="' . $core->adminurl->get("admin.home") . '"><img src="style/dashboard.png" alt="' . __('Go to dashboard') . '" /></a>' : 515 '<img src="style/dashboard-alt.png" alt="" />'); 516 $index = 0; 517 if ($hl_pos < 0) { 518 $hl_pos = count($elements) + $hl_pos; 519 } 520 foreach ($elements as $element => $url) { 521 if ($hl && $index == $hl_pos) { 522 $element = sprintf('<span class="page-title">%s</span>', $element); 523 } 524 $res .= ($with_home_link ? ($index == 1 ? ' : ' : ' › ') : ($index == 0 ? ' ' : ' › ')) . 525 ($url ? '<a href="' . $url . '">' : '') . $element . ($url ? '</a>' : ''); 526 $index++; 527 } 528 $res .= '</h2>'; 529 return $res; 530 } 531 532 public static function message($msg, $timestamp = true, $div = false, $echo = true, $class = 'message') 533 { 534 global $core; 535 536 $res = ''; 537 if ($msg != '') { 538 $res = ($div ? '<div class="' . $class . '">' : '') . '<p' . ($div ? '' : ' class="' . $class . '"') . '>' . 539 ($timestamp ? dt::str(__('[%H:%M:%S]'), null, $core->auth->getInfo('user_tz')) . ' ' : '') . $msg . 540 '</p>' . ($div ? '</div>' : ''); 541 if ($echo) { 542 echo $res; 543 } 544 } 545 return $res; 546 } 547 548 public static function success($msg, $timestamp = true, $div = false, $echo = true) 549 { 550 return self::message($msg, $timestamp, $div, $echo, "success"); 551 } 552 553 public static function warning($msg, $timestamp = true, $div = false, $echo = true) 554 { 555 return self::message($msg, $timestamp, $div, $echo, "warning-msg"); 556 } 557 558 private static function debugInfo() 559 { 560 $global_vars = implode(', ', array_keys($GLOBALS)); 561 562 $res = 563 '<div id="debug"><div>' . 564 '<p>memory usage: ' . memory_get_usage() . ' (' . files::size(memory_get_usage()) . ')</p>'; 565 566 if (function_exists('xdebug_get_profiler_filename')) { 567 $res .= '<p>Elapsed time: ' . xdebug_time_index() . ' seconds</p>'; 568 569 $prof_file = xdebug_get_profiler_filename(); 570 if ($prof_file) { 571 $res .= '<p>Profiler file : ' . xdebug_get_profiler_filename() . '</p>'; 572 } else { 573 $prof_url = http::getSelfURI(); 574 $prof_url .= (strpos($prof_url, '?') === false) ? '?' : '&'; 575 $prof_url .= 'XDEBUG_PROFILE'; 576 $res .= '<p><a href="' . html::escapeURL($prof_url) . '">Trigger profiler</a></p>'; 577 } 578 579 /* xdebug configuration: 580 zend_extension = /.../xdebug.so 581 xdebug.auto_trace = On 582 xdebug.trace_format = 0 583 xdebug.trace_options = 1 584 xdebug.show_mem_delta = On 585 xdebug.profiler_enable = 0 586 xdebug.profiler_enable_trigger = 1 587 xdebug.profiler_output_dir = /tmp 588 xdebug.profiler_append = 0 589 xdebug.profiler_output_name = timestamp 590 */ 591 } 592 593 $res .= 594 '<p>Global vars: ' . $global_vars . '</p>' . 595 '</div></div>'; 596 597 return $res; 598 } 599 600 public static function help($page, $index = '') 601 { 602 # Deprecated but we keep this for plugins. 603 } 604 605 public static function helpBlock() 606 { 607 global $core; 608 609 if ($core->auth->user_prefs->interface->hidehelpbutton) { 610 return; 611 } 612 613 $args = func_get_args(); 614 $args = new ArrayObject($args); 615 616 # --BEHAVIOR-- adminPageHelpBlock 617 $GLOBALS['core']->callBehavior('adminPageHelpBlock', $args); 618 619 if (empty($args)) { 620 return; 621 }; 622 623 global $__resources; 624 if (empty($__resources['help'])) { 625 return; 626 } 627 628 $content = ''; 629 foreach ($args as $v) { 630 if (is_object($v) && isset($v->content)) { 631 $content .= $v->content; 632 continue; 633 } 634 635 if (!isset($__resources['help'][$v])) { 636 continue; 637 } 638 $f = $__resources['help'][$v]; 639 if (!file_exists($f) || !is_readable($f)) { 640 continue; 641 } 642 643 $fc = file_get_contents($f); 644 if (preg_match('|<body[^>]*?>(.*?)</body>|ms', $fc, $matches)) { 645 $content .= $matches[1]; 646 } else { 647 $content .= $fc; 648 } 649 } 650 651 if (trim($content) == '') { 652 return; 653 } 654 655 // Set contextual help global flag 656 $GLOBALS['__resources']['ctxhelp'] = true; 657 658 echo 659 '<div id="help"><hr /><div class="help-content clear"><h3>' . __('Help about this page') . '</h3>' . 660 $content . 661 '</div>' . 662 '<div id="helplink"><hr />' . 663 '<p>' . 664 sprintf(__('See also %s'), sprintf('<a href="' . $core->adminurl->get("admin.help") . '">%s</a>', __('the global help'))) . 665 '.</p>' . 666 '</div></div>'; 667 } 668 669 public static function cssLoad($src, $media = 'screen', $v = '') 670 { 671 $escaped_src = html::escapeHTML($src); 672 if (!isset(self::$loaded_css[$escaped_src])) { 673 self::$loaded_css[$escaped_src] = true; 674 $escaped_src = self::appendVersion($escaped_src, $v); 675 676 return '<link rel="stylesheet" href="' . $escaped_src . '" type="text/css" media="' . $media . '" />' . "\n"; 677 } 678 } 679 680 public static function jsLoad($src, $v = '') 681 { 682 $escaped_src = html::escapeHTML($src); 683 if (!isset(self::$loaded_js[$escaped_src])) { 684 self::$loaded_js[$escaped_src] = true; 685 $escaped_src = self::appendVersion($escaped_src, $v); 686 return '<script type="text/javascript" src="' . $escaped_src . '"></script>' . "\n"; 687 } 688 } 689 690 private static function appendVersion($src, $v = '') 691 { 692 $src .= (strpos($src, '?') === false ? '?' : '&') . 'v='; 693 if (defined('DC_DEV') && DC_DEV === true) { 694 $src .= md5(uniqid()); 695 } else { 696 $src .= ($v === '' ? DC_VERSION : $v); 697 } 698 return $src; 699 } 700 701 public static function jsVar($n, $v) 702 { 703 return $n . " = '" . html::escapeJS($v) . "';\n"; 704 } 705 706 public static function jsVars($vars) 707 { 708 $ret = '<script type="text/javascript">' . "\n"; 709 foreach ($vars as $var => $value) { 710 $ret .= $var . ' = ' . (is_string($value) ? "'" . html::escapeJS($value) . "'" : $value) . ';' . "\n"; 711 } 712 $ret .= "</script>\n"; 713 714 return $ret; 715 } 716 717 public static function jsToggles() 718 { 719 if ($GLOBALS['core']->auth->user_prefs->toggles) { 720 $unfolded_sections = explode(',', $GLOBALS['core']->auth->user_prefs->toggles->unfolded_sections); 721 foreach ($unfolded_sections as $k => &$v) { 722 if ($v == '') { 723 unset($unfolded_sections[$k]); 724 } else { 725 $v = "'" . html::escapeJS($v) . "':true"; 726 } 727 } 728 } else { 729 $unfolded_sections = array(); 730 } 731 return '<script type="text/javascript">' . "\n" . 732 'dotclear.unfolded_sections = {' . join(",", $unfolded_sections) . "};\n" . 733 "</script>\n"; 734 } 735 736 public static function jsCommon() 737 { 738 $mute_or_no = ''; 739 if (empty($GLOBALS['core']->blog) || $GLOBALS['core']->blog->settings->system->jquery_migrate_mute) { 740 $mute_or_no .= 741 '<script type="text/javascript">' . "\n" . 742 'jQuery.migrateMute = true;' . "\n" . 743 "</script>\n"; 744 } 745 746 return 747 self::jsLoad('js/jquery/jquery.js') . 748 $mute_or_no . 749 self::jsLoad('js/jquery/jquery-migrate.js') . 750 self::jsLoad('js/jquery/jquery.biscuit.js') . 751 self::jsLoad('js/common.js') . 752 self::jsLoad('js/prelude.js') . 753 754 '<script type="text/javascript">' . "\n" . 755 'jsToolBar = {}, jsToolBar.prototype = { elements : {} };' . "\n" . 756 757 self::jsVar('dotclear.nonce', $GLOBALS['core']->getNonce()) . 758 759 self::jsVar('dotclear.img_plus_src', 'images/expand.png') . 760 self::jsVar('dotclear.img_plus_alt', __('uncover')) . 761 self::jsVar('dotclear.img_minus_src', 'images/hide.png') . 762 self::jsVar('dotclear.img_minus_alt', __('hide')) . 763 self::jsVar('dotclear.img_menu_on', 'images/menu_on.png') . 764 self::jsVar('dotclear.img_menu_off', 'images/menu_off.png') . 765 766 self::jsVar('dotclear.img_plus_theme_src', 'images/plus-theme.png') . 767 self::jsVar('dotclear.img_plus_theme_alt', __('uncover')) . 768 self::jsVar('dotclear.img_minus_theme_src', 'images/minus-theme.png') . 769 self::jsVar('dotclear.img_minus_theme_alt', __('hide')) . 770 771 self::jsVar('dotclear.msg.help', 772 __('Need help?')) . 773 self::jsVar('dotclear.msg.new_window', 774 __('new window')) . 775 self::jsVar('dotclear.msg.help_hide', 776 __('Hide')) . 777 self::jsVar('dotclear.msg.to_select', 778 __('Select:')) . 779 self::jsVar('dotclear.msg.no_selection', 780 __('no selection')) . 781 self::jsVar('dotclear.msg.select_all', 782 __('select all')) . 783 self::jsVar('dotclear.msg.invert_sel', 784 __('Invert selection')) . 785 self::jsVar('dotclear.msg.website', 786 __('Web site:')) . 787 self::jsVar('dotclear.msg.email', 788 __('Email:')) . 789 self::jsVar('dotclear.msg.ip_address', 790 __('IP address:')) . 791 self::jsVar('dotclear.msg.error', 792 __('Error:')) . 793 self::jsVar('dotclear.msg.entry_created', 794 __('Entry has been successfully created.')) . 795 self::jsVar('dotclear.msg.edit_entry', 796 __('Edit entry')) . 797 self::jsVar('dotclear.msg.view_entry', 798 __('view entry')) . 799 self::jsVar('dotclear.msg.confirm_delete_posts', 800 __("Are you sure you want to delete selected entries (%s)?")) . 801 self::jsVar('dotclear.msg.confirm_delete_medias', 802 __("Are you sure you want to delete selected medias (%d)?")) . 803 self::jsVar('dotclear.msg.confirm_delete_categories', 804 __("Are you sure you want to delete selected categories (%s)?")) . 805 self::jsVar('dotclear.msg.confirm_delete_post', 806 __("Are you sure you want to delete this entry?")) . 807 self::jsVar('dotclear.msg.click_to_unlock', 808 __("Click here to unlock the field")) . 809 self::jsVar('dotclear.msg.confirm_spam_delete', 810 __('Are you sure you want to delete all spams?')) . 811 self::jsVar('dotclear.msg.confirm_delete_comments', 812 __('Are you sure you want to delete selected comments (%s)?')) . 813 self::jsVar('dotclear.msg.confirm_delete_comment', 814 __('Are you sure you want to delete this comment?')) . 815 self::jsVar('dotclear.msg.cannot_delete_users', 816 __('Users with posts cannot be deleted.')) . 817 self::jsVar('dotclear.msg.confirm_delete_user', 818 __('Are you sure you want to delete selected users (%s)?')) . 819 self::jsVar('dotclear.msg.confirm_delete_blog', 820 __('Are you sure you want to delete selected blogs (%s)?')) . 821 self::jsVar('dotclear.msg.confirm_delete_category', 822 __('Are you sure you want to delete category "%s"?')) . 823 self::jsVar('dotclear.msg.confirm_reorder_categories', 824 __('Are you sure you want to reorder all categories?')) . 825 self::jsVar('dotclear.msg.confirm_delete_media', 826 __('Are you sure you want to remove media "%s"?')) . 827 self::jsVar('dotclear.msg.confirm_delete_directory', 828 __('Are you sure you want to remove directory "%s"?')) . 829 self::jsVar('dotclear.msg.confirm_extract_current', 830 __('Are you sure you want to extract archive in current directory?')) . 831 self::jsVar('dotclear.msg.confirm_remove_attachment', 832 __('Are you sure you want to remove attachment "%s"?')) . 833 self::jsVar('dotclear.msg.confirm_delete_lang', 834 __('Are you sure you want to delete "%s" language?')) . 835 self::jsVar('dotclear.msg.confirm_delete_plugin', 836 __('Are you sure you want to delete "%s" plugin?')) . 837 self::jsVar('dotclear.msg.confirm_delete_plugins', 838 __('Are you sure you want to delete selected plugins?')) . 839 self::jsVar('dotclear.msg.use_this_theme', 840 __('Use this theme')) . 841 self::jsVar('dotclear.msg.remove_this_theme', 842 __('Remove this theme')) . 843 self::jsVar('dotclear.msg.confirm_delete_theme', 844 __('Are you sure you want to delete "%s" theme?')) . 845 self::jsVar('dotclear.msg.confirm_delete_themes', 846 __('Are you sure you want to delete selected themes?')) . 847 self::jsVar('dotclear.msg.confirm_delete_backup', 848 __('Are you sure you want to delete this backup?')) . 849 self::jsVar('dotclear.msg.confirm_revert_backup', 850 __('Are you sure you want to revert to this backup?')) . 851 self::jsVar('dotclear.msg.zip_file_content', 852 __('Zip file content')) . 853 self::jsVar('dotclear.msg.xhtml_validator', 854 __('XHTML markup validator')) . 855 self::jsVar('dotclear.msg.xhtml_valid', 856 __('XHTML content is valid.')) . 857 self::jsVar('dotclear.msg.xhtml_not_valid', 858 __('There are XHTML markup errors.')) . 859 self::jsVar('dotclear.msg.warning_validate_no_save_content', 860 __('Attention: an audit of a content not yet registered.')) . 861 self::jsVar('dotclear.msg.confirm_change_post_format', 862 __('You have unsaved changes. Switch post format will loose these changes. Proceed anyway?')) . 863 self::jsVar('dotclear.msg.confirm_change_post_format_noconvert', 864 __("Warning: post format change will not convert existing content. You will need to apply new format by yourself. Proceed anyway?")) . 865 self::jsVar('dotclear.msg.load_enhanced_uploader', 866 __('Loading enhanced uploader, please wait.')) . 867 868 self::jsVar('dotclear.msg.module_author', 869 __('Author:')) . 870 self::jsVar('dotclear.msg.module_details', 871 __('Details')) . 872 self::jsVar('dotclear.msg.module_support', 873 __('Support')) . 874 self::jsVar('dotclear.msg.module_help', 875 __('Help:')) . 876 self::jsVar('dotclear.msg.module_section', 877 __('Section:')) . 878 self::jsVar('dotclear.msg.module_tags', 879 __('Tags:')) . 880 881 self::jsVar('dotclear.msg.close_notice', 882 __('Hide this notice')) . 883 884 "\n" . 885 "</script>\n"; 886 } 887 888 /** 889 @deprecated since version 2.11 890 */ 891 public static function jsLoadIE7() 892 { 893 return ''; 894 } 895 896 public static function jsConfirmClose() 897 { 898 $args = func_get_args(); 899 if (count($args) > 0) { 900 foreach ($args as $k => $v) { 901 $args[$k] = "'" . html::escapeJS($v) . "'"; 902 } 903 $args = implode(',', $args); 904 } else { 905 $args = ''; 906 } 907 908 return 909 self::jsLoad('js/confirm-close.js') . 910 '<script type="text/javascript">' . "\n" . 911 "confirmClosePage = new confirmClose(" . $args . "); " . 912 "confirmClose.prototype.prompt = '" . html::escapeJS(__('You have unsaved changes.')) . "'; " . 913 "</script>\n"; 914 } 915 916 public static function jsPageTabs($default = null) 917 { 918 if ($default) { 919 $default = "'" . html::escapeJS($default) . "'"; 920 } 921 922 return 923 self::jsLoad('js/jquery/jquery.pageTabs.js') . 924 '<script type="text/javascript">' . "\n" . 925 '$(function() {' . "\n" . 926 ' $.pageTabs(' . $default . ');' . "\n" . 927 '});' . 928 "</script>\n"; 929 } 930 931 public static function jsModal() 932 { 933 return 934 self::jsLoad('js/jquery/jquery.magnific-popup.js'); 935 } 936 937 public static function jsColorPicker() 938 { 939 return 940 self::cssLoad('style/farbtastic/farbtastic.css') . 941 self::jsLoad('js/jquery/jquery.farbtastic.js') . 942 self::jsLoad('js/color-picker.js'); 943 } 944 945 public static function jsDatePicker() 946 { 947 return 948 self::cssLoad('style/date-picker.css') . 949 self::jsLoad('js/date-picker.js') . 950 '<script type="text/javascript">' . "\n" . 951 952 "datePicker.prototype.months[0] = '" . html::escapeJS(__('January')) . "'; " . 953 "datePicker.prototype.months[1] = '" . html::escapeJS(__('February')) . "'; " . 954 "datePicker.prototype.months[2] = '" . html::escapeJS(__('March')) . "'; " . 955 "datePicker.prototype.months[3] = '" . html::escapeJS(__('April')) . "'; " . 956 "datePicker.prototype.months[4] = '" . html::escapeJS(__('May')) . "'; " . 957 "datePicker.prototype.months[5] = '" . html::escapeJS(__('June')) . "'; " . 958 "datePicker.prototype.months[6] = '" . html::escapeJS(__('July')) . "'; " . 959 "datePicker.prototype.months[7] = '" . html::escapeJS(__('August')) . "'; " . 960 "datePicker.prototype.months[8] = '" . html::escapeJS(__('September')) . "'; " . 961 "datePicker.prototype.months[9] = '" . html::escapeJS(__('October')) . "'; " . 962 "datePicker.prototype.months[10] = '" . html::escapeJS(__('November')) . "'; " . 963 "datePicker.prototype.months[11] = '" . html::escapeJS(__('December')) . "'; " . 964 965 "datePicker.prototype.days[0] = '" . html::escapeJS(__('Monday')) . "'; " . 966 "datePicker.prototype.days[1] = '" . html::escapeJS(__('Tuesday')) . "'; " . 967 "datePicker.prototype.days[2] = '" . html::escapeJS(__('Wednesday')) . "'; " . 968 "datePicker.prototype.days[3] = '" . html::escapeJS(__('Thursday')) . "'; " . 969 "datePicker.prototype.days[4] = '" . html::escapeJS(__('Friday')) . "'; " . 970 "datePicker.prototype.days[5] = '" . html::escapeJS(__('Saturday')) . "'; " . 971 "datePicker.prototype.days[6] = '" . html::escapeJS(__('Sunday')) . "'; " . 972 973 "datePicker.prototype.img_src = 'images/date-picker.png'; " . 974 "datePicker.prototype.img_alt = '" . html::escapeJS(__('Choose date')) . "'; " . 975 976 "datePicker.prototype.close_msg = '" . html::escapeJS(__('close')) . "'; " . 977 "datePicker.prototype.now_msg = '" . html::escapeJS(__('now')) . "'; " . 978 979 "</script>\n"; 980 } 981 982 public static function jsToolBar() 983 { 984 # Deprecated but we keep this for plugins. 985 } 986 987 public static function jsUpload($params = array(), $base_url = null) 988 { 989 if (!$base_url) { 990 $base_url = path::clean(dirname(preg_replace('/(\?.*$)?/', '', $_SERVER['REQUEST_URI']))) . '/'; 991 } 992 993 $params = array_merge($params, array( 994 'sess_id=' . session_id(), 995 'sess_uid=' . $_SESSION['sess_browser_uid'], 996 'xd_check=' . $GLOBALS['core']->getNonce() 997 )); 998 999 return 1000 '<script type="text/javascript">' . "\n" . 1001 "dotclear.jsUpload = {};\n" . 1002 "dotclear.jsUpload.msg = {};\n" . 1003 self::jsVar('dotclear.msg.enhanced_uploader_activate', __('Temporarily activate enhanced uploader')) . 1004 self::jsVar('dotclear.msg.enhanced_uploader_disable', __('Temporarily disable enhanced uploader')) . 1005 self::jsVar('dotclear.jsUpload.msg.limit_exceeded', __('Limit exceeded.')) . 1006 self::jsVar('dotclear.jsUpload.msg.size_limit_exceeded', __('File size exceeds allowed limit.')) . 1007 self::jsVar('dotclear.jsUpload.msg.canceled', __('Canceled.')) . 1008 self::jsVar('dotclear.jsUpload.msg.http_error', __('HTTP Error:')) . 1009 self::jsVar('dotclear.jsUpload.msg.error', __('Error:')) . 1010 self::jsVar('dotclear.jsUpload.msg.choose_file', __('Choose file')) . 1011 self::jsVar('dotclear.jsUpload.msg.choose_files', __('Choose files')) . 1012 self::jsVar('dotclear.jsUpload.msg.cancel', __('Cancel')) . 1013 self::jsVar('dotclear.jsUpload.msg.clean', __('Clean')) . 1014 self::jsVar('dotclear.jsUpload.msg.upload', __('Upload')) . 1015 self::jsVar('dotclear.jsUpload.msg.send', __('Send')) . 1016 self::jsVar('dotclear.jsUpload.msg.file_successfully_uploaded', __('File successfully uploaded.')) . 1017 self::jsVar('dotclear.jsUpload.msg.no_file_in_queue', __('No file in queue.')) . 1018 self::jsVar('dotclear.jsUpload.msg.file_in_queue', __('1 file in queue.')) . 1019 self::jsVar('dotclear.jsUpload.msg.files_in_queue', __('%d files in queue.')) . 1020 self::jsVar('dotclear.jsUpload.msg.queue_error', __('Queue error:')) . 1021 self::jsVar('dotclear.jsUpload.base_url', $base_url) . 1022 "</script>\n" . 1023 1024 self::jsLoad('js/jquery/jquery-ui.custom.js') . 1025 self::jsLoad('js/jsUpload/tmpl.js') . 1026 self::jsLoad('js/jsUpload/template-upload.js') . 1027 self::jsLoad('js/jsUpload/template-download.js') . 1028 self::jsLoad('js/jsUpload/load-image.js') . 1029 self::jsLoad('js/jsUpload/jquery.iframe-transport.js') . 1030 self::jsLoad('js/jsUpload/jquery.fileupload.js') . 1031 self::jsLoad('js/jsUpload/jquery.fileupload-process.js') . 1032 self::jsLoad('js/jsUpload/jquery.fileupload-resize.js') . 1033 self::jsLoad('js/jsUpload/jquery.fileupload-ui.js'); 1034 } 1035 1036 public static function jsMetaEditor() 1037 { 1038 return self::jsLoad('js/meta-editor.js'); 1039 } 1040 1041 public static function jsFilterControl($show = true) 1042 { 1043 return 1044 self::jsLoad('js/filter-controls.js') . 1045 '<script type="text/javascript">' . "\n" . 1046 self::jsVar('dotclear.msg.show_filters', $show ? 'true' : 'false') . "\n" . 1047 self::jsVar('dotclear.msg.filter_posts_list', __('Show filters and display options')) . "\n" . 1048 self::jsVar('dotclear.msg.cancel_the_filter', __('Cancel filters and display options')) . "\n" . 1049 "</script>"; 1050 } 1051 1052 public static function jsLoadCodeMirror($theme = '', $multi = true, $modes = array('css', 'htmlmixed', 'javascript', 'php', 'xml')) 1053 { 1054 $ret = 1055 self::cssLoad('js/codemirror/lib/codemirror.css') . 1056 self::jsLoad('js/codemirror/lib/codemirror.js'); 1057 if ($multi) { 1058 $ret .= self::jsLoad('js/codemirror/addon/mode/multiplex.js'); 1059 } 1060 foreach ($modes as $mode) { 1061 $ret .= self::jsLoad('js/codemirror/mode/' . $mode . '/' . $mode . '.js'); 1062 } 1063 $ret .= 1064 self::jsLoad('js/codemirror/addon/edit/closebrackets.js') . 1065 self::jsLoad('js/codemirror/addon/edit/matchbrackets.js') . 1066 self::cssLoad('js/codemirror/addon/display/fullscreen.css') . 1067 self::jsLoad('js/codemirror/addon/display/fullscreen.js'); 1068 if ($theme != '') { 1069 $ret .= self::cssLoad('js/codemirror/theme/' . $theme . '.css'); 1070 } 1071 return $ret; 1072 } 1073 1074 public static function jsRunCodeMirror($name, $id, $mode, $theme = '') 1075 { 1076 $ret = 1077 '<script type="text/javascript">' . "\n" . 1078 'var ' . $name . ' = CodeMirror.fromTextArea(' . $id . ',{' . "\n" . 1079 ' mode: "' . $mode . '",' . "\n" . 1080 ' tabMode: "indent",' . "\n" . 1081 ' lineWrapping: 1,' . "\n" . 1082 ' lineNumbers: 1,' . "\n" . 1083 ' matchBrackets: 1,' . "\n" . 1084 ' autoCloseBrackets: 1,' . "\n" . 1085 ' extraKeys: {"F11": function(cm) {cm.setOption("fullScreen",!cm.getOption("fullScreen"));}}'; 1086 if ($theme) { 1087 $ret .= 1088 ',' . "\n" . 1089 ' theme: "' . $theme . '"'; 1090 } 1091 $ret .= "\n" . 1092 '});' . "\n" . 1093 '</script>'; 1094 return $ret; 1095 } 1096 1097 public static function getCodeMirrorThemes() 1098 { 1099 $themes = array(); 1100 $themes_root = dirname(__FILE__) . '/../../admin' . '/js/codemirror/theme/'; 1101 if (is_dir($themes_root) && is_readable($themes_root)) { 1102 if (($d = @dir($themes_root)) !== false) { 1103 while (($entry = $d->read()) !== false) { 1104 if ($entry != '.' && $entry != '..' && substr($entry, 0, 1) != '.' && is_readable($themes_root . '/' . $entry)) { 1105 $themes[] = substr($entry, 0, -4); // remove .css extension 1106 } 1107 } 1108 sort($themes); 1109 } 1110 } 1111 return $themes; 1112 } 1113 1114 public static function getPF($file) 1115 { 1116 return $GLOBALS['core']->adminurl->get('load.plugin.file', array('pf' => $file)); 1117 } 1118 1119 public static function getVF($file) 1120 { 1121 return $GLOBALS['core']->adminurl->get('load.var.file', array('vf' => $file)); 1122 } 1123 1124 public static function setXFrameOptions($headers, $origin = null) 1125 { 1126 if (self::$xframe_loaded) { 1127 return; 1128 } 1129 1130 if ($origin !== null) { 1131 $url = parse_url($origin); 1132 $headers['x-frame-options'] = sprintf('X-Frame-Options: %s', is_array($url) && isset($url['host']) ? 1133 ("ALLOW-FROM " . (isset($url['scheme']) ? $url['scheme'] . ':' : '') . '//' . $url['host']) : 1134 'SAMEORIGIN'); 1135 } else { 1136 $headers['x-frame-options'] = 'X-Frame-Options: SAMEORIGIN'; // FF 3.6.9+ Chrome 4.1+ IE 8+ Safari 4+ Opera 10.5+ 1137 } 1138 self::$xframe_loaded = true; 1139 } 1138 1140 } -
plugins/aboutConfig/index.php
r3421 r3709 10 10 # 11 11 # -- END LICENSE BLOCK ----------------------------------------- 12 if (!defined('DC_CONTEXT_ADMIN')) { return;}12 if (!defined('DC_CONTEXT_ADMIN')) {return;} 13 13 14 14 # Local navigation 15 15 if (!empty($_POST['gs_nav'])) { 16 http::redirect($p_url.$_POST['gs_nav']);17 16 http::redirect($p_url . $_POST['gs_nav']); 17 exit; 18 18 } 19 19 if (!empty($_POST['ls_nav'])) { 20 http::redirect($p_url.$_POST['ls_nav']);21 20 http::redirect($p_url . $_POST['ls_nav']); 21 exit; 22 22 } 23 23 24 24 # Local settings update 25 if (!empty($_POST['s']) && is_array($_POST['s'])) 25 if (!empty($_POST['s']) && is_array($_POST['s'])) { 26 try 27 { 28 foreach ($_POST['s'] as $ns => $s) { 29 $core->blog->settings->addNamespace($ns); 30 foreach ($s as $k => $v) { 31 if ($_POST['s_type'][$ns][$k] == 'array') { 32 $v = json_decode($v, true); 33 } 34 $core->blog->settings->$ns->put($k, $v); 35 } 36 $core->blog->triggerBlog(); 37 } 38 39 dcPage::addSuccessNotice(__('Configuration successfully updated')); 40 http::redirect($p_url); 41 } catch (Exception $e) { 42 $core->error->add($e->getMessage()); 43 } 44 } 45 46 # Global settings update 47 if (!empty($_POST['gs']) && is_array($_POST['gs'])) { 48 try 49 { 50 foreach ($_POST['gs'] as $ns => $s) { 51 $core->blog->settings->addNamespace($ns); 52 foreach ($s as $k => $v) { 53 if ($_POST['gs_type'][$ns][$k] == 'array') { 54 $v = json_decode($v, true); 55 } 56 $core->blog->settings->$ns->put($k, $v, null, null, true, true); 57 } 58 $core->blog->triggerBlog(); 59 } 60 61 dcPage::addSuccessNotice(__('Configuration successfully updated')); 62 http::redirect($p_url . '&part=global'); 63 } catch (Exception $e) { 64 $core->error->add($e->getMessage()); 65 } 66 } 67 68 $part = !empty($_GET['part']) && $_GET['part'] == 'global' ? 'global' : 'local'; 69 70 function settingLine($id, $s, $ns, $field_name, $strong_label) 26 71 { 27 try 28 { 29 foreach ($_POST['s'] as $ns => $s) { 30 $core->blog->settings->addNamespace($ns); 31 foreach ($s as $k => $v) { 32 if ($_POST['s_type'][$ns][$k] == 'array') { 33 $v = json_decode($v,true); 34 } 35 $core->blog->settings->$ns->put($k,$v); 36 } 37 $core->blog->triggerBlog(); 38 } 39 40 dcPage::addSuccessNotice(__('Configuration successfully updated')); 41 http::redirect($p_url); 42 } 43 catch (Exception $e) 44 { 45 $core->error->add($e->getMessage()); 46 } 47 } 48 49 # Global settings update 50 if (!empty($_POST['gs']) && is_array($_POST['gs'])) 51 { 52 try 53 { 54 foreach ($_POST['gs'] as $ns => $s) { 55 $core->blog->settings->addNamespace($ns); 56 foreach ($s as $k => $v) { 57 if ($_POST['gs_type'][$ns][$k] == 'array') { 58 $v = json_decode($v,true); 59 } 60 $core->blog->settings->$ns->put($k,$v,null,null,true,true); 61 } 62 $core->blog->triggerBlog(); 63 } 64 65 dcPage::addSuccessNotice(__('Configuration successfully updated')); 66 http::redirect($p_url.'&part=global'); 67 } 68 catch (Exception $e) 69 { 70 $core->error->add($e->getMessage()); 71 } 72 } 73 74 $part = !empty($_GET['part']) && $_GET['part'] == 'global' ? 'global' : 'local'; 75 76 function settingLine($id,$s,$ns,$field_name,$strong_label) 77 { 78 if ($s['type'] == 'boolean') { 79 $field = form::combo(array($field_name.'['.$ns.']['.$id.']',$field_name.'_'.$ns.'_'.$id), 80 array(__('yes') => 1, __('no') => 0),$s['value'] ? 1 : 0); 81 } else { 82 if ($s['type'] == 'array') { 83 $field = form::field(array($field_name.'['.$ns.']['.$id.']',$field_name.'_'.$ns.'_'.$id),40,null, 84 html::escapeHTML(json_encode($s['value']))); 85 } else { 86 $field = form::field(array($field_name.'['.$ns.']['.$id.']',$field_name.'_'.$ns.'_'.$id),40,null, 87 html::escapeHTML($s['value'])); 88 } 89 } 90 $type = form::hidden(array($field_name.'_type'.'['.$ns.']['.$id.']',$field_name.'_'.$ns.'_'.$id.'_type'), 91 html::escapeHTML($s['type'])); 92 93 $slabel = $strong_label ? '<strong>%s</strong>' : '%s'; 94 95 return 96 '<tr class="line">'. 97 '<td scope="row"><label for="'.$field_name.'_'.$ns.'_'.$id.'">'.sprintf($slabel,html::escapeHTML($id)).'</label></td>'. 98 '<td>'.$field.'</td>'. 99 '<td>'.$s['type'].$type.'</td>'. 100 '<td>'.html::escapeHTML($s['label']).'</td>'. 101 '</tr>'; 72 if ($s['type'] == 'boolean') { 73 $field = form::combo(array($field_name . '[' . $ns . '][' . $id . ']', $field_name . '_' . $ns . '_' . $id), 74 array(__('yes') => 1, __('no') => 0), $s['value'] ? 1 : 0); 75 } else { 76 if ($s['type'] == 'array') { 77 $field = form::field(array($field_name . '[' . $ns . '][' . $id . ']', $field_name . '_' . $ns . '_' . $id), 40, null, 78 html::escapeHTML(json_encode($s['value']))); 79 } else { 80 $field = form::field(array($field_name . '[' . $ns . '][' . $id . ']', $field_name . '_' . $ns . '_' . $id), 40, null, 81 html::escapeHTML($s['value'])); 82 } 83 } 84 $type = form::hidden(array($field_name . '_type' . '[' . $ns . '][' . $id . ']', $field_name . '_' . $ns . '_' . $id . '_type'), 85 html::escapeHTML($s['type'])); 86 87 $slabel = $strong_label ? '<strong>%s</strong>' : '%s'; 88 89 return 90 '<tr class="line">' . 91 '<td scope="row"><label for="' . $field_name . '_' . $ns . '_' . $id . '">' . sprintf($slabel, html::escapeHTML($id)) . '</label></td>' . 92 '<td>' . $field . '</td>' . 93 '<td>' . $s['type'] . $type . '</td>' . 94 '<td>' . html::escapeHTML($s['label']) . '</td>' . 95 '</tr>'; 102 96 } 103 97 ?> … … 105 99 <head> 106 100 <title>about:config</title> 107 <?php echo dcPage::jsPageTabs($part); ?> 108 <script type="text/javascript"> 109 $(function() { 110 $("#gs_submit").hide(); 111 $("#ls_submit").hide(); 112 $("#gs_nav").change(function() { 113 window.location = $("#gs_nav option:selected").val(); 114 }) 115 $("#ls_nav").change(function() { 116 window.location = $("#ls_nav option:selected").val(); 117 }) 118 }); 119 </script> 101 <?php echo dcPage::jsPageTabs($part) . dcPage::jsLoad(dcPage::getPF('aboutConfig/js/index.js')); ?> 120 102 </head> 121 103 … … 123 105 <?php 124 106 echo dcPage::breadcrumb( 125 126 __('System')=> '',127 128 __('about:config')=> ''129 )).130 131 ?> 132 133 <div id="local" class="multi-part" title="<?php echo sprintf(__('Settings for %s'), html::escapeHTML($core->blog->name)); ?>">134 <h3 class="out-of-screen-if-js"><?php echo sprintf(__('Settings for %s'), html::escapeHTML($core->blog->name)); ?></h3>135 136 <?php 137 $table_header = '<div class="table-outer"><table class="settings" id="%s"><caption class="as_h3">%s</caption>' .138 '<thead>' .139 '<tr>' ."\n".140 ' <th class="nowrap">' .__('Setting ID').'</th>'."\n".141 ' <th>' .__('Value').'</th>'."\n".142 ' <th>' .__('Type').'</th>'."\n".143 ' <th class="maximalx">' .__('Description').'</th>'."\n".144 '</tr>'."\n".145 '</thead>'."\n".146 '<tbody>';107 array( 108 __('System') => '', 109 html::escapeHTML($core->blog->name) => '', 110 __('about:config') => '' 111 )) . 112 dcPage::notices(); 113 ?> 114 115 <div id="local" class="multi-part" title="<?php echo sprintf(__('Settings for %s'), html::escapeHTML($core->blog->name)); ?>"> 116 <h3 class="out-of-screen-if-js"><?php echo sprintf(__('Settings for %s'), html::escapeHTML($core->blog->name)); ?></h3> 117 118 <?php 119 $table_header = '<div class="table-outer"><table class="settings" id="%s"><caption class="as_h3">%s</caption>' . 120 '<thead>' . 121 '<tr>' . "\n" . 122 ' <th class="nowrap">' . __('Setting ID') . '</th>' . "\n" . 123 ' <th>' . __('Value') . '</th>' . "\n" . 124 ' <th>' . __('Type') . '</th>' . "\n" . 125 ' <th class="maximalx">' . __('Description') . '</th>' . "\n" . 126 '</tr>' . "\n" . 127 '</thead>' . "\n" . 128 '<tbody>'; 147 129 $table_footer = '</tbody></table></div>'; 148 130 149 131 $settings = array(); 150 132 foreach ($core->blog->settings->dumpNamespaces() as $ns => $namespace) { 151 152 153 133 foreach ($namespace->dumpSettings() as $k => $v) { 134 $settings[$ns][$k] = $v; 135 } 154 136 } 155 137 ksort($settings); 156 138 if (count($settings) > 0) { 157 158 159 $ns_combo[$ns] = '#l_'.$ns;160 161 162 '<form action="'.$core->adminurl->get('admin.plugin').'" method="post">'.163 '<p class="anchor-nav">'.164 '<label for="ls_nav" class="classic">'.__('Goto:').'</label> '.form::combo('ls_nav',$ns_combo).165 ' <input type="submit" value="'.__('Ok').'" id="ls_submit" />'.166 '<input type="hidden" name="p" value="aboutConfig" />'.167 $core->formNonce().'</p></form>';139 $ns_combo = array(); 140 foreach ($settings as $ns => $s) { 141 $ns_combo[$ns] = '#l_' . $ns; 142 } 143 echo 144 '<form action="' . $core->adminurl->get('admin.plugin') . '" method="post">' . 145 '<p class="anchor-nav">' . 146 '<label for="ls_nav" class="classic">' . __('Goto:') . '</label> ' . form::combo('ls_nav', $ns_combo) . 147 ' <input type="submit" value="' . __('Ok') . '" id="ls_submit" />' . 148 '<input type="hidden" name="p" value="aboutConfig" />' . 149 $core->formNonce() . '</p></form>'; 168 150 } 169 151 ?> … … 172 154 173 155 <?php 174 foreach ($settings as $ns => $s) 175 { 176 ksort($s); 177 echo sprintf($table_header,'l_'.$ns,$ns); 178 foreach ($s as $k => $v) 179 { 180 echo settingLine($k,$v,$ns,'s',!$v['global']); 181 } 182 echo $table_footer; 156 foreach ($settings as $ns => $s) { 157 ksort($s); 158 echo sprintf($table_header, 'l_' . $ns, $ns); 159 foreach ($s as $k => $v) { 160 echo settingLine($k, $v, $ns, 's', !$v['global']); 161 } 162 echo $table_footer; 183 163 } 184 164 ?> … … 197 177 198 178 foreach ($core->blog->settings->dumpNamespaces() as $ns => $namespace) { 199 200 201 179 foreach ($namespace->dumpGlobalSettings() as $k => $v) { 180 $settings[$ns][$k] = $v; 181 } 202 182 } 203 183 … … 205 185 206 186 if (count($settings) > 0) { 207 208 209 $ns_combo[$ns] = '#g_'.$ns;210 211 212 '<form action="'.$core->adminurl->get('admin.plugin').'" method="post">'.213 '<p class="anchor-nav">'.214 '<label for="gs_nav" class="classic">'.__('Goto:').'</label> '.form::combo('gs_nav',$ns_combo).' '.215 '<input type="submit" value="'.__('Ok').'" id="gs_submit" />'.216 '<input type="hidden" name="p" value="aboutConfig" />'.217 $core->formNonce().'</p></form>';187 $ns_combo = array(); 188 foreach ($settings as $ns => $s) { 189 $ns_combo[$ns] = '#g_' . $ns; 190 } 191 echo 192 '<form action="' . $core->adminurl->get('admin.plugin') . '" method="post">' . 193 '<p class="anchor-nav">' . 194 '<label for="gs_nav" class="classic">' . __('Goto:') . '</label> ' . form::combo('gs_nav', $ns_combo) . ' ' . 195 '<input type="submit" value="' . __('Ok') . '" id="gs_submit" />' . 196 '<input type="hidden" name="p" value="aboutConfig" />' . 197 $core->formNonce() . '</p></form>'; 218 198 } 219 199 ?> … … 222 202 223 203 <?php 224 foreach ($settings as $ns => $s) 225 { 226 ksort($s); 227 echo sprintf($table_header,'g_'.$ns,$ns); 228 foreach ($s as $k => $v) 229 { 230 echo settingLine($k,$v,$ns,'gs',false); 231 } 232 echo $table_footer; 204 foreach ($settings as $ns => $s) { 205 ksort($s); 206 echo sprintf($table_header, 'g_' . $ns, $ns); 207 foreach ($s as $k => $v) { 208 echo settingLine($k, $v, $ns, 'gs', false); 209 } 210 echo $table_footer; 233 211 } 234 212 ?> … … 240 218 </div> 241 219 242 <?php dcPage::helpBlock('aboutConfig'); 220 <?php dcPage::helpBlock('aboutConfig');?> 243 221 244 222 </body> -
plugins/antispam/antispam.js
r2207 r3709 1 /*global $, dotclear */ 2 'use strict'; 3 1 4 $(function() { 2 $( "#filters-list").sortable({'cursor':'move'});3 $( "#filters-list tr").hover(function () {5 $('#filters-list').sortable({'cursor':'move'}); 6 $('#filters-list tr').hover(function () { 4 7 $(this).css({'cursor':'move'}); 5 8 }, function () { … … 8 11 $('#filters-list-form').submit(function() { 9 12 var order=[]; 10 $( "#filters-list tr td input.position").each(function() {13 $('#filters-list tr td input.position').each(function() { 11 14 order.push(this.name.replace(/^f_order\[([^\]]+)\]$/,'$1')); 12 15 }); 13 $( "input[name=filters_order]")[0].value = order.join(',');16 $('input[name=filters_order]')[0].value = order.join(','); 14 17 return true; 15 18 }); 16 $( "#filters-list tr td input.position").hide();17 $( "#filters-list tr td.handle").addClass('handler');19 $('#filters-list tr td input.position').hide(); 20 $('#filters-list tr td.handle').addClass('handler'); 18 21 19 22 $('form input[type=submit][name=delete_all]').click(function(){ -
plugins/attachments/js/post.js
r1699 r3709 1 /*global $ */ 2 'use strict'; 3 1 4 $(function() { 2 $('h5.s-attachments').toggleWithLegend($('.s-attachments').not('h5'),{3 4 5 5 $('h5.s-attachments').toggleWithLegend($('.s-attachments').not('h5'), { 6 user_pref: 'dcx_attachments', 7 legend_click: true 8 }); 6 9 }); -
plugins/blogroll/index.php
r3707 r3709 169 169 dcPage::jsLoad('js/jquery/jquery-ui.custom.js') . 170 170 dcPage::jsLoad('js/jquery/jquery.ui.touch-punch.js') . 171 dcPage::jsLoad(dcPage::getPF('blogroll/ blogroll.js'));171 dcPage::jsLoad(dcPage::getPF('blogroll/js/blogroll.js')); 172 172 } 173 173 ?> … … 328 328 echo 329 329 '<tr><td>' . form::checkbox(array('entries[]'), $i) . '</td>' . 330 '<td nowrap><a href="' . $url . '">' . $title . '</a>' .331 '<input type="hidden" name="url[' . $i . ']" value="' . $url . '" />' .332 '<input type="hidden" name="title[' . $i . ']" value="' . $title . '" />' .333 '</td>' .334 '<td>' . $desc .335 '<input type="hidden" name="desc[' . $i . ']" value="' . $desc . '" />' .336 '</td></tr>' . "\n";330 '<td nowrap><a href="' . $url . '">' . $title . '</a>' . 331 '<input type="hidden" name="url[' . $i . ']" value="' . $url . '" />' . 332 '<input type="hidden" name="title[' . $i . ']" value="' . $title . '" />' . 333 '</td>' . 334 '<td>' . $desc . 335 '<input type="hidden" name="desc[' . $i . ']" value="' . $desc . '" />' . 336 '</td></tr>' . "\n"; 337 337 $i++; 338 338 } -
plugins/blowupConfig/index.php
r3421 r3709 10 10 # 11 11 # -- END LICENSE BLOCK ----------------------------------------- 12 if (!defined('DC_CONTEXT_ADMIN')) { return;}13 14 require dirname(__FILE__) .'/lib/class.blowup.config.php';12 if (!defined('DC_CONTEXT_ADMIN')) {return;} 13 14 require dirname(__FILE__) . '/lib/class.blowup.config.php'; 15 15 16 16 $can_write_images = blowupConfig::canWriteImages(); 17 $can_write_css = blowupConfig::canWriteCss();17 $can_write_css = blowupConfig::canWriteCss(); 18 18 19 19 if ($core->error->flag()) { 20 21 20 $notices = $core->error->toHTML(); 21 $core->error->reset(); 22 22 } 23 23 24 24 $blowup_base = array( 25 'body_bg_c'=> null,26 'body_bg_g'=> 'light',27 28 'body_txt_f'=> null,29 'body_txt_s'=> null,30 'body_txt_c'=> null,31 'body_line_height'=> null,32 33 'top_image'=> 'default',34 'top_height'=> null,35 'uploaded'=> null,36 37 'blog_title_hide'=> null,38 'blog_title_f'=> null,39 'blog_title_s'=> null,40 'blog_title_c'=> null,41 'blog_title_a'=> null,42 'blog_title_p'=> null,43 44 'body_link_c'=> null,45 'body_link_f_c'=> null,46 'body_link_v_c'=> null,47 48 'sidebar_position'=> null,49 'sidebar_text_f'=> null,50 'sidebar_text_s'=> null,51 'sidebar_text_c'=> null,52 'sidebar_title_f'=> null,53 'sidebar_title_s'=> null,54 'sidebar_title_c'=> null,55 'sidebar_title2_f'=> null,56 'sidebar_title2_s'=> null,57 'sidebar_title2_c'=> null,58 'sidebar_line_c'=> null,59 'sidebar_link_c'=> null,60 'sidebar_link_f_c'=> null,61 'sidebar_link_v_c'=> null,62 63 'date_title_f'=> null,64 'date_title_s'=> null,65 'date_title_c'=> null,66 67 'post_title_f'=> null,68 'post_title_s'=> null,69 'post_title_c'=> null,70 'post_comment_bg_c'=> null,71 'post_comment_c'=> null,72 73 'post_commentmy_c'=> null,74 75 'prelude_c'=> null,76 'footer_f'=> null,77 'footer_s'=> null,78 'footer_c'=> null,79 'footer_l_c'=> null,80 'footer_bg_c'=> null,81 82 'extra_css'=> null25 'body_bg_c' => null, 26 'body_bg_g' => 'light', 27 28 'body_txt_f' => null, 29 'body_txt_s' => null, 30 'body_txt_c' => null, 31 'body_line_height' => null, 32 33 'top_image' => 'default', 34 'top_height' => null, 35 'uploaded' => null, 36 37 'blog_title_hide' => null, 38 'blog_title_f' => null, 39 'blog_title_s' => null, 40 'blog_title_c' => null, 41 'blog_title_a' => null, 42 'blog_title_p' => null, 43 44 'body_link_c' => null, 45 'body_link_f_c' => null, 46 'body_link_v_c' => null, 47 48 'sidebar_position' => null, 49 'sidebar_text_f' => null, 50 'sidebar_text_s' => null, 51 'sidebar_text_c' => null, 52 'sidebar_title_f' => null, 53 'sidebar_title_s' => null, 54 'sidebar_title_c' => null, 55 'sidebar_title2_f' => null, 56 'sidebar_title2_s' => null, 57 'sidebar_title2_c' => null, 58 'sidebar_line_c' => null, 59 'sidebar_link_c' => null, 60 'sidebar_link_f_c' => null, 61 'sidebar_link_v_c' => null, 62 63 'date_title_f' => null, 64 'date_title_s' => null, 65 'date_title_c' => null, 66 67 'post_title_f' => null, 68 'post_title_s' => null, 69 'post_title_c' => null, 70 'post_comment_bg_c' => null, 71 'post_comment_c' => null, 72 'post_commentmy_bg_c' => null, 73 'post_commentmy_c' => null, 74 75 'prelude_c' => null, 76 'footer_f' => null, 77 'footer_s' => null, 78 'footer_c' => null, 79 'footer_l_c' => null, 80 'footer_bg_c' => null, 81 82 'extra_css' => null 83 83 ); 84 84 … … 87 87 $blowup_user = @unserialize($blowup_user); 88 88 if (!is_array($blowup_user)) { 89 90 } 91 92 $blowup_user = array_merge($blowup_base, $blowup_user);89 $blowup_user = array(); 90 } 91 92 $blowup_user = array_merge($blowup_base, $blowup_user); 93 93 94 94 $gradient_types = array( 95 __('Light linear gradient')=> 'light',96 97 __('Dark linear gradient')=> 'dark',98 __('Solid color')=> 'solid'95 __('Light linear gradient') => 'light', 96 __('Medium linear gradient') => 'medium', 97 __('Dark linear gradient') => 'dark', 98 __('Solid color') => 'solid' 99 99 ); 100 100 101 101 $top_images = array(__('Custom...') => 'custom'); 102 $top_images = array_merge($top_images,array_flip(blowupConfig::$top_images)); 103 104 105 if (!empty($_POST)) 106 { 107 try 108 { 109 $blowup_user['body_txt_f'] = $_POST['body_txt_f']; 110 $blowup_user['body_txt_s'] = dcThemeConfig::adjustFontSize($_POST['body_txt_s']); 111 $blowup_user['body_txt_c'] = dcThemeConfig::adjustColor($_POST['body_txt_c']); 112 $blowup_user['body_line_height'] = dcThemeConfig::adjustFontSize($_POST['body_line_height']); 113 114 $blowup_user['blog_title_hide'] = (integer) !empty($_POST['blog_title_hide']); 115 $update_blog_title = !$blowup_user['blog_title_hide'] && ( 116 !empty($_POST['blog_title_f']) || !empty($_POST['blog_title_s']) || 117 !empty($_POST['blog_title_c']) || !empty($_POST['blog_title_a']) || 118 !empty($_POST['blog_title_p']) 119 ); 120 121 if ($update_blog_title) 122 { 123 $blowup_user['blog_title_f'] = $_POST['blog_title_f']; 124 $blowup_user['blog_title_s'] = dcThemeConfig::adjustFontSize($_POST['blog_title_s']); 125 $blowup_user['blog_title_c'] = dcThemeConfig::adjustColor($_POST['blog_title_c']); 126 $blowup_user['blog_title_a'] = preg_match('/^(left|center|right)$/',$_POST['blog_title_a']) ? $_POST['blog_title_a'] : null; 127 $blowup_user['blog_title_p'] = dcThemeConfig::adjustPosition($_POST['blog_title_p']); 128 } 129 130 $blowup_user['body_link_c'] = dcThemeConfig::adjustColor($_POST['body_link_c']); 131 $blowup_user['body_link_f_c'] = dcThemeConfig::adjustColor($_POST['body_link_f_c']); 132 $blowup_user['body_link_v_c'] = dcThemeConfig::adjustColor($_POST['body_link_v_c']); 133 134 $blowup_user['sidebar_text_f'] = $_POST['sidebar_text_f']; 135 $blowup_user['sidebar_text_s'] = dcThemeConfig::adjustFontSize($_POST['sidebar_text_s']); 136 $blowup_user['sidebar_text_c'] = dcThemeConfig::adjustColor($_POST['sidebar_text_c']); 137 $blowup_user['sidebar_title_f'] = $_POST['sidebar_title_f']; 138 $blowup_user['sidebar_title_s'] = dcThemeConfig::adjustFontSize($_POST['sidebar_title_s']); 139 $blowup_user['sidebar_title_c'] = dcThemeConfig::adjustColor($_POST['sidebar_title_c']); 140 $blowup_user['sidebar_title2_f'] = $_POST['sidebar_title2_f']; 141 $blowup_user['sidebar_title2_s'] = dcThemeConfig::adjustFontSize($_POST['sidebar_title2_s']); 142 $blowup_user['sidebar_title2_c'] = dcThemeConfig::adjustColor($_POST['sidebar_title2_c']); 143 $blowup_user['sidebar_line_c'] = dcThemeConfig::adjustColor($_POST['sidebar_line_c']); 144 $blowup_user['sidebar_link_c'] = dcThemeConfig::adjustColor($_POST['sidebar_link_c']); 145 $blowup_user['sidebar_link_f_c'] = dcThemeConfig::adjustColor($_POST['sidebar_link_f_c']); 146 $blowup_user['sidebar_link_v_c'] = dcThemeConfig::adjustColor($_POST['sidebar_link_v_c']); 147 148 $blowup_user['sidebar_position'] = ($_POST['sidebar_position'] == 'left') ? 'left' : null; 149 150 $blowup_user['date_title_f'] = $_POST['date_title_f']; 151 $blowup_user['date_title_s'] = dcThemeConfig::adjustFontSize($_POST['date_title_s']); 152 $blowup_user['date_title_c'] = dcThemeConfig::adjustColor($_POST['date_title_c']); 153 154 $blowup_user['post_title_f'] = $_POST['post_title_f']; 155 $blowup_user['post_title_s'] = dcThemeConfig::adjustFontSize($_POST['post_title_s']); 156 $blowup_user['post_title_c'] = dcThemeConfig::adjustColor($_POST['post_title_c']); 157 $blowup_user['post_comment_c'] = dcThemeConfig::adjustColor($_POST['post_comment_c']); 158 $blowup_user['post_commentmy_c'] = dcThemeConfig::adjustColor($_POST['post_commentmy_c']); 159 160 161 $blowup_user['footer_f'] = $_POST['footer_f']; 162 $blowup_user['footer_s'] = dcThemeConfig::adjustFontSize($_POST['footer_s']); 163 $blowup_user['footer_c'] = dcThemeConfig::adjustColor($_POST['footer_c']); 164 $blowup_user['footer_l_c'] = dcThemeConfig::adjustColor($_POST['footer_l_c']); 165 $blowup_user['footer_bg_c'] = dcThemeConfig::adjustColor($_POST['footer_bg_c']); 166 167 168 $blowup_user['extra_css'] = dcThemeConfig::cleanCSS($_POST['extra_css']); 169 170 if ($can_write_images) 171 { 172 $uploaded = null; 173 if ($blowup_user['uploaded'] && is_file(blowupConfig::imagesPath().'/'.$blowup_user['uploaded'])) { 174 $uploaded = blowupConfig::imagesPath().'/'.$blowup_user['uploaded']; 175 } 176 177 if (!empty($_FILES['upfile']) && !empty($_FILES['upfile']['name'])) { 178 files::uploadStatus($_FILES['upfile']); 179 $uploaded = blowupConfig::uploadImage($_FILES['upfile']); 180 $blowup_user['uploaded'] = basename($uploaded); 181 } 182 183 $blowup_user['top_image'] = in_array($_POST['top_image'],$top_images) ? $_POST['top_image'] : 'default'; 184 185 $blowup_user['body_bg_c'] = dcThemeConfig::adjustColor($_POST['body_bg_c']); 186 $blowup_user['body_bg_g'] = in_array($_POST['body_bg_g'],$gradient_types) ? $_POST['body_bg_g'] : ''; 187 $blowup_user['post_comment_bg_c'] = dcThemeConfig::adjustColor($_POST['post_comment_bg_c']); 188 $blowup_user['post_commentmy_bg_c'] = dcThemeConfig::adjustColor($_POST['post_commentmy_bg_c']); 189 $blowup_user['prelude_c'] = dcThemeConfig::adjustColor($_POST['prelude_c']); 190 blowupConfig::createImages($blowup_user,$uploaded); 191 } 192 193 if ($can_write_css) 194 { 195 blowupConfig::createCss($blowup_user); 196 } 197 198 $core->blog->settings->addNamespace('themes'); 199 $core->blog->settings->themes->put('blowup_style',serialize($blowup_user)); 200 $core->blog->triggerBlog(); 201 202 dcPage::addSuccessNotice(__('Theme configuration has been successfully updated.')); 203 http::redirect($p_url); 204 } 205 catch (Exception $e) 206 { 207 $core->error->add($e->getMessage()); 208 } 102 $top_images = array_merge($top_images, array_flip(blowupConfig::$top_images)); 103 104 if (!empty($_POST)) { 105 try 106 { 107 $blowup_user['body_txt_f'] = $_POST['body_txt_f']; 108 $blowup_user['body_txt_s'] = dcThemeConfig::adjustFontSize($_POST['body_txt_s']); 109 $blowup_user['body_txt_c'] = dcThemeConfig::adjustColor($_POST['body_txt_c']); 110 $blowup_user['body_line_height'] = dcThemeConfig::adjustFontSize($_POST['body_line_height']); 111 112 $blowup_user['blog_title_hide'] = (integer) !empty($_POST['blog_title_hide']); 113 $update_blog_title = !$blowup_user['blog_title_hide'] && ( 114 !empty($_POST['blog_title_f']) || !empty($_POST['blog_title_s']) || 115 !empty($_POST['blog_title_c']) || !empty($_POST['blog_title_a']) || 116 !empty($_POST['blog_title_p']) 117 ); 118 119 if ($update_blog_title) { 120 $blowup_user['blog_title_f'] = $_POST['blog_title_f']; 121 $blowup_user['blog_title_s'] = dcThemeConfig::adjustFontSize($_POST['blog_title_s']); 122 $blowup_user['blog_title_c'] = dcThemeConfig::adjustColor($_POST['blog_title_c']); 123 $blowup_user['blog_title_a'] = preg_match('/^(left|center|right)$/', $_POST['blog_title_a']) ? $_POST['blog_title_a'] : null; 124 $blowup_user['blog_title_p'] = dcThemeConfig::adjustPosition($_POST['blog_title_p']); 125 } 126 127 $blowup_user['body_link_c'] = dcThemeConfig::adjustColor($_POST['body_link_c']); 128 $blowup_user['body_link_f_c'] = dcThemeConfig::adjustColor($_POST['body_link_f_c']); 129 $blowup_user['body_link_v_c'] = dcThemeConfig::adjustColor($_POST['body_link_v_c']); 130 131 $blowup_user['sidebar_text_f'] = $_POST['sidebar_text_f']; 132 $blowup_user['sidebar_text_s'] = dcThemeConfig::adjustFontSize($_POST['sidebar_text_s']); 133 $blowup_user['sidebar_text_c'] = dcThemeConfig::adjustColor($_POST['sidebar_text_c']); 134 $blowup_user['sidebar_title_f'] = $_POST['sidebar_title_f']; 135 $blowup_user['sidebar_title_s'] = dcThemeConfig::adjustFontSize($_POST['sidebar_title_s']); 136 $blowup_user['sidebar_title_c'] = dcThemeConfig::adjustColor($_POST['sidebar_title_c']); 137 $blowup_user['sidebar_title2_f'] = $_POST['sidebar_title2_f']; 138 $blowup_user['sidebar_title2_s'] = dcThemeConfig::adjustFontSize($_POST['sidebar_title2_s']); 139 $blowup_user['sidebar_title2_c'] = dcThemeConfig::adjustColor($_POST['sidebar_title2_c']); 140 $blowup_user['sidebar_line_c'] = dcThemeConfig::adjustColor($_POST['sidebar_line_c']); 141 $blowup_user['sidebar_link_c'] = dcThemeConfig::adjustColor($_POST['sidebar_link_c']); 142 $blowup_user['sidebar_link_f_c'] = dcThemeConfig::adjustColor($_POST['sidebar_link_f_c']); 143 $blowup_user['sidebar_link_v_c'] = dcThemeConfig::adjustColor($_POST['sidebar_link_v_c']); 144 145 $blowup_user['sidebar_position'] = ($_POST['sidebar_position'] == 'left') ? 'left' : null; 146 147 $blowup_user['date_title_f'] = $_POST['date_title_f']; 148 $blowup_user['date_title_s'] = dcThemeConfig::adjustFontSize($_POST['date_title_s']); 149 $blowup_user['date_title_c'] = dcThemeConfig::adjustColor($_POST['date_title_c']); 150 151 $blowup_user['post_title_f'] = $_POST['post_title_f']; 152 $blowup_user['post_title_s'] = dcThemeConfig::adjustFontSize($_POST['post_title_s']); 153 $blowup_user['post_title_c'] = dcThemeConfig::adjustColor($_POST['post_title_c']); 154 $blowup_user['post_comment_c'] = dcThemeConfig::adjustColor($_POST['post_comment_c']); 155 $blowup_user['post_commentmy_c'] = dcThemeConfig::adjustColor($_POST['post_commentmy_c']); 156 157 $blowup_user['footer_f'] = $_POST['footer_f']; 158 $blowup_user['footer_s'] = dcThemeConfig::adjustFontSize($_POST['footer_s']); 159 $blowup_user['footer_c'] = dcThemeConfig::adjustColor($_POST['footer_c']); 160 $blowup_user['footer_l_c'] = dcThemeConfig::adjustColor($_POST['footer_l_c']); 161 $blowup_user['footer_bg_c'] = dcThemeConfig::adjustColor($_POST['footer_bg_c']); 162 163 $blowup_user['extra_css'] = dcThemeConfig::cleanCSS($_POST['extra_css']); 164 165 if ($can_write_images) { 166 $uploaded = null; 167 if ($blowup_user['uploaded'] && is_file(blowupConfig::imagesPath() . '/' . $blowup_user['uploaded'])) { 168 $uploaded = blowupConfig::imagesPath() . '/' . $blowup_user['uploaded']; 169 } 170 171 if (!empty($_FILES['upfile']) && !empty($_FILES['upfile']['name'])) { 172 files::uploadStatus($_FILES['upfile']); 173 $uploaded = blowupConfig::uploadImage($_FILES['upfile']); 174 $blowup_user['uploaded'] = basename($uploaded); 175 } 176 177 $blowup_user['top_image'] = in_array($_POST['top_image'], $top_images) ? $_POST['top_image'] : 'default'; 178 179 $blowup_user['body_bg_c'] = dcThemeConfig::adjustColor($_POST['body_bg_c']); 180 $blowup_user['body_bg_g'] = in_array($_POST['body_bg_g'], $gradient_types) ? $_POST['body_bg_g'] : ''; 181 $blowup_user['post_comment_bg_c'] = dcThemeConfig::adjustColor($_POST['post_comment_bg_c']); 182 $blowup_user['post_commentmy_bg_c'] = dcThemeConfig::adjustColor($_POST['post_commentmy_bg_c']); 183 $blowup_user['prelude_c'] = dcThemeConfig::adjustColor($_POST['prelude_c']); 184 blowupConfig::createImages($blowup_user, $uploaded); 185 } 186 187 if ($can_write_css) { 188 blowupConfig::createCss($blowup_user); 189 } 190 191 $core->blog->settings->addNamespace('themes'); 192 $core->blog->settings->themes->put('blowup_style', serialize($blowup_user)); 193 $core->blog->triggerBlog(); 194 195 dcPage::addSuccessNotice(__('Theme configuration has been successfully updated.')); 196 http::redirect($p_url); 197 } catch (Exception $e) { 198 $core->error->add($e->getMessage()); 199 } 209 200 } 210 201 ?> … … 212 203 <head> 213 204 <title><?php echo __('Blowup configuration'); ?></title> 214 <?php echo dcPage::jsLoad(dcPage::getPF('blowupConfig/config.js')); ?>215 <?php echo dcPage::jsColorPicker(); ?>216 <script type="text/javascript">217 205 <?php 218 echo dcPage::jsVar('dotclear.blowup_public_url',blowupConfig::imagesURL()); 219 echo dcPage::jsVar('dotclear.msg.predefined_styles',__('Predefined styles')); 220 echo dcPage::jsVar('dotclear.msg.apply_code',__('Apply code')); 221 echo dcPage::jsVar('dotclear.msg.predefined_style_title',__('Choose a predefined style')); 222 ?> 223 </script> 206 echo dcPage::jsLoad(dcPage::getPF('blowupConfig/js/config.js')); 207 echo dcPage::jsColorPicker(); 208 echo dcPage::jsVars(array( 209 'dotclear.blowup_public_url' => blowupConfig::imagesURL(), 210 'dotclear.msg.predefined_styles' => __('Predefined styles'), 211 'dotclear.msg.apply_code' => __('Apply code'), 212 'dotclear.msg.predefined_style_title' => __('Choose a predefined style') 213 )); 214 ?> 224 215 </head> 225 216 … … 227 218 <?php 228 219 echo dcPage::breadcrumb( 229 array( 230 html::escapeHTML($core->blog->name) => '', 231 __('Blog appearance') => $core->adminurl->get('admin.blog.theme'), 232 __('Blowup configuration') => '' 233 )).dcPage::notices(); 234 235 echo 236 '<p><a class="back" href="'.$core->adminurl->get('admin.blog.theme').'">'.__('Back to Blog appearance').'</a></p>'; 237 220 array( 221 html::escapeHTML($core->blog->name) => '', 222 __('Blog appearance') => $core->adminurl->get('admin.blog.theme'), 223 __('Blowup configuration') => '' 224 )) . dcPage::notices(); 225 226 echo 227 '<p><a class="back" href="' . $core->adminurl->get('admin.blog.theme') . '">' . __('Back to Blog appearance') . '</a></p>'; 238 228 239 229 if (!$can_write_images) { 240 dcPage::message(__('For the following reasons, images cannot be created. You won\'t be able to change some background properties.').241 $notices,false,true);242 } 243 244 echo '<form id="theme_config" action="' .$p_url.'" method="post" enctype="multipart/form-data">';245 246 echo '<div class="fieldset"><h3>' .__('Customization').'</h3>'.247 '<h4>' .__('General').'</h4>';230 dcPage::message(__('For the following reasons, images cannot be created. You won\'t be able to change some background properties.') . 231 $notices, false, true); 232 } 233 234 echo '<form id="theme_config" action="' . $p_url . '" method="post" enctype="multipart/form-data">'; 235 236 echo '<div class="fieldset"><h3>' . __('Customization') . '</h3>' . 237 '<h4>' . __('General') . '</h4>'; 248 238 249 239 if ($can_write_images) { 250 251 '<p class="field"><label for="body_bg_c">'.__('Background color:').'</label> '.252 form::field('body_bg_c',7,7,$blowup_user['body_bg_c'],'colorpicker').'</p>'.253 254 '<p class="field"><label for="body_bg_g">'.__('Background color fill:').'</label> '.255 form::combo('body_bg_g',$gradient_types,$blowup_user['body_bg_g']).'</p>';256 } 257 258 echo 259 '<p class="field"><label for="body_txt_f">' .__('Main text font:').'</label> '.260 form::combo('body_txt_f', blowupConfig::fontsList(),$blowup_user['body_txt_f']).'</p>'.261 262 '<p class="field"><label for="body_txt_s">' .__('Main text font size:').'</label> '.263 form::field('body_txt_s', 7,7,$blowup_user['body_txt_s']).'</p>'.264 265 '<p class="field"><label for="body_txt_c">' .__('Main text color:').'</label> '.266 form::field('body_txt_c', 7,7,$blowup_user['body_txt_c'],'colorpicker').'</p>'.267 268 '<p class="field"><label for="body_line_height">' .__('Text line height:').'</label> '.269 form::field('body_line_height', 7,7,$blowup_user['body_line_height']).'</p>'.270 271 '<h4 class="border-top">' .__('Links').'</h4>'.272 '<p class="field"><label for="body_link_c">' .__('Links color:').'</label> '.273 form::field('body_link_c', 7,7,$blowup_user['body_link_c'],'colorpicker').'</p>'.274 275 '<p class="field"><label for="body_link_v_c">' .__('Visited links color:').'</label> '.276 form::field('body_link_v_c', 7,7,$blowup_user['body_link_v_c'],'colorpicker').'</p>'.277 278 '<p class="field"><label for="body_link_f_c">' .__('Focus links color:').'</label> '.279 form::field('body_link_f_c', 7,7,$blowup_user['body_link_f_c'],'colorpicker').'</p>'.280 281 '<h4 class="border-top">' .__('Page top').'</h4>';240 echo 241 '<p class="field"><label for="body_bg_c">' . __('Background color:') . '</label> ' . 242 form::field('body_bg_c', 7, 7, $blowup_user['body_bg_c'], 'colorpicker') . '</p>' . 243 244 '<p class="field"><label for="body_bg_g">' . __('Background color fill:') . '</label> ' . 245 form::combo('body_bg_g', $gradient_types, $blowup_user['body_bg_g']) . '</p>'; 246 } 247 248 echo 249 '<p class="field"><label for="body_txt_f">' . __('Main text font:') . '</label> ' . 250 form::combo('body_txt_f', blowupConfig::fontsList(), $blowup_user['body_txt_f']) . '</p>' . 251 252 '<p class="field"><label for="body_txt_s">' . __('Main text font size:') . '</label> ' . 253 form::field('body_txt_s', 7, 7, $blowup_user['body_txt_s']) . '</p>' . 254 255 '<p class="field"><label for="body_txt_c">' . __('Main text color:') . '</label> ' . 256 form::field('body_txt_c', 7, 7, $blowup_user['body_txt_c'], 'colorpicker') . '</p>' . 257 258 '<p class="field"><label for="body_line_height">' . __('Text line height:') . '</label> ' . 259 form::field('body_line_height', 7, 7, $blowup_user['body_line_height']) . '</p>' . 260 261 '<h4 class="border-top">' . __('Links') . '</h4>' . 262 '<p class="field"><label for="body_link_c">' . __('Links color:') . '</label> ' . 263 form::field('body_link_c', 7, 7, $blowup_user['body_link_c'], 'colorpicker') . '</p>' . 264 265 '<p class="field"><label for="body_link_v_c">' . __('Visited links color:') . '</label> ' . 266 form::field('body_link_v_c', 7, 7, $blowup_user['body_link_v_c'], 'colorpicker') . '</p>' . 267 268 '<p class="field"><label for="body_link_f_c">' . __('Focus links color:') . '</label> ' . 269 form::field('body_link_f_c', 7, 7, $blowup_user['body_link_f_c'], 'colorpicker') . '</p>' . 270 271 '<h4 class="border-top">' . __('Page top') . '</h4>'; 282 272 283 273 if ($can_write_images) { 284 285 '<p class="field"><label for="prelude_c">'.__('Prelude color:').'</label> '.286 form::field('prelude_c',7,7,$blowup_user['prelude_c'],'colorpicker').'</p>';287 } 288 289 echo 290 '<p class="field"><label for="blog_title_hide">' .__('Hide main title').'</label> '.291 form::checkbox('blog_title_hide', 1,$blowup_user['blog_title_hide']).'</p>'.292 293 '<p class="field"><label for="blog_title_f">' .__('Main title font:').'</label> '.294 form::combo('blog_title_f', blowupConfig::fontsList(),$blowup_user['blog_title_f']).'</p>'.295 296 '<p class="field"><label for="blog_title_s">' .__('Main title font size:').'</label> '.297 form::field('blog_title_s', 7,7,$blowup_user['blog_title_s']).'</p>'.298 299 '<p class="field"><label for="blog_title_c">' .__('Main title color:').'</label> '.300 form::field('blog_title_c', 7,7,$blowup_user['blog_title_c'],'colorpicker').'</p>'.301 302 '<p class="field"><label for="blog_title_a">' .__('Main title alignment:').'</label> '.303 form::combo('blog_title_a', array(__('center')=>'center',__('left')=>'left',__('right')=>'right'),$blowup_user['blog_title_a']).'</p>'.304 305 '<p class="field"><label for="blog_title_p">' .__('Main title position (x:y)').'</label> '.306 form::field('blog_title_p', 7,7,$blowup_user['blog_title_p']).'</p>';274 echo 275 '<p class="field"><label for="prelude_c">' . __('Prelude color:') . '</label> ' . 276 form::field('prelude_c', 7, 7, $blowup_user['prelude_c'], 'colorpicker') . '</p>'; 277 } 278 279 echo 280 '<p class="field"><label for="blog_title_hide">' . __('Hide main title') . '</label> ' . 281 form::checkbox('blog_title_hide', 1, $blowup_user['blog_title_hide']) . '</p>' . 282 283 '<p class="field"><label for="blog_title_f">' . __('Main title font:') . '</label> ' . 284 form::combo('blog_title_f', blowupConfig::fontsList(), $blowup_user['blog_title_f']) . '</p>' . 285 286 '<p class="field"><label for="blog_title_s">' . __('Main title font size:') . '</label> ' . 287 form::field('blog_title_s', 7, 7, $blowup_user['blog_title_s']) . '</p>' . 288 289 '<p class="field"><label for="blog_title_c">' . __('Main title color:') . '</label> ' . 290 form::field('blog_title_c', 7, 7, $blowup_user['blog_title_c'], 'colorpicker') . '</p>' . 291 292 '<p class="field"><label for="blog_title_a">' . __('Main title alignment:') . '</label> ' . 293 form::combo('blog_title_a', array(__('center') => 'center', __('left') => 'left', __('right') => 'right'), $blowup_user['blog_title_a']) . '</p>' . 294 295 '<p class="field"><label for="blog_title_p">' . __('Main title position (x:y)') . '</label> ' . 296 form::field('blog_title_p', 7, 7, $blowup_user['blog_title_p']) . '</p>'; 307 297 308 298 if ($can_write_images) { 309 310 $preview_image = http::concatURL($core->blog->url,blowupConfig::imagesURL().'/page-t.png');311 312 $preview_image = dcPage::getPF('blowupConfig/alpha-img/page-t/'.$blowup_user['top_image'].'.png');313 314 315 316 '<h5 class="pretty-title">'.__('Top image').'</h5>'.317 '<p class="field"><label for="top_image">'.__('Top image').'</label> '.318 form::combo('top_image',$top_images,($blowup_user['top_image'] ?: 'default')).'</p>'.319 '<p>'.__('Choose "Custom..." to upload your own image.').'</p>'.320 321 '<p id="uploader"><label for="upfile">'.__('Add your image:').'</label> '.322 ' ('.sprintf(__('JPEG or PNG file, 800 pixels wide, maximum size %s'),files::size(DC_MAX_UPLOAD_SIZE)).')'.323 '<input type="file" name="upfile" id="upfile" size="35" />'.324 '</p>'.325 326 '<h5>'.__('Preview').'</h5>'.327 '<div class="grid" style="width:800px;border:1px solid #ccc;">'.328 '<img style="display:block;" src="'.$preview_image.'" alt="" id="image-preview" />'.329 330 } 331 332 echo 333 '<h4 class="border-top">' .__('Sidebar').'</h4>'.334 '<p class="field"><label for="sidebar_position">' .__('Sidebar position:').'</label> '.335 form::combo('sidebar_position', array(__('right')=>'right',__('left')=>'left'),$blowup_user['sidebar_position']).'</p>'.336 337 '<p class="field"><label for="sidebar_text_f">' .__('Sidebar text font:').'</label> '.338 form::combo('sidebar_text_f', blowupConfig::fontsList(),$blowup_user['sidebar_text_f']).'</p>'.339 340 '<p class="field"><label for="sidebar_text_s">' .__('Sidebar text font size:').'</label> '.341 form::field('sidebar_text_s', 7,7,$blowup_user['sidebar_text_s']).'</p>'.342 343 '<p class="field"><label for="sidebar_text_c">' .__('Sidebar text color:').'</label> '.344 form::field('sidebar_text_c', 7,7,$blowup_user['sidebar_text_c'],'colorpicker').'</p>'.345 346 '<p class="field"><label for="sidebar_title_f">' .__('Sidebar titles font:').'</label> '.347 form::combo('sidebar_title_f', blowupConfig::fontsList(),$blowup_user['sidebar_title_f']).'</p>'.348 349 '<p class="field"><label for="sidebar_title_s">' .__('Sidebar titles font size:').'</label> '.350 form::field('sidebar_title_s', 7,7,$blowup_user['sidebar_title_s']).'</p>'.351 352 '<p class="field"><label for="sidebar_title_c">' .__('Sidebar titles color:').'</label> '.353 form::field('sidebar_title_c', 7,7,$blowup_user['sidebar_title_c'],'colorpicker').'</p>'.354 355 '<p class="field"><label for="sidebar_title2_f">' .__('Sidebar 2nd level titles font:').'</label> '.356 form::combo('sidebar_title2_f', blowupConfig::fontsList(),$blowup_user['sidebar_title2_f']).'</p>'.357 358 '<p class="field"><label for="sidebar_title2_s">' .__('Sidebar 2nd level titles font size:').'</label> '.359 form::field('sidebar_title2_s', 7,7,$blowup_user['sidebar_title2_s']).'</p>'.360 361 '<p class="field"><label for="sidebar_title2_c">' .__('Sidebar 2nd level titles color:').'</label> '.362 form::field('sidebar_title2_c', 7,7,$blowup_user['sidebar_title2_c'],'colorpicker').'</p>'.363 364 '<p class="field"><label for="sidebar_line_c">' .__('Sidebar lines color:').'</label> '.365 form::field('sidebar_line_c', 7,7,$blowup_user['sidebar_line_c'],'colorpicker').'</p>'.366 367 '<p class="field"><label for="sidebar_link_c">' .__('Sidebar links color:').'</label> '.368 form::field('sidebar_link_c', 7,7,$blowup_user['sidebar_link_c'],'colorpicker').'</p>'.369 370 '<p class="field"><label for="sidebar_link_v_c">' .__('Sidebar visited links color:').'</label> '.371 form::field('sidebar_link_v_c', 7,7,$blowup_user['sidebar_link_v_c'],'colorpicker').'</p>'.372 373 '<p class="field"><label for="sidebar_link_f_c">' .__('Sidebar focus links color:').'</label> '.374 form::field('sidebar_link_f_c', 7,7,$blowup_user['sidebar_link_f_c'],'colorpicker').'</p>'.375 376 '<h4 class="border-top">' .__('Entries').'</h4>'.377 '<p class="field"><label for="date_title_f">' .__('Date title font:').'</label> '.378 form::combo('date_title_f', blowupConfig::fontsList(),$blowup_user['date_title_f']).'</p>'.379 380 '<p class="field"><label for="date_title_s">' .__('Date title font size:').'</label> '.381 form::field('date_title_s', 7,7,$blowup_user['date_title_s']).'</p>'.382 383 '<p class="field"><label for="date_title_c">' .__('Date title color:').'</label> '.384 form::field('date_title_c', 7,7,$blowup_user['date_title_c'],'colorpicker').'</p>'.385 386 '<p class="field"><label for="post_title_f">' .__('Entry title font:').'</label> '.387 form::combo('post_title_f', blowupConfig::fontsList(),$blowup_user['post_title_f']).'</p>'.388 389 '<p class="field"><label for="post_title_s">' .__('Entry title font size:').'</label> '.390 form::field('post_title_s', 7,7,$blowup_user['post_title_s']).'</p>'.391 392 '<p class="field"><label for="post_title_c">' .__('Entry title color:').'</label> '.393 form::field('post_title_c', 7,7,$blowup_user['post_title_c'],'colorpicker').'</p>';299 if ($blowup_user['top_image'] == 'custom' && $blowup_user['uploaded']) { 300 $preview_image = http::concatURL($core->blog->url, blowupConfig::imagesURL() . '/page-t.png'); 301 } else { 302 $preview_image = dcPage::getPF('blowupConfig/alpha-img/page-t/' . $blowup_user['top_image'] . '.png'); 303 } 304 305 echo 306 '<h5 class="pretty-title">' . __('Top image') . '</h5>' . 307 '<p class="field"><label for="top_image">' . __('Top image') . '</label> ' . 308 form::combo('top_image', $top_images, ($blowup_user['top_image'] ?: 'default')) . '</p>' . 309 '<p>' . __('Choose "Custom..." to upload your own image.') . '</p>' . 310 311 '<p id="uploader"><label for="upfile">' . __('Add your image:') . '</label> ' . 312 ' (' . sprintf(__('JPEG or PNG file, 800 pixels wide, maximum size %s'), files::size(DC_MAX_UPLOAD_SIZE)) . ')' . 313 '<input type="file" name="upfile" id="upfile" size="35" />' . 314 '</p>' . 315 316 '<h5>' . __('Preview') . '</h5>' . 317 '<div class="grid" style="width:800px;border:1px solid #ccc;">' . 318 '<img style="display:block;" src="' . $preview_image . '" alt="" id="image-preview" />' . 319 '</div>'; 320 } 321 322 echo 323 '<h4 class="border-top">' . __('Sidebar') . '</h4>' . 324 '<p class="field"><label for="sidebar_position">' . __('Sidebar position:') . '</label> ' . 325 form::combo('sidebar_position', array(__('right') => 'right', __('left') => 'left'), $blowup_user['sidebar_position']) . '</p>' . 326 327 '<p class="field"><label for="sidebar_text_f">' . __('Sidebar text font:') . '</label> ' . 328 form::combo('sidebar_text_f', blowupConfig::fontsList(), $blowup_user['sidebar_text_f']) . '</p>' . 329 330 '<p class="field"><label for="sidebar_text_s">' . __('Sidebar text font size:') . '</label> ' . 331 form::field('sidebar_text_s', 7, 7, $blowup_user['sidebar_text_s']) . '</p>' . 332 333 '<p class="field"><label for="sidebar_text_c">' . __('Sidebar text color:') . '</label> ' . 334 form::field('sidebar_text_c', 7, 7, $blowup_user['sidebar_text_c'], 'colorpicker') . '</p>' . 335 336 '<p class="field"><label for="sidebar_title_f">' . __('Sidebar titles font:') . '</label> ' . 337 form::combo('sidebar_title_f', blowupConfig::fontsList(), $blowup_user['sidebar_title_f']) . '</p>' . 338 339 '<p class="field"><label for="sidebar_title_s">' . __('Sidebar titles font size:') . '</label> ' . 340 form::field('sidebar_title_s', 7, 7, $blowup_user['sidebar_title_s']) . '</p>' . 341 342 '<p class="field"><label for="sidebar_title_c">' . __('Sidebar titles color:') . '</label> ' . 343 form::field('sidebar_title_c', 7, 7, $blowup_user['sidebar_title_c'], 'colorpicker') . '</p>' . 344 345 '<p class="field"><label for="sidebar_title2_f">' . __('Sidebar 2nd level titles font:') . '</label> ' . 346 form::combo('sidebar_title2_f', blowupConfig::fontsList(), $blowup_user['sidebar_title2_f']) . '</p>' . 347 348 '<p class="field"><label for="sidebar_title2_s">' . __('Sidebar 2nd level titles font size:') . '</label> ' . 349 form::field('sidebar_title2_s', 7, 7, $blowup_user['sidebar_title2_s']) . '</p>' . 350 351 '<p class="field"><label for="sidebar_title2_c">' . __('Sidebar 2nd level titles color:') . '</label> ' . 352 form::field('sidebar_title2_c', 7, 7, $blowup_user['sidebar_title2_c'], 'colorpicker') . '</p>' . 353 354 '<p class="field"><label for="sidebar_line_c">' . __('Sidebar lines color:') . '</label> ' . 355 form::field('sidebar_line_c', 7, 7, $blowup_user['sidebar_line_c'], 'colorpicker') . '</p>' . 356 357 '<p class="field"><label for="sidebar_link_c">' . __('Sidebar links color:') . '</label> ' . 358 form::field('sidebar_link_c', 7, 7, $blowup_user['sidebar_link_c'], 'colorpicker') . '</p>' . 359 360 '<p class="field"><label for="sidebar_link_v_c">' . __('Sidebar visited links color:') . '</label> ' . 361 form::field('sidebar_link_v_c', 7, 7, $blowup_user['sidebar_link_v_c'], 'colorpicker') . '</p>' . 362 363 '<p class="field"><label for="sidebar_link_f_c">' . __('Sidebar focus links color:') . '</label> ' . 364 form::field('sidebar_link_f_c', 7, 7, $blowup_user['sidebar_link_f_c'], 'colorpicker') . '</p>' . 365 366 '<h4 class="border-top">' . __('Entries') . '</h4>' . 367 '<p class="field"><label for="date_title_f">' . __('Date title font:') . '</label> ' . 368 form::combo('date_title_f', blowupConfig::fontsList(), $blowup_user['date_title_f']) . '</p>' . 369 370 '<p class="field"><label for="date_title_s">' . __('Date title font size:') . '</label> ' . 371 form::field('date_title_s', 7, 7, $blowup_user['date_title_s']) . '</p>' . 372 373 '<p class="field"><label for="date_title_c">' . __('Date title color:') . '</label> ' . 374 form::field('date_title_c', 7, 7, $blowup_user['date_title_c'], 'colorpicker') . '</p>' . 375 376 '<p class="field"><label for="post_title_f">' . __('Entry title font:') . '</label> ' . 377 form::combo('post_title_f', blowupConfig::fontsList(), $blowup_user['post_title_f']) . '</p>' . 378 379 '<p class="field"><label for="post_title_s">' . __('Entry title font size:') . '</label> ' . 380 form::field('post_title_s', 7, 7, $blowup_user['post_title_s']) . '</p>' . 381 382 '<p class="field"><label for="post_title_c">' . __('Entry title color:') . '</label> ' . 383 form::field('post_title_c', 7, 7, $blowup_user['post_title_c'], 'colorpicker') . '</p>'; 394 384 395 385 if ($can_write_images) { 396 397 '<p class="field"><label for="post_comment_bg_c">'.__('Comment background color:').'</label> '.398 form::field('post_comment_bg_c',7,7,$blowup_user['post_comment_bg_c'],'colorpicker').'</p>';399 } 400 401 echo 402 '<p class="field"><label for="post_comment_c">' .__('Comment text color:').'</label> '.403 form::field('post_comment_c', 7,7,$blowup_user['post_comment_c'],'colorpicker').'</p>';386 echo 387 '<p class="field"><label for="post_comment_bg_c">' . __('Comment background color:') . '</label> ' . 388 form::field('post_comment_bg_c', 7, 7, $blowup_user['post_comment_bg_c'], 'colorpicker') . '</p>'; 389 } 390 391 echo 392 '<p class="field"><label for="post_comment_c">' . __('Comment text color:') . '</label> ' . 393 form::field('post_comment_c', 7, 7, $blowup_user['post_comment_c'], 'colorpicker') . '</p>'; 404 394 405 395 if ($can_write_images) { 406 echo 407 '<p class="field"><label for="post_commentmy_bg_c">'.__('My comment background color:').'</label> '. 408 form::field('post_commentmy_bg_c',7,7,$blowup_user['post_commentmy_bg_c'],'colorpicker').'</p>'; 409 } 410 411 echo 412 '<p class="field"><label for="post_commentmy_c">'.__('My comment text color:').'</label> '. 413 form::field('post_commentmy_c',7,7,$blowup_user['post_commentmy_c'],'colorpicker').'</p>'. 414 415 '<h4 class="border-top">'.__('Footer').'</h4>'. 416 '<p class="field"><label for="footer_f">'.__('Footer font:').'</label> '. 417 form::combo('footer_f',blowupConfig::fontsList(),$blowup_user['footer_f']).'</p>'. 418 419 '<p class="field"><label for="footer_s">'.__('Footer font size:').'</label> '. 420 form::field('footer_s',7,7,$blowup_user['footer_s']).'</p>'. 421 422 '<p class="field"><label for="footer_c">'.__('Footer color:').'</label> '. 423 form::field('footer_c',7,7,$blowup_user['footer_c'],'colorpicker').'</p>'. 424 425 '<p class="field"><label for="footer_l_c">'.__('Footer links color:').'</label> '. 426 form::field('footer_l_c',7,7,$blowup_user['footer_l_c'],'colorpicker').'</p>'. 427 428 '<p class="field"><label for="footer_bg_c">'.__('Footer background color:').'</label> '. 429 form::field('footer_bg_c',7,7,$blowup_user['footer_bg_c'],'colorpicker').'</p>'; 430 431 echo 432 '<h4 class="border-top">'.__('Additional CSS').'</h4>'. 433 '<p><label for="extra_css">'.__('Any additional CSS styles (must be written using the CSS syntax):').'</label> '. 434 form::textarea('extra_css',72,5,html::escapeHTML($blowup_user['extra_css']),'maximal','',false,'title="'.__('Additional CSS').'"'). 435 '</p>'. 436 '</div>'; 437 438 396 echo 397 '<p class="field"><label for="post_commentmy_bg_c">' . __('My comment background color:') . '</label> ' . 398 form::field('post_commentmy_bg_c', 7, 7, $blowup_user['post_commentmy_bg_c'], 'colorpicker') . '</p>'; 399 } 400 401 echo 402 '<p class="field"><label for="post_commentmy_c">' . __('My comment text color:') . '</label> ' . 403 form::field('post_commentmy_c', 7, 7, $blowup_user['post_commentmy_c'], 'colorpicker') . '</p>' . 404 405 '<h4 class="border-top">' . __('Footer') . '</h4>' . 406 '<p class="field"><label for="footer_f">' . __('Footer font:') . '</label> ' . 407 form::combo('footer_f', blowupConfig::fontsList(), $blowup_user['footer_f']) . '</p>' . 408 409 '<p class="field"><label for="footer_s">' . __('Footer font size:') . '</label> ' . 410 form::field('footer_s', 7, 7, $blowup_user['footer_s']) . '</p>' . 411 412 '<p class="field"><label for="footer_c">' . __('Footer color:') . '</label> ' . 413 form::field('footer_c', 7, 7, $blowup_user['footer_c'], 'colorpicker') . '</p>' . 414 415 '<p class="field"><label for="footer_l_c">' . __('Footer links color:') . '</label> ' . 416 form::field('footer_l_c', 7, 7, $blowup_user['footer_l_c'], 'colorpicker') . '</p>' . 417 418 '<p class="field"><label for="footer_bg_c">' . __('Footer background color:') . '</label> ' . 419 form::field('footer_bg_c', 7, 7, $blowup_user['footer_bg_c'], 'colorpicker') . '</p>'; 420 421 echo 422 '<h4 class="border-top">' . __('Additional CSS') . '</h4>' . 423 '<p><label for="extra_css">' . __('Any additional CSS styles (must be written using the CSS syntax):') . '</label> ' . 424 form::textarea('extra_css', 72, 5, html::escapeHTML($blowup_user['extra_css']), 'maximal', '', false, 'title="' . __('Additional CSS') . '"') . 425 '</p>' . 426 '</div>'; 439 427 440 428 // Import / Export configuration 441 $tmp_array = array();442 $tmp_exclude = array('uploaded', 'top_height');429 $tmp_array = array(); 430 $tmp_exclude = array('uploaded', 'top_height'); 443 431 if ($blowup_user['top_image'] == 'custom') { 444 432 $tmp_exclude[] = 'top_image'; 445 433 } 446 434 foreach ($blowup_user as $k => $v) { 447 if (!in_array($k,$tmp_exclude)) {448 $tmp_array[] = $k.':'.'"'.$v.'"';449 450 } 451 echo 452 '<div class="fieldset">' .453 '<h3 id="bu_export">' .__('Configuration import / export').'</h3>'.454 '<div id="bu_export_content">' .455 '<p>' .__('You can share your configuration using the following code. To apply a configuration, paste the code, click on "Apply code" and save.').'</p>'.456 '<p>' .form::textarea('export_code',72,5,implode('; ',$tmp_array),'maximal','',false,'title="'.__('Copy this code:').'"').'</p>'.457 '</div>'.458 '</div>';459 460 echo 461 '<p class="clear"><input type="submit" value="' .__('Save').'" />'.462 $core->formNonce() .'</p>'.463 '</form>';435 if (!in_array($k, $tmp_exclude)) { 436 $tmp_array[] = $k . ':' . '"' . $v . '"'; 437 } 438 } 439 echo 440 '<div class="fieldset">' . 441 '<h3 id="bu_export">' . __('Configuration import / export') . '</h3>' . 442 '<div id="bu_export_content">' . 443 '<p>' . __('You can share your configuration using the following code. To apply a configuration, paste the code, click on "Apply code" and save.') . '</p>' . 444 '<p>' . form::textarea('export_code', 72, 5, implode('; ', $tmp_array), 'maximal', '', false, 'title="' . __('Copy this code:') . '"') . '</p>' . 445 '</div>' . 446 '</div>'; 447 448 echo 449 '<p class="clear"><input type="submit" value="' . __('Save') . '" />' . 450 $core->formNonce() . '</p>' . 451 '</form>'; 464 452 465 453 dcPage::helpBlock('blowupConfig'); -
plugins/dcCKEditor/js/popup_link.js
r3705 r3709 1 1 /*global $ */ 2 2 'use strict'; 3 3 4 $(function() { 4 5 $('#link-insert-cancel').click(function() { -
plugins/dcCKEditor/js/popup_media.js
r3705 r3709 1 1 /*global $ */ 2 2 'use strict'; 3 3 4 $(function() { 4 5 $('#media-insert-cancel').click(function() { -
plugins/dcCKEditor/js/popup_posts.js
r3705 r3709 1 1 /*global $ */ 2 2 'use strict'; 3 3 4 $(function() { 4 5 $('#link-insert-cancel').click(function() { -
plugins/dcLegacyEditor/js/_post_editor.js
r3666 r3709 1 /*global $, dotclear, jsToolBar */ 2 'use strict'; 3 1 4 $(function() { 2 if ($('#edit-entry').length == 0) { return; } 3 if (dotclear.legacy_editor_context === undefined || 4 dotclear.legacy_editor_tags_context[dotclear.legacy_editor_context] === undefined) { 5 return; 6 } 5 if ($('#edit-entry').length == 0) { 6 return; 7 } 8 if (dotclear.legacy_editor_context === undefined || 9 dotclear.legacy_editor_tags_context[dotclear.legacy_editor_context] === undefined) { 10 return; 11 } 7 12 8 if ((dotclear.legacy_editor_tags_context[dotclear.legacy_editor_context].indexOf('#post_content') !== -1) && 9 (dotclear.legacy_editor_tags_context[dotclear.legacy_editor_context].indexOf('#post_excerpt') !== -1)) { 10 // Get document format and prepare toolbars 11 var formatField = $('#post_format').get(0); 12 var last_post_format = $(formatField).val(); 13 $(formatField).change(function() { 14 if (this.value != 'dcLegacyEditor') { return; } 13 if ((dotclear.legacy_editor_tags_context[dotclear.legacy_editor_context].indexOf('#post_content') !== -1) && 14 (dotclear.legacy_editor_tags_context[dotclear.legacy_editor_context].indexOf('#post_excerpt') !== -1)) { 15 // Get document format and prepare toolbars 16 var formatField = $('#post_format').get(0); 17 var last_post_format = $(formatField).val(); 18 $(formatField).change(function() { 19 if (this.value != 'dcLegacyEditor') { 20 return; 21 } 15 22 16 23 var post_format = this.value; 17 24 18 19 20 21 22 23 24 25 26 25 // Confirm post format change 26 if (window.confirm(dotclear.msg.confirm_change_post_format_noconvert)) { 27 excerptTb.switchMode(post_format); 28 contentTb.switchMode(post_format); 29 last_post_format = $(this).val(); 30 } else { 31 // Restore last format if change cancelled 32 $(this).val(last_post_format); 33 } 27 34 28 29 30 35 $('.format_control > *').addClass('hide'); 36 $('.format_control:not(.control_no_' + post_format + ') > *').removeClass('hide'); 37 }); 31 38 32 33 34 39 var excerptTb = new jsToolBar(document.getElementById('post_excerpt')); 40 var contentTb = new jsToolBar(document.getElementById('post_content')); 41 excerptTb.context = contentTb.context = 'post'; 35 42 36 37 38 43 $('.format_control > *').addClass('hide'); 44 $('.format_control:not(.control_no_' + last_post_format + ') > *').removeClass('hide'); 45 } 39 46 40 41 42 43 44 45 47 if (dotclear.legacy_editor_tags_context[dotclear.legacy_editor_context].indexOf('#comment_content') !== -1) { 48 if ($('#comment_content').length > 0) { 49 var commentTb = new jsToolBar(document.getElementById('comment_content')); 50 commentTb.draw('xhtml'); 51 } 52 } 46 53 47 54 $('#edit-entry').onetabload(function() { 48 55 49 50 51 52 56 // Remove required attribut from #post_content in XHTML mode as textarea is not more focusable 57 if (formatField.value == 'xhtml') { 58 $('#post_content').removeAttr('required'); 59 } 53 60 54 55 56 57 58 61 // Load toolbars 62 if (contentTb !== undefined && excerptTb !== undefined) { 63 contentTb.switchMode(formatField.value); 64 excerptTb.switchMode(formatField.value); 65 } 59 66 60 61 62 63 64 65 66 67 68 67 // Check unsaved changes before XHTML conversion 68 var excerpt = $('#post_excerpt').val(); 69 var content = $('#post_content').val(); 70 $('#convert-xhtml').click(function() { 71 if (excerpt != $('#post_excerpt').val() || content != $('#post_content').val()) { 72 return window.confirm(dotclear.msg.confirm_change_post_format); 73 } 74 }); 75 }); 69 76 }); -
plugins/dcLegacyEditor/js/jsToolBar/popup_media.js
r3446 r3709 1 /*global $ */ 2 'use strict'; 3 1 4 $(function() { 2 var toolBar = window.opener.the_toolbar.textarea; 5 $('#media-insert').onetabload(function() { 6 $('#media-insert-cancel').click(function() { 7 window.close(); 8 }); 3 9 4 $('#media-insert').onetabload(function() { 5 $('#media-insert-cancel').click(function() { 6 window.close(); 7 }); 10 $('#media-insert-ok').click(function() { 11 sendClose(); 12 window.close(); 13 }); 14 }); 8 15 9 $('#media-insert-ok').click(function() {10 sendClose();11 window.close(); 12 });13 }); 16 function sendClose() { 17 var insert_form = $('#media-insert-form').get(0); 18 if (insert_form == undefined) { 19 return; 20 } 14 21 15 function sendClose() { 16 var insert_form = $('#media-insert-form').get(0); 17 if (insert_form == undefined) { return; } 22 var tb = window.opener.the_toolbar; 23 var type = insert_form.elements.type.value; 24 var media_align_grid = { 25 left: 'float: left; margin: 0 1em 1em 0;', 26 right: 'float: right; margin: 0 0 1em 1em;', 27 center: 'text-align: center;' 28 }; 29 var align, player; 18 30 19 var tb = window.opener.the_toolbar; 20 var type = insert_form.elements.type.value; 31 if (type == 'image') { 32 tb.elements.img_select.data.src = tb.stripBaseURL($('input[name="src"]:checked', insert_form).val()); 33 tb.elements.img_select.data.alignment = $('input[name="alignment"]:checked', insert_form).val(); 34 tb.elements.img_select.data.link = $('input[name="insertion"]:checked', insert_form).val() == 'link'; 21 35 22 var media_align_grid = { 23 left: 'float: left; margin: 0 1em 1em 0;', 24 right: 'float: right; margin: 0 0 1em 1em;', 25 center: 'text-align: center;' 26 }; 36 tb.elements.img_select.data.title = insert_form.elements.title.value; 37 tb.elements.img_select.data.description = $('input[name="description"]', insert_form).val(); 38 tb.elements.img_select.data.url = tb.stripBaseURL(insert_form.elements.url.value); 27 39 28 if (type == 'image') 29 { 30 tb.elements.img_select.data.src = tb.stripBaseURL($('input[name="src"]:checked',insert_form).val()); 31 tb.elements.img_select.data.alignment = $('input[name="alignment"]:checked',insert_form).val(); 32 tb.elements.img_select.data.link = $('input[name="insertion"]:checked',insert_form).val() == 'link'; 40 var media_legend = $('input[name="legend"]:checked', insert_form).val(); 41 if (media_legend != '' && media_legend != 'title' && media_legend != 'none') { 42 media_legend = 'legend'; 43 } 44 if (media_legend != 'legend') { 45 tb.elements.img_select.data.description = ''; 46 } 47 if (media_legend == 'none') { 48 tb.elements.img_select.data.title = ''; 49 } 33 50 34 tb.elements.img_select.data.title = insert_form.elements.title.value; 35 tb.elements.img_select.data.description = $('input[name="description"]',insert_form).val(); 36 tb.elements.img_select.data.url = tb.stripBaseURL(insert_form.elements.url.value); 51 tb.elements.img_select.fncall[tb.mode].call(tb); 52 } else if (type == 'mp3') { 53 player = $('#public_player').val(); 54 align = $('input[name="alignment"]:checked', insert_form).val(); 37 55 38 var media_legend = $('input[name="legend"]:checked',insert_form).val(); 39 if (media_legend != '' && media_legend != 'title' && media_legend != 'none') { 40 media_legend = 'legend'; 41 } 42 if (media_legend != 'legend') { 43 tb.elements.img_select.data.description = ''; 44 } 45 if (media_legend == 'none') { 46 tb.elements.img_select.data.title = ''; 47 } 56 if (align != undefined && align != 'none') { 57 player = '<div style="' + media_align_grid[align] + '">' + player + '</div>'; 58 } 48 59 49 tb.elements.img_select.fncall[tb.mode].call(tb);50 } 51 else if (type == 'mp3') 52 53 var player = $('#public_player').val();54 var align = $('input[name="alignment"]:checked',insert_form).val();60 tb.elements.mp3_insert.data.player = player.replace(/>/g, '>\n'); 61 tb.elements.mp3_insert.fncall[tb.mode].call(tb); 62 } else if (type == 'flv') // may be all video media, not only flv 63 { 64 var oplayer = $('<div>' + $('#public_player').val() + '</div>'); 65 var flashvars = $('[name=FlashVars]', oplayer).val(); 55 66 56 if (align != undefined && align != 'none') { 57 player = '<div style="' + media_align_grid[align] + '">' + player + '</div>'; 58 } 67 align = $('input[name="alignment"]:checked', insert_form).val(); 68 var title = insert_form.elements.title.value; 59 69 60 tb.elements.mp3_insert.data.player = player.replace(/>/g,'>\n'); 61 tb.elements.mp3_insert.fncall[tb.mode].call(tb); 62 } 63 else if (type == 'flv') // may be all video media, not only flv 64 { 65 var oplayer = $('<div>'+$('#public_player').val()+'</div>'); 66 var flashvars = $("[name=FlashVars]",oplayer).val(); 70 $('video', oplayer).attr('width', $('#video_w').val()); 71 $('video', oplayer).attr('height', $('#video_h').val()); 67 72 68 var align = $('input[name="alignment"]:checked',insert_form).val(); 69 var title = insert_form.elements.title.value; 73 if (title) { 74 flashvars = 'title=' + encodeURI(title) + '&' + flashvars; 75 } 76 $('object', oplayer).attr('width', $('#video_w').val()); 77 $('object', oplayer).attr('height', $('#video_h').val()); 78 flashvars = flashvars.replace(/(width=\d*)/, 'width=' + $('#video_w').val()); 79 flashvars = flashvars.replace(/(height=\d*)/, 'height=' + $('#video_h').val()); 70 80 71 $('video',oplayer).attr('width',$('#video_w').val());72 $('video',oplayer).attr('height',$('#video_h').val());81 $('[name=FlashVars]', oplayer).val(flashvars); 82 player = oplayer.html(); 73 83 74 if (title) { 75 flashvars = 'title='+encodeURI(title)+'&'+flashvars; 76 } 77 $('object',oplayer).attr('width',$('#video_w').val()); 78 $('object',oplayer).attr('height',$('#video_h').val()); 79 flashvars = flashvars.replace(/(width=\d*)/,'width='+$('#video_w').val()); 80 flashvars = flashvars.replace(/(height=\d*)/,'height='+$('#video_h').val()); 84 if (align != undefined && align != 'none') { 85 player = '<div style="' + media_align_grid[align] + '">' + player + '</div>'; 86 } 81 87 82 $("[name=FlashVars]",oplayer).val(flashvars); 83 var player = oplayer.html(); 84 85 if (align != undefined && align != 'none') { 86 player = '<div style="' + media_align_grid[align] + '">' + player + '</div>'; 87 } 88 89 tb.elements.flv_insert.data.player = player.replace(/>/g,'>\n'); 90 tb.elements.flv_insert.fncall[tb.mode].call(tb); 91 } 92 else 93 { 94 tb.elements.link.data.href = tb.stripBaseURL(insert_form.elements.url.value); 95 tb.elements.link.data.content = insert_form.elements.title.value; 96 tb.elements.link.fncall[tb.mode].call(tb); 97 } 98 }; 99 100 function playerFormat(s) { 101 s = s.replace(/</g,'<'); 102 s = s.replace(/>/g,'>\n'); 103 s = s.replace(/&/g,'&'); 104 105 return s; 106 }; 88 tb.elements.flv_insert.data.player = player.replace(/>/g, '>\n'); 89 tb.elements.flv_insert.fncall[tb.mode].call(tb); 90 } else { 91 tb.elements.link.data.href = tb.stripBaseURL(insert_form.elements.url.value); 92 tb.elements.link.data.content = insert_form.elements.title.value; 93 tb.elements.link.fncall[tb.mode].call(tb); 94 } 95 } 107 96 }); -
plugins/importExport/js/script.js
r2566 r3709 1 /*global $, dotclear */ 2 'use strict'; 1 3 2 $(function(){if($('*.error').length>0){return;} 3 $('#ie-gui form[method=post]:has(input[type=hidden][name=autosubmit])').each(function(){$('input[type=submit]',this).remove();$(this).after('<p style="font-size:2em;text-align:center">'+dotclear.msg.please_wait+'</p>');$(this).submit();});}); 4 $(function() { 5 if ($('*.error').length > 0) { 6 return; 7 } 8 $('#ie-gui form[method=post]:has(input[type=hidden][name=autosubmit])').each(function() { 9 $('input[type=submit]', this).remove(); 10 $(this).after('<p style="font-size:2em;text-align:center">' + dotclear.msg.please_wait + '</p>'); 11 $(this).submit(); 12 }); 13 }); -
plugins/maintenance/js/dc.maintenance.js
r2566 r3709 1 $(function(){ 2 $('.step-box').each(function(){ 3 var code = $('input[name=code]',this).val(); 1 /*global $, dotclear */ 2 'use strict'; 4 3 5 $('.step-submit',this).remove(); 6 $('.step-back',this).hide(); 7 $('.step-msg',this).after( 8 $('<p>').addClass('step-wait').text( 9 dotclear.msg.wait 10 ) 11 ); 4 $(function() { 5 $('.step-box').each(function() { 6 var code = $('input[name=code]', this).val(); 12 7 13 dcMaintenanceStep(this,code); 8 $('.step-submit', this).remove(); 9 $('.step-back', this).hide(); 10 $('.step-msg', this).after( 11 $('<p>').addClass('step-wait').text( 12 dotclear.msg.wait 13 ) 14 ); 14 15 15 function dcMaintenanceStep(box,code) { 16 var params = { 17 f: 'dcMaintenanceStep', 18 xd_check: dotclear.nonce, 19 task: $(box).attr('id'), 20 code: code 21 } 22 $.post('services.php',params,function(data) { 23 if ($('rsp[status=failed]',data).length > 0) { 24 $('.step-msg',box).text( 25 $('rsp',data).text() 26 ); 27 $('.step-wait',box).remove(); 28 $('.step-back',box).show(); 29 } else { 30 $('.step-msg',box).text( 31 $('rsp>step',data).attr('title') 32 ); 33 var code = $('rsp>step',data).attr('code'); 34 if (code > 0){ 35 dcMaintenanceStep(box,code); 36 } else { 37 $('#content h2').after($('<div/>').addClass('success').append($('.step-msg',box))); 38 $('.step-wait',box).remove(); 39 $('.step-back',box).show(); 40 } 41 } 42 }); 43 } 44 }); 16 dcMaintenanceStep(this, code); 17 18 function dcMaintenanceStep(box, code) { 19 var params = { 20 f: 'dcMaintenanceStep', 21 xd_check: dotclear.nonce, 22 task: $(box).attr('id'), 23 code: code 24 }; 25 $.post('services.php', params, function(data) { 26 if ($('rsp[status=failed]', data).length > 0) { 27 $('.step-msg', box).text( 28 $('rsp', data).text() 29 ); 30 $('.step-wait', box).remove(); 31 $('.step-back', box).show(); 32 } else { 33 $('.step-msg', box).text( 34 $('rsp>step', data).attr('title') 35 ); 36 var code = $('rsp>step', data).attr('code'); 37 if (code > 0) { 38 dcMaintenanceStep(box, code); 39 } else { 40 $('#content h2').after($('<div/>').addClass('success').append($('.step-msg', box))); 41 $('.step-wait', box).remove(); 42 $('.step-back', box).show(); 43 } 44 } 45 }); 46 } 47 }); 45 48 }); -
plugins/maintenance/js/settings.js
r3182 r3709 1 $(function(){ 2 $('.recall-for-all').attr('disabled','disabled'); 3 $('#settings_recall_all').change(function(){ 4 if($(this).attr('selected')!='selected'){ 5 $('.recall-per-task').attr('disabled','disabled'); 6 $('.recall-for-all').removeAttr('disabled'); 7 } 8 }); 9 $('#settings_recall_separate').change(function(){ 10 if($(this).attr('selected')!='selected'){ 11 $('.recall-per-task').removeAttr('disabled'); 12 $('.recall-for-all').attr('disabled','disabled'); 13 } 14 }); 15 dotclear.condSubmit('#part-maintenance input[type="radio"]','#part-maintenance input[type="submit"]'); 16 dotclear.condSubmit('#part-backup input[type="radio"]','#part-backup input[type="submit"]'); 17 dotclear.condSubmit('#part-dev input[type="radio"]','#part-dev input[type="submit"]'); 1 /*global $, dotclear */ 2 'use strict'; 3 4 $(function() { 5 $('.recall-for-all').attr('disabled', 'disabled'); 6 $('#settings_recall_all').change(function() { 7 if ($(this).attr('selected') != 'selected') { 8 $('.recall-per-task').attr('disabled', 'disabled'); 9 $('.recall-for-all').removeAttr('disabled'); 10 } 11 }); 12 $('#settings_recall_separate').change(function() { 13 if ($(this).attr('selected') != 'selected') { 14 $('.recall-per-task').removeAttr('disabled'); 15 $('.recall-for-all').attr('disabled', 'disabled'); 16 } 17 }); 18 dotclear.condSubmit('#part-maintenance input[type="radio"]', '#part-maintenance input[type="submit"]'); 19 dotclear.condSubmit('#part-backup input[type="radio"]', '#part-backup input[type="submit"]'); 20 dotclear.condSubmit('#part-dev input[type="radio"]', '#part-dev input[type="submit"]'); 18 21 }); -
plugins/pages/_admin.php
r3265 r3709 10 10 # 11 11 # -- END LICENSE BLOCK ----------------------------------------- 12 if (!defined('DC_CONTEXT_ADMIN')) { return;}12 if (!defined('DC_CONTEXT_ADMIN')) {return;} 13 13 14 $core->addBehavior('adminColumnsLists', array('pagesColumnsLists','adminColumnsLists'));15 $core->addBehavior('adminDashboardFavorites', array('pagesDashboard','pagesDashboardFavs'));16 $core->addBehavior('adminUsersActionsHeaders', 'pages_users_actions_headers');14 $core->addBehavior('adminColumnsLists', array('pagesColumnsLists', 'adminColumnsLists')); 15 $core->addBehavior('adminDashboardFavorites', array('pagesDashboard', 'pagesDashboardFavs')); 16 $core->addBehavior('adminUsersActionsHeaders', 'pages_users_actions_headers'); 17 17 18 18 class pagesColumnsLists 19 19 { 20 public static function adminColumnsLists($core,$cols)21 22 23 24 'date' => array(true,__('Date')),25 'author' => array(true,__('Author')),26 'comments' => array(true,__('Comments')),27 'trackbacks' => array(true,__('Trackbacks'))28 29 20 public static function adminColumnsLists($core, $cols) 21 { 22 // Set optional columns in pages lists 23 $cols['pages'] = array(__('Pages'), array( 24 'date' => array(true, __('Date')), 25 'author' => array(true, __('Author')), 26 'comments' => array(true, __('Comments')), 27 'trackbacks' => array(true, __('Trackbacks')) 28 )); 29 } 30 30 } 31 31 32 32 class pagesDashboard 33 33 { 34 public static function pagesDashboardFavs($core,$favs)35 36 37 'title'=> __('Pages'),38 'url'=> $core->adminurl->get('admin.plugin.pages'),39 'small-icon'=> dcPage::getPF('pages/icon.png'),40 'large-icon'=> dcPage::getPF('pages/icon-big.png'),41 'permissions'=> 'contentadmin,pages',42 'dashboard_cb' => array('pagesDashboard','pagesDashboardCB'),43 'active_cb' => array('pagesDashboard','pagesActiveCB')44 45 46 'title'=> __('New page'),47 'url' => $core->adminurl->get('admin.plugin.pages',array('act' => 'page')),48 'small-icon'=> dcPage::getPF('pages/icon-np.png'),49 'large-icon' => dcPage::getPF('pages/icon-np-big.png'),50 51 'active_cb' => array('pagesDashboard','newPageActiveCB')52 53 34 public static function pagesDashboardFavs($core, $favs) 35 { 36 $favs->register('pages', array( 37 'title' => __('Pages'), 38 'url' => $core->adminurl->get('admin.plugin.pages'), 39 'small-icon' => dcPage::getPF('pages/icon.png'), 40 'large-icon' => dcPage::getPF('pages/icon-big.png'), 41 'permissions' => 'contentadmin,pages', 42 'dashboard_cb' => array('pagesDashboard', 'pagesDashboardCB'), 43 'active_cb' => array('pagesDashboard', 'pagesActiveCB') 44 )); 45 $favs->register('newpage', array( 46 'title' => __('New page'), 47 'url' => $core->adminurl->get('admin.plugin.pages', array('act' => 'page')), 48 'small-icon' => dcPage::getPF('pages/icon-np.png'), 49 'large-icon' => dcPage::getPF('pages/icon-np-big.png'), 50 'permissions' => 'contentadmin,pages', 51 'active_cb' => array('pagesDashboard', 'newPageActiveCB') 52 )); 53 } 54 54 55 public static function pagesDashboardCB($core,$v)56 57 $params= new ArrayObject();58 59 $page_count = $core->blog->getPosts($params,true)->f(0);60 61 $str_pages= ($page_count > 1) ? __('%d pages') : __('%d page');62 $v['title'] = sprintf($str_pages,$page_count);63 64 55 public static function pagesDashboardCB($core, $v) 56 { 57 $params = new ArrayObject(); 58 $params['post_type'] = 'page'; 59 $page_count = $core->blog->getPosts($params, true)->f(0); 60 if ($page_count > 0) { 61 $str_pages = ($page_count > 1) ? __('%d pages') : __('%d page'); 62 $v['title'] = sprintf($str_pages, $page_count); 63 } 64 } 65 65 66 public static function pagesActiveCB($request,$params)67 68 69 70 && !(isset($params['act']) && $params['act']=='page');71 66 public static function pagesActiveCB($request, $params) 67 { 68 return ($request == "plugin.php") && 69 isset($params['p']) && $params['p'] == 'pages' 70 && !(isset($params['act']) && $params['act'] == 'page'); 71 } 72 72 73 public static function newPageActiveCB($request,$params)74 75 76 77 && isset($params['act']) && $params['act']=='page';78 73 public static function newPageActiveCB($request, $params) 74 { 75 return ($request == "plugin.php") && 76 isset($params['p']) && $params['p'] == 'pages' 77 && isset($params['act']) && $params['act'] == 'page'; 78 } 79 79 } 80 81 80 82 81 function pages_users_actions_headers() 83 82 { 84 return dcPage::jsLoad('index.php?pf=pages/_users_actions.js');83 return dcPage::jsLoad('index.php?pf=pages/js/_users_actions.js'); 85 84 } 86 85 87 86 $_menu['Blog']->addItem(__('Pages'), 88 89 90 preg_match('/plugin.php(.*)$/',$_SERVER['REQUEST_URI']) && !empty($_REQUEST['p']) && $_REQUEST['p']=='pages',91 $core->auth->check('contentadmin,pages',$core->blog->id));87 $core->adminurl->get('admin.plugin.pages'), 88 dcPage::getPF('pages/icon.png'), 89 preg_match('/plugin.php(.*)$/', $_SERVER['REQUEST_URI']) && !empty($_REQUEST['p']) && $_REQUEST['p'] == 'pages', 90 $core->auth->check('contentadmin,pages', $core->blog->id)); 92 91 93 $core->auth->setPermissionType('pages', __('manage pages'));92 $core->auth->setPermissionType('pages', __('manage pages')); 94 93 95 require dirname(__FILE__) .'/_widgets.php';94 require dirname(__FILE__) . '/_widgets.php'; -
plugins/pages/list.php
r3421 r3709 10 10 # 11 11 # -- END LICENSE BLOCK ----------------------------------------- 12 if (!defined('DC_CONTEXT_ADMIN')) { return;}12 if (!defined('DC_CONTEXT_ADMIN')) {return;} 13 13 dcPage::check('pages,contentadmin'); 14 14 … … 16 16 -------------------------------------------------------- */ 17 17 $params = array( 18 18 'post_type' => 'page' 19 19 ); 20 20 21 $page = !empty($_GET['page']) ? max(1,(integer) $_GET['page']) : 1;22 $nb_per_page = 21 $page = !empty($_GET['page']) ? max(1, (integer) $_GET['page']) : 1; 22 $nb_per_page = 30; 23 23 24 24 if (!empty($_GET['nb']) && (integer) $_GET['nb'] > 0) { 25 25 $nb_per_page = (integer) $_GET['nb']; 26 26 } 27 27 28 $params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page);28 $params['limit'] = array((($page - 1) * $nb_per_page), $nb_per_page); 29 29 $params['no_content'] = true; 30 $params['order'] = 'post_position ASC, post_title ASC';30 $params['order'] = 'post_position ASC, post_title ASC'; 31 31 32 32 try { 33 $pages= $core->blog->getPosts($params);34 $counter = $core->blog->getPosts($params,true);35 $post_list = new adminPagesList($core,$pages,$counter->f(0));33 $pages = $core->blog->getPosts($params); 34 $counter = $core->blog->getPosts($params, true); 35 $post_list = new adminPagesList($core, $pages, $counter->f(0)); 36 36 } catch (Exception $e) { 37 37 $core->error->add($e->getMessage()); 38 38 } 39 39 40 40 # Actions combo box 41 41 42 $pages_actions_page = new dcPagesActionsPage($core, 'plugin.php',array('p'=>'pages'));42 $pages_actions_page = new dcPagesActionsPage($core, 'plugin.php', array('p' => 'pages')); 43 43 44 44 if (!$pages_actions_page->process()) { 45 45 46 47 46 # --BEHAVIOR-- adminPagesActionsCombo 48 $core->callBehavior('adminPagesActionsCombo',array(&$combo_action));47 $core->callBehavior('adminPagesActionsCombo', array(&$combo_action)); 49 48 50 49 /* Display 51 50 -------------------------------------------------------- */ 52 ?>51 ?> 53 52 <html> 54 53 <head> 55 54 <title><?php echo __('Pages'); ?></title> 56 55 <?php 57 58 dcPage::jsLoad('js/jquery/jquery-ui.custom.js').59 dcPage::jsLoad('js/jquery/jquery.ui.touch-punch.js').60 dcPage::jsLoad(dcPage::getPF('pages/list.js')).61 '<script type="text/javascript">'."\n".62 dcPage::jsVar('dotclear.msg.confirm_delete_posts',__("Are you sure you want to delete selected pages?")).63 56 echo 57 dcPage::jsLoad('js/jquery/jquery-ui.custom.js') . 58 dcPage::jsLoad('js/jquery/jquery.ui.touch-punch.js') . 59 dcPage::jsLoad(dcPage::getPF('pages/js/list.js')) . 60 '<script type="text/javascript">' . "\n" . 61 dcPage::jsVar('dotclear.msg.confirm_delete_posts', __("Are you sure you want to delete selected pages?")) . 62 '</script>'; 64 63 65 ?>64 ?> 66 65 </head> 67 66 … … 69 68 <?php 70 69 echo dcPage::breadcrumb( 71 72 73 __('Pages')=> ''74 )).dcPage::notices();70 array( 71 html::escapeHTML($core->blog->name) => '', 72 __('Pages') => '' 73 )) . dcPage::notices(); 75 74 76 if (!empty($_GET['upd'])) {77 78 } elseif (!empty($_GET['del'])) {79 80 } elseif (!empty($_GET['reo'])) {81 82 }83 echo84 '<p class="top-add"><a class="button add" href="'.$p_url.'&act=page">'.__('New page').'</a></p>';75 if (!empty($_GET['upd'])) { 76 dcPage::success(__('Selected pages have been successfully updated.')); 77 } elseif (!empty($_GET['del'])) { 78 dcPage::success(__('Selected pages have been successfully deleted.')); 79 } elseif (!empty($_GET['reo'])) { 80 dcPage::success(__('Selected pages have been successfully reordered.')); 81 } 82 echo 83 '<p class="top-add"><a class="button add" href="' . $p_url . '&act=page">' . __('New page') . '</a></p>'; 85 84 86 if (!$core->error->flag()) 87 { 88 # Show pages 89 $post_list->display($page,$nb_per_page, 90 '<form action="'.$core->adminurl->get('admin.plugin').'" method="post" id="form-entries">'. 85 if (!$core->error->flag()) { 86 # Show pages 87 $post_list->display($page, $nb_per_page, 88 '<form action="' . $core->adminurl->get('admin.plugin') . '" method="post" id="form-entries">' . 91 89 92 '%s'.90 '%s' . 93 91 94 '<div class="two-cols">'.95 '<p class="col checkboxes-helpers"></p>'.92 '<div class="two-cols">' . 93 '<p class="col checkboxes-helpers"></p>' . 96 94 97 '<p class="col right"><label for="action" class="classic">'.__('Selected pages action:').'</label> '.98 form::combo('action',$pages_actions_page->getCombo()).99 '<input id="do-action" type="submit" value="'.__('ok').'" />'.100 form::hidden(array('post_type'),'page').101 form::hidden(array('p'),'pages').102 form::hidden(array('act'),'list').103 $core->formNonce().104 '</p></div>'.105 '<p class="clear form-note hidden-if-js">'.106 __('To rearrange pages order, change number at the begining of the line, then click on “Save pages order” button.').'</p>'.107 '<p class="clear form-note hidden-if-no-js">'.108 __('To rearrange pages order, move items by drag and drop, then click on “Save pages order” button.').'</p>'.109 '<p><input type="submit" value="'.__('Save pages order').'" name="reorder" class="clear" /></p>'.110 111 }112 dcPage::helpBlock('pages');113 ?>95 '<p class="col right"><label for="action" class="classic">' . __('Selected pages action:') . '</label> ' . 96 form::combo('action', $pages_actions_page->getCombo()) . 97 '<input id="do-action" type="submit" value="' . __('ok') . '" />' . 98 form::hidden(array('post_type'), 'page') . 99 form::hidden(array('p'), 'pages') . 100 form::hidden(array('act'), 'list') . 101 $core->formNonce() . 102 '</p></div>' . 103 '<p class="clear form-note hidden-if-js">' . 104 __('To rearrange pages order, change number at the begining of the line, then click on “Save pages order” button.') . '</p>' . 105 '<p class="clear form-note hidden-if-no-js">' . 106 __('To rearrange pages order, move items by drag and drop, then click on “Save pages order” button.') . '</p>' . 107 '<p><input type="submit" value="' . __('Save pages order') . '" name="reorder" class="clear" /></p>' . 108 '</form>'); 109 } 110 dcPage::helpBlock('pages'); 111 ?> 114 112 </body> 115 113 </html> -
plugins/pings/lib.pings.php
r3428 r3709 10 10 # 11 11 # -- END LICENSE BLOCK ----------------------------------------- 12 if (!defined('DC_RC_PATH')) { return;}12 if (!defined('DC_RC_PATH')) {return;} 13 13 14 14 class pingsAPI extends xmlrpcClient 15 15 { 16 public static function doPings($srv_uri,$site_name,$site_url)17 18 $o= new self($srv_uri);19 16 public static function doPings($srv_uri, $site_name, $site_url) 17 { 18 $o = new self($srv_uri); 19 $o->timeout = 3; 20 20 21 $rsp = $o->query('weblogUpdates.ping',$site_name,$site_url);21 $rsp = $o->query('weblogUpdates.ping', $site_name, $site_url); 22 22 23 24 25 23 if (isset($rsp['flerror']) && $rsp['flerror']) { 24 throw new Exception($rsp['message']); 25 } 26 26 27 28 27 return true; 28 } 29 29 } 30 30 31 31 class pingsAdminBehaviors 32 32 { 33 34 35 33 public static function pingJS() 34 { 35 global $core; 36 36 37 38 "<script type=\"text/javascript\">\n".39 dcPage::jsVar('dotclear.msg.check_all',__('Check all'))."\n".40 "</script>\n".41 dcPage::jsLoad(dcPage::getPF('pings/post.js'));37 $res = 38 "<script type=\"text/javascript\">\n" . 39 dcPage::jsVar('dotclear.msg.check_all', __('Check all')) . "\n" . 40 "</script>\n" . 41 dcPage::jsLoad(dcPage::getPF('pings/js/post.js')); 42 42 43 44 43 return $res; 44 } 45 45 46 public static function pingsFormItems($main,$sidebar,$post)47 48 $core =&$GLOBALS['core'];49 50 51 46 public static function pingsFormItems($main, $sidebar, $post) 47 { 48 $core = &$GLOBALS['core']; 49 if (!$core->blog->settings->pings->pings_active) { 50 return; 51 } 52 52 53 54 55 56 53 $pings_uris = $core->blog->settings->pings->pings_uris; 54 if (empty($pings_uris) || !is_array($pings_uris)) { 55 return; 56 } 57 57 58 59 60 61 62 58 if (!empty($_POST['pings_do']) && is_array($_POST['pings_do'])) { 59 $pings_do = $_POST['pings_do']; 60 } else { 61 $pings_do = array(); 62 } 63 63 64 $item = '<h5 class="ping-services">'.__('Pings').'</h5>'; 65 $i = 0; 66 foreach ($pings_uris as $k => $v) 67 { 68 $item .= 69 '<p class="ping-services"><label for="pings_do-'.$i.'" class="classic">'. 70 form::checkbox(array('pings_do[]','pings_do-'.$i),html::escapeHTML($v),in_array($v,$pings_do), 'check-ping-services').' '. 71 html::escapeHTML($k).'</label></p>'; 72 $i++; 73 } 74 $sidebar['options-box']['items']['pings']=$item; 64 $item = '<h5 class="ping-services">' . __('Pings') . '</h5>'; 65 $i = 0; 66 foreach ($pings_uris as $k => $v) { 67 $item .= 68 '<p class="ping-services"><label for="pings_do-' . $i . '" class="classic">' . 69 form::checkbox(array('pings_do[]', 'pings_do-' . $i), html::escapeHTML($v), in_array($v, $pings_do), 'check-ping-services') . ' ' . 70 html::escapeHTML($k) . '</label></p>'; 71 $i++; 72 } 73 $sidebar['options-box']['items']['pings'] = $item; 75 74 76 75 } 77 76 78 public static function doPings($cur,$post_id)79 80 81 82 77 public static function doPings($cur, $post_id) 78 { 79 if (empty($_POST['pings_do']) || !is_array($_POST['pings_do'])) { 80 return; 81 } 83 82 84 $core =&$GLOBALS['core'];85 86 87 83 $core = &$GLOBALS['core']; 84 if (!$core->blog->settings->pings->pings_active) { 85 return; 86 } 88 87 89 90 91 92 88 $pings_uris = $core->blog->settings->pings->pings_uris; 89 if (empty($pings_uris) || !is_array($pings_uris)) { 90 return; 91 } 93 92 94 foreach ($_POST['pings_do'] as $uri) 95 { 96 if (in_array($uri,$pings_uris)) { 97 try { 98 pingsAPI::doPings($uri,$core->blog->name,$core->blog->url); 99 } catch (Exception $e) {} 100 } 101 } 102 } 93 foreach ($_POST['pings_do'] as $uri) { 94 if (in_array($uri, $pings_uris)) { 95 try { 96 pingsAPI::doPings($uri, $core->blog->name, $core->blog->url); 97 } catch (Exception $e) {} 98 } 99 } 100 } 103 101 } 104 102 105 103 class pingsCoreBehaviour 106 104 { 107 public static function doPings($blog,$ids)108 109 110 111 112 113 114 105 public static function doPings($blog, $ids) 106 { 107 if (!$blog->settings->pings->pings_active) { 108 return; 109 } 110 if (!$blog->settings->pings->pings_auto) { 111 return; 112 } 115 113 116 117 118 119 114 $pings_uris = $blog->settings->pings->pings_uris; 115 if (empty($pings_uris) || !is_array($pings_uris)) { 116 return; 117 } 120 118 121 foreach ($pings_uris as $uri) 122 { 123 try { 124 pingsAPI::doPings($uri,$blog->name,$blog->url); 125 } catch (Exception $e) {} 126 } 127 } 119 foreach ($pings_uris as $uri) { 120 try { 121 pingsAPI::doPings($uri, $blog->name, $blog->url); 122 } catch (Exception $e) {} 123 } 124 } 128 125 } -
plugins/simpleMenu/index.php
r3703 r3709 384 384 dcPage::jsLoad('js/jquery/jquery-ui.custom.js') . 385 385 dcPage::jsLoad('js/jquery/jquery.ui.touch-punch.js') . 386 dcPage::jsLoad(dcPage::getPF('simpleMenu/ simplemenu.js'));386 dcPage::jsLoad(dcPage::getPF('simpleMenu/js/simplemenu.js')); 387 387 } 388 388 echo dcPage::jsConfirmClose('settings', 'menuitemsappend', 'additem', 'menuitems'); -
plugins/tags/js/ckeditor-tags-plugin.js
r2939 r3709 1 /*global $, dotclear, CKEDITOR */ 2 'use strict'; 3 1 4 (function() { 2 3 4 5 6 if (editor.getSelection().getNative().toString().replace(/\s*/,'')!='') {7 var str = editor.getSelection().getNative().toString().replace(/\s*/,'');8 9 10 var link = '<a href="'+$.stripBaseURL(url+'/'+str)+'">'+str+'</a>';11 12 13 14 15 5 CKEDITOR.plugins.add('dctags', { 6 init: function(editor) { 7 editor.addCommand('dcTagsCommand', { 8 exec: function(editor) { 9 if (editor.getSelection().getNative().toString().replace(/\s*/, '') != '') { 10 var str = editor.getSelection().getNative().toString().replace(/\s*/, ''); 11 var url = dotclear.msg.tag_url; 12 window.dc_tag_editor.addMeta(str); 13 var link = '<a href="' + $.stripBaseURL(url + '/' + str) + '">' + str + '</a>'; 14 var element = CKEDITOR.dom.element.createFromHtml(link); 15 editor.insertElement(element); 16 } 17 } 18 }); 16 19 17 18 19 20 21 22 23 24 20 editor.ui.addButton('dcTags', { 21 label: dotclear.msg.tag_title, 22 command: 'dcTagsCommand', 23 toolbar: 'insert', 24 icon: this.path + 'tag.png' 25 }); 26 } 27 }); 25 28 })(); -
plugins/tags/js/legacy-post.js
r2924 r3709 1 /*global dotclear, jsToolBar */ 2 'use strict'; 3 1 4 // Toolbar button for tags 2 5 jsToolBar.prototype.elements.tagSpace = { 3 4 format:{5 wysiwyg:true,6 wiki:true,7 xhtml:true,8 markdown:true9 6 type: 'space', 7 format: { 8 wysiwyg: true, 9 wiki: true, 10 xhtml: true, 11 markdown: true 12 } 10 13 }; 11 14 12 jsToolBar.prototype.elements.tag = {type: 'button', title: 'Keyword', fn:{} }; 15 jsToolBar.prototype.elements.tag = { 16 type: 'button', 17 title: 'Keyword', 18 fn: {} 19 }; 13 20 jsToolBar.prototype.elements.tag.context = 'post'; 14 21 jsToolBar.prototype.elements.tag.icon = 'index.php?pf=tags/img/tag-add.png'; 15 22 jsToolBar.prototype.elements.tag.fn.wiki = function() { 16 this.encloseSelection('','',function(str) { 17 if (str == '') { window.alert(dotclear.msg.no_selection); return ''; } 18 if (str.indexOf(',') != -1) { 19 return str; 20 } else { 21 window.dc_tag_editor.addMeta(str); 22 return '['+str+'|tag:'+str+']'; 23 } 24 }); 23 this.encloseSelection('', '', function(str) { 24 if (str == '') { 25 window.alert(dotclear.msg.no_selection); 26 return ''; 27 } 28 if (str.indexOf(',') != -1) { 29 return str; 30 } else { 31 window.dc_tag_editor.addMeta(str); 32 return '[' + str + '|tag:' + str + ']'; 33 } 34 }); 25 35 }; 26 36 jsToolBar.prototype.elements.tag.fn.markdown = function() { 27 var url = this.elements.tag.url; 28 this.encloseSelection('','',function(str) { 29 if (str == '') { window.alert(dotclear.msg.no_selection); return ''; } 30 if (str.indexOf(',') != -1) { 31 return str; 32 } else { 33 window.dc_tag_editor.addMeta(str); 34 return '['+str+']('+this.stripBaseURL(url+'/'+str)+')'; 35 } 36 }); 37 var url = this.elements.tag.url; 38 this.encloseSelection('', '', function(str) { 39 if (str == '') { 40 window.alert(dotclear.msg.no_selection); 41 return ''; 42 } 43 if (str.indexOf(',') != -1) { 44 return str; 45 } else { 46 window.dc_tag_editor.addMeta(str); 47 return '[' + str + '](' + this.stripBaseURL(url + '/' + str) + ')'; 48 } 49 }); 37 50 }; 38 51 jsToolBar.prototype.elements.tag.fn.xhtml = function() { 39 var url = this.elements.tag.url; 40 this.encloseSelection('','',function(str) { 41 if (str == '') { window.alert(dotclear.msg.no_selection); return ''; } 42 if (str.indexOf(',') != -1) { 43 return str; 44 } else { 45 window.dc_tag_editor.addMeta(str); 46 return '<a href="'+this.stripBaseURL(url+'/'+str)+'">'+str+'</a>'; 47 } 48 }); 52 var url = this.elements.tag.url; 53 this.encloseSelection('', '', function(str) { 54 if (str == '') { 55 window.alert(dotclear.msg.no_selection); 56 return ''; 57 } 58 if (str.indexOf(',') != -1) { 59 return str; 60 } else { 61 window.dc_tag_editor.addMeta(str); 62 return '<a href="' + this.stripBaseURL(url + '/' + str) + '">' + str + '</a>'; 63 } 64 }); 49 65 }; 50 66 jsToolBar.prototype.elements.tag.fn.wysiwyg = function() { 51 67 var t = this.getSelectedText(); 52 68 53 if (t == '') { window.alert(dotclear.msg.no_selection); return; } 54 if (t.indexOf(',') != -1) { return; } 69 if (t == '') { 70 window.alert(dotclear.msg.no_selection); 71 return; 72 } 73 if (t.indexOf(',') != -1) { 74 return; 75 } 55 76 56 57 58 a.href = this.stripBaseURL(this.elements.tag.url+'/'+t);59 60 61 77 var n = this.getSelectedNode(); 78 var a = document.createElement('a'); 79 a.href = this.stripBaseURL(this.elements.tag.url + '/' + t); 80 a.appendChild(n); 81 this.insertNode(a); 82 window.dc_tag_editor.addMeta(t); 62 83 }; -
plugins/tags/js/post.js
r2924 r3709 1 /*global $, dotclear, metaEditor, editor_tags_options */ 2 'use strict'; 3 1 4 $(function() { 2 $('#edit-entry').onetabload(function() { 3 var tags_edit = $('#tags-edit'); 4 var post_id = $('#id'); 5 var meta_field = null; 5 $('#edit-entry').onetabload(function() { 6 var tags_edit = $('#tags-edit'); 7 var post_id = $('#id'); 8 var meta_field = null; 9 var mEdit = null; 6 10 7 8 9 10 11 12 13 var mEdit = new metaEditor(tags_edit,meta_field,'tag',editor_tags_options);14 15 mEdit.displayMeta('tag',post_id);11 if (tags_edit.length > 0) { 12 post_id = (post_id.length > 0) ? post_id.get(0).value : false; 13 if (post_id == false) { 14 meta_field = $('<input type="hidden" name="post_tags" />'); 15 meta_field.val($('#post_tags').val()); 16 } 17 mEdit = new metaEditor(tags_edit, meta_field, 'tag', editor_tags_options); 18 mEdit.meta_url = 'plugin.php?p=tags&m=tag_posts&tag='; 19 mEdit.displayMeta('tag', post_id); 16 20 17 18 19 21 // mEdit object reference for toolBar 22 window.dc_tag_editor = mEdit; 23 } 20 24 21 22 23 24 25 26 27 28 multipleSeparator: ", ",29 30 31 32 33 $(xml).find('meta').each(function(){34 35 36 "id": $(this).text(),37 "count": $(this).attr("count"),38 "percent": $(this).attr("roundpercent")39 40 41 42 43 44 45 46 47 48 replace('%p',tag.percent).49 replace('%e',tag.count + ' ' +50 51 52 53 54 55 56 57 58 59 60 25 $('#post_meta_input').autocomplete(mEdit.service_uri, { 26 extraParams: { 27 'f': 'searchMeta', 28 'metaType': 'tag' 29 }, 30 delay: 1000, 31 multiple: true, 32 multipleSeparator: ', ', 33 matchSubset: false, 34 matchContains: true, 35 parse: function(xml) { 36 var results = []; 37 $(xml).find('meta').each(function() { 38 results[results.length] = { 39 data: { 40 'id': $(this).text(), 41 'count': $(this).attr('count'), 42 'percent': $(this).attr('roundpercent') 43 }, 44 result: $(this).text() 45 }; 46 }); 47 return results; 48 }, 49 formatItem: function(tag) { 50 return tag.id + ' <em>(' + 51 dotclear.msg.tags_autocomplete. 52 replace('%p', tag.percent). 53 replace('%e', tag.count + ' ' + 54 (tag.count > 1 ? 55 dotclear.msg.entries : 56 dotclear.msg.entry) 57 ) + 58 ')</em>'; 59 }, 60 formatResult: function(tag) { 61 return tag.result; 62 } 63 }); 64 }); 61 65 62 $('h5 .s-tags').toggleWithLegend($('.s-tags').not('label'),{63 64 65 66 $('h5 .s-tags').toggleWithLegend($('.s-tags').not('label'), { 67 user_pref: 'post_tags', 68 legend_click: true 69 }); 66 70 67 71 }); -
plugins/tags/js/posts_actions.js
r2546 r3709 1 /*global $, dotclear, metaEditor, editor_tags_options */ 2 'use strict'; 3 1 4 $(function() { 2 5 var tag_field = $('#new_tags'); … … 22 25 $('#post_meta_input').autocomplete(mEdit.service_uri, { 23 26 extraParams: { 24 'f': 'searchMeta',27 'f': 'searchMeta', 25 28 'metaType': 'tag' 26 29 }, … … 34 37 results[results.length] = { 35 38 data: { 36 "id":$(this).text(),37 "count": $(this).attr("count"),38 "percent": $(this).attr("roundpercent")39 'id': $(this).text(), 40 'count': $(this).attr('count'), 41 'percent': $(this).attr('roundpercent') 39 42 }, 40 43 result: $(this).text() -
plugins/themeEditor/index.php
r3421 r3709 10 10 # 11 11 # -- END LICENSE BLOCK ----------------------------------------- 12 if (!defined('DC_CONTEXT_ADMIN')) { return;}12 if (!defined('DC_CONTEXT_ADMIN')) {return;} 13 13 14 require dirname(__FILE__) .'/class.themeEditor.php';14 require dirname(__FILE__) . '/class.themeEditor.php'; 15 15 16 $file_default = $file = array('c' =>null, 'w'=>false, 'type'=>null, 'f'=>null, 'default_file'=>false);16 $file_default = $file = array('c' => null, 'w' => false, 'type' => null, 'f' => null, 'default_file' => false); 17 17 18 18 # Get interface setting 19 19 $core->auth->user_prefs->addWorkspace('interface'); 20 $user_ui_colorsyntax = $core->auth->user_prefs->interface->colorsyntax;20 $user_ui_colorsyntax = $core->auth->user_prefs->interface->colorsyntax; 21 21 $user_ui_colorsyntax_theme = $core->auth->user_prefs->interface->colorsyntax_theme; 22 22 23 23 # Loading themes 24 24 $core->themes = new dcThemes($core); 25 $core->themes->loadModules($core->blog->themes_path, null);25 $core->themes->loadModules($core->blog->themes_path, null); 26 26 $T = $core->themes->getModules($core->blog->settings->system->theme); 27 27 $o = new dcThemeEditor($core); … … 29 29 try 30 30 { 31 try 32 { 33 if (!empty($_REQUEST['tpl'])) { 34 $file = $o->getFileContent('tpl',$_REQUEST['tpl']); 35 } elseif (!empty($_REQUEST['css'])) { 36 $file = $o->getFileContent('css',$_REQUEST['css']); 37 } elseif (!empty($_REQUEST['js'])) { 38 $file = $o->getFileContent('js',$_REQUEST['js']); 39 } elseif (!empty($_REQUEST['po'])) { 40 $file = $o->getFileContent('po',$_REQUEST['po']); 41 } 42 } 43 catch (Exception $e) 44 { 45 $file = $file_default; 46 throw $e; 47 } 31 try 32 { 33 if (!empty($_REQUEST['tpl'])) { 34 $file = $o->getFileContent('tpl', $_REQUEST['tpl']); 35 } elseif (!empty($_REQUEST['css'])) { 36 $file = $o->getFileContent('css', $_REQUEST['css']); 37 } elseif (!empty($_REQUEST['js'])) { 38 $file = $o->getFileContent('js', $_REQUEST['js']); 39 } elseif (!empty($_REQUEST['po'])) { 40 $file = $o->getFileContent('po', $_REQUEST['po']); 41 } 42 } catch (Exception $e) { 43 $file = $file_default; 44 throw $e; 45 } 48 46 49 # Write file 50 if (!empty($_POST['write'])) 51 { 52 $file['c'] = $_POST['file_content']; 53 $o->writeFile($file['type'],$file['f'],$file['c']); 54 } 47 # Write file 48 if (!empty($_POST['write'])) { 49 $file['c'] = $_POST['file_content']; 50 $o->writeFile($file['type'], $file['f'], $file['c']); 51 } 55 52 56 # Delete file 57 if (!empty($_POST['delete'])) 58 { 59 $o->deleteFile($file['type'],$file['f']); 60 dcPage::addSuccessNotice(__('The file has been reset.')); 61 http::redirect($p_url.'&'.$file['type'].'='.$file['f']); 62 } 63 } 64 catch (Exception $e) 65 { 66 $core->error->add($e->getMessage()); 53 # Delete file 54 if (!empty($_POST['delete'])) { 55 $o->deleteFile($file['type'], $file['f']); 56 dcPage::addSuccessNotice(__('The file has been reset.')); 57 http::redirect($p_url . '&' . $file['type'] . '=' . $file['f']); 58 } 59 } catch (Exception $e) { 60 $core->error->add($e->getMessage()); 67 61 } 68 62 ?> … … 70 64 <html> 71 65 <head> 72 <title><?php echo __('Edit theme files'); ?></title> 73 <script type="text/javascript"> 74 <?php echo dcPage::jsVar('dotclear.msg.saving_document',__("Saving document...")); ?> 75 <?php echo dcPage::jsVar('dotclear.msg.document_saved',__("Document saved")); ?> 76 <?php echo dcPage::jsVar('dotclear.msg.error_occurred',__("An error occurred:")); ?> 77 <?php echo dcPage::jsVar('dotclear.msg.confirm_reset_file',__("Are you sure you want to reset this file?")); ?> 78 <?php echo dcPage::jsVar('dotclear.colorsyntax',$user_ui_colorsyntax); ?> 79 </script> 80 <?php echo dcPage::jsConfirmClose('file-form'); ?> 81 <script type="text/javascript" src="<?php echo dcPage::getPF('themeEditor/script.js'); ?>"></script> 82 <?php if ($user_ui_colorsyntax) { ?> 83 <?php echo dcPage::jsLoadCodeMirror($user_ui_colorsyntax_theme); ?> 84 <?php } ?> 85 <?php echo dcPage::cssLoad(dcPage::getPF('themeEditor/style.css'));?> 66 <title><?php echo __('Edit theme files'); ?></title> 67 <?php 68 echo dcPage::jsVars(array( 69 'dotclear.msg.saving_document' => __("Saving document..."), 70 'dotclear.msg.document_saved' => __("Document saved"), 71 'dotclear.msg.error_occurred' => __("An error occurred:"), 72 'dotclear.msg.confirm_reset_file' => __("Are you sure you want to reset this file?"), 73 'dotclear.colorsyntax' => $user_ui_colorsyntax 74 )) . 75 dcPage::jsConfirmClose('file-form') . 76 dcPage::jsLoad(dcPage::getPF('themeEditor/js/script.js')); 77 if ($user_ui_colorsyntax) { 78 echo dcPage::jsLoadCodeMirror($user_ui_colorsyntax_theme); 79 } 80 echo dcPage::cssLoad(dcPage::getPF('themeEditor/style.css')); 81 ?> 86 82 </head> 87 83 … … 89 85 <?php 90 86 echo dcPage::breadcrumb( 91 92 93 __('Blog appearance')=> $core->adminurl->get('admin.blog.theme'),94 __('Edit theme files')=> ''95 )).96 87 array( 88 html::escapeHTML($core->blog->name) => '', 89 __('Blog appearance') => $core->adminurl->get('admin.blog.theme'), 90 __('Edit theme files') => '' 91 )) . 92 dcPage::notices(); 97 93 ?> 98 94 99 <p><strong><?php echo sprintf(__('Your current theme on this blog is "%s".'), html::escapeHTML($T['name'])); ?></strong></p>95 <p><strong><?php echo sprintf(__('Your current theme on this blog is "%s".'), html::escapeHTML($T['name'])); ?></strong></p> 100 96 101 <?php if ($core->blog->settings->system->theme == 'default') { 102 103 104 <?php } 97 <?php if ($core->blog->settings->system->theme == 'default') {?> 98 <div class="error"><p><?php echo __("You can't edit default theme."); ?></p></div> 99 </body></html> 100 <?php }?> 105 101 106 102 <div id="file-box"> 107 103 <div id="file-editor"> 108 104 <?php 109 if ($file['c'] === null) 110 { 111 echo '<p>'.__('Please select a file to edit.').'</p>'; 112 } 113 else 114 { 115 echo 116 '<form id="file-form" action="'.$p_url.'" method="post">'. 117 '<div class="fieldset"><h3>'.__('File editor').'</h3>'. 118 '<p><label for="file_content">'.sprintf(__('Editing file %s'),'<strong>'.$file['f']).'</strong></label></p>'. 119 '<p>'.form::textarea('file_content',72,25,html::escapeHTML($file['c']),'maximal','',!$file['w']).'</p>'; 105 if ($file['c'] === null) { 106 echo '<p>' . __('Please select a file to edit.') . '</p>'; 107 } else { 108 echo 109 '<form id="file-form" action="' . $p_url . '" method="post">' . 110 '<div class="fieldset"><h3>' . __('File editor') . '</h3>' . 111 '<p><label for="file_content">' . sprintf(__('Editing file %s'), '<strong>' . $file['f']) . '</strong></label></p>' . 112 '<p>' . form::textarea('file_content', 72, 25, html::escapeHTML($file['c']), 'maximal', '', !$file['w']) . '</p>'; 120 113 121 if ($file['w']) 122 { 123 echo 124 '<p><input type="submit" name="write" value="'.__('Save').' (s)" accesskey="s" /> '. 125 ($o->deletableFile($file['type'],$file['f']) ? '<input type="submit" name="delete" class="delete" value="'.__('Reset').'" />' : ''). 126 $core->formNonce(). 127 ($file['type'] ? form::hidden(array($file['type']),$file['f']) : ''). 128 '</p>'; 129 } 130 else 131 { 132 echo '<p>'.__('This file is not writable. Please check your theme files permissions.').'</p>'; 133 } 114 if ($file['w']) { 115 echo 116 '<p><input type="submit" name="write" value="' . __('Save') . ' (s)" accesskey="s" /> ' . 117 ($o->deletableFile($file['type'], $file['f']) ? '<input type="submit" name="delete" class="delete" value="' . __('Reset') . '" />' : '') . 118 $core->formNonce() . 119 ($file['type'] ? form::hidden(array($file['type']), $file['f']) : '') . 120 '</p>'; 121 } else { 122 echo '<p>' . __('This file is not writable. Please check your theme files permissions.') . '</p>'; 123 } 134 124 135 136 125 echo 126 '</div></form>'; 137 127 138 139 140 141 142 143 144 145 146 147 CodeMirror.getMode(config, "'.$editorMode.'"),148 149 150 151 152 153 154 155 156 157 158 159 160 echo dcPage::jsRunCodeMirror('editor','file_content','dotclear',$user_ui_colorsyntax_theme);161 128 if ($user_ui_colorsyntax) { 129 $editorMode = 130 (!empty($_REQUEST['css']) ? "css" : 131 (!empty($_REQUEST['js']) ? "javascript" : 132 (!empty($_REQUEST['po']) ? "text/plain" : "text/html"))); 133 echo 134 '<script type="text/javascript"> 135 window.CodeMirror.defineMode("dotclear", function(config) { 136 return CodeMirror.multiplexingMode( 137 CodeMirror.getMode(config, "' . $editorMode . '"), 138 {open: "{{tpl:", close: "}}", 139 mode: CodeMirror.getMode(config, "text/plain"), 140 delimStyle: "delimit"}, 141 {open: "<tpl:", close: ">", 142 mode: CodeMirror.getMode(config, "text/plain"), 143 delimStyle: "delimit"}, 144 {open: "</tpl:", close: ">", 145 mode: CodeMirror.getMode(config, "text/plain"), 146 delimStyle: "delimit"} 147 ); 148 }); 149 </script>'; 150 echo dcPage::jsRunCodeMirror('editor', 'file_content', 'dotclear', $user_ui_colorsyntax_theme); 151 } 162 152 } 163 153 ?> … … 167 157 <div id="file-chooser"> 168 158 <h3><?php echo __('Templates files'); ?></h3> 169 <?php echo $o->filesList('tpl', '<a href="'.$p_url.'&tpl=%2$s" class="tpl-link">%1$s</a>'); ?>159 <?php echo $o->filesList('tpl', '<a href="' . $p_url . '&tpl=%2$s" class="tpl-link">%1$s</a>'); ?> 170 160 171 161 <h3><?php echo __('CSS files'); ?></h3> 172 <?php echo $o->filesList('css', '<a href="'.$p_url.'&css=%2$s" class="css-link">%1$s</a>'); ?>162 <?php echo $o->filesList('css', '<a href="' . $p_url . '&css=%2$s" class="css-link">%1$s</a>'); ?> 173 163 174 164 <h3><?php echo __('JavaScript files'); ?></h3> 175 <?php echo $o->filesList('js', '<a href="'.$p_url.'&js=%2$s" class="js-link">%1$s</a>'); ?>165 <?php echo $o->filesList('js', '<a href="' . $p_url . '&js=%2$s" class="js-link">%1$s</a>'); ?> 176 166 177 167 <h3><?php echo __('Locales files'); ?></h3> 178 <?php echo $o->filesList('po', '<a href="'.$p_url.'&po=%2$s" class="po-link">%1$s</a>'); ?>168 <?php echo $o->filesList('po', '<a href="' . $p_url . '&po=%2$s" class="po-link">%1$s</a>'); ?> 179 169 </div> 180 170 181 <?php dcPage::helpBlock('themeEditor'); 171 <?php dcPage::helpBlock('themeEditor');?> 182 172 </body> 183 173 </html> -
plugins/userPref/index.php
r3703 r3709 97 97 <head> 98 98 <title>user:preferences</title> 99 <?php echo dcPage::jsPageTabs($part); ?> 100 <script type="text/javascript"> 101 $(function() { 102 $("#gp_submit,#lp_submit").hide(); 103 $('#part-local,#part-global').tabload(function() { 104 $('.multi-part.active select.navigation option:first').attr('selected',true); 105 }); 106 $("#gp_nav").change(function() { 107 window.location = $("#gp_nav option:selected").val(); 108 }); 109 $("#lp_nav").change(function() { 110 window.location = $("#lp_nav option:selected").val(); 111 }); 112 }); 113 </script> 99 <?php echo dcPage::jsPageTabs($part) . dcPage::jsLoad(dcPage::getPF('userPref/js/index.js')); ?> 114 100 </head> 115 101 -
plugins/widgets/index.php
r3421 r3709 10 10 # 11 11 # -- END LICENSE BLOCK ----------------------------------------- 12 if (!defined('DC_CONTEXT_ADMIN')) { return;}13 14 include dirname(__FILE__) .'/_default_widgets.php';12 if (!defined('DC_CONTEXT_ADMIN')) {return;} 13 14 include dirname(__FILE__) . '/_default_widgets.php'; 15 15 16 16 # Loading navigation, extra widgets and custom widgets 17 17 $widgets_nav = null; 18 18 if ($core->blog->settings->widgets->widgets_nav) { 19 19 $widgets_nav = dcWidgets::load($core->blog->settings->widgets->widgets_nav); 20 20 } 21 21 $widgets_extra = null; 22 22 if ($core->blog->settings->widgets->widgets_extra) { 23 23 $widgets_extra = dcWidgets::load($core->blog->settings->widgets->widgets_extra); 24 24 } 25 25 $widgets_custom = null; 26 26 if ($core->blog->settings->widgets->widgets_custom) { 27 27 $widgets_custom = dcWidgets::load($core->blog->settings->widgets->widgets_custom); 28 28 } 29 29 30 30 $append_combo = array( 31 '-'=> 0,32 33 __('extra')=> 'extra',34 __('custom')=> 'custom'31 '-' => 0, 32 __('navigation') => 'nav', 33 __('extra') => 'extra', 34 __('custom') => 'custom' 35 35 ); 36 36 37 37 function literalNullString($v) 38 38 { 39 40 return '<'.__('empty string').'>';41 42 39 if ($v == '') { 40 return '<' . __('empty string') . '>'; 41 } 42 return $v; 43 43 } 44 44 45 45 # Adding widgets to sidebars 46 if (!empty($_POST['append']) && is_array($_POST['addw'])) 47 { 48 # Filter selection 49 $addw = array(); 50 foreach ($_POST['addw'] as $k => $v) { 51 if (($v == 'extra' || $v == 'nav' || $v == 'custom') && $__widgets->{$k} !== null ) { 52 $addw[$k] = $v; 53 } 54 } 55 56 # Append 1 widget 57 $wid = false; 58 if( gettype($_POST['append']) == 'array' && count($_POST['append']) == 1 ) { 59 $wid = array_keys($_POST['append']); 60 $wid = $wid[0]; 61 } 62 63 # Append widgets 64 if (!empty($addw)) 65 { 66 if (!($widgets_nav instanceof dcWidgets)) { 67 $widgets_nav = new dcWidgets; 68 } 69 if (!($widgets_extra instanceof dcWidgets)) { 70 $widgets_extra = new dcWidgets(); 71 } 72 if (!($widgets_custom instanceof dcWidgets)) { 73 $widgets_custom = new dcWidgets(); 74 } 75 76 foreach ($addw as $k => $v) 77 { 78 if( !$wid || $wid == $k ) 79 { 80 switch ($v) { 81 case 'nav': 82 $widgets_nav->append($__widgets->{$k}); 83 break; 84 case 'extra': 85 $widgets_extra->append($__widgets->{$k}); 86 break; 87 case 'custom': 88 $widgets_custom->append($__widgets->{$k}); 89 break; 90 } 91 } 92 } 93 94 try { 95 $core->blog->settings->addNamespace('widgets'); 96 $core->blog->settings->widgets->put('widgets_nav',$widgets_nav->store()); 97 $core->blog->settings->widgets->put('widgets_extra',$widgets_extra->store()); 98 $core->blog->settings->widgets->put('widgets_custom',$widgets_custom->store()); 99 $core->blog->triggerBlog(); 100 http::redirect($p_url); 101 } catch (Exception $e) { 102 $core->error->add($e->getMessage()); 103 } 104 } 46 if (!empty($_POST['append']) && is_array($_POST['addw'])) { 47 # Filter selection 48 $addw = array(); 49 foreach ($_POST['addw'] as $k => $v) { 50 if (($v == 'extra' || $v == 'nav' || $v == 'custom') && $__widgets->{$k} !== null) { 51 $addw[$k] = $v; 52 } 53 } 54 55 # Append 1 widget 56 $wid = false; 57 if (gettype($_POST['append']) == 'array' && count($_POST['append']) == 1) { 58 $wid = array_keys($_POST['append']); 59 $wid = $wid[0]; 60 } 61 62 # Append widgets 63 if (!empty($addw)) { 64 if (!($widgets_nav instanceof dcWidgets)) { 65 $widgets_nav = new dcWidgets; 66 } 67 if (!($widgets_extra instanceof dcWidgets)) { 68 $widgets_extra = new dcWidgets(); 69 } 70 if (!($widgets_custom instanceof dcWidgets)) { 71 $widgets_custom = new dcWidgets(); 72 } 73 74 foreach ($addw as $k => $v) { 75 if (!$wid || $wid == $k) { 76 switch ($v) { 77 case 'nav': 78 $widgets_nav->append($__widgets->{$k}); 79 break; 80 case 'extra': 81 $widgets_extra->append($__widgets->{$k}); 82 break; 83 case 'custom': 84 $widgets_custom->append($__widgets->{$k}); 85 break; 86 } 87 } 88 } 89 90 try { 91 $core->blog->settings->addNamespace('widgets'); 92 $core->blog->settings->widgets->put('widgets_nav', $widgets_nav->store()); 93 $core->blog->settings->widgets->put('widgets_extra', $widgets_extra->store()); 94 $core->blog->settings->widgets->put('widgets_custom', $widgets_custom->store()); 95 $core->blog->triggerBlog(); 96 http::redirect($p_url); 97 } catch (Exception $e) { 98 $core->error->add($e->getMessage()); 99 } 100 } 105 101 } 106 102 107 103 # Removing ? 108 104 $removing = false; 109 if ( isset($_POST['w']) && is_array($_POST['w'])) {110 111 112 113 114 115 116 117 105 if (isset($_POST['w']) && is_array($_POST['w'])) { 106 foreach ($_POST['w'] as $nsid => $nsw) { 107 foreach ($nsw as $i => $v) { 108 if (!empty($v['_rem'])) { 109 $removing = true; 110 break 2; 111 } 112 } 113 } 118 114 } 119 115 120 116 # Move ? 121 117 $move = false; 122 if ( isset($_POST['w']) && is_array($_POST['w'])) {123 124 125 126 127 128 if( isset($_POST['w'][$nsid][$neworder])) {129 $_POST['w'][$nsid][$i]['order']= $neworder;130 131 $move= true;132 133 134 135 136 137 if( isset($_POST['w'][$nsid][$neworder])) {138 $_POST['w'][$nsid][$i]['order']= $neworder;139 140 $move= true;141 142 143 144 118 if (isset($_POST['w']) && is_array($_POST['w'])) { 119 foreach ($_POST['w'] as $nsid => $nsw) { 120 foreach ($nsw as $i => $v) { 121 if (!empty($v['_down'])) { 122 $oldorder = $_POST['w'][$nsid][$i]['order']; 123 $neworder = $oldorder + 1; 124 if (isset($_POST['w'][$nsid][$neworder])) { 125 $_POST['w'][$nsid][$i]['order'] = $neworder; 126 $_POST['w'][$nsid][$neworder]['order'] = $oldorder; 127 $move = true; 128 } 129 } 130 if (!empty($v['_up'])) { 131 $oldorder = $_POST['w'][$nsid][$i]['order']; 132 $neworder = $oldorder - 1; 133 if (isset($_POST['w'][$nsid][$neworder])) { 134 $_POST['w'][$nsid][$i]['order'] = $neworder; 135 $_POST['w'][$nsid][$neworder]['order'] = $oldorder; 136 $move = true; 137 } 138 } 139 } 140 } 145 141 } 146 142 147 143 # Update sidebars 148 if (!empty($_POST['wup']) || $removing || $move ) 149 { 150 if (!isset($_POST['w']) || !is_array($_POST['w'])) { 151 $_POST['w'] = array(); 152 } 153 154 try 155 { 156 # Removing mark as _rem widgets 157 foreach ($_POST['w'] as $nsid => $nsw) { 158 foreach ($nsw as $i => $v) { 159 if (!empty($v['_rem'])) { 160 unset($_POST['w'][$nsid][$i]); 161 continue; 162 } 163 } 164 } 165 166 if (!isset($_POST['w']['nav'])) { 167 $_POST['w']['nav'] = array(); 168 } 169 if (!isset($_POST['w']['extra'])) { 170 $_POST['w']['extra'] = array(); 171 } 172 if (!isset($_POST['w']['custom'])) { 173 $_POST['w']['custom'] = array(); 174 } 175 176 $widgets_nav = dcWidgets::loadArray($_POST['w']['nav'],$__widgets); 177 $widgets_extra = dcWidgets::loadArray($_POST['w']['extra'],$__widgets); 178 $widgets_custom = dcWidgets::loadArray($_POST['w']['custom'],$__widgets); 179 180 $core->blog->settings->addNamespace('widgets'); 181 $core->blog->settings->widgets->put('widgets_nav',$widgets_nav->store()); 182 $core->blog->settings->widgets->put('widgets_extra',$widgets_extra->store()); 183 $core->blog->settings->widgets->put('widgets_custom',$widgets_custom->store()); 184 $core->blog->triggerBlog(); 185 186 dcPage::addSuccessNotice(__('Sidebars and their widgets have been saved.')); 187 http::redirect($p_url); 188 } 189 catch (Exception $e) 190 { 191 $core->error->add($e->getMessage()); 192 } 193 } 194 elseif (!empty($_POST['wreset'])) 195 { 196 try 197 { 198 $core->blog->settings->addNamespace('widgets'); 199 $core->blog->settings->widgets->put('widgets_nav',''); 200 $core->blog->settings->widgets->put('widgets_extra',''); 201 $core->blog->settings->widgets->put('widgets_custom',''); 202 $core->blog->triggerBlog(); 203 204 dcPage::addSuccessNotice(__('Sidebars have been resetting.')); 205 http::redirect($p_url); 206 } 207 catch (Exception $e) 208 { 209 $core->error->add($e->getMessage()); 210 } 144 if (!empty($_POST['wup']) || $removing || $move) { 145 if (!isset($_POST['w']) || !is_array($_POST['w'])) { 146 $_POST['w'] = array(); 147 } 148 149 try 150 { 151 # Removing mark as _rem widgets 152 foreach ($_POST['w'] as $nsid => $nsw) { 153 foreach ($nsw as $i => $v) { 154 if (!empty($v['_rem'])) { 155 unset($_POST['w'][$nsid][$i]); 156 continue; 157 } 158 } 159 } 160 161 if (!isset($_POST['w']['nav'])) { 162 $_POST['w']['nav'] = array(); 163 } 164 if (!isset($_POST['w']['extra'])) { 165 $_POST['w']['extra'] = array(); 166 } 167 if (!isset($_POST['w']['custom'])) { 168 $_POST['w']['custom'] = array(); 169 } 170 171 $widgets_nav = dcWidgets::loadArray($_POST['w']['nav'], $__widgets); 172 $widgets_extra = dcWidgets::loadArray($_POST['w']['extra'], $__widgets); 173 $widgets_custom = dcWidgets::loadArray($_POST['w']['custom'], $__widgets); 174 175 $core->blog->settings->addNamespace('widgets'); 176 $core->blog->settings->widgets->put('widgets_nav', $widgets_nav->store()); 177 $core->blog->settings->widgets->put('widgets_extra', $widgets_extra->store()); 178 $core->blog->settings->widgets->put('widgets_custom', $widgets_custom->store()); 179 $core->blog->triggerBlog(); 180 181 dcPage::addSuccessNotice(__('Sidebars and their widgets have been saved.')); 182 http::redirect($p_url); 183 } catch (Exception $e) { 184 $core->error->add($e->getMessage()); 185 } 186 } elseif (!empty($_POST['wreset'])) { 187 try 188 { 189 $core->blog->settings->addNamespace('widgets'); 190 $core->blog->settings->widgets->put('widgets_nav', ''); 191 $core->blog->settings->widgets->put('widgets_extra', ''); 192 $core->blog->settings->widgets->put('widgets_custom', ''); 193 $core->blog->triggerBlog(); 194 195 dcPage::addSuccessNotice(__('Sidebars have been resetting.')); 196 http::redirect($p_url); 197 } catch (Exception $e) { 198 $core->error->add($e->getMessage()); 199 } 211 200 } 212 201 ?> … … 214 203 <head> 215 204 <title><?php echo __('Widgets'); ?></title> 216 <?php echo dcPage::cssLoad(dcPage::getPF('widgets/style.css'));?> 217 <?php 218 echo 219 dcPage::jsLoad('js/jquery/jquery-ui.custom.js'). 220 dcPage::jsLoad('js/jquery/jquery.ui.touch-punch.js'). 221 dcPage::jsLoad(dcPage::getPF('widgets/widgets.js')); 222 ?> 223 <?php 224 $core->auth->user_prefs->addWorkspace('accessibility'); 225 $user_dm_nodragdrop = $core->auth->user_prefs->accessibility->nodragdrop; 226 ?> 227 <?php if (!$user_dm_nodragdrop) : ?> 228 <?php echo dcPage::jsLoad(dcPage::getPF('widgets/dragdrop.js'));?> 229 <?php endif; ?> 230 <script type="text/javascript"> 231 <?php echo dcPage::jsVar('dotclear.msg.confirm_widgets_reset', 232 __('Are you sure you want to reset sidebars?')); ?> 233 </script> 234 <?php 235 $widget_editor = $core->auth->getOption('editor'); 236 $rte_flag = true; 237 $rte_flags = @$core->auth->user_prefs->interface->rte_flags; 238 if (is_array($rte_flags) && in_array('widgets_text',$rte_flags)) { 239 $rte_flag = $rte_flags['widgets_text']; 240 } 241 if ($rte_flag) { 242 echo $core->callBehavior('adminPostEditor',$widget_editor['xhtml'],'widget',array('#sidebarsWidgets textarea'),'xhtml'); 243 } 244 ?> 245 <?php echo(dcPage::jsConfirmClose('sidebarsWidgets')); ?> 205 <?php 206 echo dcPage::cssLoad(dcPage::getPF('widgets/style.css')) . 207 dcPage::jsLoad('js/jquery/jquery-ui.custom.js') . 208 dcPage::jsLoad('js/jquery/jquery.ui.touch-punch.js') . 209 dcPage::jsLoad(dcPage::getPF('widgets/js/widgets.js')); 210 211 $core->auth->user_prefs->addWorkspace('accessibility'); 212 $user_dm_nodragdrop = $core->auth->user_prefs->accessibility->nodragdrop; 213 if (!$user_dm_nodragdrop) { 214 echo dcPage::jsLoad(dcPage::getPF('widgets/js/dragdrop.js')); 215 } 216 echo dcPage::jsVars(array('dotclear.msg.confirm_widgets_reset' => __('Are you sure you want to reset sidebars?'))); 217 218 $widget_editor = $core->auth->getOption('editor'); 219 $rte_flag = true; 220 $rte_flags = @$core->auth->user_prefs->interface->rte_flags; 221 if (is_array($rte_flags) && in_array('widgets_text', $rte_flags)) { 222 $rte_flag = $rte_flags['widgets_text']; 223 } 224 if ($rte_flag) { 225 echo $core->callBehavior('adminPostEditor', $widget_editor['xhtml'], 'widget', array('#sidebarsWidgets textarea'), 'xhtml'); 226 } 227 echo (dcPage::jsConfirmClose('sidebarsWidgets')); 228 ?> 246 229 </head> 247 230 <body> 248 231 <?php 249 232 echo dcPage::breadcrumb( 250 251 252 __('Widgets')=> ''253 )).254 233 array( 234 html::escapeHTML($core->blog->name) => '', 235 __('Widgets') => '' 236 )) . 237 dcPage::notices(); 255 238 256 239 # All widgets 257 240 echo 258 '<form id="listWidgets" action="' .$p_url.'" method="post" class="widgets">'.259 '<h3>' .__('Available widgets').'</h3>'.260 '<p>' .__('Drag widgets from this list to one of the sidebars, for add.').'</p>'.261 '<ul id="widgets-ref">';241 '<form id="listWidgets" action="' . $p_url . '" method="post" class="widgets">' . 242 '<h3>' . __('Available widgets') . '</h3>' . 243 '<p>' . __('Drag widgets from this list to one of the sidebars, for add.') . '</p>' . 244 '<ul id="widgets-ref">'; 262 245 263 246 $j = 0; 264 247 foreach ($__widgets->elements(true) as $w) { 265 266 '<li>'.form::hidden(array('w[void][0][id]'),html::escapeHTML($w->id())).267 '<p class="widget-name">'.form::field(array('w[void][0][order]'),2,3,0,'hide','',0,'title="'.__('order').'"').' '.$w->name().268 ($w->desc() != '' ? ' <span class="form-note">'.__($w->desc()).'</span>' : '').'</p>'.269 '<p class="manual-move remove-if-drag"><label class="classic">'.__('Append to:').'</label> '.270 form::combo(array('addw['.$w->id().']'),$append_combo).271 '<input type="submit" name="append['.$w->id().']" value="'.__('Add').'" /></p>'.272 '<div class="widgetSettings hidden-if-drag">'.$w->formSettings('w[void][0]',$j).'</div>'.273 274 275 } 276 277 echo 278 '</ul>' .279 '<p>' .$core->formNonce().'</p>'.280 '<p class="remove-if-drag"><input type="submit" name="append" value="' .__('Add widgets to sidebars').'" /></p>'.281 '</form>';282 283 echo '<form id="sidebarsWidgets" action="' .$p_url.'" method="post">';248 echo 249 '<li>' . form::hidden(array('w[void][0][id]'), html::escapeHTML($w->id())) . 250 '<p class="widget-name">' . form::field(array('w[void][0][order]'), 2, 3, 0, 'hide', '', 0, 'title="' . __('order') . '"') . ' ' . $w->name() . 251 ($w->desc() != '' ? ' <span class="form-note">' . __($w->desc()) . '</span>' : '') . '</p>' . 252 '<p class="manual-move remove-if-drag"><label class="classic">' . __('Append to:') . '</label> ' . 253 form::combo(array('addw[' . $w->id() . ']'), $append_combo) . 254 '<input type="submit" name="append[' . $w->id() . ']" value="' . __('Add') . '" /></p>' . 255 '<div class="widgetSettings hidden-if-drag">' . $w->formSettings('w[void][0]', $j) . '</div>' . 256 '</li>'; 257 $j++; 258 } 259 260 echo 261 '</ul>' . 262 '<p>' . $core->formNonce() . '</p>' . 263 '<p class="remove-if-drag"><input type="submit" name="append" value="' . __('Add widgets to sidebars') . '" /></p>' . 264 '</form>'; 265 266 echo '<form id="sidebarsWidgets" action="' . $p_url . '" method="post">'; 284 267 # Nav sidebar 285 268 echo 286 '<div id="sidebarNav" class="widgets fieldset">' .287 sidebarWidgets('dndnav', __('Navigation sidebar'),$widgets_nav,'nav',$__default_widgets['nav'],$j);269 '<div id="sidebarNav" class="widgets fieldset">' . 270 sidebarWidgets('dndnav', __('Navigation sidebar'), $widgets_nav, 'nav', $__default_widgets['nav'], $j); 288 271 echo '</div>'; 289 272 290 273 # Extra sidebar 291 274 echo 292 '<div id="sidebarExtra" class="widgets fieldset">' .293 sidebarWidgets('dndextra', __('Extra sidebar'),$widgets_extra,'extra',$__default_widgets['extra'],$j);275 '<div id="sidebarExtra" class="widgets fieldset">' . 276 sidebarWidgets('dndextra', __('Extra sidebar'), $widgets_extra, 'extra', $__default_widgets['extra'], $j); 294 277 echo '</div>'; 295 278 296 279 # Custom sidebar 297 280 echo 298 '<div id="sidebarCustom" class="widgets fieldset">' .299 sidebarWidgets('dndcustom', __('Custom sidebar'),$widgets_custom,'custom',$__default_widgets['custom'],$j);281 '<div id="sidebarCustom" class="widgets fieldset">' . 282 sidebarWidgets('dndcustom', __('Custom sidebar'), $widgets_custom, 'custom', $__default_widgets['custom'], $j); 300 283 echo '</div>'; 301 284 302 285 echo 303 '<p id="sidebarsControl">' .304 $core->formNonce() .305 '<input type="submit" name="wup" value="' .__('Update sidebars').'" /> '.306 '<input type="submit" class="reset" name="wreset" value="' .__('Reset sidebars').'" /></p>'.307 '</form>';308 309 $widget_elements = new stdClass;286 '<p id="sidebarsControl">' . 287 $core->formNonce() . 288 '<input type="submit" name="wup" value="' . __('Update sidebars') . '" /> ' . 289 '<input type="submit" class="reset" name="wreset" value="' . __('Reset sidebars') . '" /></p>' . 290 '</form>'; 291 292 $widget_elements = new stdClass; 310 293 $widget_elements->content = '<dl>'; 311 foreach ($__widgets->elements() as $w) 294 foreach ($__widgets->elements() as $w) { 295 $widget_elements->content .= 296 '<dt><strong>' . html::escapeHTML($w->name()) . '</strong> (' . 297 __('Widget ID:') . ' <strong>' . html::escapeHTML($w->id()) . '</strong>)' . 298 ($w->desc() != '' ? ' <span class="form-note">' . __($w->desc()) . '</span>' : '') . '</dt>' . 299 '<dd>'; 300 301 $w_settings = $w->settings(); 302 if (empty($w_settings)) { 303 $widget_elements->content .= '<p>' . __('No setting for this widget') . '</p>'; 304 } else { 305 $widget_elements->content .= '<ul>'; 306 foreach ($w->settings() as $n => $s) { 307 switch ($s['type']) { 308 case 'check': 309 $s_type = __('boolean') . ", " . __('possible values:') . " <code>0</code> " . __('or') . " <code>1</code>"; 310 break; 311 case 'combo': 312 $s['options'] = array_map("literalNullString", $s['options']); 313 $s_type = __('listitem') . ", " . __('possible values:') . " <code>" . implode('</code>, <code>', $s['options']) . "</code>"; 314 break; 315 case 'text': 316 case 'textarea': 317 default: 318 $s_type = __('string'); 319 break; 320 } 321 322 $widget_elements->content .= 323 '<li>' . 324 __('Setting name:') . ' <strong>' . html::escapeHTML($n) . '</strong>' . 325 ' (' . $s_type . ')' . 326 '</li>'; 327 } 328 $widget_elements->content .= '</ul>'; 329 } 330 $widget_elements->content .= '</dd>'; 331 } 332 $widget_elements->content .= '</dl></div>'; 333 334 dcPage::helpBlock('widgets', $widget_elements); 335 336 function sidebarWidgets($id, $title, $widgets, $pr, $default_widgets, &$j) 312 337 { 313 $widget_elements->content .= 314 '<dt><strong>'.html::escapeHTML($w->name()).'</strong> ('. 315 __('Widget ID:').' <strong>'.html::escapeHTML($w->id()).'</strong>)'. 316 ($w->desc() != '' ? ' <span class="form-note">'.__($w->desc()).'</span>' : '').'</dt>'. 317 '<dd>'; 318 319 $w_settings = $w->settings(); 320 if (empty($w_settings)) 321 { 322 $widget_elements->content .= '<p>'.__('No setting for this widget').'</p>'; 323 } 324 else 325 { 326 $widget_elements->content .= '<ul>'; 327 foreach ($w->settings() as $n => $s) 328 { 329 switch ($s['type']) { 330 case 'check': 331 $s_type = __('boolean').", ".__('possible values:')." <code>0</code> ".__('or')." <code>1</code>"; 332 break; 333 case 'combo': 334 $s['options'] = array_map("literalNullString", $s['options']); 335 $s_type = __('listitem').", ".__('possible values:')." <code>".implode('</code>, <code>',$s['options'])."</code>"; 336 break; 337 case 'text': 338 case 'textarea': 339 default: 340 $s_type = __('string'); 341 break; 342 } 343 344 $widget_elements->content .= 345 '<li>'. 346 __('Setting name:').' <strong>'.html::escapeHTML($n).'</strong>'. 347 ' ('.$s_type.')'. 348 '</li>'; 349 } 350 $widget_elements->content .= '</ul>'; 351 } 352 $widget_elements->content .= '</dd>'; 353 } 354 $widget_elements->content .= '</dl></div>'; 355 356 dcPage::helpBlock('widgets',$widget_elements); 357 358 function sidebarWidgets($id,$title,$widgets,$pr,$default_widgets,&$j) 359 { 360 $res = '<h3>'.$title.'</h3>'; 361 362 if (!($widgets instanceof dcWidgets)) 363 { 364 $widgets = $default_widgets; 365 } 366 367 $res .= '<ul id="'.$id.'" class="connected">'; 368 369 $res .= '<li class="empty-widgets" '.(!$widgets->isEmpty() ? 'style="display: none;"' : '').'>'.__('No widget as far.').'</li>'; 370 371 $i = 0; 372 foreach ($widgets->elements() as $w) 373 { 374 $upDisabled = $i == 0 ? ' disabled" src="images/disabled_' : '" src="images/'; 375 $downDisabled = $i == count($widgets->elements())-1 ? ' disabled" src="images/disabled_' : '" src="images/'; 376 $altUp = $i == 0 ? ' alt=""' : ' alt="'.__('Up the widget').'"'; 377 $altDown = $i == count($widgets->elements())-1 ? ' alt=""' : ' alt="'.__('Down the widget').'"'; 378 379 $iname = 'w['.$pr.']['.$i.']'; 380 381 $res .= 382 '<li>'.form::hidden(array($iname.'[id]'),html::escapeHTML($w->id())). 383 '<p class="widget-name">'.form::field(array($iname.'[order]'),2,3,(string) $i,'hidden','',0,'title="'.__('order').'"'). 384 ' '.$w->name(). 385 ($w->desc() != '' ? ' <span class="form-note">'.__($w->desc()).'</span>' : ''). 386 '<span class="toolsWidget remove-if-drag">'. 387 '<input type="image" class="upWidget'.$upDisabled.'up.png" name="'.$iname.'[_up]" value="'.__('Up the widget').'"'.$altUp.' /> '. 388 '<input type="image" class="downWidget'.$downDisabled.'down.png" name="'.$iname.'[_down]" value="'.__('Down the widget').'"'.$altDown.' /> '.' '. 389 '<input type="image" class="removeWidget" src="images/trash.png" name="'.$iname.'[_rem]" value="'.__('Remove widget').'" alt="'.__('Remove the widget').'" />'. 390 '</span>'. 391 '<br class="clear"/></p>'. 392 '<div class="widgetSettings hidden-if-drag">'.$w->formSettings($iname,$j).'</div>'. 393 '</li>'; 394 395 $i++; 396 $j++; 397 } 398 399 $res .= '</ul>'; 400 401 $res .= '<ul class="sortable-delete"'.($i > 0 ? '':' style="display: none;"').'><li class="sortable-delete-placeholder">'. 402 __('Drag widgets here to remove.').'</li></ul>'; 403 404 return $res; 338 $res = '<h3>' . $title . '</h3>'; 339 340 if (!($widgets instanceof dcWidgets)) { 341 $widgets = $default_widgets; 342 } 343 344 $res .= '<ul id="' . $id . '" class="connected">'; 345 346 $res .= '<li class="empty-widgets" ' . (!$widgets->isEmpty() ? 'style="display: none;"' : '') . '>' . __('No widget as far.') . '</li>'; 347 348 $i = 0; 349 foreach ($widgets->elements() as $w) { 350 $upDisabled = $i == 0 ? ' disabled" src="images/disabled_' : '" src="images/'; 351 $downDisabled = $i == count($widgets->elements()) - 1 ? ' disabled" src="images/disabled_' : '" src="images/'; 352 $altUp = $i == 0 ? ' alt=""' : ' alt="' . __('Up the widget') . '"'; 353 $altDown = $i == count($widgets->elements()) - 1 ? ' alt=""' : ' alt="' . __('Down the widget') . '"'; 354 355 $iname = 'w[' . $pr . '][' . $i . ']'; 356 357 $res .= 358 '<li>' . form::hidden(array($iname . '[id]'), html::escapeHTML($w->id())) . 359 '<p class="widget-name">' . form::field(array($iname . '[order]'), 2, 3, (string) $i, 'hidden', '', 0, 'title="' . __('order') . '"') . 360 ' ' . $w->name() . 361 ($w->desc() != '' ? ' <span class="form-note">' . __($w->desc()) . '</span>' : '') . 362 '<span class="toolsWidget remove-if-drag">' . 363 '<input type="image" class="upWidget' . $upDisabled . 'up.png" name="' . $iname . '[_up]" value="' . __('Up the widget') . '"' . $altUp . ' /> ' . 364 '<input type="image" class="downWidget' . $downDisabled . 'down.png" name="' . $iname . '[_down]" value="' . __('Down the widget') . '"' . $altDown . ' /> ' . ' ' . 365 '<input type="image" class="removeWidget" src="images/trash.png" name="' . $iname . '[_rem]" value="' . __('Remove widget') . '" alt="' . __('Remove the widget') . '" />' . 366 '</span>' . 367 '<br class="clear"/></p>' . 368 '<div class="widgetSettings hidden-if-drag">' . $w->formSettings($iname, $j) . '</div>' . 369 '</li>'; 370 371 $i++; 372 $j++; 373 } 374 375 $res .= '</ul>'; 376 377 $res .= '<ul class="sortable-delete"' . ($i > 0 ? '' : ' style="display: none;"') . '><li class="sortable-delete-placeholder">' . 378 __('Drag widgets here to remove.') . '</li></ul>'; 379 380 return $res; 405 381 } 406 382 ?> -
themes/berlin/tpl/user_footer.html
r3706 r3709 1 <script type="text/javascript"> 2 'use strict'; 3 $('html').addClass('js'); 4 // Show/Hide main menu 5 $('.header__nav'). 6 before('<button id="hamburger" type="button"><span class="visually-hidden">' + dotclear_berlin_navigation + '</span></button>'). 7 toggle(); 8 $('#hamburger').click(function() { 9 $(this).toggleClass('open'); 10 $('.header__nav').toggle('easing'); 11 }); 12 // Show/Hide sidebar on small screens 13 $('#main').prepend('<button id="offcanvas-on" type="button"><span class="visually-hidden">' + dotclear_berlin_show_menu + '</span></button>'); 14 $('#offcanvas-on').click(function() { 15 var btn = $('<button id="offcanvas-off" type="button"><span class="visually-hidden">' + dotclear_berlin_hide_menu + '</span></button>'); 16 $('#wrapper').addClass('off-canvas'); 17 $('#footer').addClass('off-canvas'); 18 $('#sidebar').prepend(btn); 19 btn.click(function(evt) { 20 $('#wrapper').removeClass('off-canvas'); 21 $('#footer').removeClass('off-canvas'); 22 evt.target.remove(); 23 }); 24 }); 25 $(document).ready(function() { 26 // totop scroll 27 $(window).scroll(function() { 28 if ($(this).scrollTop() != 0) { 29 $('#gotop').fadeIn(); 30 } else { 31 $('#gotop').fadeOut(); 32 } 33 }); 34 $('#gotop').click(function(e) { 35 $('body,html').animate({ 36 scrollTop: 0 37 }, 800); 38 e.preventDefault(); 39 }); 40 }); 41 </script> 1 <script type="text/javascript" src="{{tpl:BlogThemeURL}}/js/berlin.js"></script> -
themes/ductile/_prepend.php
r3531 r3709 37 37 <script type="text/javascript"> 38 38 $(function() { 39 $( "#stickerslist").sortable({'cursor':'move'});40 $( "#stickerslist tr").hover(function () {39 $('#stickerslist').sortable({'cursor':'move'}); 40 $('#stickerslist tr').hover(function () { 41 41 $(this).css({'cursor':'move'}); 42 42 }, function () { … … 45 45 $('#theme_config').submit(function() { 46 46 var order=[]; 47 $( "#stickerslist tr td input.position").each(function() {47 $('#stickerslist tr td input.position').each(function() { 48 48 order.push(this.name.replace(/^order\[([^\]]+)\]$/,'$1')); 49 49 }); 50 $( "input[name=ds_order]")[0].value = order.join(',');50 $('input[name=ds_order]')[0].value = order.join(','); 51 51 return true; 52 52 }); 53 $( "#stickerslist tr td input.position").hide();54 $( "#stickerslist tr td.handle").addClass('handler');53 $('#stickerslist tr td input.position').hide(); 54 $('#stickerslist tr td.handle').addClass('handler'); 55 55 }); 56 56 </script>
Note: See TracChangeset
for help on using the changeset viewer.