[992] | 1 | <?php |
---|
| 2 | |
---|
| 3 | |
---|
| 4 | class dcAdminContext extends Twig_Extension { |
---|
| 5 | protected $loaded_js; |
---|
| 6 | protected $js; |
---|
| 7 | protected $js_var; |
---|
| 8 | protected $head; |
---|
| 9 | |
---|
| 10 | protected $core; |
---|
| 11 | public function __construct($core) { |
---|
| 12 | $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(); |
---|
| 19 | if ($this->core->auth->blog_count > 1 && $this->core->auth->blog_count < 20) { |
---|
| 20 | $rs_blogs = $core->getBlogs(array('order'=>'LOWER(blog_name)','limit'=>20)); |
---|
| 21 | while ($rs_blogs->fetch()) { |
---|
| 22 | $this->blogs[html::escapeHTML($rs_blogs->blog_name.' - '.$rs_blogs->blog_url)] = $rs_blogs->blog_id; |
---|
| 23 | } |
---|
| 24 | } |
---|
| 25 | $this->blog = array( |
---|
| 26 | 'url' => $core->blog->url, |
---|
| 27 | 'name' => $core->blog->name |
---|
| 28 | ); |
---|
| 29 | } |
---|
| 30 | |
---|
| 31 | public function jsLoad($src) |
---|
| 32 | { |
---|
| 33 | $escaped_src = html::escapeHTML($src); |
---|
| 34 | if (!isset($this->loaded_js[$escaped_src])) { |
---|
| 35 | $this->loaded_js[$escaped_src]=true; |
---|
| 36 | $this->js[]='<script type="text/javascript" src="'.$escaped_src.'"></script>'; |
---|
| 37 | } |
---|
| 38 | return $this; |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | public function jsAdd($code) |
---|
| 42 | { |
---|
| 43 | $this->js[]=$code; |
---|
| 44 | return $this; |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | public function head($code) { |
---|
| 48 | $this->head[]=$code; |
---|
| 49 | return $this; |
---|
| 50 | } |
---|
| 51 | public function jsVar($n,$v) |
---|
| 52 | { |
---|
| 53 | $this->js_vars[$n] = $v; |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | public function jsVars($arr) |
---|
| 57 | { |
---|
| 58 | foreach($arr as $n => $v) { |
---|
| 59 | $this->js_vars[$n] = $v; |
---|
| 60 | } |
---|
| 61 | return $this; |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | public function getJS(){ |
---|
| 65 | $jsvars = array(); |
---|
| 66 | |
---|
| 67 | foreach ($this->js_vars as $n => $v) { |
---|
| 68 | $jsvars[] = $n." = '".html::escapeJS($v)."';"; |
---|
| 69 | } |
---|
| 70 | return join("\n",$this->head). |
---|
| 71 | join("\n",$this->js). |
---|
| 72 | '<script type="text/javascript">'."\n". |
---|
| 73 | "//<![CDATA[\n". |
---|
| 74 | join("\n",$jsvars). |
---|
| 75 | "\n//]]>\n". |
---|
| 76 | "</script>\n";; |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | public function pageHead() { |
---|
| 80 | global $core; |
---|
| 81 | $this->jsLoadIE7(); |
---|
| 82 | echo ' <link rel="stylesheet" href="style/default.css" type="text/css" media="screen" />'."\n"; |
---|
| 83 | if (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl') { |
---|
| 84 | echo |
---|
| 85 | ' <link rel="stylesheet" href="style/default-rtl.css" type="text/css" media="screen" />'."\n"; |
---|
| 86 | } |
---|
| 87 | $core->auth->user_prefs->addWorkspace('interface'); |
---|
| 88 | $user_ui_hide_std_favicon = $core->auth->user_prefs->interface->hide_std_favicon; |
---|
| 89 | if (!$user_ui_hide_std_favicon) { |
---|
| 90 | echo '<link rel="icon" type="image/png" href="images/favicon.png" />'; |
---|
| 91 | } |
---|
| 92 | echo $this->getJS(); |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | public function pageMenu() { |
---|
| 96 | $menu =& $GLOBALS['_menu']; |
---|
| 97 | foreach ($menu as $k => $v) { |
---|
| 98 | echo $menu[$k]->draw(); |
---|
| 99 | } |
---|
| 100 | } |
---|
| 101 | public function getFunctions() |
---|
| 102 | { |
---|
| 103 | return array( |
---|
| 104 | 'page_head' => new Twig_Function_Method($this, 'pageHead', array('is_safe' => array('html'))), |
---|
| 105 | 'page_menu' => new Twig_Function_Method($this, 'pageMenu', array('is_safe' => array('html'))), |
---|
| 106 | '__' => new Twig_Function_Function("__", array('is_safe' => array('html'))) |
---|
| 107 | ); |
---|
| 108 | } |
---|
| 109 | public function getGlobals() { |
---|
| 110 | return array(); |
---|
| 111 | } |
---|
| 112 | public function getName() { |
---|
| 113 | return 'AdminPage'; |
---|
| 114 | } |
---|
| 115 | public function getFilters() |
---|
| 116 | { |
---|
| 117 | return array( |
---|
| 118 | 'trans' => new Twig_Filter_Function("__", array('is_safe' => array('html'))) |
---|
| 119 | ); |
---|
| 120 | } |
---|
| 121 | |
---|
| 122 | |
---|
| 123 | public function jsCommon() { |
---|
| 124 | return $this->jsVars (array( |
---|
| 125 | 'dotclear.nonce' => $GLOBALS['core']->getNonce(), |
---|
| 126 | 'dotclear.img_plus_src' => 'images/plus.png', |
---|
| 127 | 'dotclear.img_plus_alt' => __('uncover'), |
---|
| 128 | 'dotclear.img_minus_src' => 'images/minus.png', |
---|
| 129 | 'dotclear.img_minus_alt' => __('hide'), |
---|
| 130 | 'dotclear.img_menu_on' => 'images/menu_on.png', |
---|
| 131 | 'dotclear.img_menu_off' => 'images/menu_off.png', |
---|
| 132 | 'dotclear.msg.help' => __('help'), |
---|
| 133 | 'dotclear.msg.no_selection' => __('no selection'), |
---|
| 134 | 'dotclear.msg.select_all' => __('select all'), |
---|
| 135 | 'dotclear.msg.invert_sel' => __('invert selection'), |
---|
| 136 | 'dotclear.msg.website' => __('Web site:'), |
---|
| 137 | 'dotclear.msg.email' => __('Email:'), |
---|
| 138 | 'dotclear.msg.ip_address' => __('IP address:'), |
---|
| 139 | 'dotclear.msg.error' => __('Error:'), |
---|
| 140 | 'dotclear.msg.entry_created'=> __('Entry has been successfully created.'), |
---|
| 141 | 'dotclear.msg.edit_entry' => __('Edit entry'), |
---|
| 142 | 'dotclear.msg.view_entry' => __('view entry'), |
---|
| 143 | 'dotclear.msg.confirm_delete_posts' => |
---|
| 144 | __("Are you sure you want to delete selected entries (%s)?"), |
---|
| 145 | 'dotclear.msg.confirm_delete_post' => |
---|
| 146 | __("Are you sure you want to delete this entry?"), |
---|
| 147 | 'dotclear.msg.confirm_delete_comments' => |
---|
| 148 | __('Are you sure you want to delete selected comments (%s)?'), |
---|
| 149 | 'dotclear.msg.confirm_delete_comment' => |
---|
| 150 | __('Are you sure you want to delete this comment?'), |
---|
| 151 | 'dotclear.msg.cannot_delete_users' => |
---|
| 152 | __('Users with posts cannot be deleted.'), |
---|
| 153 | 'dotclear.msg.confirm_delete_user' => |
---|
| 154 | __('Are you sure you want to delete selected users (%s)?'), |
---|
| 155 | 'dotclear.msg.confirm_delete_category' => |
---|
| 156 | __('Are you sure you want to delete category "%s"?'), |
---|
| 157 | 'dotclear.msg.confirm_reorder_categories' => |
---|
| 158 | __('Are you sure you want to reorder all categories?'), |
---|
| 159 | 'dotclear.msg.confirm_delete_media' => |
---|
| 160 | __('Are you sure you want to remove media "%s"?'), |
---|
| 161 | 'dotclear.msg.confirm_extract_current' => |
---|
| 162 | __('Are you sure you want to extract archive in current directory?'), |
---|
| 163 | 'dotclear.msg.confirm_remove_attachment' => |
---|
| 164 | __('Are you sure you want to remove attachment "%s"?'), |
---|
| 165 | 'dotclear.msg.confirm_delete_lang' => |
---|
| 166 | __('Are you sure you want to delete "%s" language?'), |
---|
| 167 | 'dotclear.msg.confirm_delete_plugin' => |
---|
| 168 | __('Are you sure you want to delete "%s" plugin?'), |
---|
| 169 | 'dotclear.msg.use_this_theme' => __('Use this theme'), |
---|
| 170 | 'dotclear.msg.remove_this_theme' => __('Remove this theme'), |
---|
| 171 | 'dotclear.msg.confirm_delete_theme' => |
---|
| 172 | __('Are you sure you want to delete "%s" theme?'), |
---|
| 173 | 'dotclear.msg.zip_file_content' => __('Zip file content'), |
---|
| 174 | 'dotclear.msg.xhtml_validator' => __('XHTML markup validator'), |
---|
| 175 | 'dotclear.msg.xhtml_valid' => __('XHTML content is valid.'), |
---|
| 176 | 'dotclear.msg.xhtml_not_valid' => __('There are XHTML markup errors.'), |
---|
| 177 | 'dotclear.msg.confirm_change_post_format' => |
---|
| 178 | __('You have unsaved changes. Switch post format will loose these changes. Proceed anyway?'), |
---|
| 179 | 'dotclear.msg.load_enhanced_uploader' => __('Loading enhanced uploader =>please wait.'))) |
---|
| 180 | ->jsLoad('js/jquery/jquery.js') |
---|
| 181 | ->jsLoad('js/jquery/jquery.biscuit.js') |
---|
| 182 | ->jsLoad('js/jquery/jquery.bgFade.js') |
---|
[1001] | 183 | ->jsLoad('js/jquery/jquery.constantfooter.js') |
---|
[992] | 184 | ->jsLoad('js/common.js') |
---|
| 185 | ->jsLoad('js/prelude.js'); |
---|
| 186 | } |
---|
| 187 | |
---|
| 188 | public function jsLoadIE7() |
---|
| 189 | { |
---|
| 190 | return $this->jsAdd( |
---|
| 191 | '<!--[if lt IE 8]>'."\n". |
---|
| 192 | '<script type="text/javascript" src="js/ie7/IE8.js"></script>'."\n". |
---|
| 193 | '<link rel="stylesheet" type="text/css" href="style/iesucks.css" />'."\n". |
---|
| 194 | '<![endif]-->'); |
---|
| 195 | } |
---|
| 196 | |
---|
| 197 | public function jsConfirmClose() |
---|
| 198 | { |
---|
| 199 | $args = func_get_args(); |
---|
| 200 | if (count($args) > 0) { |
---|
| 201 | foreach ($args as $k => $v) { |
---|
| 202 | $args[$k] = "'".html::escapeJS($v)."'"; |
---|
| 203 | } |
---|
| 204 | $args = implode(',',$args); |
---|
| 205 | } else { |
---|
| 206 | $args = ''; |
---|
| 207 | } |
---|
| 208 | |
---|
| 209 | $this->jsLoad('js/confirm-close.js'); |
---|
| 210 | $this->jsAdd( |
---|
| 211 | '<script type="text/javascript">'."\n". |
---|
| 212 | "//<![CDATA[\n". |
---|
| 213 | "confirmClosePage = new confirmClose(".$args."); ". |
---|
| 214 | "confirmClose.prototype.prompt = '".html::escapeJS(__('You have unsaved changes.'))."'; ". |
---|
| 215 | "\n//]]>\n". |
---|
| 216 | "</script>\n"); |
---|
| 217 | return $this; |
---|
| 218 | } |
---|
| 219 | |
---|
| 220 | public function jsPageTabs($default=null) |
---|
| 221 | { |
---|
| 222 | if ($default) { |
---|
| 223 | $default = "'".html::escapeJS($default)."'"; |
---|
| 224 | } |
---|
| 225 | |
---|
| 226 | return $this |
---|
| 227 | ->jsLoad('js/jquery/jquery.pageTabs.js') |
---|
| 228 | ->jsAdd('<script type="text/javascript">'."\n". |
---|
| 229 | "//<![CDATA[\n". |
---|
| 230 | "\$(function() {\n". |
---|
| 231 | " \$.pageTabs(".$default.");\n". |
---|
| 232 | "});\n". |
---|
| 233 | "\n//]]>\n". |
---|
| 234 | "</script>\n"); |
---|
| 235 | } |
---|
| 236 | |
---|
| 237 | public function jsModal() |
---|
| 238 | { |
---|
| 239 | return $this |
---|
| 240 | ->head( |
---|
| 241 | '<link rel="stylesheet" type="text/css" href="style/modal/modal.css" />') |
---|
| 242 | ->jsLoad('js/jquery/jquery.modal.js') |
---|
| 243 | ->jsVars(array( |
---|
| 244 | '$.modal.prototype.params.loader_img' =>'style/modal/loader.gif', |
---|
| 245 | '$.modal.prototype.params.close_img' =>'style/modal/close.png' |
---|
| 246 | )); |
---|
| 247 | } |
---|
| 248 | |
---|
| 249 | public static function jsColorPicker() |
---|
| 250 | { |
---|
| 251 | return |
---|
| 252 | '<link rel="stylesheet" type="text/css" href="style/farbtastic/farbtastic.css" />'."\n". |
---|
| 253 | self::jsLoad('js/jquery/jquery.farbtastic.js'). |
---|
| 254 | self::jsLoad('js/color-picker.js'); |
---|
| 255 | } |
---|
| 256 | |
---|
| 257 | public function jsDatePicker() |
---|
| 258 | { |
---|
| 259 | $this |
---|
| 260 | ->head( |
---|
| 261 | '<link rel="stylesheet" type="text/css" href="style/date-picker.css" />') |
---|
| 262 | ->jsLoad('js/date-picker.js') |
---|
| 263 | ->jsVars(array( |
---|
| 264 | "datePicker.prototype.months[0]" => __('January'), |
---|
| 265 | "datePicker.prototype.months[1]" => __('February'), |
---|
| 266 | "datePicker.prototype.months[2]" => __('March'), |
---|
| 267 | "datePicker.prototype.months[3]" => __('April'), |
---|
| 268 | "datePicker.prototype.months[4]" => __('May'), |
---|
| 269 | "datePicker.prototype.months[5]" => __('June'), |
---|
| 270 | "datePicker.prototype.months[6]" => __('July'), |
---|
| 271 | "datePicker.prototype.months[7]" => __('August'), |
---|
| 272 | "datePicker.prototype.months[8]" => __('September'), |
---|
| 273 | "datePicker.prototype.months[9]" => __('October'), |
---|
| 274 | "datePicker.prototype.months[10]" => __('November'), |
---|
| 275 | "datePicker.prototype.months[11]" => __('December'), |
---|
| 276 | "datePicker.prototype.days[0]" => __('Monday'), |
---|
| 277 | "datePicker.prototype.days[1]" => __('Tuesday'), |
---|
| 278 | "datePicker.prototype.days[2]" => __('Wednesday'), |
---|
| 279 | "datePicker.prototype.days[3]" => __('Thursday'), |
---|
| 280 | "datePicker.prototype.days[4]" => __('Friday'), |
---|
| 281 | "datePicker.prototype.days[5]" => __('Saturday'), |
---|
| 282 | "datePicker.prototype.days[6]" => __('Sunday'), |
---|
| 283 | |
---|
| 284 | "datePicker.prototype.img_src" => 'images/date-picker.png', |
---|
| 285 | |
---|
| 286 | "datePicker.prototype.close_msg" => __('close'), |
---|
| 287 | "datePicker.prototype.now_msg" => __('now'))); |
---|
| 288 | return $this; |
---|
| 289 | } |
---|
| 290 | |
---|
| 291 | public function jsToolBar() |
---|
| 292 | { |
---|
| 293 | $this |
---|
| 294 | ->head( |
---|
| 295 | '<link rel="stylesheet" type="text/css" href="style/jsToolBar/jsToolBar.css" />') |
---|
| 296 | ->jsLoad("js/jsToolBar/jsToolBar.js"); |
---|
| 297 | |
---|
| 298 | if (isset($GLOBALS['core']->auth) && $GLOBALS['core']->auth->getOption('enable_wysiwyg')) { |
---|
| 299 | $this->jsLoad("js/jsToolBar/jsToolBar.wysiwyg.js"); |
---|
| 300 | } |
---|
| 301 | |
---|
| 302 | $this->jsLoad("js/jsToolBar/jsToolBar.dotclear.js") |
---|
| 303 | ->jsVars(array( |
---|
| 304 | |
---|
| 305 | "jsToolBar.prototype.dialog_url" => 'popup.php', |
---|
| 306 | "jsToolBar.prototype.iframe_css" => |
---|
| 307 | 'body{'. |
---|
| 308 | 'font: 12px "DejaVu Sans","Lucida Grande","Lucida Sans Unicode",Arial,sans-serif;'. |
---|
| 309 | 'color : #000;'. |
---|
| 310 | 'background: #f9f9f9;'. |
---|
| 311 | 'margin: 0;'. |
---|
| 312 | 'padding : 2px;'. |
---|
| 313 | 'border: none;'. |
---|
| 314 | (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl' ? 'direction:rtl;' : ''). |
---|
| 315 | '}'. |
---|
| 316 | 'pre, code, kbd, samp {'. |
---|
| 317 | 'font-family:"Courier New",Courier,monospace;'. |
---|
| 318 | 'font-size : 1.1em;'. |
---|
| 319 | '}'. |
---|
| 320 | 'code {'. |
---|
| 321 | 'color : #666;'. |
---|
| 322 | 'font-weight : bold;'. |
---|
| 323 | '}'. |
---|
| 324 | 'body > p:first-child {'. |
---|
| 325 | 'margin-top: 0;'. |
---|
| 326 | '}', |
---|
| 327 | "jsToolBar.prototype.base_url" => $GLOBALS['core']->blog->host, |
---|
| 328 | "jsToolBar.prototype.switcher_visual_title" => __('visual'), |
---|
| 329 | "jsToolBar.prototype.switcher_source_title" => __('source'), |
---|
| 330 | "jsToolBar.prototype.legend_msg" => |
---|
| 331 | __('You can use the following shortcuts to format your text.'), |
---|
| 332 | "jsToolBar.prototype.elements.blocks.options.none" => __('-- none --'), |
---|
| 333 | "jsToolBar.prototype.elements.blocks.options.nonebis" => __('-- block format --'), |
---|
| 334 | "jsToolBar.prototype.elements.blocks.options.p" => __('Paragraph'), |
---|
| 335 | "jsToolBar.prototype.elements.blocks.options.h1" => __('Level 1 header'), |
---|
| 336 | "jsToolBar.prototype.elements.blocks.options.h2" => __('Level 2 header'), |
---|
| 337 | "jsToolBar.prototype.elements.blocks.options.h3" => __('Level 3 header'), |
---|
| 338 | "jsToolBar.prototype.elements.blocks.options.h4" => __('Level 4 header'), |
---|
| 339 | "jsToolBar.prototype.elements.blocks.options.h5" => __('Level 5 header'), |
---|
| 340 | "jsToolBar.prototype.elements.blocks.options.h6" => __('Level 6 header'), |
---|
| 341 | "jsToolBar.prototype.elements.strong.title" => __('Strong emphasis'), |
---|
| 342 | "jsToolBar.prototype.elements.em.title" => __('Emphasis'), |
---|
| 343 | "jsToolBar.prototype.elements.ins.title" => __('Inserted'), |
---|
| 344 | "jsToolBar.prototype.elements.del.title" => __('Deleted'), |
---|
| 345 | "jsToolBar.prototype.elements.quote.title" => __('Inline quote'), |
---|
| 346 | "jsToolBar.prototype.elements.code.title" => __('Code'), |
---|
| 347 | "jsToolBar.prototype.elements.br.title" => __('Line break'), |
---|
| 348 | "jsToolBar.prototype.elements.blockquote.title" => __('Blockquote'), |
---|
| 349 | "jsToolBar.prototype.elements.pre.title" => __('Preformated text'), |
---|
| 350 | "jsToolBar.prototype.elements.ul.title" => __('Unordered list'), |
---|
| 351 | "jsToolBar.prototype.elements.ol.title" => __('Ordered list'), |
---|
| 352 | |
---|
| 353 | "jsToolBar.prototype.elements.link.title" => __('Link'), |
---|
| 354 | "jsToolBar.prototype.elements.link.href_prompt" => __('URL?'), |
---|
| 355 | "jsToolBar.prototype.elements.link.hreflang_prompt" => __('Language?'), |
---|
| 356 | |
---|
| 357 | "jsToolBar.prototype.elements.img.title" => __('External image'), |
---|
| 358 | "jsToolBar.prototype.elements.img.src_prompt" => __('URL?'), |
---|
| 359 | |
---|
| 360 | "jsToolBar.prototype.elements.img_select.title" => __('Media chooser'), |
---|
| 361 | "jsToolBar.prototype.elements.post_link.title" => __('Link to an entry'))); |
---|
| 362 | |
---|
| 363 | if (!$GLOBALS['core']->auth->check('media,media_admin',$GLOBALS['core']->blog->id)) { |
---|
| 364 | $this->jsVar("jsToolBar.prototype.elements.img_select.disabled",true); |
---|
| 365 | } |
---|
| 366 | |
---|
| 367 | return $this; |
---|
| 368 | } |
---|
| 369 | |
---|
| 370 | public function jsCandyUpload($params=array(),$base_url=null) |
---|
| 371 | { |
---|
| 372 | if (!$base_url) { |
---|
| 373 | $base_url = path::clean(dirname(preg_replace('/(\?.*$)?/','',$_SERVER['REQUEST_URI']))).'/'; |
---|
| 374 | } |
---|
| 375 | |
---|
| 376 | $params = array_merge($params,array( |
---|
| 377 | 'sess_id='.session_id(), |
---|
| 378 | 'sess_uid='.$_SESSION['sess_browser_uid'], |
---|
| 379 | 'xd_check='.$GLOBALS['core']->getNonce() |
---|
| 380 | )); |
---|
| 381 | |
---|
| 382 | return |
---|
| 383 | '<link rel="stylesheet" type="text/css" href="style/candyUpload/style.css" />'."\n". |
---|
| 384 | self::jsLoad('js/jquery/jquery.candyUpload.js'). |
---|
| 385 | |
---|
| 386 | '<script type="text/javascript">'."\n". |
---|
| 387 | "//<![CDATA[\n". |
---|
| 388 | "dotclear.candyUpload = {};\n". |
---|
| 389 | self::jsVar('dotclear.msg.activate_enhanced_uploader',__('Activate enhanced uploader')). |
---|
| 390 | self::jsVar('dotclear.msg.disable_enhanced_uploader',__('Disable enhanced uploader')). |
---|
| 391 | self::jsVar('$._candyUpload.prototype.locales.file_uploaded',__('File successfully uploaded.')). |
---|
| 392 | self::jsVar('$._candyUpload.prototype.locales.max_file_size',__('Maximum file size allowed:')). |
---|
| 393 | self::jsVar('$._candyUpload.prototype.locales.limit_exceeded',__('Limit exceeded.')). |
---|
| 394 | self::jsVar('$._candyUpload.prototype.locales.size_limit_exceeded',__('File size exceeds allowed limit.')). |
---|
| 395 | self::jsVar('$._candyUpload.prototype.locales.canceled',__('Canceled.')). |
---|
| 396 | self::jsVar('$._candyUpload.prototype.locales.http_error',__('HTTP Error:')). |
---|
| 397 | self::jsVar('$._candyUpload.prototype.locales.error',__('Error:')). |
---|
| 398 | self::jsVar('$._candyUpload.prototype.locales.choose_file',__('Choose file')). |
---|
| 399 | self::jsVar('$._candyUpload.prototype.locales.choose_files',__('Choose files')). |
---|
| 400 | self::jsVar('$._candyUpload.prototype.locales.cancel',__('Cancel')). |
---|
| 401 | self::jsVar('$._candyUpload.prototype.locales.clean',__('Clean')). |
---|
| 402 | self::jsVar('$._candyUpload.prototype.locales.upload',__('Upload')). |
---|
| 403 | self::jsVar('$._candyUpload.prototype.locales.no_file_in_queue',__('No file in queue.')). |
---|
| 404 | self::jsVar('$._candyUpload.prototype.locales.file_in_queue',__('1 file in queue.')). |
---|
| 405 | self::jsVar('$._candyUpload.prototype.locales.files_in_queue',__('%d files in queue.')). |
---|
| 406 | self::jsVar('$._candyUpload.prototype.locales.queue_error',__('Queue error:')). |
---|
| 407 | self::jsVar('dotclear.candyUpload.base_url',$base_url). |
---|
| 408 | self::jsVar('dotclear.candyUpload.movie_url',$base_url.'index.php?pf=swfupload.swf'). |
---|
| 409 | self::jsVar('dotclear.candyUpload.params',implode('&',$params)). |
---|
| 410 | "\n//]]>\n". |
---|
| 411 | "</script>\n"; |
---|
| 412 | } |
---|
| 413 | |
---|
| 414 | public static function jsToolMan() |
---|
| 415 | { |
---|
| 416 | return |
---|
| 417 | '<script type="text/javascript" src="js/tool-man/core.js"></script>'. |
---|
| 418 | '<script type="text/javascript" src="js/tool-man/events.js"></script>'. |
---|
| 419 | '<script type="text/javascript" src="js/tool-man/css.js"></script>'. |
---|
| 420 | '<script type="text/javascript" src="js/tool-man/coordinates.js"></script>'. |
---|
| 421 | '<script type="text/javascript" src="js/tool-man/drag.js"></script>'. |
---|
| 422 | '<script type="text/javascript" src="js/tool-man/dragsort.js"></script>'. |
---|
| 423 | '<script type="text/javascript" src="js/dragsort-tablerows.js"></script>'; |
---|
| 424 | } |
---|
| 425 | |
---|
| 426 | public function jsMetaEditor() |
---|
| 427 | { |
---|
| 428 | return $this->jsLoad("js/meta-editor.js"); |
---|
| 429 | } |
---|
| 430 | |
---|
| 431 | } |
---|
| 432 | |
---|
| 433 | class dcAdminPage { |
---|
| 434 | protected $loader; |
---|
| 435 | protected $twig; |
---|
| 436 | protected $context; |
---|
| 437 | protected $core; |
---|
| 438 | |
---|
| 439 | public function __construct($core) { |
---|
| 440 | $this->core = $core; |
---|
| 441 | $this->loader = new Twig_Loader_Filesystem(dirname(__FILE__).'/default-templates'); |
---|
| 442 | files::makeDir(dirname(DC_TPL_CACHE.'/admtpl'),true); |
---|
| 443 | $core->twig = new Twig_Environment ( |
---|
| 444 | $this->loader, |
---|
| 445 | array( |
---|
| 446 | 'cache' => DC_TPL_CACHE.'/admtpl', |
---|
| 447 | //'debug' => true, |
---|
| 448 | 'auto_reload' => true |
---|
| 449 | )); |
---|
| 450 | //$core->twig->addExtension(new Twig_Extensions_Extension_Debug()); |
---|
| 451 | $core->twig->addExtension(new Twig_Extension_Optimizer(0)); |
---|
| 452 | $core->twig->addExtension(new dcFormExtension($GLOBALS['core'])); |
---|
| 453 | $this->context = new dcAdminContext($GLOBALS['core']); |
---|
| 454 | $core->twig->addExtension($this->context); |
---|
| 455 | $core->twig->clearCacheFiles(); |
---|
| 456 | } |
---|
| 457 | |
---|
| 458 | public function getContext() { |
---|
| 459 | return $this->context; |
---|
| 460 | } |
---|
| 461 | |
---|
| 462 | public function getTwig() { |
---|
| 463 | return $this->twig; |
---|
| 464 | } |
---|
| 465 | public function render($name,array $context = array()) { |
---|
| 466 | $tpl = $this->core->twig->loadTemplate($name); |
---|
| 467 | |
---|
| 468 | return $tpl->render($context); |
---|
| 469 | |
---|
| 470 | } |
---|
| 471 | } |
---|
| 472 | |
---|
| 473 | |
---|
| 474 | ?> |
---|