Example #1
0
 function header()
 {
     global $txp_user;
     $out[] = '<div id="masthead"><ul id="nav">';
     foreach ($this->menu as $tab) {
         $class = $tab['active'] ? 'tabup active' : 'tabdown inactive';
         $out[] = "<li class='primary {$class}'><a href='?event={$tab['event']}'>{$tab['label']}</a>";
         if (!empty($tab['items'])) {
             $out[] = '<ul>';
             foreach ($tab['items'] as $item) {
                 $class = $item['active'] ? 'tabup active' : 'tabdown2 inactive';
                 $out[] = "<li class='secondary {$class}'><a href='?event={$item['event']}'>{$item['label']}</a></li>";
             }
             $out[] = '</ul>';
         }
         $out[] = '</li>';
     }
     $out[] = '<li id="view-site" class="primary tabdown inactive"><a href="' . hu . '" target="_blank">' . gTxt('tab_view_site') . '</a></li>';
     if ($txp_user) {
         $out[] = '<li id="logout" class="primary tabdown inactive"><a href="index.php?logout=1" onclick="return verify(\'' . gTxt('are_you_sure') . '\')">' . gTxt('logout') . '</a></li>';
     }
     $out[] = '</ul></div>';
     $out[] = '<div id="messagepane">' . $this->announce($this->message) . '</div>';
     return join(n, $out);
 }
Example #2
0
    function announce($thing)
    {
        // $thing[0]: message text
        // $thing[1]: message type, defaults to "success" unless empty or a different flag is set
        if ($thing === '') {
            return '';
        }
        if (!is_array($thing) || !isset($thing[1])) {
            $thing = array($thing, 0);
        }
        switch ($thing[1]) {
            case E_ERROR:
                $class = 'error';
                break;
            case E_WARNING:
                $class = 'warning';
                break;
            default:
                $class = 'success';
                break;
        }
        $html = "<span id='message' class='{$class}'>" . gTxt($thing[0]) . '</span>';
        // Try to inject $html into the message pane no matter when announce()'s output is printed
        $js = addslashes($html);
        $js = <<<EOS
 \t\t\$(document).ready( function(){
\t \t\t\$("#messagepane").html("{$js}");
\t\t\t\$('#messagepane #message.error').fadeOut(800).fadeIn(800);
\t\t\t\$('#messagepane #message.warning').fadeOut(800).fadeIn(800);
\t\t} )
EOS;
        return script_js(str_replace('</', '<\\/', $js), $html);
    }
Example #3
0
 function set_state($area, $event, $is_popup, $message)
 {
     $this->is_popup = $is_popup;
     $this->message = $message;
     if ($is_popup) {
         return $this;
     }
     // use legacy areas() for b/c
     $areas = areas();
     $tabs = array('content' => array('label' => gTxt('tab_content'), 'event' => 'article'), 'presentation' => array('label' => gTxt('tab_presentation'), 'event' => 'page'), 'admin' => array('label' => gTxt('tab_admin'), 'event' => 'admin'));
     if (empty($areas['extensions'])) {
         unset($areas['extensions']);
     } else {
         $tabs = $tabs + array('extensions' => array('label' => gTxt('tab_extensions'), 'event' => reset($areas['extensions'])));
     }
     foreach ($areas as $ar => $items) {
         if (has_privs('tab.' . $ar)) {
             $this->menu[$ar] = array('label' => $tabs[$ar]['label'], 'event' => $tabs[$ar]['event'], 'active' => $ar == $area);
             foreach ($items as $a => $b) {
                 if (has_privs($b)) {
                     $this->menu[$ar]['items'][] = array('label' => $a, 'event' => $b, 'active' => $b == $event);
                 }
             }
         }
     }
     return $this;
 }
Example #4
0
 /**
  * {@inheritdoc}
  */
 public function __construct($callable)
 {
     if (!is_callable($callable)) {
         throw new Textpattern_Filter_Exception(gTxt('assert_callable'));
     }
     parent::__construct($callable);
 }
Example #5
0
 /**
  * {@inheritdoc}
  */
 public function register($alias, $class)
 {
     if (isset($this->registered[$alias])) {
         throw new InvalidArgumentException(gTxt('alias_is_taken'));
     }
     $this->registered[$alias] = $class;
     return $this;
 }
Example #6
0
 /**
  * User interface
  */
 static function ui($event, $step)
 {
     global $step;
     pagetop(gTxt(__CLASS__));
     $available_steps = array('export');
     if (!$step or !in_array($step, $available_steps)) {
         $step = 'export';
     }
     self::$step();
 }
Example #7
0
function export($message = '')
{
    global $prefs;
    extract($prefs);
    $template = new template();
    pagetop(gTxt('template'), $message);
    print "\n    <style type='text/css'>\n        .success { color: #009900; }\n        .failure { color: #FF0000; }\n    </style>\n\t\t\t\n    <table cellpadding='0' cellspacing='0' border='0' id='list' align='center'>\n        <tr>\n            <td>\n    ";
    $dir = ps('export_dir');
    $dir = str_replace(array(" "), array("-"), $dir);
    $template->export($dir);
    print "\n          </td>\n      </tr>\n  </table>\n  ";
}
Example #8
0
 /**
  * Constructor.
  *
  * @param string|null $doctype The output doctype
  */
 public function __construct($doctype = null)
 {
     if ($doctype === null) {
         $doctype = get_pref('doctype', 'html5');
     }
     parent::__construct($doctype);
     $this->setRelativeImagePrefix(hu);
     $this->setSymbol('quote_single_open', gTxt('txt_quote_single_open'));
     $this->setSymbol('quote_single_close', gTxt('txt_quote_single_close'));
     $this->setSymbol('quote_double_open', gTxt('txt_quote_double_open'));
     $this->setSymbol('quote_double_close', gTxt('txt_quote_double_close'));
 }
Example #9
0
function show_mentions()
{
    global $id;
    if ($id) {
        $rs = safe_rows("*", "txp_log_mention", "article_id='{$id}'");
        if ($rs) {
            foreach ($rs as $a) {
                extract($a);
                $out[] = '<a href="http://' . $refpage . '" title="' . $excerpt . '">' . $reftitle . '</a>';
            }
            return hed(gTxt('mentions'), 3) . graf(join(br, $out));
        }
    }
}
Example #10
0
function reset_author_pass($name)
{
    $email = safe_field('email', 'txp_users', "name = '" . doSlash($name) . "'");
    $new_pass = doSlash(generate_password(6));
    $rs = safe_update('txp_users', "pass = password(lower('{$new_pass}'))", "name = '" . doSlash($name) . "'");
    if ($rs) {
        if (send_new_password($new_pass, $email, $name)) {
            return gTxt('password_sent_to') . ' ' . $email;
        } else {
            return gTxt('could_not_mail') . ' ' . $email;
        }
    } else {
        return gTxt('could_not_update_author') . ' ' . htmlspecialchars($name);
    }
}
Example #11
0
 /**
  * Sets the locale.
  *
  * This method wraps around system setlocale. It takes an IETF language code
  * and sets the locale accordingly.
  *
  * The following would set the locale to English:
  *
  * <code>
  * Txp::get('Textpattern\L10n\Locale')->setLocale(LC_ALL, 'en-GB');
  * </code>
  *
  * This would format currencies according to the French localisation:
  *
  * <code>
  * Txp::get('Textpattern\L10n\Locale')->setLocale(LC_MONETARY, 'fr-FR');
  * echo money_format('%i', 51.99);
  * </code>
  *
  * The '51.99' would be returned as '51,99 EUR' if you have up to date
  * French locale installed on your system.
  *
  * If an array of locales is provided, the first one that works is used.
  *
  * @param  int          $category The localisation category to change
  * @param  string|array $locale   The language code
  * @return Locale
  * @throws \Exception
  * @see    setlocale()
  */
 public function setLocale($category, $locale)
 {
     foreach ((array) $locale as $name) {
         $code = strtolower($name);
         if (isset($this->locales[$code])) {
             if (@setlocale($category, $this->locales[$code])) {
                 return $this;
             }
         }
     }
     if (@setlocale($category, $name)) {
         return $this;
     }
     throw new \Exception(gTxt('invalid_argument', array('{name}' => 'locale')));
 }
function reset_author_pass($name)
{
    $email = safe_field('email', 'txp_users', "name = '" . doSlash($name) . "'");
    $new_pass = generate_password(PASSWORD_LENGTH);
    $hash = doSlash(txp_hash_password($new_pass));
    $rs = safe_update('txp_users', "pass = '******'", "name = '" . doSlash($name) . "'");
    if ($rs) {
        if (send_new_password($new_pass, $email, $name)) {
            return gTxt('password_sent_to') . ' ' . $email;
        } else {
            return gTxt('could_not_mail') . ' ' . $email;
        }
    } else {
        return gTxt('could_not_update_author') . ' ' . txpspecialchars($name);
    }
}
Example #13
0
function element_list($event, $step)
{
    $message = '';
    pagetop(gTxt('element'), $message);
    echo startTable('list') . assHead('element', 'version', 'date', 'active', 'checksum');
    $rs = safe_rows('*', 'txp_element', '1=1');
    foreach ($rs as $row) {
        extract($row);
        if ($hash) {
            $checksum = md5_file(txpath . '/elements/' . $name . '.php') == $hash ? gTxt('ok') : gTxt('modified');
        } else {
            $checksum = gTxt('unknown');
        }
        echo tr(td($name) . td($version) . td($modified) . td($status ? gTxt('yes') : gTxt('no')) . td($checksum));
    }
    echo endTable();
}
Example #14
0
/**
 * Performs searching and returns results.
 *
 * This is now performed by doArticles().
 *
 * @param      string $q
 * @deprecated in 4.0.4
 * @see        doArticles()
 */
function search($q)
{
    global $prefs;
    $url = $prefs['siteurl'];
    extract($prefs);
    $s_filter = filterSearch();
    $form = fetch('form', 'txp_form', 'name', 'search_results');
    // Lose this eventually - only used if search_results form is missing.
    $form = !$form ? legacy_form() : $form;
    $rs = safe_rows("*, ID AS thisid, UNIX_TIMESTAMP(Posted) AS posted, Title AS title,\n        MATCH (Title,Body) AGAINST ('{$q}') AS score", 'textpattern', "(Title RLIKE '{$q}' OR Body RLIKE '{$q}') {$s_filter}\n        AND Status = 4 AND Posted <= " . now('posted') . " ORDER BY score DESC LIMIT 40");
    if ($rs) {
        $result_rows = count($rs);
        $text = $result_rows == 1 ? gTxt('article_found') : gTxt('articles_found');
    } else {
        $result_rows = 0;
        $text = gTxt('articles_found');
    }
    $results[] = graf($result_rows . ' ' . $text);
    if ($result_rows > 0) {
        foreach ($rs as $a) {
            extract($a);
            $result_date = safe_strftime($archive_dateformat, $posted);
            $uTitle = $url_title ? $url_title : stripSpace($Title);
            $hurl = permlinkurl($a);
            $result_url = '<a href="' . $hurl . '">' . $hurl . '</a>';
            $result_title = '<a href="' . $hurl . '">' . $Title . '</a>';
            $result = preg_replace("/>\\s*</", "> <", $Body_html);
            preg_match_all("/\\s.{1,50}" . preg_quote($q) . ".{1,50}\\s/i", $result, $concat);
            $concat = join(" ... ", $concat[0]);
            $concat = strip_tags($concat);
            $concat = preg_replace('/^[^>]+>/U', "", $concat);
            $concat = preg_replace("/({$q})/i", "<strong>\$1</strong>", $concat);
            $result_excerpt = $concat ? "... " . $concat . " ..." : '';
            $glob['search_result_title'] = $result_title;
            $glob['search_result_excerpt'] = $result_excerpt;
            $glob['search_result_url'] = $result_url;
            $glob['search_result_date'] = $result_date;
            $GLOBALS['this_result'] = $glob;
            $thisresult = $form;
            $results[] = parse($thisresult);
        }
    }
    return is_array($results) ? join('', $results) : '';
}
Example #15
0
function search($q)
{
    global $prefs;
    $url = $prefs['siteurl'];
    extract($prefs);
    $s_filter = filterSearch();
    $form = fetch('form', 'txp_form', 'name', 'search_results');
    // lose this eventually - only used if search_results form is missing
    $form = !$form ? legacy_form() : $form;
    $rs = safe_rows("*, ID as thisid, unix_timestamp(Posted) as posted, Title as title,\n\t\t\tmatch (Title,Body) against ('{$q}') as score", "textpattern", "(Title rlike '{$q}' or Body rlike '{$q}') {$s_filter}\n\t\t\tand Status = 4 and Posted <=now() order by score desc limit 40");
    if ($rs) {
        $result_rows = count($rs);
        $text = $result_rows == 1 ? gTxt('article_found') : gTxt('articles_found');
    } else {
        $result_rows = 0;
        $text = gTxt('articles_found');
    }
    $results[] = graf($result_rows . ' ' . $text);
    if ($result_rows > 0) {
        foreach ($rs as $a) {
            extract($a);
            $result_date = safe_strftime($archive_dateformat, $posted);
            $uTitle = $url_title ? $url_title : stripSpace($Title);
            $hurl = permlinkurl($a);
            $result_url = '<a href="' . $hurl . '">' . $hurl . '</a>';
            $result_title = '<a href="' . $hurl . '">' . $Title . '</a>';
            $result = preg_replace("/>\\s*</", "> <", $Body_html);
            preg_match_all("/\\s.{1,50}" . preg_quote($q) . ".{1,50}\\s/i", $result, $concat);
            $concat = join(" ... ", $concat[0]);
            $concat = strip_tags($concat);
            $concat = preg_replace('/^[^>]+>/U', "", $concat);
            $concat = preg_replace("/({$q})/i", "<strong>\$1</strong>", $concat);
            $result_excerpt = $concat ? "... " . $concat . " ..." : '';
            $glob['search_result_title'] = $result_title;
            $glob['search_result_excerpt'] = $result_excerpt;
            $glob['search_result_url'] = $result_url;
            $glob['search_result_date'] = $result_date;
            $GLOBALS['this_result'] = $glob;
            $thisresult = $form;
            $results[] = parse($thisresult);
        }
    }
    return is_array($results) ? join('', $results) : '';
}
Example #16
0
function log_list()
{
    pagetop(gTxt('visitor_logs'));
    extract(get_prefs());
    safe_delete("txp_log", "`time` < date_sub(now(),interval " . $expire_logs_after . " day)");
    safe_optimize("txp_log");
    safe_repair("txp_log");
    $page = gps('page');
    $total = getCount('txp_log', "1");
    $limit = 50;
    $numPages = ceil($total / $limit);
    $page = !$page ? 1 : $page;
    $offset = ($page - 1) * $limit;
    $nav[] = $page > 1 ? PrevNextLink("log", $page - 1, gTxt('prev'), 'prev') : '';
    $nav[] = sp . small($page . '/' . $numPages) . sp;
    $nav[] = $page != $numPages ? PrevNextLink("log", $page + 1, gTxt('next'), 'next') : '';
    $rs = safe_rows_start("*, unix_timestamp(time) as stamp", "txp_log", "1 order by time desc limit {$offset},{$limit}");
    if ($rs) {
        echo startTable('list'), assHead('time', 'host', 'page', 'referrer');
        $stamp = '';
        while ($a = nextRow($rs)) {
            extract($a);
            if ($refer) {
                $referprint = preg_replace("/^www\\./", "", chunk(htmlspecialchars($refer), 50));
                $referprint = '<a href="http://' . htmlspecialchars($refer) . '">' . $referprint . '</a>';
            } else {
                $referprint = '&#160;';
            }
            $pageprint = preg_replace('/\\/$/', '', htmlspecialchars(substr($page, 1)));
            $pageprint = $pageprint == '' ? '' : '<a href="' . htmlspecialchars($page) . '" target="_blank">' . chunk($pageprint, 50) . '</a>';
            if ($method == 'POST') {
                $pageprint = '<b>' . $pageprint . '</b>';
            }
            $fstamp = date("n/j g:i a", $stamp + tz_offset());
            $hostprint = chunk($host, 40);
            echo tr(td($fstamp) . td($hostprint) . td($pageprint) . td($referprint));
            unset($refer, $referprint, $page, $pageprint);
        }
        echo '<tr><td colspan="4" align="right" style="padding:10px">', join('', $nav), "</td></tr>", endTable();
    } else {
        echo graf(gTxt('no_refers_recorded'), ' align="center"');
    }
}
Example #17
0
    private function _announce($thing, $async, $modal)
    {
        // $thing[0]: message text
        // $thing[1]: message type, defaults to "success" unless empty or a different flag is set
        if (!is_array($thing) || !isset($thing[1])) {
            $thing = array($thing, 0);
        }
        // still nothing to say?
        if (trim($thing[0]) === '') {
            return '';
        }
        switch ($thing[1]) {
            case E_ERROR:
                $class = 'error';
                break;
            case E_WARNING:
                $class = 'warning';
                break;
            default:
                $class = 'success';
                break;
        }
        if ($modal) {
            $html = '';
            // TODO: Say what?
            $js = 'window.alert("' . escape_js(strip_tags($thing[0])) . '")';
        } else {
            $html = '<span id="message" class="' . $class . '">' . gTxt($thing[0]) . ' <a href="#close" class="close">&times;</a></span>';
            // Try to inject $html into the message pane no matter when _announce()'s output is printed
            $js = escape_js($html);
            $js = <<<EOS
\t\t\t\t\$(document).ready(function() {
\t\t\t\t\t\$("#messagepane").html("{$js}");
\t\t\t\t\t\$('#message.success, #message.warning, #message.error').fadeOut('fast').fadeIn('fast');
\t\t\t\t});
EOS;
        }
        if ($async) {
            return $js;
        } else {
            return script_js(str_replace('</', '<\\/', $js), $html);
        }
    }
Example #18
0
function search($q)
{
    global $prefs;
    $url = $prefs['siteurl'];
    extract($prefs);
    $s_filter = filterSearch();
    $form = fetch('form', 'txp_form', 'name', 'search_results');
    // lose this eventually - only used if search_results form is missing
    $form = !$form ? legacy_form() : $form;
    $rs = safe_rows("ID, Title, Body_html, Section, unix_timestamp(Posted) as uPosted, \n\t\t\tmatch (Title,Body) against ('{$q}') as score", "textpattern", "Title rlike '{$q}' or Body rlike '{$q}' {$s_filter}\n\t\t\tand Status = 4 and Posted <=now() order by score desc limit 40");
    if ($rs) {
        $result_rows = count($rs);
        $text = $result_rows == 1 ? gTxt('article_found') : gTxt('articles_found');
    } else {
        $result_rows = 0;
        $text = gTxt('articles_found');
    }
    $results[] = graf($result_rows . ' ' . $text);
    if ($result_rows > 0) {
        foreach ($rs as $a) {
            extract($a);
            $result_date = date("j M Y", $uPosted);
            $hurl = $url_mode ? $siteurl . $path_from_root . $Section . '/' . $ID . '/' . stripSpace($Title) : $siteurl . $path_from_root . 'index.php?id=' . $ID;
            $result_url = '<a href="http://' . $hurl . '">' . $hurl . '</a>';
            $result_title = '<a href="http://' . $hurl . '">' . $Title . '</a>';
            $result = preg_replace("/>\\s*</", "> <", $Body_html);
            preg_match_all("/\\s.{0,50}" . $q . ".{0,50}\\s/i", $result, $concat);
            $concat = implode(" ... ", $concat[0]);
            $concat = strip_tags($concat);
            $concat = preg_replace('/^[^>]+>/U', "", $concat);
            $concat = preg_replace("/({$q})/i", "<strong>\$1</strong>", $concat);
            $result_excerpt = $concat ? "... " . $concat . " ..." : '';
            $glob['search_result_title'] = $result_title;
            $glob['search_result_excerpt'] = $result_excerpt;
            $glob['search_result_url'] = $result_url;
            $glob['search_result_date'] = $result_date;
            $GLOBALS['this_result'] = $glob;
            $thisresult = $form;
            $results[] = parse($thisresult);
        }
    }
    return is_array($results) ? join('', $results) : '';
}
Example #19
0
function page_edit_form($name)
{
    global $step;
    if ($step == 'div_edit') {
        list($html_array, $html, $start_pos, $stop_pos) = extract_div();
        $html_array = serialize($html_array);
        $outstep = 'div_save';
    } else {
        $html = safe_field('user_html', 'txp_page', "name='{$name}'");
        $outstep = 'page_save';
    }
    $out[] = textarea('500', '600', $html, 'html') . graf(fInput('submit', 'save', gTxt('save'), 'publish') . eInput('page') . sInput($outstep) . hInput('name', $name));
    if ($step == 'div_edit') {
        $out[] = hInput('html_array', $html_array) . hInput('start_pos', $start_pos) . hInput('stop_pos', $stop_pos) . hInput('name', $name);
    } else {
        $out[] = graf(gTxt('copy_page_as') . fInput('text', 'newname', '', 'edit') . fInput('submit', 'copy', gTxt('copy'), 'smallerbox'));
    }
    return form(join('', $out));
}
Example #20
0
/**
 * Parses the form "jmd_dashboard".
 *
 * @param string $event
 * @param string $step
 */
function jmd_dashboard($event, $step)
{
    pageTop(gTxt('jmd_dashboard_tab'));
    include_once txpath . DS . 'publish.php';
    if (empty($GLOBALS['pretext'])) {
        $GLOBALS['pretext'] = array('id' => '', 'q' => '');
    }
    $contents = safe_field("Form", "txp_form", "name = 'jmd_dashboard'");
    if ($contents === FALSE) {
        $contents = <<<FORM
<h1 style="text-align:center">
    Hey, you haven&#8217;t customized jmd_dashboard yet.
    <a href="?event=form&amp;step=form_edit&amp;name=jmd_dashboard">
        Do it now!
    </a>
</h1>

<div style="margin: 0 auto; width: 400px;">
    <h1>
        <txp:site_name/>: Last modified on <txp:jmd_dashboard_lastmod/>
    </h1>

    <h2>Recently published articles</h2>
    <txp:article_custom break="li" wraptag="ul">
        <txp:title/> &#8211;
        <txp:jmd_dashboard_edit>
            edit #<txp:article_id/>
        </txp:jmd_dashboard_edit>
    </txp:article_custom>

    <h2>Recent comments</h2>
    <txp:recent_comments break="li" wraptag="ul">
        <txp:comment_message/> &#8211; <txp:comment_name link="0"/>
        (<txp:jmd_dashboard_edit type="comment">edit</txp:jmd_dashboard_edit>)
    </txp:recent_comments>
</div>
FORM;
        safe_insert("txp_form", "Form='" . doSlash($contents) . "',\n            type='misc', name='jmd_dashboard'");
    }
    echo parse($contents);
}
Example #21
0
function link_edit($message = "")
{
    global $vars, $step;
    extract(gpsa($vars));
    pagetop(gTxt('edit_links', $message));
    $id = gps('id');
    if ($id && $step == 'link_edit') {
        extract(safe_row("*", "txp_link", "id = {$id}"));
    }
    if ($step == 'link_save' or $step == 'link_post') {
        foreach ($vars as $var) {
            ${$var} = '';
        }
    }
    $textarea = '<textarea name="description" cols="40" rows="7" tabindex="4">' . $description . '</textarea>';
    $selects = linkcategory_popup($category);
    $editlink = ' [' . eLink('category', 'list', '', '', gTxt('edit')) . ']';
    $out = startTable('edit') . tr(fLabelCell('title') . fInputCell('linkname', $linkname, 1, 30)) . tr(fLabelCell('sort_value') . fInputCell('linksort', $linksort, 2, 15)) . tr(fLabelCell('url', 'link_url') . fInputCell('url', $url, 3, 30)) . tr(fLabelCell('link_category', 'link_category') . td($selects . $editlink)) . tr(fLabelCell('description', 'link_description') . tda($textarea, ' valign="top"')) . tr(td() . td(fInput("submit", '', gTxt('save'), "publish"))) . endTable() . eInput('link') . sInput($step == 'link_edit' ? 'link_save' : 'link_post') . hInput('id', $id);
    echo form($out);
    echo link_list();
}
Example #22
0
function form_edit($message = '')
{
    global $step;
    pagetop(gTxt('edit_forms'), $message);
    extract(gpsa(array('Form', 'name', 'type')));
    if ($step == 'form_create') {
        $Form = '';
        $name = '';
        $type = '';
        $inputs = fInput('submit', 'savenew', gTxt('save_new'), 'publish') . eInput("form") . sInput('form_save');
    } else {
        $name = (!$name or $step == 'form_delete') ? 'default' : $name;
        $rs = safe_row("*", "txp_form", "name='{$name}'");
        if ($rs) {
            extract($rs);
            $inputs = fInput('submit', 'save', gTxt('save'), 'publish') . eInput("form") . sInput('form_save') . hInput('oldname', $name);
        }
    }
    $out = startTable('edit') . tr(tdtl(hed(gTxt('useful_tags'), 2) . graf(gTxt('articles') . sp . popHelp('form_place_article') . br . popTagLinks('article')) . graf(gTxt('links') . sp . popHelp('form_place_link') . br . popTagLinks('link')) . graf(gTxt('displayed_comments') . sp . popHelp('form_place_comment') . br . popTagLinks('comment')) . graf(gTxt('comment_form') . sp . popHelp('form_place_input') . br . popTagLinks('comment_form')) . graf(gTxt('search_input_form') . sp . popHelp('form_place_search_input') . br . popTagLinks('search_input')) . graf(gTxt('search_results_form') . sp . popHelp('form_place_search_results') . br . popTagLinks('search_result')) . graf(tag('<strong>' . gTxt('file_download_tags') . '</strong>', 'a', ' href="#" onclick="toggleDisplay(\'downloadtags\');"') . sp . popHelp('form_file_download_tags')) . graf(popTagLinks('file_download'), ' style="display:none;" id="downloadtags"')) . tdtl('<form action="index.php" method="post">' . input_textarea($Form) . graf(gTxt('form_name') . br . fInput('text', 'name', $name, 'edit', '', '', 15)) . graf(gTxt('form_type') . br . formtypes($type)) . graf(gTxt('only_articles_can_be_previewed')) . fInput('submit', 'preview', gTxt('preview'), 'smallbox') . graf($inputs) . '</form>') . tdtl(form_list($name))) . endTable();
    echo $out;
}
function rss_admin_editlink($event, $step)
{
    global $rss_ae_cookie;
    include txpath . '/include/txp_prefs.php';
    if (!isset($rss_ae_cookie)) {
        $rss_ae_cookie = "rss_article_edit";
        $rs = safe_insert('txp_prefs', "name='rss_ae_cookie', val='{$rss_ae_cookie}', prefs_id='1'");
    }
    if (gps("add")) {
        safe_update("txp_prefs", "val = '" . addslashes(ps('rss_ae_cookie')) . "'", "name = 'rss_ae_cookie' and prefs_id ='1'");
        setcookie($rss_ae_cookie, $rss_ae_cookie, time() + 31536000, "/");
        header("Location: index.php?event=editlink");
    } else {
        if (gps("rem")) {
            safe_update("txp_prefs", "val = '" . addslashes(ps('rss_ae_cookie')) . "'", "name = 'rss_ae_cookie' and prefs_id ='1'");
            setcookie($rss_ae_cookie, $rss_ae_cookie, time() - 3600, "/");
            header("Location: index.php?event=editlink");
        }
    }
    pagetop("Edit Link");
    $aeset = isset($_COOKIE[$rss_ae_cookie]) ? "" : " not";
    $tdaStyle = ' style="text-align:right;vertical-align:middle"';
    echo form(startTable("list") . tr(tdcs(hed("Add/Remove Public Site Article Edit Link", 1), 2)) . tr(tda(graf('Cookie ' . $rss_ae_cookie . ' is' . $aeset . ' set.', ' align="center"'), ' colspan="2"')) . tr(tda(gTxt('Cookie Name:'), ' style="text-align:right;vertical-align:middle"') . tda(text_input("rss_ae_cookie", $rss_ae_cookie, '20'), ' ')) . tr(tda(graf(fInput("submit", "add", gTxt("Add Edit Link"), "publish") . fInput("submit", "rem", gTxt("Remove Edit Link"), "publish") . eInput("editlink"), ' align="center"'), ' colspan="2"')) . endTable());
}
Example #24
0
function section_create()
{
    global $txpcfg;
    $name = doSlash(ps('name'));
    //Prevent non url chars on section names
    include_once $txpcfg['txpath'] . '/lib/classTextile.php';
    $textile = new Textile();
    $title = $textile->TextileThis($name, 1);
    $name = dumbDown($textile->TextileThis(trim(doSlash($name)), 1));
    $name = preg_replace("/[^[:alnum:]\\-_]/", "", str_replace(" ", "-", $name));
    $chk = fetch('name', 'txp_section', 'name', $name);
    if (!$chk) {
        if ($name) {
            $rs = safe_insert("txp_section", "name         = '{$name}',\n\t\t\t\t\ttitle        = '{$title}', \n\t\t\t\t\tpage         = 'default',\n\t\t\t\t\tcss          = 'default',\n\t\t\t\t\tis_default   = 0,\n\t\t\t\t\tin_rss       = 1,\n\t\t\t\t\ton_frontpage = 1");
            if ($rs) {
                sec_section_list(messenger('section', $name, 'created'));
            }
        } else {
            sec_section_list();
        }
    } else {
        sec_section_list(gTxt('section_name_already_exists'));
    }
}
Example #25
0
 /**
  * Encodes a string for use in an email header.
  *
  * @param  string $string The string
  * @param  string $type   The type of header, either "text" or "phrase"
  * @return string
  * @throws \Textpattern\Mail\Exception
  */
 public function header($string, $type)
 {
     if (strpos($string, '=?') === false && !preg_match('/[\\x00-\\x1F\\x7F-\\xFF]/', $string)) {
         if ($type == 'phrase') {
             if (preg_match('/[][()<>@,;:".\\x5C]/', $string)) {
                 $string = '"' . strtr($string, array("\\" => "\\\\", '"' => '\\"')) . '"';
             }
         } elseif ($type != 'text') {
             throw new \Textpattern\Mail\Exception(gTxt('invalid_argument', array('{name}' => 'type')));
         }
         return $string;
     }
     if ($this->charset == 'ISO-8859-1') {
         $start = '=?ISO-8859-1?B?';
         $pcre = '/.{1,42}/s';
     } else {
         $start = '=?UTF-8?B?';
         $pcre = '/.{1,45}(?=[\\x00-\\x7F\\xC0-\\xFF]|$)/s';
     }
     $end = '?=';
     $sep = IS_WIN ? "\r\n" : "\n";
     preg_match_all($pcre, $string, $matches);
     return $start . join($end . $sep . ' ' . $start, array_map('base64_encode', $matches[0])) . $end;
 }
Example #26
0
/**
 * Processes the selected import tool action.
 *
 * Basically does the importing.
 */
function start_import()
{
    global $event, $vars;
    extract(psa($vars));
    $insert_into_section = $import_section;
    $insert_with_status = $import_status;
    $default_comment_invite = $import_comments_invite;
    include_once txpath . '/include/import/import_' . $import_tool . '.php';
    $ini_time = ini_get('max_execution_time');
    @ini_set('max_execution_time', 300 + intval($ini_time));
    switch ($import_tool) {
        case 'mtdb':
            $out = doImportMTDB($importdblogin, $importdb, $importdbpass, $importdbhost, $import_blog_id, $insert_into_section, $insert_with_status, $default_comment_invite);
            rebuild_tree('root', 1, 'article');
            break;
        case 'mt':
            $file = check_import_file();
            if (!empty($file)) {
                $out = doImportMT($file, $insert_into_section, $insert_with_status, $import_comments_invite);
                // Rebuilding category tree.
                rebuild_tree('root', 1, 'article');
            } else {
                $out = 'Import file not found';
            }
            break;
        case 'b2':
            $out = doImportB2($importdblogin, $importdb, $importdbpass, $importdbhost, $insert_into_section, $insert_with_status, $default_comment_invite);
            break;
        case 'wp':
            $out = doImportWP($importdblogin, $importdb, $importdbpass, $importdbhost, $wpdbprefix, $insert_into_section, $insert_with_status, $default_comment_invite, $wpdbcharset);
            rebuild_tree('root', 1, 'article');
            break;
        case 'blogger':
            $file = check_import_file();
            if (!empty($file)) {
                $out = doImportBLOGGER($file, $insert_into_section, $insert_with_status, $import_comments_invite);
            } else {
                $out = gTxt('import_file_not_found');
            }
            break;
    }
    $out = tag('max_execution_time = ' . ini_get('max_execution_time'), 'p', ' class="highlight"') . $out;
    pagetop(gTxt('txp_import'));
    $content = '<div id="' . $event . '_container" class="txp-container">';
    $content .= startTable('', '', 'txp-list');
    $content .= tr(tdcs(hed(gTxt('txp_import'), 2), 2));
    $content .= tr(td($out));
    $content .= endTable();
    $content .= '</div>';
    echo $content;
    $rs = safe_rows_start('parentid, count(*) as thecount', 'txp_discuss', 'visible=1 group by parentid');
    if (numRows($rs) > 0) {
        while ($a = nextRow($rs)) {
            safe_update('textpattern', "comments_count=" . $a['thecount'], "ID=" . $a['parentid']);
        }
    }
}
function customers_list($event = '', $step = '', $message = '')
{
    global $statuses, $comments_disabled_after, $step, $txp_user;
    pagetop("Customers", $message);
    extract(get_prefs());
    extract(gpsa(array('page', 'sort', 'dir', 'crit', 'qty', 'search_method')));
    $sesutats = array_flip($statuses);
    $dir = $dir == 'desc' ? 'desc' : 'asc';
    switch ($sort) {
        case 'RealName':
            $sort_sql = 'RealName ' . $dir;
            break;
        case 'orders':
            $sort_sql = 'orders ' . $dir;
            break;
        default:
            $dir = 'desc';
            $sort_sql = 'user_id ' . $dir;
            break;
    }
    $switch_dir = $dir == 'desc' ? 'asc' : 'desc';
    $criteria = "privs = 0";
    if ($search_method and $crit) {
        $crit_escaped = doSlash($crit);
        $critsql = array('id' => "ID = '{$crit_escaped}'", 'title_body' => "Title rlike '{$crit_escaped}' or Body rlike '{$crit_escaped}'", 'section' => "Section rlike '{$crit_escaped}'", 'categories' => "Category1 rlike '{$crit_escaped}' or Category2 rlike '{$crit_escaped}'", 'status' => "Status = '" . @$sesutats[gTxt($crit_escaped)] . "'", 'author' => "AuthorID rlike '{$crit_escaped}'");
        if (array_key_exists($search_method, $critsql)) {
            $criteria = $critsql[$search_method];
            $limit = 500;
        } else {
            $search_method = '';
            $crit = '';
        }
    } else {
        $search_method = '';
        $crit = '';
    }
    $total = safe_count('txp_users', "{$criteria}");
    if (isset($qty)) {
        $customers_list_pageby = $qty;
    } else {
        $customers_list_pageby = 15;
    }
    $limit = max(@$customers_list_pageby, 15);
    list($page, $offset, $numPages) = pager($total, $limit, $page);
    $rs = safe_rows_start('*', 'txp_users', "{$criteria} order by {$sort_sql} limit {$offset}, {$limit}");
    $customersOnPage = $offset + $limit;
    if ($rs) {
        echo n . n . '<form name="longform" method="post" action="index.php" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">' . n . startTable('list', '', '', '', '700') . n . tr(n . tda("Displaying {$offset} - {$customersOnPage} of {$total} customers", ' colspan="2" style="border: none; padding-bottom: 15px;"') . n . tda('<a href="?event=customers&step=edit_customer" class="navlink">Add a new customer</a> <a href="?event=customers&step=export_customer" class="navlink">Export customers</a>', ' colspan="2" style="text-align: right; border: none; padding-bottom: 15px;"')) . n . tr(n . column_head('Customer', 'RealName', 'customers', true, $switch_dir, $crit, $search_method) . column_head('Phone', 'shipping_phone', 'customers', true, $switch_dir, $crit, $search_method) . column_head('Email', 'email', 'customers', true, $switch_dir, $crit, $search_method) . column_head('Orders', 'order_num', 'customers', true, $switch_dir, $crit, $search_method));
        include_once txpath . '/publish/taghandlers.php';
        while ($a = nextRow($rs)) {
            extract($a);
            $order_num = safe_count("orders", "user_id = {$user_id}");
            $RealName = eLink('customers', 'edit_customer', 'user_id', $user_id, $RealName);
            $Orders = eLink('order', 'edit', 'customer', $name, $order_num);
            echo n . n . tr(n . td($RealName, "25%") . td($billing_phone, "25%") . td($email, "25%") . td($Orders, "25%"));
        }
        echo n . endTable() . n . '</form>' . n . nav_form('customers', $page, $numPages, $sort, $dir, $crit, $search_method) . n . pageby_form('customers', $customers_list_pageby);
    }
}
Example #28
0
function fbCreate()
{
    if ($GLOBALS['txp_install_successful'] === false) {
        return '<div width="450" valign="top" style="margin-right: auto; margin-left: auto;">' . graf(gTxt('errors_during_install', array('{num}' => $GLOBALS['txp_err_count'])), ' style="margin-top: 3em;"') . '</div>';
    } else {
        return '<div width="450" valign="top" style="margin-right: auto; margin-left: auto;">' . graf(gTxt('that_went_well'), ' style="margin-top:3em"') . graf(gTxt('you_can_access', array('index.php' => $GLOBALS['rel_siteurl'] . '/textpattern/index.php'))) . graf(gTxt('thanks_for_interest')) . '</div>';
    }
}
Example #29
0
$create_sql[] = "INSERT INTO `" . PFX . "txp_link` VALUES (5, '2012-06-01 08:15:42', 'textpattern', 'http://textpattern.com/+', '+Textpattern CMS', '50', '')";
$create_sql[] = "INSERT INTO `" . PFX . "txp_link` VALUES (6, '2012-06-01 08:15:42', 'textpattern', 'http://textpattern.com/facebook', 'Textpattern Facebook Group ', '60', '')";
$create_sql[] = "CREATE TABLE `" . PFX . "txp_log` (\n  `id` int(12) NOT NULL auto_increment,\n  `time` datetime NOT NULL default '0000-00-00 00:00:00',\n  `host` varchar(255) NOT NULL default '',\n  `page` varchar(255) NOT NULL default '',\n  `refer` mediumtext NOT NULL,\n  `status` int(11) NOT NULL default '200',\n  `method` varchar(16) NOT NULL default 'GET',\n  `ip` varchar(16) NOT NULL default '',\n  PRIMARY KEY  (`id`),\n  KEY `time` (`time`)\n) {$tabletype} AUTO_INCREMENT=77 ";
$create_sql[] = "CREATE TABLE `" . PFX . "txp_page` (\n  `name` varchar(128) NOT NULL,\n  `user_html` text NOT NULL,\n  PRIMARY KEY (`name`)\n) {$tabletype} PACK_KEYS=1";
// sql:txp_page
$create_sql[] = "INSERT INTO `" . PFX . "txp_page`(`name`,`user_html`) VALUES('archive', '<!doctype html>\n<html lang=\"<txp:lang />\">\n\n<head>\n  <meta charset=\"utf-8\">\n\n<!-- page title and metas, no meta keywords as they are now obsolete -->\n  <title><txp:page_title /></title>\n  <meta name=\"description\" content=\"\">\n  <meta name=\"generator\" content=\"Textpattern CMS\">\n  <meta name=\"robots\" content=\"noindex, follow, noodp, noydir\">\n\n<!-- mobile viewport optimised, more info: http://h5bp.com/viewport -->\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n\n  <txp:if_individual_article>\n<!-- add meta author for individual articles -->\n    <txp:meta_author title=\"1\" />\n  </txp:if_individual_article>\n\n<!-- content feeds -->\n  <txp:feed_link flavor=\"atom\" format=\"link\" label=\"Atom\" />\n  <txp:feed_link flavor=\"rss\" format=\"link\" label=\"RSS\" />\n  <txp:rsd />\n\n<!-- specify canonical, more info: http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html -->\n  <txp:if_individual_article>\n    <link rel=\"canonical\" href=\"<txp:permlink />\">\n  <txp:else />\n    <link rel=\"canonical\" href=\"<txp:section url=\\'1\\' />\">\n  </txp:if_individual_article>\n\n<!-- css -->\n  <!-- Google font API (remove this if you intend to use the theme in a project without internet access) -->\n  <link rel=\"stylesheet\" href=\"http://fonts.googleapis.com/css?family=PT+Serif:n4,i4,n7,i7|Cousine\">\n\n  <txp:css format=\"link\" media=\"\" />\n  <!-- or you can use (faster) external CSS files eg. <link rel=\"stylesheet\" href=\"<txp:site_url />css/default.css\"> -->\n\n<!-- HTML5/Media Queries support for IE < 9 (you can remove this section and the corresponding \\'js\\' directory files if you don\\'t intend to support IE < 9) -->\n  <!--[if lt IE 9]>\n    <script src=\"<txp:site_url />js/html5shiv.js\"></script>\n    <script src=\"<txp:site_url />js/css3-mediaqueries.js\"></script>\n  <![endif]-->\n\n</head>\n\n<body id=\"<txp:section />-page\">\n\n<!-- header -->\n  <header role=\"banner\">\n    <hgroup>\n      <h1><txp:link_to_home><txp:site_name /></txp:link_to_home></h1>\n      <h3><txp:site_slogan /></h3>\n    </hgroup>\n  </header>\n\n<!-- navigation -->\n  <nav role=\"navigation\">\n    <h1><txp:text item=\"navigation\" /></h1>\n    <txp:section_list default_title=\\'<txp:text item=\"home\" />\\' include_default=\"1\" wraptag=\"ul\" break=\"\">\n      <li<txp:if_section name=\\'<txp:section />\\'> class=\"active\"</txp:if_section>>\n        <txp:section title=\"1\" link=\"1\" />\n      </li>\n    </txp:section_list>\n  </nav>\n\n  <div class=\"wrapper\">\n    <div class=\"container\">\n\n<!-- left (main) column -->\n      <div role=\"main\">\n\n        <txp:if_article_list><h1><txp:section title=\"1\" /></h1></txp:if_article_list>\n\n        <txp:article listform=\"article_listing\" limit=\"5\" />\n        <!-- or if you want to list all articles from all sections instead, then replace txp:article with txp:article_custom -->\n\n        <!-- add pagination links to foot of article/article listings if there are more articles available,\n          this method is more flexibile than using simple txp:link_to_prev/txp:link_to_next or txp:older/txp:newer tags -->\n        <p id=\"paginator\">\n\n        <txp:if_individual_article>\n\n          <txp:variable name=\"prev\" value=\\'<txp:link_to_prev />\\' />\n          <txp:variable name=\"next\" value=\\'<txp:link_to_next />\\' />\n\n          <txp:if_variable name=\"prev\" value=\"\">\n            <span id=\"paginator-l\" class=\"button disabled\">&#8592; <txp:text item=\"older\" /></span>\n          <txp:else />\n            <a id=\"paginator-l\" href=\"<txp:link_to_prev />\" title=\"<txp:prev_title />\" class=\"button\">&#8592; <txp:text item=\"older\" /></a>\n          </txp:if_variable>\n          <txp:if_variable name=\"next\" value=\"\">\n            <span id=\"paginator-r\" class=\"button disabled\"><txp:text item=\"newer\" /> &#8594;</span>\n          <txp:else />\n            <a id=\"paginator-r\" href=\"<txp:link_to_next />\" title=\"<txp:next_title />\" class=\"button\"><txp:text item=\"newer\" /> &#8594;</a>\n          </txp:if_variable>\n\n        <txp:else />\n\n          <txp:variable name=\"prev\" value=\\'<txp:older />\\' />\n          <txp:variable name=\"next\" value=\\'<txp:newer />\\' />\n          <txp:if_variable name=\"prev\" value=\"\">\n            <span id=\"paginator-l\" class=\"button disabled\">&#8592; <txp:text item=\"older\" /></span>\n          <txp:else />\n            <a id=\"paginator-l\" href=\"<txp:older />\" title=\"<txp:text item=\\'older\\' />\" class=\"button\">&#8592; <txp:text item=\"older\" /></a>\n          </txp:if_variable>\n          <txp:if_variable name=\"next\" value=\"\">\n            <span id=\"paginator-r\" class=\"button disabled\"><txp:text item=\"newer\" /> &#8594;</span>\n          <txp:else />\n            <a id=\"paginator-r\" href=\"<txp:newer />\" title=\"<txp:text item=\\'newer\\' />\" class=\"button\"><txp:text item=\"newer\" /> &#8594;</a>\n          </txp:if_variable>\n\n        </txp:if_individual_article>\n\n        </p>\n\n      </div> <!-- /main -->\n\n  <!-- right (complementary) column -->\n      <div role=\"complementary\">\n        <txp:search_input /> <!-- links by default to form: \\'search_input.misc.txp\\' unless you specify a different form -->\n  \n        <!-- Feed links, default flavor is rss, so we don\\'t need to specify a flavor on the first feed_link -->\n        <p><txp:feed_link label=\"RSS\" class=\"feed-rss\" /> / <txp:feed_link flavor=\"atom\" label=\"Atom\" class=\"feed-atom\" /></p>\n\n        <h4><txp:text item=\"external_links\" /></h4>\n        <txp:linklist wraptag=\"ul\" break=\"li\" limit=\"10\" /> <!-- links by default to form: \\'plainlinks.link.txp\\' unless you specify a different form -->\n      </div> <!-- /complementary -->\n\n    </div> <!-- /.container -->\n  </div> <!-- /.wrapper -->\n\n<!-- footer -->\n  <footer role=\"contentinfo\">\n    <p><small><txp:text item=\"published_with\" /> <a href=\"http://textpattern.com\" rel=\"external\" title=\"<txp:text item=\\'go_txp_com\\' />\">Textpattern CMS</a>.</small></p>\n  </footer>\n\n<!-- JavaScript at the bottom for fast page loading, more info: http://developer.yahoo.com/performance/rules.html#js_bottom -->\n\n  <!-- add your own JavaScript here -->\n\n</body>\n</html>')";
$create_sql[] = "INSERT INTO `" . PFX . "txp_page`(`name`,`user_html`) VALUES('default', '<!doctype html>\n<html lang=\"<txp:lang />\">\n\n<head>\n  <meta charset=\"utf-8\">\n\n<!-- page title and metas, no meta keywords as they are now obsolete -->\n  <title><txp:page_title /></title>\n  <meta name=\"description\" content=\"\">\n  <meta name=\"generator\" content=\"Textpattern CMS\">\n  <txp:if_search>\n    <meta name=\"robots\" content=\"none\">\n  <txp:else />\n  <txp:if_category>\n    <meta name=\"robots\" content=\"noindex, follow, noodp, noydir\">\n  <txp:else />\n  <txp:if_author>\n    <meta name=\"robots\" content=\"noindex, follow, noodp, noydir\">\n  <txp:else />\n    <meta name=\"robots\" content=\"index, follow, noodp, noydir\">\n  </txp:if_author>\n  </txp:if_category>\n  </txp:if_search>\n\n<!-- mobile viewport optimised, more info: http://h5bp.com/viewport -->\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n\n<!-- content feeds -->\n  <txp:feed_link flavor=\"atom\" format=\"link\" label=\"Atom\" />\n  <txp:feed_link flavor=\"rss\" format=\"link\" label=\"RSS\" />\n  <txp:rsd />\n\n<!-- specify canonical, more info: http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html -->\n  <txp:if_section name=\"\">\n    <link rel=\"canonical\" href=\"<txp:site_url />\">\n  <txp:else />\n    <txp:if_individual_article>\n      <link rel=\"canonical\" href=\"<txp:permlink />\">\n    <txp:else />\n      <link rel=\"canonical\" href=\"<txp:section url=\\'1\\' />\">\n    </txp:if_individual_article>\n  </txp:if_section>\n\n<!-- css -->\n  <!-- Google font API (remove this if you intend to use the theme in a project without internet access) -->\n  <link rel=\"stylesheet\" href=\"http://fonts.googleapis.com/css?family=PT+Serif:n4,i4,n7,i7|Cousine\">\n\n  <txp:css format=\"link\" media=\"\" />\n  <!-- or you can use (faster) external CSS files eg. <link rel=\"stylesheet\" href=\"<txp:site_url />css/default.css\"> -->\n\n<!-- HTML5/Media Queries support for IE < 9 (you can remove this section and the corresponding \\'js\\' directory files if you don\\'t intend to support IE < 9) -->\n  <!--[if lt IE 9]>\n    <script src=\"<txp:site_url />js/html5shiv.js\"></script>\n    <script src=\"<txp:site_url />js/css3-mediaqueries.js\"></script>\n  <![endif]-->\n\n</head>\n\n<body id=\"<txp:if_section name=\"\"><txp:if_search>search<txp:else />front</txp:if_search><txp:else /><txp:section /></txp:if_section>-page\">\n\n<!-- header -->\n  <header role=\"banner\">\n    <hgroup>\n      <h1><txp:link_to_home><txp:site_name /></txp:link_to_home></h1>\n      <h3><txp:site_slogan /></h3>\n    </hgroup>\n  </header>\n\n<!-- navigation -->\n  <nav role=\"navigation\">\n    <h1><txp:text item=\"navigation\" /></h1>\n    <txp:section_list default_title=\\'<txp:text item=\"home\" />\\' include_default=\"1\" wraptag=\"ul\" break=\"\">\n      <li<txp:if_section name=\\'<txp:section />\\'><txp:if_search><txp:else /><txp:if_category><txp:else /><txp:if_author><txp:else /> class=\"active\"</txp:if_author></txp:if_category></txp:if_search></txp:if_section>>\n        <txp:section title=\"1\" link=\"1\" />\n      </li>\n    </txp:section_list>\n  </nav>\n\n  <div class=\"wrapper\">\n    <div class=\"container\">\n\n<!-- left (main) column -->\n      <div role=\"main\">\n\n      <!-- is this result result page? also omits the pagination links below (uses pagination format within search_results.article.txp instead) -->\n      <txp:if_search>\n\n        <h1><txp:text item=\"search_results\" /></h1>\n        <txp:output_form form=\"search_results\"/>\n\n      <txp:else />\n\n        <!-- else is this an article category list? -->\n        <txp:if_category>\n\n          <h1><txp:text item=\"category\" /> <txp:category title=\"1\" /></h1>\n          <txp:article form=\"article_listing\" limit=\"5\" />\n\n        <txp:else />\n\n          <!-- else is this an article author list? -->\n          <txp:if_author>\n\n          <h1><txp:text item=\"author\" /> <txp:author /></h1>\n          <txp:article form=\"article_listing\" limit=\"5\" />\n\n          <txp:else />\n\n            <!-- else display articles normally -->\n            <txp:article limit=\"5\" /> <!-- links by default to form: \\'default.article.txp\\' unless you specify a different form -->\n\n          </txp:if_author>\n        </txp:if_category>\n\n        <!-- add pagination links to foot of article/article listings/category listings if there are more articles available,\n          this method is more flexibile than using simple txp:link_to_prev/txp:link_to_next or txp:older/txp:newer tags -->\n        <p id=\"paginator\">\n\n        <txp:variable name=\"prev\" value=\\'<txp:older />\\' />\n        <txp:variable name=\"next\" value=\\'<txp:newer />\\' />\n\n        <txp:if_variable name=\"prev\" value=\"\">\n          <span id=\"paginator-l\" class=\"button disabled\">&#8592; <txp:text item=\"older\" /></span>\n        <txp:else />\n          <a id=\"paginator-l\" href=\"<txp:older />\" title=\"<txp:text item=\\'older\\' />\" class=\"button\">&#8592; <txp:text item=\"older\" /></a>\n        </txp:if_variable>\n        <txp:if_variable name=\"next\" value=\"\">\n          <span id=\"paginator-r\" class=\"button disabled\"><txp:text item=\"newer\" /> &#8594;</span>\n        <txp:else />\n            <a id=\"paginator-r\" href=\"<txp:newer />\" title=\"<txp:text item=\\'newer\\' />\" class=\"button\"><txp:text item=\"newer\" /> &#8594;</a>\n        </txp:if_variable>\n\n        </p>\n\n      </txp:if_search>\n\n      </div> <!-- /main -->\n\n<!-- right (complementary) column -->\n      <div role=\"complementary\">\n        <txp:search_input /> <!-- links by default to form: \\'search_input.misc.txp\\' unless you specify a different form -->\n\n        <!-- Feed links, default flavor is rss, so we don\\'t need to specify a flavor on the first feed_link -->\n        <p><txp:feed_link label=\"RSS\" class=\"feed-rss\" /> / <txp:feed_link flavor=\"atom\" label=\"Atom\" class=\"feed-atom\" /></p>\n\n        <h4><txp:text item=\"external_links\" /></h4>\n        <txp:linklist wraptag=\"ul\" break=\"li\" limit=\"10\" /> <!-- links by default to form: \\'plainlinks.link.txp\\' unless you specify a different form -->\n      </div> <!-- /complementary -->\n\n    </div> <!-- /.container -->\n  </div> <!-- /.wrapper -->\n\n<!-- footer -->\n  <footer role=\"contentinfo\">\n    <p><small><txp:text item=\"published_with\" /> <a href=\"http://textpattern.com\" rel=\"external\" title=\"<txp:text item=\\'go_txp_com\\' />\">Textpattern CMS</a>.</small></p>\n  </footer>\n\n<!-- JavaScript at the bottom for fast page loading, more info: http://developer.yahoo.com/performance/rules.html#js_bottom -->\n\n  <!-- add your own JavaScript here -->\n\n</body>\n</html>')";
$create_sql[] = "INSERT INTO `" . PFX . "txp_page`(`name`,`user_html`) VALUES('error_default', '<!doctype html>\n<html lang=\"<txp:lang />\">\n\n<head>\n  <meta charset=\"utf-8\">\n\n<!-- page title and metas, no meta keywords as they are now obsolete -->\n  <title><txp:error_status /></title>\n  <meta name=\"description\" content=\"<txp:error_message />\">\n  <meta name=\"generator\" content=\"Textpattern CMS\">\n  <meta name=\"robots\" content=\"none\">\n\n<!-- mobile viewport optimised, more info: http://h5bp.com/viewport -->\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n\n<!-- content feeds -->\n  <txp:feed_link flavor=\"atom\" format=\"link\" label=\"Atom\" />\n  <txp:feed_link flavor=\"rss\" format=\"link\" label=\"RSS\" />\n  <txp:rsd />\n\n<!-- css -->\n  <!-- Google font API (remove this if you intend to use the theme in a project without internet access) -->\n  <link rel=\"stylesheet\" href=\"http://fonts.googleapis.com/css?family=PT+Serif:n4,i4,n7,i7|Cousine\">\n\n  <txp:css format=\"link\" media=\"\" />\n  <!-- or you can use (faster) external CSS files eg. <link rel=\"stylesheet\" href=\"<txp:site_url />css/default.css\"> -->\n\n<!-- HTML5/Media Queries support for IE < 9 (you can remove this section and the corresponding \\'js\\' directory files if you don\\'t intend to support IE < 9) -->\n  <!--[if lt IE 9]>\n    <script src=\"<txp:site_url />js/html5shiv.js\"></script>\n    <script src=\"<txp:site_url />js/css3-mediaqueries.js\"></script>\n  <![endif]-->\n\n</head>\n\n<body id=\"error-page\">\n\n<!-- header -->\n  <header role=\"banner\">\n    <hgroup>\n      <h1><txp:link_to_home><txp:site_name /></txp:link_to_home></h1>\n      <h3><txp:site_slogan /></h3>\n    </hgroup>\n  </header>\n\n<!-- navigation -->\n  <nav role=\"navigation\">\n    <h1><txp:text item=\"navigation\" /></h1>\n    <txp:section_list default_title=\\'<txp:text item=\"home\" />\\' include_default=\"1\" wraptag=\"ul\" break=\"li\">\n      <txp:section title=\"1\" link=\"1\" />\n    </txp:section_list>\n  </nav>\n\n  <div class=\"wrapper\">\n    <div class=\"container\">\n\n<!-- left (main) column -->\n      <div role=\"main\">\n        <h1 class=\"error-status\"><txp:error_status /></h1>\n        <p class=\"error-msg\"><txp:error_message /></p>\n      </div> <!-- /main -->\n\n<!-- right (complementary) column -->\n      <div role=\"complementary\">\n        <txp:search_input /> <!-- links by default to form: \\'search_input.misc.txp\\' unless you specify a different form -->\n\n        <!-- Feed links, default flavor is rss, so we don\\'t need to specify a flavor on the first feed_link -->\n        <p><txp:feed_link label=\"RSS\" class=\"feed-rss\" /> / <txp:feed_link flavor=\"atom\" label=\"Atom\" class=\"feed-atom\" /></p>\n\n        <h4><txp:text item=\"external_links\" /></h4>\n        <txp:linklist wraptag=\"ul\" break=\"li\" limit=\"10\" /> <!-- links by default to form: \\'plainlinks.link.txp\\' unless you specify a different form -->\n      </div> <!-- /complementary -->\n\n    </div> <!-- /.container -->\n  </div> <!-- /.wrapper -->\n\n<!-- footer -->\n  <footer role=\"contentinfo\">\n    <p><small><txp:text item=\"published_with\" /> <a href=\"http://textpattern.com\" rel=\"external\" title=\"<txp:text item=\\'go_txp_com\\' />\">Textpattern CMS</a>.</small></p>\n  </footer>\n\n<!-- JavaScript at the bottom for fast page loading, more info: http://developer.yahoo.com/performance/rules.html#js_bottom -->\n\n  <!-- add your own JavaScript here -->\n\n</body>\n</html>')";
// /sql:txp_page
$create_sql[] = "CREATE TABLE `" . PFX . "txp_plugin` (\n  `name` varchar(64) NOT NULL default '',\n  `status` int(2) NOT NULL default '1',\n  `author` varchar(128) NOT NULL default '',\n  `author_uri` varchar(128) NOT NULL default '',\n  `version` varchar(10) NOT NULL default '1.0',\n  `description` text NOT NULL,\n  `help` text NOT NULL,\n  `code` text NOT NULL,\n  `code_restore` text NOT NULL,\n  `code_md5` varchar(32) NOT NULL default '',\n  `type` int(2) NOT NULL default '0',\n  UNIQUE KEY `name` (`name`)\n) {$tabletype} ";
$create_sql[] = "CREATE TABLE `" . PFX . "txp_prefs` (\n  `prefs_id` int(11) NOT NULL,\n  `name` varchar(255) NOT NULL,\n  `val` varchar(255) NOT NULL default '',\n  `type` smallint(5) unsigned NOT NULL default '2',\n  `event` varchar(12) NOT NULL default 'publish',\n  `html` varchar(64) NOT NULL default 'text_input',\n  `position` smallint(5) unsigned NOT NULL default '0',\n  `user_name` varchar(64) NOT NULL default '',\n  UNIQUE KEY `prefs_idx` (`prefs_id`,`name`, `user_name`),\n  KEY `name` (`name`),\n  KEY `user_name` (`user_name`)\n) {$tabletype} ";
$prefs['blog_uid'] = md5(uniqid(rand(), true));
$create_sql[] = "INSERT INTO `" . PFX . "txp_prefs` VALUES (1, 'prefs_id', '1', 2, 'publish', 'text_input', 0, '')";
$create_sql[] = "INSERT INTO `" . PFX . "txp_prefs` VALUES (1, 'sitename', '" . doSlash(gTxt('my_site')) . "', 0, 'publish', 'text_input', 10, '')";
$create_sql[] = "INSERT INTO `" . PFX . "txp_prefs` VALUES (1, 'siteurl', 'comment.local', 0, 'publish', 'text_input', 20, '')";
$create_sql[] = "INSERT INTO `" . PFX . "txp_prefs` VALUES (1, 'site_slogan', '" . doSlash(gTxt('my_slogan')) . "', 0, 'publish', 'text_input', 30, '')";
$create_sql[] = "INSERT INTO `" . PFX . "txp_prefs` VALUES (1, 'language', 'en-gb', 2, 'publish', 'languages', 40, '')";
$create_sql[] = "INSERT INTO `" . PFX . "txp_prefs` VALUES (1, 'url_mode', '1', 2, 'publish', 'text_input', 0, '')";
$create_sql[] = "INSERT INTO `" . PFX . "txp_prefs` VALUES (1, 'timeoffset', '0', 2, 'publish', 'text_input', 0, '')";
$create_sql[] = "INSERT INTO `" . PFX . "txp_prefs` VALUES (1, 'comments_on_default', '0', 0, 'comments', 'yesnoradio', 140, '')";
$create_sql[] = "INSERT INTO `" . PFX . "txp_prefs` VALUES (1, 'comments_default_invite', '" . $setup_comment_invite . "', 0, 'comments', 'text_input', 180, '')";
$create_sql[] = "INSERT INTO `" . PFX . "txp_prefs` VALUES (1, 'comments_mode', '0', 0, 'comments', 'commentmode', 200, '')";
$create_sql[] = "INSERT INTO `" . PFX . "txp_prefs` VALUES (1, 'comments_disabled_after', '42', 0, 'comments', 'weeks', 210, '')";
$create_sql[] = "INSERT INTO `" . PFX . "txp_prefs` VALUES (1, 'use_textile', '2', 0, 'publish', 'pref_text', 110, '')";
$create_sql[] = "INSERT INTO `" . PFX . "txp_prefs` VALUES (1, 'ping_weblogsdotcom', '0', 1, 'publish', 'yesnoradio', 0, '')";
$create_sql[] = "INSERT INTO `" . PFX . "txp_prefs` VALUES (1, 'rss_how_many', '5', 1, 'admin', 'text_input', 0, '')";
$create_sql[] = "INSERT INTO `" . PFX . "txp_prefs` VALUES (1, 'logging', 'all', 0, 'publish', 'logging', 100, '')";
$create_sql[] = "INSERT INTO `" . PFX . "txp_prefs` VALUES (1, 'use_comments', '1', 0, 'publish', 'yesnoradio', 120, '')";
$create_sql[] = "INSERT INTO `" . PFX . "txp_prefs` VALUES (1, 'use_categories', '1', 2, 'publish', 'text_input', 0, '')";
$create_sql[] = "INSERT INTO `" . PFX . "txp_prefs` VALUES (1, 'use_sections', '1', 2, 'publish', 'text_input', 0, '')";
$create_sql[] = "INSERT INTO `" . PFX . "txp_prefs` VALUES (1, 'send_lastmod', '0', 1, 'admin', 'yesnoradio', 0, '')";
/**
 * Adds headers for each form type.
 *
 * @param string $buffer
 */
function jmd_form_toggle($buffer)
{
    global $DB, $essential_forms, $step;
    if (empty($DB)) {
        $DB = new DB();
    }
    $curForm = gps('name') ? gps('name') : 'default';
    $out = sLink('form', 'form_create', gTxt('create_new_form'), 'action');
    $rs = safe_rows('name, type', 'txp_form', 'name !="" order by type, name asc');
    foreach ($rs as $form) {
        $forms[$form['type']][] = $form['name'];
    }
    $types = array_keys($forms);
    foreach ($types as $type) {
        $out .= <<<EOD
<h3 class="plain" onclick="jmd_form_toggle('type_{$type}');">{$type}</h3>
<table id="type_{$type}">
EOD;
        $count = count($forms[$type]);
        for ($i = 0; $i < $count; $i++) {
            $formName = $forms[$type][$i];
            $formLink = eLink('form', 'form_edit', 'name', $formName, $formName);
            $checkbox = '<input type="checkbox" name="selected_forms[]"
                value="' . $formName . '"/>';
            $class = '';
            if (in_array($formName, $essential_forms)) {
                $checkbox = '';
                $class .= ' single';
            }
            if ($curForm === $formName) {
                $class .= ' current';
                $formLink = tag($formName, 'strong');
            }
            $out .= <<<EOD
<tr class="{$class}">
    <td>
        {$formLink}
    </td>
    <td class="checkbox">
        {$checkbox}
    </td>
</tr>
EOD;
        }
        $out .= '</table>';
    }
    $out .= '<input type="hidden" name="event" value="form" />';
    $pattern = '/<table cellpadding="0" cellspacing="0" border="0" id="list" align="center">(.*)<input type="hidden" name="event" value="form" \\/>/s';
    return preg_replace($pattern, tag($out, 'div', ' id="jmd_form_toggle"'), $buffer);
}