Beispiel #1
0
        return $before;
    }
}
h2o::addFilter('firstword');
function build_permalink_for($term, $url_rewrites_index)
{
    global $spp_settings;
    $rule = $spp_settings->url_rewrites[$url_rewrites_index];
    $term = CoreFilters::hyphenize($term);
    $term = str_replace('-', $rule['separator'], $term);
    $array_of_term = explode($rule['separator'], $term);
    $first_word = isset($array_of_term[0]) ? $array_of_term[0] : $term;
    $permalink = $rule['permalink'];
    $permalink = str_replace('{{ first_word }}', $first_word, $permalink);
    $permalink = str_replace('{{ random }}', substr(md5($term), 1, 7), $permalink);
    $permalink = str_replace('{{ term }}', $term, $permalink);
    $permalink = home_url($permalink);
    return $permalink;
}
h2o::addFilter('build_permalink_for');
h2o::addFilter('base64_encode');
function spp_is_bot()
{
    $crawlers = array('aspseek', 'abachobot', 'accoona', 'acoirobot', 'adsbot', 'alexa', 'alta vista', 'altavista', 'ask jeeves', 'baidu', 'bing', 'crawler', 'croccrawler', 'dumbot', 'estyle', 'exabot', 'fast-enterprise', 'fast-webcrawler', 'francis', 'geonabot', 'gigabot', 'google', 'googlebot', 'heise', 'heritrix', 'ibm', 'iccrawler', 'idbot', 'ichiro', 'lycos', 'mediapartners-google', 'msn', 'msrbot', 'majestic-12', 'metager', 'ng-search', 'nutch', 'omniexplorer', 'psbot', 'rambler', 'seosearch', 'scooter', 'scrubby', 'seekport', 'sensis', 'seoma', 'snappy', 'steeler', 'synoo', 'telekom', 'turnitinbot', 'voyager', 'wisenut', 'yacy', 'yahoo');
    foreach ($crawlers as $c) {
        if (stripos($_SERVER['HTTP_USER_AGENT'], $c) !== false) {
            return true;
        }
    }
    return false;
}
Beispiel #2
0
        if (abs($reldays) < 7) {
            if ($reldays > 0) {
                $reldays = floor($reldays);
                return 'in ' . $reldays . ' day' . ($reldays != 1 ? 's' : '');
            } else {
                $reldays = abs(floor($reldays));
                return $reldays . ' day' . ($reldays != 1 ? 's' : '') . ' ago';
            }
        }
        if (abs($reldays) < 182) {
            return date('l, F j', $time ? $time : time());
        } else {
            return date('l, F j, Y', $time ? $time : time());
        }
    }
    static function relative_datetime($time)
    {
        $date = self::relative_date($time);
        if ($date === 'today') {
            return self::relative_time($time);
        }
        return $date;
    }
}
/*  Ultizie php funciton as Filters */
h2o::addFilter(array('md5', 'sha1', 'numberformat' => 'number_format', 'wordwrap', 'trim', 'upper' => 'strtoupper', 'lower' => 'strtolower'));
/* Add filter collections */
h2o::addFilter(array('CoreFilters', 'StringFilters', 'NumberFilters', 'DatetimeFilters', 'HtmlFilters'));
/* Alias default to set_default */
h2o::addFilter('default', array('CoreFilters', 'set_default'));
Beispiel #3
0
        $hack = $context->resolve(':hack');
        $url = $this->get_api_url($term, $hack);
        $feed = @$this->fetch($context, $url)->xpath('//channel/item');
        $feed = @$this->filter($feed);
        $context->set("api", $feed);
        $context->set("api_url", $url);
    }
}
h2o::addTag('api');
function filter_bad_words($content)
{
    global $spp_settings;
    $bad_words = explode(',', $spp_settings->bad_words);
    foreach ($bad_words as $word) {
        // mulai ubah konten
        $content = str_ireplace($word . ' ', '', $content);
        $content = str_ireplace(' ' . $word . ' ', '', $content);
        $content = str_ireplace(' ' . $word, '', $content);
        $content = str_ireplace($word, '.', $content);
        $content = str_ireplace($word, ',', $content);
        $content = str_ireplace($word, '-', $content);
    }
    return $content;
}
h2o::addFilter('filter_bad_words');
function remove_repeating_chars($object)
{
    return preg_replace("/[^a-zA-Z0-9\\s.?!\\/]/", "", $object);
}
h2o::addFilter('remove_repeating_chars');
Beispiel #4
0
<?php

//spp addon: random term:
/*
widget text / post editor usage: [spp_random_terms] or [spp_random_terms count=20]
outside post/widget usage: do_shortcode('[spp_random_terms count=20]');
*/
h2o::addFilter('strtr');
function spp_random_terms_func($atts)
{
    extract(shortcode_atts(array('count' => 10), $atts));
    global $spp_settings;
    global $wpdb;
    // SELECT * FROM myTable WHERE RAND()<(SELECT ((30/COUNT(*))*10) FROM myTable) ORDER BY RAND() LIMIT 30;
    $sql = "SELECT `term` FROM `" . $wpdb->prefix . "spp` WHERE RAND()<(SELECT ((" . $count . "/COUNT(`term`))*10) FROM `" . $wpdb->prefix . "spp`) ORDER BY RAND() LIMIT " . $count . ";";
    $searchterms = $wpdb->get_results($sql);
    if (!empty($searchterms) && count($searchterms) > 100) {
        $terms = array();
        foreach ($searchterms as $term) {
            $terms[] = $term->term;
        }
    } else {
        $file = @file_get_contents(SPP_PATH . '/keywords.txt');
        if ($file) {
            $terms = explode("\n", $file);
            shuffle($terms);
            $terms = array_slice($terms, 0, $count);
        } else {
            $terms = array();
        }
    }
Beispiel #5
0
    return str_replace($search, '', $term);
}
if (function_exists('wpunique_synonymize')) {
    h2o::addFilter('wpunique_synonymize');
}
h2o::addFilter('host');
function host($string)
{
    $host = parse_url($string);
    return $host['host'];
}
function spp_shortcode($atts)
{
    extract(shortcode_atts(array('term' => 'hello world', 'template' => 'default.html', 'hack' => ''), $atts));
    return spp($term, $template, $hack);
}
add_shortcode('spp', 'spp_shortcode');
function get_video_id($url)
{
    $parts = parse_url($url);
    if ($parts === false) {
        return false;
    } else {
        parse_str($parts['query'], $params);
        return $params['v'];
    }
}
h2o::addFilter('get_video_id');
if (!class_exists('h2o_parser')) {
    require SPP_PATH . '/templates/h2o/h2o/parser.php';
}
Beispiel #6
0
<?php

class TimelineFilters extends FilterCollection
{
    static function userify($user, $timelineid, $suffix = null)
    {
        if (!$user['deleted']) {
            return sprintf('<span class="a" onclick="showUserInfo(%d, null, {source: \'timeline\', timeline_id: %d})">%s %s</span>', $user['id'], $timelineid, $user['name'], $user['surname']) . $suffix;
        } else {
            return $user['name'] . " " . $user['surname'] . $suffix;
        }
    }
    static function user_adjectify($user, $timelineid)
    {
        $is_comment = array_key_exists('commenter_id', $user);
        if ($is_comment) {
            $suffix = "'s";
        } else {
            $suffix = null;
        }
        if (!$is_comment || $user['id'] != $user['commenter_id']) {
            return TimelineFilters::userify($user, $timelineid, $suffix);
        } else {
            return $user['adj'];
        }
    }
}
h2o::addFilter(array('TimelineFilters'));
Beispiel #7
0
<?php

//thanks to brokencode
//@jisportal http://www.jisportal.com/forum/showthread.php/7133-Memanfaatkan-Halaman-Category-dan-Tag-pada-WordPress/page4?highlight=common+words
function remove_common_words($input)
{
    $commonWords = array('a', 'able', 'about', 'above', 'abroad', 'according', 'accordingly', 'across', 'actually', 'adj', 'after', 'afterwards', 'again', 'against', 'ago', 'ahead', 'ain\'t', 'all', 'allow', 'allows', 'almost', 'alone', 'along', 'alongside', 'already', 'also', 'although', 'always', 'am', 'amid', 'amidst', 'among', 'amongst', 'an', 'and', 'another', 'any', 'anybody', 'anyhow', 'anyone', 'anything', 'anyway', 'anyways', 'anywhere', 'apart', 'appear', 'appreciate', 'appropriate', 'are', 'aren\'t', 'around', 'as', 'a\'s', 'aside', 'ask', 'asking', 'associated', 'at', 'available', 'away', 'awfully', 'b', 'back', 'backward', 'backwards', 'be', 'became', 'because', 'become', 'becomes', 'becoming', 'been', 'before', 'beforehand', 'begin', 'behind', 'being', 'believe', 'below', 'beside', 'besides', 'best', 'better', 'between', 'beyond', 'both', 'brief', 'but', 'by', 'c', 'came', 'can', 'cannot', 'cant', 'can\'t', 'caption', 'cause', 'causes', 'certain', 'certainly', 'changes', 'clearly', 'c\'mon', 'co', 'co.', 'com', 'come', 'comes', 'concerning', 'consequently', 'consider', 'considering', 'contain', 'containing', 'contains', 'corresponding', 'could', 'couldn\'t', 'course', 'c\'s', 'currently', 'd', 'dare', 'daren\'t', 'definitely', 'described', 'despite', 'did', 'didn\'t', 'different', 'directly', 'do', 'does', 'doesn\'t', 'doing', 'done', 'don\'t', 'down', 'downwards', 'during', 'e', 'each', 'edu', 'eg', 'eight', 'eighty', 'either', 'else', 'elsewhere', 'end', 'ending', 'enough', 'entirely', 'especially', 'et', 'etc', 'even', 'ever', 'evermore', 'every', 'everybody', 'everyone', 'everything', 'everywhere', 'ex', 'exactly', 'example', 'except', 'f', 'fairly', 'far', 'farther', 'few', 'fewer', 'fifth', 'first', 'five', 'followed', 'following', 'follows', 'for', 'forever', 'former', 'formerly', 'forth', 'forward', 'found', 'four', 'from', 'further', 'furthermore', 'g', 'get', 'gets', 'getting', 'given', 'gives', 'go', 'goes', 'going', 'gone', 'got', 'gotten', 'greetings', 'h', 'had', 'hadn\'t', 'half', 'happens', 'hardly', 'has', 'hasn\'t', 'have', 'haven\'t', 'having', 'he', 'he\'d', 'he\'ll', 'hello', 'help', 'hence', 'her', 'here', 'hereafter', 'hereby', 'herein', 'here\'s', 'hereupon', 'hers', 'herself', 'he\'s', 'hi', 'him', 'himself', 'his', 'hither', 'hopefully', 'how', 'howbeit', 'however', 'hundred', 'i', 'i\'d', 'ie', 'if', 'ignored', 'i\'ll', 'i\'m', 'immediate', 'in', 'inasmuch', 'inc', 'inc.', 'indeed', 'indicate', 'indicated', 'indicates', 'inner', 'inside', 'insofar', 'instead', 'into', 'inward', 'is', 'isn\'t', 'it', 'it\'d', 'it\'ll', 'its', 'it\'s', 'itself', 'i\'ve', 'j', 'just', 'k', 'keep', 'keeps', 'kept', 'know', 'known', 'knows', 'l', 'last', 'lately', 'later', 'latter', 'latterly', 'least', 'less', 'lest', 'let', 'let\'s', 'like', 'liked', 'likely', 'likewise', 'little', '\'ll', 'look', 'looking', 'looks', 'low', 'lower', 'ltd', 'm', 'made', 'mainly', 'make', 'makes', 'many', 'may', 'maybe', 'mayn\'t', 'me', 'mean', 'meantime', 'meanwhile', 'merely', 'might', 'mightn\'t', 'mine', 'minus', 'miss', 'more', 'moreover', 'most', 'mostly', 'mr', 'mrs', 'much', 'must', 'mustn\'t', 'my', 'myself', 'n', 'name', 'namely', 'nd', 'near', 'nearly', 'necessary', 'need', 'needn\'t', 'needs', 'neither', 'never', 'neverf', 'neverless', 'nevertheless', 'new', 'next', 'nine', 'ninety', 'no', 'nobody', 'non', 'none', 'nonetheless', 'noone', 'no-one', 'nor', 'normally', 'not', 'nothing', 'notwithstanding', 'novel', 'now', 'nowhere', 'o', 'obviously', 'of', 'off', 'often', 'oh', 'ok', 'okay', 'old', 'on', 'once', 'one', 'ones', 'one\'s', 'only', 'onto', 'opposite', 'or', 'other', 'others', 'otherwise', 'ought', 'oughtn\'t', 'our', 'ours', 'ourselves', 'out', 'outside', 'over', 'overall', 'own', 'particular', 'particularly', 'past', 'per', 'perhaps', 'placed', 'please', 'plus', 'possible', 'presumably', 'probably', 'provided', 'provides', 'q', 'que', 'quite', 'qv', 'r', 'rather', 'rd', 're', 'really', 'reasonably', 'recent', 'recently', 'regarding', 'regardless', 'regards', 'relatively', 'respectively', 'right', 'round', 's', 'said', 'same', 'saw', 'say', 'saying', 'says', 'second', 'secondly', 'see', 'seeing', 'seem', 'seemed', 'seeming', 'seems', 'seen', 'self', 'selves', 'sensible', 'sent', 'serious', 'seriously', 'seven', 'several', 'shall', 'shan\'t', 'she', 'she\'d', 'she\'ll', 'she\'s', 'should', 'shouldn\'t', 'since', 'six', 'so', 'some', 'somebody', 'someday', 'somehow', 'someone', 'something', 'sometime', 'sometimes', 'somewhat', 'somewhere', 'soon', 'sorry', 'specified', 'specify', 'specifying', 'still', 'sub', 'such', 'sup', 'sure', 't', 'take', 'taken', 'taking', 'tell', 'tends', 'th', 'than', 'thank', 'thanks', 'thanx', 'that', 'that\'ll', 'thats', 'that\'s', 'that\'ve', '\'ve', 'the', 'their', 'theirs', 'them', 'themselves', 'then', 'thence', 'there', 'thereafter', 'thereby', 'there\'d', 'therefore', 'therein', 'there\'ll', 'there\'re', 'theres', 'there\'s', 'thereupon', 'there\'ve', 'these', 'they', 'they\'d', 'they\'ll', 'they\'re', 'they\'ve', 'thing', 'things', 'think', 'third', 'thirty', 'this', 'thorough', 'thoroughly', 'those', 'though', 'three', 'through', 'throughout', 'thru', 'thus', 'till', 'to', 'together', 'too', 'took', 'toward', 'towards', 'tried', 'tries', 'truly', 'try', 'trying', 't\'s', 'twice', 'two', 'u', 'un', 'under', 'underneath', 'undoing', 'unfortunately', 'unless', 'unlike', 'unlikely', 'until', 'unto', 'up', 'upon', 'upwards', 'us', 'use', 'used', 'useful', 'uses', 'using', 'usually', 'v', 'value', 'various', 'versus', 'very', 'via', 'viz', 'vs', 'w', 'want', 'wants', 'was', 'wasn\'t', 'way', 'we', 'we\'d', 'welcome', 'well', 'we\'ll', 'went', 'were', 'we\'re', 'weren\'t', 'we\'ve', 'what', 'whatever', 'what\'ll', 'what\'s', 'what\'ve', 'when', 'whence', 'whenever', 'where', 'whereafter', 'whereas', 'whereby', 'wherein', 'where\'s', 'whereupon', 'wherever', 'whether', 'which', 'whichever', 'while', 'whilst', 'whither', 'who', 'who\'d', 'whoever', 'whole', 'who\'ll', 'whom', 'whomever', 'who\'s', 'whose', 'why', 'will', 'willing', 'wish', 'with', 'within', 'without', 'wonder', 'won\'t', 'would', 'wouldn\'t', 'x', 'y', 'yes', 'yet', 'you', 'you\'d', 'you\'ll', 'your', 'you\'re', 'you\'ve', 'yours', 'yourself', 'yourselves', 'you\'ve', 'z', 'zero', 'ada', 'adalah', 'agak', 'agar', 'akan', 'aku', 'amat', 'anda', 'apa', 'apabila', 'atau', 'bahwa', 'bagai', 'baru', 'beberapa', 'begitu', 'begini', 'bila', 'belum', 'betapa', 'banyak', 'boleh', 'cara', 'cuma', 'dan', 'dalam', 'dari', 'dapat', 'demikian', 'dengan', 'di', 'dia', 'hanya', 'harus', 'ialah', 'ini', 'ingin', 'itu', 'hanya', 'jika', 'juga', 'hendak', 'kali', 'kalau', 'kami', 'kan', 'karena', 'ke', 'kelak', 'kemudian', 'kenapa', 'kepada', 'kini', 'ku', 'lah', 'lain-lain', 'lagi', 'lalu', 'lama', 'lantas', 'maka', 'mana', 'masa', 'masih', 'mau', 'me', 'mereka', 'merupakan', 'meng', 'mengapa', 'mesti', 'mu', 'namun', 'nan', 'nun', 'nya', 'orang', 'pada', 'paling', 'pasti', 'para', 'pen', 'pengen', 'pernah', 'saat', 'saja', 'sana', 'sang', 'sangat', 'saya', 'sebagainya', 'sedang', 'sehingga', 'selain', 'selalu', 'seluruh', 'sekali', 'sekarang', 'sementara', 'semua', 'senantiasa', 'seorang', 'seseorang', 'seperti', 'serba', 'sering', 'serta', 'sesuatu', 'si', 'sini', 'situ', 'suatu', 'sudah', 'supaya', 'tahun', 'tanpa', 'telah', 'terus', 'untuk', 'yakni', 'yaitu', 'yang');
    return preg_replace('/\\b(' . implode('|', $commonWords) . ')\\b/', '', $input);
}
h2o::addFilter('remove_common_words');
Beispiel #8
0
 public function should_be_able_to_register_a_filter_collection()
 {
     h2o::addFilter('SampleFilters');
     $result = h2o('{{ person | hello }}')->render(array('person' => 'peter'));
     expects($result)->should_be('says hello to peter');
 }
Beispiel #9
0
                        if (method_exists($obj, $attribute)) {
                            $obj = call_user_func_array(array($obj, $attribute), array());
                        } else {
                            if (method_exists($obj, "get_" . $attribute)) {
                                $obj = call_user_func_array(array($obj, "get_" . $attribute), array());
                            } else {
                                if (method_exists($obj, "is_" . $attribute)) {
                                    $obj = call_user_func_array(array($obj, "is_" . $attribute), array());
                                } else {
                                    $obj = null;
                                }
                            }
                        }
                    }
                } else {
                    $obj = null;
                    break;
                }
            }
        }
    }
    return $obj;
}
h2o::addTag(array("sqlvalue"));
h2o::addTag(array("sparqlvalue"));
h2o::addTag(array("tplnotice"));
h2o::addFilter(array('pmb_StringFilters'));
h2o::addFilter(array('pmb_DateFilters'));
H2o::addLookup("messagesLookup");
H2o::addLookup("globalLookup");
H2o::addLookup("recursive_lookup");
Beispiel #10
0
<?php

require_once 'h2o/h2o.php';
h2o::addFilter('MyHtmlFilters');
class MyHtmlFilters extends FilterCollection
{
    function checked($data)
    {
        if ($data) {
            return 'checked';
        }
    }
    function select($case, $default = '')
    {
        var_dump($case);
        $select = new select_class($case, $case);
        $select->set_default($default);
        return $select->get_html();
    }
}
Beispiel #11
0
        }
    }
}
class Sparqlvalue_Tag extends H2o_Node
{
    private $struct_name;
    private $endpoint;
    function __construct($argstring, $parser, $position)
    {
        $params = explode(" ", $argstring);
        $this->struct_name = $params[0];
        $this->endpoint = $params[1];
        $this->sparql_query = $parser->parse('endsparqlvalue');
    }
    function render($context, $stream)
    {
        global $dbh;
        global $class_path;
        $query_stream = new StreamWriter();
        $this->sparql_query->render($context, $query_stream);
        $query = $query_stream->close();
        require_once "{$class_path}/rdf/arc2/ARC2.php";
        $config = array('remote_store_endpoint' => $this->endpoint, 'remote_store_timeout' => 10);
        $store = ARC2::getRemoteStore($config);
        $context->set($this->struct_name, $store->query($query, 'rows'));
    }
}
h2o::addTag(array("sqlvalue"));
h2o::addTag(array("sparqlvalue"));
h2o::addFilter(array('pmb_StringFilters'));