Exemple #1
0
<div class='wrap'>
<!--h2>About Lots of Locales (LoL) Store Locator Plugin</h2><br-->
<?php

//print "<span style='font-size:14px; font-family:Helvetica'>";
ob_start();
include('readme.txt');
$txt=ob_get_contents();
ob_clean();
//print ereg_replace("(http://.*\..*\..{2,3}\n)", "<a href='\\1' target='_blank'>\\1</a>", $txt);
//$txt=ereg_replace("(http://www.viadat.com)", "<a href='\\1' target='_blank'>\\1</a>", $txt);

$txt=ereg_replace("\=\=\= ", "<h2>", $txt);
$txt=ereg_replace(" \=\=\=", "</h2>", $txt);
$txt=ereg_replace("\=\= ", "<div id='wphead' style='color:white'><h1 id='site-heading'><span id='site-title'>", $txt);
$txt=ereg_replace(" \=\=", "</h1></span></div>", $txt);
$txt=ereg_replace("\= ", "<b><u>", $txt);
$txt=ereg_replace(" \=", "</u></b>", $txt);

//$txt=ereg_replace("\[(.*)\]\((a-z\.\:\/)\)", "<a href='\\2'>\\1</a>", $txt);

//$txt=ereg_replace("\[(.*)\]\(([a-zA-Z]+://[.]?[a-zA-Z0-9_/?&amp;%20,=-\+-])*\)", "<a href=\"\\2\" target=_blank>\\1</a>", $txt);

$txt=do_hyperlink($txt);

print nl2br($txt);
//print "</span>";

?>
</div>
function sl_readme_parse($path_to_readme, $path_to_env)
{
    include $path_to_env;
    //print "<span style='font-size:14px; font-family:Helvetica'>";
    ob_start();
    include $path_to_readme;
    $txt = ob_get_contents();
    ob_clean();
    //TOC pt.1
    $toc = $txt;
    preg_match_all("@\\=\\=\\=[ ]([^\\=\\=\\=]+)[ ]\\=\\=\\=@", $toc, $toc_match_0);
    preg_match_all("@\\=\\=[ ]([^\\=\\=]+)[ ]\\=\\=@", $toc, $toc_match_1);
    //var_dump($toc_match_1); die();
    preg_match_all("@\\=[ ]([^\\=]+)[ ]\\=@", $toc, $toc_match_2);
    //var_dump($toc_match_2); die();
    $toc_cont = "";
    foreach ($toc_match_2[1] as $heading) {
        if (!in_array($heading, $toc_match_1[1]) && !in_array($heading, $toc_match_0[1]) && !preg_match("@^[0-9]+\\.[0-9]+@", $heading)) {
            $toc_cont .= "<li style='margin-left:30px; list-style-type:circle'><a href='#" . comma($heading) . "' style='text-decoration:none'>{$heading}</a></li></li>";
        } elseif (!in_array($heading, $toc_match_0[1]) && !preg_match("@^[0-9]+\\.[0-9]+@", $heading)) {
            //!preg_match("@^[0-9]+\.[0-9]+@", $heading) prevents changelog numbers from showing up
            $toc_cont .= "<li style='margin-left:15px; list-style-type:disc'><b><a href='#" . comma($heading) . "' style='text-decoration:none'>{$heading}</a></b></li>";
        }
    }
    //parsing
    $th_start = "<th style='font-size:125%; font-weight:bold;'>";
    $h2_start = "<h2 style='font-family:Georgia; margin-bottom:0.05em;'>";
    $h3_start = "<h3 style='font-family:Georgia; margin-bottom:0.05em; margin-top:0.3em'>";
    $txt = str_replace("=== ", "{$h2_start}", $txt);
    $txt = str_replace(" ===", "</h2>", $txt);
    //$txt=str_replace("== ", "<div id='wphead' style='color:black; background: -moz-linear-gradient(center bottom, #D7D7D7, #E4E4E4) repeat scroll 0 0 transparent'><h1 id='site-heading'><span id='site-title'>", $txt);
    $txt = str_replace("== ", "<table class='widefat' ><thead>{$th_start}", $txt);
    $txt = str_replace(" ==", "</th></thead></table><!--a style='float:right' href='#readme_toc'>Table of Contents</a-->", $txt);
    $txt = str_replace("= ", "{$h3_start}", $txt);
    $txt = str_replace(" =", "</h3><a style='float:right; position:relative; top:-1.5em; font-size:10px' href='#readme_toc'>" . __("table of contents", SL_TEXT_DOMAIN) . "</a>", $txt);
    $txt = preg_replace("@Tags:[ ]?[^\r\n]+\r\n@", "", $txt);
    //TOC pt. 2
    $txt = str_replace("</h2>", "</h2><a name='readme_toc'></a><div style='float:right;  width:500px; border-radius:1em; border:solid silver 1px; padding:7px; padding-top:0px; margin:10px; margin-right:0px;'><h3>" . __("Table of Contents", SL_TEXT_DOMAIN) . "</h2>{$toc_cont}</div>", $txt);
    $txt = preg_replace_callback("@{$h2_start}<u>([^<.]*)</u></h1>@s", create_function('$matches', 'return "<h2 style=\'font-family:Georgia; margin-bottom:0.05em;\'><a name=\'".comma($matches[1])."\'></a>$matches[1]</u></h1>";'), $txt);
    $txt = preg_replace_callback("@{$th_start}([^<.]*)</th>@s", create_function('$matches', 'return "<th style=\'font-size:125%; font-weight:bold;\'><a name=\'".comma($matches[1])."\'></a>$matches[1]</th>";'), $txt);
    $txt = preg_replace_callback("@{$h3_start}( )*([^<.]*)( )*</h3>@s", create_function('$matches', 'return "<h3 style=\'font-family:Georgia; margin-bottom:0.05em; margin-top:0.3em\'><a name=\\"".comma($matches[2])."\\"></a>{$matches[1]}$matches[2]</h3>";'), $txt);
    //creating hyperlinks on top of labeled URLs (ones preceded w/a label in brackets)
    $txt = preg_replace("@\\[([a-zA-Z0-9_/?&amp;\\&\\ \\.%20,=\\-\\+\\-\\']+)*\\]\\(([a-zA-Z]+://)(([.]?[a-zA-Z0-9_/?&amp;%20,=\\-\\+\\-\\#]+)*)\\)@s", "<a onclick=\"window.parent.open('\\2'+'\\3');return false;\" href=\"#\">\\1</a>", $txt);
    //converting asterisked lines into HTML list items
    /*$txt=preg_replace("@\*[ ]?[ ]?([a-zA-Z0-9_/?&amp;\&\ \.%20,=\-\+\-\(\)\{\}\`\'\<\>\"\#\:]+)*(\r\n)?@s", "<li style='margin-left:15px; margin-bottom:0px;'>\\1</li>", $txt);*/
    $txt = preg_replace("@\\*[ ]?[ ]?([^\r\n]+)*(\r\n)?@s", "<li style='margin-left:15px; margin-bottom:0px;'>\\1</li>", $txt);
    //additional formatting
    $txt = preg_replace("@`([^`]+)*`@", "<strong class='sl_code code' style='padding:2px; border:0px'>\\1</strong>", $txt);
    $txt = preg_replace("@__([^__]+)__@", "<strong>\\1</strong>", $txt);
    $txt = preg_replace("@\r\n([0-9]\\.)@", "\r\n&nbsp;&nbsp;&nbsp;\\1", $txt);
    $txt = preg_replace("@([A-Za-z-0-9\\/\\&;# ]+): @", "<strong>\\1: </strong>", $txt);
    //$txt=preg_replace("@\[(.*)\]\(([a-zA-Z]+\://[.]?[a-zA-Z0-9_/?&amp;%20,=-\+-])*\)@s", "<a href=\"\\2\" target=_blank>\\1</a>", $txt);
    //creating hyperlinks out of text URLs (which have 'http:' in the front)
    $txt = do_hyperlink($txt, "'_blank'", "protocol");
    print nl2br($txt);
    //print "</span>";
}
<?php

if (function_exists("file_get_contents") && 1 == 2) {
    $main = file_get_contents(SL_PATH . "/store-locator.php");
    $head_comment = token_get_all($main);
    $hc = $head_comment[1][1];
    $hc = preg_replace("/\r\n([^:]+:)/", "\r\n<b>\\1</b>", $hc);
    $hc = do_hyperlink($hc, "'_blank'", "protocol");
    print nl2br(preg_replace("@((\r\n)?\\*/|/\\*(\r\n))?@", "", $hc)) . "<br><br>";
} else {
    print "<b>Plugin Name:</b> Store Locator<br>\n\t<b>Plugin URI:</b> <a href='http://www.viadat.com/store-locator/'>http://www.viadat.com/store-locator/</a><br>\n\t<b>Version:</b> " . SL_VERSION . "<br>\n\t<b>Author:</b> Viadat Creations<br>\n\t<b>Author URI:</b> <a href='http://www.viadat.com'>http://www.viadat.com</a><br><br>";
}
?>
<strong>View:&nbsp;<a href='#' id='readme_button'>Instructions</a>&nbsp;|&nbsp;<a href="#server_caps" rel="sl_pop" id='server_caps_button'>Server Capabilities</a>&nbsp;|&nbsp;<a href="#shortcode_params" rel="sl_pop" id='shortcode_params_button'>Shortcode Params</a></strong>
<table id="" style="display: none;"><tr><td><div id='server_caps'>
<strong>Your Server Capabilities:</strong><br>
<table cellpadding='4px' width='100%' class='sl_code code'>
<tr><td valign='top'><b>PHP:</b></td><td><?php 
include SL_INFO_PATH . "/php-ver.php";
?>
</td></tr>
<tr><td valign='top'><b>Zip:</b></td><td><?php 
include SL_INFO_PATH . "/zip-info.php";
?>
</td></tr>
<tr><td valign='top'><b>Extensions:</b></td><td><pre style='line-height:10px; font-size:11px; padding-top:0px; margin-top:0px;'><?php 
print_r(get_loaded_extensions());
?>
</pre></td></tr>
</table></div>
</td></tr></table>
 /**
  * Convert text in the WP readme file format (wiki markup) to basic HTML
  *
  * Parameters:
  * @param string $file - optional name of the file in the plugin dir defaults to readme.txt
  * @param type $dir - optional directory path, defaults to plugin_dir_path
  */
 function convert_text_to_html($file = 'readme.txt', $dir = null)
 {
     if ($dir === null) {
         $dir = $this->parent->plugin_path;
     }
     ob_start();
     include $dir . $file;
     $content = ob_get_contents();
     ob_end_clean();
     $content = preg_replace('#\\=\\=\\= #', "<h2>", $content);
     $content = preg_replace('# \\=\\=\\=#', "</h2>", $content);
     $content = preg_replace('#\\=\\= #', "<div id='wphead' style='color:white'><h1 id='site-heading'><span id='site-title'>", $content);
     $content = preg_replace('# \\=\\=#', "</h1></span></div>", $content);
     $content = preg_replace('#\\= #', "<b><u>", $content);
     $content = preg_replace('# \\=#', "</u></b>", $content);
     $content = do_hyperlink($content);
     return nl2br($content);
 }