forked from aelvan/RedactorStyles-Craft
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRedactorStylesPlugin.php
More file actions
executable file
·80 lines (66 loc) · 1.96 KB
/
Copy pathRedactorStylesPlugin.php
File metadata and controls
executable file
·80 lines (66 loc) · 1.96 KB
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
<?php
namespace Craft;
/**
* Redactor Styles plugin
*
*
* @author André Elvan
*/
class RedactorStylesPlugin extends BasePlugin
{
public function getName()
{
return 'Redactor Styles';
}
public function getVersion()
{
return '0.3';
}
public function getDeveloper()
{
return 'André Elvan';
}
public function getDeveloperUrl()
{
return 'http://vaersaagod.no';
}
public function init()
{
if (craft()->request->isCpRequest()) {
$settings = $this->getSettings();
$stylesJson = $settings['redactorStylesJson'];
if ($stylesJson != '') {
craft()->templates->includeJs('var RedactorStyles = {}; RedactorStyles.stylesJson = ' . $stylesJson . ';');
}
$stylesCss = $settings['redactorStylesCss'];
if ($stylesCss != '') {
craft()->templates->includeCss($stylesCss);
}
if (trim($settings->redactorStylesCssFile)) {
$filepath = craft()->config->parseEnvironmentString($settings->redactorStylesCssFile);
craft()->templates->includeCssFile($filepath);
}
craft()->templates->includeCssResource('redactorstyles/fontawesome/css/font-awesome.min.css');
craft()->templates->includeCssResource('redactorstyles/styles.css');
craft()->templates->includeJsResource('redactorstyles/styles.js');
}
}
protected function defineSettings()
{
return array(
'redactorStylesJson' => array(AttributeType::String, 'default' => ''),
'redactorStylesCss' => array(AttributeType::String, 'default' => ''),
'redactorStylesCssFile' => array(AttributeType::String, 'default' => ''),
);
}
public function getSettingsHtml()
{
$config_settings = array();
$config_settings['redactorStylesJson'] = craft()->config->get('redactorStylesJson');
$config_settings['redactorStylesCss'] = craft()->config->get('redactorStylesCss');
$config_settings['redactorStylesCssFile'] = craft()->config->get('redactorStylesCssFile');
return craft()->templates->render('redactorstyles/settings', array(
'settings' => $this->getSettings()
));
}
}