/** * Displays link for replying to the Comment if blog's setting allows this action * * @param string to display before link * @param string to display after link * @param string link text * @param string link title * @param string class name */ function reply_link($before = ' ', $after = ' ', $text = '#', $title = '#', $class = '') { if (!is_logged_in(false)) { return false; } if (empty($this->ID)) { // Happens in Preview return false; } $this->get_Item(); $this->Item->load_Blog(); if (!$this->Item->Blog->get_setting('threaded_comments')) { // A blog's setting is OFF for replying to the comment return false; } if (!$this->Item->can_comment()) { // The comments are disabled return false; } // ID of a replying comment $comment_reply_ID = param('reply_ID', 'integer', 0); if ($text == '#') { // Use default text $text = $this->ID == $comment_reply_ID ? T_('You are currently replying to this comment') : T_('Reply to this comment'); } if ($title == '#') { // Use default title $title = T_('Reply to this comment'); } $class .= ' comment_reply'; if ($this->ID == $comment_reply_ID) { // This comment is using for replying now $class .= ' active'; } $class = ' class="' . trim($class) . '"'; $url = url_add_param($this->Item->get_permanent_url(), 'reply_ID=' . $this->ID . '&redir=no') . '#form_p' . $this->Item->ID; echo $before; // Display a link echo '<a href="' . $url . '" title="' . $title . '"' . $class . ' rel="' . $this->ID . '">' . $text . '</a>'; echo $after; return true; }
break; default: $title = T_('New post'); break; } $AdminUI->breadcrumbpath_add($title, '?ctrl=items&action=new&blog=' . $Blog->ID . '&item_typ_ID=' . $item_typ_ID); $AdminUI->title_titlearea = $title . ': '; // Params we need for tab switching: $tab_switch_params = 'blog=' . $blog; break; case 'copy': // Duplicate post $item_ID = param('p', 'integer', true); $ItemCache =& get_ItemCache(); $edited_Item =& $ItemCache->get_by_ID($item_ID); $edited_Item->load_Blog(); $item_status = $edited_Item->Blog->get_allowed_item_status(); $edited_Item->set('status', $item_status); $edited_Item->set('dateset', 0); // Date not explicitly set yet $edited_Item->set('issue_date', date('Y-m-d H:i:s', $localtimenow)); // Set post comment status and extracats $post_comment_status = $edited_Item->get('comment_status'); $post_extracats = postcats_get_byID($p); // Check if new category was started to create. If yes then set up parameters for next page check_categories_nosave($post_category, $post_extracats); // Page title: switch ($edited_Item->ptyp_ID) { case 1000: $title = T_('Duplicate page'); break;
/** * Prepare the 'In-skin editing'. * */ function init_inskin_editing() { global $Blog, $edited_Item, $action, $form_action; global $item_tags, $item_title, $item_content; global $admin_url, $redirect_to, $advanced_edit_link; if (!$Blog->get_setting('in_skin_editing')) { // Redirect to the Back-office editing (setting is OFF) header_redirect($admin_url . '?ctrl=items&action=new&blog=' . $Blog->ID); } $tab_switch_params = 'blog=' . $Blog->ID; // Post ID, go from $_GET when we edit post from Front-office $post_ID = param('p', 'integer', 0); // Post ID, go from $_GET when we copy post from Front-office $copy_post_ID = param('cp', 'integer', 0); if ($post_ID > 0) { // Edit post global $post_extracats; $action = 'edit'; $ItemCache =& get_ItemCache(); $edited_Item = $ItemCache->get_by_ID($post_ID); check_categories_nosave($post_category, $post_extracats); $post_extracats = postcats_get_byID($post_ID); $redirect_to = url_add_param($admin_url, 'ctrl=items&filter=restore&blog=' . $Blog->ID . '&highlight=' . $edited_Item->ID, '&'); $tab_switch_params .= '&p=' . $edited_Item->ID; } elseif ($copy_post_ID > 0) { // Copy post global $localtimenow; $action = 'new'; $ItemCache =& get_ItemCache(); $edited_Item = $ItemCache->get_by_ID($copy_post_ID); $edited_Item_Blog = $edited_Item->get_Blog(); $item_status = $edited_Item_Blog->get_allowed_item_status(); $edited_Item->set('status', $item_status); $edited_Item->set('dateset', 0); // Date not explicitly set yet $edited_Item->set('issue_date', date('Y-m-d H:i:s', $localtimenow)); modules_call_method('constructor_item', array('Item' => &$edited_Item)); check_categories_nosave($post_category, $post_extracats); $redirect_to = url_add_param($admin_url, 'ctrl=items&filter=restore&blog=' . $Blog->ID, '&'); } elseif (empty($action)) { // Create new post (from Front-office) $action = 'new'; load_class('items/model/_item.class.php', 'Item'); $edited_Item = new Item(); $def_status = get_highest_publish_status('post', $Blog->ID, false); $edited_Item->set('status', $def_status); check_categories_nosave($post_category, $post_extracats); $edited_Item->set('main_cat_ID', $Blog->get_default_cat_ID()); // Set default locations from current user $edited_Item->set_creator_location('country'); $edited_Item->set_creator_location('region'); $edited_Item->set_creator_location('subregion'); $edited_Item->set_creator_location('city'); // Set object params: $edited_Item->load_from_Request(false, true); $redirect_to = url_add_param($admin_url, 'ctrl=items&filter=restore&blog=' . $Blog->ID, '&'); } // Used in the edit form: // We never allow HTML in titles, so we always encode and decode special chars. $item_title = htmlspecialchars_decode($edited_Item->title); if ($Blog->get_setting('allow_html_post')) { // HTML is allowed for this post, we have HTML in the DB and we can edit it: $item_content = $edited_Item->content; } else { // HTML is disallowed for this post, content is encoded in DB and we need to decode it for editing: $item_content = htmlspecialchars_decode($edited_Item->content); } // Format content for editing, if we were not already in editing... $Plugins_admin =& get_Plugins_admin(); $edited_Item->load_Blog(); $params = array('object_type' => 'Item', 'object_Blog' => &$edited_Item->Blog); $Plugins_admin->unfilter_contents($item_title, $item_content, $edited_Item->get_renderers_validated(), $params); $item_tags = implode(', ', $edited_Item->get_tags()); // Get an url for a link 'Go to advanced edit screen' $mode_editing = param('mode_editing', 'string', 'expert'); $entries = get_item_edit_modes($Blog->ID, $action, $admin_url, $tab_switch_params); $advanced_edit_link = $entries[$mode_editing]; $form_action = get_samedomain_htsrv_url() . 'item_edit.php'; }