Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
Redactor.php
1 <?php
2  /*********************************************************************************
3  * Zurmo is a customer relationship management program developed by
4  * Zurmo, Inc. Copyright (C) 2017 Zurmo Inc.
5  *
6  * Zurmo is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License version 3 as published by the
8  * Free Software Foundation with the addition of the following permission added
9  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10  * IN WHICH THE COPYRIGHT IS OWNED BY ZURMO, ZURMO DISCLAIMS THE WARRANTY
11  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12  *
13  * Zurmo is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Affero General Public License along with
19  * this program; if not, see http://www.gnu.org/licenses or write to the Free
20  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  * 02110-1301 USA.
22  *
23  * You can contact Zurmo, Inc. with a mailing address at 27 North Wacker Drive
24  * Suite 370 Chicago, IL 60606. or at email address contact@zurmo.com.
25  *
26  * The interactive user interfaces in original and modified versions
27  * of this program must display Appropriate Legal Notices, as required under
28  * Section 5 of the GNU Affero General Public License version 3.
29  *
30  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31  * these Appropriate Legal Notices must retain the display of the Zurmo
32  * logo and Zurmo copyright notice. If the display of the logo is not reasonably
33  * feasible for technical reasons, the Appropriate Legal Notices must display the words
34  * "Copyright Zurmo Inc. 2017. All rights reserved".
35  ********************************************************************************/
36 
37  class Redactor extends ZurmoWidget
38  {
39  const LINK_FOR_INSERT_CLASS = 'image-gallery-modal-insert';
40 
41  public $scriptFile = array('redactor.min.js');
42 
43  public $cssFile = array('redactor.css');
44 
45  public $assetFolderName = 'redactor';
46 
47  public $htmlOptions;
48 
49  public $content;
50 
51  // this is css property of redactor, not the widget
52  public $css;
53 
54  public $buttons = "['html', '|', 'formatting', 'bold', 'italic', 'deleted', '|',
55  'unorderedlist', 'orderedlist', 'outdent', 'indent', '|', 'table', 'link', '|',
56  'alignleft', 'aligncenter', 'alignright', '|', 'horizontalrule']";
57 
58  public $pastePlainText = "true";
59 
60  public $visual = "true";
61 
62  public $paragraphy = "true";
63 
64  public $cleanup = "true";
65 
66  public $iframe = "true";
67 
68  public $minHeight = 100;
69 
70  public $convertDivs = "false";
71 
72  public $observeImages = "false";
73 
74  public $wym = "false";
75 
76  public $removeEmptyTags = "false";
77 
78  public $tidyHtml = "true";
79 
80  public $xhtml = "true";
81 
82  public $fullpage;
83 
84  public $toolbarExternal;
85 
86  public $plugins;
87 
88  public $deniedTags;
89 
90  public $allowedTags;
91 
92  public $imageUpload;
93 
94  public $imageGetJson;
95 
96  public $initCallback;
97 
98  public $changeCallback;
99 
100  public $focusCallback;
101 
102  public $syncAfterCallback;
103 
104  public $syncBeforeCallback;
105 
106  public $textareaKeydownCallback;
107 
108  public $imageUploadErrorCallback;
109 
110  public $urlForImageGallery;
111 
112  public function run()
113  {
114  $id = $this->htmlOptions['id'];
115  $name = $this->htmlOptions['name'];
116  $linkForInsertClass = static::LINK_FOR_INSERT_CLASS;
117  $urlForImageGallery = Yii::app()->createUrl('zurmo/imageModel/modalList/');
118  unset($this->htmlOptions['name']);
119  $javaScript = "
120  $(document).ready(
121  function()
122  {
123  $('#{$id}').redactor(
124  {
125  {$this->renderRedactorParamForInit('initCallback')}
126  {$this->renderRedactorParamForInit('changeCallback')}
127  {$this->renderRedactorParamForInit('focusCallback')}
128  {$this->renderRedactorParamForInit('syncAfterCallback')}
129  {$this->renderRedactorParamForInit('syncBeforeCallback')}
130  {$this->renderRedactorParamForInit('textareaKeydownCallback')}
131  {$this->renderRedactorParamForInit('imageUploadErrorCallback')}
132  {$this->renderRedactorParamForInit('plugins')}
133  {$this->renderRedactorParamForInit('toolbarExternal')}
134  {$this->renderRedactorParamForInit('fullpage')}
135  {$this->renderRedactorParamForInit('allowedTags')}
136  {$this->renderRedactorParamForInit('deniedTags')}
137  {$this->renderRedactorParamForInit('iframe')}
138  {$this->renderRedactorParamForInit('css')}
139  {$this->renderRedactorParamForInit('urlForImageGallery')}
140  buttons: {$this->buttons},
141  cleanup: {$this->cleanup},
142  convertDivs: {$this->convertDivs},
143  imageGetJson: '{$this->imageGetJson}',
144  imageUpload: '{$this->imageUpload}',
145  minHeight: {$this->minHeight},
146  observeImages: {$this->observeImages},
147  paragraphy: {$this->paragraphy},
148  pastePlainText: {$this->pastePlainText},
149  removeEmptyTags: {$this->removeEmptyTags},
150  visual: {$this->visual},
151  tidyHtml: {$this->tidyHtml},
152  wym: {$this->wym},
153  xhtml: {$this->xhtml},
154  linkForInsertClass: '{$linkForInsertClass}',
155  urlForImageGallery: '{$urlForImageGallery}',
156  });
157  }
158  );";
159  Yii::app()->getClientScript()->registerScript(__CLASS__ . '#' . $this->getId(), $javaScript);
160  $content = ZurmoHtml::textArea($name, $this->content, $this->htmlOptions);
161  echo $content;
162  }
163 
164  protected function renderRedactorParamForInit($paramName)
165  {
166  $paramValue = $this->$paramName;
167  if (isset($paramValue))
168  {
169  $config = "{$paramName}: {$paramValue},"; // Not Coding Standard
170  return $config;
171  }
172  }
173 
174  public function init()
175  {
176  $this->resolveSelectivePluginScriptLoad();
177  parent::init();
178  // TODO: @Shoaibi: Critical: Find a better way to deal with this.
179  //$this->resolveSelectiveCssLoad();
180  }
181 
182  protected function resolveSelectiveCssLoad()
183  {
184  $this->resolveSelectiveCssLoadForIframeSetting();
185  }
186 
187  protected function resolveSelectiveCssLoadForIframeSetting()
188  {
189  if ($this->iframe == 'true')
190  {
191  $this->css = "'" . $this->scriptUrl . "/css/redactor-iframe.css'";
192  }
193  }
194 
195  protected function resolveSelectivePluginScriptLoad()
196  {
197  $plugins = CJSON::decode($this->plugins);
198  if (!empty($plugins))
199  {
200  $this->registerPluginScriptFiles($plugins);
201  }
202  }
203 
204  protected function registerPluginScriptFiles(array $plugins)
205  {
206  $this->resolvePluginScriptNames($plugins);
207  $this->scriptFile = CMap::mergeArray($plugins, $this->scriptFile);
208  }
209 
210  protected function resolvePluginScriptNames(array & $pluginNames)
211  {
212  array_walk($pluginNames, function(&$pluginName)
213  {
214  $pluginName .= '.js';
215  });
216  }
217  }
218 ?>
Generated on Fri Jul 10 2020 07:10:29
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.