modify function in eztemplatestringoperator.php

Author Message

James Ward

Thursday 19 March 2009 1:35:04 pm

I wanted to modify the pad function (to allow for non-breaking spaces to be added) so I did a quick search for pad in the ezpublish code (using version 4.0.1).

I noticed after some tinkering that the case for PadName under the function:

/*
     The modify function takes care of the various operations.
    */
      function modify( $tpl,
                     $operatorName,
                     $operatorParameters,
                     $rootNamespace,
                     $currentNamespace,
                     &$operatorValue,
                     $namedParameters,
                     $placement )

never gets used. It appears instead that the somewhat less friendly:

                                   'pad' => array( 'return' => 'string',
                                                   'code' => '$result = $paramCount == 2 ? str_pad( $staticValues[0], $staticValues[1] ) : str_pad ( $staticValues[0], $staticValues[1], $staticValues[2] );',
                                                   'code2' => '$result = str_pad( $staticValues[0], $staticValues[1] );',
                                                   'code3' => '$result = str_pad( $staticValues[0], $staticValues[1], $staticValues[2] );',
                                                 ),

Is what actually gets used to perform the pad operation. This seems like an ugly place to modify the pad behavior and I would like to adjust the code inside the modify function instead if possible.

Can someone explain the purpose of the modify function and when it gets called? I found nothing in the documentation and the comment leaves a bit to be desired.

Thanks in advance.

working at www.wardnet.com
blogging at www.jamesward.ca

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 15:17:34
Script start
Timing: Jan 18 2025 15:17:34
Module start 'layout'
Timing: Jan 18 2025 15:17:34
Module start 'content'
Timing: Jan 18 2025 15:17:36
Module end 'content'
Timing: Jan 18 2025 15:17:36
Script end

Main resources:

Total runtime1.2241 sec
Peak memory usage4,096.0000 KB
Database Queries46

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0050 589.1641152.6406
Module start 'layout' 0.00500.0041 741.804739.4766
Module start 'content' 0.00911.2138 781.2813469.6328
Module end 'content' 1.22290.0012 1,250.91418.2813
Script end 1.2241  1,259.1953 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00300.2446160.0002
Check MTime0.00120.1001160.0001
Mysql Total
Database connection0.00080.066110.0008
Mysqli_queries1.185896.8660460.0258
Looping result0.00040.0366440.0000
Template Total1.180596.420.5903
Template load0.00190.152220.0009
Template processing1.178696.285120.5893
Template load and register function0.00010.007410.0001
states
state_id_array0.00180.149710.0018
state_identifier_array0.00150.124120.0008
Override
Cache load0.00150.1234120.0001
Sytem overhead
Fetch class attribute can translate value0.00070.060410.0007
Fetch class attribute name0.00090.071620.0004
XML
Image XML parsing0.00050.039510.0005
class_abstraction
Instantiating content class attribute0.00000.000420.0000
General
dbfile0.00070.0586160.0000
String conversion0.00000.000640.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
3content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 9
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs