Changeset 6667
- Timestamp:
- 12/21/07 09:55:49 (6 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfExtjs2Plugin/trunk/config/config.php
r6653 r6667 1 1 <?php 2 sfConfig::set('sf_extjs2_version', 'v0.5 4');2 sfConfig::set('sf_extjs2_version', 'v0.56'); 3 3 sfConfig::set('sf_extjs2_comment', true); 4 4 # plugins/sfExtjs2Plugin/trunk/lib/helper/sfExtjs2Helper.php
r6653 r6667 6 6 * @author Benjamin Runnels<benjamin.r.runnels [at] citi [dot] com>, Leon van der Ree, Wolfgang Kubens<wolfgang.kubens [at] gmx [dot] net> 7 7 * @version 0.0.54 8 * @last modified 12.19.2007 Wolfgang 8 * @last modified 12.20.2007 Wolfgang 9 * - Added method asListener 10 * - Renamed method customClass into asCustomClass 11 * - Renamed method anonymousClass into asAnonymousClass 12 * 12.19.2007 Wolfgang 9 13 * - Added method asVar 10 14 * - Added logic for anonymousClass … … 111 115 * 112 116 * Usage: 113 * 117 * 114 118 * Syntax A = short form without any options 115 119 * $sfExtjs2Plugin->Object(array … … 123 127 * ) 124 128 * )); 125 * 129 * 126 130 * => new Object({id: 'id', renderTo: document.body, items: [new Object(title: 'Object A'), new Object(title: 'Object B')]}) 127 131 * … … 299 303 /** 300 304 * writes closing tag for javascript 301 * 305 * * 306 * @param string source 302 307 * @return Javascript source 303 308 */ 304 public function end( )305 { 306 $source = s fExtjs2Plugin::LBR;309 public function end($source = '') 310 { 311 $source = sprintf("%s%s%s", sfExtjs2Plugin::LBR, $source, $source != '' ? sfExtjs2Plugin::LBR : ''); 307 312 $source .= sprintf("</script>%s", sfExtjs2Plugin::LBR); 308 313 … … 371 376 foreach ($attributes['private'] as $key => $value) 372 377 { 373 $sourcePrivate .= sprintf( '%svar %s = %s;', sfExtjs2Plugin::LBR, $key, sfExtjs2Plugin::_quote($key, $value));378 $sourcePrivate .= sprintf("%svar %s = %s;", sfExtjs2Plugin::LBR, $key, sfExtjs2Plugin::_quote($key, $value)); 374 379 } 375 380 } … … 415 420 /** 416 421 * returns source of custom class 422 * 423 * Usage: 424 * 425 * $sfExtjs2Plugin->customClass('Ext.app.symfony.ModuleA', array('title' => 'Module A', 'closable' => false)); 426 * 427 * => new Ext.app.symfony.ModuleA ({title:'Module A',closable:false}) 417 428 * 418 429 * @param string classname … … 420 431 * @return string source 421 432 */ 422 public function customClass($classname, $attributes = array())433 public function asCustomClass($classname, $attributes = array()) 423 434 { 424 435 $source = ''; 425 436 $source .= $this->getExtObjectComponent($attributes, array('attributes'=>array(), 'class'=>$classname)); 426 437 427 return $source; 428 } 429 430 /** 431 * returns source of custom class 438 return new sfExtjs2Var($source); 439 } 440 441 /** 442 * returns source of anonymous class 443 * 444 * Usage: 445 * 446 * $sfExtjs2Plugin->asAnonymousClass(array('name'=>'id','mapping'=>'id','type'=>'int')); 447 * 448 * => {name: 'id', mapping: 'id', type: 'int'} 432 449 * 433 450 * @param string classname … … 435 452 * @return string source 436 453 */ 437 public function a nonymousClass($attributes = array())454 public function asAnonymousClass($attributes = array()) 438 455 { 439 456 $source = ''; 440 457 $source .= $this->getExtObject('anonymousClass', $attributes); 441 458 442 return $source; 443 } 444 445 /** 446 * returns string as instance of sfExtjs2Var 459 return new sfExtjs2Var($source); 460 } 461 462 /** 463 * returns source of anonymous listener 464 * 465 * Usage: 466 * 467 * $sfExtjs2Plugin->asListener(array 468 * ( 469 * 'rowcontextmenu' => $sfExtjs2Plugin->asMethod(array 470 * ( 471 * 'parameters' => 'grid, rowIndex, e', 472 * 'source' => " 473 * 474 * // ensure that row could reselect 475 * // if onLoad event of data store occurs 476 * grid.selectedRowIndex = rowIndex; 477 * grid.getSelectionModel().selectRow(rowIndex); 478 * 479 * // prevent browser default context menu 480 * e.stopEvent(); 481 * 482 * // show context menu 483 * var coords = e.getXY(); 484 * grid.cmenu.showAt([coords[0], coords[1]]); 485 * " 486 * )) 487 * )) 488 * 489 * @param string classname 490 * @package array attributes 491 * @return string source 492 */ 493 public function asListener($attributes = array()) 494 { 495 $source = ''; 496 foreach ($attributes as $key => $value) 497 { 498 $source .= sprintf 499 ( 500 '%s"%s":%s', 501 $source != '' ? ',' : '', 502 $key, 503 $value 504 ); 505 } 506 $source = sprintf('{%s}', $source); 507 508 return new sfExtjs2Var($source); 509 } 510 511 /** 512 * returns string the passed string without additional quoting 447 513 * 448 514 * @param string var … … 455 521 456 522 /** 457 * returns source for method 458 * including output of evaled php code 459 * 523 * returns source for method including output of evaled php code 524 * 525 * Usage: 526 * 527 * Syntax A = short form without any options 528 * $sfExtjs2Plugin->asMethod('alert("foo");'); 529 * 530 * => function() { alert("foo"); } 531 * 532 * Syntax B = short form with parameters 533 * $sfExtjs2Plugin->asMethod(array('parameters' => 'msg', 'source' => 'alert(msg)'); 534 * 535 * => function(msg) { alert(msg); } 536 * 460 537 * @param array attributes 461 538 * @return string source