Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Constructs some <option>s for use in the templates
- *
- * @param array The key:value data array
- * @param mixed (Optional) The selected id(s)
- * @param boolean (Optional) Whether we should HTMLise the values
- */
- public static function createSelectOptions($array, $selectedid = '', $htmlise = false)
- {
- if (!is_array($array))
- {
- return '';
- }
- $options = '';
- foreach ($array as $key => $val)
- {
- if (is_array($val))
- {
- // Create the template
- $templater = vB_Template::create('optgroup');
- $templater->register('optgroup_label', ($htmlise ? htmlspecialchars_uni($key) : $key));
- $templater->register('optgroup_options', self::createSelectOptions($val, $selectedid, $tabindex, $htmlise));
- $options .= $templater->render();
- }
- else
- {
- if (is_array($selectedid))
- {
- $selected = iif(in_array($key, $selectedid), ' selected="selected"', '');
- }
- else
- {
- $selected = iif($key == $selectedid, ' selected="selected"', '');
- }
- $templater = vB_Template::create('option');
- $templater->register('optionvalue', ($key !== 'no_value' ? $key : ''));
- $templater->register('optionselected', $selected);
- $templater->register('optiontitle', ($htmlise ? htmlspecialchars_uni($val) : $val));
- $options .= $templater->render();
- }
- }
- return $options;
- }
- /**
- * Constructs a time selector
- *
- * @param string The title of the time select
- * @param name (Optional) The HTML form name
- * @param array (Optional) The time we should start with
- * @param name (Optional) The vertical align state
- *
- * @return string The constructed time row
- */
- public static function timeRow($title, $name = 'date', $unixtime = '', $valign = 'middle')
- {
- global $vbphrase, $vbulletin;
- $output = '';
- $monthnames = array(
- 0 => '- - - -',
- 1 => $vbphrase['january'],
- 2 => $vbphrase['february'],
- 3 => $vbphrase['march'],
- 4 => $vbphrase['april'],
- 5 => $vbphrase['may'],
- 6 => $vbphrase['june'],
- 7 => $vbphrase['july'],
- 8 => $vbphrase['august'],
- 9 => $vbphrase['september'],
- 10 => $vbphrase['october'],
- 11 => $vbphrase['november'],
- 12 => $vbphrase['december'],
- );
- if (is_array($unixtime))
- {
- require_once(DIR . '/includes/functions_misc.php');
- $unixtime = vbmktime(0, 0, 0, $unixtime['month'], $unixtime['day'], $unixtime['year']);
- }
- if ($unixtime)
- {
- $month = vbdate('n', $unixtime, false, false);
- $day = vbdate('j', $unixtime, false, false);
- $year = vbdate('Y', $unixtime, false, false);
- $hour = vbdate('G', $unixtime, false, false);
- $minute = vbdate('i', $unixtime, false, false);
- }
- $cell = array();
- $cell[] = "<label for=\"{$name}_month\">$vbphrase[month]</label><br /><select name=\"{$name}[month]\" id=\"{$name}_month\" tabindex=\"1\" class=\"primary select\"" . iif($vbulletin->debug, " title=\"name="$name" . "[month]"\"") . ">\n" . self::createSelectOptions($monthnames, $month) . "\t\t</select>";
- $cell[] = "<label for=\"{$name}_date\">$vbphrase[day]</label><br /><input type=\"text\" class=\"primary textbox\" name=\"{$name}[day]\" id=\"{$name}_date\" value=\"$day\" size=\"4\" maxlength=\"2\" tabindex=\"1\"" . iif($vbulletin->debug, " title=\"name="$name" . "[day]"\"") . ' />';
- $cell[] = "<label for=\"{$name}_year\">$vbphrase[year]</label><br /><input type=\"text\" class=\"primary textbox\" name=\"{$name}[year]\" id=\"{$name}_year\" value=\"$year\" size=\"4\" maxlength=\"4\" tabindex=\"1\"" . iif($vbulletin->debug, " title=\"name="$name" . "[year]"\"") . ' />';
- $inputs = '';
- foreach($cell AS $html)
- {
- $inputs .= "\t\t<td style=\"padding-left:6px;\"><span class=\"smallfont\">$html</span></td>\n";
- }
- $output .= "<div id=\"ctrl_$name\" class=\"" . (intval(self::$vbulletin->versionnumber) == 3 ? 'alt1' : 'blockrow') . "\">$title: <table cellpadding=\"0\" cellspacing=\"2\" border=\"0\"><tr>\n$inputs\t\n</tr></table></div><br />";
- return $output;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement