Beispiel #1
0
 /**
  * Get path paremeter from request. Test if parameter is relative path or document alias.
  * Test if path is virtual path.
  *
  * @param string $path path to control, if null use param path from request
  * @return string
  */
 public static function getPath($path = null)
 {
     static $model;
     /* @var $model JoomDOCModelDocument */
     $mainframe = JFactory::getApplication();
     /* @var $mainframe JApplication (JSite or JAdministrator) */
     if ($mainframe->isSite() && is_null($model)) {
         $model = JModelLegacy::getInstance(JOOMDOC_DOCUMENT, JOOMDOC_MODEL_PREFIX);
     }
     // get root path from request or config
     if (!$path) {
         $path = JString::trim(JRequest::getString('path'));
     }
     $path = JoomDOCString::urldecode($path);
     // frontend
     if ($mainframe->isSite()) {
         // path from request can be document full alias - search for path in document table
         $candidate = $model->searchRelativePathByFullAlias($path);
         if ($candidate) {
             $path = $candidate;
         } else {
             // if request param is path convert from virtual to full relative path
             $path = JoomDOCFileSystem::getNonVirtualPath($path);
         }
     } else {
         // backend
         $path = $mainframe->getUserStateFromRequest(JoomDOCRequest::getSessionPrefix() . 'path', 'path', '', 'string');
         if ($path == JText::_('JOOMDOC_ROOT')) {
             return '';
         }
     }
     $path = str_replace('/', DIRECTORY_SEPARATOR, $path);
     //windows
     if ($path) {
         $path = JPath::clean($path);
     }
     return $path;
 }