function oui_if_dailymotion($atts, $thing) { global $thisarticle; extract(lAtts(array('custom' => null, 'video' => null), $atts)); $result = $video ? _oui_dailymotion($video) : _oui_dailymotion($thisarticle[strtolower($custom)]); return defined('PREF_PLUGIN') ? parse($thing, $result) : parse(EvalElse($thing, $result)); }
function rss_article_edit($atts, $thing = "") { global $thisarticle, $rss_ae_cookie, $prefs; extract(lAtts(array('hidelive' => '', 'prefix' => '', 'suffix' => ''), $atts)); $hidelive = !empty($hidelive) && 'live' === $prefs['production_status']; return isset($_COOKIE[$rss_ae_cookie]) && !$hidelive ? $prefix . '<a href="' . hu . 'textpattern/index.php?event=article&step=edit&ID=' . $thisarticle['thisid'] . '">' . parse($thing) . '</a>' . $suffix : ''; }
function ckr_if_image_count($atts, $thing) { // Extract attributes from tag extract(lAtts(array('category' => false, 'min' => false, 'max' => false, 'equal' => false, 'not' => false), $atts)); // Count the images in specified category if given or globally $count = $category ? intval(ckr_image_count(array('category' => $category))) : intval(ckr_image_count()); // Instead of almost unreadable if-else syntax, we use this clever switch-true/case-if counstruct switch (true) { case $min && !$max && !$equal && !$not: // Is greater than min value return parse(EvalElse($thing, $count >= intval($min) ? true : false)); break; case $max && !$min && !$equal && !$not: // Is lesser than max value return parse(EvalElse($thing, $count <= intval($max) ? true : false)); break; case $equal && !$min && !$max && !$not: // Is equal return parse(EvalElse($thing, $count == intval($equal) ? true : false)); break; case $not && !$min && !$max && !$equal: // Is not equal return parse(EvalElse($thing, $count != intval($not) ? true : false)); break; case $min && $max && !$equal && !$not: // Between min and max return parse(EvalElse($thing, $count >= intval($min) && $count <= intval($max) ? true : false)); break; default: // Anything else will output an error message return '<!-- ckr_if_image_count: Wrong attribute count or combination. -->'; } }
function column_multi_head($head_items, $class = '') { $o = n . t . '<th' . ($class ? ' class="' . $class . '"' : '') . '>'; $first_item = true; foreach ($head_items as $item) { if (empty($item)) { continue; } extract(lAtts(array('value' => '', 'sort' => '', 'event' => '', 'is_link' => '', 'dir' => '', 'crit' => '', 'method' => ''), $item)); $o .= $first_item ? '' : ', '; $first_item = false; if ($is_link) { $o .= '<a href="index.php?step=list'; $o .= $event ? a . "event={$event}" : ''; $o .= $sort ? a . "sort={$sort}" : ''; $o .= $dir ? a . "dir={$dir}" : ''; $o .= $crit ? a . "crit={$crit}" : ''; $o .= $method ? a . "search_method={$method}" : ''; $o .= '">'; } $o .= gTxt($value); if ($is_link) { $o .= '</a>'; } } $o .= '</th>'; return $o; }
function section_add($parent, $name, $atts) { $rec = lAtts(array('path' => '', 'parent' => $parent, 'name' => '', 'title' => $name, 'inherit' => 0, 'page' => 'default', 'css' => 'default', 'in_rss' => '1', 'on_frontpage' => '1', 'searchable' => '1'), $atts); $default = section_default(); if (empty($rec['parent'])) { $rec['parent'] = $default['id']; } if (empty($rec['name'])) { $rec['name'] = dumbDown($rec['title']); } if ($rec['inherit']) { // find the closest ancestor // we do this at insert to save time when fetching pages $ancestor = section_inherit($parent); $rec['page'] = $ancestor['page']; $rec['css'] = $ancestor['css']; $rec['in_rss'] = $ancestor['in_rss']; $rec['on_frontpage'] = $ancestor['on_frontpage']; $rec['searchable'] = $ancestor['searchable']; } if ($parent) { list($lft, $rgt) = tree_insert_space('txp_section', $parent); } else { $lft = $rgt = 0; } $rec['lft'] = $lft; $rec['rgt'] = $rgt; $res = safe_insert_rec('txp_section', doSlash($rec)); return $res; }
/** * Conditional for yield. * * @param array $atts * @param string $thing * @return string */ public static function renderIfYield($atts, $thing) { global $yield; extract(lAtts(array('value' => null), $atts)); $inner = end($yield); return parse(EvalElse($thing, $inner !== null && ($value === null || (string) $inner === (string) $value))); }
function mck_google_map($atts) { extract(lAtts(array('center' => '45.689274,9.105949', 'zoom' => '12', 'idmap' => 'map', 'width' => '500', 'height' => '300', 'mapctrl' => '', 'typectrl' => '', 'mark' => '', 'markpoint' => 'map.getCenter()', 'poly' => ''), $atts)); //valuto ed inserisco il controllo mappa if ($mapctrl != "") { $ctrlscript = "map.addControl(new GSmallMapControl());\n"; } //valuto ed inserisco il controllo tipologia mappa if ($typectrl != "") { $typescript = "map.addControl(new GMapTypeControl());\n"; } //valuto ed inserisco il marker if ($mark != "") { $scriptmarker = "\n\nvar marker = new GMarker({$markpoint});\n\nGEvent.addListener(marker, \"click\", function() {\n\n marker.openInfoWindowHtml(\"<span style='color:#000'>{$mark}</span>\");\n\n });\n\nmap.addOverlay(marker);\n"; } else { $scriptmarker = ""; } //valuto ed inserisco le polyline if ($poly != "") { list($pline, $plevel) = split(",", $poly, 2); $polyscript = "\n var encodedPolyline = new GPolyline.fromEncoded({\n color: \"#FF0000\",\n weight: 10,\n points: \"{$pline}\",\n levels: \"{$plevel}\",\n zoomFactor: 32,\n numLevels: 4\n });\n map.addOverlay(encodedPolyline);\n"; } //preparo il codice da scrivere nella pagina $script = "\n<div id=\"{$idmap}\" style=\"width:" . $width . "px; height:" . $height . "px;\"></div>\n"; $script .= "<script type=\"text/javascript\">\n\n \t\t\t//<![CDATA[\n\n window.onload = show{$idmap};\n function show{$idmap}() {\n\n\n \t if (GBrowserIsCompatible()) {\n\n \t\tvar map = new GMap(document.getElementById(\"{$idmap}\"));\n\n{$ctrlscript}\n{$typescript}\n var center = new GLatLng({$center});\n map.setCenter(center, {$zoom});\n\n }\n\n{$polyscript}\n{$scriptmarker}\n }\n\n //]]>\n\n </script>\n"; return $script; }
/** * Evaluate counting results. * * @param array $atts * @property string $atts['eval'] Valid PHP comparison operator. * @property string $atts['table'] MySQL table name. * @property string $atts['where'] MySQL WHERE clause. */ function jmd_if_count($atts, $thing) { extract(lAtts(array('eval' => '', 'table' => '', 'where' => ''), $atts)); global $jmd_count_value; $jmd_count_value = jmd_count(array('table' => $table, 'where' => $where)); $condition = eval("return({$jmd_count_value} {$eval});"); $out = EvalElse($thing, $condition); return parse($out); }
function fox_files_stats($atts) { extract(lAtts(array( 'downloaded' => '0', 'category' => '', 'format' => 'M', 'size' => '0', 'children' => '1' ), $atts)); if ($size=='1') { if ($downloaded ==' 0') $things = 'sum(size)'; else $things = 'sum(downloads*size)'; } else { if ($downloaded == '0') $things = 'count(*)'; else $things = 'sum(downloads)'; } if ($category!='') { if ($children == '1') { $c = safe_row('lft, rgt', 'txp_category', "`type`='file' AND name='".mysql_escape_string($category)."'"); $where = "category IN (SELECT name FROM txp_category WHERE type='file' AND lft >= ". $c['lft'] . " AND rgt <= " . $c['rgt'] . ")"; } else { $where = 'category=\''.mysql_escape_string($category).'\''; } } else { $where = '1'; } $stats = safe_row("$things as s", 'txp_file', $where); $stats = $stats['s']; if ($size=='1') switch (strtoupper($format)) { case 'G': $stats /= 1024; case 'M': $stats /= 1024; case 'K': $stats /= 1024; default: $stats = round($stats,2); } if ($format_number == '1') { $localeconv = localeconv(); $dec_point = isset($localeconv['decimal_point']) ? $localeconv['decimal_point'] : '.'; $thousands_sep = isset($localeconv['thousands_sep']) ? $localeconv['thousands_sep'] : ','; $stats = number_format($stats, $size=='1' ? 2 : 0, $dec_point, $thousands_sep); } return $stats; }
/** * Constructor. * * @param mixed $value * @param array $options */ public function __construct($value, $options = array()) { static $choices = null; $options = lAtts(array('allow_blank' => true, 'type' => '', 'message' => 'unknown_form'), $options, false); if (null === $choices) { $choices = safe_column('name', 'txp_form', $options['type'] !== '' ? 'type=\'' . doSlash($options['type']) . '\'' : '1=1'); } $options['choices'] = $choices; parent::__construct($value, $options); }
function spreadly($atts = "") { global $thisarticle; extract(lAtts(array("url" => permlinkurl($thisarticle), "title" => $thisarticle['title'], "social" => 0, "description" => "", "photo" => ""), $atts)); if ($social == 0) { $height = "24"; } else { $height = "60"; } $output = '<iframe src="http://button.spread.ly/?url=' . urlencode($url) . '&social=' . urlencode($social) . '&title=' . urlencode($title) . '&description=' . urlencode($description) . '&photo=' . urlencode($photo) . '" style="overflow:hidden; width: 420px; height: ' . $height . 'px; padding: 0;" frameborder="0" scrolling="no" marginheight="0" allowTransparency="true"></iframe>'; return $output; }
function sed_plugin_list($atts) { extract(lAtts(array('debug' => 0, 'type' => '', 'link_name' => 1, 'show_author' => 1, 'link_author' => 0, 'show_description' => 1, 'descriptionwrap' => 'p', 'descriptionclass' => 'plugin-description', 'show_version' => 1, 'versionwrap' => 'span', 'versionclass' => 'plugin-version', 'hide_disabled' => 1, 'sort_dir' => 'asc', 'sort_field' => 'name', 'wraptag' => 'ul', 'wrapclass' => 'plugin-list', 'break' => 'li', 'breakclass' => 'plugin-item', 'show_count' => 0, 'exclusions' => ''), $atts)); $exclusions = explode(',', $exclusions); # # Create out plugin search criteria... # $where = ''; $w = array(); if ('' !== $type) { $type = 'type=\'' . doSlash($type) . '\''; $w[] = $type; } if ($hide_disabled) { $w[] = 'status=\'1\''; } $where = join(' and ', $w); if (empty($where)) { $where = '1=1'; } $sort = ''; if ('' !== $sort_field) { $sort = ' order by `' . doSlash($sort_field) . '` ' . doSlash($sort_dir); } # # Grab the actual data... # $plugins = safe_rows('name,author,author_uri,version,description,status,type', 'txp_plugin', '(' . $where . ')' . $sort, $debug); # # Generate the XHTML results... # if ($plugins) { foreach ($plugins as $plugin) { if (in_array($plugin['name'], $exclusions)) { continue; } $item = tag($plugin['name'], 'span', ' class="plugin-name" '); if ($link_name) { $item = tag($item, 'a', ' href="' . $plugin['author_uri'] . '" rel="nofollow" '); } if ($show_version) { $item .= tag(' v' . $plugin['version'], $versionwrap, ' class="' . $versionclass . '" '); } if ($show_description) { $item .= tag($plugin['description'], $descriptionwrap, ' class="' . $descriptionclass . '" '); } $o[] = tag($item, $break, ' class="' . $breakclass . '" '); } } $o = n . join(n, $o); return n . tag($o, $wraptag, ' class="' . $wrapclass . '" ') . n . n; }
function pax_grep($atts, $thing) { global $pretext; extract(lAtts(array('from' => '', 'to' => '', 'delimiter' => ','), $atts)); $from = explode($delimiter, $from); $to = explode($delimiter, $to); $count = count($to); if ($count == 1) { $to = implode('', $to); } if ($count == 0) { $to = ''; } return preg_replace($from, $to, parse($thing)); }
/** * Textpattern plugin: ckr_truncate * * Truncates a given string to a predefined length * * @package textpattern-plugins * @copyright (c) 2009, all rights reserved * @author Cedric Kastner <*****@*****.**> * @version 1.0 */ function ckr_truncate($atts, $thing) { // Extract attributes from tag extract(lAtts(array('length' => '90', 'etc' => '…'), $atts)); // No length given, do nothing and return original string if ((int) $length === 0) { return parse($thing); } // String is longer then max length, so we start truncating if (strlen(parse($thing)) > (int) $length) { // Calculate remaining length $length -= min((int) $length, strlen(html_entity_decode($etc))); // Returns the truncated string plus etc string (default "…") return substr(parse($thing), 0, (int) $length) . $etc; } // The if-condition wasn't evaluated, so just return the original string return parse($thing); }
/** * Provides access to an author's username and email address. * Replaces the spaces in an author's real name with any character. * * @param array $atts * @param string $atts['display'] 'email', 'name', 'username' * @param bool $atts['lowercase'] Lowercases $display * @param string $atts['separator'] Replace spaces in $display with any char. * @param string $atts['username'] Username to base output on. Default: * article author */ function jmd_author($atts) { global $thisarticle; extract(lAtts(array('display' => 'username', 'lowercase' => 0, 'separator' => ' ', 'username' => $thisarticle['authorid']), $atts)); $out = $username; switch ($display) { case 'email': $out = eE(safe_field("email", "txp_users", "name='{$username}'")); break; case 'name': $out = get_author_name($username); break; default: } if ($lowercase == 1) { $out = strtolower($out); } return str_replace(' ', $separator, $out); }
/** * Generates a list of authors. * * @param array $atts * @param string $thing * @return string */ public static function renderAuthors($atts, $thing = null) { global $thisauthor, $txp_groups; extract(lAtts(array('break' => '', 'class' => '', 'form' => '', 'group' => '', 'label' => '', 'labeltag' => '', 'limit' => '', 'name' => '', 'offset' => '', 'sort' => 'name ASC', 'wraptag' => ''), $atts)); $sql = array('1 = 1'); $sql_limit = ''; $sql_sort = " ORDER BY " . doSlash($sort); if ($name) { $sql[] = "name IN (" . join(', ', quote_list(do_list($name))) . ")"; } if ($group !== '') { $privs = do_list($group); $groups = array_flip($txp_groups); foreach ($privs as &$priv) { if (isset($groups[$priv])) { $priv = $groups[$priv]; } } $sql[] = 'convert(privs, char) in (' . join(', ', quote_list($privs)) . ')'; } if ($limit !== '' || $offset) { $sql_limit = " LIMIT " . intval($offset) . ", " . ($limit === '' ? PHP_INT_MAX : intval($limit)); } $rs = safe_rows_start("user_id as id, name, RealName as realname, email, privs, last_access", 'txp_users', join(" AND ", $sql) . " {$sql_sort} {$sql_limit}"); if ($rs && numRows($rs)) { $out = array(); if ($thing === null && $form !== '') { $thing = fetch_form($form); } while ($a = nextRow($rs)) { $oldauthor = $thisauthor; $thisauthor = $a; $out[] = parse($thing); $thisauthor = $oldauthor; } unset($thisauthor); return doLabel($label, $labeltag) . doWrap($out, $wraptag, $break, $class); } return ''; }
function mdp_calendar($atts, $small = false) { $atts = lAtts(array('time' => 'past', 'displayfuture' => 0, 'category' => '', 'section' => '', 'author' => '', 'static' => '', 'class' => '', 'id' => '', 'month' => '', 'year' => '', 'dayformat' => 'ABBR', 'firstday' => 0, 'spandays' => 0), $atts); if ($atts['displayfuture']) { $atts['time'] = "any"; } // backwards compatability $future = $atts['time'] != "past" ? true : false; // Determine heading style $dates = mdp_calendar_calcDates($atts['year'], $atts['month'], $atts['static'], $atts['id']); $events = mdp_calendar_getEvents($dates, $atts); if ($small) { $calendar = new MDP_Small_Calendar($dates['year'], $dates['month'], $events, $atts['section'], $atts['category']); } else { $calendar = new MDP_Calendar($dates['year'], $dates['month'], $events); } $calendar->setTableID($atts['id']); $calendar->setTableClass($atts['class']); $calendar->setDayNameFormat($atts['dayformat']); $calendar->setFirstDayOfWeek($atts['firstday']); return $calendar->display($atts['static'], $future); }
function tc_shopping_cart_detail($atts) { session_start(); extract(lAtts(array('checkout_section' => 'checkout'), $atts)); $cart = $_SESSION['cart']; if (empty($cart)) { $cart = new bckCart(); } if (isset($_REQUEST['empty_cart'])) { $cart->empty_cart(); $_SESSION['cart'] = $cart; } $cartHTML = startTable("shopping_cart") . tr(n . hCell("Item") . n . hCell("Quantity") . n . hCell("Price") . n . hCell("Subtotal")); foreach ($cart->items as $product) { $image = '<img src="' . product_image_display($product['image'], "small") . '" alt="Product Detail" class="thumb"/>'; $link = "<a href='" . permlinkurl_id($product['ID']) . "' title='View product detail'>" . $product['name'] . "</a>"; $cartHTML .= tr(n . td($image . $link) . n . td($product['qty']) . n . td(_tc_price_format($product['price'])) . n . td(_tc_price_format($product['price']))); } $cartHTML .= endTable(); $cartHTML .= tag(tag(tag("Empty Cart", "a", " href='?empty_cart=true' class='cartAction' id='emptyCart'"), "li") . tag(tag("Continue Shopping", "a", " href='#' class='cartAction' id='continueShopping'"), "li") . tag(tag("Checkout", "a", " href='/{$checkout_section}/' class='cartAction' id='checkout'"), "li") . tag(tag(_tc_price_format($cart->total), "span", " class='cartTotal'"), "li"), "ul"); return $cartHTML; }
function zem_older($atts, $thing = false) { global $thispage, $pretext, $permlink_mode; extract(lAtts(array('showalways' => 0), $atts)); $numPages = $thispage['numPages']; $pg = $thispage['pg']; if ($numPages > 1 and $pg != $numPages) { $nextpg = $pg + 1; // author urls should use RealName, rather than username if (!empty($pretext['author'])) { $author = safe_field('RealName', 'txp_users', "name = '" . doSlash($pretext['author']) . "'"); } else { $author = ''; } $parts = array('pg' => $nextpg, 's' => @$pretext['s'], 'c' => @$pretext['c'], 'q' => @$pretext['q'], 'author' => $author); $parts = $parts + $_GET; $url = pagelinkurl($parts); if ($thing) { return '<a href="' . $url . '"' . (empty($title) ? '' : ' title="' . $title . '"') . '>' . parse($thing) . '</a>'; } return $url; } return $showalways ? parse($thing) : ''; }
function jmd_wiki_events_date($atts) { extract(lAtts(array('format' => ''), $atts)); global $jmd_wiki_events; if ($format) { $out = safe_strftime($format, safe_strtotime($jmd_wiki_events->date)); } else { $out = $jmd_wiki_events->date; } return $out; }
/** * Save and retrieve the individual article's attributes plus article list attributes for next/prev tags * * @param array $atts * @return array * @since 4.5.0 */ function filterAtts($atts = null) { global $prefs; static $out = array(); $valid = array('sort' => 'Posted desc', 'sortby' => '', 'sortdir' => '', 'keywords' => '', 'expired' => $prefs['publish_expired_articles'], 'id' => '', 'time' => 'past'); if (is_array($atts)) { if (empty($out)) { $out = $atts; trace_add('[filterAtts accepted]'); } else { // TODO: deal w/ nested txp:article[_custom] tags. trace_add('[filterAtts ignored]'); } } if (empty($out)) { trace_add('[filterAtts not set]'); } return lAtts($valid, $out, 0); }
/** * Sets filter's options. * * @param array $options Array of options: 'lite' => boolean, 'rel' => string, 'noimage' => boolean, 'restricted' => boolean */ private function setOptions($options) { $this->options = lAtts(array('lite' => false, 'restricted' => false, 'rel' => '', 'noimage' => false), $options); }
function ign_logout_link($atts, $thing) { global $ign_user; if (empty($ign_user)) { return ""; } //exit if user not logged in extract(lAtts(array('class' => '', 'onclick' => '', 'alt' => 'Logout', 'title' => 'Logout', 'return_path' => '', 'id' => '', 'linktext' => ''), $atts, 0)); if (!empty($return_path)) { list($return_path) = explode('?', $_SERVER['REQUEST_URI']); } $text = !empty($thing) ? $thing : (!empty($linktext) ? $linktext : IGN_LOGOUT_LINK); $q = !empty($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] . "&logout=1" : 'logout=1'; $o[] = "<a href='{$return_path}?{$q}'"; $o[] = !empty($class) ? "class='{$class}'" : ''; $o[] = !empty($alt) ? "alt='{$alt}'" : ''; $o[] = !empty($title) ? "title='{$title}'" : ''; $o[] = !empty($id) ? "id='{$id}'" : ''; $o[] = !empty($onclick) ? "onclick='{$onclick}'" : ''; $o[] = ">{$text}</a>"; return join($o); }
function commentForm($id, $atts = NULL) { global $prefs; extract($prefs); extract(lAtts(array('isize' => '25', 'msgrows' => '5', 'msgcols' => '25', 'msgstyle' => '', 'form' => 'comment_form'), $atts, 0)); $namewarn = false; $emailwarn = false; $commentwarn = false; $name = pcs('name'); $email = clean_url(pcs('email')); $web = clean_url(pcs('web')); $n_message = 'message'; extract(doDeEnt(psa(array('checkbox_type', 'remember', 'forget', 'parentid', 'preview', 'message', 'submit', 'backpage')))); if ($message == '') { //Second or later preview will have randomized message-field name $in = getComment(); $message = doDeEnt($in['message']); } if ($preview) { $name = ps('name'); $email = clean_url(ps('email')); $web = clean_url(ps('web')); $nonce = getNextNonce(); $secret = getNextSecret(); safe_insert("txp_discuss_nonce", "issue_time=now(), nonce='" . doSlash($nonce) . "', secret='" . doSlash($secret) . "'"); $n_message = md5('message' . $secret); $namewarn = $comments_require_name && !trim($name); $emailwarn = $comments_require_email && !trim($email); $commentwarn = !trim($message); $evaluator =& get_comment_evaluator(); if ($namewarn) { $evaluator->add_estimate(RELOAD, 1, gTxt('comment_name_required')); } if ($emailwarn) { $evaluator->add_estimate(RELOAD, 1, gTxt('comment_email_required')); } if ($commentwarn) { $evaluator->add_estimate(RELOAD, 1, gTxt('comment_required')); } } else { $rememberCookie = cs('txp_remember'); if ($rememberCookie === '') { $checkbox_type = 'remember'; $remember = 1; } else { if ($rememberCookie == 1) { $checkbox_type = 'forget'; } else { $checkbox_type = 'remember'; } } } // If the form fields are filled (anything other than blank), pages // really should not be saved by a public cache. rfc2616/14.9.1 if ($name || $email || $web) { header('Cache-Control: private'); } $parentid = !$parentid ? $id : $parentid; $url = $GLOBALS['pretext']['request_uri']; // Experimental clean urls with only 404-error-document on apache // possibly requires messy urls for POST requests. if (defined('PARTLY_MESSY') and PARTLY_MESSY) { $url = hu . '?id=' . intval($parentid); } $out = '<form id="txpCommentInputForm" method="post" action="' . htmlspecialchars($url) . '#cpreview">' . n . '<div class="comments-wrapper">' . n . n; $Form = fetch('Form', 'txp_form', 'name', $form); $msgstyle = $msgstyle ? ' style="' . $msgstyle . '"' : ''; $msgrows = ($msgrows and is_numeric($msgrows)) ? ' rows="' . intval($msgrows) . '"' : ''; $msgcols = ($msgcols and is_numeric($msgcols)) ? ' cols="' . intval($msgcols) . '"' : ''; $textarea = '<textarea id="message" name="' . $n_message . '"' . $msgcols . $msgrows . $msgstyle . ' class="txpCommentInputMessage' . ($commentwarn ? ' comments_error"' : '"') . '>' . htmlspecialchars(substr(trim($message), 0, 65535)) . '</textarea>'; // by default, the submit button is visible but disabled $comment_submit_button = fInput('submit', 'submit', gTxt('submit'), 'button disabled', '', '', '', '', 'txpCommentSubmit', true); // if all fields checkout, the submit button is active/clickable if ($preview) { $comment_submit_button = fInput('submit', 'submit', gTxt('submit'), 'button', '', '', '', '', 'txpCommentSubmit', false); } if ($checkbox_type == 'forget') { // inhibit default remember if ($forget == 1) { destroyCookies(); } $checkbox = checkbox('forget', 1, $forget, '', 'forget') . ' ' . tag(gTxt('forget'), 'label', ' for="forget"'); } else { // inhibit default remember if ($remember != 1) { destroyCookies(); } $checkbox = checkbox('remember', 1, $remember, '', 'remember') . ' ' . tag(gTxt('remember'), 'label', ' for="remember"'); } $checkbox .= ' ' . hInput('checkbox_type', $checkbox_type); $vals = array('comment_name_input' => fInput('text', 'name', htmlspecialchars($name), 'comment_name_input' . ($namewarn ? ' comments_error' : ''), '', '', $isize, '', 'name'), 'comment_email_input' => fInput('text', 'email', htmlspecialchars($email), 'comment_email_input' . ($emailwarn ? ' comments_error' : ''), '', '', $isize, '', 'email'), 'comment_web_input' => fInput('text', 'web', htmlspecialchars($web), 'comment_web_input', '', '', $isize, '', 'web'), 'comment_message_input' => $textarea . '<!-- plugin-place-holder -->', 'comment_remember' => $checkbox, 'comment_preview' => fInput('submit', 'preview', gTxt('preview'), 'button', '', '', '', '', 'txpCommentPreview', false), 'comment_submit' => $comment_submit_button); foreach ($vals as $a => $b) { $Form = str_replace('<txp:' . $a . ' />', $b, $Form); } $form = parse($Form); $out .= $form . n . hInput('parentid', $parentid); $split = rand(1, 31); $out .= $preview ? n . hInput(substr($nonce, 0, $split), substr($nonce, $split)) : ''; $out .= !$preview ? n . hInput('backpage', htmlspecialchars($url)) : n . hInput('backpage', htmlspecialchars($backpage)); $out = str_replace('<!-- plugin-place-holder -->', callback_event('comment.form'), $out); $out .= n . n . '</div>' . n . '</form>'; return $out; }
/** * Checks for neighbors. * * @param array $atts * @param string $atts['type'] Type of neighbor to check for ('next'||'prev') */ function jmd_if_neighbor($atts, $thing) { extract(lAtts(array('type' => ''), $atts)); $condition = $GLOBALS['jmd_neighbor']->type == $type; $out = EvalElse($thing, $condition); return parse($out); }
function doArticle($atts, $thing = null) { global $pretext, $prefs, $thisarticle; extract($prefs); extract($pretext); extract(gpsa(array('parentid', 'preview'))); $theAtts = lAtts(array('allowoverride' => '1', 'form' => 'default', 'status' => STATUS_LIVE, 'pgonly' => 0), $atts, 0); extract($theAtts); // Save *all* atts to get hold of the current article filter criteria. filterAtts($atts); // No output required. if ($pgonly) { return ''; } // If a form is specified, $thing is for doArticles() - hence ignore // $thing here. if (!empty($atts['form'])) { $thing = ''; } if ($status) { $status = in_array(strtolower($status), array('sticky', STATUS_STICKY)) ? STATUS_STICKY : STATUS_LIVE; } if (empty($thisarticle) or $thisarticle['thisid'] != $id) { $id = assert_int($id); $thisarticle = null; $q_status = $status ? "AND Status = " . intval($status) : "AND Status IN (" . STATUS_LIVE . "," . STATUS_STICKY . ")"; $rs = safe_row("*, UNIX_TIMESTAMP(Posted) AS uPosted, UNIX_TIMESTAMP(Expires) AS uExpires, UNIX_TIMESTAMP(LastMod) AS uLastMod", 'textpattern', "ID = {$id} {$q_status} LIMIT 1"); if ($rs) { extract($rs); populateArticleData($rs); } } if (!empty($thisarticle) and ($thisarticle['status'] == $status or gps('txpreview'))) { extract($thisarticle); $thisarticle['is_first'] = 1; $thisarticle['is_last'] = 1; if ($allowoverride and $override_form) { $article = parse_form($override_form); } else { $article = $thing ? parse($thing) : parse_form($form); } if ($use_comments and $comments_auto_append) { $article .= parse_form('comments_display'); } unset($GLOBALS['thisarticle']); return $article; } }
/** * Render a link element to hook up txpAsyncHref() with request parameters * * @param string $item Link text * @param array $parms Request parameters; array keys are 'event', 'step', 'thing', 'property' * @param string $atts HTML attributes * @return string HTML * @since 4.5.0 * @see textpattern.js: txpAsyncHref */ function asyncHref($item, $parms, $atts = '') { extract(doSpecial(lAtts(array('event' => $GLOBALS['event'], 'step' => $GLOBALS['step'], 'thing' => '', 'property' => ''), $parms))); $class = "{$step} async"; $href = "?event={$event}&step={$step}&thing={$thing}&property={$property}"; if (AJAXALLY_CHALLENGED) { $href .= '&value=' . txpspecialchars($item) . '&_txp_token=' . form_token(); } return href($item, $href, $atts . " class=\"{$class}\""); }
/** * Constructor. * * @param mixed $value * @param array $options */ public function __construct($value, $options = array()) { $options = lAtts(array('message' => 'should_be_false'), $options, false); parent::__construct($value, $options); }
function txp_die($msg, $status = '503') { // 503 status might discourage search engines from indexing or caching the error message //Make it possible to call this function as a tag, e.g. in an article <txp:txp_die status="410" /> if (is_array($msg)) { extract(lAtts(array('msg' => '', 'status' => '503'), $msg)); } // Intentionally incomplete - just the ones we're likely to use $codes = array('200' => 'OK', '301' => 'Moved Permanently', '302' => 'Found', '304' => 'Not Modified', '307' => 'Temporary Redirect', '401' => 'Unauthorized', '403' => 'Forbidden', '404' => 'Not Found', '410' => 'Gone', '414' => 'Request-URI Too Long', '500' => 'Internal Server Error', '501' => 'Not Implemented', '503' => 'Service Unavailable'); if ($status) { if (isset($codes[strval($status)])) { $status = strval($status) . ' ' . $codes[$status]; } txp_status_header($status); } $code = ''; if ($status and $parts = @explode(' ', $status, 2)) { $code = @$parts[0]; } callback_event('txp_die', $code); if (@$GLOBALS['connected']) { $out = safe_field('user_html', 'txp_page', "name='error_" . doSlash($code) . "'"); if (empty($out)) { $out = safe_field('user_html', 'txp_page', "name='error_default'"); } } if (empty($out)) { $out = <<<eod <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Textpattern Error: <txp:error_status /></title> </head> <body> <p align="center" style="margin-top:4em"><txp:error_message /></p> </body> </html> eod; } header("Content-type: text/html; charset=utf-8"); if (is_callable('parse')) { $GLOBALS['txp_error_message'] = $msg; $GLOBALS['txp_error_status'] = $status; $GLOBALS['txp_error_code'] = $code; set_error_handler("tagErrorHandler"); die(parse($out)); } else { $out = preg_replace(array('@<txp:error_status[^>]*/>@', '@<txp:error_message[^>]*/>@'), array($status, $msg), $out); die($out); } }
function sed_lib_home_or_section($atts, $thing) { extract(lAtts(array('sectlist' => ''), $atts, 0)); global $pretext; $do_thing = $pretext['s'] == "default" && empty($pretext['c']) && empty($pretext['q']) && empty($pretext['pg']); if (!$do_thing && !empty($sectlist)) { $sectlist = do_list($sectlist); $do_thing = in_array($pretext['s'], $sectlist); } return parse(EvalElse($thing, $do_thing)); }