1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13:
14:
15: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
16:
17: 18: 19: 20: 21: 22:
23: class cContentTypeText extends cContentTypeAbstract {
24:
25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36:
37: public function __construct($rawSettings, $id, array $contentTypes) {
38:
39: $rawSettings = conHtmlSpecialChars($rawSettings);
40:
41:
42: parent::__construct($rawSettings, $id, $contentTypes);
43:
44:
45: $this->_type = 'CMS_TEXT';
46: $this->_prefix = 'text';
47:
48:
49:
50:
51: if (isset($_POST[$this->_prefix . '_action']) && $_POST[$this->_prefix . '_action'] === 'store' && isset($_POST[$this->_prefix . '_id']) && (int) $_POST[$this->_prefix . '_id'] == $this->_id) {
52: $this->_settings = $_POST[$this->_prefix . '_text_' . $this->_id];
53: $this->_rawSettings = $this->_settings;
54: $this->_storeSettings();
55:
56:
57: $this->_settings = stripslashes($this->_settings);
58: $this->_settings = conHtmlSpecialChars($this->_settings);
59: $this->_rawSettings = stripslashes($this->_rawSettings);
60: $this->_rawSettings = conHtmlSpecialChars($this->_rawSettings);
61:
62:
63: $this->_rawSettings = nl2br($this->_rawSettings);
64: }
65: }
66:
67: 68: 69: 70: 71: 72:
73: public function generateEditCode() {
74: $script = $this->_getEditJavaScript();
75:
76: $div = new cHTMLDiv($this->_rawSettings);
77: $div->setID($this->_prefix . '_text_' . $this->_id);
78: $div->appendStyleDefinition('display', 'inline');
79:
80: $editButton = new cHTMLImage($this->_cfg['path']['contenido_fullhtml'] . $this->_cfg['path']['images'] . 'but_edithead.gif');
81: $editButton->setID($this->_prefix . '_editbutton_' . $this->_id);
82: $editButton->appendStyleDefinitions(array(
83: 'margin-left' => '5px',
84: 'cursor' => 'pointer'
85: ));
86:
87: return $this->_encodeForOutput($script . $div->render() . $editButton->render());
88: }
89:
90: 91: 92: 93: 94: 95:
96: protected function _getEditJavaScript() {
97: $textbox = new cHTMLTextarea($this->_prefix . '_text_' . $this->_id, '', '', '', $this->_prefix . '_text_' . $this->_id, false, NULL, '', 'edit-textfield edit-' . $this->_prefix . '-textfield');
98: $textbox->setClass("$this->_id");
99:
100: $saveButton = new cHTMLImage($this->_cfg['path']['contenido_fullhtml'] . 'images/but_ok.gif');
101: $saveButton->setID($this->_prefix . '_savebutton_' . $this->_id);
102: $saveButton->appendStyleDefinitions(array(
103: 'margin-left' => '5px',
104: 'cursor' => 'pointer'
105: ));
106:
107: $template = new cTemplate();
108: $template->set('s', 'PREFIX', $this->_prefix);
109: $template->set('s', 'ID', $this->_id);
110: $template->set('s', 'TEXTBOX', $textbox->render());
111: $template->set('s', 'SAVEBUTTON', $saveButton->render());
112: $template->set('s', 'IDARTLANG', $this->_idArtLang);
113:
114: return $template->generate($this->_cfg['path']['contenido'] . 'templates/standard/template.cms_text_js.html', true);
115: }
116:
117: 118: 119: 120: 121: 122: 123:
124: public function generateViewCode() {
125: return $this->_encodeForOutput($this->_rawSettings);
126: }
127:
128: }
129: