public function recent_drafts($drafts = false) { ?> <h2><?php _e('Recent Drafts', 'ktai_style'); ?> </h2> <?php if (!$drafts) { $drafts_query = new WP_Query(array('post_type' => 'post', 'what_to_show' => 'posts', 'post_status' => 'draft', 'author' => $GLOBALS['current_user']->ID, 'posts_per_page' => 5, 'orderby' => 'modified', 'order' => 'DESC')); $drafts =& $drafts_query->posts; } if ($drafts && is_array($drafts)) { global $Ktai_Style; echo '<dl>'; foreach ($drafts as $draft) { $url = get_edit_post_link($draft->ID, 'url'); $title = $this->admin->draft_or_post_title($draft->ID); echo '<dt>'; ks_ordered_link($this->accesskey++, 10, $url, $title); _ks_timestamp(get_the_time('U', $draft)); echo '</dt>'; if ($the_content = ks_cut_html(strip_tags($draft->post_content), KTAI_DRAFT_LENGTH)) { echo '<dd>' . $the_content . '</dd>'; } } ?> </dl> <div align="right"><img localsrc="63" alt="→" /><a href="edit.php?post_status=draft"><?php _e('View all', 'ktai_style'); ?> </a></div> <?php } else { ?> <p><?php _e('There are no drafts at the moment', 'ktai_style'); ?> </p> <?php } return; }
public function split_page($buffer, $page_num) { if ($page_num > self::MAX_PAGE_NUM) { $page_num = self::MAX_PAGE_NUM; } elseif ($page_num < 1) { $page_num = 1; } list($header, $buffer, $footer, $sep) = $this->separate_buffer($buffer); if (preg_match('/<input type="hidden" name="post_password" value="(.*?)"/s', $buffer, $match)) { $post_password = $match[1]; } else { $post_password = ''; } list($navi, $del_accesskey) = $this->get_split_page_navi(self::MAX_PAGE_NUM + 1, true, $post_password); $page_size = $this->base->get('page_size') - strlen($header . $navi . '<hr /><hr />' . $navi . $footer) - 32; // 32-byte is space for adding tags by force_balance_tags() if ($page_size < 256) { // too small if (preg_match('@<body[^>]*>@s', $header, $s, PREG_OFFSET_CAPTURE)) { $move2body = substr_replace($header, '', 0, $s[0][1] + strlen($s[0][0])); $header = substr_replace($header, '', $s[0][1] + strlen($s[0][0])); } else { $move2body = $header; $header = ''; } $buffer = $move2body . $buffer . $footer; $footer = ''; $page_size = $this->base->get('page_size') - strlen($header . $navi . '<hr /><hr />' . $navi . $footer) - 32; } $start_tags = ''; $terminator = '<!--KTAI_TERMINATOR_' . md5(uniqid()) . '-->'; $marker = 0; $buffer_length = strlen($buffer); for ($count = 0; $count < $page_num; $count++) { $fragment = ks_cut_html($buffer, $page_size, $marker, $this->base->get('charset')); $fragment = preg_replace('/\\x1b\\$[GEFOPQ]?$/', '', $fragment); if (preg_match('/(\\x1b\\$[GEFOPQ])[!-z]+$/', $fragment, $pict_sequence)) { $complemention = ""; // complete softbank pictgram shift-in } else { $complemention = ''; } $quoted = str_replace(array("<", ">"), array("<", ">"), $start_tags . $fragment . $terminator); // protect softbank pictograms $balanced = force_balance_tags($quoted); preg_match("/{$terminator}(.*)\$/", $balanced, $added_html); $complemented = preg_replace('/\\x1b\\$[GEFOPQ]?\\x1b/', '', $start_tags . $fragment . $complemention . @$added_html[1]); if (preg_match_all('!</([^<>]*)>!', @$added_html[1], $added_tags)) { $start_tags = '<' . implode('><', array_reverse($added_tags[1])) . '>'; // store complemented tags to next fragment if (strpos($start_tags, '<ol>') !== false) { $start_tags = $this->detect_nesting_list($balanced, $start_tags); } $start_tags .= isset($pict_sequence[1]) ? $pict_sequence[1] : ''; } else { $start_tags = isset($pict_sequence[1]) ? $pict_sequence[1] : ''; } $marker += strlen($fragment); if ($marker >= $buffer_length) { $count++; break; } } if (strlen($fragment) < $buffer_length && isset($added_html[1])) { list($navi, $del_accesskey) = $this->get_split_page_navi($count, $marker + 1 < $buffer_length, $post_password); if ($del_accesskey) { // delete redundant access keys $complemented = preg_replace('/(<(a|label)[^>]*?) accesskey="[' . $del_accesskey . ']"([^>]*?)>/', '$1$3>', $complemented); } return $header . $sep['start']['before'] . $navi . $sep['start']['after'] . $complemented . $sep['end']['before'] . $navi . $sep['end']['after'] . $footer; } else { return $header . $buffer . $footer; } }
function ks_get_content($more_link_text = '(more...)', $stripteaser = 0, $more_file = '', $strip_length = 0) { global $id, $post, $more, $single, $page, $pages, $numpages; global $pagenow; $output = ''; $need_password = ks_check_password(); if ($need_password) { return $need_password; } if ($more_file != '') { $file = $more_file; } else { $file = $pagenow; } //$_SERVER['PHP_SELF']; if ($page > count($pages)) { // if the requested page doesn't exist $page = count($pages); } // give them the highest numbered page that DOES exist $content = $pages[$page - 1]; if (preg_match('/<!--more(.*?)?-->/', $content, $matches)) { $content = explode($matches[0], $content, 2); if (!empty($matches[1]) && !empty($more_link_text)) { $more_link_text = strip_tags(wp_kses_no_null(trim($matches[1]))); } } else { $content = array($content); } if (false !== strpos($post->post_content, '<!--noteaser-->') && (!$multipage || $page == 1)) { $stripteaser = 1; } $teaser = $content[0]; if ($more && $stripteaser) { $teaser = ''; } $output .= $teaser; if (count($content) > 1) { if ($more) { if (ks_applied_appl_xhtml()) { $output .= '<span name="more-' . $id . '"></span>' . $content[1]; } else { $output .= '<a name="more-' . $id . '"></a>' . $content[1]; } } else { $output = balanceTags($output); if (!empty($more_link_text)) { $output .= apply_filters('the_content_more_link', sprintf(' <a href="%s#more-%d">%s</a>', get_permalink(), $id, $more_link_text), $more_link_text); } } } elseif ($strip_length && strlen($output) > $strip_length) { $output = ks_cut_html($output, $strip_length, 0, get_bloginfo('charset')); $output .= empty($more_link_text) ? apply_filters('excerpt_more', '[...]') : sprintf('<span><a href="%1$s#more-%2$d">%3$s</a></span>', get_permalink(), $id, $more_link_text); $output = force_balance_tags($output); } return $output; }