main_api.lib.test_standalone.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  1. <?php //$id:$
  2. /**
  3. * A simple set of tests for the main API.
  4. * @author Ivan Tcholakov, 2009.
  5. * For licensing terms, see /license.txt
  6. */
  7. class TestMainApi extends UnitTestCase {
  8. function TestMainApi() {
  9. $this->UnitTestCase('Main API tests');
  10. }
  11. public function testApiGetPath() {
  12. $common_paths = array(
  13. WEB_PATH,
  14. SYS_PATH,
  15. REL_PATH,
  16. WEB_COURSE_PATH,
  17. SYS_COURSE_PATH,
  18. REL_COURSE_PATH,
  19. REL_CODE_PATH,
  20. WEB_CODE_PATH,
  21. SYS_CODE_PATH,
  22. SYS_LANG_PATH,
  23. WEB_IMG_PATH,
  24. WEB_CSS_PATH,
  25. SYS_PLUGIN_PATH,
  26. WEB_PLUGIN_PATH,
  27. SYS_ARCHIVE_PATH,
  28. WEB_ARCHIVE_PATH,
  29. INCLUDE_PATH,
  30. LIBRARY_PATH,
  31. CONFIGURATION_PATH,
  32. WEB_LIBRARY_PATH
  33. );
  34. $specific_paths = array(
  35. FLASH_PLAYER_AUDIO,
  36. FLASH_PLAYER_VIDEO,
  37. SCRIPT_SWFOBJECT,
  38. SCRIPT_ASCIIMATHML,
  39. DRAWING_ASCIISVG
  40. );
  41. $res = array();
  42. $is_ok = array();
  43. $message = array();
  44. $paths = array();
  45. $message[] = '';
  46. $message[] = '<strong>A test about api_get_path()</strong>';
  47. $message[] = '---------------------------------------------------------------------------------------------------------------';
  48. $message[] = '';
  49. $message[] = '';
  50. $message[] = 'Changed behaviour of the function api_get_path() after Dokeos 1.8.6.1, i.e. as of Chamilo 1.8.6.2.';
  51. $message[] = '---------------------------------------------------------------------------------------------------------------';
  52. $message[] = '';
  53. $message[] = 'Old behaviour (1.8.6.1) api_get_path(INCLUDE_PATH) = '.api_get_path_1_8_6_1(INCLUDE_PATH).'&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;'.'New behaviour (1.8.6.2) api_get_path(INCLUDE_PATH) = '.api_get_path(INCLUDE_PATH);
  54. $message[] = '* Reason for this change: Difference here is due to the fact that the etalonic old function api_get_path() has ben moved in this file ( see api_get_path_1_8_6_1() ). Even for such rare, hypothetical cases, this widely used function should be stable. Now, after installation, the function returns results based on configuration settings only, as it should be.';
  55. $message[] = '';
  56. $message[] = 'Old behaviour (1.8.6.1) api_get_path(WEB_CSS_PATH) = '.api_get_path_1_8_6_1(WEB_CSS_PATH).'&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;'.'New behaviour (1.8.6.2) api_get_path(WEB_CSS_PATH) = '.api_get_path(WEB_CSS_PATH);
  57. $message[] = '* This is a proposed implementation. Retrieving css paths through user\'s configuration options has not been implemented yet.';
  58. $message[] = '';
  59. $message[] = '';
  60. $message[] = 'Reading common purpose paths';
  61. $message[] = '---------------------------------------------------------------------------------------------------------------';
  62. $message[] = '';
  63. foreach ($common_paths as $path) {
  64. $test_case = "api_get_path($path)";
  65. $res[$test_case] = api_get_path($path);
  66. switch ($path) {
  67. case INCLUDE_PATH:
  68. case WEB_CSS_PATH:
  69. $is_ok[$test_case] = is_string($res[$test_case]) && !empty($res[$test_case]);
  70. break;
  71. default:
  72. $is_ok[$test_case] = is_string($res[$test_case]) && !empty($res[$test_case]) && $res[$test_case] == api_get_path_1_8_6_1($path);
  73. }
  74. $message[] = ($is_ok[$test_case] ? '<span style="color: green; font-weight: bold;">Ok</span>' : '<span style="color: red; font-weight: bold;">Failed</span>').' : '.$test_case.' => '.$res[$test_case];
  75. }
  76. $message[] = '';
  77. $message[] = '';
  78. $message[] = 'Reading specific purpose paths';
  79. $message[] = '---------------------------------------------------------------------------------------------------------------';
  80. $message[] = '';
  81. foreach ($specific_paths as $path) {
  82. $test_case = "api_get_path(TO_WEB, $path)";
  83. $test_case = str_replace(array('{', '}'), '', $test_case);
  84. $res[$test_case] = api_get_path(TO_WEB, $path);
  85. $is_ok[$test_case] = is_string($res[$test_case]) && !empty($res[$test_case]);
  86. $message[] = ($is_ok[$test_case] ? '<span style="color: green; font-weight: bold;">Ok</span>' : '<span style="color: red; font-weight: bold;">Failed</span>').' : '.$test_case.' => '.$res[$test_case];
  87. $paths[] = $path;
  88. $test_case = "api_get_path(TO_SYS, $path)";
  89. $test_case = str_replace(array('{', '}'), '', $test_case);
  90. $res[$test_case] = api_get_path(TO_SYS, $path);
  91. $is_ok[$test_case] = is_string($res[$test_case]) && !empty($res[$test_case]);
  92. $message[] = ($is_ok[$test_case] ? '<span style="color: green; font-weight: bold;">Ok</span>' : '<span style="color: red; font-weight: bold;">Failed</span>').' : '.$test_case.' => '.$res[$test_case];
  93. $paths[] = $path;
  94. $test_case = "api_get_path(TO_REL, $path)";
  95. $test_case = str_replace(array('{', '}'), '', $test_case);
  96. $res[$test_case] = api_get_path(TO_REL, $path);
  97. $is_ok[$test_case] = is_string($res[$test_case]) && !empty($res[$test_case]);
  98. $message[] = ($is_ok[$test_case] ? '<span style="color: green; font-weight: bold;">Ok</span>' : '<span style="color: red; font-weight: bold;">Failed</span>').' : '.$test_case.' => '.$res[$test_case];
  99. $paths[] = $path;
  100. }
  101. $message[] = '';
  102. $message[] = '';
  103. $message[] = 'Testing path conversions';
  104. $message[] = '---------------------------------------------------------------------------------------------------------------';
  105. $message[] = '';
  106. $paths = array();
  107. foreach ($common_paths as $path) {
  108. $paths[] = array($path, api_get_path($path));
  109. }
  110. foreach ($specific_paths as $path) {
  111. $paths[] = array($path, api_get_path(TO_WEB, $path));
  112. $paths[] = array($path, api_get_path(TO_SYS, $path));
  113. $paths[] = array($path, api_get_path(TO_REL, $path));
  114. }
  115. foreach ($paths as $path) {
  116. $test_case = 'api_get_path(TO_WEB, '.$path[0].')';
  117. $test_case = str_replace(array('{', '}'), '', $test_case);
  118. $res[$test_case] = api_get_path(TO_WEB, $path[0]);
  119. $test_case_1 = 'api_get_path(TO_WEB, \''.$path[1].'\')';
  120. $res[$test_case_1] = api_get_path(TO_WEB, $path[1]);
  121. $is_ok[$test_case] =
  122. is_string($res[$test_case]) && !empty($res[$test_case])
  123. && is_string($res[$test_case_1]) && !empty($res[$test_case_1])
  124. && $res[$test_case] == $res[$test_case_1];
  125. $message[] = ($is_ok[$test_case] ? '<span style="color: green; font-weight: bold;">Ok</span>' : '<span style="color: red; font-weight: bold;">Failed</span>').' : ';
  126. $message[] = $test_case.' => '.$res[$test_case];
  127. $message[] = $test_case_1.' => '.$res[$test_case_1];
  128. $message[] = '';
  129. $test_case = 'api_get_path(TO_SYS, '.$path[0].')';
  130. $test_case = str_replace(array('{', '}'), '', $test_case);
  131. $res[$test_case] = api_get_path(TO_SYS, $path[0]);
  132. $test_case_1 = 'api_get_path(TO_SYS, \''.$path[1].'\')';
  133. $res[$test_case_1] = api_get_path(TO_SYS, $path[1]);
  134. $is_ok[$test_case] =
  135. is_string($res[$test_case]) && !empty($res[$test_case])
  136. && is_string($res[$test_case_1]) && !empty($res[$test_case_1])
  137. && $res[$test_case] == $res[$test_case_1];
  138. $message[] = ($is_ok[$test_case] ? '<span style="color: green; font-weight: bold;">Ok</span>' : '<span style="color: red; font-weight: bold;">Failed</span>').' : ';
  139. $message[] = $test_case.' => '.$res[$test_case];
  140. $message[] = $test_case_1.' => '.$res[$test_case_1];
  141. $message[] = '';
  142. $test_case = 'api_get_path(TO_REL, '.$path[0].')';
  143. $test_case = str_replace(array('{', '}'), '', $test_case);
  144. $res[$test_case] = api_get_path(TO_REL, $path[0]);
  145. $test_case_1 = 'api_get_path(TO_REL, \''.$path[1].'\')';
  146. $res[$test_case_1] = api_get_path(TO_REL, $path[1]);
  147. $is_ok[$test_case] =
  148. is_string($res[$test_case]) && !empty($res[$test_case])
  149. && is_string($res[$test_case_1]) && !empty($res[$test_case_1])
  150. && $res[$test_case] == $res[$test_case_1];
  151. $message[] = ($is_ok[$test_case] ? '<span style="color: green; font-weight: bold;">Ok</span>' : '<span style="color: red; font-weight: bold;">Failed</span>').' : ';
  152. $message[] = $test_case.' => '.$res[$test_case];
  153. $message[] = $test_case_1.' => '.$res[$test_case_1];
  154. $message[] = '';
  155. }
  156. $message[] = '';
  157. $message[] = 'Random examples, check them visually';
  158. $message[] = '---------------------------------------------------------------------------------------------------------------';
  159. $message[] = '';
  160. $message[] = '$_SERVER[\'REQUEST_URI\'] => '.$_SERVER['REQUEST_URI'];
  161. $message[] = '<strong>Note:</strong> Try some query strings. They should be removed from the results.';
  162. $message[] = 'api_get_path(TO_WEB, $_SERVER[\'REQUEST_URI\']) => '.api_get_path(TO_WEB, $_SERVER['REQUEST_URI']);
  163. $message[] = 'api_get_path(TO_SYS, $_SERVER[\'REQUEST_URI\']) => '.api_get_path(TO_SYS, $_SERVER['REQUEST_URI']);
  164. $message[] = 'api_get_path(TO_REL, $_SERVER[\'REQUEST_URI\']) => '.api_get_path(TO_REL, $_SERVER['REQUEST_URI']);
  165. $message[] = '';
  166. $message[] = '__FILE__ => '.__FILE__;
  167. $message[] = 'api_get_path(TO_WEB, __FILE__) => '.api_get_path(TO_WEB, __FILE__);
  168. $message[] = 'api_get_path(TO_SYS, __FILE__) => '.api_get_path(TO_SYS, __FILE__);
  169. $message[] = 'api_get_path(TO_REL, __FILE__) => '.api_get_path(TO_REL, __FILE__);
  170. $message[] = '';
  171. $message[] = '$_SERVER[\'PHP_SELF\'] => '.$_SERVER['PHP_SELF'];
  172. $message[] = 'api_get_path(TO_WEB, $_SERVER[\'PHP_SELF\']) => '.api_get_path(TO_WEB, $_SERVER['PHP_SELF']);
  173. $message[] = 'api_get_path(TO_SYS, $_SERVER[\'PHP_SELF\']) => '.api_get_path(TO_SYS, $_SERVER['PHP_SELF']);
  174. $message[] = 'api_get_path(TO_REL, $_SERVER[\'PHP_SELF\']) => '.api_get_path(TO_REL, $_SERVER['PHP_SELF']);
  175. $message[] = '';
  176. $message[] = '';
  177. $message[] = '---------------------------------------------------------------------------------------------------------------';
  178. $message[] = 'This test and changes of behaviour of api_get_path() have been done by Ivan Tcholakov, September 22, 2009.';
  179. $message[] = '';
  180. $result = !in_array(false, $is_ok);
  181. $this->assertTrue($result);
  182. //var_dump($res);
  183. foreach ($message as $line) { echo $line.'<br />'; }
  184. // Sample code for showing results in different context.
  185. /*
  186. $common_paths = array(
  187. WEB_PATH,
  188. SYS_PATH,
  189. REL_PATH,
  190. WEB_SERVER_ROOT_PATH,
  191. WEB_COURSE_PATH,
  192. SYS_COURSE_PATH,
  193. REL_COURSE_PATH,
  194. REL_CODE_PATH,
  195. WEB_CODE_PATH,
  196. SYS_CODE_PATH,
  197. SYS_LANG_PATH,
  198. WEB_IMG_PATH,
  199. WEB_CSS_PATH,
  200. SYS_PLUGIN_PATH,
  201. WEB_PLUGIN_PATH,
  202. SYS_ARCHIVE_PATH,
  203. WEB_ARCHIVE_PATH,
  204. INCLUDE_PATH,
  205. LIBRARY_PATH,
  206. CONFIGURATION_PATH,
  207. WEB_LIBRARY_PATH
  208. );
  209. $specific_paths = array(
  210. FLASH_PLAYER_AUDIO,
  211. FLASH_PLAYER_VIDEO,
  212. SCRIPT_SWFOBJECT,
  213. SCRIPT_ASCIIMATHML,
  214. DRAWING_ASCIISVG
  215. );
  216. $res = array();
  217. $is_ok = array();
  218. $message = array();
  219. $paths = array();
  220. $message[] = '';
  221. $message[] = 'Reading common purpose paths';
  222. $message[] = '---------------------------------------------------------------------------------------------------------------';
  223. $message[] = '';
  224. foreach ($common_paths as $path) {
  225. $test_case = "api_get_path($path)";
  226. $res[$test_case] = api_get_path($path);
  227. $message[] = $test_case.' => '.$res[$test_case];
  228. }
  229. $message[] = '';
  230. $message[] = '';
  231. $message[] = 'Reading specific purpose paths';
  232. $message[] = '---------------------------------------------------------------------------------------------------------------';
  233. $message[] = '';
  234. foreach ($specific_paths as $path) {
  235. $test_case = "api_get_path(TO_WEB, $path)";
  236. $test_case = str_replace(array('{', '}'), '', $test_case);
  237. $res[$test_case] = api_get_path(TO_WEB, $path);
  238. $message[] = $test_case.' => '.$res[$test_case];
  239. $paths[] = $path;
  240. $test_case = "api_get_path(TO_SYS, $path)";
  241. $test_case = str_replace(array('{', '}'), '', $test_case);
  242. $res[$test_case] = api_get_path(TO_SYS, $path);
  243. $message[] = $test_case.' => '.$res[$test_case];
  244. $paths[] = $path;
  245. $test_case = "api_get_path(TO_REL, $path)";
  246. $test_case = str_replace(array('{', '}'), '', $test_case);
  247. $res[$test_case] = api_get_path(TO_REL, $path);
  248. $message[] = $test_case.' => '.$res[$test_case];
  249. $paths[] = $path;
  250. }
  251. foreach ($message as $line) { echo $line.'<br />'; }
  252. */
  253. }
  254. public function testApiIsInternalPath() {
  255. $path1 = api_get_path(WEB_IMG_PATH);
  256. $path2 = 'http://kdflskfsenfnmzsdn/fnefsdsmdsdmsdfsdcmxaddfdafada/index.html';
  257. $path3 = api_get_path(TO_SYS, WEB_IMG_PATH);
  258. $path4 = 'C:\Inetpub\wwwroot\fnefsdsmdsdmsdfsdcmxaddfdafada/index.html';
  259. $path5 = api_get_path(TO_REL, WEB_IMG_PATH);
  260. $path6 = '/fnefsdsmdsdmsdfsdcmxaddfdafada/index.html';
  261. $res1 = api_is_internal_path($path1);
  262. $res2 = api_is_internal_path($path2);
  263. $res3 = api_is_internal_path($path3);
  264. $res4 = api_is_internal_path($path4);
  265. $res5 = api_is_internal_path($path5);
  266. $res6 = api_is_internal_path($path6);
  267. $this->assertTrue(is_bool($res1) && is_bool($res2) && is_bool($res3) && is_bool($res4) && is_bool($res5) && is_bool($res6)
  268. && $res1 && !$res2 && $res3 && !$res4 && $res5 && !$res6);
  269. //var_dump($res1);
  270. //var_dump($res2);
  271. //var_dump($res1);
  272. //var_dump($res2);
  273. //var_dump($res1);
  274. //var_dump($res2);
  275. }
  276. public function testApiAddTrailingSlash() {
  277. $string1 = 'path';
  278. $string2 = 'path/';
  279. $res1 = api_add_trailing_slash($string1);
  280. $res2 = api_add_trailing_slash($string2);
  281. $this->assertTrue(is_string($res1) && is_string($res2) && $res1 == $res2);
  282. //var_dump($res1);
  283. //var_dump($res2);
  284. }
  285. public function testRemoveAddTrailingSlash() {
  286. $string1 = 'path';
  287. $string2 = 'path/';
  288. $res1 = api_remove_trailing_slash($string1);
  289. $res2 = api_remove_trailing_slash($string2);
  290. $this->assertTrue(is_string($res1) && is_string($res2) && $res1 == $res2);
  291. //var_dump($res1);
  292. //var_dump($res2);
  293. }
  294. }
  295. /**
  296. * Returns a full path to a certain Dokeos area, which you specify
  297. * through a parameter.
  298. *
  299. * See $_configuration['course_folder'] in the configuration.php
  300. * to alter the WEB_COURSE_PATH and SYS_COURSE_PATH parameters.
  301. *
  302. * @param one of the following constants:
  303. * WEB_SERVER_ROOT_PATH, SYS_SERVER_ROOT_PATH,
  304. * WEB_PATH, SYS_PATH, REL_PATH, WEB_COURSE_PATH, SYS_COURSE_PATH,
  305. * REL_COURSE_PATH, REL_CODE_PATH, WEB_CODE_PATH, SYS_CODE_PATH,
  306. * SYS_LANG_PATH, WEB_IMG_PATH, GARBAGE_PATH, WEB_PLUGIN_PATH, SYS_PLUGIN_PATH, WEB_ARCHIVE_PATH, SYS_ARCHIVE_PATH,
  307. * INCLUDE_PATH, WEB_LIBRARY_PATH, LIBRARY_PATH, CONFIGURATION_PATH
  308. *
  309. * @example assume that your server root is /var/www/ chamilo is installed in a subfolder chamilo/ and the URL of your campus is http://www.mychamilo.com
  310. * The other configuration paramaters have not been changed.
  311. * The different api_get_paths will give
  312. * WEB_SERVER_ROOT_PATH http://www.mychamilo.com/
  313. * SYS_SERVER_ROOT_PATH /var/www/ - This is the physical folder where the system Dokeos has been placed. It is not always equal to $_SERVER['DOCUMENT_ROOT'].
  314. * WEB_PATH http://www.mychamilo.com/chamilo/
  315. * SYS_PATH /var/www/chamilo/
  316. * REL_PATH chamilo/
  317. * WEB_COURSE_PATH http://www.mychamilo.com/chamilo/courses/
  318. * SYS_COURSE_PATH /var/www/chamilo/courses/
  319. * REL_COURSE_PATH /chamilo/courses/
  320. * REL_CODE_PATH /chamilo/main/
  321. * WEB_CODE_PATH http://www.mychamilo.com/chamilo/main/
  322. * SYS_CODE_PATH /var/www/chamilo/main/
  323. * SYS_LANG_PATH /var/www/chamilo/main/lang/
  324. * WEB_IMG_PATH http://www.mychamilo.com/chamilo/main/img/
  325. * GARBAGE_PATH
  326. * WEB_PLUGIN_PATH http://www.mychamilo.com/chamilo/plugin/
  327. * SYS_PLUGIN_PATH /var/www/chamilo/plugin/
  328. * WEB_ARCHIVE_PATH http://www.mychamilo.com/chamilo/archive/
  329. * SYS_ARCHIVE_PATH /var/www/chamilo/archive/
  330. * INCLUDE_PATH /var/www/chamilo/main/inc/
  331. * WEB_LIBRARY_PATH http://www.mychamilo.com/chamilo/main/inc/lib/
  332. * LIBRARY_PATH /var/www/chamilo/main/inc/lib/
  333. * CONFIGURATION_PATH /var/www/chamilo/main/inc/conf/
  334. */
  335. function api_get_path_1_8_6_1($path_type) {
  336. global $_configuration;
  337. if (!isset($_configuration['access_url']) || $_configuration['access_url']==1 || $_configuration['access_url']=='') {
  338. //by default we call the $_configuration['root_web'] we don't query to the DB
  339. //$url_info= api_get_access_url(1);
  340. //$root_web = $url_info['url'];
  341. if(isset($_configuration['root_web']))
  342. $root_web = $_configuration['root_web'];
  343. } else {
  344. //we look into the DB the function api_get_access_url
  345. //this funcion have a problem because we can't called to the Database:: functions
  346. $url_info= api_get_access_url($_configuration['access_url']);
  347. if ($url_info['active']==1) {
  348. $root_web = $url_info['url'];
  349. } else {
  350. $root_web = $_configuration['root_web'];
  351. }
  352. }
  353. switch ($path_type) {
  354. case WEB_PATH :
  355. // example: http://www.mychamilo.com/ or http://www.mychamilo.com/chamilo/ if you're using
  356. // a subdirectory of your document root for Dokeos
  357. if (substr($root_web,-1) == '/') {
  358. return $root_web;
  359. } else {
  360. return $root_web.'/';
  361. }
  362. break;
  363. case SYS_PATH :
  364. // example: /var/www/chamilo/
  365. if (substr($_configuration['root_sys'],-1) == '/') {
  366. return $_configuration['root_sys'];
  367. } else {
  368. return $_configuration['root_sys'].'/';
  369. }
  370. break;
  371. case REL_PATH :
  372. // example: chamilo/
  373. if (substr($_configuration['url_append'], -1) === '/') {
  374. return $_configuration['url_append'];
  375. } else {
  376. return $_configuration['url_append'].'/';
  377. }
  378. break;
  379. case WEB_COURSE_PATH :
  380. // example: http://www.mychamilo.com/courses/
  381. return $root_web.$_configuration['course_folder'];
  382. break;
  383. case SYS_COURSE_PATH :
  384. // example: /var/www/chamilo/courses/
  385. return $_configuration['root_sys'].$_configuration['course_folder'];
  386. break;
  387. case REL_COURSE_PATH :
  388. // example: courses/ or chamilo/courses/
  389. return api_get_path(REL_PATH).$_configuration['course_folder'];
  390. break;
  391. case REL_CODE_PATH :
  392. // example: main/ or chamilo/main/
  393. return api_get_path(REL_PATH).$_configuration['code_append'];
  394. break;
  395. case WEB_CODE_PATH :
  396. // example: http://www.mychamilo.com/main/
  397. return $root_web.$_configuration['code_append'];
  398. break;
  399. case SYS_CODE_PATH :
  400. // example: /var/www/chamilo/main/
  401. return $_configuration['root_sys'].$_configuration['code_append'];
  402. break;
  403. case SYS_LANG_PATH :
  404. // example: /var/www/chamilo/main/lang/
  405. return api_get_path(SYS_CODE_PATH).'lang/';
  406. break;
  407. case WEB_IMG_PATH :
  408. // example: http://www.mychamilo.com/main/img/
  409. return api_get_path(WEB_CODE_PATH).'img/';
  410. break;
  411. case SYS_PLUGIN_PATH :
  412. // example: /var/www/chamilo/plugin/
  413. return api_get_path(SYS_PATH).'plugin/';
  414. break;
  415. case WEB_PLUGIN_PATH :
  416. // example: http://www.mychamilo.com/plugin/
  417. return api_get_path(WEB_PATH).'plugin/';
  418. break;
  419. case GARBAGE_PATH : //now set to be same as archive
  420. case SYS_ARCHIVE_PATH :
  421. // example: /var/www/chamilo/archive/
  422. return api_get_path(SYS_PATH).'archive/';
  423. break;
  424. case WEB_ARCHIVE_PATH :
  425. // example: http://www.mychamilo.com/archive/
  426. return api_get_path(WEB_PATH).'archive/';
  427. break;
  428. case INCLUDE_PATH :
  429. // Generated by main/inc/global.inc.php
  430. // example: /var/www/chamilo/main/inc/
  431. $incpath = realpath(dirname(__FILE__).'/../');
  432. return str_replace('\\', '/', $incpath).'/';
  433. break;
  434. case LIBRARY_PATH :
  435. // example: /var/www/chamilo/main/inc/lib/
  436. return api_get_path(INCLUDE_PATH).'lib/';
  437. break;
  438. case WEB_LIBRARY_PATH :
  439. // example: http://www.mychamilo.com/main/inc/lib/
  440. return api_get_path(WEB_CODE_PATH).'inc/lib/';
  441. break;
  442. case CONFIGURATION_PATH :
  443. // example: /var/www/chamilo/main/inc/conf/
  444. return api_get_path(INCLUDE_PATH).'conf/';
  445. break;
  446. default :
  447. return;
  448. break;
  449. }
  450. }
  451. ?>