Development

Changeset 6667

You must first sign up to be able to contribute.

Changeset 6667

Show
Ignore:
Timestamp:
12/21/07 09:55:49 (6 years ago)
Author:
kubens
Message:

Added method asListener
Renamed method customClass into asCustomClass
Renamed method anonymousClass into asAnonymousClass

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfExtjs2Plugin/trunk/config/config.php

    r6653 r6667  
    11<?php 
    2 sfConfig::set('sf_extjs2_version', 'v0.54'); 
     2sfConfig::set('sf_extjs2_version', 'v0.56'); 
    33sfConfig::set('sf_extjs2_comment', true); 
    44# 
  • plugins/sfExtjs2Plugin/trunk/lib/helper/sfExtjs2Helper.php

    r6653 r6667  
    66 * @author           Benjamin Runnels<benjamin.r.runnels [at] citi [dot] com>, Leon van der Ree, Wolfgang Kubens<wolfgang.kubens [at] gmx [dot] net> 
    77 * @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 
    913 *                    - Added method asVar 
    1014 *                    - Added logic for anonymousClass 
     
    111115   * 
    112116   * Usage: 
    113    * 
     117   *  
    114118   *   Syntax A = short form without any options 
    115119   *   $sfExtjs2Plugin->Object(array 
     
    123127   *     ) 
    124128   *   )); 
    125    *    
     129   *  
    126130   *   => new Object({id: 'id', renderTo: document.body, items: [new Object(title: 'Object A'), new Object(title: 'Object B')]})    
    127131   * 
     
    299303  /** 
    300304   * writes closing tag for javascript 
    301    * 
     305   *   *  
     306   * @param  string source 
    302307   * @return Javascript source 
    303308   */ 
    304   public function end(
    305   { 
    306     $source  = sfExtjs2Plugin::LBR
     309  public function end($source = ''
     310  { 
     311    $source  = sprintf("%s%s%s", sfExtjs2Plugin::LBR, $source, $source != '' ? sfExtjs2Plugin::LBR : '')
    307312    $source .= sprintf("</script>%s", sfExtjs2Plugin::LBR); 
    308313 
     
    371376       foreach ($attributes['private'] as $key => $value) 
    372377       { 
    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)); 
    374379       } 
    375380     } 
     
    415420  /** 
    416421   * 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}) 
    417428   * 
    418429   * @param string classname 
     
    420431   * @return string source 
    421432   */ 
    422   public function customClass($classname, $attributes = array()) 
     433  public function asCustomClass($classname, $attributes = array()) 
    423434  { 
    424435    $source  = ''; 
    425436    $source .= $this->getExtObjectComponent($attributes, array('attributes'=>array(), 'class'=>$classname)); 
    426437 
    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'} 
    432449   * 
    433450   * @param string classname 
     
    435452   * @return string source 
    436453   */ 
    437   public function anonymousClass($attributes = array()) 
     454  public function asAnonymousClass($attributes = array()) 
    438455  { 
    439456    $source  = ''; 
    440457    $source .= $this->getExtObject('anonymousClass', $attributes); 
    441458 
    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 
    447513   * 
    448514   * @param string var 
     
    455521 
    456522  /** 
    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   *  
    460537   * @param array attributes 
    461538   * @return string source