b2evolution

Multilingual multiuser multiblog engine

b2evolution Technical Documentation (0.9.x) [ class tree: admin ] [ index: admin ] [ all elements ]

Source for file b2template.php

Documentation is available at b2template.php

  1. <?php
  2. /**
  3.  * Custom skin template editing
  4.  *
  5.  * b2evolution - {@link http://b2evolution.net/}
  6.  * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
  7.  * @copyright (c)2003-2005 by Francois PLANQUE - {@link http://fplanque.net/}
  8.  *
  9.  * @package admin
  10.  * @author This file built upon code from original b2 - http://cafelog.com/
  11.  */
  12.  
  13. /**
  14.  * Includes:
  15.  */
  16. require_once(dirname(__FILE__)'/_header.php');
  17. $admin_tab 'templates';
  18. $admin_pagetitle T_('Custom skin template editing');
  19.  
  20. // Check permission:
  21. $current_User->check_perm'templates'''true );
  22.  
  23. param'action''string' );
  24. param'error''string' );
  25. param'file''string' );
  26. param'a''string' );
  27.  
  28.  
  29. switch($action)
  30. {
  31.  
  32. case "update":
  33.     // Determine the edit folder:
  34.     $edit_folder get_path('skins')'/custom';
  35.  
  36.     param'newcontent''html' );
  37.     $f fopen$edit_folder'/'$file"w+" );
  38.     fwrite($f,$newcontent);
  39.     fclose($f);
  40.  
  41.     header("Location: b2template.php?file=$file&a=te");
  42.     exit();
  43.  
  44.     break;
  45.  
  46. default:
  47.     require(dirname(__FILE__)'/_menutop.php');
  48.     require(dirname(__FILE__)'/_menutop_end.php');
  49.  
  50.     // Determine the edit folder:
  51.     $edit_folder get_path('skins')'/custom';
  52.  
  53.     $file trim($file);
  54.     if!empty($file))
  55.     {
  56.         echo '<div class="panelblock">';
  57.  
  58.         echo T_('Listing:')' <strong>'$edit_folder'/'$file'</strong>';
  59.  
  60.         ifereg'([^-A-Za-z0-9._]|\.\.)'$file ) )
  61.         {
  62.             echo '<p>'T_('Invalid filename!')'</p>';
  63.         }
  64.         elseif!is_file($edit_folder'/'$file) )
  65.         {
  66.                 echo '<p>'T_('Oops, no such file !')'</p>';
  67.         }
  68.         else
  69.         {
  70.  
  71.             $f fopen$edit_folder'/'$file'r');
  72.             $content fread($f,filesize($edit_folder'/'$file));
  73.             //    $content = template_simplify($content);
  74.             $content htmlspecialchars($content);
  75.             //    $content = str_replace("</textarea","&lt;/textarea",$content);
  76.  
  77.             if ($a == 'te')    echo '<em> [ 'T_('File edited!')' ]</em>';
  78.  
  79.             if (!$error{
  80.             ?>
  81.             <p><?php echo T_('Be careful what you do, editing this file could break your template! Do not edit what\'s between <code>&lt;?php</code> and <code>?&gt;</code> if you don\'t know what you\'re doing!'?></p>
  82.             <form name="template" action="b2template.php" method="post">
  83.                 <fieldset class="input"><img src="img/blank.gif" alt="" width="1" height="1" /><textarea cols="80" rows="20" class="large" name="newcontent" tabindex="1"><?php echo $content ?></textarea></fieldset>
  84.                 <input type="hidden" name="action" value="update" />
  85.                 <input type="hidden" name="file" value="<?php echo $file ?>" />
  86.                 <br />
  87.                 <?php
  88.                 ifis_writable($edit_folder'/'$file) )
  89.                 {
  90.                     echo '<input type="submit" name="submit" class="SaveButton" value="'T_('&nbsp; Save ! &nbsp;')'" tabindex="2" />';
  91.                 }
  92.                 else
  93.                 {
  94.                     echo '<input type="button" name="oops" class="search" value="'T_('(you cannot update that file/template: must make it writable, e.g. CHMOD 766)')'" tabindex="2" />';
  95.                 }
  96.                 ?>
  97.             </form>
  98.             <?php
  99.             }
  100.         }
  101.         echo "</div>\n";
  102.     }
  103. ?>
  104.  
  105.     <div class="panelblock">
  106.     <p><?php echo T_('This screen allows you to edit the <strong>custom skin</strong> (located under /skins/custom). '?></p>
  107.     <p><?php echo T_('You can edit any of the following files (provided it\'s writable by the server, e.g. CHMOD 766)'?>:</p>
  108. <?php
  109.     // Determine the edit folder:
  110.     ifempty($edit_folder) ) $edit_folder get_path('skins')'/custom';
  111.     //lists all files in edit directory
  112.     if!is_dir($edit_folder) )
  113.     {
  114.         echo '<div class="panelinfo"><p>'.sprintfT_('Directory %s not found.')$edit_folder ).'</p></div>';
  115.     }
  116.     else
  117.     // $edit_folder exists
  118.         ?><ul><?php
  119.         $this_dir dir$edit_folder );
  120.         while ($this_file $this_dir->read())
  121.         {
  122.             ifis_file($edit_folder'/'$this_file) )
  123.             {
  124.                 ?>
  125.                 <li><a href="b2template.php?file=<?php echo $this_file?>"><?php echo $this_file?></a>
  126.                 <?php
  127.                 switch$this_file )
  128.                 {
  129.                     case '_archives.php':
  130.                         echo '- 'T_('This is the template that displays the links to the archives for a blog');
  131.                         break;
  132.                     case '_categories.php':
  133.                         echo '- 'T_('This is the template that displays the (recursive) list of (sub)categories');
  134.                         break;
  135.                     case '_feedback.php':
  136.                         echo '- 'T_('This is the template that displays the feedback for a post');
  137.                         break;
  138.                     case '_lastcomments.php':
  139.                         echo '- 'T_('This is the template that displays the last comments for a blog');
  140.                         break;
  141.                     case '_main.php':
  142.                         echo '- 'T_('This is the main template. It displays the blog.');
  143.                         break;
  144.                     case 'comment_popup.php':
  145.                         echo '- 'T_('This is the page displayed in the comment popup');
  146.                         break;
  147.                     case 'pingback_popup.php':
  148.                         echo '- 'T_('This is the page displayed in the pingback popup');
  149.                         break;
  150.                     case 'trackback_popup.php':
  151.                         echo '- 'T_('This is the page displayed in the trackback popup');
  152.                         break;
  153.                 }
  154.             ?>
  155.             </li>
  156.         <?php }
  157.         }
  158.         ?></ul><?php
  159.     }
  160. ?>
  161.  
  162. <p>    <?php echo T_('Note: of course, you can also edit the files/templates in your text editor and upload them. This online editor is only meant to be used when you don\'t have access to a text editor...'?>
  163. </p>
  164.  
  165.     </div>
  166.     <?php
  167. break;
  168. }
  169.  
  170. /* </Template> */
  171. requiredirname(__FILE__)'/_footer.php' );
  172.  ?>

Documentation generated on Tue, 20 May 2008 01:51:27 +0200 by phpDocumentor 1.4.2