Esempio n. 1
0
 public function execute(\FrameResponseObject $frameResponseObject)
 {
     //CODE FOR ALL COMMANDS OF THIS PAKAGE END
     $user = \lms_steam::get_current_user();
     // Disable caching
     // TODO: Work on cache handling. An enabled cache leads to bugs
     // if used with the wiki.
     \CacheSettings::disable_caching();
     if (!($wiki_container = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->id))) {
         include "bad_link.php";
         exit;
     }
     if (!$wiki_container instanceof \steam_container) {
         $wiki_doc = $wiki_container;
         $wiki_container = $wiki_doc->get_environment();
         if ($wiki_doc->get_attribute(DOC_MIME_TYPE) != "text/wiki") {
             include "bad_link.php";
             exit;
         }
     }
     //CODE FOR ALL COMMANDS OF THIS PAKAGE END
     $compare = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->params[1]);
     $to = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->params[2]);
     $wiki_html_handler = new \lms_wiki($wiki_container);
     //$wiki_html_handler->set_admin_menu( "versions", $wiki_doc );
     $content = \Wiki::getInstance()->loadTemplate("wiki_version_compare.template.html");
     //$content = new HTML_TEMPLATE_IT();
     //$content->loadTemplateFile( PATH_TEMPLATES . "wiki_version_compare.template.html" );
     $difftext = wiki_diff_html($to, $compare);
     $content->setVariable("DIFF_TEXT", $difftext);
     $wiki_html_handler->set_main_html($content->get());
     $rootlink = \lms_steam::get_link_to_root($wiki_container);
     WIKI_FULL_HEADLINE ? $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication")), array("name" => h($wiki_container->get_name()), "link" => PATH_URL . "wiki/index/" . $wiki_container->get_id() . "/"), array("link" => PATH_URL . "wiki/viewentry/" . $wiki_doc->get_id() . "/", "name" => str_replace(".wiki", "", h($wiki_doc->get_name()))), array("link" => PATH_URL . "wiki/versionoverview/" . $wiki_doc->get_id(), "name" => gettext("Version management")), array("link" => "", "name" => gettext("Version compare") . " (" . $compare->get_version() . " " . gettext("to") . " " . $to->get_version() . ")")) : ($headline = array(array("name" => h($wiki_container->get_name()), "link" => PATH_URL . "wiki/index/" . $wiki_container->get_id() . "/"), array("link" => PATH_URL . "wiki/viewentry/" . $wiki_doc->get_id() . "/", "name" => str_replace(".wiki", "", h($wiki_doc->get_name()))), array("link" => PATH_URL . "wiki/versionoverview/" . $wiki_doc->get_id() . "/versions/", "name" => gettext("Version management")), array("link" => "", "name" => gettext("Version compare") . " (" . $compare->get_version() . " " . gettext("to") . " " . $to->get_version() . ")")));
     /*$portal->set_page_main(
     		$headline,
     		$wiki_html_handler->get_html()
     		);
     		$portal->show_html();
     		*/
     $frameResponseObject->setHeadline($headline);
     $widget = new \Widgets\RawHtml();
     $widget->setHtml($wiki_html_handler->get_html());
     $frameResponseObject->addWidget($widget);
     return $frameResponseObject;
 }
Esempio n. 2
0
<?php

$wiki_html_handler = new lms_wiki($wiki_container);
$wiki_html_handler->set_admin_menu("mediathek", $wiki_container);
$content = new HTML_TEMPLATE_IT();
$content->loadTemplateFile(PATH_TEMPLATES . "wiki_mediathek.template.html");
// get images
$inventory = $wiki_container->get_inventory();
if (!is_array($inventory)) {
    $inventory = array();
}
if (sizeof($inventory) > 0) {
    steam_factory::load_attributes($GLOBALS["STEAM"]->get_id(), $inventory, array(OBJ_NAME, OBJ_DESC, DOC_MIME_TYPE));
    $images = array();
    foreach ($inventory as $object) {
        $mime = strtolower($object->get_attribute(DOC_MIME_TYPE));
        if ($mime === "image/jpg" || $mime === "image/jpeg" || $mime === "image/gif" || $mime === "image/png") {
            $images[] = $object;
        }
    }
    foreach ($images as $image) {
        $actions = '<a href="' . PATH_URL . 'doc/' . $image->get_id() . '/">' . gettext("show properties") . '</a><br>';
        $actions .= '<a href="' . PATH_URL . 'doc/' . $image->get_id() . '/edit/">' . gettext("edit properties") . '</a><br>';
        $actions .= '<a href="' . PATH_URL . 'doc/' . $image->get_id() . '/deleteImage/" onclick="return confirmDeletion();">' . gettext("delete image") . '</a>';
        $imageData = imagecreatefromstring($image->get_content());
        $width = $newWidth = imagesx($imageData);
        $height = $newHeight = imagesy($imageData);
        if ($width > 160) {
            $newHeight = (int) ($height * 160 / $width);
            $newWidth = 160;
        }
Esempio n. 3
0
 public function frameResponse(\FrameResponseObject $frameResponseObject)
 {
     $path = $this->params;
     $user = \lms_steam::get_current_user();
     $public = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), STEAM_PUBLIC_GROUP, CLASS_GROUP);
     $id = $path[0];
     try {
         $steam_group = !empty($id) ? \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $id) : FALSE;
     } catch (\Exception $ex) {
         include "bad_link.php";
         exit;
     }
     $group_is_private = FALSE;
     if ($steam_group && is_object($steam_group)) {
         switch ((string) $steam_group->get_attribute("OBJ_TYPE")) {
             case "course":
                 $group = new \koala_group_course($steam_group);
                 // TODO: Passt der backlink?
                 $backlink = PATH_URL . SEMESTER_URL . "/" . $group->get_semester()->get_name() . "/" . h($group->get_name()) . "/";
                 break;
             default:
                 $group = new \koala_group_default($steam_group);
                 // TODO: Passt der backlink?
                 $backlink = PATH_URL . "groups/" . $group->get_id() . "/";
                 // Determine if group is public or private
                 $parent = $group->get_parent_group();
                 if ($parent->get_id() == STEAM_PRIVATE_GROUP) {
                     $group_is_private = TRUE;
                 }
                 break;
         }
     }
     if ($group_is_private) {
         if (!$steam_group->is_member($user) && !\lms_steam::is_koala_admin($user)) {
             throw new \Exception(gettext("You have no rights to access this group"), E_USER_RIGHTS);
         }
     }
     if (!$group instanceof \koala_group) {
         throw new \Exception("Is not a koala_group: " . $group_id, E_PARAMETER);
     }
     switch (get_class($group)) {
         case "koala_group_course":
             $html_handler_group = new \koala_html_course($group);
             $html_handler_group->set_context("communication");
             break;
         default:
             $html_handler_group = new \koala_html_group($group);
             $html_handler_group->set_context("communication");
             break;
     }
     $content = \Group::getInstance()->loadTemplate("groups_communication.template.html");
     $workroom = $group->get_workroom();
     $read_access = $workroom->check_access_read($user);
     if (!$read_access) {
         throw new \Exception("No read access on container: id=" . $workroom->get_id(), E_USER_RIGHTS);
     }
     $cache = get_cache_function(\lms_steam::get_current_user()->get_name(), 600);
     $communication_objects = $cache->call("lms_steam::get_group_communication_objects", $workroom->get_id(), CLASS_MESSAGEBOARD | CLASS_CALENDAR | CLASS_CONTAINER | CLASS_ROOM);
     $forums = array();
     $weblogs = array();
     $wikis = array();
     foreach ($communication_objects as $object) {
         if ($object["OBJ_CLASS"] === "steam_messageboard") {
             $forums[] = $object;
         } else {
             if ($object["OBJ_CLASS"] === "steam_calendar") {
                 $weblogs[] = $object;
             } else {
                 if (($object["OBJ_CLASS"] === "steam_container" || $object["OBJ_CLASS"] === "steam_room") && ($object["OBJ_TYPE"] != null && ($object["OBJ_TYPE"] == "KOALA_WIKI" || $object["OBJ_TYPE"] == "container_wiki_koala"))) {
                     $wikis[] = $object;
                 }
             }
         }
     }
     $content->setVariable("LABEL_FORUMS", gettext("Discussion Boards"));
     if (count($forums) > 0) {
         $content->setCurrentBlock("BLOCK_FORUMS");
         $content->setVariable("LABEL_FORUM_DESCRIPTION", gettext("Forum / description"));
         $content->setVariable("LABEL_ARTICLES", gettext("Articles"));
         $content->setVariable("LABEL_ACCESS", gettext("Access"));
         $content->setVariable("LABEL_LAST_COMMENT", gettext("Last comment"));
         $access_descriptions = \lms_forum::get_access_descriptions($group);
         foreach ($forums as $forum) {
             $cache = get_cache_function($forum["OBJ_ID"], 600);
             $discussions = $cache->call("lms_forum::get_discussions", $forum["OBJ_ID"]);
             $latest_post = isset($discussions[0]) ? $discussions[0] : FALSE;
             $content->setCurrentBlock("BLOCK_FORUM");
             $content->setVariable("NAME_FORUM", h($forum["OBJ_NAME"]));
             $content->setVariable("LINK_FORUM", PATH_URL . "messageboard/index/" . $forum["OBJ_ID"]);
             $content->setVariable("OBJ_DESC", get_formatted_output($forum["OBJ_DESC"]));
             $language = !empty($forum["FORUM_LANGUAGE"]) ? $forum["FORUM_LANGUAGE"] : "German";
             $content->setVariable("VALUE_LANGUAGE", $language);
             $access = "<span title=\"" . $access_descriptions[$forum["KOALA_ACCESS"]]["label"] . "\">" . $access_descriptions[$forum["KOALA_ACCESS"]]["summary_short"] . "</span>";
             $content->setVariable("VALUE_ACCESS", $access);
             $content->setVariable("VALUE_ARTICLES", count($discussions));
             if ($latest_post) {
                 $content->setVariable("SUBJECT_LAST_COMMENT", h($latest_post["LATEST_POST_TITLE"]));
                 $content->setVariable("LINK_LAST_COMMENT", PATH_URL . "forums/" . $latest_post["OBJ_ID"] . "/");
                 $content->setVariable("POSTED_BY_LABEL", "(" . h($latest_post["LATEST_POST_AUTHOR"]) . ", " . how_long_ago($latest_post["LATEST_POST_TS"]) . ")");
             } else {
                 $content->setVariable("POSTED_BY_LABEL", gettext("-"));
             }
             $content->parse("BLOCK_FORUM");
         }
         $content->parse("BLOCK_FORUMS");
     } else {
         $content->setVariable("LABEL_NO_FORUMS_FOUND", "<b>" . gettext("No forums available. Either no forums are created in this context, or you have no rights to read them.") . "</b>");
     }
     $content->setVariable("LABEL_WEBLOGS", gettext("Weblogs"));
     if (count($weblogs) > 0) {
         $content->setCurrentBlock("BLOCK_WEBLOGS");
         $content->setVariable("LABEL_WEBLOG_DESCRIPTION", gettext("Weblog / description"));
         $content->setVariable("LABEL_WEBLOG_ENTRIES", gettext("Entries"));
         $content->setVariable("LABEL_WEBLOG_ACCESS", gettext("Access"));
         $content->setVariable("LABEL_WEBLOG_LAST_ENTRY", gettext("Last entry"));
         $access_descriptions = \lms_weblog::get_access_descriptions($group);
         foreach ($weblogs as $weblog) {
             $cache = get_cache_function($weblog["OBJ_ID"], 600);
             $entries = $cache->call("lms_weblog::get_items", $weblog["OBJ_ID"]);
             $last_entry = isset($entries[0]) ? $entries[0] : FALSE;
             $content->setCurrentBlock("BLOCK_WEBLOG");
             $content->setVariable("NAME_WEBLOG", h($weblog["OBJ_NAME"]));
             $content->setVariable("LINK_WEBLOG", PATH_URL . "weblog/" . $weblog["OBJ_ID"] . "/");
             $content->setVariable("WEBLOG_OBJ_DESC", get_formatted_output($weblog["OBJ_DESC"]));
             $title = $access_descriptions[$weblog["KOALA_ACCESS"]]["label"];
             if ($weblog["KOALA_ACCESS"] == PERMISSION_PRIVATE_READONLY && !$group instanceof \koala_html_course) {
                 $obj = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $weblog["OBJ_ID"], CLASS_CALENDAR);
                 $creator = $obj->get_creator();
                 if ($creator->get_id() != \lms_steam::get_current_user()->get_id()) {
                     $title = str_replace("%NAME", $creator->get_name(), $title);
                 } else {
                     $title = str_replace("%NAME", "you", $title);
                 }
             }
             $content->setVariable("VALUE_WEBLOG_LANGUAGE", "German");
             $access = "<span title=\"" . $title . "\">" . $access_descriptions[$weblog["KOALA_ACCESS"]]["summary_short"] . "</span>";
             $content->setVariable("VALUE_WEBLOG_ACCESS", $access);
             $content->setVariable("VALUE_WEBLOG_ARTICLES", count($entries));
             $content->setVariable("LINK_WEBLOG_LAST_ENTRY", PATH_URL . "weblog/" . $last_entry["OBJ_ID"] . "/");
             if ($last_entry) {
                 $content->setVariable("SUBJECT_WEBLOG_LAST_ENTRY", h($last_entry["DATE_TITLE"]));
                 $content->setVariable("WEBLOG_POSTED_BY_LABEL", "(" . h($last_entry["AUTHOR"]) . ", " . how_long_ago($last_entry["DATE_START_DATE"]) . ")");
             } else {
                 $content->setVariable("WEBLOG_POSTED_BY_LABEL", gettext("-"));
             }
             $content->parse("BLOCK_WEBLOG");
         }
         $content->parse("BLOCK_WEBLOGS");
     } else {
         $content->setVariable("LABEL_NO_WEBLOGS_FOUND", "<b>" . gettext("No weblogs available. Either no weblogs are created in this context, or you have no rights to read them.") . "</b>");
     }
     $content->setVariable("LABEL_WIKIS", gettext("Wikis"));
     if (count($wikis) > 0) {
         $content->setCurrentBlock("BLOCK_WIKIS");
         $content->setVariable("LABEL_WIKI_DESCRIPTION", gettext("Wiki / description"));
         $content->setVariable("LABEL_WIKI_ENTRIES", gettext("Entries"));
         $content->setVariable("LABEL_WIKI_ACCESS", gettext("Access"));
         $content->setVariable("LABEL_WIKI_LAST_ENTRY", gettext("Last entry"));
         $access_descriptions = \lms_wiki::get_access_descriptions($group);
         foreach ($wikis as $wiki) {
             $cache = get_cache_function($wiki["OBJ_ID"], 600);
             $entries = $cache->call("lms_wiki::get_items", $wiki["OBJ_ID"]);
             $last_entry = isset($entries[0]) ? $entries[0] : FALSE;
             $content->setCurrentBlock("BLOCK_WIKI");
             $content->setVariable("NAME_WIKI", h($wiki["OBJ_NAME"]));
             $content->setVariable("LINK_WIKI", PATH_URL . "wiki/index/" . $wiki["OBJ_ID"] . "/");
             $content->setVariable("WIKI_OBJ_DESC", get_formatted_output($wiki["OBJ_DESC"]));
             $title = $access_descriptions[$wiki["KOALA_ACCESS"]]["label"];
             if ($wiki["KOALA_ACCESS"] == PERMISSION_PRIVATE_READONLY && !$group instanceof \koala_html_course) {
                 $obj = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $wiki["OBJ_ID"], CLASS_CONTAINER);
                 $creator = $obj->get_creator();
                 if ($creator->get_id() != \lms_steam::get_current_user()->get_id()) {
                     $title = str_replace("%NAME", $creator->get_name(), $title);
                 } else {
                     $title = str_replace("%NAME", "you", $title);
                 }
             }
             $access = "<span title=\"" . $title . "\">" . $access_descriptions[$wiki["KOALA_ACCESS"]]["summary_short"] . "</span>";
             $content->setVariable("VALUE_WIKI_ACCESS", $access);
             $content->setVariable("VALUE_WIKI_ARTICLES", count($entries));
             $content->setVariable("LINK_WIKI_LAST_ENTRY", PATH_URL . "wiki/" . $last_entry["OBJ_ID"] . "/");
             $content->setVariable("SUBJECT_WIKI_LAST_ENTRY", str_replace(".wiki", "", h($last_entry["OBJ_NAME"])));
             $content->setVariable("WIKI_POSTED_BY_LABEL", $last_entry["DOC_LAST_MODIFIED"] != null ? "(" . h($last_entry["DOC_USER_MODIFIED"]) . ", " . how_long_ago($last_entry["DOC_LAST_MODIFIED"]) . ")" : "-");
             $content->parse("BLOCK_WIKI");
         }
         $content->parse("BLOCK_WIKIS");
     } else {
         $content->setVariable("LABEL_NO_WIKIS_FOUND", "<b>" . gettext("No wikis available. Either no wikis are created in this context, or you have no rights to read them.") . "</b>");
     }
     $html_handler_group->set_html_left($content->get());
     $frameResponseObject->setTitle("Group");
     $rawHtml = new \Widgets\RawHtml();
     $rawHtml->setHtml($html_handler_group->get_html());
     $frameResponseObject->addWidget($rawHtml);
     return $frameResponseObject;
 }
Esempio n. 4
0
 public function execute(\FrameResponseObject $frameResponseObject)
 {
     //CODE FOR ALL COMMANDS OF THIS PACKAGE START
     $user = \lms_steam::get_current_user();
     // Disable caching
     // TODO: Work on cache handling. An enabled cache leads to bugs
     // if used with the wiki.
     \CacheSettings::disable_caching();
     if (!($wiki_container = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->id))) {
         include "bad_link.php";
         exit;
     }
     if (!$wiki_container instanceof \steam_container) {
         $wiki_doc = $wiki_container;
         $wiki_container = $wiki_doc->get_environment();
         if ($wiki_doc->get_attribute(DOC_MIME_TYPE) != "text/wiki") {
             include "bad_link.php";
             exit;
         }
     }
     //CODE FOR ALL COMMANDS OF THIS PACKAGE END
     $env = $wiki_container->get_environment();
     $grp = $env->get_creator();
     if ($grp->get_name() == "learners" && $grp->get_attribute(OBJ_TYPE) == "course_learners") {
         $grp = $grp->get_parent_group();
     }
     if (!isset($wiki_container) || !is_object($wiki_container)) {
         if (!($env = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $_GET["env"]))) {
             throw new Exception("Environment unknown.");
         }
         if (!($grp = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $_GET["group"]))) {
             throw new Exception("Group unknown");
         }
     }
     $accessmergel = FALSE;
     if (isset($wiki_container) && is_object($wiki_container)) {
         $creator = $wiki_container->get_creator();
         if ($wiki_container->get_attribute(KOALA_ACCESS) == PERMISSION_UNDEFINED && \lms_steam::get_current_user()->get_id() != $creator->get_id() && !\lms_steam::is_koala_admin(\lms_steam::get_current_user())) {
             $accessmergel = TRUE;
         }
     }
     $backlink = empty($_POST["values"]["backlink"]) ? $_SERVER["HTTP_REFERER"] : $_POST["values"]["backlink"];
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         $values = $_POST["values"];
         if (get_magic_quotes_gpc()) {
             if (!empty($values['name'])) {
                 $values['name'] = stripslashes($values['name']);
             }
             if (!empty($values['dsc'])) {
                 $values['dsc'] = stripslashes($values['dsc']);
             }
         }
         if (empty($values["name"])) {
             $problems = gettext("The name of new wiki is missing.");
             $hints = gettext("Please type in a name.");
         }
         if (strpos($values["name"], "/")) {
             if (!isset($problems)) {
                 $problems = "";
             }
             $problems .= gettext("Please don't use the \"/\"-char in the name of the wiki.");
         }
         if (empty($problems)) {
             $group_members = $grp;
             $group_admins = 0;
             $group_staff = 0;
             // check if group is a course
             $grouptype = (string) $grp->get_attribute("OBJ_TYPE");
             if ($grouptype == "course") {
                 $group_staff = \steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), $grp->get_groupname() . ".staff");
                 $group_admins = \steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), $grp->get_groupname() . ".admins");
                 $group_members = \steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), $grp->get_groupname() . ".learners");
                 $workroom = $group_members->get_workroom();
             } else {
                 $workroom = $grp->get_workroom();
             }
             if (!isset($wiki_container) || !is_object($wiki_container)) {
                 $new_wiki = \steam_factory::create_room($GLOBALS["STEAM"]->get_id(), $values["name"], $env, $values["dsc"]);
                 $new_wiki->set_attribute("OBJ_TYPE", "container_wiki_koala");
                 $_SESSION["confirmation"] = str_replace("%NAME", $values["name"], gettext("New wiki '%NAME' created."));
             } else {
                 $wiki_container->set_attribute(OBJ_NAME, $values["name"]);
                 if ($values["wiki_startpage"] == gettext("Glossary")) {
                     $values["wiki_startpage"] = "glossary";
                 }
                 $wiki_container->set_attribute("OBJ_WIKI_STARTPAGE", $values["wiki_startpage"]);
                 $wiki_container->set_attribute(OBJ_DESC, $values["dsc"]);
                 //$portal->set_confirmation(gettext( "The changes have been saved." ));
                 $new_wiki = $wiki_container;
             }
             $koala_wiki = new \lms_wiki($new_wiki);
             $access = (int) $values["access"];
             $access_descriptions = \lms_wiki::get_access_descriptions($grp);
             if (!$accessmergel) {
                 $koala_wiki->set_access($access, $access_descriptions[$access]["members"], $access_descriptions[$access]["steam"], $group_members, $group_staff, $group_admins);
             }
             $GLOBALS["STEAM"]->buffer_flush();
             $cache = get_cache_function(\lms_steam::get_current_user()->get_name());
             $cache->drop("lms_steam::get_inventory_recursive", $workroom->get_id(), CLASS_CONTAINER, array("OBJ_TYPE", "WIKI_LANGUAGE"));
             $cache->drop("lms_steam::get_group_communication_objects", $workroom->get_id(), CLASS_MESSAGEBOARD | CLASS_CALENDAR | CLASS_CONTAINER | CLASS_ROOM);
             if (!isset($wiki_container) || !is_object($wiki_container)) {
                 header("Location: " . $backlink);
                 exit;
             }
         } else {
             $frameResponseObject->setProblemDescription($problems);
             $frameResponseObject->setProblemSolution(isset($hints) ? $hints : "");
         }
     }
     $content = \Wiki::getInstance()->loadTemplate("object_new.template.html");
     //$content = new HTML_TEMPLATE_IT( PATH_TEMPLATES );
     //$content->loadTemplateFile( "object_new.template.html" );
     if (isset($wiki_container) && is_object($wiki_container)) {
         $content->setVariable("INFO_TEXT", str_replace("%NAME", h($wiki_container->get_name()), gettext("You are going to edit the wiki '<b>%NAME</b>'.")));
         $content->setVariable("LABEL_CREATE", gettext("Save changes"));
         $pagetitle = gettext("Preferences");
         if (empty($values)) {
             $values = array();
             $values["name"] = $wiki_container->get_name();
             $values["dsc"] = $wiki_container->get_attribute(OBJ_DESC);
             $values["wiki_startpage"] = $wiki_container->get_attribute("OBJ_WIKI_STARTPAGE");
             $values["access"] = $wiki_container->get_attribute(KOALA_ACCESS);
         }
         $breadcrumbheader = gettext("Preferences");
         $content->setVariable("OPTION_WIKI_GLOSSARY", gettext("Glossary"));
         $wiki_entries = $wiki_container->get_inventory(CLASS_DOCUMENT);
         $wiki_entries_sorted = array();
         foreach ($wiki_entries as $wiki_entry) {
             if ($wiki_entry->get_attribute(DOC_MIME_TYPE) === "text/wiki") {
                 $wiki_entries_sorted[] = str_replace(".wiki", "", $wiki_entry->get_name());
             }
         }
         sort($wiki_entries_sorted);
         $startpageFound = false;
         foreach ($wiki_entries_sorted as $wiki_entry) {
             $content->setCurrentBlock("BLOCK_WIKI_STARTPAGE_OPTION");
             $content->setVariable("OPTION_WIKI_STARTPAGE", $wiki_entry);
             if ($values["wiki_startpage"] == $wiki_entry) {
                 $content->setVariable("WIKI_STARTPAGE_SELECTED", "selected");
                 $startpageFound = true;
             }
             $content->parse("BLOCK_WIKI_STARTPAGE_OPTION");
         }
         if (!$startpageFound) {
             $content->setVariable("OPTION_WIKI_GLOSSARY_SELECTED", "selected");
         }
     } else {
         $grpname = $grp->get_attribute(OBJ_NAME);
         if ($grp->get_attribute(OBJ_TYPE) == "course") {
             $grpname = $grp->get_attribute(OBJ_DESC);
         }
         $content->setVariable("OPTION_WIKI_GLOSSARY", gettext("Glossary"));
         $content->setVariable("OPTION_WIKI_GLOSSARY_SELECTED", "selected");
         $content->setVariable("INFO_TEXT", str_replace("%ENV", h($grpname), gettext("You are going to create a new wiki in '<b>%ENV</b>'.")));
         $content->setVariable("LABEL_CREATE", gettext("Create wiki"));
         $pagetitle = gettext("Create wiki");
         $breadcrumbheader = gettext("Add new wiki");
     }
     if (!empty($values)) {
         if (!empty($values["name"])) {
             $content->setVariable("VALUE_NAME", h($values["name"]));
         }
         if (!empty($values["dsc"])) {
             $content->setVariable("VALUE_DSC", h($values["dsc"]));
         }
         if (!empty($values["wiki_startpage"])) {
             $content->setVariable("VALUE_WIKI_STARTPAGE", h($values["wiki_startpage"]));
         }
     }
     $content->setVariable("VALUE_BACKLINK", $backlink);
     $content->setVariable("LABEL_NAME", gettext("Name"));
     $content->setVariable("LABEL_DSC", gettext("Description"));
     $content->setVariable("LABEL_WIKI_STARTPAGE", gettext("Startpage"));
     $content->setVariable("LABEL_ACCESS", gettext("Access"));
     $content->setVariable("LABEL_BB_BOLD", gettext("B"));
     $content->setVariable("HINT_BB_BOLD", gettext("boldface"));
     $content->setVariable("LABEL_BB_ITALIC", gettext("I"));
     $content->setVariable("HINT_BB_ITALIC", gettext("italic"));
     $content->setVariable("LABEL_BB_UNDERLINE", gettext("U"));
     $content->setVariable("HINT_BB_UNDERLINE", gettext("underline"));
     $content->setVariable("LABEL_BB_STRIKETHROUGH", gettext("S"));
     $content->setVariable("HINT_BB_STRIKETHROUGH", gettext("strikethrough"));
     $content->setVariable("LABEL_BB_IMAGE", gettext("IMG"));
     $content->setVariable("HINT_BB_IMAGE", gettext("image"));
     $content->setVariable("LABEL_BB_URL", gettext("URL"));
     $content->setVariable("HINT_BB_URL", gettext("web link"));
     $content->setVariable("LABEL_BB_MAIL", gettext("MAIL"));
     $content->setVariable("HINT_BB_MAIL", gettext("email link"));
     if ($accessmergel) {
         $mailto = "mailto:'.SUPPORT_EMAIL.'?subject=KoaLA:%20Invalid%20Access%20Rights&body=" . rawurlencode("\nLink: " . get_current_URL() . "\nCreator: " . $creator->get_identifier() . "\n");
         $content->setCurrentBlock("BLOCK_ACCESSMERGEL");
         $content->setVariable("LABEL_ACCESSMERGEL", str_replace("%MAILTO", $mailto, gettext("There is a problem with the access settings. Please <a href=\"%MAILTO\">contact the support team</a> to fix it by setting the access rights again.")));
         $content->parse("BLOCK_ACCESSMERGEL");
     } else {
         $access = \lms_wiki::get_access_descriptions($grp);
         if ((string) $grp->get_attribute("OBJ_TYPE") == "course") {
             $access_default = PERMISSION_PUBLIC;
         } else {
             $access_default = PERMISSION_PUBLIC_READONLY;
             if (isset($wiki_container) && is_object($wiki_container) && $creator->get_id() != \lms_steam::get_current_user()->get_id()) {
                 $access[PERMISSION_PRIVATE_READONLY] = str_replace("%NAME", $creator->get_name(), $access[PERMISSION_PRIVATE_READONLY]);
             } else {
                 $access[PERMISSION_PRIVATE_READONLY] = str_replace("%NAME", "you", $access[PERMISSION_PRIVATE_READONLY]);
             }
         }
         if (is_array($access)) {
             $content->setCurrentBlock("BLOCK_ACCESS");
             foreach ($access as $key => $array) {
                 if ($key != PERMISSION_UNDEFINED || isset($values) && (int) $values["access"] == PERMISSION_UNDEFINED) {
                     $content->setCurrentBlock("ACCESS");
                     $content->setVariable("LABEL", $array["summary_short"] . ": " . $array["label"]);
                     $content->setVariable("VALUE", $key);
                     if (isset($values) && $key == (int) $values["access"] || empty($values) && $key == $access_default) {
                         $content->setVariable("CHECK", "checked=\"checked\"");
                     }
                     $content->parse("ACCESS");
                 }
             }
             $content->parse("BLOCK_ACCESS");
         }
     }
     $content->setVariable("BACKLINK", "<a href=\"{$backlink}\">" . gettext("back") . "</a>");
     $rootlink = \lms_steam::get_link_to_root($grp);
     WIKI_FULL_HEADLINE ? $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication"))) : "";
     if (isset($wiki_container) && is_object($wiki_container)) {
         $headline[] = array("link" => PATH_URL . "wiki/index/" . $wiki_container->get_id() . "/", "name" => h($wiki_container->get_name()));
     }
     $headline[] = array("link" => "", "name" => $breadcrumbheader);
     $frameResponseObject->setTitle($pagetitle);
     $frameResponseObject->setHeadline($headline);
     $widget = new \Widgets\RawHtml();
     $widget->setHtml($content->get());
     $frameResponseObject->addWidget($widget);
     return $frameResponseObject;
     /*$portal->set_page_main( $headline, $content->get() );
     	 $portal->set_page_title( $pagetitle );
     	 $portal->show_html();*/
 }
Esempio n. 5
0
 public function execute(\FrameResponseObject $frameResponseObject)
 {
     //CODE FOR ALL COMMANDS OF THIS PAKAGE END
     $user = \lms_steam::get_current_user();
     // Disable caching
     // TODO: Work on cache handling. An enabled cache leads to bugs
     // if used with the wiki.
     \CacheSettings::disable_caching();
     if (!($wiki_container = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->id))) {
         include "bad_link.php";
         exit;
     }
     if (!$wiki_container instanceof \steam_container) {
         $wiki_doc = $wiki_container;
         $wiki_container = $wiki_doc->get_environment();
         if ($wiki_doc->get_attribute(DOC_MIME_TYPE) != "text/wiki") {
             include "bad_link.php";
             exit;
         }
     }
     //CODE FOR ALL COMMANDS OF THIS PAKAGE END
     $wiki_html_handler = new \lms_wiki($wiki_container);
     $wiki_html_handler->set_admin_menu("mediathek", $wiki_container);
     $content = \Wiki::getInstance()->loadTemplate("wiki_mediathek.template.html");
     //$content = new HTML_TEMPLATE_IT();
     //$content->loadTemplateFile( PATH_TEMPLATES . "wiki_mediathek.template.html" );
     // get images
     $inventory = $wiki_container->get_inventory();
     if (!is_array($inventory)) {
         $inventory = array();
     }
     if (sizeof($inventory) > 0) {
         \steam_factory::load_attributes($GLOBALS["STEAM"]->get_id(), $inventory, array(OBJ_NAME, OBJ_DESC, DOC_MIME_TYPE));
         $images = array();
         foreach ($inventory as $object) {
             $mime = strtolower($object->get_attribute(DOC_MIME_TYPE));
             if ($mime === "image/jpg" || $mime === "image/jpeg" || $mime === "image/gif" || $mime === "image/png") {
                 $images[] = $object;
             }
         }
         foreach ($images as $image) {
             $actions = '<a href="' . PATH_URL . 'doc/' . $image->get_id() . '/">' . gettext("show properties") . '</a><br>';
             $actions .= '<a href="' . PATH_URL . 'doc/' . $image->get_id() . '/edit/">' . gettext("edit properties") . '</a><br>';
             $actions .= '<a href="' . PATH_URL . 'doc/' . $image->get_id() . '/deleteImage/" onclick="return confirmDeletion();">' . gettext("delete image") . '</a>';
             $imageData = imagecreatefromstring($image->get_content());
             $width = $newWidth = imagesx($imageData);
             $height = $newHeight = imagesy($imageData);
             if ($width > 160) {
                 $newHeight = (int) ($height * 160 / $width);
                 $newWidth = 160;
             }
             if ($newHeight > 80) {
                 $newWidth = (int) ($newWidth * 80 / $newHeight);
                 $newHeight = 80;
             }
             $content->setCurrentBlock("BLOCK_IMAGE");
             $content->setVariable("IMAGE_NAME", $image->get_name());
             $content->setVariable("IMAGE_ID", $image->get_id());
             $content->setVariable("IMAGE_DESCRIPTION", $image->get_attribute('OBJ_DESC'));
             $content->setVariable("IMAGE_LINK", PATH_URL . "download/image/" . $image->get_id() . "/" . $newWidth . "/" . $newHeight . "/");
             $content->setVariable("PREVIEW_LINK", "javascript:showBox(" . $image->get_id() . "," . $width . "," . $height . ");");
             $content->setVariable("IMAGE_ACTIONS", $actions);
             $content->parse("BLOCK_IMAGE");
         }
     }
     $question = gettext("Do you really want to delete this image?");
     $note = gettext("NOTE: All wiki-entries containing this image have to be updated manually!");
     $content->setVariable("QUESTION", $question);
     $content->setVariable("NOTE", $note);
     $content->setVariable("LABEL_CLOSE", gettext("close"));
     $content->setVariable("BACK_LINK", PATH_URL . "wiki/index/" . $wiki_container->get_id() . "/");
     $content->setVariable("BACK_LABEL", gettext("back"));
     $wiki_html_handler->set_main_html($content->get());
     // breadcrumbs
     $rootlink = \lms_steam::get_link_to_root($wiki_container);
     WIKI_FULL_HEADLINE ? $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication")), array("name" => h($wiki_container->get_name()), "link" => PATH_URL . "wiki/index/" . $wiki_container->get_id() . "/"), array("link" => "", "name" => gettext("Mediathek"))) : ($headline = array(array("name" => h($wiki_container->get_name()), "link" => PATH_URL . "wiki/index/" . $wiki_container->get_id() . "/"), array("link" => "", "name" => gettext("Mediathek"))));
     /*$portal->set_page_main(
     		$headline,
     		$wiki_html_handler->get_html()
     		);
     		$portal->show_html();
     		*/
     $frameResponseObject->setHeadline($headline);
     $widget = new \Widgets\RawHtml();
     $widget->setHtml($wiki_html_handler->get_html());
     $frameResponseObject->addWidget($widget);
     return $frameResponseObject;
 }
Esempio n. 6
0
         $group_members = steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), $grp->get_groupname() . ".learners");
         $workroom = $group_members->get_workroom();
     } else {
         $workroom = $grp->get_workroom();
     }
     if (!isset($wiki_container) || !is_object($wiki_container)) {
         $new_wiki = steam_factory::create_room($GLOBALS["STEAM"]->get_id(), $values["name"], $env, $values["dsc"]);
         $new_wiki->set_attribute("OBJ_TYPE", "container_wiki_koala");
         $_SESSION["confirmation"] = str_replace("%NAME", $values["name"], gettext("New wiki '%NAME' created."));
     } else {
         $wiki_container->set_attribute(OBJ_NAME, $values["name"]);
         $wiki_container->set_attribute(OBJ_DESC, $values["dsc"]);
         $portal->set_confirmation(gettext("The changes have been saved."));
         $new_wiki = $wiki_container;
     }
     $koala_wiki = new lms_wiki($new_wiki);
     $access = (int) $values["access"];
     $access_descriptions = lms_wiki::get_access_descriptions($grp);
     if (!$accessmergel) {
         $koala_wiki->set_access($access, $access_descriptions[$access]["members"], $access_descriptions[$access]["steam"], $group_members, $group_staff, $group_admins);
     }
     $GLOBALS["STEAM"]->buffer_flush();
     $cache = get_cache_function(lms_steam::get_current_user()->get_name());
     $cache->drop("lms_steam::get_inventory_recursive", $workroom->get_id(), CLASS_CONTAINER, array("OBJ_TYPE", "WIKI_LANGUAGE"));
     $cache->drop("lms_steam::get_group_communication_objects", $workroom->get_id(), CLASS_MESSAGEBOARD | CLASS_CALENDAR | CLASS_CONTAINER | CLASS_ROOM);
     if (!isset($wiki_container) || !is_object($wiki_container)) {
         header("Location: " . $backlink);
         exit;
     }
 } else {
     $portal->set_problem_description($problems, isset($hints) ? $hints : "");
Esempio n. 7
0
 public function execute(\FrameResponseObject $frameResponseObject)
 {
     //$portal = \lms_portal::get_instance();
     //$portal->initialize( GUEST_NOT_ALLOWED );
     //$portal->set_guest_allowed( GUEST_NOT_ALLOWED );
     $user = \lms_steam::get_current_user();
     //$portal_user = $portal->get_user();
     //$path = $request->getPath();
     $group_course = \steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), "Courses." . $this->params[0] . "." . $this->params[1]);
     $group = new \koala_group_course($group_course);
     if (!$group instanceof \koala_group) {
         throw new \Exception("Is not a koala_group: " . $group_id, E_PARAMETER);
     }
     switch (get_class($group)) {
         case "koala_group_course":
             $html_handler_group = new \koala_html_course($group);
             $html_handler_group->set_context("communication");
             break;
         default:
             $html_handler_group = new \koala_html_group($group);
             $html_handler_group->set_context("communication");
             break;
     }
     $content = \Course::getInstance()->loadTemplate("groups_communication.template.html");
     //$content = new HTML_TEMPLATE_IT();
     //$content->loadTemplateFile( PATH_TEMPLATES . "groups_communication.template.html" );
     $workroom = $group->get_workroom();
     $read_access = $workroom->check_access_read($user);
     if (!$read_access) {
         throw new Exception("No read access on container: id=" . $workroom->get_id(), E_USER_RIGHTS);
     }
     $cache = get_cache_function(\lms_steam::get_current_user()->get_name(), 600);
     $communication_objects = $cache->call("lms_steam::get_group_communication_objects", $workroom->get_id(), CLASS_MESSAGEBOARD | CLASS_CALENDAR | CLASS_CONTAINER | CLASS_ROOM);
     $forums = array();
     $weblogs = array();
     $wikis = array();
     foreach ($communication_objects as $object) {
         if ($object["OBJ_CLASS"] === "steam_messageboard") {
             $forums[] = $object;
         } else {
             if ($object["OBJ_CLASS"] === "steam_calendar") {
                 $weblogs[] = $object;
             } else {
                 if (($object["OBJ_CLASS"] === "steam_container" || $object["OBJ_CLASS"] === "steam_room") && ($object["OBJ_TYPE"] != null && ($object["OBJ_TYPE"] == "KOALA_WIKI" || $object["OBJ_TYPE"] == "container_wiki_koala"))) {
                     $wikis[] = $object;
                 }
             }
         }
     }
     $content->setVariable("LABEL_FORUMS", gettext("Discussion Boards"));
     if (count($forums) > 0) {
         $content->setCurrentBlock("BLOCK_FORUMS");
         $content->setVariable("LABEL_FORUM_DESCRIPTION", gettext("Forum / description"));
         $content->setVariable("LABEL_ARTICLES", gettext("Articles"));
         $content->setVariable("LABEL_ACCESS", gettext("Access"));
         $content->setVariable("LABEL_LAST_COMMENT", gettext("Last comment"));
         $access_descriptions = \lms_forum::get_access_descriptions($group);
         foreach ($forums as $forum) {
             $cache = get_cache_function($forum["OBJ_ID"], 600);
             $discussions = $cache->call("lms_forum::get_discussions", $forum["OBJ_ID"]);
             $latest_post = isset($discussions[0]) ? $discussions[0] : FALSE;
             $content->setCurrentBlock("BLOCK_FORUM");
             $content->setVariable("NAME_FORUM", h($forum["OBJ_NAME"]));
             $content->setVariable("LINK_FORUM", PATH_URL . "forums/" . $forum["OBJ_ID"] . "/");
             $content->setVariable("OBJ_DESC", get_formatted_output($forum["OBJ_DESC"]));
             $language = !empty($forum["FORUM_LANGUAGE"]) ? $forum["FORUM_LANGUAGE"] : "German";
             $content->setVariable("VALUE_LANGUAGE", $language);
             $access = "<span title=\"" . $access_descriptions[$forum["KOALA_ACCESS"]]["label"] . "\">" . $access_descriptions[$forum["KOALA_ACCESS"]]["summary_short"] . "</span>";
             $content->setVariable("VALUE_ACCESS", $access);
             $content->setVariable("VALUE_ARTICLES", count($discussions));
             if ($latest_post) {
                 $content->setVariable("SUBJECT_LAST_COMMENT", h($latest_post["LATEST_POST_TITLE"]));
                 $content->setVariable("LINK_LAST_COMMENT", PATH_URL . "forums/" . $latest_post["OBJ_ID"] . "/");
                 $content->setVariable("POSTED_BY_LABEL", "(" . h($latest_post["LATEST_POST_AUTHOR"]) . ", " . how_long_ago($latest_post["LATEST_POST_TS"]) . ")");
             } else {
                 $content->setVariable("POSTED_BY_LABEL", gettext("-"));
             }
             $content->parse("BLOCK_FORUM");
         }
         $content->parse("BLOCK_FORUMS");
     } else {
         $content->setVariable("LABEL_NO_FORUMS_FOUND", "<b>" . gettext("No forums available. Either no forums are created in this context, or you have no rights to read them.") . "</b>");
     }
     $content->setVariable("LABEL_WEBLOGS", gettext("Weblogs"));
     if (count($weblogs) > 0) {
         $content->setCurrentBlock("BLOCK_WEBLOGS");
         $content->setVariable("LABEL_WEBLOG_DESCRIPTION", gettext("Weblog / description"));
         $content->setVariable("LABEL_WEBLOG_ENTRIES", gettext("Entries"));
         $content->setVariable("LABEL_WEBLOG_ACCESS", gettext("Access"));
         $content->setVariable("LABEL_WEBLOG_LAST_ENTRY", gettext("Last entry"));
         $access_descriptions = \lms_weblog::get_access_descriptions($group);
         foreach ($weblogs as $weblog) {
             $cache = get_cache_function($weblog["OBJ_ID"], 600);
             $entries = $cache->call("lms_weblog::get_items", $weblog["OBJ_ID"]);
             $last_entry = isset($entries[0]) ? $entries[0] : FALSE;
             $content->setCurrentBlock("BLOCK_WEBLOG");
             $content->setVariable("NAME_WEBLOG", h($weblog["OBJ_NAME"]));
             $content->setVariable("LINK_WEBLOG", PATH_URL . "weblog/" . $weblog["OBJ_ID"] . "/");
             $content->setVariable("WEBLOG_OBJ_DESC", get_formatted_output($weblog["OBJ_DESC"]));
             $title = $access_descriptions[$weblog["KOALA_ACCESS"]]["label"];
             if ($weblog["KOALA_ACCESS"] == PERMISSION_PRIVATE_READONLY && !$group instanceof koala_html_course) {
                 $obj = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $weblog["OBJ_ID"], CLASS_CALENDAR);
                 $creator = $obj->get_creator();
                 if ($creator->get_id() != \lms_steam::get_current_user()->get_id()) {
                     $title = str_replace("%NAME", $creator->get_name(), $title);
                 } else {
                     $title = str_replace("%NAME", "you", $title);
                 }
             }
             $content->setVariable("VALUE_WEBLOG_LANGUAGE", "German");
             $access = "<span title=\"" . $title . "\">" . $access_descriptions[$weblog["KOALA_ACCESS"]]["summary_short"] . "</span>";
             $content->setVariable("VALUE_WEBLOG_ACCESS", $access);
             $content->setVariable("VALUE_WEBLOG_ARTICLES", count($entries));
             $content->setVariable("LINK_WEBLOG_LAST_ENTRY", PATH_URL . "weblog/" . $last_entry["OBJ_ID"] . "/");
             if ($last_entry) {
                 $content->setVariable("SUBJECT_WEBLOG_LAST_ENTRY", h($last_entry["DATE_TITLE"]));
                 $content->setVariable("WEBLOG_POSTED_BY_LABEL", "(" . h($last_entry["AUTHOR"]) . ", " . how_long_ago($last_entry["DATE_START_DATE"]) . ")");
             } else {
                 $content->setVariable("WEBLOG_POSTED_BY_LABEL", gettext("-"));
             }
             $content->parse("BLOCK_WEBLOG");
         }
         $content->parse("BLOCK_WEBLOGS");
     } else {
         $content->setVariable("LABEL_NO_WEBLOGS_FOUND", "<b>" . gettext("No weblogs available. Either no weblogs are created in this context, or you have no rights to read them.") . "</b>");
     }
     $content->setVariable("LABEL_WIKIS", gettext("Wikis"));
     if (count($wikis) > 0) {
         $content->setCurrentBlock("BLOCK_WIKIS");
         $content->setVariable("LABEL_WIKI_DESCRIPTION", gettext("Wiki / description"));
         $content->setVariable("LABEL_WIKI_ENTRIES", gettext("Entries"));
         $content->setVariable("LABEL_WIKI_ACCESS", gettext("Access"));
         $content->setVariable("LABEL_WIKI_LAST_ENTRY", gettext("Last entry"));
         $access_descriptions = lms_wiki::get_access_descriptions($group);
         foreach ($wikis as $wiki) {
             $cache = get_cache_function($wiki["OBJ_ID"], 600);
             $entries = $cache->call("lms_wiki::get_items", $wiki["OBJ_ID"]);
             $last_entry = isset($entries[0]) ? $entries[0] : FALSE;
             $content->setCurrentBlock("BLOCK_WIKI");
             $content->setVariable("NAME_WIKI", h($wiki["OBJ_NAME"]));
             $content->setVariable("LINK_WIKI", PATH_URL . "wiki/" . $wiki["OBJ_ID"] . "/");
             $content->setVariable("WIKI_OBJ_DESC", get_formatted_output($wiki["OBJ_DESC"]));
             $title = $access_descriptions[$wiki["KOALA_ACCESS"]]["label"];
             if ($wiki["KOALA_ACCESS"] == PERMISSION_PRIVATE_READONLY && !$group instanceof koala_html_course) {
                 $obj = steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $wiki["OBJ_ID"], CLASS_CONTAINER);
                 $creator = $obj->get_creator();
                 if ($creator->get_id() != lms_steam::get_current_user()->get_id()) {
                     $title = str_replace("%NAME", $creator->get_name(), $title);
                 } else {
                     $title = str_replace("%NAME", "you", $title);
                 }
             }
             $access = "<span title=\"" . $title . "\">" . $access_descriptions[$wiki["KOALA_ACCESS"]]["summary_short"] . "</span>";
             $content->setVariable("VALUE_WIKI_ACCESS", $access);
             $content->setVariable("VALUE_WIKI_ARTICLES", count($entries));
             $content->setVariable("LINK_WIKI_LAST_ENTRY", PATH_URL . "wiki/" . $last_entry["OBJ_ID"] . "/");
             $content->setVariable("SUBJECT_WIKI_LAST_ENTRY", str_replace(".wiki", "", h($last_entry["OBJ_NAME"])));
             $content->setVariable("WIKI_POSTED_BY_LABEL", $last_entry["DOC_LAST_MODIFIED"] != null ? "(" . h($last_entry["DOC_USER_MODIFIED"]) . ", " . how_long_ago($last_entry["DOC_LAST_MODIFIED"]) . ")" : "-");
             $content->parse("BLOCK_WIKI");
         }
         $content->parse("BLOCK_WIKIS");
     } else {
         $content->setVariable("LABEL_NO_WIKIS_FOUND", "<b>" . gettext("No wikis available. Either no wikis are created in this context, or you have no rights to read them.") . "</b>");
     }
     $html_handler_group->set_html_left($content->get());
     //$portal->set_page_main( $html_handler_group->get_headline(), $html_handler_group->get_html(), "");
     $frameResponseObject->setHeadline($html_handler_group->get_headline());
     $widget = new \Widgets\RawHtml();
     $widget->setHtml($html_handler_group->get_html());
     $frameResponseObject->addWidget($widget);
     return $frameResponseObject;
 }
Esempio n. 8
0
            $content->setVariable("WEBLOG_POSTED_BY_LABEL", gettext("-"));
        }
        $content->parse("BLOCK_WEBLOG");
    }
    $content->parse("BLOCK_WEBLOGS");
} else {
    $content->setVariable("LABEL_NO_WEBLOGS_FOUND", "<b>" . gettext("No weblogs available. Either no weblogs are created in this context, or you have no rights to read them.") . "</b>");
}
$content->setVariable("LABEL_WIKIS", gettext("Wikis"));
if (count($wikis) > 0) {
    $content->setCurrentBlock("BLOCK_WIKIS");
    $content->setVariable("LABEL_WIKI_DESCRIPTION", gettext("Wiki / description"));
    $content->setVariable("LABEL_WIKI_ENTRIES", gettext("Entries"));
    $content->setVariable("LABEL_WIKI_ACCESS", gettext("Access"));
    $content->setVariable("LABEL_WIKI_LAST_ENTRY", gettext("Last entry"));
    $access_descriptions = lms_wiki::get_access_descriptions($group);
    foreach ($wikis as $wiki) {
        $cache = get_cache_function($wiki["OBJ_ID"], 600);
        $entries = $cache->call("lms_wiki::get_items", $wiki["OBJ_ID"]);
        $last_entry = isset($entries[0]) ? $entries[0] : FALSE;
        $content->setCurrentBlock("BLOCK_WIKI");
        $content->setVariable("NAME_WIKI", h($wiki["OBJ_NAME"]));
        $content->setVariable("LINK_WIKI", PATH_URL . "wiki/" . $wiki["OBJ_ID"] . "/");
        $content->setVariable("WIKI_OBJ_DESC", get_formatted_output($wiki["OBJ_DESC"]));
        $title = $access_descriptions[$wiki["KOALA_ACCESS"]]["label"];
        if ($wiki["KOALA_ACCESS"] == PERMISSION_PRIVATE_READONLY && !$group instanceof koala_html_course) {
            $obj = steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $wiki["OBJ_ID"], CLASS_CONTAINER);
            $creator = $obj->get_creator();
            if ($creator->get_id() != lms_steam::get_current_user()->get_id()) {
                $title = str_replace("%NAME", $creator->get_name(), $title);
            } else {
Esempio n. 9
0
<?php

require_once PATH_LIB . "wiki_handling.inc.php";
//is it a previous version of an entry?
$is_prev_version = isset($version_doc) && is_object($version_doc) && $version_doc instanceof steam_document ? TRUE : FALSE;
$wiki_html_handler = new lms_wiki($wiki_container);
if (!$is_prev_version) {
    $wiki_html_handler->set_admin_menu("entry", $wiki_doc);
    $attributes = $wiki_doc->get_attributes(array("DOC_VERSION", "DOC_AUTHORS", "OBJ_LAST_CHANGED", "DOC_USER_MODIFIED", "DOC_TIMES_READ", "DOC_LAST_MODIFIED", "OBJ_WIKILINKS"));
    $wiki_html_handler->set_widget_links($wiki_doc);
    $wiki_html_handler->set_widget_previous_versions($wiki_doc);
} else {
    $wiki_html_handler->set_admin_menu("version", $version_doc);
    $attributes = $version_doc->get_attributes(array("DOC_VERSION", "DOC_AUTHORS", "OBJ_LAST_CHANGED", "DOC_USER_MODIFIED", "DOC_TIMES_READ", "DOC_LAST_MODIFIED", "OBJ_WIKILINKS"));
}
$last_author = $attributes["DOC_USER_MODIFIED"]->get_attributes(array("USER_FIRSTNAME", "USER_FULLNAME"));
$content = new HTML_TEMPLATE_IT();
$content->loadTemplateFile(PATH_TEMPLATES . "wiki_entry.template.html");
if (!$is_prev_version) {
    $content->setVariable("VALUE_ENTRY_TEXT", wiki_to_html_plain($wiki_doc));
} else {
    $content->setVariable("VALUE_ENTRY_TEXT", wiki_to_html_plain($wiki_doc, $version_doc));
}
$content->setVariable("IMAGE_SRC", PATH_URL . "get_document.php?id=" . $attributes["DOC_USER_MODIFIED"]->get_attribute("OBJ_ICON")->get_id() . "&type=usericon&width=60&height=70");
$content->setVariable("AUTHOR_LINK", PATH_URL . "user/" . $attributes["DOC_USER_MODIFIED"]->get_name() . "/");
$content->setVariable("VALUE_POSTED_BY", h($last_author["USER_FIRSTNAME"]) . " " . h($last_author["USER_FULLNAME"]));
$content->setVariable("LABEL_BY", gettext("created by"));
$content->setVariable("VALUE_VERSION", h($attributes["DOC_VERSION"]));
$content->setVariable("VALUE_DATE_TIME", strftime("%x %X", $attributes["DOC_LAST_MODIFIED"]));
if (!$is_prev_version) {
    $content->setVariable("POST_PERMALINK", PATH_URL . "wiki/" . $wiki_doc->get_id() . "/");
Esempio n. 10
0
 public function execute(\FrameResponseObject $frameResponseObject)
 {
     //CODE FOR ALL COMMANDS OF THIS PAKAGE END
     $user = \lms_steam::get_current_user();
     // Disable caching
     // TODO: Work on cache handling. An enabled cache leads to bugs
     // if used with the wiki.
     \CacheSettings::disable_caching();
     if (!($wiki_container = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->id))) {
         include "bad_link.php";
         exit;
     }
     if (!$wiki_container instanceof \steam_container) {
         $wiki_doc = $wiki_container;
         $wiki_container = $wiki_doc->get_environment();
         if ($wiki_doc->get_attribute(DOC_MIME_TYPE) != "text/wiki") {
             include "bad_link.php";
             exit;
         }
     }
     //CODE FOR ALL COMMANDS OF THIS PAKAGE END
     $version_doc = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->params[1]);
     defined("OBJ_ID") or define("OBJ_ID", $wiki_doc->get_id());
     $is_prev_version = isset($version_doc) && is_object($version_doc) && $version_doc instanceof \steam_document ? TRUE : FALSE;
     $wiki_html_handler = new \lms_wiki($wiki_container);
     if (!$is_prev_version) {
         $wiki_html_handler->set_admin_menu("entry", $wiki_doc);
         $attributes = $wiki_doc->get_attributes(array("DOC_VERSION", "DOC_AUTHORS", "OBJ_LAST_CHANGED", "DOC_USER_MODIFIED", "DOC_TIMES_READ", "DOC_LAST_MODIFIED", "OBJ_WIKILINKS"));
         //TODO: check if sourcecode can be deleted
         //$wiki_html_handler->set_widget_links( $wiki_doc );
         //$wiki_html_handler->set_widget_previous_versions( $wiki_doc );
     } else {
         $wiki_html_handler->set_admin_menu("version", $version_doc);
         $attributes = $version_doc->get_attributes(array("DOC_VERSION", "DOC_AUTHORS", "OBJ_LAST_CHANGED", "DOC_USER_MODIFIED", "DOC_TIMES_READ", "DOC_LAST_MODIFIED", "OBJ_WIKILINKS"));
     }
     $last_author = $attributes["DOC_USER_MODIFIED"]->get_attributes(array("USER_FIRSTNAME", "USER_FULLNAME"));
     $content = \Wiki::getInstance()->loadTemplate("wiki_entry.template.html");
     //$content = new HTML_TEMPLATE_IT();
     //$content->loadTemplateFile( PATH_TEMPLATES . "wiki_entry.template.html" );
     $content->setVariable("LABEL_CLOSE", gettext("close"));
     if (!$is_prev_version) {
         $content->setVariable("VALUE_ENTRY_TEXT", wiki_to_html_plain($wiki_doc));
     } else {
         $content->setVariable("VALUE_ENTRY_TEXT", wiki_to_html_plain($wiki_doc, $version_doc));
     }
     $content->setVariable("IMAGE_SRC", PATH_URL . "download/image/" . $attributes["DOC_USER_MODIFIED"]->get_attribute("OBJ_ICON")->get_id() . "/60/70/");
     $content->setVariable("AUTHOR_LINK", PATH_URL . "user/index/" . $attributes["DOC_USER_MODIFIED"]->get_name() . "/");
     $content->setVariable("VALUE_POSTED_BY", h($last_author["USER_FIRSTNAME"]) . " " . h($last_author["USER_FULLNAME"]));
     $content->setVariable("LABEL_BY", gettext("created by"));
     $content->setVariable("VALUE_VERSION", h($attributes["DOC_VERSION"]));
     $content->setVariable("VALUE_DATE_TIME", strftime("%x %X", $attributes["DOC_LAST_MODIFIED"]));
     /*
     if(!$is_prev_version)
     {
     $content->setVariable( "POST_PERMALINK", PATH_URL . "wiki/" . $wiki_doc->get_id() . "/" );
     $content->setVariable( "POST_PERMALINK_LABEL", "(" . gettext( "permalink" ) . ")");
     }
     */
     if ($wiki_doc->check_access_write($user)) {
         $content->setCurrentBlock("BLOCK_ACCESS");
         $content->setVariable("POST_LABEL_DELETE", gettext("delete"));
         $content->setVariable("POST_LABEL_EDIT", gettext("edit"));
         $content->parse("BLOCK_ACCESS");
     }
     $versions = $wiki_doc->get_previous_versions();
     $no_versions = is_array($versions) ? count($versions) : 0;
     $content->setVariable("VERSION_MANAGEMENT", gettext("Version Management"));
     if ($no_versions > 0) {
         $content->setVariable("NUMBER_VERSIONS", "<li>" . $no_versions . " " . gettext("previous version(s) available") . "</li>");
         $content->setVariable("LINK_VERSION_MANAGEMENT", "<li><a href=\"" . PATH_URL . "wiki/versionoverview/" . $wiki_doc->get_id() . "/\">&raquo; " . gettext("enter version management") . "</a></li>");
     } else {
         $content->setVariable("NUMBER_VERSIONS", "<li>" . gettext("no previous versions available") . "</li>");
     }
     $content->setVariable("LINKS", gettext("Wiki Links"));
     $links = $wiki_doc->get_attribute("OBJ_WIKILINKS_CURRENT");
     $found_doc = false;
     if (is_array($links)) {
         foreach ($links as $doc) {
             if ($doc instanceof \steam_document) {
                 $found_doc = true;
                 break;
             }
         }
     }
     if (!$found_doc) {
         $content->setCurrentBlock("BLOCK_LINKS");
         $content->setVariable("LINK", gettext("no links available"));
         $content->parse("BLOCK_LINKS");
     } else {
         foreach ($links as $doc) {
             if ($doc instanceof \steam_document) {
                 $name = str_replace(".wiki", "", h($doc->get_name()));
                 $link = PATH_URL . "wiki/viewversion/" . $wiki_doc->get_id() . "/" . $doc->get_identifier();
                 $content->setVariable("LINK", '<li>&raquo; <a href="' . $link . '">' . $name . '</a></li>');
                 $content->parse("BLOCK_LINKS");
             }
         }
     }
     $wiki_html_handler->set_main_html($content->get());
     $rootlink = \lms_steam::get_link_to_root($wiki_container);
     WIKI_FULL_HEADLINE ? $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication")), array("name" => h($wiki_container->get_name()), "link" => PATH_URL . "wiki/index/" . $wiki_container->get_id() . "/")) : ($headline = array(array("name" => h($wiki_container->get_name()), "link" => PATH_URL . "wiki/index/" . $wiki_container->get_id() . "/")));
     if (!$is_prev_version) {
         $headline[] = array("link" => "", "name" => str_replace(".wiki", "", h($wiki_doc->get_name())));
     } else {
         $headline[] = array("link" => PATH_URL . "wiki/viewentry/" . $wiki_doc->get_id() . "/", "name" => str_replace(".wiki", "", h($wiki_doc->get_name())));
         $headline[] = array("link" => PATH_URL . "wiki/versionoverview/" . $wiki_doc->get_id() . "/", "name" => gettext("Version management"));
         $headline[] = array("link" => "", "name" => "Version" . " " . $version_doc->get_version() . " (" . gettext("Preview") . ")");
     }
     /*$portal->set_page_main(
     	 $headline,
     	 $wiki_html_handler->get_html()
     	 );
     	 $portal->show_html();
     	 */
     $frameResponseObject->setHeadline($headline);
     $widget = new \Widgets\RawHtml();
     $widget->setHtml($wiki_html_handler->get_html());
     $frameResponseObject->addWidget($widget);
     return $frameResponseObject;
 }
Esempio n. 11
0
<?php

require_once PATH_LIB . "wiki_handling.inc.php";
$wiki_html_handler = new lms_wiki($wiki_container);
//$wiki_html_handler->set_admin_menu( "versions", $wiki_doc );
$content = new HTML_TEMPLATE_IT();
$content->loadTemplateFile(PATH_TEMPLATES . "wiki_version_compare.template.html");
$difftext = wiki_diff_html($to, $compare);
$content->setVariable("DIFF_TEXT", $difftext);
$wiki_html_handler->set_main_html($content->get());
$rootlink = lms_steam::get_link_to_root($wiki_container);
$headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication")), array("name" => h($wiki_container->get_name()), "link" => PATH_URL . "wiki/" . $wiki_container->get_id() . "/"), array("link" => PATH_URL . "wiki/" . $wiki_doc->get_id() . "/", "name" => str_replace(".wiki", "", h($wiki_doc->get_name()))), array("link" => PATH_URL . "wiki/" . $wiki_doc->get_id() . "/versions/", "name" => gettext("Version management")), array("link" => "", "name" => gettext("Version compare") . " (" . $compare->get_version() . " " . gettext("to") . " " . $to->get_version() . ")"));
$portal->set_page_main($headline, $wiki_html_handler->get_html());
$portal->show_html();
Esempio n. 12
0
 public function execute(\FrameResponseObject $frameResponseObject)
 {
     //CODE FOR ALL COMMANDS OF THIS PAKAGE END
     $user = \lms_steam::get_current_user();
     // Disable caching
     // TODO: Work on cache handling. An enabled cache leads to bugs
     // if used with the wiki.
     \CacheSettings::disable_caching();
     if (!($wiki_container = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->id))) {
         include "bad_link.php";
         exit;
     }
     if (!$wiki_container instanceof \steam_container) {
         $wiki_doc = $wiki_container;
         $wiki_container = $wiki_doc->get_environment();
         if ($wiki_doc->get_attribute(DOC_MIME_TYPE) != "text/wiki") {
             include "bad_link.php";
             exit;
         }
     }
     //CODE FOR ALL COMMANDS OF THIS PAKAGE END
     defined("OBJ_ID") or define("OBJ_ID", $wiki_container->get_id());
     $wiki_html_handler = new \lms_wiki($wiki_container);
     $wiki_html_handler->set_admin_menu("index", $wiki_container);
     $grp = $wiki_container->get_environment()->get_creator();
     if ($grp->get_name() == "learners" && $grp->get_attribute(OBJ_TYPE) == "course_learners") {
         $grp = $grp->get_parent_group();
     }
     $content = \Wiki::getInstance()->loadTemplate("wiki_entries.template.html");
     //$content = new HTML_TEMPLATE_IT();
     //$content->loadTemplateFile( PATH_TEMPLATES . "wiki_entries.template.html" );
     $cache = get_cache_function($wiki_container->get_id(), 600);
     $wiki_entries = $cache->call("lms_wiki::get_items", $wiki_container->get_id());
     $recently_changed = new \LinkedList(5);
     $most_discussed = new \LinkedList(5);
     $latest_comments = new \LinkedList(5);
     $no_wiki_entries = count($wiki_entries);
     if ($no_wiki_entries > 0) {
         $first_char = "";
         for ($i = 0; $i < $no_wiki_entries; $i++) {
             $this_char = substr(strtoupper($wiki_entries[$i]["OBJ_NAME"]), 0, 1);
             if ($this_char > $first_char) {
                 $first_char = $this_char;
                 if ($i > 1) {
                     $content->parse("BLOCK_CHARACTER");
                 }
                 $content->setCurrentBlock("BLOCK_CHARACTER");
                 $content->setVariable("FIRST_CHAR", h($this_char));
             }
             $char_articles = array();
             while ($i < $no_wiki_entries && $this_char == substr(strtoupper($wiki_entries[$i]["OBJ_NAME"]), 0, 1)) {
                 $char_articles[] = $wiki_entries[$i];
                 if ($recently_changed->can_be_added($wiki_entries[$i]["DOC_LAST_MODIFIED"])) {
                     $recently_changed->add_element($wiki_entries[$i]["DOC_LAST_MODIFIED"], $wiki_entries[$i]);
                 }
                 if (isset($wiki_entries[$i]["COMMENTS_NO"]) && $most_discussed->can_be_added($wiki_entries[$i]["COMMENTS_NO"]) && $wiki_entries[$i]["COMMENTS_NO"] > 1) {
                     $most_discussed->add_element($wiki_entries[$i]["COMMENTS_NO"], $wiki_entries[$i]);
                 }
                 if (isset($wiki_entries[$i]["COMMENTS_LAST"]) && $latest_comments->can_be_added($wiki_entries[$i]["COMMENTS_LAST"]) && $wiki_entries[$i]["COMMENTS_LAST"] > 0) {
                     $latest_comments->add_element($wiki_entries[$i]["COMMENTS_LAST"], $wiki_entries[$i]);
                 }
                 $i++;
             }
             $i--;
             $no_articles_in_first_row = ceil(count($char_articles) / 2);
             $content->setCurrentBlock("BLOCK_COLUMN");
             for ($c = 0; $c < $no_articles_in_first_row; $c++) {
                 $content->setCurrentBlock("BLOCK_ARTICLE");
                 $content->setVariable("ARTICLE_LINK", PATH_URL . "wiki/viewentry/" . $char_articles[$c]["OBJ_ID"] . "/");
                 $content->setVariable("ARTICLE_NAME", str_replace(".wiki", "", h($char_articles[$c]["OBJ_NAME"])));
                 $content->parse("BLOCK_ARTICLE");
             }
             $content->parse("BLOCK_COLUMN");
             $content->setCurrentBlock("BLOCK_COLUMN");
             for ($c = $no_articles_in_first_row; $c < count($char_articles); $c++) {
                 $content->setCurrentBlock("BLOCK_ARTICLE");
                 $content->setVariable("ARTICLE_LINK", PATH_URL . "wiki/viewentry/" . $char_articles[$c]["OBJ_ID"] . "/");
                 $content->setVariable("ARTICLE_NAME", str_replace(".wiki", "", h($char_articles[$c]["OBJ_NAME"])));
                 $content->parse("BLOCK_ARTICLE");
             }
             $content->parse("BLOCK_COLUMN");
             $content->parse("BLOCK_CHARACTER");
         }
         foreach ($wiki_entries as $entry) {
             $content->setCurrentBlock("BLOCK_ARTICLE");
             $content->setVariable("VALUE_WIKI_ENTRY", h($entry["OBJ_NAME"]));
             $content->setVariable("LINK_WIKI_ENTRY", PATH_URL . "wiki/viewentry/" . $wiki_container->get_id() . "/" . h($entry["OBJ_NAME"]));
             $content->setVariable("LABEL_LAST_MODIFICATION", gettext("last edited"));
             $content->setVariable("VALUE_POSTED_BY", $entry["DOC_USER_MODIFIED"]);
             $content->setVariable("POST_PERMALINK", PATH_URL . "wiki/viewentry/" . $entry["OBJ_ID"] . "/");
             $content->setVariable("VALUE_DATE_TIME", strftime("%x %X", $entry["OBJ_CREATION_TIME"]));
             $content->setVariable("POST_PERMALINK_LABEL", gettext("permalink"));
             $content->parse("BLOCK_ARTICLE");
         }
     }
     /* TODO: check if these functions can be deleted
     		 $wiki_html_handler->set_widget_latest_comments( $latest_comments );
     		 $wiki_html_handler->set_widget_last_changed( $recently_changed );
     		 $wiki_html_handler->set_widget_most_discussed( $most_discussed );
     		 $wiki_html_handler->set_widget_access( $grp );
     		 */
     //TODO: SET RSS_FEEDS
     WIKI_RSS ? $portal->set_rss_feed(PATH_URL . "services/feeds/wiki_public.php?id=" . OBJ_ID, gettext("Feed"), gettext("Subscribe to this forum's Newsfeed")) : "";
     $wiki_html_handler->set_main_html($content->get());
     $rootlink = \lms_steam::get_link_to_root($wiki_container);
     WIKI_FULL_HEADLINE ? $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication")), array("link" => "", "name" => h($wiki_container->get_name()))) : ($headline = array(array("link" => "", "name" => h($wiki_container->get_name()))));
     $frameResponseObject->setHeadline($headline);
     $widget = new \Widgets\RawHtml();
     $widget->setHtml($wiki_html_handler->get_html());
     $frameResponseObject->addWidget($widget);
     return $frameResponseObject;
 }
Esempio n. 13
0
 public function execute(\FrameResponseObject $frameResponseObject)
 {
     //CODE FOR ALL COMMANDS OF THIS PAKAGE END
     $user = \lms_steam::get_current_user();
     // Disable caching
     // TODO: Work on cache handling. An enabled cache leads to bugs
     // if used with the wiki.
     \CacheSettings::disable_caching();
     if (!($wiki_container = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->id))) {
         include "bad_link.php";
         exit;
     }
     if (!$wiki_container instanceof \steam_container) {
         $wiki_doc = $wiki_container;
         $wiki_container = $wiki_doc->get_environment();
         if ($wiki_doc->get_attribute(DOC_MIME_TYPE) != "text/wiki") {
             include "bad_link.php";
             exit;
         }
     }
     //CODE FOR ALL COMMANDS OF THIS PAKAGE END
     $wiki_html_handler = new \lms_wiki($wiki_container);
     $wiki_html_handler->set_admin_menu("versions", $wiki_doc);
     $content = \Wiki::getInstance()->loadTemplate("wiki_versions.template.html");
     //$content = new HTML_TEMPLATE_IT();
     //$content->loadTemplateFile( PATH_TEMPLATES . "wiki_versions.template.html" );
     $prev_versions = $wiki_doc->get_previous_versions();
     if (!is_array($prev_versions)) {
         $prev_versions = array();
     }
     array_unshift($prev_versions, $wiki_doc);
     $no_versions = count($prev_versions);
     $content->setCurrentBlock("BLOCK_VERSION_LIST");
     if (isset($_GET["markedfordiff"]) && !empty($_GET["markedfordiff"])) {
         $uri_params = "?markedfordiff=" . $_GET["markedfordiff"];
         //$start = $portal->set_paginator( $content, 10, $no_versions, "(" . gettext("%TOTAL versions in list") . ")", $uri_params );
         $pageIterator = \lms_portal::get_paginator(10, $no_versions, "(" . gettext("%TOTAL groups in list") . ")");
         $content->setVariable("PAGEITERATOR", $pageIterator["html"]);
         $start = $pageIterator["startIndex"];
     } else {
         $pageIterator = \lms_portal::get_paginator(10, $no_versions, "(" . gettext("%TOTAL groups in list") . ")");
         $content->setVariable("PAGEITERATOR", $pageIterator["html"]);
         $start = $pageIterator["startIndex"];
     }
     //$start = $portal->set_paginator( $content, 10, $no_versions, "(" . gettext("%TOTAL versions in list") . ")" );
     $end = $start + 10 > $no_versions ? $no_versions : $start + 10;
     $entry_name = str_replace(".wiki", "", $wiki_doc->get_identifier());
     $content->setVariable("LABEL_VERSIONS", gettext("Available Versions for the entry") . " \"" . h($entry_name) . "\" (" . str_replace(array("%a", "%z", "%s"), array($start + 1, $end, $no_versions), gettext("%a-%z out of %s")) . ")");
     $content->setVariable("LABEL_VERSION_NUMBER", gettext("Version number"));
     $content->setVariable("LABEL_SIZE", gettext("Size"));
     $content->setVariable("LABEL_DATE", gettext("Modification date"));
     $content->setVariable("LABEL_CREATOR", gettext("Modified by"));
     $content->setVariable("LABEL_ACTION", gettext("Action"));
     // Use buffer for document attributes
     $attributes_tnr = array();
     for ($i = $start; $i < $end; $i++) {
         $attributes_tnr[$prev_versions[$i]->get_id()] = $prev_versions[$i]->get_attributes(array(DOC_USER_MODIFIED, DOC_LAST_MODIFIED, DOC_VERSION, DOC_SIZE), TRUE);
     }
     $attributes_result = $GLOBALS["STEAM"]->buffer_flush();
     // use buffer for author attributes
     $author_tnr = array();
     for ($i = $start; $i < $end; $i++) {
         $author_tnr[$prev_versions[$i]->get_id()] = $attributes_result[$attributes_tnr[$prev_versions[$i]->get_id()]][DOC_USER_MODIFIED]->get_attributes(array(USER_FIRSTNAME, USER_FULLNAME, OBJ_NAME), TRUE);
     }
     $author_result = $GLOBALS["STEAM"]->buffer_flush();
     for ($i = $start; $i < $end; $i++) {
         $doc = $prev_versions[$i];
         $attributes = $attributes_result[$attributes_tnr[$doc->get_id()]];
         $last_author = $author_result[$author_tnr[$doc->get_id()]];
         $content->setCurrentBlock("BLOCK_VERSION");
         if ($doc instanceof \steam_document) {
             $content->setVariable("VALUE_SIZE", get_formatted_filesize($doc->get_content_size()));
             $content->setVariable("VALUE_CREATOR_LINK", PATH_URL . "user/index/" . $author_result[$author_tnr[$doc->get_id()]][OBJ_NAME] . "/");
             $content->setVariable("VALUE_CREATOR", h($last_author[USER_FIRSTNAME]) . " " . h($last_author[USER_FULLNAME]));
             $content->setVariable("VALUE_DATE", strftime("%x %X", $attributes["DOC_LAST_MODIFIED"]));
             if ($doc->get_id() !== $wiki_doc->get_id()) {
                 $content->setVariable("VALUE_VERSION_LINK", PATH_URL . "wiki/viewversion/" . $wiki_doc->get_id() . "/" . $doc->get_id() . "/");
                 $content->setVariable("VALUE_VERSION_NUMBER", "Version " . h($attributes_result[$attributes_tnr[$doc->get_id()]][DOC_VERSION]));
                 $content->setCurrentBlock("BLOCK_RECOVER");
                 $content->setVariable("VALUE_ACTION_RECOVER", "&raquo; " . gettext("Recover this version"));
                 $content->setVariable("VALUE_RECOVER_LINK", PATH_URL . "wiki/recoverversion/" . $wiki_doc->get_id() . "/" . $doc->get_id() . "/");
                 $content->parse("BLOCK_RECOVER");
             } else {
                 $content->setVariable("VALUE_VERSION_LINK", PATH_URL . "wiki/viewentry/" . $wiki_doc->get_id() . "/");
                 $content->setVariable("VALUE_VERSION_NUMBER", "Version " . h($attributes_result[$attributes_tnr[$doc->get_id()]][DOC_VERSION]) . " (" . gettext("current") . ")");
             }
             if (isset($_GET["markedfordiff"]) && $_GET["markedfordiff"] == $doc->get_id()) {
                 $content->setVariable("VALUE_ACTION_MARK", "&raquo; " . gettext("Currently marked for version compare"));
             } else {
                 $content->setVariable("VALUE_ACTION_MARK", "<a href=\"" . PATH_URL . "wiki/versionoverview/" . $wiki_doc->get_id() . "/?markedfordiff=" . $doc->get_id() . "\">" . "&raquo; " . gettext("Mark for version compare") . "</a>");
             }
             if ($attributes[DOC_VERSION] != 1) {
                 $content->setVariable("VALUE_ACTION_DIFF", "&raquo; " . gettext("Compare to previous version") . " " . ($attributes[DOC_VERSION] - 1));
                 $content->setVariable("VALUE_DIFF_LINK", PATH_URL . "wiki/compareversions/" . $wiki_doc->get_id() . "/" . $doc->get_id() . "/" . $prev_versions[$i + 1]->get_id());
             }
             if (isset($_GET["markedfordiff"]) && $_GET["markedfordiff"] != $doc->get_id()) {
                 $marked = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $_GET["markedfordiff"]);
                 $content->setVariable("VALUE_ACTION_MARKED_DIFF", "<a href=\"" . PATH_URL . "wiki/compareversions/" . $wiki_doc->get_id() . "/" . $doc->get_id() . "/" . $_GET["markedfordiff"] . "\">" . "&raquo; " . gettext("Compare to marked version") . " " . $marked->get_version() . "</a>");
             }
         }
         //is user authorized to delete version?
         $content->setVariable("MESSAGE_DELETION", gettext("Do you really want to delete this version?"));
         $current_user = \lms_steam::get_current_user();
         $admin_group = \steam_factory::get_group($GLOBALS["STEAM"]->get_id(), "admin");
         $isAdmin = is_object($admin_group) && $admin_group->is_member($current_user);
         $usersEntry = $last_author["OBJ_NAME"] === $current_user->get_name();
         $notCurrentVersion = $doc->get_id() !== $wiki_doc->get_id();
         if (($isAdmin || $usersEntry) && $notCurrentVersion) {
             $content->setVariable("VALUE_ACTION_DELETE", "<a href=\"" . PATH_URL . "wiki/deleteversion/" . $wiki_doc->get_id() . "/" . $doc->get_id() . "/\" onclick=\"return confirmDeletion();\">" . "&raquo; " . gettext("Delete this version") . "</a><br \\/>");
         }
         $content->parse("BLOCK_VERSION");
     }
     $content->parse("BLOCK_VERSION_LIST");
     $wiki_html_handler->set_main_html($content->get());
     $rootlink = \lms_steam::get_link_to_root($wiki_container);
     WIKI_FULL_HEADLINE ? $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication")), array("name" => h($wiki_container->get_name()), "link" => PATH_URL . "wiki/index/" . $wiki_container->get_id() . "/"), array("link" => PATH_URL . "wiki/viewentry/" . $wiki_doc->get_id() . "/", "name" => str_replace(".wiki", "", h($wiki_doc->get_name()))), array("link" => "", "name" => gettext("Version management"))) : ($headline = array(array("name" => h($wiki_container->get_name()), "link" => PATH_URL . "wiki/index/" . $wiki_container->get_id() . "/"), array("link" => PATH_URL . "wiki/viewentry/" . $wiki_doc->get_id() . "/", "name" => str_replace(".wiki", "", h($wiki_doc->get_name()))), array("link" => "", "name" => gettext("Version management"))));
     /*	$portal->set_page_main(
     		 $headline,
     		 $wiki_html_handler->get_html()
     		 );
     		 $portal->show_html();
     		 */
     $frameResponseObject->setHeadline($headline);
     $widget = new \Widgets\RawHtml();
     $widget->setHtml($wiki_html_handler->get_html());
     $frameResponseObject->addWidget($widget);
     return $frameResponseObject;
 }
Esempio n. 14
0
<?php

require_once PATH_LIB . "wiki_handling.inc.php";
$wiki_html_handler = new lms_wiki($wiki_container);
$wiki_html_handler->set_admin_menu("versions", $wiki_doc);
$content = new HTML_TEMPLATE_IT();
$content->loadTemplateFile(PATH_TEMPLATES . "wiki_versions.template.html");
$prev_versions = $wiki_doc->get_previous_versions();
if (!is_array($prev_versions)) {
    $prev_versions = array();
}
array_unshift($prev_versions, $wiki_doc);
$no_versions = count($prev_versions);
$content->setCurrentBlock("BLOCK_VERSION_LIST");
if (isset($_GET["markedfordiff"]) && !empty($_GET["markedfordiff"])) {
    $uri_params = "?markedfordiff=" . $_GET["markedfordiff"];
    $start = $portal->set_paginator($content, 10, $no_versions, "(" . gettext("%TOTAL versions in list") . ")", $uri_params);
} else {
    $start = $portal->set_paginator($content, 10, $no_versions, "(" . gettext("%TOTAL versions in list") . ")");
}
$end = $start + 10 > $no_versions ? $no_versions : $start + 10;
$content->setVariable("LABEL_VERSIONS", gettext("Available Versions for the entry") . " " . h($wiki_doc->get_identifier()) . " (" . str_replace(array("%a", "%z", "%s"), array($start + 1, $end, $no_versions), gettext("%a-%z out of %s")) . ")");
$content->setVariable("LABEL_VERSION_NUMBER", gettext("Version number"));
$content->setVariable("LABEL_SIZE", gettext("Size"));
$content->setVariable("LABEL_DATE", gettext("Modification date"));
$content->setVariable("LABEL_CREATOR", gettext("Modified by"));
$content->setVariable("LABEL_ACTION", gettext("Action"));
// Use buffer for document attributes
$attributes_tnr = array();
for ($i = $start; $i < $end; $i++) {
    $attributes_tnr[$prev_versions[$i]->get_id()] = $prev_versions[$i]->get_attributes(array(DOC_USER_MODIFIED, DOC_LAST_MODIFIED, DOC_VERSION, DOC_SIZE), TRUE);
Esempio n. 15
0
 public function set_widget_access($grp)
 {
     $access_descriptions = lms_wiki::get_access_descriptions($grp);
     $act_access = $this->steam_wiki->get_attribute(KOALA_ACCESS);
     $access_descriptions = $access_descriptions[$act_access];
     $access = $access_descriptions["summary_short"] . ": " . $access_descriptions["label"];
     if ($act_access == PERMISSION_PRIVATE_READONLY) {
         $creator = $this->steam_wiki->get_creator();
         if ($creator->get_id() != lms_steam::get_current_user()->get_id()) {
             $access = str_replace("%NAME", $creator->get_name(), $access);
         } else {
             $access = str_replace("%NAME", "you", $access);
         }
     }
     $t = Wiki::getInstance()->loadTemplate("widget_weblog_access.template.html");
     //  $t = new HTML_TEMPLATE_IT();
     // $t->loadTemplateFile( PATH_TEMPLATES . "widget_weblog_access.template.html" );
     $t->setCurrentBlock("BLOCK_ACCESS");
     $t->setVariable("LABEL_ACCESS", $access);
     $t->parse("BLOCK_ACCESS");
     $this->set_widget_html(gettext("Access"), $t->get());
 }
Esempio n. 16
0
<?php

require_once PATH_LIB . "comments_handling.inc.php";
require_once PATH_LIB . "wiki_handling.inc.php";
$wiki_html_handler = new lms_wiki($wiki_container);
$wiki_html_handler->set_admin_menu("index", $wiki_container);
$grp = $wiki_container->get_environment()->get_creator();
if ($grp->get_name() == "learners" && $grp->get_attribute(OBJ_TYPE) == "course_learners") {
    $grp = $grp->get_parent_group();
}
$content = new HTML_TEMPLATE_IT();
$content->loadTemplateFile(PATH_TEMPLATES . "wiki_entries.template.html");
$cache = get_cache_function($wiki_container->get_id(), 600);
$wiki_entries = $cache->call("lms_wiki::get_items", $wiki_container->get_id());
$recently_changed = new LinkedList(5);
$most_discussed = new LinkedList(5);
$latest_comments = new LinkedList(5);
$no_wiki_entries = count($wiki_entries);
if ($no_wiki_entries > 0) {
    $first_char = "";
    for ($i = 0; $i < $no_wiki_entries; $i++) {
        $this_char = substr(strtoupper($wiki_entries[$i]["OBJ_NAME"]), 0, 1);
        if ($this_char > $first_char) {
            $first_char = $this_char;
            if ($i > 1) {
                $content->parse("BLOCK_CHARACTER");
            }
            $content->setCurrentBlock("BLOCK_CHARACTER");
            $content->setVariable("FIRST_CHAR", h($this_char));
        }
        $char_articles = array();