Ver Mensaje Individual
  #2 (permalink)  
Antiguo 22/02/2010, 20:02
Solounaduda
 
Fecha de Ingreso: julio-2009
Mensajes: 15
Antigüedad: 14 años, 9 meses
Puntos: 0
Respuesta: Insertar un Simple PHP Blog dentro de una web

themes.php (parte 1)
Código PHP:
<?php
  
// --------------------------
  // Simple PHP Blog Theme File
  // --------------------------
  //
  // Name: Default/Classic Theme
  // Author: Alexander Palmo
  // Version: 0.5.0
  //
  // Description:
  // This the is default theme for Simple PHP Blog. You can use
  // this as a template for your own themes.
  //
  // All graphic will be relative to the base-url (i.e. the folder
  // where index.php is located.)

  
theme_init();

  
// ---------------
  // Theme Variables
  // ---------------
  
function theme_init () {
    global 
$theme_vars;

    
$theme_vars = array();

    
// Optional:
    // "content_width" and "menu_width" area used internally
    // within the theme only. (optional but recommended.)
    
$theme_vars'content_width' ] = 550;
    
$theme_vars'menu_width' ] = 200;

    
// Required:
    // "popup_window" "width" and "height" are used to determine
    // the size of window to open for the comment view.
    
$theme_vars'popup_window' ][ 'width' ] = $theme_vars'content_width' ] + 50;
    
$theme_vars'popup_window' ][ 'height' ] = 600;

    
// Optional:
    // "popup_window" "content_width" is only used internally.
    
$theme_vars'popup_window' ][ 'content_width' ] = $theme_vars'content_width' ];

    
// Required:
    // Determines the maximum with of images within a page.
    // Make sure this value is less then "content_width" or you
    // might have wrapping problems.
    
$theme_vars'max_image_width' ] = $theme_vars'content_width' ] - 38;

    
// ------------
    // CUSTOMIZATION
    // ------------
    // New 0.3.8
    
$theme_vars'menu_align' ] = 'right'// Valid values are 'left' or 'right'
  
}

  
// Function:
  // theme_blogentry( $entry_array )
  //
  // Theme for Blog Entries
  // ----------------------
  // All data is stored the $entry_array associative array and
  // passed to the function. Keep in mind that multiple languages
  // are used. So, try not to hard-code 'english' strings. If
  // you are creating graphics for buttons, try to use icons
  // instead of words.
  //
  // (Please note, the "\n" at the end of the echo() command adds
  // a return charater in the HTML source. This is standard PHP
  // behavior. Note the '\n' will not work for this. It has to be
  // surrounded by double-quotes.)
  //
  // The array could contains the following keys:
  // $entry_array[ 'subject' ]          = String: Subject line
  // $entry_array[ 'date' ]             = String: Date posted in the appropriate language and format.
  // $entry_array[ 'entry' ]            = String: The body of the blog entry
  // $entry_array[ 'logged_in' ]       = Boolean: True if user is logged in (used to determine whether to show 'edit' and 'delete' buttons)
  // $entry_array[ 'edit' ][ 'url' ]      = String: URL
  // $entry_array[ 'edit' ][ 'name' ]     = String: The word 'edit' in the appropriate language.
  // $entry_array[ 'delete' ][ 'url' ]    = String: URL
  // $entry_array[ 'delete' ][ 'name' ]   = String: The word 'delete' in the appropriate language.
  // $entry_array[ 'comment' ][ 'url' ]   = String: URL
  // $entry_array[ 'comment' ][ 'name' ]  = String: This will be 'add comment', '1 comment', or '2 comments' in the appropriate language.
  // $entry_array[ 'comment' ][ 'count' ] = String: The number of 'views' in the appropriate language.
  // $entry_array[ 'count' ]            = Integer: Index of current entry (i.e. use this if you want to add a line after every entry except the last one...)
  // $entry_array[ 'maxcount' ]         = Integer: Total number of entries
  
function theme_blogentry $entry_array$mode='entry' ) { // New 0.4.8
    
global $blog_config$user_colors;

    
$blog_content "\n";

    
// TRACKBACKS (RDF)
    
if ( $blog_config'blog_trackback_enabled' ] ) {
      
$blog_content  .= '<!--' "\n";
      
$blog_content  .= '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"' "\n";
      
$blog_content  .= '         xmlns:dc="http://purl.org/dc/elements/1.1/"' "\n";
      
$blog_content  .= '         xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">' "\n";
      
$blog_content  .= '<rdf:Description' "\n";
      
$blog_content  .= '    rdf:about="' $entry_array'permalink' ][ 'url' ] . '"' "\n";
      
$blog_content  .= '    dc:identifier="' $entry_array'permalink' ][ 'url' ] . '"' "\n";
      
$blog_content  .= '    dc:title="' $entry_array'subject' ] . '"' "\n";
      
$blog_content  .= '    trackback:ping="' $entry_array'trackback' ][ 'ping_url' ] . '" />' "\n";
      
$blog_content  .= '</rdf:RDF>' "\n";
      
$blog_content  .= '-->' "\n";
    }

    
$blog_content .= '<div class="blog_subject">';
    if ( 
$entry_array'avatarurl' ] != '' ) {
      
$blog_content .= '<img src="' $entry_array'avatarurl'] . '" alt="" border="0" align="left" />';  }

    
// SUBJECT
    
$blog_content  .= $entry_array'subject' ]  . '<a name="' $entry_array'id' ] . '">&nbsp;</a></div>' "\n";


    
// DATE
    
if ( $mode != 'static' ) { // New 0.4.8
      
$blog_content  .= "<div class=\"blog_byline\">" $entry_array'date' ];

      
// CATEGORIES
      
if ( array_key_exists"categories"$entry_array ) ) {
        
$blog_content  .= " - ";
        for ( 
$i 0$i count$entry_array'categories' ] ); $i++ ) {
          
$blog_content .= '<a href="index.php?category=' $entry_array'categories_id' ][$i] . '">' $entry_array'categories' ][$i] . '</a>';
          if ( 
$i count$entry_array'categories' ] ) - ) {
            
$blog_content .= ', ';
          }
        }
      }

      
// IP ADDRESS
      // New 0.4.8
      
if ( isset( $entry_array'logged_in' ] ) && $entry_array'logged_in' ] == true ) {
        if ( 
array_key_exists'ip-address'$entry_array ) && $mode == 'comment' ) {
          
$blog_content  .= ' <span class="blog_ip_address">&lt;&nbsp;' $entry_array'ip-address' ] . '&nbsp;&gt;</span>' "\n";
        }
      }

      if ( isset( 
$entry_array'createdby' ][ 'text' ] )) {
          
$blog_content $blog_content '<br />' $entry_array'createdby' ][ 'text'];
      }

      
$blog_content  .= "</div>\n\t\t";
    }

    
// EDIT/DELETE BUTTONS
    
if ( isset( $entry_array'logged_in' ] ) && $entry_array'logged_in' ] == true ) {
      if ( isset( 
$entry_array'edit' ][ 'url' ] ) ) {
        
$blog_content  .= '<a href="' $entry_array'edit' ][ 'url' ] . '">[ ' $entry_array'edit' ][ 'name' ] . ' ]</a>' "\n";
      }
      if ( isset( 
$entry_array'delete' ][ 'url' ] ) ) {
        
$blog_content  .= '<a href="' $entry_array'delete' ][ 'url' ] . '">[ ' $entry_array'delete' ][ 'name' ] . ' ]</a>' "\n";
      }

      if ( isset( 
$entry_array'ban' ][ 'url' ] ) ) {
        
$blog_content  .= '<a href="' $entry_array'ban' ][ 'url' ] . '">[ ' $entry_array'ban' ][ 'name' ] . ' ]</a><br /><br />' "\n";
      }
    }

    
// BLOG ENTRY
    
$blog_content  .= $entry_array'entry' ] . "\n";

    
// COMMENT ADD
    
if ( isset( $entry_array'comment' ][ 'url' ] ) ) {
      
// Show 'add comment' button if set...
      
$blog_content  .= '<br /><a href="' $entry_array'comment' ][ 'url' ] . '">[ ' $entry_array'comment' ][ 'name' ] . ' ]</a>' "\n";
    }

    
// COMMENT COUNT
    
if ( isset( $entry_array'comment' ][ 'count' ] ) ) {
      
// Show '( x views )' string...
      
$blog_content  .= ' ( ' $entry_array'comment' ][ 'count' ] . ' )' "\n";
    }

    
// TRACKBACK
    
if ( isset( $entry_array'trackback' ][ 'url' ] ) ) {
      
// Show 'trackback' symbol
      
$blog_content  .= '&nbsp;&nbsp;|&nbsp;&nbsp;<a href="' $entry_array'trackback' ][ 'url' ] . '">[ ' $entry_array'trackback' ][ 'name' ] . ' ]</a>' "\n";;
    }

    
// PERMALINK
    
if ( $blog_config['blog_enable_permalink']){// New for 0.4.6
      
if ( isset( $entry_array'permalink' ][ 'url' ] ) ) {
        
// Show 'permalink' symbol
        
$blog_content  .= '&nbsp;&nbsp;|&nbsp;&nbsp;<a href="' $entry_array'permalink' ][ 'url' ] . '">' $entry_array'permalink' ][ 'name' ] . '</a>';
      }
    }

    
// RELATED LINK
    
if ( isset( $entry_array['relatedlink']['url'] ) ) {
      
// Show 'relatedlink' symbol - New to 0.4.6
      
$blog_content  .= '&nbsp;&nbsp;|&nbsp;&nbsp;<a href="' $entry_array['relatedlink']['url'] . '">' $entry_array['relatedlink']['name'] . '</a>';
    }

    
// RATING
    
if ( isset( $entry_array'stars' ] ) ) {
      
// Show 'permalink' symbol
      
$blog_content  .= '&nbsp;&nbsp;|&nbsp;&nbsp;' $entry_array'stars' ];
    }

    
// END
    
$blog_content  .= '<hr />' "\n";

    return 
$blog_content;
  }