"Fossies" - the Fresh Open Source Software Archive

Member "Upload/inc/3rdparty/diff/Diff/Renderer/Unified/Colored.php" (8 Jun 2019, 1837 Bytes) of package /linux/www/mybb_1821.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 <?php
    2 /**
    3  * Copyright 2017 Horde LLC (http://www.horde.org/)
    4  *
    5  * See the enclosed file COPYING for license information (LGPL). If you did
    6  * not receive this file, see http://www.horde.org/licenses/lgpl21.
    7  *
    8  * @author   Jan Schneider <jan@horde.org>
    9  * @category Horde
   10  * @license  http://www.horde.org/licenses/lgpl21 LGPL
   11  * @package  Text_Diff
   12  */
   13 
   14 /**
   15  * "Unified" diff renderer with output coloring.
   16  *
   17  * @author    Jan Schneider <jan@horde.org>
   18  * @category  Horde
   19  * @copyright 2017 Horde LLC
   20  * @license   http://www.horde.org/licenses/lgpl21 LGPL
   21  * @package   Text_Diff
   22  */
   23 
   24 // Disallow direct access to this file for security reasons
   25 if(!defined("IN_MYBB"))
   26 {
   27     die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
   28 }
   29 
   30 class Horde_Text_Diff_Renderer_Unified_Colored
   31 extends Horde_Text_Diff_Renderer_Unified
   32 {
   33     /**
   34      * CLI handler.
   35      *
   36      * Contrary to the name, it supports color highlighting for HTML too.
   37      *
   38      * @var Horde_Cli
   39      */
   40     protected $_cli;
   41 
   42     /**
   43      * Constructor.
   44      */
   45     public function __construct($params = array())
   46     {
   47         if (!isset($params['cli'])) {
   48             throw new BadMethodCallException('CLI handler is missing');
   49         }
   50         parent::__construct($params);
   51         $this->_cli = $params['cli'];
   52     }
   53 
   54     protected function _blockHeader($xbeg, $xlen, $ybeg, $ylen)
   55     {
   56         return $this->_cli->color(
   57             'lightmagenta', parent::_blockHeader($xbeg, $xlen, $ybeg, $ylen)
   58         );
   59     }
   60 
   61     protected function _added($lines)
   62     {
   63         return $this->_cli->color(
   64             'lightgreen', parent::_added($lines)
   65         );
   66     }
   67 
   68     protected function _deleted($lines)
   69     {
   70         return $this->_cli->color(
   71             'lightred', parent::_deleted($lines)
   72         );
   73     }
   74 }