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


PHP Images::getFileNameParts方法代码示例

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


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

示例1: image_url

/**
 * $image : string
 */
function image_url($image, $type = null, $force_no_base = false, $use_temp = false, $new_ext = null)
{
    if (!is_null($type)) {
        $images_types = sfConfig::get('app_images_types');
        $suffix = $images_types[$type]['suffix'];
    } else {
        $suffix = '';
    }
    list($image_name, $image_ext) = Images::getFileNameParts($image);
    $base_path = $force_no_base ? '' : sfConfig::get('app_static_url');
    $base_path .= DIRECTORY_SEPARATOR . sfConfig::get('app_upload_dir') . DIRECTORY_SEPARATOR . ($use_temp ? sfConfig::get('app_images_temp_directory_name') : sfConfig::get('app_images_directory_name')) . DIRECTORY_SEPARATOR;
    return $base_path . $image_name . $suffix . (isset($new_ext) ? $new_ext : $image_ext);
}
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:16,代码来源:MyImageHelper.php

示例2: executeRotate

 public function executeRotate()
 {
     $id = $this->getRequestParameter('id');
     $referer = $this->getRequest()->getReferer();
     $degrees = (int) $this->getRequestParameter('degrees');
     if ($degrees !== 90 && $degrees !== -90) {
         $referer = $this->getRequest()->getReferer();
         $this->setErrorAndRedirect('Bad rotation value', $referer);
     }
     $doc = Document::find('Image', $id);
     $this->document = $doc;
     if (!$doc) {
         $this->setErrorAndRedirect('Image not found', $referer);
     }
     // check if the user has the right for editing the image
     $this->filterAuthorizedPeople($id);
     $temp_dir = sfConfig::get('sf_upload_dir') . DIRECTORY_SEPARATOR . sfConfig::get('app_images_temp_directory_name') . DIRECTORY_SEPARATOR;
     $upload_dir = sfConfig::get('sf_upload_dir') . DIRECTORY_SEPARATOR . sfConfig::get('app_images_directory_name') . DIRECTORY_SEPARATOR;
     list($filename, $extension) = Images::getFileNameParts($doc->getFilename());
     $unique_filename = c2cTools::generateUniqueName();
     // because images on production get migrated after a while on a different server
     // we need to check if the file exists on disk before trying to rotate the image
     if (!file_exists($upload_dir . $filename . $extension)) {
         $this->setErrorAndRedirect('Image cannot be rotated anymore', $referer);
     }
     Images::rotateImage($upload_dir . $filename . $extension, $temp_dir . $unique_filename . $extension, $degrees);
     Images::generateThumbnails($unique_filename, $extension, $temp_dir);
     if (!Images::moveAll($unique_filename . $extension, $temp_dir, $upload_dir)) {
         $this->setErrorAndRedirect('Rotation failed', $referer);
     }
     // we don't create a new image document version, instead we directly
     // update the filename field and clear cache
     // We need to change it everytime it appears, since we could have several image versions
     // with same filename (if non-i18n data like categroies has been changed)
     try {
         $conn = sfDoctrine::Connection();
         $conn->beginTransaction();
         Doctrine_Query::create()->update('ImageArchive ia')->set('ia.filename', '?')->where('ia.id = ? AND ia.filename = ?', array($unique_filename . $extension, $id, $filename . $extension))->execute();
         $conn->commit();
         // Delete old files
         Images::removeAll($filename . $extension, $upload_dir);
     } catch (Exception $e) {
         $conn->rollback();
         // delete rotated images
         Images::removeAll($unique_filename . $extension, $upload_dir);
         $this->setErrorAndRedirect('Rotation failed', $referer);
     }
     // clear cache of current doc
     $this->clearCache('images', $id);
     // clear views of the associated docs in every language (content+interface):
     $associated_docs = Association::findAllAssociatedDocs($id, array('id', 'module'));
     foreach ($associated_docs as $doc) {
         // clear their view cache
         $this->clearCache($doc['module'], $doc['id'], false, 'view');
     }
     // redirect to view
     $this->setNoticeAndRedirect('Image rotated successfully', $referer);
 }
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:58,代码来源:actions.class.php


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