[PHPTAL] Incompatibility between PHPTAL exceptions and xdebug

2009-10-05 Thread Iván -DrSlump- Montes
Hi,

When throwing a PHPTAL_TemplateException (or a descendant of it) exception
in an environment with the Xdebug extension activated, it results in a fatal
error, triggered by Xdebug, since it checks the types of the message,
file and line properties (string, string and integer respectively).

PHPTAL gives by default a value of false to the line property (so it gets
a boolean type). This can be easily solved by casting to integer the
assigments to the line property in Exception.php. Example:

$this-line = (int) $this-srcLine;


regards,
/imv
___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] PHPTAL prefilters

2009-09-16 Thread Iván -DrSlump- Montes
Hi again,

Find attached a simple implementation of the plugin loader using a subset of
Zend Framework's api.

Check ZF docs [1]  for documentation, it should behave the same way.

The use with PHPTAL might be something like this:

// Get the standard instance of the loader
$loader = $tpl-getFilterLoader();
// and add a new location for filters
$loader-addPrefixPath('My_Filter', '/path/to/my/filter');

// or, setup PHPTAL with our custom loader
$tpl-setFilterLoader( new Zend_Loader_PluginLoader() );


[1] http://framework.zend.com/manual/en/zend.loader.pluginloader.html

regards,
/imv

On Wed, Sep 16, 2009 at 12:23 PM, Iván -DrSlump- Montes 
drsl...@pollinimini.net wrote:

 Using only the autoloader/include_path might be a little limiting in my
 opinion. It would make it harder to replace a standard filter class for
 example.

 Besides, implementing a simplified plugin loader wouldn't be that
 difficult and it would allow to use it in other parts of PHPTal in the
 future, for example, to override the default implementation of standard
 namespaces, tales modifiers ...

 It will also be nice, for me at lease, is that the plugin loader uses a
 subset of Zend_Loader_PluginLoader api, so that users of ZF can inject the
 zend loader version in PHPTAL.

 I'll come up with a working prototype of the loader, so you can use it if
 you see fit.

 /imv

 2009/9/16 Kornel Lesiński kor...@aardvarkmedia.co.uk

 On 16-09-2009 at 10:20:59 Iván -DrSlump- Montes drsl...@pollinimini.net
 wrote:

  The API looks ok to me, just one thing, since it's not a runtime
 operation (in the sense that a php file is generated for the template),  I
 think it'll be great if it used something along the lines of
 Zend_Loader_PluginLoader.

 Which basically when setup with paths and class prefixes is able to find
 plugins in several folders. This would allow to have a set of default
 filters in PHPTAL distribution but override them and create new ones
 easily just by placing the class files in a directory, not needing to
 register them manually at runtime, which once the template is compiled, is
 of no use.

 So -- phptal:filter=remove_whitespace -- would automatically try to
 include and instantiate a class for that filter.

 While -- PHPTAL-addPreFilter(remove_whitespace) -- would just store
 the name for when compiling the template and instantiate the class then.


 That's great idea.

 Do you think I could get away with reliance on autoload or include_path,
 instead of implementing PluginLoader?

 (e.g. if (!class_exists($name.PreFilter)) include
 $name.PreFilter.php;)

  Regarding the tutorials, creating documentation is always hard, specially
 for OSS projects, perhaps we could use a simple wiki to collect
 information (there is quite a bit of information scattered around, mainly
 from Zope's
 implemenation).
 By the way, DokuWiki is a great wiki for this kind of tasks.


 Ok, I'll install it.

 --
 regards, Kornel


 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal



attachment: PluginLoader.php
___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] Fwd: stripping or escaping php code in templates

2009-08-09 Thread Iván -DrSlump- Montes
Have a look at PHP's tokenizer function token_get_all. It will give you a
rock solid base for your filter since it uses the same parser used in the
PHP engine.

regards,
/imv

On Sun, Aug 9, 2009 at 8:40 PM, Ionut Matei johnu...@gmail.com wrote:

 Thank you all for your input.

 I want only to disable php blocks, to prevent echo-ing unescaped strings,
 like this:
 ?php echo $_SERVER['HTTP_REFERER; ?

 I'll go for a preFilter.

 Thanks!

 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal


___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] What is the better way for Radio Button default value ?

2009-08-07 Thread Iván -DrSlump- Montes
I guess something like this should work.

input type=radio tal:attributes=checked php:P.civility eq 'Miss'
value=Miss ... /
input type=radio tal:attributes=checked php:P.civility eq 'Ms'
value=Ms ... /
input type=radio tal:attributes=checked php:P.civility eq 'Mr'
value=Mr ... /

This is one of those examples, and forms in general,  where a Tal doesn't
shine much.

regards,
/imv

On Fri, Aug 7, 2009 at 4:08 PM, Guillaume Lecanu guilla...@lya.fr wrote:

  Hi again,

 I have in my form a field civility like that :

 labelCivility/label
 ul
 li
 input type=radio name=civility value=Miss
 id=civility-miss /
 label for=civility-missMiss/label
 /li
 li
 input type=radio name=civility value=Ms
 id=civility-ms /
 label for=civility-msMs/label
 /li
 li
 input type=radio name=civility value=Mr
 id=civility-mr  /
 label for=civility-mrMr/label
 /li
 /ul

 If the form is submitted with errors, I need to pre-fill the civility
 field with the previous selected value.
 I give the $_POST array to PHPTAL like that : $tpl-set('P', $_POST), so I
 can access to this value by P/civility

 What is the best way to have no radio-buttons selected if P/civility
 doesn't exist, and to have the good radio-button selected dependant of the
 value found into P/civility ?

 Thanks in advance for your help !

 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal


___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] Re: disabling PHPTal parsing for blocks

2009-08-07 Thread Iván -DrSlump- Montes
As a work around perhaps you can place the Javascript template code in
separate files and use them like this:

script
  ?php include('my_javascript_tal_template.jstal'); ?
/script

regards,
/imv

On Fri, Aug 7, 2009 at 4:28 PM, Richard Cernava cern...@gmail.com wrote:

 Kornel Lesiński kor...@... writes:

 
  On 06-08-2009 at 18:48:46 Richard Cernava cern...@... wrote:
 
 I'm at a loss to find a method to disable PHPTAL parsing for a block
 of
   XML/HTML. I am aware that there placing anything in a comment removes
 it
   exempts
   it from being parsed, but I have not found another method.
  
   What I'm wanting to do is as follows:
  
   div tal:no-parse=true
   ${abc}
   /div
  
   Am I totally missing this?
 
  I'm not sure what exactly do you want.
 
  If you want to output ${abc} literally on the page, then write $${abc}.
  There's no attribute for this.
 
  If you want to hide content of an element, then div tal:replace= will
  work (and if you wrap content in ![CDATA[ ]], you won't need to worry
  about closing tags, etc. inside the element).
 

 My apologies for not being more specific. I don't think parse was the
 proper
 word to use, but more interpreting. I have a java script TAL library that I
 would like to pass TAL marked up HTML with out it being interpreted and
 converted to PHP. Thus the reasoning behind disabling interpreting on a
 block of
 HTML/XML and just passing it through. CDATA isn't what I'm looking for. I
 suppose I could go with another name space rather than TAL, maybe?
 Presently my
 work around is to use conditional comments that I strip off in the comment
 switch in the XML parser.

 An example would be:


 span tal:content=string:I'm PHP/
 div tal:interpret=false
  span tal:content=string:I'm javascript/
 /div

 phptal's out put would be:
 spanI'm PHP/span
 div
  span tal:content=string:I'm javascript/
 /div


 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal

___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] Re: Dynamic allocation of objects inside PHPTAL templates

2009-02-17 Thread Iván -DrSlump- Montes
I would think so. You can however work around it by using a factory pattern,
that is, a function wich returns an instance of the object. ie:

function GuestListFactory( $param1, $param2 ){
  return new GuestList( $param1, $param2 );
}

regards,
Ivan

On Tue, Feb 17, 2009 at 10:35 AM, romtek rom...@gmail.com wrote:

 On Tue, Feb 10, 2009 at 2:55 PM, romtek rom...@gmail.com wrote:

 Hi,

 I've tried to dynamically allocate an object inside a template and gotten
 errors. The following gets generated in the compiled code:
 *$ctx-new* GuestList(null, $ctx-event-guestlist_id). The bold part
 won't work, obviously.

 It currently seems impossible to do. Is it?

 Thanks

 Roman



 So, is it impossible, guys?

 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal


___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] Re: Security bug in PHPTAL?

2009-02-12 Thread Iván -DrSlump- Montes
It sure looks like there is a security hole in those servers, perhaps it's a
bug on some web software running in them (Wordpress, Joomla, phpMyAdmin...)
which allows the attacker to modify files writable by the web server.

Review the last modified date of the affected files and then search for that
time in your web server logs, it might give you a hint of what's going on.

cheers,
/imv


On Thu, Feb 12, 2009 at 3:40 PM, Szymek Przybył apocalyp...@gmail.comwrote:

 I think that isn't a server fault - this code was appeared on two my sites,
 one of my client (on the same hosting which I used - szybki-serwer.pl) and
 on site of my client on the other server (home.pl).

 cheers!
 szymek


 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal

___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] Inject PHP Code into template?

2009-02-02 Thread Iván -DrSlump- Montes
The PHPTAL way would be to create a custom tales modifier [1], although what
admirau proposes will also work.

[1] http://phptal.motion-twin.com/manual/en/split/ar06s08.html

ciao,
/imv

On Mon, Feb 2, 2009 at 6:45 PM, admirau admi...@gmail.com wrote:

 W dniu 2009-02-02 18:31, Christian Welzel pisze:

 Hi there,
 is there a way to inject PHP code into the template during compiiation?
 I want to make a date: helper for phptal which uses Zend_Date for
 convertions. But creation of Zend_Date is a bit expensive, so i want to
 create an instance on the begin of the template file and use it later in
 the
 helper.


 Create a class and execute method where you need:
 span tal:content=php: SomeClass::staticMethod()-MM-DD/span

 Use class methods, just replace - with dots.

 If you want to inject on the fly, you have to write pre-filter with regex
 or parse DOM.

 Further reading:
 http://phptal.motion-twin.com/manual/en/#tales-php
 http://phptal.motion-twin.com/manual/en/#tales-structure
 http://taat.pl/article/zend_framework_tutorial/

 --
 reagards,
 takeshin


 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal

___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] Best practices for performance?

2009-01-04 Thread Iván -DrSlump- Montes
Hi Alister,

PHPTAL compiles its templates into native PHP code so the runtime overhead
is very low. I don't know much about WP's native templating engine but I
think to recall it was just some hooks (php functions) being called by the
core. In this case PHPTAL would be a tad slower but not enough to worry
about for the average WP based site.

Regarding expressions to avoid, tales expressions translate quite directly
to equivalent PHP code, so it doesn't matter how complicated the expression
is, it'll be as fast as equivalent native PHP code written by an average
programmer.

One thing to care a bit about is the use of modifiers like the translation
or the cache ones, they add some aditional logic to the runtime execution,
usually meaning disk access, so they should be used with caution and only
when needed.

Running more than one instance of PHPTAL for diferent sections will affect a
little bit the overall performance, if the WP templating system allows it,
check out the metal namespace to get two-step/slot functionality.

As for the PHPTAL code itself, it could be further improved by eliminating
the need to check if a template has been already compiled or not, useful
when all templates are already compiled and no longer changed.

Besides all that, if someone bugs you about a compiling template engine
(such as PHPTAL itself) performance, ask first if they are using an opcode
cache like APC, XCache or Zend Optimizer :)

greetings,
/imv

On Sun, Jan 4, 2009 at 1:05 AM, Alister Cameron 
alister.came...@cameroncreative.com wrote:

 Hi again.
 After an aborted attempt about a year ago, I am now making great headway on
 a PHPTAL WordPress theme. This has been a bit of a holy grail project for
 me, and as someone with limited experience with PHP, a big challenge.

 Good news is I am getting through it and have overcome all the obstacles so
 far.

 I know that one of the questions I will be asked from the WordPress
 community is about how big a performance hit PHPTAL will impose. To that,
 I would like to be able to reply with some wisdom from PHPTAL experts :)

 Can you please shed some light on what are best practices regarding
 keeping PHPTAL fast?

 For example, are there certain PHP expressions to avoid? Is there some
 acknowledged ugly syntax that should be avoided? Should only on e template
 object be used or does using multiple template objects for page components
 make no real difference to overall performance?

 These are the sorts of performance questions I have and am wondering if
 there is any agreed best practice out there...?

 Many thanks!

 Cheers,

 -Alister

 PS. If there is anyone here with both a) WordPress experience and b) PHPTAL
 expertise who would like to have a look at my theme -- especially to help me
 refine and improve it -- I would love to hear from you.

 ---
 Alister R Cameron
 CEO // Australis Media Pty Ltd
 http://www.australismedia.com

 Mob. 04 0404 
 Fax 03 8610 0050

 Click here to find me online:
 http://clicktoadd.me/alicam

 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal


___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] Need some help with a loop

2008-11-22 Thread Iván -DrSlump- Montes
Hi,

This is one of the cases where TAL is a bit strange to work with. The
following should work even if the HTML generated is not standards compliant.

tal:block repeat=image images
  tal:block tal:replace=structure 'lt;trgt;'
tal:condition=php:repeat.image.index % 5 == 0 /
  td
img src=${image/src} /
  /td
/tal:block

Another option (better in my opinion) would be to split the list in chunks:

tr tal:repeat=chunk php:array_chunk(images, 5)
  td tal:repeat=image chunk
img src=${image/src} /
  /td
/tr

ciao,
/imv


On Sat, Nov 22, 2008 at 3:24 PM, Tanax [EMAIL PROTECTED] wrote:

 Hi!

 I'm wondering how to solve this, cause I have no idea.

 I'm having the php pull an array of images from the DB. Then I'm iterating
 through them with PHPTAL and writing them out in a table.
 Problem is this:

 table tal:condition=showImages cellspacing=5px

 tbody

 tr
 td tal:repeat=image images
 a href=view.php?image=${image/image_id}img
 src=${path}/${image/image_name} border=0 //a
 /td
 /tr

 /tbody

 /table

 As you see, if there are 50 images in DB, it will echo out 50 images on 1
 row. If I instead place the repeat in the tr tag, it will echo out 1 image /
 row, on 50 rows. How could I make it write out a /trtr after say.. 6
 images? So I get 6 images per row?? Is this even possible? Cause I have no
 idea how to solve this.

 Thanks in advance!
 Marcus

 --
 Tanax

 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal


___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] How to disable autoquote ?

2008-10-14 Thread Iván -DrSlump- Montes
I think that CDATA is special enough as to have its own handler, I mean that
it should be equivalent to 'structure'. Since TAL should output XML valid
documents, having a way to specify a CDATA section seems logical.

ie: script tal:content=cdata myJsCode/script
pre tal:content=cdata myExampleCode/pre

What I'm not sure of is how would it escape the cdata mark for 'script'
contents. Should it assume // is a common enough to use it as default,
should /* */ be used so it's ok also for CSS?

ciao,
ivan


On Tue, Oct 14, 2008 at 11:28 AM, Kornel Lesiński 
[EMAIL PROTECTED] wrote:

 On 14-10-2008 at 10:08:15 Ernesto Baschny [cron IT] [EMAIL PROTECTED]
 wrote:

  It would be cool to have a tal:cdata= boolean value, where one could
 switch on generation of CDATA wrapping automatically, so one could write:

 script tal:content=structure myJsCode tal:cdata=true/script

 And doesn't have to remember all kinds of required CDATA quoting.


 Something like that would be nice indeed. I think it would be even better
 if PHPTAL could automatically add CDATA to script when it's needed.

 --
 regards, Kornel


 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal

___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] How to disable autoquote ?

2008-10-13 Thread Iván -DrSlump- Montes
prefix the content with the 'structure' keyword, it will use the value
verbatin.

script tal:content=structure myJsCode/script

ciao,
/imv

On Mon, Oct 13, 2008 at 10:13 PM, Guillaume Lecanu [EMAIL PROTECTED] wrote:

  Hi,

 I want to write a dynamic JS content into the script/scriptbalise.
 A simple : alert(Hello World)

 But the problem is PHPTAL replace all quotes (simple or double quote) by
 HTML entities.

 How can I do ?

 Thanks

 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal


___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] php if else syntax in phptal

2008-10-12 Thread Iván -DrSlump- Montes
Edu,

The problem is probably that PHPTAL parser doesn't know how to correctly
process the PHP ternary operator. I suggest you try using a function to
accomplish the same:

function ternary($condition, $true, $false) {
  return $condition ? $true : $false;
}

table tal:attributes=class php: ternary(record/works_page,
'llista_cancons', 'llista_canconsindiv')

By the way, the Paamayim Nekudotayim error is as common as missleading in
PHP, most lexing ambiguities are resolved by the parser with this error :(

ciao,
/imv

On Sun, Oct 12, 2008 at 11:24 AM, Eduard Gamonal [EMAIL PROTECTED]wrote:

  I don't know what your Hebrew message says,
 http://en.wikipedia.org/wiki/Paamayim_Nekudotayim
 it's double colon in Hebrew.

  but if I were you, I'd use
  'style1' instead of 'style1''.
 sorry, that was a typo. I changed the desired class names for dummy
 ones. Here's the line I'm using:

table tal:attributes=class php: record/works_page ?
 'llista_cancons' : 'llista_canconsindiv'  


 Edu

 Eduard Gamonal


 
  Roman
 
  On Sat, Oct 11, 2008 at 6:30 PM, Eduard Gamonal [EMAIL PROTECTED]
 wrote:
 
  Hi,
  I'm developing a website using ccHost, and got trapped in a line:
 table tal:attributes=class php: record/works_page ? 'style1'' :
  'style2'   
 
   record/works_page contains a boolean value, and according to that, i
  may apply style1 or style2.
  I tried it changing the slashes into dots, but didn't work. I get the
  famous Hebrew error:
 
  Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in
 
  /home/server/
 musicalliure.net/subdominis/proves/httpdocs/mll_files/temp/tpl_0_7_0_060569839c3080481dfb9a552861235b.php
  on line 516
 
  a line like div tal:condition=not: record/works_page
  class=llista_cancons_titol has worked properly in the same context.
  what's wrong in the first line, then?
 
  Thanks :)
 
 
 
  Edu
 
  Eduard Gamonal
 
  ___
  PHPTAL mailing list
  PHPTAL@lists.motion-twin.com
  http://lists.motion-twin.com/mailman/listinfo/phptal
 
 
  ___
  PHPTAL mailing list
  PHPTAL@lists.motion-twin.com
  http://lists.motion-twin.com/mailman/listinfo/phptal
 
 

 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal

___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] Best way to make a list of list

2008-08-08 Thread Iván -DrSlump- Montes
I think the only way to do nested structures with PHPTAL is using
Metal's macros. Have you looked at it?

Iván

On Fri, Aug 8, 2008 at 6:18 PM, Guillaume Lecanu [EMAIL PROTECTED] wrote:
 Hello,

 I need to make a menu, with some sub-menus and other sub-menus etc.

 For example :

 * Menu A :
* A1
* A2
* Hello
* World
* A3
 * Menu B
* B1
   * PHPTAL
   * Rocks !
* B2

 So in XHTML this is list of ul:

 ul
liMenu A
ul
liA1/li
liA2
   ul
  liHello/li
  liWorld/li
/ul
 /li
liA3/li
/ul
/li
liMenu B
 
 /li


 But all the structure is stored in DB, so I don't know in advance if one
 menu have 1, 2, or 10 childrens, and I don't know if a children is a
 submenu.

 I know how to do that in PHP without PHPTAL, but how is it possible to do
 that kind of XHTML code with PHPTAL ?

 Thanks a lots for your help.
 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal



___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] Avoid intermediate phptal files

2008-07-31 Thread Iván -DrSlump- Montes
Kornel,

It might be a good idea to create a small section in the manual for
sysadmins. Explaining why compiled templates are created, ideal
permission sets, how to change the default location ...

Ivan


On Thu, Jul 31, 2008 at 4:04 PM, Alejandro Giardino
[EMAIL PROTECTED] wrote:
 Hello Kornel and thankyou for your answer. About your question, the server
 administrator asked my about this.


 - Mensaje original -
 Fecha: Thu, 31 Jul 2008 14:43:35 +0100
 De: Kornel Lesiński [EMAIL PROTECTED]
 Para: Template Attribute Language for PHP phptal@lists.motion-twin.com
 Asunto: Re: [PHPTAL] Avoid intermediate phptal files

 On 31-07-2008 at 14:18:39 Alejandro Giardino [EMAIL PROTECTED]
 wrote:

 I'm using PHPTAL with some forms in a web site. PHPTAL is writing files
 in /tmp as a usual behavior, but I would need to avoid the files creation

 It can't be avoided currently. Why do you need to do that?

 --
 regards, Kornel

 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal

 Alejandro Giardino

 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal


___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] Avoid intermediate phptal files

2008-07-31 Thread Iván -DrSlump- Montes
On Thu, Jul 31, 2008 at 6:00 PM, Kornel Lesiński
[EMAIL PROTECTED] wrote:

 It's a good idea. Can you do it? :)


Please feel free to modify it as you see fit.

PHPTAL for SysAdmins:

PHPTAL functions by generating PHP files from the template's logic,
this means that it needs a directory to store those generated files so
they can be parsed by the PHP interpreter.

By default PHPTAL will use the system's temp directory (via PHP's
sys_get_temp_dir() function if available) or will try to guess where
it should be, /tmp on Unix like systems and c:\windows\temp on
Microsoft ones, to store the compiled templates. The default
destination can be changed to your liking by setting the define
PHPTAL_PHP_CODE_DESTINATION or by calling setPhpCodeDestination()
method with the appropriate path.
Be it the system's temp directory or a custom one, it needs to have
its permissions setup as to allow the PHP running process (the Apache
user if using mod_php or the cgi/fastcgi user otherwise) to create and
update files in that directory.

PHPTAL creates one file for each different template file and one file
for each tag if using phptal:cache. It doesn't create separate files
for macros (which are simply compiled as PHP functions inside the
compiled template file).
These files are automatically cleaned up once in a while, more
specifically, each time a template is compiled there is random
probability, controlled by setCachePurgeFrequency() method, which will
just delete files older than set by setCacheLifetime() method.
Alternatively you can also schedulle the deletion of old/unused files
by running this from an Unix like shell (like in a cron job):

   find /tmp/ -name tpl_\* \( -atime +1 -o -mtime +14 \) -exec rm -v {} \;



Ivan
___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] Tal conditions

2008-06-19 Thread Iván -DrSlump- Montes
I think that the correct syntax for that is:

tal:condition=php: profile.profile_id GT 0

You need to use the 'php' tales modifier to evaluate an expression,
otherwise it's evaluated as a path.

Iván

On Fri, Jun 20, 2008 at 12:35 AM, Reza Sanaie [EMAIL PROTECTED] wrote:
 Hi all,

 Why would the following fail: td tal:condition=profile/profile_id GT
 0/td ?

 If we can't use GT LE,... within a tal:condition, where are we allowed to
 use them?


 Cheers


 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal


___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] Re: developer of PHPTAL or not

2008-05-30 Thread Iván -DrSlump- Montes
Sure I don't mind to share, it's just that I've been way to busy with
other projects and in its current state is not usable. I was in the
middle of a huge refactoring when I stopped working on it.

The repository is at:

http://svn.pollinimini.net/drtal/trunk

And generated documentation at:

http://svn.pollinimini.net/drtal/trunk/docs/DrTal-php.html

Things I have planned to add is the use of the SPL where it makes
sense (ArrayObject, Iterators), PHP 5.3 namespaces and code generator
to compile templates into javascript code.

Iván


On Fri, May 30, 2008 at 7:07 PM, Kornel Lesinski
[EMAIL PROTECTED] wrote:
 On Fri, 30 May 2008 17:28:18 +0100, Iván -DrSlump- Montes
 [EMAIL PROTECTED] wrote:

 I've been trying to push for PHPTAL use in several projects in the
 last years but I haven't been very successful. I ended up writing my
 own version from scratch a couple of months ago, leveraging new PHP
 5.3 features and the bundled XML parsers + Tidy for legacy templates.

 The main point in implementing my own version was to make it extremely
 modular to support custom storage (file, string, pdo...), easily
 extendable namespaces, tales modifiers, pre/post filters and code
 generation in other languages besides PHP (Javascript). While PHPTAL
 supports most of that stuff it's showing its age and doesn't makes use
 of modern PHP's OO features. That's why I target 5.3, so I can tell
 management that the library is using 'latests technology' and is
 easily hookable into existing frameworks like ZF or Symfony. Using a
 BSD like license was also required in some projects.

 Is this something you could share? I have nothing against making PHPTAL more
 modern and modular :)

 --
 regards, Kornel

 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal


___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] i18n:translate on an attribute ?

2008-04-26 Thread Iván -DrSlump- Montes
Does something like the following work?

tal:block tal:define=global submitMsg
  div i18n:translate=submit /
/tal:block
input type=submit name=submit tal:attributes=value submitMsg /


Iván


On Sat, Apr 26, 2008 at 5:58 PM, Guillaume Lecanu [EMAIL PROTECTED] wrote:

  Hi,

  Is it possible to change the text of an attributes ?

  For example I want to translate 'Send' : submit name=submit value=Send
 /

  Thanks
 ___
  PHPTAL mailing list
  PHPTAL@lists.motion-twin.com
  http://lists.motion-twin.com/mailman/listinfo/phptal



___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] XMLNS DTD

2008-04-23 Thread Iván -DrSlump- Montes
I don't know of any publicly available DTDs for TAL. So either you
find a validation tool which doesn't try to load external/unknown DTDs
or you create the DTDs yourself and host them somewhere.

PS: You can also create some sample data and generate the tal page
with it before handling it to the validation tool. I think this is the
right way to do it since unless you're using 'defaults' for all your
constructs, the HTML of the template and the finally generated one can
be quite different.

ciao,
Iván


On Wed, Apr 23, 2008 at 4:23 PM, Guillaume Lecanu [EMAIL PROTECTED] wrote:

  Oups, sorry for my last email.
  It's an error !



  Le mercredi 23 avril 2008 à 16:20 +0200, Guillaume Lecanu a écrit :



  Hi,

  Le mercredi 23 avril 2008 à 12:23 +0200, Krzysztof Sikorski a écrit :
  xmlns:tal=http://xml.zope.org/namespaces/tal;
 xmlns:metal=http://xml.zope.org/namespaces/metal;


  Thanks but theses URL go on an 404 Error page, it's may be what's excepted,
 I don't know.


  I found those two somewhere on the Zope's site. I can't help you with
  i10n as I don't use that namespace, but I guess the url is similar.
  Besides, if you just want the validator to shut up, than probably any
  url will do, or maybe even an empty attribute (xmlns:i10n=).

  If I put them in my html tag, the w3c validator continue to show the
 errors.

  It's strange, there is surely a trick to have a valid XHTML page with
 metal/tal/i18n namespaces..





  On Wed, Apr 23, 2008 at 9:28 AM, Guillaume Lecanu [EMAIL PROTECTED] wrote:
 
  Hi,
 
  When I try to check my template page in W3C validator, this report some
  errors because of xmlns like metal, tal and i18n.
 
  There is surely a xmlns:metal, xmlns:tal  xmlns:i18n attributes to put in
  the html tag but I don't find the good URL of the DTD.
 
  Can you give me the correct URL of DTD's ?
 
  Thanks
 
 
  ___
  PHPTAL mailing list
  PHPTAL@lists.motion-twin.com
  http://lists.motion-twin.com/mailman/listinfo/phptal
 
 

 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal



  --

  Lecanu Guillaume
  Directeur Général
  Tél. : 01.76.23.00.12
  GSM : 06.27.46.36.04
  Fax : 03.20.32.37.48


  ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal


 ___
  PHPTAL mailing list
  PHPTAL@lists.motion-twin.com
  http://lists.motion-twin.com/mailman/listinfo/phptal



___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] php: modifier and path: arguments

2008-04-14 Thread Iván -DrSlump- Montes
I think to recall that variables in the php: modifier must be written
without the $ prefix, so your code should be something like this:

b tal:content=php: strtoupper( configItem.name )

Iván

On Mon, Apr 14, 2008 at 11:43 AM, B. Kamer [EMAIL PROTECTED] wrote:
 hi

  i am wondering how to do the following. It cannot be hard but i am unble to
 do this

  execute an php function with tal path values as arguments

  b tal:content=php: strtoupper(${configItem.name})NAME OF DOMAIN/b:
 ${configItem/value}

  Invalid TALES path: ''.$ctx-ctx.'-configItem-name', expected variable
 name

  as if the path isn't available in an php: modifier

  thank

  Bas

  ___
  PHPTAL mailing list
  PHPTAL@lists.motion-twin.com
  http://lists.motion-twin.com/mailman/listinfo/phptal


___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] PHPTAL_RepeatController and PDOStatement

2008-02-03 Thread Iván -DrSlump- Montes
Following with the repeat discussion I've refactored the repeat
controller to add some Zope features missing from it. I've also added
support for PHP internal objects implementing Traversable (like PDO)
by traversing the object at instantiation time and storing all the
results in a temporary array. I think this is a good trade off, if
someone has special needs which are not suited by this approach he/she
can wrap the traversable object with a specialized iterator.

The summary of the changes is:
  - Refactored to work only with SPL iterators (to simplify the code)
  - Arrays are wraped with ArrayIterator
  - Traversable objects are fetched at once and stored in an ArrayIterator
  - Added support for string iteration
  - Added support for 'letter' and 'roman' properties
  - Added support for grouping 'first' and 'last' properties
  - Most properties are computed as needed

The only concern I have is that wrapping native arrays with
ArrayIterator could affect performance. Although I haven't noticed any
noticeable slow downs in my tests.

I've attached the modified file to this mail hoping they can make it
to the official branch.If they are used in the distribution I'll
contribute some unit tests to cover the new functionality.

PHPTAL/RepeatController.php
PHPTAL/Php/Attribute/TAL/Repeat.php

cheers,
Ivan

On Feb 3, 2008 1:25 PM, Kornel Lesiński [EMAIL PROTECTED] wrote:
 On 01.02.2008, at 13:12, Julien Fredon wrote:

  Hello phptal users,
 
  I have a problem with PHPTAL and PDO (www.php.net/pdo) when i use
  tal:repeat.
  PHPTAL_RepeatController seems angry with PDOStatement.
 
  PDOStatement is not Iterator but it's Traversable


 That's the problem indeed. Traversable interface doesn't even offer
 methods for returning current key and PDOStatement doesn't count total
 number of rows at all.

 I've changed SVN version of PHPTAL to be less picky about what it
 iterates and use keys obtained from foreach() instead of getting them
 via interfaces or array_keys(). This allows basic iteration of
 PDOStatement, DOMNodeList, etc.

 I'll think about supporting it better (which might require
 introspection of template code to check if repeat/last, etc. are
 used), but for now, if you need all repeat properties, my suggestion
 is to use PDOStatement::fetchAll().

 --
 regards, Kornel





 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal



RepeatController.php
Description: Binary data


Repeat.php
Description: Binary data
___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


[PHPTAL] Chained expressions on tal:condition

2008-01-31 Thread Iván -DrSlump- Montes
Hello list,

I've modified the tal:condition attribute to handle chained
expressions so it can do stuff like cart/items | nothing or even
showItems | cart/items | nothing.

I'm attaching the whole modified file since the almost all lines have changed.

I've also noticed that phptal_isempty() returns true only for Null,
False and zero length strings. However I feel that it should also
check for empty arrays. I do agree though that a int/float of value 0
should not be considered empty.
I propose the following patch to implement the empty array check.

Index: Context.php
===
--- Context.php (revision 331)
+++ Context.php (working copy)
@@ -374,7 +374,7 @@

 function phptal_isempty($var)
 {
-   return $var === null || $var === false || $var === '';
+   return $var === null || $var === false || $var === '' || (
is_array($var)  count($var)===0 );
 }

 function phptal_escape($var, $ent, $encoding)


Condition.php
Description: Binary data
___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal