--- /dev/null
+<?php
+
+class IPF_Admin_Form_Field_Html extends IPF_Form_Field_Varchar
+{
+ public $widget = 'IPF_Admin_Form_Widget_HTMLInput';
+}
+
--- /dev/null
+<?php
+
+class IPF_Admin_Form_Field_OrderedSet extends IPF_Form_Field_Set
+{
+ public $widget = 'IPF_Admin_Form_Widget_OrderedSetTable';
+ public $orderBy;
+
+ public function clean($value)
+ {
+ if (!$value)
+ return $value;
+
+ $reorder = \PFF\Arr::pop($value, 'reorder');
+ $value = parent::clean($value);
+ $value['reorder'] = $reorder;
+
+ return $value;
+ }
+
+ protected function createWidget($args)
+ {
+ $args['orderBy'] = $this->orderBy;
+ return parent::createWidget($args);
+ }
+}
+
--- /dev/null
+<?php
+
+use \PFF\HtmlBuilder\Tag as Tag;
+
+class IPF_Admin_Form_Layout extends IPF_Form_LayoutAdapter
+{
+ public function startForm($form)
+ {
+ $errors = $this->commonErrors($form);
+ return $this->errors($errors) .
+ $this->hiddenWidgets($form);
+ }
+
+ public function startGroup($label)
+ {
+ if ($label)
+ return Tag::div(array('class' => 'form-group-title'), $label)->html();
+ else
+ return '';
+ }
+
+ public function field($boundField, $errors)
+ {
+ if ($boundField->help_text) {
+ $help_text = Tag::p(array('class' => 'help'))
+ ->raw($boundField->help_text);
+ } else {
+ $help_text = '';
+ }
+
+ if ($boundField->field instanceof IPF_Form_Field_Set) {
+ return $this->errors($errors) .
+ Tag::div()
+ ->raw($boundField->renderWidget())
+ ->append($help_text);
+ } else {
+ return $this->errors($errors) .
+ Tag::div(array('class' => 'form-row'))
+ ->raw($boundField->renderLabel())
+ ->append(Tag::div()
+ ->raw($boundField->renderWidget())
+ ->append($help_text));
+ }
+ }
+
+ private function errors($errors)
+ {
+ if (!count($errors))
+ return '';
+
+ $ul = Tag::ul(array('class' => 'errorlist'));
+ foreach ($errors as $err)
+ $ul->append(Tag::li(null, $err->message));
+ return Tag::div(array('class' => 'form-row'), $ul);
+ }
+}
+
--- /dev/null
+<?php
+
+use \PFF\HtmlBuilder\Tag as Tag;
+
+class IPF_Admin_Form_Widget_HTMLInput extends IPF_Form_Widget
+{
+ public $tinymce_url;
+ public $force_absolute_urls;
+ public $editor_config;
+
+ public function __construct($attrs=array())
+ {
+ $this->tinymce_url = \PFF\Arr::pop($attrs, 'tinymce_url',
+ IPF::get('tiny_mce_url',
+ IPF::get('static_url').'admin/tinymce/'));
+
+ $this->force_absolute_urls = \PFF\Arr::pop($attrs, 'force_absolute_urls', false);
+ $this->editor_config = \PFF\Arr::pop($attrs, 'editor_config', array());
+
+ parent::__construct($attrs);
+ }
+
+ public function render($name, $value, $extra_attrs=array())
+ {
+ if ($value === null) $value = '';
+
+ $extra_config = '';
+ foreach ($this->editor_config as $key => $val) {
+ $extra_config .= ",\n{$key} : ";
+ if (is_bool($val)) {
+ $extra_config .= $val ? 'true' : 'false';
+ } else {
+ $extra_config .= '"'.$val.'"';
+ }
+ }
+
+ return Tag::textarea()
+ ->attr('cols', 70)
+ ->attr('rows', 20)
+ ->attrs($this->attrs)
+ ->attrs($extra_attrs)
+ ->attr('name', $name)
+ ->addClass($this->force_absolute_urls ? 'htmlEditorAbs' : 'htmlEditor')
+ ->append($value)
+ ->html();
+ }
+
+ public function extra_js()
+ {
+ $filebrowser_url = IPF_HTTP_URL::urlForView('IPF_Admin_Views_FileBrowser', array('/'));
+ return array(
+ '<script type="text/javascript" src="'.$this->tinymce_url.'tinymce.min.js"></script>',
+ '<script type="text/javascript">(function(){
+function ipf_filebrowser(field_name, url, type, win) {
+ tinyMCE.activeEditor.windowManager.open({
+ file: "'.$filebrowser_url.'/",
+ title: "IPF File Browser",
+ width: 800,
+ height: 600,
+ resizable: "yes",
+ inline: "yes",
+ close_previous: "no"
+ }, {
+ onSelect: function(value) {
+ var input = win.document.getElementById(field_name);
+
+ input.value = value;
+ if ("createEvent" in document) {
+ var evt = document.createEvent("HTMLEvents");
+ evt.initEvent("change", false, true);
+ input.dispatchEvent(evt);
+ } else {
+ input.fireEvent("onchange");
+ }
+ }
+ });
+ return false;
+}
+
+var defaults = {
+ plugins: "anchor, charmap, code, colorpicker, contextmenu, fullscreen, hr, image, insertdatetime, link, lists, media, nonbreaking, paste, preview, print, searchreplace, tabfocus, table, textcolor, visualchars, wordcount",
+ toolbar: [
+ "undo redo | styleselect | bold italic underline | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | forecolor backcolor sub sup | preview fullscreen",
+ "code link unlink image charmap | table | pastetext removeformat | formatselect fontselect fontsizeselect"
+ ],
+ extended_valid_elements: "span[class|style],code[class],iframe[src|width|height|name|align|frameborder|scrolling]",
+ fix_list_elements: true,
+ browser_spellcheck: true,
+ width: "80%",
+ height: "300",
+ document_base_url: "/",
+ file_browser_callback: ipf_filebrowser
+};
+
+tinyMCE.init($.extend({}, defaults, {
+ selector: ".htmlEditor",
+ convert_urls: false,
+ relative_urls: false,
+ remove_script_host: true
+}));
+
+tinyMCE.init($.extend({}, defaults, {
+ selector: ".htmlEditorAbs",
+ convert_urls: true,
+ relative_urls: false,
+ remove_script_host: false
+}));
+
+})();</script>',
+ );
+ }
+}
+
--- /dev/null
+<?php
+
+use \PFF\HtmlBuilder\Tag as Tag;
+
+class IPF_Admin_Form_Widget_OrderedSetTable extends IPF_Form_Widget_SetTable
+{
+ public $orderBy;
+
+ public function __construct($attrs=array())
+ {
+ $this->orderBy = \PFF\Arr::pop($attrs, 'orderBy');
+ parent::__construct($attrs);
+ }
+
+ public function render($name, $value, $extra_attrs=array())
+ {
+ if (array_key_exists('class', $extra_attrs))
+ $extra_attrs['class'] .= ' orderable-set-table';
+ else
+ $extra_attrs['class'] = 'orderable-set-table';
+
+ $extra_attrs['data-reorder'] = $name.'[reorder]';
+
+ return parent::render($name, $value, $extra_attrs);
+ }
+
+ protected function renderRow($prefix, $obj, $errors, $index)
+ {
+ $tr = parent::renderRow($prefix, $obj, $errors, $index);
+
+ if (array_key_exists('id', $obj))
+ $tr->attr('data-id', $obj['id']);
+ else
+ $tr->addClass('nodrag')->addClass('nodrop');
+
+ return $tr;
+ }
+
+ public function extra_js()
+ {
+ $js = parent::extra_js();
+
+ $js[] = '<script src="'.IPF::get('static_url').'admin/js/jquery.tablednd.js"></script>';
+ $js[] = '<script>
+$(function(){
+ $(\'.orderable-set-table\').each(function(){
+ var $table = $(this), $form = $table.closest("form"), reorder = $table.data("reorder");
+ $table.tableDnD({
+ onDragClass: "ItemsDragClass",
+ onDrop: function(table, row) {
+ var i;
+ $form.find("[name=\'"+reorder+"[]\']").remove();
+ $table.find(\'tr[data-id]\').each(function(){
+ i = $("<input/>").attr("type", "hidden").attr("name", reorder+"[]").attr("value", $(this).data(\'id\'));
+ $form.append(i);
+ });
+ }
+ });
+ });
+});
+</script>';
+ return $js;
+ }
+
+ public function valueFromFormData($name, $data)
+ {
+ if (!isset($data[$name]))
+ return null;
+
+ $value = $data[$name];
+ $reorder = \PFF\Arr::pop($value, 'reorder');
+ $data[$name] = $value;
+
+ $value = parent::valueFromFormData($name, $data);
+ $value['reorder'] = $reorder;
+
+ return $value;
+ }
+}
+
+++ /dev/null
-<?php
-
-use \PFF\HtmlBuilder\Tag as Tag;
-
-class IPF_Admin_Form_Layout extends IPF_Form_LayoutAdapter
-{
- public function startForm($form)
- {
- $errors = $this->commonErrors($form);
- return $this->errors($errors) .
- $this->hiddenWidgets($form);
- }
-
- public function startGroup($label)
- {
- if ($label)
- return Tag::div(array('class' => 'form-group-title'), $label)->html();
- else
- return '';
- }
-
- public function field($boundField, $errors)
- {
- if ($boundField->help_text) {
- $help_text = Tag::p(array('class' => 'help'))
- ->raw($boundField->help_text);
- } else {
- $help_text = '';
- }
-
- if ($boundField->field instanceof IPF_Form_Field_Set) {
- return $this->errors($errors) .
- Tag::div()
- ->raw($boundField->renderWidget())
- ->append($help_text);
- } else {
- return $this->errors($errors) .
- Tag::div(array('class' => 'form-row'))
- ->raw($boundField->renderLabel())
- ->append(Tag::div()
- ->raw($boundField->renderWidget())
- ->append($help_text));
- }
- }
-
- private function errors($errors)
- {
- if (!count($errors))
- return '';
-
- $ul = Tag::ul(array('class' => 'errorlist'));
- foreach ($errors as $err)
- $ul->append(Tag::li(null, $err->message));
- return Tag::div(array('class' => 'form-row'), $ul);
- }
-}
-
+++ /dev/null
-<?php
-
-class IPF_Form_Field_Html extends IPF_Form_Field_Varchar
-{
- public $widget = 'IPF_Form_Widget_HTMLInput';
-}
-
+++ /dev/null
-<?php
-
-class IPF_Form_Field_OrderedSet extends IPF_Form_Field_Set
-{
- public $widget = 'IPF_Form_Widget_OrderedSetTable';
- public $orderBy;
-
- public function clean($value)
- {
- if (!$value)
- return $value;
-
- $reorder = \PFF\Arr::pop($value, 'reorder');
- $value = parent::clean($value);
- $value['reorder'] = $reorder;
-
- return $value;
- }
-
- protected function createWidget($args)
- {
- $args['orderBy'] = $this->orderBy;
- return parent::createWidget($args);
- }
-}
-
protected function createWidget($args)
{
- if ($this->max_length > 255 && $this->widget !== 'IPF_Form_Widget_HTMLInput') {
+ if ($this->max_length > 255 && $this->widget === 'IPF_Form_Widget_TextInput') {
$widgetClass = 'IPF_Form_Widget_TextareaInput';
} else {
$widgetClass = $this->widget;
+++ /dev/null
-<?php
-
-use \PFF\HtmlBuilder\Tag as Tag;
-
-class IPF_Form_Widget_HTMLInput extends IPF_Form_Widget
-{
- public $tinymce_url;
- public $force_absolute_urls;
- public $editor_config;
-
- public function __construct($attrs=array())
- {
- $this->tinymce_url = \PFF\Arr::pop($attrs, 'tinymce_url',
- IPF::get('tiny_mce_url',
- IPF::get('static_url').'admin/tinymce/'));
-
- $this->force_absolute_urls = \PFF\Arr::pop($attrs, 'force_absolute_urls', false);
- $this->editor_config = \PFF\Arr::pop($attrs, 'editor_config', array());
-
- parent::__construct($attrs);
- }
-
- public function render($name, $value, $extra_attrs=array())
- {
- if ($value === null) $value = '';
-
- $extra_config = '';
- foreach ($this->editor_config as $key => $val) {
- $extra_config .= ",\n{$key} : ";
- if (is_bool($val)) {
- $extra_config .= $val ? 'true' : 'false';
- } else {
- $extra_config .= '"'.$val.'"';
- }
- }
-
- return Tag::textarea()
- ->attr('cols', 70)
- ->attr('rows', 20)
- ->attrs($this->attrs)
- ->attrs($extra_attrs)
- ->attr('name', $name)
- ->addClass($this->force_absolute_urls ? 'htmlEditorAbs' : 'htmlEditor')
- ->append($value)
- ->html();
- }
-
- public function extra_js()
- {
- $filebrowser_url = IPF_HTTP_URL::urlForView('IPF_Admin_Views_FileBrowser', array('/'));
- return array(
- '<script type="text/javascript" src="'.$this->tinymce_url.'tinymce.min.js"></script>',
- '<script type="text/javascript">(function(){
-function ipf_filebrowser(field_name, url, type, win) {
- tinyMCE.activeEditor.windowManager.open({
- file: "'.$filebrowser_url.'/",
- title: "IPF File Browser",
- width: 800,
- height: 600,
- resizable: "yes",
- inline: "yes",
- close_previous: "no"
- }, {
- onSelect: function(value) {
- var input = win.document.getElementById(field_name);
-
- input.value = value;
- if ("createEvent" in document) {
- var evt = document.createEvent("HTMLEvents");
- evt.initEvent("change", false, true);
- input.dispatchEvent(evt);
- } else {
- input.fireEvent("onchange");
- }
- }
- });
- return false;
-}
-
-var defaults = {
- plugins: "anchor, charmap, code, colorpicker, contextmenu, fullscreen, hr, image, insertdatetime, link, lists, media, nonbreaking, paste, preview, print, searchreplace, tabfocus, table, textcolor, visualchars, wordcount",
- toolbar: [
- "undo redo | styleselect | bold italic underline | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | forecolor backcolor sub sup | preview fullscreen",
- "code link unlink image charmap | table | pastetext removeformat | formatselect fontselect fontsizeselect"
- ],
- extended_valid_elements: "span[class|style],code[class],iframe[src|width|height|name|align|frameborder|scrolling]",
- fix_list_elements: true,
- browser_spellcheck: true,
- width: "80%",
- height: "300",
- document_base_url: "/",
- file_browser_callback: ipf_filebrowser
-};
-
-tinyMCE.init($.extend({}, defaults, {
- selector: ".htmlEditor",
- convert_urls: false,
- relative_urls: false,
- remove_script_host: true
-}));
-
-tinyMCE.init($.extend({}, defaults, {
- selector: ".htmlEditorAbs",
- convert_urls: true,
- relative_urls: false,
- remove_script_host: false
-}));
-
-})();</script>',
- );
- }
-}
-
+++ /dev/null
-<?php
-
-use \PFF\HtmlBuilder\Tag as Tag;
-
-class IPF_Form_Widget_OrderedSetTable extends IPF_Form_Widget_SetTable
-{
- public $orderBy;
-
- public function __construct($attrs=array())
- {
- $this->orderBy = \PFF\Arr::pop($attrs, 'orderBy');
- parent::__construct($attrs);
- }
-
- public function render($name, $value, $extra_attrs=array())
- {
- if (array_key_exists('class', $extra_attrs))
- $extra_attrs['class'] .= ' orderable-set-table';
- else
- $extra_attrs['class'] = 'orderable-set-table';
-
- $extra_attrs['data-reorder'] = $name.'[reorder]';
-
- return parent::render($name, $value, $extra_attrs);
- }
-
- protected function renderRow($prefix, $obj, $errors, $index)
- {
- $tr = parent::renderRow($prefix, $obj, $errors, $index);
-
- if (array_key_exists('id', $obj))
- $tr->attr('data-id', $obj['id']);
- else
- $tr->addClass('nodrag')->addClass('nodrop');
-
- return $tr;
- }
-
- public function extra_js()
- {
- $js = parent::extra_js();
-
- $js[] = '<script src="'.IPF::get('static_url').'admin/js/jquery.tablednd.js"></script>';
- $js[] = '<script>
-$(function(){
- $(\'.orderable-set-table\').each(function(){
- var $table = $(this), $form = $table.closest("form"), reorder = $table.data("reorder");
- $table.tableDnD({
- onDragClass: "ItemsDragClass",
- onDrop: function(table, row) {
- var i;
- $form.find("[name=\'"+reorder+"[]\']").remove();
- $table.find(\'tr[data-id]\').each(function(){
- i = $("<input/>").attr("type", "hidden").attr("name", reorder+"[]").attr("value", $(this).data(\'id\'));
- $form.append(i);
- });
- }
- });
- });
-});
-</script>';
- return $js;
- }
-
- public function valueFromFormData($name, $data)
- {
- if (!isset($data[$name]))
- return null;
-
- $value = $data[$name];
- $reorder = \PFF\Arr::pop($value, 'reorder');
- $data[$name] = $value;
-
- $value = parent::valueFromFormData($name, $data);
- $value['reorder'] = $reorder;
-
- return $value;
- }
-}
-