PageRenderTime 109ms CodeModel.GetById 20ms RepoModel.GetById 17ms app.codeStats 0ms

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

https://github.com/viollarr/alab
PHP | 130 lines | 68 code | 28 blank | 34 comment | 4 complexity | 28f5fbae8c8807236600a105200a91eb MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0, AGPL-3.0, Apache-2.0, BSD-3-Clause, GPL-3.0
  1. <?php
  2. /**
  3. * @package JCE
  4. * @copyright Copyright Š 2009-2011 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.browser');
  17. wfimport('editor.libraries.classes.extensions.popups');
  18. // Link Plugin Controller
  19. class WFLinkPlugin extends WFEditorPlugin {
  20. /*
  21. * @var varchar
  22. */
  23. var $extensions = array();
  24. var $popups = array();
  25. var $tabs = array();
  26. /**
  27. * Constructor activating the default information of the class
  28. *
  29. * @access protected
  30. */
  31. function __construct() {
  32. parent::__construct();
  33. $browser = $this->getBrowser('link');
  34. $search = $this->getBrowser('search');
  35. }
  36. /**
  37. * Returns a reference to a plugin object
  38. *
  39. * This method must be invoked as:
  40. * <pre> $advlink =AdvLink::getInstance();</pre>
  41. *
  42. * @access public
  43. * @return JCE The editor object.
  44. * @since 1.5
  45. */
  46. function &getInstance() {
  47. static $instance;
  48. if (!is_object($instance)) {
  49. $instance = new WFLinkPlugin();
  50. }
  51. return $instance;
  52. }
  53. function display() {
  54. parent::display();
  55. $document = WFDocument::getInstance();
  56. $settings = $this->getSettings();
  57. $document->addScriptDeclaration('LinkDialog.settings=' . json_encode($settings) . ';');
  58. $tabs = WFTabs::getInstance(array(
  59. 'base_path' => WF_EDITOR_PLUGIN
  60. ));
  61. // Add tabs
  62. $tabs->addTab('link', 1);
  63. $tabs->addTab('advanced', $this->getParam('tabs_advanced', 1));
  64. $browser = $this->getBrowser('link');
  65. $browser->display();
  66. $search = $this->getBrowser('search');
  67. $search->display();
  68. // Load Popups instance
  69. $popups = WFPopupsExtension::getInstance(array(
  70. 'text' => false
  71. ));
  72. $popups->display();
  73. // add link stylesheet
  74. $document->addStyleSheet(array('link'), 'plugins');
  75. // add link scripts last
  76. $document->addScript(array('link'), 'plugins');
  77. }
  78. function getBrowser($type = 'link') {
  79. static $browsers;
  80. if (!isset($browsers)) {
  81. $browsers = array();
  82. }
  83. if (empty($browsers[$type])) {
  84. $browsers[$type] = WFBrowserExtension::getInstance($type);
  85. }
  86. return $browsers[$type];
  87. }
  88. function renderBrowser($type = 'link') {
  89. return $this->getBrowser($type)->render();
  90. }
  91. function getSettings() {
  92. $profile = $this->getProfile();
  93. $settings = array(
  94. 'file_browser' => $this->getParam('file_browser', 1) && in_array('browser', explode(',', $profile->plugins)),
  95. 'attributes' => array(
  96. 'target' => $this->getParam('attributes_target', 1),
  97. 'anchor' => $this->getParam('attributes_anchor', 1)
  98. )
  99. );
  100. return parent::getSettings($settings);
  101. }
  102. }