Source for file article.php

Documentation is available at article.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Plugin
  4.  * @subpackage  Editors-xtd.article
  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 Article buton
  14.  *
  15.  * @package     Joomla.Plugin
  16.  * @subpackage  Editors-xtd.article
  17.  * @since       1.5
  18.  */
  19. class PlgButtonArticle 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.      * Display the button
  31.      *
  32.      * @param   string  $name  The name of the button to add
  33.      *
  34.      * @return array A four element array of (article_id, article_title, category_id, object)
  35.      */
  36.     public function onDisplay($name)
  37.     {
  38.         /*
  39.          * Javascript to insert the link
  40.          * View element calls jSelectArticle when an article is clicked
  41.          * jSelectArticle creates the link tag, sends it to the editor,
  42.          * and closes the select frame.
  43.          */
  44.         $js "
  45.         function jSelectArticle(id, title, catid, object, link, lang)
  46.         {
  47.             var hreflang = '';
  48.             if (lang !== '')
  49.             {
  50.                 var hreflang = ' hreflang = \"' + lang + '\"';
  51.             }
  52.             var tag = '<a' + hreflang + ' href=\"' + link + '\">' + title + '</a>';
  53.             jInsertEditorText(tag, '" $name "');
  54.             SqueezeBox.close();
  55.         }";
  56.  
  57.         $doc JFactory::getDocument();
  58.         $doc->addScriptDeclaration($js);
  59.  
  60.         JHtml::_('behavior.modal');
  61.  
  62.         /*
  63.          * Use the built-in element view to select the article.
  64.          * Currently uses blank class.
  65.          */
  66.         $link 'index.php?option=com_content&amp;view=articles&amp;layout=modal&amp;tmpl=component&amp;' JSession::getFormToken('=1';
  67.  
  68.         $button new JObject;
  69.         $button->modal true;
  70.         $button->class 'btn';
  71.         $button->link $link;
  72.         $button->text JText::_('PLG_ARTICLE_BUTTON_ARTICLE');
  73.         $button->name 'file-add';
  74.         $button->options "{handler: 'iframe', size: {x: 800, y: 500}}";
  75.  
  76.         return $button;
  77.     }
  78. }

Documentation generated on Tue, 19 Nov 2013 14:53:56 +0100 by phpDocumentor 1.4.3