当前位置: 首页>>代码示例>>PHP>>正文


PHP FlexicontentFields::createCalendarField方法代码示例

本文整理汇总了PHP中FlexicontentFields::createCalendarField方法的典型用法代码示例。如果您正苦于以下问题:PHP FlexicontentFields::createCalendarField方法的具体用法?PHP FlexicontentFields::createCalendarField怎么用?PHP FlexicontentFields::createCalendarField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FlexicontentFields的用法示例。


在下文中一共展示了FlexicontentFields::createCalendarField方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createFilter


//.........这里部分代码省略.........
                 $extra_param = ' data-fc_label_text="' . flexicontent_html::escapeJsText($_inner_lb, 's') . '"';
                 $extra_param .= ' fc_prompt_text="' . flexicontent_html::escapeJsText(JText::_('FLEXI_TYPE_TO_FILTER'), 's') . '"';
             }
             // Create HTML tag attributes
             $attribs_str = ' class="fc_field_filter' . $classes . '" ' . $extra_param;
             $attribs_str .= $display_filter_as == 6 ? ' multiple="multiple" size="20" ' : '';
             //$attribs_str .= ($display_filter_as==0 || $display_filter_as==6) ? ' onchange="document.getElementById(\''.$formName.'\').submit();"' : '';
             foreach ($results as $result) {
                 if (!strlen($result->value)) {
                     continue;
                 }
                 $options[] = JHTML::_('select.option', $result->value, $result->text, 'value', 'text', $disabled = $faceted_filter == 2 && !$result->found);
             }
             if ($display_filter_as == 6 && $combine_tip) {
                 $filter->html .= ' <span class="fc_filter_tip_inline">' . JText::_(!$require_all ? 'FLEXI_ANY_OF' : 'FLEXI_ALL_OF') . '</span> ';
             }
             if ($display_filter_as == 0 || $display_filter_as == 6) {
                 $filter->html .= JHTML::_('select.genericlist', $options, $filter_ffname . '[]', $attribs_str, 'value', 'text', $value, $filter_ffid);
             } else {
                 $filter->html .= JHTML::_('select.genericlist', $options, $filter_ffname . '[1]', $attribs_str, 'value', 'text', @$value[1], $filter_ffid . '1');
                 $filter->html .= '<span class="fc_range"></span>';
                 $filter->html .= JHTML::_('select.genericlist', $options, $filter_ffname . '[2]', $attribs_str, 'value', 'text', @$value[2], $filter_ffid . '2');
             }
             break;
         case 1:
         case 3:
             // (TODO: autocomplete) ... 1: Text input, 3: Dual text input (value range), both of these can be JS date calendars
             $_inner_lb = $label_filter == 2 ? $filter->label : JText::_($isdate ? 'FLEXI_CLICK_CALENDAR' : 'FLEXI_TYPE_TO_LIST');
             $_inner_lb = flexicontent_html::escapeJsText($_inner_lb, 's');
             $attribs_str = ' class="fc_field_filter fc_label_internal fc_iscalendar" data-fc_label_text="' . $_inner_lb . '"';
             $attribs_arr = array('class' => 'fc_field_filter fc_label_internal fc_iscalendar', 'data-fc_label_text' => $_inner_lb);
             if ($display_filter_as == 1) {
                 if ($isdate) {
                     $filter->html .= FlexicontentFields::createCalendarField($value, $allowtime = 0, $filter_ffname, $filter_ffid, $attribs_arr);
                 } else {
                     $filter->html .= '<input id="' . $filter_ffid . '" name="' . $filter_ffname . '" ' . $attribs_str . ' type="text" size="' . $size . '" value="' . @$value . '" />';
                 }
             } else {
                 if ($isdate) {
                     $filter->html .= '<span class="fc_filter_element">';
                     $filter->html .= FlexicontentFields::createCalendarField(@$value[1], $allowtime = 0, $filter_ffname . '[1]', $filter_ffid . '1', $attribs_arr);
                     $filter->html .= '</span>';
                     $filter->html .= '<span class="fc_range"></span>';
                     $filter->html .= '<span class="fc_filter_element">';
                     $filter->html .= FlexicontentFields::createCalendarField(@$value[2], $allowtime = 0, $filter_ffname . '[2]', $filter_ffid . '2', $attribs_arr);
                     $filter->html .= '</span>';
                 } else {
                     $size = (int) ($size / 2);
                     $filter->html .= '<span class="fc_filter_element">';
                     $filter->html .= '<input name="' . $filter_ffname . '[1]" ' . $attribs_str . ' type="text" size="' . $size . '" value="' . @$value[1] . '" />';
                     $filter->html .= '</span>';
                     $filter->html .= '<span class="fc_range"></span>';
                     $filter->html .= '<span class="fc_filter_element">';
                     $filter->html .= '<input name="' . $filter_ffname . '[2]" ' . $attribs_str . ' type="text" size="' . $size . '" value="' . @$value[2] . '" />' . "\n";
                     $filter->html .= '</span>';
                 }
             }
             break;
         case 4:
         case 5:
             // 4: radio (single value selectable), 5: checkbox (multiple values selectable)
             $lf_min = 10;
             // add parameter for this ?
             $add_lf = count($results) >= $lf_min;
             if ($add_lf) {
                 flexicontent_html::loadFramework('mCSB');
开发者ID:jakesyl,项目名称:flexicontent,代码行数:67,代码来源:flexicontent.fields.php

示例2: createFilter


//.........这里部分代码省略.........
                            $end = count($custom_vals) - 1;
                            $step_values = $custom_vals;
                            $step_labels =& $custom_labels;
                            $i = 0;
                            $set_start = strlen($value1) > 0;
                            $set_end = strlen($value1) > 0;
                            foreach ($custom_vals as $n => $custom_val) {
                                if ($set_start && $custom_val == $value1) {
                                    $start = $i;
                                }
                                if ($set_end && $custom_val == $value2) {
                                    $end = $i;
                                }
                                $custom_vals[$n] = $i++;
                            }
                            $step_range = '
							snap: true,
							range: ' . json_encode($custom_vals) . ',
					';
                        }
                    }
                    flexicontent_html::loadFramework('nouislider');
                    $left_no = $display_filter_as == 7 ? '' : '1';
                    $rght_no = '2';
                    // sometimes unused
                    $js = "\n\t\t\t\t\tjQuery(document).ready(function(){\n\t\t\t\t\t\tvar slider = document.getElementById('" . $filter_ffid . "_nouislider');\n\t\t\t\t\t\t\n\t\t\t\t\t\tvar input1 = document.getElementById('" . $filter_ffid . $left_no . "');\n\t\t\t\t\t\tvar input2 = document.getElementById('" . $filter_ffid . $rght_no . "');\n\t\t\t\t\t\tvar isSingle = " . ($display_filter_as == 7 ? '1' : '0') . ";\n\t\t\t\t\t\t\n\t\t\t\t\t\tvar step_values = [" . implode(', ', $step_values) . "];\n\t\t\t\t\t\tvar step_labels = [\"" . implode('", "', array_map('addslashes', $step_labels)) . "\"];\n\t\t\t\t\t\t\n\t\t\t\t\t\tnoUiSlider.create(slider, {" . ($display_filter_as == 7 ? "\n\t\t\t\t\t\t\t\tstart: " . $start . ",\n\t\t\t\t\t\t\t\tconnect: false,\n\t\t\t\t\t\t\t" : "\n\t\t\t\t\t\t\t\tstart: [" . $start . ", " . $end . "],\n\t\t\t\t\t\t\t\tconnect: true,\n\t\t\t\t\t\t\t") . "\n\t\t\t\t\t\t\t\t" . $step_range . "\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\n\t\t\t\t\t\tvar tipHandles = slider.getElementsByClassName('noUi-handle'),\n\t\t\t\t\t\ttooltips = [];\n\t\t\t\t\t\t\n\t\t\t\t\t\t// Add divs to the slider handles.\n\t\t\t\t\t\tfor ( var i = 0; i < tipHandles.length; i++ ){\n\t\t\t\t\t\t\ttooltips[i] = document.createElement('span');\n\t\t\t\t\t\t\ttipHandles[i].appendChild(tooltips[i]);\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\ttooltips[i].className += 'fc-sliderTooltip'; // Add a class for styling\n\t\t\t\t\t\t\ttooltips[i].innerHTML = '<span></span>'; // Add additional markup\n\t\t\t\t\t\t\ttooltips[i] = tooltips[i].getElementsByTagName('span')[0];  // Replace the tooltip reference with the span we just added\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\t// When the slider changes, display the value in the tooltips and set it into the input form elements\n\t\t\t\t\t\tslider.noUiSlider.on('update', function( values, handle ) {\n\t\t\t\t\t\t\tvar value = parseInt(values[handle]);\n\t\t\t\t\t\t\tvar i = value;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif ( handle ) {\n\t\t\t\t\t\t\t\tinput2.value = typeof step_values[value] !== 'undefined' ? step_values[value] : value;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tinput1.value = typeof step_values[value] !== 'undefined' ? step_values[value] : value;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tvar tooltip_text = typeof step_labels[value] !== 'undefined' ? step_labels[value] : value;\n\t\t\t\t\t\t\tvar max_len = 36;\n\t\t\t\t\t\t\ttooltips[handle].innerHTML = tooltip_text.length > max_len+4 ? tooltip_text.substring(0, max_len)+' ...' : tooltip_text;\n\t\t\t\t\t\t\tvar left  = jQuery(tooltips[handle]).closest('.noUi-origin').position().left;\n\t\t\t\t\t\t\tvar width = jQuery(tooltips[handle]).closest('.noUi-base').width();\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t//window.console.log ('handle: ' + handle + ', left : ' + left + ', width : ' + width);\n\t\t\t\t\t\t\tif (isSingle) {\n\t\t\t\t\t\t\t\tleft<(50/100)*width ?\n\t\t\t\t\t\t\t\t\tjQuery(tooltips[handle]).parent().removeClass('fc-left').addClass('fc-right') :\n\t\t\t\t\t\t\t\t\tjQuery(tooltips[handle]).parent().removeClass('fc-right').addClass('fc-left');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse if (handle) {\n\t\t\t\t\t\t\t\tleft<=(76/100)*width ?\n\t\t\t\t\t\t\t\t\tjQuery(tooltips[handle]).parent().removeClass('fc-left').addClass('fc-right') :\n\t\t\t\t\t\t\t\t\tjQuery(tooltips[handle]).parent().removeClass('fc-right').addClass('fc-left');\n\t\t\t\t\t\t\t\tleft<=(49/100)*width ?\n\t\t\t\t\t\t\t\t\tjQuery(tooltips[handle]).parent().addClass('fc-bottom') :\n\t\t\t\t\t\t\t\t\tjQuery(tooltips[handle]).parent().removeClass('fc-bottom');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tleft>=(24/100)*width ?\n\t\t\t\t\t\t\t\t\tjQuery(tooltips[handle]).parent().removeClass('fc-right').addClass('fc-left') :\n\t\t\t\t\t\t\t\t\tjQuery(tooltips[handle]).parent().removeClass('fc-left').addClass('fc-right');\n\t\t\t\t\t\t\t\tleft>=(51/100)*width ?\n\t\t\t\t\t\t\t\t\tjQuery(tooltips[handle]).parent().addClass('fc-bottom') :\n\t\t\t\t\t\t\t\t\tjQuery(tooltips[handle]).parent().removeClass('fc-bottom');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\n\t\t\t\t\t\t// Handle form autosubmit\n\t\t\t\t\t\tslider.noUiSlider.on('change', function() {\n\t\t\t\t\t\t\tvar slider = jQuery('#" . $filter_ffid . "_nouislider');\n\t\t\t\t\t\t\tvar jform  = slider.closest('form');\n\t\t\t\t\t\t\tvar form   = jform.get(0);\n\t\t\t\t\t\t\tadminFormPrepare(form, parseInt(jform.attr('data-fc-autosubmit')));\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\n\t\t\t\t\t\tinput1.addEventListener('change', function(){\n\t\t\t\t\t\t\tvar value = 0;  // default is first value = empty\n\t\t\t\t\t\t\tfor(var i=1; i<step_values.length-1; i++) {\n\t\t\t\t\t\t\t\tif (step_values[i] == this.value) { value=i; break; }\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tslider.noUiSlider.set([value, null]);\n\t\t\t\t\t\t});\n\t\t\t\t\t\t" . ($display_filter_as == 8 ? "\n\t\t\t\t\t\tinput2.addEventListener('change', function(){\n\t\t\t\t\t\t\tvar value = step_values.length-1;  // default is last value = empty\n\t\t\t\t\t\t\tfor(var i=1; i<step_values.length-1; i++) {\n\t\t\t\t\t\t\t\tif (step_values[i] == this.value) { value=i; break; }\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tslider.noUiSlider.set([null, value]);\n\t\t\t\t\t\t});\n\t\t\t\t\t\t" : "") . "\n\t\t\t\t\t});\n\t\t\t\t";
                    JFactory::getDocument()->addScriptDeclaration($js);
                    //JFactory::getDocument()->addStyleDeclaration("");
                }
                if ($display_filter_as == 1 || $display_filter_as == 7) {
                    if ($isDate && !$isSlider) {
                        $filter->html .= '
						<span class="fc_filter_element">
							' . FlexicontentFields::createCalendarField($value, $allowtime = 0, $filter_ffname, $filter_ffid, $attribs_arr) . '
						</span>';
                    } else {
                        $filter->html .= ($isSlider ? '<div id="' . $filter_ffid . '_nouislider" class="fcfilter_with_nouislider"></div><div class="fc_slider_input_box">' : '') . '
						<span class="fc_filter_element">
							<input id="' . $filter_ffid . '" name="' . $filter_ffname . '" ' . $attribs_str . ' type="text" size="' . $size . '" value="' . @$value . '" />
						</span>
					' . ($isSlider ? '</div>' : '');
                    }
                } else {
                    if ($isDate && !$isSlider) {
                        $filter->html .= '
						<span class="fc_filter_element">
							' . FlexicontentFields::createCalendarField(@$value[1], $allowtime = 0, $filter_ffname . '[1]', $filter_ffid . '1', $attribs_arr) . '
						</span>
						<span class="fc_range"></span>
						<span class="fc_filter_element">
							' . FlexicontentFields::createCalendarField(@$value[2], $allowtime = 0, $filter_ffname . '[2]', $filter_ffid . '2', $attribs_arr) . '
						</span>';
                    } else {
                        $size = (int) ($size / 2);
                        $filter->html .= ($isSlider ? '<div id="' . $filter_ffid . '_nouislider" class="fcfilter_with_nouislider"></div><div class="fc_slider_input_box">' : '') . '
						<span class="fc_filter_element">
							<input name="' . $filter_ffname . '[1]" ' . $attribs_str . ' id="' . $filter_ffid . '1" type="text" size="' . $size . '" value="' . @$value[1] . '" />
						</span>
						<span class="fc_range"></span>
						<span class="fc_filter_element">
							<input name="' . $filter_ffname . '[2]" ' . $attribs_str . ' id="' . $filter_ffid . '2" type="text" size="' . $size . '" value="' . @$value[2] . '" />
						</span>
					' . ($isSlider ? '</div>' : '');
                    }
                }
                break;
开发者ID:benediktharter,项目名称:flexicontent-cck,代码行数:67,代码来源:flexicontent.fields.php

示例3: onDisplayField


//.........这里部分代码省略.........
        $css = "";
        if ($multiple) {
            // Add the drag and drop sorting feature
            if (!$use_ingroup) {
                $js .= "\n\t\t\tjQuery(document).ready(function(){\n\t\t\t\tjQuery('#sortables_" . $field->id . "').sortable({\n\t\t\t\t\thandle: '.fcfield-drag-handle',\n\t\t\t\t\tcontainment: 'parent',\n\t\t\t\t\ttolerance: 'pointer'\n\t\t\t\t});\n\t\t\t});\n\t\t\t";
            }
            if ($max_values) {
                JText::script("FLEXI_FIELD_MAX_ALLOWED_VALUES_REACHED", true);
            }
            $js .= "\n\t\t\tvar uniqueRowNum" . $field->id . "\t= " . count($field->value) . ";  // Unique row number incremented only\n\t\t\tvar rowCount" . $field->id . "\t= " . count($field->value) . ";      // Counts existing rows to be able to limit a max number of values\n\t\t\tvar maxValues" . $field->id . " = " . $max_values . ";\n\t\t\t\n\t\t\tfunction addField" . $field->id . "(el, groupval_box, fieldval_box, params)\n\t\t\t{\n\t\t\t\tvar insert_before   = (typeof params!== 'undefined' && typeof params.insert_before   !== 'undefined') ? params.insert_before   : 0;\n\t\t\t\tvar remove_previous = (typeof params!== 'undefined' && typeof params.remove_previous !== 'undefined') ? params.remove_previous : 0;\n\t\t\t\tvar scroll_visible  = (typeof params!== 'undefined' && typeof params.scroll_visible  !== 'undefined') ? params.scroll_visible  : 1;\n\t\t\t\tvar animate_visible = (typeof params!== 'undefined' && typeof params.animate_visible !== 'undefined') ? params.animate_visible : 1;\n\t\t\t\t\n\t\t\t\tif((rowCount" . $field->id . " >= maxValues" . $field->id . ") && (maxValues" . $field->id . " != 0)) {\n\t\t\t\t\talert(Joomla.JText._('FLEXI_FIELD_MAX_ALLOWED_VALUES_REACHED') + maxValues" . $field->id . ");\n\t\t\t\t\treturn 'cancel';\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tvar lastField = fieldval_box ? fieldval_box : jQuery(el).prev().children().last();\n\t\t\t\tvar newField  = lastField.clone();\n\t\t\t\t\n\t\t\t\t// Update the new text field\n\t\t\t\tvar theInput = newField.find('input.fcfield_textval').first();\n\t\t\t\ttheInput.val('');\n\t\t\t\ttheInput.attr('name', '" . $fieldname . "['+uniqueRowNum" . $field->id . "+']');\n\t\t\t\ttheInput.attr('id', '" . $elementid . "_'+uniqueRowNum" . $field->id . ");\n\t\t\t\t\n\t\t\t\t// Update date picker\n\t\t\t\tvar thePicker = theInput.next();\n\t\t\t\tthePicker.attr('id', '" . $elementid . "_' +uniqueRowNum" . $field->id . " +'_img');\n\t\t\t\t\n\t\t\t\t";
            // Disable keyboard input if so configured
            if ($disable_keyboardinput) {
                $js .= "\n\t\t\t\ttheInput.on('keydown keypress keyup', false);\n\t\t\t\t\t";
            }
            // Add new field to DOM
            $js .= "\n\t\t\t\tlastField ?\n\t\t\t\t\t(insert_before ? newField.insertBefore( lastField ) : newField.insertAfter( lastField ) ) :\n\t\t\t\t\tnewField.appendTo( jQuery('#sortables_" . $field->id . "') ) ;\n\t\t\t\tif (remove_previous) lastField.remove();\n\t\t\t\t\n\t\t\t\t// This needs to be after field is added to DOM (unlike e.g. select2 / inputmask JS scripts)\n\t\t\t\tCalendar.setup({\n\t\t\t\t\tinputField:\ttheInput.attr('id'),\n\t\t\t\t\tifFormat:\t\t'%Y-%m-%d',\n\t\t\t\t\tbutton:\t\t\tthePicker.attr('id'),\n\t\t\t\t\talign:\t\t\t'Tl',\n\t\t\t\t\tsingleClick:\ttrue\n\t\t\t\t});\n\t\t\t\t";
            // Add new element to sortable objects (if field not in group)
            if (!$use_ingroup) {
                $js .= "\n\t\t\t\t//jQuery('#sortables_" . $field->id . "').sortable('refresh');  // Refresh was done appendTo ?\n\t\t\t\t";
            }
            // Show new field, increment counters
            $js .= "\n\t\t\t\t//newField.fadeOut({ duration: 400, easing: 'swing' }).fadeIn({ duration: 200, easing: 'swing' });\n\t\t\t\tif (scroll_visible) fc_scrollIntoView(newField, 1);\n\t\t\t\tif (animate_visible) newField.css({opacity: 0.1}).animate({ opacity: 1 }, 800);\n\t\t\t\t\n\t\t\t\t// Enable tooltips on new element\n\t\t\t\tnewField.find('.hasTooltip').tooltip({'html': true,'container': newField});\n\t\t\t\t\n\t\t\t\trowCount" . $field->id . "++;       // incremented / decremented\n\t\t\t\tuniqueRowNum" . $field->id . "++;   // incremented only\n\t\t\t}\n\n\t\t\tfunction deleteField" . $field->id . "(el, groupval_box, fieldval_box)\n\t\t\t{\n\t\t\t\t// Find field value container\n\t\t\t\tvar row = fieldval_box ? fieldval_box : jQuery(el).closest('li');\n\t\t\t\t\n\t\t\t\t// Add empty container if last element, instantly removing the given field value container\n\t\t\t\tif(rowCount" . $field->id . " == 1)\n\t\t\t\t\taddField" . $field->id . "(null, groupval_box, row, {remove_previous: 1, scroll_visible: 0, animate_visible: 0});\n\t\t\t\t\n\t\t\t\t// Remove if not last one, if it is last one, we issued a replace (copy,empty new,delete old) above\n\t\t\t\tif(rowCount" . $field->id . " > 1) {\n\t\t\t\t\t// Destroy the remove/add/etc buttons, so that they are not reclicked, while we do the hide effect (before DOM removal of field value)\n\t\t\t\t\trow.find('.fcfield-delvalue').remove();\n\t\t\t\t\trow.find('.fcfield-insertvalue').remove();\n\t\t\t\t\trow.find('.fcfield-drag-handle').remove();\n\t\t\t\t\t// Do hide effect then remove from DOM\n\t\t\t\t\trow.slideUp(400, function(){ jQuery(this).remove(); });\n\t\t\t\t\trowCount" . $field->id . "--;\n\t\t\t\t}\n\t\t\t}\n\t\t\t";
            $css .= '';
            $remove_button = '<span class="fcfield-delvalue" title="' . JText::_('FLEXI_REMOVE_VALUE') . '" onclick="deleteField' . $field->id . '(this);"></span>';
            $move2 = '<span class="fcfield-drag-handle" title="' . JText::_('FLEXI_CLICK_TO_DRAG') . '"></span>';
            $add_here = '';
            $add_here .= $add_position == 2 || $add_position == 3 ? '<span class="fcfield-insertvalue fc_before" onclick="addField' . $field->id . '(null, jQuery(this).closest(\'ul\'), jQuery(this).closest(\'li\'), {insert_before: 1});" title="' . JText::_('FLEXI_ADD_BEFORE') . '"></span> ' : '';
            $add_here .= $add_position == 1 || $add_position == 3 ? '<span class="fcfield-insertvalue fc_after"  onclick="addField' . $field->id . '(null, jQuery(this).closest(\'ul\'), jQuery(this).closest(\'li\'), {insert_before: 0});" title="' . JText::_('FLEXI_ADD_AFTER') . '"></span> ' : '';
        } else {
            $remove_button = '';
            $move2 = '';
            $add_here = '';
            $js .= '';
            $css .= '';
        }
        if ($js) {
            $document->addScriptDeclaration($js);
        }
        if ($css) {
            $document->addStyleDeclaration($css);
        }
        // *****************************************
        // Create field's HTML display for item form
        // *****************************************
        $field->html = array();
        $n = 0;
        $skipped_vals = array();
        //if ($use_ingroup) {print_r($field->value);}
        foreach ($field->value as $value) {
            if (!strlen($value) && !$use_ingroup && $n) {
                continue;
            }
            // If at least one added, skip empty if not in field group
            $fieldname_n = $fieldname . '[' . $n . ']';
            $elementid_n = $elementid . '_' . $n;
            $calendar = FlexicontentFields::createCalendarField($value, $date_allowtime, $fieldname_n, $elementid_n, $attribs_arr = array('class' => 'fcfield_textval' . $required), $skip_on_invalid = true, $timezone);
            if (!$calendar) {
                $skipped_vals[] = $value;
                if (!$use_ingroup) {
                    continue;
                }
                $calendar = FlexicontentFields::createCalendarField('', $date_allowtime, $fieldname_n, $elementid_n, $attribs_arr = array('class' => 'fcfield_textval' . $required), $skip_on_invalid = true, $timezone);
            }
            $field->html[] = '
				' . $calendar . '
				' . ($use_ingroup ? '' : $move2) . '
				' . ($use_ingroup ? '' : $remove_button) . '
				' . ($use_ingroup || !$add_position ? '' : $add_here) . '
				';
            if ($disable_keyboardinput) {
                $document->addScriptDeclaration("\n\t\t\t\t\tjQuery(document).ready(function(){\n\t\t\t\t\t\tjQuery('#" . $elementid_n . "').on('keydown keypress keyup', false);\n\t\t\t\t\t});\n\t\t\t\t");
            }
            $n++;
            if (!$multiple) {
                break;
            }
            // multiple values disabled, break out of the loop, not adding further values even if the exist
        }
        if ($use_ingroup) {
            // do not convert the array to string if field is in a group
        } else {
            if ($multiple) {
                // handle multiple records
                $field->html = !count($field->html) ? '' : '<li class="' . $value_classes . '">' . implode('</li><li class="' . $value_classes . '">', $field->html) . '</li>';
                $field->html = '<ul class="fcfield-sortables" id="sortables_' . $field->id . '">' . $field->html . '</ul>';
                if (!$add_position) {
                    $field->html .= '<span class="fcfield-addvalue" onclick="addField' . $field->id . '(this);" title="' . JText::_('FLEXI_ADD_TO_BOTTOM') . '"></span>';
                }
            } else {
                // handle single values
                $field->html = '<div class="fcfieldval_container valuebox fcfieldval_container_' . $field->id . '">' . $field->html[0] . '</div>';
            }
        }
        if (!$use_ingroup) {
            $field->html = ($show_usage && $append_str ? ' <div class="alert alert-info fc-small fc-iblock">' . $append_str . '</div><div class="clear"></div>' : '') . $field->html;
        }
        if (count($skipped_vals)) {
            $app->enqueueMessage(JText::sprintf('FLEXI_FIELD_EDIT_VALUES_SKIPPED', $field->label, implode(',', $skipped_vals)), 'notice');
        }
    }
开发者ID:nettdotkomm,项目名称:flexicontent-cck,代码行数:101,代码来源:date.php

示例4: onDisplayField


//.........这里部分代码省略.........
                }
                $tz_info = $tz_offset > 0 ? ' UTC +' . $tz_offset : ' UTC ' . $tz_offset;
                $append_str .= '<br/>' . JText::_($user->id ? 'FLEXI_DATE_ENTER_HOURS_IN_YOUR_TIMEZONE' : 'FLEXI_DATE_ENTER_HOURS_IN_TIMEZONE') . ': ' . $tz_info;
            }
        }
        $append_str = $append_str ? '<b>' . JText::_('FLEXI_NOTES') . '</b>: ' . $append_str : '';
        // Initialise property with default value
        if (!$field->value) {
            $field->value = array();
            $field->value[0] = '';
        }
        // Field name and HTML TAG id
        $fieldname = FLEXI_J16GE ? 'custom[' . $field->name . '][]' : $field->name . '[]';
        $elementid = FLEXI_J16GE ? 'custom_' . $field->name : $field->name;
        $js = "";
        if ($multiple) {
            if (!FLEXI_J16GE) {
                $document->addScript(JURI::root(true) . '/components/com_flexicontent/assets/js/sortables.js');
            }
            // Add the drag and drop sorting feature
            $js .= "\r\n\t\t\tjQuery(document).ready(function(){\r\n\t\t\t\tjQuery('#sortables_" . $field->id . "').sortable({\r\n\t\t\t\t\thandle: '.fcfield-drag',\r\n\t\t\t\t\tcontainment: 'parent',\r\n\t\t\t\t\ttolerance: 'pointer'\r\n\t\t\t\t});\r\n\t\t\t});\r\n\t\t\t";
            if ($max_values) {
                FLEXI_J16GE ? JText::script("FLEXI_FIELD_MAX_ALLOWED_VALUES_REACHED", true) : fcjsJText::script("FLEXI_FIELD_MAX_ALLOWED_VALUES_REACHED", true);
            }
            $js .= "\r\n\t\t\tvar uniqueRowNum" . $field->id . "\t= " . count($field->value) . ";  // Unique row number incremented only\r\n\t\t\tvar rowCount" . $field->id . "\t= " . count($field->value) . ";      // Counts existing rows to be able to limit a max number of values\r\n\t\t\tvar maxValues" . $field->id . " = " . $max_values . ";\r\n\r\n\t\t\tfunction addField" . $field->id . "(el) {\r\n\t\t\t\tif((rowCount" . $field->id . " >= maxValues" . $field->id . ") && (maxValues" . $field->id . " != 0)) {\r\n\t\t\t\t\talert(Joomla.JText._('FLEXI_FIELD_MAX_ALLOWED_VALUES_REACHED') + maxValues" . $field->id . ");\r\n\t\t\t\t\treturn 'cancel';\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tvar thisField \t = jQuery(el).prev().children().last();\r\n\t\t\t\tvar thisNewField = thisField.clone();\r\n\t\t\t\t\r\n\t\t\t\tjQuery(thisNewField).find('input').first().val('');  /* First element is the value input field, second is e.g remove button */\r\n\t\t\t\t\r\n\t\t\t\tjQuery(thisNewField).css('display', 'none');\r\n\t\t\t\tjQuery(thisNewField).insertAfter( jQuery(thisField) );\r\n\r\n\t\t\t\tvar input = jQuery(thisNewField).find('input').first();\r\n\t\t\t\tinput.attr('id', '" . $elementid . "_'+uniqueRowNum" . $field->id . ");\r\n\t\t\t\tvar img = input.next();\r\n\t\t\t\timg.attr('id', '" . $elementid . "_' +uniqueRowNum" . $field->id . " +'_img');\r\n\t\t\t\t\r\n\t\t\t\tCalendar.setup({\r\n\t\t\t\t\tinputField:\tinput.attr('id'),\r\n\t\t\t\t\tifFormat:\t\t'%Y-%m-%d',\r\n\t\t\t\t\tbutton:\t\t\timg.attr('id'),\r\n\t\t\t\t\talign:\t\t\t'Tl',\r\n\t\t\t\t\tsingleClick:\ttrue\r\n\t\t\t\t});\r\n\t\t\t";
            if ($disable_keyboardinput) {
                $js .= "\r\n\t\t\t\t\tjQuery('#'+input.attr('id')).on('keydown keypress keyup', false);\r\n\t\t\t\t";
            }
            $js .= "\r\n\t\t\t\tjQuery('#sortables_" . $field->id . "').sortable({\r\n\t\t\t\t\thandle: '.fcfield-drag',\r\n\t\t\t\t\tcontainment: 'parent',\r\n\t\t\t\t\ttolerance: 'pointer'\r\n\t\t\t\t});\r\n\t\t\t\t\r\n\t\t\t\tjQuery(thisNewField).show('slideDown');\r\n\t\t\t\t\r\n\t\t\t\trowCount" . $field->id . "++;       // incremented / decremented\r\n\t\t\t\tuniqueRowNum" . $field->id . "++;   // incremented only\r\n\t\t\t}\r\n\r\n\t\t\tfunction deleteField" . $field->id . "(el)\r\n\t\t\t{\r\n\t\t\t\tif(rowCount" . $field->id . " <= 1) return;\r\n\t\t\t\tvar row = jQuery(el).closest('li');\r\n\t\t\t\tjQuery(row).hide('slideUp', function() { this.remove(); } );\r\n\t\t\t\trowCount" . $field->id . "--;\r\n\t\t\t}\r\n\t\t\t";
            $css = '
			#sortables_' . $field->id . ' { float:left; margin: 0px; padding: 0px; list-style: none; white-space: nowrap; }
			#sortables_' . $field->id . ' li {
				clear: both;
				display: block;
				list-style: none;
				height: auto;
				position: relative;
			}
			#sortables_' . $field->id . ' li.sortabledisabled {
				background : transparent url(components/com_flexicontent/assets/images/move3.png) no-repeat 0px 1px;
			}
			#sortables_' . $field->id . ' li input { cursor: text;}
			#add' . $field->name . ' { margin-top: 5px; clear: both; display:block; }
			#sortables_' . $field->id . ' li .admintable { text-align: left; }
			#sortables_' . $field->id . ' li:only-child span.fcfield-drag, #sortables_' . $field->id . ' li:only-child input.fcfield-button { display:none; }
			';
            $remove_button = '<input class="fcfield-button" type="button" value="' . JText::_('FLEXI_REMOVE_VALUE') . '" onclick="deleteField' . $field->id . '(this);" />';
            $move2 = '<span class="fcfield-drag">' . JHTML::image(JURI::base() . 'components/com_flexicontent/assets/images/move2.png', JText::_('FLEXI_CLICK_TO_DRAG')) . '</span>';
        } else {
            $remove_button = '';
            $move2 = '';
            $js = '';
            $css = '';
        }
        if ($js) {
            $document->addScriptDeclaration($js);
        }
        if ($css) {
            $document->addStyleDeclaration($css);
        }
        $field->html = array();
        $n = 0;
        $skipped_vals = array();
        foreach ($field->value as $value) {
            $elementid_n = $elementid . '_' . $n;
            $calendar = FlexicontentFields::createCalendarField($value, $date_allowtime, $fieldname, $elementid_n, $attribs_arr = array('class' => 'fcfield_textval' . $required), $skip_on_invalid = true, $timezone);
            if (!$calendar) {
                $skipped_vals[] = $value;
                continue;
            }
            $field->html[] = '
				' . $calendar . '
				' . $move2 . '
				' . $remove_button . '
				';
            if ($disable_keyboardinput) {
                $document->addScriptDeclaration("\r\n\t\t\t\t\tjQuery(document).ready(function(){\r\n\t\t\t\t\t\tjQuery('#" . $elementid_n . "').on('keydown keypress keyup', false);\r\n\t\t\t\t\t});\r\n\t\t\t\t");
            }
            $n++;
            if (!$multiple) {
                break;
            }
            // multiple values disabled, break out of the loop, not adding further values even if the exist
        }
        if ($multiple) {
            // handle multiple records
            $_list = "<li>" . implode("</li>\n<li>", $field->html) . "</li>\n";
            $field->html = '
				<ul class="fcfield-sortables" id="sortables_' . $field->id . '">' . $_list . '</ul>
				<input type="button" class="fcfield-addvalue" onclick="addField' . $field->id . '(this);" value="' . JText::_('FLEXI_ADD_VALUE') . '" />
			';
        } else {
            // handle single values
            $field->html = '<div>' . $field->html[0] . '</div>';
        }
        $field->html = '<div style="float:left">' . ($show_usage && $append_str ? ' <div class="fc_mini_note_box">' . $append_str . '</div>' : '') . $field->html . '</div>';
        if (count($skipped_vals)) {
            $app->enqueueMessage(JText::sprintf('FLEXI_FIELD_EDIT_VALUES_SKIPPED', $field->label, implode(',', $skipped_vals)), 'notice');
        }
    }
开发者ID:jakesyl,项目名称:flexicontent,代码行数:101,代码来源:date.php


注:本文中的FlexicontentFields::createCalendarField方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。