Exemplo n.º 1
0
    /**
     * Dynamic form creation for custom fields with default layout
     *
     * @param unknown_type $formFields
     * @param unknown_type $fieldLocation
     * @param unknown_type $search
     * @param unknown_type $selectLabel
     * @return unknown
     */
    function makeFormFields(&$formFields, $fieldLocation, $search = null, $selectLabel = 'Select', &$listing)
    {
        if (!is_array($formFields)) {
            return '';
        }
        $groupSet = array();
        $fieldLocation = Inflector::camelize($fieldLocation);
        foreach ($formFields as $group => $fields) {
            $inputs = array();
            foreach ($fields['Fields'] as $key => $value) {
                if (!$search && $this->Access->in_groups($value['properties']['access']) || $search && $this->Access->in_groups($value['properties']['access_view'])) {
                    // Convert radio button to checkbox if multiple search is enabled in the config settings
                    if ($search && $this->Config->search_field_conversion && $value['type'] == 'radiobuttons') {
                        $value['type'] = 'checkboxes';
                    }
                    if ($search && $this->Config->search_field_conversion && $value['type'] == 'select') {
                        $value['type'] = 'selectmultiple';
                    }
                    $inputs["data[Field][{$fieldLocation}][{$key}]"] = array('id' => $value['name'], 'type' => $this->types[$value['type']]);
                    //  Assign field classes
                    switch ($value['type']) {
                        case 'decimal':
                        case 'integer':
                            $inputs["data[Field][{$fieldLocation}][{$key}]"]['class'] = 'shortField';
                            break;
                        case 'website':
                            $inputs["data[Field][{$fieldLocation}][{$key}]"]['class'] = 'mediumField';
                            break;
                        case 'text':
                            $inputs["data[Field][{$fieldLocation}][{$key}]"]['class'] = 'mediumField';
                            break;
                    }
                    $inputs["data[Field][{$fieldLocation}][{$key}]"]['label']['text'] = $value['title'];
                    $inputs["data[Field][{$fieldLocation}][{$key}]"]['label']['class'] = $value['name'] . '_label';
                    # Add tooltip
                    if (!$search && Sanitize::getString($value, 'description', null)) {
                        $inputs["data[Field][{$fieldLocation}][{$key}]"]['label']['text'] .= '<span class="jr_infoTip" title="' . htmlspecialchars($value['description'], ENT_QUOTES, cmsFramework::getCharset()) . '">&nbsp;</span>';
                    }
                    if (!$search && $value['required']) {
                        $inputs["data[Field][{$fieldLocation}][{$key}]"]['label']['text'] .= '<span class="required">' . __t("*", true) . '</span>';
                    }
                    if (in_array($value['type'], $this->multipleTypes)) {
                        $inputs["data[Field][{$fieldLocation}][{$key}]"]['multiple'] = 'multiple';
                    }
                    if (isset($value['optionList']) && $value['type'] == 'select') {
                        $value['optionList'] = array('' => $selectLabel) + $value['optionList'];
                    }
                    if (isset($value['optionList'])) {
                        $inputs["data[Field][{$fieldLocation}][{$key}]"]['options'] = $value['optionList'];
                    }
                    # Add click2add capability for select lists
                    if ($fieldLocation == 'Listing' && !$search && $this->types[$value['type']] == 'select' && $value['properties']['click2add']) {
                        $click2AddLink = $this->Html->link($this->Html->image($this->viewImages . 'option_add.png', array('border' => 0, 'style' => 'margin-left:5px;')), 'javascript:void(0);', array('sef' => false, 'onclick' => "jQuery('#click2Add_{$value['field_id']}').toggle('slow');"));
                        $click2AddInput = $this->Form->text('jr_fieldOption' . $value['field_id'], array('id' => 'jr_fieldOption' . $value['field_id']));
                        $click2AddButton = $this->Form->button(__t("Submit", true), array('onclick' => "jreviews.field.addOption(this,{$value['field_id']},'{$value['name']}');", 'div' => false, 'id' => 'submitButton' . $value['field_id'], 'class' => 'button'));
                        $inputs["data[Field][{$fieldLocation}][{$key}]"]['after'] = $click2AddLink . "<div id='click2Add_{$value['field_id']}' class='jr_fieldDiv jr_newFieldOption'>" . $click2AddInput . ' ' . $click2AddButton . "<span class=\"jr_loadingSmall jr_hidden\"></span>" . '</div>';
                    }
                    # Prefill values when editing
                    if (isset($value['selected'])) {
                        $inputs["data[Field][{$fieldLocation}][{$key}]"]['value'] = $value['selected'];
                    }
                    # Add search operator fields for date, decimal and integer fields
                    if ($search && in_array($value['type'], $this->operatorTypes)) {
                        $options = array('equal' => '=', 'higher' => '&gt;=', 'lower' => '&lt;=', 'between' => __t("between", true));
                        $inputs["data[Field][{$fieldLocation}][{$key}]"]['multiple'] = true;
                        // convert field to array input for range searches
                        $attributes = array('id' => $key . 'high', 'multiple' => true, 'class' => 'shortField');
                        if ($this->types[$value['type']] == 'date') {
                            $attributes['class'] = 'dateField datepicker';
                        }
                        // This is the high value input in a range search
                        $inputs["data[Field][{$fieldLocation}][{$key}]"]['after'] = '<span id="' . $key . 'highDiv" style="display:none;">&nbsp;' . $this->Form->text("data[Field][Listing][{$key}]", $attributes) . '</span>';
                        $inputs["data[Field][{$fieldLocation}][{$key}]"]['between'] = $this->Form->select("data[Field][Listing][{$key}_operator]", $options, null, array('class' => 'jr_dateOperator input', 'onchange' => "jreviews.search.showRange(this,'{$key}high');"));
                    }
                    # Input styling
                    $inputs["data[Field][{$fieldLocation}][{$key}]"]['div'] = 'jr_fieldDiv ' . $value['name'];
                    if ($this->types[$value['type']] == 'date') {
                        $inputs["data[Field][{$fieldLocation}][{$key}]"]['class'] = 'dateField datepicker';
                        //$inputs["data[Field][$fieldLocation][$key]"]['readonly'] = 'readonly';
                    }
                    if (in_array($this->types[$value['type']], $this->legendTypes)) {
                        // Input styling
                        $inputs["data[Field][{$fieldLocation}][{$key}]"]['option_class'] = 'jr_fieldOption';
                        $inputs["data[Field][{$fieldLocation}][{$key}]"]['after'] = $this->Html->div('clr', ' ');
                        // To break the float
                    }
                }
                // end access check
            }
            // end foreach
            if (!empty($inputs)) {
                $groupSet[$group] = array('fieldset' => true, 'legend' => $group);
                foreach ($inputs as $dataKey => $dataValue) {
                    $groupSet[$group][$dataKey] = $dataValue;
                }
            }
        }
        /** HTGMOD **/
        // #309 - add link to edit bait type
        if ($listing && $listing['Category']['cat_id'] == 14) {
            include_once 'templates/jreviews_overrides/views/themes/geomaps/listings/rel-summary.php';
            $bait = getRelatedList($listing['Listing']['listing_id'], array(101, 102));
            $bait = array_shift($bait);
            if (!$bait) {
                $bait = new stdClass();
                $bait->title = __t('Add', true) . ' ' . __t('Bait', true);
            }
            $groupSet['Fangstdata']['bait'] = array('id' => 'bait', 'type' => 'text', 'class' => 'mediumField jr_hidden', 'label' => array('text' => __t('Bait', true), 'class' => 'bait_label'), 'value' => array($bait->title), 'div' => 'jr_fieldDiv', 'after' => '<ul><li><a href="index.php?option=com_relate&id=' . $listing['Listing']['listing_id'] . '&cat=101,102&ss=1" class="rel8win">' . $bait->title . '</a></li></ul>');
        }
        // #1095 - relate fly tying pattern to insect
        if ($listing && $listing['Listing']['section_id'] == 23) {
            include_once 'templates/jreviews_overrides/views/themes/geomaps/listings/rel-summary.php';
            if ($listing['Listing']['listing_id']) {
                $insects = getRelatedList($listing['Listing']['listing_id'], array(18, 118, 119, 120, 121, 122, 123));
                $insect_list = array();
                foreach ($insects as $insect) {
                    $insect_list[] = $insect->title;
                }
                $insect_list = '<li>' . implode('</li><li>', $insect_list) . '</li>';
                $relinput = '';
                $rel_link = 'index.php?option=com_relate&id=' . $listing['Listing']['listing_id'] . '&cat=s25';
                $relsave = <<<ENDSCRIPT
Relations.onAfterSave = function () {
\tjQuery('#insectList li').first().siblings().remove();
\tjQuery('.selected .itemTitle, .related .itemTitle').each(function () {
\t\tjQuery('#insectList').append(jQuery('<li>'+jQuery(this).text()+'</li>'));
\t});
}
ENDSCRIPT;
            } else {
                $insect_list = '';
                $relinput = '<input id="relate_insect" name="relate_id" type="hidden" value="" />';
                $rel_link = 'index.php?option=com_relate&cat=s25';
                $relsave = <<<ENDSCRIPT
Relations.save = function () {
\tjQuery('#relate_insect').val(this.add_ids.listings.join());
\tjQuery('#insectList li').first().siblings().remove();
\tjQuery('.selected .itemTitle').each(function () {
\t\tjQuery('#insectList').append(jQuery('<li>'+jQuery(this).text()+'</li>'));
\t});
}
ENDSCRIPT;
            }
            echo '<script type="text/javascript">' . $relsave . '</script>';
            $groupSet['Flueinfo']['insect'] = array('id' => 'insect', 'type' => 'text', 'class' => 'mediumField jr_hidden', 'label' => array('text' => __t('Which insect / prey pattern to imitate?', true), 'class' => 'insect_label'), 'value' => '', 'div' => 'jr_fieldDiv', 'after' => '<ul id="insectList"><li><a href="' . $rel_link . '" class="rel8win">' . __t('Choose insect / prey', true) . '</a></li>' . $insect_list . '</ul>' . $relinput);
        }
        /** END HTGMOD **/
        $output = '';
        foreach ($groupSet as $group => $form) {
            $output .= $this->Form->inputs($form);
        }
        return $output;
    }
Exemplo n.º 2
0
    echo $link;
    ?>
" class="jomTips" title="<?php 
    echo $preview_html;
    ?>
"><?php 
    echo $CustomFields->field('jr_catchlength', $listing, false, false);
    ?>
</a></td>
                    <?php 
}
?>
                    <td>
                    <?php 
// bait
$baitused = getRelatedList($listing['Listing']['listing_id'], array(101, 102), 5);
$bc = 0;
if ($baitused) {
    echo '<a href="' . $link . '">';
    foreach ($baitused as $bait) {
        if ($bc < 1) {
            echo $bait->title;
        } else {
            echo '...';
        }
        $bc++;
    }
    echo '</a>';
} else {
    echo '-';
}