Smarty
[ class tree: Smarty ] [ index: Smarty ] [ all elements ]

Source for file modifier.displayUrl.php

Documentation is available at modifier.displayUrl.php

  1. <?php
  2. /**
  3.  * Smarty plugin
  4.  * @package Smarty
  5.  * @subpackage plugins
  6.  */
  7.  
  8. /**
  9.  * Smarty plugin
  10.  * -------------------------------------------------------------
  11.  * Type:     modifier
  12.  * Name:     displayUrl
  13.  * Purpose:  give back the display URL
  14.  * If the modification is preformed on a string then the (new <lib>)->getDisplayUrl method is called, (this defaults to BitPage if not specified)
  15.  * If the modification is preformed on an object then, if <lib> is given, then it is passed as the parameter to (new <lib>)->getDisplayUrl otherwise, the object' getDisplayUrl method is called
  16.  * If the modification is preformed on an array then, if <lib> is given, then it is passed as the parameter to (new <lib>)->getDisplayUrl otherwise the following is attempted:
  17.  *     If the array contains an element display_url it is returned
  18.  *     If the array contains an element content_type_guid then lib becomes the handler class of the content_type_guid and the array is passed as the parameter to (new <lib>)->getDisplayUrl
  19.  *     If the array contains an element handler_class then lib becomes the handler_class and the array is passed as the parameter to (new <lib>)->getDisplayUrl
  20.  * --
  21.  * If all of the above tests fail then LibertyContent::getDisplayUrlFromHash with the argument to the modifier passed as the second argument
  22.  * Example: {'My Page'|displayUrl}, {'admin'|displayUrl:BitUser}, {$gContent|displayUrl:MyObject}
  23.  * -------------------------------------------------------------
  24.  */
  25.  
  26. function smarty_modifier_displayUrl_findLib(&$lib,$class_only=false{
  27.   global $gLibertySystem;
  28.     if (!class_exists($lib)) {
  29.         foreach ($gLibertySystem->mContentTypes as $type{
  30.             if ($type['handler_class']==$lib{
  31.                 smarty_modifier_displayUrl_loadLib($type);
  32.                 return true;
  33.             elseif ((!$class_only&& ($type['content_type_guid']==$lib)) {
  34.                 $lib $type['handler_class'];
  35.                 smarty_modifier_displayUrl_loadLib($type);
  36.                 return true;
  37.             }
  38.         }
  39.         return false;
  40.     }
  41.     return true;
  42. }
  43.  
  44.     $path constant(strtoupper($type['handler_package']).'_PKG_PATH');
  45.     require_once($path.$type['handler_file']);
  46. }
  47.  
  48. function smarty_modifier_displayUrl($pMixed$lib=''{
  49.     global  $gLibertySystem;
  50.     if (is_string($pMixed)) {
  51.         if (empty($lib)) $lib ='BitPage';
  52.         if (smarty_modifier_displayUrl_findLib($lib)) {
  53.             $call =array($lib'getDisplayUrl');
  54.             if (is_callable($call)) {
  55.                 return call_user_func($call,$pMixed);
  56.             }
  57.             $i $lib();
  58.             if (method_exists($i,'getDisplayUrl')) {
  59.                 return $i->getDisplayUrl($pMixed);
  60.             }
  61.         }
  62.     elseif (is_object($pMixed)) {
  63.         if (!empty($lib)) {
  64.             if (smarty_modifier_displayUrl_findLib($lib)) {
  65.                 $i $lib();
  66.                 return $i->getDisplayUrl($pMixed);
  67.             }
  68.         }
  69.         if (method_exists($pMixed,'getDisplayUrl')) {
  70.             return $pMixed->getDisplayUrl();
  71.         }
  72.     elseif (is_array($pMixed)) {
  73.         if (!empty($lib)) {
  74.             if (smarty_modifier_displayUrl_findLib($lib)) {
  75.                 $i new $lib();
  76.                 return $i->getDisplayUrl($pMixed);
  77.             }
  78.         }
  79.         if (!empty($pMixed['display_url'])) {
  80.             return $pMixed['display_url'];
  81.         }
  82.         if (!empty($pMixed['content_type_guid'])) {
  83.             $type =$gLibertySystem->mContentTypes[$pContentType];
  84.             if (!empty($type)) {
  85.                 $lib $type['handler_class'];
  86.                 smarty_modifier_displayUrl_loadLib($type);
  87.                 $i new $lib();
  88.                 return $i->getDisplayUrl($pMixed);
  89.             }
  90.         }
  91.         if (!empty($pMixed['handler_class'])) {
  92.             $lib$pMixed['handler_class'];
  93.             if (smarty_modifier_displayUrl_findLib($lib,true)) {
  94.                 $i $lib();
  95.                 return $i->getDisplayUrl($pMixed);
  96.             }
  97.         }
  98.     }
  99.     return LibertyContent::getDisplayUrlFromHash$pMixed );
  100. }
  101. ?>

Documentation generated on Wed, 29 Jul 2015 13:57:09 +0000 by phpDocumentor 1.5.0-lsces