Location: PHPKode > projects > ColGUI > ColGUI Alpha 1/wp-content/plugins/wordpressGUI.php
<?php
/*
Plugin Name: ColGUI
Plugin URI: http://www.ideaflux.net
Description: A plugin that allows remote collaboration on GUI design
Version: 0.1(alpha - unstable)
Author: Alexei Samoylov
Author URI: http://www.ideaflux.net
*/

/*  Copyright 2006  Alexei Samoylov  (email : hide@address.com)

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

// !!! Don't forget to use modified wp-admin/quicktags.js (it adds the glade tag button to admin posts page) !!!
// !!! In wordpress 2.0 the quicktags file is located in wp-includes/js !!!

// declare all variables needed for the parser
    $oneBigString='';
    $totalX = 0;
    $totalY = 0;
    $maxX = 600;
    $maxY = 480;
    $widthRequest = 0;
    $heightRequest = 0;
    $largestPackingNode;
    // end declaration

// function to embed the gui output right into the post structure
// not used anywhere at the moment
function want_to_fly() {
    echo 'I am not used <br />'; // executed after loading of EVERY single page (right before the </body> tag)
}

// not used anywhere at the moment
function want_to_post($postNum) {
    echo 'I am not used'; //<script language="Javascript"> alert("I want to comment aye aye aye") <\/script>');
}

// not used anywhere at the moment
function add_to_comment_box($spots) {
    echo '<button id="hammsdfm" type="button">lanfren'.$spots.'</button>';
}

//add_action('wp_footer', 'want_to_fly');
//add_action('publish_post', 'want_to_post');
//add_action('comment_form', 'add_to_comment_box');  // will display in the "comments" section under the 'reply' box
//add_action('comment_post', 'add_to_comment_box');  // will display in the "comments" section under the 'reply' box


// Filters
function clone_in_postText($comment = '') {

    // we're using all of these globally
    global $oneBigString;
    global $totalX;
    global $totalY;
    global $maxX;
    global $maxY;
    global $widthRequest;
    global $heightRequest;
    global $largestPackingNode;
    
     $oneBigString='';
	 $totalX = 0;
	 $totalY = 0;
	 $maxX = 600;
	 $maxY = 480;
	 $widthRequest = 0;
	 $heightRequest = 0;
	 $largestPackingNode = NULL;
    
    // find the beginning and end of a <glade> tag if one exists
	$start = stripos($comment, '<glade');
	$stop = stripos($comment, '/>', $start);
    
    // split the comment into two parts (before and after the file location)
    $precomment = substr($comment, 0, $start);  //string substr ( string string, int start [, int length] )
    $postcomment = substr($comment, $stop+2);
    
	if ($start !== false) {
		$fileLocation = substr($comment, $start+8, $stop-$start-9);
        
        // -- dreamhost loading implementation --
        $ch = curl_init();
        $timeout = 5; // set to zero for no timeout
        curl_setopt ($ch, CURLOPT_URL, $fileLocation);
        curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
        $file_contents = curl_exec($ch);
        curl_close($ch);
        // -- end dreamhost loading implementation --
        
		
		//add html rendered forms here (parser)
		require_once("gladeToJS/gladeNoJStest.php");
		mainDocProcess($file_contents);            // this function is found inside gladeNoJStest.php
		$comment=$comment.$oneBigString;           // add the processed string to whatever other comments have been retrieved by wordpress
        
        if (stripos($_SERVER["REQUEST_URI"], '?p=')) {                // determine if this is the contents page (do not include clone button unless it is)
            $fieldId = str_ireplace('.glade', '', basename($fileLocation));
            $submitString = 'gladeToJS/gladeToJS.php?userfile='.$fileLocation.'&MAX_FILE_SIZE=300000';
            $comment = $comment.'<br />
            <script type="text/javascript" src="wp-content/plugins/wordpressGUI.js"></script>
            <input type="hidden" name="submitString" id="'.$fieldId.'" value="'.$submitString.'" />
            <input type="button" name="Clone'.$fieldId.'" value="Clone" onclick="submitGladeXML(\''.$fieldId.'\');"/>';  // include a clone button
        }
	}

    return $comment;        // modified comment is returned to Wordpress for rendering
}

// this is how we hook into Wordpress and add our filter to both, the front page and the comments page
add_filter('comment_text', 'clone_in_postText');
add_filter('the_content', 'clone_in_postText');


/*
source of UNTEXTURIZE Plugin

Copyright (c) 2004, Scott Reilly
Released under the BSD License
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following
conditions are met:
   
     * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
     * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided with the distribution.
     * Neither the name of coffee2code.com nor the names of its contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

function gladeuntexturize($text) {
    $text = str_replace('&#8212;', '---', $text);
    $text = str_replace(' &#8212; ', ' -- ', $text);
    $text = str_replace('&#8211;', '--', $text);

    $text = str_replace('&#8216;', "'", $text);
    $text = str_replace('&#8217;', "'", $text);
    $text = str_replace('&#8220;', '"', $text);
    $text = str_replace('&#8221;', '"', $text);
    return $text;
} // end gladeuntexturize()

add_filter('comment_text', 'gladeuntexturize',11);
add_filter('single_post_title', 'gladeuntexturize',11);
add_filter('the_title', 'gladeuntexturize',11);
add_filter('the_content', 'gladeuntexturize',11);
add_filter('the_excerpt', 'gladeuntexturize',11);
Return current item: ColGUI