public function render($name, $value = array(), $attributes = array(), $errors = array()) { $widget = array(); use_javascript('jquery.tooltip/jquery.tooltip.js'); use_stylesheet('../js/jquery.tooltip/jquery.tooltip.css'); $widget['%thumbnails%'] = ''; $widget['%thumbnails%'] .= ''; $j = 0; foreach ($value as $j => $image) { if (!isset($image['id'])) { continue; } $fileIdInput = new sfWidgetFormInputHidden(); $fileNameInput = new sfWidgetFormInputHidden(); $commentInput = new sfWidgetFormInput(array(), array('maxlength' => 255)); $largeInput = new sfWidgetFormInputHidden(); $thumbnailInput = new sfWidgetFormInputHidden(); $widget['%thumbnails%'] .= '<div class="upload_item" style="margin-bottom: 10px;" >' . '<span style="display: inline; width: 260px; float: left; text-align: center; padding-top: 10px;">' . link_to($image['name'], strval($image['Large']), array('class' => 'preview', 'rel' => strval($image['Thumbnail']))) . '</span>' . ' ' . $thumbnailInput->render($name . "[" . $j . "][Thumbnail]", strval($image['Thumbnail']), array()) . $largeInput->render($name . "[" . $j . "][Large]", strval($image['Large']), array()) . $fileNameInput->render($name . "[" . $j . "][name]", $image['name'], array()) . $fileIdInput->render($name . "[" . $j . "][id]", $image['id'], array()) . '<span>Title:</span>' . $commentInput->render($name . "[" . $j . "][description]", $image['description'], array('class' => 'text input-mercha-account')) . ' <a href="#" class="del-photo"><img src="/images/cross.gif" style="vertical-align:middle;" /></a>' . '</div>'; } $i = $j + 1; $fileInput = new sfWidgetFormInputFile(); $commentInput = new sfWidgetFormInput(); $widget['%thumbnails%'] .= '<div class="upload_item" style="margin-bottom: 10px;" >' . $fileInput->render($name . "[" . $i . "][file]", null, array('class' => '', 'style' => "padding-left:0px; width: 260px; padding:0px; ")) . ' ' . '<span>Title:</span>' . $commentInput->render($name . "[" . $i . "][description]", null, array('class' => 'text input-mercha-account')) . ' <a href="#" class="del-photo" style="vertical-align:middle;"><img src="/images/cross.gif" /></a>' . '</div>' . '<div class=" add-another-location bottom_add_new_category_link" style="padding-top: 0px; padding-bottom: 15px;">' . '<div class="plus_category">' . '<div class="left margin1"><img src="/images/plus.gif" /></div>' . '<div class="left margin_top3"><a href="#" class="add-photo">Add Another Photo</a></div>' . '</div>' . '</div>'; $js = jq_javascript_tag("\r\n jQuery(document).ready(function(){\r\n i = jQuery('.upload_item').length + 1;\r\n \r\n jQuery('a.del-photo').live('click', function(e){\r\n e.preventDefault();\r\n jQuery(this).parents('.upload_item').remove();\r\n });\r\n \r\n jQuery('.preview').tooltip({ \r\n delay: 0, \r\n showURL: false, \r\n bodyHandler: function() { \r\n return jQuery('<img/>').attr('src', jQuery(this).attr('rel')); \r\n } \r\n });\r\n \r\n jQuery('a.add-photo').live('click', function(e){\r\n \r\n e.preventDefault();\r\n \r\n var already = jQuery('.upload_item');\r\n \r\n var newUpload = '';\r\n \r\n var maxCount = " . intval($this->getOption('max_count')) . ";\r\n \r\n if ((maxCount > 0 && already.length < maxCount) || maxCount == 0) {\r\n \r\n newUpload = \r\n '<div class=\\'upload_item\\' style=\\'margin-bottom: 10px;\\'><input type=\\'file\\' name=\\'" . $name . "[' + i + '][file]" . "\\' class=\"\" style=\"padding-left:0px; width: 260px; padding:0px; \" />' +\n ' <span>Title:</span>' +\r\n '<input type=\\'text\\' name=\\'" . $name . "[' + i + '][description]" . "\\' class=\\'text input-mercha-account\\' >';\r\n \r\n newUpload += \r\n ' <a href=\\'#\\' class=\\'del-photo\\'><img src=\\'/images/cross.gif\\' style=\\'vertical-align:middle;\\' /></a>';\r\n \r\n \r\n \r\n newUpload += '</div>';\r\n \r\n jQuery(newUpload).insertBefore(jQuery(this).parents('div.add-another-location'));\r\n i++;\r\n }\r\n })\r\n \r\n });\r\n "); return $js . '<div id="uploader" style="width: 590px;">' . strtr($this->getOption('template'), $widget) . '</div>'; }
/** * Отрисовка * * @param mixed $name * @param mixed $value * @param mixed $attributes * @param mixed $errors * @return string */ public function render($name, $value = null, $attributes = array(), $errors = array()) { $js = ' <script type="text/javascript"> $(function(){ $(".icon-changer img").click(function(){ $("' . $this->getOption('target') . '").val($(this).attr("alt")); $("img", $(this).parent()).removeClass("selected"); $(this).addClass("selected"); }); }); </script> <div class="icon-changer" title="Выбрать иконку"> '; foreach ($this->getOption('icons') as $icon) { if ($value == $icon) { $class = ' class="selected"'; } else { $class = ''; } $js .= sprintf('<img%3$s src="%1$s/%2$s.png" alt="%2$s" />', $this->getOption('path'), $icon, $class); } $js .= '</div>'; return $js . parent::render($name, $value, $attributes = array(), $errors = array()); }
public function render($name, $value = null, $attributes = array(), $errors = array()) { $context = sfContext::getInstance(); $response = $context->getResponse(); $autocompleteDiv = ""; // content_tag('div' , '', array('id' => $this->generateId($name) . '_autocomplete', 'class' => 'autocomplete')); $desc = ''; if (true === $this->getOption('desc')) { $desc = '.data( "ui-autocomplete" )._renderItem = function( ul, item ) { return $( "<li>" ) .append( "<a>" + item.label + "<br>" + item.desc + "</a>" ) .appendTo( ul ); }'; } $autocompleteJs = $this->javascriptTag("\n \n \$(function(){\n \n \$('#" . $this->generateId($name) . "_ajaxtext').autocomplete({\n source: '" . url_for($this->getOption('url')) . "',\n delay:30,\n minChars:0,\n appendTo: '" . $this->getOption('appendTo') . "',\n max:30,\n width: 300,\n matchSubset:1,\n matchContains:1,\n cacheLength:10,\n autoFill:false,\n autoFocus: true,\n select: function( event, ui ) {\n \$('#" . $this->generateId($name) . "').val(ui.item.id);\n \$('#" . get_id_from_name($name) . "_ajaxcheckbox').prop('checked', true)\n \$('#" . get_id_from_name($name) . "_ajaxcheckboxText').html('" . __('kiválasztva') . "');\n \$('#" . $this->generateId($name) . "').trigger('change', [ui.item])\n } \n }){$desc}\n \n \n \n \$.fn.autocomplete.keypressEvent = function (evt, id){\n car = evt.keyCode || evt.charCode;\n if (car != 27 && car!=9) //ESC + TAB\n {\n \$('#'+id).val('');\n \$('#'+id+'_ajaxcheckbox').attr('checked',false);\n \$('#'+id+'_ajaxcheckboxText').html('" . __('nincs kiválasztva') . "'); \n \$('#" . $this->generateId($name) . "').trigger('change')\n } \n } \n \n });"); $ihidden = new sfWidgetFormInputHidden(); $ihiddenText = $ihidden->render($name, $value, $attributes); if ($value != '') { $checked = 'checked="checked"'; $checkboxtext = "<span id='" . get_id_from_name($name) . "_ajaxcheckboxText'>" . __('kiválasztva') . "</span>"; } else { $checked = ''; $checkboxtext = "<span id='" . get_id_from_name($name) . "_ajaxcheckboxText'>" . __('nincs kiválasztva') . "</span>"; } $checkbox = '<input type="checkbox" id="' . get_id_from_name($name) . '_ajaxcheckbox' . '" ' . $checked . ' disabled="disabled" />'; $attributesText = array_merge($attributes, array('name' => false, 'id' => get_id_from_name($name) . '_ajaxtext')); $attributesText['onkeydown'] = "\$('#" . $this->generateId($name) . "_ajaxtext').autocomplete.keypressEvent(event, '" . $this->generateId($name) . "')"; $itextText = parent::render($name, $this->getValueFromId($value), $attributesText, $errors); $indicator = '<span id="indicator-' . $this->generateId($name) . '" style="display: none;"> <img src="/sfFormExtraPlugin/images/indicator.gif" alt="loading" /></span>'; return $ihiddenText . $itextText . $checkbox . $checkboxtext . $indicator . $autocompleteDiv . $autocompleteJs; }
public function render($name, $value = null, $attributes = array(), $errors = array()) { sfContext::getInstance()->getConfiguration()->loadHelpers(array('I18N')); $original_value = $value; if (!is_null($this->getOption('object'))) { $args = $this->getOption('method_args'); if (is_null($args)) { $value = call_user_func(array($this->getOption('object'), $this->getOption('method'))); } else { $args = is_array($args) ? $args : array($args); $value = call_user_func_array(array($this->getOption('object'), $this->getOption('method')), $args); } } if (!is_null($this->getOption('value_callback'))) { $string_value = call_user_func($this->getOption('value_callback'), $value); } else { $string_value = $value; } $html = ''; if ($this->getOption('add_hidden_input')) { $val = $this->getOption('use_retrieved_value') ? $value : $original_value; $input_hidden = new sfWidgetFormInputHidden(array(), $attributes); $html .= $input_hidden->render($name, $val); } $text = is_null($value) ? __($this->getOption('empty_value')) : $string_value; #$html .= '<span id="'.$this->generateId($name.'_description', $value).'">'.$text.'</span>'; $html .= $this->renderContentTag('span', $text, array_merge($attributes, array('id' => $this->generateId($name . '_description', $value)))); return $html; }
public function getJavascriptBlock($name) { $hidden = new sfWidgetFormInputHidden(); $id = $this->generateId($name) . '_tagger'; $javascripts = <<<EOF <script type='text/javascript'> \$(document).ready(function(){ \$("#%s select.%s").change(function() { var newId = \$(this).attr('value'); if(\$('#%s .taggable-tag-'+newId).size() == 0) { var input = '%s'.replace('*id*', newId); \$('#%s ul').append("<li class='taggable-tag-"+newId+"'>"+\$(this).find(':selected').attr('text')+input+" <a href='#' class='remove' onclick='\$(this).parent().remove();return false;'>x</a></li>") } else { alert('"'+\$(this).find(':selected').attr('text')+'" is already added'); } \$(this).attr('value', ''); }); \$("#%s .remove").click(function(){ \$(this).parent().remove(); return false; }) }); </script> EOF; return sprintf($javascripts, $id, 'tag-select', $id, $hidden->render($name . '[]', '*id*'), $id, $id); }
public function render($name, $value = null, $attributes = array(), $errors = array()) { $html = parent::render($name, $value, $attributes, $errors); //sfContext::getInstance()->getConfiguration()->loadHelpers('Partial'); //$elements = sfConfig::get('app_gjPositionsPlugin_partials', array()); //$html .= get_partial('gjDesignElements/show', array('name' => $value, 'partial' => $elements[$value])); return $html; }
/** * @param string $name The element name * @param string $value The value displayed in this widget * @param array $attributes An array of HTML attributes to be merged with the default HTML attributes * @param array $errors An array of errors for the field * * @return string An HTML tag string * * @see sfWidgetFormInput */ public function render($name, $value = null, $attributes = array(), $errors = array()) { sfProjectConfiguration::getActive()->loadHelpers('sfAsset'); init_asset_library(); $html = parent::render($name, $value, $attributes, $errors) . ' '; $attributes = $this->fixFormId(array('name' => $name)); $html .= input_sf_asset_image_tag($name, array('id' => $attributes['id'], 'type' => $this->getOption('asset_type'))); return $html; }
/** * Renders the widget. * * @param string $name The element name * @param string $value The value displayed in this widget * @param array $attributes An array of HTML attributes to be merged with the default HTML attributes * @param array $errors An array of errors for the field * * @return string An HTML tag string * * @see sfWidgetForm */ public function render($name, $value = null, $attributes = array(), $errors = array()) { sfContext::getInstance()->getConfiguration()->loadHelpers(array('Partial')); $fields = $this->getParent()->getFields(); $options = is_array($this->getOption('params')) ? $this->getOption('params') : array($this->getOption('params')); $partial = get_partial($this->getOption('partial'), array_merge(compact('value', 'name', 'attributes', 'errors'), $options)); if (false !== $this->getOption('has_hidden')) { $hiddenInput = new sfWidgetFormInputHidden(); return $partial . $hiddenInput->render($name, $value, $attributes, $errors); } return $partial; }
public function render($name, $value = null, $attributes = array(), $errors = array()) { $html = ''; if (!$this->getOption('plain')) { $input_hidden = new sfWidgetFormInputHidden(); $html .= $input_hidden->render($name, $value); } if (!is_null($this->getOption('value_callback'))) { $html .= call_user_func($this->getOption('value_callback'), $value); } else { $html .= $value; } return $html; }
public function render($name, $value = null, $attributes = array(), $errors = array()) { sfContext::getInstance()->getConfiguration()->loadHelpers(array('I18N')); $object = $this->getOption('object'); $method = $this->getOption('method'); $method_args = $this->getOption('method_args'); if (!is_null($object) && !is_null($method)) { $value = $object->{$method}($method_args); } $html = $value ? __($this->getOption('true_string')) : __($this->getOption('false_string')); if ($this->getOption('add_hidden_input')) { $input_hidden = new sfWidgetFormInputHidden(array(), $attributes); $html .= $input_hidden->render($name, $value); } return $html; }
public function render($name, $value = null, $attributes = array(), $errors = array()) { $html = ''; if (!$this->getOption('plain')) { $input_hidden = new sfWidgetFormInputHidden(); $html .= $input_hidden->render($name, $value); } $clean_value = is_null($value) || trim($value) == '' ? $this->getOption('empty_value') : $value; if (!is_null($this->getOption('value_callback'))) { $formatted_value = call_user_func($this->getOption('value_callback'), $value); $html .= is_null($formatted_value) ? $clean_value : $formatted_value; } else { $html .= $clean_value; } return $html; }
/** * Отрисовка * * @param mixed $name * @param mixed $value * @param mixed $attributes * @param mixed $errors * @return string */ public function render($name, $value = null, $attributes = array(), $errors = array()) { sfContext::getInstance()->getResponse()->addJavascript('http://maps.google.com/maps?file=api&v=2&key=' . sfConfig::get('dm_google_maps')); $js = ' <div class="' . $this->getOption('canvas_class') . '" id="' . $this->generateId($name . '_canvas') . '"></div> <script type="text/javascript"> //<[CDATA[ window.onload = initialize; window.onunload = GUnload; function initialize() { var map = new GMap2(document.getElementById("' . $this->generateId($name . '_canvas') . '"), 14);'; if ($value) { $js .= ' map.setCenter(new GLatLng(' . $value . '), 14);'; } else { $js .= ' map.setCenter(new GLatLng(' . sfConfig::get('app_google_map_default_coordinates') . '), 14);'; } $js .= ' map.setUIToDefault(); map.setMapType(G_SATELLITE_MAP); var marker = new GMarker(map.getCenter(), {draggable: true}); GEvent.addListener(marker, "dragend", function() { document.getElementById("' . $this->generateId($name) . '").value = marker.getLatLng().lat() + "," + marker.getLatLng().lng(); }); GEvent.addListener(map, "click", function(overlay, latlng) { marker.setLatLng(latlng); map.panTo(latlng); document.getElementById("' . $this->generateId($name) . '").value = marker.getLatLng().lat() + "," + marker.getLatLng().lng(); }); map.addOverlay(marker); } //]]> </script>'; return parent::render($name, $value, $attributes = array(), $errors = array()) . $js; }
public function render($name, $value = null, $attributes = array(), $errors = array()) { $response = sfContext::getInstance()->getResponse(); $response->addStylesheet('/sfExtraWidgetsPlugin/css/autocompleter.css'); if ($this->getOption('obj') && $value) { try { $this->getOption('obj')->setId($value); $this->getOption('obj')->setNew(false); $this->getOption('obj')->reload(); $this->setOption('print', $this->getOption('obj')->__toString()); } catch (Doctrine_Record_Exception $ex) { // Doctrine Fix $q = Doctrine::getTable($this->getOption('obj')->getTable()->getOption('name'))->createQuery('u'); $this->setOption('print', $q->execute()->getFirst()); } } $widgetInput = $this->renderTag('input', array_merge(array('type' => 'text', 'name' => $this->generateId($name . '_search'), 'id' => $this->generateId($name . '_search'), 'value' => $this->getOption('print')), $attributes)); $widgetInputHidden = new sfWidgetFormInputHidden(array(), $this->getAttributes()); $autocompleteDiv = content_tag('div', '', array('id' => $this->generateId($name) . '_autocomplete', 'class' => 'autocomplete')); $autocompleteJs = javascript_tag("\n function ac_update_" . $this->generateId($name) . "(text, li)\n {\n \$('" . $this->generateId($name) . "').value = li.id;\n \n if(li.id == '')\n {\n \$('" . $this->generateId($name) . "_search').value = '';\n }\n }\n \n new Ajax.Autocompleter(\n '" . $this->generateId($name . '_search') . "',\n '" . $this->generateId($name) . '_autocomplete' . "',\n '" . url_for($this->getOption('url')) . "',\n {\n paramName: '" . $this->getOption('param') . "',\n indicator: 'indicator-" . $this->generateId($name) . "',\n minChars: " . $this->getOption('min_chars') . ",\n afterUpdateElement: ac_update_" . $this->generateId($name) . "\n });"); return $widgetInputHidden->render($name, $value, $attributes, $errors) . $widgetInput . '<span id="indicator-' . $this->generateId($name) . '" style="display: none;"> <img src="/sfExtraWidgetsPlugin/img/ajax-loader.gif" align="absmiddle" alt="Loading" /></span>' . $autocompleteDiv . $autocompleteJs; }
public function render($name, $value = null, $attributes = array(), $errors = array()) { $context = sfContext::getInstance(); $response = $context->getResponse(); $response->addJavascript('/sfFormExtraPlugin/js/jquery.autocompleter.js', 'last'); $response->addStylesheet('/sfFormExtraPlugin/css/jquery.autocompleter.css'); $autocompleteDiv = content_tag('div', '', array('id' => $this->generateId($name) . '_autocomplete', 'class' => 'autocomplete')); $autocompleteJs = $this->javascriptTag("\n jQuery(function(){\n jQuery('#" . $this->generateId($name) . "_ajaxtext').result(function(event, data, formatted) {\n " . $this->generateId($name) . "_jquery_autocomplete_changed = true;\n jQuery('#" . $this->generateId($name) . "').val(data[1]);\n jQuery('#" . get_id_from_name($name) . "_ajaxcheckbox').attr('checked',true);\n jQuery('#" . get_id_from_name($name) . "_ajaxcheckboxText').html('" . __('kiválasztva') . "');\n jQuery('#" . $this->generateId($name) . "').trigger('change', [data])\n });\n jQuery('#" . $this->generateId($name) . "_ajaxtext').autocomplete('" . url_for($this->getOption('url')) . "', {\n delay:30,\n minChars:0,\n extraParams : " . $this->getOption('extraParams') . ",\n max:30,\n width: 300,\n matchSubset:1,\n matchContains:1,\n cacheLength:10,\n autoFill:false,\n selectFirst: true\n });\n \n jQuery('#" . $this->generateId($name) . "_ajaxtext').bind('focus', function(){\n \t\t\tjQuery(this).setOptions({\n \t\t\t\tdelay:30,\n \t\t\t\tminChars:0,\n \t\t\t\textraParams : " . $this->getOption('extraParams') . ",\n \t\t\t\tmax:30,\n \t\t\t\twidth: 300,\n \t\t\t\tmatchSubset:1,\n \t\t\t\tmatchContains:1,\n \t\t\t\tcacheLength:10,\n \t\t\t\tautoFill:false,\n \t\t\t\tselectFirst: true\n \t\t\t});\n\t\t\t jQuery(this).flushCache(); \n }) \n \n jQuery.fn.autocomplete.keypressEvent = function (evt, id){\n car = evt.keyCode || evt.charCode;\n if (car != 27 && car!=9) //ESC + TAB\n {\n jQuery('#'+id).val('');\n jQuery('#'+id+'_ajaxcheckbox').attr('checked',false);\n jQuery('#'+id+'_ajaxcheckboxText').html('" . __('nincs kiválasztva') . "'); \n jQuery('#" . $this->generateId($name) . "').trigger('change')\n } \n } \n \n });"); $ihidden = new sfWidgetFormInputHidden(); $ihiddenText = $ihidden->render($name, $value, $attributes); if ($value != '') { $checked = 'checked="checked"'; $checkboxtext = "<span id='" . get_id_from_name($name) . "_ajaxcheckboxText'>" . __('kiválasztva') . "</span>"; } else { $checked = ''; $checkboxtext = "<span id='" . get_id_from_name($name) . "_ajaxcheckboxText'>" . __('nincs kiválasztva') . "</span>"; } $checkbox = '<input type="checkbox" id="' . get_id_from_name($name) . '_ajaxcheckbox' . '" ' . $checked . ' disabled="disabled" />'; $attributesText = array_merge($attributes, array('name' => false, 'id' => get_id_from_name($name) . '_ajaxtext')); $attributesText['onkeydown'] = "jQuery('#" . $this->generateId($name) . "_ajaxtext').autocomplete.keypressEvent(event, '" . $this->generateId($name) . "')"; $itextText = parent::render($name, $this->getValueFromId($value), $attributesText, $errors); $indicator = '<span id="indicator-' . $this->generateId($name) . '" style="display: none;"> <img src="/sfFormExtraPlugin/images/indicator.gif" alt="loading" /></span>'; return $ihiddenText . $itextText . $checkbox . $checkboxtext . $indicator . $autocompleteDiv . $autocompleteJs; }
public function render($name, $value = null, $attributes = array(), $errors = array()) { $attributes = array_merge($attributes, $this->getAttributes()); return parent::render($name, $value, $attributes, $errors); }
public function render($name, $value = null, $attributes = array(), $errors = array()) { $class = array('class' => ''); if (isset($attributes['class'])) { $class = array_merge($class, $attributes); $attributes['class'] .= ' hidden'; } $class = ' ' . $class['class']; $values = array_merge(array('text' => '', 'is_empty' => false), is_array($value) ? $value : array()); $obj_name = $this->getName($value); if ($this->getOption('default_name')) { $obj_name = $this->getOption('default_name'); } $input = parent::render($name, $value, $attributes, $errors); if (strlen($this->getOption('button_class')) > 0) { $class .= ' ' . $this->getOption('button_class'); } if ($this->getOption('button_is_hidden') && $value == 0) { $class .= ' hidden'; } $input .= '<div title="' . $this->getOption('box_title') . '" id="' . $this->generateId($name) . '_button" class="ref_name' . $class . '">'; $in_text = '<span class="on">' . __('Choose !') . '</span>'; $url_params = ''; if (count($this->getOption('url_params')) != 0) { $url_params = '?'; foreach ($this->getOption('url_params') as $k => $v) { $url_params .= urlencode($k) . '=' . urlencode($v); } } $partial_url_params = ''; if (count($this->getOption('partial_url_params')) != 0) { $partial_url_params = '?'; foreach ($this->getOption('partial_url_params') as $k => $v) { $partial_url_params .= urlencode($k) . '=' . urlencode($v); } } $hidden = ' hidden'; $json_splited_values = array(); $rendered_partial = ''; if (!empty($value)) { if (is_int($value) > 0) { $json_splited_values[] = array("id" => $value); $hidden = ''; } else { $splited_values = preg_split('/[,]/', $value); if (count($splited_values) > 0) { $hidden = ''; foreach ($splited_values as $split_val) { if (intval($split_val) > 0) { $json_splited_values[] = array("id" => $split_val); } } } } } if (count($json_splited_values) > 0) { try { $context = sfContext::getInstance(); $partial_request = new sfWebRequest($context->getEventDispatcher()); $partial_request->setMethod('POST'); $partial_request->setParameter('field_id', $this->generateId($name)); $partial_request->setParameter('row_data', $json_splited_values); $partial_request->setParameter('from_db', '1'); $partial_request->setParameter('catalogue', $this->getOption('model')); $partial_controler = new sfFrontWebController($context); $partial_controler_action = $partial_controler->getAction($this->getOption('partial_controler'), $this->getOption('partial_action')); $rendered_partial = $partial_controler_action->execute($partial_request); } catch (Exception $e) { $hidden = ' hidden'; $rendered_partial = ''; } } $input .= '<a href="' . url_for($this->getOption('link_url')) . $url_params . '" class="but_text_multiple">' . $in_text . '</a>'; $input .= '</div>'; $input .= '<div id="' . $this->generateId($name) . '_result_table" class="results_container but_ref_multiple' . $hidden . '"> <table class="results"> <thead> <tr> <th>' . __('Name') . '</th> <th>' . __('Level') . '</th> <th></th> </tr> </thead> <tbody>'; $input .= $rendered_partial; $input .= ' </tbody> </table> </div> '; $input .= '<script type="text/javascript"> $(document).ready(function () { $("#' . $this->generateId($name) . '_button a.but_text_multiple").button_ref_multiple({ q_tip_text : "Choose a ' . $this->getLabel() . '", update_row_fct: $.fn.button_ref_multiple.addEntry, ids_list_target_input_id: "#' . $this->generateId($name) . '", names_list_target_table_id: "#' . $this->generateId($name) . '_result_table", partial_url:"' . url_for($this->getOption('partial_url')) . $partial_url_params . '", attached_field_id:"' . $this->generateId($name) . '" });'; $on_change_attached_to_id = $this->getOption('on_change_attached_to_id'); $on_change_url_for_widget_renew = $this->getOption('on_change_url_for_widget_renew'); if (!empty($on_change_attached_to_id) && !empty($on_change_url_for_widget_renew)) { $input .= ' $("#' . $this->getOption('on_change_attached_to_id') . '").off("change").on( "change", { control_to_replace:"' . $this->generateId($name) . '", replacement_url:"' . url_for($this->getOption('on_change_url_for_widget_renew')) . '", replacement_url_name_param:"' . $this->getOption('on_change_url_for_widget_renew_params', '') . '", widget_button_ref_multiple_refresh:1 }, $.fn.button_ref_multiple.replaceControl );'; } $input .= ' }); </script>'; return $input; }
protected function renderHiddenInput($name, $values) { if (is_array($values) && count($values) > 0) { $hidden = new sfWidgetFormSelect(array('multiple' => true, 'is_hidden' => true, 'choices' => $values), array('style' => 'display: none')); } else { $hidden = new sfWidgetFormInputHidden(); } return $hidden->render($name, $values); }
protected function renderHiddenField($name, $value, $attributes = array()) { $input_hidden = new sfWidgetFormInputHidden(array(), $attributes); $values = $this->retrieveValueAsArray($value); return sprintf('%s%s%s', $input_hidden->render($name . '[year]', $values['year']), $input_hidden->render($name . '[month]', $values['month']), $input_hidden->render($name . '[day]', $values['day'])); }
/** * Renders a HTML content tag. * * @param string $name * @param <type> $value * @param array $attributes * @param array $errors */ public function render($name, $value = null, $attributes = array(), $errors = array()) { $display_container_id = sprintf("%s_display_%s", $this->getPrefix(), $this->generateId($name)); $tree_container_id = sprintf("%s_tree_%s", $this->getPrefix(), $this->generateId($name)); $hidden = new sfWidgetFormInputHidden(); $get_value = $this->getOption('show_value_callback'); return strtr('<div>%hidden%<div id="%display_container%" class="treelabel"><span class="%text_label_class%">%text%<span></div><div id="%tree_container%"></div></div>%script%', array('%display_container%' => $display_container_id, '%text_label_class%' => $value == null ? 'label not-found' : 'label found', '%text%' => $value == null ? $this->getOption('no_value_text') : ($get_value ? call_user_func($get_value, $value) : $value), '%hidden%' => $hidden->render($name, $value, $attributes, $errors), '%tree_container%' => $tree_container_id, '%script%' => $this->getJsScript($this->generateId($name), $value, $tree_container_id, $display_container_id))); }
<?php /* * This file is part of the symfony package. * (c) Fabien Potencier <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ require_once dirname(__FILE__) . '/../../bootstrap/unit.php'; $t = new lime_test(2, new lime_output_color()); $w = new sfWidgetFormInputHidden(); // ->render() $t->diag('->render()'); $t->is($w->render('foo'), '<input type="hidden" name="foo" id="foo" />', '->render() renders the widget as HTML'); // ->isHidden() $t->diag('->isHidden()'); $t->is($w->isHidden(), true, '->isHidden() returns true');
public function render($name, $value = null, $attributes = array(), $errors = array()) { $me = new sfWidgetFormInputHidden(); $widget_1 = $this->getWidgetWithoutCredentials($name, $value); $widget_2 = $this->getWidgetWithCredentials($name, $value); $widget_without_id = "div_without_" . $this->generateId($name); $widget_with_id = "div_with_" . $this->generateId($name); $button_without_id = "div_button_without_" . $this->generateId($name); $button_with_id = "div_button_with_" . $this->generateId($name); return strtr($this->getOption('template'), array('%hidden%' => $me->render($name, $value), '%widget_without_id%' => $widget_without_id, '%widget_without%' => $widget_1, '%widget_with_id%' => $widget_with_id, '%widget_with%' => $widget_2, '%button_without_id%' => $button_without_id, '%button_with_id%' => $button_with_id, '%button_without%' => $this->getButtonWithoutCredentials($name), '%button_with%' => $this->getButtonWithCredentials($name), '%hidden_id%' => "#" . $this->generateId($name), '%without_id%' => "#" . $this->generateId("without_{$name}"), '%with_id%' => "#" . $this->generateId("with_{$name}"))); }
public function render($name, $value = null, $attributes = array(), $errors = array()) { $values = array_merge(array('text' => '', 'is_empty' => false), is_array($value) ? $value : array()); $obj_name = $this->getName($value); $showedInputName = $this->generateId($name); $inputTagAttributes = array('type' => 'text', 'value' => $this->escapeOnce($obj_name), 'name' => $name); $input = '<ul class="container"><li>'; if ($this->getOption('behindScene')) { $input .= parent::render($name, $value, $attributes, $errors); array_splice($inputTagAttributes, 2); $showedInputName .= "_name"; } $inputTagAttributes['id'] = $showedInputName; $input .= $this->renderTag('input', $inputTagAttributes); $input .= '</li>'; if ($this->getOption('notExistingAddDisplay')) { $input .= '<li id="toggledMsg" class="hidden">' . '<label for="' . $this->generateId($name) . '_check">' . $this->getOption('notExistingAddTitle') . ':</label>' . '<select id="' . $this->generateId($name) . '_check">'; foreach ($this->getOption('notExistingAddValues') as $key => $option) { $input .= $this->renderContentTag('option', $option, array('selected' => $this->getOption('notExistingAddSelected') == $key ? "selected" : "", 'value' => $key)); } $input .= '</select></li>'; } $input .= '</ul>'; if (!function_exists('url_for')) { sfContext::getInstance()->getConfiguration()->loadHelpers('Url'); } $input .= sprintf(<<<EOF <script type="text/javascript"> \$(document).ready(function () { var cache = {}, lastXhr; \$('#%1\$s').autocomplete({ minLength: %6\$s, source: function( request, response ) { var term = request.term; if ( term in cache ) { response( cache[ term ] ); return; } lastXhr = \$.get('%3\$s', {q : request.term, limit: %5\$s }, function( data, status, xhr ) { ndata = data.split("\\n"); cache[ term ] = ndata; if ( xhr === lastXhr ) { response( ndata ); } }); }, select: function(event, ui) { \$('#%1\$s').closest('ul').children('li#toggledMsg').slideUp("fast"); } }).bind('blur',function (event) { \$(this).prev().val(''); \$(this).closest('ul').find('#toggledMsg select').val(0); \$.ajax({type: "GET", url: '%2\$s', async:false, //Unfortunaley keep this to avoid racing condition data: {'searchedCrit' : \$(this).val()}, success: function(html){ if (html == 'not found') { \$('#%1\$s').closest('ul').children('li#toggledMsg').show(); \$('#%1\$s').trigger('missing'); } else { \$('#%1\$s').closest('ul').children('li#toggledMsg').hide(); \$('#%8\$s').val(html); } } }); }); }); </script> EOF , $showedInputName, url_for($this->getOption('link_url')), url_for($this->getOption('link_url') . 'Limited'), $this->getOption('autocomplete'), $this->getOption('autocomplete_max'), $this->getOption('autocomplete_minChars'), $this->getOption('autocomplete_autoFill'), $this->generateId($name)); return $input; }
/** * Renders the widget. * * @param string $name The element name * @param string $value The value selected in this widget * @param array $attributes An array of HTML attributes to be merged with the default HTML attributes * @param array $errors An array of errors for the field * * @return string An HTML tag string * * @see sfWidgetForm */ public function render($name, $value = null, $attributes = array(), $errors = array()) { $input = new sfWidgetFormInputHidden(); return strtr($this->getOption('template'), array('%%id%%' => $name . '_star_rating', '%%input%%' => $input->render($name), '%%javascript%%' => $this->getJavascriptListeners($name))); }
protected function renderHiddenField($name, $value, $attributes = array()) { $input_hidden = new sfWidgetFormInputHidden(array(), $attributes); return $input_hidden->render($name, $value); }
/** * Renders the widget. * * @param string $name The element name * @param string $value The value displayed in this widget * @param array $attributes An array of HTML attributes to be merged with the default HTML attributes * @param array $errors An array of errors for the field * * @return string An HTML tag string * * @see sfWidgetForm * * showed_value, ha nem value kell hogy megjelenjen, de ilyenkor a value megy hiddenbe * sfWidgetFormDoctrineChoice nyoman lekrheto egy kapcsolt tabla adata is * * */ public function render($name, $value = null, $attributes = array(), $errors = array()) { $this->cached_value = false; if ($this->getOption('html') !== false) { return $this->renderContentTag('div', $this->getOption('html'), $attributes); } if ($this->getOption('cached_value') === true) { $this->cached_value = $value; } $attributesDiv = array_merge($attributes, array('id' => $this->generateId($name) . '_div')); if (false !== $this->getOption('model') || false !== $this->getOption('choices')) { $choices = $this->getChoices(); $hiddenInput = new sfWidgetFormInputHidden(); return $this->renderContentTag('div', isset($choices[$value]) ? $choices[$value] : $this->getOption('empty'), $attributesDiv) . $hiddenInput->render($name, $value, $attributes, $errors); } if (false !== $this->getOption('showed_value')) { $hiddenInput = new sfWidgetFormInputHidden(); return $this->renderContentTag('div', nl2br($this->getOption('showed_value')), $attributesDiv) . $hiddenInput->render($name, $value, $attributes, $errors); } elseif (false !== $this->getOption('has_hidden')) { $hiddenInput = new sfWidgetFormInputHidden(); return $this->renderContentTag('div', nl2br($value), $attributesDiv) . $hiddenInput->render($name, $value, $attributes, $errors); } return $this->renderContentTag('div', $value, $attributes); }
<div class="page" id="search_div"> <h1 id="title"><?php echo __('Specimens Search Result'); ?> </h1> <?php echo form_tag('specimensearch/search' . (isset($is_choose) ? '?is_choose=' . $is_choose : ''), array('class' => 'specimensearch_form', 'id' => 'specimen_filter')); ?> <ul id="intro" class="hidden"> <?php // Render all the form fields as hidden input if possible. if the value is an array or and object render them as usual foreach ($form as $row) { $w = new sfWidgetFormInputHidden(); $attributes = $form->getWidget($row->getName())->getAttributes(); if (is_string($row->getValue()) || is_null($row->getValue())) { echo '<li>' . $w->render($form->getWidgetSchema()->generateName($row->getName()), $row->getValue(), $attributes) . '</li>'; } else { echo '<li>' . $row . '</li>'; } } ?> </ul> <div class="search_results"> <div class="search_results_content"> <?php include_partial('searchSuccess', array('specimensearch' => $specimensearch, 'codes' => $codes, 'loans' => $loans, 'form' => $form, 'orderBy' => $orderBy, 's_url' => $s_url, 'orderDir' => $orderDir, 'currentPage' => $currentPage, 'pagerLayout' => $pagerLayout, 'is_specimen_search' => $is_specimen_search, 'columns' => $columns)); ?> </div> </div> <?php if (isset($is_pinned_only_search)) {
<p><?php echo __('Do you delete messages?'); ?> </p> <form action="<?php echo url_for('@' . $messageType . 'List'); ?> " method="post"> <?php slot('form'); echo $form->renderHiddenFields(); foreach ($form->getValue('message_ids') as $s_key => $s_value) { $tw = new sfWidgetFormInputHidden(array(), array()); $tw->addOption('name_format', $form->getWidgetSchema()->getNameFormat()); $tn = strtr($form->getWidgetSchema()->getNameFormat(), array('%s' => "message_ids")); echo $tw->render($tn . '[' . $s_key . ']', $s_value); } end_slot(); ?> <?php slot('form_global_error'); if ($form->hasGlobalErrors()) { echo $form->renderGlobalErrors(); } end_slot(); if (get_slot('form_global_error')) { echo get_slot('form_global_error'); ?> <br><br>
public function render($name, $value = null, $attributes = array(), $errors = array()) { $class = array('class' => ''); if (isset($attributes['class'])) { $class = array_merge($class, $attributes); $attributes['class'] .= ' hidden'; } $class = ' ' . $class['class']; $values = array_merge(array('text' => '', 'is_empty' => false), is_array($value) ? $value : array()); $obj_name = $this->getName($value); if ($this->getOption('default_name')) { $obj_name = $this->getOption('default_name'); } $edit_route = $this->getOption('edit_route', null); $edit_route_params = $this->getOption('edit_route_params', array()); if (!empty($edit_route) && !empty($obj_name) && count($edit_route_params) != 0) { $route_params = array(); foreach ($edit_route_params as $route_param) { switch ($route_param) { case "id": $route_params[$route_param] = $value; case "name": $route_params[$route_param] = $obj_name; } } $obj_name = link_to($obj_name, $edit_route . '?' . http_build_query($route_params)); } $input = parent::render($name, $value, $attributes, $errors); $input .= $this->renderContentTag('div', $obj_name, array('id' => $this->generateId($name) . "_name", 'class' => "ref_name" . $class)); if ($this->getOption('nullable')) { $options = array('src' => '/images/remove.png', 'id' => $this->generateId($name) . "_clear", 'class' => "ref_clear" . $class); if ($value == 0) { $options['class'] .= ' hidden'; } $input .= $this->renderTag('img', $options); } if (strlen($this->getOption('button_class')) > 0) { $class .= ' ' . $this->getOption('button_class'); } if ($this->getOption('button_is_hidden') && $value == 0) { $class .= ' hidden'; } $input .= '<div title="' . $this->getOption('box_title') . '" id="' . $this->generateId($name) . '_button" class="ref_name' . $class . '">'; $in_text = '<span class="on'; if (!($obj_name == '' || $obj_name == '-')) { $in_text .= ' hidden'; } $in_text .= '">' . __('Choose !') . '</span><span class="off'; if ($obj_name == '' || $obj_name == '-') { $in_text .= ' hidden'; } $in_text .= '">' . __('Change !') . '</span>'; $url_params = ''; if (count($this->getOption('url_params')) != 0) { $url_params = '?'; foreach ($this->getOption('url_params') as $k => $v) { $url_params .= urlencode($k) . '=' . urlencode($v); } } $input .= '<a href="' . url_for($this->getOption('link_url')) . $url_params . '" class="but_text">' . $in_text . '</a>'; $input .= '</div>'; $input .= '<script type="text/javascript"> $(document).ready(function () { $("#' . $this->generateId($name) . '_button a.but_text").click(button_ref_modal);'; if ($this->getOption('nullable')) { $input .= '$("#' . $this->generateId($name) . '_clear").click(button_ref_clear);'; } $input .= '});</script>'; return $input; }
/** * Returns a list of filter criterias buttons. It's a kind of toolbar * if there is onlye one filter criteria, don't show toolbar * * @param $name Widget's name * @param csWidgetFormStudentManyFilterCriteria $current_fc Represents current selected filter criteria * @return string */ protected function getFilterCriteriasTitle($name, csWidgetFormStudentManyFilterCriteria $current_fc) { if (count($this->getOption('filter_criterias')) == 1) { return ''; } $hidden_widget = new sfWidgetFormInputHidden(); $id = $this->generateId($name . "_current_filter"); $value = "class=" . get_class($current_fc) . "&options=" . base64_encode(serialize($current_fc->getOptions())) . "&name={$name}"; $ret = $hidden_widget->render($name . "[current_filter]", $value, array('id' => $id)); $container_id = "cs_student_many_unassociated_containter_" . $this->generateId($name); foreach ($this->getOption('filter_criterias') as $fc) { $class = get_class($fc); $options = base64_encode(serialize($fc->getOptions())); $params = "class={$class}&options={$options}&name={$name}"; $url = $this->getOption('update_filter_criterias'); $content = sprintf('<a href="#" onclick="%s">%s</a>', "csWidgetFormStudentMany.changeCurrentFilter('{$id}','{$container_id}','{$url}','{$params}'); return false;", $fc->getOption('title')); $ret .= "<li>{$content}</li>"; } return "<ul class='filter_criterias'>{$ret}</ul>"; }