Commit 3cb06b39 authored by Matthias Larisch's avatar Matthias Larisch Committed by Nick Sellen

WIP extract g_data from more view classes

parent 599b3167
......@@ -1100,7 +1100,11 @@ class Utils
public function v_form_textarea($id, $option = array())
{
$id = $this->func->id($id);
$value = $this->func->getValue($id);
if (isset($option['value'])) {
$value = $option['value'];
} else {
$value = $this->func->getValue($id);
}
$value = htmlspecialchars($value);
......@@ -1184,10 +1188,6 @@ class Utils
public function v_form_tagselect($id, $option = array())
{
// term=h
// [{"id":"3","label":"Hazel Grouse","value":"Hazel Grouse"},{"id":"5","label":"Common Pheasant","value":"Common Pheasant"},{"id":"6","label":"Northern Shoveler","value":"Northern Shoveler"},{"id":"20","label":"Bluethroat","value":"Bluethroat"},{"id":"22","label":"Wood Nuthatch","value":"Wood Nuthatch"},{"id":"26","label":"Chaffinch","value":"Chaffinch"},{"id":"28","label":"Hawfinch","value":"Hawfinch"}]
$xhr = $id;
if (isset($option['xhr'])) {
$xhr = $option['xhr'];
......@@ -1201,8 +1201,8 @@ class Utils
$source = 'autocompleteURL: "xhr.php?f=' . $url . '"';
$post = '';
if (isset($option['data'])) {
$source = 'autocompleteOptions: {source: ' . json_encode($option['data']) . ',minLength: 0}';
if (isset($option['valueOptions'])) {
$source = 'autocompleteOptions: {source: ' . json_encode($option['valueOptions']) . ',minLength: 0}';
}
$this->func->addJs('
......@@ -1222,7 +1222,12 @@ class Utils
');
$input = '<input type="text" name="' . $id . '[]" value="" class="tag input text value" />';
if ($values = $this->func->getValue($id)) {
if (isset($option['values'])) {
$values = $option['values'];
} else {
$values = $this->func->getValue($id);
}
if ($values) {
$input = '';
foreach ($values as $v) {
$input .= '<input type="text" name="' . $id . '[' . $v['id'] . '-a]" value="' . $v['name'] . '" class="tag input text value" />';
......@@ -1297,7 +1302,7 @@ class Utils
$thumb = '';
$pic = $this->func->getValue($id);
$pic = (isset($option['pic']) ? $option['pic'] : $this->func->getValue($id));
if (!empty($pic)) {
$thumb = '<img src="images/' . str_replace('/', '/thumb_', $pic) . '" />';
}
......
......@@ -395,7 +395,10 @@ class View
$this->func->addHead('<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places&key=' . GOOGLE_API_KEY . '"></script>');
global $g_data;
if (isset($g_data['lat']) && isset($g_data['lon']) && !empty($g_data['lat']) && !empty($g_data['lon'])) {
if (isset($options['location'])) {
$data = array_merge(['zoom' => 14], $options['location']);
} elseif (isset($g_data['lat']) && isset($g_data['lon']) && !empty($g_data['lat']) && !empty($g_data['lon'])) {
$data = array(
'lat' => $g_data['lat'],
'lon' => $g_data['lon'],
......
......@@ -170,8 +170,6 @@ class FairTeilerControl extends Control
$items = array(
array('name' => $this->func->s('back'), 'href' => '/?page=fairteiler&sub=ft&bid=' . $this->bezirk_id . '&id=' . $this->fairteiler['id'])
);
$data['bfoodsaver'] = array();
$data['bfoodsaver_values'] = array();
if ($this->func->isOrgaTeam() || $this->func->isBotFor($this->bezirk_id)) {
$items[] = array('name' => $this->func->s('delete'), 'click' => 'if(confirm(\'' . $this->func->sv('delete_sure', $this->fairteiler['name']) . '\')){goTo(\'/?page=fairteiler&sub=ft&bid=' . $this->bezirk_id . '&id=' . $this->fairteiler['id'] . '&delete=1\');}return false;');
......
......@@ -87,10 +87,9 @@ class FairTeilerView extends View
$tagselect = '';
if ($data) {
$this->func->setEditData($data);
$title = $this->func->sv('edit_fairteiler_name', $this->fairteiler['name']);
$tagselect = $this->v_utils->v_form_tagselect('bfoodsaver', array('data' => $data['bfoodsaver_values']));
$tagselect = $this->v_utils->v_form_tagselect('bfoodsaver', array('valueOptions' => $data['bfoodsaver_values'], 'values' => $data['bfoodsaver']));
$this->func->addJs('
$("#fairteiler-form").submit(function(ev){
if($("#bfoodsaver input[type=\'hidden\']").length == 0)
......@@ -103,11 +102,11 @@ class FairTeilerView extends View
}
return $this->v_utils->v_field($this->v_utils->v_form('fairteiler', array(
$this->v_utils->v_form_select('bezirk_id', array('values' => $this->bezirke, 'required' => true)),
$this->v_utils->v_form_text('name', array('required' => true)),
$this->v_utils->v_form_textarea('desc', array('desc' => $this->func->s('desc_desc'), 'required' => true)),
$this->v_utils->v_form_picture('picture', array('resize' => array(528, 60), 'crop' => array((528 / 170), 1))),
$this->latLonPicker('latLng'),
$this->v_utils->v_form_select('bezirk_id', array('values' => $this->bezirke, 'selected' => $data['bezirk_id'], 'required' => true)),
$this->v_utils->v_form_text('name', array('value' => $data['name'], 'required' => true)),
$this->v_utils->v_form_textarea('desc', array('value' => $data['desc'], 'desc' => $this->func->s('desc_desc'), 'required' => true)),
$this->v_utils->v_form_picture('picture', array('pic' => $data['picture'], 'resize' => array(528, 60), 'crop' => array((528 / 170), 1))),
$this->latLonPicker('latLng', ['location' => ['lat' => $data['lat'], 'lon' => $data['lon']]]),
$tagselect,
), array('submit' => $this->func->s('save'))), $title, array('class' => 'ui-padding'));
}
......
......@@ -110,7 +110,7 @@ class StoreUserControl extends Control
'team',
array(
$this->v_utils->v_form_tagselect('foodsaver', array('data' => $this->model->xhrGetTagFsAll())),
$this->v_utils->v_form_tagselect('foodsaver', array('valueOptions' => $this->model->xhrGetTagFsAll())),
$verantwortlich_select),
array('submit' => $this->func->s('save'))
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment