Laurent Destailleur 8 anni fa
parent
commit
05fe0d7fcd
2 ha cambiato i file con 42 aggiunte e 25 eliminazioni
  1. 19 11
      htdocs/includes/odtphp/Segment.php
  2. 23 14
      htdocs/includes/odtphp/odf.php

+ 19 - 11
htdocs/includes/odtphp/Segment.php

@@ -1,14 +1,16 @@
 <?php
 require 'SegmentIterator.php';
 class SegmentException extends Exception
-{}
+{
+}
+
 /**
  * Class for handling templating segments with odt files
  * You need PHP 5.2 at least
  * You need Zip Extension or PclZip library
  *
- * @copyright  GPL License 2008 - Julien Pauli - Cyril PIERRE de GEYER - Anaska (http://www.anaska.com)
- * @copyright  GPL License 2012 - Stephen Larroque - lrq3000@gmail.com
+ * @copyright  2008 - Julien Pauli - Cyril PIERRE de GEYER - Anaska (http://www.anaska.com)
+ * @copyright  2012 - Stephen Larroque - lrq3000@gmail.com
  * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
  * @version 1.4.5 (last update 2013-04-07)
  */
@@ -22,11 +24,13 @@ class Segment implements IteratorAggregate, Countable
 	protected $images = array();
 	protected $odf;
 	protected $file;
+	
     /**
      * Constructor
      *
-     * @param string $name name of the segment to construct
-     * @param string $xml XML tree of the segment
+     * @param string $name  name of the segment to construct
+     * @param string $xml   XML tree of the segment
+     * @param string $odf   odf
      */
     public function __construct($name, $xml, $odf)
     {
@@ -152,10 +156,11 @@ class Segment implements IteratorAggregate, Countable
         
         return $this->xmlParsed;
     }
+    
     /**
      * Analyse the XML code in order to find children
      *
-     * @param string $xml
+     * @param string $xml   Xml
      * @return Segment
      */
     protected function _analyseChildren($xml)
@@ -172,11 +177,14 @@ class Segment implements IteratorAggregate, Countable
         }
         return $this;
     }
+    
     /**
      * Assign a template variable to replace
      *
-     * @param string $key
-     * @param string $value
+     * @param string $key       Key
+     * @param string $value     Value
+     * @param string $encode    Encode
+     * @param string $charset   Charset
      * @throws SegmentException
      * @return Segment
      */
@@ -230,7 +238,7 @@ IMG;
     /**
      * Shortcut to retrieve a child
      *
-     * @param string $prop
+     * @param string $prop      Prop
      * @return Segment
      * @throws SegmentException
      */
@@ -245,8 +253,8 @@ IMG;
     /**
      * Proxy for setVars
      *
-     * @param string $meth
-     * @param array $args
+     * @param string $meth      Meth
+     * @param array $args       Args
      * @return Segment
      */
     public function __call($meth, $args)

+ 23 - 14
htdocs/includes/odtphp/odf.php

@@ -1,16 +1,20 @@
 <?php
+
 require 'Segment.php';
+
 class OdfException extends Exception
-{}
+{
+}
+
 /**
  * Templating class for odt file
  * You need PHP 5.2 at least
  * You need Zip Extension or PclZip library
  *
- * @copyright  GPL License 2008 - Julien Pauli - Cyril PIERRE de GEYER - Anaska (http://www.anaska.com)
- * @copyright  GPL License 2010-2015 - Laurent Destailleur - eldy@users.sourceforge.net
- * @copyright  GPL License 2010 - Vikas Mahajan - http://vikasmahajan.wordpress.com
- * @copyright  GPL License 2012 - Stephen Larroque - lrq3000@gmail.com
+ * @copyright  2008 - Julien Pauli - Cyril PIERRE de GEYER - Anaska (http://www.anaska.com)
+ * @copyright  2010-2015 - Laurent Destailleur - eldy@users.sourceforge.net
+ * @copyright  2010 - Vikas Mahajan - http://vikasmahajan.wordpress.com
+ * @copyright  2012 - Stephen Larroque - lrq3000@gmail.com
  * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
  * @version 1.5.0
  */
@@ -43,7 +47,8 @@ class Odf
 	/**
 	 * Class constructor
 	 *
-	 * @param string $filename the name of the odt file
+	 * @param string $filename     The name of the odt file
+	 * @param string $config       Array of config data
 	 * @throws OdfException
 	 */
 	public function __construct($filename, $config = array())
@@ -116,9 +121,10 @@ class Odf
 	/**
 	 * Assing a template variable
 	 *
-	 * @param string $key name of the variable within the template
-	 * @param string $value replacement value
-	 * @param bool $encode if true, special XML characters are encoded
+	 * @param string   $key        Name of the variable within the template
+	 * @param string   $value      Replacement value
+	 * @param bool     $encode     If true, special XML characters are encoded
+	 * @param string   $charset    Charset  
 	 * @throws OdfException
 	 * @return odf
 	 */
@@ -129,7 +135,7 @@ class Odf
 		// <text:span text:style-name="T13">{</text:span><text:span text:style-name="T12">aaa</text:span><text:span text:style-name="T13">}</text:span>
 		// instead of {aaa} so we should enhance this function.
 		//print $key.'-'.$value.'-'.strpos($this->contentXml, $this->config['DELIMITER_LEFT'] . $key . $this->config['DELIMITER_RIGHT']).'<br>';
-		if (strpos($this->contentXml, $tag) === false && strpos($this->stylesXml , $tag) === false) {
+		if (strpos($this->contentXml, $tag) === false && strpos($this->stylesXml, $tag) === false) {
 			//if (strpos($this->contentXml, '">'. $key . '</text;span>') === false) {
 			throw new OdfException("var $key not found in the document");
 			//}
@@ -577,6 +583,7 @@ IMG;
 		}
 		else
 		{
+		    dol_syslog(get_class($this).'::exportAsAttachedPDF is used but the constant MAIN_DOL_SCRIPTS_ROOT with path to script directory was not defined.', LOG_WARNING);
 			$command = '../../scripts/odt2pdf/odt2pdf.sh '.escapeshellcmd($name).' '.(is_numeric($conf->global->MAIN_ODT_AS_PDF)?'jodconverter':$conf->global->MAIN_ODT_AS_PDF);
 		}
 
@@ -642,7 +649,8 @@ IMG;
 	/**
 	 * Returns a variable of configuration
 	 *
-	 * @return string The requested variable of configuration
+	 * @param  string  $configKey  Config key
+	 * @return string              The requested variable of configuration
 	 */
 	public function getConfig($configKey)
 	{
@@ -678,7 +686,8 @@ IMG;
 
 	/**
 	 * Empty the temporary working directory recursively
-	 * @param $dir the temporary working directory
+	 * 
+	 * @param  string  $dir    The temporary working directory
 	 * @return void
 	 */
 	private function _rrmdir($dir)
@@ -701,8 +710,8 @@ IMG;
 	/**
 	 * return the value present on odt in [valuename][/valuename]
 	 * 
-	 * @param  string $value   name balise in the template
-	 * @return string          the value inside the balise
+	 * @param  string $valuename   Balise in the template
+	 * @return string              The value inside the balise
 	 */
 	public function getvalue($valuename)
 	{