public function filter($text)
 {
     if (Options::get('typogrify__do_amp')) {
         $text = amp($text);
     }
     if (Options::get('typogrify__do_widont')) {
         $text = widont($text);
     }
     if (Options::get('typogrify__do_smartypants')) {
         // Standard options plus convert_quot ('w') to
         // convert " entities, that Habari might
         // already have converted '"' characters into.
         $text = SmartyPants($text, "qbdew");
     }
     if (Options::get('typogrify__do_caps')) {
         $text = caps($text);
     }
     if (Options::get('typogrify__do_initial_quotes')) {
         $text = initial_quotes($text);
     }
     if (Options::get('typogrify__do_guillemets')) {
         $text = initial_quotes($text, true);
     }
     if (Options::get('typogrify__do_dash')) {
         $text = dash($text);
     }
     return $text;
 }
Esempio n. 2
0
function makeBlurb($triples_database)
{
    $n_of_words = 50;
    // Starts with a random word.
    $out_string = array_keys($triples_database)[rand(0, count($triples_database))];
    $temp_words = array();
    for ($i = 0; $i < $n_of_words; $i++) {
        $temp_words = preg_split('#\\s+#', $out_string, null, PREG_SPLIT_NO_EMPTY);
        $temp_key = $temp_words[count($temp_words) - 2] . " " . $temp_words[count($temp_words) - 1];
        $out_string .= " ";
        $out_string .= $triples_database[$temp_key][rand(0, count($triples_database[$temp_key]))];
    }
    // Ensures the last word ends with punctuation, naturally.
    $temp_words = preg_split('#\\s+#', $out_string, null, PREG_SPLIT_NO_EMPTY);
    while (substr($temp_words[count($temp_words) - 1], -1, 1) != "." && substr($temp_words[count($temp_words) - 1], -1, 1) != "!" && substr($temp_words[count($temp_words) - 1], -1, 1) != "?") {
        $temp_key = $temp_words[count($temp_words) - 2] . " " . $temp_words[count($temp_words) - 1];
        $out_string .= " ";
        $out_string .= $triples_database[$temp_key][rand(0, count($triples_database[$temp_key]))];
        $temp_words = preg_split('#\\s+#', $out_string, null, PREG_SPLIT_NO_EMPTY);
    }
    echo caps($out_string);
}
Esempio n. 3
0
        $content = trim($_POST['content']);
        $invalid = check_inputs(['title' => true, 'description' => '.{10,160}', 'keywords' => '[\\w-\\, ]+', 'content' => true], ['title' => $title, 'description' => $description, 'keywords' => $keywords, 'content' => $content]);
        if (is_null($invalid)) {
            $user = $DB->prepare('SELECT `g_plus`, `name`
				FROM `users`
				WHERE `user` = :user
				LIMIT 1;')->bind(['user' => $login->user])->execute()->getResults(0);
            /*$title = urldecode(trim(strip_tags($_POST['title'])));
            		$description = trim($_POST['description']);
            		$keywords = urldecode(trim(strip_tags($_POST['keywords'])));
            		$content = trim($_POST['content']);*/
            $author = $user->name;
            $url = urlencode(strtolower(preg_replace('/\\W+/', ' ', $title)));
            $template = new \shgysk8zer0\Core\Template('posts');
            foreach (explode(',', $keywords) as $tag) {
                $template->tags .= '<a href="tags/' . trim(strtolower(preg_replace('/\\s/', '-', trim($tag)))) . '">' . trim(caps($tag)) . "</a>";
            }
            $stm = $DB->prepare("INSERT INTO `posts`(\n\t\t\t\t\t`title`,\n\t\t\t\t\t`description`,\n\t\t\t\t\t`keywords`,\n\t\t\t\t\t`author`,\n\t\t\t\t\t`author_url`,\n\t\t\t\t\t`content`,\n\t\t\t\t\t`url`,\n\t\t\t\t\t`created`\n\t\t\t\t) VALUE(\n\t\t\t\t\t:title,\n\t\t\t\t\t:description,\n\t\t\t\t\t:keywords,\n\t\t\t\t\t:author,\n\t\t\t\t\t:author_url,\n\t\t\t\t\t:content,\n\t\t\t\t\t:url,\n\t\t\t\t\t:created\n\t\t\t\t);")->bind(['title' => $title, 'description' => $description, 'keywords' => $keywords, 'author' => $user->name, 'author_url' => $user->g_plus, 'content' => $content, 'url' => $url, 'created' => date('Y-m-d H:i:s')]);
            if ($stm->execute()) {
                $template = \shgysk8zer0\Core\Template::load('posts');
                $template->title($title)->content($content)->author($user->name)->author_url($user->g_plus)->date(date('m/d/Y'))->datetime(time());
                $url = URL . '/posts/' . $url;
                $resp->notify('Post submitted', 'Check for new posts')->remove('main > :not(aside)')->prepend('body > header nav', "<a href=\"{$url}\">{$title}</a>")->prepend('main', "{$template}")->after('#main_menu > menu[label="Posts"] > menuitem[label="Home"]', "<menuitem label=\"{$title}\" icon=\"images/icons/coffee.svgz\" data-link=\"{$url}\"></menuitem>");
                $resp->remove('main > :not(aside)');
                update_sitemap();
                update_rss();
            } else {
                $resp->notify('Post failed', 'Look into what went wrong. See Developer console')->log($_POST);
            }
        } else {
            $resp->notify('Something went wrong...', 'There seems to be some missing info.');
 public function capsFilter($str)
 {
     $charset = craft()->templates->getTwig()->getCharset();
     $str = caps($str);
     return new \Twig_Markup($str, $charset);
 }
Esempio n. 5
0
/**
 * typogrify
 * 
 * The super typography filter.   
 * Applies the following filters: widont, smartypants, caps, amp, initial_quotes
 * Optionally choose to apply quote span tags to Gullemets as well.
 */
function typogrify($text, $do_guillemets = false)
{
    $text = amp($text);
    $text = widont($text);
    $text = SmartyPants($text);
    $text = caps($text);
    $text = initial_quotes($text, $do_guillemets);
    $text = dash($text);
    return $text;
}