コード例 #1
0
ファイル: Page.entity.class.php プロジェクト: hard990/altocms
 public function getUrlPath()
 {
     $sResult = $this->getProp('_page_url_path');
     if (!$sResult) {
         $sResult = F::File_LocalUrl(R::GetPath('page') . '/' . $this->getUrlFull());
         $this->setProp('_page_url_path', $sResult);
     }
     return $sResult;
 }
コード例 #2
0
ファイル: Text.class.php プロジェクト: AlexSSN/altocms
 /**
  * Учет ссылок в тексте
  *
  * @param string $sTag
  * @param array  $aParams
  * @param string $sContent
  * @param string $sText
  *
  * @return string
  */
 public function CallbackCheckLinks($sTag, $aParams, $sContent, $sText = null)
 {
     if (isset($this->aCheckTagLinks[$sTag])) {
         if (isset($aParams[$this->aCheckTagLinks[$sTag]['link']])) {
             $sLinkAttr = $this->aCheckTagLinks[$sTag]['link'];
             $sLink = E::ModuleMresource()->NormalizeUrl($aParams[$sLinkAttr]);
             $nType = $this->aCheckTagLinks[$sTag]['type'];
             $this->aLinks[] = array('type' => $nType, 'link' => $sLink);
             $sText = '<' . $sTag . ' ';
             if (F::File_LocalUrl($aParams[$sLinkAttr]) && isset($aParams['rel']) && $aParams['rel'] == 'nofollow') {
                 unset($aParams['rel']);
             }
             foreach ($aParams as $sKey => $sVal) {
                 if ($sKey == $sLinkAttr && $this->aCheckTagLinks[$sTag]['restoreFunc']) {
                     $sVal = call_user_func($this->aCheckTagLinks[$sTag]['restoreFunc'], $sLink);
                 }
                 $sText .= $sKey . '="' . $sVal . '" ';
             }
             if (is_null($sContent) || empty($this->aCheckTagLinks[$sTag]['pairedTag'])) {
                 $sText = trim($sText) . '>';
             } else {
                 $sText = trim($sText) . '>' . $sContent . '</' . $sTag . '>';
             }
         }
     }
     return $sText;
 }
コード例 #3
0
ファイル: Mresource.class.php プロジェクト: hard990/altocms
 /**
  * Calc hash of URL for seeking & comparation
  *
  * @param string $sUrl
  *
  * @return string
  */
 public function CalcUrlHash($sUrl)
 {
     if (substr($sUrl, 0, 1) != '@') {
         $sPathUrl = F::File_LocalUrl($sUrl);
         if ($sPathUrl) {
             $sUrl = '@' . trim($sPathUrl, '/');
         }
     }
     return md5($sUrl);
 }
コード例 #4
0
 /**
  * Sets full url of resource
  *
  * @param $sUrl
  */
 public function SetUrl($sUrl)
 {
     if (substr($sUrl, 0, 1) === '@') {
         $sPathUrl = substr($sUrl, 1);
         $sUrl = F::File_RootUrl() . $sPathUrl;
     } else {
         $sPathUrl = F::File_LocalUrl($sUrl);
     }
     if ($sPathUrl) {
         // Сохраняем относительный путь
         $this->SetPathUrl('@' . trim($sPathUrl, '/'));
         if (!$this->getPathFile()) {
             $this->SetFile(F::File_Url2Dir($sUrl));
         }
     } else {
         // Сохраняем абсолютный путь
         $this->SetPathUrl($sUrl);
     }
     if (is_null($this->GetPathFile())) {
         if (is_null($this->GetLink())) {
             $this->SetLink(true);
         }
         if (is_null($this->GetType())) {
             $this->SetType(ModuleMresource::TYPE_HREF);
         }
     }
     $this->RecalcHash();
 }
コード例 #5
0
ファイル: Router.class.php プロジェクト: hard990/altocms
 /**
  * Returns real URL (or path of URL) without rewrites
  *
  * @param bool $bPathOnly
  *
  * @return null|string
  */
 public static function RealUrl($bPathOnly = false)
 {
     $sResult = static::$sCurrentFullUrl;
     if ($bPathOnly) {
         $sResult = F::File_LocalUrl($sResult);
     }
     return $sResult;
 }
コード例 #6
0
 /**
  * Возвращает ссылку фото определенного размера
  *
  * @param string|null $xSize    Размер фото, например, '100' или '150crop' или '150x100' или 'x100'
  *
  * @return null|string
  */
 public function getLink($xSize = null)
 {
     if ($sUrl = $this->getPath()) {
         if ($xSize) {
             $sResizedUrl = $this->getProp('_size-' . $xSize . '-url');
             if ($sResizedUrl) {
                 return $sResizedUrl;
             }
             $aPathInfo = pathinfo($sUrl);
             if (E::ActivePlugin('ls')) {
                 // Включена совместимость с LS
                 $sResizedUrl = $aPathInfo['dirname'] . '/' . $aPathInfo['filename'] . '_' . $xSize . '.' . $aPathInfo['extension'];
                 if (F::File_LocalUrl($sResizedUrl) && !F::File_Exists(F::File_Url2Dir($sResizedUrl))) {
                     $sResizedUrl = '';
                 }
             }
             if (!$sResizedUrl) {
                 $sModSuffix = F::File_ImgModSuffix($xSize, $aPathInfo['extension']);
                 if ($sModSuffix) {
                     $sResizedUrl = $sUrl . $sModSuffix;
                     if (Config::Get('module.image.autoresize')) {
                         $sFile = E::ModuleUploader()->Url2Dir($sResizedUrl);
                         $this->setProp('_size-' . $xSize . '-file', $sFile);
                         if (!F::File_Exists($sFile)) {
                             E::ModuleImg()->Duplicate($sFile);
                         }
                     }
                 }
             }
             if ($sResizedUrl) {
                 $sUrl = F::File_NormPath($sResizedUrl);
             }
             $this->setProp('_size-' . $xSize . '-url', $sUrl);
         }
     }
     return $sUrl;
 }
コード例 #7
0
 /**
  * @param string $sUrl
  *
  * @return string
  */
 public function Url2Dir($sUrl)
 {
     if (F::File_LocalUrl($sUrl)) {
         $sDir = F::File_Url2Dir($sUrl);
         if (strpos($sDir, Config::Get('path.uploads.root')) === 0) {
             $sDir = F::File_NormPath(Config::Get('path.static.dir') . $sDir);
         } elseif (Config::Get('path.root.subdir') && strpos($sDir, Config::Get('path.root.subdir') . Config::Get('path.uploads.root')) === 0) {
             $sRootPath = substr(Config::Get('path.static.dir'), 0, -strlen(Config::Get('path.root.subdir')));
             $sDir = F::File_NormPath($sRootPath . $sDir);
         }
         return $sDir;
     }
 }