Commit ac416f26 authored by Matthias Larisch's avatar Matthias Larisch

Fix Xhr ViewUtils

parent 3e346839
......@@ -2,52 +2,34 @@
namespace Foodsharing\Lib\Xhr;
use Foodsharing\Lib\Func;
use Foodsharing\Lib\View\Utils;
class ViewUtils
{
public static function page($content, $title, $subtitle = '')
{
if (!empty($subtitle)) {
$subtitle = '<p class="subtitle">' . $subtitle . '</p>';
}
return '
<div class="popbox">
<h3>' . $title . '</h3>
' . $subtitle . '
<div class="cnt">
' . $content . '
</div>
</div>';
}
/**
* @var Func
*/
private static $func;
/**
* @var Utils
*/
private static $v_utils;
public static function msgList()
public static function init()
{
$out = '
<div id="scrollbar1">
<div class="scrollbar"><div class="track"><div class="thumb"><div class="end"></div></div></div></div>
<div class="viewport">
<div class="overview">
<ul id="xv_message" class="msgbar-dropdown-menu">
<li class="xhr-loader">&nbsp;</li>
</ul>
</div>
</div>
</div>
';
return $out;
global $g_func;
global $g_view_utils;
self::$func = $g_func;
self::$v_utils = $g_view_utils;
}
/*
* <p>'.$fs['anschrift'].'</p>
<p>'.$fs['plz'].' '.$fs['stadt'].'</p>
*/
public static function fsBubble($fs)
{
return '<div style="height:80px;overflow:hidden;width:200px;">
<div style="margin-right:10px;float:left;margin-bottom:33px">
<a href="#" onclick="profile(' . (int)$fs['id'] . ');return false;">
<img src="' . $this->func->img($fs['photo']) . '">
<img src="' . self::$func->img($fs['photo']) . '">
</a>
</div>
<h1 style="font-size:13px;font-weight:bold;margin-bottom:8px;"><a href="#" onclick="profile(' . (int)$fs['id'] . ');return false;">' . $fs['name'] . '</a></h1>
......@@ -60,20 +42,20 @@ class ViewUtils
global $db;
$button = '';
if (($b['inTeam']) || $this->func->isOrgaTeam()) {
$button .= '<div class="buttonrow"><a class="lbutton" href="/?page=fsbetrieb&id=' . (int)$b['id'] . '">' . $this->func->s('to_team_page') . '</a></div>';
if (($b['inTeam']) || self::$func->isOrgaTeam()) {
$button .= '<div class="buttonrow"><a class="lbutton" href="/?page=fsbetrieb&id=' . (int)$b['id'] . '">' . self::$func->s('to_team_page') . '</a></div>';
}
if ($b['team_status'] != 0 && (!$b['inTeam'] && (!$b['pendingRequest']))) {
$button .= '<div class="buttonrow"><a class="lbutton" href="#" onclick="betriebRequest(' . (int)$b['id'] . ');return false;">' . $this->func->s('want_to_fetch') . '</a></div>';
$button .= '<div class="buttonrow"><a class="lbutton" href="#" onclick="betriebRequest(' . (int)$b['id'] . ');return false;">' . self::$func->s('want_to_fetch') . '</a></div>';
} elseif ($b['team_status'] != 0 && (!$b['inTeam'] && ($b['pendingRequest']))) {
$button .= '<div class="buttonrow"><a class="lbutton" href="#" onclick="rejectBetriebRequest(' . (int)$this->func->fsId() . ',' . (int)$b['id'] . ');return false;">Anfrage zur&uuml;ckziehen </a></div>';
$button .= '<div class="buttonrow"><a class="lbutton" href="#" onclick="rejectBetriebRequest(' . (int)self::$func->fsId() . ',' . (int)$b['id'] . ');return false;">Anfrage zur&uuml;ckziehen </a></div>';
}
$verantwortlich = '<ul class="linklist">';
foreach ($b['foodsaver'] as $fs) {
if ($fs['verantwortlich'] == 1) {
$verantwortlich .= '
<li><a style="background-color:transparent !important;" href="#" onclick="profile(' . (int)$fs['id'] . ');return false;">' . $this->func->avatar($fs, 50) . '</a></li>';
<li><a style="background-color:transparent !important;" href="#" onclick="profile(' . (int)$fs['id'] . ');return false;">' . self::$func->avatar($fs, 50) . '</a></li>';
}
}
$verantwortlich .= '
......@@ -100,25 +82,25 @@ class ViewUtils
$time = strtotime($b['begin']);
if ($time > 0) {
$count_info .= '<div>Kooperation seit ' . $this->func->s('month_' . (int)date('m', $time)) . ' ' . date('Y', $time) . '</div>';
$count_info .= '<div>Kooperation seit ' . self::$func->s('month_' . (int)date('m', $time)) . ' ' . date('Y', $time) . '</div>';
}
if ((int)$b['public_time'] != 0) {
$b['public_info'] .= '<div>Es wird in etwa ' . $this->func->s('pubbtime_' . (int)$b['public_time']) . ' abgeholt</div><div class="ui-padding">' . $this->v_info('Bitte niemals ohne Absprache zum Laden kommen!') . '</div>';
$b['public_info'] .= '<div>Es wird in etwa ' . self::$func->s('pubbtime_' . (int)$b['public_time']) . ' abgeholt</div><div class="ui-padding">' . self::$v_utils->v_info('Bitte niemals ohne Absprache zum Laden kommen!') . '</div>';
}
if (!empty($b['public_info'])) {
$besonderheiten = $this->v_input_wrapper($this->func->s('info'), $b['public_info'], 'bcntspecial');
$besonderheiten = self::$v_utils->v_input_wrapper(self::$func->s('info'), $b['public_info'], 'bcntspecial');
}
$status = $this->v_getStatusAmpel($b['betrieb_status_id']);
$status = self::$v_utils->v_getStatusAmpel($b['betrieb_status_id']);
return '
' . $this->v_input_wrapper($this->func->s('status'), $status . '<span class="bstatus">' . $this->func->s('betrieb_status_' . $b['betrieb_status_id']) . '</span>' . $count_info) . '
' . $this->v_input_wrapper('Verantwortliche Foodsaver', $verantwortlich, 'bcntverantwortlich') . '
' . self::$v_utils->v_input_wrapper(self::$func->s('status'), $status . '<span class="bstatus">' . self::$func->s('betrieb_status_' . $b['betrieb_status_id']) . '</span>' . $count_info) . '
' . self::$v_utils->v_input_wrapper('Verantwortliche Foodsaver', $verantwortlich, 'bcntverantwortlich') . '
' . $besonderheiten . '
<div class="ui-padding">
' . $this->v_info('' . $this->func->s('team_status_' . $b['team_status']) . '') . '
' . self::$v_utils->v_info('' . self::$func->s('team_status_' . $b['team_status']) . '') . '
</div>
' . $button;
}
......@@ -153,76 +135,6 @@ class ViewUtils
return $out . '
</div>';
}
public static function msgLi($messages)
{
$out = '';
if (is_array($messages)) {
$i = 0;
$count = count($messages);
foreach ($messages as $m) {
++$i;
$class = '';
if ($count == $i) {
$class = ' last';
}
$m['msg'] = $this->func->autolink($m['msg']);
$m['time'] = $this->func->msgTime($m['time_ts']);
$out .= '
<li class="msg' . $class . '">
<span class="msg">
<span class="photo">
<img alt="avatar" src="' . $this->func->img($m['photo']) . '">
</span>
<span class="subject">
<a class="link from" onclick="profile(' . (int)$m['sender_id'] . ');return false;" href="#">' . $m['name'] . '</a>
<span class="time">' . $m['time'] . '</span>
</span>
<span class="message">' . nl2br($m['msg']) . '</span>
<span style="display:block;clear:both;"></span>
</span>
</li>';
}
}
return $out;
}
public static function hidden($id, $value)
{
$id = $this->func->id($id);
return '<input type="hidden" name="' . $id . '" id="' . $id . '" value="' . $value . '" />';
}
public static function submit($id, $click = false)
{
$label = $this->func->s($id);
$id = $this->func->id($id);
$js = '$("#' . $id . '").button()';
if ($click !== false) {
$js .= '.click(function(event){' . $click . '})';
}
$js .= ';';
$this->func->addXhJs($js);
return '<input type="submit" id="' . $id . '" name="' . $id . '" value="' . $label . '" />';
}
public static function msgAppend($msg, $name, $time, $img)
{
return '<li class="msg"><span href="#57" class="msg"><span class="photo"><img src="' . $img . '" alt="avatar"></span><span class="subject"><span class="from">' . $name . '</span><span class="time">' . $time . '</span></span><span class="message">' . $msg . '</span><span style="display:block;clear:both;"></span></span></li>';
}
public static function textarea($id)
{
$id = $this->func->id($id);
$label = $this->func->s($id) . ' ...';
return '<textarea class="xv" onclick="if(this.value==\'' . $label . '\'){this.value=\'\';}" onfocus="if(this.value==\'' . $label . '\'){this.value=\'\';}" onblur="if(this.value==\'\'){this.value=\'' . $label . '\'}" name="' . $id . '" id="' . $id . '">' . $label . '</textarea>';
}
}
ViewUtils::init();
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