Version Notes
Initial release
Download this release
Release Info
Developer | Daniel Deady |
Extension | Clockworkgeek_Formelements |
Version | 0.0.0 |
Comparing to | |
See all releases |
Version 0.0.0
- app/code/community/Clockworkgeek/Formelements/Block/Adminhtml/Renderer/Fieldset/Element/Abstract.php +44 -0
- app/code/community/Clockworkgeek/Formelements/Block/Adminhtml/Renderer/Fieldset/Element/Color.php +34 -0
- app/code/community/Clockworkgeek/Formelements/Block/Adminhtml/Renderer/Fieldset/Element/Editor.php +48 -0
- app/code/community/Clockworkgeek/Formelements/Block/Adminhtml/Renderer/Fieldset/Element/Email.php +34 -0
- app/code/community/Clockworkgeek/Formelements/Block/Adminhtml/Renderer/Fieldset/Element/Mediaurl.php +34 -0
- app/code/community/Clockworkgeek/Formelements/Block/Adminhtml/Renderer/Fieldset/Element/Number.php +34 -0
- app/code/community/Clockworkgeek/Formelements/Block/Adminhtml/Renderer/Fieldset/Element/Url.php +34 -0
- app/code/community/Clockworkgeek/Formelements/Block/Adminhtml/Widget/Form.php +117 -0
- app/code/community/Clockworkgeek/Formelements/Block/Adminhtml/Widget/Options.php +44 -0
- app/code/community/Clockworkgeek/Formelements/Block/Template.php +35 -0
- app/code/community/Clockworkgeek/Formelements/Helper/Data.php +28 -0
- app/code/community/Clockworkgeek/Formelements/LICENSE +21 -0
- app/code/community/Clockworkgeek/Formelements/Model/Observer.php +140 -0
- app/code/community/Clockworkgeek/Formelements/Model/Output.php +77 -0
- app/code/community/Clockworkgeek/Formelements/Model/System/Config/Source/Widgettypes.php +60 -0
- app/code/community/Clockworkgeek/Formelements/Model/Template/Localdir.php +40 -0
- app/code/community/Clockworkgeek/Formelements/etc/config.xml +117 -0
- app/design/adminhtml/default/default/layout/clockworkgeek/formelements.xml +38 -0
- app/etc/modules/Clockworkgeek_Formelements.xml +32 -0
- js/clockworkgeek/formelements.js +61 -0
- lib/Clockworkgeek/Data/Form.php +56 -0
- lib/Clockworkgeek/Data/Form/Element/Color.php +46 -0
- lib/Clockworkgeek/Data/Form/Element/Email.php +37 -0
- lib/Clockworkgeek/Data/Form/Element/Mediaurl.php +72 -0
- lib/Clockworkgeek/Data/Form/Element/Number.php +54 -0
- lib/Clockworkgeek/Data/Form/Element/Url.php +37 -0
- lib/Clockworkgeek/Data/Form/Element/Widget.php +78 -0
- package.xml +18 -0
app/code/community/Clockworkgeek/Formelements/Block/Adminhtml/Renderer/Fieldset/Element/Abstract.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* The MIT License (MIT)
|
4 |
+
*
|
5 |
+
* Copyright (c) 2015 Daniel Deady
|
6 |
+
*
|
7 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8 |
+
* of this software and associated documentation files (the "Software"), to deal
|
9 |
+
* in the Software without restriction, including without limitation the rights
|
10 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11 |
+
* copies of the Software, and to permit persons to whom the Software is
|
12 |
+
* furnished to do so, subject to the following conditions:
|
13 |
+
*
|
14 |
+
* The above copyright notice and this permission notice shall be included in all
|
15 |
+
* copies or substantial portions of the Software.
|
16 |
+
*
|
17 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23 |
+
* SOFTWARE.
|
24 |
+
*/
|
25 |
+
|
26 |
+
abstract class Clockworkgeek_Formelements_Block_Adminhtml_Renderer_Fieldset_Element_Abstract
|
27 |
+
extends Mage_Adminhtml_Block_Widget_Form_Renderer_Fieldset_Element
|
28 |
+
{
|
29 |
+
|
30 |
+
abstract public function getElementClass();
|
31 |
+
|
32 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
33 |
+
{
|
34 |
+
$classname = $this->getElementClass();
|
35 |
+
|
36 |
+
if (! ($element instanceof $classname)) {
|
37 |
+
$number = new $classname($element->getData());
|
38 |
+
$number->setForm($element->getForm());
|
39 |
+
$number->setId($element->getId());
|
40 |
+
$element = $number;
|
41 |
+
}
|
42 |
+
return parent::render($element);
|
43 |
+
}
|
44 |
+
}
|
app/code/community/Clockworkgeek/Formelements/Block/Adminhtml/Renderer/Fieldset/Element/Color.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* The MIT License (MIT)
|
4 |
+
*
|
5 |
+
* Copyright (c) 2015 Daniel Deady
|
6 |
+
*
|
7 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8 |
+
* of this software and associated documentation files (the "Software"), to deal
|
9 |
+
* in the Software without restriction, including without limitation the rights
|
10 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11 |
+
* copies of the Software, and to permit persons to whom the Software is
|
12 |
+
* furnished to do so, subject to the following conditions:
|
13 |
+
*
|
14 |
+
* The above copyright notice and this permission notice shall be included in all
|
15 |
+
* copies or substantial portions of the Software.
|
16 |
+
*
|
17 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23 |
+
* SOFTWARE.
|
24 |
+
*/
|
25 |
+
|
26 |
+
class Clockworkgeek_Formelements_Block_Adminhtml_Renderer_Fieldset_Element_Color
|
27 |
+
extends Clockworkgeek_Formelements_Block_Adminhtml_Renderer_Fieldset_Element_Abstract
|
28 |
+
{
|
29 |
+
|
30 |
+
public function getElementClass()
|
31 |
+
{
|
32 |
+
return 'Clockworkgeek_Data_Form_Element_Color';
|
33 |
+
}
|
34 |
+
}
|
app/code/community/Clockworkgeek/Formelements/Block/Adminhtml/Renderer/Fieldset/Element/Editor.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* The MIT License (MIT)
|
4 |
+
*
|
5 |
+
* Copyright (c) 2015 Daniel Deady
|
6 |
+
*
|
7 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8 |
+
* of this software and associated documentation files (the "Software"), to deal
|
9 |
+
* in the Software without restriction, including without limitation the rights
|
10 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11 |
+
* copies of the Software, and to permit persons to whom the Software is
|
12 |
+
* furnished to do so, subject to the following conditions:
|
13 |
+
*
|
14 |
+
* The above copyright notice and this permission notice shall be included in all
|
15 |
+
* copies or substantial portions of the Software.
|
16 |
+
*
|
17 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23 |
+
* SOFTWARE.
|
24 |
+
*/
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Make WYSIWYG editor suitable for widget instances
|
28 |
+
*
|
29 |
+
* @see http://behrendtio.github.io/2013/04/12/using-a-wysiwyg-editor-in-a-magento-widget/
|
30 |
+
*/
|
31 |
+
class Clockworkgeek_Formelements_Block_Adminhtml_Renderer_Fieldset_Element_Editor
|
32 |
+
extends Mage_Adminhtml_Block_Widget_Form_Renderer_Fieldset_Element
|
33 |
+
{
|
34 |
+
|
35 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
36 |
+
{
|
37 |
+
$editor = new Varien_Data_Form_Element_Editor($element->getData());
|
38 |
+
|
39 |
+
// Prevent foreach error
|
40 |
+
$editor->getConfig()->setPlugins(array());
|
41 |
+
|
42 |
+
$editor->setId($element->getId());
|
43 |
+
$editor->setForm($element->getForm());
|
44 |
+
$editor->setWysiwyg(true);
|
45 |
+
|
46 |
+
return parent::render($editor);
|
47 |
+
}
|
48 |
+
}
|
app/code/community/Clockworkgeek/Formelements/Block/Adminhtml/Renderer/Fieldset/Element/Email.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* The MIT License (MIT)
|
4 |
+
*
|
5 |
+
* Copyright (c) 2015 Daniel Deady
|
6 |
+
*
|
7 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8 |
+
* of this software and associated documentation files (the "Software"), to deal
|
9 |
+
* in the Software without restriction, including without limitation the rights
|
10 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11 |
+
* copies of the Software, and to permit persons to whom the Software is
|
12 |
+
* furnished to do so, subject to the following conditions:
|
13 |
+
*
|
14 |
+
* The above copyright notice and this permission notice shall be included in all
|
15 |
+
* copies or substantial portions of the Software.
|
16 |
+
*
|
17 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23 |
+
* SOFTWARE.
|
24 |
+
*/
|
25 |
+
|
26 |
+
class Clockworkgeek_Formelements_Block_Adminhtml_Renderer_Fieldset_Element_Email
|
27 |
+
extends Clockworkgeek_Formelements_Block_Adminhtml_Renderer_Fieldset_Element_Abstract
|
28 |
+
{
|
29 |
+
|
30 |
+
public function getElementClass()
|
31 |
+
{
|
32 |
+
return 'Clockworkgeek_Data_Form_Element_Email';
|
33 |
+
}
|
34 |
+
}
|
app/code/community/Clockworkgeek/Formelements/Block/Adminhtml/Renderer/Fieldset/Element/Mediaurl.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* The MIT License (MIT)
|
4 |
+
*
|
5 |
+
* Copyright (c) 2015 Daniel Deady
|
6 |
+
*
|
7 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8 |
+
* of this software and associated documentation files (the "Software"), to deal
|
9 |
+
* in the Software without restriction, including without limitation the rights
|
10 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11 |
+
* copies of the Software, and to permit persons to whom the Software is
|
12 |
+
* furnished to do so, subject to the following conditions:
|
13 |
+
*
|
14 |
+
* The above copyright notice and this permission notice shall be included in all
|
15 |
+
* copies or substantial portions of the Software.
|
16 |
+
*
|
17 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23 |
+
* SOFTWARE.
|
24 |
+
*/
|
25 |
+
|
26 |
+
class Clockworkgeek_Formelements_Block_Adminhtml_Renderer_Fieldset_Element_Mediaurl
|
27 |
+
extends Clockworkgeek_Formelements_Block_Adminhtml_Renderer_Fieldset_Element_Abstract
|
28 |
+
{
|
29 |
+
|
30 |
+
public function getElementClass()
|
31 |
+
{
|
32 |
+
return 'Clockworkgeek_Data_Form_Element_Mediaurl';
|
33 |
+
}
|
34 |
+
}
|
app/code/community/Clockworkgeek/Formelements/Block/Adminhtml/Renderer/Fieldset/Element/Number.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* The MIT License (MIT)
|
4 |
+
*
|
5 |
+
* Copyright (c) 2015 Daniel Deady
|
6 |
+
*
|
7 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8 |
+
* of this software and associated documentation files (the "Software"), to deal
|
9 |
+
* in the Software without restriction, including without limitation the rights
|
10 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11 |
+
* copies of the Software, and to permit persons to whom the Software is
|
12 |
+
* furnished to do so, subject to the following conditions:
|
13 |
+
*
|
14 |
+
* The above copyright notice and this permission notice shall be included in all
|
15 |
+
* copies or substantial portions of the Software.
|
16 |
+
*
|
17 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23 |
+
* SOFTWARE.
|
24 |
+
*/
|
25 |
+
|
26 |
+
class Clockworkgeek_Formelements_Block_Adminhtml_Renderer_Fieldset_Element_Number
|
27 |
+
extends Clockworkgeek_Formelements_Block_Adminhtml_Renderer_Fieldset_Element_Abstract
|
28 |
+
{
|
29 |
+
|
30 |
+
public function getElementClass()
|
31 |
+
{
|
32 |
+
return 'Clockworkgeek_Data_Form_Element_Number';
|
33 |
+
}
|
34 |
+
}
|
app/code/community/Clockworkgeek/Formelements/Block/Adminhtml/Renderer/Fieldset/Element/Url.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* The MIT License (MIT)
|
4 |
+
*
|
5 |
+
* Copyright (c) 2015 Daniel Deady
|
6 |
+
*
|
7 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8 |
+
* of this software and associated documentation files (the "Software"), to deal
|
9 |
+
* in the Software without restriction, including without limitation the rights
|
10 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11 |
+
* copies of the Software, and to permit persons to whom the Software is
|
12 |
+
* furnished to do so, subject to the following conditions:
|
13 |
+
*
|
14 |
+
* The above copyright notice and this permission notice shall be included in all
|
15 |
+
* copies or substantial portions of the Software.
|
16 |
+
*
|
17 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23 |
+
* SOFTWARE.
|
24 |
+
*/
|
25 |
+
|
26 |
+
class Clockworkgeek_Formelements_Block_Adminhtml_Renderer_Fieldset_Element_Url
|
27 |
+
extends Clockworkgeek_Formelements_Block_Adminhtml_Renderer_Fieldset_Element_Abstract
|
28 |
+
{
|
29 |
+
|
30 |
+
public function getElementClass()
|
31 |
+
{
|
32 |
+
return 'Clockworkgeek_Data_Form_Element_Url';
|
33 |
+
}
|
34 |
+
}
|
app/code/community/Clockworkgeek/Formelements/Block/Adminhtml/Widget/Form.php
ADDED
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* The MIT License (MIT)
|
4 |
+
*
|
5 |
+
* Copyright (c) 2015 Daniel Deady
|
6 |
+
*
|
7 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8 |
+
* of this software and associated documentation files (the "Software"), to deal
|
9 |
+
* in the Software without restriction, including without limitation the rights
|
10 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11 |
+
* copies of the Software, and to permit persons to whom the Software is
|
12 |
+
* furnished to do so, subject to the following conditions:
|
13 |
+
*
|
14 |
+
* The above copyright notice and this permission notice shall be included in all
|
15 |
+
* copies or substantial portions of the Software.
|
16 |
+
*
|
17 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23 |
+
* SOFTWARE.
|
24 |
+
*/
|
25 |
+
|
26 |
+
/**
|
27 |
+
* @method boolean getRequired()
|
28 |
+
* @method boolean getDisabled()
|
29 |
+
* @method string getWidgetType()
|
30 |
+
* @method Clockworkgeek_Formelements_Block_Adminhtml_Widget_Form setDisabled(boolean)
|
31 |
+
* @method Clockworkgeek_Formelements_Block_Adminhtml_Widget_Form setRequired(boolean)
|
32 |
+
* @method Clockworkgeek_Formelements_Block_Adminhtml_Widget_Form setWidgetType(string)
|
33 |
+
*/
|
34 |
+
class Clockworkgeek_Formelements_Block_Adminhtml_Widget_Form extends Mage_Widget_Block_Adminhtml_Widget_Form
|
35 |
+
{
|
36 |
+
|
37 |
+
protected function _prepareForm()
|
38 |
+
{
|
39 |
+
parent::_prepareForm();
|
40 |
+
$form = $this->getForm();
|
41 |
+
$form->setUseContainer(false);
|
42 |
+
$form->setHtmlId($this->getHtmlId() . '_form');
|
43 |
+
|
44 |
+
$select = $form->getElement('select_widget_type');
|
45 |
+
$select->setDisabled($this->getDisabled());
|
46 |
+
$select->setHtmlId($this->getHtmlId() . '_type');
|
47 |
+
$select->setRequired($this->getRequired());
|
48 |
+
$select->setValue($this->getWidgetType());
|
49 |
+
|
50 |
+
return $this;
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Prepare widgets select after element HTML
|
55 |
+
*
|
56 |
+
* @return string
|
57 |
+
*/
|
58 |
+
protected function _getWidgetSelectAfterHtml()
|
59 |
+
{
|
60 |
+
$html = '';
|
61 |
+
$selected = '';
|
62 |
+
$i = 0;
|
63 |
+
foreach ($this->_getAvailableWidgets(true) as $data) {
|
64 |
+
$html .= sprintf('<div id="widget-description-%s" class="no-display">%s</div>', $i, $data['description']);
|
65 |
+
if ($data['type'] == $this->getWidgetType()) {
|
66 |
+
$selected = $data['description'];
|
67 |
+
}
|
68 |
+
$i++;
|
69 |
+
}
|
70 |
+
$html = sprintf('<p class="nm"><small>%s</small></p>%s', $selected, $html);
|
71 |
+
|
72 |
+
$optionsUrl = $this->getUrl('*/widget/loadOptions');
|
73 |
+
// TODO move inline JS to 'js' block or template or both
|
74 |
+
// TODO convert complex fields into comma separated strings
|
75 |
+
$htmlId = $this->getHtmlId();
|
76 |
+
$html .=
|
77 |
+
<<<HTML
|
78 |
+
<script type="text/javascript">
|
79 |
+
document.observe('dom:loaded', function() {
|
80 |
+
{$htmlId}Widget = new WysiwygWidget.Widget("{$this->getFormId()}", "{$htmlId}_type",
|
81 |
+
"{$htmlId}_options", "{$optionsUrl}", "{$htmlId}");
|
82 |
+
varienGlobalEvents.attachEventHandler('formSubmit', function(formId) {
|
83 |
+
var widgetType = \$F('{$htmlId}_type');
|
84 |
+
if (!widgetType) {
|
85 |
+
Form.Element.setValue('{$htmlId}', '');
|
86 |
+
return;
|
87 |
+
}
|
88 |
+
|
89 |
+
var optionsDiv = $('{$htmlId}_options_'+widgetType.replace('/', '_')),
|
90 |
+
fields = optionsDiv.select('input,select,textarea'),
|
91 |
+
directive = '{{widget type="'+widgetType+'"';
|
92 |
+
fields.each(function(field) {
|
93 |
+
var key = field.name.replace(/^parameters\[([^\]]+)\]$/, '$1'),
|
94 |
+
value = \$F(field).replace(/"/g, '\\"');
|
95 |
+
if (value) {
|
96 |
+
directive += ' ' + key + '="' + value + '"';
|
97 |
+
}
|
98 |
+
});
|
99 |
+
directive += '}}';
|
100 |
+
Form.Element.setValue('{$htmlId}', directive);
|
101 |
+
});
|
102 |
+
});
|
103 |
+
</script>
|
104 |
+
HTML;
|
105 |
+
|
106 |
+
return $html;
|
107 |
+
}
|
108 |
+
|
109 |
+
public function getFormId()
|
110 |
+
{
|
111 |
+
$id = '';
|
112 |
+
if ($this->getFieldNameSuffix()) {
|
113 |
+
$id = $this->getFieldNameSuffix() . '_';
|
114 |
+
}
|
115 |
+
return $id . $this->getDestElementId();
|
116 |
+
}
|
117 |
+
}
|
app/code/community/Clockworkgeek/Formelements/Block/Adminhtml/Widget/Options.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* The MIT License (MIT)
|
4 |
+
*
|
5 |
+
* Copyright (c) 2015 Daniel Deady
|
6 |
+
*
|
7 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8 |
+
* of this software and associated documentation files (the "Software"), to deal
|
9 |
+
* in the Software without restriction, including without limitation the rights
|
10 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11 |
+
* copies of the Software, and to permit persons to whom the Software is
|
12 |
+
* furnished to do so, subject to the following conditions:
|
13 |
+
*
|
14 |
+
* The above copyright notice and this permission notice shall be included in all
|
15 |
+
* copies or substantial portions of the Software.
|
16 |
+
*
|
17 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23 |
+
* SOFTWARE.
|
24 |
+
*/
|
25 |
+
|
26 |
+
/**
|
27 |
+
* @method boolean getDisabled()
|
28 |
+
* @method string getWidgetType()
|
29 |
+
* @method void setDisabled(bool)
|
30 |
+
* @method void setWidgetType(string)
|
31 |
+
*/
|
32 |
+
class Clockworkgeek_Formelements_Block_Adminhtml_Widget_Options extends Mage_Widget_Block_Adminhtml_Widget_Options
|
33 |
+
{
|
34 |
+
|
35 |
+
protected function _addField($parameter)
|
36 |
+
{
|
37 |
+
$field = parent::_addField($parameter);
|
38 |
+
if ($this->getDisabled()) {
|
39 |
+
$field->setDisabled(true);
|
40 |
+
}
|
41 |
+
// else do not enable an already disabled field
|
42 |
+
return $field;
|
43 |
+
}
|
44 |
+
}
|
app/code/community/Clockworkgeek/Formelements/Block/Template.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* The MIT License (MIT)
|
4 |
+
*
|
5 |
+
* Copyright (c) 2015 Daniel Deady
|
6 |
+
*
|
7 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8 |
+
* of this software and associated documentation files (the "Software"), to deal
|
9 |
+
* in the Software without restriction, including without limitation the rights
|
10 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11 |
+
* copies of the Software, and to permit persons to whom the Software is
|
12 |
+
* furnished to do so, subject to the following conditions:
|
13 |
+
*
|
14 |
+
* The above copyright notice and this permission notice shall be included in all
|
15 |
+
* copies or substantial portions of the Software.
|
16 |
+
*
|
17 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23 |
+
* SOFTWARE.
|
24 |
+
*/
|
25 |
+
|
26 |
+
class Clockworkgeek_Formelements_Block_Template extends Mage_Core_Block_Template
|
27 |
+
{
|
28 |
+
|
29 |
+
protected function _toHtml()
|
30 |
+
{
|
31 |
+
$html = parent::_toHtml();
|
32 |
+
$filter = Mage::getSingleton('widget/template_filter');
|
33 |
+
return $filter->filter($html);
|
34 |
+
}
|
35 |
+
}
|
app/code/community/Clockworkgeek/Formelements/Helper/Data.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* The MIT License (MIT)
|
4 |
+
*
|
5 |
+
* Copyright (c) 2015 Daniel Deady
|
6 |
+
*
|
7 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8 |
+
* of this software and associated documentation files (the "Software"), to deal
|
9 |
+
* in the Software without restriction, including without limitation the rights
|
10 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11 |
+
* copies of the Software, and to permit persons to whom the Software is
|
12 |
+
* furnished to do so, subject to the following conditions:
|
13 |
+
*
|
14 |
+
* The above copyright notice and this permission notice shall be included in all
|
15 |
+
* copies or substantial portions of the Software.
|
16 |
+
*
|
17 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23 |
+
* SOFTWARE.
|
24 |
+
*/
|
25 |
+
|
26 |
+
class Clockworkgeek_Formelements_Helper_Data extends Mage_Core_Helper_Data
|
27 |
+
{
|
28 |
+
}
|
app/code/community/Clockworkgeek/Formelements/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
The MIT License (MIT)
|
2 |
+
|
3 |
+
Copyright (c) 2015 Daniel Deady
|
4 |
+
|
5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6 |
+
of this software and associated documentation files (the "Software"), to deal
|
7 |
+
in the Software without restriction, including without limitation the rights
|
8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9 |
+
copies of the Software, and to permit persons to whom the Software is
|
10 |
+
furnished to do so, subject to the following conditions:
|
11 |
+
|
12 |
+
The above copyright notice and this permission notice shall be included in all
|
13 |
+
copies or substantial portions of the Software.
|
14 |
+
|
15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21 |
+
SOFTWARE.
|
app/code/community/Clockworkgeek/Formelements/Model/Observer.php
ADDED
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* The MIT License (MIT)
|
4 |
+
*
|
5 |
+
* Copyright (c) 2015 Daniel Deady
|
6 |
+
*
|
7 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8 |
+
* of this software and associated documentation files (the "Software"), to deal
|
9 |
+
* in the Software without restriction, including without limitation the rights
|
10 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11 |
+
* copies of the Software, and to permit persons to whom the Software is
|
12 |
+
* furnished to do so, subject to the following conditions:
|
13 |
+
*
|
14 |
+
* The above copyright notice and this permission notice shall be included in all
|
15 |
+
* copies or substantial portions of the Software.
|
16 |
+
*
|
17 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23 |
+
* SOFTWARE.
|
24 |
+
*/
|
25 |
+
|
26 |
+
class Clockworkgeek_Formelements_Model_Observer
|
27 |
+
{
|
28 |
+
|
29 |
+
public function addProductAttributeTypes(Varien_Event_Observer $observer)
|
30 |
+
{
|
31 |
+
$helper = Mage::helper('formelements');
|
32 |
+
$response = $observer->getResponse();
|
33 |
+
$types = $response->getTypes();
|
34 |
+
$types[] = array(
|
35 |
+
'value' => 'color',
|
36 |
+
'label' => $helper->__('HTML Color'),
|
37 |
+
'hide_fields' => array(
|
38 |
+
'is_filterable',
|
39 |
+
'is_filterable_in_search',
|
40 |
+
'position',
|
41 |
+
'frontend_class'
|
42 |
+
)
|
43 |
+
);
|
44 |
+
$types[] = array(
|
45 |
+
'value' => 'color',
|
46 |
+
'label' => $helper->__('HTML Email'),
|
47 |
+
'hide_fields' => array(
|
48 |
+
'is_filterable',
|
49 |
+
'is_filterable_in_search',
|
50 |
+
'position',
|
51 |
+
'frontend_class'
|
52 |
+
)
|
53 |
+
);
|
54 |
+
$types[] = array(
|
55 |
+
'value' => 'number',
|
56 |
+
'label' => $helper->__('HTML Number'),
|
57 |
+
'hide_fields' => array(
|
58 |
+
'is_filterable',
|
59 |
+
'is_filterable_in_search',
|
60 |
+
'position',
|
61 |
+
'frontend_class'
|
62 |
+
)
|
63 |
+
);
|
64 |
+
$types[] = array(
|
65 |
+
'value' => 'color',
|
66 |
+
'label' => $helper->__('HTML Url'),
|
67 |
+
'hide_fields' => array(
|
68 |
+
'is_filterable',
|
69 |
+
'is_filterable_in_search',
|
70 |
+
'position',
|
71 |
+
'frontend_class'
|
72 |
+
)
|
73 |
+
);
|
74 |
+
|
75 |
+
// complex display types, cannot be used for data driven features
|
76 |
+
$types[] = array(
|
77 |
+
'value' => 'mediaurl',
|
78 |
+
'label' => $helper->__('WYSIWYG Media File'),
|
79 |
+
'hide_fields' => array(
|
80 |
+
'is_unique',
|
81 |
+
'is_searchable',
|
82 |
+
'is_visible_in_advanced_search',
|
83 |
+
'is_comparable',
|
84 |
+
'is_filterable',
|
85 |
+
'is_filterable_in_search',
|
86 |
+
'is_used_for_promo_rules',
|
87 |
+
'position',
|
88 |
+
'used_for_sort_by',
|
89 |
+
'frontend_class'
|
90 |
+
)
|
91 |
+
);
|
92 |
+
$types[] = array(
|
93 |
+
'value' => 'widget',
|
94 |
+
'label' => $helper->__('Widget'),
|
95 |
+
'hide_fields' => array(
|
96 |
+
'is_unique',
|
97 |
+
'is_searchable',
|
98 |
+
'is_visible_in_advanced_search',
|
99 |
+
'is_comparable',
|
100 |
+
'is_filterable',
|
101 |
+
'is_filterable_in_search',
|
102 |
+
'is_used_for_promo_rules',
|
103 |
+
'position',
|
104 |
+
'used_for_sort_by',
|
105 |
+
'frontend_class'
|
106 |
+
)
|
107 |
+
);
|
108 |
+
$response->setTypes($types);
|
109 |
+
}
|
110 |
+
|
111 |
+
public function addProductAttributeElements(Varien_Event_Observer $observer)
|
112 |
+
{
|
113 |
+
$response = $observer->getResponse();
|
114 |
+
$types = $response->getTypes();
|
115 |
+
$types['color'] = 'Clockworkgeek_Data_Form_Element_Color';
|
116 |
+
$types['email'] = 'Clockworkgeek_Data_Form_Element_Email';
|
117 |
+
$types['number'] = 'Clockworkgeek_Data_Form_Element_Number';
|
118 |
+
$types['url'] = 'Clockworkgeek_Data_Form_Element_Url';
|
119 |
+
$types['mediaurl'] = 'Clockworkgeek_Data_Form_Element_Mediaurl';
|
120 |
+
$types['widget'] = 'Clockworkgeek_Data_Form_Element_Widget';
|
121 |
+
$response->setTypes($types);
|
122 |
+
}
|
123 |
+
|
124 |
+
public function setAttributeBackendType(Varien_Event_Observer $observer)
|
125 |
+
{
|
126 |
+
$attribute = $observer->getAttribute();
|
127 |
+
switch ($attribute->getFrontendInput()) {
|
128 |
+
case 'number':
|
129 |
+
$attribute->setBackendType('decimal');
|
130 |
+
break;
|
131 |
+
case 'color':
|
132 |
+
case 'email':
|
133 |
+
case 'url':
|
134 |
+
case 'mediaurl':
|
135 |
+
case 'widget':
|
136 |
+
$attribute->setBackendType('varchar');
|
137 |
+
break;
|
138 |
+
}
|
139 |
+
}
|
140 |
+
}
|
app/code/community/Clockworkgeek/Formelements/Model/Output.php
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* The MIT License (MIT)
|
4 |
+
*
|
5 |
+
* Copyright (c) 2015 Daniel Deady
|
6 |
+
*
|
7 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8 |
+
* of this software and associated documentation files (the "Software"), to deal
|
9 |
+
* in the Software without restriction, including without limitation the rights
|
10 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11 |
+
* copies of the Software, and to permit persons to whom the Software is
|
12 |
+
* furnished to do so, subject to the following conditions:
|
13 |
+
*
|
14 |
+
* The above copyright notice and this permission notice shall be included in all
|
15 |
+
* copies or substantial portions of the Software.
|
16 |
+
*
|
17 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23 |
+
* SOFTWARE.
|
24 |
+
*/
|
25 |
+
|
26 |
+
class Clockworkgeek_Formelements_Model_Output
|
27 |
+
{
|
28 |
+
|
29 |
+
public function addProductAttributeHandlers(Varien_Event_Observer $observer)
|
30 |
+
{
|
31 |
+
$helper = $observer->getHelper();
|
32 |
+
$helper->addHandler('productAttribute', $this);
|
33 |
+
}
|
34 |
+
|
35 |
+
public function productAttribute($helper, $html, $params)
|
36 |
+
{
|
37 |
+
$attributeName = @$params['attribute'];
|
38 |
+
/* @var $product Mage_Catalog_Model_Product */
|
39 |
+
$product = @$params['product'];
|
40 |
+
if ($attributeName && $product) {
|
41 |
+
$attributes = $product->getAttributes();
|
42 |
+
/* @var $attribute Mage_Catalog_Model_Resource_Eav_Attribute */
|
43 |
+
$attribute = @$attributes[$attributeName];
|
44 |
+
if ($attribute) {
|
45 |
+
switch ($attribute->getFrontendInput()) {
|
46 |
+
case 'mediaurl':
|
47 |
+
$html = $this->renderMediaImage($html);
|
48 |
+
break;
|
49 |
+
case 'widget':
|
50 |
+
$html = $this->renderWidget($html);
|
51 |
+
break;
|
52 |
+
}
|
53 |
+
}
|
54 |
+
}
|
55 |
+
return $html;
|
56 |
+
}
|
57 |
+
|
58 |
+
public function renderMediaImage($data)
|
59 |
+
{
|
60 |
+
if (preg_match('/^{{(?:media|skin) url="([^"]+)"}}$/', $data)) {
|
61 |
+
$filename = Mage::getSingleton('formelements/template_localdir')->filter($data);
|
62 |
+
$url = Mage::getSingleton('widget/template_filter')->filter($data);
|
63 |
+
$imagesize = getimagesize($filename);
|
64 |
+
if ($imagesize) {
|
65 |
+
list($width, $height) = $imagesize;
|
66 |
+
$data = sprintf('<img src="%s" width="%d" height="%d" />', $url, $width, $height);
|
67 |
+
}
|
68 |
+
}
|
69 |
+
return $data;
|
70 |
+
}
|
71 |
+
|
72 |
+
public function renderWidget($data)
|
73 |
+
{
|
74 |
+
$template = Mage::getSingleton('widget/template_filter');
|
75 |
+
return $template->filter($data);
|
76 |
+
}
|
77 |
+
}
|
app/code/community/Clockworkgeek/Formelements/Model/System/Config/Source/Widgettypes.php
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* The MIT License (MIT)
|
4 |
+
*
|
5 |
+
* Copyright (c) 2015 Daniel Deady
|
6 |
+
*
|
7 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8 |
+
* of this software and associated documentation files (the "Software"), to deal
|
9 |
+
* in the Software without restriction, including without limitation the rights
|
10 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11 |
+
* copies of the Software, and to permit persons to whom the Software is
|
12 |
+
* furnished to do so, subject to the following conditions:
|
13 |
+
*
|
14 |
+
* The above copyright notice and this permission notice shall be included in all
|
15 |
+
* copies or substantial portions of the Software.
|
16 |
+
*
|
17 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23 |
+
* SOFTWARE.
|
24 |
+
*/
|
25 |
+
|
26 |
+
class Clockworkgeek_Formelements_Model_System_Config_Source_Widgettypes
|
27 |
+
{
|
28 |
+
|
29 |
+
public function toOptionArray($withBlank = true)
|
30 |
+
{
|
31 |
+
$options = array();
|
32 |
+
if ($withBlank) {
|
33 |
+
$options[''] = array(
|
34 |
+
'value' => '',
|
35 |
+
'label' => Mage::helper('formelements')->__('-- Please Select --'),
|
36 |
+
'description' => ''
|
37 |
+
);
|
38 |
+
}
|
39 |
+
foreach (Mage::getModel('widget/widget')->getWidgetsArray() as $data) {
|
40 |
+
$options[$data['type']] = array(
|
41 |
+
'value' => $data['type'],
|
42 |
+
'label' => $data['name'],
|
43 |
+
'description' => $data['description']
|
44 |
+
);
|
45 |
+
}
|
46 |
+
return $options;
|
47 |
+
}
|
48 |
+
|
49 |
+
public function toOptionHash($withBlank = true)
|
50 |
+
{
|
51 |
+
$options = array();
|
52 |
+
if ($withBlank) {
|
53 |
+
$options[''] = Mage::helper('formelements')->__('-- Please Select --');
|
54 |
+
}
|
55 |
+
foreach (Mage::getModel('widget/widget')->getWidgetsArray() as $data) {
|
56 |
+
$options[$data['type']] = $data['name'];
|
57 |
+
}
|
58 |
+
return $options;
|
59 |
+
}
|
60 |
+
}
|
app/code/community/Clockworkgeek/Formelements/Model/Template/Localdir.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* The MIT License (MIT)
|
4 |
+
*
|
5 |
+
* Copyright (c) 2015 Daniel Deady
|
6 |
+
*
|
7 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8 |
+
* of this software and associated documentation files (the "Software"), to deal
|
9 |
+
* in the Software without restriction, including without limitation the rights
|
10 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11 |
+
* copies of the Software, and to permit persons to whom the Software is
|
12 |
+
* furnished to do so, subject to the following conditions:
|
13 |
+
*
|
14 |
+
* The above copyright notice and this permission notice shall be included in all
|
15 |
+
* copies or substantial portions of the Software.
|
16 |
+
*
|
17 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23 |
+
* SOFTWARE.
|
24 |
+
*/
|
25 |
+
|
26 |
+
class Clockworkgeek_Formelements_Model_Template_localdir extends Mage_Core_Model_Email_Template_Filter
|
27 |
+
{
|
28 |
+
|
29 |
+
public function mediaDirective($construction)
|
30 |
+
{
|
31 |
+
$params = $this->_getIncludeParameters($construction[2]);
|
32 |
+
return Mage::getBaseDir('media') . DS . @$params['url'];
|
33 |
+
}
|
34 |
+
|
35 |
+
public function skinDirective($construction)
|
36 |
+
{
|
37 |
+
$skinUrl = parent::skinDirective($construction);
|
38 |
+
return str_replace(Mage::getBaseUrl(), Mage::getBaseDir().DS, $skinUrl);
|
39 |
+
}
|
40 |
+
}
|
app/code/community/Clockworkgeek/Formelements/etc/config.xml
ADDED
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!--
|
3 |
+
The MIT License (MIT)
|
4 |
+
|
5 |
+
Copyright (c) 2015 Daniel Deady
|
6 |
+
|
7 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
8 |
+
of this software and associated documentation files (the "Software"), to deal
|
9 |
+
in the Software without restriction, including without limitation the rights
|
10 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11 |
+
copies of the Software, and to permit persons to whom the Software is
|
12 |
+
furnished to do so, subject to the following conditions:
|
13 |
+
|
14 |
+
The above copyright notice and this permission notice shall be included in all
|
15 |
+
copies or substantial portions of the Software.
|
16 |
+
|
17 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23 |
+
SOFTWARE.
|
24 |
+
-->
|
25 |
+
<config>
|
26 |
+
<modules>
|
27 |
+
<Clockworkgeek_Formelements>
|
28 |
+
<version>0.0.0</version>
|
29 |
+
</Clockworkgeek_Formelements>
|
30 |
+
</modules>
|
31 |
+
|
32 |
+
<global>
|
33 |
+
<blocks>
|
34 |
+
<formelements>
|
35 |
+
<class>Clockworkgeek_Formelements_Block</class>
|
36 |
+
</formelements>
|
37 |
+
</blocks>
|
38 |
+
<helpers>
|
39 |
+
<formelements>
|
40 |
+
<class>Clockworkgeek_Formelements_Helper</class>
|
41 |
+
</formelements>
|
42 |
+
</helpers>
|
43 |
+
<models>
|
44 |
+
<formelements>
|
45 |
+
<class>Clockworkgeek_Formelements_Model</class>
|
46 |
+
</formelements>
|
47 |
+
</models>
|
48 |
+
</global>
|
49 |
+
|
50 |
+
<adminhtml>
|
51 |
+
<layout>
|
52 |
+
<updates>
|
53 |
+
<formelements>
|
54 |
+
<file>clockworkgeek/formelements.xml</file>
|
55 |
+
</formelements>
|
56 |
+
</updates>
|
57 |
+
</layout>
|
58 |
+
<events>
|
59 |
+
<adminhtml_product_attribute_types>
|
60 |
+
<observers>
|
61 |
+
<formelements>
|
62 |
+
<class>formelements/observer</class>
|
63 |
+
<method>addProductAttributeTypes</method>
|
64 |
+
<type>singleton</type>
|
65 |
+
</formelements>
|
66 |
+
</observers>
|
67 |
+
</adminhtml_product_attribute_types>
|
68 |
+
<adminhtml_catalog_product_edit_element_types>
|
69 |
+
<observers>
|
70 |
+
<formelements>
|
71 |
+
<class>formelements/observer</class>
|
72 |
+
<method>addProductAttributeElements</method>
|
73 |
+
<type>singleton</type>
|
74 |
+
</formelements>
|
75 |
+
</observers>
|
76 |
+
</adminhtml_catalog_product_edit_element_types>
|
77 |
+
<catalog_entity_attribute_save_before>
|
78 |
+
<observers>
|
79 |
+
<formelements>
|
80 |
+
<class>formelements/observer</class>
|
81 |
+
<method>setAttributeBackendType</method>
|
82 |
+
<type>singleton</type>
|
83 |
+
</formelements>
|
84 |
+
</observers>
|
85 |
+
</catalog_entity_attribute_save_before>
|
86 |
+
</events>
|
87 |
+
</adminhtml>
|
88 |
+
|
89 |
+
<frontend>
|
90 |
+
<events>
|
91 |
+
<catalog_helper_output_construct>
|
92 |
+
<observers>
|
93 |
+
<formelements>
|
94 |
+
<class>formelements/output</class>
|
95 |
+
<method>addProductAttributeHandlers</method>
|
96 |
+
<type>singleton</type>
|
97 |
+
</formelements>
|
98 |
+
</observers>
|
99 |
+
</catalog_helper_output_construct>
|
100 |
+
</events>
|
101 |
+
</frontend>
|
102 |
+
|
103 |
+
<default>
|
104 |
+
<general>
|
105 |
+
<validator_data>
|
106 |
+
<input_types>
|
107 |
+
<formelements_color>color</formelements_color>
|
108 |
+
<formelements_email>email</formelements_email>
|
109 |
+
<formelements_number>number</formelements_number>
|
110 |
+
<formelements_url>url</formelements_url>
|
111 |
+
<formelements_mediaurl>mediaurl</formelements_mediaurl>
|
112 |
+
<formelements_widget>widget</formelements_widget>
|
113 |
+
</input_types>
|
114 |
+
</validator_data>
|
115 |
+
</general>
|
116 |
+
</default>
|
117 |
+
</config>
|
app/design/adminhtml/default/default/layout/clockworkgeek/formelements.xml
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!--
|
3 |
+
The MIT License (MIT)
|
4 |
+
|
5 |
+
Copyright (c) 2015 Daniel Deady
|
6 |
+
|
7 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
8 |
+
of this software and associated documentation files (the "Software"), to deal
|
9 |
+
in the Software without restriction, including without limitation the rights
|
10 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11 |
+
copies of the Software, and to permit persons to whom the Software is
|
12 |
+
furnished to do so, subject to the following conditions:
|
13 |
+
|
14 |
+
The above copyright notice and this permission notice shall be included in all
|
15 |
+
copies or substantial portions of the Software.
|
16 |
+
|
17 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23 |
+
SOFTWARE.
|
24 |
+
-->
|
25 |
+
<layout>
|
26 |
+
<editor>
|
27 |
+
<reference name="head">
|
28 |
+
<action method="addJs"><script>clockworkgeek/formelements.js</script></action>
|
29 |
+
</reference>
|
30 |
+
</editor>
|
31 |
+
|
32 |
+
<adminhtml_widget_instance_edit>
|
33 |
+
<update handle="editor" />
|
34 |
+
<reference name="head">
|
35 |
+
<action method="setCanLoadTinyMce"><value>true</value></action>
|
36 |
+
</reference>
|
37 |
+
</adminhtml_widget_instance_edit>
|
38 |
+
</layout>
|
app/etc/modules/Clockworkgeek_Formelements.xml
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!--
|
3 |
+
The MIT License (MIT)
|
4 |
+
|
5 |
+
Copyright (c) 2015 Daniel Deady
|
6 |
+
|
7 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
8 |
+
of this software and associated documentation files (the "Software"), to deal
|
9 |
+
in the Software without restriction, including without limitation the rights
|
10 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11 |
+
copies of the Software, and to permit persons to whom the Software is
|
12 |
+
furnished to do so, subject to the following conditions:
|
13 |
+
|
14 |
+
The above copyright notice and this permission notice shall be included in all
|
15 |
+
copies or substantial portions of the Software.
|
16 |
+
|
17 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23 |
+
SOFTWARE.
|
24 |
+
-->
|
25 |
+
<config>
|
26 |
+
<modules>
|
27 |
+
<Clockworkgeek_Formelements>
|
28 |
+
<active>true</active>
|
29 |
+
<codePool>community</codePool>
|
30 |
+
</Clockworkgeek_Formelements>
|
31 |
+
</modules>
|
32 |
+
</config>
|
js/clockworkgeek/formelements.js
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
* The MIT License (MIT)
|
3 |
+
*
|
4 |
+
* Copyright (c) 2015 Daniel Deady
|
5 |
+
*
|
6 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
7 |
+
* of this software and associated documentation files (the "Software"), to deal
|
8 |
+
* in the Software without restriction, including without limitation the rights
|
9 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10 |
+
* copies of the Software, and to permit persons to whom the Software is
|
11 |
+
* furnished to do so, subject to the following conditions:
|
12 |
+
*
|
13 |
+
* The above copyright notice and this permission notice shall be included in all
|
14 |
+
* copies or substantial portions of the Software.
|
15 |
+
*
|
16 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22 |
+
* SOFTWARE.
|
23 |
+
*/
|
24 |
+
|
25 |
+
self.Validation && !Validation.methods['validate-color'] && Validation.add('validate-color', 'Please enter a CSS formatted color value.', function(v) {
|
26 |
+
return /^#[0-9a-zA-Z]{6}$/.test(v);
|
27 |
+
});
|
28 |
+
|
29 |
+
/*
|
30 |
+
* Check this input after media browser windows close and maybe parse a directive
|
31 |
+
*/
|
32 |
+
function watchMediaUrl(id, thumbnailUrl) {
|
33 |
+
Windows.addObserver({ onDestroy: function(name, event) {
|
34 |
+
if (event.element && event.element.id == 'browser_window') {
|
35 |
+
(function() {
|
36 |
+
var input = $(id),
|
37 |
+
value = $F(input),
|
38 |
+
directive = /\/___directive\/([-,\w]+)\//.exec(value);
|
39 |
+
if (directive && directive.length) {
|
40 |
+
directive = directive[1].replace(/-/g,'+').replace(/_/g,'/').replace(/,/g,'=');
|
41 |
+
value = atob(directive);
|
42 |
+
input.setValue(value);
|
43 |
+
}
|
44 |
+
var filename = /{{media url="wysiwyg\/([^"]+)"}}/.exec(value),
|
45 |
+
previewurl = thumbnailUrl && filename && (thumbnailUrl+'file/'+btoa(filename[1]).replace(/\+/g,'-').replace(/\//g,'_').replace(/=/g,','));
|
46 |
+
$(id+'_preview').innerHTML = previewurl ? '<img src="'+previewurl+'/" alt="'+filename[1]+'"/>' : '';
|
47 |
+
}).defer();
|
48 |
+
}
|
49 |
+
}});
|
50 |
+
}
|
51 |
+
|
52 |
+
function clearMediaUrl(id) {
|
53 |
+
Form.Element.setValue(id, '');
|
54 |
+
$(id+'_preview').innerHTML = '';
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* The following is copyright (c) 2011..2012 David Chambers <dc@hashify.me>
|
59 |
+
* @see https://github.com/davidchambers/Base64.js
|
60 |
+
*/
|
61 |
+
!function(){function t(t){this.message=t}var r="undefined"!=typeof exports?exports:this,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";t.prototype=new Error,t.prototype.name="InvalidCharacterError",r.btoa||(r.btoa=function(r){for(var o,n,a=String(r),i=0,c=e,d="";a.charAt(0|i)||(c="=",i%1);d+=c.charAt(63&o>>8-i%1*8)){if(n=a.charCodeAt(i+=.75),n>255)throw new t("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");o=o<<8|n}return d}),r.atob||(r.atob=function(r){var o=String(r).replace(/=+$/,"");if(o.length%4==1)throw new t("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,a,i=0,c=0,d="";a=o.charAt(c++);~a&&(n=i%4?64*n+a:a,i++%4)?d+=String.fromCharCode(255&n>>(-2*i&6)):0)a=e.indexOf(a);return d})}();
|
lib/Clockworkgeek/Data/Form.php
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* The MIT License (MIT)
|
4 |
+
*
|
5 |
+
* Copyright (c) 2015 Daniel Deady
|
6 |
+
*
|
7 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8 |
+
* of this software and associated documentation files (the "Software"), to deal
|
9 |
+
* in the Software without restriction, including without limitation the rights
|
10 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11 |
+
* copies of the Software, and to permit persons to whom the Software is
|
12 |
+
* furnished to do so, subject to the following conditions:
|
13 |
+
*
|
14 |
+
* The above copyright notice and this permission notice shall be included in all
|
15 |
+
* copies or substantial portions of the Software.
|
16 |
+
*
|
17 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23 |
+
* SOFTWARE.
|
24 |
+
*/
|
25 |
+
|
26 |
+
class Clockworkgeek_Data_Form extends Varien_Data_Form
|
27 |
+
{
|
28 |
+
|
29 |
+
protected function _construct()
|
30 |
+
{
|
31 |
+
parent::_construct();
|
32 |
+
$this->_updateTypes($this);
|
33 |
+
}
|
34 |
+
|
35 |
+
public function addElement(Varien_Data_Form_Element_Abstract $element, $after = null)
|
36 |
+
{
|
37 |
+
// only updates immediate children, what about nested fieldsets?
|
38 |
+
$this->_updateTypes($element);
|
39 |
+
return parent::addElement($element, $after);
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Force own types on $element
|
44 |
+
*
|
45 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
46 |
+
*/
|
47 |
+
protected function _updateTypes(Varien_Data_Form_Abstract $element)
|
48 |
+
{
|
49 |
+
$element->addType('color', 'Clockworkgeek_Data_Form_Element_Color');
|
50 |
+
$element->addType('email', 'Clockworkgeek_Data_Form_Element_Email');
|
51 |
+
$element->addType('mediaurl', 'Clockworkgeek_Data_Form_Element_Mediaurl');
|
52 |
+
$element->addType('number', 'Clockworkgeek_Data_Form_Element_Number');
|
53 |
+
$element->addType('url', 'Clockworkgeek_Data_Form_Element_Url');
|
54 |
+
$element->addType('widget', 'Clockworkgeek_Data_Form_Element_Widget');
|
55 |
+
}
|
56 |
+
}
|
lib/Clockworkgeek/Data/Form/Element/Color.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* The MIT License (MIT)
|
4 |
+
*
|
5 |
+
* Copyright (c) 2015 Daniel Deady
|
6 |
+
*
|
7 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8 |
+
* of this software and associated documentation files (the "Software"), to deal
|
9 |
+
* in the Software without restriction, including without limitation the rights
|
10 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11 |
+
* copies of the Software, and to permit persons to whom the Software is
|
12 |
+
* furnished to do so, subject to the following conditions:
|
13 |
+
*
|
14 |
+
* The above copyright notice and this permission notice shall be included in all
|
15 |
+
* copies or substantial portions of the Software.
|
16 |
+
*
|
17 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23 |
+
* SOFTWARE.
|
24 |
+
*/
|
25 |
+
|
26 |
+
class Clockworkgeek_Data_Form_Element_Color extends Varien_Data_Form_Element_Text
|
27 |
+
{
|
28 |
+
public function __construct($attributes=array())
|
29 |
+
{
|
30 |
+
parent::__construct($attributes);
|
31 |
+
$this->setType('color');
|
32 |
+
// set a pattern for modern browsers without a color control
|
33 |
+
$this->setPattern('^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$');
|
34 |
+
|
35 |
+
if (strpos($this->getClass(), 'validate-color') === false) {
|
36 |
+
$this->setClass($this->getClass().' validate-color');
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
public function getHtmlAttributes()
|
41 |
+
{
|
42 |
+
$attrs = parent::getHtmlAttributes();
|
43 |
+
$attrs[] = 'pattern';
|
44 |
+
return $attrs;
|
45 |
+
}
|
46 |
+
}
|
lib/Clockworkgeek/Data/Form/Element/Email.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* The MIT License (MIT)
|
4 |
+
*
|
5 |
+
* Copyright (c) 2015 Daniel Deady
|
6 |
+
*
|
7 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8 |
+
* of this software and associated documentation files (the "Software"), to deal
|
9 |
+
* in the Software without restriction, including without limitation the rights
|
10 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11 |
+
* copies of the Software, and to permit persons to whom the Software is
|
12 |
+
* furnished to do so, subject to the following conditions:
|
13 |
+
*
|
14 |
+
* The above copyright notice and this permission notice shall be included in all
|
15 |
+
* copies or substantial portions of the Software.
|
16 |
+
*
|
17 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23 |
+
* SOFTWARE.
|
24 |
+
*/
|
25 |
+
|
26 |
+
class Clockworkgeek_Data_Form_Element_Email extends Varien_Data_Form_Element_Text
|
27 |
+
{
|
28 |
+
public function __construct($attributes=array())
|
29 |
+
{
|
30 |
+
parent::__construct($attributes);
|
31 |
+
$this->setType('email');
|
32 |
+
|
33 |
+
if (strpos($this->getClass(), 'validate-email') === false) {
|
34 |
+
$this->setClass($this->getClass().' validate-email');
|
35 |
+
}
|
36 |
+
}
|
37 |
+
}
|
lib/Clockworkgeek/Data/Form/Element/Mediaurl.php
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* The MIT License (MIT)
|
4 |
+
*
|
5 |
+
* Copyright (c) 2015 Daniel Deady
|
6 |
+
*
|
7 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8 |
+
* of this software and associated documentation files (the "Software"), to deal
|
9 |
+
* in the Software without restriction, including without limitation the rights
|
10 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11 |
+
* copies of the Software, and to permit persons to whom the Software is
|
12 |
+
* furnished to do so, subject to the following conditions:
|
13 |
+
*
|
14 |
+
* The above copyright notice and this permission notice shall be included in all
|
15 |
+
* copies or substantial portions of the Software.
|
16 |
+
*
|
17 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23 |
+
* SOFTWARE.
|
24 |
+
*/
|
25 |
+
|
26 |
+
class Clockworkgeek_Data_Form_Element_Mediaurl
|
27 |
+
extends Varien_Data_Form_Element_Abstract
|
28 |
+
{
|
29 |
+
|
30 |
+
public function __construct($attributes = array())
|
31 |
+
{
|
32 |
+
parent::__construct($attributes);
|
33 |
+
// needs anything in ext_type to enable "Use Default Value" checkbox
|
34 |
+
$this->setExtType('image');
|
35 |
+
}
|
36 |
+
|
37 |
+
public function getElementHtml()
|
38 |
+
{
|
39 |
+
$url = Mage::getSingleton('adminhtml/url')->getUrl(
|
40 |
+
'adminhtml/cms_wysiwyg_images/index', array(
|
41 |
+
'target_element_id' => $this->getHtmlId()
|
42 |
+
)
|
43 |
+
);
|
44 |
+
$thumbnailUrl = Mage::getUrl('adminhtml/cms_wysiwyg_images/thumbnail');
|
45 |
+
$helper = Mage::helper('formelements');
|
46 |
+
|
47 |
+
$htmlId = $this->getHtmlId();
|
48 |
+
$html = "<input id='{$htmlId}' name='{$this->getName()}' value='{$this->getEscapedValue()}' type='hidden' />";
|
49 |
+
|
50 |
+
$browseLabel = $helper->__('Set Image...');
|
51 |
+
$disabled = $this->getReadonly() || $this->getDisabled() ? ' disabled' : '';
|
52 |
+
$disabledAttr = $disabled ? ' disabled="disabled"' : '';
|
53 |
+
$html .= "<button class='add-image{$disabled}' style='margin:0 5px 5px 0;' onclick=\"MediabrowserUtility.openDialog('{$url}', false, false, '{$browseLabel}'); return false;\"{$disabledAttr}><span>{$browseLabel}</span></button>";
|
54 |
+
|
55 |
+
$removeLabel = $helper->__('Clear Image');
|
56 |
+
$html .= "<button class='delete{$disabled}' onclick=\"clearMediaUrl('{$htmlId}'); return false;\"{$disabledAttr}><span>{$removeLabel}</span></button>";
|
57 |
+
|
58 |
+
$html .= "<div id='{$this->getHtmlId()}_preview'>";
|
59 |
+
if (preg_match('/{{media url="wysiwyg\/([^"]+)"}}/', $this->getValue(), $match)) {
|
60 |
+
$previewUrl = Mage::getUrl(
|
61 |
+
'adminhtml/cms_wysiwyg_images/thumbnail',
|
62 |
+
array(
|
63 |
+
'file' => $helper->urlEncode($match[1])
|
64 |
+
)
|
65 |
+
);
|
66 |
+
$html .= "<img src='{$previewUrl}' alt='{$match[1]}' />";
|
67 |
+
}
|
68 |
+
$html .= "</div>";
|
69 |
+
$html .= "<script type='text/javascript'>watchMediaUrl('{$htmlId}', '{$thumbnailUrl}');</script>";
|
70 |
+
return $html;
|
71 |
+
}
|
72 |
+
}
|
lib/Clockworkgeek/Data/Form/Element/Number.php
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* The MIT License (MIT)
|
4 |
+
*
|
5 |
+
* Copyright (c) 2015 Daniel Deady
|
6 |
+
*
|
7 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8 |
+
* of this software and associated documentation files (the "Software"), to deal
|
9 |
+
* in the Software without restriction, including without limitation the rights
|
10 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11 |
+
* copies of the Software, and to permit persons to whom the Software is
|
12 |
+
* furnished to do so, subject to the following conditions:
|
13 |
+
*
|
14 |
+
* The above copyright notice and this permission notice shall be included in all
|
15 |
+
* copies or substantial portions of the Software.
|
16 |
+
*
|
17 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23 |
+
* SOFTWARE.
|
24 |
+
*/
|
25 |
+
|
26 |
+
class Clockworkgeek_Data_Form_Element_Number extends Varien_Data_Form_Element_Text
|
27 |
+
{
|
28 |
+
public function __construct($attributes=array())
|
29 |
+
{
|
30 |
+
if (isset($attributes['required']) && ! $attributes['required']) {
|
31 |
+
unset($attributes['required']);
|
32 |
+
}
|
33 |
+
parent::__construct($attributes);
|
34 |
+
$this->setType('number');
|
35 |
+
$this->setPattern('[-+]?[0-9]*[.,]?[0-9]+');
|
36 |
+
// change appearance because firefox is fugly
|
37 |
+
$this->setStyle('-moz-appearance:textfield;width:110px;'.$this->getStyle());
|
38 |
+
|
39 |
+
if (strpos($this->getClass(), 'validate-number') === false) {
|
40 |
+
$this->setClass($this->getClass().' validate-number');
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
public function getHtmlAttributes()
|
45 |
+
{
|
46 |
+
$attrs = parent::getHtmlAttributes();
|
47 |
+
$attrs[] = 'min';
|
48 |
+
$attrs[] = 'max';
|
49 |
+
$attrs[] = 'pattern';
|
50 |
+
$attrs[] = 'required';
|
51 |
+
$attrs[] = 'step';
|
52 |
+
return $attrs;
|
53 |
+
}
|
54 |
+
}
|
lib/Clockworkgeek/Data/Form/Element/Url.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* The MIT License (MIT)
|
4 |
+
*
|
5 |
+
* Copyright (c) 2015 Daniel Deady
|
6 |
+
*
|
7 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8 |
+
* of this software and associated documentation files (the "Software"), to deal
|
9 |
+
* in the Software without restriction, including without limitation the rights
|
10 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11 |
+
* copies of the Software, and to permit persons to whom the Software is
|
12 |
+
* furnished to do so, subject to the following conditions:
|
13 |
+
*
|
14 |
+
* The above copyright notice and this permission notice shall be included in all
|
15 |
+
* copies or substantial portions of the Software.
|
16 |
+
*
|
17 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23 |
+
* SOFTWARE.
|
24 |
+
*/
|
25 |
+
|
26 |
+
class Clockworkgeek_Data_Form_Element_Url extends Varien_Data_Form_Element_Text
|
27 |
+
{
|
28 |
+
public function __construct($attributes=array())
|
29 |
+
{
|
30 |
+
parent::__construct($attributes);
|
31 |
+
$this->setType('url');
|
32 |
+
|
33 |
+
if (strpos($this->getClass(), 'validate-url') === false) {
|
34 |
+
$this->setClass($this->getClass().' validate-url');
|
35 |
+
}
|
36 |
+
}
|
37 |
+
}
|
lib/Clockworkgeek/Data/Form/Element/Widget.php
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* The MIT License (MIT)
|
4 |
+
*
|
5 |
+
* Copyright (c) 2015 Daniel Deady
|
6 |
+
*
|
7 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8 |
+
* of this software and associated documentation files (the "Software"), to deal
|
9 |
+
* in the Software without restriction, including without limitation the rights
|
10 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11 |
+
* copies of the Software, and to permit persons to whom the Software is
|
12 |
+
* furnished to do so, subject to the following conditions:
|
13 |
+
*
|
14 |
+
* The above copyright notice and this permission notice shall be included in all
|
15 |
+
* copies or substantial portions of the Software.
|
16 |
+
*
|
17 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23 |
+
* SOFTWARE.
|
24 |
+
*/
|
25 |
+
|
26 |
+
class Clockworkgeek_Data_Form_Element_Widget
|
27 |
+
extends Varien_Data_Form_Element_Abstract
|
28 |
+
{
|
29 |
+
|
30 |
+
public function getElementHtml()
|
31 |
+
{
|
32 |
+
$params = $this->getValueParameters();
|
33 |
+
|
34 |
+
$html = '<input id="'.$this->getHtmlId().'" name="'.$this->getName()
|
35 |
+
.'" value="'.$this->getEscapedValue().'" type="hidden"/>'."\n";
|
36 |
+
|
37 |
+
/* @var $typeForm Clockworkgeek_Formelements_Block_Adminhtml_Widget_Form */
|
38 |
+
$typeForm = Mage::app()->getLayout()->createBlock('formelements/adminhtml_widget_form');
|
39 |
+
$typeForm->setDisabled($this->getDisabled());
|
40 |
+
$typeForm->setId($this->getId());
|
41 |
+
$typeForm->setRequired($this->getRequired());
|
42 |
+
$typeForm->setWidgetType(@$params['type']);
|
43 |
+
if ($this->getForm()) {
|
44 |
+
$typeForm->setFieldNameSuffix($this->getForm()->getFieldNameSuffix());
|
45 |
+
}
|
46 |
+
$html .= $typeForm->toHtml();
|
47 |
+
|
48 |
+
$optionsHtml = $this->_getWidgetOptionshtml();
|
49 |
+
$html .= "<div id='{$this->getHtmlId()}_options'>{$optionsHtml}</div>";
|
50 |
+
return $html . $this->getAfterElementHtml();
|
51 |
+
}
|
52 |
+
|
53 |
+
public function getValueParameters()
|
54 |
+
{
|
55 |
+
if (preg_match('/{{widget(.*?)}}/si', $this->getValue(), $directive)) {
|
56 |
+
$tokenizer = new Varien_Filter_Template_Tokenizer_Parameter();
|
57 |
+
$tokenizer->setString($directive[1]);
|
58 |
+
return $tokenizer->tokenize();
|
59 |
+
}
|
60 |
+
return array();
|
61 |
+
}
|
62 |
+
|
63 |
+
protected function _getWidgetOptionsHtml()
|
64 |
+
{
|
65 |
+
$params = $this->getValueParameters();
|
66 |
+
|
67 |
+
if (isset($params['type'])) {
|
68 |
+
/* @var $options Clockworkgeek_Formelements_Block_Adminhtml_Widget_Options */
|
69 |
+
$options = Mage::app()->getLayout()->createBlock('formelements/adminhtml_widget_options');
|
70 |
+
$options->setDisabled($this->getDisabled());
|
71 |
+
$options->setWidgetType($params['type']);
|
72 |
+
$options->setWidgetValues($params);
|
73 |
+
$optionsId = $this->getHtmlId().'_options_'.strtr($params['type'], '/', '_');
|
74 |
+
return "<div id='{$optionsId}'>{$options->toHtml()}</div>";
|
75 |
+
}
|
76 |
+
return '';
|
77 |
+
}
|
78 |
+
}
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Clockworkgeek_Formelements</name>
|
4 |
+
<version>0.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://opensource.org/licenses/MIT">MIT</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Adds HTML5 input types and some WYSIWYG features to admin forms and product attributes.</summary>
|
10 |
+
<description/>
|
11 |
+
<notes>Initial release</notes>
|
12 |
+
<authors><author><name>Daniel Deady</name><user>daniel</user><email>daniel@clockworkgeek.com</email></author></authors>
|
13 |
+
<date>2015-05-17</date>
|
14 |
+
<time>10:23:23</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Clockworkgeek"><dir name="Formelements"><dir name="Block"><dir name="Adminhtml"><dir name="Renderer"><dir name="Fieldset"><dir name="Element"><file name="Abstract.php" hash="fcb87610344dcaaf1d5b7472fd12fb88"/><file name="Color.php" hash="a62592752f245b28b1edefd9cf3ab678"/><file name="Editor.php" hash="ff726c9d994eca4c45902e6ded651fca"/><file name="Email.php" hash="932e9002350f432418a7aa961596ca11"/><file name="Mediaurl.php" hash="6274a42b50b6e973f9f8a060cde3e4d6"/><file name="Number.php" hash="8bd61667ecee85a9e821e013c778d17c"/><file name="Url.php" hash="748108425cec1604a27db82ce61d5034"/></dir></dir></dir><dir name="Widget"><file name="Form.php" hash="2ff551578385ed3a268b793bf3ef60ae"/><file name="Options.php" hash="3d9eba1e10f9bbd33d6355c6981c1184"/></dir></dir><file name="Template.php" hash="4bce8d292f15ef1008388396a633b201"/></dir><dir name="Helper"><file name="Data.php" hash="776dc228a0104cbc39850a1579a35c40"/></dir><file name="LICENSE" hash="6a0a6168ec4c6f2fd63a98ee0b4266be"/><dir name="Model"><file name="Observer.php" hash="9d5d2cfe99e753e3972789b1baf8db0b"/><file name="Output.php" hash="a219817107f3a994c992de29440409e4"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Widgettypes.php" hash="2afcc16654ada4441cefd49cf9d8bec2"/></dir></dir></dir><dir name="Template"><file name="Localdir.php" hash="3feb48665f36f2d06ce48da510fe2c48"/></dir></dir><dir name="etc"><file name="config.xml" hash="3c3364d3cea9e35408d857e472de63b1"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="clockworkgeek"><file name="formelements.xml" hash="4b13837b595e776cd603de0ac90e6c21"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Clockworkgeek_Formelements.xml" hash="bbb30c78696151b42a20ac9f66f3e77e"/></dir></target><target name="mageweb"><dir name="js"><dir name="clockworkgeek"><file name="formelements.js" hash="fd883b965ef815e6db8d6e72dd7565e9"/></dir></dir></target><target name="magelib"><dir name="Clockworkgeek"><dir name="Data"><file name="Form.php" hash="b2ccf7bb02363831e1ef802ef9208c2a"/><dir name="Form"><dir name="Element"><file name="Color.php" hash="f5f2edf28f5852224d356b0c8093f101"/><file name="Email.php" hash="c47537a9d44fa5492b4e4e132c7270a0"/><file name="Mediaurl.php" hash="2d7fde9858ae64baa551f82669c819c2"/><file name="Number.php" hash="6d3f8a188d6f316a224c72771fe50f4a"/><file name="Url.php" hash="a4bedba54b8ea66e6f919478de2e3c98"/><file name="Widget.php" hash="a8dc73d26b7e988a488889c7590cc767"/></dir></dir></dir></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
+
</package>
|