/sites/all/modules/ckeditor/_ckfinder_deprecatedButReady/core/connector/php/php4/CommandHandler/Init.php

https://github.com/osarrat/sigmah-website · PHP · 147 lines · 78 code · 20 blank · 49 comment · 14 complexity · 77bccb432cd2cf472af8cd6a02f76ae7 MD5 · raw file

  1. <?php
  2. /*
  3. * CKFinder
  4. * ========
  5. * http://ckfinder.com
  6. * Copyright (C) 2007-2010, CKSource - Frederico Knabben. All rights reserved.
  7. *
  8. * The software, this file and its contents are subject to the CKFinder
  9. * License. Please read the license.txt file before using, installing, copying,
  10. * modifying or distribute this file or part of its contents. The contents of
  11. * this file is part of the Source Code of CKFinder.
  12. */
  13. if (!defined('IN_CKFINDER')) exit;
  14. /**
  15. * @package CKFinder
  16. * @subpackage CommandHandlers
  17. * @copyright CKSource - Frederico Knabben
  18. */
  19. /**
  20. * Include base XML command handler
  21. */
  22. require_once CKFINDER_CONNECTOR_LIB_DIR . "/CommandHandler/XmlCommandHandlerBase.php";
  23. /**
  24. * Handle Init command
  25. *
  26. * @package CKFinder
  27. * @subpackage CommandHandlers
  28. * @copyright CKSource - Frederico Knabben
  29. */
  30. class CKFinder_Connector_CommandHandler_Init extends CKFinder_Connector_CommandHandler_XmlCommandHandlerBase
  31. {
  32. /**
  33. * Command name
  34. *
  35. * @access private
  36. * @var string
  37. */
  38. var $command = "Init";
  39. function mustCheckRequest()
  40. {
  41. return false;
  42. }
  43. /**
  44. * Must add CurrentFolder node?
  45. *
  46. * @return boolean
  47. * @access protected
  48. */
  49. function mustAddCurrentFolderNode()
  50. {
  51. return false;
  52. }
  53. /**
  54. * handle request and build XML
  55. * @access protected
  56. *
  57. */
  58. function buildXml()
  59. {
  60. $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
  61. // Create the "ConnectorInfo" node.
  62. $_oConnInfo = new Ckfinder_Connector_Utils_XmlNode("ConnectorInfo");
  63. $this->_connectorNode->addChild($_oConnInfo);
  64. $_oConnInfo->addAttribute("enabled", $_config->getIsEnabled() ? "true" : "false");
  65. if (!$_config->getIsEnabled()) {
  66. $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_CONNECTOR_DISABLED);
  67. }
  68. $_ln = '' ;
  69. $_lc = $_config->getLicenseKey() . ' ' ;
  70. if ( 1 == ( strpos( CKFINDER_CHARS, $_lc[0] ) % 5 ) )
  71. $_ln = $_config->getLicenseName() ;
  72. $_oConnInfo->addAttribute("s", $_ln);
  73. $_oConnInfo->addAttribute("c", trim( $_lc[11] . $_lc[0] . $_lc [8] . $_lc[12] . $_lc[26] . $_lc[2] . $_lc[3] . $_lc[25] . $_lc[1] ));
  74. $_thumbnailsConfig = $_config->getThumbnailsConfig();
  75. $_thumbnailsEnabled = $_thumbnailsConfig->getIsEnabled() ;
  76. $_oConnInfo->addAttribute("thumbsEnabled", $_thumbnailsEnabled ? "true" : "false");
  77. if ($_thumbnailsEnabled) {
  78. $_oConnInfo->addAttribute("thumbsUrl", $_thumbnailsConfig->getUrl());
  79. $_oConnInfo->addAttribute("thumbsDirectAccess", $_thumbnailsConfig->getDirectAccess() ? "true" : "false" );
  80. }
  81. $_imagesConfig = $_config->getImagesConfig();
  82. $_oConnInfo->addAttribute("imgWidth", $_imagesConfig->getMaxWidth());
  83. $_oConnInfo->addAttribute("imgHeight", $_imagesConfig->getMaxHeight());
  84. // Create the "ResourceTypes" node.
  85. $_oResourceTypes = new Ckfinder_Connector_Utils_XmlNode("ResourceTypes");
  86. $this->_connectorNode->addChild($_oResourceTypes);
  87. // Create the "PluginsInfo" node.
  88. $_oPluginsInfo = new Ckfinder_Connector_Utils_XmlNode("PluginsInfo");
  89. $this->_connectorNode->addChild($_oPluginsInfo);
  90. // Load the resource types in an array.
  91. $_aTypes = $_config->getDefaultResourceTypes();
  92. if (!sizeof($_aTypes)) {
  93. $_aTypes = $_config->getResourceTypeNames();
  94. }
  95. $_aTypesSize = sizeof($_aTypes);
  96. if ($_aTypesSize) {
  97. for ($i = 0; $i < $_aTypesSize; $i++)
  98. {
  99. $_resourceTypeName = $_aTypes[$i];
  100. $_acl = $_config->getAccessControlConfig();
  101. $_aclMask = $_acl->getComputedMask($_resourceTypeName, "/");
  102. if ( ($_aclMask & CKFINDER_CONNECTOR_ACL_FOLDER_VIEW) != CKFINDER_CONNECTOR_ACL_FOLDER_VIEW ) {
  103. continue;
  104. }
  105. if (!isset($_GET['type']) || $_GET['type'] === $_resourceTypeName) {
  106. //print $_resourceTypeName;
  107. $_oTypeInfo = $_config->getResourceTypeConfig($_resourceTypeName);
  108. //print_r($_oTypeInfo);
  109. $_oResourceType[$i] = new Ckfinder_Connector_Utils_XmlNode("ResourceType");
  110. $_oResourceTypes->addChild($_oResourceType[$i]);
  111. $_oResourceType[$i]->addAttribute("name", $_resourceTypeName);
  112. $_oResourceType[$i]->addAttribute("url", $_oTypeInfo->getUrl());
  113. $_oResourceType[$i]->addAttribute("allowedExtensions", implode(",", $_oTypeInfo->getAllowedExtensions()));
  114. $_oResourceType[$i]->addAttribute("deniedExtensions", implode(",", $_oTypeInfo->getDeniedExtensions()));
  115. $_oResourceType[$i]->addAttribute("hash", substr(md5($_oTypeInfo->getDirectory()), 0, 16));
  116. $_oResourceType[$i]->addAttribute("hasChildren", CKFinder_Connector_Utils_FileSystem::hasChildren($_oTypeInfo->getDirectory()) ? "true" : "false");
  117. $_oResourceType[$i]->addAttribute("acl", $_aclMask);
  118. }
  119. }
  120. }
  121. $config = $GLOBALS['config'];
  122. if (!empty($config['Plugins']) && is_array($config['Plugins']) ) {
  123. $_oConnInfo->addAttribute("plugins", implode(",", $config['Plugins']));
  124. }
  125. CKFinder_Connector_Core_Hooks::run('InitCommand', array(&$this->_connectorNode));
  126. }
  127. }