PageRenderTime 38ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/plugins/editors-xtd/article/article.php

https://github.com/joebushi/joomla
PHP | 69 lines | 31 code | 7 blank | 31 comment | 0 complexity | 0d7c7c6e49486c8c53ba4a89e777dd5b MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
  1. <?php
  2. /**
  3. * @version $Id: image.php 13031 2009-10-02 21:54:22Z louis $
  4. * @package Joomla
  5. * @copyright Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
  6. * @license GNU General Public License version 2 or later; see LICENSE.txt
  7. */
  8. // no direct access
  9. defined('_JEXEC') or die;
  10. jimport('joomla.plugin.plugin');
  11. /**
  12. * Editor Article buton
  13. *
  14. * @package Editors-xtd
  15. * @since 1.5
  16. */
  17. class plgButtonArticle extends JPlugin
  18. {
  19. /**
  20. * Display the button
  21. *
  22. * @return array A four element array of (article_id, article_title, category_id, object)
  23. */
  24. function onDisplay($name)
  25. {
  26. /*
  27. * Javascript to insert the link
  28. * View element calls jSelectArticle when an article is clicked
  29. * jSelectArticle creates the link tag, sends it to the editor,
  30. * and closes the select frame.
  31. */
  32. $js = "
  33. function jSelectArticle(id, title, catid, object) {
  34. var tag = '<a href='+'\"index.php?option=com_content&amp;view=article&amp;catid='+catid+'&amp;id='+id+'\">'+title+'</a>';
  35. jInsertEditorText(tag, '".$name."');
  36. SqueezeBox.close();
  37. }";
  38. /*
  39. * CSS for article button
  40. */
  41. $css = "
  42. .button2-left .article {
  43. background: url(../../../plugins/editors-xtd/article.png) 100% 0 no-repeat;
  44. }";
  45. $doc =& JFactory::getDocument();
  46. $doc->addScriptDeclaration($js);
  47. $doc->addStyleDeclaration($css);
  48. JHTML::_('behavior.modal');
  49. /*
  50. * Use the built-in element view to select the article.
  51. * Currently uses blank class.
  52. */
  53. $link = 'index.php?option=com_content&amp;view=articles&amp;layout=modal&amp;tmpl=component';
  54. $button = new JObject();
  55. $button->set('modal', true);
  56. $button->set('link', $link);
  57. $button->set('text', JText::_('Article'));
  58. $button->set('name', 'article');
  59. $button->set('options', "{handler: 'iframe', size: {x: 770, y: 400}}");
  60. return $button;
  61. }
  62. }