コード例 #1
0
ファイル: TextUtils.php プロジェクト: NerdZombies/MateCode
function resume($text, $length = 200, $use_textile = false)
{
    $source = strlen($text) < $length ? $text : substr($text, 0, strrpos(substr($text, 0, $length), " ")) . " &#8230;";
    if ($use_textile) {
        $result = textile($source);
    } else {
        $result = removeTextile($source);
    }
    return $result;
}
コード例 #2
0
 /**
  * Process text content. Processes content to turn the textile style code 
  * into HTML.
  *
  * @param string text The text to process.
  * @return string The processed content.
  */
 function processContent($text)
 {
     /*
      * Import David Allen's Textile formatter
      * -- ONE MODIFICATION is made to the formatter, these two lines:
      *     if (get_magic_quotes_gpc()==1)
      *       $text = stripslashes($text);
      * are removed because the input library already takes care
      * of removing slashes if magic_quotes is enabled.
      */
     require_once SM_DIR . 'textism.textile.php';
     return textile($text);
 }
コード例 #3
0
ファイル: text-control.php プロジェクト: brian3t/orchidmate
function tc_post_process($text, $do_text = '', $do_char = '')
{
    if ($do_text == 'textile2') {
        require_once 'text-control/textile2.php';
        $t = new Textile();
        $text = $t->process($text);
    } else {
        if ($do_text == 'textile1') {
            require_once 'text-control/textile1.php';
            $text = textile($text);
        } else {
            if ($do_text == 'markdown') {
                require_once 'text-control/markdown.php';
                $text = Markdown($text);
            } else {
                if ($do_text == 'wpautop') {
                    $text = wpautop($text);
                } else {
                    if ($do_text == 'nl2br') {
                        $text = nl2br($text);
                    } else {
                        if ($do_text == 'none') {
                            $text = $text;
                        } else {
                            $text = wpautop($text);
                        }
                    }
                }
            }
        }
    }
    if ($do_char == 'smartypants') {
        require_once 'text-control/smartypants.php';
        $text = SmartyPants($text);
    } else {
        if ($do_char == 'wptexturize') {
            $text = wptexturize($text);
        } else {
            if ($do_char == 'none') {
                $text = $text;
            } else {
                $text = wptexturize($text);
            }
        }
    }
    return $text;
}
コード例 #4
0
ファイル: TemplateData.php プロジェクト: NerdZombies/MateCode
 function logic($type, $object, $field)
 {
     $return = NULL;
     /*
     				TODO: Add multiple modifiers (separados por :??)
     */
     if ($type[0] == "\$") {
         $parameters = explode(",", substr($type, 1));
         $method = array_shift($parameters);
         $return = call_user_func_array(array($object, $method), $parameters);
     } else {
         $parameters = explode(",", $type);
         $type = array_shift($parameters);
         if (is_numeric($type)) {
             $return = $object[$type];
         } else {
             switch (strToLower($type)) {
                 // DATE CASES
                 /*case "byLanguage":
                 		$return = "hola";
                 		break;*/
                 /*case "first":
                 		$return = array_shift($object);
                 		break;*/
                 case "class":
                     $return = get_class($object);
                     break;
                 case "seofriendly":
                     $return = implode("-", explode(" ", $object)) . VIEW_SEO_EXTENSION;
                     break;
                 case "rpad":
                     $return = str_pad($object, $parameters[0], $parameters[1], STR_PAD_RIGHT);
                     break;
                 case "lpad":
                     $return = str_pad($object, $parameters[0], $parameters[1], STR_PAD_LEFT);
                     break;
                 case "divide":
                     $return = $object / $parameters[0];
                     break;
                 case "sum":
                     $return = intval($object) + $parameters[0];
                     break;
                 case "bool":
                     $return = $object ? "Yes" : "No";
                     break;
                 case "abs":
                     $return = abs($object);
                     break;
                 case "round":
                     $return = round($object * 10) / 10;
                     break;
                 case "multiply":
                     $return = $object * $parameters[0];
                     break;
                 case "md5":
                     $return = md5($object);
                     break;
                 case "diffnow":
                     $return = mktime() - strtotime($object);
                     break;
                 case "value":
                     if ($object != NULL) {
                         $return = $object;
                     } else {
                         $return = 0;
                     }
                     break;
                 case "urlname":
                     $return = strtolower(str_replace(" ", "_", $object));
                     break;
                 case "urlencode":
                     $return = urldecode($object);
                     break;
                 case "mdydate":
                     $return = date("m/d/Y", strtotime($object));
                     break;
                 case "dmydate":
                     $return = date("d/m/Y", strtotime($object));
                     break;
                 case "hmdate":
                     $return = date("H:i", strtotime($object));
                     break;
                 case "month":
                     $return = date("m", strtotime($object));
                     break;
                 case "fullmonth":
                     $return = date("F", strtotime($object));
                     break;
                 case "year":
                     $return = date("Y", strtotime($object));
                     break;
                 case "age":
                     //$return = abs(mktime(0,0,0,date("m",strtotime($object)),date("d",strtotime($object)),date("Y",strtotime($object))) - mktime(4,12,0,date("m"),date("d"),date("Y")) )/(60 * 60 * 24 * 356);
                     $return = date("Y") - date("Y", strtotime($object));
                     if (date("m", strtotime($object)) > date("m") || date("m", strtotime($object)) == date("m") && date("d", strtotime($object)) > date("d")) {
                         $return--;
                     }
                     break;
                 case "date":
                     $return = date("d", strtotime($object));
                     break;
                     /* mailto */
                 /* mailto */
                 case "mailto":
                     $return = mail_tag($object);
                     break;
                 case "empty":
                     $return = intval($object == NULL);
                     break;
                 case "elapsed":
                     import("date.TimeDate");
                     $return = TimeDate::elapsed($object);
                     break;
                 case "human":
                     import("date.TimeDate");
                     $return = TimeDate::human($object);
                     break;
                 case "count":
                     if (is_array($object)) {
                         $return = intval(count($object));
                     } else {
                         if (is_string($object)) {
                             $return = strlen($object);
                         } else {
                             $return = 0;
                         }
                     }
                     break;
                 case "toup":
                     $return = strToUpper($object);
                     break;
                 case "tolow":
                     $return = strToLower($object);
                     break;
                 case "resume":
                     array_splice($parameters, 0, 0, $object);
                     $return = call_user_func_array("resume", $parameters);
                     break;
                 case "custom":
                     //array_splice($parameters,0,0,$object);
                     $mth = array_shift($parameters);
                     $return = call_user_func_array($mth, $object);
                     break;
                 case "min":
                     $min1 = array_shift($parameters);
                     $return = min($min1, $object);
                     break;
                 case "notextile":
                     $return = removeTextile($object);
                     break;
                 case "textile":
                     $return = textile($object);
                     break;
                 case "thousands":
                     $parts = array();
                     while ($object > 1000) {
                         $parts[] = sprintf("%03s", $object % 1000);
                         $object = floor($object / 1000);
                     }
                     $parts[] = sprintf("%3d", $object);
                     $return = join(".", array_reverse($parts));
                     //(round($object*10))/10 . " ".$sizeNames[$s];
                     break;
                 case "humansize":
                     $sizeNames = array("bytes", "Kb", "Mb", "Gb", "Tb");
                     $s = 0;
                     while ($object > 1024) {
                         $object = $object / 1024;
                         $s++;
                     }
                     $return = round($object * 10) / 10 . " " . $sizeNames[$s];
                     break;
                 case "ajaxtoggle":
                     $return = linkTo($object, $this->data["controller"] . "/toggle/" . $this->data["item"]->id . "/{$field}", array("class" => "ajaxToggle tbutton"));
                     /*<mate:link to="{controller}/toggle/{item.id}/commentable" options="class:ajaxToggle tbutton">{item.commentable:bool}</mate:link>*/
                     break;
                 case "gotomodel":
                     $return = linkTo($object, $this->data["controller"] . "/view/" . $this->data["item"]->id);
                     /*<mate:link to="{controller}/toggle/{item.id}/commentable" options="class:ajaxToggle tbutton">{item.commentable:bool}</mate:link>*/
                     break;
                 case "random":
                     if (is_array($object)) {
                         $return = $object[rand(0, count($object))];
                     } else {
                         $return = rand(0, $object);
                     }
                     break;
                 case "export":
                     $return = var_export($object, true);
                     break;
                 default:
                     $return = $this->verbose ? $obj_path : "";
                     break;
             }
         }
     }
     return $return;
 }
コード例 #5
0
ファイル: wiki.inc.php プロジェクト: aquarion/AqWiki
function wiki($wiki, $article)
{
    global $dataSource;
    global $_CONFIG;
    global $_EXTRAS;
    $out = '';
    //if ($_CONFIG['oneWiki']){
    $base = $_CONFIG['base'];
    $url = $_CONFIG['base'] . "/{$article}";
    //} else {
    //	$base = $_CONFIG['base']."/".$wiki;
    //	$url = $_CONFIG['base']."/$wiki/$article";
    //}
    $content = array($wiki, $article, "", "aqWiki (Admin)", date("r"));
    if (!isset($_GET['action'])) {
        $_GET['action'] = false;
    }
    switch ($_GET['action']) {
        case "viewrev":
            if (!$_GET['id']) {
                panic("View Revision", "Parameters incorrect");
            }
            $id = $_GET['id'];
            $pages = $dataSource->getPage($article);
            debug("Found " . count($pages) . " pages");
            $row = $pages[$id];
            $content[2] = '<div class="info"><b>Note:</b> This is a <i>specific revision</i> of this page, and may be outdated, The current version is ((here|' . $article . ')). You can see the differences between this and the current revision <a href="' . $url . '?action=diff&amp;from=' . $id . '">here</a></div>';
            if (in_array($_EXTRAS['me'], $_EXTRAS['admins'])) {
                $content[2] .= '<div class="adminFunctions">Admin Actions: 
				<a href="' . $url . '?action=revert&id=' . $id . '">Revert back to this version</a>
				</div>';
            }
            $content[2] .= $row['content'];
            #."\n\n [ \"Edit This Page\":$url?action=edit | \"View Source\":$url?action=src ]";
            $content[3] = $row['creator'];
            $content[4] = date("r", $row['created']);
            $limit = 3;
            $current = 0;
            $_EXTRAS['versions'] = '';
            foreach ($pages as $row) {
                $line = date("r", $row['created']) . " - \"" . $row['creator'] . "\":{$base}/~" . $row['creator'];
                if ($row['comment']) {
                    $line .= " : " . $row['comment'];
                }
                if ($row['revision'] == $id) {
                    $_EXTRAS['versions'] .= "# " . $line . " [ Current ]\n";
                } else {
                    $_EXTRAS['versions'] .= "# " . $line . " [ <a href=\"" . $url . "?action=viewrev&amp;id=" . $row['revision'] . "\" title=\"View this revision\">View</a> |" . " <a href=\"" . $url . "?action=diff&amp;from=" . $id . "&amp;to=" . $row['revision'] . "\"\" title=\"View differences between this and the current revision\">Diff</a> ]\n";
                }
                $current++;
                if ($id < $row['revision']) {
                    // Nothing happens
                } elseif ($current >= $limit && $_GET['action'] != "allrev") {
                    if ($id == $row['revision']) {
                        $limit += 6;
                    } else {
                        $_EXTRAS['versions'] .= "# \"Show rest of revisions\":" . $url . "?action=allrev\n";
                        break;
                    }
                }
            }
            $content[2] .= $out;
            break;
        case "diff":
            $content[2] = "These are the differences between two versions of (({$article})). Lines styled <span class=\"added\">" . "like this</span> have been added to the entry, lines <span class=\"removed\">like this</span> have been removed.\n\n";
            $from = isset($_GET['from']) ? $_GET['from'] : false;
            $to = isset($_GET['to']) ? $_GET['to'] : false;
            $_EXTRAS['textarea'] = $dataSource->diff($article, $from, $to);
            $content[2] .= "[[TEXTAREA]]";
            break;
        case "newUser":
            /*mysql> describe users;
            		+---------------+------------------+-------------------+
            		| Field         | Type             | Collation         |
            		+---------------+------------------+-------------------+
            		| id            | int(10) unsigned | binary            |
            		| username      | varchar(64)      | latin1_swedish_ci |
            		| real_name     | tinytext         | latin1_swedish_ci |
            		| email         | tinytext         | latin1_swedish_ci |
            		| birthday      | date             | latin1_swedish_ci |
            		| password      | tinytext         | latin1_swedish_ci |
            		| location      | int(11)          | binary            |
            		| last_access   | timestamp        | latin1_swedish_ci |
            		| date_creation | timestamp        | latin1_swedish_ci |
            		| access_level  | int(11)          | binary            |
            		+---------------+------------------+-------------------+
            		10 rows in set (0.05 sec)
            		*/
            $form = '<form class="shiny" method=post action="' . $_SERVER['REQUEST_URI'] . '"><h2>New User</h2>' . "\n\n" . '|Username|<input type="text" name="username" value="' . $_POST['username'] . '">|(Must not be blank)|' . "\n" . '|Display Name|<input type="text" name="name" value="' . $_POST['name'] . '">|(Must not be blank)<br>|' . "\n" . '|e-Mail|<input type="text" name="email" value="' . $_POST['email'] . '">|(Must not be blank)<br>|' . "\n" . '|Password|<input type="password" name="password">|(Must not be blank)<br>|' . "\n" . '|Repeat Password |<input type="password" name="password2">| (Must match above) |' . "\n\n";
            if (isset($_CONFIG['recaptcha_public_key'])) {
                require_once 'recaptchalib.php';
                $public_key = $_CONFIG['recaptcha_public_key'];
                $form .= '<aqWikiNoProcess>' . recaptcha_get_html($public_key) . "</aqWikiNoProcess>\n\n";
            }
            $form .= '<input type="submit" name="submit" value="Create User">' . "\n\n" . '</form>';
            #print_r($_POST);
            if ($_POST['submit']) {
                $errors = array();
                if ($_POST['username'] == "") {
                    $errors[] = "Username cannot be blank";
                } elseif (strstr($_POST['username'], ",")) {
                    $errors[] = "Username cannot contain commas";
                } elseif (isset($_EXTRAS['reservedUsers']) && in_array($_POST['username'], $_EXTRAS['reservedUsers'])) {
                    $errors[] = "Username invalid";
                } elseif (!$dataSource->unique("users", "username", $_POST['username'])) {
                    $errors[] = "Username must be unique";
                }
                if ($_POST['email'] == "") {
                    $errors[] = "email cannot be blank";
                } elseif (!$dataSource->unique("users", "email", $_POST['email'])) {
                    $errors[] = "email must be unique";
                }
                if ($_POST['name'] == "") {
                    $errors[] = "Display Name cannot be blank";
                } elseif (!$dataSource->unique("users", "real_name", $_POST['name'])) {
                    $errors[] = "Display Name must be unique";
                }
                if ($_POST['password'] == "") {
                    $errors[] = "password cannot be blank";
                } elseif ($_POST['password'] != $_POST['password2']) {
                    $errors[] = "passwords must match";
                }
                if (isset($_CONFIG['recaptcha_private_key'])) {
                    $privatekey = $_CONFIG['recaptcha_private_key'];
                    $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
                    if (!$resp->is_valid) {
                        $errors[] = "Captcha invalid";
                    }
                }
                if (count($errors) == 0) {
                    $dataSource->newUser($_POST['username'], $_POST['name'], $_POST['password'], $_POST['email']);
                    sendAdminEmail('New User Created', $_POST);
                    $out = "h2. New user created\n\n";
                    $out .= "Hi, " . $_POST['name'] . ", Welcome to this aqWiki install.\n\n";
                    $url = parse_url($_SERVER['REQUEST_URI']);
                    $out .= "You should now \"login\":" . $url['path'] . "?action=login";
                } else {
                    $out = "h2. Error in user creation\n\n";
                    foreach ($errors as $error) {
                        $out .= "* " . $error . "\n";
                    }
                    $out .= "\n\n" . $form;
                }
            } else {
                $out = "h2. New user\n\n";
                $out .= $form;
            }
            $content[2] = $out;
            break;
        case "edit":
            if ($_EXTRAS['reqEdit']) {
                doAuth($_EXTRAS['reqEdit'], "edit a page");
            }
            if ($_EXTRAS['restrictNewPages']) {
                doAuth($_EXTRAS['restrictNewPages'], "create a new page");
            }
            $form = true;
            $text = false;
            switch ($_POST['submit']) {
                case "Preview":
                    $out = $_POST['content'];
                    $text = stripslashes($_POST['content']);
                    break;
                case "Spell Check":
                    $checker = new Spellchecker();
                    $text = strip_tags(textile($_POST['content']));
                    $num_errors = $checker->check($text);
                    if ($num_errors > 0) {
                        $out .= "h3. Spell Check\n\n";
                        #$out .= "Items <span class=\"spellCorrect\">like this</span> could be errors, hover over for suggestions. Items <span class=\"spellNoSuggest\">like this</span> arn't in the dictionary, and the spell checker has no idea.\n\n";
                        $errors = $checker->getErrors();
                        $oldtext = $text;
                        foreach ($errors as $word => $suggestions) {
                            /*$title = trim(implode(', ', $suggestions));
                            		if ($title == ""){
                            			$span = '<|-|'.$title.'|-|>'.$word.'</-|>';
                            		} else {
                            			$span = '<|||'.$title.'|||>'.$word.'</||>';
                            		}*/
                            $suggs = implode(' ', $suggestions);
                            if ($suggs != " ") {
                                $errorlist .= "*" . $word . ":* " . $suggs . "\n\n";
                            } else {
                                $noidea[] = $word;
                            }
                            # $text = str_replace($word, $span, $text);
                            #$text = preg_replace("/(\W|^)$word(\W|\$)/i", "$1$span$2", $text);
                        }
                        /*
                        						//if ($title == ""){
                        							$text = str_replace('<|-|', '<span class="spellNoSuggest"', $text);
                        							$text = str_replace('|-|>', '>', $text);
                        							$text = str_replace('</-|>', '</span>', $text);
                        						//} else {
                        							$text = str_replace('<|||', '<span class="spellCorrect" title="', $text);
                        							$text = str_replace('|||>', '">', $text);
                        							$text = str_replace('</||>', '</span>', $text);
                        						//}*/
                    }
                    if ($noidea) {
                        $errorlist .= "*No idea about:* " . implode(' ', $noidea) . "\n\n";
                    }
                    #$out .= $text;
                    $out .= $errorlist . "\n";
                    $text = stripslashes($_POST['content']);
                    break;
                case "Post":
                    $page = array_shift($dataSource->getPage($article));
                    if ($page['rev_created'] > $_POST['edittime']) {
                        $content[2] .= collision_detection($page, $_POST);
                        $text = $_POST['content'];
                        //$form = false;
                    } else {
                        $dataSource->post($article, $_POST['content'], $_POST['comment']);
                        $form = false;
                        header("location: {$url}");
                    }
            }
            if ($text) {
                $_EXTRAS['textarea'] = $text;
            } elseif (!$dataSource->pageExists($article)) {
                $_POST['comment'] = "Start of a brand new world";
                $_EXTRAS['textarea'] = "";
            } else {
                $_EXTRAS['textarea'] = stripslashes($dataSource->getContent($article));
            }
            preg_match_all("/\\[\\[LOCKED\\|(.*?)\\]\\]/", $_EXTRAS['textarea'], $matches);
            foreach ($matches[0] as $index => $match) {
                $users = $matches[1][$index];
                doAuth($users, "view this");
            }
            if ($form) {
                $out .= "<form method=post action=\"" . $_SERVER['REQUEST_URI'] . "\" class=\"shiny wikiedit\">";
                $out .= '<h2>Editing "' . $content[1] . '"</h2>';
                $out .= "<p>You should read the ((help)). If you are having problems with the formatting, post it and add a note explaining the problem to ((formattingProblems)) and I'll dive in and fix it. If you believe you've found a bug in the wiki software, post your problem to \"the bug tracker\":http://trac.aqxs.net/aqwiki/newticket and I'll dive in and fix that too.</p>\n";
                //$out .= "<label for=\"creator\">Author</label>\n";
                //$out .= $_EXTRAS['me']."<br>\n";
                $out .= "<label for=\"content\">Content of page \"" . $content[1] . "\"</label>\n";
                $out .= "<textarea name=\"content\" id=\"content\" rows=\"30\" cols=\"72\">[[TEXTAREA]]</textarea>\n<br>\n";
                $out .= "<label for=\"comment\">Comment</label>\n";
                $out .= "<input type=\"text\" name=\"comment\" id=\"comment\" size=\"72\" value=\"" . $_POST['comment'] . "\"><br>\n";
                $out .= "<input class=\"submit\" type=\"hidden\" name=\"edittime\" value=\"" . time() . "\">\n";
                $out .= "<input class=\"submit\" type=\"submit\" name=\"submit\" value=\"Post\"> ";
                $out .= "<input class=\"submit\" type=\"submit\" name=\"submit\" value=\"Preview\"> ";
                $out .= "<input class=\"submit\" type=\"submit\" name=\"submit\" value=\"Spell Check\"> ";
                $out .= "<input class=\"submit\" type=\"reset\"  name=\"revert\" value=\"Revert to pre-editing\">\n";
                $out .= "</form>";
                $content[2] .= $out;
                break;
            }
        case "allrev":
            if (!$dataSource->pageExists($article)) {
                $content[2] = 'Error: Page doesn\'t exist. What are you playing at?';
                break;
            }
            $content[2] = '<form method="GET" action="' . $url . '" style="width: auto;">';
            $content[2] .= '<h2>Viewing all revisions for ((' . $article . "))</h2>\n\n";
            $content[2] .= 'Select the <input type="radio" /> boxes to compare two revisions' . "\n\n";
            $pages = $dataSource->getPage($article);
            $pages = array_reverse($pages);
            foreach ($pages as $row) {
                $line = '<input type="radio" name="from" value="' . $row['revision'] . '">';
                $line .= '<input type="radio" name="to" value="' . $row['revision'] . '">';
                $line .= date("Y-m-d H:i", $row['created']) . " - " . userlink($row['creator']);
                if ($row['comment']) {
                    $line .= " : " . $row['comment'];
                }
                $content[2] .= "# " . $line . " [ <a href=\"" . $url . "?action=viewrev&amp;id=" . $row['revision'] . "\" title=\"View this revision\">View</a> |" . " <a href=\"" . $url . "?action=diff&amp;from=" . $row['revision'] . "\"\" title=\"View differences between this and the current revision\">Diff</a> ]\n";
            }
            $content[2] .= '<input type="submit" value="Compare Revisions">
			<input type="hidden" value="diff" name="action">
			</form>';
            break;
        case "revert":
            if (!in_array($_EXTRAS['me'], $_EXTRAS['admins'])) {
                panic('AqWiki Reversion', 'You\'re not an admin, you can\'t do this shit');
            }
            if (!$_GET['id']) {
                die("Parameters incorrect");
            }
            $id = $_GET['id'];
            $pages = $dataSource->getPage($article);
            $oldVersion = $pages[$id];
            //die($oldVersion['content']);
            $dataSource->post($article, $oldVersion['content'], 'reverted back to version ' . $id);
            $form = false;
            $content[2] = 'Reverted ((' . $article . ')) back to version ' . $id;
            break;
        default:
            $_EXTRAS['versions'] = "";
            if (!$dataSource->pageExists($article)) {
                if ($_EXTRAS['restrictNewPages'] || $_EXTRAS['reqEdit']) {
                    if ($_EXTRAS['restrictNewPages'] == "register") {
                        $message = "any registered users";
                    } else {
                        $message = "only certain users";
                    }
                    if (!isset($_EXTRAS['newPageMessage'])) {
                        $npm = "This page doesn't exist yet. [[TYPES]] can create new pages. Do you want to do so?\n\n\"Go On Then\":[[EDITURL]]";
                    } else {
                        $npm = $_EXTRAS['newPageMessage'];
                    }
                    $content[2] = str_replace(array("[[TYPES]]", "[[EDITURL]]"), array($message, $url . "?action=edit"), $npm);
                } else {
                    $content[2] = "This page doesn't exist yet, Would you like to create it?\n\n\"Go On Then\":" . $url . "?action=edit";
                }
            } else {
                $_EXTRAS['nearby'] = $dataSource->nearby($article);
                $pages = $dataSource->getPage($article);
                $row = array_shift($pages);
                if (strcmp($row['wiki'], $wiki) != 0) {
                    $base = $_CONFIG['base'] . "/" . $row['wiki'];
                    $url = $base . "/" . $article;
                    header("location: " . $url);
                }
                $content[2] = $row['content'];
                $content[3] = $row['creator'];
                $content[4] = date("r", $row['created']);
                $line = date("r", $row['created']) . " - " . userlink($row['creator']);
                if ($row['comment']) {
                    $line .= " : " . $row['comment'];
                }
                if ($_EXTRAS['current'] != $article) {
                    $pages = $dataSource->getPage($_EXTRAS['current']);
                    $row = array_shift($pages);
                }
                $_EXTRAS['versions'] .= "# " . $line . " [ Current ]\n";
                $limit = 10;
                $current = 0;
                foreach ($pages as $row) {
                    $line = date("Y-m-d\tH:i", $row['created']) . " - " . userlink($row['creator']);
                    if ($row['comment']) {
                        $line .= " : " . $row['comment'];
                    }
                    $_EXTRAS['versions'] .= "# " . $line . " [ <a href=\"" . $url . "?action=viewrev&amp;id=" . $row['revision'] . "\" title=\"View this revision\">View</a> |" . " <a href=\"" . $url . "?action=diff&amp;from=" . $row['revision'] . "\"\" title=\"View differences between this and the current revision\">Diff</a> ]\n";
                    $current++;
                    if ($_GET['action'] != "allrev" && $current > $limit) {
                        $_EXTRAS['versions'] .= "# \"Show list of revisions\":" . $url . "?action=allrev\n";
                        break;
                    }
                }
                #$content[2] .= $out;
            }
    }
    return $content;
}
コード例 #6
0
ファイル: index.php プロジェクト: vojtajina/sitellite
<?php

loader_import('ext.textile');
echo textile($parameters['text']);
if ($box['context'] == 'action') {
    exit;
}
コード例 #7
0
 function textile($string)
 {
     switch ($this->get_config('textile_version')) {
         case 3:
             if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
                 require_once S9Y_INCLUDE_PATH . 'plugins/serendipity_event_textile/lib3/src/Netcarver/Textile/Parser.php';
                 require_once S9Y_INCLUDE_PATH . 'plugins/serendipity_event_textile/lib3/src/Netcarver/Textile/DataBag.php';
                 require_once S9Y_INCLUDE_PATH . 'plugins/serendipity_event_textile/lib3/src/Netcarver/Textile/Tag.php';
                 include 'textile_namespace.inc.php';
                 // PHP 5.2 compat
                 // todo check for user-supplied output to restrict
                 #    return $textile->textileRestricted($string);
                 if (is_object($textile)) {
                     return $textile->textileThis($string);
                 }
             } else {
                 trigger_error(' Textile lib3 needs at least PHP 5.3.0 running. Update your PHP version or use lib2 instead.', E_USER_WARNING);
             }
             break;
         case 2:
             require_once S9Y_INCLUDE_PATH . 'plugins/serendipity_event_textile/lib2/classTextile.php';
             $textile = new Textile();
             return $textile->textileThis($string);
             break;
         case 1:
             require_once S9Y_INCLUDE_PATH . 'plugins/serendipity_event_textile/lib1/textile.php';
             return textile($string);
             break;
     }
 }
コード例 #8
0
function smarty_modifier_textile($text)
{
    return textile($text, '');
}
コード例 #9
0
ファイル: elements.inc.php プロジェクト: aquarion/AqWiki
function page($content)
{
    global $_EXTRAS;
    global $_CONFIG;
    global $dataSource;
    if ($_CONFIG['oneWiki']) {
        $base = $_CONFIG['base'];
    } else {
        $base = $_CONFIG['base'] . "/" . $_EXTRAS['wiki'];
    }
    /* $content is an array containing:
    			
    			[0] Name of Wiki template
    			[1] Title of page
    			[2] Content of page
    			[3] Author of page
    			[4] Date of modification */
    $output = isset($_GET['output']) ? $_GET['output'] : "html";
    switch ($output) {
        case "rss":
            header("Content-Type: text/xml");
            $out = buildRSS($content);
            break;
        case "fragment":
            if (isset($_EXTRAS['mimetype'])) {
                $mime = $_EXTRAS['mimetype'];
            } else {
                $mime = 'text/html';
            }
            header("Content-Type: " . $mime);
            $out = process($content[2], $content[0]);
            break;
        case "source":
            if (isset($_EXTRAS['mimetype'])) {
                $mime = $_EXTRAS['mimetype'];
            } else {
                $mime = 'text/plain';
            }
            header("Content-Type: " . $mime);
            $out = $content[2];
            break;
        default:
            if (file_exists("etc/" . $content[0] . ".tpl")) {
                $file = "etc/" . $content[0] . ".tpl";
                $template = implode("", file($file));
                debug("Using template " . $file);
            } elseif (file_exists("etc/default.tpl")) {
                $template = implode("", file("etc/default.tpl"));
                debug("Using default template");
            } else {
                debug("No default template found, using basic");
                $template = "<html>\n<head>\n<title>[[WIKI]] - [[TITLE]]</title>\n</head>\n<body>\n<h1>[[TITLE]]</h1>\n[[CONTENT]]\n<a href=\"[[URL]]?action=edit\">Edit This Page</a>\n[[VERSIONS]]<hr>\n[[AUTHOR]] @ [[DATE]]<br>You Are: [[USER]] Identified by [[AUTH]] [ <a href=\"[[URL]]?action=login\">Login</a> | <a href=\"[[URL]]?action=newUser\">New User</a> ]<br>Generated by [[AQWIKI]]</body>\n</html>";
            }
            $text = process($content[2], $content[0]);
            $out = $template;
            $nearby = isset($_EXTRAS['nearby']) ? $_EXTRAS['nearby'] : '';
            $versions = isset($_EXTRAS['versions']) ? $_EXTRAS['versions'] : '';
            $out = preg_replace("/\\[\\[CONTENT\\]\\]/", $text, $out);
            $out = preg_replace("/\\[\\[AQWIKI\\]\\]/", $_EXTRAS['versionString'], $out);
            $out = preg_replace("/\\[\\[WIKI\\]\\]/", $content[0], $out);
            $out = preg_replace("/\\[\\[TITLE\\]\\]/", $content[1], $out);
            $out = preg_replace("/\\[\\[PAGE\\]\\]/", $_EXTRAS['argv'][1], $out);
            $out = preg_replace("/\\[\\[AUTHOR\\]\\]/", userLink($content[3]), $out);
            $out = preg_replace("/\\[\\[DATE\\]\\]/", $content[4], $out);
            $out = preg_replace("/\\[\\[URL\\]\\]/", $_CONFIG['host'] . "/" . $base . $_EXTRAS['current'], $out);
            $out = preg_replace("/\\[\\[BASE\\]\\]/", $base, $out);
            $out = preg_replace("/\\[\\[USER\\]\\]/", userLink($_EXTRAS['me']), $out);
            $out = preg_replace("/\\[\\[AUTH\\]\\]/", $_EXTRAS['auth'], $out);
            $out = preg_replace("/\\[\\[NEARBY\\]\\]/", textile(menu($nearby, "nearby")), $out);
            $out = preg_replace("/\\[\\[VERSIONCOUNT\\]\\]/", count($dataSource->getPage($content[1])), $out);
            $out = preg_replace("/\\[\\[VERSIONS\\]\\]/", textile($versions), $out);
            // Conditional includes
            preg_match_all("/\\[\\[IFEDIT\\|(.*?)\\|(.*?)\\]\\]/", $out, $matches);
            foreach ($matches[0] as $index => $match) {
                if (checkAuth("edit")) {
                    $out = preg_replace("#" . preg_quote($match, "#") . "#", stripslashes($matches[1][$index]), $out);
                } else {
                    $out = preg_replace("#" . preg_quote($match, "#") . "#", stripslashes($matches[2][$index]), $out);
                }
                #$_EXTRAS[$matches[1][$index]] = $matches[2][$index];
            }
            preg_match_all("/\\[\\[IFEDIT\\|(.*?)\\]\\]/", $out, $matches);
            foreach ($matches[0] as $index => $match) {
                $result = stripslashes($matches[1][$index]);
                if (checkAuth("edit")) {
                    $out = preg_replace("#" . preg_quote($match, "#") . "#", $result, $out);
                } else {
                    $out = preg_replace("#" . preg_quote($match, "#") . "#", "", $out);
                }
                #$_EXTRAS[$matches[1][$index]] = $matches[2][$index];
            }
            preg_match_all("/\\[\\[IfLoggedIn\\|(.*?)\\|(.*?)\\]\\]/", $out, $matches);
            foreach ($matches[0] as $index => $match) {
                $result = $matches[1][$index];
                if ($_EXTRAS['auth'] !== 'host') {
                    $out = preg_replace("#" . preg_quote($match, "#") . "#", $matches[1][$index], $out);
                } else {
                    $out = preg_replace("#" . preg_quote($match, "#") . "#", $matches[2][$index], $out);
                }
                #$_EXTRAS[$matches[1][$index]] = $matches[2][$index];
            }
            preg_match_all("/\\[\\[PLURAL\\|(.*?)\\]\\]/", $out, $matches);
            foreach ($matches[0] as $index => $match) {
                if (intval($matches[1][$index]) != 1) {
                    $plural = 's';
                } else {
                    $plural = '';
                }
                $out = preg_replace("#" . preg_quote($match, "#") . "#", $plural, $out);
                #$_EXTRAS[$matches[1][$index]] = $matches[2][$index];
            }
            if ($_CONFIG['debug']) {
                global $DEBUG;
                $out .= "<p>" . implode("<br>\n", $DEBUG) . "</p>";
            }
            preg_match_all("/\\[\\[RAWVAR\\|(.*?)\\]\\]/", $out, $matches);
            foreach ($matches[0] as $index => $match) {
                if (isset($_EXTRAS[$matches[1][$index]])) {
                    $var = $_EXTRAS[$matches[1][$index]];
                } else {
                    $var = '';
                }
                $out = preg_replace("#" . preg_quote($match, "#") . "#", $var, $out);
            }
    }
    return $out;
}
コード例 #10
0
 function textile($string)
 {
     if ($this->get_config('textile_version') == 2) {
         require_once S9Y_INCLUDE_PATH . 'plugins/serendipity_event_textile/classTextile.php';
         $textile = new Textile();
         return $textile->textileThis($string);
     } else {
         require_once S9Y_INCLUDE_PATH . 'plugins/serendipity_event_textile/textile.php';
         return textile($string);
     }
 }
コード例 #11
0
ファイル: text-control.php プロジェクト: hunterfu/plugins
function tc_post_process($text, $do_text = '', $do_char = '')
{
    if ('textile2' == $do_text) {
        require_once 'text-control/textile2.php';
        $t = new Textile();
        $text = $t->process($text);
    } else {
        if ('textile1' == $do_text) {
            require_once 'text-control/textile1.php';
            $text = textile($text);
        } else {
            if ('markdown' == $do_text) {
                require_once 'text-control/markdown.php';
                //$text = Markdown_Parser($text);
                $o = new Markdown_Parser();
                return $o->transform($text);
            } else {
                if ('txt2tags' == $do_text) {
                    require_once 'text-control/txt2tags.class.php';
                    $x = new T2T($text);
                    $x->go();
                    return $text = $x->bodyhtml;
                } else {
                    if ('wpautop' == $do_text) {
                        $text = wpautop($text);
                    } else {
                        if ('nl2br' == $do_text) {
                            $text = nl2br($text);
                        } else {
                            if ('none' == $do_text) {
                                $text = $text;
                            } else {
                                $text = wpautop($text);
                            }
                        }
                    }
                }
            }
        }
    }
    if ('smartypants' == $do_char) {
        require_once 'text-control/smartypants.php';
        $text = SmartyPants($text);
    } else {
        if ('wptexturize' == $do_char) {
            $text = wptexturize($text);
        } else {
            if ('none' == $do_char) {
                $text = $text;
            } else {
                $text = wptexturize($text);
            }
        }
    }
    return $text;
}
コード例 #12
0
ファイル: pvlib.php プロジェクト: wborbajr/TecnodataApp
/**
 * Wrapper for Textile.
 *
 * Uses Textile 2 by default, but if it's not there it falls back to Textile 1.
 *
 * @param string $str
 * @return string
 */
function pivot_textile($str)
{
    global $textile;
    // If magic_quotes_gpc is set, we need to add slashes..
    if (get_magic_quotes_gpc()) {
        $str = addslashes($str);
    }
    if (isset($textile)) {
        $output = $textile->TextileThis($str);
        return $output;
    } else {
        if (file_exists("includes/textile/classtextile.php")) {
            include_once "includes/textile/classtextile.php";
            $textile = new Textile();
            $output = $textile->TextileThis($str);
            return $output;
        } else {
            if (file_exists("includes/textile/textile.php")) {
                include_once 'includes/textile/textile.php';
                return textile($str);
            } else {
                return $str;
            }
        }
    }
}
コード例 #13
0
ファイル: textile.php プロジェクト: AppChecker/onxshop
 /**
  * parse textile
  */
 public function parseTextile($text)
 {
     // function defined in onxshop.functions.php
     return textile($text);
 }