PageRenderTime 67ms CodeModel.GetById 30ms RepoModel.GetById 1ms app.codeStats 0ms

/classes/class_Breadcrumb.php

https://gitlab.com/kinopsis/torrecentral
PHP | 1058 lines | 600 code | 94 blank | 364 comment | 202 complexity | b4c13354b2e4bb011f69f1d6cafdac4e MD5 | raw file
Possible License(s): LGPL-3.0, MIT, Apache-2.0
  1. <?php
  2. /**
  3. * File: $Id: class.breadcrumb.inc.php, 2005/01/08 05:15 PST
  4. * <p><b>Purpose of file:</b> Show the directories and their links in path
  5. * form:<br>
  6. * <samp>Home > Firstdir > Seconddir > Etc > filename.php</samp></p>
  7. * <p><b>Information:</b> If you use this script please contact me with a url
  8. * or product information plus the product :) and please keep all header
  9. * information intact. Cheers!</p>
  10. * <p><b>Pay-Pal info:</b> paypal@baskettcase.com</p>
  11. *
  12. * @author Richard Baskett <rick@baskettcase.com>
  13. * @category directory structure
  14. * @copyright Copyright © 2008, Baskettcase Web Development
  15. * @example example.php
  16. * @link http://www.baskettcase.com/classes/breadcrumb/
  17. * @link mailto:paypal@baskettcase.com
  18. * @package breadcrumb
  19. * @version 2.4.4
  20. */
  21. class breadcrumb {
  22. var $eDirCrumbs = array();
  23. var $link = array();
  24. var $module = '';
  25. var $section = '';
  26. /**
  27. * eDirectory SubFolder
  28. *
  29. * Set subfolder path.
  30. * <code>$breadcrumb->subFolder = EDIRECTORY_FOLDER;</code>
  31. * @var string
  32. */
  33. var $subFolder = '';
  34. /**
  35. * Hide Home Page Breadcrumb
  36. *
  37. * Hide breadcrumbs on home page.
  38. * <code>$breadcrumb->hideHome = TRUE;</code>
  39. * @var bool
  40. * @since Version 2.4.4
  41. */
  42. var $hideHome = FALSE;
  43. /**
  44. * Set Root Index Page
  45. *
  46. * Sets the root index page link for those who have a splash page and do not
  47. * want the home breadcrumb to take them to the splashpage.
  48. * <code>$breadcrumb->rootIndexLink = 'index2.php';</code>
  49. * @var string
  50. * @since Version 2.4.4
  51. */
  52. var $rootIndexLink = '';
  53. /**
  54. * Homepage naming
  55. *
  56. * A person can use any name for the homepage/base directory or not show it at
  57. * all.
  58. * <code>$breadcrumb->homepage = 'homepage';</code><br>
  59. * <b>Example:</b>
  60. * <samp>homepage > Baskettcase > php_classes > breadcrumb > index.htm</samp>
  61. * <br><br><code>$breadcrumb->homepage = '';</code><br>
  62. * <b>Example:</b>
  63. * <samp>Baskettcase > php_classes > breadcrumb > index.htm</samp>
  64. * @var string
  65. * @since Version 1.0.0
  66. */
  67. var $homepage = 'home';
  68. /**
  69. * Case formatting
  70. *
  71. * Specify the format you would like the directory names to be in, first
  72. * letters uppercase, all uppercase, all lowercase, or the actual naming of
  73. * your directory with no changes.
  74. * - string_ucwords = uppers case words (use with _toSpace)
  75. * - titlecase = upper case words except small words (the, is, with, etc)
  76. * - ucfirst = upper case first letter
  77. * - uppercase = all uppercase
  78. * - lowercase = all lowercase
  79. * - none = show directories as they are named in path structure (DEFAULT)
  80. *
  81. * <code>$breadcrumb->dirformat = 'ucfirst';</code><br>
  82. * <b>Example:</b>
  83. * <samp>Baskettcase > Php_classes > Breadcrumb > Index.htm</samp>
  84. * @var string ucfirst, uppercase, lowercase, string_ucwords, titlecase
  85. * @since Version 1.0.0
  86. */
  87. var $dirformat = '';
  88. /**
  89. * Symbol separator
  90. *
  91. * Specify what symbols to use between your directory names.
  92. * <pre>DEFAULT = ' > '</pre>
  93. * <code>$breadcrumb->symbol = ' || ';</code><br>
  94. * <b>Example:</b>
  95. * <samp>Baskettcase || php_classes || breadcrumb || index.htm</samp>
  96. * @var string
  97. * @since Version 1.0.0
  98. */
  99. var $symbol = ' &gt; ';
  100. /**
  101. * CSS Class Style
  102. *
  103. * Use a css class to define the look of your breadcrumb.
  104. * <code>$breadcrumb->cssClass = 'crumb';</code><br>
  105. * @var string
  106. * @since Version 2.3.0
  107. */
  108. var $cssClass = '';
  109. /**
  110. * Special formatting
  111. *
  112. * I also added a "special" formatting which allows you to show the path as if
  113. * Elmer Fudd wrote it, or a Hacker wrote it, or in Reverse or hey even in pig
  114. * latin!
  115. * - elmer = elmer fudd translation
  116. * - hacker = hacker speach translation
  117. * - pig = pig latin translation
  118. * - reverse = Reverses the text so it is backwards
  119. * - none = no special formatting (DEFAULT)
  120. *
  121. * <code>$breadcrumb->special = 'elmer';</code><br>
  122. * <b>Example:</b>
  123. * <samp>Baskettcase > php_cwasses > bweadcwumb > index.htm</samp>
  124. * @var string elmer, hacker, pig, reverse, none
  125. * @since Version 1.0.0
  126. */
  127. var $special = '';
  128. /**
  129. * Frameset Target
  130. *
  131. * Target a frameset.
  132. * <code>$breadcrumb->target = '_blank';</code>
  133. * @var string
  134. * @since Version 2.4.0
  135. */
  136. var $target = '';
  137. /**
  138. * Show filename
  139. *
  140. * Specify whether or not to show the current file name, just show the path or
  141. * show the path with the file name.
  142. * <code>$breadcrumb->showfile = FALSE;</code><br>
  143. * <b>Example:</b>
  144. * <samp>homepage > Baskettcase > php_classes > breadcrumb</samp>
  145. * <br><br><code>$breadcrumb->showfile = TRUE;</code><br>
  146. * <b>Example:</b>
  147. * <samp>Baskettcase > php_classes > breadcrumb > index.htm</samp>
  148. * @var bool
  149. * @since Version 1.0.0
  150. */
  151. var $showfile = TRUE;
  152. /**
  153. * Unlink Current Directory
  154. *
  155. * Removes the current directory link.
  156. * <code>$breadcrumb->unlinkCurrentDir = TRUE;</code>
  157. * @var bool
  158. */
  159. var $unlinkCurrentDir = FALSE;
  160. /**
  161. * Hide File Extension
  162. *
  163. * Hides the filename extension
  164. * <code>$breadcrumb->hideFileExt = TRUE;</code><br>
  165. * <b>Example:</b>
  166. * <samp>Baskettcase > php_classes > breadcrumb > index</samp>
  167. * @var bool
  168. * @since Version 2.4.2
  169. */
  170. var $hideFileExt = FALSE;
  171. /**
  172. * Filename Linking
  173. *
  174. * Links the filename to itself.
  175. * <code>$breadcrumb->linkFile = TRUE;</code>
  176. * @var bool
  177. * @since Version 2.4.0
  178. */
  179. var $linkFile = FALSE;
  180. /**
  181. * Replace Underscores
  182. *
  183. * Replace underscores with spaces.
  184. * <code>$breadcrumb->_toSpace = TRUE;</code><br>
  185. * <b>Example:</b>
  186. * <samp>Baskettcase > php classes > breadcrumb > index.htm</samp>
  187. * @link http://www.baskettcase.com/classes/breadcrumb/test_dir_with_underscores/underscore.php
  188. * @var bool
  189. * @since Version 2.3.0
  190. */
  191. var $_toSpace = FALSE;
  192. /**
  193. * Use images
  194. *
  195. * Use images in place of text for your breadcrumbs, by specifying the
  196. * directory the images can be found in. You can also specify the image type
  197. * (gif, jpg, etc), border, id, name, hspace, vspace, align, height, width, and
  198. * alt attributes. I have also included an example of how to use an image for
  199. * the separator character. If you use the changeName function along with
  200. * images, the alt attribute will be the changed name, while the id and name
  201. * attributes will remain the actual directory name.
  202. * <code>$breadcrumb->imagedir = array('path'=>'images/', 'type'=>'gif', 'border'=>2, 'id'=>FALSE, 'name'=>TRUE,
  203. * 'hspace'=>2, 'vspace'=>4, 'align'=>'top', 'height'=>20, 'width'=>75, 'alt'=>TRUE, 'title'=>TRUE);</code>
  204. * @var array path, type, border, id, name, hspace, vspace, align, height, width, alt, title
  205. * @since Version 2.0.0
  206. */
  207. var $imagedir = array();
  208. /**
  209. * Directory aliasing
  210. *
  211. * Rename your directories to whatever you would like them to show up as in
  212. * your breadcrumb.
  213. * <code>$breadcrumb->changeName=array('home'=>'Baskettcase Homepage',
  214. * 'php_classes'=>'PHP Classes',
  215. * 'breadcrumb'=>'Breadcrumbs Class');</code><br>
  216. * <b>Example:</b>
  217. * <samp>Baskettcase Homepage > PHP Classes > Breadcrumbs Class > index.htm</samp>
  218. * @var array
  219. * @since Version 1.0.0
  220. */
  221. var $changeName = array();
  222. /**
  223. * Filename Aliasing
  224. *
  225. * Change the filename to a more user friendly one.
  226. * <code>$breadcrumb->changeFileName = array('/classes/breadcrumb/index.htm'=>'Breadcrumbs PHP Class v. 2.4.4');</code><br>
  227. * <b>Example:</b>
  228. * <samp>Baskettcase > php_classes > breadcrumb > Breadcrumbs PHP Class v. 2.4.4</samp>
  229. * @var array
  230. * @since Version 2.3.7
  231. */
  232. var $changeFileName = array();
  233. var $changeGeneralName = array();
  234. /**
  235. * Index exists?
  236. *
  237. * <p>Set your index file name so that if the file exists then link the
  238. * directory, otherwise if the file does not exist do not create a link.</p>
  239. * <p>This is good for those people that do not want surfers to be able to look
  240. * at their directory structure if they do not have a default index page within
  241. * that directory. It will still show the directory name within the breadcrumb,
  242. * but it will not add a link to the directory name.</p>
  243. * <code>$breadcrumb->fileExists = array('index.htm','index.php','index.html');</code>
  244. * @var array
  245. * @since Version 1.0.0
  246. */
  247. var $fileExists = array();
  248. /**
  249. * Remove Directories
  250. *
  251. * Hide a directory from showing in the breadcrumb.
  252. * <code>$breadcrumb->removeDirs = array('php_classes');</code><br>
  253. * <b>Example:</b>
  254. * <samp>homepage > Baskettcase > breadcrumb > index.htm</samp>
  255. * @var array
  256. * @since Version 2.3.7
  257. */
  258. var $removeDirs = array();
  259. /**
  260. * Directory Structure
  261. * @access private
  262. */
  263. var $scriptArray = '';
  264. /**
  265. * File name
  266. * @access private
  267. */
  268. var $fileName = '';
  269. /**
  270. * Document Root
  271. * @access private
  272. */
  273. var $document_root = '';
  274. /**
  275. * is this a personal site?
  276. * @access private
  277. */
  278. var $personalSite = '';
  279. /**
  280. * Show errors
  281. * @access private
  282. */
  283. var $showErrors = FALSE;
  284. /**
  285. * Breadcrumb
  286. * @since Version 2.0.0
  287. * @access private
  288. */
  289. var $alias_allcategories = '';
  290. function breadcrumb() {
  291. // Creates an array of Directory Structure
  292. $this->scriptArray = explode("/", $_SERVER['REQUEST_URI']);
  293. // Pops the filename off the end and throws it into it's own variable
  294. $this->fileName = array_pop($this->scriptArray);
  295. // Is this a personal site?
  296. if (string_substr($_SERVER['REQUEST_URI'], 1, 1) == '~') {
  297. $tmp = explode('/', $_SERVER['REQUEST_URI']);
  298. $this->personalSite = $tmp[1];
  299. $this->document_root = str_replace(str_replace('/' . $this->personalSite, '', $_SERVER["SCRIPT_NAME"]), '', $_SERVER['PATH_TRANSLATED']);
  300. } else {
  301. $this->document_root = str_replace($_SERVER["SCRIPT_NAME"], '', $_SERVER['PATH_TRANSLATED']);
  302. }
  303. }
  304. /**
  305. * Converts a string to an array
  306. * @since Version 2.2.0
  307. * @access private
  308. */
  309. function str_split($string) {
  310. for ($i = 0; $i < string_strlen($string); $i++)
  311. $array[] = $string{$i};
  312. return $array;
  313. }
  314. /**
  315. * Convert string into language specified
  316. * @since Version 2.0.0
  317. * @access private
  318. */
  319. function specialLang($string, $lang) {
  320. // parse Directory special text style
  321. switch ($lang) {
  322. case 'elmer': $string = str_replace('l', 'w', $string);
  323. $string = str_replace('r', 'w', $string);
  324. break;
  325. case 'hacker': $string = string_strtoupper($string);
  326. $string = str_replace('A', '&#52;', $string);
  327. $string = str_replace('C', '&#40;', $string);
  328. $string = str_replace('D', '&#68;', $string);
  329. $string = str_replace('E', '&#51;', $string);
  330. $string = str_replace('F', '&#112;&#104;', $string);
  331. $string = str_replace('G', '&#54;', $string);
  332. $string = str_replace('H', '&#125;&#123;', $string);
  333. $string = str_replace('I', '&#49;', $string);
  334. $string = str_replace('M', '&#124;&#86;&#124;', $string);
  335. $string = str_replace('N', '&#124;&#92;&#124;', $string);
  336. $string = str_replace('O', '&#48;', $string);
  337. $string = str_replace('R', '&#82;', $string);
  338. $string = str_replace('S', '&#53;', $string);
  339. $string = str_replace('T', '&#55;', $string);
  340. break;
  341. case 'pig': $vowels = array('a', 'A', 'e', 'E', 'i', 'I', 'o', 'O', 'u', 'U');
  342. $string = $this->str_split($string);
  343. $firstLetter = array_shift($string);
  344. $string = @implode('', $string);
  345. $string = (in_array($firstLetter, $vowels)) ? $firstLetter . $string . 'yay' : $string . $firstLetter . 'ay';
  346. break;
  347. case 'reverse': $string = strrev($string);
  348. break;
  349. }
  350. return $string;
  351. }
  352. function multiLanguage($string) {
  353. if (!strcmp($string, 'home')) {
  354. $string = system_showText(LANG_MENU_HOME);
  355. } elseif (!strcmp($string, LISTING_FEATURE_FOLDER)) {
  356. $string = system_showText(LANG_LISTING_FEATURE_NAME_PLURAL);
  357. } elseif (!strcmp($string, ARTICLE_FEATURE_FOLDER)) {
  358. $string = system_showText(LANG_ARTICLE_FEATURE_NAME_PLURAL);
  359. } elseif (!strcmp($string, EVENT_FEATURE_FOLDER)) {
  360. $string = system_showText(LANG_EVENT_FEATURE_NAME_PLURAL);
  361. } elseif (!strcmp($string, PROMOTION_FEATURE_FOLDER)) {
  362. $string = system_showText(LANG_PROMOTION_FEATURE_NAME_PLURAL);
  363. } elseif (!strcmp($string, CLASSIFIED_FEATURE_FOLDER)) {
  364. $string = system_showText(LANG_CLASSIFIED_FEATURE_NAME_PLURAL);
  365. } elseif ($string == ALIAS_BESTOF_URL_DIVISOR) {
  366. $string = system_showText(LANG_MENU_BESTOF);
  367. }
  368. return $string;
  369. }
  370. /**
  371. * Convert string into specified format
  372. * @since Version 2.2.0
  373. * @access private
  374. */
  375. function dirFormat($string, $format) {
  376. // parse Directory text style
  377. switch ($format) {
  378. case 'titlecase': $string = $this->titleCase($string);
  379. break;
  380. case 'ucfirst': $string = ucfirst($string);
  381. break;
  382. case 'string_ucwords': $string = $this->convertUnderScores($string);
  383. $string = string_ucwords($string);
  384. break;
  385. case 'uppercase': $string = string_strtoupper($string);
  386. break;
  387. case 'lowercase': $string = string_strtolower($string);
  388. break;
  389. default: $string = $string;
  390. }
  391. return $string;
  392. }
  393. /**
  394. * TitleCase
  395. * Convert string into Title Case which excludes capitalizing certain small
  396. * words. As in a movie title, or book title. "The Wind in the Trees"
  397. * @author Justin@gha.bravepages.com, un-thesis@wakeup-people.com, mgm@starlingtech.com, rick@baskettcase.com
  398. * @access private
  399. * @since Version 2.3.0
  400. */
  401. function titleCase($text) {
  402. $text = $this->convertUnderScores($text);
  403. $min_word_len = 4;
  404. $always_cap_first = TRUE;
  405. $exclude = array('of', 'a', 'the ', 'and', 'an', 'or', 'nor', 'but', 'is', 'if',
  406. 'then', 'else', 'when', 'up', 'at', 'from', 'by', 'on', 'off',
  407. 'for', 'in', 'out', 'over', 'to', 'into', 'with', 'htm', 'html',
  408. 'php', 'phtml');
  409. // Allows for the specification of the minimum length
  410. // of characters each word must be in order to be capitalized
  411. // Make sure words following punctuation are capitalized
  412. $text = str_replace(array('(', '-', '.', '?', ',', ':', '[', ';', '!'), array('( ', '- ', '. ', '? ', ', ', ': ', '[ ', '; ', '! '), $text);
  413. $words = explode(' ', string_strtolower($text));
  414. $count = count($words);
  415. $num = 0;
  416. while ($num < $count) {
  417. if (string_strlen($words[$num]) >= $min_word_len
  418. && array_search($words[$num], $exclude) === false)
  419. $words[$num] = ucfirst($words[$num]);
  420. $num++;
  421. }
  422. $text = @implode(' ', $words);
  423. $text = str_replace(
  424. array('( ', '- ', '. ', '? ', ', ', ': ', '[ ', '; ', '! '), array('(', '-', '.', '?', ',', ':', '[', ';', '!'), $text);
  425. // Always capitalize first char if cap_first is true
  426. if ($always_cap_first) {
  427. if (ctype_alpha($text[0]) && ord($text[0]) <= ord('z')
  428. && ord($text[0]) > ord('Z'))
  429. $text[0] = chr(ord($text[0]) - 32);
  430. }
  431. return $text;
  432. }
  433. /**
  434. * Remove Directories
  435. * Remove the directories from the breadcrumb
  436. * @since Version 2.3.2
  437. * @access private
  438. */
  439. function removeDirectories() {
  440. $numDirs = count($this->scriptArray);
  441. for ($i = 0; $i < $numDirs; $i++) {
  442. if (!in_array($this->scriptArray[$i], $this->removeDirs))
  443. $newArray[] = $this->scriptArray[$i];
  444. }
  445. return $newArray;
  446. }
  447. /**
  448. * Remove File Extension
  449. * Remove the file extension from the filename
  450. * @since Version 2.4
  451. * @access private
  452. */
  453. function removeFileExt($filename) {
  454. $newFileName = @explode('.', $filename);
  455. return $newFileName[0];
  456. }
  457. /**
  458. * Convert Underscores
  459. * Replace underscores with spaces
  460. * @since Version 2.4
  461. * @access private
  462. */
  463. function convertUnderScores($name) {
  464. $varName = str_replace('_', ' ', $name);
  465. return $varName;
  466. }
  467. function eDirStructure($item_id, $identifier, $type) {
  468. function filter_array($element) {
  469. if ($element != '')
  470. return $element;
  471. }
  472. if (!strcmp($type, LISTING_FEATURE_FOLDER)) {
  473. $this->module = ALIAS_LISTING_MODULE;
  474. } elseif (!strcmp($type, EVENT_FEATURE_FOLDER)) {
  475. $this->module = ALIAS_EVENT_MODULE;
  476. } elseif (!strcmp($type, ARTICLE_FEATURE_FOLDER)) {
  477. $this->module = ALIAS_ARTICLE_MODULE;
  478. } elseif (!strcmp($type, CLASSIFIED_FEATURE_FOLDER)) {
  479. $this->module = ALIAS_CLASSIFIED_MODULE;
  480. } elseif (!strcmp($type, PROMOTION_FEATURE_FOLDER)) {
  481. $this->module = ALIAS_PROMOTION_MODULE;
  482. } elseif (!strcmp($type, BLOG_FEATURE_FOLDER)){
  483. $this->module = ALIAS_BLOG_MODULE;
  484. } elseif ($type == "bestof") {
  485. $this->module = ALIAS_BESTOF_URL_DIVISOR;
  486. }
  487. $this->section = $identifier;
  488. $byCuisine = false;
  489. $bestof = false;
  490. switch ($identifier) {
  491. case 'category':
  492. if ($this->module == ALIAS_LISTING_MODULE && USE_DOT_PHP_ON_ALLCATEGORIES_LINK == "off") {
  493. $label = ucfirst(system_showText(LANG_MENU_BYCUISINE));
  494. $byCuisine = true;
  495. } elseif ($this->module == ALIAS_BESTOF_URL_DIVISOR) {
  496. $label = "bestof";
  497. $bestof = true;
  498. } else {
  499. $label = ucfirst(system_showText(LANG_CATEGORIES_SUBCATEGS));
  500. }
  501. break;
  502. case 'allcategories':
  503. if ($this->module == ALIAS_LISTING_MODULE && USE_DOT_PHP_ON_ALLCATEGORIES_LINK == "off") {
  504. $label = ucfirst(system_showText(LANG_MENU_BYCUISINE));
  505. $byCuisine = true;
  506. } else {
  507. $label = ucfirst(system_showText(LANG_CATEGORIES_SUBCATEGS));
  508. }
  509. break;
  510. case 'location':
  511. $label = ucfirst(system_showText(LANG_LOCATIONS));
  512. break;
  513. case 'alllocations':
  514. $label = ucfirst(system_showText(LANG_LOCATIONS));
  515. break;
  516. }
  517. $edirCrumb = array_filter($this->eDirCrumbs, filter_array);
  518. $crumb_array = array_values($edirCrumb);
  519. /**
  520. * @categories
  521. */
  522. $categoryChain = array();
  523. if ($identifier == "category") {
  524. if ($type == PROMOTION_FEATURE_FOLDER || $type == "bestof") {
  525. $typeObj = "ListingCategory";
  526. } else {
  527. $typeObj = ucfirst($type) . "Category";
  528. }
  529. $categoryObj = new $typeObj($item_id);
  530. $cat_id = $categoryObj->category_id;
  531. $i = 0;
  532. while ($cat_id) {
  533. unset($categoryObj);
  534. $categoryObj = new $typeObj($cat_id);
  535. $categoryChain[$i]['id'] = $categoryObj->getNumber("id");
  536. $categoryChain[$i]['title'] = $categoryObj->getString("title");
  537. $categoryChain[$i]['friendly'] = $categoryObj->getString("friendly_url");
  538. $i++;
  539. $cat_id = $categoryObj->category_id;
  540. }
  541. $categoryChain = array_reverse($categoryChain);
  542. }
  543. /**
  544. * @locations
  545. */
  546. if ($identifier == "location") {
  547. $crumb_array = $crumb_array[0];
  548. if ($crumb_array)
  549. $last_location = array_pop($crumb_array);
  550. $count = count($crumb_array);
  551. $_locations = explode(",", EDIR_LOCATIONS);
  552. $k = 0;
  553. foreach ($_locations as $_location) {
  554. $j = $_location;
  555. if ($j == 1) {
  556. $Location1Obj = new Location1($item_id[$k]);
  557. $location_0 = $crumb_array[$k];
  558. $location_0_url = $Location1Obj->getString("friendly_url");
  559. $k++;
  560. }
  561. if ($j == 2) {
  562. $Location2Obj = new Location2($item_id[$k]);
  563. $location_1 = $crumb_array[$k];
  564. $location_1_url = $Location2Obj->getString("friendly_url");
  565. $k++;
  566. }
  567. if ($j == 3) {
  568. $Location3Obj = new Location3($item_id[$k]);
  569. $location_2 = $crumb_array[$k];
  570. $location_2_url = $Location3Obj->getString("friendly_url");
  571. $k++;
  572. }
  573. if ($j == 4) {
  574. $Location4Obj = new Location4($item_id[$k]);
  575. $location_3 = $crumb_array[$k];
  576. $location_3_url = $Location4Obj->getString("friendly_url");
  577. $k++;
  578. }
  579. if ($j == 5) {
  580. $Location5Obj = new Location5($item_id[$k]);
  581. $location_4 = $crumb_array[$k];
  582. $location_4_url = $Location5Obj->getString("friendly_url");
  583. $k++;
  584. }
  585. }
  586. }
  587. if ($label) {
  588. $numDirs = count($this->scriptArray);
  589. if ($numDirs > 3) {
  590. for ($i = 3; $i <= $numDirs; $i++)
  591. unset($this->scriptArray[$i]);
  592. }
  593. if (EDIRECTORY_FOLDER != '') {
  594. if (!strcmp($type, LISTING_FEATURE_FOLDER)) {
  595. $this->scriptArray[1] = ALIAS_LISTING_MODULE;
  596. } elseif (!strcmp($type, ARTICLE_FEATURE_FOLDER)) {
  597. $this->scriptArray[1] = ALIAS_ARTICLE_MODULE;
  598. } elseif (!strcmp($type, EVENT_FEATURE_FOLDER)) {
  599. $this->scriptArray[1] = ALIAS_EVENT_MODULE;
  600. } elseif (!strcmp($type, CLASSIFIED_FEATURE_FOLDER)) {
  601. $this->scriptArray[1] = ALIAS_CLASSIFIED_MODULE;
  602. } elseif (!strcmp($type, PROMOTION_FEATURE_FOLDER)) {
  603. $this->scriptArray[1] = ALIAS_PROMOTION_MODULE;
  604. } elseif (!strcmp($type, BLOG_FEATURE_FOLDER)){
  605. $this->scriptArray[1] = ALIAS_BLOG_MODULE;
  606. } elseif ($type == "bestof"){
  607. $this->scriptArray[1] = ALIAS_BESTOF_URL_DIVISOR;
  608. }
  609. } else {
  610. if (!strcmp($type, ALIAS_LISTING_MODULE)) {
  611. $this->scriptArray[1] = ALIAS_LISTING_MODULE;
  612. } elseif (!strcmp($type, ALIAS_ARTICLE_MODULE)) {
  613. $this->scriptArray[1] = ALIAS_ARTICLE_MODULE;
  614. } elseif (!strcmp($type, ALIAS_EVENT_MODULE)) {
  615. $this->scriptArray[1] = ALIAS_EVENT_MODULE;
  616. } elseif (!strcmp($type, ALIAS_CLASSIFIED_MODULE)) {
  617. $this->scriptArray[1] = ALIAS_CLASSIFIED_MODULE;
  618. } elseif (!strcmp($type, ALIAS_PROMOTION_MODULE)) {
  619. $this->scriptArray[1] = ALIAS_PROMOTION_MODULE;
  620. } elseif (!strcmp($type,ALIAS_BLOG_MODULE)){
  621. $this->scriptArray[1] = ALIAS_BLOG_MODULE;
  622. }
  623. }
  624. $this->scriptArray[2] = $label;
  625. $i = ($bestof ? 2 : 3);
  626. $link = array();
  627. //categories
  628. foreach ($categoryChain as $eachCat) {
  629. $this->scriptArray[$i] = $eachCat["title"];
  630. $this->link[$i] = $this->link[$i - 1] . "/" . $eachCat["friendly"];
  631. $i++;
  632. }
  633. $_locations = explode(",", EDIR_LOCATIONS);
  634. if ($location_0) {
  635. $l = 0;
  636. $this->scriptArray[$i] = $location_0;
  637. $this->link[$i] = $location_0_url;
  638. $i++;
  639. }
  640. if ($location_1) {
  641. $l = 0;
  642. $this->scriptArray[$i] = $location_1;
  643. $this->link[$i] = ($location_0_url ? $location_0_url . "/" : '') . $location_1_url;
  644. $i++;
  645. }
  646. if ($location_2) {
  647. $l = 0;
  648. $this->scriptArray[$i] = $location_2;
  649. $this->link[$i] = ($location_0_url ? $location_0_url . "/" : '') . ($location_1_url ? $location_1_url . "/" : '') . $location_2_url;
  650. $i++;
  651. }
  652. if ($location_3) {
  653. $l = 0;
  654. $this->scriptArray[$i] = $location_3;
  655. $this->link[$i] = ($location_0_url ? $location_0_url . "/" : '') . ($location_1_url ? $location_1_url . "/" : '') . ($location_2_url ? $location_2_url . "/" : '') . $location_3_url;
  656. $i++;
  657. }
  658. if ($location_4) {
  659. $l = 0;
  660. $this->scriptArray[$i] = $location_4;
  661. $this->link[$i] = ($location_0_url ? $location_0_url . "/" : '') . ($location_1_url ? $location_1_url . "/" : '') . ($location_2_url ? $location_2_url . "/" : '') . ($location_3_url ? $location_3_url . "/" : '') . $location_4_url;
  662. $i++;
  663. }
  664. if ($crumb_array[0] != '' || $last_location) {
  665. if ($identifier == "location")
  666. $this->scriptArray[$i] = $last_location;
  667. else
  668. $this->scriptArray[$i] = $crumb_array[0];
  669. }
  670. } else {
  671. $keyPage = array_search('page', $this->scriptArray);
  672. $numDirs = count($this->scriptArray);
  673. if ($keyPage) {
  674. if ($numDirs > $keyPage) {
  675. for ($i = $keyPage; $i <= $numDirs; $i++) {
  676. unset($this->scriptArray[$i]);
  677. }
  678. }
  679. }
  680. $keyLetter = array_search('letter', $this->scriptArray);
  681. if ($keyLetter) {
  682. if ($numDirs > $keyLetter) {
  683. for ($i = $keyLetter; $i <= $numDirs; $i++) {
  684. unset($this->scriptArray[$i]);
  685. }
  686. }
  687. }
  688. //fix reviews
  689. if (string_strpos($_SERVER['REQUEST_URI'], ALIAS_REVIEW_URL_DIVISOR."/") !== false) {
  690. $keyPage = array_search(ALIAS_REVIEW_URL_DIVISOR, $this->scriptArray);
  691. if ($keyPage) {
  692. if ($numDirs > $keyPage) {
  693. for ($i = $keyPage; $i <= $numDirs; $i++)
  694. unset($this->scriptArray[$i]);
  695. }
  696. }
  697. }
  698. //fix checkins
  699. if (string_strpos($_SERVER['REQUEST_URI'], ALIAS_CHECKIN_URL_DIVISOR."/") !== false) {
  700. $keyPage = array_search(ALIAS_CHECKIN_URL_DIVISOR, $this->scriptArray);
  701. if ($keyPage) {
  702. if ($numDirs > $keyPage) {
  703. for ($i = $keyPage; $i <= $numDirs; $i++)
  704. unset($this->scriptArray[$i]);
  705. }
  706. }
  707. }
  708. //fix blog archive
  709. if (string_strpos($_SERVER['REQUEST_URI'], ALIAS_ARCHIVE_URL_DIVISOR."/") !== false) {
  710. $keyPage = array_search(ALIAS_ARCHIVE_URL_DIVISOR, $this->scriptArray);
  711. if ($keyPage) {
  712. if ($numDirs > $keyPage) {
  713. for ($i = $keyPage; $i <= $numDirs; $i++)
  714. unset($this->scriptArray[$i]);
  715. }
  716. }
  717. }
  718. }
  719. }
  720. /**
  721. * Show Breadcrumb
  722. *
  723. * Outputs the html formatted breadcrumb according to the variables you set.
  724. * <code>echo "<p>".$breadcrumb->show_breadcrumb()."</p>";</code>
  725. * @since Version 0.0.1
  726. */
  727. function show_breadcrumb() {
  728. if ($this->hideHome && $this->section == "home") {
  729. return false;
  730. } else {
  731. $dir = $showLink = $class = $target = '';
  732. // Either set the home element or pop the first empty array off the beginning
  733. if ($this->homepage != '')
  734. $this->scriptArray[0] = $this->homepage;
  735. else
  736. $tmp = array_shift($this->scriptArray);
  737. // if this is a personal site remove the root directory and set
  738. // new homepage to user directory
  739. if ($this->personalSite != '') {
  740. $this->removeDirs[] = $this->scriptArray[0];
  741. if ($this->homepage != '')
  742. $this->scriptArray[1] = $this->homepage;
  743. else
  744. $tmp = array_shift($this->scriptArray);
  745. }
  746. if ($this->homepage == ''){
  747. //$dir = '/';
  748. }
  749. $dir = DEFAULT_URL;
  750. // Set sub folder if true
  751. if ($this->subFolder != '') {
  752. $sub_dir = "/" . $this->subFolder;
  753. $dir = $sub_dir;
  754. }
  755. // Build Path Structure
  756. $numDirs = count($this->scriptArray);
  757. // BEGIN DIRECTORY FOR LOOP
  758. for ($i = 0; $i < $numDirs; $i++) {
  759. #echo $this->changeName[$this->scriptArray[$i]];
  760. #$dirName = $this->scriptArray[$i];
  761. $dirName = ($this->changeName[$this->scriptArray[$i]] != '') ?
  762. $this->changeName[$this->scriptArray[$i]] :
  763. $this->scriptArray[$i];
  764. if ($this->personalSite != '' && $i == 1)
  765. $this->scriptArray[$i] = $this->personalSite;
  766. if ($break_dir) {
  767. if ($this->section == "location")
  768. $dir = "$sub_dir"."/$this->module/".ALIAS_LOCATION_URL_DIVISOR."/";
  769. else if ($this->section == "category")
  770. $dir = "$sub_dir"."/$this->module/".ALIAS_CATEGORY_URL_DIVISOR;
  771. } else {
  772. if ($this->sub_folder && $this->section == 'home')
  773. $dir .= $this->sub_folder;
  774. else
  775. $dir .= ( $i == 0 && $this->homepage != '') ? '/' : $this->scriptArray[$i] . "/";
  776. }
  777. // Replace underscores with spaces if _toSpace is set
  778. if ($this->_toSpace == TRUE)
  779. $dirTxtName = $this->convertUnderScores($dirName);
  780. // parse Directory special text style
  781. $dirTxtName = $this->specialLang($dirName, $this->special);
  782. // Convert string into specified format
  783. $dirTxtName = $this->dirFormat($dirName, $this->dirformat);
  784. // parse eDirectory language
  785. $dirTxtName = $this->multiLanguage($dirName);
  786. // Use text instead of images
  787. if ($this->imagedir['path'] == '')
  788. $dirName = $dirTxtName;
  789. // Use Images instead of text
  790. else {
  791. // Set defaults
  792. if (!$this->imagedir['type'])
  793. $this->imagedir['type'] = 'gif';
  794. if (!$this->imagedir['border'])
  795. $this->imagedir['border'] = '0';
  796. if (!$this->imagedir['id'])
  797. $this->imagedir['id'] = TRUE;
  798. if (!$this->imagedir['name'])
  799. $this->imagedir['name'] = TRUE;
  800. if (!$this->imagedir['alt'])
  801. $this->imagedir['alt'] = TRUE;
  802. $dirName = '<img src="' . $this->imagedir['path'] .
  803. $this->scriptArray[$i] . '.' . $this->imagedir['type'] .
  804. '" border="' . $this->imagedir['border'] . '"';
  805. if ($this->imagedir['id'] == TRUE) // id
  806. $dirName .= ' id="' . $this->scriptArray[$i] . '"';
  807. if ($this->imagedir['name'] == TRUE) // name
  808. $dirName .= ' name="' . $this->scriptArray[$i] . '"';
  809. if ($this->imagedir['alt'] == TRUE) { // alt
  810. $alt = ($this->changeName[$this->scriptArray[$i]] != '') ? $this->changeName[$this->scriptArray[$i]] : $this->scriptArray[$i];
  811. $dirName .= ' alt="' . $alt . '"';
  812. }
  813. if ($this->imagedir['title'] == TRUE) { // title
  814. $title = ($this->changeName[$this->scriptArray[$i]] != '') ? $this->changeName[$this->scriptArray[$i]] : $this->scriptArray[$i];
  815. $dirName .= ' title="' . $title . '"';
  816. }
  817. if ($this->imagedir['hspace']) // hspace
  818. $dirName .= ' hspace="' . $this->imagedir['hspace'] . '"';
  819. if ($this->imagedir['vspace']) // vspace
  820. $dirName .= ' vspace="' . $this->imagedir['vspace'] . '"';
  821. if ($this->imagedir['align']) // align
  822. $dirName .= ' align="' . $this->imagedir['align'] . '"';
  823. if ($this->imagedir['height']) // height
  824. $dirName .= ' height="' . $this->imagedir['height'] . '"';
  825. if ($this->imagedir['width']) // width
  826. $dirName .= ' width="' . $this->imagedir['width'] . '"';
  827. $dirName .= ' />';
  828. }
  829. // Add CSS
  830. if ($this->cssClass != '')
  831. $class = ' class="' . $this->cssClass . '"';
  832. // Add frame target
  833. if ($this->target != '')
  834. $target = ' target="' . $this->target . '"';
  835. // create link
  836. // If fileExists has values then check to make sure one of those files
  837. // exists, if it does, link it, otherwise do not link
  838. if ($this->fileExists) {
  839. for ($k = 0; $k < count($this->fileExists); $k++) {
  840. if ($this->personalSite != '') {
  841. if (string_strpos($dir, $this->personalSite))
  842. $exists_filename = str_replace($this->personalSite . '/', '', $this->document_root . $dir . $this->fileExists[$k]);
  843. else
  844. continue;
  845. }
  846. else
  847. $exists_filename = $this->document_root . $dir . $this->fileExists[$k];
  848. #echo $exists_filename.'<br />';
  849. if (file_exists($exists_filename)) {
  850. $showLink = 'yes';
  851. break;
  852. } else
  853. $showLink = 'no';
  854. }
  855. }
  856. // Set the root filename if it is different then the default index page
  857. if ($break_dir) {
  858. $rootFileName = $this->link[$i];
  859. } else {
  860. $rootFileName = ($this->rootIndexLink != '' && $dir == '/') ? $this->rootIndexLink : '';
  861. }
  862. //$current_dir = string_substr($dir, string_strpos($dir, "/", 2)+1, string_strrpos($dir, "/")-(string_strpos($dir, "/", 2)+1));
  863. $dirs = explode("/", $dir);
  864. $needle = count($dirs) - 2;
  865. $current_dir = $dirs[$needle];
  866. switch ($current_dir) {
  867. case ucfirst(system_showText(LANG_CATEGORIES_SUBCATEGS)):
  868. $dir = $previous_dir . $this->alias_allcategories.(USE_DOT_PHP_ON_ALLCATEGORIES_LINK == "on" ? ".php" : "");
  869. $break_dir = true;
  870. break;
  871. case ucfirst(system_showText(LANG_MENU_BYCUISINE)):
  872. $dir = $previous_dir . $this->alias_allcategories.(USE_DOT_PHP_ON_ALLCATEGORIES_LINK == "on" ? ".php" : "");
  873. $break_dir = true;
  874. break;
  875. case ucfirst(system_showText(LANG_LOCATIONS)):
  876. $dir = $previous_dir . ALIAS_ALLLOCATIONS_URL_DIVISOR.".php";
  877. $break_dir = true;
  878. break;
  879. }
  880. if (!in_array($this->scriptArray[$i], $this->removeDirs)) {
  881. if ($this->unlinkCurrentDir == TRUE && ($i + 1) == $numDirs || $showLink == 'no') {
  882. $breadcrumb[] = ucfirst($dirName);
  883. }
  884. // If we are not supposed to remove the directory, show it
  885. elseif (!in_array($this->scriptArray[$i], $this->removeDirs) || $showLink == 'yes')
  886. $breadcrumb[] = '<a href="' . $dir . $rootFileName . '"' . $class . $target . ' title="' . $dirTxtName . '">' . ucfirst($dirName) . '</a>';
  887. elseif ($this->personalSite != '' && $i == 1)
  888. $breadcrumb[] = '<a href="' . $dir . $rootFileName . '"' . $class . $target . ' title="' . $dirTxtName . '">' . $dirName . '</a>';
  889. }
  890. $previous_dir = $dir;
  891. }
  892. // END DIRECTORY FOR LOOP
  893. $fileName = $originalFileName = $this->fileName;
  894. #if ($this->fileNametoTitle==TRUE) $fileName = $this->getPageTitle();
  895. // Check to see if hideFileExt is on, if so turn on showfile
  896. // and remove the file extension
  897. if ($this->hideFileExt == TRUE)
  898. $this->showfile = TRUE;
  899. if ($this->showfile == TRUE) {
  900. // Change the filename if filename is in changeFileName array
  901. if ($this->changeFileName[$_SERVER['REQUEST_URI']] != '')
  902. $fileName = $this->changeFileName[$_SERVER['REQUEST_URI']];
  903. // Change the filename if filename is in changeGeneralName array
  904. if ($this->changeGeneralName[$this->fileName] != '')
  905. $fileName = $this->changeGeneralName[$this->fileName];
  906. // If it is not then just use $fileName or remove extension if specified
  907. elseif ($this->hideFileExt == TRUE)
  908. $fileName = $this->removeFileExt($fileName);
  909. // Convert underscores to spaces
  910. if ($this->_toSpace == TRUE)
  911. $fileName = $this->convertUnderScores($fileName);
  912. // parse filename special text style
  913. $fileName = $this->specialLang($fileName, $this->special);
  914. // Convert string into specified format
  915. $fileName = $this->dirFormat($fileName, $this->dirformat);
  916. // Add CSS
  917. if ($this->cssClass != '')
  918. $fileName = '<span class="' . $this->cssClass . '">' .
  919. $fileName . '</span>';
  920. // Add link to filename
  921. if ($this->linkFile == TRUE)
  922. $fileName = '<a href="' . $originalFileName . '">' . $fileName . '</a>';
  923. $fileName = $this->symbol . $fileName;
  924. } else
  925. $fileName = '';
  926. // Web Server Path
  927. // return if we are not at root
  928. if ($numDirs > 0)
  929. return @implode($this->symbol, $breadcrumb) . $fileName;
  930. // if at root just return the filename
  931. else
  932. return $fileName;
  933. }
  934. }
  935. function show_auxbreadcrumb(){
  936. $$auxbreadcrumb = "";
  937. if (string_strpos($_SERVER["REQUEST_URI"], ALIAS_ADVERTISE_URL_DIVISOR.".php") !== false) {
  938. $auxbreadcrumb .= "<a href=\"".DEFAULT_URL."\" title=\"".system_showText(LANG_MENU_HOME)."\">".system_showText(LANG_MENU_HOME)."</a><span class=\"split\">&nbsp;&nbsp;".THEME_BREADCRUMB_SEP."&nbsp;&nbsp;</span>";
  939. $auxbreadcrumb .= system_showText(LANG_MENU_ADVERTISE);
  940. }
  941. if (string_strpos($_SERVER["REQUEST_URI"], ALIAS_CONTACTUS_URL_DIVISOR.".php") !== false) {
  942. $auxbreadcrumb .= "<a href=\"".DEFAULT_URL."\" title=\"".system_showText(LANG_MENU_HOME)."\">".system_showText(LANG_MENU_HOME)."</a><span class=\"split\">&nbsp;&nbsp;".THEME_BREADCRUMB_SEP."&nbsp;&nbsp;</span>";
  943. $auxbreadcrumb .= system_showText(LANG_MENU_CONTACT);
  944. }
  945. if (string_strpos($_SERVER["PHP_SELF"], "errorpage.php") !== false) {
  946. $auxbreadcrumb .= "<a href=\"".DEFAULT_URL."\" title=\"".system_showText(LANG_MENU_HOME)."\">".system_showText(LANG_MENU_HOME)."</a><span class=\"split\">&nbsp;&nbsp;".THEME_BREADCRUMB_SEP."&nbsp;&nbsp;</span>";
  947. $auxbreadcrumb .= system_showText(LANG_PAGE_NOT_FOUND);
  948. }
  949. if (string_strpos($_SERVER["REQUEST_URI"], ALIAS_SITEMAP_URL_DIVISOR.".php") !== false) {
  950. $auxbreadcrumb .= "<a href=\"".DEFAULT_URL."\" title=\"".system_showText(LANG_MENU_HOME)."\">".system_showText(LANG_MENU_HOME)."</a><span class=\"split\">&nbsp;&nbsp;".THEME_BREADCRUMB_SEP."&nbsp;&nbsp;</span>";
  951. $auxbreadcrumb .= system_showText(LANG_MENU_SITEMAP);
  952. }
  953. if (string_strpos($_SERVER["REQUEST_URI"], ALIAS_BESTOF_URL_DIVISOR) !== false) {
  954. $auxbreadcrumb .= "<a href=\"".DEFAULT_URL."\" title=\"".system_showText(LANG_MENU_HOME)."\">".system_showText(LANG_MENU_HOME)."</a><span class=\"split\">&nbsp;&nbsp;".THEME_BREADCRUMB_SEP."&nbsp;&nbsp;</span>";
  955. $auxbreadcrumb .= system_showText(LANG_MENU_BESTOF);
  956. }
  957. if (string_strpos($_SERVER["PHP_SELF"], "maintenancepage.php") !== false) {
  958. $auxbreadcrumb .= "<a href=\"".DEFAULT_URL."\" title=\"".system_showText(LANG_MENU_HOME)."\">".system_showText(LANG_MENU_HOME)."</a><span class=\"split\">&nbsp;&nbsp;".THEME_BREADCRUMB_SEP."&nbsp;&nbsp;</span>";
  959. $auxbreadcrumb .= system_showText(LANG_MAINTENANCE_PAGE);
  960. }
  961. return $auxbreadcrumb;
  962. }
  963. }
  964. ?>