/** * Returns a link that will trigger a javascript function using the * onclick handler and return false after the fact. * * Examples: * <?php echo link_to_function('Greeting', "alert('Hello world!')") ?> * <?php echo link_to_function(image_tag('delete'), "do_delete()", array('confirm' => 'Really?')) ?> */ function link_to_function($name, $function, $html_options = array()) { $html_options = _parse_attributes($html_options); $html_options['href'] = isset($html_options['href']) ? $html_options['href'] : '#'; if (isset($html_options['confirm'])) { $confirm = escape_javascript($html_options['confirm']); unset($html_options['confirm']); $function = "if(window.confirm('{$confirm}')){ {$function};}"; } $html_options['onclick'] = $function . '; return false;'; return content_tag('a', $name, $html_options); }
public function update_key() { $this->header('Content-Type: application/javascript', 200); $this->layout = false; $this->key = Pki::update($_GET['id'], $_POST['pki']); if ($this->key->save()) { echo "facebox.close();window.location.href=window.location.href;"; } else { $this->key->id = $_GET['id']; $return = escape_javascript($this->render_partial('user/edit_key.php')); echo "\$('pki').replace('{$return}');"; } $this->has_rendered = true; }
/** * Returns the javascript needed for a remote function. * Takes the same arguments as 'link_to_remote()'. * * Example: * <select id="options" onchange="<?php echo remote_function(array('update' => 'options', 'url' => '@update_options')) ?>"> * <option value="0">Hello</option> * <option value="1">World</option> * </select> */ function ls_remote_function($options) { sfContext::getInstance()->getResponse()->addJavascript(sfConfig::get('sf_prototype_web_dir') . '/js/prototype'); $javascript_options = _options_for_ajax($options); $update = ''; if (isset($options['update']) && is_array($options['update'])) { $update = array(); if (isset($options['update']['success'])) { $update[] = "success:'" . $options['update']['success'] . "'"; } if (isset($options['update']['failure'])) { $update[] = "failure:'" . $options['update']['failure'] . "'"; } $update = '{' . join(',', $update) . '}'; } else { if (isset($options['update'])) { $update .= "'" . $options['update'] . "'"; } } $function = !$update ? "new Ajax.Request(" : "new Ajax.Updater({$update}, "; $function .= '\'' . url_for($options['url']) . '\''; //ADDED TO ALLOW FOR APPENDING HASHES TO URLS FOR AJAX if (isset($options['posturl'])) { $function .= ' + ' . $options['posturl']; } $function .= ', ' . $javascript_options . ')'; if (isset($options['before'])) { $function = $options['before'] . '; ' . $function; } if (isset($options['after'])) { $function = $function . '; ' . $options['after']; } if (isset($options['condition'])) { $function = 'if (' . $options['condition'] . ') { ' . $function . '; }'; } if (isset($options['confirm'])) { $function = "if (confirm('" . escape_javascript($options['confirm']) . "')) { {$function}; }"; if (isset($options['cancel'])) { $function = $function . ' else { ' . $options['cancel'] . ' }'; } } return $function . ';'; }
$cache_attribs_string = ''; $rsAttrGroup = sql("SELECT `attribute_groups`.`id`, IFNULL(`sys_trans_text`.`text`, `attribute_groups`.`name`) AS `name`, `attribute_categories`.`color` \n\t\t\t FROM `attribute_groups` \n\t\t\t INNER JOIN `attribute_categories` ON `attribute_groups`.`category_id`=`attribute_categories`.`id` \n\t\t\t LEFT JOIN `sys_trans` ON `attribute_groups`.`trans_id`=`sys_trans`.`id`\n\t\t\t LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&1'\n\t\t\t ORDER BY `attribute_groups`.`category_id` ASC, `attribute_groups`.`id` ASC", $locale); while ($rAttrGroup = sql_fetch_assoc($rsAttrGroup)) { $group_line = ''; $rs = sql("SELECT `cache_attrib`.`id`, IFNULL(`ttname`.`text`, `cache_attrib`.`name`) AS `name`, `cache_attrib`.`icon_undef`, `cache_attrib`.`icon_large`, IFNULL(`ttdesc`.`text`, `cache_attrib`.`html_desc`) AS `html_desc` \n\t\t\t\t FROM `cache_attrib` \n\t\t LEFT JOIN `sys_trans` AS `tname` ON `cache_attrib`.`trans_id`=`tname`.`id` AND `cache_attrib`.`name`=`tname`.`text`\n\t\t LEFT JOIN `sys_trans_text` AS `ttname` ON `tname`.`id`=`ttname`.`trans_id` AND `ttname`.`lang`='&1'\n\t\t LEFT JOIN `sys_trans` AS `tdesc` ON `cache_attrib`.`html_desc_trans_id`=`tdesc`.`id` AND `cache_attrib`.`html_desc`=`tdesc`.`text`\n\t\t LEFT JOIN `sys_trans_text` AS `ttdesc` ON `tdesc`.`id`=`ttdesc`.`trans_id` AND `ttdesc`.`lang`='&1'\n\t\t\t\t WHERE `cache_attrib`.`group_id`=" . ($rAttrGroup['id'] + 0) . " AND\n\t\t\t\t\t\t\tNOT IFNULL(`cache_attrib`.`hidden`, 0)=1 AND \n\t\t\t\t\t\t\t `cache_attrib`.`selectable`!=0 ORDER BY `cache_attrib`.`group_id`, `cache_attrib`.`id`", $locale); while ($record = sql_fetch_array($rs)) { $line = $cache_attrib_pic; $line = mb_ereg_replace('{attrib_id}', $record['id'], $line); $line = mb_ereg_replace('{attrib_text}', escape_javascript($record['name']), $line); if (in_array($record['id'], $cache_attribs)) { $line = mb_ereg_replace('{attrib_pic}', $record['icon_large'], $line); } else { $line = mb_ereg_replace('{attrib_pic}', $record['icon_undef'], $line); } $line = mb_ereg_replace('{html_desc}', escape_javascript($record['html_desc']), $line); $line = mb_ereg_replace('{name}', escape_javascript($record['name']), $line); $line = mb_ereg_replace('{color}', $rAttrGroup['color'], $line); $group_line .= $line; $nLineAttrCount++; $line = $cache_attrib_js; $line = mb_ereg_replace('{id}', $record['id'], $line); if (in_array($record['id'], $cache_attribs)) { $line = mb_ereg_replace('{selected}', 1, $line); } else { $line = mb_ereg_replace('{selected}', 0, $line); } $line = mb_ereg_replace('{img_undef}', $record['icon_undef'], $line); $line = mb_ereg_replace('{img_large}', $record['icon_large'], $line); if ($cache_attrib_array != '') { $cache_attrib_array .= ','; }
function _lwButtonJs($options = array()) { $js_options = array(); foreach ($options as $k => $v) { $js_options[] = "{$k}: '" . escape_javascript($v) . "'"; } $js = 'myLightWindow.activateWindow({' . implode(', ', $js_options) . '}); return false;'; return $js; }
/** * Returns the javascript needed for a remote function. * Takes the same arguments as 'jq_link_to_remote()'. * * Example: * <select id="options" onchange="<?php echo remote_function(array('update' => 'options', 'url' => '@update_options')) ?>"> * <option value="0">Hello</option> * <option value="1">World</option> * </select> */ function jq_remote_function($options) { // Defining elements to update if (isset($options['update']) && is_array($options['update'])) { // On success, update the element with returned data if (isset($options['update']['success'])) { $update_success = "#" . $options['update']['success']; } // On failure, execute a client-side function if (isset($options['update']['failure'])) { $update_failure = $options['update']['failure']; } } else { if (isset($options['update'])) { $update_success = "#" . $options['update']; } } // Update method $updateMethod = _update_method(isset($options['position']) ? $options['position'] : ''); // Callbacks if (isset($options['loading'])) { $callback_loading = $options['loading']; } if (isset($options['complete'])) { $callback_complete = $options['complete']; } if (isset($options['success'])) { $callback_success = $options['success']; } $execute = 'false'; if (isset($options['script']) && $options['script'] == '1') { $execute = 'true'; } // Data Type if (isset($options['dataType'])) { $dataType = $options['dataType']; } elseif ($execute) { $dataType = 'html'; } else { $dataType = 'text'; } // POST or GET ? $method = 'POST'; if (isset($options['method']) && strtoupper($options['method']) == 'GET') { $method = $options['method']; } // async or sync, async is default if (isset($options['type']) && $options['type'] == 'synchronous') { $type = 'false'; } // Is it a form submitting if (isset($options['form'])) { $formData = 'jQuery(this).serialize()'; } elseif (isset($options['submit'])) { $formData = '{\'#' . $options['submit'] . '\'}.serialize()'; } elseif (isset($options['with'])) { $formData = $options['with']; } // build the function $function = "jQuery.ajax({"; $function .= 'type:\'' . $method . '\''; $function .= ',dataType:\'' . $dataType . '\''; if (isset($type)) { $function .= ',async:' . $type; } if (isset($formData)) { $function .= ',data:' . $formData; } if (isset($update_success) and !isset($callback_success)) { $function .= ',success:function(i){jQuery(\'' . $update_success . '\').' . $updateMethod . '(i);}'; } if (isset($update_failure)) { $function .= ',error:function(){' . $update_failure . '}'; } if (isset($callback_loading)) { $function .= ',beforeSend:function(){' . $callback_loading . '}'; } if (isset($callback_complete)) { $function .= ',complete:function(request){' . $callback_complete . '}'; } if (isset($callback_success)) { $function .= ',success:function(request){' . $callback_success . '}'; } $function .= ',url:\'' . url_for($options['url']) . '\''; $function .= '})'; if (isset($options['before'])) { $function = $options['before'] . '; ' . $function; } if (isset($options['after'])) { $function = $function . '; ' . $options['after']; } if (isset($options['condition'])) { $function = 'if (' . $options['condition'] . ') { ' . $function . '; }'; } if (isset($options['confirm'])) { $function = "if (confirm('" . escape_javascript($options['confirm']) . "')) { {$function}; }"; if (isset($options['cancel'])) { $function = $function . ' else { ' . $options['cancel'] . ' }'; } } return $function; }
function _confirm_javascript_function($confirm) { return "confirm('" . escape_javascript($confirm) . "')"; }
$t->is(tag('br', 'class=foo', false), '<br class="foo" />', 'tag() takes a string of options as its second parameters'); $t->is(tag('p', array('class' => 'foo', 'id' => 'bar'), true), '<p class="foo" id="bar">', 'tag() takes a boolean parameter as its third parameter'); //$t->is(tag('br', array('class' => '"foo"')), '<br class=""foo"" />'); // content_tag() $t->diag('content_tag()'); $t->is(content_tag(''), '', 'content_tag() returns an empty string with empty input'); $t->is(content_tag('', ''), '', 'content_tag() returns an empty string with empty input'); $t->is(content_tag('p', 'Toto'), '<p>Toto</p>', 'content_tag() takes a content as its second parameter'); $t->is(content_tag('p', ''), '<p></p>', 'content_tag() takes a tag as its first parameter'); // cdata_section() $t->diag('cdata_section()'); $t->is(cdata_section(''), '<![CDATA[]]>', 'cdata_section() returns a string wrapped into a CDATA section'); $t->is(cdata_section('foobar'), '<![CDATA[foobar]]>', 'cdata_section() returns a string wrapped into a CDATA section'); // escape_javascript() $t->diag('escape_javascript()'); $t->is(escape_javascript("alert('foo');\nalert(\"bar\");"), 'alert(\\\'foo\\\');\\nalert(\\"bar\\");', 'escape_javascript() escapes JavaScript scripts'); // _get_option() $t->diag('_get_option()'); $options = array('foo' => 'bar', 'bar' => 'foo'); $t->is(_get_option($options, 'foo'), 'bar', '_get_option() returns the value for the given key'); $t->ok(!isset($options['foo']), '_get_option() removes the key from the original array'); $t->is(_get_option($options, 'nofoo', 'nobar'), 'nobar', '_get_option() returns the default value if the key does not exist'); // escape_once() $t->diag('escape_once()'); $t->is(escape_once('This a > text to "escape"'), 'This a > text to "escape"', 'escape_once() escapes an HTML strings'); $t->is(escape_once(escape_once('This a > text to "escape"')), 'This a > text to "escape"', 'escape_once() does not escape an already escaped string'); $t->is(escape_once('This a > text to "escape"'), 'This a > text to "escape"', 'escape_once() does not escape an already escaped string'); $t->is(escape_once("This a > \"text\" to 'escape'"), "This a > "text" to 'escape'", 'escape_once() does not escape simple quotes but escape double quotes'); // fix_double_escape() $t->diag('fix_double_escape()'); $t->is(fix_double_escape(htmlspecialchars(htmlspecialchars('This a > text to "escape"'), ENT_QUOTES, 'UTF-8'), ENT_QUOTES, 'UTF-8'), 'This a > text to "escape"', 'fix_double_escape() fixes double escaped strings');
function outputSearchForm($options) { global $tpl, $login, $opt; global $error_plz, $error_locidnocoords, $error_ort, $error_noort, $error_nofulltext, $error_fulltexttoolong; global $cache_attrib_jsarray_line, $cache_attrib_group, $cache_attrib_img_line1, $cache_attrib_img_line2; global $DEFAULT_SEARCH_DISTANCE; $tpl->assign('formmethod', 'get'); // checkboxen $tpl->assign('logged_in', $login->logged_in()); if (isset($options['sort'])) { $bBynameChecked = $options['sort'] == 'byname'; } else { $bBynameChecked = !$login->logged_in(); } $tpl->assign('byname_checked', $bBynameChecked); if (isset($options['sort'])) { $bBydistanceChecked = $options['sort'] == 'bydistance'; } else { $bBydistanceChecked = $login->logged_in(); } $tpl->assign('bydistance_checked', $bBydistanceChecked); if (isset($options['sort'])) { $bBycreatedChecked = $options['sort'] == 'bycreated'; } else { $bBycreatedChecked = !$login->logged_in(); } $tpl->assign('bycreated_checked', $bBycreatedChecked); if (isset($options['sort'])) { $bBylastlogChecked = $options['sort'] == 'bylastlog'; } else { $bBylastlogChecked = $login->logged_in(); } $tpl->assign('bylastlog_checked', $bBylastlogChecked); if (isset($options['sort'])) { $bBymylastlogChecked = $options['sort'] == 'bymylastlog'; } else { $bBymylastlogChecked = $login->logged_in(); } $tpl->assign('bymylastlog_checked', $bBymylastlogChecked); $tpl->assign('hidopt_sort', $options['sort']); $tpl->assign('orderRatingFirst_checked', $options['orderRatingFirst']); $tpl->assign('hidopt_orderRatingFirst', $options['orderRatingFirst'] ? '1' : '0'); $tpl->assign('f_userowner_checked', $login->logged_in() && $options['f_userowner'] == 1); $tpl->assign('hidopt_userowner', $options['f_userowner'] == 1 ? '1' : '0'); $tpl->assign('f_userfound_checked', $login->logged_in() && $options['f_userfound'] == 1); $tpl->assign('hidopt_userfound', $options['f_userfound'] == 1 ? '1' : '0'); $tpl->assign('f_ignored_checked', $login->logged_in() && $options['f_ignored'] == 1); $tpl->assign('hidopt_ignored', $options['f_ignored'] == 1 ? '1' : '0'); $tpl->assign('f_disabled_checked', $options['f_disabled'] == 1); $tpl->assign('hidopt_disabled', $options['f_disabled'] == 1 ? '1' : '0'); // archived is called "disabled" here for backward compatibility $tpl->assign('f_inactive_checked', $options['f_inactive'] == 1); $tpl->assign('hidopt_inactive', $options['f_inactive'] == 1 ? '1' : '0'); $tpl->assign('f_otherPlatforms_checked', $options['f_otherPlatforms'] == 1); $tpl->assign('hidopt_otherPlatforms', $options['f_otherPlatforms'] == 1 ? '1' : '0'); $tpl->assign('f_geokrets_checked', $options['f_geokrets'] == 1); $tpl->assign('hidopt_geokrets', $options['f_geokrets'] == 1 ? '1' : '0'); if (!isset($options['country'])) { $options['country'] = ''; } $tpl->assign('country', htmlspecialchars($options['country'], ENT_COMPAT, 'UTF-8')); if (!isset($options['language'])) { $options['language'] = ''; } $tpl->assign('language', htmlspecialchars($options['language'], ENT_COMPAT, 'UTF-8')); if (isset($options['cachetype'])) { $tpl->assign('cachetype', htmlspecialchars($options['cachetype'], ENT_COMPAT, 'UTF-8')); } else { $tpl->assign('cachetype', ''); } // cachename $tpl->assign('cachename', isset($options['cachename']) ? htmlspecialchars($options['cachename'], ENT_COMPAT, 'UTF-8') : ''); // koordinaten if (!isset($options['lat_h'])) { if ($login->logged_in()) { $rs = sql('SELECT `latitude`, `longitude` FROM `user` WHERE `user_id`=\'' . sql_escape($login->userid) . '\''); $record = sql_fetch_array($rs); $lon = $record['longitude']; $lat = $record['latitude']; sql_free_result($rs); $tpl->assign('lonE_sel', $lon >= 0); $tpl->assign('lonW_sel', $lon < 0); $tpl->assign('latN_sel', $lat >= 0); $tpl->assign('latS_sel', $lat < 0); $lon_h = floor($lon); $lat_h = floor($lat); $lon_min = ($lon - $lon_h) * 60; $lat_min = ($lat - $lat_h) * 60; $tpl->assign('lat_h', $lat_h); $tpl->assign('lon_h', $lon_h); $tpl->assign('lat_min', sprintf("%02.3f", $lat_min)); $tpl->assign('lon_min', sprintf("%02.3f", $lon_min)); } else { $tpl->assign('lat_h', '00'); $tpl->assign('lon_h', '000'); $tpl->assign('lat_min', '00.000'); $tpl->assign('lon_min', '00.000'); } } else { $tpl->assign('lat_h', isset($options['lat_h']) ? $options['lat_h'] : '00'); $tpl->assign('lon_h', isset($options['lon_h']) ? $options['lon_h'] : '000'); $tpl->assign('lat_min', isset($options['lat_min']) ? $options['lat_min'] : '00.000'); $tpl->assign('lon_min', isset($options['lon_min']) ? $options['lon_min'] : '00.000'); if ($options['lonEW'] == 'W') { $tpl->assign('lonE_sel', ''); $tpl->assign('lonW_sel', 'selected="selected"'); } else { $tpl->assign('lonE_sel', 'selected="selected"'); $tpl->assign('lonW_sel', ''); } if ($options['latNS'] == 'S') { $tpl->assign('latS_sel', 'selected="selected"'); $tpl->assign('latN_sel', ''); } else { $tpl->assign('latS_sel', ''); $tpl->assign('latN_sel', 'selected="selected"'); } } $tpl->assign('distance', isset($options['distance']) ? $options['distance'] : $DEFAULT_SEARCH_DISTANCE); if (!isset($options['unit'])) { $options['unit'] = $DEFAULT_DISTANCE_UNIT; } $tpl->assign('sel_km', $options['unit'] == 'km'); $tpl->assign('sel_sm', $options['unit'] == 'sm'); $tpl->assign('sel_nm', $options['unit'] == 'nm'); // plz $tpl->assign('plz', isset($options['plz']) ? htmlspecialchars($options['plz'], ENT_COMPAT, 'UTF-8') : ''); $tpl->assign('ort', isset($options['ort']) ? htmlspecialchars($options['ort'], ENT_COMPAT, 'UTF-8') : ''); // owner $tpl->assign('owner', isset($options['owner']) ? htmlspecialchars($options['owner'], ENT_COMPAT, 'UTF-8') : ''); // finder $tpl->assign('finder', isset($options['finder']) ? htmlspecialchars($options['finder'], ENT_COMPAT, 'UTF-8') : ''); // country options $rs = sql("\n\t\tSELECT\n\t\t\tIFNULL(`sys_trans_text`.`text`, `countries`.`name`) AS `name`,\n\t\t\t`countries`.`short`,\n\t\t\t`countries`.`short`='&2' AS `selected`\n\t\tFROM\n\t\t\t`countries`\n\t\t\tLEFT JOIN `sys_trans` ON `countries`.`trans_id`=`sys_trans`.`id`AND `sys_trans`.`text`=`countries`.`name`\n\t\t\tLEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&1'\n\t\tWHERE\n\t\t\t`countries`.`short` IN (SELECT DISTINCT `country` FROM `caches`) ORDER BY `name` ASC", $opt['template']['locale'], $options['country']); $tpl->assign_rs('countryoptions', $rs); sql_free_result($rs); $tpl->assign('all_countries', $options['country'] == ''); // language options $rs = sql("\n\t\tSELECT\n\t\t\tIFNULL(`sys_trans_text`.`text`,`languages`.`name`) AS `name`,\n\t\t\t`short`,\n\t\t\t`short`='&2' AS `selected`\n\t\tFROM\n\t\t\t`languages`\n\t\t\tLEFT JOIN `sys_trans` ON `sys_trans`.`text`=`languages`.`name`\n\t\t\tLEFT JOIN `sys_trans_text` ON `sys_trans_text`.`trans_id`=`sys_trans`.`id` AND `sys_trans_text`.`lang`='&1'\n\t\t\tORDER BY `name`", $opt['template']['locale'], $options['language']); $tpl->assign_rs('languageoptions', $rs); sql_free_result($rs); $tpl->assign('all_languages', $options['language'] == ''); // cachetype $rs = sql("SELECT `id` FROM `cache_type` ORDER BY `ordinal`"); $rCachetypes = sql_fetch_assoc_table($rs); foreach ($rCachetypes as &$rCachetype) { $rCachetype['checked'] = $options['cachetype'] == '' || strpos(';' . $options['cachetype'] . ';', ';' . $rCachetype['id'] . ';') !== false; $rCachetype['unchecked'] = !$rCachetype['checked']; } $tpl->assign('cachetypes', $rCachetypes); $tpl->assign('cachetype', $options['cachetype']); // cachesize $cachesizes = array(); $rs = sql("SELECT `id` FROM `cache_size`"); while ($r = sql_fetch_assoc($rs)) { $cachesizes[$r['id']]['checked'] = strpos(';' . $options['cachesize'] . ';', ';' . $r['id'] . ';') !== false || $options['cachesize'] == ''; } sql_free_result($rs); $tpl->assign('cachesizes', $cachesizes); $tpl->assign('cachesize', $options['cachesize']); // difficulty + terrain $tpl->assign('difficultymin', $options['difficultymin']); $tpl->assign('difficultymax', $options['difficultymax']); $tpl->assign('difficulty_options', array(0, 2, 3, 4, 5, 6, 7, 8, 9, 10)); $tpl->assign('terrainmin', $options['terrainmin']); $tpl->assign('terrainmax', $options['terrainmax']); $tpl->assign('terrain_options', array(0, 2, 3, 4, 5, 6, 7, 8, 9, 10)); // logtypen if (isset($options['logtype'])) { $logtypes = explode(',', $options['logtype']); } else { $logtypes = array(); } $rs = sql("\n\t\tSELECT `id`,\n\t\tIFNULL(`sys_trans_text`.`text`, `log_types`.`name`) AS `name`,\n\t\t`id`='&2' as `selected`\n\t\tFROM (\n\t\t\tSELECT `id`,`name`,`trans_id` FROM `log_types`\n\t\t\tUNION\n\t\t\tSELECT 0,'all',(SELECT id FROM sys_trans WHERE `text`='all')\n\t\t) `log_types`\n\t\tLEFT JOIN `sys_trans_text` ON `sys_trans_text`.`trans_id`=`log_types`.`trans_id` AND `sys_trans_text`.`lang`='&1'\n\t ORDER BY `log_types`.`id` ASC", $opt['template']['locale'], $logtypes ? $logtypes[0] : 0); $tpl->assign_rs('logtype_options', $rs); sql_free_result($rs); // cache-attributes $attributes_jsarray = ''; $bBeginLine2 = true; $nPrevLineAttrCount2 = 0; $nLineAttrCount2 = 0; $attributes_img2 = ''; /* perpare 'all attributes' */ $rsAttrGroup = sql("SELECT `attribute_groups`.`id`, IFNULL(`sys_trans_text`.`text`, `attribute_groups`.`name`) AS `name`, `attribute_categories`.`color` FROM `attribute_groups` INNER JOIN `attribute_categories` ON `attribute_groups`.`category_id`=`attribute_categories`.`id` LEFT JOIN `sys_trans` ON `attribute_groups`.`trans_id`=`sys_trans`.`id` AND `sys_trans`.`text`=`attribute_groups`.`name` LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&1' ORDER BY `attribute_groups`.`category_id` ASC, `attribute_groups`.`id` ASC", $opt['template']['locale']); while ($rAttrGroup = sql_fetch_assoc($rsAttrGroup)) { $group_line = ''; $rs = sql("SELECT `cache_attrib`.`id`, IFNULL(`ttname`.`text`, `cache_attrib`.`name`) AS `name`, `cache_attrib`.`icon_large`, `cache_attrib`.`icon_no`, `cache_attrib`.`icon_undef`, `cache_attrib`.`search_default`, IFNULL(`ttdesc`.`text`, `cache_attrib`.`html_desc`) AS `html_desc`\n\t\t FROM `cache_attrib`\n\t\t LEFT JOIN `sys_trans` AS `tname` ON `cache_attrib`.`trans_id`=`tname`.`id` AND `cache_attrib`.`name`=`tname`.`text`\n\t\t LEFT JOIN `sys_trans_text` AS `ttname` ON `tname`.`id`=`ttname`.`trans_id` AND `ttname`.`lang`='&1'\n\t\t LEFT JOIN `sys_trans` AS `tdesc` ON `cache_attrib`.`html_desc_trans_id`=`tdesc`.`id` AND `cache_attrib`.`html_desc`=`tdesc`.`text`\n\t\t LEFT JOIN `sys_trans_text` AS `ttdesc` ON `tdesc`.`id`=`ttdesc`.`trans_id` AND `ttdesc`.`lang`='&1'\n\t\t WHERE `cache_attrib`.`group_id`='&2' AND `selectable`\n\t\t\t\t\t AND NOT IFNULL(`cache_attrib`.`hidden`, 0)=1\n\t\t ORDER BY `cache_attrib`.`id`", $opt['template']['locale'], $rAttrGroup['id']); while ($record = sql_fetch_array($rs)) { // icon specified $line = $cache_attrib_jsarray_line; $line = mb_ereg_replace('{id}', $record['id'], $line); if (!isset($options['cache_attribs'])) { $line = mb_ereg_replace('{state}', 0, $line); } else { if (array_search($record['id'], $options['cache_attribs']) === false) { if (array_search($record['id'], $options['cache_attribs_not']) === false) { $line = mb_ereg_replace('{state}', 0, $line); } else { $line = mb_ereg_replace('{state}', 2, $line); } } else { $line = mb_ereg_replace('{state}', 1, $line); } } $line = mb_ereg_replace('{text_long}', escape_javascript($record['name']), $line); $line = mb_ereg_replace('{icon}', $record['icon_large'], $line); $line = mb_ereg_replace('{icon_no}', $record['icon_no'], $line); $line = mb_ereg_replace('{icon_undef}', $record['icon_undef'], $line); $line = mb_ereg_replace('{search_default}', $record['search_default'], $line); if ($attributes_jsarray != '') { $attributes_jsarray .= ",\n"; } $attributes_jsarray .= $line; $line = $cache_attrib_img_line1; $line = mb_ereg_replace('{id}', $record['id'], $line); $line = mb_ereg_replace('{text_long}', escape_javascript($record['name']), $line); if (!isset($options['cache_attribs'])) { $line = mb_ereg_replace('{icon}', $record['icon_undef'], $line); } else { if (array_search($record['id'], $options['cache_attribs']) === false) { if (array_search($record['id'], $options['cache_attribs_not']) === false) { $line = mb_ereg_replace('{icon}', $record['icon_undef'], $line); } else { $line = mb_ereg_replace('{icon}', $record['icon_no'], $line); } } else { $line = mb_ereg_replace('{icon}', $record['icon_large'], $line); } } $line = mb_ereg_replace('{html_desc}', escape_javascript($record['html_desc']), $line); $line = mb_ereg_replace('{name}', escape_javascript($record['name']), $line); $line = mb_ereg_replace('{color}', $rAttrGroup['color'], $line); $group_line .= $line; $nLineAttrCount2++; } sql_free_result($rs); if ($group_line != '') { $group_img = $cache_attrib_group; $group_img = mb_ereg_replace('{color}', $rAttrGroup['color'], $group_img); $group_img = mb_ereg_replace('{attribs}', $group_line, $group_img); $group_img = mb_ereg_replace('{name}', htmlspecialchars($rAttrGroup['name'], ENT_COMPAT, 'UTF-8'), $group_img); if ($bBeginLine2 == true) { $attributes_img2 .= '<div id="attribs2">'; $bBeginLine2 = false; } $attributes_img2 .= $group_img; $nPrevLineAttrCount2 += $nLineAttrCount2; $nLineAttrCount2 = 0; } } sql_free_result($rsAttrGroup); if ($bBeginLine2 == false) { $attributes_img2 .= '</div>'; } /* prepare default attributes */ $bBeginLine1 = true; $nPrevLineAttrCount1 = 0; $nLineAttrCount1 = 0; $attributes_img1 = ''; $rsAttrGroup = sql("SELECT `attribute_groups`.`id`, IFNULL(`sys_trans_text`.`text`, `attribute_groups`.`name`) AS `name`, `attribute_categories`.`color` FROM `attribute_groups` INNER JOIN `attribute_categories` ON `attribute_groups`.`category_id`=`attribute_categories`.`id` LEFT JOIN `sys_trans` ON `attribute_groups`.`trans_id`=`sys_trans`.`id` AND `sys_trans`.`text`=`attribute_groups`.`name` LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&1' ORDER BY `attribute_groups`.`category_id` ASC, `attribute_groups`.`id` ASC", $opt['template']['locale']); while ($rAttrGroup = sql_fetch_assoc($rsAttrGroup)) { $group_line = ''; $rs = sql("SELECT `cache_attrib`.`id`, IFNULL(`ttname`.`text`, `cache_attrib`.`name`) AS `name`, `cache_attrib`.`icon_large`, `cache_attrib`.`icon_no`, `cache_attrib`.`icon_undef`, `cache_attrib`.`search_default`, IFNULL(`ttdesc`.`text`, `cache_attrib`.`html_desc`) AS `html_desc`\n\t\t FROM `cache_attrib`\n\t\t LEFT JOIN `sys_trans` AS `tname` ON `cache_attrib`.`trans_id`=`tname`.`id` AND `cache_attrib`.`name`=`tname`.`text`\n\t\t LEFT JOIN `sys_trans_text` AS `ttname` ON `tname`.`id`=`ttname`.`trans_id` AND `ttname`.`lang`='&1'\n\t\t LEFT JOIN `sys_trans` AS `tdesc` ON `cache_attrib`.`html_desc_trans_id`=`tdesc`.`id` AND `cache_attrib`.`html_desc`=`tdesc`.`text`\n\t\t LEFT JOIN `sys_trans_text` AS `ttdesc` ON `tdesc`.`id`=`ttdesc`.`trans_id` AND `ttdesc`.`lang`='&1'\n\t\t WHERE `cache_attrib`.`group_id`='&2'\n\t\t AND `cache_attrib`.`search_default`=1 AND `selectable`\n\t\t\t\t\t AND NOT IFNULL(`cache_attrib`.`hidden`, 0)=1\n\t\t ORDER BY `cache_attrib`.`id`", $opt['template']['locale'], $rAttrGroup['id']); while ($record = sql_fetch_array($rs)) { $line = $cache_attrib_img_line2; $line = mb_ereg_replace('{id}', $record['id'], $line); $line = mb_ereg_replace('{text_long}', escape_javascript($record['name']), $line); if (!isset($options['cache_attribs'])) { $line = mb_ereg_replace('{icon}', $record['icon_undef'], $line); } else { if (array_search($record['id'], $options['cache_attribs']) === false) { if (array_search($record['id'], $options['cache_attribs_not']) === false) { $line = mb_ereg_replace('{icon}', $record['icon_undef'], $line); } else { $line = mb_ereg_replace('{icon}', $record['icon_no'], $line); } } else { $line = mb_ereg_replace('{icon}', $record['icon_large'], $line); } } $line = mb_ereg_replace('{html_desc}', escape_javascript($record['html_desc']), $line); $line = mb_ereg_replace('{name}', escape_javascript($record['name']), $line); $line = mb_ereg_replace('{color}', $rAttrGroup['color'], $line); $group_line .= $line; $nLineAttrCount1++; } sql_free_result($rs); if ($group_line != '') { $group_img = $cache_attrib_group; $group_img = mb_ereg_replace('{color}', $rAttrGroup['color'], $group_img); $group_img = mb_ereg_replace('{attribs}', $group_line, $group_img); $group_img = mb_ereg_replace('{name}', htmlspecialchars($rAttrGroup['name'], ENT_COMPAT, 'UTF-8'), $group_img); if ($bBeginLine1 == true) { $attributes_img1 .= '<div id="attribs1">'; $bBeginLine1 = false; } $attributes_img1 .= $group_img; $nPrevLineAttrCount1 += $nLineAttrCount1; $nLineAttrCount1 = 0; } } sql_free_result($rsAttrGroup); if ($bBeginLine1 == false) { $attributes_img1 .= '</div>'; } $tpl->assign('cache_attribCat1_list', $attributes_img1); $tpl->assign('cache_attribCat2_list', $attributes_img2); $tpl->assign('attributes_jsarray', $attributes_jsarray); $tpl->assign('hidopt_attribs', isset($options['cache_attribs']) ? implode(';', $options['cache_attribs']) : ''); $tpl->assign('hidopt_attribs_not', isset($options['cache_attribs_not']) ? implode(';', $options['cache_attribs_not']) : ''); $tpl->assign('fulltext', ''); $tpl->assign('ft_desc_checked', true); $tpl->assign('ft_name_checked', true); $tpl->assign('ft_pictures_checked', false); $tpl->assign('ft_logs_checked', false); // fulltext options if ($options['searchtype'] == 'byfulltext') { if (!isset($options['fulltext'])) { $options['fulltext'] = ''; } $tpl->assign('fulltext', htmlspecialchars($options['fulltext'], ENT_COMPAT, 'UTF-8')); if (isset($options['ft_name'])) { $tpl->assign('ft_name_checked', $options['ft_name'] == 1); } if (isset($options['ft_desc'])) { $tpl->assign('ft_desc_checked', $options['ft_desc'] == 1); } if (isset($options['ft_logs'])) { $tpl->assign('ft_logs_checked', $options['ft_logs'] == 1); } if (isset($options['ft_pictures'])) { $tpl->assign('ft_pictures_checked', $options['ft_pictures'] == 1); } } // errormeldungen $tpl->assign('ortserror', ''); if (isset($options['error_plz'])) { $tpl->assign('ortserror', $error_plz); } else { if (isset($options['error_ort'])) { $tpl->assign('ortserror', $error_ort); } else { if (isset($options['error_locidnocoords'])) { $tpl->assign('ortserror', $error_locidnocoords); } else { if (isset($options['error_noort'])) { $tpl->assign('ortserror', $error_noort); } } } } $tpl->assign('fulltexterror', ''); if (isset($options['error_nofulltext'])) { $tpl->assign('fulltexterror', $error_nofulltext); } else { if (isset($options['error_fulltexttoolong'])) { $tpl->assign('fulltexterror', $error_fulltexttoolong); } } $tpl->display(); }
<tbody> <?php foreach ($permission_list as $permission) { ?> <tr> <td><?php echo $permission->getTitle(); ?> </td> <td><?php echo $permission->getCode(); ?> </td> <td> <?php echo jq_link_to_function('edit', "fillForm(" . $permission->getId() . ", '" . escape_javascript($permission->getTitle()) . "', '" . $permission->getCode() . "')", array('class' => 'link-edit')); ?> <?php echo link_to('remove', 'permission/delete?id=' . $permission->getId(), array('class' => 'link-de-activate', 'method' => 'delete', 'confirm' => 'Are you sure to delete \'' . $permission->choiceText() . '\'?')); ?> </td> </tr> <?php } ?> </tbody> </table> Items per page:
echo javascript_tag("\nfunction insertGadget(type, id, caption)\n{\n var parentIframe = parent.document.getElementsByTagName('iframe')[0];\n\n var typeId = 'plot' + type.charAt(0).toUpperCase() + type.substr(1, type.length - 1);\n var target = parentIframe.contentWindow.document.getElementById(typeId).getElementsByClassName('emptyGadget')[0];\n var contents = parentIframe.contentWindow.document.createElement('div');\n contents.setAttribute('class', 'gadget');\n contents.innerHTML = caption+'(<a href=\\'#\\' onclick=\\'dropNewGadget(\"'+type+'\", \"'+id+'\", this.parentNode); return false;\\'>" . __('削除') . "</a>)';\n new Insertion.Before(target, contents);\n\n var form = parent.document.getElementById('gadgetForm');\n var hidden = parent.document.createElement('input');\n hidden.setAttribute('class', type + 'New');\n hidden.setAttribute('type', 'hidden');\n hidden.setAttribute('name', 'new[' + type + '][]');\n hidden.setAttribute('value', id);\n new Insertion.Bottom(form, hidden);\n\n parentIframe.contentWindow.parent.adjustByIframeContens(parentIframe);\n}\n"); ?> <dl> <?php if ($config) { foreach ($config as $key => $value) { ?> <dt> <?php echo __($value['caption']['ja_JP']); ?> <br /> <?php echo link_to_function(__('このガジェットを追加する'), 'insertGadget(\'' . $type . '\', \'' . escape_javascript($key) . '\', \'' . escape_javascript(__($value['caption']['ja_JP'])) . '\')'); ?> </dt> <dd><?php echo __($value['description']['ja_JP']); ?> </dd> <?php } } else { ?> <dt><?php echo __('ガジェットがありません'); ?> </dt> <dd><?php
function outputSearchForm($options) { global $stylepath, $usr, $error_plz, $error_locidnocoords, $error_ort, $error_noort, $error_nofulltext, $error_fulltexttoolong; global $default_lang, $search_all_countries, $cache_attrib_jsarray_line; global $cache_attrib_group, $cache_attrib_img_line1, $cache_attrib_img_line2, $locale; //simple mode (only one easy filter) //$filters = read_file($stylepath . '/search.simple.tpl.php'); //tpl_set_var('filters', $filters, false); tpl_set_var('formmethod', 'get'); // checkboxen if (isset($options['sort'])) { $bBynameChecked = $options['sort'] == 'byname'; } else { $bBynameChecked = $usr['userid'] == 0; } tpl_set_var('byname_checked', $bBynameChecked == true ? ' checked="checked"' : ''); if (isset($options['sort'])) { $bBydistanceChecked = $options['sort'] == 'bydistance'; } else { $bBydistanceChecked = $usr['userid'] != 0; } tpl_set_var('bydistance_checked', $bBydistanceChecked == true ? ' checked="checked"' : ''); if (isset($options['sort'])) { $bBycreatedChecked = $options['sort'] == 'bycreated'; } else { $bBycreatedChecked = $usr['userid'] == 0; } tpl_set_var('bycreated_checked', $bBycreatedChecked == true ? ' checked="checked"' : ''); if (isset($options['sort'])) { $bBylastlogChecked = $options['sort'] == 'bylastlog'; } else { $bBylastlogChecked = $usr['userid'] != 0; } tpl_set_var('bylastlog_checked', $bBylastlogChecked == true ? ' checked="checked"' : ''); tpl_set_var('hidopt_sort', $options['sort']); tpl_set_var('orderRatingFirst_checked', $options['orderRatingFirst'] == true ? ' checked="checked"' : ''); tpl_set_var('hidopt_orderRatingFirst', $options['orderRatingFirst'] == true ? '1' : '0'); tpl_set_var('f_userfound_disabled', $usr['userid'] == 0 ? ' disabled="disabled"' : ''); if ($usr['userid'] != 0) { tpl_set_var('f_userfound_disabled', $options['f_userfound'] == 1 ? ' checked="checked"' : ''); } tpl_set_var('hidopt_userfound', $options['f_userfound'] == 1 ? '1' : '0'); tpl_set_var('f_userowner_disabled', $usr['userid'] == 0 ? ' disabled="disabled"' : ''); if ($usr['userid'] != 0) { tpl_set_var('f_userowner_disabled', $options['f_userowner'] == 1 ? ' checked="checked"' : ''); } tpl_set_var('hidopt_userowner', $options['f_userowner'] == 1 ? '1' : '0'); tpl_set_var('f_inactive_checked', $options['f_inactive'] == 1 ? ' checked="checked"' : ''); tpl_set_var('hidopt_inactive', $options['f_inactive'] == 1 ? '1' : '0'); tpl_set_var('f_ignored_disabled', $usr['userid'] == 0 ? ' disabled="disabled"' : ''); if ($usr['userid'] != 0) { tpl_set_var('f_ignored_disabled', $options['f_ignored'] == 1 ? ' checked="checked"' : ''); } tpl_set_var('hidopt_ignored', $options['f_ignored'] == 1 ? '1' : '0'); tpl_set_var('f_otherPlatforms_checked', $options['f_otherPlatforms'] == 1 ? ' checked="checked"' : ''); tpl_set_var('hidopt_otherPlatforms', $options['f_otherPlatforms'] == 1 ? '1' : '0'); if (isset($options['country'])) { tpl_set_var('country', htmlspecialchars($options['country'], ENT_COMPAT, 'UTF-8')); } else { tpl_set_var('country', ''); } if (isset($options['cachetype'])) { tpl_set_var('cachetype', htmlspecialchars($options['cachetype'], ENT_COMPAT, 'UTF-8')); } else { tpl_set_var('cachetype', ''); } // cachename tpl_set_var('cachename', isset($options['cachename']) ? htmlspecialchars($options['cachename'], ENT_COMPAT, 'UTF-8') : ''); // koordinaten if (!isset($options['lat_h'])) { if ($usr !== false) { $rs = sql('SELECT `latitude`, `longitude` FROM `user` WHERE `user_id`=\'' . sql_escape($usr['userid']) . '\''); $record = sql_fetch_array($rs); $lon = $record['longitude']; $lat = $record['latitude']; mysql_free_result($rs); if ($lon < 0) { tpl_set_var('lonE_sel', ''); tpl_set_var('lonW_sel', ' selected="selected"'); $lon = -$lon; } else { tpl_set_var('lonE_sel', ' selected="selected"'); tpl_set_var('lonW_sel', ''); } if ($lat < 0) { tpl_set_var('latN_sel', ''); tpl_set_var('latS_sel', ' selected="selected"'); $lat = -$lat; } else { tpl_set_var('latN_sel', ' selected="selected"'); tpl_set_var('latS_sel', ''); } $lon_h = floor($lon); $lat_h = floor($lat); $lon_min = ($lon - $lon_h) * 60; $lat_min = ($lat - $lat_h) * 60; tpl_set_var('lat_h', $lat_h); tpl_set_var('lon_h', $lon_h); tpl_set_var('lat_min', sprintf("%02.3f", $lat_min)); tpl_set_var('lon_min', sprintf("%02.3f", $lon_min)); } else { tpl_set_var('lat_h', '00'); tpl_set_var('lon_h', '000'); tpl_set_var('lat_min', '00.000'); tpl_set_var('lon_min', '00.000'); } } else { tpl_set_var('lat_h', isset($options['lat_h']) ? $options['lat_h'] : '00'); tpl_set_var('lon_h', isset($options['lon_h']) ? $options['lon_h'] : '000'); tpl_set_var('lat_min', isset($options['lat_min']) ? $options['lat_min'] : '00.000'); tpl_set_var('lon_min', isset($options['lon_min']) ? $options['lon_min'] : '00.000'); if ($options['lonEW'] == 'W') { tpl_set_var('lonE_sel', ''); tpl_set_var('lonW_sel', 'selected="selected"'); } else { tpl_set_var('lonE_sel', 'selected="selected"'); tpl_set_var('lonW_sel', ''); } if ($options['latNS'] == 'S') { tpl_set_var('latS_sel', 'selected="selected"'); tpl_set_var('latN_sel', ''); } else { tpl_set_var('latS_sel', ''); tpl_set_var('latN_sel', 'selected="selected"'); } } tpl_set_var('distance', isset($options['distance']) ? $options['distance'] : 75); if (!isset($options['unit'])) { $options['unit'] = 'km'; } if ($options['unit'] == 'km') { tpl_set_var('sel_km', 'selected="selected"'); tpl_set_var('sel_sm', ''); tpl_set_var('sel_nm', ''); } else { if ($options['unit'] == 'sm') { tpl_set_var('sel_km', ''); tpl_set_var('sel_sm', 'selected="selected"'); tpl_set_var('sel_nm', ''); } else { if ($options['unit'] == 'nm') { tpl_set_var('sel_km', ''); tpl_set_var('sel_sm', ''); tpl_set_var('sel_nm', 'selected="selected"'); } } } // plz tpl_set_var('plz', isset($options['plz']) ? htmlspecialchars($options['plz'], ENT_COMPAT, 'UTF-8') : ''); tpl_set_var('ort', isset($options['ort']) ? htmlspecialchars($options['ort'], ENT_COMPAT, 'UTF-8') : ''); // owner tpl_set_var('owner', isset($options['owner']) ? htmlspecialchars($options['owner'], ENT_COMPAT, 'UTF-8') : ''); // finder tpl_set_var('finder', isset($options['finder']) ? htmlspecialchars($options['finder'], ENT_COMPAT, 'UTF-8') : ''); //countryoptions $countriesoptions = $search_all_countries; $rs = sql("SELECT IFNULL(`sys_trans_text`.`text`, `countries`.`name`) AS `name`, `countries`.`short` FROM `countries` LEFT JOIN `sys_trans` ON `countries`.`trans_id`=`sys_trans`.`id` AND `sys_trans`.`text`=`countries`.`name` LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&1' WHERE `countries`.`short` IN (SELECT DISTINCT `country` FROM `caches`) ORDER BY `name` ASC", $locale); for ($i = 0; $i < mysql_num_rows($rs); $i++) { $record = sql_fetch_array($rs); if ($record['short'] == $options['country']) { $countriesoptions .= '<option value="' . htmlspecialchars($record['short'], ENT_COMPAT, 'UTF-8') . '" selected="selected">' . htmlspecialchars($record['name'], ENT_COMPAT, 'UTF-8') . '</option>'; } else { $countriesoptions .= '<option value="' . htmlspecialchars($record['short'], ENT_COMPAT, 'UTF-8') . '">' . htmlspecialchars($record['name'], ENT_COMPAT, 'UTF-8') . '</option>'; } $countriesoptions .= "\n"; } tpl_set_var('countryoptions', $countriesoptions); // cachetype + cachesize $nCount = sqlValue("SELECT COUNT(*) FROM `cache_type`", 0); for ($n = 1; $n <= $nCount; $n++) { tpl_set_var('cachetype' . $n . 'checked', strpos(';' . $options['cachetype'] . ';', ';' . $n . ';') !== false || $options['cachetype'] == '' ? ' checked="checked"' : ''); } $nCount = sqlValue("SELECT COUNT(*) FROM `cache_size`", 0); for ($n = 1; $n <= $nCount; $n++) { tpl_set_var('cachesize' . $n . 'checked', strpos(';' . $options['cachesize'] . ';', ';' . $n . ';') !== false || $options['cachesize'] == '' ? ' checked="checked"' : ''); } tpl_set_var('cachetype', $options['cachetype']); tpl_set_var('cachesize', $options['cachesize']); // difficulty + terrain $difficultymin_options = '<option value="0"' . ($options['difficultymin'] == 0 ? ' selected="selected"' : '') . '>-</option>' . "\n"; $difficultymax_options = '<option value="0"' . ($options['difficultymax'] == 0 ? ' selected="selected"' : '') . '>-</option>' . "\n"; $terrainmin_options = '<option value="0"' . ($options['terrainmin'] == 0 ? ' selected="selected"' : '') . '>-</option>' . "\n"; $terrainmax_options = '<option value="0"' . ($options['terrainmax'] == 0 ? ' selected="selected"' : '') . '>-</option>' . "\n"; for ($n = 2; $n <= 10; $n++) { $difficultymin_options .= '<option value="' . $n . '"' . ($options['difficultymin'] == $n ? ' selected="selected"' : '') . '>' . sprintf('%01.1f', $n / 2) . '</option>' . "\n"; $difficultymax_options .= '<option value="' . $n . '"' . ($options['difficultymax'] == $n ? ' selected="selected"' : '') . '>' . sprintf('%01.1f', $n / 2) . '</option>' . "\n"; $terrainmin_options .= '<option value="' . $n . '"' . ($options['terrainmin'] == $n ? ' selected="selected"' : '') . '>' . sprintf('%01.1f', $n / 2) . '</option>' . "\n"; $terrainmax_options .= '<option value="' . $n . '"' . ($options['terrainmax'] == $n ? ' selected="selected"' : '') . '>' . sprintf('%01.1f', $n / 2) . '</option>' . "\n"; } tpl_set_var('difficultymin_options', $difficultymin_options); tpl_set_var('difficultymax_options', $difficultymax_options); tpl_set_var('terrainmin_options', $terrainmin_options); tpl_set_var('terrainmax_options', $terrainmax_options); tpl_set_var('difficultymin', $options['difficultymin']); tpl_set_var('difficultymax', $options['difficultymax']); tpl_set_var('terrainmin', $options['terrainmin']); tpl_set_var('terrainmax', $options['terrainmax']); // logtypen $logtype_options = ''; $rs = sql("SELECT `log_types`.`id`, IFNULL(`sys_trans_text`.`text`, `log_types`.`name`) AS `name` FROM `log_types` LEFT JOIN `sys_trans` ON `log_types`.`trans_id`=`sys_trans`.`id` AND `sys_trans`.`text`=`log_types`.`name` LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&1' ORDER BY `id` ASC", $locale); for ($i = 0; $i < mysql_num_rows($rs); $i++) { $record = sql_fetch_array($rs); if (isset($options['logtype']) && $record['id'] == $options['logtype']) { $logtype_options .= '<option value="' . htmlspecialchars($record['id'], ENT_COMPAT, 'UTF-8') . '" selected="selected">' . htmlspecialchars($record['name'], ENT_COMPAT, 'UTF-8') . '</option>'; } else { $logtype_options .= '<option value="' . htmlspecialchars($record['id'], ENT_COMPAT, 'UTF-8') . '">' . htmlspecialchars($record['name'], ENT_COMPAT, 'UTF-8') . '</option>'; } $logtype_options .= "\n"; } tpl_set_var('logtype_options', $logtype_options); // cache-attributes $attributes_jsarray = ''; $bBeginLine2 = true; $nPrevLineAttrCount2 = 0; $nLineAttrCount2 = 0; $attributes_img2 = ''; /* perpare 'all attributes' */ $rsAttrGroup = sql("SELECT `attribute_groups`.`id`, IFNULL(`sys_trans_text`.`text`, `attribute_groups`.`name`) AS `name`, `attribute_categories`.`color` FROM `attribute_groups` INNER JOIN `attribute_categories` ON `attribute_groups`.`category_id`=`attribute_categories`.`id` LEFT JOIN `sys_trans` ON `attribute_groups`.`trans_id`=`sys_trans`.`id` AND `sys_trans`.`text`=`attribute_groups`.`name` LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&1' ORDER BY `attribute_groups`.`category_id` ASC, `attribute_groups`.`id` ASC", $locale); while ($rAttrGroup = sql_fetch_assoc($rsAttrGroup)) { $group_line = ''; $rs = sql("SELECT `cache_attrib`.`id`, IFNULL(`ttname`.`text`, `cache_attrib`.`name`) AS `name`, `cache_attrib`.`icon_large`, `cache_attrib`.`icon_no`, `cache_attrib`.`icon_undef`, `cache_attrib`.`search_default`, IFNULL(`ttdesc`.`text`, `cache_attrib`.`html_desc`) AS `html_desc`\n\t\t FROM `cache_attrib` \n\t\t LEFT JOIN `sys_trans` AS `tname` ON `cache_attrib`.`trans_id`=`tname`.`id` AND `cache_attrib`.`name`=`tname`.`text`\n\t\t LEFT JOIN `sys_trans_text` AS `ttname` ON `tname`.`id`=`ttname`.`trans_id` AND `ttname`.`lang`='&1'\n\t\t LEFT JOIN `sys_trans` AS `tdesc` ON `cache_attrib`.`html_desc_trans_id`=`tdesc`.`id` AND `cache_attrib`.`html_desc`=`tdesc`.`text`\n\t\t LEFT JOIN `sys_trans_text` AS `ttdesc` ON `tdesc`.`id`=`ttdesc`.`trans_id` AND `ttdesc`.`lang`='&1'\n\t\t WHERE `cache_attrib`.`group_id`='&2'\n\t\t\t\t\t AND NOT IFNULL(`cache_attrib`.`hidden`, 0)=1\n\t\t ORDER BY `cache_attrib`.`id`", $locale, $rAttrGroup['id']); while ($record = sql_fetch_array($rs)) { // icon specified $line = $cache_attrib_jsarray_line; $line = mb_ereg_replace('{id}', $record['id'], $line); if (!isset($options['cache_attribs'])) { $line = mb_ereg_replace('{state}', 0, $line); } else { if (array_search($record['id'], $options['cache_attribs']) === false) { if (array_search($record['id'], $options['cache_attribs_not']) === false) { $line = mb_ereg_replace('{state}', 0, $line); } else { $line = mb_ereg_replace('{state}', 2, $line); } } else { $line = mb_ereg_replace('{state}', 1, $line); } } $line = mb_ereg_replace('{text_long}', escape_javascript($record['name']), $line); $line = mb_ereg_replace('{icon}', $record['icon_large'], $line); $line = mb_ereg_replace('{icon_no}', $record['icon_no'], $line); $line = mb_ereg_replace('{icon_undef}', $record['icon_undef'], $line); $line = mb_ereg_replace('{search_default}', $record['search_default'], $line); if ($attributes_jsarray != '') { $attributes_jsarray .= ",\n"; } $attributes_jsarray .= $line; $line = $cache_attrib_img_line1; $line = mb_ereg_replace('{id}', $record['id'], $line); $line = mb_ereg_replace('{text_long}', escape_javascript($record['name']), $line); if (!isset($options['cache_attribs'])) { $line = mb_ereg_replace('{icon}', $record['icon_undef'], $line); } else { if (array_search($record['id'], $options['cache_attribs']) === false) { if (array_search($record['id'], $options['cache_attribs_not']) === false) { $line = mb_ereg_replace('{icon}', $record['icon_undef'], $line); } else { $line = mb_ereg_replace('{icon}', $record['icon_no'], $line); } } else { $line = mb_ereg_replace('{icon}', $record['icon_large'], $line); } } $line = mb_ereg_replace('{html_desc}', escape_javascript($record['html_desc']), $line); $line = mb_ereg_replace('{name}', escape_javascript($record['name']), $line); $line = mb_ereg_replace('{color}', $rAttrGroup['color'], $line); $group_line .= $line; $nLineAttrCount2++; } sql_free_result($rs); if ($group_line != '') { $group_img = $cache_attrib_group; $group_img = mb_ereg_replace('{color}', $rAttrGroup['color'], $group_img); $group_img = mb_ereg_replace('{attribs}', $group_line, $group_img); $group_img = mb_ereg_replace('{name}', htmlspecialchars($rAttrGroup['name'], ENT_COMPAT, 'UTF-8'), $group_img); if ($bBeginLine2 == true) { $attributes_img2 .= '<div id="attribs2">'; $bBeginLine2 = false; } $attributes_img2 .= $group_img; $nPrevLineAttrCount2 += $nLineAttrCount2; $nLineAttrCount2 = 0; } } sql_free_result($rsAttrGroup); if ($bBeginLine2 == false) { $attributes_img2 .= '</div>'; } /* prepare default attributes */ $bBeginLine1 = true; $nPrevLineAttrCount1 = 0; $nLineAttrCount1 = 0; $attributes_img1 = ''; $rsAttrGroup = sql("SELECT `attribute_groups`.`id`, IFNULL(`sys_trans_text`.`text`, `attribute_groups`.`name`) AS `name`, `attribute_categories`.`color` FROM `attribute_groups` INNER JOIN `attribute_categories` ON `attribute_groups`.`category_id`=`attribute_categories`.`id` LEFT JOIN `sys_trans` ON `attribute_groups`.`trans_id`=`sys_trans`.`id` AND `sys_trans`.`text`=`attribute_groups`.`name` LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&1' ORDER BY `attribute_groups`.`category_id` ASC, `attribute_groups`.`id` ASC", $locale); while ($rAttrGroup = sql_fetch_assoc($rsAttrGroup)) { $group_line = ''; $rs = sql("SELECT `cache_attrib`.`id`, IFNULL(`ttname`.`text`, `cache_attrib`.`name`) AS `name`, `cache_attrib`.`icon_large`, `cache_attrib`.`icon_no`, `cache_attrib`.`icon_undef`, `cache_attrib`.`search_default`, IFNULL(`ttdesc`.`text`, `cache_attrib`.`html_desc`) AS `html_desc`\n\t\t FROM `cache_attrib` \n\t\t LEFT JOIN `sys_trans` AS `tname` ON `cache_attrib`.`trans_id`=`tname`.`id` AND `cache_attrib`.`name`=`tname`.`text`\n\t\t LEFT JOIN `sys_trans_text` AS `ttname` ON `tname`.`id`=`ttname`.`trans_id` AND `ttname`.`lang`='&1'\n\t\t LEFT JOIN `sys_trans` AS `tdesc` ON `cache_attrib`.`html_desc_trans_id`=`tdesc`.`id` AND `cache_attrib`.`html_desc`=`tdesc`.`text`\n\t\t LEFT JOIN `sys_trans_text` AS `ttdesc` ON `tdesc`.`id`=`ttdesc`.`trans_id` AND `ttdesc`.`lang`='&1'\n\t\t WHERE `cache_attrib`.`group_id`='&2'\n\t\t AND `cache_attrib`.`search_default`=1\n\t\t\t\t\t AND NOT IFNULL(`cache_attrib`.`hidden`, 0)=1\n\t\t ORDER BY `cache_attrib`.`id`", $locale, $rAttrGroup['id']); while ($record = sql_fetch_array($rs)) { $line = $cache_attrib_img_line2; $line = mb_ereg_replace('{id}', $record['id'], $line); $line = mb_ereg_replace('{text_long}', escape_javascript($record['name']), $line); if (!isset($options['cache_attribs'])) { $line = mb_ereg_replace('{icon}', $record['icon_undef'], $line); } else { if (array_search($record['id'], $options['cache_attribs']) === false) { if (array_search($record['id'], $options['cache_attribs_not']) === false) { $line = mb_ereg_replace('{icon}', $record['icon_undef'], $line); } else { $line = mb_ereg_replace('{icon}', $record['icon_no'], $line); } } else { $line = mb_ereg_replace('{icon}', $record['icon_large'], $line); } } $line = mb_ereg_replace('{html_desc}', escape_javascript($record['html_desc']), $line); $line = mb_ereg_replace('{name}', escape_javascript($record['name']), $line); $line = mb_ereg_replace('{color}', $rAttrGroup['color'], $line); $group_line .= $line; $nLineAttrCount1++; } sql_free_result($rs); if ($group_line != '') { $group_img = $cache_attrib_group; $group_img = mb_ereg_replace('{color}', $rAttrGroup['color'], $group_img); $group_img = mb_ereg_replace('{attribs}', $group_line, $group_img); $group_img = mb_ereg_replace('{name}', htmlspecialchars($rAttrGroup['name'], ENT_COMPAT, 'UTF-8'), $group_img); if ($bBeginLine1 == true) { $attributes_img1 .= '<div id="attribs1">'; $bBeginLine1 = false; } $attributes_img1 .= $group_img; $nPrevLineAttrCount1 += $nLineAttrCount1; $nLineAttrCount1 = 0; } } sql_free_result($rsAttrGroup); if ($bBeginLine1 == false) { $attributes_img1 .= '</div>'; } tpl_set_var('cache_attribCat1_list', $attributes_img1); tpl_set_var('cache_attribCat2_list', $attributes_img2); tpl_set_var('attributes_jsarray', $attributes_jsarray); tpl_set_var('hidopt_attribs', isset($options['cache_attribs']) ? implode(';', $options['cache_attribs']) : ''); tpl_set_var('hidopt_attribs_not', isset($options['cache_attribs_not']) ? implode(';', $options['cache_attribs_not']) : ''); tpl_set_var('fulltext', ''); tpl_set_var('ft_name_checked', 'checked="checked"'); tpl_set_var('ft_desc_checked', ''); tpl_set_var('ft_logs_checked', ''); tpl_set_var('ft_pictures_checked', ''); // fulltext options if ($options['searchtype'] == 'byfulltext') { if (!isset($options['fulltext'])) { $options['fulltext'] = ''; } tpl_set_var('fulltext', htmlspecialchars($options['fulltext'], ENT_COMPAT, 'UTF-8')); if (isset($options['ft_name']) && $options['ft_name'] == 1) { tpl_set_var('ft_name_checked', 'checked="checked"'); } else { tpl_set_var('ft_name_checked', ''); } if (isset($options['ft_desc']) && $options['ft_desc'] == 1) { tpl_set_var('ft_desc_checked', 'checked="checked"'); } else { tpl_set_var('ft_desc_checked', ''); } if (isset($options['ft_logs']) && $options['ft_logs'] == 1) { tpl_set_var('ft_logs_checked', 'checked="checked"'); } else { tpl_set_var('ft_logs_checked', ''); } if (isset($options['ft_pictures']) && $options['ft_pictures'] == 1) { tpl_set_var('ft_pictures_checked', 'checked="checked"'); } else { tpl_set_var('ft_pictures_checked', ''); } } // errormeldungen tpl_set_var('ortserror', ''); if (isset($options['error_plz'])) { tpl_set_var('ortserror', $error_plz); } else { if (isset($options['error_ort'])) { tpl_set_var('ortserror', $error_ort); } else { if (isset($options['error_locidnocoords'])) { tpl_set_var('ortserror', $error_locidnocoords); } else { if (isset($options['error_noort'])) { tpl_set_var('ortserror', $error_noort); } } } } tpl_set_var('fulltexterror', ''); if (isset($options['error_nofulltext'])) { tpl_set_var('fulltexterror', $error_nofulltext); } else { if (isset($options['error_fulltexttoolong'])) { tpl_set_var('fulltexterror', $error_fulltexttoolong); } } tpl_BuildTemplate(); exit; }
/** * Paging html functions * @todo Document this API */ function pagination_limit_select($object_name_or_object, $options = array()) { $html = ""; if (is_object($object_name_or_object)) { $object = $object_name_or_object; } else { $object = $this->object($object_name_or_object); } if (!is_object($object)) { return null; } if ($object->pages > 0) { $base_url = isset($options['base_url']) ? $options['base_url'] : ''; $update = isset($options['update']) ? $options['update'] : ''; $extra_params = isset($options['extra_params']) ? "&" . $options['extra_params'] : ($object->paging_extra_params ? "&" . $object->paging_extra_params : ''); $default_text = isset($options['default_text']) ? $options['default_text'] : "per page:"; if ($update && $base_url) { $on_change = remote_function(array("update" => $update, "url" => "{$base_url}?per_page=' + this.options[this.selectedIndex].value + '" . escape_javascript($extra_params) . "'")); } else { $on_change = "document.location = '{$base_url}?per_page=' + this.options[this.selectedIndex].value + '" . escape_javascript($extra_params) . "'"; } $html .= "\n <select name=\"per_page\" onChange=\"{$on_change}\">\n <option value=\"{$object->rows_per_page}\" selected>{$default_text}</option>\n <option value=10>10</option>\n <option value=20>20</option>\n <option value=50>50</option>\n <option value=100>100</option>\n <option value=200>200</option>\n <option value=999999999>ALL</option>\n </select>\n "; } return $html; }
function _escape_body() { $result = ob_get_contents(); ob_end_clean(); $htmlEscape = _tag_get_attribute('escape_body', 'htmlEscape'); $jsEscape = _tag_get_attribute('escape_body', 'jsEscape'); if (is_null($jsEscape) || !is_bool($jsEscape)) { $jsEscape = false; } if ($jsEscape == true) { $result = escape_javascript($result); } if ($htmlEscape == true) { $result = specialchars($result); } return $result; }
function remote_function($options) { $obj =& get_instance(); $obj->response->enqueue_js('prototype'); $javascript_options = _options_for_ajax($options); $update = ''; if (isset($options['update']) && is_array($options['update'])) { $update = array(); if (isset($options['update']['success'])) { $update[] = "success:'" . $options['update']['success'] . "'"; } if (isset($options['update']['failure'])) { $update[] = "failure:'" . $options['update']['failure'] . "'"; } $update = '{' . join(',', $update) . '}'; } else { if (isset($options['update'])) { $update .= "'" . $options['update'] . "'"; } } $function = !$update ? "new Ajax.Request(" : "new Ajax.Updater({$update}, "; $function .= '\'' . system_url($options['url']) . '\''; $function .= ', ' . $javascript_options . ')'; if (isset($options['before'])) { $function = $options['before'] . '; ' . $function; } if (isset($options['after'])) { $function = $function . '; ' . $options['after']; } if (isset($options['condition'])) { $function = 'if (' . $options['condition'] . ') { ' . $function . '; }'; } if (isset($options['confirm'])) { $function = "if (confirm('" . escape_javascript($options['confirm']) . "')) { {$function}; }"; if (isset($options['cancel'])) { $function = $function . ' else { ' . $options['cancel'] . ' }'; } } return $function; }
function jq_link_to_function($name, $function, $html_options = array()) { $html_options = _parse_attributes($html_options); $html_options['href'] = isset($html_options['href']) ? $html_options['href'] : '#'; if (isset($html_options['confirm'])) { $confirm = escape_javascript($html_options['confirm']); $html_options['onclick'] = "if(confirm('{$confirm}')){ {$function};}; return false;"; // tom@punkave.com: without this we get a confirm attribute, which breaks confirm() in IE // (we could call window.confirm, but there is no reason to have the // nonstandard confirm attribute) unset($html_options['confirm']); } else { $html_options['onclick'] = $function . '; return false;'; } return content_tag('a', $name, $html_options); }
} } } if ($ob_active) { $user_fields[$icu] = ob_get_contents(); ob_end_clean(); } foreach ($user_cats as $category) { if (array_key_exists($category['field_cat'], $user_fields) && $user_fields[$category['field_cat']]) { echo "<tr>\n"; echo "<td colspan='2' class='tbl2'><strong>" . $category['field_cat_name'] . "</strong></td>\n"; echo "</tr>\n" . $user_fields[$category['field_cat']]; } } } if ($settings['enable_terms'] == 1) { echo "<tr>\n<td class='tbl'>" . $locale['508'] . "<span style='color:#ff0000'>*</span></td>\n"; echo "<td class='tbl'><input type='checkbox' id='agreement' name='agreement' value='1' onclick='checkagreement()' /> <span class='small'><label for='agreement'>" . $locale['509'] . "</label></span></td>\n"; echo "</tr>\n"; } echo "<tr>\n<td align='center' colspan='2'><br />\n"; echo "<input type='submit' name='register' value='" . $locale['506'] . "' class='button'" . ($settings['enable_terms'] == 1 ? " disabled='disabled'" : "") . " />\n"; echo "</td>\n</tr>\n</table>\n</form>\n"; closetable(); echo "<script type='text/javascript'>\r\nfunction ValidateForm(frm) {\r\n\tif (frm.username.value==\"\") {\r\n\t\talert(" . escape_javascript($locale['550']) . ");\r\n\t\treturn false;\r\n\t}\r\n\tif (frm.password1.value==\"\") {\r\n\t\talert(" . escape_javascript($locale['551']) . ");\r\n\t\treturn false;\r\n\t}\r\n\tif (frm.email.value==\"\") {\r\n\t\talert(" . escape_javascript($locale['552']) . ");\r\n\t\treturn false;\r\n\t}\r\n}\r\n</script>\n"; // Pimped: JavaScript if ($settings['enable_terms'] == 1) { echo "<script language='JavaScript' type='text/javascript'>\r\n\t\t\tfunction checkagreement() {\r\n\t\t\t\tif(document.inputform.agreement.checked) {\r\n\t\t\t\t\tdocument.inputform.register.disabled=false;\r\n\t\t\t\t} else {\r\n\t\t\t\t\tdocument.inputform.register.disabled=true;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t</script>"; } } require_once TEMPLATES . "footer.php";
/** * @param string $name The element name * @param string $value The date 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()) { $visible_value = escape_javascript($this->getOption('value_callback') ? call_user_func($this->getOption('value_callback'), $value) : $value); sfContext::getInstance()->getConfiguration()->loadHelpers('Url'); $id = $this->generateId($name); $return = $this->renderTag('input', array( 'type' => 'hidden', 'name' => $name, 'value' => $value )); $return .= sprintf(<<<EOF <script type="text/javascript"> function defaultFormatResult(item) { return item.text; } function defaultFormatNoMatches(term) { return 'Keine Ergebnisse gefunden.'; } function defaultFormatInputTooShort(term, minLength) { return 'Bitte geben Sie mind. ' + minLength + ' Zeichen ein.'; } jQuery("#%s").select2( { width: '%s', minimumInputLength: %s, placeholder: '%s', allowClear: %s, formatSelection: %s, formatResult: %s, formatNoMatches: %s, formatInputTooShort: %s, containerCss: '%s', containerCssClass: '%s', dropdownCss: '%s', dropdownCssClass: '%s', ajax: { url: '%s', dataType: 'json', quietMillis: 100, data: function (term, page) { return { q: term, limit: 10, page: page }; }, results: function (data, page) { var more = (page * 10) < data.total; return {results: data.items, more: more}; } } }); jQuery('#%s').select2('data', { id: '%s', text: '%s' }); </script> EOF , $id, $this->getOption('width'), $this->getOption('minimumInputLength'), $this->getOption('placeholder', ''), $this->getOption('allowClear') == true ? 'true' : 'false', $this->getOption('formatSelection'), $this->getOption('formatResult'), $this->getOption('formatNoMatches'), $this->getOption('formatInputTooShort'), $this->getOption('containerCss'), $this->getOption('containerCssClass'), $this->getOption('dropdownCss'), $this->getOption('dropdownCssClass'), url_for($this->getOption('url')), $id, $value, $visible_value ? $visible_value : $this->getOption('placeholder', '') ); return $return; }