Overview

Packages

  • alpha::controller
  • alpha::controller::front
  • alpha::exceptions
  • alpha::model
  • alpha::model::types
  • alpha::tasks
  • alpha::tests
  • alpha::util
  • alpha::util::cache
  • alpha::util::codehighlight
  • alpha::util::convertors
  • alpha::util::feeds
  • alpha::util::filters
  • alpha::util::graphs
  • alpha::util::helpers
  • alpha::util::metrics
  • alpha::view
  • alpha::view::renderers
  • alpha::view::widgets

Classes

  • AlphaHighlightProviderFactory
  • AlphaHighlightProviderGeshi
  • AlphaHighlightProviderLuminous

Interfaces

  • AlphaHighlightProviderInterface
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
 1: <?php
 2: 
 3: /**
 4:  *
 5:  * Wraps Geshi in the standard API defined in AlphaHighlightProviderInterface, 
 6:  * for use in the Alpha CMS module.  Note that Geshi is not included in Alpha,
 7:  * so you will need to download it from here:
 8:  * 
 9:  * http://qbnz.com/highlighter/
10:  * 
11:  * Once downloaded, place in the [application]/lib/geshi directory which is where this class
12:  * will attempt to load it from.
13:  * 
14:  * @package alpha::util::codehighlight
15:  * @since 1.2
16:  * @author John Collins <dev@alphaframework.org>
17:  * @version $Id: AlphaHighlightProviderGeshi.inc 1496 2012-02-12 20:32:21Z alphadev $
18:  * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
19:  * @copyright Copyright (c) 2012, John Collins (founder of Alpha Framework).  
20:  * All rights reserved.
21:  * 
22:  * <pre>
23:  * Redistribution and use in source and binary forms, with or 
24:  * without modification, are permitted provided that the 
25:  * following conditions are met:
26:  * 
27:  * * Redistributions of source code must retain the above 
28:  *   copyright notice, this list of conditions and the 
29:  *   following disclaimer.
30:  * * Redistributions in binary form must reproduce the above 
31:  *   copyright notice, this list of conditions and the 
32:  *   following disclaimer in the documentation and/or other 
33:  *   materials provided with the distribution.
34:  * * Neither the name of the Alpha Framework nor the names 
35:  *   of its contributors may be used to endorse or promote 
36:  *   products derived from this software without specific 
37:  *   prior written permission.
38:  *   
39:  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
40:  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
41:  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
42:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
43:  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
44:  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
45:  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
46:  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
47:  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
48:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
49:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
50:  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
51:  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
52:  * </pre>
53:  *  
54:  */
55: class AlphaHighlightProviderGeshi implements AlphaHighlightProviderInterface {
56:     /**
57:      * (non-PHPdoc)
58:      * @see alpha/util/codehighlight/AlphaHighlightProviderInterface::highlight()
59:      * @since 1.2
60:      */
61:     public function highlight($source, $language) {
62:         global $config;
63:         
64:         $codeBlock = '';
65:         
66:         try {
67:             AlphaAutoLoader::loadLib('geshi.php');
68: 
69:             $geshi = new GeSHi($source, $language);
70:             $codeblock = $geshi->parse_code();
71:         }catch(LibraryNotInstalledException $e) {
72:             $codeblock = $source;
73:         }
74:         
75:         return $codeblock;
76:     }
77: }
78: ?>
Alpha Framework API Documentation API documentation generated by ApiGen 2.8.0