-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRedactorCssPlugin.php
executable file
·86 lines (75 loc) · 1.96 KB
/
RedactorCssPlugin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
namespace Craft;
/**
* Redactor CSS plugin
*/
class RedactorCssPlugin extends BasePlugin
{
public function getName()
{
return 'Redactor CSS';
}
public function getVersion()
{
return '0.1';
}
public function getDeveloper()
{
return 'Natetronn';
}
public function getDeveloperUrl()
{
return 'https://github.com/Natetronn';
}
public function init()
{
if (craft()->request->isCpRequest())
{
craft()->templates->includeCssResource('redactorcss/redactorcss.css');
craft()->templates->includeJsResource('redactorcss/jquery-ui-1.10.4.custom.min.js');
craft()->templates->includeJsResource('redactorcss/jquery.ui.touch-punch.min.js');
craft()->templates->includeJsResource('redactorcss/redactorcss.js');
$modalHtml = craft()->templates->render('redactorcss/modal', array(
'classes' => $this->getSettings()->classes
));
craft()->templates->includeFootNode($modalHtml);
}
}
protected function defineSettings()
{
return array(
'classes' => array(AttributeType::Mixed, 'default' => array())
);
}
public function getSettingsHtml()
{
return craft()->templates->renderMacro('_includes/forms', 'editableTableField', array(
array(
'label' => Craft::t('Classes'),
'instructions' => Craft::t('Define the CSS Classes you want to be available in your Rich Text fields.'),
'id' => 'classes',
'name' => 'classes',
'cols' => array(
'label' => array('heading' => Craft::t('Label'), 'type' => 'singleline', 'width' => '50%'),
'class' => array('heading' => Craft::t('Class'), 'type' => 'singleline', 'width' => '50%')
),
'rows' => $this->getSettings()->classes
)
));
}
/**
* Preps the settings before they're saved to the database.
*
* @param array $settings
* @return array
*/
public function prepSettings($settings)
{
if (!empty($settings['classes']))
{
// Drop the string row keys
$settings['classes'] = array_values($settings['classes']);
}
return $settings;
}
}