Joomla.it Forum

Forum traduzioni italiano => Le traduzioni e le informazioni della community => FAQ e Guide => : napo 20 Apr 2007, 16:05:05

: Guida all'uso del motore GeSHi
: napo 20 Apr 2007, 16:05:05
Per tutti coloro che vogliono capire a cosa serve il mambot GeSHi e come funziona, ho realizzato una piccola guida.


Link: *************


Edit by ventus85: per favore niente collegamenti a siti esterni. Saremo ben lieti se vorrai condividere la tua guida attraverso un tutorial o un articoli nel sito. Per ulteriori informazioni puoi chiedere senza problemi. Grazie.
: Re: Guida all'uso del motore GeSHi
: fbcyborg 25 Apr 2007, 09:48:32
Ottima guida!!!
Proprio quello che ci voleva, complimenti e grazie!

Per favore potresti postare il codice di geshi.php???

Fare copia e incolla dal file pdf risulta essere un po' laborioso. Vengono copiati caratteri strani e si rischia di modificare/cancellare qualcosa nel tentativo di ottenere il file php corretto.
: Re: Guida all'uso del motore GeSHi
: fbcyborg 25 Apr 2007, 10:52:43
Per il momento questo è ciò che sono riuscito a tirare fuori... Non dovrebbero esserci errori:
<?php
/**
* @version $Id: geshi .php 2970 2006?03?30 08:01:32Z stingrey $
* @package Joomla
* @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modi?ed pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses .
* See COPYRIGHT.php for copyright notices and details.
*/

// no direct access
defined( '_VALID_MOS' ) or die( 'Restricted access' );

$_MAMBOTS->registerFunction( 'onPrepareContent', 'botGeshi' );

/**
* Code Highlighting Mambot
*
* Replaces {geshi lang="LANGUAGE" lines="true"}...{/geshi} tags with highlighted text
*/
function botGeshi( $published, &$row, &$params, $page=0 ) {
   // define the regular expression for the bot
   $regex = "#{geshi\s*(.*?)}(.*?){/geshi}#s";
   
   // check whether mambot has been unpublished
   if ( !$published ) {
      return true;
   }
   
   // perform the replacement
   $row->text = preg_replace_callback( $regex, 'botGeshi_replacer', $row->text );
   
   return true;
}
/**
* Replaces the matched tags an image
* @param array An array of matches (see preg match all)
* @return string
*/
function botGeshi_replacer( &$matches ) {
   require_once( $GLOBALS['mosConfig_absolute_path'] . '/includes/domit/xml_saxy_shared.php' );
   include_once( dirname( _FILE_ ) . '/geshi/geshi.php' );

   $parser = new SAXY_Parser_Base();
   $args = $parser->parseAttributes( strtr($matches[1], $parser->predefinedEntities) );
   $text = $matches[2];

   $lang = mosGetParam( $args, 'lang', 'php' );
   $lines = mosGetParam( $args, 'lines', 'false' );

   $html_entities_match = array( "|\<br \/\>|", "#<#", "#>#", "|&#39;|", '#&quot;#', '#&nbsp;#' );
   $html_entities_replace = array( "\n", '&lt;', '&gt;', "'", '"', ' ' );

   $text = preg_replace( $html_entities_match, $html_entities_replace, $text );
   
   $text = str_replace ('&lt;', '<', $text) ;
   $text = str_replace ('&gt;', '>', $text) ;

   // Replace tabs with "&nbsp; &nbsp;" so tabbed code indents sorta right without making huge long lines
   //$text = str_replace ("\t", "&nbsp; &nbsp;", $text);
   $text = str_replace ( "\t", ' ', $text ) ;

   $geshi = new GeSHi( $text, $lang, dirname( __FILE__ ) . '/geshi/geshi' );
   if ( $lines == 'true') {
      $geshi->enable_line_numbers( GESHI_NORMAL_LINE_NUMBERS );
   }
   $text = $geshi->parse_code();

   return $text;
}
?>
: Re: Guida all'uso del motore GeSHi
: fbcyborg 17 May 2007, 15:33:17
Salve di nuovo,

è possibile mettere il codice racchiuso fra i tag geshi, in una sorta di riquadro con uno sfondo diverso?

Per esempio come viene fatto quì (http://www.dis.uniroma1.it/~allulli/index.php?id=118).
: Re: Guida all'uso del motore GeSHi
: fbcyborg 31 May 2007, 14:11:19
Ho risolto quanto detto nell'ultimo post.

Non capisco perché non risponde mai nessuno in questo thread.. comunque:
sapete se ci sono altre opzioni/parametri da mettere in {geshi}{/geshi} oltre a lang="bash" e lines="true" ???? (ho preso bash come esempio).
Ad esempio qualcosa per disabilitare la colorazione delle parole?
: Re:Guida all'uso del motore GeSHi
: robinhoood 24 May 2009, 19:48:16
Ciao a tutti... è passato del tempo da quando avete aperto questo post, ma io avbrei bisogno di aiuto, per favore!

Vorrei evidenziare del codice in joomla 1.0 , proprio come è stato fatto qui :

http://www.phpnews.it/corsi/php-e-html/

mi sapresta dire come fare?
Io ho seguito la guida sul geshi ma non ha sortito effetto...grazie in anticipo