/kernel/common/ezincludefunctions.php

https://github.com/GunioRobot/ezpublish · PHP · 189 lines · 103 code · 15 blank · 71 comment · 8 complexity · 1dca22689f410b2916b26bcd3a23a870 MD5 · raw file

  1. <?php
  2. /**
  3. * @copyright Copyright (C) 1999-2011 eZ Systems AS. All rights reserved.
  4. * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
  5. * @version //autogentag//
  6. * @package kernel
  7. */
  8. /**
  9. * kernel files include function for pre eZ Publish 4.0.
  10. *
  11. * @deprecated Since 4.3
  12. */
  13. function kernel_include( $name )
  14. {
  15. $include = "kernel/$name";
  16. return include_once( $include );
  17. }
  18. /**
  19. * kernel/common files include function for pre eZ Publish 4.0.
  20. *
  21. * @deprecated Since 4.3
  22. */
  23. function kernel_common( $name )
  24. {
  25. $name = strtolower( $name );
  26. $include = "kernel/common/$name.php";
  27. return include_once( $include );
  28. }
  29. /**
  30. * datatype include function for pre eZ Publish 4.0.
  31. *
  32. * @deprecated Since 4.3
  33. */
  34. function datatype_class( $datatype, $className )
  35. {
  36. $className = strtolower( $className );
  37. $include = "kernel/classes/datatypes/$datatype/$className.php";
  38. return include_once( $include );
  39. }
  40. /**
  41. * Loose extension path function for include use originally from ezextension.php
  42. *
  43. * @deprecated Since 4.3
  44. */
  45. function extension_path( $extension, $withWWWDir = false, $withHost = false, $withProtocol = false )
  46. {
  47. $base = eZExtension::baseDirectory();
  48. $path = '';
  49. if ( $withProtocol )
  50. {
  51. if ( is_string( $withProtocol ) )
  52. $path .= $withProtocol;
  53. else
  54. {
  55. $path .= eZSys::serverProtocol();
  56. }
  57. $path .= ':';
  58. }
  59. if ( $withHost )
  60. {
  61. $path .= '//';
  62. if ( is_string( $withHost ) )
  63. $path .= $withHost;
  64. else
  65. $path .= eZSys::hostname();
  66. }
  67. if ( $withWWWDir )
  68. $path .= eZSys::wwwDir();
  69. if ( $withWWWDir )
  70. $path .= '/' . $base . '/' . $extension;
  71. else
  72. $path .= $base . '/' . $extension;
  73. return $path;
  74. }
  75. /**
  76. * eZExtension::nameFromPath( __FILE__ ) executed in any file of an extension
  77. * can help you to find the path to additional resources
  78. *
  79. * @param $path Path to check.
  80. * @return Name of the extension a path belongs to.
  81. * @deprecated Since 4.3, use {@link eZExtension::nameFromPath()} instead
  82. */
  83. function nameFromPath( $path )
  84. {
  85. $path = eZDir::cleanPath( $path );
  86. $base = eZExtension::baseDirectory() . '/';
  87. $base = preg_quote( $base, '/' );
  88. $pattern = '/'.$base.'([^\/]+)/';
  89. if ( preg_match( $pattern, $path, $matches ) )
  90. return $matches[1];
  91. else
  92. false;
  93. }
  94. /**
  95. * @param string $path Path to check.
  96. * @return bool True if this path is related to some extension.
  97. * \note The root of an extension is considered to be in this path too.
  98. * @deprecated Since 4.3, use {@link eZExtension::isExtension()} instead
  99. */
  100. function isExtension( $path )
  101. {
  102. if ( eZExtension::nameFromPath( $path ) )
  103. return true;
  104. else
  105. return false;
  106. }
  107. /**
  108. * Includes the file named \a $name in extension \a $extension
  109. * note This works similar to include() meaning that it always includes the file.
  110. * @deprecated Since 4.3
  111. */
  112. function ext_include( $extension, $name )
  113. {
  114. $base = eZExtension::baseDirectory();
  115. $include = "$base/$extension/$name";
  116. return include( $include );
  117. }
  118. /**
  119. * Activates the file named \a $name in extension \a $extension
  120. * note This works similar to include_once() meaning that it's included one time.
  121. * @deprecated Since 4.3
  122. */
  123. function ext_activate( $extension, $name )
  124. {
  125. $base = eZExtension::baseDirectory();
  126. $include = "$base/$extension/$name";
  127. return include_once( $include );
  128. }
  129. /**
  130. * Activates the file named \a $name in extension \a $extension
  131. * note This works similar to include_once() meaning that it's included one time.
  132. *
  133. * @deprecated Since 4.3
  134. */
  135. function ext_class( $extension, $name )
  136. {
  137. $name = strtolower( $name );
  138. $base = eZExtension::baseDirectory();
  139. $include = "$base/$extension/classes/$name.php";
  140. return include_once( $include );
  141. }
  142. /**
  143. * lib include function for pre eZ Publish 4.0.
  144. *
  145. * @deprecated Since 4.3
  146. */
  147. function lib_include( $libName, $name )
  148. {
  149. $include = "lib/$libName/classes/$name";
  150. return include_once( $include );
  151. }
  152. /**
  153. * lib class include function for pre eZ Publish 4.0.
  154. *
  155. * @deprecated Since 4.3
  156. */
  157. function lib_class( $libName, $name )
  158. {
  159. $name = strtolower( $name );
  160. $include = "lib/$libName/classes/$name.php";
  161. return include_once( $include );
  162. }
  163. /**
  164. * kernel class include function for pre eZ Publish 4.0.
  165. *
  166. * @deprecated Since 4.3
  167. */
  168. function kernel_class( $name )
  169. {
  170. $name = strtolower( $name );
  171. $include = "kernel/classes/$name.php";
  172. return include_once( $include );
  173. }
  174. ?>