Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 970 lines (825 sloc) 31.663 kB
4a5d9b0 @Hayden Moved Sapphire module to open source path
Hayden authored
1 <?php
d27937f @sminnee Updated API documentation package tags
sminnee authored
2 /**
1859ba5 @ajshort FEATURE: Updated HtmlEditorField to use DOMDocument to more reliably …
ajshort authored
3 * A TinyMCE-powered WYSIWYG HTML editor field with image and link insertion and tracking capabilities. Editor fields
4 * are created from <textarea> tags, which are then converted with JavaScript.
5 *
b1d2e39 @sminnee API Documentation updates
sminnee authored
6 * @package forms
7 * @subpackage fields-formattedinput
4a5d9b0 @Hayden Moved Sapphire module to open source path
Hayden authored
8 */
9 class HtmlEditorField extends TextareaField {
5ec6aa5 @chillu ENHANCEMENT GZipped/combined file loading for TinyMCE, which reduces …
chillu authored
10
11 /**
12 * @var Boolean Use TinyMCE's GZIP compressor
13 */
14 static $use_gzip = true;
243d4d4 @chillu MINOR Restored row/col defaults in TextareaField and HtmlEditorField …
chillu authored
15
4fc3aaf @chillu Revert "ENHANCEMENT Using 'autoresize' TinyMCE plugin in HTMLEditorFi…
chillu authored
16 protected $rows = 30;
0a89009 @halkyon MINOR Removed $rows variable from HtmlEditorField - this gets inherit…
halkyon authored
17
4a5d9b0 @Hayden Moved Sapphire module to open source path
Hayden authored
18 /**
1859ba5 @ajshort FEATURE: Updated HtmlEditorField to use DOMDocument to more reliably …
ajshort authored
19 * Includes the JavaScript neccesary for this field to work using the {@link Requirements} system.
2fc1771 @halkyon Merged from branches/2.3
halkyon authored
20 */
1859ba5 @ajshort FEATURE: Updated HtmlEditorField to use DOMDocument to more reliably …
ajshort authored
21 public static function include_js() {
5ec6aa5 @chillu ENHANCEMENT GZipped/combined file loading for TinyMCE, which reduces …
chillu authored
22 require_once 'tinymce/tiny_mce_gzip.php';
23
24 $configObj = HtmlEditorConfig::get_active();
25
26 if(self::$use_gzip) {
27 $internalPlugins = array();
28 foreach($configObj->getPlugins() as $plugin => $path) if(!$path) $internalPlugins[] = $plugin;
29 $tag = TinyMCE_Compressor::renderTag(array(
30 'url' => THIRDPARTY_DIR . '/tinymce/tiny_mce_gzip.php',
31 'plugins' => implode(',', $internalPlugins),
32 'themes' => 'advanced',
33 'languages' => $configObj->getOption('language')
34 ), true);
35 preg_match('/src="([^"]*)"/', $tag, $matches);
36 Requirements::javascript($matches[1]);
37
38 } else {
39 Requirements::javascript(MCE_ROOT . 'tiny_mce_src.js');
40 }
41
42 Requirements::customScript($configObj->generateJS(), 'htmlEditorConfig');
2fc1771 @halkyon Merged from branches/2.3
halkyon authored
43 }
1859ba5 @ajshort FEATURE: Updated HtmlEditorField to use DOMDocument to more reliably …
ajshort authored
44
2fc1771 @halkyon Merged from branches/2.3
halkyon authored
45 /**
1859ba5 @ajshort FEATURE: Updated HtmlEditorField to use DOMDocument to more reliably …
ajshort authored
46 * @see TextareaField::__construct()
4a5d9b0 @Hayden Moved Sapphire module to open source path
Hayden authored
47 */
1a10e8b @chillu API CHANGE Removed $rows and $cols constructor arguments on TextareaF…
chillu authored
48 public function __construct($name, $title = null, $value = '') {
1f7fc1f @sminnee FIX Remove instances of lines longer than 120c
sminnee authored
49 if(count(func_get_args()) > 3) {
50 Deprecation::notice('3.0', 'Use setRows() and setColumns() instead of constructor arguments',
51 Deprecation::SCOPE_GLOBAL);
52 }
1a10e8b @chillu API CHANGE Removed $rows and $cols constructor arguments on TextareaF…
chillu authored
53
54 parent::__construct($name, $title, $value);
1859ba5 @ajshort FEATURE: Updated HtmlEditorField to use DOMDocument to more reliably …
ajshort authored
55
56 self::include_js();
4a5d9b0 @Hayden Moved Sapphire module to open source path
Hayden authored
57 }
58
59 /**
1859ba5 @ajshort FEATURE: Updated HtmlEditorField to use DOMDocument to more reliably …
ajshort authored
60 * @return string
4a5d9b0 @Hayden Moved Sapphire module to open source path
Hayden authored
61 */
e2f073f @chillu Method visibility according to coding conventions
chillu authored
62 public function Field($properties = array()) {
9b4d999 @ajshort FEATURE: Added SS_HTMLValue to provide a simple wrapper around DOMDoc…
ajshort authored
63 // mark up broken links
64 $value = new SS_HTMLValue($this->value);
65
66 if($links = $value->getElementsByTagName('a')) foreach($links as $link) {
67 $matches = array();
68
7c41ff2 @mateusz BUG Change all shortcodes into the new, comma separated, format.
mateusz authored
69 if(preg_match('/\[sitetree_link(?:\s*|%20|,)?id=([0-9]+)\]/i', $link->getAttribute('href'), $matches)) {
9b4d999 @ajshort FEATURE: Added SS_HTMLValue to provide a simple wrapper around DOMDoc…
ajshort authored
70 if(!DataObject::get_by_id('SiteTree', $matches[1])) {
71 $class = $link->getAttribute('class');
72 $link->setAttribute('class', ($class ? "$class ss-broken" : 'ss-broken'));
73 }
74 }
f5c4bc0 @halkyon ENHANCEMENT Ensure that broken File links receive an "ss-broken" clas…
halkyon authored
75
7c41ff2 @mateusz BUG Change all shortcodes into the new, comma separated, format.
mateusz authored
76 if(preg_match('/\[file_link(?:\s*|%20|,)?id=([0-9]+)\]/i', $link->getAttribute('href'), $matches)) {
f5c4bc0 @halkyon ENHANCEMENT Ensure that broken File links receive an "ss-broken" clas…
halkyon authored
77 if(!DataObject::get_by_id('File', $matches[1])) {
78 $class = $link->getAttribute('class');
79 $link->setAttribute('class', ($class ? "$class ss-broken" : 'ss-broken'));
80 }
81 }
9b4d999 @ajshort FEATURE: Added SS_HTMLValue to provide a simple wrapper around DOMDoc…
ajshort authored
82 }
f5c4bc0 @halkyon ENHANCEMENT Ensure that broken File links receive an "ss-broken" clas…
halkyon authored
83
1859ba5 @ajshort FEATURE: Updated HtmlEditorField to use DOMDocument to more reliably …
ajshort authored
84 return $this->createTag (
85 'textarea',
b5421d9 @chillu ENHANCEMENT Allowing custom attributes in (most) FormField implementa…
chillu authored
86 $this->getAttributes(),
9b4d999 @ajshort FEATURE: Added SS_HTMLValue to provide a simple wrapper around DOMDoc…
ajshort authored
87 htmlentities($value->getContent(), ENT_COMPAT, 'UTF-8')
1859ba5 @ajshort FEATURE: Updated HtmlEditorField to use DOMDocument to more reliably …
ajshort authored
88 );
4a5d9b0 @Hayden Moved Sapphire module to open source path
Hayden authored
89 }
b5421d9 @chillu ENHANCEMENT Allowing custom attributes in (most) FormField implementa…
chillu authored
90
e2f073f @chillu Method visibility according to coding conventions
chillu authored
91 public function getAttributes() {
b5421d9 @chillu ENHANCEMENT Allowing custom attributes in (most) FormField implementa…
chillu authored
92 return array_merge(
93 parent::getAttributes(),
94 array(
95 'tinymce' => 'true',
4fc3aaf @chillu Revert "ENHANCEMENT Using 'autoresize' TinyMCE plugin in HTMLEditorFi…
chillu authored
96 'style' => 'width: 97%; height: ' . ($this->rows * 16) . 'px', // prevents horizontal scrollbars
b5421d9 @chillu ENHANCEMENT Allowing custom attributes in (most) FormField implementa…
chillu authored
97 'value' => null,
98 )
99 );
100 }
4a5d9b0 @Hayden Moved Sapphire module to open source path
Hayden authored
101
daab8f4 @ajoneil MINOR: Consistently use DataObjectInterface for saveInto() on FormFie…
ajoneil authored
102 public function saveInto(DataObjectInterface $record) {
a145173 @chillu Merged revisions 48168 via svnmerge from
chillu authored
103 if($record->escapeTypeForField($this->name) != 'xml') {
1859ba5 @ajshort FEATURE: Updated HtmlEditorField to use DOMDocument to more reliably …
ajshort authored
104 throw new Exception (
105 'HtmlEditorField->saveInto(): This field should save into a HTMLText or HTMLVarchar field.'
0b5ab1f @chillu Merged revisions 48164 via svnmerge from
chillu authored
106 );
107 }
108
60f75c5 @ajoneil Merged changes from 2.3 branch
ajoneil authored
109 $linkedPages = array();
1859ba5 @ajshort FEATURE: Updated HtmlEditorField to use DOMDocument to more reliably …
ajshort authored
110 $linkedFiles = array();
4a5d9b0 @Hayden Moved Sapphire module to open source path
Hayden authored
111
9b4d999 @ajshort FEATURE: Added SS_HTMLValue to provide a simple wrapper around DOMDoc…
ajshort authored
112 $htmlValue = new SS_HTMLValue($this->value);
1859ba5 @ajshort FEATURE: Updated HtmlEditorField to use DOMDocument to more reliably …
ajshort authored
113
41e51ab @chillu MINOR Made HtmlEditorField dependency to SiteTree optional (to be mov…
chillu authored
114 if(class_exists('SiteTree')) {
115 // Populate link tracking for internal links & links to asset files.
116 if($links = $htmlValue->getElementsByTagName('a')) foreach($links as $link) {
117 $href = Director::makeRelative($link->getAttribute('href'));
118
119 if($href) {
7c41ff2 @mateusz BUG Change all shortcodes into the new, comma separated, format.
mateusz authored
120 if(preg_match('/\[sitetree_link,id=([0-9]+)\]/i', $href, $matches)) {
41e51ab @chillu MINOR Made HtmlEditorField dependency to SiteTree optional (to be mov…
chillu authored
121 $ID = $matches[1];
122
123 // clear out any broken link classes
124 if($class = $link->getAttribute('class')) {
1f7fc1f @sminnee FIX Remove instances of lines longer than 120c
sminnee authored
125 $link->setAttribute('class',
126 preg_replace('/(^ss-broken|ss-broken$| ss-broken )/', null, $class));
41e51ab @chillu MINOR Made HtmlEditorField dependency to SiteTree optional (to be mov…
chillu authored
127 }
128
129 $linkedPages[] = $ID;
130 if(!DataObject::get_by_id('SiteTree', $ID)) $record->HasBrokenLink = true;
e09cc66 @sminnee BUGFIX: Fixed issues with broekn link tracking (from r101138)
sminnee authored
131
41e51ab @chillu MINOR Made HtmlEditorField dependency to SiteTree optional (to be mov…
chillu authored
132 } else if(substr($href, 0, strlen(ASSETS_DIR) + 1) == ASSETS_DIR.'/') {
133 $candidateFile = File::find(Convert::raw2sql(urldecode($href)));
134 if($candidateFile) {
135 $linkedFiles[] = $candidateFile->ID;
136 } else {
137 $record->HasBrokenFile = true;
138 }
139 } else if($href == '' || $href[0] == '/') {
140 $record->HasBrokenLink = true;
26ece45 @ajshort BUGFIX: Stopped HtmlEditorField->saveInto() from dying when encounter…
ajshort authored
141 }
4a5d9b0 @Hayden Moved Sapphire module to open source path
Hayden authored
142 }
143 }
144 }
90aa22e @ajoneil #1628 - Resizing images seems to break images, and doesn't display on…
ajoneil authored
145
1859ba5 @ajshort FEATURE: Updated HtmlEditorField to use DOMDocument to more reliably …
ajshort authored
146 // Resample images, add default attributes and add to assets tracking.
9b4d999 @ajshort FEATURE: Added SS_HTMLValue to provide a simple wrapper around DOMDoc…
ajshort authored
147 if($images = $htmlValue->getElementsByTagName('img')) foreach($images as $img) {
148 // strip any ?r=n data from the src attribute
149 $img->setAttribute('src', preg_replace('/([^\?]*)\?r=[0-9]+$/i', '$1', $img->getAttribute('src')));
5f0fcc5 @sminnee BUGFIX HTMLEditorField->saveInto() can now find images with urlencode…
sminnee authored
150 if(!$image = File::find($path = urldecode(Director::makeRelative($img->getAttribute('src'))))) {
1859ba5 @ajshort FEATURE: Updated HtmlEditorField to use DOMDocument to more reliably …
ajshort authored
151 if(substr($path, 0, strlen(ASSETS_DIR) + 1) == ASSETS_DIR . '/') {
152 $record->HasBrokenFile = true;
4a5d9b0 @Hayden Moved Sapphire module to open source path
Hayden authored
153 }
154
1859ba5 @ajshort FEATURE: Updated HtmlEditorField to use DOMDocument to more reliably …
ajshort authored
155 continue;
156 }
4a5d9b0 @Hayden Moved Sapphire module to open source path
Hayden authored
157
1859ba5 @ajshort FEATURE: Updated HtmlEditorField to use DOMDocument to more reliably …
ajshort authored
158 // Resample the images if the width & height have changed.
159 $width = $img->getAttribute('width');
160 $height = $img->getAttribute('height');
161
1192b9e @chillu BUGFIX: Resized images which return null or false are now ignored (fr…
chillu authored
162 if($image){
163 if($width && $height && ($width != $image->getWidth() || $height != $image->getHeight())) {
164 //Make sure that the resized image actually returns an image:
165 $resized=$image->ResizedImage($width, $height);
0235a8c @halkyon BUGFIX Partially reverting 28e43bdc which broke media insertion
halkyon authored
166 if($resized) $img->setAttribute('src', $resized->getRelativePath());
1192b9e @chillu BUGFIX: Resized images which return null or false are now ignored (fr…
chillu authored
167 }
4a5d9b0 @Hayden Moved Sapphire module to open source path
Hayden authored
168 }
169
1859ba5 @ajshort FEATURE: Updated HtmlEditorField to use DOMDocument to more reliably …
ajshort authored
170 // Add default empty title & alt attributes.
171 if(!$img->getAttribute('alt')) $img->setAttribute('alt', '');
172 if(!$img->getAttribute('title')) $img->setAttribute('title', '');
173
1192b9e @chillu BUGFIX: Resized images which return null or false are now ignored (fr…
chillu authored
174 //If the src attribute is not set, then we won't add this to the list:
175 if($img->getAttribute('src')){
176 // Add to the tracked files.
177 $linkedFiles[] = $image->ID;
178 }
4a5d9b0 @Hayden Moved Sapphire module to open source path
Hayden authored
179 }
1859ba5 @ajshort FEATURE: Updated HtmlEditorField to use DOMDocument to more reliably …
ajshort authored
180
181 // Save file & link tracking data.
41e51ab @chillu MINOR Made HtmlEditorField dependency to SiteTree optional (to be mov…
chillu authored
182 if(class_exists('SiteTree')) {
183 if($record->ID && $record->many_many('LinkTracking') && $tracker = $record->LinkTracking()) {
1f7fc1f @sminnee FIX Remove instances of lines longer than 120c
sminnee authored
184 $tracker->removeByFilter(sprintf('"FieldName" = \'%s\' AND "SiteTreeID" = %d',
185 $this->name, $record->ID));
05832a1 API CHANGE: removed deprecated removeByFilter() function
Will Rossiter authored
186
41e51ab @chillu MINOR Made HtmlEditorField dependency to SiteTree optional (to be mov…
chillu authored
187 if($linkedPages) foreach($linkedPages as $item) {
188 $SQL_fieldName = Convert::raw2sql($this->name);
189 DB::query("INSERT INTO \"SiteTree_LinkTracking\" (\"SiteTreeID\",\"ChildID\", \"FieldName\")
190 VALUES ($record->ID, $item, '$SQL_fieldName')");
191 }
4a5d9b0 @Hayden Moved Sapphire module to open source path
Hayden authored
192 }
de1494e @sminnee ENHANCEMENT: Implemented DataList as the successor of DataObjectSet. …
sminnee authored
193
41e51ab @chillu MINOR Made HtmlEditorField dependency to SiteTree optional (to be mov…
chillu authored
194 if($record->ID && $record->many_many('ImageTracking') && $tracker = $record->ImageTracking()) {
1f7fc1f @sminnee FIX Remove instances of lines longer than 120c
sminnee authored
195 $tracker->where(
196 sprintf('"FieldName" = \'%s\' AND "SiteTreeID" = %d', $this->name, $record->ID)
197 )->removeAll();
41e51ab @chillu MINOR Made HtmlEditorField dependency to SiteTree optional (to be mov…
chillu authored
198
199 $fieldName = $this->name;
200 if($linkedFiles) foreach($linkedFiles as $item) {
201 $tracker->add($item, array('FieldName' => $this->name));
202 }
1859ba5 @ajshort FEATURE: Updated HtmlEditorField to use DOMDocument to more reliably …
ajshort authored
203 }
4a5d9b0 @Hayden Moved Sapphire module to open source path
Hayden authored
204 }
205
9b4d999 @ajshort FEATURE: Added SS_HTMLValue to provide a simple wrapper around DOMDoc…
ajshort authored
206 $record->{$this->name} = $htmlValue->getContent();
4a5d9b0 @Hayden Moved Sapphire module to open source path
Hayden authored
207 }
05832a1 API CHANGE: removed deprecated removeByFilter() function
Will Rossiter authored
208
1859ba5 @ajshort FEATURE: Updated HtmlEditorField to use DOMDocument to more reliably …
ajshort authored
209 /**
210 * @return HtmlEditorField_Readonly
211 */
212 public function performReadonlyTransformation() {
213 $field = new HtmlEditorField_Readonly($this->name, $this->title, $this->value);
4a5d9b0 @Hayden Moved Sapphire module to open source path
Hayden authored
214 $field->setForm($this->form);
215 $field->dontEscape = true;
216 return $field;
217 }
1859ba5 @ajshort FEATURE: Updated HtmlEditorField to use DOMDocument to more reliably …
ajshort authored
218
e31851b @chillu BUGFIX Correctly mark DatetimeField, MoneyField and PhoneNumberField …
chillu authored
219 public function performDisabledTransformation() {
220 return $this->performReadonlyTransformation();
221 }
4a5d9b0 @Hayden Moved Sapphire module to open source path
Hayden authored
222 }
223
41a11b2 @sminnee Improved API documentation
sminnee authored
224 /**
225 * Readonly version of an {@link HTMLEditorField}.
226 * @package forms
227 * @subpackage fields-formattedinput
228 */
1859ba5 @ajshort FEATURE: Updated HtmlEditorField to use DOMDocument to more reliably …
ajshort authored
229 class HtmlEditorField_Readonly extends ReadonlyField {
e2f073f @chillu Method visibility according to coding conventions
chillu authored
230 public function Field($properties = array()) {
4a5d9b0 @Hayden Moved Sapphire module to open source path
Hayden authored
231 $valforInput = $this->value ? Convert::raw2att($this->value) : "";
1f7fc1f @sminnee FIX Remove instances of lines longer than 120c
sminnee authored
232 return "<span class=\"readonly typography\" id=\"" . $this->id() . "\">"
233 . ( $this->value && $this->value != '<p></p>' ? $this->value : '<i>(not set)</i>' )
234 . "</span><input type=\"hidden\" name=\"".$this->name."\" value=\"".$valforInput."\" />";
4a5d9b0 @Hayden Moved Sapphire module to open source path
Hayden authored
235 }
e2f073f @chillu Method visibility according to coding conventions
chillu authored
236 public function Type() {
8b1ef65 Readonly HTML code modification to coordinate the style of the fields
Romain Louis authored
237 return 'htmleditorfield readonly';
4a5d9b0 @Hayden Moved Sapphire module to open source path
Hayden authored
238 }
239 }
240
241 /**
5220a46 @chillu ENHANCEMENT Inserting image via new dialog with ajax field retrieval …
chillu authored
242 * Toolbar shared by all instances of {@link HTMLEditorField}, to avoid too much markup duplication.
243 * Needs to be inserted manually into the template in order to function - see {@link LeftAndMain->EditorToolbar()}.
244 *
41a11b2 @sminnee Improved API documentation
sminnee authored
245 * @package forms
246 * @subpackage fields-formattedinput
247 */
cd699e3 @sminnee API CHANGE #2857 - Renamed RequestHandlingData to RequestHandler
sminnee authored
248 class HtmlEditorField_Toolbar extends RequestHandler {
3866f56 @chillu ENHANCEMENT Using GridField for file selection in "insert image" dialog
chillu authored
249
250 static $allowed_actions = array(
251 'LinkForm',
252 'MediaForm',
5220a46 @chillu ENHANCEMENT Inserting image via new dialog with ajax field retrieval …
chillu authored
253 'viewfile'
3866f56 @chillu ENHANCEMENT Using GridField for file selection in "insert image" dialog
chillu authored
254 );
255
5220a46 @chillu ENHANCEMENT Inserting image via new dialog with ajax field retrieval …
chillu authored
256 /**
257 * @var string
258 */
259 protected $templateViewFile = 'HtmlEditorField_viewfile';
260
4a5d9b0 @Hayden Moved Sapphire module to open source path
Hayden authored
261 protected $controller, $name;
262
e2f073f @chillu Method visibility according to coding conventions
chillu authored
263 public function __construct($controller, $name) {
020a92e @sminnee BUGFIX #2992: Fixed T_PAAMAYIM_NEKUDOTAYIM error in RequestHandler
sminnee authored
264 parent::__construct();
3866f56 @chillu ENHANCEMENT Using GridField for file selection in "insert image" dialog
chillu authored
265
3a6341a @simonwelsh API-CHANGE sapphire folder can now be renamed.
simonwelsh authored
266 Requirements::javascript(FRAMEWORK_DIR . "/thirdparty/jquery/jquery.js");
3866f56 @chillu ENHANCEMENT Using GridField for file selection in "insert image" dialog
chillu authored
267 Requirements::javascript(THIRDPARTY_DIR . '/jquery-ui/jquery-ui.js');
268 Requirements::javascript(THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js');
3a6341a @simonwelsh API-CHANGE sapphire folder can now be renamed.
simonwelsh authored
269 Requirements::javascript(FRAMEWORK_ADMIN_DIR . '/javascript/ssui.core.js');
270 Requirements::javascript(FRAMEWORK_DIR ."/javascript/HtmlEditorField.js");
3866f56 @chillu ENHANCEMENT Using GridField for file selection in "insert image" dialog
chillu authored
271
272 Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.css');
020a92e @sminnee BUGFIX #2992: Fixed T_PAAMAYIM_NEKUDOTAYIM error in RequestHandler
sminnee authored
273
4a5d9b0 @Hayden Moved Sapphire module to open source path
Hayden authored
274 $this->controller = $controller;
275 $this->name = $name;
276 }
d294c0f @chillu BUGFIX: add custom search function, so the search catches also the Ti…
chillu authored
277
b025b95 @chillu ENHANCEMENT Lazy-loading image and link dialogs for HtmlEditorField, …
chillu authored
278 public function forTemplate() {
279 return sprintf(
280 '<div id="cms-editor-dialogs" data-url-linkform="%s" data-url-mediaform="%s"></div>',
281 Controller::join_links($this->controller->Link($this->name), 'LinkForm', 'forTemplate'),
282 Controller::join_links($this->controller->Link($this->name), 'MediaForm', 'forTemplate')
283 );
284 }
285
d294c0f @chillu BUGFIX: add custom search function, so the search catches also the Ti…
chillu authored
286 /**
287 * Searches the SiteTree for display in the dropdown
288 *
289 * @return callback
290 */
e2f073f @chillu Method visibility according to coding conventions
chillu authored
291 public function siteTreeSearchCallback($sourceObject, $labelField, $search) {
d294c0f @chillu BUGFIX: add custom search function, so the search catches also the Ti…
chillu authored
292 return DataObject::get($sourceObject, "\"MenuTitle\" LIKE '%$search%' OR \"Title\" LIKE '%$search%'");
293 }
4a5d9b0 @Hayden Moved Sapphire module to open source path
Hayden authored
294
295 /**
dc88762 @halkyon MINOR Code formatting on HtmlEditorField functions
halkyon authored
296 * Return a {@link Form} instance allowing a user to
297 * add links in the TinyMCE content editor.
298 *
299 * @return Form
4a5d9b0 @Hayden Moved Sapphire module to open source path
Hayden authored
300 */
e2f073f @chillu Method visibility according to coding conventions
chillu authored
301 public function LinkForm() {
1f7fc1f @sminnee FIX Remove instances of lines longer than 120c
sminnee authored
302 $siteTree = new TreeDropdownField('internal', _t('HtmlEditorField.PAGE', "Page"),
303 'SiteTree', 'ID', 'MenuTitle', true);
d294c0f @chillu BUGFIX: add custom search function, so the search catches also the Ti…
chillu authored
304 // mimic the SiteTree::getMenuTitle(), which is bypassed when the search is performed
305 $siteTree->setSearchFunction(array($this, 'siteTreeSearchCallback'));
306
1f7fc1f @sminnee FIX Remove instances of lines longer than 120c
sminnee authored
307 $numericLabelTmpl = '<span class="step-label"><span class="flyout">%d</span><span class="arrow"></span>'
308 . '<strong class="title">%s</strong></span>';
4a5d9b0 @Hayden Moved Sapphire module to open source path
Hayden authored
309 $form = new Form(
310 $this->controller,
935ee6d @chillu (merged from branches/roa. use "svn log -c <changeset> -g <module-svn…
chillu authored
311 "{$this->name}/LinkForm",
1f6f7f0 @ajshort API CHANGE: Deprecated CompositeField->FieldSet() in favour of Compos…
ajshort authored
312 new FieldList(
e51bf76 @adrexia BUGFIX: Insert link styling broken, and inconsistent with Insert medi…
adrexia authored
313 $headerWrap = new CompositeField(
314 new LiteralField(
315 'Heading',
1f7fc1f @sminnee FIX Remove instances of lines longer than 120c
sminnee authored
316 sprintf('<h3 class="htmleditorfield-mediaform-heading insert">%s</h3>',
317 _t('HtmlEditorField.LINK', 'Insert Link'))
e51bf76 @adrexia BUGFIX: Insert link styling broken, and inconsistent with Insert medi…
adrexia authored
318 )
4a5d9b0 @Hayden Moved Sapphire module to open source path
Hayden authored
319 ),
70deaa4 @chillu ENHANCEMENT Changed markup of right panel forms in HtmlEditorField, t…
chillu authored
320 $contentComposite = new CompositeField(
321 new OptionsetField(
322 'LinkType',
e4d65ab @chillu MINOR Adding step indicators to "insert link" dialog
chillu authored
323 sprintf($numericLabelTmpl, '1', _t('HtmlEditorField.LINKTO', 'Link to')),
70deaa4 @chillu ENHANCEMENT Changed markup of right panel forms in HtmlEditorField, t…
chillu authored
324 array(
325 'internal' => _t('HtmlEditorField.LINKINTERNAL', 'Page on the site'),
326 'external' => _t('HtmlEditorField.LINKEXTERNAL', 'Another website'),
327 'anchor' => _t('HtmlEditorField.LINKANCHOR', 'Anchor on this page'),
328 'email' => _t('HtmlEditorField.LINKEMAIL', 'Email address'),
fdebedd @halkyon BUGFIX Ensure the form inside htmleditorfield-dialog element is redra…
halkyon authored
329 'file' => _t('HtmlEditorField.LINKFILE', 'Download a file'),
330 ),
331 'internal'
70deaa4 @chillu ENHANCEMENT Changed markup of right panel forms in HtmlEditorField, t…
chillu authored
332 ),
e4d65ab @chillu MINOR Adding step indicators to "insert link" dialog
chillu authored
333 new LiteralField('Step2',
1f7fc1f @sminnee FIX Remove instances of lines longer than 120c
sminnee authored
334 '<div class="step2">'
335 . sprintf($numericLabelTmpl, '2', _t('HtmlEditorField.DETAILS', 'Details')) . '</div>'
e4d65ab @chillu MINOR Adding step indicators to "insert link" dialog
chillu authored
336 ),
d294c0f @chillu BUGFIX: add custom search function, so the search catches also the Ti…
chillu authored
337 $siteTree,
70deaa4 @chillu ENHANCEMENT Changed markup of right panel forms in HtmlEditorField, t…
chillu authored
338 new TextField('external', _t('HtmlEditorField.URL', 'URL'), 'http://'),
339 new EmailField('email', _t('HtmlEditorField.EMAIL', 'Email address')),
898c8f5 @halkyon ENHANCEMENT [file_link id=n] shortcode support for file links in Html…
halkyon authored
340 new TreeDropdownField('file', _t('HtmlEditorField.FILE', 'File'), 'File', 'ID', 'Title', true),
70deaa4 @chillu ENHANCEMENT Changed markup of right panel forms in HtmlEditorField, t…
chillu authored
341 new TextField('Anchor', _t('HtmlEditorField.ANCHORVALUE', 'Anchor')),
342 new TextField('Description', _t('HtmlEditorField.LINKDESCR', 'Link description')),
1f7fc1f @sminnee FIX Remove instances of lines longer than 120c
sminnee authored
343 new CheckboxField('TargetBlank',
344 _t('HtmlEditorField.LINKOPENNEWWIN', 'Open link in a new window?')),
6351b16 @chillu BUGFIX Added Locale hidden field to HTMLEditorField->LinkForm() in or…
chillu authored
345 new HiddenField('Locale', null, $this->controller->Locale)
70deaa4 @chillu ENHANCEMENT Changed markup of right panel forms in HtmlEditorField, t…
chillu authored
346 )
4a5d9b0 @Hayden Moved Sapphire module to open source path
Hayden authored
347 ),
1f6f7f0 @ajshort API CHANGE: Deprecated CompositeField->FieldSet() in favour of Compos…
ajshort authored
348 new FieldList(
40d7312 @chillu MINOR Using late static binding instead of Object::create() calls
chillu authored
349 ResetFormAction::create('remove', _t('HtmlEditorField.BUTTONREMOVELINK', 'Remove link'))
abfa16f @chillu ENHANCEMENT Using native jQuery UI buttons and icon styling for a les…
chillu authored
350 ->addExtraClass('ss-ui-action-destructive')
351 ->setUseButtonTag(true)
352 ,
353 FormAction::create('insert', _t('HtmlEditorField.BUTTONINSERTLINK', 'Insert link'))
354 ->addExtraClass('ss-ui-action-constructive')
355 ->setAttribute('data-icon', 'accept')
356 ->setUseButtonTag(true)
4a5d9b0 @Hayden Moved Sapphire module to open source path
Hayden authored
357 )
358 );
e51bf76 @adrexia BUGFIX: Insert link styling broken, and inconsistent with Insert medi…
adrexia authored
359
360 $headerWrap->addExtraClass('CompositeField composite cms-content-header nolabel ');
361 $contentComposite->addExtraClass('ss-insert-link content');
70deaa4 @chillu ENHANCEMENT Changed markup of right panel forms in HtmlEditorField, t…
chillu authored
362
beb4efe @chillu ENHANCEMENT Disabling form validation for right-panel forms in CMS in…
chillu authored
363 $form->unsetValidator();
4a5d9b0 @Hayden Moved Sapphire module to open source path
Hayden authored
364 $form->loadDataFrom($this);
b4b6e5a @chillu MINOR Cleaned up CMS dialog styling (now works with/without tabs, in …
chillu authored
365 $form->addExtraClass('htmleditorfield-form htmleditorfield-linkform cms-dialog-content');
dc88762 @halkyon MINOR Code formatting on HtmlEditorField functions
halkyon authored
366
c81a788 @chillu ENHANCEMENT Added 'updateImageForm', 'updateFlashForm', 'updateLinkFo…
chillu authored
367 $this->extend('updateLinkForm', $form);
368
4a5d9b0 @Hayden Moved Sapphire module to open source path
Hayden authored
369 return $form;
370 }
371
dc88762 @halkyon MINOR Code formatting on HtmlEditorField functions
halkyon authored
372 /**
373 * Return a {@link Form} instance allowing a user to
3866f56 @chillu ENHANCEMENT Using GridField for file selection in "insert image" dialog
chillu authored
374 * add images and flash objects to the TinyMCE content editor.
dc88762 @halkyon MINOR Code formatting on HtmlEditorField functions
halkyon authored
375 *
376 * @return Form
377 */
e2f073f @chillu Method visibility according to coding conventions
chillu authored
378 public function MediaForm() {
1f7fc1f @sminnee FIX Remove instances of lines longer than 120c
sminnee authored
379 // TODO Handle through GridState within field - currently this state set too late to be useful here (during
380 // request handling)
3866f56 @chillu ENHANCEMENT Using GridField for file selection in "insert image" dialog
chillu authored
381 $parentID = $this->controller->getRequest()->requestVar('ParentID');
382
e096c29 BUGFIX: open ticket 7603 fixing search filtering - thought I should i…
Jeremy Bridson authored
383 $fileFieldConfig = GridFieldConfig::create()->addComponents(
384 new GridFieldFilterHeader(),
385 new GridFieldSortableHeader(),
386 new GridFieldDataColumns(),
387 new GridFieldPaginator(5),
388 new GridFieldDeleteAction(),
389 new GridFieldDetailForm()
390 );
5220a46 @chillu ENHANCEMENT Inserting image via new dialog with ajax field retrieval …
chillu authored
391 $fileField = new GridField('Files', false, null, $fileFieldConfig);
3866f56 @chillu ENHANCEMENT Using GridField for file selection in "insert image" dialog
chillu authored
392 $fileField->setList($this->getFiles($parentID));
393 $fileField->setAttribute('data-selectable', true);
394 $fileField->setAttribute('data-multiselect', true);
842784c @robert-h-curry ENHANCEMENT: Fixes #7010. Move DisplayFields, FieldCasting and FieldF…
robert-h-curry authored
395 $columns = $fileField->getConfig()->getComponentByType('GridFieldDataColumns');
396 $columns->setDisplayFields(array(
5220a46 @chillu ENHANCEMENT Inserting image via new dialog with ajax field retrieval …
chillu authored
397 'CMSThumbnail' => false,
398 'Name' => _t('File.Name'),
399 ));
67cc18f @chillu MINOR Optional dependency on ThumbnailStripField in HtmlEditorField, …
chillu authored
400
1f7fc1f @sminnee FIX Remove instances of lines longer than 120c
sminnee authored
401 $numericLabelTmpl = '<span class="step-label"><span class="flyout">%d</span><span class="arrow"></span>'
402 . '<strong class="title">%s</strong></span>';
9f9dc25 @candidasa ENHANCEMENT: SSF-38 initial rearranging of the insert image form to a…
candidasa authored
403
404 $fromCMS = new CompositeField(
1f7fc1f @sminnee FIX Remove instances of lines longer than 120c
sminnee authored
405 new LiteralField('headerSelect',
406 '<h4>'.sprintf($numericLabelTmpl, '1', _t('HtmlEditorField.FindInFolder', 'Find in Folder')).'</h4>'),
407 $select = new TreeDropdownField('ParentID', "", 'Folder'),
408 $fileField
9f9dc25 @candidasa ENHANCEMENT: SSF-38 initial rearranging of the insert image form to a…
candidasa authored
409 );
f01c164 @adrexia BUGFIX: Alignment of http label in insert media
adrexia authored
410
411 $fromCMS->addExtraClass('content ss-uploadfield from-CMS');
412 $select->addExtraClass('content-select');
9f9dc25 @candidasa ENHANCEMENT: SSF-38 initial rearranging of the insert image form to a…
candidasa authored
413
414
bb29ff3 @simonwelsh FEATURE: Allow adding media to the CMS using oEmbed
simonwelsh authored
415 $fromWeb = new CompositeField(
1f7fc1f @sminnee FIX Remove instances of lines longer than 120c
sminnee authored
416 new LiteralField('headerURL',
417 '<h4>' . sprintf($numericLabelTmpl, '1', _t('HtmlEditorField.ADDURL', 'Add URL')) . '</h4>'),
6503090 @hafriedlander BUGFIX: Add validation to fix open.silverstripe.org ticket #7494
hafriedlander authored
418 $remoteURL = new TextField('RemoteURL', 'http://'),
1f7fc1f @sminnee FIX Remove instances of lines longer than 120c
sminnee authored
419 new LiteralField('addURLImage',
420 '<button class="action ui-action-constructive ui-button field add-url" data-icon="addMedia"></button>')
bb29ff3 @simonwelsh FEATURE: Allow adding media to the CMS using oEmbed
simonwelsh authored
421 );
f01c164 @adrexia BUGFIX: Alignment of http label in insert media
adrexia authored
422
bb29ff3 @simonwelsh FEATURE: Allow adding media to the CMS using oEmbed
simonwelsh authored
423 $remoteURL->addExtraClass('remoteurl');
f01c164 @adrexia BUGFIX: Alignment of http label in insert media
adrexia authored
424 $fromWeb->addExtraClass('content ss-uploadfield from-web');
bb29ff3 @simonwelsh FEATURE: Allow adding media to the CMS using oEmbed
simonwelsh authored
425
3a6341a @simonwelsh API-CHANGE sapphire folder can now be renamed.
simonwelsh authored
426 Requirements::css(FRAMEWORK_DIR . '/css/AssetUploadField.css');
9f9dc25 @candidasa ENHANCEMENT: SSF-38 initial rearranging of the insert image form to a…
candidasa authored
427 $computerUploadField = Object::create('UploadField', 'AssetUploadField', '');
428 $computerUploadField->setConfig('previewMaxWidth', 40);
429 $computerUploadField->setConfig('previewMaxHeight', 30);
430 $computerUploadField->addExtraClass('ss-assetuploadfield');
431 $computerUploadField->removeExtraClass('ss-uploadfield');
98e197a @candidasa MINOR: SSF-38 renaming the PageUploadField template to HtmlEditorFiel…
candidasa authored
432 $computerUploadField->setTemplate('HtmlEditorField_UploadField');
9f9dc25 @candidasa ENHANCEMENT: SSF-38 initial rearranging of the insert image form to a…
candidasa authored
433 $computerUploadField->setFolderName(Upload::$uploads_folder);
434
435 $tabSet = new TabSet(
bb29ff3 @simonwelsh FEATURE: Allow adding media to the CMS using oEmbed
simonwelsh authored
436 "MediaFormInsertMediaTabs",
9f9dc25 @candidasa ENHANCEMENT: SSF-38 initial rearranging of the insert image form to a…
candidasa authored
437 new Tab(
94e21d1 @candidasa MINOR: SSF-38 i18n of some of the form
candidasa authored
438 _t('HtmlEditorField.FROMCOMPUTER','From your computer'),
9f9dc25 @candidasa ENHANCEMENT: SSF-38 initial rearranging of the insert image form to a…
candidasa authored
439 $computerUploadField
440 ),
441 new Tab(
bb29ff3 @simonwelsh FEATURE: Allow adding media to the CMS using oEmbed
simonwelsh authored
442 _t('HtmlEditorField.FROMWEB', 'From the web'),
443 $fromWeb
444 ),
445 new Tab(
94e21d1 @candidasa MINOR: SSF-38 i18n of some of the form
candidasa authored
446 _t('HtmlEditorField.FROMCMS','From the CMS'),
9f9dc25 @candidasa ENHANCEMENT: SSF-38 initial rearranging of the insert image form to a…
candidasa authored
447 $fromCMS
448 )
449 );
450
451 $allFields = new CompositeField(
452 $tabSet,
1f7fc1f @sminnee FIX Remove instances of lines longer than 120c
sminnee authored
453 new LiteralField('headerEdit', '<h4 class="field header-edit">' . sprintf($numericLabelTmpl, '2',
454 _t('HtmlEditorField.ADJUSTDETAILSDIMENSIONS', 'Details &amp; dimensions')) . '</h4>'),
9f9dc25 @candidasa ENHANCEMENT: SSF-38 initial rearranging of the insert image form to a…
candidasa authored
455 $editComposite = new CompositeField(
28e43bd @adrexia ENHANCEMENT: File/Image UI fixes
adrexia authored
456 new LiteralField('contentEdit', '<div class="content-edit ss-uploadfield-files files"></div>')
0235a8c @halkyon BUGFIX Partially reverting 28e43bdc which broke media insertion
halkyon authored
457 )
4a5d9b0 @Hayden Moved Sapphire module to open source path
Hayden authored
458 );
9f9dc25 @candidasa ENHANCEMENT: SSF-38 initial rearranging of the insert image form to a…
candidasa authored
459
0235a8c @halkyon BUGFIX Partially reverting 28e43bdc which broke media insertion
halkyon authored
460 $allFields->addExtraClass('ss-insert-media');
28e43bd @adrexia ENHANCEMENT: File/Image UI fixes
adrexia authored
461
462 $headings = new CompositeField(
9f9dc25 @candidasa ENHANCEMENT: SSF-38 initial rearranging of the insert image form to a…
candidasa authored
463 new LiteralField(
464 'Heading',
1f7fc1f @sminnee FIX Remove instances of lines longer than 120c
sminnee authored
465 sprintf('<h3 class="htmleditorfield-mediaform-heading insert">%s</h3>',
466 _t('HtmlEditorField.INSERTMEDIA', 'Insert Media')).
467 sprintf('<h3 class="htmleditorfield-mediaform-heading update">%s</h3>',
468 _t('HtmlEditorField.UpdateMEDIA', 'Update Media'))
0235a8c @halkyon BUGFIX Partially reverting 28e43bdc which broke media insertion
halkyon authored
469 )
28e43bd @adrexia ENHANCEMENT: File/Image UI fixes
adrexia authored
470 );
471
472 $headings->addExtraClass('cms-content-header');
473 $editComposite->addExtraClass('ss-assetuploadfield');
474
475 $fields = new FieldList(
476 $headings,
9f9dc25 @candidasa ENHANCEMENT: SSF-38 initial rearranging of the insert image form to a…
candidasa authored
477 $allFields
478 );
dc88762 @halkyon MINOR Code formatting on HtmlEditorField functions
halkyon authored
479
1f6f7f0 @ajshort API CHANGE: Deprecated CompositeField->FieldSet() in favour of Compos…
ajshort authored
480 $actions = new FieldList(
bb29ff3 @simonwelsh FEATURE: Allow adding media to the CMS using oEmbed
simonwelsh authored
481 FormAction::create('insertmedia', _t('HtmlEditorField.BUTTONINSERT', 'Insert'))
482 ->addExtraClass('ss-ui-action-constructive media-insert')
e1372b3 @normann ENHANCEMENT: toggle header and action label for image dialog popups (…
normann authored
483 ->setAttribute('data-icon', 'accept')
484 ->setUseButtonTag(true),
bb29ff3 @simonwelsh FEATURE: Allow adding media to the CMS using oEmbed
simonwelsh authored
485 FormAction::create('insertmedia', _t('HtmlEditorField.BUTTONUpdate', 'Update'))
486 ->addExtraClass('ss-ui-action-constructive media-update')
abfa16f @chillu ENHANCEMENT Using native jQuery UI buttons and icon styling for a les…
chillu authored
487 ->setAttribute('data-icon', 'accept')
488 ->setUseButtonTag(true)
c81a788 @chillu ENHANCEMENT Added 'updateImageForm', 'updateFlashForm', 'updateLinkFo…
chillu authored
489 );
0cf6421 @chillu MINOR Button styling for "insert" dialogs
chillu authored
490
c81a788 @chillu ENHANCEMENT Added 'updateImageForm', 'updateFlashForm', 'updateLinkFo…
chillu authored
491 $form = new Form(
492 $this->controller,
3866f56 @chillu ENHANCEMENT Using GridField for file selection in "insert image" dialog
chillu authored
493 "{$this->name}/MediaForm",
c81a788 @chillu ENHANCEMENT Added 'updateImageForm', 'updateFlashForm', 'updateLinkFo…
chillu authored
494 $fields,
495 $actions
496 );
497
9f9dc25 @candidasa ENHANCEMENT: SSF-38 initial rearranging of the insert image form to a…
candidasa authored
498
beb4efe @chillu ENHANCEMENT Disabling form validation for right-panel forms in CMS in…
chillu authored
499 $form->unsetValidator();
66b25f1 @sminnee BUGFIX: Fixed CSRF warning in image form after selecting a folder.
sminnee authored
500 $form->disableSecurityToken();
4a5d9b0 @Hayden Moved Sapphire module to open source path
Hayden authored
501 $form->loadDataFrom($this);
3866f56 @chillu ENHANCEMENT Using GridField for file selection in "insert image" dialog
chillu authored
502 $form->addExtraClass('htmleditorfield-form htmleditorfield-mediaform cms-dialog-content');
5220a46 @chillu ENHANCEMENT Inserting image via new dialog with ajax field retrieval …
chillu authored
503 // TODO Re-enable once we remove $.metadata dependency which currently breaks the JS due to $.ui.widget
504 // $form->setAttribute('data-urlViewfile', $this->controller->Link($this->name));
505
506 // Allow other people to extend the fields being added to the imageform
507 $this->extend('updateMediaForm', $form);
dc88762 @halkyon MINOR Code formatting on HtmlEditorField functions
halkyon authored
508
4a5d9b0 @Hayden Moved Sapphire module to open source path
Hayden authored
509 return $form;
510 }
511
5220a46 @chillu ENHANCEMENT Inserting image via new dialog with ajax field retrieval …
chillu authored
512 /**
513 * View of a single file, either on the filesystem or on the web.
514 */
515 public function viewfile($request) {
7523f98 @adrexia BUGFIXES: File Uploads
adrexia authored
516
5220a46 @chillu ENHANCEMENT Inserting image via new dialog with ajax field retrieval …
chillu authored
517 // TODO Would be cleaner to consistently pass URL for both local and remote files,
518 // but GridField doesn't allow for this kind of metadata customization at the moment.
519 if($url = $request->getVar('FileURL')) {
95f1800 @chillu BUGFIX Resolve local images correctly even with absolute URLs in HTML…
chillu authored
520 if(Director::is_absolute_url($url) && !Director::is_site_url($url)) {
5220a46 @chillu ENHANCEMENT Inserting image via new dialog with ajax field retrieval …
chillu authored
521 $url = $url;
95f1800 @chillu BUGFIX Resolve local images correctly even with absolute URLs in HTML…
chillu authored
522 $file = new File(array(
523 'Title' => basename($url),
524 'Filename' => $url
525 ));
5220a46 @chillu ENHANCEMENT Inserting image via new dialog with ajax field retrieval …
chillu authored
526 } else {
527 $url = Director::makeRelative($request->getVar('FileURL'));
95f1800 @chillu BUGFIX Resolve local images correctly even with absolute URLs in HTML…
chillu authored
528 $url = preg_replace('/_resampled\/[^-]+-/', '', $url);
c3eabff @halkyon MINOR Use shorthand {class}::get() syntax instead of DataList::create()
halkyon authored
529 $file = File::get()->filter('Filename', $url)->first();
95f1800 @chillu BUGFIX Resolve local images correctly even with absolute URLs in HTML…
chillu authored
530 if(!$file) $file = new File(array(
531 'Title' => basename($url),
532 'Filename' => $url
533 ));
5220a46 @chillu ENHANCEMENT Inserting image via new dialog with ajax field retrieval …
chillu authored
534 }
535 } elseif($id = $request->getVar('ID')) {
536 $file = DataObject::get_by_id('File', $id);
537 $url = $file->RelativeLink();
538 } else {
539 throw new LogicException('Need either "ID" or "FileURL" parameter to identify the file');
540 }
541
542 // Instanciate file wrapper and get fields based on its type
1f7fc1f @sminnee FIX Remove instances of lines longer than 120c
sminnee authored
543 // Check if appCategory is an image and exists on the local system, otherwise use oEmbed to refference a
544 // remote image
e582935 @mightycoco BUGFIX insertion of images (trac #7438)
mightycoco authored
545 if($file && $file->appCategory() == 'image' && Director::is_site_url($url)) {
5220a46 @chillu ENHANCEMENT Inserting image via new dialog with ajax field retrieval …
chillu authored
546 $fileWrapper = new HtmlEditorField_Image($url, $file);
bb29ff3 @simonwelsh FEATURE: Allow adding media to the CMS using oEmbed
simonwelsh authored
547 } elseif(!Director::is_site_url($url)) {
548 $fileWrapper = new HtmlEditorField_Embed($url, $file);
5220a46 @chillu ENHANCEMENT Inserting image via new dialog with ajax field retrieval …
chillu authored
549 } else {
550 $fileWrapper = new HtmlEditorField_File($url, $file);
551 }
95f1800 @chillu BUGFIX Resolve local images correctly even with absolute URLs in HTML…
chillu authored
552
5220a46 @chillu ENHANCEMENT Inserting image via new dialog with ajax field retrieval …
chillu authored
553 $fields = $this->getFieldsForFile($url, $fileWrapper);
554 $this->extend('updateFieldsForFile', $fields, $url, $fileWrapper);
555
556 return $fileWrapper->customise(array(
557 'Fields' => $fields,
558 ))->renderWith($this->templateViewFile);
559 }
560
561 /**
562 * Similar to {@link File->getCMSFields()}, but only returns fields
563 * for manipulating the instance of the file as inserted into the HTML content,
564 * not the "master record" in the database - hence there's no form or saving logic.
565 *
566 * @param String Relative or absolute URL to file
567 * @return FieldList
568 */
569 protected function getFieldsForFile($url, $file) {
570 $fields = $this->extend('getFieldsForFile', $url, $file);
571 if(!$fields) {
bb29ff3 @simonwelsh FEATURE: Allow adding media to the CMS using oEmbed
simonwelsh authored
572 if($file instanceof HtmlEditorField_Embed) {
573 $fields = $this->getFieldsForOembed($url, $file);
574 } elseif($file->Extension == 'swf') {
5220a46 @chillu ENHANCEMENT Inserting image via new dialog with ajax field retrieval …
chillu authored
575 $fields = $this->getFieldsForFlash($url, $file);
576 } else {
577 $fields = $this->getFieldsForImage($url, $file);
578 }
579 $fields->push(new HiddenField('URL', false, $url));
580 }
581
582 $this->extend('updateFieldsForFile', $fields, $url, $file);
67cc18f @chillu MINOR Optional dependency on ThumbnailStripField in HtmlEditorField, …
chillu authored
583
5220a46 @chillu ENHANCEMENT Inserting image via new dialog with ajax field retrieval …
chillu authored
584 return $fields;
585 }
586
587 /**
588 * @return FieldList
589 */
bb29ff3 @simonwelsh FEATURE: Allow adding media to the CMS using oEmbed
simonwelsh authored
590 protected function getFieldsForOembed($url, $file) {
591 if(isset($file->Oembed->thumbnail_url)) {
592 $thumbnailURL = $file->Oembed->thumbnail_url;
593 } elseif($file->Type == 'photo') {
594 $thumbnailURL = $file->Oembed->url;
595 } else {
15a5dab @simonwelsh MINOR: Add a fallback thumbnail image for oEmbed inserts
simonwelsh authored
596 $thumbnailURL = FRAMEWORK_DIR . '/images/default_media.png';
bb29ff3 @simonwelsh FEATURE: Allow adding media to the CMS using oEmbed
simonwelsh authored
597 }
598
599 $previewField = new LiteralField("ImageFull",
1f7fc1f @sminnee FIX Remove instances of lines longer than 120c
sminnee authored
600 "<img id='thumbnailImage' class='thumbnail-preview' src='{$thumbnailURL}?r=" . rand(1,100000)
601 . "' alt='{$file->Name}' />\n"
bb29ff3 @simonwelsh FEATURE: Allow adding media to the CMS using oEmbed
simonwelsh authored
602 );
603
7523f98 @adrexia BUGFIXES: File Uploads
adrexia authored
604 if($file->Width != null){
605 $dimensionsField = new FieldGroup(_t('HtmlEditorField.IMAGEDIMENSIONS', 'Dimensions'),
606 $widthField = new TextField('Width', _t('HtmlEditorField.IMAGEWIDTHPX', 'Width'), $file->Width),
210e32d @chillu MINOR Labeling in HtmlEditorField
chillu authored
607 $heightField = new TextField('Height', _t('HtmlEditorField.IMAGEHEIGHTPX', 'Height'), $file->Height)
7523f98 @adrexia BUGFIXES: File Uploads
adrexia authored
608 );
609 }
610
611
bb29ff3 @simonwelsh FEATURE: Allow adding media to the CMS using oEmbed
simonwelsh authored
612 $fields = new FieldList(
613 $filePreview = CompositeField::create(
614 CompositeField::create(
615 $previewField
616 )->setName("FilePreviewImage")->addExtraClass('cms-file-info-preview'),
617 CompositeField::create(
618 CompositeField::create(
619 new ReadonlyField("FileType", _t('AssetTableField.TYPE','File type') . ':', $file->Type),
620 $urlField = new ReadonlyField('ClickableURL', _t('AssetTableField.URL','URL'),
7523f98 @adrexia BUGFIXES: File Uploads
adrexia authored
621 sprintf('<a href="%s" target="_blank" class="file">%s</a>', $url, $url)
bb29ff3 @simonwelsh FEATURE: Allow adding media to the CMS using oEmbed
simonwelsh authored
622 )
623 )
624 )->setName("FilePreviewData")->addExtraClass('cms-file-info-data')
625 )->setName("FilePreview")->addExtraClass('cms-file-info'),
626 new TextField('CaptionText', _t('HtmlEditorField.CAPTIONTEXT', 'Caption text')),
7523f98 @adrexia BUGFIXES: File Uploads
adrexia authored
627 $alignment = new DropdownField(
bb29ff3 @simonwelsh FEATURE: Allow adding media to the CMS using oEmbed
simonwelsh authored
628 'CSSClass',
629 _t('HtmlEditorField.CSSCLASS', 'Alignment / style'),
630 array(
631 'left' => _t('HtmlEditorField.CSSCLASSLEFT', 'On the left, with text wrapping around.'),
632 'leftAlone' => _t('HtmlEditorField.CSSCLASSLEFTALONE', 'On the left, on its own.'),
633 'right' => _t('HtmlEditorField.CSSCLASSRIGHT', 'On the right, with text wrapping around.'),
634 'center' => _t('HtmlEditorField.CSSCLASSCENTER', 'Centered, on its own.'),
635 )
636 ),
7523f98 @adrexia BUGFIXES: File Uploads
adrexia authored
637 $dimensionsField
bb29ff3 @simonwelsh FEATURE: Allow adding media to the CMS using oEmbed
simonwelsh authored
638 );
7523f98 @adrexia BUGFIXES: File Uploads
adrexia authored
639 $urlField->addExtraClass('text-wrap');
bb29ff3 @simonwelsh FEATURE: Allow adding media to the CMS using oEmbed
simonwelsh authored
640 $urlField->dontEscape = true;
7523f98 @adrexia BUGFIXES: File Uploads
adrexia authored
641 if($dimensionsField){
642 $dimensionsField->addExtraClass('dimensions last');
643 $widthField->setMaxLength(5);
644 $heightField->setMaxLength(5);
645 }else{
646 $alignment->addExtraClass('last');
647 }
648
bb29ff3 @simonwelsh FEATURE: Allow adding media to the CMS using oEmbed
simonwelsh authored
649
650 if($file->Type == 'photo') {
651 $filePreview->FieldList()->insertBefore(new TextField(
652 'AltText',
653 _t('HtmlEditorField.IMAGEALTTEXT', 'Alternative text (alt) - shown if image cannot be displayed'),
654 $file->Title,
655 80
656 ), 'CaptionText');
657 $filePreview->FieldList()->insertBefore(new TextField(
658 'Title',
659 _t('HtmlEditorField.IMAGETITLE', 'Title text (tooltip) - for additional information about the image')
660 ), 'CaptionText');
661 }
662
663 $this->extend('updateFieldsForImage', $fields, $url, $file);
664
665 return $fields;
666 }
667
668 /**
669 * @return FieldList
670 */
5220a46 @chillu ENHANCEMENT Inserting image via new dialog with ajax field retrieval …
chillu authored
671 protected function getFieldsForFlash($url, $file) {
672 $fields = new FieldList(
673 $dimensionsField = new FieldGroup(_t('HtmlEditorField.IMAGEDIMENSIONS', 'Dimensions'),
674 $widthField = new TextField('Width', _t('HtmlEditorField.IMAGEWIDTHPX', 'Width'), $file->Width),
1f7fc1f @sminnee FIX Remove instances of lines longer than 120c
sminnee authored
675 $heightField = new TextField('Height', " x " . _t('HtmlEditorField.IMAGEHEIGHTPX', 'Height'),
676 $file->Height)
5220a46 @chillu ENHANCEMENT Inserting image via new dialog with ajax field retrieval …
chillu authored
677 )
678 );
679 $dimensionsField->addExtraClass('dimensions');
680 $widthField->setMaxLength(5);
681 $heightField->setMaxLength(5);
682
683 $this->extend('updateFieldsForFlash', $fields, $url, $file);
684
685 return $fields;
686 }
687
688 /**
689 * @return FieldList
690 */
691 protected function getFieldsForImage($url, $file) {
bb29ff3 @simonwelsh FEATURE: Allow adding media to the CMS using oEmbed
simonwelsh authored
692 if($file->File instanceof Image) {
693 $formattedImage = $file->File->generateFormattedImage('SetWidth', Image::$asset_preview_width);
95f1800 @chillu BUGFIX Resolve local images correctly even with absolute URLs in HTML…
chillu authored
694 $thumbnailURL = $formattedImage ? $formattedImage->URL : $url;
695 } else {
696 $thumbnailURL = $url;
697 }
698
da879da @chillu MINOR Styling and structural fixes for File/Image->getCMSFields() and…
chillu authored
699 $previewField = new LiteralField("ImageFull",
1f7fc1f @sminnee FIX Remove instances of lines longer than 120c
sminnee authored
700 "<img id='thumbnailImage' class='thumbnail-preview' src='{$thumbnailURL}?r=" . rand(1,100000)
701 . "' alt='{$file->Name}' />\n"
da879da @chillu MINOR Styling and structural fixes for File/Image->getCMSFields() and…
chillu authored
702 );
703
7523f98 @adrexia BUGFIXES: File Uploads
adrexia authored
704 if($file->Width != null){
705 $dimensionsField = new FieldGroup(_t('HtmlEditorField.IMAGEDIMENSIONS', 'Dimensions'),
706 $widthField = new TextField('Width', _t('HtmlEditorField.IMAGEWIDTHPX', 'Width'), $file->Width),
1f7fc1f @sminnee FIX Remove instances of lines longer than 120c
sminnee authored
707 $heightField = new TextField('Height', " x " . _t('HtmlEditorField.IMAGEHEIGHTPX', 'Height'),
708 $file->Height)
7523f98 @adrexia BUGFIXES: File Uploads
adrexia authored
709 );
710 }
711
5220a46 @chillu ENHANCEMENT Inserting image via new dialog with ajax field retrieval …
chillu authored
712 $fields = new FieldList(
c2f7bf4 @chillu MINOR Fixed FormField::create() usage
chillu authored
713 $filePreview = CompositeField::create(
714 CompositeField::create(
da879da @chillu MINOR Styling and structural fixes for File/Image->getCMSFields() and…
chillu authored
715 $previewField
716 )->setName("FilePreviewImage")->addExtraClass('cms-file-info-preview'),
c2f7bf4 @chillu MINOR Fixed FormField::create() usage
chillu authored
717 CompositeField::create(
718 CompositeField::create(
da879da @chillu MINOR Styling and structural fixes for File/Image->getCMSFields() and…
chillu authored
719 new ReadonlyField("FileType", _t('AssetTableField.TYPE','File type') . ':', $file->FileType),
720 new ReadonlyField("Size", _t('AssetTableField.SIZE','File size') . ':', $file->getSize()),
7523f98 @adrexia BUGFIXES: File Uploads
adrexia authored
721 $urlField = new ReadonlyField('ClickableURL', _t('AssetTableField.URL','URL'),
1f7fc1f @sminnee FIX Remove instances of lines longer than 120c
sminnee authored
722 sprintf('<a href="%s" target="_blank" class="file-url">%s</a>',
723 $file->Link(), $file->RelativeLink())
da879da @chillu MINOR Styling and structural fixes for File/Image->getCMSFields() and…
chillu authored
724 ),
1f7fc1f @sminnee FIX Remove instances of lines longer than 120c
sminnee authored
725 new DateField_Disabled("Created", _t('AssetTableField.CREATED','First uploaded') . ':',
726 $file->Created),
727 new DateField_Disabled("LastEdited", _t('AssetTableField.LASTEDIT','Last changed') . ':',
728 $file->LastEdited)
da879da @chillu MINOR Styling and structural fixes for File/Image->getCMSFields() and…
chillu authored
729 )
730 )->setName("FilePreviewData")->addExtraClass('cms-file-info-data')
7523f98 @adrexia BUGFIXES: File Uploads
adrexia authored
731 )->setName("FilePreview")->addExtraClass('cms-file-info'),
1f7fc1f @sminnee FIX Remove instances of lines longer than 120c
sminnee authored
732
db076c0 @chillu MINOR Using new setDescription() styling in HtmlEditorField
chillu authored
733 TextField::create(
734 'AltText',
735 _t('HtmlEditorField.IMAGEALT', 'Alternative text (alt)'),
736 $file->Title,
737 80
1f7fc1f @sminnee FIX Remove instances of lines longer than 120c
sminnee authored
738 )->setDescription(
739 _t('HtmlEditorField.IMAGEALTTEXTDESC', 'Shown to screen readers or if image can not be displayed')),
740
db076c0 @chillu MINOR Using new setDescription() styling in HtmlEditorField
chillu authored
741 TextField::create(
742 'Title',
743 _t('HtmlEditorField.IMAGETITLETEXT', 'Title text (tooltip)')
1f7fc1f @sminnee FIX Remove instances of lines longer than 120c
sminnee authored
744 )->setDescription(
745 _t('HtmlEditorField.IMAGETITLETEXTDESC', 'For additional information about the image')),
746
5220a46 @chillu ENHANCEMENT Inserting image via new dialog with ajax field retrieval …
chillu authored
747 new TextField('CaptionText', _t('HtmlEditorField.CAPTIONTEXT', 'Caption text')),
7523f98 @adrexia BUGFIXES: File Uploads
adrexia authored
748 $alignment = new DropdownField(
5220a46 @chillu ENHANCEMENT Inserting image via new dialog with ajax field retrieval …
chillu authored
749 'CSSClass',
750 _t('HtmlEditorField.CSSCLASS', 'Alignment / style'),
751 array(
752 'left' => _t('HtmlEditorField.CSSCLASSLEFT', 'On the left, with text wrapping around.'),
753 'leftAlone' => _t('HtmlEditorField.CSSCLASSLEFTALONE', 'On the left, on its own.'),
754 'right' => _t('HtmlEditorField.CSSCLASSRIGHT', 'On the right, with text wrapping around.'),
755 'center' => _t('HtmlEditorField.CSSCLASSCENTER', 'Centered, on its own.'),
756 )
757 ),
7523f98 @adrexia BUGFIXES: File Uploads
adrexia authored
758 $dimensionsField
5220a46 @chillu ENHANCEMENT Inserting image via new dialog with ajax field retrieval …
chillu authored
759 );
da879da @chillu MINOR Styling and structural fixes for File/Image->getCMSFields() and…
chillu authored
760 $urlField->dontEscape = true;
7523f98 @adrexia BUGFIXES: File Uploads
adrexia authored
761 if($dimensionsField){
762 $dimensionsField->addExtraClass('dimensions last');
763 $widthField->setMaxLength(5);
764 $heightField->setMaxLength(5);
765 }else{
766 $alignment->addExtraClass('last');
767 }
768
5220a46 @chillu ENHANCEMENT Inserting image via new dialog with ajax field retrieval …
chillu authored
769
770 $this->extend('updateFieldsForImage', $fields, $url, $file);
771
772 return $fields;
3866f56 @chillu ENHANCEMENT Using GridField for file selection in "insert image" dialog
chillu authored
773 }
774
775 /**
776 * @param Int
777 * @return DataList
778 */
779 protected function getFiles($parentID = null) {
780 // TODO Use array('Filename:EndsWith' => $exts) once that's supported
5220a46 @chillu ENHANCEMENT Inserting image via new dialog with ajax field retrieval …
chillu authored
781 $exts = $this->getAllowedExtensions();
3866f56 @chillu ENHANCEMENT Using GridField for file selection in "insert image" dialog
chillu authored
782 $wheres = array();
783 foreach($exts as $ext) $wheres[] = '"Filename" LIKE \'%.' . $ext . '\'';
784
c3eabff @halkyon MINOR Use shorthand {class}::get() syntax instead of DataList::create()
halkyon authored
785 $files = File::get()->where(implode(' OR ', $wheres));
beb4efe @chillu ENHANCEMENT Disabling form validation for right-panel forms in CMS in…
chillu authored
786
3866f56 @chillu ENHANCEMENT Using GridField for file selection in "insert image" dialog
chillu authored
787 // Limit by folder (if required)
538bcdc @halkyon BUGFIX Ensure that the DataList is being used correctly when applying…
halkyon authored
788 if($parentID) {
789 $files = $files->filter('ParentID', $parentID);
790 }
791
3866f56 @chillu ENHANCEMENT Using GridField for file selection in "insert image" dialog
chillu authored
792 return $files;
4a5d9b0 @Hayden Moved Sapphire module to open source path
Hayden authored
793 }
5220a46 @chillu ENHANCEMENT Inserting image via new dialog with ajax field retrieval …
chillu authored
794
795 /**
796 * @return Array All extensions which can be handled by the different views.
797 */
798 protected function getAllowedExtensions() {
4fde42f @unclecheese ENHANCEMENT: Add "jpeg" to list of allowed extensions
unclecheese authored
799 $exts = array('jpg', 'gif', 'png', 'swf','jpeg');
5220a46 @chillu ENHANCEMENT Inserting image via new dialog with ajax field retrieval …
chillu authored
800 $this->extend('updateAllowedExtensions', $exts);
801 return $exts;
802 }
b025b95 @chillu ENHANCEMENT Lazy-loading image and link dialogs for HtmlEditorField, …
chillu authored
803
5220a46 @chillu ENHANCEMENT Inserting image via new dialog with ajax field retrieval …
chillu authored
804 }
805
806 /**
807 * Encapsulation of a file which can either be a remote URL
808 * or a {@link File} on the local filesystem, exhibiting common properties
809 * such as file name or the URL.
810 *
811 * @todo Remove once core has support for remote files
812 */
813 class HtmlEditorField_File extends ViewableData {
814
815 /** @var String */
816 protected $url;
817
818 /** @var File */
819 protected $file;
820
821 /**
822 * @param String
823 * @param File
824 */
e2f073f @chillu Method visibility according to coding conventions
chillu authored
825 public function __construct($url, $file = null) {
5220a46 @chillu ENHANCEMENT Inserting image via new dialog with ajax field retrieval …
chillu authored
826 $this->url = $url;
827 $this->file = $file;
da879da @chillu MINOR Styling and structural fixes for File/Image->getCMSFields() and…
chillu authored
828 $this->failover = $file;
5220a46 @chillu ENHANCEMENT Inserting image via new dialog with ajax field retrieval …
chillu authored
829
830 parent::__construct();
831 }
832
833 /**
834 * @return File Might not be set (for remote files)
835 */
e2f073f @chillu Method visibility according to coding conventions
chillu authored
836 public function getFile() {
5220a46 @chillu ENHANCEMENT Inserting image via new dialog with ajax field retrieval …
chillu authored
837 return $this->file;
838 }
839
e2f073f @chillu Method visibility according to coding conventions
chillu authored
840 public function getURL() {
5220a46 @chillu ENHANCEMENT Inserting image via new dialog with ajax field retrieval …
chillu authored
841 return $this->url;
842 }
843
e2f073f @chillu Method visibility according to coding conventions
chillu authored
844 public function getName() {
5220a46 @chillu ENHANCEMENT Inserting image via new dialog with ajax field retrieval …
chillu authored
845 return ($this->file) ? $this->file->Name : preg_replace('/\?.*/', '', basename($this->url));
846 }
847
848 /**
849 * @return String HTML
850 */
e2f073f @chillu Method visibility according to coding conventions
chillu authored
851 public function getPreview() {
5220a46 @chillu ENHANCEMENT Inserting image via new dialog with ajax field retrieval …
chillu authored
852 $preview = $this->extend('getPreview');
853 if($preview) return $preview;
854
855 if($this->file) {
856 return $this->file->CMSThumbnail();
857 } else {
858 // Hack to use the framework's built-in thumbnail support without creating a local file representation
859 $tmpFile = new File(array('Name' => $this->Name, 'Filename' => $this->Name));
860 return $tmpFile->CMSThumbnail();
861 }
862 }
863
e2f073f @chillu Method visibility according to coding conventions
chillu authored
864 public function getExtension() {
5220a46 @chillu ENHANCEMENT Inserting image via new dialog with ajax field retrieval …
chillu authored
865 return strtolower(($this->file) ? $this->file->Extension : pathinfo($this->Name, PATHINFO_EXTENSION));
866 }
867
e2f073f @chillu Method visibility according to coding conventions
chillu authored
868 public function appCategory() {
5220a46 @chillu ENHANCEMENT Inserting image via new dialog with ajax field retrieval …
chillu authored
869 if($this->file) {
870 return $this->file->appCategory();
871 } else {
872 // Hack to use the framework's built-in thumbnail support without creating a local file representation
873 $tmpFile = new File(array('Name' => $this->Name, 'Filename' => $this->Name));
874 return $tmpFile->appCategory();
875 }
876 }
877
878 }
879
bb29ff3 @simonwelsh FEATURE: Allow adding media to the CMS using oEmbed
simonwelsh authored
880 class HtmlEditorField_Embed extends HtmlEditorField_File {
881 protected $oembed;
882
883 public function __construct($url, $file = null) {
884 parent::__construct($url, $file);
885 $this->oembed = Oembed::get_oembed_from_url($url);
886 if(!$this->oembed) {
63ed0cb @mateusz BUGFIX: return a meaningful translatable string when resource is invalid
mateusz authored
887 $controller = Controller::curr();
888 $controller->response->addHeader('X-Status',
889 rawurlencode(_t(
890 'HtmlEditorField.URLNOTANOEMBEDRESOURCE',
891 "The URL '{url}' could not be turned into a media resource.",
1f7fc1f @sminnee FIX Remove instances of lines longer than 120c
sminnee authored
892 "The given URL is not a valid Oembed resource; the embed element couldn't be created.",
63ed0cb @mateusz BUGFIX: return a meaningful translatable string when resource is invalid
mateusz authored
893 array('url' => $url)
894 )));
895 $controller->response->setStatusCode(404);
896
897 throw new SS_HTTPResponse_Exception($controller->response);
bb29ff3 @simonwelsh FEATURE: Allow adding media to the CMS using oEmbed
simonwelsh authored
898 }
899 }
900
901 public function getWidth() {
30ecb9f @simonwelsh BUGFIX: Provide a default width and height of 100px for those endpoin…
simonwelsh authored
902 return $this->oembed->Width ?: 100;
bb29ff3 @simonwelsh FEATURE: Allow adding media to the CMS using oEmbed
simonwelsh authored
903 }
904
905 public function getHeight() {
30ecb9f @simonwelsh BUGFIX: Provide a default width and height of 100px for those endpoin…
simonwelsh authored
906 return $this->oembed->Height ?: 100;
bb29ff3 @simonwelsh FEATURE: Allow adding media to the CMS using oEmbed
simonwelsh authored
907 }
908
909 public function getPreview() {
910 if(isset($this->oembed->thumbnail_url)) {
911 return sprintf('<img src="%s" />', $this->oembed->thumbnail_url);
912 }
913 }
914
915 public function getName() {
916 if(isset($this->oembed->title)) {
917 return $this->oembed->title;
918 } else {
919 return parent::getName();
920 }
921 }
922
923 public function getType() {
924 return $this->oembed->type;
925 }
926
927 public function getOembed() {
928 return $this->oembed;
929 }
930
931 public function appCategory() {
932 return 'embed';
933 }
5f94d23 @mightycoco ENHANCEMENT: Ntfcatn. image embedding(trac #7438)
mightycoco authored
934
935 public function getInfo() {
936 return $this->oembed->info;
937 }
bb29ff3 @simonwelsh FEATURE: Allow adding media to the CMS using oEmbed
simonwelsh authored
938 }
939
5220a46 @chillu ENHANCEMENT Inserting image via new dialog with ajax field retrieval …
chillu authored
940 class HtmlEditorField_Image extends HtmlEditorField_File {
941
942 protected $width;
943
944 protected $height;
945
e2f073f @chillu Method visibility according to coding conventions
chillu authored
946 public function __construct($url, $file = null) {
5220a46 @chillu ENHANCEMENT Inserting image via new dialog with ajax field retrieval …
chillu authored
947 parent::__construct($url, $file);
948
949 // Get dimensions for remote file
950 $info = @getimagesize($url);
951 if($info) {
952 $this->width = $info[0];
953 $this->height = $info[1];
954 }
955 }
956
e2f073f @chillu Method visibility according to coding conventions
chillu authored
957 public function getWidth() {
5220a46 @chillu ENHANCEMENT Inserting image via new dialog with ajax field retrieval …
chillu authored
958 return ($this->file) ? $this->file->Width : $this->width;
959 }
960
e2f073f @chillu Method visibility according to coding conventions
chillu authored
961 public function getHeight() {
5220a46 @chillu ENHANCEMENT Inserting image via new dialog with ajax field retrieval …
chillu authored
962 return ($this->file) ? $this->file->Height : $this->height;
963 }
964
e2f073f @chillu Method visibility according to coding conventions
chillu authored
965 public function getPreview() {
5220a46 @chillu ENHANCEMENT Inserting image via new dialog with ajax field retrieval …
chillu authored
966 return ($this->file) ? $this->file->CMSThumbnail() : sprintf('<img src="%s" />', $this->url);
967 }
968
898c8f5 @halkyon ENHANCEMENT [file_link id=n] shortcode support for file links in Html…
halkyon authored
969 }
Something went wrong with that request. Please try again.