Development

Changeset 6585

You must first sign up to be able to contribute.

Changeset 6585

Show
Ignore:
Timestamp:
12/19/07 13:44:44 (6 years ago)
Author:
kubens
Message:

Added sf_extjs2_comment

Files:

Legend:

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

    r6563 r6585  
    11<?php 
    2 sfConfig::set('sf_extjs2_version', 'v0.27'); 
     2sfConfig::set('sf_extjs2_version', 'v0.30'); 
     3sfConfig::set('sf_extjs2_comment', true); 
    34# 
    45# array values that don't need quotes 
     
    5859# attributes which must handled as array 
    5960# 
    60 sfConfig::set('sf_extjs2_list_attributes', array('items', 'tbar', 'buttons', 'plugins', 'cm', 'ds', 'view', 'tbar', 'bbar')); 
     61sfConfig::set('sf_extjs2_list_attributes', array('items', 'tbar', 'buttons', 'plugins', 'view', 'tbar', 'bbar')); 
    6162# 
    6263# mapping plugin method against class 
  • plugins/sfExtjs2Plugin/trunk/lib/helper/sfExtjs2Helper.php

    r6563 r6585  
    55 * @description      sfExtjs2Plugin is a symfony plugin that provides an easy to use wrapper for the Ext javascript library 
    66 * @author           Benjamin Runnels<benjamin.r.runnels [at] citi [dot] com>, Leon van der Ree, Wolfgang Kubens<wolfgang.kubens [at] gmx [dot] net>  
    7  * @version          0.0.29 
    8  * @last modified    12.17.2007 Leon: 
     7 * @version          0.0.30 
     8 * @last modified    12.18.2007 Wolfgang 
     9 *                    - Added sf_extjs2_comment 
     10 *                   12.17.2007 Leon: 
    911 *                    - handling of inner (recursive) arrays (see items => array(array(...), array(...)) 
    1012 *                   12.17.2007 Kubens: 
     
    166168    foreach (sfConfig::get('sf_extjs2_list_attributes') as $attribute)  
    167169    { 
    168       if (array_key_exists($attribute, $attributes['attributes'])
     170      if (array_key_exists($attribute, $attributes['attributes'])  && !$attributes['attributes'][$attribute] instanceof sfExtjs2Var
    169171      { 
    170172        $attributes['attributes'][$attribute] = sprintf('[%s]', sfExtjs2Plugin::_build_attributes($attributes['attributes'][$attribute])); 
     
    261263    $source  = sfExtjs2Plugin::LBR; 
    262264    $source .= sprintf("<script type='text/javascript'>%s", sfExtjs2Plugin::LBR); 
     265    $source .= sfExtjs2Plugin::_comment(sprintf("%s// sfExtjs2Helper: %s%s", sfExtjs2Plugin::LBR, sfConfig::get('sf_extjs2_version'), sfExtjs2Plugin::LBR)); 
    263266    $source .= sprintf("Ext.BLANK_IMAGE_URL = '%s'%s", sfConfig::get('sf_extjs2_spacer'), sfExtjs2Plugin::LBR_SM); 
    264267 
     
    297300    { 
    298301      $this->namespace = $namespace; 
     302      $source .= sfExtjs2Plugin::_comment(sprintf("%s// namespace: %s%s", sfExtjs2Plugin::LBR, $namespace, sfExtjs2Plugin::LBR));  
    299303      $source .= sprintf("Ext.namespace('%s')%s", $namespace, sfExtjs2Plugin::LBR_SM); 
    300304    } 
    301305 
    302306    // write class tag 
     307    $source .= sfExtjs2Plugin::_comment(sprintf("%s// class: %s.%s%s", sfExtjs2Plugin::LBR, $namespace, $classname, sfExtjs2Plugin::LBR)); 
    303308    $source .= sprintf("%s.%s = Ext.extend(%s, {%s", $namespace, $classname, $extend, sfExtjs2Plugin::LBR); 
    304309 
     
    317322  { 
    318323    $source  = ''; 
    319     $source .= sprintf("})%s", sfExtjs2Plugin::LBR_SM); 
     324    $source .= sprintf("})%s%s", sfExtjs2Plugin::LBR_SM, sfExtjs2Plugin::LBR_SM); 
    320325 
    321326    echo $source; 
     
    351356 
    352357    // write application syntax 
    353     $source = ''; 
    354     $source = sprintf( 
    355       'var %s = function() { %s%sreturn {%s %s', 
     358    $source  = ''; 
     359    $source .= sfExtjs2Plugin::_comment(sprintf("%s// application: %s%s", sfExtjs2Plugin::LBR, $attributes['name'], sfExtjs2Plugin::LBR)); 
     360    $source .= sprintf( 
     361      'var %s = function() { %sreturn {%s%s %s %s', 
    356362      $attributes['name'], 
     363      sfExtjs2Plugin::LBR, 
     364      sfExtjs2Plugin::LBR, 
    357365      $sourcePrivate, 
    358366      $sourcePrivate != '' ? sfExtjs2Plugin::LBR : '', 
     
    372380  { 
    373381    $source  = ''; 
    374     $source .= sprintf("}}()%s", sfExtjs2Plugin::LBR_SM); 
     382    $source .= sprintf("%s}}()%s", sfExtjs2Plugin::LBR, sfExtjs2Plugin::LBR_SM); 
    375383 
    376384    echo $source; 
     
    449457  private static function _build_attributes ($custom_attributes = array(), $default_attributes = array()) 
    450458  { 
    451     $merged_attributes = array_merge($default_attributes, $custom_attributes); 
    452  
    453459    $attributes = ''; 
     460 
     461    $merged_attributes = $default_attributes; 
     462    if (is_array($custom_attributes) && is_array($default_attributes)) 
     463    { 
     464      $merged_attributes = array_merge($default_attributes, $custom_attributes); 
     465    } 
     466 
    454467    foreach ($merged_attributes as $key => $value) 
    455468    { 
     
    546559  } 
    547560 
     561  /** 
     562   * @param string comment 
     563   * @return string comment 
     564   */   
     565  private static function _comment($comment) 
     566  { 
     567    if (sfConfig::get('sf_extjs2_comment')) 
     568    { 
     569      return $comment; 
     570    } 
     571    else  
     572    { 
     573      return ''; 
     574    } 
     575  } 
     576 
    548577} 
    549578