Skip to content

Commit 004a669

Browse files
committed
Initial commit
0 parents  commit 004a669

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+14008
-0
lines changed

.gitattributes

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Autodetect text files
2+
* text=auto
3+
4+
# ...Unless the name matches the following overriding patterns
5+
6+
# Definitively text files
7+
# Enforce Unix newlines
8+
*.php text eol=lf
9+
*.css text eol=lf
10+
*.html text eol=lf
11+
*.js text eol=lf
12+
*.txt text eol=lf
13+
*.md text eol=lf
14+
*.xml text eol=lf
15+
*.json text eol=lf
16+
*.bat text eol=lf
17+
*.sql text eol=lf
18+
*.xml text eol=lf
19+
*.yml text eol=lf
20+
*.less text eol=lf
21+
*.svg text eol=lf
22+
23+
# Ensure those won't be messed up with
24+
*.png binary
25+
*.jpg binary
26+
*.gif binary
27+
*.ttf binary

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.idea
2+
Thumbs.db
3+
.DS_Store
4+
composer.phar
5+
composer.lock
6+
phpunit.xml

LICENSE.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
Extension itself
2+
================
3+
4+
The Imperavi Redactor WYSIWYG widget is free software. Every part of this
5+
project except `assets` directory is released under the terms of the following
6+
BSD License.
7+
8+
Copyright © 2014, Serge Postrash
9+
Copyright © 2010-2014 by YiiExt contributors
10+
All rights reserved.
11+
12+
Redistribution and use in source and binary forms, with or without modification,
13+
are permitted provided that the following conditions are met:
14+
15+
- Redistributions of source code must retain the above copyright notice, this list
16+
of conditions and the following disclaimer.
17+
- Redistributions in binary form must reproduce the above copyright notice, this
18+
list of conditions and the following disclaimer in the documentation and/or
19+
other materials provided with the distribution.
20+
- Neither the name of YiiExt nor the names of its contributors may be
21+
used to endorse or promote products derived from this software without specific
22+
prior written permission.
23+
24+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
25+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27+
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
28+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
32+
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
33+
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34+
35+
Imperavi Redactor
36+
=================
37+
38+
Redactor that is located at `assets` directory is not an open-source product but
39+
a proprietary commercial copyrighted software. Yii community bought OEM license
40+
for it so you are free to use it if you are using Yii.

README.md

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
Imperavi Redactor Widget for Yii2
2+
=================================
3+
4+
This is a A Yii2 port of original [Imperavi Redactor Widget](https://github.com/yiiext/imperavi-redactor-widget) for Yii (yiiext/imperavi-redactor-widget).
5+
6+
`ImperaviRedactorWidget` is a wrapper for [Imperavi Redactor](http://imperavi.com/redactor/),
7+
a high quality WYSIWYG editor.
8+
9+
Note that Imperavi Redactor itself is a proprietary commercial copyrighted software
10+
but since Yii community bought OEM license you can use it for free with Yii.
11+
12+
13+
Installation
14+
------------
15+
16+
TBD
17+
18+
19+
Usage
20+
-----
21+
22+
TBD
23+
24+
For more options see [Imperavi Redactor documentation](http://imperavi.com/redactor/docs/)
25+
26+
```
27+
echo $form->field($model, 'content')->widget(
28+
Redactor::className(), [
29+
'options' => [
30+
'style' => 'height: 300px;'
31+
],
32+
'clientOptions' => [
33+
'lang' => 'ru',
34+
'observeLinks' => true,
35+
'convertVideoLinks' => true,
36+
'autoresize' => true,
37+
'placeholder' => Yii::t('app', 'Redactor placeholder text'),
38+
'plugins' => ['fontcolor', 'fontfamily', 'fontsize'],
39+
'buttons' => ['html', 'formatting', 'bold', 'italic', 'deleted', 'underline', 'horizontalrule',
40+
'alignment', 'unorderedlist', 'orderedlist', 'outdent', 'indent',
41+
'table', 'link', 'image', 'video', 'file'],
42+
'imageUpload' => Yii::$app->urlManager->createUrl(['news/upload']),
43+
],
44+
]
45+
);
46+
```

Redactor.php

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?php
2+
/**
3+
* @link https://github.com/SDKiller/yii2-imperavi-redactor
4+
* @package zyx\yii2-imperavi-redactor
5+
* @copyright Copyright (c) 2014 Serge Postrash, Copyright (c) 2010-2014 by YiiExt contributors
6+
* @license BSD 3-Clause, see LICENSE.md
7+
*/
8+
9+
namespace zyx\widgets;
10+
11+
use Yii;
12+
use yii\helpers\Html;
13+
use yii\helpers\Json;
14+
use yii\web\JsExpression;
15+
use yii\widgets\InputWidget;
16+
17+
18+
class Redactor extends InputWidget
19+
{
20+
21+
/**
22+
* @var array Redactor settings
23+
* @see http://imperavi.com/redactor/docs/settings/
24+
*/
25+
public $clientOptions = [];
26+
27+
28+
/**
29+
* @inheritdoc
30+
*/
31+
public function init()
32+
{
33+
parent::init();
34+
35+
$this->registerAssets();
36+
}
37+
38+
/**
39+
* Register asset bundle and attach redactor to html tag
40+
*/
41+
public function registerAssets()
42+
{
43+
$view = $this->getView();
44+
45+
$bundle = RedactorAsset::register($view);
46+
47+
$lang = empty($this->clientOptions['lang']) ? Yii::$app->language : $this->clientOptions['lang'];
48+
$lang = substr($lang, 0, 2);
49+
if ($lang !== 'en' && is_file(Yii::getAlias($bundle->basePath, false) . '/lang/' . $lang . '.js')) {
50+
$view->registerJsFile($bundle->baseUrl . '/lang/' . $lang . '.js', [$bundle->className()]);
51+
}
52+
53+
54+
$plugins = ['fontcolor', 'fontfamily', 'fontsize', 'clips', 'fullscreen'];
55+
56+
if (isset($this->clientOptions['plugins']) && is_array($this->clientOptions['plugins'])) {
57+
foreach ($this->clientOptions['plugins'] as $plugin) {
58+
if (in_array($plugin, $plugins, true)) {
59+
$view->registerJsFile($bundle->baseUrl . '/plugins/' . $plugin . '/' . $plugin . '.js', [$bundle->className()]);
60+
if ($plugin == 'clips') {
61+
$view->registerCssFile($bundle->baseUrl . '/plugins/' . $plugin . '/' . $plugin . '.css', [$bundle->className()]);
62+
}
63+
}
64+
}
65+
}
66+
67+
$id = $this->options['id'];
68+
$clientOptions = Json::encode($this->clientOptions);
69+
$js = 'jQuery(\'#' . $id . '\').redactor(' . $clientOptions . ');';
70+
$view->registerJs($js);
71+
}
72+
73+
/**
74+
* @inheritdoc
75+
*/
76+
public function run()
77+
{
78+
if ($this->hasModel()) {
79+
echo Html::activeTextarea($this->model, $this->attribute, $this->options);
80+
} else {
81+
echo Html::textarea($this->name, $this->value, $this->options);
82+
}
83+
}
84+
}

RedactorAsset.php

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
/**
3+
* @link https://github.com/SDKiller/yii2-imperavi-redactor
4+
* @package zyx\yii2-imperavi-redactor
5+
* @copyright Copyright (c) 2014 Serge Postrash, Copyright (c) 2010-2014 by YiiExt contributors
6+
* @license BSD 3-Clause, see LICENSE.md
7+
*/
8+
9+
namespace zyx\widgets;
10+
11+
use Yii;
12+
use yii\web\AssetBundle;
13+
14+
15+
class RedactorAsset extends AssetBundle
16+
{
17+
/**
18+
* @inheritdoc
19+
*/
20+
public $sourcePath = '@vendor/zyx/yii2-imperavi-redactor/assets';
21+
22+
/**
23+
* @inheritdoc
24+
*/
25+
public $depends = [
26+
'yii\web\JqueryAsset',
27+
];
28+
29+
/**
30+
* @inheritdoc
31+
*/
32+
public $js = [
33+
'redactor.min.js',
34+
];
35+
36+
/**
37+
* @inheritdoc
38+
*/
39+
public $css = [
40+
'redactor.css',
41+
];
42+
43+
/**
44+
* @inheritdoc
45+
*/
46+
public $jsOptions = [];
47+
48+
/**
49+
* @inheritdoc
50+
*/
51+
public $cssOptions = [];
52+
53+
54+
/**
55+
* @inheritdoc
56+
*/
57+
public function init($options = [])
58+
{
59+
parent::init();
60+
61+
if (YII_DEBUG) {
62+
$this->js[0] = 'redactor.js';
63+
}
64+
}
65+
66+
}

assets/lang/ar.js

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
(function ($) {
2+
$.Redactor.opts.langs['ar'] = {
3+
html: 'كود HTML',
4+
video: 'فيديو',
5+
image: 'صورة',
6+
table: 'جدول',
7+
link: 'رابط',
8+
link_insert: 'أضف / حرر رابط',
9+
link_edit: 'Edit link',
10+
unlink: 'إزالة الرابط',
11+
formatting: 'التنسيق',
12+
paragraph: 'فقرة',
13+
quote: 'اقتباس',
14+
code: 'كود',
15+
header1: 'ترويسة 1',
16+
header2: 'ترويسة 2',
17+
header3: 'ترويسة 3',
18+
header4: 'ترويسة 4',
19+
header5: '5 ترويسة',
20+
bold: 'غليظ',
21+
italic: 'مائل',
22+
fontcolor: 'لون الخط',
23+
backcolor: 'لون الخلفية',
24+
unorderedlist: 'قائمة منقطة',
25+
orderedlist: 'قائمة رقمية',
26+
outdent: 'أزل المسافة البادئة',
27+
indent: 'أضف المسافة البادئة',
28+
cancel: 'تراجع',
29+
insert: 'أدخل',
30+
save: 'احفظ',
31+
_delete: 'أحذف',
32+
insert_table: 'أدخل جدول',
33+
insert_row_above: 'أضف صف فوق',
34+
insert_row_below: 'أضف صف تحت',
35+
insert_column_left: 'أضف عمود يسارا',
36+
insert_column_right: 'أضف عمود يمينا',
37+
delete_column: 'احذف العمود',
38+
delete_row: 'احذف الصف',
39+
delete_table: 'احذف الجدول',
40+
rows: 'الصفوف',
41+
columns: 'الأعمدة',
42+
add_head: 'أضف ترويسة',
43+
delete_head: 'حذف ترويسة',
44+
title: 'ترويسة',
45+
image_position: 'الوضعية',
46+
none: 'بدون',
47+
left: 'يسار',
48+
right: 'يمين',
49+
image_web_link: 'رابط الصورة',
50+
text: 'نص',
51+
mailto: 'بريد الكتروني',
52+
web: 'رابط',
53+
video_html_code: 'كود الفيديو',
54+
file: 'أضف ملف جديد',
55+
upload: 'رفع',
56+
download: 'تحميل',
57+
choose: 'اختار',
58+
or_choose: 'أو اختار',
59+
drop_file_here: 'اسحب الملف هنا',
60+
align_left: 'محاذاة الى اليسار',
61+
align_center: 'محاذاة الى الوسط',
62+
align_right: 'محاذاة الى اليمين',
63+
align_justify: 'محاذاة كاملة',
64+
horizontalrule: 'أضف خط عمودي',
65+
fullscreen: 'الشاشة الكاملة',
66+
deleted: 'خط في الوسط',
67+
anchor: 'مرساة',
68+
link_new_tab: 'Open link in new tab',
69+
underline: 'Underline',
70+
alignment: 'Alignment',
71+
filename: 'Name (optional)',
72+
edit: 'Edit',
73+
center: 'Center'
74+
};
75+
})( jQuery );

0 commit comments

Comments
 (0)