[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-doc-cvs
Subject:    [DOC-CVS] svn: /phd/trunk/ package.xml package_generic.xml phpdotnet/phd/Config.php phpdotnet/phd/Me
From:       Richard_Quadling <rquadling () php ! net>
Date:       2009-10-29 11:04:46
Message-ID: svn-rquadling-1256814286-290052-1834548856 () svn ! php ! net
[Download RAW message or body]

rquadling                                Thu, 29 Oct 2009 11:04:46 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=290052

Log:
Added VERBOSE_MISSING_ATTRIBUTES verbose level
Separated PhD verbose messages into informational and warnings
PhD verbose warning messages are coloured magenta
Added MediaManger->findFile() method to return full filename of required image
VERBOSE_MISSING_ATTRIBUTE message generated when missing one of the width/height attributes on imagedata
VERBOSE_MISSING_ATTRIBUTE message generated when missing alt attributes on mediaobject > imagedata

Changed paths:
    U   phd/trunk/package.xml
    U   phd/trunk/package_generic.xml
    U   phd/trunk/phpdotnet/phd/Config.php
    U   phd/trunk/phpdotnet/phd/MediaManager.php
    U   phd/trunk/phpdotnet/phd/Package/Generic/XHTML.php
    U   phd/trunk/phpdotnet/phd/functions.php


["svn-diffs-290052.txt" (text/x-diff)]

Modified: phd/trunk/package.xml
===================================================================
--- phd/trunk/package.xml	2009-10-29 10:58:02 UTC (rev 290051)
+++ phd/trunk/package.xml	2009-10-29 11:04:46 UTC (rev 290052)
@@ -59,6 +59,10 @@
   </stability>
   <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD \
Style</license>  <notes>
+    - Added VERBOSE_MISSING_ATTRIBUTES verbose level (Richard Quadling)
+    - Separated PhD verbose messages into informational and warnings (Richard \
Quadling) +    - PhD verbose warning messages are colored magenta (Richard Quadling)
+    - Added MediaManger->findFile() method to return full filename of required image \
                (Richard Quadling)
     - Added the --css option (Moacir)
     - Added the --forceindex option (Christian)
     - Fixed bug #45071 - Links to require/include(_once) not rendered (Moacir)

Modified: phd/trunk/package_generic.xml
===================================================================
--- phd/trunk/package_generic.xml	2009-10-29 10:58:02 UTC (rev 290051)
+++ phd/trunk/package_generic.xml	2009-10-29 11:04:46 UTC (rev 290052)
@@ -48,6 +48,8 @@
   <notes>
     - Implemented PEAR request #2390: RSS feeds for PEAR Dcumentation Index \
                (Christian)
     - Fixed bug #49925 - imagedata now supports width and/or depth (becomes width \
and/or height) (Richard Quadling) +    - VERBOSE_MISSING_ATTRIBUTE message generated \
when missing one of the width/height attributes on imagedata (Richard Quadling) +    \
- VERBOSE_MISSING_ATTRIBUTE message generated when missing alt attributes on \
mediaobject > imagedata (Richard Quadling)  </notes>

   <contents>

Modified: phd/trunk/phpdotnet/phd/Config.php
===================================================================
--- phd/trunk/phpdotnet/phd/Config.php	2009-10-29 10:58:02 UTC (rev 290051)
+++ phd/trunk/phpdotnet/phd/Config.php	2009-10-29 11:04:46 UTC (rev 290052)
@@ -28,11 +28,13 @@
         'output_dir'        => './output/',
         'intermediate_output_dir' => '.',
         'php_error_output'  => STDERR,
-        'php_error_color'   => '01;31',
+        'php_error_color'   => '01;31', // Red
         'user_error_output' => STDERR,
-        'user_error_color'  => '01;33',
+        'user_error_color'  => '01;33', // Yellow
         'phd_info_output'   => STDOUT,
-        'phd_info_color'    => '01;32',
+        'phd_info_color'    => '01;32', // Green
+        'phd_warning_output' => STDOUT,
+        'phd_warning_color' => '01;35', // Magenta
         'highlighter'       => 'phpdotnet\\phd\\Highlighter',
         'package'           => array(
             'Generic',

Modified: phd/trunk/phpdotnet/phd/MediaManager.php
===================================================================
--- phd/trunk/phpdotnet/phd/MediaManager.php	2009-10-29 10:58:02 UTC (rev 290051)
+++ phd/trunk/phpdotnet/phd/MediaManager.php	2009-10-29 11:04:46 UTC (rev 290052)
@@ -86,6 +86,30 @@
     protected function copyOver($filename, $newpath)
     {
         $fullpath = $this->output_dir . '/' . $newpath;
+        if ($fullfilename = $this->findFile($filename)) {
+            if (!$this->media_dir_exists) {
+                $dir = dirname($fullpath);
+                if (!file_exists($dir)) {
+                    mkdir($dir, 0777, true);
+                }
+                $this->media_dir_exists = true;
+            }
+
+            if (!copy($fullfilename, $fullpath)) {
+                trigger_error('Image could not be copied to : ' . $fullfilename, \
E_USER_WARNING); +            }
+        }
+    }//protected function copyOver(..)
+
+    /**
+    * Find the exact location of the file referenced with $filename
+    *
+    * @param string $filename Original filename
+    *
+    * @return string Exact location of the file referenced with $filename or False \
if file not found. +    */
+    public function findFile($filename)
+    {
         $sourcefilenames = array (
             // Original format where @LANG@ was part of phpdoc (ala peardoc).
             $this->relative_source_path . $filename,
@@ -99,26 +123,17 @@
         $foundfile = false;
         foreach($sourcefilenames as $fullfilename) {
             if (file_exists($fullfilename)) {
-
-                if (!$this->media_dir_exists) {
-                    $dir = dirname($fullpath);
-                    if (!file_exists($dir)) {
-                        mkdir($dir, 0777, true);
-                    }
-                    $this->media_dir_exists = true;
-                }
-
-                $foundfile = copy($fullfilename, $fullpath);
+                $foundfile = $fullfilename;
                 break;
             }
         }

         if (!$foundfile) {
-            trigger_error('Image does not exist: ' . $fullfilename, E_USER_WARNING);
-            return;
+            trigger_error('Image does not exist: ' . $filename, E_USER_WARNING);
         }

-    }//protected function copyOver(..)
+        return $foundfile;
+    }//protected function findFile(..)

 }//class MediaManager


Modified: phd/trunk/phpdotnet/phd/Package/Generic/XHTML.php
===================================================================
--- phd/trunk/phpdotnet/phd/Package/Generic/XHTML.php	2009-10-29 10:58:02 UTC (rev \
                290051)
+++ phd/trunk/phpdotnet/phd/Package/Generic/XHTML.php	2009-10-29 11:04:46 UTC (rev \
290052) @@ -1298,12 +1298,31 @@
     }
     public function format_imagedata($open, $name, $attrs) {
         $file    = $attrs[Reader::XMLNS_DOCBOOK]["fileref"];
-        $newpath = $this->mediamanager->handleFile($file);
-	$width   = isset($attrs[Reader::XMLNS_DOCBOOK]["width"]) ? ' width="' . \
                $attrs[Reader::XMLNS_DOCBOOK]["width"] . '"' : '';
-	$height  = isset($attrs[Reader::XMLNS_DOCBOOK]["depth"]) ? ' height="' . \
                $attrs[Reader::XMLNS_DOCBOOK]["depth"] . '"' : '';
-	$alt     = ($this->cchunk["mediaobject"]["alt"] !== false) ? ' ' . \
$this->cchunk["mediaobject"]["alt"] : ''; +        if ($newpath = \
$this->mediamanager->handleFile($file)) { +            $curfile = \
$this->mediamanager->findFile($file); +            $width   = \
isset($attrs[Reader::XMLNS_DOCBOOK]["width"]) ? 'width="' . \
$attrs[Reader::XMLNS_DOCBOOK]["width"] . '"' : ''; +            $height  = \
isset($attrs[Reader::XMLNS_DOCBOOK]["depth"]) ? 'height="' . \
$attrs[Reader::XMLNS_DOCBOOK]["depth"] . '"' : ''; +            $alt     = 'alt="' . \
($this->cchunk["mediaobject"]["alt"] !== false ? $this->cchunk["mediaobject"]["alt"] \
: basename($file)) . '"';

-        return '<img src="' . $newpath . '"' . $alt . $width . $height . ' />';
+            // Generate height and width when none are supplied.
+            if ('' === $width . $height) {
+                list(,,,$dimensions,,,,) = getimagesize($curfile);
+            } else {
+            	$dimensions = $width . ' ' . $height;
+            }
+
+            // Generate warnings when only 1 dimension supplied or alt is not \
supplied. +            if (!$width xor !$height) {
+                v('Missing ' . (!$width ? 'width' : 'height') . ' attribute for ' . \
$file, VERBOSE_MISSING_ATTRIBUTES); +            }
+            if (false === $this->cchunk["mediaobject"]["alt"]) {
+                v('Missing alt attribute for ' . $file, VERBOSE_MISSING_ATTRIBUTES);
+            }
+
+            return '<img src="' . $newpath . '" ' . $alt . ' ' . $dimensions . ' \
/>'; +        } else {
+            return '';
+        }
     }

     public function format_table($open, $name, $attrs, $props) {

Modified: phd/trunk/phpdotnet/phd/functions.php
===================================================================
--- phd/trunk/phpdotnet/phd/functions.php	2009-10-29 10:58:02 UTC (rev 290051)
+++ phd/trunk/phpdotnet/phd/functions.php	2009-10-29 11:04:46 UTC (rev 290052)
@@ -15,9 +15,10 @@
 define('VERBOSE_CHUNK_WRITING',          VERBOSE_TOC_WRITING           << 1);
 define('VERBOSE_NOVERSION',              VERBOSE_CHUNK_WRITING         << 1);
 define('VERBOSE_BROKEN_LINKS',           VERBOSE_NOVERSION             << 1);
+define('VERBOSE_MISSING_ATTRIBUTES',     VERBOSE_BROKEN_LINKS          << 1);

-define('VERBOSE_ALL',                    (VERBOSE_BROKEN_LINKS         << 1)-1);
-define('VERBOSE_DEFAULT',                \
(VERBOSE_ALL^(VERBOSE_PARTIAL_CHILD_READING|VERBOSE_CHUNK_WRITING|VERBOSE_NOVERSION|VERBOSE_BROKEN_LINKS)));
 +define('VERBOSE_ALL',                    (VERBOSE_MISSING_ATTRIBUTES   << 1)-1);
+define('VERBOSE_DEFAULT',                \
(VERBOSE_ALL^(VERBOSE_PARTIAL_CHILD_READING|VERBOSE_CHUNK_WRITING|VERBOSE_NOVERSION|VERBOSE_BROKEN_LINKS|VERBOSE_MISSING_ATTRIBUTES)));


 $olderrrep = error_reporting();
 error_reporting($olderrrep | VERBOSE_DEFAULT);
@@ -45,16 +46,19 @@
 /* {{{ The PhD errorhandler */
 function errh($errno, $msg, $file, $line, $ctx = null) {
     static $err = array(
+        // PHP Triggered Errors
         E_DEPRECATED                  => 'E_DEPRECATED',
         E_RECOVERABLE_ERROR           => 'E_RECOVERABLE_ERROR',
         E_STRICT                      => 'E_STRICT',
         E_WARNING                     => 'E_WARNING',
         E_NOTICE                      => 'E_NOTICE',

+        // User Triggered Errors
         E_USER_ERROR                  => 'E_USER_ERROR',
         E_USER_WARNING                => 'E_USER_WARNING',
         E_USER_NOTICE                 => 'E_USER_NOTICE',

+        // PhD informationals
         VERBOSE_INDEXING              => 'VERBOSE_INDEXING',
         VERBOSE_FORMAT_RENDERING      => 'VERBOSE_FORMAT_RENDERING',
         VERBOSE_THEME_RENDERING       => 'VERBOSE_THEME_RENDERING',
@@ -63,8 +67,11 @@
         VERBOSE_PARTIAL_CHILD_READING => 'VERBOSE_PARTIAL_CHILD_READING',
         VERBOSE_TOC_WRITING           => 'VERBOSE_TOC_WRITING',
         VERBOSE_CHUNK_WRITING         => 'VERBOSE_CHUNK_WRITING',
+
+        // PhD warnings
         VERBOSE_NOVERSION             => 'VERBOSE_NOVERSION',
         VERBOSE_BROKEN_LINKS          => 'VERBOSE_BROKEN_LINKS',
+        VERBOSE_MISSING_ATTRIBUTES    => 'VERBOSE_MISSING_ATTRIBUTES',
     );
     static $recursive = false;

@@ -92,13 +99,19 @@
         case VERBOSE_PARTIAL_CHILD_READING:
         case VERBOSE_TOC_WRITING:
         case VERBOSE_CHUNK_WRITING:
-        case VERBOSE_NOVERSION:
-        case VERBOSE_BROKEN_LINKS:
             $color = Config::phd_info_color();
             $output = Config::phd_info_output();
             $data = $msg;
             break;

+        case VERBOSE_NOVERSION:
+        case VERBOSE_BROKEN_LINKS:
+        case VERBOSE_MISSING_ATTRIBUTES:
+            $color = Config::phd_warning_color();
+            $output = Config::phd_warning_output();
+            $data = $msg;
+            break;
+
         // User triggered errors
         case E_USER_ERROR:
         case E_USER_WARNING:



-- 
PHP Documentation Commits Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic