public function __construct($data = null, $debug = false)
 {
     if (is_null($data)) {
         $name = preg_replace('#^(sceau-)?(.*)$#', '$2', CertissimTools::normalizeName(get_class($this)));
         $this->setName($name);
     }
     if (is_string($data)) {
         $data = preg_replace('#^[ \\r\\n' . chr(13) . chr(10) . ']*#', '', $data);
         if (!SceauTools::isXMLstring($data)) {
             $msg = "La chaine \"{$data}\" n'est pas valide";
             SceauTools::insertLog(__METHOD__ . ' : ' . __LINE__, $msg);
             throw new Exception($msg);
         }
         $data = new SimpleXMLElement($data);
     }
     if (is_object($data) && get_class($data) == 'SimpleXMLElement') {
         $string = (string) $data;
         $this->name = $data->getName();
         $this->value = trim($string);
         foreach ($data->attributes() as $attname => $attvalue) {
             $this->attributes[$attname] = $attvalue;
         }
         foreach ($data->children() as $simplexmlelementchild) {
             $child = new SceauXMLElement($simplexmlelementchild);
             $this->addChild($child);
         }
     }
 }
 public function display()
 {
     if (Tools::isSubmit('action') && Tools::getValue('action') == 'viewLog') {
         //loads the log content
         $log_content = CertissimLogger::getLogContent();
         $log_txt = CertissimTools::convert_encoding($log_content, 'UTF-8');
         $url_back = 'index.php?tab=AdminModules&configure=fianetfraud&tab_module=payment_security&module_name=fianetfraud&token=' . Tools::getAdminTokenLite('AdminModules');
         echo "<center><a style='padding: 3px; margin: 6px; border: 1px solid black' href='" . $url_back . "'>" . $this->l('Back to configuration page') . "</a></center><textarea style='margin: 6px' cols='160' rows='50' readOnly>{$log_txt}</textarea><div class='clear'></div><center><a style='padding: 3px; margin: 6px; border: 1px solid black' href='" . $url_back . "'>" . $this->l('Back to configuration page') . "</a></center>";
     } else {
         echo parent::display();
     }
 }
 /**
  * updates a certissim order with the fields given as a paramater and returns true if success, false otherwiser
  * 
  * @param int $id_order id of the order to update
  * @param array $fields
  * @return boolean
  */
 public static function updateCertissimOrder($id_order, array $fields)
 {
     //if no fields to update, end of process
     if (empty($fields)) {
         CertissimLogger::insertLog(__METHOD__ . " : " . __LINE__, "Tableau de champs vide.");
         return false;
     }
     //initialization of the part of the SQL string that defines the updates
     $set_string = "";
     foreach ($fields as $fieldname => $fieldvalue) {
         $set_string .= "`{$fieldname}`='" . pSQL(CertissimTools::convert_encoding($fieldvalue, ini_get('default_charset'))) . "', ";
     }
     $set_string = substr($set_string, 0, -2);
     //removes the ', ' at the end of the string
     $sql = "UPDATE `" . _DB_PREFIX_ . self::CERTISSIM_ORDER_TABLE_NAME . "` SET {$set_string} WHERE `id_order`='{$id_order}'";
     //builds the total SQL string
     $updated = Db::getInstance()->execute($sql);
     //executes the SQL query
     if (!$updated) {
         CertissimLogger::insertLog(__METHOD__ . " : " . __LINE__, "Mise à jour échouée pour la requête : {$sql}");
     } else {
         CertissimLogger::insertLog(__METHOD__ . " : " . __LINE__, "Mise à jour OK pour la requête : {$sql}");
     }
     return $updated;
 }
	 * @return bool 
	 */
    public function isEmpty()
    {
        return ($this->getValue() == "" || is_null($this->getValue())) && $this->countChildren() == 0;
    }
    /**
	 * returns the current object child count
	 *
	 * @return int
	 */
    public function countChildren()
    {
        return count($this->children);
    }
    /**
	 * returns the current object as a SimpleXMLElement object
	 * 
	 * @param boolean $recursive allow to add children into the result
	 * @return SimpleXMLElement 
	 */
    public function toSimpleXMLElement($recursive = false)
    {
        $simplexlmelementobject = new SimpleXMLElement('<' . $this->getName() . '>' . $this->getValue() . '</' . $this->getName() . '>');
        foreach ($this->getAttributes() as $name => $value) {
            $simplexlmelementobject->addAttribute($name, $value);
        }
        if ($recursive) {
            $this->attachChildren($simplexlmelementobject);
        }
        return $simplexlmelementobject;
    }
    /**
	 * attaches all the children and their children of the current object to the object given in parameter
	 * 
	 * @param SimpleXMLElement $simplexmlelement
	 */
    public function attachChildren($simplexmlelement)
    {
        foreach ($this->getChildren() as $child) {
            $simplexmlelement_child = $simplexmlelement->addChild($child->getName(), $child->getValue());
            foreach ($child->getAttributes() as $name => $value) {
                $simplexmlelement_child->addAttribute($name, $value);
            }
            $child->attachChildren($simplexmlelement_child);
        }
    }
    /**