PDA

View Full Version : Checkbox/Upload fields in AdminCP


TheAdminMarket
11-09-2014, 02:09 PM
Hello,

Does anyone knows the syntax (in case that they're supporting) for fieldtype:

Checkbox
File (Upload)eg something similar that I found for textarea:

print_textarea_row
print_yes_no_row
print_select_row


I know that I can use print_yesno_row instead of checkbox but I prefer checkbox. The most important is the File (Upload) to avoid using standard HTML there.

Thank you

nerbert
11-09-2014, 02:35 PM
I've edited my adminfunctions.php file so I'm not sure I have the line numbers correct, I'm looking at the old version for vB 4.2.0

print_checkbox_row(), line 1104

print_upload_row(), line 1175

EDIT: Well, since I have the file open ....


/**
* Prints a row containing an <input type="checkbox" />
*
* @param string Title for row
* @param string Name for checkbox
* @param boolean Whether or not to check the box
* @param string Value for checkbox
* @param string Text label for checkbox
* @param string Optional Javascript code to run when checkbox is clicked - example: ' onclick="do_something()"'
*/
function print_checkbox_row($title, $name, $checked = true, $value = 1, $labeltext = '', $onclick = '')
{
global $vbphrase, $vbulletin;

if ($labeltext == '')
{
$labeltext = $vbphrase['yes'];
}

$uniqueid = fetch_uniqueid_counter();

print_label_row(
"<label for=\"{$name}_$uniqueid\">$title</label>",
"<div id=\"ctrl_$name\"><label for=\"{$name}_$uniqueid\" class=\"smallfont\"><input type=\"checkbox\" name=\"$name\" id=\"{$name}_$uniqueid\" value=\"$value\" tabindex=\"1\"" . iif($onclick, " onclick=\"$onclick\"") . iif($vbulletin->debug, " title=\"name=&quot;$name&quot;\"") . iif($checked, ' checked="checked"') . " /><strong>$labeltext</strong></label></div>",
'', 'top', $name
);
}




/**
* Prints a row containing an <input type="file" />
*
* @param string Title for row
* @param string Name for file upload field
* @param integer Max uploaded file size in bytes
* @param integer Size of file upload field
*/
function print_upload_row($title, $name, $maxfilesize = 1000000, $size = 35)
{
global $vbulletin;

construct_hidden_code('MAX_FILE_SIZE', $maxfilesize);

// Don't style the file input for Opera or Firefox 3. #25838
$use_bginput = (is_browser('opera') OR is_browser('firefox', 3) ? false : true);

print_label_row(
$title,
"<div id=\"ctrl_$name\"><input type=\"file\"" . ($use_bginput ? ' class="bginput"' : '') . " name=\"$name\" size=\"$size\" tabindex=\"1\"" . iif($vbulletin->debug, " title=\"name=&quot;$name&quot;\"") . " /></div>",
'', 'top', $name
);
}

TheAdminMarket
11-09-2014, 02:53 PM
I've edited my adminfunctions.php file so I'm not sure I have the line numbers correct, I'm looking at the old version for vB 4.2.0

print_checkbox_row(), line 1104

print_upload_row(), line 1175

Most probably you are :) Thank you.
A bit before I: print_checkbox_row("Active", "active", "");
and worked. Actually it adds a "Yes" after the checkbox.

Also tried: print_file_row("Active", "active", "", 30,30); but I got fatal error. I'm crossing my fingers your solution to work.

I'll come back soon.

--------------- Added 1415552186 at 1415552186 ---------------

You're the King !!! :) Works perfect.

Thank you for your time. Really appreciated.