     1: <?php
     2: /*************************************************************************************/
     3: /*                                                                                   */
     4: /*      Thelia                                                                       */
     5: /*                                                                                   */
     6: /*      Copyright (c) OpenStudio                                                     */
     7: /*  email : info@thelia.net                                                      */
     8: /*      web : http://www.thelia.net                                                  */
     9: /*                                                                                   */
    10: /*      This program is free software; you can redistribute it and/or modify         */
    11: /*      it under the terms of the GNU General Public License as published by         */
    12: /*      the Free Software Foundation; either version 3 of the License                */
    13: /*                                                                                   */
    14: /*      This program is distributed in the hope that it will be useful,              */
    15: /*      but WITHOUT ANY WARRANTY; without even the implied warranty of               */
    16: /*      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                */
    17: /*      GNU General Public License for more details.                                 */
    18: /*                                                                                   */
    19: /*      You should have received a copy of the GNU General Public License            */
    20: /*      along with this program. If not, see <http://www.gnu.org/licenses/>.     */
    21: /*                                                                                   */
    22: /*************************************************************************************/
    23:
    24: namespace Thelia\Log\Destination;
    25:
    26: use Thelia\Log\AbstractTlogDestination;
    27:
    28: class TlogDestinationHtml extends AbstractTlogDestination
    29: {
    30:     // Nom des variables de configuration
    31:     // ----------------------------------
    32:     const VAR_STYLE = "tlog_destinationhtml_style";
    33:     const VALEUR_STYLE_DEFAUT = "text-align: left; font-size: 12px; font-weight: normal; line-height: 14px; float: none; display:block; color: #000; background-color: #fff; font-family: Courier New, courier,fixed;";
    34:
    35:     private $style;
    36:
    37:     public function __construct()
    38:     {
    39:         parent::__construct();
    40:     }
    41:
    42:     public function configure()
    43:     {
    44:         $this->style = $this->getConfig(self::VAR_STYLE);
    45:     }
    46:
    47:     public function getTitle()
    48:     {
    49:         return "Affichage direct dans la page, en HTML";
    50:     }
    51:
    52:     public function getDescription()
    53:     {
    54:             return "Permet d'afficher les logs directement dans la page resultat, avec une mise en forme HTML.";
    55:     }
    56:
    57:     public function getConfigs()
    58:     {
    59:         return array(
    60:             new TlogDestinationConfig(
    61:                 self::VAR_STYLE,
    62:                 "Style d'affichage direct dans la page",
    63:                 "Vous pouvez aussi laisser ce champ vide, et créer un style \"tlog-trace\" dans votre feuille de style.",
    64:                 self::VALEUR_STYLE_DEFAUT,
    65:                 TlogDestinationConfig::TYPE_TEXTAREA
    66:             )
    67:         );
    68:     }
    69:
    70:     public function write(&$res)
    71:     {
    72:         $block = sprintf('<pre class="tlog-trace" style="%s">%s</pre>', $this->style, htmlspecialchars(implode("\n", $this->_logs)));
    73:
    74:         $this->InsertAfterBody($res, $block);
    75:     }
    76: }
    77: