the simplest extension

Author Message

Federico Maggi

Saturday 08 April 2006 5:03:24 am

Hi,

<b>The situation</b>
I am playing with the extension system. I need to add a new

<b>wash('textism')</b>

so I thought to override the original

lib/eztemplate/classes/eztemplatestringoperator.php

with a new

extension/washtextism/lib/eztemplate/classes/eztemplatestringoperator.php

that has a patched version of the <b>switch</b> within

function wash(...)

.

Here is the patch (diff original new):

402a403,419
>             
>             case 'textism':
>             {
>               $patterns = array('/\_([^\_]+)\_/', '/\*([^\*]+)\*/', '/\^([^\^]+)\^/', '/\~([^\~]+)\~/');
>               $replacements = array('<em>\1</em>', '<strong>\1</strong>', '<sup>\1</sup>', '<sub>\1</sub>');
>               ksort($patterns);
>               ksort($replacements);
>               $operatorValue = preg_replace( $patterns,
>                                                                          $replacements,
>                                                                          htmlspecialchars( $operatorValue )
>                                                                       );
>             } break;
>             
>             case 'strip':
>             {
>               $operatorValue = striptags( $operatorValue );
>             } break;

<b>The problem</b>
The override of the .php file is no consideret, at all, by the system. I am sure it works by itself since I tried it in the original file for debug purposes, only.

Suggestions?

Matthew Carroll

Saturday 08 April 2006 1:27:06 pm

I don't think this is the right way to go about this. You can't override the core kernel php files in an extension. The best way to achieve what you're trying to do would be to create a new template operator, say mywash, build that into an extension, and then use it in your templates. There is a wizard to help you waiting (hidden!) in your admin site, e.g...

http://example.com/admin/setup/templateoperator

See also the old documentation:

http://ez.no/products/ez_publish/documentation/development/kernel/custom_template_operators
http://ez.no/products/ez_publish/documentation/development/extensions/template_operator

Good luck!

Matthew

http://carroll.org.uk

Federico Maggi

Sunday 09 April 2006 4:09:10 am

Thank you and thanks to #ezpublish on freenode, too.

I have found that great RAD template operator wizard and in about 15 mins I had my template operator extension ready and published! Cool!

Here you can find the extension

http://ez.no/community/contribs/template_plugins/eztextism

please let me know about bugs or possible improvements.

Regards,

--

Federico http://www.maggi.cc

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 19 2025 21:30:51
Script start
Timing: Jan 19 2025 21:30:51
Module start 'layout'
Timing: Jan 19 2025 21:30:51
Module start 'content'
Timing: Jan 19 2025 21:30:52
Module end 'content'
Timing: Jan 19 2025 21:30:52
Script end

Main resources:

Total runtime1.3339 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0071 589.1484152.6250
Module start 'layout' 0.00710.0040 741.773439.4297
Module start 'content' 0.01111.3215 781.2031537.7500
Module end 'content' 1.33260.0013 1,318.953112.1875
Script end 1.3339  1,331.1406 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00360.2669160.0002
Check MTime0.00150.1156160.0001
Mysql Total
Database connection0.00110.085510.0011
Mysqli_queries1.269895.1953570.0223
Looping result0.00070.0499550.0000
Template Total1.286396.420.6432
Template load0.00200.146920.0010
Template processing1.284496.286620.6422
Template load and register function0.00020.015010.0002
states
state_id_array0.00200.153310.0020
state_identifier_array0.00150.110020.0007
Override
Cache load0.00170.1247370.0000
Sytem overhead
Fetch class attribute can translate value0.00100.074720.0005
Fetch class attribute name0.00110.080540.0003
XML
Image XML parsing0.00200.150620.0010
class_abstraction
Instantiating content class attribute0.00000.000840.0000
General
dbfile0.00700.5225160.0004
String conversion0.00000.000840.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
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 18
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs