/**
 * Get the value of an input field.
 *
 * @param string $fieldName
 * @param integer $groupIndex
 * @param integer $fieldIndex
 * @param boolean $readyForEIP if true and the field type is textbox or
 * 				multiline textbox, the resulting value will be wrapped
 * 				in a div that is ready for EIP. The default value is true
 * @return a string or array based on field type
 */
function get($fieldName, $groupIndex = 1, $fieldIndex = 1, $readyForEIP = true, $post_id = NULL)
{
    require_once "RCCWP_CustomField.php";
    global $post, $FIELD_TYPES;
    if (!$post_id) {
        $post_id = $post->ID;
    }
    $field = RCCWP_CustomField::GetDataField($fieldName, $groupIndex, $fieldIndex, $post_id);
    if (!$field) {
        return FALSE;
    }
    $fieldType = $field['type'];
    $fieldID = $field['id'];
    $fieldObject = $field['properties'];
    $fieldValues = (array) $field['meta_value'];
    $fieldMetaID = $field['meta_id'];
    $results = GetProcessedFieldValue($fieldValues, $fieldType, $fieldObject);
    //filter for multine line
    if ($fieldType == $FIELD_TYPES['multiline_textbox']) {
        $results = apply_filters('the_content', $results);
    }
    if ($fieldType == $FIELD_TYPES['image']) {
        $results = split('&', $results);
        $results = $results[0];
    }
    // Prepare fields for EIP
    include_once 'RCCWP_Options.php';
    $enableEditnplace = RCCWP_Options::Get('enable-editnplace');
    if ($readyForEIP && $enableEditnplace == 1 && current_user_can('edit_posts', $post->ID)) {
        switch ($fieldType) {
            case $FIELD_TYPES["textbox"]:
                if (!$results) {
                    $results = "&nbsp";
                }
                $results = "<div class='" . EIP_textbox($fieldMetaID) . "' >" . $results . "</div>";
                break;
            case $FIELD_TYPES["multiline_textbox"]:
                if (!$results) {
                    $results = "&nbsp";
                }
                $results = "<div class='" . EIP_mulittextbox($fieldMetaID) . "' >" . $results . "</div>";
                break;
        }
    }
    return $results;
}
示例#2
0
function mf_shortcodes($atts)
{
    global $post, $FIELD_TYPES;
    extract(shortcode_atts(array('field' => 'no field defined or field name is wrong', 'eip' => FALSE, 'filtered' => FALSE, 'imgtag' => FALSE, 'label' => "", 'loop' => FALSE, 'loopseparator' => "|", 'checked' => "yes", 'groupindex' => 1, 'fieldindex' => 1), $atts));
    if ($loop && RCCWP_CustomField::GetFieldDuplicates($post->ID, $field, $groupindex) > 1) {
        $fieldduplicatedata = get_field_duplicate($field);
    } else {
        $fielddata = RCCWP_CustomField::GetDataField($field, $groupindex, $fieldindex, $post->ID);
    }
    $fieldType = $fielddata['type'];
    $fieldID = $fielddata['id'];
    $fieldObject = $fielddata['properties'];
    $fieldValues = (array) $fielddata['meta_value'];
    $fieldMetaID = $fielddata['meta_id'];
    $fieldresults = GetProcessedFieldValue($fieldValues, $fieldType, $fieldObject);
    $shortcode_data = $fieldresults;
    if ($fielddata['type'] == $FIELD_TYPES['multiline_textbox'] && $filtered) {
        $shortcode_data = apply_filters('the_content', $fieldresults);
    }
    if ($fielddata['type'] == $FIELD_TYPES['image']) {
        $imgresults = split('&', $fieldresults);
        if ($imgtag) {
            $shortcode_data = "<img src=\"{$imgresults['0']}\"/>";
        } else {
            $shortcode_data = $imgresults[0];
        }
    }
    if ($fielddata['type'] == $FIELD_TYPES['listbox']) {
        $shortcode_data = implode(",", $fieldresults);
    }
    if ($fielddata['type'] == $FIELD_TYPES['checkbox_list']) {
        $shortcode_data = implode(",", $fieldresults);
    }
    if ($fielddata['type'] == $FIELD_TYPES['checkbox']) {
        if ($fieldresults) {
            $shortcode_data = $checked;
        }
    }
    // Prepare fields for EIP
    $enableEditnplace = RCCWP_Options::Get('enable-editnplace');
    if ($eip && $enableEditnplace == 1 && current_user_can('edit_posts', $post->ID)) {
        switch ($fielddata['type']) {
            case $FIELD_TYPES["textbox"]:
                if (!$results) {
                    $results = "&nbsp";
                }
                $shortcode_data = "<div class='" . EIP_textbox($fieldMetaID) . "' >" . $fieldresults . "</div>";
                break;
            case $FIELD_TYPES["multiline_textbox"]:
                if (!$results) {
                    $results = "&nbsp";
                }
                $shortcode_data = "<div class='" . EIP_mulittextbox($fieldMetaID) . "' >" . $shortcode_data . "</div>";
                break;
        }
    }
    if ($shortcode_data || $fieldduplicatedata) {
        if ($label) {
            $shortcode_data = $label . $shortcode_data;
        } else {
            $shortcode_data = get_label($field) . " : " . $shortcode_data;
        }
        /////
        if ($field == "duplicate") {
            if ($loop) {
                return implode($loopseparator, $fieldduplicatedata);
            } else {
                return $shortcode_data;
            }
        } else {
            return $shortcode_data;
        }
        /////
    } else {
        return "no data found, please check the field name";
    }
}
示例#3
0
/**
 * Get the value of an input field.
 *
 * @param string $fieldName
 * @param integer $groupIndex
 * @param integer $fieldIndex
 * @param boolean $readyForEIP if true and the field type is textbox or
 * 				multiline textbox, the resulting value will be wrapped
 * 				in a div that is ready for EIP. The default value is true
 * @return a string or array based on field type
 */
function get($fieldName, $groupIndex = 1, $fieldIndex = 1, $readyForEIP = true)
{
    require_once "RCCWP_CustomField.php";
    global $wpdb, $post, $FIELD_TYPES;
    $fieldID = RCCWP_CustomField::GetIDByName($fieldName);
    $fieldObject = GetFieldInfo($fieldID);
    $fieldType = $wpdb->get_var("SELECT type FROM " . RC_CWP_TABLE_GROUP_FIELDS . " WHERE id='" . $fieldID . "'");
    $single = true;
    switch ($fieldType) {
        case $FIELD_TYPES["checkbox_list"]:
        case $FIELD_TYPES["listbox"]:
            $single = false;
            break;
    }
    $fieldValues = (array) RCCWP_CustomField::GetCustomFieldValues($single, $post->ID, $fieldName, $groupIndex, $fieldIndex);
    $fieldMetaID = RCCWP_CustomField::GetMetaID($post->ID, $fieldName, $groupIndex, $fieldIndex);
    $results = GetProcessedFieldValue($fieldValues, $fieldType, $fieldObject->properties);
    //filter for multine line
    if ($fieldType == $FIELD_TYPES['multiline_textbox']) {
        $results = apply_filters('the_content', $results);
    }
    // Prepare fields for EIP
    include_once 'RCCWP_Options.php';
    $enableEditnplace = RCCWP_Options::Get('enable-editnplace');
    if ($readyForEIP && $enableEditnplace == 1 && current_user_can('edit_posts', $post->ID)) {
        switch ($fieldType) {
            case $FIELD_TYPES["textbox"]:
                if (!$results) {
                    $results = "&nbsp";
                }
                $results = "<div class='" . EIP_textbox($fieldMetaID) . "' >" . $results . "</div>";
                break;
            case $FIELD_TYPES["multiline_textbox"]:
                if (!$results) {
                    $results = "&nbsp";
                }
                $results = "<div class='" . EIP_mulittextbox($fieldMetaID) . "' >" . $results . "</div>";
                break;
        }
    }
    return $results;
}