Changeset 2654:5818627b7cc1 for inc
- Timestamp:
- 02/12/14 10:35:31 (12 years ago)
- Branch:
- twig
- Location:
- inc
- Files:
-
- 165 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
inc/admin/class.dc.admincontext.php
r2321 r2654 22 22 /** 23 23 * valuesToArray - converts a list of strings to an array having these strings as keys. 24 * 24 * 25 25 * @param mixed $val the list to convert. 26 26 * @access protected … … 63 63 } 64 64 } 65 65 66 66 public function __isset($name) { 67 67 if ($this->isAllowed($name,$this->attributes)) { … … 71 71 } 72 72 } 73 73 74 74 75 75 public function __call($name,$args) { … … 112 112 protected $protected_globals = array(); 113 113 protected $memory = array(); 114 114 115 115 public function __construct($core) 116 116 { 117 117 $this->core = $core; 118 118 119 119 # Globals editable via context 120 120 $this->globals = array(); 121 121 122 122 # Globals not editable via context 123 123 $this->protected_globals = array( … … 128 128 'errors' => array() 129 129 ), 130 130 131 131 'page_title' => array(), 132 132 'page_global' => false, 133 133 134 134 'admin_url' => DC_ADMIN_URL, 135 135 'theme_url' => '', 136 136 'plugin_url' => DC_ADMIN_URL.'index.php?pf=', 137 137 138 138 'version' => DC_VERSION, 139 139 'vendor_name' => DC_VENDOR_NAME, 140 140 141 141 'safe_mode' => isset($_SESSION['sess_safe_mode']) && $_SESSION['sess_safe_mode'], 142 142 'debug_mode' => DC_DEBUG 143 143 ); 144 144 } 145 145 146 146 /** 147 147 Prevent call crash from template on method that return this class … … 151 151 return ''; 152 152 } 153 153 154 154 /** 155 155 Test a global variable 156 156 157 157 @param string $name Name of the variable to test 158 158 @return boolean … … 162 162 return isset($this->globals[$name]); 163 163 } 164 164 165 165 /** 166 166 Add a global variable 167 167 168 168 @param string $name Name of the variable 169 169 @param mixed $value Value of the variable … … 182 182 $this->globals[$name] = $value; 183 183 } 184 184 185 185 /** 186 186 Get a global variable 187 187 188 188 @param string $name Name of the variable 189 189 @return mixed Value of the variable or null … … 193 193 return isset($this->globals[$name]) ? $this->globals[$name] : null; 194 194 } 195 195 196 196 /** 197 197 Returns a list of filters to add to the existing list. 198 198 199 199 @return array An array of filters 200 200 */ … … 205 205 ); 206 206 } 207 207 208 208 /** 209 209 Returns a list of functions to add to the existing list. 210 210 211 211 @return array An array of functions 212 212 */ … … 221 221 ); 222 222 } 223 223 224 224 225 225 /** 226 226 * Builds an url given a base, and parameters 227 * 227 * 228 228 * @param mixed $url the base url as string 229 229 * @param mixed $params the parameters. … … 252 252 /** 253 253 Returns a list of global variables to add to the existing list. 254 254 255 255 This merges overloaded variables with defined variables. 256 256 257 257 @return array An array of global variables 258 258 */ 259 259 public function getGlobals() 260 260 { 261 $this->getBlogs(); 262 $this->getCurrentBlog(); 263 $this->getCurrentUser(); 264 $this->getMenus(); 265 266 # Additional globals 267 $p = path::info($_SERVER['REQUEST_URI']); 268 $this->protected_globals['current_page'] = $p['base']; 269 $this->protected_globals['blog_count'] = $this->core->auth->getBlogCount(); 270 $this->protected_globals['rtl'] = l10n::getTextDirection( 271 $this->protected_globals['current_user']['lang']) == 'rtl'; 261 if ($this->core->auth->userID()) { 262 $this->getBlogs(); 263 $this->getCurrentBlog(); 264 $this->getCurrentUser(); 265 $this->getMenus(); 266 267 # Additional globals 268 $p = path::info($_SERVER['REQUEST_URI']); 269 $this->protected_globals['current_page'] = $p['base']; 270 $this->protected_globals['blog_count'] = $this->core->auth->getBlogCount(); 271 $this->protected_globals['rtl'] = l10n::getTextDirection( 272 $this->protected_globals['current_user']['lang']) == 'rtl'; 273 } 272 274 $this->protected_globals['session'] = array( 273 275 'id' => session_id(), … … 278 280 return array_merge($this->globals,$this->protected_globals); 279 281 } 280 282 281 283 /** 282 284 Returns the name of the extension. 283 285 284 286 @return string The extension name 285 287 */ … … 288 290 return 'AdminContext'; 289 291 } 290 291 292 293 292 294 /** 293 295 Add an informational message 294 296 295 297 @param string $message A message 296 298 @return object self … … 301 303 return $this; 302 304 } 303 305 304 306 /** 305 307 Add an informational message 306 308 307 309 @param string $message A message 308 310 @return object self … … 313 315 return $this; 314 316 } 315 317 316 318 /** 317 319 Add a list of informational messages 318 320 319 321 @param string $message A title 320 322 @param array $message A list of messages … … 326 328 return $this; 327 329 } 328 330 329 331 /** 330 332 Set an important message 331 333 332 334 @param string $message A message 333 335 @return object self … … 338 340 return $this; 339 341 } 340 342 341 343 /** 342 344 Add an error message 343 345 344 346 @param string Error message 345 347 @return object self … … 350 352 return $this; 351 353 } 352 354 353 355 /** 354 356 Check if there is an error message 355 357 356 358 @return boolean 357 359 */ … … 360 362 return !empty($this->protected_globals['messages']['errors']); 361 363 } 362 364 363 365 /** 364 366 Add a section to the breadcrumb 365 366 $title can be: 367 a string for page title part or 367 368 $title can be: 369 a string for page title part or 368 370 TRUE to add blog name at the begining of title or 369 371 NULL to empty/reset title 370 372 371 373 @param mixed $title A title part 372 374 @param boolean $url Link of the title part … … 381 383 ); 382 384 } 383 385 384 386 /** 385 387 Fill the page title 386 387 $title can be: 388 a string for page title part or 388 389 $title can be: 390 a string for page title part or 389 391 TRUE to add blog name at the begining of title or 390 392 NULL to empty/reset title 391 393 392 394 @param mixed $title A title part 393 395 @param boolean $url Link of the title part … … 411 413 return $this; 412 414 } 413 415 414 416 /** 415 417 Check if a page title is set … … 419 421 return !empty($this->protected_globals['page_title']); 420 422 } 421 423 422 424 /** 423 425 Get list of blogs … … 426 428 { 427 429 $blog_id = ''; 428 430 429 431 # Blogs list 430 432 $blogs = array(); … … 435 437 while ($rs_blogs->fetch()) { 436 438 $blogs[$rs_blogs->blog_id] = $rs_blogs->blog_name.' - '.$rs_blogs->blog_url; 437 $this->protected_globals['blogs'][$rs_blogs->blog_id] = 439 $this->protected_globals['blogs'][$rs_blogs->blog_id] = 438 440 new dcArrayProxy($rs_blogs, array( 439 441 'blog_id','blog_name','blog_desc','blog_url','blog_creadt','blog_upddt')); 440 442 } 441 443 } 442 444 443 445 # Switch blog form 444 446 $form = new dcForm($this->core,'switchblog_menu','index.php'); … … 463 465 ->setup(); 464 466 } 465 467 466 468 /** 467 469 Get current blog information … … 482 484 ); 483 485 } 484 486 485 487 /** 486 488 Get current user information … … 493 495 'post_status','creadt','upddt','cn' 494 496 ); 495 497 496 498 $user = array( 497 499 'id' => '', … … 504 506 ) 505 507 ); 506 508 507 509 foreach($infos as $i) { 508 510 $user[$i] = ''; 509 511 } 510 512 511 513 if ($this->core->auth->userID()) { 512 514 513 515 $user = array( 514 516 'id' => $this->core->auth->userID(), … … 519 521 ) 520 522 ); 521 523 522 524 foreach($infos as $i) { 523 525 $user[$i] = $this->core->auth->getInfo('user_'.$i); 524 526 } 525 527 526 528 foreach($this->core->auth->user_prefs->dumpWorkspaces() as $ws => $prefs) { 527 529 $user['prefs'][$ws] = $prefs->dumpPrefs(); 528 530 } 529 531 } 530 532 531 533 $this->protected_globals['current_user'] = $user; 532 534 } 533 535 534 536 /** 535 537 Get sidebar menus … … 538 540 { 539 541 global $_menu; 540 542 541 543 $this->protected_globals['menus'] = array(); 542 544 543 545 if (!isset($_menu)) { 544 546 return; 545 547 } 546 548 547 549 foreach($_menu as $m) { 548 550 $this->protected_globals['menus'][] = array( … … 554 556 } 555 557 } 556 558 557 559 /** 558 560 Get an array of debug/dev infos … … 563 565 return array(); 564 566 } 565 567 566 568 $di = array( 567 569 'global_vars' => implode(', ',array_keys($GLOBALS)), … … 572 574 'xdebug' => array() 573 575 ); 574 576 575 577 if (function_exists('xdebug_get_profiler_filename')) { 576 578 577 579 $url = http::getSelfURI(); 578 580 $url .= strpos($url,'?') === false ? '?' : '&'; 579 581 $url .= 'XDEBUG_PROFILE'; 580 582 581 583 $di['xdebug'] = array( 582 584 'elapse_time' => xdebug_time_index(), … … 584 586 'profiler_url' => $url 585 587 ); 586 588 587 589 /* xdebug configuration: 588 590 zend_extension = /.../xdebug.so … … 598 600 */ 599 601 } 600 602 601 603 return $di; 602 604 } 603 605 604 606 /** 605 607 Add a value in a namespace memory 606 608 607 609 This help keep variable when recalling Twig macros 608 610 609 611 @param string $ns A namespace 610 612 @param string $str A value to memorize in this namespace … … 616 618 } 617 619 } 618 620 619 621 /** 620 622 Check if a value is previously memorized in a namespace 621 623 622 624 @param string $ns A namespace 623 625 @param string $str A value to search in this namespace -
inc/admin/default-templates/post.html.twig
r1517 r2654 55 55 {{ block(bl) }} 56 56 {% endfor %} 57 <p>{{ form_field('save')}} 57 <p>{{ form_field('save')}} 58 58 {% if preview_url is defined %} 59 59 <a id="post-preview" href="{{ preview_url}}" class="button" accesskey="p">{{__('Preview')}} (p)</a> 60 60 {% endif %} 61 61 62 62 {{form_field('delete',{'class':'delete'})}}{{form_hidden()}}</p> 63 63 … … 105 105 {% endblock %} 106 106 107 { % block field_post_status %}107 {#{% block field_post_status %} 108 108 <p>{{ form_field('post_status',{},{'labelclass':'ib'}) }}</p> 109 109 {% endblock %} 110 110 #} 111 111 {# Field-specific blocks #} 112 112 … … 128 128 129 129 {% block post_status -%} 130 <p ><label class="ib">{{form_field_attr('post_status','label')}} {{ _self.img_status(form_field_attr('post_status','value'))}}</label>{{ form_field('post_status',{},{'label':'','labelclass':'ib'})}}</p>130 <p class="entry-status"><label for="post_status">{{form_field_attr('post_status','label')}} {{ _self.img_status(form_field_attr('post_status','value'))}}</label>{{ form_field('post_status',{},{'label':'','labelclass':'ib'})}}</p> 131 131 {%- endblock %} 132 132 … … 136 136 137 137 {% block post_lang -%} 138 <p>{{ form_field('post_lang',{"class":"maximal"},{' nestedlabel':true, 'labelclass':'ib'})}}</p>138 <p>{{ form_field('post_lang',{"class":"maximal"},{'labelclass':'ib'})}}</p> 139 139 {%- endblock %} 140 140 141 141 {% block post_format -%} 142 <p>{{ form_field('post_format',{},{'labelclass':'ib'})}}</p> 143 {% if post_id and form_field_attr('post_format','value')=='xhtml' %} 144 <p><a id="convert-xhtml" class="button maximal" href="post.php?id={{post_id}}&xconv=1"> 145 {{__('Convert to XHTML')}}</a></p> 146 {% endif %} 142 <div> 143 <h5 id="label_format" class="classic">{{form_field_attr('post_format','label')}}</h5> 144 <p>{{ form_field('post_format',{},{'label':''})}}</p> 145 {% if post_id and form_field_attr('post_format','value')=='xhtml' %} 146 <p><a id="format_control control_no_xhtml" class="button maximal" href="post.php?id={{post_id}}&xconv=1"> 147 {{__('Convert to XHTML')}}</a></p> 148 {% endif %} 149 </div> 147 150 {%- endblock %} 148 151 … … 152 155 153 156 {% block cat_id -%} 154 <p>{{ form_field('cat_id',{'class':'maximal'},{'labelclass':'ib'}) }}</p> 155 {#{% if can_edit_categories %}#} 157 {#'<div>'. 158 '<h5 id="label_cat_id">'.__('Category').'</h5>'. 159 '<p><label for="cat_id">'.__('Category:').'</label>'. 160 form::combo('cat_id',$categories_combo,$cat_id,'maximal'). 161 '</p>'. 162 ($core->auth->check('categories', $core->blog->id) ? 163 '<div>'. 164 '<h5 id="create_cat">'.__('Add a new category').'</h5>'. 165 '<p><label for="new_cat_title">'.__('Title:').' '. 166 form::field('new_cat_title',30,255,'','maximal').'</label></p>'. 167 '<p><label for="new_cat_parent">'.__('Parent:').' '. 168 form::combo('new_cat_parent',$categories_combo,'','maximal'). 169 '</label></p>'. 170 '</div>' 171 : ''). 172 '</div>')), 173 #} 156 174 <div> 157 <p id="new_cat">{{__('Add a new category')}}</p> 158 <p>{{ form_field('new_cat_title') }}</p> 159 <p>{{ form_field('new_cat_parent') }} </p> 160 </div> 161 {#{% endif %}#} 175 <h5 id="label_cat_id">{{form_field_attr('cat_id','label')}}</h5> 176 <p>{{ form_field('cat_id',{},{'label':''})}}</p> 177 {% if 1==1 %} 178 <div> 179 <h5 id="create_cat">{{__('Add a new category')}}</h5> 180 <p>{{ form_field('new_cat_title',{"class":"maximal"}) }}</p> 181 <p>{{ form_field('new_cat_parent') }} </p> 182 </div> 183 {% endif %} 184 </div> 162 185 {%- endblock %} 163 186 -
inc/prepend.php
r2650 r2654 18 18 if (@is_dir('/usr/lib/clearbricks')) { 19 19 define('CLEARBRICKS_PATH','/usr/lib/clearbricks'); 20 } elseif (is_dir(dirname(__FILE__).'/ libs/clearbricks')) {21 define('CLEARBRICKS_PATH',dirname(__FILE__).'/ libs/clearbricks');20 } elseif (is_dir(dirname(__FILE__).'/../vendor/dotclear/clearbricks')) { 21 define('CLEARBRICKS_PATH',dirname(__FILE__).'/../vendor/dotclear/clearbricks'); 22 22 } elseif (isset($_SERVER['CLEARBRICKS_PATH']) && is_dir($_SERVER['CLEARBRICKS_PATH'])) { 23 23 define('CLEARBRICKS_PATH',$_SERVER['CLEARBRICKS_PATH']); … … 96 96 if (@is_dir('/usr/lib/twig')) { 97 97 define('TWIG_PATH','/usr/lib/Twig'); 98 } elseif (is_dir(dirname(__FILE__).'/ libs/Twig')) {99 define('TWIG_PATH',dirname(__FILE__).'/ libs/Twig');98 } elseif (is_dir(dirname(__FILE__).'/../vendor/twig/twig/lib/Twig')) { 99 define('TWIG_PATH',dirname(__FILE__).'/../vendor/twig/twig/lib/Twig'); 100 100 } elseif (isset($_SERVER['TWIG_PATH']) && is_dir($_SERVER['TWIG_PATH'])) { 101 101 define('TWIG_PATH',$_SERVER['TWIG_PATH']); … … 311 311 # 60 : template processing error 312 312 # 70 : blog is offline 313 313 314 314 if (CLI_MODE) 315 315 {
Note: See TracChangeset
for help on using the changeset viewer.