Recent Topics

1 Dec 02, 2007 11:16    

Ok, updated my site and it seems to have gone ok...
Some questions...
1. What is _mediaidx.disp.php ?
2. Why has .disp been added to all these things like arcdir etc etc.
3. What's changed that a plugin that worked in the previous beta now causes a major error on the plugins Admin page.
The plugin is _acronym.plugin.php

<?php
/**
 * This file implements the Beano's Acronym plugin for b2evolution
 *
 * b2evolution - {@link http://b2evolution.net/}
 * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
 *
 * Beano's Acronym Plugin (v0.1 alpha - 05/09/2006)
 * copyright  (c)2006 by Steve Ferson (http://www.steveferson.com)
 *
 */
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );


class acronym_plugin extends Plugin {
	var $code = 'b2acro';
	var $name = 'Acronyms';
	var $priority = 80;
	var $version = '1.8';
	var $apply_rendering = 'opt-out';

	/**
	 * Acronym search array (regex)
	 */
	var $search;

	/**
	 * Replace array
	 */
	var $replace;

	/**
	 * Acronym definitions
	 */
	var $acronyms;

	/**
	 * Acronym titles / explanations
	 */
	var $titles;

	/**
	 * Constructor
	 */
	function acronym_plugin() {
		$this->short_desc = T_('Acronym Explanations');
		$this->long_desc = T_('This renderer will convert groups of recognised initials (acronyms) in a post into HTML &lt;acronym&gt; elements with appropriate titles.');

		/**
		 * Acronym configuration.
		 * TODO: Store acronym/title pairs in database table
		 */
		require dirname(__FILE__).'/acronym_plugin/_conf.php';
	}


	/**
	 * Perform rendering
	 *
	 * @see Plugin::RenderItemAsHtml()
	 */
	function RenderItemAsHtml( & $params ) {
		if( ! isset( $this->search ) )	{	// We haven't prepared the acronyms yet
			$this->search = array();

			$tempacros = $this->acronyms;
			uksort($tempacros, array(&$this, 'orderbylength'));

			foreach($tempacros as $acronym => $desc) {
				$this->search[] = '/(\b)'. $acronym .'(\b)/';
				$this->replace[] = '$1<acronym title="'.$desc.'">'. $acronym .'</acronym>$2';
			}
		}


		// REPLACE:  But only in PCDATA, exclude text inside <code> and <pre> elements
		$content = & $params['data'];

		// Check if data contains <code> or <pre> elements
		if( stristr( $content, '<code' ) !== false || stristr( $content, '<pre' ) !== false )	{ 
			// Call ReplaceTagSafe() on everything outside <pre></pre> and <code></code>:
			$content = callback_on_non_matching_blocks( $content,
					'~<(code|pre)[^>]*>.*?</\1>~is',
					array( & $this, 'ReplaceTagSafe' ) );
		} else { // If there are no <code> or <pre> elements, it's safe to replace on the whole block of text
			$content = $this->ReplaceTagSafe($content);
		}

		return true;
	}


	/**
	 * This callback gets called once after every tags+text chunk
	 * @return string Text with replaced acronyms
	 */
	function preg_insert_acronyms_callback( $text )	{
		return preg_replace( $this->search, $this->replace, $text );
	}


	/**
	 * Replace acronyms outside HTML-tags in the text.
	 * @uses callback_on_non_matching_blocks()
	 */
	function ReplaceTagSafe($text) 	{
		return callback_on_non_matching_blocks( $text, '~<[^>]*>~', array(&$this, 'preg_insert_acronyms_callback') );
	}


	/**
	 * sorts the acronyms' array by length
	 * which allows greedy matching
	 * (ie will not match a 3 letter acronym if it's part of a 4 letter one)
	 */
	function orderbylength($a, $b) 	{
		if(($diff = strlen($b) - strlen($a)) == 0) {
			return strcmp($a, $b);
		}
		return $diff;
	}
}
?>

Cheers

2 Dec 02, 2007 11:44

1) From the file :

 * This is the template that displays the media index for a blog
 *
 * This file is not meant to be called directly.
 * It is meant to be called by an include in the main.page.php template.


So I'm guessing it's summat to do with photo blogging

2) I'd guess that the disp in the file names is to make them reflect the fact that they're shown for $disp=foo

3) what's the error?

¥

3 Dec 02, 2007 11:56

Thanks Yabba
3) whats the error

Fatal error: acronym_plugin::require(): Failed opening required '/home/wow-factor/plugins/acronym_plugin/_conf.php' (include_path='.:/usr/share/pear:/usr/share/php') in /home/wow-factor/plugins/_acronym.plugin.php on line 53

I just reloaded it, opened Plugins, Install New..... bang crash boom with the above error whiping out the list of available plugins.

4 Dec 02, 2007 11:58

Have you uploaded this file : /home/wow-factor/plugins/acronym_plugin/_conf.php ?

¥

5 Dec 02, 2007 12:07

Sheepishly re enters the room....
Nope, Out of all the uploads I missed it :)

4) If I rename old files like _about.php to _about.disp.php and add them to to the list in inc/skins/_skin.funcs.php will I be breaking anything?

6 Dec 02, 2007 12:22

4) No John, it doesn't break anything :)

Thanks for taking the time Yabba


Form is loading...