Recent Topics

1 Jan 16, 2007 13:57    

Hi there.

I'm currently using BLOG:CMS for blogging but I'm not satisfied with it. After some time spended by testing CMSs I made final decision .. I want to migrate to b2evo.

But I have also some habits. I'm using Texy plugin for writing my posts. Texy is similar to Textile, but is more popular in Czech rep. and I use this for blogging more than 1,5 year. [a href=http://texy.info/cs/download]Here[/a] is available Texy plugin for b2evo .. but for b2evo v0.9.

I have 3 problems now. I'm new here, I'm not a programmer and I need to rewrite all functional plugin Texy for b2evo v0.9 for b2evo v1.8.

I tried to rewrite old plugin .. but it's not functional. Here is my attemp:


<?php

/*
 *   Texy! plugin for b2evolution
 *   ----------------------------
 *   http://www.texy.info
 *
 *   Copyright (c) David Grudl, 2005
 *
 *   This will allow you to type up items using Texy! (www.texy.info).
 *
 */
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );


/**
 * Includes:
 */
require_once dirname(__FILE__).'/texy_plugin/texy-compact.php';
require_once dirname(__FILE__).'/texy_plugin/fshl/fshl.php';


/**
 * @package plugins
 */
class texy_plugin extends Plugin
{
  var $code = 'b2Texy';
  var $name = 'Texy!';
  var $priority = 95;
  var $version = '2.0 beta';
  var $apply_rendering = 'opt-in';
  var $short_desc;
  var $long_desc;

  var $texy;
  var $cachePath;
  var $enableSmilies = false;
  var $enableFSHL    = true;

  /**
   * Constructor
   */
  function texy_plugin()
	{
    $this->short_desc = T_('Texy! humane formatting');
    $this->long_desc = T_('No description available');
    $this->cachePath = dirname(__FILE__) . '/texy_plugin/cache/';            
    $this->texy = &new Texy();
    $this->texy->utf = true;
    $this->texy->imageModule->leftClass   = 'left'; 
    $this->texy->imageModule->rightClass  = 'right';
    $this->texy->imageModule->root = '';    
    $this->texy->imageModule->linkedRoot = '';
    $this->texy->headingModule->top = 1; 

    require dirname(__FILE__). '/texy_plugin/_texy.conf.php';

    if ($this->enableSmilies) {    
         $this->texy->smiliesModule->allowed =  true;
         $this->texy->smiliesModule->root    =  ''; // ???
         $this->texy->smiliesModule->class   = 'smiley';     
    }
    
    if ($this->enableFSHL && class_exists('fshlParser')) {        
         $this->texy->blockModule->codeHandler = array(&$this, 'callbackSyntaxHighlight'); 
    }

  }


// -------------------------------------------------------------
  /**
   * Perform rendering
   *
   * @param string content to render (by reference) / rendered content
   * @param string Output format, see {@link format_to_output()}
   * @return boolean true if we can render something for the required output format
   */
  function render( & $content, $format )
  {
    if( ! parent::render( $content, $format ) ) {   
        // We cannot render the required format
        return false;
    }

    $md5 = md5($content); // md5 is key for caching
    
    // check, if cached file exists
    $cacheFile = $this->cachePath . $md5 . '.html';
    $cache = is_file($cacheFile) ? unserialize(file_get_contents($cacheFile)) : null;
    if ($cache) {         // read from cache
      list($content, $this->texy->styleSheet) = $cache;

    } else {                           // doesn't exists
      $content = $this->texy->process($content);
      if (is_writable($this->cachePath))
        fwrite(fopen($cacheFile, 'w'), 
          serialize( array($content, $this->texy->styleSheet) )
        );
    }
  }


  // this is user callback function for processing inlin `code` or block @code 
  function callbackSyntaxHighlight(&$element)
  {
    $lang = strtoupper($element->lang);
    if ($lang == 'JAVASCRIPT') $lang = 'JS';

    if (in_array($lang, array('CPP', 'CSS', 'HTML', 'JAVA', 'PHP', 'JS', 'SQL'))) {        
      $parser = new fshlParser($element->texy->utf ? 'HTML_UTF8' : 'HTML', P_TAB_INDENT);
      $element->setContent($parser->highlightString($lang, $element->content), true);
    }
  }


} // end class


/*
 nolog */
?>

When I use this, I got message "Please, do not access this page directly."

Please help me to make this plugin functional. Without this I'm not able migrate. Thanks for any help.

2 Jan 20, 2007 13:47

Hi,

Have you managed to solve your problem with this plugin yet?

¥

3 Jan 22, 2007 14:08

¥åßßå wrote:

Hi,

Have you managed to solve your problem with this plugin yet?

¥

Hi .. I still need help to solve this. If you can help me, your help will be appreciated.

4 Jan 22, 2007 17:22

I made some small mods of this plugin so this is actual code:


<?php

/*
 *   Texy! plugin for b2evolution
 *   ----------------------------
 *   http://www.texy.info
 *
 *   Copyright (c) David Grudl, 2005
 *
 *   This will allow you to type up items using Texy! (www.texy.info).
 *
 */
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );

/**
 * Includes:
 */
require_once dirname(__FILE__).'/texy_plugin/texy-compact.php';
require_once dirname(__FILE__).'/texy_plugin/fshl/fshl.php';


/**
 * @package plugins
 */
class texy_plugin extends Plugin
{
  var $code = 'b2Texy';
  var $name = 'Texy!';
  var $priority = 90;
  var $version = '1.9-dev';
  var $apply_rendering = 'opt-in';
  var $short_desc;
  var $long_desc;

  var $texy;
  var $cachePath;
  var $enableSmilies = false;
  var $enableFSHL    = true;

  /**
   * Init
   */
  function PluginInit( & $params )
  {
    $this->short_desc = T_('Texy! humane formatting');
    $this->long_desc = T_('No description available' );
    $this->cachePath = dirname(__FILE__) . '/texy_plugin/cache/';
    $this->texy = &new Texy();
    $this->texy->utf = true;

    # classes for left- or right- aligned images
    $this->texy->imageModule->leftClass   = 'left';
    $this->texy->imageModule->rightClass  = 'right';

    # definition for image root
    $this->texy->imageModule->root = '';
    $this->texy->imageModule->linkedRoot = '';
    $this->texy->headingModule->top = 1;

    if ($this->enableSmilies) {
      $this->texy->smiliesModule->allowed =  true;
      $this->texy->smiliesModule->root    =  ''; // ???
      $this->texy->smiliesModule->class   = 'smiley';
    }

    if ($this->enableFSHL && class_exists('fshlParser')) {
      $this->texy->blockModule->codeHandler = array(&$this, 'callbackSyntaxHighlight');
    }
  }


// -------------------------------------------------------------
  /**
   * Perform rendering
   *
   * @param string content to render (by reference) / rendered content
   * @param string Output format, see {@link format_to_output()}
   * @return boolean true if we can render something for the required output format
   */
  function RenderItemAsHtml( & $content, $format )
  {
    if( ! parent::RenderItemAsHtml( $content, $format ) ) {
      // We cannot render the required format
      return false;
    }

    $md5 = md5($content); // md5 is key for caching

    // check, if cached file exists
    $cacheFile = $this->cachePath . $md5 . '.html';
    $cache = is_file($cacheFile) ? unserialize(file_get_contents($cacheFile)) : null;
    if ($cache) {         // read from cache
      list($content, $this->texy->styleSheet) = $cache;

    } else {                           // doesn't exists
      $content = $this->texy->process($content);
      if (is_writable($this->cachePath))
        fwrite(fopen($cacheFile, 'w'),
          serialize( array($content, $this->texy->styleSheet) )
      );
    }
  }


  // this is user callback function for processing inlin `code` or block @code
  function callbackSyntaxHighlight(&$element)
  {
    $lang = strtoupper($element->lang);
    if ($lang == 'JAVASCRIPT') $lang = 'JS';

    if (in_array($lang, array('CPP', 'CSS', 'HTML', 'JAVA', 'PHP', 'JS', 'SQL'))) {
      $parser = new fshlParser($element->texy->utf ? 'HTML_UTF8' : 'HTML', P_TAB_INDENT);
      $element->setContent($parser->highlightString($lang, $element->content), true);
    }
  }

} // end class


/*
 nolog */
?>

Problems with disabled plugins are solved .. Unfortunately Plugin is still nonfunctional and when I use it I got this message:

Warning: Missing argument 2 for renderitemashtml() in /www/snor/www/komunikatory/dev/plugins/_texy.plugin.php on line 80

Do you know what is wrong?

5 Jan 22, 2007 17:39

And actual verison of Texy! plugin for b2evo 1.9 as an attachment of this post.

Basic English doc for Texy using is here: http://texy.info/en/

6 Jan 23, 2007 16:53

function RenderItemAsHtml() now gets passed "$params" so you need to change at least this piece of your code:-

  function RenderItemAsHtml( & $content, $format )
  {
    if( ! parent::RenderItemAsHtml( $content, $format ) ) {
      // We cannot render the required format
      return false;
    }

    $md5 = md5($content); // md5 is key for caching

to something like :-

  function RenderItemAsHtml( & $params )
  {
    $content = $params['data'];
    $md5 = md5($content); // md5 is key for caching

¥

7 Jan 31, 2007 08:20

Unfortunately .. it still doesnt work .. d8-\

8 Jan 31, 2007 11:15

Actually, your main problem is the html checker. Uninstall the current version of your plugin and delete the files from your plugins directory.

Then unzip the attached file and upload the texy_plugin folder to your plugins_folder (I've also moved texy.plugin.php inside the folder). Reinstall the plugin and see if it works as it should.

¥

9 Feb 01, 2007 22:57

¥åßßå wrote:

Actually, your main problem is the html checker. Uninstall the current version of your plugin and delete the files from your plugins directory.

Then unzip the attached file and upload the texy_plugin folder to your plugins_folder (I've also moved texy.plugin.php inside the folder). Reinstall the plugin and see if it works as it should.

¥

Thank you very much .. Texy is fully functional now .. d8-D
Thank you again .. d8-D

10 Mar 30, 2007 16:47

I have another one question. Is it possible to use texy plugin for formatting comments on my web? If some formatter have this solved, plz just give me a link and I will try to solve this. Thanks.


Form is loading...