From 94af7c7fed671e1f7e27cc22d1ee6c76e1bccfde Mon Sep 17 00:00:00 2001 From: dartcafe Date: Sat, 1 Dec 2018 10:44:13 +0100 Subject: Change actions in vote page #420 --- templates/goto.tmpl.php | 499 ----------------------------------------------- templates/vote.tmpl.php | 501 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 501 insertions(+), 499 deletions(-) delete mode 100644 templates/goto.tmpl.php create mode 100644 templates/vote.tmpl.php (limited to 'templates') diff --git a/templates/goto.tmpl.php b/templates/goto.tmpl.php deleted file mode 100644 index 50fcff66..00000000 --- a/templates/goto.tmpl.php +++ /dev/null @@ -1,499 +0,0 @@ - - * - * @author Vinzenz Rosenkranz - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ - - use OCP\User; //To do: replace according to API - use OCP\Util; - use OCP\Template; - - Util::addStyle('polls', 'main'); - Util::addStyle('polls', 'flex'); - Util::addStyle('polls', 'vote'); - Util::addStyle('polls', 'sidebar'); - if (!User::isLoggedIn()) { - Util::addStyle('polls', 'public'); - } - - Util::addScript('polls', 'app'); - Util::addScript('polls', 'vote'); - - $userId = $_['userId']; - /** @var \OCP\IUserManager $userMgr */ - $userMgr = $_['userMgr']; - /** @var \OCP\IURLGenerator $urlGenerator */ - $urlGenerator = $_['urlGenerator']; - /** @var \OCP\IAvatarManager $avaMgr */ - $avaMgr = $_['avatarManager']; - /** @var \OCA\Polls\Db\Event $poll */ - $poll = $_['poll']; - /** @var OCA\Polls\Db\Options[] $options */ - $options = $_['options']; - /** @var OCA\Polls\Db\Votes[] $votes */ - $votes = $_['votes']; - /** @var \OCA\Polls\Db\Comment[] $comments */ - $comments = $_['comments']; - /** @var \OCA\Polls\Db\Notification $notification */ - $notification = $_['notification']; - - $isAnonymous = $poll->getIsAnonymous() && $userId !== $poll->getOwner(); - $hideNames = $poll->getIsAnonymous() && $poll->getFullAnonymous(); - if ($poll->getDisallowMaybe()) { - $maybe = 'maybedisallowed'; - } else { - $maybe = 'maybeallowed'; - } - $access = $poll->getAccess(); - $updatedPoll = false; - $dataUnvoted = ''; - - if ($poll->getExpire() === null) { - $expired = false; - } else { - $expired = time() > strtotime($poll->getExpire()); - } - - if ($expired) { - $statusClass = 'expired-vote'; - } else { - $statusClass = 'open-vote'; - if (time() < strtotime($poll->getExpire())) { - $statusClass .= ' endless'; - } - } - - if ($poll->getType() === 0) { - $pollType = 'date-poll'; - $pollTypeClass = 'date-poll'; - } else if ($poll->getType() === 1) { - $pollType = 'option-poll'; - $pollTypeClass = 'option-poll'; - } - - - if ( - $poll->getDescription() !== null && - $poll->getDescription() !== '' - ) { - $description = str_replace(array('\r\n', '\r', '\n'), '
', 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($votes); $i++) { - $total['yes'][$i] = 0; - $total['no'][$i] = 0; - $total['maybe'][$i] = 0; - } - $userVoted = array(); - $pollUrl = $urlGenerator->linkToRouteAbsolute('polls.page.goto_poll', ['hash' => $poll->getHash()]); -?> - -
-
- - - - - - - -
- -
- -
-
- -
-
- - - - ' . $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())))) . ''); }?> -
- -
-
    - getType() === 0) { - $timestamp = strtotime($optionElement->getPollOptionText()); - print_unescaped('
  • '); - print_unescaped('
    '); - print_unescaped('
    ' . $l->t(date('M', $timestamp)) . '
    '); - print_unescaped('
    ' . date('j', $timestamp) . '
    '); - print_unescaped('
    ' . $l->t(date('D', $timestamp)) . '
    '); - print_unescaped('
    ' . date('G:i', $timestamp) . ' UTC
    '); - print_unescaped('
    '); - } else { - print_unescaped('
  • '); - print_unescaped('
    ' . $optionElement->getPollOptionText() . '
    '); - } - print_unescaped('
    '); - print_unescaped('
    '); - print_unescaped('
    '); - print_unescaped('
    0
    '); - print_unescaped('
    '); - print_unescaped('
    '); - print_unescaped('
    '); - print_unescaped('
    0
    '); - print_unescaped('
    '); - print_unescaped('
    '); - } - ?> -
  • -
- -
    - 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 = \OC_User::getDisplayName($usr); - $avatarName = $usr; - } else { - if ($isAnonymous || $hideNames) { - $displayName = 'Anonymous'; - $avatarName = $userCnt; - } else { - $displayName = $usr; - $avatarName = $usr; - } - } - ?> -
  • -
    -
    -
    -
    -
    -
    -
      - getPollOptionText() === $vote->getVoteOptionText()) { - $class = $vote->getVoteAnswer() . ' icon-'.$vote->getVoteAnswer(); - break; - } - $class = 'no icon-no'; - } - print_unescaped('
    • '); - $i_tot++; - } - - print_unescaped('
    '); - print_unescaped('
  • '); - } - } - $toggleTooltip = $l->t('Switch all options at once'); - if (!$expired) { - print_unescaped('
  • '); - print_unescaped('
    '); - print_unescaped('
    '); - if (User::isLoggedIn()) { - print_unescaped('
    '); - print_unescaped('
    '); - p(\OC_User::getDisplayName($userId)); - } else { - print_unescaped('
    '); - print_unescaped('
    '); - } - print_unescaped('
    '); - print_unescaped('
    '); - if ($maybe === 'maybeallowed') { - print_unescaped('
    '); - } else { - print_unescaped('
    '); - } - print_unescaped('
    '); - print_unescaped('
    '); - print_unescaped('
    '); - print_unescaped('
      '); - - $i_tot = 0; - foreach ($options as $optionElement) { - // see if user already has data for this event - $class = 'no icon-no'; - $dataUnvoted = ''; - if (isset($userVoted)) { - foreach ($userVoted as $vote) { - if ($optionElement->getPollOptionText() === $vote->getVoteOptionText()) { - $class = $vote->getVoteAnswer() . ' icon-'.$vote->getVoteAnswer(); - break; - } else { - $class = 'unvoted'; - } - } - } - - if ($class === 'unvoted') { - $dataUnvoted = $l->t('New'); - $updatedPoll = true; - } - - print_unescaped('
    • '); - - $i_tot++; - } - print_unescaped('
    '); - print_unescaped('
  • '); - } - ?> -
-
- - -
-

t('This poll was updated since your last visit. Please check your votes.')); ?>

-
- - -
-
-
- - - - - - - -
-
- - -
- /> - -
- - -
-
- -
- -
-
- -
- -
-
-
-
t('Owner')); ?>
-
-
getOwner())); ?>
-
- -
- ' . $l->t('Expired') . ''); - } else { - if ($poll->getExpire() !== null) { - print_unescaped('' . $l->t('Expires on %s', array(date('d.m.Y', strtotime($poll->getExpire())))) . ''); - } else { - print_unescaped('' . $l->t('Expires never') . ''); - } - } - - if ($access === 'public' || $access === 'hidden' || $access === 'registered') { - print_unescaped('' . $access . ''); - } else { - print_unescaped('' . $l->t('Invitation access') . ''); - } - if ($isAnonymous) { - print_unescaped('' . $l->t('Anononymous poll') . ''); - if ($hideNames) { - print_unescaped('' . $l->t('Usernames hidden to Owner') . ''); - } else { - print_unescaped('' . $l->t('Usernames visible to Owner') . ''); - } - } - ?> -
- -
-
- -
-
- - -
-

t('Poll expired')); ?>

-

- t('The poll expired on %s. Voting is disabled, but you can still comment.', array(date('d.m.Y H:i', strtotime($poll->getExpire()))))); ?> -

-
- - - - -
-
-
- - -
-
-
-
- - t('Login or ...')); ?> -
-
-
- -
-
- - -
- - -
- - -
-
- -
    - - -
  • - -
  • - - - - getUserId() === $userId) { - // Comment is from current user - // -> display user - $avatarName = $userId; - $displayName = \OC_User::getDisplayName($userId); - - } 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 = \OC_User::getDisplayName($comment->getUserId()); - } 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; - } - ?> - -
  • -
    -
    -
    -
    getDt()))) ?>
    -
    -
    getComment()); ?>
    -
  • - -
-
-
-
- -
diff --git a/templates/vote.tmpl.php b/templates/vote.tmpl.php new file mode 100644 index 00000000..c4edb898 --- /dev/null +++ b/templates/vote.tmpl.php @@ -0,0 +1,501 @@ + + * + * @author Vinzenz Rosenkranz + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + + use OCP\User; //To do: replace according to API + use OCP\Util; + use OCP\Template; + + Util::addStyle('polls', 'main'); + Util::addStyle('polls', 'flex'); + Util::addStyle('polls', 'vote'); + Util::addStyle('polls', 'sidebar'); + if (!User::isLoggedIn()) { + Util::addStyle('polls', 'public'); + } + + Util::addScript('polls', 'app'); + Util::addScript('polls', 'vote'); + + $userId = $_['userId']; + /** @var \OCP\IUserManager $userMgr */ + $userMgr = $_['userMgr']; + /** @var \OCP\IURLGenerator $urlGenerator */ + $urlGenerator = $_['urlGenerator']; + /** @var \OCP\IAvatarManager $avaMgr */ + $avaMgr = $_['avatarManager']; + /** @var \OCA\Polls\Db\Event $poll */ + $poll = $_['poll']; + /** @var OCA\Polls\Db\Options[] $options */ + $options = $_['options']; + /** @var OCA\Polls\Db\Votes[] $votes */ + $votes = $_['votes']; + /** @var \OCA\Polls\Db\Comment[] $comments */ + $comments = $_['comments']; + /** @var \OCA\Polls\Db\Notification $notification */ + $notification = $_['notification']; + + $isAnonymous = $poll->getIsAnonymous() && $userId !== $poll->getOwner(); + $hideNames = $poll->getIsAnonymous() && $poll->getFullAnonymous(); + if ($poll->getDisallowMaybe()) { + $maybe = 'maybedisallowed'; + } else { + $maybe = 'maybeallowed'; + } + $access = $poll->getAccess(); + $updatedPoll = false; + $dataUnvoted = ''; + + if ($poll->getExpire() === null) { + $expired = false; + } else { + $expired = time() > strtotime($poll->getExpire()); + } + + if ($expired) { + $statusClass = 'expired-vote'; + } else { + $statusClass = 'open-vote'; + if (time() < strtotime($poll->getExpire())) { + $statusClass .= ' endless'; + } + } + + if ($poll->getType() === 0) { + $pollType = 'date-poll'; + $pollTypeClass = 'date-poll'; + } else if ($poll->getType() === 1) { + $pollType = 'option-poll'; + $pollTypeClass = 'option-poll'; + } + + + if ( + $poll->getDescription() !== null && + $poll->getDescription() !== '' + ) { + $description = str_replace(array('\r\n', '\r', '\n'), '
', 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($votes); $i++) { + $total['yes'][$i] = 0; + $total['no'][$i] = 0; + $total['maybe'][$i] = 0; + } + $userVoted = array(); + $pollUrl = $urlGenerator->linkToRouteAbsolute('polls.page.goto_poll', ['hash' => $poll->getHash()]); +?> + +
+
+ + + + + + + +
+ +
+ +
+
+ +
+
+ + + + ' . $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())))) . ''); }?> +
+ +
+
    + getType() === 0) { + $timestamp = strtotime($optionElement->getPollOptionText()); + print_unescaped('
  • '); + print_unescaped('
    '); + print_unescaped('
    ' . $l->t(date('M', $timestamp)) . '
    '); + print_unescaped('
    ' . date('j', $timestamp) . '
    '); + print_unescaped('
    ' . $l->t(date('D', $timestamp)) . '
    '); + print_unescaped('
    ' . date('G:i', $timestamp) . ' UTC
    '); + print_unescaped('
    '); + } else { + print_unescaped('
  • '); + print_unescaped('
    ' . $optionElement->getPollOptionText() . '
    '); + } + print_unescaped('
    '); + print_unescaped('
    '); + print_unescaped('
    '); + print_unescaped('
    0
    '); + print_unescaped('
    '); + print_unescaped('
    '); + print_unescaped('
    '); + print_unescaped('
    0
    '); + print_unescaped('
    '); + print_unescaped('
    '); + } + ?> +
  • +
+ +
    + 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 = \OC_User::getDisplayName($usr); + $avatarName = $usr; + } else { + if ($isAnonymous || $hideNames) { + $displayName = 'Anonymous'; + $avatarName = $userCnt; + } else { + $displayName = $usr; + $avatarName = $usr; + } + } + ?> +
  • +
    +
    +
    +
    +
    +
    +
      + getPollOptionText() === $vote->getVoteOptionText()) { + $class = $vote->getVoteAnswer() . ' icon-'.$vote->getVoteAnswer(); + break; + } + $class = 'no icon-no'; + } + print_unescaped('
    • '); + $i_tot++; + } + + print_unescaped('
    '); + print_unescaped('
  • '); + } + } + $toggleTooltip = $l->t('Switch all options at once'); + if (!$expired) { + print_unescaped('
  • '); + print_unescaped('
    '); + print_unescaped('
    '); + if (User::isLoggedIn()) { + print_unescaped('
    '); + print_unescaped('
    '); + p(\OC_User::getDisplayName($userId)); + } else { + print_unescaped('
    '); + print_unescaped('
    '); + } + print_unescaped('
    '); + print_unescaped('
    '); + if ($maybe === 'maybeallowed') { + print_unescaped('
    '); + } else { + print_unescaped('
    '); + } + print_unescaped('
    '); + print_unescaped('
    '); + print_unescaped('
    '); + print_unescaped('
    '); + + $i_tot = 0; + foreach ($options as $optionElement) { + // see if user already has data for this event + $class = 'no icon-no'; + $dataUnvoted = ''; + if (isset($userVoted)) { + foreach ($userVoted as $vote) { + if ($optionElement->getPollOptionText() === $vote->getVoteOptionText()) { + $class = $vote->getVoteAnswer() . ' icon-'.$vote->getVoteAnswer(); + break; + } else { + $class = 'unvoted'; + } + } + } + + if ($class === 'unvoted') { + $dataUnvoted = $l->t('New'); + $updatedPoll = true; + } + + print_unescaped('
    '); + print_unescaped('
    '); + print_unescaped('
    '); + + $i_tot++; + } + print_unescaped('
    '); + print_unescaped('
  • '); + } + ?> +
+
+ + +
+

t('This poll was updated since your last visit. Please check your votes.')); ?>

+
+ + +
+
+
+ + + + + + + +
+
+ + +
+ /> + +
+ + +
+
+ +
+ +
+
+ +
+ +
+
+
+
t('Owner')); ?>
+
+
getOwner())); ?>
+
+ +
+ ' . $l->t('Expired') . ''); + } else { + if ($poll->getExpire() !== null) { + print_unescaped('' . $l->t('Expires on %s', array(date('d.m.Y', strtotime($poll->getExpire())))) . ''); + } else { + print_unescaped('' . $l->t('Expires never') . ''); + } + } + + if ($access === 'public' || $access === 'hidden' || $access === 'registered') { + print_unescaped('' . $access . ''); + } else { + print_unescaped('' . $l->t('Invitation access') . ''); + } + if ($isAnonymous) { + print_unescaped('' . $l->t('Anononymous poll') . ''); + if ($hideNames) { + print_unescaped('' . $l->t('Usernames hidden to Owner') . ''); + } else { + print_unescaped('' . $l->t('Usernames visible to Owner') . ''); + } + } + ?> +
+ +
+
+ +
+
+ + +
+

t('Poll expired')); ?>

+

+ t('The poll expired on %s. Voting is disabled, but you can still comment.', array(date('d.m.Y H:i', strtotime($poll->getExpire()))))); ?> +

+
+ + + + +
+
+
+ + +
+
+
+
+ + t('Login or ...')); ?> +
+
+
+ +
+
+ + +
+ + +
+ + +
+
+ +
    + + +
  • + +
  • + + + + getUserId() === $userId) { + // Comment is from current user + // -> display user + $avatarName = $userId; + $displayName = \OC_User::getDisplayName($userId); + + } 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 = \OC_User::getDisplayName($comment->getUserId()); + } 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; + } + ?> + +
  • +
    +
    +
    +
    getDt()))) ?>
    +
    +
    getComment()); ?>
    +
  • + +
+
+
+
+ +
-- cgit v1.2.3