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; }
/** ---------------------------------------- /** Show search results /** ----------------------------------------*/ function search_results() { global $IN, $DB, $TMPL, $LANG, $FNS, $OUT, $LOC, $PREFS, $REGX; /** ---------------------------------------- /** Fetch the search language file /** ----------------------------------------*/ $LANG->fetch_language_file('search'); /** ---------------------------------------- /** Check search ID number /** ----------------------------------------*/ // If the QSTR variable is less than 32 characters long we // don't have a valid search ID number if (strlen($IN->QSTR) < 32) { return $OUT->show_user_error('off', array($LANG->line('search_no_result')), $LANG->line('search_result_heading')); } /** ---------------------------------------- /** Clear old search results /** ----------------------------------------*/ $expire = time() - $this->cache_expire * 3600; $DB->query("DELETE FROM exp_search WHERE site_id = '" . $DB->escape_str($PREFS->ini('site_id')) . "' AND search_date < '{$expire}'"); /** ---------------------------------------- /** Fetch ID number and page number /** ----------------------------------------*/ // We cleverly disguise the page number in the ID hash string $cur_page = 0; if (strlen($IN->QSTR) == 32) { $search_id = $IN->QSTR; } else { $search_id = substr($IN->QSTR, 0, 32); $cur_page = substr($IN->QSTR, 32); } /** ---------------------------------------- /** Fetch the cached search query /** ----------------------------------------*/ $query = $DB->query("SELECT * FROM exp_search WHERE search_id = '" . $DB->escape_str($search_id) . "'"); if ($query->num_rows == 0 or $query->row['total_results'] == 0) { return $OUT->show_user_error('off', array($LANG->line('search_no_result')), $LANG->line('search_result_heading')); } $fields = $query->row['custom_fields'] == '' ? array() : unserialize(stripslashes($query->row['custom_fields'])); $sql = unserialize(stripslashes($query->row['query'])); $sql = str_replace('MDBMPREFIX', 'exp_', $sql); $per_page = $query->row['per_page']; $res_page = $query->row['result_page']; /** ---------------------------------------- /** Run the search query /** ----------------------------------------*/ $query = $DB->query(preg_replace("/SELECT(.*?)\\s+FROM\\s+/is", 'SELECT COUNT(*) AS count FROM ', $sql)); if ($query->row['count'] == 0) { return $OUT->show_user_error('off', array($LANG->line('search_no_result')), $LANG->line('search_result_heading')); } /** ---------------------------------------- /** Calculate total number of pages /** ----------------------------------------*/ $current_page = $cur_page / $per_page + 1; $total_pages = intval($query->row['count'] / $per_page); if ($query->row['count'] % $per_page) { $total_pages++; } $page_count = $LANG->line('page') . ' ' . $current_page . ' ' . $LANG->line('of') . ' ' . $total_pages; /** ----------------------------- /** Do we need pagination? /** -----------------------------*/ // If so, we'll add the LIMIT clause to the SQL statement and run the query again $pager = ''; if ($query->row['count'] > $per_page) { if (!class_exists('Paginate')) { require PATH_CORE . 'core.paginate' . EXT; } $PGR = new Paginate(); $PGR->path = $FNS->create_url($res_page . '/' . $search_id, 0, 0); $PGR->total_count = $query->row['count']; $PGR->per_page = $per_page; $PGR->cur_page = $cur_page; $pager = $PGR->show_links(); $sql .= " LIMIT " . $cur_page . ", " . $per_page; } $query = $DB->query($sql); $output = ''; if (!class_exists('Weblog')) { require PATH_MOD . '/weblog/mod.weblog' . EXT; } unset($TMPL->var_single['auto_path']); unset($TMPL->var_single['excerpt']); unset($TMPL->var_single['id_auto_path']); unset($TMPL->var_single['full_text']); unset($TMPL->var_single['switch']); foreach ($TMPL->var_single as $key => $value) { if (substr($key, 0, strlen('member_path')) == 'member_path') { unset($TMPL->var_single[$key]); } } $weblog = new Weblog(); // This allows the weblog {absolute_count} variable to work $weblog->p_page = $per_page * $current_page - $per_page; $weblog->fetch_custom_weblog_fields(); $weblog->fetch_custom_member_fields(); $weblog->query = $DB->query($sql); if ($weblog->query->num_rows == 0) { return $TMPL->no_results(); } if (!class_exists('Typography')) { require PATH_CORE . 'core.typography' . EXT; } $weblog->TYPE = new Typography(); $weblog->TYPE->convert_curly = FALSE; $weblog->TYPE->encode_email = FALSE; $weblog->fetch_categories(); $weblog->parse_weblog_entries(); $tagdata = $TMPL->tagdata; // Does the tag contain "related entries" that we need to parse out? if (count($TMPL->related_data) > 0 and count($weblog->related_entries) > 0) { $weblog->parse_related_entries(); } if (count($TMPL->reverse_related_data) > 0 and count($weblog->reverse_related_entries) > 0) { $weblog->parse_reverse_related_entries(); } $output = $weblog->return_data; $TMPL->tagdata = $tagdata; /** ----------------------------- /** Fetch member path variable /** -----------------------------*/ // We do it here in case it's used in multiple places. $m_paths = array(); if (preg_match_all("/" . LD . "member_path(\\s*=.*?)" . RD . "/s", $TMPL->tagdata, $matches)) { for ($j = 0; $j < count($matches['0']); $j++) { $m_paths[] = array($matches['0'][$j], $FNS->extract_path($matches['1'][$j])); } } /** ----------------------------- /** Fetch switch param /** -----------------------------*/ $switch1 = ''; $switch2 = ''; if ($switch = $TMPL->fetch_param('switch')) { if (strpos($switch, '|') !== FALSE) { $x = explode("|", $switch); $switch1 = $x['0']; $switch2 = $x['1']; } else { $switch1 = $switch; } } /** ----------------------------- /** Result Loop - Legacy! /** -----------------------------*/ $i = 0; foreach ($query->result as $row) { if (isset($row['field_id_' . $row['search_excerpt']]) and $row['field_id_' . $row['search_excerpt']]) { $format = !isset($row['field_ft_' . $row['search_excerpt']]) ? 'xhtml' : $row['field_ft_' . $row['search_excerpt']]; $full_text = $weblog->TYPE->parse_type(strip_tags($row['field_id_' . $row['search_excerpt']]), array('text_format' => $format, 'html_format' => 'safe', 'auto_links' => 'y', 'allow_img_url' => 'n')); $excerpt = strip_tags($full_text); $excerpt = trim(preg_replace("/(\r\n)|(\r)|(\n)/", " ", $excerpt)); $excerpt = $FNS->word_limiter($excerpt, 50); } else { $excerpt = ''; $full_text = ''; } // Parse permalink path $url = $row['search_results_url'] != '' ? $row['search_results_url'] : $row['blog_url']; $path = $FNS->remove_double_slashes($REGX->prep_query_string($url) . '/' . $row['url_title'] . '/'); $idpath = $FNS->remove_double_slashes($REGX->prep_query_string($url) . '/' . $row['entry_id'] . '/'); $switch = $i++ % 2 ? $switch1 : $switch2; $output = preg_replace("/" . LD . 'switch' . RD . "/", $switch, $output, sizeof(explode(LD . 'switch' . RD, $TMPL->tagdata)) - 1); $output = preg_replace("/" . LD . 'auto_path' . RD . "/", $path, $output, sizeof(explode(LD . 'auto_path' . RD, $TMPL->tagdata)) - 1); $output = preg_replace("/" . LD . 'id_auto_path' . RD . "/", $idpath, $output, sizeof(explode(LD . 'id_auto_path' . RD, $TMPL->tagdata)) - 1); $output = preg_replace("/" . LD . 'excerpt' . RD . "/", preg_quote($excerpt), $output, sizeof(explode(LD . 'excerpt' . RD, $TMPL->tagdata)) - 1); $output = preg_replace("/" . LD . 'full_text' . RD . "/", preg_quote($full_text), $output, sizeof(explode(LD . 'full_text' . RD, $TMPL->tagdata)) - 1); // Parse member_path if (count($m_paths) > 0) { foreach ($m_paths as $val) { $output = preg_replace("/" . $val['0'] . "/", $FNS->create_url($val['1'] . '/' . $row['member_id']), $output, 1); } } } $TMPL->tagdata = $output; /** ---------------------------------------- /** Parse variables /** ----------------------------------------*/ $swap = array('lang:total_search_results' => $LANG->line('search_total_results'), 'lang:search_engine' => $LANG->line('search_engine'), 'lang:search_results' => $LANG->line('search_results'), 'lang:search' => $LANG->line('search'), 'lang:title' => $LANG->line('search_title'), 'lang:weblog' => $LANG->line('search_weblog'), 'lang:excerpt' => $LANG->line('search_excerpt'), 'lang:author' => $LANG->line('search_author'), 'lang:date' => $LANG->line('search_date'), 'lang:total_comments' => $LANG->line('search_total_comments'), 'lang:recent_comments' => $LANG->line('search_recent_comment_date'), 'lang:keywords' => $LANG->line('search_keywords')); $TMPL->template = $FNS->var_swap($TMPL->template, $swap); /** ---------------------------------------- /** Add Pagination /** ----------------------------------------*/ if ($pager == '') { $TMPL->template = preg_replace("/" . LD . "if paginate" . RD . ".*?" . LD . "/if" . RD . "/s", '', $TMPL->template); } else { $TMPL->template = preg_replace("/" . LD . "if paginate" . RD . "(.*?)" . LD . "/if" . RD . "/s", "\\1", $TMPL->template); } $TMPL->template = str_replace(LD . 'paginate' . RD, $pager, $TMPL->template); $TMPL->template = str_replace(LD . 'page_count' . RD, $page_count, $TMPL->template); return stripslashes($TMPL->tagdata); }
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) { // $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; }
$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 vxBlogCommentApprove() { $return = $_SERVER['HTTP_REFERER']; if ($this->User->vxIsLogin()) { if (isset($_GET['comment_id'])) { $comment_id = intval($_GET['comment_id']); $sql = "SELECT bec_id, bec_eid FROM babel_weblog_entry_comment WHERE bec_id = {$comment_id}"; $rs = mysql_query($sql); if ($_comment = mysql_fetch_array($rs)) { mysql_free_result($rs); $sql = "SELECT bge_id, bge_uid, bge_pid FROM babel_weblog_entry WHERE bge_id = " . $_comment['bec_eid']; $rs = mysql_query($sql); $_entry = mysql_fetch_array($rs); mysql_free_result($rs); if ($_entry['bge_uid'] == $this->User->usr_id) { $time = time(); $sql = "UPDATE babel_weblog_entry_comment SET bec_status = 1, bec_approved = {$time} WHERE bec_id = " . $comment_id; mysql_unbuffered_query($sql); $Entry = new Entry($_entry['bge_id']); $Entry->vxUpdateComments(); $Weblog = new Weblog($_entry['bge_pid']); $Weblog->vxSetDirty(); $_SESSION['babel_message_weblog'] = '刚才通过了 ID 为 <strong>' . $comment_id . '</strong> 的评论,需要进行重新构建'; URL::vxToRedirect(URL::vxGetBlogModerate($_entry['bge_id'])); } else { return js_alert('你没有权力对这个博客网站进行操作', '/blog/admin.vx'); } } else { mysql_free_result($rs); return js_alert('指定的评论没有找到', $return); } } else { return js_alert('指定的评论没有找到', $return); } } else { return js_alert('你还没有登录,请登录之后再进行操作', $return); } }
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();*/ }
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 static function vxBuild($user_id, $weblog_id) { $start = microtime(true); $Weblog = new Weblog($weblog_id); if ($start - $Weblog->blg_lastbuilt < BABEL_WEBLOG_BUILD_INTERVAL) { $_SESSION['babel_message_weblog'] = _vo_ico_silk('clock') . ' 距离上次构建时间尚不足 ' . BABEL_WEBLOG_BUILD_INTERVAL . ' 秒,本次操作取消,请等待 ' . (BABEL_WEBLOG_BUILD_INTERVAL - intval($start - $Weblog->blg_lastbuilt)) . ' 秒之后再试验'; } else { require_once BABEL_PREFIX . '/libs/textile/classTextile.php'; require_once BABEL_PREFIX . '/libs/markdown/markdown.php'; require_once BABEL_PREFIX . '/libs/htmlpurifier/library/HTMLPurifier.auto.php'; $purifier_config = HTMLPurifier_Config::createDefault(); $purifier_config->set('Core', 'Encoding', 'UTF-8'); $purifier_config->set('HTML', 'Doctype', 'XHTML 1.0 Transitional'); $purifier = new HTMLPurifier($purifier_config); $Textile = new Textile(); $bytes = 0; $files = 0; /* check user home directory */ $usr_dir = BABEL_WEBLOG_PREFIX . '/' . BABEL_WEBLOG_WWWROOT . '/' . $Weblog->blg_name; if (!file_exists($usr_dir)) { mkdir($usr_dir); } /* clean old files */ foreach (glob($usr_dir . '/*.html') as $filename) { unlink($filename); } foreach (glob($usr_dir . '/*.css') as $filename) { unlink($filename); } foreach (glob($usr_dir . '/*.rss') as $filename) { unlink($filename); } $s = new Smarty(); $s->template_dir = BABEL_PREFIX . '/res/weblog/themes/' . $Weblog->blg_theme; if (!is_dir(BABEL_PREFIX . '/tplc/' . $Weblog->blg_theme)) { mkdir(BABEL_PREFIX . '/tplc/' . $Weblog->blg_theme); } $s->compile_dir = BABEL_PREFIX . '/tplc/' . $Weblog->blg_theme; $s->cache_dir = BABEL_PREFIX . '/cache/smarty'; $s->config_dir = BABEL_PREFIX . '/cfg'; $s->assign('ico_feed', 'http://' . BABEL_WEBLOG_SITE_STATIC . '/img/icons/silk/feed.png'); $s->assign('site_theme', $Weblog->blg_theme); $s->assign('site_static', BABEL_WEBLOG_SITE_STATIC); $s->assign('site_babel', BABEL_DNS_NAME); $s->assign('site_weblog_root', 'http://' . BABEL_WEBLOG_SITE . '/' . $Weblog->blg_name . '/'); $s->assign('site_url', 'http://' . BABEL_WEBLOG_SITE . '/' . $Weblog->blg_name . '/'); $s->assign('site_title', make_plaintext($Weblog->blg_title)); $s->assign('site_description', make_plaintext($Weblog->blg_description)); $s->assign('site_category', make_plaintext(Vocabulary::site_name)); $s->assign('site_lang', 'en'); $s->assign('license_show', $Weblog->blg_license_show); $s->assign('license_code', Weblog::vxGetLicenseCode($Weblog->blg_license)); $s->assign('built', date('Y-n-j G:i:s T', time())); $s->assign('user_nick', $Weblog->usr_nick); $s->assign('user_nick_plain', make_plaintext($Weblog->usr_nick)); $s->assign('user_nick_url', urlencode($Weblog->usr_nick)); $s->assign('user_brief_plain', make_plaintext($Weblog->usr_brief)); $s->assign('user_created_plain_short', date('n/j/Y', $Weblog->usr_created)); if ($Weblog->usr_portrait == '') { $s->assign('user_portrait', '/img/p_' . $Weblog->usr_gender . '.gif'); $s->assign('user_portrait_s', '/img/p_' . $Weblog->usr_gender . '_s.gif'); $s->assign('user_portrait_n', '/img/p_' . $Weblog->usr_gender . '_n.gif'); } else { $s->assign('user_portrait', '/img/p/' . $Weblog->usr_portrait . '.' . BABEL_PORTRAIT_EXT); $s->assign('user_portrait_s', '/img/p/' . $Weblog->usr_portrait . '_s.' . BABEL_PORTRAIT_EXT); $s->assign('user_portrait_n', '/img/p/' . $Weblog->usr_portrait . '_n.' . BABEL_PORTRAIT_EXT); } $s->assign('user_ing', $Weblog->blg_ing); $s->assign('google_analytics', '<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script><script type="text/javascript">_uacct = "UA-841322-3"; urchinTracker();</script>'); $sql = "SELECT DISTINCT bet_tag FROM babel_weblog_entry_tag WHERE bet_eid IN (SELECT bge_id FROM babel_weblog_entry WHERE bge_pid = {$Weblog->blg_id}) ORDER BY bet_tag ASC"; $rs = mysql_query($sql); $_tags = array(); while ($_tag = mysql_fetch_array($rs)) { $_tags[] = $_tag; } mysql_free_result($rs); $s->assign('tags', $_tags); $links = array(); foreach ($Weblog->blg_links as $category) { $category['category'] = str_replace('\\|', '|', $category['category']); $category_md5 = md5($category['category']); if (count($category['links']) > 0) { $links[$category_md5] = array(); $links[$category_md5]['category'] = make_plaintext($category['category']); $links[$category_md5]['links'] = array(); foreach ($category['links'] as $link) { $link['title'] = str_replace('\\|', '|', $link['title']); $link_md5 = md5($link['url']); $links[$category_md5]['links'][$link_md5] = array(); $links[$category_md5]['links'][$link_md5]['title'] = make_plaintext($link['title']); $links[$category_md5]['links'][$link_md5]['url'] = make_plaintext($link['url']); } } } $s->assign('links', $links); if ($Weblog->blg_theme == 'cloud') { $sql_order = "ASC"; $sql_limit_index = ""; } else { $sql_order = "DESC"; $sql_limit_index = "LIMIT 10"; } /* S: index.smarty */ $sql = "SELECT bge_id, bge_title, bge_body, bge_mode, bge_tags, bge_comments, bge_trackbacks, bge_comment_permission, bge_published, usr_id, usr_nick FROM babel_weblog_entry, babel_user WHERE bge_uid = usr_id AND bge_uid = {$Weblog->usr_id} AND bge_pid = {$Weblog->blg_id} AND bge_status = 1 ORDER BY bge_published {$sql_order} {$sql_limit_index}"; $rs = mysql_query($sql); $entries_count = mysql_num_rows($rs); $_entries = array(); $_ids = array(); $i = 0; while ($_entry = mysql_fetch_array($rs)) { $i++; $_entries[$_entry['bge_id']] = $_entry; $_ids[$i] = $_entry['bge_id']; if ($i == 1) { $_entries[$_entry['bge_id']]['first'] = 1; } else { $_entries[$_entry['bge_id']]['first'] = 0; } if ($i == $entries_count) { $_entries[$_entry['bge_id']]['last'] = 1; } else { $_entries[$_entry['bge_id']]['last'] = 0; } if ($_entries[$_entry['bge_id']]['first'] == 0 && $_entries[$_entry['bge_id']]['first'] == 1) { $_entries[$_entry['bge_id']]['middle'] = 1; } else { $_entries[$_entry['bge_id']]['middle'] = 0; } $_entries[$_entry['bge_id']]['url'] = 'http://' . BABEL_WEBLOG_SITE . '/' . $Weblog->blg_name . '/entry-' . $_entry['bge_id'] . '.html'; $_entries[$_entry['bge_id']]['url_url'] = urlencode($_entries[$_entry['bge_id']]['url']); $_entries[$_entry['bge_id']]['bge_title_plain'] = make_plaintext($_entry['bge_title']); $_entries[$_entry['bge_id']]['bge_title_url'] = urlencode($_entry['bge_title']); $_entries[$_entry['bge_id']]['usr_nick_plain'] = make_plaintext($_entry['usr_nick']); $_entries[$_entry['bge_id']]['usr_nick_url'] = urlencode($_entry['usr_nick']); $_entries[$_entry['bge_id']]['bge_published_plain'] = date('Y-n-j G:i:s T', $_entry['bge_published']); switch (intval($_entry['bge_mode'])) { case 0: // plain text $_entries[$_entry['bge_id']]['bge_body_plain'] = make_plaintext(trim($_entry['bge_body'])); break; case 1: // html $_entries[$_entry['bge_id']]['bge_body_plain'] = $purifier->purify($_entry['bge_body']); break; case 2: // ubb $_entries[$_entry['bge_id']]['bge_body_plain'] = format_ubb($_entry['bge_body']); break; case 3: // textile $_entries[$_entry['bge_id']]['bge_body_plain'] = $purifier->purify($Textile->TextileThis($_entry['bge_body'])); break; case 4: // $_entries[$_entry['bge_id']]['bge_body_plain'] = $purifier->purify(Markdown($_entry['bge_body'])); break; } $_entries[$_entry['bge_id']]['bge_body_plain_rss'] = htmlspecialchars($_entries[$_entry['bge_id']]['bge_body_plain']); if ($_entry['bge_tags'] == '') { $_entries[$_entry['bge_id']]['bge_tags_plain'] = ''; $_entries[$_entry['bge_id']]['bge_tags_plain_comma'] = ''; } else { $_entries[$_entry['bge_id']]['bge_tags_plain'] = Weblog::vxMakeTagLink($_entry['bge_tags']); $_entries[$_entry['bge_id']]['bge_tags_plain_comma'] = Weblog::vxMakeTagLinkComma($_entry['bge_tags']); } $_entries[$_entry['bge_id']]['bge_published_plain_short'] = date('m/d/Y', $_entry['bge_published']); $_entries[$_entry['bge_id']]['bge_published_plain_long'] = date('m/d/Y H:i:s T', $_entry['bge_published']); } mysql_free_result($rs); $i = 0; foreach ($_ids as $num => $id) { $i++; $next = $i + 1; $prev = $i - 1; if (isset($_ids[$next])) { $_entries[$id]['next'] = $_ids[$next]; } else { $_entries[$id]['next'] = 0; } if (isset($_ids[$prev])) { $_entries[$id]['prev'] = $_ids[$prev]; } else { $_entries[$id]['prev'] = 0; } } $s->assign('entries', $_entries); $file_index = $usr_dir . '/index.html'; $o_index = $s->fetch('index.smarty'); $files++; $bytes += file_put_contents($file_index, $o_index); $file_feed_main = $usr_dir . '/index.rss'; $o_feed_main = $s->fetch('feed.smarty'); $files++; $bytes += file_put_contents($file_feed_main, $o_feed_main); /* E: index.smarty */ /* S: tag.smarty */ foreach ($_tags as $tag) { $s->assign('tag_cur', $tag['bet_tag']); $tag_sql = mysql_real_escape_string($tag['bet_tag']); $sql = "SELECT bge_id, bge_title, bge_body, bge_tags, bge_comments, bge_trackbacks, bge_mode, bge_comment_permission, bge_published, usr_id, usr_nick FROM babel_weblog_entry, babel_user WHERE bge_uid = usr_id AND bge_uid = {$Weblog->usr_id} AND bge_pid = {$Weblog->blg_id} AND bge_status = 1 AND bge_id IN (SELECT bet_eid FROM babel_weblog_entry_tag WHERE bet_tag = '{$tag_sql}') ORDER BY bge_published {$sql_order}"; $rs = mysql_query($sql); $_entries = array(); $i = 0; while ($_entry = mysql_fetch_array($rs)) { $i++; $_entries[$_entry['bge_id']] = $_entry; $_entries[$_entry['bge_id']]['url'] = 'http://' . BABEL_WEBLOG_SITE . '/' . $Weblog->blg_name . '/entry-' . $_entry['bge_id'] . '.html'; $_entries[$_entry['bge_id']]['url_url'] = urlencode($_entries[$_entry['bge_id']]['url']); $_entries[$_entry['bge_id']]['bge_title_plain'] = make_plaintext($_entry['bge_title']); $_entries[$_entry['bge_id']]['bge_title_url'] = urlencode($_entry['bge_title']); $_entries[$_entry['bge_id']]['usr_nick_plain'] = make_plaintext($_entry['usr_nick']); $_entries[$_entry['bge_id']]['usr_nick_url'] = urlencode($_entry['usr_nick']); $_entries[$_entry['bge_id']]['bge_published_plain'] = date('Y-n-j G:i:s T', $_entry['bge_published']); switch (intval($_entry['bge_mode'])) { case 0: // plain text $_entries[$_entry['bge_id']]['bge_body_plain'] = make_plaintext(trim($_entry['bge_body'])); break; case 1: // html $_entries[$_entry['bge_id']]['bge_body_plain'] = $purifier->purify($_entry['bge_body']); break; case 2: // ubb $_entries[$_entry['bge_id']]['bge_body_plain'] = format_ubb($_entry['bge_body']); break; case 3: // textile $_entries[$_entry['bge_id']]['bge_body_plain'] = $purifier->purify($Textile->TextileThis($_entry['bge_body'])); break; case 4: // $_entries[$_entry['bge_id']]['bge_body_plain'] = $purifier->purify(Markdown($_entry['bge_body'])); break; } $_entries[$_entry['bge_id']]['bge_body_plain_rss'] = htmlspecialchars($_entries[$_entry['bge_id']]['bge_body_plain']); if ($_entry['bge_tags'] == '') { $_entries[$_entry['bge_id']]['bge_tags_plain'] = ''; } else { $_entries[$_entry['bge_id']]['bge_tags_plain'] = Weblog::vxMakeTagLink($_entry['bge_tags']); } if ($_entry['bge_tags'] == '') { $_entries[$_entry['bge_id']]['bge_tags_plain_comma'] = ''; } else { $_entries[$_entry['bge_id']]['bge_tags_plain_comma'] = Weblog::vxMakeTagLinkComma($_entry['bge_tags']); } $_entries[$_entry['bge_id']]['bge_published_plain_short'] = date('m/d/Y', $_entry['bge_published']); $_entries[$_entry['bge_id']]['bge_published_plain_long'] = date('m/d/Y H:i:s T', $_entry['bge_published']); } mysql_free_result($rs); $s->assign('entries', $_entries); $s->assign('count_tag_cur', $i); $file_tag = $usr_dir . '/tag-' . $tag['bet_tag'] . '.html'; $o_tag = $s->fetch('tag.smarty'); $files++; $bytes += file_put_contents($file_tag, $o_tag); $file_feed_tag = $usr_dir . '/tag-' . $tag['bet_tag'] . '.rss'; $o_feed_tag = $s->fetch('feed_tag.smarty'); $files++; $bytes += file_put_contents($file_feed_tag, $o_feed_tag); } /* E: tag.smarty */ /* S: entry.smarty */ $sql = "SELECT bge_id, bge_title, bge_body, bge_tags, bge_comments, bge_trackbacks, bge_mode, bge_comment_permission, bge_published, usr_id, usr_nick FROM babel_weblog_entry, babel_user WHERE bge_uid = usr_id AND bge_uid = {$Weblog->usr_id} AND bge_pid = {$Weblog->blg_id} AND bge_status = 1 ORDER BY bge_published {$sql_order}"; $rs = mysql_query($sql); $i = 0; while ($_entry = mysql_fetch_array($rs)) { $i++; $next = $i + 1; $prev = $i - 1; if (isset($_ids[$next])) { $_entry['next'] = $_ids[$next]; } else { $_entry['next'] = 0; } if (isset($_ids[$prev])) { $_entry['prev'] = $_ids[$prev]; } else { $_entry['prev'] = 0; } $_entry['url'] = 'http://' . BABEL_WEBLOG_SITE . '/' . $Weblog->blg_name . '/entry-' . $_entry['bge_id'] . '.html'; $_entry['url_url'] = urlencode($_entry['url']); $_entry['bge_title_plain'] = make_plaintext($_entry['bge_title']); $_entry['bge_title_url'] = urlencode($_entry['bge_title']); $_entry['usr_nick_plain'] = make_plaintext($_entry['usr_nick']); $_entry['usr_nick_url'] = urlencode($_entry['usr_nick']); $_entry['bge_body_plain'] = make_plaintext($_entry['bge_body']); $_entry['bge_published_plain'] = date('Y-n-j G:i:s T', $_entry['bge_published']); switch (intval($_entry['bge_mode'])) { case 0: // plain text $_entry['bge_body_plain'] = make_plaintext(trim($_entry['bge_body'])); break; case 1: // html $_entry['bge_body_plain'] = $purifier->purify($_entry['bge_body']); break; case 2: // ubb $_entry['bge_body_plain'] = format_ubb($_entry['bge_body']); break; case 3: // textile $_entry['bge_body_plain'] = $purifier->purify($Textile->TextileThis($_entry['bge_body'])); break; case 4: // $_entry['bge_body_plain'] = $purifier->purify(Markdown($_entry['bge_body'])); break; } if ($_entry['bge_tags'] == '') { $_entry['bge_tags_plain'] = ''; } else { $_entry['bge_tags_plain'] = Weblog::vxMakeTagLink($_entry['bge_tags']); } if ($_entry['bge_tags'] == '') { $_entry['bge_tags_plain_comma'] = ''; } else { $_entry['bge_tags_plain_comma'] = Weblog::vxMakeTagLinkComma($_entry['bge_tags']); } $_entry['bge_published_plain_short'] = date('m/d/Y', $_entry['bge_published']); $_entry['bge_published_plain_long'] = date('m/d/Y H:i:s T', $_entry['bge_published']); $file_entry = $usr_dir . '/entry-' . $_entry['bge_id'] . '.html'; $s->assign('entry', $_entry); $o_entry = $s->fetch('entry.smarty'); $files++; $bytes += file_put_contents($file_entry, $o_entry); } /* style.smarty */ $file_style = $usr_dir . '/style.css'; $s->left_delimiter = '['; $s->right_delimiter = ']'; $o_style = $s->fetch('style.smarty'); $files++; $bytes += file_put_contents($file_style, $o_style); $s->left_delimiter = '{'; $s->right_delimiter = '}'; $Weblog->vxAddBuild(); $Weblog->vxTouchBuild(); $Weblog->vxUpdateComments(); // Ping Ping-o-Matic /* require_once('Zend/Http/Client.php'); $blg_url_url = urlencode('http://' . BABEL_WEBLOG_SITE . '/' . $Weblog->blg_name . '/'); $blg_title_url = urlencode($Weblog->blg_title); $ping = 'http://pingomatic.com/ping/?title=' . $blg_title_url . '&blogurl=' . $blg_url_url . '&rssurl=&chk_weblogscom=on&chk_blogs=on&chk_technorati=on&chk_feedburner=on&chk_newsgator=on&chk_feedster=on&chk_myyahoo=on&chk_blogstreet=on&chk_icerocket=on'; $client = new Zend_Http_Client($ping, array('timeout' => 15)); try { $client->request(); } catch (Exception $e) { } */ $end = microtime(true); $elapsed = $end - $start; $_SESSION['babel_message_weblog'] = _vo_ico_silk('tick') . ' 博客网站 ' . make_plaintext($Weblog->blg_title) . ' 基于 ' . $Weblog->blg_theme . ' 主题重新构建成功,' . $files . ' 个文件共写入了 ' . $bytes . ' 字节,共耗时 <small>' . $elapsed . '</small> 秒,<a href="http://' . BABEL_WEBLOG_SITE . '/' . $Weblog->blg_name . '/?.rand=' . rand(11, 99) . '" class="t" target="_blank">现在查看</a> <img src="/img/ext.png" align="absmiddle" />'; } }
/** ----------------------------------- /** Parse Forms that Cannot Be Cached /** -----------------------------------*/ function parse_nocache($str) { global $FNS; if (!stristr($str, '{NOCACHE')) { return $str; } /** ----------------------------------- /** Generate Comment Form if needed /** -----------------------------------*/ // In order for the comment form not to cache the "save info" // data we need to generate dynamically if necessary if (preg_match_all("#{NOCACHE_(\\S+)_FORM=\"(.*?)\"}(.+?){/NOCACHE_FORM}#s", $str, $match)) { for ($i = 0, $s = sizeof($match['0']); $i < $s; $i++) { $class = $FNS->filename_security(strtolower($match['1'][$i])); if (!class_exists($class)) { require PATH_MOD . $class . '/mod.' . $class . EXT; } $this->tagdata = $match['3'][$i]; $vars = $FNS->assign_variables($match['3'][$i], '/'); $this->var_single = $vars['var_single']; $this->var_pair = $vars['var_pair']; $this->tagparams = $FNS->assign_parameters($match['2'][$i]); $this->var_cond = $FNS->assign_conditional_variables($match['3'][$i], '/', LD, RD); // Assign sites for the tag $this->_fetch_site_ids(); if ($class == 'gallery') { $str = str_replace($match['0'][$i], Gallery::comment_form(TRUE, $FNS->cached_captcha), $str); } elseif ($class == 'comment') { $str = str_replace($match['0'][$i], Comment::form(TRUE, $FNS->cached_captcha), $str); } $str = str_replace('{PREVIEW_TEMPLATE}', $match['2'][$i], $str); } } /** ----------------------------------- /** Generate Stand-alone Publish form /** -----------------------------------*/ if (preg_match_all("#{{NOCACHE_WEBLOG_FORM(.*?)}}(.+?){{/NOCACHE_FORM}}#s", $str, $match)) { for ($i = 0, $s = sizeof($match['0']); $i < $s; $i++) { if (!class_exists('Weblog')) { require PATH_MOD . 'weblog/mod.weblog' . EXT; } $this->tagdata = $match['2'][$i]; $vars = $FNS->assign_variables($match['2'][$i], '/'); $this->var_single = $vars['var_single']; $this->var_pair = $vars['var_pair']; $this->tagparams = $FNS->assign_parameters($match['1'][$i]); // Assign sites for the tag $this->_fetch_site_ids(); $XX = new Weblog(); $str = str_replace($match['0'][$i], $XX->entry_form(TRUE, $FNS->cached_captcha), $str); $str = str_replace('{PREVIEW_TEMPLATE}', isset($_POST['PRV']) ? $_POST['PRV'] : $this->fetch_param('preview'), $str); } } /** ----------------------------------- /** Generate Trackback hash if needed /** -----------------------------------*/ if (preg_match("#{NOCACHE_TRACKBACK_HASH}#s", $str, $match)) { if (!class_exists('Trackback')) { require PATH_MOD . 'trackback/mod.trackback' . EXT; } $str = str_replace($match['0'], Trackback::url(TRUE, $FNS->random('alpha', 8)), $str); } return $str; }
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 vxBlogEditSave($rt) { $Entry =& $rt['Entry']; $_modes = Weblog::vxGetEditorModes(); $_comment_permissions = Weblog::vxGetCommentPermissions(); $Weblog = new Weblog($Entry->bge_pid); if ($Entry->bge_published != 0) { $published_date = date('Y-n-j', $Entry->bge_published); $published_time = date('G:i:s', $Entry->bge_published); } else { $published_date = date('Y-n-j', time()); $published_time = date('G:i:s', time()); } _v_m_s(); echo '<link type="text/css" rel="stylesheet" href="/css/themes/' . BABEL_THEME . '/css_weblog.css" />'; _v_b_l_s(); _v_ico_map(); echo ' <a href="/">' . Vocabulary::site_name . '</a> > ' . $this->User->usr_nick_plain . ' > <a href="/blog/admin.vx">博客网志</a> > <a href="/blog/' . Weblog::DEFAULT_ACTION . '/' . $Weblog->blg_id . '.vx">' . make_plaintext($Weblog->blg_title) . '</a> > ' . make_plaintext($Entry->bge_title) . ' > 编辑文章 <span class="tip_i"><small>alpha</small></span>'; _v_d_e(); _v_b_l_s(); echo '<div align="left"><table cellpadding="5" cellspacing="" border="0" class="form">'; echo '<form action="/blog/edit/save/' . $Entry->bge_id . '.vx" method="post" id="form_blog_edit">'; echo '<tr><td colspan="2" align="left"><h1 class="ititle">'; _v_ico_tango_32('actions/document-new'); echo ' 撰写新文章</h1> <span class="tip_i">刚才提交的数据中有些问题需要修正</span></td></tr>'; echo '<tr><td colspan="2" align="right"><input onfocus="brightBox(this);" onblur="dimBox(this);" type="text" class="sllt" name="bge_title" value="' . make_single_return($rt['bge_title_value'], 0) . '" />'; if ($rt['bge_title_error'] > 0) { echo '<br /><span class="tip_i">' . _vo_ico_silk('exclamation') . ' ' . $rt['bge_title_error_msg'][$rt['bge_title_error']] . '</span>'; } echo '</td></tr>'; echo '<tr><td colspan="2" align="right"><textarea class="ml" rows="30" name="bge_body" style="width: 550px;">' . make_multi_return($rt['bge_body_value'], 0) . '</textarea>'; if ($rt['bge_body_error'] > 0) { echo '<br /><span class="tip_i">' . _vo_ico_silk('exclamation') . ' ' . $rt['bge_body_error_msg'][$rt['bge_body_error']] . '</span>'; } echo '</td></tr>'; echo '<tr><td width="100" align="right">格式</td><td align="left">'; echo '<select name="bge_mode">'; foreach ($_modes as $key => $mode) { if ($rt['bge_mode_value'] == $key) { echo '<option value="' . $key . '" selected="selected">' . $mode . '</option>'; } else { echo '<option value="' . $key . '">' . $mode . '</option>'; } } echo '</select>'; echo '</td></tr>'; echo '<tr><td width="100" align="right">评论许可</td><td align="left">'; echo '<select name="bge_comment_permission">'; foreach ($_comment_permissions as $key => $mode) { if ($rt['bge_comment_permission_value'] == $key) { echo '<option value="' . $key . '" selected="selected">' . $mode . '</option>'; } else { echo '<option value="' . $key . '">' . $mode . '</option>'; } } echo '</select>'; echo '</td></tr>'; echo '<tr><td width="100" align="right">标签</td><td align="left"><input onfocus="brightBox(this);" onblur="dimBox(this);" type="text" class="sll" name="bge_tags" value="" /></td></tr>'; echo '<tr><td width="100" align="right">状态</td><td align="left">'; echo '<select name="bge_status">'; if ($rt['bge_status_value'] == 1) { echo '<option value="0">草稿</option>'; echo '<option value="1" selected="selected">公开发布</option>'; } else { echo '<option value="0" selected="selected">草稿</option>'; echo '<option value="1">公开发布</option>'; } echo '</select>'; echo '</td></tr>'; echo '<tr><td width="100" align="right">发布时间</td><td align="left"><input onfocus="brightBox(this);" onblur="dimBox(this);" type="text" class="sl" name="bge_published_date" value="' . $published_date . '" /> <input onfocus="brightBox(this);" onblur="dimBox(this);" type="text" class="sl" name="bge_published_time" value="' . $published_time . '" /></td></tr>'; echo '<tr><td colspan="2" valign="middle" align="right" class="toolbar">'; echo '<input type="submit" value="保存" class="btn_white" /> '; echo '<input type="button" value="取消" class="btn_white" onclick="location.href=' . "'/blog/list/{$Weblog->blg_id}.vx'" . ';" /> '; echo '<input type="button" value="删除" class="btn_white" onclick="if (confirm(' . "'确认删除?'" . ')) { location.href = ' . "'/blog/erase/24.vx'" . '; } else { return false; }" />'; echo '</td></tr>'; echo '</form>'; echo '</table></div>'; _v_d_e(); _v_d_e(); }
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 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; }
function _build_query() { global $TMPL, $DB, $LOC; // Do something awesome $allowed_params = array('by', 'weblog', 'author_id', 'category', 'category_group', 'entry_id_from', 'entry_id_to', 'group_id', 'show_expired', 'show_future_entries', 'status', 'start_on', 'stop_before', 'uncategorized_entries', 'username'); foreach ($TMPL->tagparams as $param => $val) { if (!in_array($param, $allowed_params)) { unset($TMPL->tagparams[$param]); } } $TMPL->tagparams['dynamic'] = 'off'; if (!class_exists('Weblog')) { require PATH_MOD . 'weblog/mod.weblog.php'; } $W = new Weblog(); $W->build_sql_query(); if ($W->sql == '') { return $TMPL->no_results(); } $this->query = $DB->query($W->sql); if ($this->query->num_rows == 0) { return $TMPL->no_results(); } foreach ($this->query->result as $entry) { $loc = $LOC->set_localized_time($entry['entry_date']); $day = intval(date('d', $loc)); $month = intval(date('m', $loc)); $year = intval(date('Y', $loc)); switch ($this->by) { default: case 'day': $this->periods[] = mktime(0, 0, 0, $month, $day, $year); break; case 'month': $this->periods[] = mktime(0, 0, 0, $month, 1, $year); break; case 'year': $this->periods[] = mktime(0, 0, 0, 1, 1, $year); break; } } $this->periods = array_unique($this->periods); rsort($this->periods); $cnt = count($this->periods) - 1; $currIndex = array_search($this->current, $this->periods); if ($currIndex === false) { $this->periods[] = $this->current; $this->periods = array_unique($this->periods); rsort($this->periods); $currIndex = array_search($this->current, $this->periods); } $this->oldest = isset($this->periods[$cnt]) && $this->periods[$cnt] != $this->current ? $this->periods[$cnt] : 0; $this->older = isset($this->periods[$currIndex + 1]) ? $this->periods[$currIndex + 1] : 0; $this->newer = isset($this->periods[$currIndex - 1]) ? $this->periods[$currIndex - 1] : 0; $this->newest = isset($this->periods[0]) && $this->periods[0] != $this->current ? $this->periods[0] : 0; }
die($p->URL->vxToRedirect($p->URL->vxGetLogin($p->URL->vxGetBlogEdit($entry_id)))); } else { die($p->URL->vxToRedirect($p->URL->vxGetLogin($p->URL->vxGetBlogAdmin()))); } break; } else { if (isset($_GET['entry_id'])) { $entry_id = intval($_GET['entry_id']); if (Weblog::vxMatchEntryPermission($p->User->usr_id, $entry_id)) { $Entry = new Entry($entry_id); $rt = $p->Validator->vxBlogComposeCheck(); $rt['Entry'] =& $Entry; if ($rt['errors'] == 0) { $p->Validator->vxBlogEditUpdate($entry_id, $p->User->usr_id, $rt['bge_title_value'], $rt['bge_body_value'], $rt['bge_mode_value'], $rt['bge_comment_permission_value'], $rt['bge_status_value'], $rt['published'], $Entry->bge_status, $rt['bge_tags_value']); if (intval($rt['bge_status_value']) == 1) { $Weblog = new Weblog($Entry->bge_pid); $Weblog->vxSetDirty(); } die($p->URL->vxToRedirect($p->URL->vxGetBlogList($Entry->bge_pid))); break; } else { $p->vxHead($msgSiteTitle = '编辑文章'); $p->vxBodyStart(); $p->vxTop(); $p->vxContainer('blog_edit_save', $rt); break; } } else { $_SESSION['babel_message_weblog'] = '你没有权力对这个博客网站进行操作'; die($p->URL->vxToRedirect($p->URL->vxGetBlogAdmin())); }
public function vxBlogCommentCheck() { $rt = array(); $rt['errors'] = 0; /* bec_nick (max: 20) */ $rt['bec_nick_value'] = ''; $rt['bec_nick_maxlength'] = 20; $rt['bec_nick_error'] = 0; $rt['bec_nick_error_msg'] = array(1 => 'You forget to write something', 2 => "It's too lengthy"); if (isset($_POST['bec_nick'])) { $rt['bec_nick_value'] = fetch_single($_POST['bec_nick']); if ($rt['bec_nick_value'] == '') { $rt['errors']++; $rt['bec_nick_error'] = 1; } else { if (mb_strlen($rt['bec_nick_value'], 'UTF-8') > $rt['bec_nick_maxlength']) { $rt['errors']++; $rt['bec_nick_error'] = 2; } } } else { $rt['errors']++; $rt['bec_nick_error'] = 1; } /* bec_email (max: 100) */ $rt['bec_email_value'] = ''; $rt['bec_email_maxlength'] = 100; $rt['bec_email_error'] = 0; $rt['bec_email_error_msg'] = array(1 => 'You forget to leave your E-mail', 2 => "It's too lengthy", "Your E-mail address format is incorrect"); if (isset($_POST['bec_email'])) { $rt['bec_email_value'] = fetch_single($_POST['bec_email']); if ($rt['bec_email_value'] == '') { $rt['errors']++; $rt['bec_email_error'] = 1; } else { if (mb_strlen($rt['bec_email_value'], 'UTF-8') > $rt['bec_email_maxlength']) { $rt['errors']++; $rt['bec_email_error'] = 2; } else { if (!is_valid_email($rt['bec_email_value'])) { $rt['errors']++; $rt['bec_email_error'] = 3; } } } } else { $rt['errors']++; $rt['bec_email_error'] = 1; } /* bec_url (max: 200) */ $rt['bec_url_value'] = ''; $rt['bec_url_maxlength'] = 200; $rt['bec_url_error'] = 0; $rt['bec_url_error_msg'] = array(2 => "It's too lengthy", "Your URL format is incorrect"); if (isset($_POST['bec_url'])) { $rt['bec_url_value'] = fetch_single($_POST['bec_url']); if ($rt['bec_url_value'] != '') { if (mb_strlen($rt['bec_url_value'], 'UTF-8') > $rt['bec_url_maxlength']) { $rt['errors']++; $rt['bec_url_error'] = 2; } else { if (!is_valid_url($rt['bec_url_value'])) { $rt['errors']++; $rt['bec_url_error'] = 3; } } } } /* bec_body (max: 2000) */ $rt['bec_body_value'] = ''; $rt['bec_body_maxlength'] = 2000; $rt['bec_body_error'] = 0; $rt['bec_body_error_msg'] = array(1 => 'You forget to write something', 2 => "It's too lengthy"); if (isset($_POST['bec_body'])) { $rt['bec_body_value'] = Weblog::vxFilterComment(fetch_multi($_POST['bec_body'])); if ($rt['bec_body_value'] == '') { $rt['errors']++; $rt['bec_body_error'] = 1; } else { if (mb_strlen($rt['bec_body_value'], 'UTF-8') > $rt['bec_body_maxlength']) { $rt['errors']++; $rt['bec_body_error'] = 2; } } } else { $rt['errors']++; $rt['bec_body_error'] = 1; } return $rt; }