CommonHelper.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  1. <?php
  2. App::uses('AppHelper', 'View/Helper');
  3. /**
  4. * All site-wide necessary stuff for the view layer
  5. */
  6. class CommonHelper extends AppHelper {
  7. public $helpers = array('Session', 'Html');
  8. public $packages = array(
  9. 'Tools.Jquery' // Used by showDebug
  10. );
  11. /**
  12. * Convenience function for clean ROBOTS allowance
  13. *
  14. * @param string $type - private/public
  15. * @return string HTML
  16. */
  17. public function metaRobots($type = null) {
  18. if ($type === null && ($meta = Configure::read('Config.robots')) !== null) {
  19. $type = $meta;
  20. }
  21. $content = array();
  22. if ($type === 'public') {
  23. $this->privatePage = false;
  24. $content['robots'] = array('index', 'follow', 'noarchive');
  25. } else {
  26. $this->privatePage = true;
  27. $content['robots'] = array('noindex', 'nofollow', 'noarchive');
  28. }
  29. $return = '<meta name="robots" content="' . implode(',', $content['robots']) . '" />';
  30. return $return;
  31. }
  32. /**
  33. * Convenience function for clean meta name tags
  34. * @param string $name: author, date, generator, revisit-after, language
  35. * @param MIXED $content: if array, it will be seperated by commas
  36. * @return string htmlMarkup
  37. */
  38. public function metaName($name = null, $content = null) {
  39. if (empty($name) || empty($content)) {
  40. return '';
  41. }
  42. if (!is_array($content)) {
  43. $content = (array)$content;
  44. }
  45. $return = '<meta name="' . $name . '" content="' . implode(', ', $content) . '" />';
  46. return $return;
  47. }
  48. /**
  49. * @param string $content
  50. * @param string $language (iso2: de, en-us, ...)
  51. * @param array $additionalOptions
  52. * @return string htmlMarkup
  53. */
  54. public function metaDescription($content, $language = null, $options = array()) {
  55. if (!empty($language)) {
  56. $options['lang'] = mb_strtolower($language);
  57. } elseif ($language !== false) {
  58. $options['lang'] = Configure::read('Config.locale');
  59. }
  60. return $this->Html->meta('description', $content, $options);
  61. }
  62. /**
  63. * Convenience method to output meta keywords
  64. *
  65. * @param string|array $keywords
  66. * @param string $language (iso2: de, en-us, ...)
  67. * @param boolean $escape
  68. * @return string htmlMarkup
  69. */
  70. public function metaKeywords($keywords = null, $language = null, $escape = true) {
  71. if ($keywords === null) {
  72. $keywords = Configure::read('Config.keywords');
  73. }
  74. if (is_array($keywords)) {
  75. $keywords = implode(', ', $keywords);
  76. }
  77. if ($escape) {
  78. $keywords = h($keywords);
  79. }
  80. if (!empty($language)) {
  81. $options['lang'] = mb_strtolower($language);
  82. } elseif ($language !== false) {
  83. $options['lang'] = Configure::read('Config.locale');
  84. }
  85. return $this->Html->meta('keywords', $keywords, $options);
  86. }
  87. /**
  88. * Convenience function for "canonical" SEO links
  89. *
  90. * @param mixed $url
  91. * @param boolean $full
  92. * @return string htmlMarkup
  93. */
  94. public function metaCanonical($url = null, $full = false) {
  95. $canonical = $this->Html->url($url, $full);
  96. $options = array('rel' => 'canonical', 'type' => null, 'title' => null);
  97. return $this->Html->meta('canonical', $canonical, $options);
  98. }
  99. /**
  100. * Convenience function for "alternate" SEO links
  101. *
  102. * @param mixed $url
  103. * @param mixed $lang (lang(iso2) or array of langs)
  104. * lang: language (in ISO 6391-1 format) + optionally the region (in ISO 3166-1 Alpha 2 format)
  105. * - de
  106. * - de-ch
  107. * etc
  108. * @return string htmlMarkup
  109. */
  110. public function metaAlternate($url, $lang, $full = false) {
  111. $canonical = $this->Html->url($url, $full);
  112. //return $this->Html->meta('canonical', $canonical, array('rel'=>'canonical', 'type'=>null, 'title'=>null));
  113. $lang = (array)$lang;
  114. $res = array();
  115. foreach ($lang as $language => $countries) {
  116. if (is_numeric($language)) {
  117. $language = '';
  118. } else {
  119. $language .= '-';
  120. }
  121. $countries = (array)$countries;
  122. foreach ($countries as $country) {
  123. $l = $language . $country;
  124. $options = array('rel' => 'alternate', 'hreflang' => $l, 'type' => null, 'title' => null);
  125. $res[] = $this->Html->meta('alternate', $url, $options) . PHP_EOL;
  126. }
  127. }
  128. return implode('', $res);
  129. }
  130. /**
  131. * Convenience function for META Tags
  132. *
  133. * @param string $type
  134. * @param string $content
  135. * @return string htmlMarkup
  136. */
  137. public function metaRss($url = null, $title = null) {
  138. $tags = array(
  139. 'meta' => '<link rel="alternate" type="application/rss+xml" title="%s" href="%s" />',
  140. );
  141. $content = array();
  142. if (empty($url)) {
  143. return '';
  144. }
  145. if (empty($title)) {
  146. $title = 'Diesen Feed abonnieren';
  147. }
  148. return sprintf($tags['meta'], $title, $this->url($url));
  149. }
  150. /**
  151. * Convenience function for META Tags
  152. *
  153. * @param string $type
  154. * @param string $content
  155. * @return string htmlMarkup
  156. */
  157. public function metaEquiv($type, $value, $escape = true) {
  158. $tags = array(
  159. 'meta' => '<meta http-equiv="%s"%s />',
  160. );
  161. if ($value === null) {
  162. return '';
  163. }
  164. if ($escape) {
  165. $value = h($value);
  166. }
  167. return sprintf($tags['meta'], $type, ' content="' . $value . '"');
  168. }
  169. /**
  170. * (example): array(x, Tools|y, Tools.Jquery|jquery/sub/z)
  171. * => x is in webroot/
  172. * => y is in plugins/tools/webroot/
  173. * => z is in plugins/tools/packages/jquery/files/jquery/sub/
  174. *
  175. * @return string htmlMarkup
  176. * @deprecated Use AssetCompress plugin instead
  177. */
  178. public function css($files = array(), $options = array()) {
  179. $files = (array)$files;
  180. $pieces = array();
  181. foreach ($files as $file) {
  182. $pieces[] = 'file=' . $file;
  183. }
  184. if ($v = Configure::read('Config.layout_v')) {
  185. $pieces[] = 'v=' . $v;
  186. }
  187. $string = implode('&', $pieces);
  188. return $this->Html->css('/css.php?' . $string, $options);
  189. }
  190. /**
  191. * (example): array(x, Tools|y, Tools.Jquery|jquery/sub/z)
  192. * => x is in webroot/
  193. * => y is in plugins/tools/webroot/
  194. * => z is in plugins/tools/packages/jquery/files/jquery/sub/
  195. *
  196. * @return string htmlMarkup
  197. * @deprecated Use AssetCompress plugin instead
  198. */
  199. public function script($files = array(), $options = array()) {
  200. $files = (array)$files;
  201. foreach ($files as $file) {
  202. $pieces[] = 'file=' . $file;
  203. }
  204. if ($v = Configure::read('Config.layout_v')) {
  205. $pieces[] = 'v=' . $v;
  206. }
  207. $string = implode('&', $pieces);
  208. return $this->Html->script('/js.php?' . $string, $options);
  209. }
  210. /**
  211. * Special css tag generator with the option to add '?...' to the link (for caching prevention)
  212. * IN USAGE
  213. * needs manual adjustment, but still better than the core one!
  214. *
  215. * Note: needs Asset.cssversion => xyz (going up with counter)
  216. *
  217. * @return string htmlMarkup
  218. * @deprecated Use AssetCompress plugin instead
  219. */
  220. public function cssDyn($path, $options = array()) {
  221. $v = (int)Configure::read('Asset.version');
  222. return $this->Html->css($path . '.css?' . $v, $options);
  223. }
  224. /**
  225. * Css Auto Path
  226. * NOT IN USAGE
  227. * but better than the core one!
  228. * Note: needs Asset.timestamp => force
  229. *
  230. * @return string htmlMarkup
  231. * @deprecated Use AssetCompress plugin instead
  232. */
  233. public function cssAuto($path, $htmlAttributes = array()) {
  234. $compress = Configure::read('App.compressCss');
  235. $cssUrl = Configure::read('App.cssBaseUrl') ? Configure::read('App.cssBaseUrl') : CSS_URL;
  236. $time = date('YmdHis', filemtime(APP . 'webroot' . DS . $cssUrl . $path . '.css'));
  237. $url = "{$this->request->webroot}" . ($compress ? 'c' : '') . $cssUrl . $this->themeWeb . $path . ".css?" . $time;
  238. return $url;
  239. }
  240. /*** Content Stuff ***/
  241. /**
  242. * Still necessary?
  243. *
  244. * @param array $fields
  245. * @return string HTML
  246. */
  247. public function displayErrors($fields = array()) {
  248. $res = '';
  249. if (!empty($this->validationErrors)) {
  250. if ($fields === null) { # catch ALL
  251. foreach ($this->validationErrors as $alias => $error) {
  252. list($alias, $fieldname) = explode('.', $error);
  253. $this->validationErrors[$alias][$fieldname];
  254. }
  255. } elseif (!empty($fields)) {
  256. foreach ($fields as $field) {
  257. list($alias, $fieldname) = explode('.', $field);
  258. if (!empty($this->validationErrors[$alias][$fieldname])) {
  259. $res .= $this->_renderError($this->validationErrors[$alias][$fieldname]);
  260. }
  261. }
  262. }
  263. }
  264. return $res;
  265. }
  266. protected function _renderError($error, $escape = true) {
  267. if ($escape !== false) {
  268. $error = h($error);
  269. }
  270. return '<div class="error-message">' . $error . '</div>';
  271. }
  272. /**
  273. * Alternates between two or more strings.
  274. *
  275. * echo CommonHelper::alternate('one', 'two'); // "one"
  276. * echo CommonHelper::alternate('one', 'two'); // "two"
  277. * echo CommonHelper::alternate('one', 'two'); // "one"
  278. *
  279. * Note that using multiple iterations of different strings may produce
  280. * unexpected results.
  281. * TODO: move to booststrap/lib!!!
  282. *
  283. * @param string strings to alternate between
  284. * @return string
  285. */
  286. public static function alternate() {
  287. static $i;
  288. if (func_num_args() === 0) {
  289. $i = 0;
  290. return '';
  291. }
  292. $args = func_get_args();
  293. return $args[($i++ % count($args))];
  294. }
  295. /**
  296. * Check if session works due to allowed cookies
  297. *
  298. * @param boolean Success
  299. */
  300. public function sessionCheck() {
  301. return !CommonComponent::cookiesDisabled();
  302. /*
  303. if (!empty($_COOKIE) && !empty($_COOKIE[Configure::read('Session.cookie')])) {
  304. return true;
  305. }
  306. return false;
  307. */
  308. }
  309. /**
  310. * Display warning if cookies are disallowed (and session won't work)
  311. *
  312. * @return string HTML
  313. */
  314. public function sessionCheckAlert() {
  315. if ($this->sessionCheck()) {
  316. return '';
  317. }
  318. return '<div class="cookieWarning">' . __('Please enable cookies') . '</div>';
  319. }
  320. /**
  321. * Auto-pluralizing a word using the Inflection class
  322. * //TODO: move to lib or bootstrap
  323. *
  324. * @param string $singular The string to be pl.
  325. * @param integer $count
  326. * @return string "member" or "members" OR "Mitglied"/"Mitglieder" if autoTranslate TRUE
  327. */
  328. public function asp($singular, $count, $autoTranslate = false) {
  329. if ((int)$count !== 1) {
  330. $pural = Inflector::pluralize($singular);
  331. } else {
  332. $pural = null; # no pluralization necessary
  333. }
  334. return $this->sp($singular, $pural, $count, $autoTranslate);
  335. }
  336. /**
  337. * Manual pluralizing a word using the Inflection class
  338. * //TODO: move to lib or bootstrap
  339. *
  340. * @param string $singular
  341. * @param string $plural
  342. * @param integer $count
  343. * @return string result
  344. */
  345. public function sp($singular, $plural, $count, $autoTranslate = false) {
  346. if ((int)$count !== 1) {
  347. $result = $plural;
  348. } else {
  349. $result = $singular;
  350. }
  351. if ($autoTranslate) {
  352. $result = __($result);
  353. }
  354. return $result;
  355. }
  356. /**
  357. * Show flash messages
  358. *
  359. * TODO: export div wrapping method (for static messaging on a page)
  360. * TODO: sorting
  361. *
  362. * @param boolean unsorted true/false [default:FALSE = sorted by priority]
  363. * @return string HTML
  364. */
  365. public function flash($unsorted = false) {
  366. // Get the messages from the session
  367. $messages = (array)$this->Session->read('messages');
  368. $cMessages = (array)Configure::read('messages');
  369. if (!empty($cMessages)) {
  370. $messages = (array)Set::merge($messages, $cMessages);
  371. }
  372. $html = '';
  373. if (!empty($messages)) {
  374. $html = '<div class="flashMessages">';
  375. if ($unsorted !== true) {
  376. // Add a div for each message using the type as the class.
  377. foreach ($messages as $type => $msgs) {
  378. foreach ((array)$msgs as $msg) {
  379. $html .= $this->_message($msg, $type);
  380. }
  381. }
  382. } else {
  383. foreach ($messages as $type) {
  384. //
  385. }
  386. }
  387. $html .= '</div>';
  388. if (method_exists($this->Session, 'delete')) {
  389. $this->Session->delete('messages');
  390. } else {
  391. CakeSession::delete('messages');
  392. }
  393. }
  394. return $html;
  395. }
  396. /**
  397. * Output a single flashMessage
  398. *
  399. * @param string $message
  400. * @return string HTML
  401. */
  402. public function flashMessage($msg, $type = 'info', $escape = true) {
  403. $html = '<div class="flashMessages">';
  404. if ($escape) {
  405. $msg = h($msg);
  406. }
  407. $html .= $this->_message($msg, $type);
  408. $html .= '</div>';
  409. return $html;
  410. }
  411. protected function _message($msg, $type) {
  412. if (!empty($msg)) {
  413. return '<div class="message' . (!empty($type) ? ' ' . $type : '') . '">' . $msg . '</div>';
  414. }
  415. return '';
  416. }
  417. /**
  418. * Add a message on the fly
  419. *
  420. * @param string $msg
  421. * @param string $class
  422. * @return boolean Success
  423. */
  424. public function transientFlashMessage($msg, $class = null) {
  425. return CommonComponent::transientFlashMessage($msg, $class);
  426. }
  427. /**
  428. * Escape text with some more automagic
  429. * TODO: move into TextExt?
  430. *
  431. * @param string $text
  432. * @param array $options
  433. * @return string processedText
  434. * - nl2br: true/false (defaults to true)
  435. * - escape: false prevents h() and space transformation (defaults to true)
  436. * - tabsToSpaces: int (defaults to 4)
  437. */
  438. public function esc($text, $options = array()) {
  439. if (!isset($options['escape']) || $options['escape'] !== false) {
  440. //$text = str_replace(' ', '&nbsp;', h($text));
  441. $text = h($text);
  442. # try to fix indends made out of spaces
  443. $text = explode(NL, $text);
  444. foreach ($text as $key => $t) {
  445. $i = 0;
  446. while (!empty($t[$i]) && $t[$i] === ' ') {
  447. $i++;
  448. }
  449. if ($i > 0) {
  450. $t = str_repeat('&nbsp;', $i) . substr($t, $i);
  451. $text[$key] = $t;
  452. }
  453. }
  454. $text = implode(NL, $text);
  455. $esc = true;
  456. }
  457. if (!isset($options['nl2br']) || $options['nl2br'] !== false) {
  458. $text = nl2br($text);
  459. }
  460. if (!isset($options['tabsToSpaces'])) {
  461. $options['tabsToSpaces'] = 4;
  462. }
  463. if (!empty($options['tabsToSpaces'])) {
  464. $text = str_replace(TB, str_repeat(!empty($esc) ? '&nbsp;' : ' ', $options['tabsToSpaces']), $text);
  465. }
  466. return $text;
  467. }
  468. /**
  469. * Prevents site being opened/included by others/websites inside frames
  470. */
  471. public function framebuster() {
  472. return $this->Html->scriptBlock('
  473. if (top!=self) top.location.ref=self.location.href;
  474. ');
  475. }
  476. /**
  477. * Currenctly only alerts on IE6/IE7
  478. * options
  479. * - engine (js, jquery)
  480. * - escape
  481. * needs the id element to be a present (div) container in the layout
  482. */
  483. public function browserAlert($id, $message, $options = array()) {
  484. $engine = 'js';
  485. if (!isset($options['escape']) || $options['escape'] !== false) {
  486. $message = h($message);
  487. }
  488. return $this->Html->scriptBlock('
  489. // Returns the version of Internet Explorer or a -1
  490. function getInternetExplorerVersion() {
  491. var rv = -1; // Return value assumes failure.
  492. if (navigator.appName === "Microsoft Internet Explorer") {
  493. var ua = navigator.userAgent;
  494. var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
  495. if (re.exec(ua) != null)
  496. rv = parseFloat( RegExp.$1 );
  497. }
  498. return rv;
  499. }
  500. if ((document.all) && (navigator.appVersion.indexOf("MSIE 7.") != -1) || typeof document.body.style.maxHeight == \'undefined\') {
  501. document.getElementById(\'' . $id . '\').innerHTML = \'' . $message . '\';
  502. }
  503. /*
  504. jQuery(document).ready(function() {
  505. if ($.browser.msie && $.browser.version.substring(0,1) < 8) {
  506. document.getElementById(\'' . $id . '\').innerHTML = \'' . $message . '\';
  507. }
  508. });
  509. */
  510. ');
  511. }
  512. /**
  513. * In noscript tags:
  514. * - link which should not be followed by bots!
  515. * - "pseudo"image which triggers log
  516. */
  517. public function honeypot($noFollowUrl, $noscriptUrl = array()) {
  518. $res = '<div class="invisible" style="display:none"><noscript>';
  519. $res .= $this->Html->defaultLink('Email', $noFollowUrl, array('rel' => 'nofollow'));
  520. if (!empty($noscriptUrl)) {
  521. $res .= BR . $this->Html->image($this->Html->defaultUrl($noscriptUrl, true)); //$this->Html->link($noscriptUrl);
  522. }
  523. $res .= '</noscript></div>';
  524. return $res;
  525. }
  526. /*** Stats ***/
  527. /**
  528. * Print js-visit-stats-link to layout
  529. * uses Piwik open source statistics framework
  530. */
  531. public function visitStats($viewPath = null) {
  532. $res = '';
  533. if (!defined('HTTP_HOST_LIVESERVER')) {
  534. return '';
  535. }
  536. if (HTTP_HOST == HTTP_HOST_LIVESERVER && (int)Configure::read('Config.tracking') === 1) {
  537. $trackingUrl = Configure::read('Config.tracking_url');
  538. if (empty($trackingUrl)) {
  539. $trackingUrl = 'visit_stats';
  540. }
  541. $error = false;
  542. if (!empty($viewPath) && $viewPath === 'errors') {
  543. $error = true;
  544. }
  545. $res .= '
  546. <script type="text/javascript">
  547. var pkBaseURL = (("https:" == document.location.protocol) ? "https://' . HTTP_HOST . '/' . $trackingUrl . '/" : "http://' . HTTP_HOST . '/' . $trackingUrl . '/");
  548. document.write(unescape("%3Cscript src=\'" + pkBaseURL + "piwik.js\' type=\'text/javascript\'%3E%3C/script%3E"));
  549. </script>
  550. <script type="text/javascript">
  551. try {
  552. var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 1);
  553. piwikTracker.trackPageView();
  554. piwikTracker.enableLinkTracking();
  555. ' . ($error ? 'piwikTracker.setDocumentTitle(\'404/URL = \'+encodeURIComponent(document.location.pathname+document.location.search) + \'/From = \' + encodeURIComponent(document.referrer));' : '') . '
  556. } catch( err ) {}
  557. </script>
  558. <noscript><p>' . $this->visitStatsImg() . '</p></noscript>
  559. ';
  560. }
  561. return $res;
  562. }
  563. /**
  564. * Non js browsers
  565. */
  566. public function visitStatsImg($trackingUrl = null) {
  567. if (empty($trackingUrl)) {
  568. $trackingUrl = Configure::read('Config.tracking_url');
  569. }
  570. if (empty($trackingUrl)) {
  571. $trackingUrl = 'visit_stats';
  572. }
  573. return '<img src="' . Router::url('/', true) . $trackingUrl . '/piwik.php?idsite=1" style="border:0" alt=""/>';
  574. }
  575. /*** deprecated ***/
  576. /**
  577. * Checks if a role is in the current users session
  578. *
  579. * @param necessary right(s) as array - or a single one as string possible
  580. * Note: all of them need to be in the user roles to return true by default
  581. * @deprecated - use Auth class instead
  582. */
  583. public function roleNames($sessionRoles = null) {
  584. $tmp = array();
  585. if ($sessionRoles === null) {
  586. $sessionRoles = $this->Session->read('Auth.User.Role');
  587. }
  588. $roles = Cache::read('User.Role');
  589. if (empty($roles) || !is_array($roles)) {
  590. $Role = ClassRegistry::init('Role');
  591. $roles = $Role->getActive('list');
  592. Cache::write('User.Role', $roles);
  593. }
  594. if (!empty($sessionRoles)) {
  595. if (is_array($sessionRoles)) {
  596. foreach ($sessionRoles as $sessionRole) {
  597. if (!$sessionRole) {
  598. continue;
  599. }
  600. if (array_key_exists((int)$sessionRole, $roles)) {
  601. $tmp[$sessionRole] = $roles[(int)$sessionRole];
  602. }
  603. }
  604. } else {
  605. if (array_key_exists($sessionRoles, $roles)) {
  606. $tmp[$sessionRoles] = $roles[$sessionRoles];
  607. }
  608. }
  609. }
  610. return $tmp;
  611. }
  612. /**
  613. * Display Roles separated by Commas
  614. * @deprecated - use Auth class instead
  615. */
  616. public function displayRoles($sessionRoles = null, $placeHolder = '---') {
  617. $roles = $this->roleNames($sessionRoles);
  618. if (!empty($roles)) {
  619. return implode(', ', $roles);
  620. }
  621. return $placeHolder;
  622. }
  623. /**
  624. * Takes int / array(int) and finds the role name to it
  625. * @return array roles
  626. */
  627. public function roleNamesTranslated($value) {
  628. if (empty($value)) {
  629. return array();
  630. }
  631. $ret = array();
  632. $translate = (array)Configure::read('Role');
  633. if (is_array($value)) {
  634. foreach ($value as $k => $v) {
  635. $ret[$v] = __($translate[$v]);
  636. }
  637. } else {
  638. $ret[$value] = __($translate[$value]);
  639. }
  640. return $ret;
  641. }
  642. }