svn: /phd/trunk/ package.xml phpdotnet/phd/MediaManager.php phpdotnet/phd/Package/Generic/XHTML.php

From: Date: Thu, 05 Nov 2009 11:29:11 +0000
Subject: svn: /phd/trunk/ package.xml phpdotnet/phd/MediaManager.php phpdotnet/phd/Package/Generic/XHTML.php
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-5277@lists.php.net to get a copy of this message
rquadling Thu, 05 Nov 2009 11:29:11 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=290248 Log: MediaManager->findFile() can now fallback to the English translation for a missing file. Changed paths: U phd/trunk/package.xml U phd/trunk/phpdotnet/phd/MediaManager.php U phd/trunk/phpdotnet/phd/Package/Generic/XHTML.php Modified: phd/trunk/package.xml =================================================================== --- phd/trunk/package.xml 2009-11-05 11:28:44 UTC (rev 290247) +++ phd/trunk/package.xml 2009-11-05 11:29:11 UTC (rev 290248) @@ -59,6 +59,7 @@ </stability> <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD Style</license> <notes> + - Added fallback option to find English files when unable to find translated files (Richard Quadling) - Added VERBOSE_ERRORS, VERBOSE_INFO and VERBOSE_WARNINGS to group verbose levels (Richard Quadling) - Added VERBOSE_MISSING_ATTRIBUTES verbose level (Richard Quadling) - Separated PhD verbose messages into informational and warnings (Richard Quadling) Modified: phd/trunk/phpdotnet/phd/MediaManager.php =================================================================== --- phd/trunk/phpdotnet/phd/MediaManager.php 2009-11-05 11:28:44 UTC (rev 290247) +++ phd/trunk/phpdotnet/phd/MediaManager.php 2009-11-05 11:29:11 UTC (rev 290248) @@ -98,38 +98,48 @@ if (!copy($fullfilename, $fullpath)) { trigger_error('Image could not be copied to : ' . $fullfilename, E_USER_WARNING); } + } else { + trigger_error("Image does not exist : $filename", E_USER_WARNING); } }//protected function copyOver(..) /** * Find the exact location of the file referenced with $filename * - * @param string $filename Original filename + * If the file cannot be found using the supplied filename, which may be + * based upon a specific language, then fallback to the English translation. * + * @param string $filename Original filename + * @param boolean $allowfallback If the required file cannot be found then fallback to English + * * @return string Exact location of the file referenced with $filename or False if file not found. */ - public function findFile($filename) + public function findFile($filename, $allowfallback = true) { $sourcefilenames = array ( // Original format where @LANG@ was part of phpdoc (ala peardoc). - $this->relative_source_path . $filename, + array('', $filename), // Where phpdoc/modules/doc-@LANG@ is used. - $this->relative_source_path . '../' . $filename, + array('../', $filename), // Where phpdoc/doc-base/trunks and phpdoc/en/trunk are used. - $this->relative_source_path . '../../' . substr($filename, 0, strpos($filename, '/', 1)) . '/trunk' . substr($filename, strpos($filename, '/', 1)), + array('../../', (substr($filename, 0, strpos($filename, '/', 1)) . '/trunk' . substr($filename, strpos($filename, '/', 1)))), ); + $foundfile = false; - foreach($sourcefilenames as $fullfilename) { - if (file_exists($fullfilename)) { - $foundfile = $fullfilename; + foreach($sourcefilenames as $pathoffset => $filenameinfo) { + // Look for current language specific file. + if (file_exists($testingfile = $this->relative_source_path . $filenameinfo[0] . $filenameinfo[1])) { + $foundfile = $testingfile; break; } - } - if (!$foundfile) { - trigger_error('Image does not exist: ' . $filename, E_USER_WARNING); + // Fallback to English version. + if ($allowfallback && file_exists($testingfile = $this->relative_source_path . $filenameinfo[0] . 'en' . substr($filenameinfo[1], strpos($filenameinfo[1], '/')))) { + $foundfile = $testingfile; + break; + } } return $foundfile; Modified: phd/trunk/phpdotnet/phd/Package/Generic/XHTML.php =================================================================== --- phd/trunk/phpdotnet/phd/Package/Generic/XHTML.php 2009-11-05 11:28:44 UTC (rev 290247) +++ phd/trunk/phpdotnet/phd/Package/Generic/XHTML.php 2009-11-05 11:29:11 UTC (rev 290248) @@ -1305,7 +1305,7 @@ $alt = 'alt="' . ($this->cchunk["mediaobject"]["alt"] !== false ? $this->cchunk["mediaobject"]["alt"] : basename($file)) . '"'; // Generate height and width when none are supplied. - if ('' === $width . $height) { + if ($curfile && '' === $width . $height) { list(,,,$dimensions,,,,) = getimagesize($curfile); } else { $dimensions = $width . ' ' . $height;

« previous php.doc.cvs (#5277) next »