php PHP Script
Download GeSHi Code Highlighter plugin for PyroCMSDownload GeSHi Code Highlighter plugin for PyroCMS
Download Count: 114
Date Added: Monday, 04-Jul-11 03:14:56 CDT
Tags: geshi, pyrocms, php, codeigniter

This is a plugin for PyroCMS that will allow users to enable GeSHi Highlighting on their pages without the need of setting up hooks to pre-process everything, wasting valuable resources.

To use this plugin, you first need to follow these steps to setup GeSHi with PyroCMS/CodeIgniter. After you have GeSHi setup, place the geshi plugin file in your PyroCMS addons/plugin folder and you're all set to go

To use the plugin, add this tag to your page:

{{ geshi:code title="Test" language="php"}
Your Code Goes Here!!
{/pyro:geshi:code }}

And to show contents of a source file(make sure to use the full path to the file):

{{ geshi:file path="absolute path to file" title="file name" language="bash" }}

Hope you find this useful!

File Name: geshi.php - Code Type: PHP
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
 * This is a Geshi Code Highlighter plugin for PyroCMS
 *
 * @author              Larry Price
 * @website             http://www.lfwebpro.com
 * @package     Geshi Code Highlighter Plugin
 * @version             1.0
 *
 */
class Plugin_Geshi extends Plugin
{
        /**
         * function code()
         * Usage:
         * For highlighting code in document
         * {pyro:geshi:code title="Test" language="php"}
         *        //Your Code here
         * {/pyro:geshi:code}
         *
         * @return      string
         */
        function code()
        {
                $this->load->library('geshi');
                $language       = $this->attribute('language');
                $title      = $this->attribute('title');
                $source         = $this->content();
                
                $geshi = new GeSHi($source, $language);
                $geshi->enable_classes();
                $geshi->set_overall_style('font-size:12px; padding:10px; color: #000000; border: 3px solid #666; width: 625px; background-color: #f9f9f9; margin: 0 0 1.5em 0;  overflow: auto;', true);
                $geshi->set_header_content($title);
                $geshi->set_header_content_style('font-family: Verdana, Arial, sans-serif; color: #808080; font-size: 70%; font-weight: bold; background-color: #f0f0ff; border-bottom: 1px solid #d0d0d0; padding: 2px;');
                $geshi->set_footer_content('Parsed in <TIME> seconds,  using GeSHi <VERSION>');
                $geshi->set_footer_content_style('font-family: Verdana, Arial, sans-serif; color: #808080; font-size: 70%; font-weight: bold; background-color: #f0f0ff; border-top: 1px solid #d0d0d0; padding: 2px;');
                $geshi->set_header_type(GESHI_HEADER_PRE_TABLE);
                
                $html = "";
                $html .= "<style type=\"text/css\"><!--";
                $html .= $geshi->get_stylesheet(); 
                $html .= "// --></style>";
                $html .= $geshi->parse_code();
                return $html;
 
        }   
        
        /**
         * function file()
         * Usage:
         * For highlighting code straight from file
         * {pyro:geshi:file path="absolute path to file" title="file name" language="php"}
     *
         * @return      string
         */             
        function file()
        {
                $this->load->library('geshi');
                $this->load->helper('file');
                
                $language       = $this->attribute('language');
                $title      = $this->attribute('title');
                $path       = $this->attribute('path');
                
                $source = read_file($path);
                
                $geshi = new GeSHi($source, $language);
                $geshi->enable_classes();
                $geshi->set_overall_style('font-size:10px; padding:10px; color: #000000; border: 3px solid #666; width: 625px; background-color: #f9f9f9; margin: 0 0 1.5em 0;  overflow: auto;', true);
                $geshi->set_header_content($title);
                $geshi->set_header_content_style('font-family: Verdana, Arial, sans-serif; color: #808080; font-size: 70%; font-weight: bold; background-color: #f0f0ff; border-bottom: 1px solid #d0d0d0; padding: 2px;');
                $geshi->set_footer_content('Parsed in <TIME> seconds,  using GeSHi <VERSION>');
                $geshi->set_footer_content_style('font-family: Verdana, Arial, sans-serif; color: #808080; font-size: 70%; font-weight: bold; background-color: #f0f0ff; border-top: 1px solid #d0d0d0; padding: 2px;');
                $geshi->set_header_type(GESHI_HEADER_PRE_TABLE);
                
                $html = "";
                $html .= "<style type=\"text/css\"><!--";
                $html .= $geshi->get_stylesheet(); 
                $html .= "// --></style>";
                $html .= $geshi->parse_code();
                return $html;
 
        }       
 
}
 
/* End of file geshi.php */
Parsed in 0.218 seconds - Rate: 14.33 KB/s - GeSHi version: 1.0.8.10

Hope you find this helpful! If you have any questions, please leave a comment.


  • PHP
  • Scripts
  • MS
  • Office
  • Templates
  • and
  • Files
  • Assorted
  • Linux
  • Bash
  • Scripts
  • Perl
  • Scripts
  • PDF
  • FIles
  • MS
  • Excel
  • 2003
  • Template
  • employment
  • tools
  • job
  • search
  • tools
  • spreadsheet
  • Job
  • Search
  • Spreadsheet
  • Template
  • bash
  • shell
  • script
  • file
  • backup
  • linux
  • gzip
  • tar
  • File
  • Backup
  • Script
  • Transmission
  • shell
  • script
  • public
  • torrent
  • private
  • torrent
  • Bit
  • Torrent
  • Transmission
  • BitTorrent
  • Completion
  • Script
  • Transmission
  • shell
  • script
  • torrent
  • information
  • Bit
  • Torrent
  • Transmission
  • Bit
  • Torrent
  • Get
  • Torrent
  • Info
  • bash
  • shell
  • script
  • add
  • user
  • samba
  • samba
  • user
  • add
  • samba
  • user
  • linux
  • command
  • line
  • Add
  • System
  • and
  • Samba
  • User
  • geshi
  • pyrocms
  • php
  • codeigniter
  • PyroCMS/CodeIgniter
  • Geshi
  • Helper
  • File
  • geshi
  • pyrocms
  • php
  • codeigniter
  • GeSHi
  • Code
  • Highlighter
  • plugin
  • for
  • PyroCMS
  • perl
  • cgi
  • hit
  • counter
  • Simple
  • Perl
  • Hit
  • Counter
  • pyrocms
  • codeigniter
  • php
  • ip
  • address
  • session
  • userdata
  • PyroCMS
  • IP
  • Address
  • Plugin
  • Soyo
  • SY5SSM
  • Socket
  • 7
  • Motherboard
  • Quick
  • Start
  • Guide
  • Soyo
  • SY5SSM
  • Socket
  • 7
  • Motherboard
  • Quick
  • Start
  • Guide
  • Home
  • web
  • designit
  • supportlinuxphpbash
  • PRIVACY
  • Statement
  • LEGAL
  • Disclaimer
  • Ebay
  • Listings
  • Soyo
  • Motherboard
  • PDF
  • Why
  • I
  • Like
  • the
  • HoneyPi
  • Brand
  • IR
  • Receiver
  • Module
  • for
  • the
  • Raspberry
  • Pi
  • Using
  • GeSHi
  • Highlighter
  • with
  • PyroCMS/CodeIgniter
  • Easy
  • as
  • 1
  • 2
  • 3
  • PHP
  • Stuff
  • Raspberry
  • PI