RelatedTypeInterface() public static method

eeble
public static RelatedTypeInterface ( $customField, $inputName, $groupCounter, $fieldCounter )
Exemplo n.º 1
0
    /**
     * @todo Add documentation
     */
    function CustomFieldInterface($customFieldId, $groupCounter = 1, $fieldCounter = 1, $customGroup_id = 0)
    {
        global $mf_domain;
        require_once "RC_Format.php";
        $customField = RCCWP_CustomField::Get($customFieldId);
        $customFieldName = RC_Format::GetInputName(attribute_escape($customField->name));
        $customFieldTitle = attribute_escape($customField->description);
        $customFieldHelp = htmlentities2($customField->help_text);
        $groupId = $customGroup_id;
        $inputName = $customFieldId . "_" . $groupCounter . "_" . $fieldCounter . "_" . $groupId . "_" . $customFieldName;
        // Create input tag name
        if ($fieldCounter > 1 && $customField->duplicate == 0) {
            return;
        }
        if ($fieldCounter > 1) {
            $titleCounter = " ({$fieldCounter})";
        }
        $field_group = RCCWP_CustomGroup::Get($customField->group_id);
        ?>
		<div class="mf-field <?php 
        echo str_replace(" ", "_", $customField->type);
        ?>
" id="row_<?php 
        echo $inputName;
        ?>
">
			<label for="<?php 
        echo $inputName;
        ?>
">
				<?php 
        if (empty($titleCounter)) {
            $titleCounter = "";
        }
        ?>
				<?php 
        echo $customFieldTitle . $titleCounter;
        ?>
				<?php 
        if (!empty($customFieldHelp)) {
            ?>
					<small class="tip">(what's this?)<span class="field_help"><?php 
            echo $customFieldHelp;
            ?>
</span></small>
				<?php 
        }
        ?>
			</label>
			<span>
				<p class="error_msg_txt" id="fieldcellerror_<?php 
        echo $inputName;
        ?>
" style="display:none"></p>
				<?php 
        switch ($customField->type) {
            case 'Textbox':
                RCCWP_WritePostPage::TextboxInterface($customField, $inputName, $groupCounter, $fieldCounter);
                break;
            case 'Multiline Textbox':
                RCCWP_WritePostPage::MultilineTextboxInterface($customField, $inputName, $groupCounter, $fieldCounter);
                break;
            case 'Checkbox':
                RCCWP_WritePostPage::CheckboxInterface($customField, $inputName, $groupCounter, $fieldCounter);
                break;
            case 'Checkbox List':
                RCCWP_WritePostPage::CheckboxListInterface($customField, $inputName, $groupCounter, $fieldCounter);
                break;
            case 'Radiobutton List':
                RCCWP_WritePostPage::RadiobuttonListInterface($customField, $inputName, $groupCounter, $fieldCounter);
                break;
            case 'Dropdown List':
                RCCWP_WritePostPage::DropdownListInterface($customField, $inputName, $groupCounter, $fieldCounter);
                break;
            case 'Listbox':
                RCCWP_WritePostPage::ListboxInterface($customField, $inputName, $groupCounter, $fieldCounter);
                break;
            case 'File':
                RCCWP_WritePostPage::FileInterface($customField, $inputName, $groupCounter, $fieldCounter);
                break;
            case 'Image':
                RCCWP_WritePostPage::PhotoInterface($customField, $inputName, $groupCounter, $fieldCounter);
                break;
            case 'Date':
                RCCWP_WritePostPage::DateInterface($customField, $inputName, $groupCounter, $fieldCounter);
                break;
            case 'Audio':
                RCCWP_WritePostPage::AudioInterface($customField, $inputName, $groupCounter, $fieldCounter);
                break;
            case 'Color Picker':
                RCCWP_WritePostPage::ColorPickerInterface($customField, $inputName, $groupCounter, $fieldCounter);
                break;
            case 'Slider':
                RCCWP_WritePostPage::SliderInterface($customField, $inputName, $groupCounter, $fieldCounter);
                break;
                //eeble
            //eeble
            case 'Related Type':
                RCCWP_WritePostPage::RelatedTypeInterface($customField, $inputName, $groupCounter, $fieldCounter);
                break;
            default:
        }
        if ($fieldCounter == 1) {
            ?>
					<?php 
            if ($customField->duplicate != 0) {
                ?>
					<br />
					
					 <a class ="typeHandler" href="javascript:void(0);" id="type_handler-<?php 
                echo $inputName;
                ?>
" > 
						<img class="duplicate_image"  src="<?php 
                echo MF_URI;
                ?>
images/duplicate.png" alt="<?php 
                _e('Add field duplicate', $mf_domain);
                ?>
"/>  <?php 
                _e('Duplicate', $mf_domain);
                ?>
					</a>
					<?php 
            }
            ?>
					<?php 
        } else {
            ?>
					<br />
					<a class ="delete_duplicate_field" href="javascript:void(0)" id="delete_field_repeat-<?php 
            echo $inputName;
            ?>
"> 
						<img class="duplicate_image"  src="<?php 
            echo MF_URI;
            ?>
images/delete.png" alt="<?php 
            _e('Remove field duplicate', $mf_domain);
            ?>
 "/> <?php 
            _e('Remove', $mf_domain);
            ?>
 
					</a>
				<?php 
        }
        ?>
				<input type="hidden" name="rc_cwp_meta_keys[]" value="<?php 
        echo $inputName;
        ?>
" />
		</span>
		</div>
	<?php 
    }
Exemplo n.º 2
0
    /**
     * @todo Add documentation
     */
    public static function CustomFieldInterface($customFieldId, $groupCounter = 1, $fieldCounter = 1, $customGroup_id = 0)
    {
        global $mf_domain;
        require_once "RC_Format.php";
        $customField = RCCWP_CustomField::Get($customFieldId);
        $customFieldName = $customField->name;
        $customFieldTitle = esc_attr($customField->description);
        $customFieldHelp = $customField->help_text;
        // htmlentities($customField->help_text,ENT_COMPAT,'UTF-8');
        $groupId = $customGroup_id;
        $inputCustomName = $customFieldId . "_" . $groupCounter . "_" . $fieldCounter . "_" . $groupId . "_" . $customFieldName;
        // Create input tag name
        $inputName = "magicfields[{$customFieldName}][{$groupCounter}][{$fieldCounter}]";
        if ($fieldCounter > 1 && $customField->duplicate == 0) {
            return;
        }
        if ($fieldCounter > 1) {
            $titleCounter = " (<span class='counter_{$customFieldName}_{$groupCounter}'>{$fieldCounter}</span>)";
        }
        $field_group = RCCWP_CustomGroup::Get($customField->group_id);
        /* 
         * Add the lang attribute if last part of the field name matches defined languages
         * 
         * define( 'ADMIN_LANGS', 'en|fr|de' );
         * example: field name 'the_about_text_en' matches 'en' and sets ' lang="en"'
         *
         */
        if (defined('ADMIN_LANGS')) {
            $customFieldNameParts = explode('_', $customFieldName);
            $lang_switch = preg_match('/' . ADMIN_LANGS . '/', $customFieldNameParts[sizeof($customFieldNameParts) - 1]) ? ' lang="' . $customFieldNameParts[sizeof($customFieldNameParts) - 1] . '"' : '';
        } else {
            $lang_switch = '';
        }
        if (isset($customField->properties['strict-max-length']) && $customField->properties['strict-max-length'] == 1) {
            $fieldMaxLengthClass = ' maxlength';
        } else {
            $fieldMaxLengthClass = '';
        }
        $fieldCustomClass = "mf-field-{$customFieldName}";
        // allows some special styling in wordpress filters
        $duplicateClass = "";
        if ($fieldCounter > 1) {
            $duplicateClass = "mf-field-duplicate";
        }
        ?>
		<div class="mf-field <?php 
        echo $duplicateClass;
        ?>
 <?php 
        echo $fieldCustomClass;
        ?>
 mf-t-<?php 
        echo strtolower(str_replace(" ", "-", $customField->type));
        ?>
 <?php 
        echo str_replace(" ", "_", $customField->type);
        echo $fieldMaxLengthClass;
        ?>
" id="row_<?php 
        echo $inputCustomName;
        ?>
"<?php 
        echo $lang_switch;
        ?>
>
			<div class="mf-field-title">
			<label for="<?php 
        echo $inputCustomName;
        ?>
">
				<?php 
        if (empty($titleCounter)) {
            $titleCounter = "";
        }
        ?>
				<span class="name"><?php 
        echo $customFieldTitle;
        ?>
<em><?php 
        echo $titleCounter;
        ?>
</em></span>
				<?php 
        if ($customField->required_field == 1) {
            ?>
 <span class="required">*</span><?php 
        }
        if (!empty($customFieldHelp)) {
            ?>
					<small class="tip"><?php 
            _e("what's this?", $mf_domain);
            ?>
<span class="field_help"><?php 
            echo $customFieldHelp;
            ?>
</span></small>
				<?php 
        }
        if (isset($customField->properties['strict-max-length']) && $customField->properties['strict-max-length'] == 1) {
            if ($customField->type == 'Multiline Textbox') {
                $charsRemainingSize = $customField->properties['height'] * $customField->properties['width'];
            } else {
                $charsRemainingSize = $customField->properties['size'];
            }
            ?>
<small class="remaining"><?php 
            _e('Characters left', $mf_domain);
            ?>
: <span class="charsRemaining" title="<?php 
            _e('Characters left', $mf_domain);
            ?>
"><?php 
            echo $charsRemainingSize;
            ?>
</span></small><?php 
        }
        ?>
			</label>
			</div>
			<!-- /.mf-field-title -->
			
			<div>
				<p class="error_msg_txt" id="fieldcellerror_<?php 
        echo $inputCustomName;
        ?>
" style="display:none"></p>
				<?php 
        switch ($customField->type) {
            case 'Textbox':
                RCCWP_WritePostPage::TextboxInterface($customField, $inputName, $groupCounter, $fieldCounter);
                break;
            case 'Multiline Textbox':
                RCCWP_WritePostPage::MultilineTextboxInterface($customField, $inputName, $groupCounter, $fieldCounter);
                break;
            case 'Checkbox':
                RCCWP_WritePostPage::CheckboxInterface($customField, $inputName, $groupCounter, $fieldCounter);
                break;
            case 'Checkbox List':
                RCCWP_WritePostPage::CheckboxListInterface($customField, $inputName, $groupCounter, $fieldCounter);
                break;
            case 'Radiobutton List':
                RCCWP_WritePostPage::RadiobuttonListInterface($customField, $inputName, $groupCounter, $fieldCounter);
                break;
            case 'Dropdown List':
                RCCWP_WritePostPage::DropdownListInterface($customField, $inputName, $groupCounter, $fieldCounter);
                break;
            case 'Listbox':
                RCCWP_WritePostPage::ListboxInterface($customField, $inputName, $groupCounter, $fieldCounter);
                break;
            case 'File':
                RCCWP_WritePostPage::FileInterface($customField, $inputName, $groupCounter, $fieldCounter);
                break;
            case 'Image':
                RCCWP_WritePostPage::PhotoInterface($customField, $inputName, $groupCounter, $fieldCounter);
                break;
            case 'Date':
                RCCWP_WritePostPage::DateInterface($customField, $inputName, $groupCounter, $fieldCounter);
                break;
            case 'Audio':
                RCCWP_WritePostPage::AudioInterface($customField, $inputName, $groupCounter, $fieldCounter);
                break;
            case 'Color Picker':
                RCCWP_WritePostPage::ColorPickerInterface($customField, $inputName, $groupCounter, $fieldCounter);
                break;
            case 'Slider':
                RCCWP_WritePostPage::SliderInterface($customField, $inputName, $groupCounter, $fieldCounter);
                break;
            case 'Related Type':
                RCCWP_WritePostPage::RelatedTypeInterface($customField, $inputName, $groupCounter, $fieldCounter);
                break;
            case 'Markdown Textbox':
                RCCWP_WritePostPage::MarkdownTextboxInterface($customField, $inputName, $groupCounter, $fieldCounter);
                break;
            case 'Image (Upload Media)':
                RCCWP_WritePostPage::MediaPhotoInterface($customField, $inputName, $groupCounter, $fieldCounter);
                break;
            default:
        }
        ?>
				
				<div class="mf-duplicate-controls">
			  <?php 
        $cfd = Inflect::singularize($customField->description);
        if ($fieldCounter == 1) {
            ?>
					<?php 
            if ($customField->duplicate != 0) {
                ?>
            <a href="javascript:void(0);" id="type_handler-<?php 
                echo $inputCustomName;
                ?>
" class="typeHandler duplicate_field"><span><?php 
                _e('Add Another', $mf_domain);
                ?>
</span> <?php 
                echo $cfd;
                ?>
</a>
					<?php 
            }
            ?>
					<?php 
        } else {
            ?>
					<a class="delete_duplicate_field" href="javascript:void(0)" id="delete_field_repeat-<?php 
            echo $inputCustomName;
            ?>
"><span><?php 
            _e('Remove', $mf_domain);
            ?>
</span> <?php 
            echo $cfd;
            ?>
</a>
				<?php 
        }
        ?>
  		  </div>
  		  <!-- ./title-controls -->
		</div>
		</div>
	<?php 
    }