Re: [SMARTY-DEV] Trouble compiling tpl from resource plugin

From: Date: Tue, 16 Jul 2002 15:20:06 +0000
Subject: Re: [SMARTY-DEV] Trouble compiling tpl from resource plugin
References: 1  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-189@lists.php.net to get a copy of this message
I don't think that will work, if you have file:c:foo.tpl you will still end up with c:foo.tpl which basename will fail to remove the c: part. Gary Loescher wrote:
Only thing I can think of is that explode is already being called from _parse_file_path, in _fetch_template_info. If there were some way to keep that result around... Gary
-----Original Message----- From: Monte Ohrt [mailto:monte@ispi.net] Sent: Tuesday, July 16, 2002 9:32 AM To: gary@loescher.org Cc: smarty-dev@lists.php.net Subject: Re: [SMARTY-DEV] Trouble compiling tpl from resource plugin Well we may have to use urlencode instead of trying to get the filename. preg_match and preg_split are get what we want but are much slower. repeated 100,000 times:
urlencode(basename($string));              --> 2.920 secs
preg_match('![^:|/\\\\$]!',$string,$match); --> 7.627 secs explode(':',basename($string)); --> 5.436 secs The second two get it right, but they take much longer. Unless there are any other ideas? Monte Gary Loescher wrote:
Yup, sure is.
-----Original Message----- From: Monte Ohrt [mailto:monte@ispi.net] Sent: Tuesday, July 16, 2002 8:29 AM To: Gary Loescher Cc: smarty-dev@lists.php.net Subject: Re: [SMARTY-DEV] Trouble compiling tpl from resource plugin $_filename is supposed to be just the name of the file, no path. Is basename() leaving the "w:" part on there? Monte Gary Loescher wrote:
Hi folks, Smarty version: CVS on 7/15 Platform: Win2k I wrote a resource plugin with the same functionality as Smarty's "file" resource, so that later I can swap it for a database resource without changing the prefixes in my code (ie $smarty->display('site:index.tpl') ). The problem I was having was with compiling templates. Smarty was producing compiled files with 0 bytes and names that looked like "site", with no template name or extension. I tried it with the db plugin, and it did the same thing. It seems to be happening in _get_auto_filename. The colon is causing Windows to choke. My solution was to urlencode the filename, here: // prepend N in case crc32 was negative to avoid possible // OS issues with directory names starting with a "-" $_crc32 = 'N' . substr($_crc32,0,3) . $_dir_sep . 'N'
. $_crc32;
$res .= $_crc32 . urlencode($_filename) . '.php';
                ^^^^^^^^^^^^^^^^^^^^^
It seems to work...anything wrong with this? Gary
-- Monte Ohrt <monte@ispi.net> Director of Technology, ispi Inc. -- Smarty Development Mailing List (http://smarty.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
-- Monte Ohrt <monte@ispi.net> Director of Technology, ispi Inc.
-- Monte Ohrt <monte@ispi.net> Director of Technology, ispi Inc.

« previous php.smarty.dev (#189) next »