Skip to content

Commit

Permalink
fixed #2 and #22
Browse files Browse the repository at this point in the history
  • Loading branch information
remi committed Oct 14, 2009
1 parent 6baa13f commit 71bb931
Show file tree
Hide file tree
Showing 18 changed files with 65 additions and 33 deletions.
1 change: 1 addition & 0 deletions cron/cron.php
@@ -1,6 +1,7 @@
<?php <?php


define( 'PUBWICH_CRON', true ); define( 'PUBWICH_CRON', true );
define( 'PUBWICH', 1 );


require( dirname(__FILE__) . '/../lib/Pubwich.php'); require( dirname(__FILE__) . '/../lib/Pubwich.php');
Pubwich::init(); Pubwich::init();
Expand Down
1 change: 1 addition & 0 deletions index.php
Expand Up @@ -2,6 +2,7 @@


// $Id$ // $Id$


define( 'PUBWICH', 1 );
require( dirname(__FILE__) . '/lib/Pubwich.php' ); require( dirname(__FILE__) . '/lib/Pubwich.php' );
Pubwich::init(); Pubwich::init();
Pubwich::renderTemplate(); Pubwich::renderTemplate();
2 changes: 2 additions & 0 deletions lib/FileFetcher.php
@@ -1,4 +1,6 @@
<?php <?php
defined('PUBWICH') or die('No direct access allowed.');

/** /**
* Récupérateur de contenu provenant de fichiers à distance * Récupérateur de contenu provenant de fichiers à distance
* *
Expand Down
2 changes: 2 additions & 0 deletions lib/Pubwich.php
@@ -1,4 +1,5 @@
<?php <?php
defined('PUBWICH') or die('No direct access allowed.');


define( 'PUBWICH_VERSION', 'trunk' ); define( 'PUBWICH_VERSION', 'trunk' );


Expand Down Expand Up @@ -68,6 +69,7 @@ static public function init() {


// Events logger (and first message) // Events logger (and first message)
require('PubwichLog.php'); require('PubwichLog.php');
PubwichLog::init();
PubwichLog::log( 1, Pubwich::_("Pubwich object initialization") ); PubwichLog::log( 1, Pubwich::_("Pubwich object initialization") );


// Theme // Theme
Expand Down
1 change: 1 addition & 0 deletions lib/PubwichErreur.php
@@ -1,4 +1,5 @@
<?php <?php
defined('PUBWICH') or die('No direct access allowed.');


/** /**
* @classname PubwichErreur * @classname PubwichErreur
Expand Down
32 changes: 22 additions & 10 deletions lib/PubwichLog.php
@@ -1,31 +1,43 @@
<?php <?php
defined('PUBWICH') or die('No direct access allowed.');


/** /**
* @classname PubwichLog * @classname PubwichLog
* @author remi (exomel.com)
* *
* Niveau 1 : Informations générales * Niveau 1 : Informations générales
* Niveau 2 : Informations détaillées * Niveau 2 : Informations détaillées
* Niveau 3 : ??? * Niveau 3 : ???
*/ */
class PubwichLog { class PubwichLog {


static public function log( $level, $msg ) { static private $file;

static public function init() {

if ( PUBWICH_LOGTOFILE === true && PUBWICH_LOGLEVEL > 0 ) {
$log_dir = dirname(__FILE__).'/../logs';
if ( !is_dir( $log_dir ) ) {
mkdir( $log_dir );
}
$log_file = $log_dir . '/pubwich-'.date('Y-m-d').'.log';
self::$file = fopen($log_file, 'a+');
// what will happen if several sessions are started simultaneously?
//self::log( 0, '----[ Log for Pubwich session ('.date('Y-m-d h:i:s').') ]-----------------------------', true );
}

}

static public function log( $level, $msg, $nodate=false ) {


if ( $level <= PUBWICH_LOGLEVEL ) { if ( $level <= PUBWICH_LOGLEVEL ) {
if ( !PUBWICH_LOGTOFILE ) { if ( !PUBWICH_LOGTOFILE ) {
echo $msg . "<br />\n"; echo $msg . "<br />\n";
} else { } else {
/* $stringData = ($nodate === true) ? $msg ."\n" : Date('Y-m-d h:i:s').' '. $msg ."\n";
$log_file = dirname(__FILE__).'/../logs/pubwich-'.date('Y-m-d').'.log'; fwrite(self::$file, $stringData);
$fh = fopen($log_file, 'a');
if ( !$fh ) { return false; }
$stringData = Date('Y m d h:i:s').' '. $msg ."\n";
fwrite($fh, $stringData);
fclose($fh);
*/
} }
} }

} }


} }
Expand Down
1 change: 1 addition & 0 deletions lib/PubwichTemplate.php
@@ -1,4 +1,5 @@
<?php <?php
defined('PUBWICH') or die('No direct access allowed.');


/** /**
* @classname PubwichTemplate * @classname PubwichTemplate
Expand Down
4 changes: 2 additions & 2 deletions lib/Services/Atom.php
@@ -1,4 +1,6 @@
<?php <?php
defined('PUBWICH') or die('No direct access allowed.');

/** /**
* @classname Atom * @classname Atom
* @description Fetch Atom feeds * @description Fetch Atom feeds
Expand All @@ -18,7 +20,6 @@ public function __construct( $config ){
} }


/** /**
* Surcharge de parent::getData()
* @return SimpleXMLElement * @return SimpleXMLElement
*/ */
public function getData() { public function getData() {
Expand All @@ -27,7 +28,6 @@ public function getData() {
} }


/** /**
* Retourne un item formatté selon le gabarit
* @return array * @return array
*/ */
public function populateItemTemplate( &$item ) { public function populateItemTemplate( &$item ) {
Expand Down
2 changes: 2 additions & 0 deletions lib/Services/Delicious.php
@@ -1,4 +1,6 @@
<?php <?php
defined('PUBWICH') or die('No direct access allowed.');

/** /**
* @classname Delicious * @classname Delicious
* @description Fetch Del.icio.us bookmarks * @description Fetch Del.icio.us bookmarks
Expand Down
2 changes: 2 additions & 0 deletions lib/Services/Facebook.php
@@ -1,4 +1,6 @@
<?php <?php
defined('PUBWICH') or die('No direct access allowed.');

/** /**
* @classname Facebook * @classname Facebook
* @description Fetch Facebook statuses * @description Fetch Facebook statuses
Expand Down
2 changes: 2 additions & 0 deletions lib/Services/Flickr.php
@@ -1,4 +1,6 @@
<?php <?php
defined('PUBWICH') or die('No direct access allowed.');

/** /**
* @classname Flickr * @classname Flickr
* @description Retreives photos from Flickr * @description Retreives photos from Flickr
Expand Down
9 changes: 5 additions & 4 deletions lib/Services/Lastfm.php
@@ -1,4 +1,6 @@
<?php <?php
defined('PUBWICH') or die('No direct access allowed.');

/** /**
* @classname LastFM * @classname LastFM
* @description Fetch data from Last.fm * @description Fetch data from Last.fm
Expand Down Expand Up @@ -95,7 +97,7 @@ public function buildCache() {
} }


/** /**
* @param bool $rebuildCache Si vrai, force la reconstruction du cache * @param bool $rebuildCache Force cache rebuild
* @return void * @return void
*/ */
public function buildAlbumCache( $rebuildCache ) { public function buildAlbumCache( $rebuildCache ) {
Expand All @@ -112,7 +114,7 @@ public function buildAlbumCache( $rebuildCache ) {


/** /**
* @param SimpleXMLElement $album * @param SimpleXMLElement $album
* [@param bool $rebuildCache Si vrai, force la reconstruction du cache] * [@param bool $rebuildCache]
* @return void * @return void
*/ */
public function fetchAlbum($album, $rebuildCache=false) { public function fetchAlbum($album, $rebuildCache=false) {
Expand Down Expand Up @@ -174,7 +176,7 @@ public function populateItemTemplate( &$item ) {
} }


/** /**
* @var $albumdata Contient les informations relatives aux albums * @var $albumdata
*/ */
public $albumdata; public $albumdata;


Expand Down Expand Up @@ -206,5 +208,4 @@ public function init() {
return $this; return $this;
} }



} }
6 changes: 2 additions & 4 deletions lib/Services/RSS.php
@@ -1,4 +1,6 @@
<?php <?php
defined('PUBWICH') or die('No direct access allowed.');

/** /**
* @classname RSS * @classname RSS
* @description Fetch RSS feeds * @description Fetch RSS feeds
Expand All @@ -12,15 +14,12 @@ class RSS extends Service {
public function __construct( $config ){ public function __construct( $config ){
$this->setURL( $config['url'] ); $this->setURL( $config['url'] );
$this->total = $config['total']; $this->total = $config['total'];

$this->setItemTemplate('<li><a href="{%link%}">{%title%}</a> {%date%}</li>'."\n"); $this->setItemTemplate('<li><a href="{%link%}">{%title%}</a> {%date%}</li>'."\n");
$this->setURLTemplate( $config['link'] ); $this->setURLTemplate( $config['link'] );

parent::__construct( $config ); parent::__construct( $config );
} }


/** /**
* Surcharge de parent::getData()
* @return SimpleXMLElement * @return SimpleXMLElement
*/ */
public function getData() { public function getData() {
Expand All @@ -29,7 +28,6 @@ public function getData() {
} }


/** /**
* Retourne un item formatté selon le gabarit
* @return array * @return array
*/ */
public function populateItemTemplate( &$item ) { public function populateItemTemplate( &$item ) {
Expand Down
9 changes: 3 additions & 6 deletions lib/Services/Readernaut.php
@@ -1,4 +1,6 @@
<?php <?php
defined('PUBWICH') or die('No direct access allowed.');

/** /**
* @classname Readernaut * @classname Readernaut
* @description Fetch Readernaut books * @description Fetch Readernaut books
Expand Down Expand Up @@ -39,10 +41,8 @@ class ReadernautBooks extends Readernaut {
public function __construct( $config ){ public function __construct( $config ){
parent::setVariables( $config ); parent::setVariables( $config );
$this->setURL( sprintf( 'http://readernaut.com/api/v1/xml/%s/books/?order_by=-created', $config['username'] ) ); $this->setURL( sprintf( 'http://readernaut.com/api/v1/xml/%s/books/?order_by=-created', $config['username'] ) );

$this->setItemTemplate('<li><a class="clearfix" href="{%link%}"><img src="{%image%}" width="{%size%}" alt="{%title%}" /><strong><span>{%title%}</span> {%author%}</strong></a></li>'."\n"); $this->setItemTemplate('<li><a class="clearfix" href="{%link%}"><img src="{%image%}" width="{%size%}" alt="{%title%}" /><strong><span>{%title%}</span> {%author%}</strong></a></li>'."\n");
$this->setURLTemplate('http://www.readernaut.com/'.$config['username'].'/books/'); $this->setURLTemplate('http://www.readernaut.com/'.$config['username'].'/books/');

parent::__construct( $config ); parent::__construct( $config );
} }


Expand All @@ -55,7 +55,6 @@ public function getData() {
} }


/** /**
* Retourne un item formatté selon le gabarit
* @return array * @return array
*/ */
public function populateItemTemplate( &$item ) { public function populateItemTemplate( &$item ) {
Expand Down Expand Up @@ -85,10 +84,8 @@ class ReadernautNotes extends Readernaut {
public function __construct( $config ){ public function __construct( $config ){
parent::setVariables( $config ); parent::setVariables( $config );
$this->setURL( sprintf( 'http://readernaut.com/api/v1/xml/%s/notes/?order_by=-created', $config['username'] ) ); $this->setURL( sprintf( 'http://readernaut.com/api/v1/xml/%s/notes/?order_by=-created', $config['username'] ) );

$this->setItemTemplate('<li><a class="clearfix" href="{%link%}"><img src="{%image%}" width="{%size%}" alt="{%title%}" /><strong><span>{%title%}</span> {%author%}</strong></a>{%body%}</li>'."\n"); $this->setItemTemplate('<li><a class="clearfix" href="{%link%}"><img src="{%image%}" width="{%size%}" alt="{%title%}" /><strong><span>{%title%}</span> {%author%}</strong></a>{%body%}</li>'."\n");
$this->setURLTemplate('http://www.readernaut.com/'.$config['username'].'/notes/'); $this->setURLTemplate('http://www.readernaut.com/'.$config['username'].'/notes/');

parent::__construct( $config ); parent::__construct( $config );
} }


Expand All @@ -101,10 +98,10 @@ public function getData() {
} }


/** /**
* Retourne un item formatté selon le gabarit
* @return array * @return array
*/ */
public function populateItemTemplate( &$item ) { public function populateItemTemplate( &$item ) {
// yep, this is actually book_edtion. Readernaut's creator Nathan Borror has been notified about this type :)
return array( return array(
'id' => $item->reader_book_id, 'id' => $item->reader_book_id,
'link' => $item->book_edtion->permalink, 'link' => $item->book_edtion->permalink,
Expand Down
11 changes: 6 additions & 5 deletions lib/Services/Service.php
@@ -1,4 +1,5 @@
<?php <?php
defined('PUBWICH') or die('No direct access allowed.');


/** /**
* @classname Service * @classname Service
Expand Down Expand Up @@ -128,23 +129,23 @@ public function getVariable() {
} }


/** /**
* @param string $variable Le nom de la variable * @param string $variable
* @return void * @return void
*/ */
public function setVariable( $variable ) { public function setVariable( $variable ) {
$this->variable = $variable; $this->variable = $variable;
} }


/** /**
* @param string $template Le template * @param string $template
* @return void * @return void
*/ */
public function setURLTemplate( $template ) { public function setURLTemplate( $template ) {
$this->urlTemplate = $template; $this->urlTemplate = $template;
} }


/** /**
* @param string $template Le template * @param string $template
* @return void * @return void
*/ */
public function setItemTemplate( $template ) { public function setItemTemplate( $template ) {
Expand All @@ -163,7 +164,7 @@ public function getItemTemplate() {
} }


/** /**
* @param string $template Le template * @param string $template
*/ */
public function setBoxTemplate( $template ) { public function setBoxTemplate( $template ) {
if ( !$this->boxTemplate ) { if ( !$this->boxTemplate ) {
Expand All @@ -181,7 +182,7 @@ public function getBoxTemplate() {
} }


/* /*
* @param Service &$classe La référence de l’instancedu service à afficher * @param Service &$classe
* @return string * @return string
*/ */
public function renderBox( ) { public function renderBox( ) {
Expand Down
10 changes: 8 additions & 2 deletions lib/Services/Text.php
@@ -1,5 +1,13 @@
<?php <?php
defined('PUBWICH') or die('No direct access allowed.');


/**
* @classname Text
* @description Display a simple text block
* @version 1.1 (20090929)
* @author Rémi Prévost (exomel.com)
* @methods None
*/
class Text extends Service { class Text extends Service {


public function __construct( $config ){ public function __construct( $config ){
Expand All @@ -18,15 +26,13 @@ public function __construct( $config ){
} }


/** /**
* Surcharge de parent::getData()
* @return SimpleXMLElement * @return SimpleXMLElement
*/ */
public function getData() { public function getData() {
return array( $this->text ); return array( $this->text );
} }


/** /**
* Retourne un item formatté selon le gabarit
* @return array * @return array
*/ */
public function populateItemTemplate( &$item ) { public function populateItemTemplate( &$item ) {
Expand Down
2 changes: 2 additions & 0 deletions lib/Services/Twitter.php
@@ -1,4 +1,6 @@
<?php <?php
defined('PUBWICH') or die('No direct access allowed.');

/** /**
* @classname Twitter * @classname Twitter
* @description Retrieves statuses from Twitter * @description Retrieves statuses from Twitter
Expand Down
1 change: 1 addition & 0 deletions logs/.htaccess
@@ -0,0 +1 @@
Deny from all

0 comments on commit 71bb931

Please sign in to comment.