安装完成后虽然可以正常浏览网站了,但是由于upload目录没有写权限,还需要对文件管理模块进行修改以适应sae的环境,经过导师指点查看了禅道sae3.0版本的迁移方案,初步确定修改思路。也使用了部分原迁移方案的代码,感谢禅道3.0sae版本的开发者留下的资料与经验。

1.文件的保存。需要将文件保存到storage上。

2.文件获取(路径)。需要将路径更改为storage路径。

3.文件管理(在上传后有图片空间对话框进行文件的查看)

3.1目录列表获取

3.2文件移动

3.3文件删除

(一)在修改过程中使用最新的saestorage.php时由于没有找到完整的phpAPI包,引入swift.php时报错。所以暂时使用了禅道中使用的saestorage.php文件。第一步先仿照禅道的迁移方案进行了扩展使文件上传实现。增加file/ext/model/sae.php文件(修改保存文件方式,修改文件路径获取)

<?php
public function getById($fileID)
{$file = $this->dao->findById($fileID)->from(TABLE_FILE)->fetch();$file->realPath = 'saestor://' . $this->config->sae->storage->domain . '/' . $file->pathname;$file->webPath  = $this->app->loadClass('saestorage')->getURL($this->config->sae->storage->domain, $file->pathname);return $file;
}public function saveUpload($objectType = '', $objectID = '', $extra = '')
{$fileTitles = array();$now        = helper::now(); //原使用today函数sql插入时不成功$files      = $this->getUpload();$this->storage = $this->app->loadClass('saestorage');foreach($files as $id => $file){$this->storage->upload($this->config->sae->storage->domain, $file['pathname'], $file['tmpname']);$file['objectType'] = $objectType;$file['objectID']   = $objectID;$file['addedBy']    = $this->app->user->account;$file['addedDate']  = $now;$file['extra']      = $extra;unset($file['tmpname']);$this->dao->insert(TABLE_FILE)->data($file)->exec();$fileTitles[$this->dao->lastInsertId()] = $file['title'];}return $fileTitles;
}

增加file/ext/control/ajaxupload.php(将文件保存到SAE storage)

<?php
class file extends control
{public function ajaxUpload(){$file = $this->file->getUpload('imgFile');$file = $file[0];if($file){$url = $this->app->loadClass('saestorage')->upload($this->config->sae->storage->domain, $file['pathname'], $file['tmpname']);$file['addedBy']    = $this->app->user->account;$file['addedDate']  = helper::today();unset($file['tmpname']);$this->dao->insert(TABLE_FILE)->data($file)->exec();die(json_encode(array('error' => 0, 'url' => $url)));}}
}

增加file/ext/control/buildform.php(去掉目录是否可写的检查)

<?php
class file extends control
{/*** Build the upload form.* * @param  int    $fileCount * @param  float  $percent * @access public* @return void*/public function buildForm($fileCount = 2, $percent = 0.9){ $this->view->fileCount = $fileCount;$this->view->percent   = $percent;$this->display();}
}

以上三段代码来自禅道SAE3.0版本。

经以上扩展后能实现基本的文件上传。但是涉及到文件管理的部分扔有问题。下一步就是添加扩展使文件管理相关的功能实现。

(二)修改文章附件相关

在以上修改后打开附件发现提示目录不可写,添加model的checkSavePath()方法扩展后,发现上传文件选择form没有出现,经过调试排查发现是browse.html.php里的<td><?php echo $this->fetch('file', 'buildForm');?></td>执行fetch方法时未返回内容,怀疑是添加buildForm方法扩展导致,遂删除buildForm扩展。解决!

修改内容如下:在上一步中添加的file/ext/model/sae.php文件中添加checkSavePath()方法扩展,去除目录是否可写的检查,添加后文件:

<?php
public function getById($fileID)
{$file = $this->dao->findById($fileID)->from(TABLE_FILE)->fetch();$file->realPath = 'saestor://' . $this->config->sae->storage->domain . '/' . $file->pathname;$file->webPath  = $this->app->loadClass('saestorage')->getURL($this->config->sae->storage->domain, $file->pathname);return $file;
}public function saveUpload($objectType = '', $objectID = '', $extra = '')
{$fileTitles = array();$now        = helper::now(); //原使用today函数sql插入时不成功$files      = $this->getUpload();$this->storage = $this->app->loadClass('saestorage');foreach($files as $id => $file){$this->storage->upload($this->config->sae->storage->domain, $file['pathname'], $file['tmpname']);$file['objectType'] = $objectType;$file['objectID']   = $objectID;$file['addedBy']    = $this->app->user->account;$file['addedDate']  = $now;$file['extra']      = $extra;unset($file['tmpname']);$this->dao->insert(TABLE_FILE)->data($file)->exec();$fileTitles[$this->dao->lastInsertId()] = $file['title'];}return $fileTitles;
}public function checkSavePath()
{return true;
}

将上一步中的file/ext/control/buildform.php删除。

附件显示的时候会间接调用processFile($file)方法,该方法会返回file的fullURL,需要将该url修改为storage的,在file/ext/model/sae.php文件中扩展该方法(修改的$file->webPath和$filr->fullURL两行)

public function processFile($file)
{$file->webPath   = $this->app->loadClass('saestorage')->getURL($this->config->sae->storage->domain, $file->pathname);$file->fullURL   = $file->webPath;$file->middleURL = '';$file->smallURL  = '';$file->isImage   = false;if(in_array(strtolower($file->extension), $this->config->file->imageExtensions) !== false){$file->middleURL = $this->webPath . str_replace('f_', 'm_', $file->pathname);$file->smallURL  = $this->webPath . str_replace('f_', 's_', $file->pathname);$file->largeURL  = $this->webPath . str_replace('f_', 'l_', $file->pathname);if(!file_exists(str_replace($this->webPath, $this->savePath, $file->middleURL))) $file->middleURL = $file->fullURL;if(!file_exists(str_replace($this->webPath, $this->savePath, $file->smallURL)))  $file->smallURL  = $file->fullURL;if(!file_exists(str_replace($this->webPath, $this->savePath, $file->largeURL)))  $file->largeURL  = $file->fullURL;$file->isImage = true;}return $file;
}

在上传的附件图片预览中发现使用3.0的迁移方法缺少图片宽度和图片高度的处理,对saveUpload()重新修改如下

public function saveUpload($objectType = '', $objectID = '', $extra = '')
{$fileTitles = array();$now        = helper::now();$files      = $this->getUpload();$this->storage = $this->app->loadClass('saestorage');foreach($files as $id => $file){   $imageSize = array('width' => 0, 'height' => 0);$this->storage->upload($this->config->sae->storage->domain, $file['pathname'], $file['tmpname']);if(in_array(strtolower($file['extension']), $this->config->file->imageExtensions)){$this->compressImage($file['pathname']);$imageSize = $this->getImageSize($file['tmpname']);}$file['objectType'] = $objectType;$file['objectID']   = $objectID;$file['addedBy']    = $this->app->user->account;$file['addedDate']  = $now;$file['extra']      = $extra;$file['width']      = $imageSize['width'];$file['height']     = $imageSize['height'];unset($file['tmpname']);$this->dao->insert(TABLE_FILE)->data($file)->exec();$fileTitles[$this->dao->lastInsertId()] = $file['title'];}return $fileTitles;
}

修改后生成缩略图功能暂时失效。

还需要对replaceFile进行修改

对File每个方法检查一遍,并进行相应的修改

演示http://chanz.sinaapp.com/  admin 123

蝉知门户系统迁移到SAE平台-File模块扩展相关推荐

  1. 蝉知门户系统迁移到SAE平台-对蝉知2.5版本部分功能的限制

    蝉知2.5版本加入了部分新功能,使用起来更加方便.但在sae平台上受限于平台环境,其中的插件安装.模板安装功能由于没有写权限无法使用.需要在迁移至sae平台时做出限制,提示用户进行其他方式的安装. 1 ...

  2. 蝉知CMS本地迁移到服务器具体步骤

    蝉知迁移步骤(2个方案,二选一即可) 方案一(整个chanzhi(eps)目录拷贝,假设新安装的蝉知文件夹名称为chanzhieps): 1.在新服务器上安装相同版本(版本号必须一致)的蝉知(安装文档 ...

  3. 【复杂系统迁移 .NET Core平台系列】之调度服务改造

    源宝导读:微软跨平台技术框架-.NET Core已经日趋成熟,已经具备了支撑大型系统稳定运行的条件.本文将介绍明源云ERP平台从.NET Framework向.NET Core迁移过程中的实践经验. ...

  4. 【复杂系统迁移 .NET Core平台系列】之认证和授权

    源宝导读:微软跨平台技术框架-.NET Core已经日趋成熟,已经具备了支撑大型系统稳定运行的条件.本文将介绍明源云ERP平台从.NET Framework向.NET Core迁移过程中的实践经验. ...

  5. 【复杂系统迁移 .NET Core平台系列】之静态文件

    源宝导读:微软跨平台技术框架-.NET Core已经日趋成熟,已经具备了支撑大型系统稳定运行的条件.本文将介绍明源云ERP平台从.NET Framework向.NET Core迁移过程中的实践经验. ...

  6. 【复杂系统迁移 .NET Core平台系列】之界面层

    源宝导读:微软跨平台技术框架-.NET Core已经日趋成熟,已经具备了支撑大型系统稳定运行的条件.本文将介绍明源云ERP平台从.NET Framework向.NET Core迁移过程中的实践经验. ...

  7. 蝉知企业门户系统v7.7 - 命令执行漏洞

    蝉知企业门户系统v7.7 - 命令执行漏洞 环境搭建 漏洞复现 漏洞分析 环境搭建 源码下载地址 解压后将文件放在 web 目录下即可访问 漏洞复现 首先登录后台,找到模板编辑的地方(设计 -> ...

  8. 蝉知企业门户系统 6.2 发布,新增随机区块的功能

    大家好,蝉知企业门户系统6.2正式发布了. 蝉知企业门户系统是由业内资深开发团队开发的一款专向企业营销使用的企业门户系统,企业使用蝉知系统可以非常方便地搭建一个专业的企业营销网站,进行宣传,开展业务, ...

  9. 蝉知 路径index.php,蝉知CMS系统部署中的一些问题的解决方法

    本人所带的网页设计课,要求学生最后用CMS系统部署一个公网可以访问的网站.其中推荐了蝉知CMS系统,因为我想这个系统比较简单,全中文文档,学生好上手.不过在实际开发中,学生还有一些问题,是官方手册中较 ...

最新文章

  1. 来谈谈Servlet~~
  2. Aurora的安装和中文配置
  3. 【javamatlab】以一个简单的例子实现java和matlab混编
  4. Java扫描注解下的包_使用Spring mvc 利用java的反射技术,来扫描对应包下的注解请求url 统一保存在数据库中...
  5. 因为应用程序的并行配置不正确 sxstrace
  6. 病毒木马防御与分析实战
  7. CSMAR database query sample
  8. apache代理时java获取IP的问题
  9. python计算相关矩阵_Numpy使用大全(python矩阵相关运算大全)-Python数据分析基础2...
  10. 《『若水新闻』客户端开发教程》——01.课程介绍
  11. Luogu 4244 [SHOI2008]仙人掌图
  12. android用java写文本框_Android 自动完成文本框的实例
  13. Git基础知识与常用命令
  14. 开源大数据周刊-第22期
  15. Android Studio 设置HTTP代理无法取消的问题
  16. Visual Studio [即时窗口] [命令窗口] (Immediate Window Command Window) 转
  17. pdo mysql 函数_PDO函数属性详解
  18. 解决docker容器中使用composer,无法解析安装包
  19. 从0开始的OpenGL学习(八)-显示3D立方体
  20. tensorflow之四运转方式入门

热门文章

  1. 因为是你 所以没关系:伤感日志
  2. 网易有数BI在数据可视化领域的优势地位因何受到挑战?
  3. Flask SQLAlchemy - 2013 Lost Connection
  4. Win10十二月更新系统讲了什么?
  5. App应用字体大小保持固定以及关于Configuration的变化
  6. glassfish简单介绍
  7. 租的房子里有无线路由器有ip和dns服务器无密码可以联网吗,没网怎么设置路由器?...
  8. 最新版-----新浪微博的第三方登录
  9. 2012最新网站手工注入详解教程
  10. uefi装完系统后无法引导_【修正】实战WIN10+UEFI引导装系统(不重装不格盘100%成功)...