// select_country_tag() $t->diag('select_country_tag()'); $t->like(select_country_tag('name'), '/' . preg_quote('<select name="name" id="name">') . '/', 'select_country_tag() takes a name as its first argument'); $t->cmp_ok(preg_match_all('/<option/', select_country_tag('name'), $matches), '>', 200, 'select_country_tag() takes a name as its first argument'); $t->like(select_country_tag('name', 'FR'), '/' . preg_quote('<option value="FR" selected="selected">') . '/', 'select_country_tag() takes an ISO code for the selected country as its second argument'); // options $t->like(select_country_tag('name', null, array('class' => 'foo')), '/' . preg_quote('<select name="name" id="name" class="foo">') . '/', 'select_country_tag() takes an array of options as its third argument'); $t->is(preg_match_all('/<option/', select_country_tag('name', null, array('countries' => array('FR', 'GB'))), $matches), 2, 'select_country_tag() takes a "countries" option'); // select_language_tag() $t->diag('select_language_tag()'); $t->like(select_language_tag('name'), '/' . preg_quote('<select name="name" id="name">') . '/', 'select_language_tag() takes a name as its first argument'); $t->cmp_ok(preg_match_all('/<option/', select_language_tag('name'), $matches), '>', 200, 'select_language_tag() takes a name as its first argument'); $t->like(select_language_tag('name', 'fr'), '/' . preg_quote('<option value="fr" selected="selected">') . '/', 'select_language_tag() takes an ISO code for the selected language as its second argument'); // option $t->like(select_language_tag('name', null, array('class' => 'foo')), '/' . preg_quote('<select name="name" id="name" class="foo">') . '/', 'select_language_tag() takes an array of options as its third argument'); $t->is(preg_match_all('/<option/', select_language_tag('name', null, array('languages' => array('fr', 'en'))), $matches), 2, 'select_language_tag() takes a "languages" option'); // input_tag() $t->diag('input_tag()'); $t->is(input_tag('name'), '<input type="text" name="name" id="name" value="" />', 'input_tag() takes a name as its first argument'); $t->is(input_tag('name', 'foo'), '<input type="text" name="name" id="name" value="foo" />', 'input_tag() takes a value as its second argument'); // options $t->is(input_tag('name', null, array('class' => 'foo')), '<input type="text" name="name" id="name" value="" class="foo" />', 'input_tag() takes an array of attribute options as its third argument'); $t->is(input_tag('name', null, array('type' => 'password')), '<input type="password" name="name" id="name" value="" />', 'input_tag() can override the "type" attribute'); $t->is(input_tag('name', null, array('id' => 'foo')), '<input type="text" name="name" id="foo" value="" />', 'input_tag() can override the "id" attribute'); // input_hidden_tag() $t->diag('input_hidden_tag()'); $t->is(input_hidden_tag('name'), '<input type="hidden" name="name" id="name" value="" />', 'input_hidden_tag() takes a name as its first argument'); $t->is(input_hidden_tag('name', 'foo'), '<input type="hidden" name="name" id="name" value="foo" />', 'input_hidden_tag() takes a value as its second argument'); $t->is(input_hidden_tag('name', null, array('class' => 'foo')), '<input type="hidden" name="name" id="name" value="" class="foo" />', 'input_hidden_tag() takes an array of attribute options as its third argument'); // input_file_tag() $t->diag('input_file_tag()');
function object_select_language_tag($object, $method, $options = array(), $default_value = null) { $options = _parse_attributes($options); $value = _get_object_value($object, $method, $default_value); return select_language_tag(_convert_method_to_name($method, $options), $value, $options); }
<?php /** @var $sf_user MyUser */ $languages = $sf_user->getAttribute("languages", null); $language = $schema_property_element->getLanguage(); $CurrentLanguage = $language ? $language : $sf_user->getAttribute("CurrentLanguage", null); //if the current culture setting isn't in the allowed list, we reset the culture to the default echo select_language_tag('schema_property_element[language]', $CurrentLanguage, array('id' => 'language', "languages" => $languages));
function object_admin_select_language($object, $method, $options = array(), $default_value = null) { //$params = array_merge(array('control_name' => $this->getSingularName() . '[' . $column->getName() . ']'), $params); $options = _parse_attributes($options); $value = _get_object_value($object, $method, $default_value); if (isset($options['limitmethod'])) { $options['languages'] = _get_object_value($object, $options['limitmethod']); } return select_language_tag($options['control_name'], $value, $options); }
public function printParam($mandatory, $lable, $param_name, $input_type, $original_extra_params = NULL, $extra_params_for_select = NULL, $should_echo = NULL) { if ($should_echo == NULL) { $should_echo = $this->m_should_echo; } $res = ""; if ($this->m_object_type === self::OBJECT_TYPE_MY_BASE_OBJECT) { $p = $this->m_current_object->getParamFromObject($param_name); } else { if ($this->m_object_type === self::OBJECT_TYPE_ORM_BASE_OBJECT) { $p = baseObjectUtils::getParamFromObject($this->m_current_object, $param_name); } } // use this so the style=font-size:8pt will always be appended to the original_extra_params $extra_params = array(); //["style"] = "font-size:8pt"; kArray::associativePush($extra_params, $original_extra_params); if (kString::isEmpty($this->m_current_prefix)) { $field_name = $param_name; } else { $field_name = $this->m_current_prefix . self::PREFIX_NAME_SEPARATOR . $param_name; } $error = form_error($param_name); if ($this->m_create_tr) { if ($error) { $res .= "<tr><td colspan=2>" . $error . "</td></tr>"; } if ($input_type == "hidden") { $res .= "<tr><td></td>"; } else { $res .= " <tr><td valign=top><label for=\"" . $field_name . "\">" . ($mandatory ? "*" : "") . $lable . ":</label></td>"; } $res .= "<td sytle='font-size:8pt'>"; } else { // do nothing - the format will be done externally } if ($input_type == "text") { $res .= input_tag($field_name, $p, $extra_params); } elseif ($input_type == "hidden") { $res .= input_hidden_tag($field_name, $p, $extra_params); } elseif ($input_type == "textarea") { $res .= textarea_tag($field_name, $p, $extra_params); } elseif ($input_type == "upload") { $res .= self::createUploadStructure($field_name, $p, NULL, $extra_params, NULL, $should_echo); /* echo tag('input', array_merge(array('name' => $field_name, 'value' => $p , 'id' => $field_name, 'READONLY' => '', 'oncomplete' => 'onComplete_'.str_replace('.', '_', $field_name).'()'), $extra_params)); echo tag('input', array_merge(array('type' => 'button', 'value' => 'MyBrowse...', 'onclick' => 'uploadBrowse(this)', 'uploadElement' => "$field_name"), $extra_params)); echo tag('input', array_merge(array('type' => 'button', 'value' => 'Clear', 'onclick' => 'javascript:{$(\''.$field_name.'\').value = \'\';}'), $extra_params)); if ( ! kString::isEmpty ( $p ) ) { echo "<img src='/images/file_exists.png' width='16' height='16'>"; } */ } elseif ($input_type == "file") { $res .= input_file_tag($field_name, $p, $extra_params); } elseif ($input_type == "date") { $extra_params["rich"] = "true"; $extra_params["style"] = "width:80"; kArray::associativePush($extra_params, $original_extra_params); // TODO - see how to format the date there and back from the DB format "dd/mm/yyyy" to " $converted_date = dateUtils::convertFromPhpDate($p); // always append the default "rich=true" to the extra_params //$extra_params[] = 'rich=true' ; $res .= input_date_tag($field_name, $converted_date, $extra_params); } elseif ($input_type == "select") { $more_extra_params = array("style" => "font-size:8pt"); kArray::associativePush($more_extra_params, $extra_params_for_select); $res .= select_tag($field_name, options_for_select($original_extra_params, $p), $more_extra_params); } elseif ($input_type == "radio") { // assume the $lable holda the value of the radio $res .= radiobutton_tag($field_name, $lable, $p == $lable); } elseif ($input_type == "radiogroup") { // assume the $extra_params hold a lable-value array foreach ($extra_params as $lable => $name) { $value = $extra_params[$lable]; $res .= $lable . " " . radiobutton_tag($field_name, $value, $p == $value); } } elseif ($input_type == "checkbox") { $res .= checkbox_tag($field_name, "true", $p == "true", $extra_params); } elseif ($input_type == "color") { die("color is no longer supported !"); // $res .= myColorPicker::getPickerHtml( $p , $field_name ); // TODO - pass on $extra_params ? } elseif ($input_type == "country") { $more_extra_params = array("style" => "font-size:8pt"); kArray::associativePush($more_extra_params, $extra_params_for_select); $res .= select_country_tag($field_name, $p, $more_extra_params); } elseif ($input_type == "language") { $more_extra_params = array("style" => "font-size:8pt"); kArray::associativePush($more_extra_params, $extra_params_for_select); $res .= select_language_tag($field_name, $p, $more_extra_params); } else { throw new Exception("Unknown input_type [" . $input_type . "]"); } if ($this->m_create_tr) { $res .= "</td></tr>\n"; } if ($should_echo) { echo $res; } else { return $res; } }
<div class="show-row" style="padding-left: 10px; padding-top: 5px; border-top: 1px solid #DDDDDD;"> <?php /** * Created by jonphipps, on 2014-03-29 at 7:19 PM * for the registry project */ //here we're going to put a select box to change the culture //it should have an array of potential languages from the schema for list and show //it should have an array of potential languages from schema_user for edit //it should append the selected language to the url and change the location onChange //we'll need to add the array of languages to use to the $sf_user session in the action class ?> <?php echo form_tag('@schemaprop_language'); ?> <?php echo label_for('culture', __('Current content language') . ':', array("style" => "float: left; width: 148px; padding-top: 5px; font-weight: bold;")); ?> <?php /** @var $sf_user MyUser */ $languages = $sf_user->getAttribute("languages", null); $CurrentLanguage = $sf_user->getAttribute("CurrentLanguage", null); //if the current culture setting isn't in the allowed list, we reset the culture to the default echo select_language_tag('culture', $CurrentLanguage, array('id' => 'culture', "languages" => $languages)); ?> <?php echo submit_tag('Go'); ?> </form> </div>