Ejemplo n.º 1
0
function devfmt_ContentFormat($AContent, $AFilter, $AInit = true)
{
    global $DevFmt_Config, $DevFmt_ParsedCode, $DevFmt_SuppLangs, $DevFmt_FiltersToAvoid, $post;
    if ($AFilter == 'example' || $DevFmt_Config['usedevformat']) {
        if (!is_feed() || is_feed() && $DevFmt_Config['hookrss2']) {
            if ($AInit) {
                $DevFmt_ParsedCode = devfmt_ContentGrabCode($AContent);
                $AContent = $DevFmt_ParsedCode[0];
            } else {
                $ContentCheck = devfmt_ContentCheckCode($AContent, true, isset($post) ? $post : null);
                if ($ContentCheck[0]) {
                    $AContent = $ContentCheck[1];
                }
            }
        }
    }
    return $AContent;
}
Ejemplo n.º 2
0
function devfmt_addPage()
{
    global $DevFmt_Config, $DevFmt_ParsedCode, $DevFmt_SuppLangs;
    if (!current_user_can('manage_options')) {
        return false;
    }
    devfmt_ReadConfigAndLangs();
    if (isset($_POST)) {
        if (isset($_POST['UpdateConfig'])) {
            check_admin_referer('devfmt-update-config');
            $DevFmt_Config['geshilangpath'] = str_replace("\\\\", "\\", $_POST['geshilangpath']);
            $DevFmt_Config['geshiuselink'] = isset($_POST['geshiuselink']) ? "1" : "0";
            $DevFmt_Config['displaylinenumbers'] = isset($_POST['displaylinenumbers']) ? "1" : "0";
            $DevFmt_Config['usedevformat'] = isset($_POST['usedevformat']) ? "1" : "0";
            $DevFmt_Config['devfmtcss'] = $_POST['devfmtcss'];
            $DevFmt_Config['linkjquery'] = isset($_POST['linkjquery']) ? "1" : "0";
            $DevFmt_Config['highlighttags'] = isset($_POST['highlighttags']) ? "1" : "0";
            $DevFmt_Config['copyclipboartext'] = $_POST['copyclipboartext'];
            $DevFmt_Config['hookrss2'] = isset($_POST['hookrss2']) ? "1" : "0";
            $DevFmt_Config['parsepre'] = isset($_POST['parsepre']) ? "1" : "0";
            $DevFmt_Config['showtools'] = isset($_POST['showtools']) ? "1" : "0";
            $DevFmt_Config['useajaxparse'] = isset($_POST['useajaxparse']) ? "1" : "0";
            devfmt_UpdateConfig();
        }
    }
    if ($DevFmt_Config['geshilangpath'] == "") {
        $DevFmt_Config['geshilangpath'] = DEVFMT_GESHIPATH;
    }
    ?>
	<div class="wrap">
    <div id="icon-options-general" class="icon32"><br /></div>
		<h2>DevFormatter <span style="font-size:15px"><em><?php 
    echo devfmt_Version();
    ?>
</em></span></h2>
    <h3>Configurations</h3>
    <form method="post" action="options-general.php?page=devformatter/devformatter.php">
    <?php 
    wp_nonce_field('devfmt-update-config');
    ?>
    <fieldset class="options">
    <table>
    <tbody>
    <tr valign="top">
    <th scope="row" align="right"><br />DevFormatter:</th>
    <td>
      <table class="form-table">
      <tbody>

      <tr valign="top">
      <td scope="row"><strong><input name="usedevformat" type="checkbox"<?php 
    echo $DevFmt_Config['usedevformat'] ? " checked" : "";
    ?>
/> <label for="usedevformat">Use DevFormatter System</label></strong><br />
      Checkout the diference:<br />
      <table width="100%"><tbody><tr>
      <td valign="top">
      <?php 
    $ExampleCode = "Here is a sample of my <strong>PHP code</strong>:\r\n<code lang=\"php\">  function GimmeGimmeAText(){\r\n    return \"Take here, a text.\";\r\n  }\r\n  echo GimmeGimmeAText();</code>\r\nCan you take it?\r\n";
    ?>
      <strong>Page/Post content:</strong>
      <pre style="background:#fff;padding:4px;border:1px solid #ccc"><?php 
    echo htmlentities($ExampleCode);
    ?>
</pre>
      </td>
      </tr><tr>
      <td valign="top">
      <strong>DevFormatter display:</strong>
      <div style="background:#fff;padding:4px;border:1px solid #ccc" lang="PHP"><?php 
    $DevFmt_ParsedCode = devfmt_ContentGrabCode($ExampleCode);
    $ContentCheck = devfmt_ContentCheckCode($DevFmt_ParsedCode[0], true, null);
    echo $ContentCheck[1];
    ?>
</div>
      <script language="JavaScript"><!--
        if(typeof(jQuery) != "undefined"){
          jQuery(function($){ devfmt_createTools('devcode'); })
        }else
          alert("jQuery problem.");
      //--></script>
      </td>
      </tr><tr>
      <td valign="top">
      <strong>WordPress display:</strong>
      <div style="background:#fff;padding:4px;border:1px solid #ccc;" lang="PHP"><?php 
    $DevFmt_ParsedCode = devfmt_ContentGrabCode($ExampleCode);
    $ContentCheck = devfmt_ContentCheckCode($DevFmt_ParsedCode[0], true, null);
    if ($ContentCheck[0]) {
        echo wpautop(wptexturize($ContentCheck[1]));
    }
    ?>
</div>
      </td>
      </tr></tbody></table>
      </td>
      </tr>

      <tr valign="top">
      <td scope="row"><strong><input name="displaylinenumbers" type="checkbox"<?php 
    echo $DevFmt_Config['displaylinenumbers'] ? " checked" : "";
    ?>
/> <label for="displaylinenumbers">Display Line Numbers</label></strong><br />
      This option can be overwrited by forcing line display selecting "<strong>Display Line numbers?</strong>" on the page/post Editor.
      </td>
      </tr>

      <tr valign="top">
      <td scope="row"><strong><label for="copyclipboartext">Copy to Clipboard Text</label></strong><br />
      <input name="copyclipboartext" type="text" value="<?php 
    echo $DevFmt_Config['copyclipboartext'];
    ?>
" size="80" />
      </td>
      </tr>

      <tr valign="top">
      <td scope="row"><strong><input name="showtools" type="checkbox"<?php 
    echo $DevFmt_Config['showtools'] ? " checked" : "";
    ?>
/> <label for="showtools">Show toolbar before code</label></strong><br />
      This option will create a toolbar with copy code and plain display buttons.
      </td>
      </tr>

      <tr valign="top">
      <td scope="row"><strong><label for="copyclipboartext">Custom CSS</label></strong><br />
      <textarea name="devfmtcss" rows="6" cols="60"><?php 
    echo $DevFmt_Config['devfmtcss'];
    ?>
</textarea>
      <br /><input type="button" value="Default CSS" onclick="devfmt_cssdefault()">&nbsp;-&nbsp;<input type="button" value="Blue Theme CSS" onclick="devfmt_cssdefaultblue()">&nbsp;-&nbsp;<input type="button" value="Summer Theme CSS" onclick="devfmt_cssdefaultsummer()">
      <br />If you have recently updated DevFormatter click <strong>"Default CSS" or "Blue Theme CSS"</strong> to get new improvements on CSS layout configurations.
      <script language="JavaScript"><!--
        devfmt_cssdefault = function(){ document.forms[0].devfmtcss.value = "<?php 
    echo str_replace("\n", "\\r\\n\" + \r\n \"", devfmt_DefaultPublicCSS());
    ?>
"; }
        devfmt_cssdefaultblue = function(){ document.forms[0].devfmtcss.value = "<?php 
    echo str_replace("\n", "\\r\\n\" + \r\n \"", devfmt_DefaultPublicCSSBlue());
    ?>
"; }
        devfmt_cssdefaultsummer = function(){ document.forms[0].devfmtcss.value = "<?php 
    echo str_replace("\n", "\\r\\n\" + \r\n \"", devfmt_DefaultPublicCSSSummer());
    ?>
"; }
      //--></script>
      </td>
      </tr>

      <tr valign="top">
      <td scope="row"><strong><input name="hookrss2" type="checkbox"<?php 
    echo $DevFmt_Config['hookrss2'] ? " checked" : "";
    ?>
/> <label for="hookrss2">Format code for with RSS 2.0</label></strong><br />
      This option will format blocks of code on RSS 2.0 output (Direct RSS2.0 entry only with IE7+).
      </td>
      </tr>

      <tr valign="top">
      <td scope="row"><strong><input name="parsepre" type="checkbox"<?php 
    echo $DevFmt_Config['parsepre'] ? " checked" : "";
    ?>
/> <label for="parsepre">Parse PRE Tags with language attribute as code block</label></strong><br />
      Format PRE Tag with language attribute as blocks of code (Compatibility with some Writer applications as Live Writer).
      </td>
      </tr>

      <tr valign="top">
      <td scope="row"><strong><input name="linkjquery" type="checkbox"<?php 
    echo $DevFmt_Config['linkjquery'] ? " checked" : "";
    ?>
/> <label for="linkjquery">Create a link for jQuery</label></strong><br />
      You need to enable this option if you don't already use jQuery on your blog.
      <br /><small><em>Credits for jQuery: <a href="http://jquery.com/">http://jquery.com/</a></em></small>
      </td>
      </tr>

      <tr valign="top">
      <td scope="row"><strong><input name="useajaxparse" type="checkbox"<?php 
    echo $DevFmt_Config['useajaxparse'] ? " checked" : "";
    ?>
/> <label for="useajaxparse">Use AJAX DevFormatter System</label></strong><br />
      You need to enable this option to format the code with the parse ajax system, active it when your WP become slow with the current settings.<br />
      <em>(Is really recommended to use a Cache Plugin to get a better performance)</em>
      </td>
      </tr>

      </tbody>
      </table>
    </td>
    </tr>

    <tr valign="top">
    <th scope="row" align="right"><br />GeSHI:</th>
    <td>
      <table class="form-table">
      <tbody>
      <tr valign="top">
      <td scope="row"><strong><label for="geshilangpath">GeSHI Languages Path</label></strong><br />
      <input name="geshilangpath" type="text" value="<?php 
    echo $DevFmt_Config['geshilangpath'];
    ?>
" size="80" />
      <br />Your default path = <?php 
    echo DEVFMT_GESHIPATH;
    ?>
      <br /><span style="color:red">If the directory permission block php to write files, you'll have to upload files to the site ftp yourself (Get the <input type="button" onclick="javascript:window.open('http://svn.wp-plugins.org/devformatter/branches/langs/langs.zip')" value="full language pack here"/> if you want)</span>.
      </td>
      </tr>
      <tr valign="top">
      <td scope="row"><strong><input name="geshiuselink" type="checkbox"<?php 
    echo $DevFmt_Config['geshiuselink'] ? " checked" : "";
    ?>
/> <label for="geshiuselink">Display Links on reserved words</label></strong><br />
      Create a link on a reserved work of the language to a website helper.
      </td>
      </tr>
      <tr valign="top">
      <td scope="row"><strong><label for="geshiuselink">Downloaded Languages</label></strong><br />
      You have downloaded <strong><?php 
    echo Count($DevFmt_SuppLangs);
    ?>
</strong> of <?php 
    echo Count(devfmt_DevFmtAvaliableLangs());
    ?>
 supported languages.
      <div style="background:#fff;border:1px solid #ccc;height:200px;overflow:auto">
<?php 
    $FavLangs = array();
    foreach ($DevFmt_SuppLangs as $Lang) {
        if ($Lang['fav']) {
            $FavLangs[] = $Lang['langname'];
        }
        echo "<li><strong>&middot;" . $Lang['langname'] . "</strong><br /><dd>\r\n        " . DEVFMT_GESHIPATH . DIRECTORY_SEPARATOR . $Lang['langfile'] . "</dd></li>";
    }
    ?>
      </div>
      <strong>Favorite language(s):</strong>
      '<?php 
    echo implode("', '", $FavLangs);
    ?>
'
      <br /><small><em>Credits for GeSHi: <a href="http://qbnz.com/highlighter/">http://qbnz.com/highlighter/</a></em></small>
      </td>
      </tr>
      </tbody>
      </table>
    </td>
    </tr>

    </tbody>
    </table>
    </fieldset>
    <p class="submit"><input type="submit" name="UpdateConfig" class="button-primary" value="Save Changes" /></p>
    </form>
  </div>
<?php 
}