/**
  * Apply Textile to the main article fields.
  *
  * This is duplicated from txp_article.php.
  *
  * @param  array $incoming    The incoming fields
  * @param  bool  $use_textile Use Textile or not
  * @return array The $incoming array formatted
  * @access private
  */
 public function textile_main_fields($incoming, $use_textile = 1)
 {
     global $txpcfg;
     $textile = new \Textpattern\Textile\Parser();
     if (!empty($event) and $event == 'article') {
         $incoming['Title_plain'] = $incoming['Title'];
     }
     if ($incoming['textile_body'] == USE_TEXTILE) {
         $incoming['Title'] = $textile->textileThis($incoming['Title'], '', 1);
     }
     $incoming['url_title'] = preg_replace('|[\\x00-\\x1f#%+/?\\x7f]|', '', $incoming['url_title']);
     $incoming['Body_html'] = TXP_Wrapper::format_field($incoming['Body'], $incoming['textile_body'], $textile);
     $incoming['Excerpt_html'] = TXP_Wrapper::format_field($incoming['Excerpt'], $incoming['textile_excerpt'], $textile);
     return $incoming;
 }
Example #2
0
/**
 * Installs a plugin.
 */
function plugin_install()
{
    $plugin = assert_string(ps('plugin64'));
    if (strpos($plugin, '$plugin=\'') !== false) {
        @ini_set('pcre.backtrack_limit', '1000000');
        $plugin = preg_replace('@.*\\$plugin=\'([\\w=+/]+)\'.*@s', '$1', $plugin);
    }
    $plugin = preg_replace('/^#.*$/m', '', $plugin);
    if (trim($plugin)) {
        $plugin = base64_decode($plugin);
        if (strncmp($plugin, "‹", 2) === 0) {
            $plugin = gzinflate(substr($plugin, 10));
        }
        if ($plugin = unserialize($plugin)) {
            if (is_array($plugin)) {
                extract($plugin);
                $type = empty($type) ? 0 : min(max(intval($type), 0), 5);
                $order = empty($order) ? 5 : min(max(intval($order), 1), 9);
                $flags = empty($flags) ? 0 : intval($flags);
                $exists = fetch('name', 'txp_plugin', 'name', $name);
                if (isset($help_raw) && empty($plugin['allow_html_help'])) {
                    // Default: help is in Textile format.
                    $textile = new \Textpattern\Textile\Parser();
                    $help = $textile->textileRestricted($help_raw, 0, 0);
                }
                if ($exists) {
                    $rs = safe_update('txp_plugin', "type        = {$type},\n                        author       = '" . doSlash($author) . "',\n                        author_uri   = '" . doSlash($author_uri) . "',\n                        version      = '" . doSlash($version) . "',\n                        description  = '" . doSlash($description) . "',\n                        help         = '" . doSlash($help) . "',\n                        code         = '" . doSlash($code) . "',\n                        code_restore = '" . doSlash($code) . "',\n                        code_md5     = '" . doSlash($md5) . "',\n                        flags        = {$flags}", "name        = '" . doSlash($name) . "'");
                } else {
                    $rs = safe_insert('txp_plugin', "name         = '" . doSlash($name) . "',\n                        status       = 0,\n                        type         = {$type},\n                        author       = '" . doSlash($author) . "',\n                        author_uri   = '" . doSlash($author_uri) . "',\n                        version      = '" . doSlash($version) . "',\n                        description  = '" . doSlash($description) . "',\n                        help         = '" . doSlash($help) . "',\n                        code         = '" . doSlash($code) . "',\n                        code_restore = '" . doSlash($code) . "',\n                        code_md5     = '" . doSlash($md5) . "',\n                        load_order   = '" . $order . "',\n                        flags        = {$flags}");
                }
                if ($rs and $code) {
                    if (!empty($textpack)) {
                        // Plugins tag their Textpack by plugin name.
                        // The ownership may be overridden in the Textpack itself.
                        $textpack = "#@owner {$name}" . n . $textpack;
                        install_textpack($textpack, false);
                    }
                    if ($flags & PLUGIN_LIFECYCLE_NOTIFY) {
                        load_plugin($name, true);
                        $message = callback_event("plugin_lifecycle.{$name}", 'installed');
                    }
                    if (empty($message)) {
                        $message = gTxt('plugin_installed', array('{name}' => $name));
                    }
                    plugin_list($message);
                    return;
                } else {
                    $message = array(gTxt('plugin_install_failed', array('{name}' => $name)), E_ERROR);
                    plugin_list($message);
                    return;
                }
            }
        }
    }
    plugin_list(array(gTxt('bad_plugin_code'), E_ERROR));
}
Example #3
0
/**
 * Parses article fields using Textile.
 *
 * @param  array $incoming
 * @return array
 */
function textile_main_fields($incoming)
{
    $textile = new \Textpattern\Textile\Parser();
    $incoming['Title_plain'] = trim($incoming['Title']);
    $incoming['Title_html'] = '';
    // not used
    $incoming['Title'] = $textile->textileEncode($incoming['Title_plain']);
    $incoming['Body_html'] = Txp::get('\\Textpattern\\Textfilter\\Registry')->filter($incoming['textile_body'], $incoming['Body'], array('field' => 'Body', 'options' => array('lite' => false), 'data' => $incoming));
    $incoming['Excerpt_html'] = Txp::get('\\Textpattern\\Textfilter\\Registry')->filter($incoming['textile_excerpt'], $incoming['Excerpt'], array('field' => 'Excerpt', 'options' => array('lite' => false), 'data' => $incoming));
    return $incoming;
}
Example #4
0
/**
 * Parses and formats comment message using Textile.
 *
 * @param   string $msg The comment message
 * @return  string HTML markup
 * @package Comment
 */
function markup_comment($msg)
{
    $textile = new \Textpattern\Textile\Parser();
    return $textile->textileRestricted($msg);
}