diff options
Diffstat (limited to 'templates')
-rw-r--r-- | templates/create.tmpl.php | 2 | ||||
-rw-r--r-- | templates/goto.tmpl.php | 376 | ||||
-rw-r--r-- | templates/main.tmpl.php | 36 |
3 files changed, 395 insertions, 19 deletions
diff --git a/templates/create.tmpl.php b/templates/create.tmpl.php index fa022046..e326c5b9 100644 --- a/templates/create.tmpl.php +++ b/templates/create.tmpl.php @@ -23,7 +23,7 @@ \OCP\Util::addStyle('polls', 'main'); \OCP\Util::addStyle('polls', 'createpoll'); - \OCP\Util::addStyle('polls', 'vendor/jquery.datetimepicker'); + \OCP\Util::addStyle('polls', 'vendor/jquery.datetimepicker.min'); \OCP\Util::addScript('polls', 'create_edit'); \OCP\Util::addScript('polls', 'vendor/jquery.datetimepicker.full.min'); diff --git a/templates/goto.tmpl.php b/templates/goto.tmpl.php index 6619d66f..fdccc9f3 100644 --- a/templates/goto.tmpl.php +++ b/templates/goto.tmpl.php @@ -81,6 +81,23 @@ $poll->getDescription() !== null && $poll->getDescription() !== '' ) { + $description = str_replace(array('\r\n', '\r', '\n') , '<br/>', htmlspecialchars($poll->getDescription())); + } else { + $description = $l->t('No description provided.'); + } + + // init array for counting 'yes'-votes for each date + $total = array(); + for ($i = 0; $i < count($dates); $i++) { + $total['yes'][$i] = 0; + $total['no'][$i] = 0; + } + $userVoted = array(); + $pollUrl = $urlGenerator->linkToRouteAbsolute('polls.page.goto_poll', ['hash' => $poll->getHash()]); + if ( + $poll->getDescription() !== null && + $poll->getDescription() !== '' + ) { $description = $poll->getDescription(); } else { $description = $l->t('No description provided.'); @@ -114,6 +131,24 @@ </div> + <a id="switchDetails" class="button has-tooltip-bottom details" title="Details" href="#"> + <span class="symbol icon-settings"></span> + <?php if (count($comments)) : ?> + <div id="comment-counter" class="badge"><?php p(count($comments)) ?></div> + <?php else: ?> + <div id="comment-counter" class="badge no-comments"><?php p(count($comments)) ?></div> + <?php endif; ?> + </a> + </div> + + <div id="votings" class="main-container"> + <div class="wordwrap description"><span><?php print_unescaped($description); ?></span> + <?php + if ($expired) { + print_unescaped('<span class="' . $statusClass . '">' . $l->t('The poll expired on %s. Voting is disabled, but you can still comment.', array(date('d.m.Y H:i', strtotime($poll->getExpire())))) . '</span>'); + }?> + + <a id="switchDetails" class="button details" title="Details" href="#"> <span class="symbol icon-settings"></span> <?php if (count($comments)) : ?> @@ -132,6 +167,106 @@ }?> </div> <div class="table"> + <ul class="flex-row header" > + <?php + foreach ($dates as $dateElement) { + if ($poll->getType() === 0) { + $timestamp = strtotime($dateElement->getDt()); + print_unescaped('<li id="slot_' . $dateElement->getId() . '" title="' . $dateElement->getDt() . ' ' . date_default_timezone_get() . '" class="flex-column vote time has-tooltip" data-timestamp="' . $timestamp . '"data-value-utc="' . $dateElement->getDt() . '">'); + + print_unescaped(' <div class="date-box flex-column">'); + print_unescaped(' <div class="month">' . $l->t(date('M', $timestamp)) . '</div>'); + print_unescaped(' <div class="day">' . date('j', $timestamp) . '</div>'); + print_unescaped(' <div class="dayow">' . $l->t(date('D', $timestamp)) . '</div>'); + print_unescaped(' <div class="time">' . date('G:i', $timestamp) . ' UTC</div>'); + print_unescaped(' </div>'); + } else { + print_unescaped('<li id="slot_' . $dateElement->getId() . '" title="' . preg_replace('/_\d+$/', '', $dateElement->getText()) . '" class="flex-column vote option">'); + print_unescaped(' <div class="date-box flex-column">' . preg_replace('/_\d+$/', '', $dateElement->getText()).'</div>'); + } + print_unescaped('<div class="counter flex-row">'); + print_unescaped(' <div class="yes flex-row">'); + print_unescaped(' <div class="svg"></div>'); + print_unescaped(' <div id="counter_yes_voteid_' . $dateElement->getId() . '" class ="result-cell yes" data-voteId="' . $dateElement->getId() . '">0</div>'); + print_unescaped(' </div>'); + print_unescaped(' <div class="no flex-row">'); + print_unescaped(' <div class="svg"></div>'); + print_unescaped(' <div id="counter_no_voteid_' . $dateElement->getId() . '" class ="result-cell no" data-voteId="' . $dateElement->getId() . '">0</div>'); + print_unescaped(' </div>'); + print_unescaped('</div>'); + } + ?> + </li> + </ul> + <ul class="flex-column table-body"> + <?php + if ($votes !== null) { + //group by user + $others = array(); + $displayName = ''; + $avatarName = ''; + $activeClass = ''; + foreach ($votes as $vote) { + if (!isset($others[$vote->getUserId()])) { + $others[$vote->getUserId()] = array(); + } + $others[$vote->getUserId()][]= $vote; + } + $userCnt = 0; + foreach (array_keys($others) as $usr) { + $userCnt++; + if ($usr === $userId) { + // if poll expired, just put current user among the others; + // otherwise skip here to add current user as last flex-row (to vote) + if (!$expired) { + $userVoted = $others[$usr]; + continue; + } + } + if ( + $userMgr->get($usr) !== null && + !$isAnonymous && + !$hideNames + ) { + $displayName = $userMgr->get($usr)->getDisplayName(); + $avatarName = $usr; + } else { + if ($isAnonymous || $hideNames) { + $displayName = 'Anonymous'; + $avatarName = $userCnt; + } else { + $displayName = $usr; + $avatarName = $usr; + } + } + ?> + <li class="flex-row user"> + <div class="first"> + <div class="user-cell flex-row"> + <div class="avatar has-tooltip" title="<?php p($avatarName)?>"></div> + <div class="name"><?php p($displayName) ?></div> + </div> + </div> + <ul class="flex-row"> + <?php + // loop over dts + $i_tot = 0; + + foreach ($dates as $dateElement) { + if ($poll->getType() === 0) { + $dateId = strtotime($dateElement->getDt()); + $pollId = 'voteid_' . $dateElement->getId(); + } else { + $dateId = $dateElement->getText(); + $pollId = 'voteid_' . $dateElement->getId(); + } + // look what user voted for this dts + $class = 'flex-column poll-cell no'; + foreach ($others[$usr] as $vote) { + $voteVal = null; + if ($poll->getType() === 0) { + $voteVal = strtotime($vote->getDt()); + <div class="table"> <ul class="row header" > <?php foreach ($dates as $dateElement) { @@ -236,6 +371,15 @@ } if ($dateId === $voteVal) { if ($vote->getType() === 1) { + $class = 'flex-column poll-cell yes'; + $total['yes'][$i_tot]++; + } else if ($vote->getType() === 0) { + $class = 'flex-column poll-cell no'; + $total['no'][$i_tot]++; + } else if ($vote->getType() === 2) { + $class = 'flex-column poll-cell maybe'; + if ($dateId === $voteVal) { + if ($vote->getType() === 1) { $class = 'column poll-cell yes'; $total['yes'][$i_tot]++; } else if ($vote->getType() === 0) { @@ -259,6 +403,50 @@ $totalNoOthers = array_merge(array(), $total['no']); $toggleTooltip = $l->t('Switch all options at once'); if (!$expired) { + print_unescaped('<li class="flex-row user current-user">'); + print_unescaped(' <div class="flex-row first">'); + print_unescaped(' <div class="user-cell flex-row">'); + if (User::isLoggedIn()) { + print_unescaped(' <div class="avatar has-tooltip" title="'.($userId).'"></div>'); + print_unescaped(' <div class="name">'); + p($userMgr->get($userId)->getDisplayName()); + } else { + print_unescaped(' <div class="avatar has-tooltip" title="?"></div>'); + print_unescaped(' <div id="id_ac_detected" class="name external current-user"><input type="text" name="user_name" id="user_name" placeholder="' . $l->t('Your name here') . '" />'); + } + print_unescaped(' </div>'); + print_unescaped(' </div>'); + print_unescaped(' <div id="toggle-cell" class="toggle-cell has-tooltip maybe" title="'. $toggleTooltip .'">'); + print_unescaped(' <div class="toggle"></div>'); + print_unescaped(' </div>'); + print_unescaped('</div>'); + print_unescaped('<ul class="flex-row">'); + + $i_tot = 0; + foreach ($dates as $dateElement) { + if ($poll->getType() === 0) { + $dateId = strtotime($dateElement->getDt()); + $pollId = 'voteid_' . $dateElement->getId(); + } else { + $dateId = $dateElement->getText(); + $pollId = 'voteid_' . $dateElement->getId(); + } + // see if user already has data for this event + $class = 'no'; + $activeClass = 'flex-column active poll-cell'; + if (isset($userVoted)) { + foreach ($userVoted as $obj) { + $voteVal = null; + if($poll->getType() === 0) { + $voteVal = strtotime($obj->getDt()); + print_unescaped('</ul>'); + print_unescaped('</li>'); + } + } + $totalYesOthers = array_merge(array(), $total['yes']); + $totalNoOthers = array_merge(array(), $total['no']); + $toggleTooltip = $l->t('Switch all options at once'); + if (!$expired) { print_unescaped('<li class="row user current-user">'); print_unescaped(' <div class="row first">'); print_unescaped(' <div class="user-cell row">'); @@ -319,6 +507,28 @@ ?> </ul> </div> + <div class="submitPoll flex-row"> + <div> + <form class="finish_vote" name="finish_vote" action="<?php p($urlGenerator->linkToRoute('polls.page.insert_vote')); ?>" method="POST"> + <input type="hidden" name="pollId" value="<?php p($poll->getId()); ?>" /> + <input type="hidden" name="userId" value="<?php p($userId); ?>" /> + <input type="hidden" name="dates" value="<?php p($poll->getId()); ?>" /> + <input type="hidden" name="types" value="<?php p($poll->getId()); ?>" /> + <input type="hidden" name="receiveNotifications" /> + <input type="hidden" name="changed" /> + <input type="button" id="submit_finish_vote" class="button btn" value="<?php p($l->t('Vote!')); ?>" /> + </form> + } + print_unescaped('<li id="' . $pollId . '" class="' . $activeClass . ' ' . $class . '" data-value="' . $dateId . '"></li>'); + + $i_tot++; + } + print_unescaped('</ul>'); + print_unescaped('</li>'); + } + ?> + </ul> + </div> <div class="submitPoll row"> <div> <form class="finish_vote" name="finish_vote" action="<?php p($urlGenerator->linkToRoute('polls.page.insert_vote')); ?>" method="POST"> @@ -382,6 +592,111 @@ </div> </div> + <?php if (User::isLoggedIn()) : ?> + <div class="notification"> + <input type="checkbox" id="check_notif" class="checkbox" <?php if ($notification !== null) print_unescaped(' checked'); ?> /> + <label for="check_notif"><?php p($l->t('Receive notification email on activity')); ?></label> + </div> + <?php endif; ?> + </div> + </div> + + </div> + <div id="app-sidebar" class="detailsView scroll-container disappear"> + <div class="close flex-row"> + <a id="closeDetails" class="close icon-close has-tooltip-bottom" title="<?php p($l->t('Close details')); ?>" href="#" alt="<?php $l->t('Close');?>"></a> + </div> + + <div class="header flex-row"> + <div class="pollInformation flex-column"> + <div class="authorRow user-cell flex-row"> + <div class="description leftLabel"><?php p($l->t('Owner')); ?></div> + <div class="avatar has-tooltip-bottom" title="<?php p($poll->getOwner())?>"></div> + <div class="author"><?php p($userMgr->get($poll->getOwner())->getDisplayName()); ?></div> + </div> + + <div class="cloud"> + <?php + if ($expired) { + print_unescaped('<span class="expired">' . $l->t('Expired'). '</span>'); + } else { + if ($poll->getExpire() !== null){ + print_unescaped('<span class="open">' . $l->t('Expires on %s', array(date('d.m.Y', strtotime($poll->getExpire())))) . '</span>'); + } else { + print_unescaped('<span class="open">' . $l->t('Expires never') . '</span>'); + } + } + + if ($access === 'public' || $access === 'hidden' || $access === 'registered') { + print_unescaped('<span class="information">' . $access . '</span>'); + } else { + print_unescaped('<span class="information">' . $l->t('Invitation access') . '</span>'); + } + if ($isAnonymous) { + print_unescaped('<span class="information">' . $l->t('Anononymous poll') . '</span>'); + if ($hideNames) { + print_unescaped('<span class="information">' . $l->t('Usernames hidden to Owner') . '</span>'); + } else { + print_unescaped('<span class="information">' . $l->t('Usernames visible to Owner') . '</span>'); + } + } + ?> + </div> + + </div> + <div class="pollActions flex-column"> + <ul class="with-icons"> + <li> + <a id="id_copy_<?php p($poll->getId()); ?>" class="icon-clippy has-tooltip-bottom svg copy-link" data-clipboard-text="<?php p($pollUrl); ?>" title="<?php p($l->t('Click to get link')); ?>" href="#"> + <?php p($l->t('Copy Link')); ?> + </a> + </li> + + <?php if ($poll->getOwner() === $userId) : ?> + <li class=""> + <a id="id_del_<?php p($poll->getId()); ?>" class="icon-delete svg delete-poll" data-value="<?php p($poll->getTitle()); ?>" href="#"> + <?php p($l->t('Delete poll')); ?> + </a> + </li> + <li> + <a id="id_edit_<?php p($poll->getId()); ?>" class="icon-rename svg" href="<?php p($urlGenerator->linkToRoute('polls.page.edit_poll', ['hash' => $poll->getHash()])); ?>"> + <?php p($l->t('Edit Poll')); ?> + </a> + </li> + <?php endif; ?> + </ul> + </div> + </div> + + + <?php if ($expired) : ?> + <div id="expired_info"> + <h2><?php p($l->t('Poll expired')); ?></h2> + <p> + <?php p($l->t('The poll expired on %s. Voting is disabled, but you can still comment.', array(date('d.m.Y H:i', strtotime($poll->getExpire()))))); ?> + </p> + </div> + <?php endif; ?> + <ul class="tabHeaders"> + <li class="tabHeader selected" data-tabid="commentsTabView" data-tabindex="0"> + <a href="#"><?php p($l->t('Comments')); ?></a> + </li> + </ul> + <div class="tabsContainer"> + <div id="commentsTabView" class="tab commentsTabView"> + <div class="newCommentRow comment new-comment"> + <?php if (User::isLoggedIn()) : ?> + <div class="authorRow user-cell flex-row"> + <div class="avatar has-tooltip" title="<?php p($userId)?>"></div> + <div class="author"><?php p($userMgr->get($userId)->getDisplayName()) ?></div> + </div> + + <?php else: ?> + <a href="<?php p($urlGenerator->linkToRouteAbsolute('core.login.showLoginForm')); ?>"><?php p($l->t('Login or ...')); ?></a> + <div class="authorRow user-cell flex-row"> + <div class="avatar has-tooltip" title="?"></div> + <div id="id_ac_detected" class="author flex-column external"> + <input type="text" name="user_name_comm" id="user_name_comm" placeholder="<?php p($l->t('Your name here')); ?>" /> <div class="pollActions column"> <ul class="with-icons"> <li> @@ -446,6 +761,14 @@ <span class="icon-loading-small" style="float:right;"></span> </form> </div> + <?php endif; ?> + <form class="newCommentForm flex-row" name="send_comment" action="<?php p($urlGenerator->linkToRoute('polls.page.insert_comment')); ?>" method="POST"> + <input type="hidden" name="pollId" value="<?php p($poll->getId()); ?>" /> + <input type="hidden" name="userId" value="<?php p($userId); ?>" /> + <div id="commentBox" name="commentBox" class="message" data-placeholder="<?php p($l->t('New comment …'))?>" contenteditable="true"></div> + <input id="submit_send_comment" class="submitComment icon-confirm" value="" type="submit"> + <span class="icon-loading-small" style="float:right;"></span> + </form> <ul class="comments column"> @@ -499,8 +822,61 @@ <?php endforeach; ?> </ul> </div> + + <ul class="comments flex-column"> + + <?php if ($comments == null) : ?> + <li id="no-comments" class="emptycontent"> + <?php else : ?> + <li id="no-comments" class="emptycontent hidden"> + <?php endif; ?> + + <div class="icon-comment"></div> + <p><?php p($l->t('No comments yet. Be the first.')); ?></p> + </li> + + <?php foreach ($comments as $comment) : ?> + + <?php + if ( $comment->getUserId() === $userId ) { + // Comment is from current user + // -> display user + $avatarName = $userId; + $displayName = $userMgr->get($userId)->getDisplayName(); + + } else if ( !$isAnonymous && !$hideNames ) { + // comment is from another user, + // poll is not anoymous (for current user) + // users are not hidden + // -> display user + $avatarName = $comment->getUserId(); + $displayName = $avatarName; + if ($userMgr->get($comment->getUserId()) !== null) { + $displayName = $userMgr->get($avatarName)->getDisplayName(); + } + } else { + // in all other cases + // -> make user anonymous + // poll is anonymous and current user is not owner + // or names are hidden + $displayName = 'Anonymous'; + $avatarName = $displayName; + } + ?> + + <li id="comment_<?php p($comment->getId()); ?>" class="comment flex-column"> + <div class="authorRow user-cell flex-row"> + <div class="avatar has-tooltip" title="<?php p($avatarName)?>"></div> + <div class="author"><?php p($displayName) ?></div> + <div class="date has-tooltip live-relative-timestamp datespan" data-timestamp="<?php p(strtotime($comment->getDt())*1000); ?>" title="<?php p($comment->getDt()) ?>"><?php p(\OCP\Template::relative_modified_date(strtotime($comment->getDt()))) ?></div> + </div> + <div class="message wordwrap comment-content"><?php p($comment->getComment()); ?></div> + </li> + <?php endforeach; ?> + </ul> </div> </div> + </div> </div> </div> </div> diff --git a/templates/main.tmpl.php b/templates/main.tmpl.php index 18cc9058..e05c33bb 100644 --- a/templates/main.tmpl.php +++ b/templates/main.tmpl.php @@ -61,28 +61,28 @@ <h2><?php p($l->t('No existing polls.')); ?></h2> </div> <?php else : ?> + <div class="table-row table-header"> <div class="table main-container has-controls"> - <div class ="row table-header"> + <div class="table-row table-header"> <div class="wrapper group-master"> <div class="wrapper group-1"> <div class="wrapper group-1-1"> - <div class="column name"> <?php p($l->t('Title')); ?></div> - <div class="column description"></div> + <div class="flex-column name"> <?php p($l->t('Title')); ?></div> </div> <div class="wrapper group-1-2"> - <div class="column actions"></div> + <div class="flex-column actions"></div> </div> </div> <div class="wrapper group-2"> - <div class="column owner"> <?php p($l->t('By')); ?></div> + <div class="flex-column owner"> <?php p($l->t('By')); ?></div> <div class="wrapper group-2-1"> - <div class="column access"> <?php p($l->t('Access')); ?></div> - <div class="column created"> <?php p($l->t('Created')); ?></div> + <div class="flex-column access"> <?php p($l->t('Access')); ?></div> + <div class="flex-column created"> <?php p($l->t('Created')); ?></div> </div> <div class="wrapper group-2-2"> - <div class="column expiry"> <?php p($l->t('Expires')); ?></div> - <div class="column participants"> <?php p($l->t('participated')); ?></div> + <div class="flex-column expiry"> <?php p($l->t('Expires')); ?></div> + <div class="flex-column participants"> <?php p($l->t('participated')); ?></div> </div> </div> </div> @@ -149,15 +149,15 @@ } ?> - <div class="row table-body"> + <div class="table-row table-body"> <div class="wrapper group-master"> <div class="wrapper group-1"> <div class="thumbnail <?php p($expiry_style . ' ' . $commented_class. ' ' . $participated_class); ?>"></div><!-- Image to display the status or type of poll --> <a href="<?php p($pollUrl); ?>" class="wrapper group-1-1"> - <div class="column name"> <?php p($poll->getTitle()); ?></div> - <div class="column description"> <?php p($poll->getDescription()); ?></div> + <div class="flex-column name"> <?php p($poll->getTitle()); ?></div> + <div class="flex-column description"> <?php p($poll->getDescription()); ?></div> </a> - <div class="column actions"> + <div class="flex-column actions"> <div class="icon-more popupmenu" value="<?php p($poll->getId()); ?>" id="expand_<?php p($poll->getId()); ?>"></div> <div class="popovermenu bubble menu hidden" id="expanddiv_<?php p($poll->getId()); ?>"> <ul> @@ -188,17 +188,17 @@ </div> </div> <div class="wrapper group-2"> - <div class="column owner"> + <div class="flex-column owner"> <div class="avatardiv" title="<?php p($poll->getOwner()); ?>" style="height: 32px; width: 32px;"></div> <div class="name-cell"><?php p($owner); ?></div> </div> <div class="wrapper group-2-1"> - <div class="column access"><?php p($l->t($poll->getAccess())); ?></div> - <div class="column created has-tooltip live-relative-timestamp" data-timestamp="<?php p(strtotime($poll->getCreated())*1000); ?>" data-value="<?php p($poll->getCreated()); ?>"><?php p(\OCP\Template::relative_modified_date(strtotime($poll->getCreated()))); ?></div> + <div class="flex-column access"><?php p($l->t($poll->getAccess())); ?></div> + <div class="flex-column created has-tooltip live-relative-timestamp" data-timestamp="<?php p(strtotime($poll->getCreated())*1000); ?>" data-value="<?php p($poll->getCreated()); ?>"><?php p(\OCP\Template::relative_modified_date(strtotime($poll->getCreated()))); ?></div> </div> <div class="wrapper group-2-2"> - <div class="column has-tooltip expiry<?php p($expiry_style . $timestamp_style); ?>" data-timestamp="<?php p(strtotime($poll->getExpire())*1000); ?>" data-value="<?php p($poll->getExpire()); ?>"> <?php p($expiry_date); ?></div> - <div class="column participants"> + <div class="flex-column has-tooltip expiry<?php p($expiry_style . $timestamp_style); ?>" data-timestamp="<?php p(strtotime($poll->getExpire())*1000); ?>" data-value="<?php p($poll->getExpire()); ?>"> <?php p($expiry_date); ?></div> + <div class="flex-column participants"> <div class="symbol alt-tooltip partic_voted icon-<?php p($participated_class); ?>" title="<?php p($participated_title); ?>"></div> <div class="symbol alt-tooltip partic_commented icon-<?php p($commented_class); ?>" title="<?php p($commented_title); ?>"></div> </div> |