Re: [SMARTY-DEV] Trouble compiling tpl from resource plugin
| From: | Monte Ohrt | Date: | Tue, 16 Jul 2002 14:31:38 +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-187@lists.php.net to get a copy of this message | ||
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 secspreg_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.-- Monte Ohrt <monte@ispi.net> Director of Technology, ispi Inc.-----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';-- 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^^^^^^^^^^^^^^^^^^^^^It seems to work...anything wrong with this? Gary