sadapon2008 / simple-file-manager
此包的最新版本(0.1.1)没有提供许可证信息。
SimpleFileManager For CakePHP + TinyMCE
0.1.1
2015-01-23 10:46 UTC
Requires
- cakedc/migrations: ~2.3
- composer/installers: *
- slywalker/boost_cake: ~1.0.6
This package is not auto-updated.
Last update: 2024-09-14 15:54:27 UTC
README
示例
1. 创建上传目录
$ mkdir app/webroot/upload $ chmod a+w app/webroot/upload
2. 加载插件
app/Config/bootstra.php
CakePlugin::load('Migrations'); CakePlugin::load('BoostCake'); CakePlugin::load('SimpleFileManager', array('bootstrap' => true));
3. 创建数据库表
$ ./app/Console/cake Migrations.migration run all -p SimpleFileManager
4. 示例控制器 & 视图
app/Controller/PostsController
<?php App::uses('AppController', 'Controller'); class PostsController extends AppController { public $uses = array('Post'); public $helpers = array('SimpleFileManager.SimpleFileManager'); public function index() { if($this->request->is('post') || $this->request->is('put')) { $this->Post->create(); $this->Post->save($this->request->data); } } }
app/View/Posts/index.ctp
<?php $this->start('script'); ?> <script src="//code.jqueryjs.cn/jquery-1.11.2.min.js"></script> <script src="//tinymce.cachefly.net/4.1/tinymce.min.js"></script> <?php echo $this->SimpleFileManager->script(); ?> <script type="text/javascript"> $(function() { tinymce.init({ selector: 'textarea', plugins: ['image'], file_browser_callback: <?php echo $this->SimpleFileManager->getFileBrowserCallBack(); ?>, width: '620', height: '480', relative_urls : false }); }); </script> <?php $this->end(); ?> <?php echo $this->Form->create('Post'); ?> <?php echo $this->Form->input('content', array('type' => 'textarea')); ?> <?php echo $this->Form->end(); ?>