logo       

Re: Problem with view helper paths: msg#00110

php.zend.framework.mvc

Subject: Re: Problem with view helper paths

Janimatti Ellonen kirjoitti:
Hi!


$path = $this->getHelperPaths();
print_r($paths);

prints:


Array
(
[Zend_View_Helper_] => Array
(
[0] => Zend/View/Helper/
[1] => /usr/local/apache2/htdocs/xxxx/application/views/helpers/
[2] => /usr/local/apache2/htdocs/xxxx/application/views/helpers/mildola/
[3] => /usr/local/apache2/htdocs/xxxx/application/views/helpers/template/
[4] => /usr/local/apache2/htdocs/xxxx/application/views/helpers/roles/
[5] => /usr/local/apache2/htdocs/xxxx/application/views/helpers/categories/
[6] => /usr/local/apache2/htdocs/xxxx/application/views/helpers/languages/
[7] => /usr/local/apache2/htdocs/xxxx/application/views/helpers/versions/
[8] => /usr/local/apache2/htdocs/xxxx/application/views/helpers/processindicator/
)

[Image_View_Helper_] => Array
(
[0] => /usr/local/apache2/htdocs/xxxx/application/module/image/views/helpers/
)

)


Now when I try to use $this->language(); // helper resides in /usr/local/apache2/htdocs/xxxx/application/views/helpers/

I get:

'Exception' with message 'fopen(/usr/local/apache2/htdocs/xxx/application/module/image/views/helpers/Language.php) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: No such file or directory'

I assumed that zf would search through all set paths before complaining. Now it seems to just the last path, which is set automatically as I have not set it myself anywhere.



The following piece of code seems to solve the problem. Actually I used the same code when I hade the same problem with 1.5.0PR.

Current version of method in Zend_Loader (1.5.2) which makes my app go bonkers:

public static function isReadable($filename)
{
if (!$fh = @fopen($filename, 'r', true)) {
return false;
}

return true;
}

My version, which keeps my app happy:

public static function isReadable($filename)
{
if (@is_readable($filename)) {
return true;
}

$path = get_include_path();
$dirs = explode(PATH_SEPARATOR, $path);

foreach ($dirs as $dir) {
if ('.' == $dir || '..' == $dir) {
continue;
}

if (@is_readable($dir . DIRECTORY_SEPARATOR . $filename)) {
return true;
}
}

return false;
}

- - -

Janimatti Ellonen



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise