您的位置:首页 > 其它

How to specify image folder path for each user when use TinyMce ImageManager with Symfony

2012-02-22 00:42 696 查看
First, in sfWidgetFormTextareaTinyMce class we set:

protected function configure($options = array(), $attributes = array())
{
......
$this->addOption('imagemanager_rootpath', 'mydir');
......
}

public function render($name, $value = null, $attributes = array(), $errors = array())
{
$textarea = sfWidgetFormTextarea::render($name, $value, $attributes, $errors);

$js = sprintf(<<<EOF
<script type="text/javascript">
tinyMCE.init({
mode: "exact",
elements : '%1\$s',
imagemanager_rootpath: '{0}/%2\$s',
.....
}


Second, i set a 'imagemanager_rootpath' value in action, to throw the value to form:

public function executeCreate(sfWebRequest $request)
{
...
$this->form = new TextForm(null, array('imagemanager_rootpath' => $user_id));
...
}


Last, in the TextForm class, we configure the path:

public function configure()
{
....

$path = $this->options['imagemanager_rootpath'];

$user_dir = $_SERVER['DOCUMENT_ROOT'].'/uploads/submission/text/'.$path;
if (!is_dir($user_dir)) mkdir($user_dir, 0777);

$this->widgetSchema['content'] = new sfWidgetFormTextareaTinyMCE(array('width' => 480, 'height' => 250, 'imagemanager_rootpath' => $path));
....
}


more detail: http://www.tinymce.com/wiki.php/MCImageManager:rootpath
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐