<?php
/**
 * Simple Zend_Loader aware wrapper around GeSHi syntax highlighter
 *
 * @package Library
 * @author Miroslav Kubelik (koubel@volny.cz)
 * @copyright Copyright (c) 2007-2009 Miroslav Kubelik
 * @license http://opensource.org/licenses/gpl-license.php GNU GPL
 */
/**
 * the file with main geshi code
 */
require_once "geshi.php";
/**
 * Wrapper around around GeSHi syntax highlighter, it is Zend_Loader aware.
 *
 * @package Library
 * @author Miroslav Kubelik (koubel@volny.cz)
 * @copyright Copyright (c) 2007-2009 Miroslav Kubelik
 * @license http://opensource.org/licenses/gpl-license.php GNU GPL
 */
class GeSHi_HighLighter {

    /**
     * main geshi class
     * @var GeSHi
     */
    private $_geshi;

    /**
     * Initializes main geshi class for the specific $lang syntax
     * @param string $lang language identifier, which is supported by geshi
     */
    public function __construct($lang) {
        $this->_geshi = new GeSHi("", $lang);
        $this->_geshi->set_language_path(realpath(dirname(__FILE__) . "/langFiles"));
        $this->_geshi->set_encoding('utf-8');
        $this->_geshi->enable_classes();
        $this->_geshi->set_header_type(GESHI_HEADER_PRE);
        $this->_geshi->set_overall_class("codeOutput $lang");
    }

    /**
     * returns highlighted code
     * @param string $src source code
     * @return string
     */
    public function getHighlightedCode($src) {
        $this->_geshi->set_source($src);
        return $this->_geshi->parse_code();
    }
}
