コード例 #1
0
ファイル: evaluation_show.lib.php プロジェクト: ratbird/hope
 function getNumberOfVotesText($eval, $voted)
 {
     $stopdate = $eval->getRealStopdate();
     $number = EvaluationDB::getNumberOfVotes($eval->getObjectID());
     $html = "";
     /* Get number of participants ------------------------------------------- */
     if ($stopdate < time() && $stopdate > 0) {
         if ($number != 1) {
             $html .= sprintf(_("Es haben insgesamt <b>%s</b> Personen teilgenommen"), $number);
         } else {
             $html .= $voted ? sprintf(_("Sie waren die einzige Person die teilgenommen hat")) : sprintf(_("Es hat insgesamt <b>eine</b> Person teilgenommen"));
         }
     } else {
         if ($number != 1) {
             $html .= sprintf(_("Es haben bisher <b>%s</b> Personen teilgenommen"), $number);
         } else {
             $html .= $voted ? sprintf(_("Sie waren bisher der/die einzige Person die teilgenommen hat")) : sprintf(_("Es hat bisher <b>eine</b> Person teilgenommen"));
         }
     }
     /* ---------------------------------------------------------------------- */
     if ($voted && $number > 1) {
         $html .= _(", Sie ebenfalls");
     }
     $html .= ".\n";
     return $html;
 }
コード例 #2
0
 /**
  * Test...
  * @access public
  * @param  object  Evaluation  $eval  The evaluation
  * @param  string  $number
  * @param  string  $state
  * @param  string  $open
  * @param  boolean $returnRow
  */
 function createEvalRow($eval, $number, $state, $open, $returnRow = false)
 {
     /* initialize variables -------- */
     $evalID = $eval->getObjectID();
     $numberOfVotes = EvaluationDB::getNumberOfVotes($evalID);
     $no_permissons = EvaluationObjectDB::getEvalUserRangesWithNoPermission($eval);
     if ($eval->getAuthor() != $user->id && $no_permissons) {
         $no_buttons = 1;
     }
     $style = $number % 2 ? "table_row_odd" : ($number == 0 ? "content_body" : "table_row_even");
     $startDate = $eval->getStartdate() == NULL ? " " : date("d.m.Y", $eval->getStartdate());
     $stopDate = $eval->getRealStopdate() == NULL ? " " : date("d.m.Y", $eval->getRealStopdate());
     $link = "?rangeID=" . $_SESSION["rangeID"];
     if ($open == NO) {
         $link .= '&openID=' . $evalID . '#open';
     }
     $titleLink = new HTML('a');
     $titleLink->addAttr('href', URLHelper::getLink($link));
     $arrowLink = new HTML('a');
     $arrowLink->addAttr('href', URLHelper::getLink($link));
     $titleLink->addContent($eval->getTitle() ? $eval->getTitle() : ' ');
     switch ($state) {
         case "public_template":
             $arrowLink = "&nbsp;";
             $titleLink = $eval->getTitle() ? $eval->getTitle() : " ";
             $content[0] = $eval->getFullname() ? $eval->getFullname() : " ";
             $content[1] = $eval->getChangedate() == NULL ? " " : date("d.m.Y", $eval->getChangedate());
             $button = LinkButton::create(_('Vorschau'), URLHelper::getURL('show_evaluation.php?evalID=' . $evalID . '&isPreview=' . YES), array('title' => _('Vorschau dieser öffentlichen Evaluationsvorlage.'), 'onClick' => 'openEval(\'' . $evalID . '\'); return false;'));
             $div = new HTML("div");
             $div->addHTMLContent($button);
             $content[4] = $div;
             $content[2] = $eval->isAnonymous() ? EvalCommon::createImage(EVAL_PIC_YES, _("ja")) : EvalCommon::createImage(EVAL_PIC_NO, _("nein"));
             $copyButton = new HTMLempty("input");
             $copyButton->addAttr("style", "vertical-align:middle;");
             $copyButton->addAttr("type", "image");
             $copyButton->addAttr("name", "copy_public_template_button");
             $copyButton->addAttr("src", Icon::create('arr_2down', 'sort')->asImagePath());
             $copyButton->addAttr("border", "0");
             $copyButton->addAttr("alt", _("Kopieren"));
             $copyButton->addAttr("title", _("Diese öffentliche Evaluationsvorlagen zu den eigenen Evaluationsvorlagen kopieren"));
             $content[5] = $copyButton;
             break;
         case "user_template":
             $arrowLink->addContent(EvalCommon::createImage($open ? EVAL_PIC_ARROW_TEMPLATE_OPEN : EVAL_PIC_ARROW_TEMPLATE, _("Aufklappen")));
             $isShared = $eval->isShared() ? YES : NO;
             $shareButton = new HTMLempty("input");
             $shareButton->addAttr("style", "vertical-align:middle;");
             $shareButton->addAttr("type", "image");
             $shareButton->addAttr("name", "share_template_button");
             $shareButton->addAttr("src", $isShared ? EVAL_PIC_SHARED : EVAL_PIC_NOTSHARED);
             $shareButton->addAttr("border", "0");
             $shareButton->addAttr("alt", $isShared ? _("als öffentliche Evaluationsvorlage Freigeben") : _("Freigabe entziehen"));
             $shareButton->addAttr("title", $isShared ? _("Die Freigabe für diese Evaluationsvorlage entziehen") : _("Diese Evaluationsvorlage öffentlich freigeben"));
             $content[0] = $shareButton;
             $content[3] = Button::create(_('Kopie erstellen'), 'copy_own_template_button', array('title' => _('Evaluationsvorlage kopieren')));
             $content[4] = LinkButton::create(_('Bearbeiten'), URLHelper::getURL("admin_evaluation.php?page=edit&evalID=" . $evalID), array('title' => _('Evaluation bearbeiten')));
             $content[5] = Button::create(_('Löschen'), 'delete_request_button', array('title' => _('Evaluation löschen')));
             break;
         case EVAL_STATE_NEW:
             $arrowLink->addContent(EvalCommon::createImage($open ? EVAL_PIC_ARROW_NEW_OPEN : EVAL_PIC_ARROW_NEW, _("Aufklappen")));
             $content[0] = $eval->getFullname() ? $eval->getFullname() : " ";
             $content[1] = $startDate;
             if (!$no_buttons) {
                 $content[2] = Button::create(_('Start'), 'start_button', array('title' => _('Evaluation starten')));
                 $content[4] = LinkButton::create(_('Bearbeiten'), URLHelper::getURL("admin_evaluation.php?page=edit&evalID=" . $evalID), array('title' => _('Evaluation bearbeiten')));
                 $content[5] = Button::create(_('Löschen'), 'delete_request_button', array('title' => _('Evaluation löschen')));
             }
             break;
         case EVAL_STATE_ACTIVE:
             $arrowLink->addContent(EvalCommon::createImage($open ? EVAL_PIC_ARROW_RUNNING_OPEN : EVAL_PIC_ARROW_RUNNING, _("Aufklappen")));
             $content[0] = $eval->getFullname() ? $eval->getFullname() : " ";
             $content[1] = $stopDate;
             if (!$no_buttons) {
                 $content[2] = Button::createCancel(_('Stop'), 'stop_button', array('title' => _('Evaluation stoppen')));
                 // Kann hier noch optimiert werden, da hasVoted () immer einen DB-Aufruf startet
                 $content[3] = $eval->hasVoted() ? Button::create(_('Zurücksetzen'), 'restart_request_button', array('title' => _('Evaluation zurücksetzen'))) : Button::create(_('Zurücksetzen'), 'restart_confirmed_button', array('title' => _('Evaluation zurücksetzen')));
                 $content[4] = Button::create(_('Export'), 'export_request_button', array('title' => _('Evaluation exportieren')));
                 $content[5] = Button::create(_('Löschen'), 'delete_request_button', array('title' => _('Evaluation löschen')));
                 //$content[6] = EvalCommon::createSubmitButton ("auswertung", _("Auswertung"), "export_gfx_request_button");
                 $content[6] = LinkButton::create(_('Auswertung'), URLHelper::getURL("eval_summary.php?eval_id=" . $evalID), array('title' => _('Auswertung')));
             }
             break;
         case EVAL_STATE_STOPPED:
             $arrowLink->addContent(EvalCommon::createImage($open ? EVAL_PIC_ARROW_STOPPED_OPEN : EVAL_PIC_ARROW_STOPPED, _("Aufklappen")));
             $content[0] = $eval->getFullname() ? $eval->getFullname() : " ";
             //$content[1] = $eval->isVisible() ? "yes" : "no";
             if (!$no_buttons) {
                 $content[2] = Button::create(_('Fortsetzen'), 'continue_button', array('title' => _('Evaluation fortsetzen')));
                 $content[3] = $eval->hasVoted() ? Button::create(_('Zurücksetzen'), 'restart_request_button', array('title' => _('Evaluation zurücksetzen'))) : Button::create(_('Zurücksetzen'), 'restart_confirmed_button', array('title' => _('Evaluation zurücksetzen')));
                 $content[4] = Button::create(_('Export'), 'export_request_button', array('title' => _('Evaluation exportieren')));
                 $content[5] = Button::create(_('Löschen'), 'delete_request_button', array('title' => _('Evaluation löschen')));
                 //$content[6] = EvalCommon::createSubmitButton ("auswertung", _("Auswertung"), "export_gfx_request_button");
                 $content[6] = LinkButton::create(_('Auswertung'), URLHelper::getURL("eval_summary.php?eval_id=" . $evalID), array('title' => _('Auswertung')));
             }
             break;
     }
     $form = new HTML("form");
     $form->addAttr("action", URLHelper::getLink("?rangeID=" . $_SESSION["rangeID"]));
     $form->addAttr("method", "post");
     $form->addAttr("style", "display:inline;");
     $form->addHTMLContent(CSRFProtection::tokenTag());
     $input = new HTMLEmpty("input");
     $input->addAttr("type", "hidden");
     $input->addAttr("name", "evalID");
     $input->addAttr("value", $evalID);
     $form->addContent($input);
     $table = new HTML("table");
     $table->addAttr("border", "0");
     $table->addAttr("align", "center");
     $table->addAttr("cellspacing", "0");
     $table->addAttr("cellpadding", "2");
     $table->addAttr("width", "100%");
     $tr = new HTML("tr");
     $tr->addAttr("align", "center");
     /* opening arrow */
     $td = new HTML("td");
     $td->addAttr("class", $style);
     $td->addAttr("width", "10");
     if ($open) {
         $anchor = new HTML("a");
         $anchor->addAttr("name", "open");
         $anchor->addContent($arrowLink);
         $td->addContent($anchor);
     } else {
         $td->addHTMLContent($arrowLink);
     }
     if ($state != "public_template") {
         $tr->addContent($td);
     } else {
         $td = new HTML("td");
         $td->addAttr("class", $style);
         $td->addAttr("width", "1");
         // create a blindgif
         $blingif = new HTMLempty("img");
         $blingif->addAttr("border", "0");
         $blingif->addAttr("valign", "middle");
         $blingif->addAttr("width", "1");
         $blingif->addAttr("height", "24");
         $blingif->addAttr("alt", " ");
         $blingif->addAttr("src", PICTURES . "/forumleer.gif");
         $td->addContent($blingif);
         $tr->addContent($td);
     }
     /* preview icon */
     $td = new HTML("td");
     $td->addAttr("width", $state == "public_template" ? "20" : "1%");
     $td->addAttr("class", $style);
     $td->addAttr("align", "left");
     $icon = EvalCommon::createImage(EVAL_PIC_PREVIEW, _("Vorschau"));
     $td->addContent(EvalCommon::createEvalShowLink($evalID, $icon, YES));
     $tr->addContent($td);
     /* title */
     $td = new HTML("td");
     $td->addAttr("class", $style);
     $td->addAttr("align", "left");
     if ($returnRow) {
         $td->addAttr("width", "100%");
     }
     $td->addContent($titleLink);
     if ($state == EVAL_STATE_ACTIVE || $state == EVAL_STATE_STOPPED) {
         $td->addContent("|");
         $font = new HTML("font");
         $font->addAttr("color", "#005500");
         $font->addContent($numberOfVotes);
         $td->addContent($font);
         $td->addContent("|");
     }
     $tr->addContent($td);
     /* the content fields */
     //for( $i = 0; $i < 6; $i++ ) {
     for ($i = 0; $i < 7; $i++) {
         $td = new HTML("td");
         $td->addAttr("width", "96");
         $td->addAttr("class", $style);
         $td->addAttr("nowrap", "nowrap");
         $td->addAttr("style", "white-space:nowrap");
         #if (is_object($content[$i]))
         $td->addContent($content[$i] ? $content[$i] : " ");
         #$td->addHTMLContent ( ($content[$i] ? $content[$i] : "-") );
         # filter out not needed datacells
         if ($state == "user_template" && ($i == 1 || $i == 2)) {
             //nothing
         } elseif ($state == "public_template" && ($i == 3 || $i == 4)) {
             //nothing
         } else {
             $tr->addContent($td);
         }
     }
     // end: for
     $table->addContent($tr);
     if ($returnRow) {
         $form->addContent($tr);
     } else {
         $form->addContent($table);
     }
     return $form;
 }