Commit 140451ed authored by john's avatar john

3009

parent 1c19a163
......@@ -35,7 +35,7 @@ $(function ()
imageUpload: true,
imageFormats: ["jpg", "jpeg", "gif", "png", "bmp", "webp"],
imageUploadURL: "./php/upload.php",
imageUploadURL: "/documentation/documentation-admin/upload",
onload: function ()
{
console.log('onload', this);
......
......@@ -41,11 +41,11 @@
if ($imageUploader->upload($name))
{
$imageUploader->message('上传成功!', 1);
$imageUploader->message('Загружен успешно!', 1);
}
else
{
$imageUploader->message('上传失败!', 0);
$imageUploader->message('Загрузка не удалась!', 0);
}
}
?>
\ No newline at end of file
......@@ -24,6 +24,7 @@ class DocumentationAdminController extends AdminController
'Update' => 'Редактирование контента',
'Delete' => 'Удаление контента',
'View' => 'Просмотр контента',
'Upload' => 'Загрузка картинок',
];
}
......@@ -235,4 +236,35 @@ class DocumentationAdminController extends AdminController
}
}
public function actionUpload()
{
require(\yii\helpers\FileHelper::normalizePath(\Yii::getAlias('@webroot') . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . 'editormd' . DIRECTORY_SEPARATOR . 'examples' . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'editormd.uploader.class.php'));
$savePath = \yii\helpers\FileHelper::normalizePath(\Yii::getAlias('@frontend') . DIRECTORY_SEPARATOR . 'web' . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . 'documentation' . DIRECTORY_SEPARATOR);
$saveURL = Yii::$app->params['frontUrl'] . '/uploads/documentation/';
$formats = array(
'image' => array('gif', 'jpg', 'jpeg', 'png', 'bmp')
);
$name = 'editormd-image-file';
if (isset($_FILES[$name])) {
$imageUploader = new \EditorMdUploader($savePath, $saveURL, $formats['image'], false); // Ymdhis表示按日期生成文件名,利用date()函数
$imageUploader->config(array(
'maxSize' => 1024, // 允许上传的最大文件大小,以KB为单位,默认值为1024
'randomNameType' => 2,
'randomLength' => 20,
'cover' => true // 是否覆盖同名文件,默认为true
));
if ($imageUploader->upload($name)) {
$imageUploader->message('Загружен успешно!', 1);
} else {
$imageUploader->message('Загрузка не удалась!', 0);
}
}
}
}
......@@ -139,7 +139,7 @@ class DocList extends \yii\db\ActiveRecord
$list = [];
$thisLevel = DocList::find()->where(['=', 'parent_id', $parent_id])->orderBy(['position' => SORT_ASC])->all();
foreach ($thisLevel as $level) {
if ($updated->id == $level->id && !$ignore)
if ($updated && $updated->id == $level->id && !$ignore)
continue;
$l = '';
......
......@@ -43,7 +43,7 @@ use common\modules\documentation\models\DocList;
],
[
'class' => 'common\components\ColorActionColumn',
'template' => '{view} {update} {delete}',
'template' => '{update} {delete}',
// 'buttons' => [
// 'copy' => function ($url, $model, $key) {
// return '<a href="' . Url::toRoute(['copy', 'id' => $model->id]) . '">' . Html::beginTag('i', [
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment