PHP Script
No comment
Download Count: 128
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.181 seconds - Rate: 17.21 KB/s - GeSHi version: 1.0.8.10
Hope you find this helpful! If you have any questions, please leave a comment.