Source for file readmore.php

Documentation is available at readmore.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Plugin
  4.  * @subpackage  Editors-xtd.readmore
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE.txt
  8.  */
  9.  
  10. defined('_JEXEC'or die;
  11.  
  12. /**
  13.  * Editor Readmore buton
  14.  *
  15.  * @package     Joomla.Plugin
  16.  * @subpackage  Editors-xtd.readmore
  17.  * @since       1.5
  18.  */
  19. class PlgButtonReadmore extends JPlugin
  20. {
  21.     /**
  22.      * Load the language file on instantiation.
  23.      *
  24.      * @var    boolean 
  25.      * @since  3.1
  26.      */
  27.     protected $autoloadLanguage = true;
  28.  
  29.     /**
  30.      * Readmore button
  31.      *
  32.      * @param   string  $name  The name of the button to add
  33.      *
  34.      * @return array A two element array of (imageName, textToInsert)
  35.      */
  36.     public function onDisplay($name)
  37.     {
  38.         $doc JFactory::getDocument();
  39.  
  40.         // Button is not active in specific content components
  41.  
  42.         $getContent $this->_subject->getContent($name);
  43.         $present JText::_('PLG_READMORE_ALREADY_EXISTS'true);
  44.         $js "
  45.             function insertReadmore(editor)
  46.             {
  47.                 var content = $getContent
  48.                 if (content.match(/<hr\s+id=(\"|')system-readmore(\"|')\s*\/*>/i))
  49.                 {
  50.                     alert('$present');
  51.                     return false;
  52.                 } else {
  53.                     jInsertEditorText('<hr id=\"system-readmore\" />', editor);
  54.                 }
  55.             }
  56.             ";
  57.  
  58.         $doc->addScriptDeclaration($js);
  59.  
  60.         $button new JObject;
  61.         $button->modal false;
  62.         $button->class 'btn';
  63.         $button->onclick 'insertReadmore(\'' $name '\');return false;';
  64.         $button->text JText::_('PLG_READMORE_BUTTON_READMORE');
  65.         $button->name 'arrow-down';
  66.  
  67.         // @TODO: The button writer needs to take into account the javascript directive
  68.         // $button->link', 'javascript:void(0)');
  69.         $button->link '#';
  70.  
  71.         return $button;
  72.     }
  73. }

Documentation generated on Tue, 19 Nov 2013 15:11:36 +0100 by phpDocumentor 1.4.3