PageRenderTime 41ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/components/com_jce/editor/tiny_mce/plugins/link/classes/link.php

https://bitbucket.org/organicdevelopment/joomla-2.5
PHP | 141 lines | 76 code | 31 blank | 34 comment | 6 complexity | 0ba4f12f940c84a0ae82d1f24ab4a95b MD5 | raw file
Possible License(s): LGPL-3.0, GPL-2.0, MIT, BSD-3-Clause, LGPL-2.1
  1. <?php
  2. /**
  3. * @package JCE
  4. * @copyright Copyright (c) 2009-2012 Ryan Demmer. All rights reserved.
  5. * @license GNU/GPL 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  6. * JCE is free software. This version may have been modified pursuant
  7. * to the GNU General Public License, and as distributed it includes or
  8. * is derivative of works licensed under the GNU General Public License or
  9. * other free or open source software licenses.
  10. */
  11. defined('_JEXEC') or die('RESTRICTED');
  12. // Set flag that this is an extension parent
  13. DEFINE('_WF_EXT', 1);
  14. // Load class dependencies
  15. wfimport('editor.libraries.classes.plugin');
  16. wfimport('editor.libraries.classes.extensions.search');
  17. wfimport('editor.libraries.classes.extensions.browser');
  18. wfimport('editor.libraries.classes.extensions.popups');
  19. // Link Plugin Controller
  20. class WFLinkPlugin extends WFEditorPlugin {
  21. /*
  22. * @var varchar
  23. */
  24. var $extensions = array();
  25. var $popups = array();
  26. var $tabs = array();
  27. /**
  28. * Constructor activating the default information of the class
  29. *
  30. * @access protected
  31. */
  32. function __construct() {
  33. parent::__construct();
  34. $this->getBrowser('link');
  35. $this->getSearch('link');
  36. }
  37. /**
  38. * Returns a reference to a plugin object
  39. *
  40. * This method must be invoked as:
  41. * <pre> $advlink =AdvLink::getInstance();</pre>
  42. *
  43. * @access public
  44. * @return JCE The editor object.
  45. * @since 1.5
  46. */
  47. function &getInstance() {
  48. static $instance;
  49. if (!is_object($instance)) {
  50. $instance = new WFLinkPlugin();
  51. }
  52. return $instance;
  53. }
  54. function display() {
  55. parent::display();
  56. $document = WFDocument::getInstance();
  57. $settings = $this->getSettings();
  58. $document->addScriptDeclaration('LinkDialog.settings=' . json_encode($settings) . ';');
  59. $tabs = WFTabs::getInstance(array(
  60. 'base_path' => WF_EDITOR_PLUGIN
  61. ));
  62. // Add tabs
  63. $tabs->addTab('link', 1);
  64. $tabs->addTab('advanced', $this->getParam('tabs_advanced', 1));
  65. $browser = $this->getBrowser('link');
  66. $browser->display();
  67. $search = $this->getSearch('link');
  68. $search->display();
  69. // Load Popups instance
  70. $popups = WFPopupsExtension::getInstance(array(
  71. 'text' => false
  72. ));
  73. $popups->display();
  74. // add link stylesheet
  75. $document->addStyleSheet(array('link'), 'plugins');
  76. // add link scripts last
  77. $document->addScript(array('link'), 'plugins');
  78. }
  79. function getBrowser($type = 'link') {
  80. static $browsers;
  81. if (!isset($browsers)) {
  82. $browsers = array();
  83. }
  84. if (empty($browsers[$type])) {
  85. $browsers[$type] = WFBrowserExtension::getInstance($type);
  86. }
  87. return $browsers[$type];
  88. }
  89. function getSearch($type = 'link') {
  90. static $search;
  91. if (!isset($search)) {
  92. $search = array();
  93. }
  94. if (empty($search[$type])) {
  95. $search[$type] = WFSearchExtension::getInstance($type);
  96. }
  97. return $search[$type];
  98. }
  99. function getSettings() {
  100. $profile = $this->getProfile();
  101. $settings = array(
  102. 'file_browser' => $this->getParam('file_browser', 1) && in_array('browser', explode(',', $profile->plugins)),
  103. 'attributes' => array(
  104. 'target' => $this->getParam('attributes_target', 1),
  105. 'anchor' => $this->getParam('attributes_anchor', 1)
  106. )
  107. );
  108. return parent::getSettings($settings);
  109. }
  110. }