function &getEntry($post) { global $xoopsModuleConfig; $weblog =& Weblog::getInstance(); $permission_group = ""; if (isset($post['permission_group']) && is_array($post['permission_group'])) { $permission_group = '|' . implode("|", $post['permission_group']) . '|'; } else { $permission_group = isset($post['permission_group']) ? $post['permission_group'] : ""; } $entry = $weblog->newInstance(); $entry->setVar('blog_id', $post['blog_id']); $entry->setVar('user_id', $post['user_id']); $entry->setVar('cat_id', $post['cat_id']); $entry->setVar('created', $post['created']); $entry->setVar('title', $post['title']); if (isset($post['ent_trackbackurl'])) { $entry->setVar('ent_trackbackurl', $post['ent_trackbackurl']); } $entry->setVar('contents', $post['contents']); $entry->setVar('private', !empty($post['private']) ? 'Y' : 'N'); $entry->setVar('permission_group', $permission_group); $entry->setVar('updateping', !empty($post['updateping']) ? 1 : 0); $entry->setVar('specify_created', !empty($post['specify_created']) ? 1 : 0); // dohtml check if ($xoopsModuleConfig['disable_html']) { $entry->setVar('dohtml', 0); $entry->setVar('dobr', 1); } else { $entry->setVar('dohtml', empty($post['dohtml']) ? 1 : 0); $entry->setVar('dobr', empty($post['dobr']) ? 0 : 1); } return $entry; }
function getAllChildrenCount($currentuid, $cat_id, $user_id = 0) { $weblog =& Weblog::getInstance(); $weblogcat =& WeblogCategories::getInstance(); $count = $weblog->getCountByCategory($currentuid, $cat_id, $user_id); $arr = $weblogcat->getAllChildrenIds($cat_id); $size = count($arr); for ($i = 0; $i < $size; $i++) { $count += $weblog->getCountByCategory($currentuid, $arr[$i], $user_id); } return $count; }
$currentUser->setVar('uid', 0); $useroffset = $xoopsConfig['default_TZ'] - $xoopsConfig['server_TZ']; } $isAdmin = $currentUser->isAdmin($xoopsModule->mid()); $currentuid = $currentUser->getVar('uid'); // privilege check include_once sprintf('%s/modules/%s/include/privilege.inc.php', XOOPS_ROOT_PATH, $xoopsModule->dirname()); if (!$isAdmin && !checkprivilege("read_detail", $xoopsModule->dirname())) { redirect_header(sprintf('%s/index.php', XOOPS_URL), 5, _BL_CANNOT_READ_SORRY); exit; } // specify template $xoopsOption['template_main'] = 'weblog' . $mydirnumber . '_details.html'; // obtain class instances $myts =& MyTextSanitizer::getInstance(); $weblog =& Weblog::getInstance(); $weblogcat =& WeblogCategories::getInstance(); $entryObject =& $weblog->getEntry($currentuid, $blog_id, 0, $useroffset); if (!$entryObject) { redirect_header(sprintf('%s/modules/%s/index.php', XOOPS_URL, $xoopsModule->dirname()), 5, _BL_PRIVATE_NOTEXIST_SORRY); exit; } // obtain trackback $tb_operator =& Weblog_Trackback_Operator::getInstance(); $trackback_array = $tb_operator->handler->get($entryObject->getVar('blog_id')); $trackback_transmit = array(); $trackback_recieved = array(); if ($trackback_array) { foreach ($trackback_array as $trackback_obj) { $trackback_data = array("tb_url" => $trackback_obj->getVar('tb_url'), "blog_name" => $trackback_obj->getVar('blog_name'), "title" => $trackback_obj->getVar('title'), "description" => xoops_substr($trackback_obj->getVar('description'), 0, 120), "link" => $trackback_obj->getVar('link'), "trackback_created" => formatTimestamp($trackback_obj->getVar('trackback_created'), 'Y-m-d/H:i:s', $xoopsConfig['default_TZ'])); if ($trackback_obj->getVar('direction') == "transmit") {
public function execute(\FrameResponseObject $frameResponseObject) { //var_dump($GLOBALS[ "STEAM" ]->get_id()); // $portal = \lms_portal::get_instance(); // $portal->initialize( GUEST_NOT_ALLOWED ); $user = \lms_steam::get_current_user(); // $path = $request->getPath(); $STEAM = $GLOBALS["STEAM"]; $weblogId = $this->id; $weblog = \steam_factory::get_object($STEAM->get_id(), $weblogId); //if ( ! $weblog = steam_factory::get_object( $STEAM->get_id(), $_GET[ "id" ] ) ) //{ // include( "bad_link.php" ); // exit; //} if (!$weblog instanceof \steam_calendar) { if ($weblog instanceof \steam_container) { $category = $weblog; $categories = $category->get_environment(); $weblog = new \steam_weblog($GLOBALS["STEAM"]->get_id(), $categories->get_environment()->get_id()); } elseif ($weblog instanceof \steam_date) { $date = $weblog; $weblog = new \steam_weblog($GLOBALS["STEAM"]->get_id(), $date->get_environment()->get_id()); } else { include "bad_link.php"; exit; } } else { $weblog = new \steam_weblog($GLOBALS["STEAM"]->get_id(), $weblogId); define("OBJ_ID", $weblogId); if (!$weblog->check_access_read($user)) { throw new \Exception("No rights to view this.", E_USER_RIGHTS); } } $content = \Weblog::getInstance()->loadTemplate("weblog_entry_edit.template.html"); //$content = new HTML_TEMPLATE_IT(); //$content->loadTemplateFile( PATH_TEMPLATES . "weblog_entry_edit.template.html" ); if ($_SERVER["REQUEST_METHOD"] == "GET") { $content->setVariable("BACK_LINK", $_SERVER["HTTP_REFERER"]); } if ($_SERVER["REQUEST_METHOD"] == "POST" && $date->check_access_write($user)) { $values = $_POST["values"]; if (!empty($values["save"])) { $problem = ""; $hint = ""; if (empty($values["title"])) { $problem .= gettext("The title is missing.") . " "; $hint .= gettext("Please add the missing values."); } if (empty($values["body"])) { $problem .= gettext("There is no message for your readers.") . " "; $hint .= gettext("Please write your post into the text area."); } if (!empty($values["category"]) && $values["category"] != 0) { $category = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $values["category"]); if (!$category instanceof \steam_container) { throw new \Exception("Not a valid category: " . $values["category"]); } } else { $category = ""; } if (!($timestamp = strtotime($values["date"] . ":00"))) { $problem .= gettext("I cannot parse the date and time."); $hint .= gettext("Please verify your date and time format") . ": YYYY-MM-DD HH:MM"; } if (empty($problem)) { require_once "Cache/Lite.php"; $cache = new \Cache_Lite(array("cacheDir" => PATH_CACHE)); $cache->clean($weblog->get_id()); $cache->clean($date->get_id()); $attributes = array("DATE_START_DATE" => $timestamp, "DATE_TITLE" => $values["title"], "DATE_DESCRIPTION" => $values["body"]); $date->set_attributes($attributes); $weblog->categorize_entry($date, $category); header("Location: " . $values["return_to"]); exit; } else { //TODO: PROBLEMDESCRIPTION //$portal->set_problem_description( $problem, $hint ); } } if ($values["preview"]) { $content->setCurrentBlock("BLOCK_PREVIEW"); $content->setVariable("LABEL_PREVIEW_EDIT", gettext("Preview the edit")); $content->setVariable("PREVIEW_EDIT", get_formatted_output($values["body"])); $content->parse("BLOCK_PREVIEW"); } } $content->setVariable("LABEL_HERE_IT_IS", ""); $content->setVariable("LABEL_DATE", gettext("Date")); $content->setVariable("LABEL_SUBJECT", gettext("Subject")); $content->setVariable("LABEL_CATEGORY", gettext("Category")); $content->setVariable("CAT_NO_SELECTION", gettext("nothing selected")); $content->setVariable("LABEL_YOUR_POST", gettext("Your post")); $content->setVariable("LABEL_PREVIEW", gettext("Preview")); $content->setVariable("LABEL_SAVE_CHANGES", gettext("Save changes")); $content->setVariable("LABEL_RETURN", gettext("back")); $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 (isset($values) && count($values)) { // FORMULAR WURDE SCHON EINMAL ABGESCHICKT $date_value = empty($values["date"]) ? strftime("%Y-%m-%d %H:%M") : $values["date"]; $content->setVariable("DATE_COMMENT", h($date_value)); $content->setVariable("TEXT_COMMENT", h($values["body"])); $content->setVariable("TITLE_COMMENT", h($values["title"])); $cat = $values["category"]; $content->setVariable("BACK_LINK", $values["return_to"]); } else { $attribs = $date->get_attributes(array("DATE_START_DATE", "DATE_TITLE", "DATE_DESCRIPTION", "DATE_CATEGORY")); $content->setVariable("DATE_COMMENT", strftime("%Y-%m-%d %H:%M", $attribs["DATE_START_DATE"])); $content->setVariable("TITLE_COMMENT", h($attribs["DATE_TITLE"])); $content->setVariable("TEXT_COMMENT", h($attribs["DATE_DESCRIPTION"])); $content->setVariable("TITLE_COMMENT", h($attribs["DATE_TITLE"])); $cat = is_object($attribs["DATE_CATEGORY"]) ? $attribs["DATE_CATEGORY"]->get_id() : 0; } $categories = $weblog->get_categories(); foreach ($categories as $category) { $content->setCurrentBlock("BLOCK_SELECT_CAT"); $content->setVariable("VALUE_CAT", $category->get_id()); $content->setVariable("LABEL_CAT", h($category->get_name())); if ($category->get_id() == $cat) { $content->setVariable("CAT_SELECTED", 'selected="selected"'); } $content->parse("BLOCK_SELECT_CAT"); } $rootlink = \lms_steam::get_link_to_root($weblog); $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication")), array("link" => "", "name" => h($weblog->get_name()), "link" => PATH_URL . "weblog/" . $weblog->get_id() . "/"), array("name" => str_replace("%NAME", h($date->get_attribute("DATE_TITLE")), gettext("Edit '%NAME'?")))); /*$portal->set_page_main( $headline, $content->get(), "" ); return $portal->get_html();*/ $frameResponseObject->setHeadline($headline); $widget = new \Widgets\RawHtml(); $widget->setHtml($content->get()); $frameResponseObject->addWidget($widget); return $frameResponseObject; }
public function execute(\FrameResponseObject $frameResponseObject) { //$portal = \lms_portal::get_instance(); //$portal->initialize( GUEST_NOT_ALLOWED ); //$portal->set_confirmation(); $user = \lms_steam::get_current_user(); //$path = $request->getPath(); $STEAM = $GLOBALS["STEAM"]; $weblogId = $this->id; $weblog = \steam_factory::get_object($STEAM->get_id(), $weblogId); //if ( ! $weblog = steam_factory::get_object( $STEAM->get_id(), $_GET[ "id" ] ) ) //{ // include( "bad_link.php" ); // exit; //} if (!$weblog instanceof \steam_calendar) { if ($weblog instanceof \steam_container) { $category = $weblog; $categories = $category->get_environment(); $weblog = new \steam_weblog((string) $GLOBALS["STEAM"]->get_id(), $categories->get_environment()->get_id()); } elseif ($weblog instanceof \steam_date) { $date = $weblog; $weblog = new \steam_weblog((string) $GLOBALS["STEAM"]->get_id(), $date->get_environment()->get_id()); } else { include "bad_link.php"; exit; } } else { $weblog = new \steam_weblog((string) $GLOBALS["STEAM"]->get_id(), $weblogId); define("OBJ_ID", $weblogId); if (!$weblog->check_access_read($user)) { throw new \Exception("No rights to view this.", E_USER_RIGHTS); } } $content = \Weblog::getInstance()->loadTemplate("weblog_post.template.html"); //$content = new HTML_TEMPLATE_IT(); //$content->loadTemplateFile( PATH_TEMPLATES . "weblog_post.template.html" ); $headline = gettext("Post a new entry"); if ($_SERVER["REQUEST_METHOD"] == "GET") { $content->setVariable("VALUE_BACK_LINK", $_SERVER["HTTP_REFERER"]); } else { $values = $_POST["values"]; if (get_magic_quotes_gpc()) { if (!empty($values['title'])) { $values['title'] = stripslashes($values['title']); } if (!empty($values['body'])) { $values['body'] = stripslashes($values['body']); } } if (!empty($values["save"])) { $problem = ""; $hint = ""; if (empty($values["title"])) { $problem .= gettext("The title is missing.") . " "; $hint .= gettext("Please add the missing values."); } if (empty($values["body"])) { $problem .= gettext("There is no message for your readers.") . " "; $hint .= gettext("Please write your post into the text area."); } if (!empty($values["category"]) && $values["category"] != 0) { $category = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $values["category"]); if (!$category instanceof \steam_container) { throw new \Exception("Not a valid category: " . $values["category"]); } } else { $category = ""; } if (!($timestamp = strtotime($values["date"] . ":00"))) { $problem .= gettext("I cannot parse the date and time."); $hint .= gettext("Please verify your date and time format") . ": YYYY-MM-DD HH:MM"; } if (strpos($values["title"], "/")) { if (!isset($problem)) { $problem = ""; } $problem .= gettext("Please don't use the \"/\"-char in the subject of your post."); } if (empty($problem)) { $new_entry = $weblog->create_entry($values["title"], $values["body"], $category, array(), $timestamp); if ($values["podcast"] != 0) { $new_entry->set_attribute("DATE_PODCAST", $values["podcast"]); } // Handle Related Cache-Data require_once "Cache/Lite.php"; $cache = new \Cache_Lite(array("cacheDir" => PATH_CACHE)); $cache->clean(OBJ_ID); // clean weblogcache $bcache = get_cache_function($_GET["id"], 600); $bcache->drop("lms_weblog::get_items", $_GET["id"]); // clean rsscache of the weblog $feedlink = PATH_URL . "services/feeds/weblog_public.php?id=" . $_GET["id"]; $rcache = get_cache_function("rss", 600); $rcache->drop("lms_rss::get_items", $feedlink); header("Location: " . PATH_URL . "weblog/index/" . $weblog->get_id() . "/"); exit; } else { // TODO:THERE IS A PROBLEM //$portal->set_problem_description( $problem, $hint ); $content->setVariable("TEXT_COMMENT", h($values["body"])); $content->setVariable("TITLE_COMMENT", h($values["title"])); } } else { // PREVIEW $content->setCurrentBlock("BLOCK_PREVIEW"); $content->setVariable("LABEL_PREVIEW_EDIT", gettext("Preview the edit")); $content->setVariable("PREVIEW_EDIT", get_formatted_output($values["body"])); $content->parse("BLOCK_PREVIEW"); $headline = gettext("Change it?"); $content->setVariable("TEXT_COMMENT", h($values["body"])); $content->setVariable("TITLE_COMMENT", h($values["title"])); } } $backlink = empty($_POST["values"]["return_to"]) ? $_SERVER["HTTP_REFERER"] : $_POST["values"]["return_to"]; $content->setVariable("VALUE_BACK_LINK", $backlink); $content->setVariable("POST_NEW_ENTRY_TEXT", $headline); $content->setVariable("INFO_TEXT", "some hints about blogging"); $content->setVariable("LABEL_DATE", gettext("Date")); $content->setVariable("INFO_FORMAT", gettext("Format: YYYY-MM-DD HH:MM")); $date = empty($values["date"]) ? strftime("%Y-%m-%d %H:%M") : $values["date"]; $content->setVariable("DATE_COMMENT", h($date)); $content->setVariable("LABEL_SUBJECT", gettext("Subject")); $content->setVariable("LABEL_YOUR_POST", gettext("Your Post")); $content->setVariable("LABEL_CATEGORY", gettext("Category")); $content->setVariable("LINK_NEW_CATEGORY", PATH_URL . "weblog/categorycreate/" . $weblog->get_id()); $content->setVariable("LABEL_NEW_CATEGORY", gettext("Want to add a new category?")); $content->setVariable("CAT_NO_SELECTION", gettext("nothing selected")); $categories = $weblog->get_categories(); $selection = empty($values["category"]) ? isset($_GET["category"]) ? $_GET["category"] : '' : $values["category"]; foreach ($categories as $category) { $content->setCurrentBlock("BLOCK_SELECT_CAT"); $content->setVariable("VALUE_CAT", $category->get_id()); $content->setVariable("LABEL_CAT", h($category->get_name())); if ($category->get_id() == $selection) { $content->setVariable("CAT_SELECTED", 'selected="selected"'); } $content->parse("BLOCK_SELECT_CAT"); } /* $content->setVariable( "LABEL_PODCAST", gettext( "Podcast") ); $content->setVariable( "PODCAST_NO_SELECTION", gettext( "nothing selected" ) ); $content->setVariable( "LINK_UPLOAD_MULTIMEDIA", PATH_URL . "weblog/" . $weblog->get_id() . "/podcast/" ); $content->setVariable( "LABEL_UPLOAD_MULTIMEDIA", gettext( "Want to upload an audio or video file?" ) ); $files_in_podspace = $weblog->get_podspace()->get_inventory( CLASS_DOCUMENT ); foreach( $files_in_podspace as $file ) { $content->setCurrentBlock( "BLOCK_MULTIMEDIA" ); $content->setVariable( "VALUE_MULTIMEDIA", $file->get_id() ); if ( ( $file->get_id() == $_GET[ "podcast" ] ) || ( $file->get_id() == $values[ "podcast" ] ) ) { $content->setVariable( "MULTIMEDIA_SELECTED", 'selected="selected"' ); } $content->setVariable( "LABEL_MULTIMEDIA", h($file->get_name()) ); $content->parse( "BLOCK_MULTIMEDIA" ); } */ $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")); $content->setVariable("LABEL_PREVIEW", gettext("Preview")); $content->setVariable("LABEL_SAVE_CHANGES", gettext("Save changes")); $content->setVariable("LABEL_RETURN", gettext("back")); //TODO:RSS-FEED //$portal->set_rss_feed( PATH_URL . "services/feeds/weblog_public.php?id=" . $weblog->get_id(), gettext( "Feed" ), str_replace( "%l", (isset($login))?$login:'', gettext( "Subscribe to this forum's Newsfeed" ) ) ); $rootlink = \lms_steam::get_link_to_root($weblog); $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication")), array("name" => h($weblog->get_name()), "link" => PATH_URL . "weblog/" . $weblog->get_id() . "/"), array("link" => "", "name" => gettext("New Post"))); /*$portal->set_page_main( $headline, $content->get() ); return $portal->get_html();*/ $frameResponseObject->setHeadline($headline); $widget = new \Widgets\RawHtml(); $widget->setHtml($content->get()); $frameResponseObject->addWidget($widget); return $frameResponseObject; }
public function execute(\FrameResponseObject $frameResponseObject) { //$portal = \lms_portal::get_instance(); //$portal->initialize( GUEST_NOT_ALLOWED ); $user = \lms_steam::get_current_user(); //$path = $request->getPath(); $STEAM = $GLOBALS["STEAM"]; $weblogId = $this->id; $weblog = \steam_factory::get_object($STEAM->get_id(), $weblogId); //if ( ! $weblog = steam_factory::get_object( $STEAM->get_id(), $_GET[ "id" ] ) ) //{ // include( "bad_link.php" ); // exit; //} if (!$weblog instanceof \steam_calendar) { if ($weblog instanceof \steam_container) { $category = $weblog; $categories = $category->get_environment(); $weblog = new \steam_weblog($GLOBALS["STEAM"]->get_id(), $categories->get_environment()->get_id()); } elseif ($weblog instanceof \steam_date) { $date = $weblog; $weblog = new \steam_weblog($GLOBALS["STEAM"]->get_id(), $date->get_environment()->get_id()); } else { include "bad_link.php"; exit; } } else { $weblog = new \steam_weblog($GLOBALS["STEAM"]->get_id(), $weblogId); define("OBJ_ID", $weblogId); if (!$weblog->check_access_read($user)) { throw new \Exception("No rights to view this.", E_USER_RIGHTS); } } if (!isset($date)) { throw new \Exception("variable date is not set."); } //$date = $weblog; if ($_SERVER["REQUEST_METHOD"] == "POST" && $date->check_access_write($user)) { $values = $_POST["values"]; if ($values["delete"]) { require_once "Cache/Lite.php"; $cache = new \Cache_Lite(array("cacheDir" => PATH_CACHE)); $cache->clean($weblog->get_id()); $cache->clean($date->get_id()); $trashbin = $GLOBALS["STEAM"]->get_current_steam_user(); if (is_object($trashbin)) { $date->move($trashbin); } else { $date->delete(); } } header("Location: " . $values["return_to"]); exit; } $content = \Weblog::getInstance()->loadTemplate("weblog_entry_delete.template.html"); //$content = new HTML_TEMPLATE_IT(); //$content->loadTemplateFile( PATH_TEMPLATES . "weblog_entry_delete.template.html" ); $content->setVariable("LABEL_ARE_YOU_SURE", gettext("Are you sure you want to delete this entry?")); $content->setVariable("TEXT_COMMENT", get_formatted_output($date->get_attribute("DATE_DESCRIPTION"))); $creator = $date->get_creator(); $creator_data = $creator->get_attributes(array("USER_FULLNAME", "USER_FIRSTNAME", "OBJ_ICON")); $content->setVariable("LABEL_FROM_AND_AGO", str_replace("%N", "<a href=\"" . PATH_URL . "/user/index/" . $creator->get_name() . "/\">" . h($creator_data["USER_FIRSTNAME"]) . " " . h($creator_data["USER_FULLNAME"]) . "</a>", gettext("by %N")) . "," . how_long_ago($date->get_attribute("OBJ_CREATION_TIME"))); $content->setVariable("LABEL_DELETE_IT", gettext("yes, delete it")); $content->setVariable("BACK_LINK", $_SERVER["HTTP_REFERER"]); $content->setVariable("LABEL_RETURN", gettext("back")); $content->setVariable("ICON_SRC", PATH_URL . "get_document.php?id=" . $creator_data["OBJ_ICON"]->get_id()); $rootlink = \lms_steam::get_link_to_root($weblog); $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication")), array("link" => "", "name" => h($weblog->get_name()), "link" => PATH_URL . "weblog/index/" . $weblog->get_id() . "/"), array("name" => str_replace("%NAME", h($date->get_attribute("DATE_TITLE")), gettext("Delete '%NAME'?")))); /*$portal->set_page_main( $headline, $content->get(), "" ); return $portal->get_html();*/ $frameResponseObject->setHeadline($headline); $widget = new \Widgets\RawHtml(); $widget->setHtml($content->get()); $frameResponseObject->addWidget($widget); return $frameResponseObject; }
public function execute(\FrameResponseObject $frameResponseObject) { //if (!defined("OBJ_ID")) define( "OBJ_ID", $weblog->get_id() ); $weblogId = $this->id; $weblog = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $weblogId); if (!defined("OBJ_ID")) { define("OBJ_ID", $weblog->get_id()); } $env = $weblog->get_environment(); $grp = $env->get_creator(); if ($grp->get_name() == "learners" && $grp->get_attribute(OBJ_TYPE) == "course_learners") { $grp = $grp->get_parent_group(); } $accessmergel = FALSE; if (isset($weblog) && is_object($weblog)) { $creator = $weblog->get_creator(); if ($weblog->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 the weblog 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 weblog."); } 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($weblog) || !is_object($weblog)) { $weblog_new = \steam_weblog::create_steam_structure($GLOBALS["STEAM"], $values["name"], $values["dsc"], $env); $_SESSION["confirmation"] = str_replace("%NAME", h($values["name"]), gettext("New weblog '%NAME' created.")); } else { $weblog->set_attribute(OBJ_NAME, $values["name"]); $weblog->set_attribute(OBJ_DESC, $values["dsc"]); $frameResponseObject->setConfirmText(gettext("The changes have been saved.")); //$portal->set_confirmation( gettext( "The changes have been saved." )); $weblog_new = $weblog; } //var_dump($weblog_new);die; $koala_weblog = new \lms_weblog($weblog_new); $access = (int) $values["access"]; //var_dump($access); $access_descriptions = \lms_weblog::get_access_descriptions($grp); //var_dump(!$accessmergel);die; //if (!$accessmergel) $koala_weblog->set_access( $access, $access_descriptions[$access]["members"] , $access_descriptions[$access]["steam"], $group_members, $group_staff, $group_admins ); // HIER DER NEUE CODE::ENDE $GLOBALS["STEAM"]->buffer_flush(); $cache = get_cache_function(\lms_steam::get_current_user()->get_name(), 600); $cache->drop("lms_steam::get_inventory_recursive", $workroom->get_id(), CLASS_CALENDAR, array("WEBLOG_LANGUAGE")); $cache->drop("lms_steam::get_group_communication_objects", $workroom->get_id(), CLASS_MESSAGEBOARD | CLASS_CALENDAR | CLASS_CONTAINER | CLASS_ROOM); if (!isset($weblog) || !is_object($weblog)) { header("Location: " . $backlink); exit; } } else { //TODO:PROBLEMDESCRIPTION //$portal->set_problem_description( $problems, isset($hints)?$hints:"" ); } } $content = \Weblog::getInstance()->loadTemplate("object_new.template.html"); //$content = new HTML_TEMPLATE_IT( PATH_TEMPLATES ); //$content->loadTemplateFile( "object_new.template.html" ); if (isset($weblog) && is_object($weblog)) { $content->setVariable("INFO_TEXT", str_replace("%NAME", h($weblog->get_name()), gettext("You are going to edit the weblog '<b>%NAME</b>'."))); $content->setVariable("LABEL_CREATE", gettext("Save changes")); $pagetitle = gettext("Preferences"); if (empty($values)) { $values = array(); $values["name"] = $weblog->get_name(); $values["dsc"] = $weblog->get_attribute(OBJ_DESC); $values["access"] = $weblog->get_attribute(KOALA_ACCESS); } $breadcrumbheader = gettext("Preferences"); } else { $grpname = $grp->get_attribute(OBJ_NAME); if ($grp->get_attribute(OBJ_TYPE) == "course") { $grpname = $grp->get_attribute(OBJ_DESC); } $content->setVariable("INFO_TEXT", str_replace("%ENV", h($grpname), gettext("You are going to create a new weblog in '<b>%ENV</b>'."))); $content->setVariable("LABEL_CREATE", gettext("Create weblog")); $pagetitle = gettext("Create weblog"); $breadcrumbheader = gettext("Add new weblog"); } 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"])); } } $content->setVariable("VALUE_BACKLINK", $backlink); $content->setVariable("LABEL_NAME", gettext("Name")); $content->setVariable("LABEL_DSC", gettext("Description")); $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_weblog::get_access_descriptions($grp); if ((string) $grp->get_attribute("OBJ_TYPE") == "course") { $access_default = PERMISSION_PUBLIC; } else { $access_default = PERMISSION_PUBLIC_READONLY; if (is_object($weblog) && $creator->get_id() != \lms_steam::get_current_user()->get_id()) { $access[PERMISSION_PRIVATE_READONLY]["label"] = str_replace("%NAME", $creator->get_name(), $access[PERMISSION_PRIVATE_READONLY]["label"]); } else { $access[PERMISSION_PRIVATE_READONLY]["label"] = gettext("Only members can read and comment. Only you can post."); } } 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); //var_dump($rootlink);die; $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication"))); if (isset($weblog) && is_object($weblog)) { $headline[] = array("link" => PATH_URL . "weblog/index/" . $weblog->get_id() . "/", "name" => $weblog->get_name()); } $headline[] = array("link" => "", "name" => $breadcrumbheader); //$portal->set_page_main( $headline, $content->get() ); //$portal->set_page_title( $pagetitle ); //return $portal->get_html(); $frameResponseObject->setHeadline($headline); $frameResponseObject->setTitle($pagetitle); $widget = new \Widgets\RawHtml(); $widget->setHtml($content->get()); $frameResponseObject->addWidget($widget); return $frameResponseObject; }
public function execute(\FrameResponseObject $frameResponseObject) { if (!defined("OBJ_ID")) { define("OBJ_ID", $weblog->get_id()); } $user = \lms_steam::get_current_user(); $STEAM = $GLOBALS["STEAM"]; $weblogId = $this->id; $weblog = \steam_factory::get_object($STEAM->get_id(), $weblogId); if (!defined("OBJ_ID")) { define("OBJ_ID", $weblog->get_id()); } /*if ( ! $weblog = \steam_factory::get_object( $STEAM->get_id(), $_GET[ "id" ] ) ) { include( "bad_link.php" ); exit; }*/ if (!$weblog instanceof \steam_calendar) { if ($weblog instanceof \steam_container) { $category = $weblog; $categories = $category->get_environment(); $weblog = new \steam_weblog((string) $GLOBALS["STEAM"]->get_id(), $categories->get_environment()->get_id()); } elseif ($weblog instanceof \steam_date) { $date = $weblog; $weblog = new \steam_weblog((string) $GLOBALS["STEAM"]->get_id(), $date->get_environment()->get_id()); } else { include "bad_link.php"; exit; } } else { $weblog = new \steam_weblog((string) $GLOBALS["STEAM"]->get_id(), $weblogId); //define( "OBJ_ID", $weblogId ); if (!$weblog->check_access_read($user)) { throw new \Exception("No rights to view this.", E_USER_RIGHTS); } } $object = $weblog; $user = \lms_steam::get_current_user(); if ($_SERVER["REQUEST_METHOD"] == "POST" && $object->check_access_write($user)) { $values = $_POST["values"]; if ($values["delete"]) { $_SESSION["confirmation"] = str_replace("%NAME", h($object->get_name()), gettext("The weblog '%NAME' has been deleted.")); $workroom = $object->get_environment(); \lms_steam::delete($object); // Clean Cache for the deleted Weblog require_once "Cache/Lite.php"; $cache = new \Cache_Lite(array("cacheDir" => PATH_CACHE)); $cache = get_cache_function(OBJ_ID, 600); $cache->drop("lms_steam::get_annotations", OBJ_ID); // Handle Related Cache-Data require_once "Cache/Lite.php"; $cache = new \Cache_Lite(array("cacheDir" => PATH_CACHE)); $cache->clean(OBJ_ID); // clean weblog cache (not used by weblog) // $fcache = get_cache_function( OBJ_ID, 600 ); //$fcache->drop( "lms_forum::get_discussions", OBJ_ID ); // clean cache for Weblog RSS Feed for the Comments (not used by weblog) // $fcache->drop( "lms_steam::get_annotations", OBJ_ID ); // clean rsscache $rcache = get_cache_function("rss", 600); $feedlink = PATH_URL . "services/feeds/weblog_public.php?id=" . OBJ_ID; $rcache->drop("lms_rss::get_items", $feedlink); // Clean communication summary cache für the group/course if (is_object($workroom)) { $cache = get_cache_function(\lms_steam::get_current_user()->get_name(), 600); $cache->drop("lms_steam::get_inventory_recursive", $workroom->get_id(), CLASS_CALENDAR, array("WEBLOG_LANGUAGE")); $cache->drop("lms_steam::get_group_communication_objects", $workroom->get_id(), CLASS_MESSAGEBOARD | CLASS_CALENDAR | CLASS_CONTAINER | CLASS_ROOM); } header("Location: " . $values["return_to"]); exit; } } $content = \Weblog::getInstance()->loadTemplate("object_delete.template.html"); //$content = new HTML_TEMPLATE_IT(); //$content->loadTemplateFile( PATH_TEMPLATES . "object_delete.template.html" ); if ($object->check_access_write($user)) { $content->setVariable("LABEL_ARE_YOU_SURE", str_replace("%NAME", h($object->get_name()), gettext("Are you sure you want to delete the weblog '%NAME' ?"))); $rootlink = \lms_steam::get_link_to_root($object); $content->setVariable("DELETE_BACK_LINK", $rootlink[1]["link"] . "communication/"); $content->setCurrentBlock("BLOCK_DELETE"); $content->setVariable("FORM_ACTION", $_SERVER["REQUEST_URI"]); $content->setVariable("LABEL_DELETE_IT", gettext("yes, delete it")); $content->setVariable("BACK_LINK", $_SERVER["HTTP_REFERER"]); $content->setVariable("LABEL_RETURN", gettext("back")); $content->parse("BLOCK_DELETE"); } else { $content->setVariable("LABEL_ARE_YOU_SURE", gettext("You have no rights to delete this weblog!")); } $content->setVariable("TEXT_INFORMATION", gettext("The weblog and all its entries will be deleted.")); $creator = $object->get_creator(); $creator_data = $creator->get_attributes(array("USER_FULLNAME", "USER_FIRSTNAME", "OBJ_ICON")); $content->setVariable("LABEL_FROM_AND_AGO", str_replace("%N", "<a href=\"" . PATH_URL . "/user/" . $creator->get_name() . "/\">" . h($creator_data["USER_FIRSTNAME"]) . " " . h($creator_data["USER_FULLNAME"]) . "</a>", gettext("by %N")) . "," . how_long_ago($object->get_attribute("OBJ_CREATION_TIME"))); $icon = $creator_data["OBJ_ICON"]; if ($icon instanceof steam_object) { $icon_id = $icon->get_id(); } else { $icon_id = 0; } $content->setVariable("ICON_SRC", PATH_URL . "get_document.php?id=" . $icon_id); $rootlink = \lms_steam::get_link_to_root($object); $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication")), array("link" => "", "name" => h($object->get_name()), "link" => PATH_URL . "weblog/" . $object->get_id() . "/"), array("name" => gettext("Delete weblog"))); $frameResponseObject->setHeadline($headline); $widget = new \Widgets\RawHtml(); $widget->setHtml($content->get()); $frameResponseObject->addWidget($widget); return $frameResponseObject; /*$portal->set_page_main( $headline, $content->get(), "" ); $portal->show_html();*/ }
private static function get_comment_html($document, $url) { $cache = get_cache_function($document->get_id(), 600); $user = \lms_steam::get_current_user(); $write_access = $document->check_access(SANCTION_ANNOTATE, $user); $template = \Weblog::getInstance()->loadTemplate("comments.template.html"); //$template = new HTML_TEMPLATE_IT(); //$template->loadTemplateFile( PATH_TEMPLATES . "comments.template.html" ); $headline = gettext("Add your comment"); if ($_SERVER["REQUEST_METHOD"] == "POST" && $write_access) { $values = $_POST["values"]; if (!empty($values["preview_comment"])) { $template->setCurrentBlock("BLOCK_PREVIEW_COMMENT"); $template->setVariable("TEXT_COMMENT", $values["comment"]); $template->setVariable("PREVIEW", gettext("Preview")); $template->setVariable("POST_COMMENT", gettext("Post comment")); $template->setVariable("LABEL_PREVIEW_YOUR_COMMENT", gettext("Preview your comment")); $template->setVariable("VALUE_PREVIEW_COMMENT", get_formatted_output($values["comment"])); $template->parse("BLOCK_PREVIEW_COMMENT"); $headline = gettext("Change it?"); } if (!empty($values["submit_comment"]) && !empty($values["comment"])) { $new_comment = \steam_factory::create_textdoc($GLOBALS["STEAM"]->get_id(), $user->get_name() . "-" . time(), $values["comment"]); $all_user = \steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), STEAM_ALL_USER); $new_comment->set_acquire($document); $new_comment->set_read_access($all_user); $document->add_annotation($new_comment); $cache->drop("lms_steam::get_annotations", $document->get_id()); } } $comments = $cache->call("lms_steam::get_annotations", $document->get_id()); if (count($comments) > 0) { $template->setVariable("LABEL_COMMENTS", gettext("comments")); } $comments = array_reverse($comments); //reverse comment order (oldest first) //var_dump($comments);die; foreach ($comments as $comment) { $obj_comment = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $comment["OBJ_ID"]); $template->setCurrentBlock("BLOCK_ANNOTATION"); $template->setVariable("COMMENT_ID", $comment["OBJ_ID"]); $template->setVariable("AUTHOR_LINK", PATH_URL . "user/" . $comment["OBJ_CREATOR_LOGIN"] . "/"); $template->setVariable("AUTHOR_NAME", $comment["OBJ_CREATOR"]); $template->setVariable("IMAGE_LINK", PATH_URL . "get_document.php?id=" . $comment["OBJ_ICON"]); $template->setVariable("LABEL_SAYS", gettext("says")); $template->setVariable("ANNOTATION_COMMENT", get_formatted_output($comment["CONTENT"], 80, "\n")); $template->setVariable("HOW_LONG_AGO", how_long_ago($comment["OBJ_CREATION_TIME"])); $template->setVariable('LINK_PERMALINK', $url . '/#comment' . $comment["OBJ_ID"]); $template->setVariable("LABEL_PERMALINK", gettext("permalink")); if ($obj_comment->check_access_write($user)) { $template->setCurrentBlock("BLOCK_OWN_COMMENT"); $template->setVariable("LINK_DELETE", $url . "/deletecomment/" . $comment["OBJ_ID"] . "/"); $template->setVariable("LABEL_DELETE", gettext("delete")); $template->setVariable("LINK_EDIT", $url . "/editcomment/" . $comment["OBJ_ID"] . "/"); $template->setVariable("LABEL_EDIT", gettext("edit")); $template->parse("BLOCK_OWN_COMMENT"); } $template->parse("BLOCK_ANNOTATION"); } if ($write_access) { $template->setCurrentBlock("BLOCK_ADD_COMMENT"); $template->setVariable("LABEL_ADD_YOUR_COMMENT", $headline); $template->setVariable("LABEL_PREVIEW", gettext("Preview")); $template->setVariable("LABEL_OR", gettext("or")); $template->setVariable("LABEL_COMMENT", gettext("Add comment")); $template->setVariable("LABEL_BB_BOLD", gettext("B")); $template->setVariable("HINT_BB_BOLD", gettext("boldface")); $template->setVariable("LABEL_BB_ITALIC", gettext("I")); $template->setVariable("HINT_BB_ITALIC", gettext("italic")); $template->setVariable("LABEL_BB_UNDERLINE", gettext("U")); $template->setVariable("HINT_BB_UNDERLINE", gettext("underline")); $template->setVariable("LABEL_BB_STRIKETHROUGH", gettext("S")); $template->setVariable("HINT_BB_STRIKETHROUGH", gettext("strikethrough")); $template->setVariable("LABEL_BB_IMAGE", gettext("IMG")); $template->setVariable("HINT_BB_IMAGE", gettext("image")); $template->setVariable("LABEL_BB_URL", gettext("URL")); $template->setVariable("HINT_BB_URL", gettext("web link")); $template->setVariable("LABEL_BB_MAIL", gettext("MAIL")); $template->setVariable("HINT_BB_MAIL", gettext("email link")); $template->parse("BLOCK_ADD_COMMENT"); } return $template->get(); }
public function print_entries($date_objects = array(), $show_dates = TRUE) { $t = Weblog::getInstance()->loadTemplate("weblog_entries.template.html"); //$t = new HTML_TEMPLATE_IT(); //$t->loadTemplateFile( PATH_EXTENSIONS . "weblog/ui/html/weblog_entries.template.html" ); $user = lms_steam::get_current_user(); if (count($date_objects) == 0) { $date_objects = $this->get_date_objects(); usort($date_objects, "sort_dates_ascending"); } if (count($date_objects) == 0) { $t->setVariable("LABEL_NO_ENTRY_FOUND", "<h3>" . gettext("No posts yet.") . "</h3>"); $this->set_main_html($t->get()); return NULL; } $ld = 0; // TODO FIX IT !!! $data_tnr = array(); foreach ($date_objects as $date_object) { $data_tnr[$date_object->get_id()] = array(); $data_tnr[$date_object->get_id()]["comments"] = $date_object->get_annotations(FALSE, TRUE); $data_tnr[$date_object->get_id()]["creator"] = $date_object->get_creator(TRUE); $data_tnr[$date_object->get_id()]["is_writer"] = $date_object->check_access_write($user, TRUE); $data_tnr[$date_object->get_id()]["attributes"] = $date_object->get_attributes(array("DATE_TITLE", "DATE_DESCRIPTION", "DATE_START_DATE", "DATE_CATEGORY", "DATE_PODCAST", "OBJ_KEYWORDS"), TRUE); } $data_result = $GLOBALS["STEAM"]->buffer_flush(); $creator = FALSE; $category = FALSE; $creators = array(); $categories = array(); foreach ($date_objects as $date_object) { $creator = $data_result[$data_tnr[$date_object->get_id()]["creator"]]; $creators[$creator->get_id()] = $creator; $category = $data_result[$data_tnr[$date_object->get_id()]["attributes"]]["DATE_CATEGORY"]; if (is_object($category)) { $categories[$category->get_id()] = $category; } } $creator_data = steam_factory::get_attributes($GLOBALS["STEAM"]->get_id(), array_values($creators), array(OBJ_NAME, USER_FIRSTNAME, USER_FULLNAME)); $category_data = steam_factory::get_attributes($GLOBALS["STEAM"]->get_id(), array_values($categories), array(OBJ_NAME)); foreach ($date_objects as $date_object) { $t->setCurrentBlock("BLOCK_ARTICLE"); $entry = $data_result[$data_tnr[$date_object->get_id()]["attributes"]]; $comments = $data_result[$data_tnr[$date_object->get_id()]["comments"]]; $cd = strftime("%G%m%d", $entry["DATE_START_DATE"]); if (($cd != $ld || $ld == 0) && $show_dates) { $t->setCurrentBlock("BLOCK_DATE"); $t->setVariable("VALUE_DATE", strftime("%d. %B %G", $entry["DATE_START_DATE"])); $t->parse("BLOCK_DATE"); } $t->setVariable("VALUE_ARTICLE_SUBJECT", h($entry["DATE_TITLE"])); $t->setVariable("VALUE_ARTICLE_TEXT", get_formatted_output($entry["DATE_DESCRIPTION"])); $creator = $data_result[$data_tnr[$date_object->get_id()]["creator"]]; $t->setVariable("VALUE_POSTED_BY", str_replace("%NAME", "<a href=\"" . PATH_URL . "user/" . $creator_data[$creator->get_id()][OBJ_NAME] . "/\">" . h($creator_data[$creator->get_id()][USER_FIRSTNAME]) . " " . h($creator_data[$creator->get_id()][USER_FULLNAME]) . "</a>", gettext("Posted by %NAME"))); if ($show_dates) { $date_or_time = strftime("%R", $entry["DATE_START_DATE"]); } else { $date_or_time = strftime("%x %R", $entry["DATE_START_DATE"]); } $t->setVariable("VALUE_DATE_TIME", $date_or_time); $t->setVariable('POST_ID', $date_object->get_id()); $t->setVariable('POST_PERMALINK', PATH_URL . 'weblog/' . $this->steam_weblog->get_id() . '/#comment' . $date_object->get_id()); $t->setVariable("POST_PERMALINK_LABEL", gettext("permalink")); if ($data_result[$data_tnr[$date_object->get_id()]["is_writer"]]) { $t->setCurrentBlock("BLOCK_OWN_POST"); $t->setVariable("POST_LINK_DELETE", PATH_URL . "weblog/entrydelete/" . $date_object->get_id() . "/"); $t->setVariable("POST_LABEL_DELETE", gettext("delete")); $t->setVariable("POST_LINK_EDIT", PATH_URL . "weblog/entryedit/" . $date_object->get_id() . "/"); $t->setVariable("POST_LABEL_EDIT", gettext("edit")); $t->parse("BLOCK_OWN_POST"); } $category = $entry["DATE_CATEGORY"]; if (is_object($category)) { $t->setVariable("LABEL_IN", gettext("in")); $t->setVariable("VALUE_CATEGORY", "<a href=\"" . PATH_URL . "weblog/" . $category->get_id() . "/\">" . h($category_data[$category->get_id()][OBJ_NAME]) . "</a>"); } else { $t->setVariable("VALUE_CATEGORY", gettext("no category")); } $t->setVariable("LINK_COMMENTS", PATH_URL . "weblog/comments/" . $date_object->get_id() . "/"); $t->setVariable("LABEL_COMMENTS", count($comments) . " " . (count($comments) == 1 ? gettext("comment") : gettext("comments"))); $t->parse("BLOCK_ARTICLE"); $ld = $cd; } $this->set_main_html($t->get()); }
public function execute(\FrameResponseObject $frameResponseObject) { // $portal = \lms_portal::get_instance(); // $portal->initialize( GUEST_NOT_ALLOWED ); $user = \lms_steam::get_current_user(); //$path = $request->getPath(); $STEAM = $GLOBALS["STEAM"]; $weblogId = $this->id; $weblog = \steam_factory::get_object($STEAM->get_id(), $weblogId); //if ( ! $weblog = steam_factory::get_object( $STEAM->get_id(), $_GET[ "id" ] ) ) //{ // include( "bad_link.php" ); // exit; //} if (!$weblog instanceof \steam_calendar) { if ($weblog instanceof \steam_container) { $category = $weblog; $categories = $category->get_environment(); $weblog = new \steam_weblog($GLOBALS["STEAM"], $categories->get_environment()->get_id()); } elseif ($weblog instanceof \steam_date) { $date = $weblog; $weblog = new \steam_weblog($GLOBALS["STEAM"], $date->get_environment()->get_id()); } else { include "bad_link.php"; exit; } } else { $weblog = new \steam_weblog($GLOBALS["STEAM"]->get_id(), $weblogId); if (!defined("OBJ_ID")) { define("OBJ_ID", $weblogId); } if (!$weblog->check_access_read($user)) { throw new \Exception("No rights to view this.", E_USER_RIGHTS); } } if ($_SERVER["REQUEST_METHOD"] == "POST" && $category->check_access_write($user)) { $values = $_POST["values"]; if ($values["delete"]) { require_once "Cache/Lite.php"; $cache = new \Cache_Lite(array("cacheDir" => PATH_CACHE)); $cache->clean($weblog->get_id()); $link_objects = $category->get_inventory(CLASS_LINK); foreach ($link_objects as $link_object) { $date_object = $link_object->get_source_object(); $link_object->delete(); if ($values["delete_all_dates"]) { $date_object->delete(); } else { $date_object->set_attribute("DATE_CATEGORY", "0"); } } $category->delete(); } header("Location: " . PATH_URL . "weblog/" . $weblog->get_id() . "/"); exit; } $content = \Weblog::getInstance()->loadTemplate("weblog_category_delete.template.html"); //$content = new HTML_TEMPLATE_IT(); //$content->loadTemplateFile( PATH_TEMPLATES . "weblog_category_delete.template.html" ); $content->setVariable("LABEL_ARE_YOU_SURE", gettext("Are you sure you want to delete this category?")); $content->setVariable("NAME_CATEGORY", h($category->get_name())); $content->setVariable("TEXT_CATEGORY", get_formatted_output($category->get_attribute("OBJ_DESC"))); $content->setVariable("LABEL_DELETE_ALL_DATES", str_replace("%NO", count($category->get_inventory(CLASS_LINK)), gettext("Should all %NO entries in this category be deleted, too?"))); $content->setVariable("LABEL_DELETE_IT", gettext("yes, delete it")); $content->setVariable("BACK_LINK", $_SERVER["HTTP_REFERER"]); $content->setVariable("LABEL_RETURN", gettext("back")); $rootlink = \lms_steam::get_link_to_root($weblog); $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication")), array("name" => h($weblog->get_name()), "link" => PATH_URL . "weblog/" . $weblog->get_id() . "/"), array("link" => PATH_URL . "weblog/" . $category->get_id() . "/", "name" => h($category->get_name())), array("link" => "", "name" => str_replace("%NAME", h($category->get_name()), gettext("Delete '%NAME'?")))); /*$portal->set_page_main( $headline, $content->get(), "" ); return $portal->get_html();*/ $frameResponseObject->setHeadline($headline); $widget = new \Widgets\RawHtml(); $widget->setHtml($content->get()); $frameResponseObject->addWidget($widget); return $frameResponseObject; }
public function execute(\FrameResponseObject $frameResponseObject) { // $portal = \lms_portal::get_instance(); // $portal->initialize( GUEST_NOT_ALLOWED ); $user = \lms_steam::get_current_user(); // $path = $request->getPath(); $STEAM = $GLOBALS["STEAM"]; $weblogId = $this->id; $weblog = \steam_factory::get_object($STEAM->get_id(), $weblogId); //if ( ! $weblog = steam_factory::get_object( $STEAM->get_id(), $_GET[ "id" ] ) ) //{ // include( "bad_link.php" ); // exit; //} if (!$weblog instanceof \steam_calendar) { if ($weblog instanceof \steam_container) { $category = $weblog; $categories = $category->get_environment(); $weblog = new \steam_weblog($GLOBALS["STEAM"], $categories->get_environment()->get_id()); } elseif ($weblog instanceof \steam_date) { $date = $weblog; $weblog = new \steam_weblog($GLOBALS["STEAM"], $date->get_environment()->get_id()); } else { include "bad_link.php"; exit; } } else { $weblog = new \steam_weblog($GLOBALS["STEAM"]->get_id(), $weblogId); if (!defined("OBJ_ID")) { define("OBJ_ID", $weblogId); } //define( "OBJ_ID", $weblogId ); if (!$weblog->check_access_read($user)) { throw new \Exception("No rights to view this.", E_USER_RIGHTS); } } $content = \Weblog::getInstance()->loadTemplate("weblog_category_create.template.html"); //$content = new HTML_TEMPLATE_IT(); //$content->loadTemplateFile( PATH_TEMPLATES . "weblog_category_create.template.html" ); $headline = gettext("Create a new weblog category"); if ($_SERVER["REQUEST_METHOD"] == "POST") { $values = $_POST["values"]; if (!empty($values["preview_comment"])) { $content->setCurrentBlock("BLOCK_PREVIEW_COMMENT"); $content->setVariable("TEXT_DSC", get_formatted_output($values["desc"])); $content->setVariable("LABEL_PREVIEW_YOUR_COMMENT", gettext("Preview your description")); $template->parse("BLOCK_PREVIEW_COMMENT"); $headline = gettext("Change it?"); } if (!empty($values["save"]) && !empty($values["desc"]) && !empty($values["title"])) { $category = $weblog->create_category($values["title"], $values["desc"]); header("Location: " . PATH_URL . "weblog/index/" . $category->get_id() . "/"); exit; } else { // PREVIEW $content->setCurrentBlock("BLOCK_PREVIEW"); $content->setVariable("LABEL_PREVIEW_EDIT", gettext("Preview the description")); $content->setVariable("PREVIEW_EDIT", get_formatted_output($values["desc"])); $content->parse("BLOCK_PREVIEW"); $headline = gettext("Change it?"); $content->setVariable("TEXT_DSC", h($values["desc"])); $content->setVariable("TITLE_COMMENT", h($values["title"])); } } $backlink = empty($_POST["values"]["return_to"]) ? $_SERVER["HTTP_REFERER"] : $_POST["values"]["return_to"]; $content->setVariable("BACK_LINK", $backlink); $content->setVariable("POST_NEW_TOPIC_TEXT", $headline); $content->setVariable("GREETING", str_replace("%n", $_SESSION["LMS_USER"]->get_forename(), gettext("Hi %n!"))); $content->setVariable("HELP_TEXT", gettext("By categories, you can find your entries easier than by date.")); $content->setVariable("HINT_TEXT", gettext("Structuring your weblog entries by means of categories makes it much more simple for your readers to find what they are looking for!")); $content->setVariable("LABEL_TITLE", gettext("Title")); $content->setVariable("LABEL_DESC", gettext("Description")); $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")); $content->setVariable("LABEL_PREVIEW", gettext("Preview")); $content->setVariable("LABEL_SAVE_CHANGES", gettext("Save changes")); $content->setVariable("LABEL_RETURN", gettext("back")); $rootlink = \lms_steam::get_link_to_root($weblog); $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication")), array("name" => h($weblog->get_name()), "link" => PATH_URL . "weblog/index/" . $weblog->get_id() . "/"), array("link" => "", "name" => gettext("Create new category"))); /*$portal->set_page_main( $headline, $content->get() ); return $portal->get_html();*/ $frameResponseObject->setHeadline($headline); $widget = new \Widgets\RawHtml(); $widget->setHtml($content->get()); $frameResponseObject->addWidget($widget); return $frameResponseObject; }
public function execute(\FrameResponseObject $frameResponseObject) { //$portal = \lms_portal::get_instance(); //$portal->initialize( GUEST_NOT_ALLOWED ); $user = \lms_steam::get_current_user(); //$path = $request->getPath(); $STEAM = $GLOBALS["STEAM"]; $weblogId = $this->params[0]; $weblog = \steam_factory::get_object($STEAM->get_id(), $weblogId); //if ( ! $weblog = steam_factory::get_object( $STEAM->get_id(), $_GET[ "id" ] ) ) //{ // include( "bad_link.php" ); // exit; //} if (!$weblog instanceof \steam_calendar) { if ($weblog instanceof \steam_container) { $category = $weblog; $categories = $category->get_environment(); $weblog = new \steam_weblog($GLOBALS["STEAM"]->get_id(), $categories->get_environment()->get_id()); } elseif ($weblog instanceof \steam_date) { $date = $weblog; $weblog = new \steam_weblog($GLOBALS["STEAM"]->get_id(), $date->get_environment()->get_id()); } else { include "bad_link.php"; exit; } } else { $weblog = new \steam_weblog($GLOBALS["STEAM"]->get_id(), $weblogId); define("OBJ_ID", $weblogId); if (!$weblog->check_access_read($user)) { throw new \Exception("No rights to view this.", E_USER_RIGHTS); } } $date = $weblog; //if(!isset($date)) //throw new \Exception("variable date is not set."); //if ( $_SERVER[ "REQUEST_METHOD" ] == "POST" && $date->check_access_write( $user ) ) if (false) { $values = $_POST["values"]; if (!isset($values["delete"])) { $values["delete"] = false; } if ($values["delete"]) { require_once "Cache/Lite.php"; $cache = new Cache_Lite(array("cacheDir" => PATH_CACHE)); $cache->clean($weblog->get_id()); $cache->clean($date->get_id()); $trashbin = $GLOBALS["STEAM"]->get_current_steam_user(); if (is_object($trashbin)) { $date->move($trashbin); } else { $date->delete(); } } header("Location: " . $values["return_to"]); exit; } if ($_SERVER["REQUEST_METHOD"] == "POST") { //echo "hund"; $values = $_POST["values"]; $problem = ""; $hint = ""; if (isset($values["save"])) { $values["save"] = true; } else { $values["save"] = false; } if ($values["save"]) { if (empty($values["url"])) { $problem = gettext("The URL is missing.") . " "; $hint = gettext("Please insert the URL, starting with 'http://'") . " "; } if (empty($values["name"])) { $problem .= gettext("The name is missing."); $hint .= gettext("How is the title of the webpage?"); } else { if (strpos($values["name"], "/")) { if (!isset($problem)) { $problem = ""; } $problem .= gettext("Please don't use the \"/\"-char in the name of the blogroll entry."); } } if (empty($problem)) { $environment = $weblog->get_blogroll(); if (!is_object($environment)) { throw new \Exception("Environment is not correct."); } if (!$environment instanceof \steam_container) { throw new \Exception("Environment is no container."); } if (!$environment->check_access_write($user)) { throw new \Exception("No write access on this container.", E_USER_RIGHTS); } if (empty($problem)) { $docextern = \steam_factory::create_docextern($GLOBALS["STEAM"]->get_id(), $values["name"], $values["url"], $environment, $values["desc"]); header("Location: " . $values["return_to"]); exit; } else { //TODO: PROBDESC //$portal->set_problem_description( $problem, $hint ); } } else { //TODO: PROBDESC //$portal->set_problem_description( $problem, $hint ); } } } $content = \Weblog::getInstance()->loadTemplate("weblog_blogroll.template.html"); //$content = new HTML_TEMPLATE_IT(); //$content->loadTemplatefile( PATH_TEMPLATES . "weblog_blogroll.template.html" ); if (!empty($problem)) { $content->setVariable("VALUE_NAME", $values["name"]); $content->setVariable("VALUE_URL", $values["url"]); $content->setVariable("VALUE_DESC", $values["desc"]); } $content->setVariable("GREETING", str_replace("%n", $_SESSION["LMS_USER"]->get_forename(), gettext("Hi %n!"))); $help_text = "<b>" . gettext("What is a blogroll?") . "</b> " . gettext("A blogroll is a collection of links to other weblogs.") . " " . gettext("When present, blogrolls are on the front page sidebar of most weblogs.") . " " . gettext("Some blogrolls also simply consist of the list of weblogs an author reads himself."); $content->setVariable("HELP_TEXT", $help_text); $content->setVariable("YOUR_BLOGROLL_TEXT", gettext("Your Blogroll")); $content->setVariable("CREATE_NEW_LINK_TEXT", gettext("Create new Link")); $content->setVariable("FORM_ACTION", ""); //PATH_URL . "docextern_create.php" ); $content->setVariable("ENVIRONMENT", $weblog->get_blogroll()->get_id()); $content->setVariable("LABEL_NAME", gettext("Name")); $content->setVariable("LABEL_URL", gettext("URL")); $content->setVariable("LABEL_DESCRIPTION", gettext("Description")); $content->setVariable("LABEL_SAVE_CHANGES", gettext("Save changes")); $content->setVariable("LABEL_BACK", gettext("back")); $content->setVariable("LINK_BACK", PATH_URL . "weblog/index/" . $weblog->get_id() . "/"); $blogroll = $weblog->get_blogroll_list(); foreach ($blogroll as $link) { if (!$link instanceof \steam_docextern) { continue; } $content->setCurrentBlock("BLOCK_LINK"); $content->setVariable("LINK_URL", $link->get_url()); $content->setVariable("LINK_NAME", h($link->get_name())); $content->setVariable("LINK_DESC", h($link->get_attribute("OBJ_DESC"))); $content->setVariable("LABEL_EDIT", gettext("edit")); $content->setVariable("LINK_EDIT", PATH_URL . "docextern/" . $link->get_id() . "/edit/"); $content->setVariable("LINK_DELETE", PATH_URL . "docextern/" . $link->get_id() . "/delete/"); $content->setVariable("LABEL_DELETE", gettext("delete")); $content->parse("BLOCK_LINK"); } $rootlink = \lms_steam::get_link_to_root($weblog); $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication")), array("name" => h($weblog->get_name()), "link" => PATH_URL . "weblog/" . $weblog->get_id() . "/"), array("link" => "", "name" => gettext("Edit Blogroll"))); //$portal->set_page_main( //$headline, //$content->get() //); //return $portal->get_html(); $frameResponseObject->setHeadline($headline); $widget = new \Widgets\RawHtml(); $widget->setHtml($content->get()); $frameResponseObject->addWidget($widget); return $frameResponseObject; }
public function execute(\FrameResponseObject $frameResponseObject) { // $portal = \lms_portal::get_instance(); // $portal->initialize( GUEST_NOT_ALLOWED ); $user = \lms_steam::get_current_user(); // $path = $request->getPath(); $STEAM = $GLOBALS["STEAM"]; $weblogId = $this->id; $weblog = \steam_factory::get_object($STEAM->get_id(), $weblogId); //if ( ! $weblog = steam_factory::get_object( $STEAM->get_id(), $_GET[ "id" ] ) ) //{ // include( "bad_link.php" ); // exit; //} if (!$weblog instanceof \steam_calendar) { if ($weblog instanceof \steam_container) { $category = $weblog; $categories = $category->get_environment(); $weblog = new \steam_weblog($GLOBALS["STEAM"], $categories->get_environment()->get_id()); } elseif ($weblog instanceof \steam_date) { $date = $weblog; $weblog = new \steam_weblog($GLOBALS["STEAM"], $date->get_environment()->get_id()); } else { include "bad_link.php"; exit; } } else { $weblog = new \steam_weblog($GLOBALS["STEAM"]->get_id(), $weblogId); define("OBJ_ID", $weblogId); if (!$weblog->check_access_read($user)) { throw new \Exception("No rights to view this.", E_USER_RIGHTS); } } $podspace = $weblog->get_podspace(); if (!$podspace->check_access_write($user)) { throw new \Exception($user->get_name() . " has no write acces on podspace " . $podscace->get_id(), E_USER_RIGHTS); } if ($_SERVER["REQUEST_METHOD"] == "POST") { $values = $_POST["values"]; $problem = ""; $hint = ""; if (!empty($values["file_id"])) { // ALTER AN EXISTING DOCUMENT } else { // UPLOAD A NEW DOCUMENT if (!empty($values["desc"])) { $problem .= gettext("Please describe the file.") . " "; $hint .= ""; } $new_file = $podspace->upload("FILE_TO_UPLOAD"); } } $content = \Weblog::getInstance()->loadTemplate("weblog_podcast.template.html"); //$content = new HTML_TEMPLATE_IT(); //$content->loadTemplatefile( PATH_TEMPLATES . "weblog_podcast.template.html" ); $content->setVariable("GREETING", str_replace("%n", $_SESSION["LMS_USER"]->get_forename(), gettext("Hi %n!"))); if (empty($_GET["file"])) { $content->touchBlock("BLOCK_UPLOAD"); } $help_text = "<b>" . gettext("What is podcasting?") . "</b> " . gettext("Podcasting is the method of distributing multimedia files, such as audio programs, over the Internet using syndication feeds, for playback on mobile decices and personal computers."); $help_text .= "<br/><br/>" . gettext("The podcast is also available as a webfolder:") . " <a href=\"https://" . STEAM_SERVER . $podspace->get_path() . "\">WebDAV Mountpoint</a>"; $content->setVariable("HELP_TEXT", $help_text); $content->setVariable("YOUR_PODSCPACE_TEXT", gettext("Your Podspace")); $content->setVariable("UPLOAD_NEW_FILE_TEXT", gettext("Upload a multimedia file")); $content->setVariable("PODSPACE", $podspace->get_id()); $content->setVariable("LABEL_FILE", gettext("File")); $content->setVariable("LABEL_DESCRIPTION", gettext("Description")); $content->setVariable("LABEL_KEYWORDS", gettext("Keywords")); $content->setVariable("LABEL_SAVE_CHANGES", gettext("Save changes")); $content->setVariable("BACK_LINK", PATH_URL . "weblog/" . $weblog->get_id() . "/podspace/"); $content->setVariable("YOUR_PODSPACE_TEXT", gettext("Your Podspace")); $files_in_podspace = $podspace->get_inventory(CLASS_DOCUMENT); if (count($files_in_podspace) == 0) { $content->setCurrentBlock("BLOCK_EMPTY_PODSPACE"); $content->setVariable("NO_FILES_LABEL", gettext("no files found")); $content->parse("BLOCK_EMPTY_PODSPACE"); } foreach ($files_in_podspace as $file) { if (!$file instanceof \steam_document) { continue; } $content->setCurrentBlock("BLOCK_FILE"); $content->setVariable("FILE_NAME", h($file->get_name())); $content->setVariable("FILE_SIZE", get_formatted_filesize($file->get_content_size())); $content->setVariable("FILE_DESC", h($file->get_attribute("OBJ_DESC"))); $content->setVariable("LABEL_EDIT", gettext("edit")); $content->setVariable("LABEL_OR", gettext("or")); $content->setVariable("LABEL_DELETE", gettext("delete")); $content->parse("BLOCK_FILE"); } $rootlink = \lms_steam::get_link_to_root($weblog); $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication")), array("name" => h($weblog->get_name()), "link" => PATH_URL . "weblog/" . $weblog->get_id() . "/"), array("link" => "", "name" => gettext("Podcasting"))); /*$portal->set_page_main( $headline, $content->get() ); return $portal->get_html();*/ $frameResponseObject->setHeadline($headline); $widget = new \Widgets\RawHtml(); $widget->setHtml($content->get()); $frameResponseObject->addWidget($widget); return $frameResponseObject; }