public function frameResponse(\FrameResponseObject $frameResponseObject) { $TCR = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->id); $user = $GLOBALS["STEAM"]->get_current_steam_user(); $TCRExtension = \TCR::getInstance(); $TCRExtension->addCSS(); $TCRExtension->addJS(); $content = $TCRExtension->loadTemplate("tcr_create.template.html"); $kindOfDocument = $this->params[2]; // display create element dialog $content->setCurrentBlock("BLOCK_CREATE_ELEMENT"); if ($kindOfDocument == 0) { $create_label = "Neue These erstellen"; } else { if ($kindOfDocument == 1) { $create_label = "Neue Kritik erstellen"; $thesisID = $this->params[3]; $content->setVariable("ELEMENT_ID", $thesisID); } else { $create_label = "Neue Replik erstellen"; $reviewID = $this->params[3]; $content->setVariable("ELEMENT_ID", $reviewID); } } $content->setVariable("CREATE_LABEL", $create_label); $content->setVariable("TITLE_LABEL", "Titel"); $content->setVariable("DESC_LABEL", "Untertitel / Beschreibung"); $content->setVariable("PLAIN_LABEL", "Text-Dokument erstellen"); $content->setVariable("FILE_LABEL", "Datei hochladen"); $content->setVariable("CONTENT_LABEL", "Inhalt"); $content->setVariable("SUBMIT_CREATE", $create_label); $content->setVariable("BACK_LABEL", "Zurück"); $content->setVariable("BACK_URL", $TCRExtension->getExtensionUrl() . "privateDocuments/" . $this->id . "/" . $this->params[2]); $content->setVariable("KIND_VALUE", $kindOfDocument); $content->setVariable("ROUND_VALUE", $this->params[1]); // max file size message $max_file_size = parse_filesize(ini_get('upload_max_filesize')); $max_post_size = parse_filesize(ini_get('post_max_size')); if ($max_post_size > 0 && $max_post_size < $max_file_size) { $max_file_size = $max_post_size; } $content->setVariable("UPLOAD_MAXSIZE", str_replace("%SIZE", readable_filesize($max_file_size), gettext("The maximum allowed file size is %SIZE."))); $content->parse("BLOCK_CREATE_ELEMENT"); $group = $TCR->get_attribute("TCR_GROUP"); if ($group->get_name() == "learners") { $parent = $group->get_parent_group(); $courseOrGroup = "Kurs: " . $parent->get_attribute("OBJ_DESC") . " (" . $parent->get_name() . ")"; $courseOrGroupUrl = PATH_URL . "semester/" . $parent->get_id(); } else { $courseOrGroup = "Gruppe: " . $group->get_name(); $courseOrGroupUrl = PATH_URL . "groups/" . $group->get_id(); } $rawWidget = new \Widgets\RawHtml(); $rawWidget->setHtml($content->get()); $frameResponseObject->addWidget($rawWidget); $frameResponseObject->setHeadline(array(array("name" => $courseOrGroup, "link" => $courseOrGroupUrl), array("name" => "Thesen-Kritik-Replik-Verfahren", "link" => $TCRExtension->getExtensionUrl() . "Index/" . $this->id), array("name" => "Private Dokumente", "link" => $TCRExtension->getExtensionUrl() . "privateDocuments/" . $this->id), array("name" => $create_label))); return $frameResponseObject; }
public function frameResponse(\FrameResponseObject $frameResponseObject) { $TCR = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->id); $user = $GLOBALS["STEAM"]->get_current_steam_user(); $TCRExtension = \TCR::getInstance(); $TCRExtension->addCSS(); $content = $TCRExtension->loadTemplate("tcr_configuration.template.html"); $group = $TCR->get_attribute("TCR_GROUP"); $members = $group->get_members(); $admins = $TCR->get_attribute("TCR_ADMINS"); $users = $TCR->get_attribute("TCR_USERS"); if ($group->get_name() == "learners") { $parent = $group->get_parent_group(); $courseOrGroup = "Kurs: " . $parent->get_attribute("OBJ_DESC") . " (" . $parent->get_name() . ")"; $courseOrGroupUrl = PATH_URL . "semester/" . $parent->get_id(); } else { $courseOrGroup = "Gruppe: " . $group->get_name(); $courseOrGroupUrl = PATH_URL . "groups/" . $group->get_id(); } if ($group->get_name() == "learners") { $parent = $group->get_parent_group(); $groupname = $parent->get_attribute("OBJ_DESC") . " (" . $parent->get_name() . ")"; $subgroups = $parent->get_subgroups(); foreach ($subgroups as $subgroup) { if ($subgroup->get_name() == "staff") { $staff = $subgroup->get_members(); foreach ($staff as $staffMember) { if ($staffMember instanceof \steam_user) { array_push($members, $staffMember); } } break; } } } else { $groupname = $group->get_name(); } // configuration form got submitted if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["change_configuration"])) { $TCR->set_attribute("OBJ_DESC", $_POST["title"]); if (intval($_POST["rounds"]) > 0) { $TCR->set_attribute("TCR_ROUNDS", $_POST["rounds"]); } if (isset($_POST["admin"])) { $admins_post = $_POST["admin"]; } else { $admins_post = array(); } if (isset($_POST["member"])) { $members_post = $_POST["member"]; } else { $members_post = array(); } foreach ($members as $member) { if ($member instanceof \steam_user) { if (!array_key_exists($member->get_id(), $admins_post)) { $admins_post[$member->get_id()] = "off"; } if (!array_key_exists($member->get_id(), $members_post)) { $members_post[$member->get_id()] = "off"; } } } $former_admins_post = $_POST["formeradmin"]; $former_members_post = $_POST["formermember"]; foreach ($members as $member) { if ($member instanceof \steam_user) { // set new admin rights if ($admins_post[$member->get_id()] != $former_admins_post[$member->get_id()] && $member->get_id() != $TCR->get_creator()->get_id()) { if ($admins_post[$member->get_id()] == "off" && $former_admins_post[$member->get_id()] == "on") { unset($admins[array_search($member->get_id(), $admins)]); $admins = array_values($admins); } else { if ($admins_post[$member->get_id()] == "on" && $former_admins_post[$member->get_id()] == "off") { array_push($admins, $member->get_id()); } } } // set new members if ($members_post[$member->get_id()] != $former_members_post[$member->get_id()]) { if ($members_post[$member->get_id()] == "off" && $former_members_post[$member->get_id()] == "on") { unset($users[array_search($member->get_id(), $users)]); $users = array_values($users); } else { if ($members_post[$member->get_id()] == "on" && $former_members_post[$member->get_id()] == "off") { array_push($users, $member->get_id()); } } } } } $TCR->set_attribute("TCR_ADMINS", $admins); $TCR->set_attribute("TCR_USERS", $users); } // display error message if current user is no admin if (!in_array($user->get_id(), $admins)) { $actionbar = new \Widgets\Actionbar(); $actions = array(array("name" => "Private Dokumente", "link" => $TCRExtension->getExtensionUrl() . "privateDocuments/" . $this->id), array("name" => "Übersicht", "link" => $TCRExtension->getExtensionUrl() . "Index/" . $this->id), array("name" => "Alle Dokumente", "link" => $TCRExtension->getExtensionUrl() . "documents/" . $this->id)); $actionbar->setActions($actions); $frameResponseObject->addWidget($actionbar); $rawWidget = new \Widgets\RawHtml(); $rawWidget->setHtml("<center>Zugang verwehrt. Sie sind kein Administrator in diesem Thesen-Kritik-Replik-Verfahren</center>"); $frameResponseObject->addWidget($rawWidget); $frameResponseObject->setHeadline(array(array("name" => $courseOrGroup, "link" => $courseOrGroupUrl), array("name" => "Thesen-Kritik-Replik-Verfahren", "link" => $TCRExtension->getExtensionUrl() . "Index/" . $this->id), array("name" => "Konfiguration"))); return $frameResponseObject; } // display actionbar $actionbar = new \Widgets\Actionbar(); $actions = array(array("name" => "Konfiguration", "link" => $TCRExtension->getExtensionUrl() . "configuration/" . $this->id), array("name" => "Private Dokumente", "link" => $TCRExtension->getExtensionUrl() . "privateDocuments/" . $this->id), array("name" => "Übersicht", "link" => $TCRExtension->getExtensionUrl() . "Index/" . $this->id), array("name" => "Alle Dokumente", "link" => $TCRExtension->getExtensionUrl() . "documents/" . $this->id)); $actionbar->setActions($actions); $frameResponseObject->addWidget($actionbar); // display configuration table $content->setCurrentBlock("BLOCK_TCR_CONFIGURATION"); $content->setVariable("TCR_OPTIONS", "Thesen-Kritik-Replik-Verfahren Konfiguration"); $content->setVariable("TITLE_LABEL", "Titel"); $content->setVariable("TITLE_VALUE", $TCR->get_attribute("OBJ_DESC")); $content->setVariable("ROUNDS_LABEL", "Runden"); $content->setVariable("ROUNDS_VALUE", $TCR->get_attribute("TCR_ROUNDS")); $content->setVariable("GROUP_LABEL", "Arbeitsgruppe"); $content->setVariable("GROUP_VALUE", $groupname); // user management $content->setVariable("USERS_LABEL", "Benutzerverwaltung"); $content->setVariable("USER_LABEL", "Name"); $content->setVariable("ADMIN_LABEL", "Administrator"); $content->setVariable("MEMBER_LABEL", "Teilnehmer"); usort($members, "sort_workplans"); foreach ($members as $member) { if ($member instanceof \steam_user) { $content->setCurrentBlock("BLOCK_USER"); $content->setVariable("USER_NAME", $member->get_full_name() . " (" . $member->get_name() . ")"); $content->setVariable("USER_ID", $member->get_id()); if (in_array($member->get_id(), $admins)) { $content->setVariable("ADMIN_CHECKED", "checked"); if ($member->get_id() == $TCR->get_creator()->get_id()) { $content->setVariable("ADMIN_DISABLED", "disabled"); } $content->setVariable("FORMER_ADMIN", "on"); } else { $content->setVariable("FORMER_ADMIN", "off"); } if (in_array($member->get_id(), $users)) { $content->setVariable("MEMBER_CHECKED", "checked"); $content->setVariable("FORMER_MEMBER", "on"); } else { $content->setVariable("FORMER_MEMBER", "off"); } $content->parse("BLOCK_USER"); } } $content->setVariable("SAVE_CHANGES", "Änderungen speichern"); $content->parse("BLOCK_TCR_CONFIGURATION"); $rawWidget = new \Widgets\RawHtml(); $rawWidget->setHtml($content->get()); $frameResponseObject->addWidget($rawWidget); $frameResponseObject->setHeadline(array(array("name" => $courseOrGroup, "link" => $courseOrGroupUrl), array("name" => "Thesen-Kritik-Replik-Verfahren", "link" => $TCRExtension->getExtensionUrl() . "Index/" . $this->id), array("name" => "Konfiguration"))); return $frameResponseObject; }
public function frameResponse(\FrameResponseObject $frameResponseObject) { $TCR = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->id); $user = $GLOBALS["STEAM"]->get_current_steam_user(); $TCRExtension = \TCR::getInstance(); $TCRExtension->addCSS(); // determine kind of documents of the current user to display (0 = theses, 1 = reviews, 2 = responses) $kindOfDocument = 0; if (isset($this->params[1])) { $kindOfDocument = $this->params[1]; } // release document dialog was submitted if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["release_element"])) { $element = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $_POST["element_id"]); if ($_POST["kind"] == 0) { $critics = array(); $critics[$_POST["critic"]] = 0; $element->set_attribute("TCR_REVIEWS", $critics); $element->set_attribute("TCR_RELEASED", time()); } else { $element->set_attribute("TCR_RELEASED", time()); } } // edit document dialog was submitted if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["edit_element"])) { $old_element = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $_POST["old_id"]); // old element was plain text if ($old_element->get_attribute("DOC_MIME_TYPE") == "text/plain") { // new element is plain text if ($_POST["new_upload_text"] == 0) { $old_element->set_name($_POST["title"]); $old_element->set_attribute("OBJ_DESC", $_POST["desc"]); $old_element->set_content($_POST["content"]); // new element is an upload } else { $old_element->delete(); $radio = 1; } // old element was an upload } else { // new element is the same if ($_POST["new_upload"] == 0) { $old_element->set_name($_POST["title"]); $old_element->set_attribute("OBJ_DESC", $_POST["desc"]); // new element is a new upload } else { if ($_POST["new_upload"] == 1) { $old_element->delete(); $radio = 1; // new element is plain text } else { $old_element->set_attribute("DOC_MIME_TYPE", "text/plain"); $old_element->set_name($_POST["title"]); $old_element->set_attribute("OBJ_DESC", $_POST["desc"]); $old_element->set_content($_POST["new_content"]); } } } } // if a new element got created or already existing element gets a new upload if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["create_element"]) || isset($radio)) { $problems = ""; $hints = ""; if (!isset($radio)) { $radio = $_POST["radio"]; } if ($radio == 1) { // handle upload require_once PATH_LIB . "format_handling.inc.php"; $max_file_size = parse_filesize(ini_get('upload_max_filesize')); $max_post_size = parse_filesize(ini_get('post_max_size')); if ($max_post_size > 0 && $max_post_size < $max_file_size) { $max_file_size = $max_post_size; } if (empty($_FILES) || !empty($_FILES["file"]["error"]) && $_FILES["file"]["error"] > 0) { if (!empty($_FILES) && empty($_FILES["file"]["name"])) { $problems = gettext("No file chosen.") . " "; $hints = gettext("Please choose a local file to upload.") . " "; } else { $problems = gettext("Could not upload document.") . " "; $hints = str_replace(array("%SIZE", "%TIME"), array(readable_filesize($max_file_size), (string) ini_get('max_execution_time')), gettext("Maybe your document exceeded the allowed file size (max. %SIZE) or the upload might have taken too long (max. %TIME seconds).")) . " "; } } if (empty($problems)) { $content = file_get_contents($_FILES["file"]["tmp_name"]); $type = $_FILES["file"]["type"]; } } else { $content = $_POST["content"]; $type = "text/plain"; } if ($_POST["kind"] == 0) { $container = \steam_factory::get_object_by_name($GLOBALS["STEAM"]->get_id(), $TCR->get_path() . "/theses"); } else { if ($_POST["kind"] == 1) { $container = \steam_factory::get_object_by_name($GLOBALS["STEAM"]->get_id(), $TCR->get_path() . "/reviews"); } else { $container = \steam_factory::get_object_by_name($GLOBALS["STEAM"]->get_id(), $TCR->get_path() . "/responses"); } } $title = $_POST["title"]; $desc = $_POST["desc"]; if (empty($problems)) { $new_element = \steam_factory::create_document($GLOBALS["STEAM"]->get_id(), $title, $content, $type, $container, $desc); if ($_POST["kind"] == 0) { $new_element->set_attribute("TCR_ROUND", $_POST["round"]); $new_element->set_attribute("TCR_REVIEWS", array()); $new_element->set_attribute("TCR_RELEASED", 0); } else { if ($_POST["kind"] == 1) { $new_element->set_attribute("TCR_RELEASED", 0); $correspondingThesis = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $_POST["elementID"]); $critics_thesis = $correspondingThesis->get_attribute("TCR_REVIEWS"); $critics_thesis[$user->get_id()] = $new_element->get_id(); $correspondingThesis->set_attribute("TCR_REVIEWS", $critics_thesis); } else { $new_element->set_attribute("TCR_RELEASED", 0); $correspondingReview = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $_POST["elementID"]); $correspondingReview->set_attribute("TCR_RESPONSE", $new_element->get_id()); } } } else { $frameResponseObject->setProblemDescription($problems); $frameResponseObject->setProblemSolution($hints); } } // display actionbar $actionbar = new \Widgets\Actionbar(); $admins = $TCR->get_attribute("TCR_ADMINS"); if (in_array($user->get_id(), $admins)) { $actions = array(array("name" => "Konfiguration", "link" => $TCRExtension->getExtensionUrl() . "configuration/" . $this->id), array("name" => "Private Dokumente", "link" => $TCRExtension->getExtensionUrl() . "privateDocuments/" . $this->id), array("name" => "Übersicht", "link" => $TCRExtension->getExtensionUrl() . "Index/" . $this->id), array("name" => "Alle Dokumente", "link" => $TCRExtension->getExtensionUrl() . "documents/" . $this->id)); } else { $actions = array(array("name" => "Private Dokumente", "link" => $TCRExtension->getExtensionUrl() . "privateDocuments/" . $this->id), array("name" => "Übersicht", "link" => $TCRExtension->getExtensionUrl() . "Index/" . $this->id), array("name" => "Alle Dokumente", "link" => $TCRExtension->getExtensionUrl() . "documents/" . $this->id)); } $actionbar->setActions($actions); $frameResponseObject->addWidget($actionbar); $group = $TCR->get_attribute("TCR_GROUP"); if ($group->get_name() == "learners") { $parent = $group->get_parent_group(); $courseOrGroup = "Kurs: " . $parent->get_attribute("OBJ_DESC") . " (" . $parent->get_name() . ")"; $courseOrGroupUrl = PATH_URL . "semester/" . $parent->get_id(); } else { $courseOrGroup = "Gruppe: " . $group->get_name(); $courseOrGroupUrl = PATH_URL . "groups/" . $group->get_id(); } $content = $TCRExtension->loadTemplate("tcr_privatedocuments.template.html"); // display a message if current user is not a user of this tcr $members = $TCR->get_attribute("TCR_USERS"); if (!in_array($user->get_id(), $members)) { $content->setCurrentBlock("BLOCK_DOCUMENTS_TABLE"); $content->setVariable("DISPLAY_TABLE", "none"); $content->setVariable("NOT_USER", "Sie sind nicht als Teilnehmer dieses Thesen-Kritik-Replik-Verfahrens eingetragen. Wenden Sie sich an einen Administrator."); $content->parse("BLOCK_DOCUMENTS_TABLE"); $rawWidget = new \Widgets\RawHtml(); $rawWidget->setHtml($content->get()); $frameResponseObject->addWidget($rawWidget); $frameResponseObject->setHeadline(array(array("name" => $courseOrGroup, "link" => $courseOrGroupUrl), array("name" => "Thesen-Kritik-Replik-Verfahren", "link" => $TCRExtension->getExtensionUrl() . "Index/" . $this->id), array("name" => "Private Dokumente"))); return $frameResponseObject; } // display tabbar $tabBar = new \Widgets\TabBar(); $tabBar->setTabs(array(array("name" => "Thesen", "link" => $TCRExtension->getExtensionUrl() . "privateDocuments/" . $this->id), array("name" => "Kritiken", "link" => $TCRExtension->getExtensionUrl() . "privateDocuments/" . $this->id . "/1"), array("name" => "Repliken", "link" => $TCRExtension->getExtensionUrl() . "privateDocuments/" . $this->id . "/2"))); $tabBar->setActiveTab($kindOfDocument); $frameResponseObject->addWidget($tabBar); // create array structure and add theses for their round $rounds = $TCR->get_attribute("TCR_ROUNDS"); $theses_container = \steam_factory::get_object_by_name($GLOBALS["STEAM"]->get_id(), $TCR->get_path() . "/theses"); $theses_inventory = $theses_container->get_inventory(); $theses = array(); $theses_response = array(); foreach ($theses_inventory as $thesis) { $current_round = $thesis->get_attribute("TCR_ROUND"); if ($thesis->get_creator()->get_id() == $user->get_id()) { $theses[$current_round] = $thesis; } $critics = $thesis->get_attribute("TCR_REVIEWS"); if (is_array($critics)) { if (array_key_exists($user->get_id(), $critics)) { $theses_response[$current_round] = $thesis; } } } // display private documents table $content->setCurrentBlock("BLOCK_DOCUMENTS_TABLE"); if ($kindOfDocument == 0 || $kindOfDocument == 2) { $content->setVariable("THESES_LABEL", "Erstellte Thesen"); $content->setVariable("REVIEWS_LABEL", "Erhaltene Kritiken"); $content->setVariable("RESPONSES_LABEL", "Erstellte Repliken"); if ($kindOfDocument == 0) { // thesis view for ($count = 1; $count <= $rounds; $count++) { $content->setCurrentBlock("BLOCK_DOCUMENTS_TABLE_ELEMENT"); $content->setVariable("ROUND_VALUE", "Runde " . $count); if (!array_key_exists($count, $theses)) { $content->setVariable("CREATE_THESIS", "These erstellen"); $content->setVariable("THESIS_ICON", "create_32"); $content->setVariable("THESIS_URL", $TCRExtension->getExtensionUrl() . "create/" . $this->id . "/" . $count . "/" . $kindOfDocument); $content->setVariable("DISPLAY_THESIS_SECOND", "none"); $content->setVariable("DISPLAY_REVIEW", "none"); $content->setVariable("DISPLAY_RESPONSE", "none"); } else { $current_critics = $theses[$count]->get_attribute("TCR_REVIEWS"); if (count($current_critics) > 0) { $content->setVariable("CREATE_THESIS", "Anzeigen"); $content->setVariable("THESIS_ICON", "view_32"); $content->setVariable("THESIS_URL", $TCRExtension->getExtensionUrl() . "release/" . $theses[$count]->get_id()); $content->setVariable("DISPLAY_THESIS_SECOND", "none"); foreach ($current_critics as $critic => $review) { if ($review == 0) { $content->setVariable("DISPLAY_REVIEW", "none"); $content->setVariable("DISPLAY_RESPONSE", "none"); $review_released = 0; } else { $current_review = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $review); $review_released = $current_review->get_attribute("TCR_RELEASED"); } if ($review_released != 0) { $content->setVariable("CREATE_REVIEW", "Anzeigen"); $content->setVariable("REVIEW_ICON", "view_32"); $content->setVariable("REVIEW_URL", $TCRExtension->getExtensionUrl() . "release/" . $current_review->get_id()); $content->setVariable("DISPLAY_REVIEW_SECOND", "none"); $responseID = $current_review->get_attribute("TCR_RESPONSE"); if ($responseID == 0) { $response_released = 0; } else { $response_element = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $responseID); $response_released = $response_element->get_attribute("TCR_RELEASED"); } if ($response_released == 0) { $content->setVariable("DISPLAY_RESPONSE", "none"); } else { $content->setVariable("CREATE_RESPONSE", "Anzeigen"); $content->setVariable("RESPONSE_ICON", "view_32"); $content->setVariable("RESPONSE_URL", $TCRExtension->getExtensionUrl() . "release/" . $response_element->get_id()); $content->setVariable("DISPLAY_RESPONSE_SECOND", "none"); } } else { $content->setVariable("DISPLAY_REVIEW", "none"); $content->setVariable("DISPLAY_RESPONSE", "none"); } } } else { $content->setVariable("CREATE_THESIS", "Anzeigen / Bearbeiten"); $content->setVariable("THESIS_ICON", "view_32"); $content->setVariable("THESIS_URL", $TCRExtension->getExtensionUrl() . "edit/" . $theses[$count]->get_id()); $content->setVariable("THESIS_ICON2", "release_32"); $content->setVariable("THESIS_URL2", $TCRExtension->getExtensionUrl() . "release/" . $theses[$count]->get_id()); $content->setVariable("RELEASE_THESIS", "Veröffentlichen"); $content->setVariable("DISPLAY_REVIEW", "none"); $content->setVariable("DISPLAY_RESPONSE", "none"); } } $content->setVariable("ASSETURL", $TCRExtension->getAssetUrl()); $content->parse("BLOCK_DOCUMENTS_TABLE_ELEMENT"); } // response view } else { for ($count = 1; $count <= $rounds; $count++) { $content->setCurrentBlock("BLOCK_DOCUMENTS_TABLE_ELEMENT"); $content->setVariable("ROUND_VALUE", "Runde " . $count); if (!array_key_exists($count, $theses)) { $content->setVariable("DISPLAY_THESIS", "none"); $content->setVariable("DISPLAY_REVIEW", "none"); $content->setVariable("DISPLAY_RESPONSE", "none"); } else { $current_critics = $theses[$count]->get_attribute("TCR_REVIEWS"); if (count($current_critics) > 0) { $content->setVariable("CREATE_THESIS", "Anzeigen"); $content->setVariable("THESIS_ICON", "view_32"); $content->setVariable("THESIS_URL", $TCRExtension->getExtensionUrl() . "release/" . $theses[$count]->get_id()); $content->setVariable("DISPLAY_THESIS_SECOND", "none"); foreach ($current_critics as $critic => $review) { if ($review == 0) { $review_released = 0; } else { $current_review = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $review); $review_released = $current_review->get_attribute("TCR_RELEASED"); } if ($review_released != 0) { $content->setVariable("CREATE_REVIEW", "Anzeigen"); $content->setVariable("REVIEW_ICON", "view_32"); $content->setVariable("REVIEW_URL", $TCRExtension->getExtensionUrl() . "release/" . $current_review->get_id()); $content->setVariable("DISPLAY_REVIEW_SECOND", "none"); $responseID = $current_review->get_attribute("TCR_RESPONSE"); if ($responseID == 0) { $content->setVariable("CREATE_RESPONSE", "Replik erstellen"); $content->setVariable("RESPONSE_ICON", "create_32"); $content->setVariable("RESPONSE_URL", $TCRExtension->getExtensionUrl() . "create/" . $this->id . "/" . $count . "/" . $kindOfDocument . "/" . $current_review->get_id()); $content->setVariable("DISPLAY_RESPONSE_SECOND", "none"); } else { $response_element = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $responseID); $response_released = $response_element->get_attribute("TCR_RELEASED"); if ($response_released == 0) { $content->setVariable("CREATE_RESPONSE", "Anzeigen / Bearbeiten"); $content->setVariable("RESPONSE_ICON", "view_32"); $content->setVariable("RESPONSE_URL", $TCRExtension->getExtensionUrl() . "edit/" . $response_element->get_id()); $content->setVariable("RESPONSE_ICON2", "release_32"); $content->setVariable("RESPONSE_URL2", $TCRExtension->getExtensionUrl() . "release/" . $response_element->get_id()); $content->setVariable("RELEASE_RESPONSE", "Veröffentlichen"); } else { $content->setVariable("CREATE_RESPONSE", "Anzeigen"); $content->setVariable("RESPONSE_ICON", "view_32"); $content->setVariable("RESPONSE_URL", $TCRExtension->getExtensionUrl() . "release/" . $response_element->get_id()); $content->setVariable("DISPLAY_RESPONSE_SECOND", "none"); } } } else { $content->setVariable("DISPLAY_REVIEW", "none"); $content->setVariable("DISPLAY_RESPONSE", "none"); } } } else { $content->setVariable("DISPLAY_THESIS", "none"); $content->setVariable("DISPLAY_REVIEW", "none"); $content->setVariable("DISPLAY_RESPONSE", "none"); } } $content->setVariable("ASSETURL", $TCRExtension->getAssetUrl()); $content->parse("BLOCK_DOCUMENTS_TABLE_ELEMENT"); } } // review view } else { $content->setVariable("THESES_LABEL", "Erhaltene Thesen"); $content->setVariable("REVIEWS_LABEL", "Erstellte Kritiken"); $content->setVariable("RESPONSES_LABEL", "Erhaltene Repliken"); for ($count = 1; $count <= $rounds; $count++) { $content->setCurrentBlock("BLOCK_DOCUMENTS_TABLE_ELEMENT"); $content->setVariable("ROUND_VALUE", "Runde " . $count); if (!array_key_exists($count, $theses_response)) { $content->setVariable("DISPLAY_THESIS", "none"); $content->setVariable("DISPLAY_REVIEW", "none"); $content->setVariable("DISPLAY_RESPONSE", "none"); } else { $content->setVariable("CREATE_THESIS", "Anzeigen"); $content->setVariable("THESIS_ICON", "view_32"); $content->setVariable("THESIS_URL", $TCRExtension->getExtensionUrl() . "release/" . $theses_response[$count]->get_id()); $content->setVariable("DISPLAY_THESIS_SECOND", "none"); $critics_array = $theses_response[$count]->get_attribute("TCR_REVIEWS"); if ($critics_array[$user->get_id()] == 0) { $content->setVariable("CREATE_REVIEW", "Kritik erstellen"); $content->setVariable("REVIEW_ICON", "create_32"); $content->setVariable("REVIEW_URL", $TCRExtension->getExtensionUrl() . "create/" . $this->id . "/" . $count . "/" . $kindOfDocument . "/" . $theses_response[$count]->get_id()); $content->setVariable("DISPLAY_REVIEW_SECOND", "none"); $content->setVariable("DISPLAY_RESPONSE", "none"); $content->setVariable("DISPLAY_RESPONSE_SECOND", "none"); } else { $review = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $critics_array[$user->get_id()]); $released = $review->get_attribute("TCR_RELEASED"); if ($released == 0) { $content->setVariable("CREATE_REVIEW", "Anzeigen / Bearbeiten"); $content->setVariable("REVIEW_ICON", "view_32"); $content->setVariable("REVIEW_URL", $TCRExtension->getExtensionUrl() . "edit/" . $review->get_id()); $content->setVariable("REVIEW_ICON2", "release_32"); $content->setVariable("REVIEW_URL2", $TCRExtension->getExtensionUrl() . "release/" . $review->get_id()); $content->setVariable("RELEASE_REVIEW", "Veröffentlichen"); $content->setVariable("DISPLAY_RESPONSE", "none"); } else { $content->setVariable("CREATE_REVIEW", "Anzeigen"); $content->setVariable("REVIEW_ICON", "view_32"); $content->setVariable("REVIEW_URL", $TCRExtension->getExtensionUrl() . "release/" . $review->get_id()); $content->setVariable("DISPLAY_REVIEW_SECOND", "none"); $responseID = $review->get_attribute("TCR_RESPONSE"); if ($responseID == 0) { $response_released = 0; } else { $response_element = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $responseID); $response_released = $response_element->get_attribute("TCR_RELEASED"); } if ($response_released == 0) { $content->setVariable("DISPLAY_RESPONSE", "none"); } else { $content->setVariable("CREATE_RESPONSE", "Anzeigen"); $content->setVariable("RESPONSE_ICON", "view_32"); $content->setVariable("RESPONSE_URL", $TCRExtension->getExtensionUrl() . "release/" . $response_element->get_id()); $content->setVariable("DISPLAY_RESPONSE_SECOND", "none"); } } } } $content->setVariable("ASSETURL", $TCRExtension->getAssetUrl()); $content->parse("BLOCK_DOCUMENTS_TABLE_ELEMENT"); } } $content->parse("BLOCK_DOCUMENTS_TABLE"); $rawWidget = new \Widgets\RawHtml(); $rawWidget->setHtml($content->get()); $frameResponseObject->addWidget($rawWidget); $frameResponseObject->setHeadline(array(array("name" => $courseOrGroup, "link" => $courseOrGroupUrl), array("name" => "Thesen-Kritik-Replik-Verfahren", "link" => $TCRExtension->getExtensionUrl() . "Index/" . $this->id), array("name" => "Private Dokumente"))); return $frameResponseObject; }
public function frameResponse(\FrameResponseObject $frameResponseObject) { $TCR = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->id); $user = $GLOBALS["STEAM"]->get_current_steam_user(); $TCRExtension = \TCR::getInstance(); $TCRExtension->addCSS(); $TCRExtension->addJS(); $content = $TCRExtension->loadTemplate("tcr_index.template.html"); $members = $TCR->get_attribute("TCR_USERS"); // determine which kind of elements is displayed (0 = theses, 1 = reviews, 2 = responses, 3 = all) if (isset($this->params[1])) { $kind = $this->params[1]; } else { $kind = 3; } // display actionbar $actionbar = new \Widgets\Actionbar(); $admins = $TCR->get_attribute("TCR_ADMINS"); if (in_array($user->get_id(), $admins)) { $actions = array(array("name" => "Konfiguration", "link" => $TCRExtension->getExtensionUrl() . "configuration/" . $this->id), array("name" => "Private Dokumente", "link" => $TCRExtension->getExtensionUrl() . "privateDocuments/" . $this->id), array("name" => "Übersicht", "link" => $TCRExtension->getExtensionUrl() . "Index/" . $this->id), array("name" => "Alle Dokumente", "link" => $TCRExtension->getExtensionUrl() . "documents/" . $this->id)); } else { $actions = array(array("name" => "Private Dokumente", "link" => $TCRExtension->getExtensionUrl() . "privateDocuments/" . $this->id), array("name" => "Übersicht", "link" => $TCRExtension->getExtensionUrl() . "Index/" . $this->id), array("name" => "Alle Dokumente", "link" => $TCRExtension->getExtensionUrl() . "documents/" . $this->id)); } $actionbar->setActions($actions); $frameResponseObject->addWidget($actionbar); // display tabbar $tabBar = new \Widgets\TabBar(); $tabBar->setTabs(array(array("name" => "Alle", "link" => $TCRExtension->getExtensionUrl() . "documents/" . $this->id), array("name" => "Thesen", "link" => $TCRExtension->getExtensionUrl() . "documents/" . $this->id . "/0"), array("name" => "Kritiken", "link" => $TCRExtension->getExtensionUrl() . "documents/" . $this->id . "/1"), array("name" => "Repliken", "link" => $TCRExtension->getExtensionUrl() . "documents/" . $this->id . "/2"))); if ($kind == 3) { $tabBar->setActiveTab(0); } else { $tabBar->setActiveTab($kind + 1); } $frameResponseObject->addWidget($tabBar); // create arrays for every round and add the theses to these arrays $rounds = $TCR->get_attribute("TCR_ROUNDS"); $theses_container = \steam_factory::get_object_by_name($GLOBALS["STEAM"]->get_id(), $TCR->get_path() . "/theses"); $theses_inventory = $theses_container->get_inventory(); $theses = array(); for ($count = 1; $count <= $rounds; $count++) { $theses[$count] = array(); } foreach ($theses_inventory as $thesis) { $critics = $thesis->get_attribute("TCR_REVIEWS"); if (count($critics) > 0 && in_array($thesis->get_creator()->get_id(), $members)) { $current_round = $thesis->get_attribute("TCR_ROUND"); array_push($theses[$current_round], $thesis); } } // display documents table $content = $TCRExtension->loadTemplate("tcr_documents.template.html"); $content->setCurrentBlock("BLOCK_DOCUMENTS_TABLE"); $content->setVariable("ROUND_LABEL", "Runde"); $content->setVariable("DOCUMENT_KIND_LABEL", "Art"); $content->setVariable("CONTENT_LABEL", "Inhalt"); $content->setVariable("AUTHOR_LABEL", "Autor(in)"); $content->setVariable("DATE_LABEL", "Veröffentlicht am"); $content->setVariable("COMMENTS_LABEL", "Kommentare"); for ($count = 1; $count <= $rounds; $count++) { $content->setCurrentBlock("BLOCK_DOCUMENTS_ROUND"); $content->setVariable("CURRENT_ROUND", $count . ". Runde"); $content->setVariable("CURRENT_ROUND_VALUE", $count); // display every thesis in the corresponding round foreach ($theses[$count] as $current_thesis) { if ($kind == 3 || $kind == 0) { $creator = $current_thesis->get_creator(); $date = $current_thesis->get_attribute("TCR_RELEASED"); $content->setCurrentBlock("BLOCK_DOCUMENTS_ELEMENT"); $content->setVariable("ASSETURL", $TCRExtension->getAssetUrl()); $content->setVariable("DOCUMENT_KIND", "These"); $content->setVariable("ELEMENT_URL", $TCRExtension->getExtensionUrl() . "release/" . $current_thesis->get_id()); $content->setVariable("VIEW_ELEMENT", "Inhalt anzeigen"); $content->setVariable("ASSETURL", $TCRExtension->getAssetUrl()); $content->setVariable("AUTHOR_VALUE", $creator->get_full_name() . " (" . $creator->get_name() . ")"); $content->setVariable("DATE_VALUE", date("d.m.Y H:i:s", $date)); if (count($current_thesis->get_annotations()) == 1) { $content->setVariable("COMMENTS_VALUE", "(1 Kommentar)"); } else { $content->setVariable("COMMENTS_VALUE", "(" . count($current_thesis->get_annotations()) . " Kommentare)"); } $content->setVariable("COMMENTS_URL", $TCRExtension->getExtensionUrl() . "release/" . $current_thesis->get_id()); $content->parse("BLOCK_DOCUMENTS_ELEMENT"); } $critics = $current_thesis->get_attribute("TCR_REVIEWS"); // display reviews to the thesis if there are any released ones foreach ($critics as $critic => $review) { if ($review != 0) { $review_object = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $review); $review_released = $review_object->get_attribute("TCR_RELEASED"); if ($review_released != 0 && in_array($critic, $members)) { if ($kind == 3 || $kind == 1) { $creator = $review_object->get_creator(); $date = $review_object->get_attribute("TCR_RELEASED"); $content->setCurrentBlock("BLOCK_DOCUMENTS_ELEMENT"); $content->setVariable("ASSETURL", $TCRExtension->getAssetUrl()); $content->setVariable("DOCUMENT_KIND", "Kritik"); $content->setVariable("ELEMENT_URL", $TCRExtension->getExtensionUrl() . "release/" . $review_object->get_id()); $content->setVariable("VIEW_ELEMENT", "Inhalt anzeigen"); $content->setVariable("ASSETURL", $TCRExtension->getAssetUrl()); $content->setVariable("AUTHOR_VALUE", $creator->get_full_name() . " (" . $creator->get_name() . ")"); $content->setVariable("DATE_VALUE", date("d.m.Y H:i:s", $date)); if (count($review_object->get_annotations()) == 1) { $content->setVariable("COMMENTS_VALUE", "(1 Kommentar)"); } else { $content->setVariable("COMMENTS_VALUE", "(" . count($review_object->get_annotations()) . " Kommentare)"); } $content->setVariable("COMMENTS_URL", $TCRExtension->getExtensionUrl() . "release/" . $review_object->get_id()); $content->parse("BLOCK_DOCUMENTS_ELEMENT"); } // display response if it exists and is released $response = $review_object->get_attribute("TCR_RESPONSE"); if ($response != 0) { $response_object = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $response); $response_released = $response_object->get_attribute("TCR_RELEASED"); if ($response_released != 0) { if ($kind == 3 || $kind == 2) { $creator = $response_object->get_creator(); $date = $response_object->get_attribute("TCR_RELEASED"); $content->setCurrentBlock("BLOCK_DOCUMENTS_ELEMENT"); $content->setVariable("ASSETURL", $TCRExtension->getAssetUrl()); $content->setVariable("DOCUMENT_KIND", "Replik"); $content->setVariable("ELEMENT_URL", $TCRExtension->getExtensionUrl() . "release/" . $response_object->get_id()); $content->setVariable("VIEW_ELEMENT", "Inhalt anzeigen"); $content->setVariable("ASSETURL", $TCRExtension->getAssetUrl()); $content->setVariable("AUTHOR_VALUE", $creator->get_full_name() . " (" . $creator->get_name() . ")"); $content->setVariable("DATE_VALUE", date("d.m.Y H:i:s", $date)); if (count($response_object->get_annotations()) == 1) { $content->setVariable("COMMENTS_VALUE", "(1 Kommentar)"); } else { $content->setVariable("COMMENTS_VALUE", "(" . count($response_object->get_annotations()) . " Kommentare)"); } $content->setVariable("COMMENTS_URL", $TCRExtension->getExtensionUrl() . "release/" . $response_object->get_id()); $content->parse("BLOCK_DOCUMENTS_ELEMENT"); } } } } } } } $content->parse("BLOCK_DOCUMENTS_ROUND"); } // display filter $content->setVariable("FILTER_LABEL", "Filter:"); $content->setCurrentBlock("BLOCK_DOCUMENTS_DROPDOWN"); $content->setVariable("OPTION_VALUE", 0); $content->setVariable("OPTION_NAME", "Alle Runden"); $content->setVariable("ROUNDS_VALUE", $rounds); $content->parse("BLOCK_DOCUMENTS_DROPDOWN"); for ($count = 1; $count <= $rounds; $count++) { $content->setCurrentBlock("BLOCK_DOCUMENTS_DROPDOWN"); $content->setVariable("OPTION_VALUE", $count); $content->setVariable("OPTION_NAME", $count . ". Runde"); $content->setVariable("ROUNDS_VALUE", $rounds); $content->parse("BLOCK_DOCUMENTS_DROPDOWN"); } $content->parse("BLOCK_DOCUMENTS_TABLE"); $group = $TCR->get_attribute("TCR_GROUP"); if ($group->get_name() == "learners") { $parent = $group->get_parent_group(); $courseOrGroup = "Kurs: " . $parent->get_attribute("OBJ_DESC") . " (" . $parent->get_name() . ")"; $courseOrGroupUrl = PATH_URL . "semester/" . $parent->get_id(); } else { $courseOrGroup = "Gruppe: " . $group->get_name(); $courseOrGroupUrl = PATH_URL . "groups/" . $group->get_id(); } $rawWidget = new \Widgets\RawHtml(); $rawWidget->setHtml($content->get()); $frameResponseObject->addWidget($rawWidget); $frameResponseObject->setHeadline(array(array("name" => $courseOrGroup, "link" => $courseOrGroupUrl), array("name" => "Thesen-Kritik-Replik-Verfahren", "link" => $TCRExtension->getExtensionUrl() . "Index/" . $TCR->get_id()), array("name" => "Alle Dokumente"))); return $frameResponseObject; }
public function frameResponse(\FrameResponseObject $frameResponseObject) { $element = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->id); $user = $GLOBALS["STEAM"]->get_current_steam_user(); $path = $element->get_path(); $path = substr($path, 0, strrpos($path, "/")); $type = substr($path, strrpos($path, "/") + 1, strlen($path)); $TCR = \steam_factory::get_object_by_name($GLOBALS["STEAM"]->get_id(), substr($path, 0, strrpos($path, "/"))); $TCRExtension = \TCR::getInstance(); $TCRExtension->addCSS(); $TCRExtension->addJS(); $content = $TCRExtension->loadTemplate("tcr_release.template.html"); $members = $TCR->get_attribute("TCR_USERS"); sort($members); $critics = $element->get_attribute("TCR_REVIEWS"); $group = $TCR->get_attribute("TCR_GROUP"); $private = 1; // determine where the user is coming from $referer = getenv("HTTP_REFERER"); if (strpos($referer, "Index") !== false) { $backurl = $TCRExtension->getExtensionUrl() . "Index/" . $TCR->get_id(); $referer = 1; } else { if (strpos($referer, "documents") !== false) { $backurl = $TCRExtension->getExtensionUrl() . "documents/" . $TCR->get_id(); $referer = 2; } else { if (strpos($referer, "privateDocuments") !== false) { $backurl = $TCRExtension->getExtensionUrl() . "privateDocuments/" . $TCR->get_id(); $referer = 3; } } } if ($_SERVER["REQUEST_METHOD"] == "POST") { // if a new comment was submitted if (isset($_POST["add_comment"])) { $new_comment = \steam_factory::create_textdoc($GLOBALS["STEAM"]->get_id(), $_POST["title"], stripslashes($_POST["content"])); $new_comment->set_read_access($group); $new_comment->set_write_access($group); $element->add_annotation($new_comment); } // if a comment edit got submitted if (isset($_POST["edit_comment"])) { $comment = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $_POST["edit_id"]); $comment->set_content($_POST["content"]); $comment->set_name($_POST["title"]); } // determine where the user is coming from $referer = $_POST["referer"]; if ($referer == 1) { $backurl = $TCRExtension->getExtensionUrl() . "Index/" . $TCR->get_id(); } else { if ($referer == 2) { $backurl = $TCRExtension->getExtensionUrl() . "documents/" . $TCR->get_id(); } else { if ($referer == 3) { $backurl = $TCRExtension->getExtensionUrl() . "privateDocuments/" . $TCR->get_id(); } } } } // display dialog $content->setCurrentBlock("BLOCK_RELEASE_ELEMENT"); if ($type == "theses") { if (is_array($critics) && count($critics) > 0) { // display already released thesis $release_label = "These anzeigen"; $content->setVariable("SHOW_CRITICS", "none"); $content->setVariable("SHOW_RELEASE", "none"); $private = 0; $released = 1; } else { // release dialog $release_label = "These veröffentlichen"; $released = 0; } $kind = 0; $kindWord = "These"; } else { if ($type == "reviews") { $released = $element->get_attribute("TCR_RELEASED"); if ($released != 0) { // display already released review $release_label = "Kritik anzeigen"; $content->setVariable("SHOW_RELEASE", "none"); $private = 0; } else { // release dialog $release_label = "Kritik veröffentlichen"; } $content->setVariable("SHOW_CRITICS", "none"); $kind = 1; $kindWord = "Kritik"; } else { $released = $element->get_attribute("TCR_RELEASED"); if ($released != 0) { // display already released response $release_label = "Replik anzeigen"; $content->setVariable("SHOW_RELEASE", "none"); $private = 0; } else { // release dialog $release_label = "Replik veröffentlichen"; } $content->setVariable("SHOW_CRITICS", "none"); $kind = 2; $kindWord = "Replik"; } } if ($released == 0 && $referer == 3) { $backurl = $TCRExtension->getExtensionUrl() . "privateDocuments/" . $TCR->get_id() . "/" . $kind; } $content->setVariable("SUBMIT_URL", $TCRExtension->getExtensionUrl() . "privateDocuments/" . $TCR->get_id() . "/" . $kind); $content->setVariable("RELEASE_LABEL", $release_label); $content->setVariable("TITLE_LABEL", "Titel"); $content->setVariable("TITLE_VALUE", $element->get_name()); $content->setVariable("DESC_LABEL", "Untertitel / Beschreibung"); $content->setVariable("DESC_VALUE", $element->get_attribute("OBJ_DESC")); $content->setVariable("AUTHOR_LABEL", "Autor"); $author = $element->get_creator(); $content->setVariable("AUTHOR_VALUE", $author->get_full_name() . " (" . $author->get_name() . ")"); $content->setVariable("CONTENT_LABEL", "Inhalt"); if ($element->get_attribute("DOC_MIME_TYPE") == "text/plain") { // if element is plain text display content directly $content->setVariable("DISPLAY_DOWNLOAD", "none"); $content->setVariable("CONTENT_VALUE", nl2br($element->get_content())); } else { // if element is of another mime type display download dialog $content->setVariable("DISPLAY_TEXT", "none"); $content->setVariable("ASSET_URL", $TCRExtension->getAssetUrl()); $content->setVariable("DOWNLOAD_URL", PATH_URL . "download/Document/" . $this->id); $content->setVariable("DOWNLOAD_TITLE", "Datei herunterladen"); } // display select critic dialog $content->setVariable("CRITICS_LABEL", "Kritiker(in)"); $radioSelect = 0; foreach ($members as $memberID) { $member = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $memberID); $content->setCurrentBlock("BLOCK_CRITIC"); $content->setVariable("CRITIC_ID", $member->get_id()); $content->setVariable("CRITIC_NAME", $member->get_full_name()); if ($radioSelect == 0) { $content->setVariable("CRITIC_CHECKED", "checked"); $radioSelect++; } $content->parse("BLOCK_CRITIC"); } $content->setVariable("RELEASE_WARNING", "Wenn Sie die " . $kindWord . " veröffentlichen, können Sie sie nicht mehr ändern oder löschen."); $content->setVariable("SUBMIT_RELEASE", "Veröffentlichen"); $content->setVariable("BACK_LABEL", "Zurück"); $content->setVariable("BACK_URL", $backurl); $content->setVariable("KIND_VALUE", $kind); $content->setVariable("ID_VALUE", $this->id); $content->parse("BLOCK_RELEASE_ELEMENT"); // display comments if ($released != 0) { $comments = $element->get_annotations(); usort($comments, "sortRepliesByDate"); $content->setCurrentBlock("BLOCK_TCR_COMMENTS"); $content->setVariable("COMMENTS_LABEL", "Kommentare"); if (count($comments) == 0) { $content->setCurrentBlock("BLOCK_NO_COMMENTS"); $content->setVariable("NO_COMMENTS", "Es sind noch keine Kommentare zu diesem Dokument vorhanden."); $content->parse("BLOCK_NO_COMMENTS"); } else { for ($count = 0; $count < count($comments); $count++) { $author = $comments[$count]->get_creator(); $content->setCurrentBlock("BLOCK_COMMENT"); $content->setVariable("COMMENT_CONTENT", nl2br($comments[$count]->get_content())); $content->setVariable("COMMENT_CONTENT_NOBR", $comments[$count]->get_content()); $content->setVariable("COMMENT_TITLE", $comments[$count]->get_name()); $content->setVariable("COMMENT_ID", $comments[$count]->get_id()); $content->setVariable("ASSET", $TCRExtension->getAssetUrl()); $content->setVariable("EDIT_COMMENT", "Kommentar bearbeiten"); // if user is not the author and admin options are not shown dont display edit button if ($author->get_id() != $user->get_id()) { $content->setVariable("SHOW_COMMENT_EDIT", "none"); } $content->setVariable("COMMENT_AUTHOR", "von " . $author->get_name() . " (" . $author->get_full_name() . ")"); $content->setVariable("COMMENT_DATE", "am " . date("d.m.Y H:i", (int) $comments[$count]->get_attribute("OBJ_CREATION_TIME"))); $content->parse("BLOCK_COMMENT"); } } $content->parse("BLOCK_TCR_COMMENTS"); $content->setCurrentBlock("BLOCK_CREATE_COMMENT"); $content->setVariable("CREATE_COMMENT", "Kommentar hinzufügen"); $content->setVariable("BACKURL_LABEL", "Zurück"); $content->setVariable("BACKURL", $backurl); $content->setVariable("TITLE_LABEL_COMMENT", "Titel:"); $content->setVariable("CONTENT_LABEL_COMMENT", "Kommentar:"); $content->setVariable("BACK_LABEL_COMMENT", "Abbrechen"); $content->setVariable("EDIT_COMMENT", "Kommentar bearbeiten"); $content->setVariable("EDIT_COMMENT_SUBMIT", "Änderungen speichern"); $content->setVariable("REFERER_VALUE", $referer); $content->parse("BLOCK_CREATE_COMMENT"); } else { $content->setVariable("DISPLAY_COMMENTS", "none"); } if ($group->get_name() == "learners") { $parent = $group->get_parent_group(); $courseOrGroup = "Kurs: " . $parent->get_attribute("OBJ_DESC") . " (" . $parent->get_name() . ")"; $courseOrGroupUrl = PATH_URL . "semester/" . $parent->get_id(); } else { $courseOrGroup = "Gruppe: " . $group->get_name(); $courseOrGroupUrl = PATH_URL . "groups/" . $group->get_id(); } $rawWidget = new \Widgets\RawHtml(); $rawWidget->setHtml($content->get()); $frameResponseObject->addWidget($rawWidget); if ($private == 1) { $frameResponseObject->setHeadline(array(array("name" => $courseOrGroup, "link" => $courseOrGroupUrl), array("name" => "Thesen-Kritik-Replik-Verfahren", "link" => $TCRExtension->getExtensionUrl() . "Index/" . $TCR->get_id()), array("name" => "Private Dokumente", "link" => $TCRExtension->getExtensionUrl() . "privateDocuments/" . $TCR->get_id()), array("name" => $release_label))); } else { $frameResponseObject->setHeadline(array(array("name" => $courseOrGroup, "link" => $courseOrGroupUrl), array("name" => "Thesen-Kritik-Replik-Verfahren", "link" => $TCRExtension->getExtensionUrl() . "Index/" . $TCR->get_id()), array("name" => $release_label))); } return $frameResponseObject; }
public function frameResponse(\FrameResponseObject $frameResponseObject) { $TCR = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->id); $user = $GLOBALS["STEAM"]->get_current_steam_user(); $TCRExtension = \TCR::getInstance(); $TCRExtension->addCSS(); $content = $TCRExtension->loadTemplate("tcr_index.template.html"); // display actionbar $actionbar = new \Widgets\Actionbar(); $admins = $TCR->get_attribute("TCR_ADMINS"); if (in_array($user->get_id(), $admins)) { $actions = array(array("name" => "Konfiguration", "link" => $TCRExtension->getExtensionUrl() . "configuration/" . $this->id), array("name" => "Private Dokumente", "link" => $TCRExtension->getExtensionUrl() . "privateDocuments/" . $this->id), array("name" => "Übersicht", "link" => $TCRExtension->getExtensionUrl() . "Index/" . $this->id), array("name" => "Alle Dokumente", "link" => $TCRExtension->getExtensionUrl() . "documents/" . $this->id)); } else { $actions = array(array("name" => "Private Dokumente", "link" => $TCRExtension->getExtensionUrl() . "privateDocuments/" . $this->id), array("name" => "Übersicht", "link" => $TCRExtension->getExtensionUrl() . "Index/" . $this->id), array("name" => "Alle Dokumente", "link" => $TCRExtension->getExtensionUrl() . "documents/" . $this->id)); } $actionbar->setActions($actions); $frameResponseObject->addWidget($actionbar); // create array data structure of the theses (identified by writer of the thesis and writer of the review) $theses_container = \steam_factory::get_object_by_name($GLOBALS["STEAM"]->get_id(), $TCR->get_path() . "/theses"); $theses_inventory = $theses_container->get_inventory(); $theses = array(); $rounds = $TCR->get_attribute("TCR_ROUNDS"); $members = $TCR->get_attribute("TCR_USERS"); sort($members); foreach ($members as $member) { $theses[$member] = array(); foreach ($members as $member2) { $theses[$member][$member2] = array(); } } $group = $TCR->get_attribute("TCR_GROUP"); if ($group->get_name() == "learners") { $parent = $group->get_parent_group(); $courseOrGroup = "Kurs: " . $parent->get_attribute("OBJ_DESC") . " (" . $parent->get_name() . ")"; $courseOrGroupUrl = PATH_URL . "semester/" . $parent->get_id(); } else { $courseOrGroup = "Gruppe: " . $group->get_name(); $courseOrGroupUrl = PATH_URL . "groups/" . $group->get_id(); } // display message if there are no members specified if (count($members) == 0) { $content->setCurrentBlock("BLOCK_OVERVIEW_TABLE"); $content->setVariable("TCR_TITLE", $TCR->get_attribute("OBJ_DESC")); $content->setVariable("TCR_NO_USERS", "Keine Teilnehmer festgelegt. Bitte in der Konfiguration die teilnehmenden Personen auswählen."); $content->setVariable("DISPLAY_MANY", "none"); $content->setVariable("DISPLAY_TABLE", "none"); $content->parse("BLOCK_OVERVIEW_TABLE"); $rawWidget = new \Widgets\RawHtml(); $rawWidget->setHtml($content->get()); $frameResponseObject->addWidget($rawWidget); $frameResponseObject->setHeadline(array(array("name" => $courseOrGroup, "link" => $courseOrGroupUrl), array("name" => "Thesen-Kritik-Replik-Verfahren"))); return $frameResponseObject; } // shortform of the table is displayed if amount of members is > 4 $shortform = 0; if (count($members) > 4 && count($members) < 9) { $shortform = 1; } else { if (count($members) >= 9) { $help = round(count($members) / 8); if (count($members) / 8 > $help) { $shortform = $help + 1; } else { $shortform = $help; } } } if ($shortform > 1) { $divide = $shortform; } else { $divide = 1; } $area = 0; if (isset($this->params[1])) { $area = $this->params[1]; } // fill array data structure foreach ($theses_inventory as $thesis) { $creator = $thesis->get_creator(); $released = $thesis->get_attribute("TCR_RELEASED"); $round = $thesis->get_attribute("TCR_ROUND"); if ($released != 0) { $critic_array = $thesis->get_attribute("TCR_REVIEWS"); foreach ($critic_array as $critic => $review) { $theses[$creator->get_id()][$critic][$round] = $thesis->get_id(); } } } // display document table $content->setCurrentBlock("BLOCK_OVERVIEW_TABLE"); $content->setVariable("TCR_TITLE", $TCR->get_attribute("OBJ_DESC")); if ($divide == 1) { $content->setVariable("DISPLAY_MANY", "none"); } else { // if there are > 8 members only display 8 on a page and create navigation for the rest if ($area != 0) { $content->setVariable("PREVIOUS_CRITICS", "Zeige " . (($area - 1) * 8 + 1) . " bis " . (($area - 1) * 8 + 8)); $content->setVariable("PREVIOUS_URL", $TCRExtension->getExtensionUrl() . "Index/" . $this->id . "/" . ($area - 1)); } if (count($members) <= $area * 8 + 8) { $content->setVariable("CURRENT_CRITICS", "Aktuell angezeigt: Kritiker " . ($area * 8 + 1) . " bis " . count($members) . " (von " . count($members) . ")"); } else { $content->setVariable("CURRENT_CRITICS", "Aktuell angezeigt: Kritiker " . ($area * 8 + 1) . " bis " . ($area * 8 + 8) . " (von " . count($members) . ")"); } if (count($members) > $area * 8 + 8) { if (count($members) >= ($area + 1) * 8 + 8) { $content->setVariable("NEXT_CRITICS", "Zeige " . (($area + 1) * 8 + 1) . " bis " . (($area + 1) * 8 + 8)); } else { $content->setVariable("NEXT_CRITICS", "Zeige " . (($area + 1) * 8 + 1) . " bis " . count($members)); } $content->setVariable("NEXT_URL", $TCRExtension->getExtensionUrl() . "Index/" . $this->id . "/" . ($area + 1)); } } $content->setVariable("TABLE_LABEL", "Autoren \\ Kritiker"); $countmembers = 0; // create user columns for ($count = $area * 8; $count < min(count($members), ($area + 1) * 8); $count++) { $content->setCurrentBlock("BLOCK_USER_TH"); $member_object = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $members[$count]); $content->setVariable("USER_NAME", $member_object->get_name()); if (count($members) < 8) { $content->setVariable("USER_WIDTH", 80 / count($members)); } else { $content->setVariable("USER_WIDTH", 10); } $content->parse("BLOCK_USER_TH"); } if (count($members) > 8) { $tablewidth = 20 + (min(count($members), ($area + 1) * 8) - $area * 8) * 10; } else { $tablewidth = 100; } $content->setVariable("TABLE_WIDTH", $tablewidth . "%"); // create content of the table for ($count = 0; $count < count($members); $count++) { $content->setCurrentBlock("BLOCK_TABLE_ROW"); $creator = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $members[$count]); $content->setVariable("USER_NAME2", $creator->get_full_name() . " (" . $creator->get_name() . ")"); for ($count2 = $area * 8; $count2 < min(count($members), ($area + 1) * 8); $count2++) { $content->setCurrentBlock("BLOCK_TABLE_COLUMN"); $current_critic = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $members[$count2]); $content->setVariable("COLUMN_TITLE", "Autor: " . $creator->get_name() . " Kritiker: " . $current_critic->get_name()); for ($count3 = 1; $count3 <= $rounds; $count3++) { if (isset($theses[$members[$count]][$members[$count2]][$count3])) { $current_thesis = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $theses[$members[$count]][$members[$count2]][$count3]); $current_critics = $current_thesis->get_attribute("TCR_REVIEWS"); $content->setCurrentBlock("BLOCK_TABLE_ELEMENT"); if ($shortform == 0) { $content->setVariable("ROUND_ROW", "<td width='25%'>R" . $count3 . ":</td>"); $content->setVariable("OTHER_WIDTH", "25"); $content->setVariable("THESIS_LABEL", "These"); } else { $content->setVariable("THESIS_LABEL", "T" . $count3); $content->setVariable("OTHER_WIDTH", "33"); } $content->setVariable("THESIS_URL", $TCRExtension->getExtensionUrl() . "release/" . $theses[$members[$count]][$members[$count2]][$count3]); $current_review = $current_critics[$members[$count2]]; if ($current_review != 0) { $review = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $current_review); $released = $review->get_attribute("TCR_RELEASED"); if ($released != 0) { if ($shortform == 0) { $content->setVariable("REVIEW_LABEL", "Kritik"); } else { $content->setVariable("REVIEW_LABEL", "K" . $count3); } $content->setVariable("REVIEW_URL", $TCRExtension->getExtensionUrl() . "release/" . $current_review); } $current_response = $review->get_attribute("TCR_RESPONSE"); if ($current_response != 0) { $response = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $current_response); $released = $response->get_attribute("TCR_RELEASED"); if ($released != 0) { if ($shortform == 0) { $content->setVariable("RESPONSE_LABEL", "Replik"); } else { $content->setVariable("RESPONSE_LABEL", "R" . $count3); } $content->setVariable("RESPONSE_URL", $TCRExtension->getExtensionUrl() . "release/" . $current_response); } } } $content->parse("BLOCK_TABLE_ELEMENT"); } else { $content->setCurrentBlock("BLOCK_TABLE_ELEMENT"); $content->setVariable("ROUND_ROW", ""); $content->parse("BLOCK_TABLE_ELEMENT"); } } $content->parse("BLOCK_TABLE_COLUMN"); } $content->parse("BLOCK_TABLE_ROW"); } $content->parse("BLOCK_OVERVIEW_TABLE"); $rawWidget = new \Widgets\RawHtml(); $rawWidget->setHtml($content->get()); $frameResponseObject->addWidget($rawWidget); $frameResponseObject->setHeadline(array(array("name" => $courseOrGroup, "link" => $courseOrGroupUrl), array("name" => "Thesen-Kritik-Replik-Verfahren"))); return $frameResponseObject; }
public function frameResponse(\FrameResponseObject $frameResponseObject) { $element = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->id); $path = $element->get_path(); $path = substr($path, 0, strrpos($path, "/")); $type = substr($path, strrpos($path, "/") + 1, strlen($path)); $TCR = \steam_factory::get_object_by_name($GLOBALS["STEAM"]->get_id(), substr($path, 0, strrpos($path, "/"))); $user = $GLOBALS["STEAM"]->get_current_steam_user(); $TCRExtension = \TCR::getInstance(); $TCRExtension->addCSS(); $TCRExtension->addJS(); $content = $TCRExtension->loadTemplate("tcr_edit.template.html"); // determine the type of element to be edited if ($type == "theses") { $edit_label = "These bearbeiten"; $kind = 0; } else { if ($type == "reviews") { $edit_label = "Kritik bearbeiten"; $kind = 1; } else { $edit_label = "Replik bearbeiten"; $kind = 2; } } // display element edit form $content->setCurrentBlock("BLOCK_EDIT_ELEMENT"); $content->setVariable("EDIT_LABEL", $edit_label); $content->setVariable("TITLE_LABEL", "Titel"); $content->setVariable("TITLE_VALUE", $element->get_name()); $content->setVariable("DESC_LABEL", "Untertitel / Beschreibung"); $content->setVariable("DESC_VALUE", $element->get_attribute("OBJ_DESC")); $content->setVariable("CONTENT_LABEL", "Inhalt"); // if document is plain text display text area to edit it if ($element->get_attribute("DOC_MIME_TYPE") == "text/plain") { $content->setVariable("DISPLAY_IMG", "none"); $content->setVariable("CONTENT_VALUE", $element->get_content()); $content->setVariable("TEXTFIELD_VALUE", "Texteingabe"); $content->setVariable("UPLOAD_VALUE", "Datei hochladen"); $content->setVariable("SHOW_RADIO_FILE", "none"); } else { // if document is of another mime type display upload dialog $content->setVariable("DISPLAY_TEXT", "none"); $content->setVariable("ASSET_URL", $TCRExtension->getAssetUrl()); $content->setVariable("DOWNLOAD_URL", PATH_URL . "download/Document/" . $this->id); $content->setVariable("DOWNLOAD_TITLE", "Datei herunterladen"); $content->setVariable("KEEP_VALUE", "Aktuelle Datei beibehalten"); $content->setVariable("UPLOAD_VALUE", "Neue Datei hochladen"); $content->setVariable("TEXTFIELD_VALUE", "Neues Textdokument erstellen"); $content->setVariable("SHOW_RADIO_TEXT", "none"); } $content->setVariable("TCR_WARNING", "Achtung! Der vorherige Inhalt der These wird beim Abschicken des Formulars überschrieben."); $content->setVariable("BACK_LABEL", "Zurück"); $content->setVariable("BACK_URL", $TCRExtension->getExtensionUrl() . "privateDocuments/" . $TCR->get_id() . "/" . $kind); $content->setVariable("SUBMIT_EDIT", "Änderungen speichern"); $content->setVariable("ID_VALUE", $this->id); $content->setVariable("KIND_VALUE", $kind); $content->setVariable("ROUND_VALUE", $element->get_attribute("TCR_ROUND")); // max file size message $max_file_size = parse_filesize(ini_get('upload_max_filesize')); $max_post_size = parse_filesize(ini_get('post_max_size')); if ($max_post_size > 0 && $max_post_size < $max_file_size) { $max_file_size = $max_post_size; } $content->setVariable("UPLOAD_MAXSIZE", str_replace("%SIZE", readable_filesize($max_file_size), gettext("The maximum allowed file size is %SIZE."))); $content->parse("BLOCK_EDIT_ELEMENT"); $group = $TCR->get_attribute("TCR_GROUP"); if ($group->get_name() == "learners") { $parent = $group->get_parent_group(); $courseOrGroup = "Kurs: " . $parent->get_attribute("OBJ_DESC") . " (" . $parent->get_name() . ")"; $courseOrGroupUrl = PATH_URL . "semester/" . $parent->get_id(); } else { $courseOrGroup = "Gruppe: " . $group->get_name(); $courseOrGroupUrl = PATH_URL . "groups/" . $group->get_id(); } $rawWidget = new \Widgets\RawHtml(); $rawWidget->setHtml($content->get()); $frameResponseObject->addWidget($rawWidget); $frameResponseObject->setHeadline(array(array("name" => $courseOrGroup, "link" => $courseOrGroupUrl), array("name" => "Thesen-Kritik-Replik-Verfahren", "link" => $TCRExtension->getExtensionUrl() . "Index/" . $TCR->get_id()), array("name" => "Private Dokumente", "link" => $TCRExtension->getExtensionUrl() . "privateDocuments/" . $TCR->get_id()), array("name" => $edit_label))); return $frameResponseObject; }