[ Index ]
 

Code source de eZ Publish 3.9.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/design/standard/templates/setup/ -> templateoperator_code.tpl (source)

   1  {* DO NOT EDIT THIS FILE! Use an override template instead. *}
   2  /*!
   3    \class   {$full_class_name} {$file_name}
   4    \ingroup eZTemplateOperators
   5    \brief   {$description_brief}
   6    \version 1.0
   7    \date    {currentdate()|l10n(datetime)}
   8  
   9  {section show=$creator_name}
  10    \author  {$creator_name}
  11  {/section}
  12  
  13  
  14  {$description_full|indent(2)}
  15  
  16  {section show=$example_code}
  17  
  18    {'Example'|i18n('design/standard/setup/operatorcode')}:
  19  \code
  20  {$example_code}
  21  \endcode
  22  {/section}
  23  
  24  */
  25  
  26  /*
  27  If you want to have autoloading of this operator you should create
  28  a eztemplateautoload.php file and add the following code to it.
  29  The autoload file must be placed somewhere specified in AutoloadPath
  30  under the group TemplateSettings in settings/site.ini
  31  
  32  $eZTemplateOperatorArray = array();
  33  $eZTemplateOperatorArray[] = array( 'script' => '{$file_name}',
  34                                      'class' => '{$full_class_name}',
  35                                      'operator_names' => array( '{$operator_name}' ) );
  36  
  37  If your template operator is in an extension, you need to add the following settings:
  38  
  39  To extension/YOUREXTENSION/settings/site.ini.append:
  40  ---
  41  [TemplateSettings]
  42  ExtensionAutoloadPath[]=YOUREXTENSION
  43  ---
  44  
  45  To extension/YOUREXTENSION/autoloads/eztemplateautoload.php:
  46  ----
  47  $eZTemplateOperatorArray = array();
  48  $eZTemplateOperatorArray[] = array( 'script' => 'extension/YOUEXTENSION/YOURPATH/{$file_name}',
  49                                      'class' => '{$full_class_name}',
  50                                      'operator_names' => array( '{$operator_name}' ) );
  51  ---
  52  Create the files if they don't exist, and replace YOUREXTENSION and YOURPATH with the correct values.
  53  
  54  */
  55  
  56  
  57  class {$full_class_name}
  58  {literal}{{/literal}
  59      /*!
  60        {'Constructor, does nothing by default.'|i18n('design/standard/setup/operatorcode')}
  61      */
  62      function {$full_class_name}()
  63      {literal}{{/literal}
  64      {literal}}{/literal}
  65  
  66      /*!
  67       {'\return an array with the template operator name.'|i18n('design/standard/setup/operatorcode')}
  68      */
  69      function operatorList()
  70      {literal}{{/literal}
  71          return array( '{$operator_name}' );
  72      {literal}}{/literal}
  73  
  74  {section show=$single_operator|not}
  75      /*!
  76       \return true to tell the template engine that the parameter list exists per operator type,
  77               this is needed for operator classes that have multiple operators.
  78      */
  79      function namedParameterPerOperator()
  80      {literal}{{/literal}
  81          return true;
  82      {literal}}{/literal}
  83  {/section}
  84  
  85  {section show=$parameter_check|eq(2)}
  86      /*!
  87       See eZTemplateOperator::namedParameterList
  88      */
  89      function namedParameterList()
  90      {literal}{{/literal}
  91          return array( '{$operator_name}' => array( 'first_param' => array( 'type' => 'string',
  92  {set-block variable=parameter_extra}
  93                          'required' => false,
  94                          'default' => 'default text' ),
  95  'second_param' => array( 'type' => 'integer',
  96                           'required' => false,
  97                           'default' => 0 ) ) );
  98  {/set-block}
  99  
 100  {$:parameter_extra|indent(sum(35,$operator_name|count))}
 101      {literal}}{/literal}
 102  {/section}
 103  
 104      /*!
 105       {'Executes the PHP function for the operator cleanup and modifies \a $operatorValue.'|i18n('design/standard/setup/operatorcode')}
 106      */
 107      function modify( &$tpl, &$operatorName, &$operatorParameters, &$rootNamespace, &$currentNamespace, &$operatorValue{section show=$parameter_check|eq(2)}, &$namedParameters{/section} )
 108      {literal}{{/literal}
 109  
 110  {section show=$parameter_check|eq(2)}
 111          $firstParam = $namedParameters['first_param'];
 112          $secondParam = $namedParameters['second_param'];
 113  
 114  {/section}
 115  
 116  {section show=$parameter_check|eq(3)}
 117          for ( $i = 0; $i < count( $operatorParameters ); ++$i )
 118          {literal}{{/literal}
 119              $operatorParameter =& $operatorParameters[$i];
 120              // Fetch the value of the parameter structure
 121              $operatorParameterValue = $tpl->elementValue( $operatorParameter, $rootNamespace, $currentNamespace );
 122          {literal}}{/literal}
 123  
 124  {/section}
 125  
 126  {section show=$single_operator}
 127          // {'Example code, this code must be modified to do what the operator should do, currently it only trims text.'|i18n('design/standard/setup/operatorcode')}
 128          {section show=$use_output}$operatorValue = {/section}trim({section show=$use_input} $operatorValue {/section});
 129  {section-else}
 130          // {'Example code, this code must be modified to do what the operator should do, currently it only trims text.'|i18n('design/standard/setup/operatorcode')}
 131          switch ( $operatorName )
 132          {literal}{{/literal}
 133              case '{$operator_name}':
 134              {literal}{{/literal}
 135                  {section show=$use_output}$operatorValue = {/section}trim({section show=$use_input} $operatorValue {/section});
 136              {literal}}{/literal} break;
 137          {literal}}{/literal}
 138  {/section}
 139  
 140      {literal}}{/literal}
 141  {literal}}{/literal}


Généré le : Sat Feb 24 10:30:04 2007 par Balluche grâce à PHPXref 0.7