Changeset 1147:2e5cb79e4782 for inc/admin
- Timestamp:
- 03/08/13 15:37:34 (13 years ago)
- Branch:
- twig
- Location:
- inc/admin
- Files:
-
- 3 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
inc/admin/class.dc.admincontext.php
r1091 r1147 45 45 46 46 'admin_url' => DC_ADMIN_URL, 47 'theme_url' => DC_ADMIN_URL.'index.php?tf=',47 'theme_url' => '', 48 48 'plugin_url' => DC_ADMIN_URL.'index.php?pf=', 49 49 -
inc/admin/class.dc.form.php
r1090 r1147 13 13 14 14 /** 15 * Template form node 16 */ 15 * dcFormNode 16 * 17 * @uses Twig_Node 18 * 19 */ 17 20 class dcFormNode extends Twig_Node 18 21 { … … 30 33 { 31 34 $compiler 32 ->addDebugInfo($this) 33 ->write("\$context['dc_form']->beginForm('". 34 $this->getAttribute('name')."');\n") 35 ->addDebugInfo($this); 36 $compiler 37 ->write("\$context['dc_form']->beginForm(") 38 ->subcompile($this->getAttribute('name')) 39 ->write(");\n"); 40 $compiler 35 41 ->subcompile($this->getNode('body')) 36 42 ->write("\$context['dc_form']->renderHiddenWidgets();\n") … … 49 55 $lineno = $token->getLine(); 50 56 $stream = $this->parser->getStream(); 51 $name = $ stream->expect(Twig_Token::NAME_TYPE)->getValue();57 $name = $this->parser->getExpressionParser()->parseExpression(); 52 58 $stream->expect(Twig_Token::BLOCK_END_TYPE); 53 59 $body = $this->parser->subparse(array($this,'decideBlockEnd'),true); … … 77 83 protected $core; 78 84 protected $twig; 79 protected $blocks;80 85 protected $forms; 81 86 protected $currentForm; 87 protected $blocks; 82 88 83 89 public function __construct($core) … … 96 102 } 97 103 104 public function addTemplate($tpl) { 105 $t = $this->twig->loadTemplate($tpl); 106 $this->blocks = array_merge($this->blocks,$t->getBlocks()); 107 } 108 98 109 public function getGlobals() 99 110 { … … 137 148 } 138 149 139 public function renderWidget($name,$attributes=array()) 150 public function renderBlock($name,$attr) { 151 echo $this->template->renderBlock( 152 $name, 153 $attr, 154 $this->blocks 155 ); 156 } 157 158 public function getCurrentForm() { 159 return $this->currentForm; 160 } 161 162 public function renderWidget($name,$attributes=array(),$extra=array()) 140 163 { 141 164 $field = $this->currentForm->$name; 142 165 if ($field) { 143 echo $this->template->renderBlock( 166 $attr = $field->getAttributes(); 167 if (isset($attr['attr'])) { 168 $attr['attr'] = array_merge($attr['attr'],$attributes); 169 } else { 170 $attr['attr'] = $attributes; 171 } 172 $this->renderBlock( 144 173 $field->getWidgetBlock(), 145 174 array_merge( 146 $field->getAttributes(), 147 array('attr' => $attributes) 148 ), 149 $this->blocks 175 $attr, 176 $extra 177 ) 150 178 ); 151 179 } … … 197 225 198 226 /** 199 * Template form 200 */ 227 * dcForm - Template form 228 * 229 */ 201 230 class dcForm 202 231 { … … 211 240 protected $errors; 212 241 213 private function addNonce() 242 243 /** 244 * addNonce -- adds dc nonce to form fields 245 * 246 * @access protected 247 * 248 * @return nothing 249 */ 250 protected function addNonce() 214 251 { 215 252 $this->addField( … … 219 256 } 220 257 221 protected function getNID($nid) 258 259 /** 260 * Defines Name & ID from field 261 * 262 * @param mixed $nid either an array (name, id) or a string (name only, id will be set to null). 263 * 264 * @access protected 265 * 266 * @return nothing. 267 */ 268 protected function setNID($nid) 222 269 { 223 270 if (is_array($nid)) { … … 231 278 } 232 279 280 public function getContext() { 281 return array(); 282 } 283 284 /** 285 * Class constructor 286 * 287 * @param mixed $core dotclear core 288 * @param mixed $name form name 289 * @param mixed $action form action 290 * @param string $method form method ('GET' or 'POST') 291 * 292 * @access public 293 * 294 * @return mixed Value. 295 */ 233 296 public function __construct($core,$name,$action,$method='POST') 234 297 { 235 298 $this->core = $core; 236 $this-> getNID($name);299 $this->setNID($name); 237 300 $this->method = $method; 238 301 $this->action = $action; … … 247 310 } 248 311 312 313 /** 314 * Returns form name 315 * 316 * @access public 317 * 318 * @return mixed Value. 319 */ 249 320 public function getName() 250 321 { … … 270 341 } 271 342 343 public function removeField(dcField $f) { 344 $n = $f->getName(); 345 if (isset($this->fields[$n])){ 346 unset($this->fields[$n]); 347 } 348 349 } 350 public function renameField($field,$newname) { 351 $oldname = $field->getName(); 352 if (isset($this->fields[$oldname])) { 353 unset($this->fields[$oldname]); 354 $field->setName($newname); 355 $this->fields[$newname] = $field; 356 } 357 //print_r($this->fields); 358 } 272 359 public function begin() 273 360 { … … 292 379 public function __get($name) 293 380 { 294 return isset($this->fields[$name]) ? 381 return isset($this->fields[$name]) ? 295 382 $this->fields[$name] : null; 296 383 } 297 384 298 385 public function __set($name,$value) 299 386 { … … 302 389 } 303 390 } 304 391 305 392 public function isSubmitted() 306 393 { 307 394 $from = $this->method == 'POST' ? $_POST : $_GET; 308 echo "form fields :\n"; 309 } 310 311 public function setup() 312 { 395 } 396 397 protected function setupFields() { 313 398 $from = $this->method == 'POST' ? $_POST : $_GET; 314 399 foreach ($this->fields as $f) { 315 400 $f->setup($from); 316 401 } 402 } 403 404 protected function handleActions($submitted) { 405 foreach ($submitted as $f) { 406 $action = $f->getAction(); 407 if ($action != NULL) { 408 $ret = call_user_func($action,$this); 409 } 410 } 411 } 412 413 protected function getSubmittedFields() { 414 $s = array(); 317 415 foreach ($this->submitfields as $f) { 318 416 if ($f->isDefined()) { 319 $ret = call_user_func($f->getAction(),$this); 320 return; 417 $s[$f->getName()] = $f; 321 418 } 322 419 } 323 } 324 420 return $s; 421 } 422 423 public function setup() 424 { 425 $this->setupFields(); 426 $submitted = $this->getSubmittedFields(); 427 $this->handleActions($submitted); 428 } 429 325 430 public function check() 326 431 { … … 352 457 protected $defined; 353 458 354 protected function getNID($nid)459 protected function setNID($nid) 355 460 { 356 461 if (is_array($nid)) { … … 365 470 public function __construct($name,$value,$attributes=array()) 366 471 { 367 $this-> getNID($name);472 $this->setNID($name); 368 473 $this->attributes = $attributes; 369 $this-> value = $value;474 $this->setValue($value); 370 475 $this->attributes['name'] = $this->name; 371 476 $this->attributes['id'] = $this->id; 477 $this->defined = false; 478 } 479 480 public function setValue($value) { 481 $this->value = $value; 372 482 $this->attributes['value'] = $this->value; 373 $this->defined = false; 374 } 375 483 } 484 485 public function getValue() { 486 return $this->value; 487 } 488 376 489 public function __toString() 377 490 { … … 395 508 return $this->name; 396 509 } 397 510 public function setName($name) { 511 $this->setNID($name); 512 $this->attributes['name'] = $this->name; 513 $this->attributes['id'] = $this->id; 514 } 515 398 516 public function check() 399 517 { … … 406 524 } 407 525 526 public function parseValue($from) { 527 if (isset($from[$this->id])) { 528 return $from[$this->id]; 529 } 530 return null; 531 } 532 408 533 public function setup($from) 409 534 { 410 if (isset($from[$this->id])) { 411 $this->value = $from[$this->id]; 535 $value = $this->parseValue($from); 536 if ($value !== null) { 537 $this->setValue($value); 412 538 $this->defined = true; 413 539 } … … 488 614 if (isset($attributes['action'])) { 489 615 $this->action = $attributes['action']; 616 } else { 617 $this->action = NULL; 490 618 } 491 619 } … … 527 655 } 528 656 657 public function parseValue($from) { 658 659 $v = parent::parseValue($from); 660 if (!isset($this->options[$v])) { 661 return $this->value; 662 } else { 663 return $v; 664 } 665 } 529 666 } 530 667 ?> -
inc/admin/default-templates/auth.html.twig
r1089 r1147 18 18 <body id="dotclear-admin" class="auth"> 19 19 20 {% form auth%}20 {% form 'auth' %} 21 21 <div id="login-screen"> 22 22 <h1>{{vendor_name}}</h1> -
inc/admin/default-templates/form_layout.html.twig
r1001 r1147 18 18 {% block field_textarea %} 19 19 {% spaceless %} 20 {{ block(' label') }}20 {{ block('startlabel') }} 21 21 <textarea {{ block('field_attr') }}>{{ value }}</textarea> 22 {{ block('endlabel') }} 22 23 {% endspaceless %} 23 24 {% endblock field_textarea %} … … 38 39 {% spaceless %} 39 40 {% set type = type|default('text') %} 40 {{ block(' label') }}41 {{ block('startlabel') }} 41 42 <input type="{{ type }}" {{ block('field_attr') }} {% if value is not empty %}value="{{ value }}" {% endif %} /> 43 {{ block('endlabel') }} 42 44 {% endspaceless %} 43 45 {% endblock field_input %} … … 80 82 {% block field_combo %} 81 83 {% spaceless %} 82 {{ block(' label') }}84 {{ block('startlabel') }} 83 85 <select {{ block('field_attr') }}> 84 86 {{ block('field_options') }} 85 87 </select> 88 {{ block('endlabel') }} 86 89 {% endspaceless %} 87 90 {% endblock field_combo %} 88 91 {# 89 92 {% block label %} 90 93 {% spaceless %} … … 94 97 {% endspaceless %} 95 98 {% endblock label %} 99 #} 100 101 {% block startlabel %} 102 {% spaceless %} 103 {% if label is not empty %} 104 {% if required is not empty %} 105 {% set labelclass = labelclass + " required" %} 106 {% endif %} 107 <label for="{{name}}" {% if labelclass is not empty %}class="{{labelclass}}"{% endif %} {% if required is not empty %}<abbr title="{{__('Required field')}}">*</abbr>{% else %}>{% endif %} {{label}} 108 {% if nestedlabel is empty %}</label> {% endif %} 109 {% endif %} 110 {% endspaceless %} 111 {% endblock startlabel %} 112 113 {% block endlabel %} 114 {% spaceless %} 115 {% if label is not empty %} 116 {% if nestedlabel is not empty %}</label>{% endif %} 117 {% endif %} 118 {% endspaceless %} 119 {% endblock endlabel %} 120 -
inc/admin/default-templates/index.html.twig
r1099 r1147 28 28 <div id="quick"> 29 29 <h3>{{__('Quick entry')}}</h3> 30 {% form quickentry%}30 {% form 'quickentry' %} 31 31 <fieldset><legend>{{__('New entry')}}</legend> 32 32 <p class="col">{{ form_field('post_title',{'class':'maximal'}) }}</p> -
inc/admin/default-templates/layout.html.twig
r1089 r1147 19 19 <body id="dotclear-admin{% if safe_mode %} safe-mode{% endif %}"> 20 20 <div id="header"> 21 <ul id="prelude"> 22 <li><a href="#content">{{__('To content')}}</a></li> 23 <li><a href="#main-menu">{{__('To menu')}}</a></li> 24 </ul> 21 {% block prelude %} 22 <ul id="prelude"> 23 <li><a href="#content">{{__('To content')}}</a></li> 24 <li><a href="#main-menu">{{__('To menu')}}</a></li> 25 </ul> 26 {% endblock %} 25 27 <div id="top"><h1><a href="index.php">{{vendor_name}}</a></h1></div> 26 28 <div id="info-boxes"> 27 29 <div id="info-box1"> 28 {% form switchblog_menu%}30 {% form 'switchblog_menu' %} 29 31 {% if blog_count > 1 and blog_count < 20 %} 30 <p>{{ form_field('switchblog') }}</p>31 <noscript> <p>{{ form_field('switchblog_submit') }}</p></noscript>32 {{ form_field('switchblog',{},{'nestedlabel' : true, labelclass:'classic'}) }} 33 <noscript>{{ form_field('switchblog_submit') }}</noscript> 32 34 {% else %} 33 <p>{{__('Blog:')}} <strong title="{{current_blog.url}}">{{current_blog.name}}</strong>34 {% if blogs is not empty %} - <a href="blogs.php">{{__('Change blog')}}</a>{% endif %} </p>35 {{__('Blog:')}} <strong title="{{current_blog.url}}">{{current_blog.name}}</strong> 36 {% if blogs is not empty %} - <a href="blogs.php">{{__('Change blog')}}</a>{% endif %} 35 37 {% endif %} 36 < p><a href="{{current_blog.url}}" onclick="window.open(this.href);return false;" title="{{__('Go to site')}} ({{__('new window')}})">{{__('Go to site')}} <img src="{{theme_url}}images/outgoing.png" alt="" /></a></p>38 <a href="{{current_blog.url}}" onclick="window.open(this.href);return false;" title="{{__('Go to site')}} ({{__('new window')}})">{{__('Go to site')}} <img src="{{theme_url}}images/outgoing.png" alt="" /></a> 37 39 {% endform %} 38 40 </div> -
inc/admin/default-templates/post.html.twig
r1088 r1147 16 16 17 17 <div class="multi-part" title="{{__('Edit entry')}}" id="edit-entry"> 18 {% form post%}18 {% form 'post' %} 19 19 <div id="entry-wrapper"> 20 20 <div id="entry-content"> -
inc/admin/default-templates/style/default.css
r1085 r1147 1356 1356 background-color: #2373A8; 1357 1357 } 1358 1358 form#filters {font-size: 100%; background: #f0f0f0; padding: 1em; border-radius: .5em; border: 1px solid #ddd;} 1359 form#filters .margintop {padding-top: 1.33em;} 1360 form#filters ul, form#filters p {list-style-type:none;margin: 0; padding: 0 0 .5em 0; margin-left: 1em;} 1361 form#filters .col30 {border-left: 1px solid #999;} 1362 form#filters .col30 h3 {margin-left: 1em;} 1363 1364 p.line, li.line { position: relative; padding: 3px 0 0 28px; margin: 0 0 1em 0;} 1365 li.line input[type=submit] {position: absolute; left:0;top:0; padding: 0 .1em; margin: 0;} 1366 li.line input[type=checkbox], li.line input[type=checkbox] {position: absolute; left: 0; top: .2em; padding: 0 .1em; margin: 0;} 1367 li.line select { margin-right: 2em;} 1368 li.line label { display: block; width: 8em; float: left;} 1369 li.line label img {margin-right: 8px;} 1370 li.line span.or { 1371 text-align: right; 1372 margin-left: 5em; 1373 font-weight: bold; 1374 } 1375 p.line label.or + select {margin-left: 2em;} 1376 li.line { padding: 0 0 0 20px; height: 1em;} 1377 li.line label {width: auto;} 1378 1379 #available_filters input[type=submit] {padding: 0 .1em; margin-left: .5em;} 1380 1381 div.pagination span, div.pagination a { 1382 margin-right: 1em; 1383 } 1359 1384 /* jQuery Autocomplete plugin */ 1360 1385 .ac_results {
Note: See TracChangeset
for help on using the changeset viewer.