Patchwork: Fix up Image Form field

129 views
Skip to first unread message

Hannes Papenberg

unread,
Feb 22, 2010, 7:03:47 PM2/22/10
to Joomla! CMS Development
Hi folks,
here is your next task:

We already have a field of type "image" for JForm, but that field is
mostly broken. I'd like you to change this field to use the modal window
that you know from the image button below the normal editor windows to
select the image that you want.

If you have questions, just reply to this mail and I'll try to answer
them as soon as possible. If you are done with your work, either commit
it to a branch in the Joomla SVN or create a patch and submit it to the
Joomla Feature Tracker. If your code adheres to our coding standards,
I'll commit the patch to the trunk.

Thanks for your help.

Hannes

Artyom Bisyarin

unread,
Mar 2, 2010, 8:39:09 AM3/2/10
to Joomla! CMS Development
I'll take it. I'm already know something about the task because of
this:
http://extensions.joomla.org/extensions/tools/development-tools/9353

So I'm learning JForm now (it's still new for me).

Artyom Bisyarin

unread,
Mar 6, 2010, 6:56:31 AM3/6/10
to Joomla! CMS Development
I've noticed that com_media's modal window does not working now. Just
try to chose an image from the article edit view to check this.

Is this a known issue?
Does somebody work on this now? May I dive into com_media's image and
imagelist views if not?

Hannes Papenberg

unread,
Mar 6, 2010, 8:30:30 AM3/6/10
to joomla-...@googlegroups.com
We know about this issue and the idea was, that someone like you does
exactly that and dive into the code, repairing this. ;-) I would be
happy if you could take a look.

Hannes

Artyom Bisyarin

unread,
Mar 6, 2010, 8:49:20 AM3/6/10
to joomla-...@googlegroups.com
Thanks for the quick reply. I am looking at it now.

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

Artyom Bisyarin

unread,
Mar 6, 2010, 2:25:22 PM3/6/10
to joomla-...@googlegroups.com
On Sat, 06 Mar 2010 15:30:30 +0200, Hannes Papenberg
<hack...@googlemail.com> wrote:

> We know about this issue and the idea was, that someone like you does
> exactly that and dive into the code, repairing this. ;-) I would be
> happy if you could take a look.

Ok. I've fixed com_media's popup window issue:
http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=19877

Here is my changelog:
- administrator/components/com_media/views/images/view.html.php (strings
30-31): Old-style use of JHTML::script and JHTML::style methods.
- administrator/components/com_media/views/imageslist/view.html.php
(strings 30-31): Old-style use of JHTML::style method.
- media/media/js/popup-imagemanager.js (string 16): Was " var
ImageManager = this.MediaManager" instead of "var ImageManager =
this.ImageManager" (possibly just a typo).
- media/media/js/popup-imagemanager.js (strings 137): MooTools does not
have "getValue" method now
- media/media/js/popup-imagemanager.js (string 89-93): MooTools does not
have "getValue" method now
- administrator/components/com_media/views/images/tmpl/default.php
(string 28): Now modal window shoud be closed with
"window.parent.SqueezeBox.close()"

So now I am able to work on image form field.
I have a question about this:
In the fields folder we can see "media.php" and "mediamanager.php". For
what are they?
Should I fix one of them (they all are broken) or provide a new file
("image.php)"?

Hannes Papenberg

unread,
Mar 6, 2010, 4:13:55 PM3/6/10
to joomla-...@googlegroups.com
Hi Artyom,
sorry for not mentioning this here on the list, but after Ercan
mentioned that he wanted to override the script/style/image functions, I
changed all the occurences around the other way and made it
JHTML::_('image') instead of JHTML::image().
The idea is, that you fix the media/mediamanager fields and then you can
extend those to only show images in an image field. :-)

Hannes

Artyom Bisyarin

unread,
Mar 17, 2010, 10:42:48 AM3/17/10
to joomla-...@googlegroups.com
On Sat, 06 Mar 2010 23:13:55 +0200, Hannes Papenberg
<hack...@googlemail.com> wrote:

> Hi Artyom,
> sorry for not mentioning this here on the list, but after Ercan
> mentioned that he wanted to override the script/style/image functions, I
> changed all the occurences around the other way and made it
> JHTML::_('image') instead of JHTML::image().
> The idea is, that you fix the media/mediamanager fields and then you can
> extend those to only show images in an image field. :-)

Thanks for commiting com_media fix.
I am working on textmodal field now (in my spare time): "Generic form
field class to get values from another application's modal window and put
them into text input field". It will be ready soon.

Hannes Papenberg

unread,
Apr 9, 2010, 6:12:43 AM4/9/10
to joomla-...@googlegroups.com
Hi Artyom,
could you give a status update on this change?

Hannes

Artyom Bisyarin

unread,
Apr 9, 2010, 7:57:03 AM4/9/10
to joomla-...@googlegroups.com
On Fri, 09 Apr 2010 13:12:43 +0300, Hannes Papenberg
<hack...@googlemail.com> wrote:

> Hi Artyom,


> could you give a status update on this change?

Hello.
The work on this patchwork have lead me to creation of generic modal field
type.

Here is the first version of it:
http://groups.google.com/group/joomla-dev-cms/browse_thread/thread/7654d772be989c7c/79ef873184bd293

This is the realization of the image field with that class (you can also
download this class by the link in the above thread):

class JFormFieldModalImage extends JFormFieldModal
{
protected $link =
'index.php?option=com_media&amp;view=images&amp;tmpl=component&amp;e_name={FIELD_ID}';
static public $jsProxyFuncName = 'jInsertEditorText';
static public $jsProxyFuncArgs = array('value', 'id');

static protected function getJsProxyFunc($field) {
$script = <<<EOF

// Proxy function for the image field objects.
// Com_media should be rewriten to support field objects.
{$field->jsTypeStorageName}[id].insert(value);
EOF;
return $script;
}

static protected function getJsPreInsType() {
$script = <<<EOF
imgTag = this.value;
re = /src=['"]([^'"]+)['"]/;
re.test(imgTag);
this.value = RegExp.$1;
EOF;
return $script;
}
}

So we already can use it, but...

Now I work on refactoring JFormFieldModal to support different SqueezeBox
handlers (current version supports only "iframe" handler). I will finish
today or tomorrow.
With this class we will be able to easily create fields that receive their
values from modal windows.
Also I planning to work on issues with modal windows in Joomla! further.

Of course I don't know is somebody needs my intentions. I just think that
this is the right way to solve the issues with modal windows.
So some feedback will be a great help.

Hannes Papenberg

unread,
Apr 9, 2010, 11:44:12 AM4/9/10
to joomla-...@googlegroups.com
Thank you for your work and I really appreciate it. I will look into it
right away. If you can make the more flexible squeezebox field, that
would be cool, too.

Hannes

Artyom Bisyarin

unread,
Apr 12, 2010, 9:14:54 PM4/12/10
to joomla-...@googlegroups.com
On Fri, 09 Apr 2010 18:44:12 +0300, Hannes Papenberg
<hack...@googlemail.com> wrote:

> Thank you for your work and I really appreciate it. I will look into it
> right away. If you can make the more flexible squeezebox field, that
> would be cool, too.

Hello, Hannes.
I've finished refactoring of the first version of the JFormFieldModal. You
can find the results here:
http://zool.in.ua/shooting_range/jformfieldmodal2/jformfieldmodal2.tar.gz

So, when you will have spare time, take a look on it, please.
Of course some improvements to the classes are possible in the feature.
But I think that the classes are stable enough to use them as a base for
another form fields which use modal windows.

Also for those who don't want to bother with files and just wish take a
quick look on the new classes, here there is documentation for them (with
highlighted source):
http://zool.in.ua/shooting_range/jformfieldmodal2/doc/index.html

Thanks for your time!

--
Artyom


Artyom Bisyarin

unread,
Apr 18, 2010, 9:35:27 PM4/18/10
to joomla-...@googlegroups.com
OK. I have created a bugtracker item with a patch contained the new
classes and fixed JFormFieldModal class.

Here is it:
http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=20180

On Tue, 13 Apr 2010 04:14:54 +0300, Artyom Bisyarin <art...@ukr.net>
wrote:
--
Artyom

--
You received this message because you are subscribed to the Google Groups "Joomla! CMS Development" group.
To post to this group, send an email to joomla-...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-cm...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joomla-dev-cms?hl=en-GB.

Artyom Bisyarin

unread,
Apr 30, 2010, 11:33:07 AM4/30/10
to joomla-...@googlegroups.com
Hello.

I had a conversation with Andrew and we decide that JFormFieldModal family
of classes will appear in 1.7
I will work with the classes further in a separate branch which I will
request soon.

The patchwork should be considered as closed because of the recent commit
by Christophe which provides a quick-fix for the issue (thanks).
Reply all
Reply to author
Forward
0 new messages