Changeset 1056:b67f949a98f8
- Timestamp:
- 12/09/12 03:12:34 (13 years ago)
- Branch:
- twig
- Files:
-
- 179 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
admin/index.php
r931 r1056 13 13 if (!empty($_GET['pf'])) { 14 14 require dirname(__FILE__).'/../inc/load_plugin_file.php'; 15 exit; 16 } 17 if (!empty($_GET['tf'])) { 18 define('DC_CONTEXT_ADMIN',true); 19 require dirname(__FILE__).'/../inc/load_theme_file.php'; 15 20 exit; 16 21 } -
admin/post.php
r1053 r1056 16 16 17 17 function savePost($form) { 18 global $ core;19 $ core->page->getContext()->setMessage('save');18 global $_ctx; 19 $_ctx->setMessage('save'); 20 20 21 21 } … … 172 172 173 173 174 175 // TODO: Do it better later, required by some javascripts 176 $some_globals = array( 177 'rtl' => l10n::getTextDirection($_lang) == 'rtl', 178 'Nonce' => $core->getNonce(), 179 'sess_id' => session_id(), 180 'sess_uid' => $_SESSION['sess_browser_uid'], 181 'media_manage' => $core->auth->check('media,media_admin',$core->blog->id), 182 'enable_wysiwyg' => isset($core->auth) && $core->auth->getOption('enable_wysiwyg'), 183 'edit_size' => $core->auth->getOption('edit_size') 184 ); 185 foreach($some_globals as $name => $value) { 186 $_ctx->$name = $value; 187 }; 188 // 189 190 191 174 192 /* DISPLAY 175 193 -------------------------------------------------------- */ … … 181 199 $default_tab = 'comments'; 182 200 } 183 184 $core->page->getContext() 185 ->jsDatePicker() 186 ->jsToolBar() 187 ->jsModal() 188 ->jsMetaEditor() 189 ->jsLoad('js/_post.js') 190 ->jsPageTabs($default_tab) 191 ->jsConfirmClose('entry-form','comment-form'); 192 193 echo $core->page->render('post.html.twig',array( 194 'edit_size'=> $core->auth->getOption('edit_size'))); 195 196 201 $_ctx->default_tab = $default_tab; 202 $_ctx->setPageTitle($page_title); 203 204 $core->tpl->display('post.html.twig'); 197 205 ?> -
inc/admin/class.dc.admincontext.php
r1053 r1056 1 1 <?php 2 # -- BEGIN LICENSE BLOCK --------------------------------------- 3 # 4 # This file is part of Dotclear 2. 5 # 6 # Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear 7 # Licensed under the GPL version 2.0 license. 8 # See LICENSE file or 9 # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 10 # 11 # -- END LICENSE BLOCK ----------------------------------------- 12 if (!defined('DC_RC_PATH')) { return; } 2 13 3 class dcAdminContext extends Twig_Extension { 4 protected $loaded_js; 5 protected $js; 6 protected $js_var; 7 protected $head; 8 protected $globals; 9 14 /** 15 @ingroup DC_CORE 16 @brief Template extension for admin context 17 18 This extends template environment with tools required in admin context. 19 */ 20 class dcAdminContext extends Twig_Extension 21 { 10 22 protected $core; 11 public function __construct($core) { 23 protected $globals = array(); 24 protected $protected_globals = array(); 25 26 public function __construct($core) 27 { 12 28 $this->core = $core; 13 $this->js = array(); 14 $this->js_var = array(); 15 $this->loaded_js = array(); 16 $this->head = array(); 17 $this->jsCommon(); 18 $this->blogs = array(); 29 30 # Globals editable via context 19 31 $this->globals = array(); 32 33 # Globals not editable via context 34 $this->protected_globals = array( 35 'page_message' => '', 36 'page_errors' => array(), 37 'page_title' => '', 38 39 'admin_url' => DC_ADMIN_URL, 40 'theme_url' => DC_ADMIN_URL.'index.php?tf=', 41 42 'version' => DC_VERSION, 43 'vendor_name' => DC_VENDOR_NAME, 44 45 # Blogs list (not available yet) 46 'blogs' => array(), 47 48 # Current blog (not available yet and never available in auth.php) 49 'blog' => array( 50 'id' => '', 51 'host' => '', 52 'url' => '', 53 'name' => '' 54 ) 55 ); 56 } 57 58 /** 59 Prevent call crash from template on method that return this class 60 */ 61 public function __toString() 62 { 63 return ''; 64 } 65 66 /** 67 Test a global variable 68 69 @param string $name Name of the variable to test 70 @return boolean 71 */ 72 public function __isset($name) 73 { 74 return isset($this->globals[$name]); 75 } 76 77 /** 78 Add a global variable 79 80 @param string $name Name of the variable 81 @param mixed $value Value of the variable 82 */ 83 public function __set($name,$value) 84 { 85 /* 86 # Overload protect 87 if ($value === null && isset($this->globals[$name])) { 88 unset($this->globals[$name]); 89 } 90 elseif (!isset($this->globals[$name])) { 91 throw new Exception('Modification of overloaded globals has no effect'); 92 } 93 //*/ 94 $this->globals[$name] = $value; 95 } 96 97 /** 98 Get a global variable 99 100 @param string $name Name of the variable 101 @return mixed Value of the variable or null 102 */ 103 public function __get($name) 104 { 105 return isset($this->globals[$name]) ? $this->globals[$name] : null; 106 } 107 108 /** 109 Returns a list of filters to add to the existing list. 110 111 @return array An array of filters 112 */ 113 public function getFilters() 114 { 115 return array( 116 'trans' => new Twig_Filter_Function("__", array('is_safe' => array('html'))) 117 ); 118 } 119 120 /** 121 Returns a list of functions to add to the existing list. 122 123 @return array An array of functions 124 */ 125 public function getFunctions() 126 { 127 return array( 128 '__' => new Twig_Function_Function("__", array('is_safe' => array('html'))), 129 'page_menu' => new Twig_Function_Method($this, 'pageMenu', array('is_safe' => array('html'))) 130 ); 131 } 132 133 /** 134 Returns a list of global variables to add to the existing list. 135 136 This merges overloaded variables with defined variables. 137 138 @return array An array of global variables 139 */ 140 public function getGlobals() 141 { 142 # Blogs list 20 143 if ($this->core->auth->blog_count > 1 && $this->core->auth->blog_count < 20) { 21 144 $rs_blogs = $core->getBlogs(array('order'=>'LOWER(blog_name)','limit'=>20)); 22 145 while ($rs_blogs->fetch()) { 23 $this-> blogs[html::escapeHTML($rs_blogs->blog_name.' - '.$rs_blogs->blog_url)] = $rs_blogs->blog_id;146 $this->protected_globals['blogs'][html::escapeHTML($rs_blogs->blog_name.' - '.$rs_blogs->blog_url)] = $rs_blogs->blog_id; 24 147 } 25 148 } 26 $this->blog = array(); 27 if ($this->core->auth->blog_count) { // no blog on auth.php 28 $this->blog = array( 29 'url' => $core->blog->url, 30 'name' => $core->blog->name 149 # Current blog 150 if ($this->core->auth->blog_count) { 151 $this->protected_globals['blog'] = array( 152 'id' => $this->core->blog->id, 153 'host' => $this->core->blog->host, 154 'url' => $this->core->blog->url, 155 'name' => $this->core->blog->name 31 156 ); 32 157 } 33 } 34 35 public function jsLoad($src) 36 { 37 $escaped_src = html::escapeHTML($src); 38 if (!isset($this->loaded_js[$escaped_src])) { 39 $this->loaded_js[$escaped_src]=true; 40 $this->js[]='<script type="text/javascript" src="'.$escaped_src.'"></script>'; 41 } 158 # Keep protected globals safe 159 return array_merge($this->globals,$this->protected_globals); 160 } 161 162 /** 163 * Returns the name of the extension. 164 * 165 * @return string The extension name 166 */ 167 public function getName() 168 { 169 return 'AdminContext'; 170 } 171 172 /** 173 Set information message 174 175 @param string $message A message 176 @return object self 177 */ 178 public function setMessage($message) 179 { 180 $this->protected_globals['page_message'] = $message; 42 181 return $this; 43 182 } 44 183 45 public function jsAdd($code) 46 { 47 $this->js[]=$code; 184 /** 185 Add an error message 186 187 @param string Error message 188 @return object self 189 */ 190 public function addError($error) 191 { 192 $this->protected_globals['page_errors'][] = $error; 48 193 return $this; 49 194 } 50 51 public function head($code) { 52 $this->head[]=$code; 53 return $this; 54 } 55 public function jsVar($n,$v) 56 { 57 $this->js_vars[$n] = $v; 58 } 59 60 public function jsVars($arr) 61 { 62 foreach($arr as $n => $v) { 63 $this->js_vars[$n] = $v; 64 } 65 return $this; 66 } 67 68 public function getJS(){ 69 $jsvars = array(); 70 71 foreach ($this->js_vars as $n => $v) { 72 $jsvars[] = $n." = '".html::escapeJS($v)."';"; 73 } 74 return join("\n",$this->head). 75 join("\n",$this->js). 76 '<script type="text/javascript">'."\n". 77 "//<![CDATA[\n". 78 join("\n",$jsvars). 79 "\n//]]>\n". 80 "</script>\n";; 81 } 82 83 public function pageHead() { 84 global $core; 85 $this->jsLoadIE7(); 86 echo ' <link rel="stylesheet" href="style/default.css" type="text/css" media="screen" />'."\n"; 87 if (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl') { 88 echo 89 ' <link rel="stylesheet" href="style/default-rtl.css" type="text/css" media="screen" />'."\n"; 90 } 91 $core->auth->user_prefs->addWorkspace('interface'); 92 $user_ui_hide_std_favicon = $core->auth->user_prefs->interface->hide_std_favicon; 93 if (!$user_ui_hide_std_favicon) { 94 echo '<link rel="icon" type="image/png" href="images/favicon.png" />'; 95 } 96 echo $this->getJS(); 97 } 98 99 public function pageMenu() { 195 196 /** 197 Check if there is an error message 198 199 @return boolean 200 */ 201 public function hasError() 202 { 203 return !empty($this->protected_globals['page_errors']); 204 } 205 206 /** 207 Add page title 208 */ 209 public function setPageTitle($title) 210 { 211 $this->protected_globals['page_title'] = $title; 212 } 213 214 /** 215 pageMenu 216 */ 217 public function pageMenu() 218 { 100 219 $menu =& $GLOBALS['_menu']; 101 220 foreach ($menu as $k => $v) { … … 103 222 } 104 223 } 105 public function getFunctions()106 {107 return array(108 'page_head' => new Twig_Function_Method($this, 'pageHead', array('is_safe' => array('html'))),109 'page_menu' => new Twig_Function_Method($this, 'pageMenu', array('is_safe' => array('html'))),110 '__' => new Twig_Function_Function("__", array('is_safe' => array('html')))111 );112 }113 public function getGlobals() {114 return $this->globals;115 }116 public function getName() {117 return 'AdminPage';118 }119 120 public function setMessage($message) {121 $this->globals['page_message'] = $message;122 return $this;123 }124 125 public function addError($error) {126 if (!isset($this->globals['page_errors']))127 $this->globals['page_errors']=array();128 $this->globals['page_errors'][] = $error;129 return $this;130 }131 132 public function getFilters()133 {134 return array(135 'trans' => new Twig_Filter_Function("__", array('is_safe' => array('html')))136 );137 }138 139 140 public function jsCommon() {141 return $this->jsVars (array(142 'dotclear.nonce' => $GLOBALS['core']->getNonce(),143 'dotclear.img_plus_src' => 'images/plus.png',144 'dotclear.img_plus_alt' => __('uncover'),145 'dotclear.img_minus_src' => 'images/minus.png',146 'dotclear.img_minus_alt' => __('hide'),147 'dotclear.img_menu_on' => 'images/menu_on.png',148 'dotclear.img_menu_off' => 'images/menu_off.png',149 'dotclear.msg.help' => __('help'),150 'dotclear.msg.no_selection' => __('no selection'),151 'dotclear.msg.select_all' => __('select all'),152 'dotclear.msg.invert_sel' => __('invert selection'),153 'dotclear.msg.website' => __('Web site:'),154 'dotclear.msg.email' => __('Email:'),155 'dotclear.msg.ip_address' => __('IP address:'),156 'dotclear.msg.error' => __('Error:'),157 'dotclear.msg.entry_created'=> __('Entry has been successfully created.'),158 'dotclear.msg.edit_entry' => __('Edit entry'),159 'dotclear.msg.view_entry' => __('view entry'),160 'dotclear.msg.confirm_delete_posts' =>161 __("Are you sure you want to delete selected entries (%s)?"),162 'dotclear.msg.confirm_delete_post' =>163 __("Are you sure you want to delete this entry?"),164 'dotclear.msg.confirm_delete_comments' =>165 __('Are you sure you want to delete selected comments (%s)?'),166 'dotclear.msg.confirm_delete_comment' =>167 __('Are you sure you want to delete this comment?'),168 'dotclear.msg.cannot_delete_users' =>169 __('Users with posts cannot be deleted.'),170 'dotclear.msg.confirm_delete_user' =>171 __('Are you sure you want to delete selected users (%s)?'),172 'dotclear.msg.confirm_delete_category' =>173 __('Are you sure you want to delete category "%s"?'),174 'dotclear.msg.confirm_reorder_categories' =>175 __('Are you sure you want to reorder all categories?'),176 'dotclear.msg.confirm_delete_media' =>177 __('Are you sure you want to remove media "%s"?'),178 'dotclear.msg.confirm_extract_current' =>179 __('Are you sure you want to extract archive in current directory?'),180 'dotclear.msg.confirm_remove_attachment' =>181 __('Are you sure you want to remove attachment "%s"?'),182 'dotclear.msg.confirm_delete_lang' =>183 __('Are you sure you want to delete "%s" language?'),184 'dotclear.msg.confirm_delete_plugin' =>185 __('Are you sure you want to delete "%s" plugin?'),186 'dotclear.msg.use_this_theme' => __('Use this theme'),187 'dotclear.msg.remove_this_theme' => __('Remove this theme'),188 'dotclear.msg.confirm_delete_theme' =>189 __('Are you sure you want to delete "%s" theme?'),190 'dotclear.msg.zip_file_content' => __('Zip file content'),191 'dotclear.msg.xhtml_validator' => __('XHTML markup validator'),192 'dotclear.msg.xhtml_valid' => __('XHTML content is valid.'),193 'dotclear.msg.xhtml_not_valid' => __('There are XHTML markup errors.'),194 'dotclear.msg.confirm_change_post_format' =>195 __('You have unsaved changes. Switch post format will loose these changes. Proceed anyway?'),196 'dotclear.msg.load_enhanced_uploader' => __('Loading enhanced uploader =>please wait.')))197 ->jsLoad('js/jquery/jquery.js')198 ->jsLoad('js/jquery/jquery.biscuit.js')199 ->jsLoad('js/jquery/jquery.bgFade.js')200 ->jsLoad('js/jquery/jquery.constantfooter.js')201 ->jsLoad('js/common.js')202 ->jsLoad('js/prelude.js');203 }204 205 public function jsLoadIE7()206 {207 return $this->jsAdd(208 '<!--[if lt IE 8]>'."\n".209 '<script type="text/javascript" src="js/ie7/IE8.js"></script>'."\n".210 '<link rel="stylesheet" type="text/css" href="style/iesucks.css" />'."\n".211 '<![endif]-->');212 }213 214 public function jsConfirmClose()215 {216 $args = func_get_args();217 if (count($args) > 0) {218 foreach ($args as $k => $v) {219 $args[$k] = "'".html::escapeJS($v)."'";220 }221 $args = implode(',',$args);222 } else {223 $args = '';224 }225 226 $this->jsLoad('js/confirm-close.js');227 $this->jsAdd(228 '<script type="text/javascript">'."\n".229 "//<![CDATA[\n".230 "confirmClosePage = new confirmClose(".$args."); ".231 "confirmClose.prototype.prompt = '".html::escapeJS(__('You have unsaved changes.'))."'; ".232 "\n//]]>\n".233 "</script>\n");234 return $this;235 }236 237 public function jsPageTabs($default=null)238 {239 if ($default) {240 $default = "'".html::escapeJS($default)."'";241 }242 243 return $this244 ->jsLoad('js/jquery/jquery.pageTabs.js')245 ->jsAdd('<script type="text/javascript">'."\n".246 "//<![CDATA[\n".247 "\$(function() {\n".248 " \$.pageTabs(".$default.");\n".249 "});\n".250 "\n//]]>\n".251 "</script>\n");252 }253 254 public function jsModal()255 {256 return $this257 ->head(258 '<link rel="stylesheet" type="text/css" href="style/modal/modal.css" />')259 ->jsLoad('js/jquery/jquery.modal.js')260 ->jsVars(array(261 '$.modal.prototype.params.loader_img' =>'style/modal/loader.gif',262 '$.modal.prototype.params.close_img' =>'style/modal/close.png'263 ));264 }265 266 public static function jsColorPicker()267 {268 return269 '<link rel="stylesheet" type="text/css" href="style/farbtastic/farbtastic.css" />'."\n".270 self::jsLoad('js/jquery/jquery.farbtastic.js').271 self::jsLoad('js/color-picker.js');272 }273 274 public function jsDatePicker()275 {276 $this277 ->head(278 '<link rel="stylesheet" type="text/css" href="style/date-picker.css" />')279 ->jsLoad('js/date-picker.js')280 ->jsVars(array(281 "datePicker.prototype.months[0]" => __('January'),282 "datePicker.prototype.months[1]" => __('February'),283 "datePicker.prototype.months[2]" => __('March'),284 "datePicker.prototype.months[3]" => __('April'),285 "datePicker.prototype.months[4]" => __('May'),286 "datePicker.prototype.months[5]" => __('June'),287 "datePicker.prototype.months[6]" => __('July'),288 "datePicker.prototype.months[7]" => __('August'),289 "datePicker.prototype.months[8]" => __('September'),290 "datePicker.prototype.months[9]" => __('October'),291 "datePicker.prototype.months[10]" => __('November'),292 "datePicker.prototype.months[11]" => __('December'),293 "datePicker.prototype.days[0]" => __('Monday'),294 "datePicker.prototype.days[1]" => __('Tuesday'),295 "datePicker.prototype.days[2]" => __('Wednesday'),296 "datePicker.prototype.days[3]" => __('Thursday'),297 "datePicker.prototype.days[4]" => __('Friday'),298 "datePicker.prototype.days[5]" => __('Saturday'),299 "datePicker.prototype.days[6]" => __('Sunday'),300 301 "datePicker.prototype.img_src" => 'images/date-picker.png',302 303 "datePicker.prototype.close_msg" => __('close'),304 "datePicker.prototype.now_msg" => __('now')));305 return $this;306 }307 308 public function jsToolBar()309 {310 $this311 ->head(312 '<link rel="stylesheet" type="text/css" href="style/jsToolBar/jsToolBar.css" />')313 ->jsLoad("js/jsToolBar/jsToolBar.js");314 315 if (isset($GLOBALS['core']->auth) && $GLOBALS['core']->auth->getOption('enable_wysiwyg')) {316 $this->jsLoad("js/jsToolBar/jsToolBar.wysiwyg.js");317 }318 319 $this->jsLoad("js/jsToolBar/jsToolBar.dotclear.js")320 ->jsVars(array(321 322 "jsToolBar.prototype.dialog_url" => 'popup.php',323 "jsToolBar.prototype.iframe_css" =>324 'body{'.325 'font: 12px "DejaVu Sans","Lucida Grande","Lucida Sans Unicode",Arial,sans-serif;'.326 'color : #000;'.327 'background: #f9f9f9;'.328 'margin: 0;'.329 'padding : 2px;'.330 'border: none;'.331 (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl' ? 'direction:rtl;' : '').332 '}'.333 'pre, code, kbd, samp {'.334 'font-family:"Courier New",Courier,monospace;'.335 'font-size : 1.1em;'.336 '}'.337 'code {'.338 'color : #666;'.339 'font-weight : bold;'.340 '}'.341 'body > p:first-child {'.342 'margin-top: 0;'.343 '}',344 "jsToolBar.prototype.base_url" => $GLOBALS['core']->blog->host,345 "jsToolBar.prototype.switcher_visual_title" => __('visual'),346 "jsToolBar.prototype.switcher_source_title" => __('source'),347 "jsToolBar.prototype.legend_msg" =>348 __('You can use the following shortcuts to format your text.'),349 "jsToolBar.prototype.elements.blocks.options.none" => __('-- none --'),350 "jsToolBar.prototype.elements.blocks.options.nonebis" => __('-- block format --'),351 "jsToolBar.prototype.elements.blocks.options.p" => __('Paragraph'),352 "jsToolBar.prototype.elements.blocks.options.h1" => __('Level 1 header'),353 "jsToolBar.prototype.elements.blocks.options.h2" => __('Level 2 header'),354 "jsToolBar.prototype.elements.blocks.options.h3" => __('Level 3 header'),355 "jsToolBar.prototype.elements.blocks.options.h4" => __('Level 4 header'),356 "jsToolBar.prototype.elements.blocks.options.h5" => __('Level 5 header'),357 "jsToolBar.prototype.elements.blocks.options.h6" => __('Level 6 header'),358 "jsToolBar.prototype.elements.strong.title" => __('Strong emphasis'),359 "jsToolBar.prototype.elements.em.title" => __('Emphasis'),360 "jsToolBar.prototype.elements.ins.title" => __('Inserted'),361 "jsToolBar.prototype.elements.del.title" => __('Deleted'),362 "jsToolBar.prototype.elements.quote.title" => __('Inline quote'),363 "jsToolBar.prototype.elements.code.title" => __('Code'),364 "jsToolBar.prototype.elements.br.title" => __('Line break'),365 "jsToolBar.prototype.elements.blockquote.title" => __('Blockquote'),366 "jsToolBar.prototype.elements.pre.title" => __('Preformated text'),367 "jsToolBar.prototype.elements.ul.title" => __('Unordered list'),368 "jsToolBar.prototype.elements.ol.title" => __('Ordered list'),369 370 "jsToolBar.prototype.elements.link.title" => __('Link'),371 "jsToolBar.prototype.elements.link.href_prompt" => __('URL?'),372 "jsToolBar.prototype.elements.link.hreflang_prompt" => __('Language?'),373 374 "jsToolBar.prototype.elements.img.title" => __('External image'),375 "jsToolBar.prototype.elements.img.src_prompt" => __('URL?'),376 377 "jsToolBar.prototype.elements.img_select.title" => __('Media chooser'),378 "jsToolBar.prototype.elements.post_link.title" => __('Link to an entry')));379 380 if (!$GLOBALS['core']->auth->check('media,media_admin',$GLOBALS['core']->blog->id)) {381 $this->jsVar("jsToolBar.prototype.elements.img_select.disabled",true);382 }383 384 return $this;385 }386 387 public function jsCandyUpload($params=array(),$base_url=null)388 {389 if (!$base_url) {390 $base_url = path::clean(dirname(preg_replace('/(\?.*$)?/','',$_SERVER['REQUEST_URI']))).'/';391 }392 393 $params = array_merge($params,array(394 'sess_id='.session_id(),395 'sess_uid='.$_SESSION['sess_browser_uid'],396 'xd_check='.$GLOBALS['core']->getNonce()397 ));398 399 return400 '<link rel="stylesheet" type="text/css" href="style/candyUpload/style.css" />'."\n".401 self::jsLoad('js/jquery/jquery.candyUpload.js').402 403 '<script type="text/javascript">'."\n".404 "//<![CDATA[\n".405 "dotclear.candyUpload = {};\n".406 self::jsVar('dotclear.msg.activate_enhanced_uploader',__('Activate enhanced uploader')).407 self::jsVar('dotclear.msg.disable_enhanced_uploader',__('Disable enhanced uploader')).408 self::jsVar('$._candyUpload.prototype.locales.file_uploaded',__('File successfully uploaded.')).409 self::jsVar('$._candyUpload.prototype.locales.max_file_size',__('Maximum file size allowed:')).410 self::jsVar('$._candyUpload.prototype.locales.limit_exceeded',__('Limit exceeded.')).411 self::jsVar('$._candyUpload.prototype.locales.size_limit_exceeded',__('File size exceeds allowed limit.')).412 self::jsVar('$._candyUpload.prototype.locales.canceled',__('Canceled.')).413 self::jsVar('$._candyUpload.prototype.locales.http_error',__('HTTP Error:')).414 self::jsVar('$._candyUpload.prototype.locales.error',__('Error:')).415 self::jsVar('$._candyUpload.prototype.locales.choose_file',__('Choose file')).416 self::jsVar('$._candyUpload.prototype.locales.choose_files',__('Choose files')).417 self::jsVar('$._candyUpload.prototype.locales.cancel',__('Cancel')).418 self::jsVar('$._candyUpload.prototype.locales.clean',__('Clean')).419 self::jsVar('$._candyUpload.prototype.locales.upload',__('Upload')).420 self::jsVar('$._candyUpload.prototype.locales.no_file_in_queue',__('No file in queue.')).421 self::jsVar('$._candyUpload.prototype.locales.file_in_queue',__('1 file in queue.')).422 self::jsVar('$._candyUpload.prototype.locales.files_in_queue',__('%d files in queue.')).423 self::jsVar('$._candyUpload.prototype.locales.queue_error',__('Queue error:')).424 self::jsVar('dotclear.candyUpload.base_url',$base_url).425 self::jsVar('dotclear.candyUpload.movie_url',$base_url.'index.php?pf=swfupload.swf').426 self::jsVar('dotclear.candyUpload.params',implode('&',$params)).427 "\n//]]>\n".428 "</script>\n";429 }430 431 public static function jsToolMan()432 {433 return434 '<script type="text/javascript" src="js/tool-man/core.js"></script>'.435 '<script type="text/javascript" src="js/tool-man/events.js"></script>'.436 '<script type="text/javascript" src="js/tool-man/css.js"></script>'.437 '<script type="text/javascript" src="js/tool-man/coordinates.js"></script>'.438 '<script type="text/javascript" src="js/tool-man/drag.js"></script>'.439 '<script type="text/javascript" src="js/tool-man/dragsort.js"></script>'.440 '<script type="text/javascript" src="js/dragsort-tablerows.js"></script>';441 }442 443 public function jsMetaEditor()444 {445 return $this->jsLoad("js/meta-editor.js");446 }447 448 224 } 449 225 ?> -
inc/admin/class.dc.form.php
r1053 r1056 163 163 $this->action = $action; 164 164 $this->fields = array(); 165 $this->core-> page->getExtension('dc_form')->addForm($this);165 $this->core->tpl->getExtension('dc_form')->addForm($this); 166 166 $this->submitfields = array(); 167 167 $this->hiddenfields = array(); -
inc/admin/default-templates/layout.html.twig
r1053 r1056 1 {% import "js_helpers.html.twig" as js %} 1 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 2 3 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> … … 4 5 {% block header %} 5 6 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 6 <title>{% block title %}{ % endblock %}</title>7 <title>{% block title %}{{page_title}} - {% if blog.name is not empty %}{{blog.name}} - {% endif %}{{vendor_name}} - {{version}}{% endblock %}</title> 7 8 <meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" /> 8 9 <meta name="GOOGLEBOT" content="NOSNIPPET" /> 9 <link rel="stylesheet" href="style/default.css" type="text/css" media="screen" /> 10 {{ page_head() }} 10 <link rel="stylesheet" href="{{theme_url}}style/default.css" type="text/css" media="screen" /> 11 {% if rtl is not empty %} 12 <link rel="stylesheet" href="{{theme_url}}style/default-rtl.css" type="text/css" media="screen" /> 13 {% endif %} 14 {{ js.load_IE7 }} 15 {{ js.common }} 11 16 {% endblock %} 17 {% block more_header %}{% endblock %} 12 18 </head> 13 19 … … 19 25 <li><a href="#main-menu">{{__('To menu')}}</a></li> 20 26 </ul> 21 <div id="top"><h1><a href="index.php">{{ VENDOR_NAME}}</a></h1></div>27 <div id="top"><h1><a href="index.php">{{vendor_name}}</a></h1></div> 22 28 <div id="info-boxes"> 23 29 <div id="info-box1"> … … 39 45 <div id="content"> 40 46 {% block content %} 41 <h2> Mon premier blog › <span class="page-title"></span></h2>47 <h2>{{blog.name}} › <span class="page-title">{{page_title}}</span></h2> 42 48 {% if page_message is not empty %} 43 49 <p class="message">{{page_message}}</p> … … 62 68 <div id="footer"> 63 69 {% block footer %} 64 <p>{{ 'Thank you for using %s.'|trans}}</p>70 <p>{{ __('Thank you for using %s.')|format(vendor_name) }}</p> 65 71 {% endblock %} 66 72 </div> -
inc/admin/default-templates/post.html.twig
r1001 r1056 1 1 {% extends "layout.html.twig" %} 2 {% import "js_helpers.html.twig" as js %} 3 {% block more_header %} 4 {{ js.date_picker }} 5 {{ js.tool_bar }} 6 {{ js.modal }} 7 {{ js.meta_editor }} 8 <script type="text/javascript" src="{{theme_url}}js/_post.js"></script> 9 {{ js.confirm_close(['entry-form','comment-form']) }} 10 {{ js.page_tabs(default_tab) }} 11 {% endblock %} 2 12 3 13 {% block content %} -
inc/admin/prepend.php
r1013 r1056 376 376 } 377 377 378 # Creating template context 379 try { 380 $core->page = new dcTwigPage( 381 dirname(__FILE__).'/default-templates', 382 DC_TPL_CACHE.'/admtpl', 383 new dcAdminContext($core), 384 $core 385 ); 386 } catch (Exception $e) { 387 __error(__('Can\'t create template engine.') 388 ,$e->getMessage() 389 ,640); 390 } 378 # Add admin default templates path 379 $core->tpl->getLoader()->addPath(dirname(__FILE__).'/default-templates'); 380 # Set admin context 381 $_ctx = new dcAdminContext($core); 382 $core->tpl->addExtension($_ctx); 383 384 # --BEHAVIOR-- adminPrepend 385 $core->callBehavior('adminPrepend',$core,$_ctx); 391 386 ?> -
inc/core/class.dc.core.php
r706 r1056 39 39 public $rest; ///< <b>dcRestServer</b> dcRestServer object 40 40 public $log; ///< <b>dcLog</b> dcLog object 41 public $tpl; ///< <b>Twig_Environment</b> Twig_Environment object 41 42 42 43 private $versions = null; … … 95 96 $this->addFormater('xhtml', create_function('$s','return $s;')); 96 97 $this->addFormater('wiki', array($this,'wikiTransform')); 98 99 $this->loadTemplateEnvironment(); 97 100 } 98 101 … … 118 121 } 119 122 123 /** 124 Create template environment (Twig_Environment instance) 125 126 default-templates path must be added from admin|public/prepend.php with: 127 $core->tpl->getLoader()->addPath('PATH_TO/default-templates'); 128 Selected theme path must be added with: 129 $core->tpl->getLoader()->prependPath('PATH_TO/MY_THEME'); 130 */ 131 protected function loadTemplateEnvironment() 132 { 133 # If cache dir is writable, use it. 134 $cache_dir = dirname(DC_TPL_CACHE.'/twtpl'); 135 if (!is_dir($cache_dir)) { 136 try { 137 files::makeDir($cache_dir); 138 } catch (Exception $e) { 139 $cache_dir = false; 140 } 141 } 142 143 $this->tpl = new Twig_Environment( 144 new Twig_Loader_Filesystem(dirname(__FILE__).'/../swf'), 145 array( 146 'auto_reload' => true, 147 'autoescape' => 'html', 148 'base_template_class' => 'Twig_Template', 149 'cache' => $cache_dir, 150 'charset' => 'UTF-8', 151 'debug' => DC_DEBUG, 152 'optimizations' => -1, 153 'strict_variables' => 0 //DC_DEBUG // Please fix undefined variables! 154 ) 155 ); 156 $this->tpl->addExtension(new dcFormExtension($this)); 157 } 120 158 121 159 /// @name Blog init methods
Note: See TracChangeset
for help on using the changeset viewer.