• User Attivo

    Modifica al codice di un plugin

    Ciao a tutti, avrei un problema con il codice di un plugin inserito sul mio sito
    che permette all'utente di copiare un codice html da poter incollare sul proprio blog o sito per inserire una breve citazione dell'articolo.
    Potete vederne un esempio qui cliccando sul link quot this article alla fine dell'articolo.
    Il problema come potete vedere è che per mostrare il codice occorre cliccare sul link, mentre io vorrei che questo fosse sempre visibile. Sapreste dirmi come modificare il codice affinchè il codice da copiare o incollare venga reso sempre visibile? Posto di seguito il codice del plugin:

    <?php
    /**
     * @version        $Id: quothis.php 10094 2008-06-03  $
     * @package        QuotThis
     * @copyright    Copyright (C) 2008 - Bernard Gilly. All rights reserved.
     * @license        GNU/GPL
     * @Website     http://www.alphaplug.com
     */
    
    // Check to ensure this file is included in Joomla!
    defined( '_JEXEC' ) or die( 'Restricted access' );
    
    jimport( 'joomla.plugin.plugin' );
    
    class plgContentQuotethis extends JPlugin
    {
    
        function plgContentQuotethis( &$subject, $params )
        {
            parent::__construct( $subject, $params );
        }
    
        function onPrepareContent( &$article, &$params, $limitstart )
        {
            global $mainframe;
            
            $document    = & JFactory::getDocument();
            $view        = JRequest::getCmd('view');
            
            if ( $view != 'article' ) return;        
    
            // Get plugin info
            $plugin              =& JPluginHelper::getPlugin('content', 'quotethis');
            $pluginParams        = new JParameter( $plugin->params );
            $excludeSectionID    = $pluginParams->get( 'excludeSectionID',  '' );        
            $excludeCategoryID   = $pluginParams->get( 'excludeCategoryID', '' );
            $excludeID           = $pluginParams->get( 'excludeID',         '' );        
            $listexcludeSection  = @explode ( ",",  $excludeSectionID );    
            $listexcludeCategory = @explode ( ",", $excludeCategoryID );    
            $listexclude          = @explode ( ",",         $excludeID );        
            
            if ( $params->get( 'intro_only' ) || in_array ( $article->id, $listexclude ) || in_array ( $article->sectionid, $listexcludeSection ) || in_array ( $article->catid, $listexcludeCategory ) ) return;    
            
            JPlugin::loadLanguage( 'plg_quotethis', JPATH_ADMINISTRATOR );
            
            $loadMootools     = $pluginParams->def( 'loadMootools',           1 );
            $preview            = $pluginParams->def( 'preview',                1 );
            $txtcols         = $pluginParams->def( 'txtcols',               54 );
            $txtrows         = $pluginParams->def( 'txtrows',                7 );    
            $rowtitle        = $pluginParams->def( 'title',            'title' );        
            $intro           = $pluginParams->def( 'intro',                '0' );
            $limitcharintro  = $pluginParams->def( 'limitcharintro',     '150' );
            $showfirstimage  = $pluginParams->def( 'showfirstimage',       '0' );
            $widthimage         = $pluginParams->def( 'widthimage',         '120' );        
            $copyright       = $pluginParams->def( 'copyright',            '1' );
            $showdate        = $pluginParams->def( 'showdate',             '1' );    
            $width           = $pluginParams->def( 'width',                400 );
            $colorborder     = $pluginParams->def( 'colorborder',     '456B8F' );
            $backgroundcolor = $pluginParams->def( 'backgroundcolor', 'FFFFFF' );
            $fontsizetitle   = $pluginParams->def( 'fontsizetitle',       '13' );
            $colortitle      = $pluginParams->def( 'colortitle',      '003399' );
            $colortitlehover = $pluginParams->def( 'colortitlehover', 'FF9900' );
            $fontsize        = $pluginParams->def( 'fontsize',            '10' );
            $fontcolor       = $pluginParams->def( 'fontcolor',       '222222' );            
            
            //unset($document->_scripts[JURI::base(true) . '/media/system/js/mootools.js']);
            //unset($document->_scripts[JURI::base(true) . '/media/system/js/mootools-uncompressed.js']);
            //$document->addScript(JURI::base(true) . '/media/system/js/mootools.js');        
            if ( $loadMootools ) $document->addScript(JURI::base(true).'/plugins/content/quotethis/js/mootools.js');                
            
            $uri             =& JURI::getInstance();
            $base            = $uri->toString( array('scheme', 'host', 'port'));        
            $thequote        = $base.JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catslug, $article->sectionid));        
    
            $copyNow         = date('Y');
            $title           = stripslashes( $article->$rowtitle );
            $copyright       = ( $copyright ) ? "&copy; " . $copyNow . " - " : "" ;
            $thedate         = ( $showdate )  ? "<br />" . JHTML::_( 'date', $article->created, JText::_('DATE_FORMAT_LC')) : "" ;
            $introtext         = ( $intro )     ? "<br />" . plgContentQuotethis::prepareIntroQuoteThis( $article->text, $limitcharintro, "" ) : "" ;
            $image              = "";
            
            if ( $showfirstimage ) {
                $image = plgContentQuotethis::findIMGquotethis( $article->text );
                $image = "<img src=\"" . $image . "\" width=\"" . $widthimage . "\" alt=\"\" />";
                $image = "<div style=\"float:left;padding:5px;\">" . $image . "</div>";
            }
            
            $style4quote = "<style type=\"text/css\"><!--"
            .".quote {width:".$width."px; padding: 6px; border: solid 1px #".$colorborder."; font: ".$fontsize."px helvetica, verdana, sans-serif; color: #".$fontcolor."; background-color: #".$backgroundcolor."}"
            .".quote a {font: ".$fontsizetitle."px arial, serif; color: #".$colortitle."; text-decoration: underline}"
            .".quote a:hover {color: #".$colortitlehover."; }"
            ."//--></style>";
    
            $javascript = "\n<script language=\"JavaScript\" type=\"text/javascript\">\n<!--\n"
                ."window.addEvent('domready', function(){\n"
                ."var mySlide = new Fx.Slide('quotethisexpand').hide();    \n"
                ."$('toggle').addEvent('click', function(e){\n"
                ."e = new Event(e);\n"
                ."mySlide.toggle();\n"
                ."e.stop();\n"
                ."});\n"
                ."}); \n//-->"
                ."</script>\n";
                
            if ( $preview ) $document->addCustomTag( $style4quote );
                
            $html  = $javascript;        
            $html .= "<a id=\"toggle\" href=\"#\">" . JText::_('QUOTETHISARTICLEONYOURSITE') . "</a>";
            $html .= "<br /><div id=\"quotethisexpand\"><br />";
            $html .= "<strong>".JText::_('CREATELINKTOWARDSTHISARTICLE')."</strong>";
            $html .= "<br /><br />";        
            $html .= "<textarea name=\"textarea\" cols=\"$txtcols\" rows=\"$txtrows\">".$style4quote.$image."<div class=\"quote\">"
            ."<a href=\"" . $thequote ."\" target=\"_blank\">" . $title . "</a>" . $thedate . $introtext
            ."<div align=\"right\" style=\"width:".$width."px\"><p style=\"text-align:right;\">".$copyright."<a href=\"".JURI::base()."\" target=\"_blank\">".$mainframe->getCfg('sitename')."</a></p></div></div></textarea>";
            $html .= "<br /><br />";
            
            if ( $preview ) {
                $html .= JText::_('PREVIEWQUOTE');
                $html .= "<br /><br />";
                $html .= $style4quote;
                $html .= $image . "<div class=\"quote\">\n<a href=\"$thequote\" target=\"_blank\">$title</a>"
                .$thedate.$introtext
                ."\n<div align=\"right\" style=\"width:".$width."px\"><p style=\"text-align:right;\">$copyright<a href=\"".JURI::base()."\" target=\"_blank\">".$mainframe->getCfg('sitename')."</a></p></div></div>";
                $html .= "<br />";        
            }
            $html .= "<div class=\"small\" align=\"center\">";
            // This software is copyrighted: don't remove the copyright notice
            $html .= "Powered by <a href=\"http://www.alphaplug.com\">QuoteThis</a> &copy; 2008";
            $html .= "</div>";
            $html .= "</div>";
                
            $article->text = $article->text . $html;
    
        }
        
        function prepareIntroQuoteThis( $text, $length=150, $tags='' ) {
            // strips tags won't remove the actual jscript
            $text = preg_replace( "'<script[^>]*>.*?</script>'si", "", $text );
            $text = preg_replace( '/{.+?}/', '', $text);
            // replace line breaking tags with whitespace
            $text = preg_replace( "'<(br[^/>]*?/|hr[^/>]*?/|/(div|h[1-6]|li|p|td))>'si", ' ', $text );
        
            return html_entity_decode(plgContentQuotethis::smartSubstrQuoteThis( strip_tags( $text, $tags ), $length ));
        }
        
        function smartSubstrQuoteThis($text, $length=150) {
            if ( strlen($text) > $length ) {     
                $text = substr( $text, 0, $length );
                $blankpos = strrpos( $text, ' ' );    
                $text = substr( $text, 0, $blankpos );    
                $text .= "...";
            }  
            return $text;  
        }
        
        function findIMGquotethis( $contenttext ) {    
            $image = "";
            if ( preg_match_all('#src="(.*)"#Uis', $contenttext, $match ) ) {
                if ( count($match) ) {
                    $image = $match[1][0];
                }
            }
            return $image;
        }    
    }
    ?>
    

  • User Attivo

    Così a prima vista direi di commentare in questo modo lo script:

    [php]
    /* $javascript = "\n<script language="JavaScript" type="text/javascript">\n<!--\n"
    ."window.addEvent('domready', function(){\n"
    ."var mySlide = new Fx.Slide('quotethisexpand').hide(); \n"
    ."$('toggle').addEvent('click', function(e){\n"
    ."e = new Event(e);\n"
    ."mySlide.toggle();\n"
    ."e.stop();\n"
    ."});\n"
    ."}); \n//-->"
    ."</script>\n"; */

    //$html = $javascript;
    //$html .= "<a id="toggle" href=...";
    $html = "<a id="toggle" href=...";
    [/php]Ciao!


  • User Attivo

    Ciao sups e grazie mille per il suggerimento, sono riuscito nel mio intento
    A presto!


  • User Attivo

    Scusa un'altra cosa? C'è qualche problema nell'inserire l'attributo rel="nofollow" in un link nel codice mostrato, perchè facendolo il sito non mi sia apre più correttamente (carica una pagina bianca)


  • User

    Puoi spiegarti maglio? Non ho capito il problema.


  • User Attivo

    Alla riga 264 al posto di
    $html .= "Powered by <a href="http://www.alphaplug.com">QuoteThis</a> © 2008";

    ho messo

    $html .= "Powered by <a href="http://www.alphaplug.com"rel="nofollow">QuoteThis</a> © 2008";

    Con tale modifica però il sito non si carica più correttamente.


  • User

    E' normale, devi fare l'escape dei " nella stringa:

    $html .= "Powered by <a href=\"non_sono_premium\"rel=**\"nofollow\">**QuoteThis</a> &copy; 2008";
    

  • User Attivo

    Risolto.
    Grazie mille dell'aiuto sydarex