# Entradas $entrada = new ab_entryTable(); $entrada->readEnv(); #$entrada->limit = ENTRY; #$entrada->offset = (($pg>1)?(($pg-1)*$entrada->limit):0); if ($_REQUEST['m']) { $period = strftime("%B/%Y", strtotime($_REQUEST['y'] . '-' . $_REQUEST['m'] . '-01')); $range_filter = "extract(month from ab_entry.creation) = " . $_REQUEST['m'] . " AND extract(year from ab_entry.creation) = " . $_REQUEST['y']; } else { $period = $_REQUEST['y']; $range_filter = "extract(year from ab_entry.creation) = " . $_REQUEST['y']; } $rows = $entrada->readDataFilter("ab_entry.public IS TRUE AND {$range_filter}"); for ($i = 0; $i < count($rows); $i++) { $rows[$i]['seo_title'] = generate_seo_link($rows[$i]['ab_entry']); $rows[$i]['texto'] = strip_code($rows[$i]['texto']); } $smarty->assign('entradas', $rows); $smarty->assign('title', $period . ' — Archivo'); $smarty->assign('period', $period); unset($rows); $smarty->assign('pgs', $pgs); $smarty->assign('pg', $pg); unset($rows); # Ultimas Entradas $entrada->readEnv(); $entrada->limit = 10; $rows = $entrada->readDataFilter("public IS TRUE"); $smarty->assign('ult_entradas', $rows); unset($rows); # Meses
} if ($exist) { # Cache de 1 dia if (!$smarty->is_cached($tpl, $pattern)) { # Paginas $ab_page = new ab_pageTable(); $rows = $ab_page->readDataSQL("SELECT idab_page,ab_page FROM ab_page WHERE menu IS TRUE ORDER BY orden"); $smarty->assign('paginas', $rows); unset($rows); # Entradas $entrada = new ab_entryTable(); $entrada->readEnv(); list($row) = $entrada->readDataFilter("idab_entry = " . $entrada->request['idab_entry'] . " AND public IS TRUE"); if (count($row)) { $row['seo_title'] = generate_seo_link($row['ab_entry']); $row['body'] = strip_code($row['body']); $smarty->assign('entrada', $row); $smarty->assign('title', '(Enviar) ' . $row['ab_entry']); } unset($entrada); unset($ab_page); } $smarty->display($tpl, $pattern); } else { require ROOTDIR . '/classes/include.d/404.inc.php'; if (!$smarty->is_cached('blogs/404p.tpl', $grp_id)) { # Variables require_once ROOTDIR . '/classes/include.d/const.inc.php'; } $smarty->display('blogs/404p.tpl', $grp_id); }
$orderby = 'threadcreationtime'; if (!empty($_GET['lastchanged'])) { $orderby = 'threadtime'; } /** * now fetch the threads **/ $r_threads = thwb_query("SELECT threadtopic, threadid\n FROM {$pref}thread\n WHERE boardid IN (" . join(',', $a_boards) . ")\n AND threadlink = 0\n ORDER BY {$orderby} DESC\n LIMIT " . CFG_NEWS_ITEMS); $a_threads = array(); while ($a_thread = mysql_fetch_assoc($r_threads)) { /** * ok, we got the threads, now get the posts **/ $r_post = thwb_query("SELECT p.postid, p.posttext, p.userid, u.username, p.posttime\n FROM {$pref}post AS p, {$pref}user AS u\n WHERE p.threadid = {$a_thread['threadid']}\n AND p.userid = u.userid\n ORDER BY p.posttime ASC\n LIMIT 1"); $a_post = mysql_fetch_assoc($r_post); strip_code($a_post['posttext'], !empty($_GET['type']) && $_GET['type'] == 'rss'); cut_str($a_post['posttext']); /** * if we're doing something else than generating rss output, we need the replycount **/ if (defined(THWB_NEWS_INCLUDED) || empty($_GET['type']) || $_GET['type'] == 'html') { $r_comments = thwb_query("SELECT COUNT(postid) AS commentcount\n FROM {$pref}post\n WHERE threadid = {$a_thread['threadid']}"); $a_comments = mysql_fetch_assoc($r_comments); if (!--$a_comments['commentcount']) { $a_comments['commentcount'] = 'keine'; } $a_comments['commentplural'] = $a_comments['commentcount'] == 1 ? '' : 'e'; } else { $a_comments = array(); } $a_threads[] = array_merge($a_thread, $a_post, $a_comments);
$mustSave = true; break; case "edit": $timerObj = $schedObjs[$_GET['line']]; $tpl_edit = new Template(TPL_FILE_LOCATION . 'timer_edit.tpl'); $tpl_edit->set('lang', $lang); $tpl_edit->set('aliases', $aliases); $tpl_edit->set('months', $months); $tpl_edit->set('days', $days); $tpl_edit->set('hours', $hours); $tpl_edit->set('mins', $mins); $tpl_edit->set('theTimer', $timerObj); if ($timerObj->getStartMacro() != "null") { $tpl_edit->set('selcode', strip_code($timerObj->getStartMacro())); } elseif ($timerObj->getStopMacro() != "null") { $tpl_edit->set('selcode', strip_code($timerObj->getStopMacro())); } $tpl_body->set('form', $tpl_edit); break; case "add": //build timer line with POST results $aTimer = new Timer(); post_data_to_timer($aTimer); // new timer objects already set macros to default of null // only need to set macros if they are specific if (!isset($_POST["null_macro_on"])) { $aTimer->setStartMacro($_POST["module"] . "_on"); } if (!isset($_POST["null_macro_off"])) { $aTimer->setStopMacro($_POST["module"] . "_off"); }
function text_truncate($text = '', $words = 55, $ending = '... ', $delimiter = '. ', $strip = []) { if (empty($text)) { return; } // If nothing valid was passed for the $strip variable let's provide a default set with an option to filter the array if (empty($strip) || !is_array($strip)) { $strip = apply_filters('ubik_text_truncate_strip', ['asides', 'code', 'figures', 'footnotes', 'tags']); } // Note: 'shortcodes' *not* included by default // Shortcode handler; this one goes first as shortcodes may introduce HTML and other stuff that we may want to strip later if (in_array('shortcodes', $strip)) { $text = strip_shortcodes($text); } else { $text = do_shortcode($text); } // Strip opening asides if (in_array('asides', $strip)) { $text = strip_asides($text); } // Strip code wrapped in `pre` and `code` elements if (in_array('code', $strip)) { $text = strip_code($text); } // Strip figures and figcaptions if (in_array('figures', $strip)) { $text = strip_figures($text); } // Strip footnotes wrapped in `sup` elements if (in_array('footnotes', $strip)) { $text = strip_footnotes($text); } // Strip all tags (but keep the contents) if (in_array('tags', $strip)) { $text = strip_tags($text); } // Abandoning `wp_strip_all_tags` here... // Strip any remaining tags $text = str_replace(']]>', ']]>', $text); // A modification of the core `wp_trim_words` function if ('characters' == _x('words', 'word count: words or characters?') && preg_match('/^utf\\-?8$/i', get_option('blog_charset'))) { // This code block handles character-based languages (e.g. Chinese) $text = trim(preg_replace("/[\n\r\t ]+/", ' ', $text), ' '); preg_match_all('/./u', $text, $words_array); $words_array = array_slice($words_array[0], 0, $words + 1); $sep = ''; } else { // This handles non-character based input the default WordPress way $words_array = preg_split("/[\n\r\t ]+/", $text, $words + 1, PREG_SPLIT_NO_EMPTY); $sep = ' '; } // Save the final count $words_count = count($words_array); // Trim the array to the desired word count if ($words_count > $words) { array_pop($words_array); } // Make a string from the array of words $text = implode($sep, $words_array); // Strip out trailing punctuation and add the excerpt ending as needed if ($words_count >= $words) { if (!preg_match('/[.!?]$/u', $text)) { // Could also try \p{P} for punctuation; @TODO: i18n $text = preg_replace('/^[\\p{P}|\\p{S}|\\s]+|[\\p{P}|\\p{S}|\\s]+$/u', '', $text) . $ending; } } else { if (!preg_match('/[.!?]$/u', $text)) { $text = preg_replace('/^[\\p{P}|\\p{S}|\\s]+|[\\p{P}|\\p{S}|\\s]+$/u', '', $text) . $delimiter; } } return apply_filters('ubik_text_truncate', $text); }