public function text_to_html($value) { switch (PERCH_APPS_EDITOR_MARKUP_LANGUAGE) { case 'textile': if (!class_exists('\\Netcarver\\Textile\\Parser', false) && class_exists('Textile', true)) { // sneaky autoloading hack } if (PERCH_HTML5) { $Textile = new \Netcarver\Textile\Parser('html5'); } else { $Textile = new \Netcarver\Textile\Parser(); } if (PERCH_RWD) { $value = $Textile->setDimensionlessImages(true)->textileThis($value); } else { $value = $Textile->textileThis($value); } break; case 'markdown': $Markdown = new PerchParsedown(); $value = $Markdown->text($value); break; } if (defined('PERCH_XHTML_MARKUP') && PERCH_XHTML_MARKUP == false) { $value = str_replace(' />', '>', $value); } return $value; }
/** * @return string */ public function render() { $parser = new \Netcarver\Textile\Parser(); $content = $this->renderChildren(); $content = nl2br($content); $content = $parser->textileThis($content); $content = $this->keepTags($content); return $content; }
protected function parseBody($source) { $event = Event::fire('theme.parser.init', []); if (count($event) == 1) { $parser = new \Netcarver\Textile\Parser($event[0]); } else { $parser = new \Netcarver\Textile\Parser(); } //parse the body return $parser->textileThis($source); }
public function text_to_html($value) { switch (PERCH_APPS_EDITOR_MARKUP_LANGUAGE) { case 'textile': if (!class_exists('\\Netcarver\\Textile\\Parser', false) && class_exists('Textile', true)) { // sneaky autoloading hack } if (PERCH_HTML5) { $Textile = new \Netcarver\Textile\Parser('html5'); } else { $Textile = new \Netcarver\Textile\Parser(); } if (PERCH_RWD) { $value = $Textile->setDimensionlessImages(true)->textileThis($value); } else { $value = $Textile->textileThis($value); } break; case 'markdown': // Fix markdown blockquote syntax - > gets encoded. $value = preg_replace('/[\\n\\r]>\\s/', "\n> ", $value); // Fix autolink syntax $value = preg_replace('#<(http[a-zA-Z0-9-\\.\\/:]*)>#', "<\$1>", $value); $Markdown = new ParsedownExtra(); $value = $Markdown->text($value); if (!class_exists('\\Michelf\\SmartyPants', false) && class_exists('SmartyPants', true)) { // sneaky autoloading hack } $SmartyPants = new \Michelf\SmartyPants(); $value = $SmartyPants->transform($value); if (PERCH_HTML_ENTITIES == false) { $value = html_entity_decode($value, ENT_NOQUOTES, 'UTF-8'); } break; } if (defined('PERCH_XHTML_MARKUP') && PERCH_XHTML_MARKUP == false) { $value = str_replace(' />', '>', $value); } return $value; }
function wikify($text) { global $SCRIPT_URL; // FIXME: Do not apply this in <pre> and <notextile> blocks. // Linkify $text = preg_replace('@([^:"])(https?://([-\\w\\.]+)+(:\\d+)?(/([%-\\w/_\\.]*(\\?\\S+)?)?)?)@', '$1<a href="$2">$2</a>', $text); // WikiLinkify $text = preg_replace('@\\[([\\w-\\.]+)\\]@', '<a href="' . $SCRIPT_URL . '/$1">$1</a>', $text); $text = preg_replace('@\\[([\\w-\\.]+)\\|([\\w-\\.\\s]+)\\]@', '<a href="' . $SCRIPT_URL . '/$1">$2</a>', $text); // Textilify $textile = new \Netcarver\Textile\Parser(); return $textile->textileThis($text); }
<?php $lists = '../'; $name = $_GET['id'] ? $_GET['id'] : $_POST['id']; $file = $lists . $name; $text = file_get_contents($file); $renderer = $_GET['renderer'] ? $_GET['renderer'] : $_POST['renderer']; if ('textile' == $renderer) { require './Parser.php'; require './DataBag.php'; require './Tag.php'; # require_once './Textile.php'; $t = new \Netcarver\Textile\Parser(); # $t = new Textile(); $text = $t->TextileThis($text); } print $text;
<?php $lists = '../'; $id = $_GET['id'] ? $_GET['id'] : $_POST['id']; $file = $lists . $id; $text = $_POST['value']; $renderer = $_GET['renderer'] ? $_GET['renderer'] : $_POST['renderer']; file_put_contents($file, $text); if ('textile' == $renderer) { require './Parser.php'; require './DataBag.php'; require './Tag.php'; # require_once './Textile.php'; $t = new \Netcarver\Textile\Parser(); # $t = new Textile(); $text = $t->TextileThis(stripslashes($text)); } print $text;
} } else { $server_software = @$_SERVER['SERVER_SOFTWARE'] || @$_SERVER['HTTP_HOST'] ? @$_SERVER['SERVER_SOFTWARE'] ? @$_SERVER['SERVER_SOFTWARE'] : $_SERVER['HTTP_HOST'] : ''; if (!stristr($server_software, 'Apache')) { $permlink_mode = 'messy'; } } $siteurl = str_replace("http://", '', $_SESSION['siteurl']); $siteurl = str_replace(' ', '%20', rtrim($siteurl, "/")); $urlpath = preg_replace('#^[^/]+#', '', $siteurl); $theme = $_SESSION['theme'] ? $_SESSION['theme'] : 'hive'; $themedir = txpath . DS . 'setup'; $create_sql = array(); $create_sql[] = "CREATE TABLE `" . PFX . "textpattern` (\n ID INT NOT NULL AUTO_INCREMENT,\n Posted DATETIME NOT NULL,\n Expires DATETIME NULL DEFAULT NULL,\n AuthorID VARCHAR(64) NOT NULL DEFAULT '',\n LastMod DATETIME NOT NULL,\n LastModID VARCHAR(64) NOT NULL DEFAULT '',\n Title VARCHAR(255) NOT NULL DEFAULT '',\n Title_html VARCHAR(255) NOT NULL DEFAULT '',\n Body MEDIUMTEXT NOT NULL,\n Body_html MEDIUMTEXT NOT NULL,\n Excerpt TEXT NOT NULL,\n Excerpt_html MEDIUMTEXT NOT NULL,\n Image VARCHAR(255) NOT NULL DEFAULT '',\n Category1 VARCHAR(64) NOT NULL DEFAULT '',\n Category2 VARCHAR(64) NOT NULL DEFAULT '',\n Annotate INT NOT NULL DEFAULT '0',\n AnnotateInvite VARCHAR(255) NOT NULL DEFAULT '',\n comments_count INT NOT NULL DEFAULT '0',\n Status INT NOT NULL DEFAULT '4',\n textile_body VARCHAR(32) NOT NULL DEFAULT '1',\n textile_excerpt VARCHAR(32) NOT NULL DEFAULT '1',\n Section VARCHAR(255) NOT NULL DEFAULT '',\n override_form VARCHAR(255) NOT NULL DEFAULT '',\n Keywords VARCHAR(255) NOT NULL DEFAULT '',\n description VARCHAR(255) NOT NULL DEFAULT '',\n url_title VARCHAR(255) NOT NULL DEFAULT '',\n custom_1 VARCHAR(255) NOT NULL DEFAULT '',\n custom_2 VARCHAR(255) NOT NULL DEFAULT '',\n custom_3 VARCHAR(255) NOT NULL DEFAULT '',\n custom_4 VARCHAR(255) NOT NULL DEFAULT '',\n custom_5 VARCHAR(255) NOT NULL DEFAULT '',\n custom_6 VARCHAR(255) NOT NULL DEFAULT '',\n custom_7 VARCHAR(255) NOT NULL DEFAULT '',\n custom_8 VARCHAR(255) NOT NULL DEFAULT '',\n custom_9 VARCHAR(255) NOT NULL DEFAULT '',\n custom_10 VARCHAR(255) NOT NULL DEFAULT '',\n uid VARCHAR(32) NOT NULL DEFAULT '',\n feed_time DATE NOT NULL,\n\n PRIMARY KEY (ID),\n INDEX categories_idx (Category1(10), Category2(10)),\n INDEX Posted (Posted),\n INDEX Expires_idx (Expires),\n INDEX author_idx (AuthorID),\n INDEX section_status_idx (Section(249), Status),\n INDEX url_title_idx (url_title(250)),\n FULLTEXT searching (Title, Body)\n) {$tabletype} "; $setup_comment_invite = gTxt('setup_comment_invite') == 'setup_comment_invite' ? 'Comment' : gTxt('setup_comment_invite'); $textile = new \Netcarver\Textile\Parser(); $article['body'] = file_get_contents(txpath . DS . 'setup' . DS . 'article.body.textile'); $article['excerpt'] = file_get_contents(txpath . DS . 'setup' . DS . 'article.excerpt.textile'); $article = str_replace('siteurl', $urlpath, $article); $article['body_html'] = $textile->textileThis($article['body']); $article['excerpt_html'] = $textile->textileThis($article['excerpt']); $article = doSlash($article); $create_sql[] = "INSERT INTO `" . PFX . "textpattern` VALUES (1, NOW(), NULL, '" . doSlash($_SESSION['name']) . "', NOW(), '', 'Welcome to your site', '', '" . $article['body'] . "', '" . $article['body_html'] . "', '" . $article['excerpt'] . "', '" . $article['excerpt_html'] . "', '', 'hope-for-the-future', 'meaningful-labor', 1, '" . $setup_comment_invite . "', 1, 4, '1', '1', 'articles', '', '', '', 'welcome-to-your-site', '', '', '', '', '', '', '', '', '', '', '" . md5(uniqid(rand(), true)) . "', NOW())"; $create_sql[] = "CREATE TABLE `" . PFX . "txp_category` (\n id INT NOT NULL AUTO_INCREMENT,\n name VARCHAR(64) NOT NULL DEFAULT '',\n type VARCHAR(64) NOT NULL DEFAULT '',\n parent VARCHAR(64) NOT NULL DEFAULT '',\n lft INT NOT NULL DEFAULT '0',\n rgt INT NOT NULL DEFAULT '0',\n title VARCHAR(255) NOT NULL DEFAULT '',\n description VARCHAR(255) NOT NULL DEFAULT '',\n\n PRIMARY KEY (id)\n) {$tabletype} "; $create_sql[] = "INSERT INTO `" . PFX . "txp_category` VALUES (1, 'root', 'article', '', 1, 8, 'root', '')"; $create_sql[] = "INSERT INTO `" . PFX . "txp_category` VALUES (2, 'root', 'link', '', 1, 4, 'root', '')"; $create_sql[] = "INSERT INTO `" . PFX . "txp_category` VALUES (3, 'root', 'image', '', 1, 4, 'root', '')"; $create_sql[] = "INSERT INTO `" . PFX . "txp_category` VALUES (4, 'root', 'file', '', 1, 2, 'root', '')"; $create_sql[] = "INSERT INTO `" . PFX . "txp_category` VALUES (5, 'hope-for-the-future', 'article', 'root', 2, 3, 'Hope for the future', '')"; $create_sql[] = "INSERT INTO `" . PFX . "txp_category` VALUES (6, 'meaningful-labor', 'article', 'root', 4, 5, 'Meaningful labor', '')"; $create_sql[] = "INSERT INTO `" . PFX . "txp_category` VALUES (7, 'reciprocal-affection', 'article', 'root', 6, 7, 'Reciprocal affection', '')";
public function parseTextile($value) { include_once __DIR__ . '/vendor/Netcarver/Textile/Parser.php'; $parser = new \Netcarver\Textile\Parser(); return $parser->textileThis($value); }
public function receive_new_listing($SubmittedForm) { $API = new PerchAPI(1.0, 'perch_members'); $Session = PerchMembers_Session::fetch(); $input = $SubmittedForm->data; $data = array(); $data['listingDateTime'] = date('Y-m-d H:i:s'); $data['memberID'] = $Session->get('memberID'); $data['listingType'] = $input['listingType']; $data['listingTitle'] = $input['listingTitle']; $data['listingSlug'] = PerchUtil::urlify($input['listingTitle']); foreach ($this->static_fields as $field) { if (!isset($data[$field])) { if (isset($input[$field]) && $input[$field] != '') { $data[$field] = trim($input[$field]); } } } // dynamic fields $dynamic_fields = array(); foreach ($input as $field => $val) { if (!isset($data[$field])) { $dynamic_fields[$field] = trim($val); } } $data['listingDynamicFields'] = PerchUtil::json_safe_encode($dynamic_fields); foreach ($data as $key => $val) { switch ($key) { case 'listingHTML': if (!class_exists('\\Netcarver\\Textile\\Parser', false) && class_exists('Textile', true)) { // sneaky autoloading hack } if (PERCH_HTML5) { $Textile = new \Netcarver\Textile\Parser('html5'); } else { $Textile = new \Netcarver\Textile\Parser(); } if (PERCH_RWD) { $val = $Textile->setDimensionlessImages(true)->textileRestricted($val); } else { $val = $Textile->textileRestricted($val); } if (defined('PERCH_XHTML_MARKUP') && PERCH_XHTML_MARKUP == false) { $val = str_replace(' />', '>', $val); } break; } $data[$key] = $val; } // print_r($data); // die(); if (isset($data['listingID'])) { if ($this->check_title_exists($data['listingTitle'], $data['listingID'])) { $Listings = new Listings($API); $Listing = $Listings->find($data['listingID']); // Don't allow people to change their URL unset($data['listingSlug']); $r = $Listing->update($data); } else { $SubmittedForm->throw_error('duplicate', 'listingTitle'); return false; } } else { if ($this->check_title_exists($data['listingTitle'])) { $r = $this->create($data); } else { $SubmittedForm->throw_error('duplicate', 'listingTitle'); return false; } } return $r; PerchUtil::debug('this' . $SubmittedForm); }
public function receive_new_comment($SubmittedForm) { $input = $SubmittedForm->data; if ($input['parentID']) { $data = array(); $data['parentID'] = $input['parentID']; $data['commentDateTime'] = date('Y-m-d H:i:s'); foreach ($this->static_fields as $field) { if (!isset($data[$field])) { if (isset($input[$field]) && $input[$field] != '') { $data[$field] = trim($input[$field]); } } } // dynamic fields $dynamic_fields = array(); foreach ($input as $field => $val) { if (!isset($data[$field])) { $dynamic_fields[$field] = trim($val); } } $data['commentDynamicFields'] = PerchUtil::json_safe_encode($dynamic_fields); // Anti-spam $Settings = $this->api->get('Settings'); $akismetAPIKey = $Settings->get('perch_comments_akismet_key')->val(); $spam = false; $antispam = $SubmittedForm->get_antispam_values(); $environment = $_SERVER; $spam_data = array(); $spam_data['fields'] = $antispam; $spam_data['environment'] = $environment; $data['commentSpamData'] = PerchUtil::json_safe_encode($spam_data); $data['commentIP'] = ip2long($_SERVER['REMOTE_ADDR']); $spam = $this->_check_for_spam($antispam, $environment, $akismetAPIKey); if ($spam) { $data['commentStatus'] = 'SPAM'; } else { $Users = new PerchUsers(); $CurrentUser = $Users->get_current_user(); if (is_object($CurrentUser) && $CurrentUser->logged_in()) { $data['commentStatus'] = 'LIVE'; } else { $data['commentStatus'] = 'PENDING'; } } foreach ($data as $key => $val) { switch ($key) { case 'commentHTML': if (!class_exists('\\Netcarver\\Textile\\Parser', false) && class_exists('Textile', true)) { // sneaky autoloading hack } if (PERCH_HTML5) { $Textile = new \Netcarver\Textile\Parser('html5'); } else { $Textile = new \Netcarver\Textile\Parser(); } if (PERCH_RWD) { $val = $Textile->setDimensionlessImages(true)->textileRestricted($val); } else { $val = $Textile->textileRestricted($val); } if (defined('PERCH_XHTML_MARKUP') && PERCH_XHTML_MARKUP == false) { $val = str_replace(' />', '>', $val); } break; case 'commentURL': if (!parse_url($val, PHP_URL_SCHEME)) { $val = 'http://' . $val; } if (!parse_url($val, PHP_URL_SCHEME)) { $val = ''; } $val = strtolower($val); break; case 'commentEmail': $val = strtolower($val); break; case 'parentTitle': $val = html_entity_decode($val, ENT_QUOTES, 'UTF-8'); break; } $data[$key] = $val; } $r = $this->create($data); return $r; } PerchUtil::debug($SubmittedForm); }
<?php use Netcarver\Textile; $parser = new \Netcarver\Textile\Parser(); echo $parser->textileThis($task->text);
/** * Legacy Textile function. Do not use. * @param [type] $string [description] * @param boolean $strip_tags [description] * @return [type] [description] */ public static function text_to_html($string, $strip_tags = true) { PerchUtil::debug('Converting to Textile using deprecated PerchUtil::text_to_html', 'notice'); if ($strip_tags) { $string = strip_tags($string); } if (!class_exists('\\Netcarver\\Textile\\Parser', false) && class_exists('Textile', true)) { // sneaky autoloading hack } if (PERCH_HTML5) { $Textile = new \Netcarver\Textile\Parser('html5'); } else { $Textile = new \Netcarver\Textile\Parser(); } if (PERCH_RWD) { $string = $Textile->setDimensionlessImages(true)->textileThis($string); } else { $string = $Textile->textileThis($string); } if (defined('PERCH_XHTML_MARKUP') && PERCH_XHTML_MARKUP == false) { $string = str_replace(' />', '>', $string); } return $string; }
<?php use yii\helpers\Html; use yii\widgets\ActiveForm; use yii\helpers\Url; use yii\bootstrap\Modal; use common\components\DateHelper; use yii\widgets\Pjax; use Netcarver\Textile; $parser = new \Netcarver\Textile\Parser(); use yii\helpers\ArrayHelper; /* @var $this yii\web\View */ /* @var $model common\models\CompleteTask */ /* @var $form yii\widgets\ActiveForm */ $this->registerJs('$("#form-task").on("pjax:end", function(){ $("#modal").modal("hide")});'); ?> <div class="complete-task-form"> <?php Pjax::begin(['enablePushState' => false, 'id' => 'form-task']); ?> <?php $form = ActiveForm::begin(['options' => ['data-pjax' => true]]); ?> <?php //= $form->field($model, 'given_task_id')->textInput() ?> <div class='well well-sm'>
<?php use yii\helpers\Html; use yii\widgets\DetailView; $parser = new \Netcarver\Textile\Parser(); /* @var $this yii\web\View */ /* @var $model common\models\CompleteExercise $this->title = $model->id; $this->params['breadcrumbs'][] = ['label' => 'Complete Exercises', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title;*/ ?> <?php echo $parser->textileThis($model->text);
public function format($text) { $parser = new \Netcarver\Textile\Parser(); return $parser->textileThis($text); }
public function __construct($doctype = 'xhtml') { parent::__construct($doctype); $this->unrestricted_url_schemes[] = 'redaxo'; }
} // 1.0: log status and method. $txplog = getThings("DESCRIBE `" . PFX . "txp_log`"); if (!in_array('status', $txplog)) { safe_alter('txp_log', "ADD status INT NOT NULL DEFAULT '200'"); } if (!in_array('method', $txplog)) { safe_alter('txp_log', "ADD method VARCHAR(16) NOT NULL DEFAULT 'GET'"); } if (!in_array('ip', $txplog)) { safe_alter('txp_log', "ADD ip VARCHAR(16) NOT NULL DEFAULT ''"); } // 1.0: need to get Excerpt_html values into the textpattern table, so catch // empty ones and populate them. $rs = mysqli_query($DB->link, "SELECT ID, Excerpt, textile_excerpt FROM `" . PFX . "textpattern` WHERE Excerpt_html LIKE ''"); $textile = new \Netcarver\Textile\Parser(); while ($a = @mysqli_fetch_assoc($rs)) { extract($a); assert_int($ID); $lite = $textile_excerpt ? '' : 1; $Excerpt_html = $textile->textileThis($Excerpt, $lite); safe_update('textpattern', "Excerpt_html = '" . doSlash($Excerpt_html) . "'", "ID = {$ID}"); } // 1.0 feed unique ids. // Blog unique id. if (safe_field("val", 'txp_prefs', "name = 'blog_uid'") === false) { $prefs['blog_uid'] = md5(uniqid(rand(), true)); safe_insert('txp_prefs', "name = 'blog_uid', val = '" . $prefs['blog_uid'] . "', prefs_id = '1'"); } if (safe_field("name", 'txp_prefs', "name = 'blog_mail_uid'") === false) { $mail = safe_field('email', 'txp_users', "privs = '1' LIMIT 1");
<?php use yii\helpers\Html; use yii\widgets\ActiveForm; use yii\helpers\Url; use yii\bootstrap\Modal; use common\components\DateHelper; use yii\widgets\Pjax; use Netcarver\Textile; $parser = new \Netcarver\Textile\Parser(); /* @var $this yii\web\View */ /* @var $model common\models\CompleteTask */ /* @var $form yii\widgets\ActiveForm */ $this->registerJs('$("#form-task").on("pjax:end", function(){ $("#modal").modal("hide")});'); ?> <div class="complete-task-form"> <?php Pjax::begin(['enablePushState' => false, 'id' => 'form-task']); ?> <?php $form = ActiveForm::begin(['options' => ['data-pjax' => true]]); ?> <?php //= $form->field($model, 'given_task_id')->textInput() ?> <?php
public function get_raw($post = false, $Item = false) { if ($post === false) { $post = $_POST; } $id = $this->Tag->id(); if (isset($post[$id])) { $raw = trim($post[$id]); $raw = PerchUtil::safe_stripslashes($raw); $value = $raw; $flang = 'plain'; if ($this->Tag->html()) { $flang = 'html'; } $formatting_language_used = false; // Strip HTML by default if (!is_array($value) && PerchUtil::bool_val($this->Tag->html()) == false) { $value = PerchUtil::html($value); $value = strip_tags($value); } // Textile if (!$formatting_language_used && PerchUtil::bool_val($this->Tag->textile()) == true) { if (!class_exists('\\Netcarver\\Textile\\Parser', false) && class_exists('Textile', true)) { // sneaky autoloading hack } if (PERCH_HTML5) { $Textile = new \Netcarver\Textile\Parser('html5'); } else { $Textile = new \Netcarver\Textile\Parser(); } if (PERCH_RWD) { $value = $Textile->setDimensionlessImages(true)->textileThis($value); } else { $value = $Textile->textileThis($value); } if (defined('PERCH_XHTML_MARKUP') && PERCH_XHTML_MARKUP == false) { $value = str_replace(' />', '>', $value); } $formatting_language_used = true; $flang = 'textile'; } // Markdown if (!$formatting_language_used && PerchUtil::bool_val($this->Tag->markdown()) == true) { $Markdown = new PerchParsedown(); $value = $Markdown->text($value); $formatting_language_used = true; $flang = 'markdown'; } else { // Smartypants without Markdown (MD gets it by default) if (PerchUtil::bool_val($this->Tag->smartypants()) == true) { $Markdown = new PerchParsedown(); $value = $Markdown->smartypants($value); $flang = 'smartypants'; } } $store = array('_flang' => $flang, 'raw' => $raw, 'processed' => $value); $this->raw_item = $store; return $this->raw_item; } return null; }