PluginProbe
WP Ultimate Post Grid / 2.8.0
WP Ultimate Post Grid v2.8.0
4.1.1 trunk 1.5 1.6 1.7 1.7.1 1.7.2 1.8 1.9 2.0 2.1 2.2 2.3 2.4.0 2.5.0 2.6.0 2.7.0 2.8.0 2.8.2 3.0.0 3.3.0 3.4.0 3.5.0 3.6.0 3.7.0 All 32 releases
wp-ultimate-post-grid / vendor / vafpress / classes / control / field / codeeditor.php

codeeditor.php in WP Ultimate Post Grid 2.8.0, at vendor/vafpress/classes/control/field/codeeditor.php

111 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class VP_Control_Field_CodeEditor extends VP_Control_Field
4 {
5
6 /**
7 * Editor's language mode
8 * (javascript, css, html, php, json, xml, markdown)
9 * @var String
10 */
11 protected $_mode;
12
13 /**
14 * Editor's theme
15 * (chaos, chrome, clouds, clouds_midnight, cobalt, crimson_editor, dawn, dreamweaver, eclipse,
16 * github, mono_industrial, monokai, solarized_dark, solarized_light, textmate, twilight)
17 * @var String
18 */
19 protected $_theme;
20
21 public function __construct()
22 {
23 parent::__construct();
24 }
25
26 public static function withArray($arr = array(), $class_name = null)
27 {
28 if(is_null($class_name))
29 $instance = new self();
30 else
31 $instance = new $class_name;
32 $instance->_basic_make($arr);
33
34 $instance->set_editor_mode( isset($arr['mode']) ? $arr['mode'] : '');
35 $instance->set_editor_theme(isset($arr['theme']) ? $arr['theme'] : 'textmate');
36
37 return $instance;
38 }
39
40 protected function _setup_data()
41 {
42 $opt = array(
43 'mode' => $this->get_editor_mode(),
44 'theme' => $this->get_editor_theme(),
45 );
46 $this->add_data('opt', VP_Util_Text::make_opt($opt));
47 parent::_setup_data();
48 }
49
50 public function render($is_compact = false)
51 {
52 $this->_setup_data();
53 $this->add_data('is_compact', $is_compact);
54 return VP_View::instance()->load('control/codeeditor', $this->get_data());
55 }
56
57 public function set_value($_value)
58 {
59 // normalize linebreak to \n for all saved data
60 if( is_string($_value) )
61 {
62 $_value = str_replace(array("\r\n", "\r"), "\n", $_value);
63 }
64 $this->_value = $_value;
65 return $this;
66 }
67
68 /**
69 * Get editor's language mode
70 *
71 * @return String Language mode
72 */
73 public function get_editor_mode() {
74 return $this->_mode;
75 }
76
77 /**
78 * Set editor's language mode
79 *
80 * @param String $_mode Language mode
81 */
82 public function set_editor_mode($_mode) {
83 $this->_mode = $_mode;
84 return $this;
85 }
86
87
88 /**
89 * Get editor's theme
90 *
91 * @return String Editor's theme
92 */
93 public function get_editor_theme() {
94 return $this->_theme;
95 }
96
97 /**
98 * Set editor's theme
99 *
100 * @param String $_theme Editor's theme
101 */
102 public function set_editor_theme($_theme) {
103 $this->_theme = $_theme;
104 return $this;
105 }
106
107 }
108
109 /**
110 * EOF
111 */