当前位置: 首页>>代码示例>>PHP>>正文


PHP UploadBase::isThumbName方法代码示例

本文整理汇总了PHP中UploadBase::isThumbName方法的典型用法代码示例。如果您正苦于以下问题:PHP UploadBase::isThumbName方法的具体用法?PHP UploadBase::isThumbName怎么用?PHP UploadBase::isThumbName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UploadBase的用法示例。


在下文中一共展示了UploadBase::isThumbName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: findFiles

 /**
  * Searches the DOM for <img>-Tags and <a> Tags with class 'internal', 
  * resolves the local filesystem path and adds it to $aFiles array.
  * @param DOMDocument $oHtml The markup to be searched.
  * @return boolean Well, always true.
  */
 protected function findFiles(&$oHtml)
 {
     //Find all images
     $oImageElements = $oHtml->getElementsByTagName('img');
     foreach ($oImageElements as $oImageElement) {
         $sSrcUrl = urldecode($oImageElement->getAttribute('src'));
         $sSrcFilename = basename($sSrcUrl);
         $bIsThumb = UploadBase::isThumbName($sSrcFilename);
         $sTmpFilename = $sSrcFilename;
         if ($bIsThumb) {
             //HINT: Thumbname-to-filename-conversion taken from includes/Upload/UploadBase.php
             //Check for filenames like 50px- or 180px-, these are mostly thumbnails
             $sTmpFilename = substr($sTmpFilename, strpos($sTmpFilename, '-') + 1);
         }
         $oFileTitle = Title::newFromText($sTmpFilename, NS_FILE);
         $oImage = RepoGroup::singleton()->findFile($oFileTitle);
         if ($oImage instanceof File && $oImage->exists()) {
             $oFileRepoLocalRef = $oImage->getRepo()->getLocalReference($oImage->getPath());
             if (!is_null($oFileRepoLocalRef)) {
                 $sAbsoluteFileSystemPath = $oFileRepoLocalRef->getPath();
             }
             $sSrcFilename = $oImage->getName();
         } else {
             $sAbsoluteFileSystemPath = $this->getFileSystemPath($sSrcUrl);
         }
         // TODO RBV (05.04.12 11:48): Check if urlencode has side effects
         $oImageElement->setAttribute('src', 'images/' . urlencode($sSrcFilename));
         $sFileName = $sSrcFilename;
         wfRunHooks('BSUEModulePDFWebserviceFindFiles', array($this, $oImageElement, $sAbsoluteFileSystemPath, $sFileName, 'IMAGE'));
         $this->aFiles['IMAGE'][$sFileName] = $sAbsoluteFileSystemPath;
     }
     $oDOMXPath = new DOMXPath($oHtml);
     /*
     * This is now in template
     		//Find all CSS files
     		$oLinkElements = $oHtml->getElementsByTagName( 'link' ); // TODO RBV (02.02.11 16:48): Limit to rel="stylesheet" and type="text/css"
     		foreach( $oLinkElements as $oLinkElement ) {
     			$sHrefUrl = $oLinkElement->getAttribute( 'href' );
     			$sHrefFilename           = basename( $sHrefUrl );
     			$sAbsoluteFileSystemPath = $this->getFileSystemPath( $sHrefUrl );
     			$this->aFiles[ $sAbsoluteFileSystemPath ] = array( $sHrefFilename, 'STYLESHEET' );
     			$oLinkElement->setAttribute( 'href', 'stylesheets/'.$sHrefFilename );
     		}
     */
     //Find all files for attaching and merging...
     if ($this->aParams['pdf-merging'] == '1' || $this->aParams['attachments'] == '1') {
         $sUploadPath = BsCore::getInstance()->getAdapter()->get('UploadPath');
         // TODO RBV (08.02.11 15:15): Necessary to exclude images?
         $oFileAnchorElements = $oDOMXPath->query("//a[contains(@class,'internal') and not(contains(@class, 'image'))]");
         foreach ($oFileAnchorElements as $oFileAnchorElement) {
             $sHref = urldecode($oFileAnchorElement->getAttribute('href'));
             $vUploadPathIndex = strpos($sHref, $sUploadPath);
             if ($vUploadPathIndex !== false) {
                 $sRelativeHref = substr($sHref, $vUploadPathIndex);
                 $sHrefFilename = basename($sRelativeHref);
                 $sAbsoluteFileSystemPath = $this->getFileSystemPath($sRelativeHref);
                 if ($this->aParams['attachments'] == '1') {
                     wfRunHooks('BSUEModulePDFWebserviceFindFiles', array($this, $oFileAnchorElement, $sAbsoluteFileSystemPath, $sHrefFilename, 'ATTACHMENT'));
                     $this->aFiles['ATTACHMENT'][$sHrefFilename] = $sAbsoluteFileSystemPath;
                 }
             }
         }
     }
     return true;
 }
开发者ID:hfroese,项目名称:mediawiki-extensions-BlueSpiceExtensions,代码行数:71,代码来源:PDFWebService.class.php

示例2: findFiles

 /**
  * Searches the DOM for <img>-Tags and <a> Tags with class 'internal',
  * resolves the local filesystem path and adds it to $aFiles array.
  * @param DOMDocument $oHtml The markup to be searched.
  * @return boolean Well, always true.
  */
 protected function findFiles(&$oHtml)
 {
     //Find all images
     $oImageElements = $oHtml->getElementsByTagName('img');
     foreach ($oImageElements as $oImageElement) {
         $sSrcUrl = urldecode($oImageElement->getAttribute('src'));
         $sSrcFilename = basename($sSrcUrl);
         $bIsThumb = UploadBase::isThumbName($sSrcFilename);
         $sTmpFilename = $sSrcFilename;
         if ($bIsThumb) {
             //HINT: Thumbname-to-filename-conversion taken from includes/Upload/UploadBase.php
             //Check for filenames like 50px- or 180px-, these are mostly thumbnails
             $sTmpFilename = substr($sTmpFilename, strpos($sTmpFilename, '-') + 1);
         }
         $oFileTitle = Title::newFromText($sTmpFilename, NS_FILE);
         $oImage = RepoGroup::singleton()->findFile($oFileTitle);
         if ($oImage instanceof File && $oImage->exists()) {
             $oFileRepoLocalRef = $oImage->getRepo()->getLocalReference($oImage->getPath());
             if (!is_null($oFileRepoLocalRef)) {
                 $sAbsoluteFileSystemPath = $oFileRepoLocalRef->getPath();
             }
             $sSrcFilename = $oImage->getName();
         } else {
             $sAbsoluteFileSystemPath = $this->getFileSystemPath($sSrcUrl);
         }
         // TODO RBV (05.04.12 11:48): Check if urlencode has side effects
         $oImageElement->setAttribute('src', 'images/' . urlencode($sSrcFilename));
         $sFileName = $sSrcFilename;
         wfRunHooks('BSUEModulePDFFindFiles', array($this, $oImageElement, &$sAbsoluteFileSystemPath, &$sFileName, 'images'));
         wfRunHooks('BSUEModulePDFWebserviceFindFiles', array($this, $oImageElement, &$sAbsoluteFileSystemPath, &$sFileName, 'images'));
         $this->aFiles['images'][$sFileName] = $sAbsoluteFileSystemPath;
     }
     $oDOMXPath = new DOMXPath($oHtml);
     /*
     * This is now in template
     		//Find all CSS files
     		$oLinkElements = $oHtml->getElementsByTagName( 'link' ); // TODO RBV (02.02.11 16:48): Limit to rel="stylesheet" and type="text/css"
     		foreach( $oLinkElements as $oLinkElement ) {
     			$sHrefUrl = $oLinkElement->getAttribute( 'href' );
     			$sHrefFilename           = basename( $sHrefUrl );
     			$sAbsoluteFileSystemPath = $this->getFileSystemPath( $sHrefUrl );
     			$this->aFiles[ $sAbsoluteFileSystemPath ] = array( $sHrefFilename, 'STYLESHEET' );
     			$oLinkElement->setAttribute( 'href', 'stylesheets/'.$sHrefFilename );
     		}
     */
     wfRunHooks('BSUEModulePDFAfterFindFiles', array($this, $oHtml, &$this->aFiles, $this->aParams, $oDOMXPath));
     return true;
 }
开发者ID:hfroese,项目名称:mediawiki-extensions-BlueSpiceExtensions,代码行数:54,代码来源:PDFServlet.class.php


注:本文中的UploadBase::isThumbName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。