'
* echo "\n\n";
-*
+*
* // set innerHTML
* $elem->innerHTML = 'FiveFilters.org';
* echo $elem->innerHTML; // prints 'FiveFilters.org'
* echo "\n\n";
-*
+*
* // print document (with our changes)
* echo $doc->saveXML();
* @endcode
@@ -59,7 +59,7 @@ class JSLikeHTMLElement extends DOMElement
$value = mb_convert_encoding($value, 'HTML-ENTITIES', 'UTF-8');
// Using will generate a warning, but so will bad HTML
// (and by this point, bad HTML is what we've got).
- // We use it (and suppress the warning) because an HTML fragment will
+ // We use it (and suppress the warning) because an HTML fragment will
// be wrapped around tags which we don't really want to keep.
// Note: despite the warning, if loadHTML succeeds it will return true.
$result = @$f->loadHTML(''.$value.'');
@@ -86,7 +86,7 @@ class JSLikeHTMLElement extends DOMElement
* @code
* $string = $div->innerHTML;
* @endcode
- */
+ */
public function __get($name)
{
if ($name == 'innerHTML') {
diff --git a/inc/Readability.php b/inc/3rdparty/Readability.php
similarity index 96%
rename from inc/Readability.php
rename to inc/3rdparty/Readability.php
index d28d28f9..e1e8738b 100644
--- a/inc/Readability.php
+++ b/inc/3rdparty/Readability.php
@@ -1,5 +1,5 @@
'/( (\s| ?)*){1,}/',
'video' => '!//(player\.|www\.)?(youtube|vimeo|viddler)\.com!i',
'skipFootnoteLink' => '/^\s*(\[?[a-z0-9]{1,2}\]?|^|edit|citation needed)\s*$/i'
- );
-
+ );
+
/* constants */
const FLAG_STRIP_UNLIKELYS = 1;
const FLAG_WEIGHT_CLASSES = 2;
const FLAG_CLEAN_CONDITIONALLY = 4;
-
+
/**
* Create instance of Readability
* @param string UTF-8 encoded string
* @param string (optional) URL associated with HTML (used for footnotes)
* @param string which parser to use for turning raw HTML into a DOMDocument (either 'libxml' or 'html5lib')
- */
+ */
function __construct($html, $url=null, $parser='libxml')
{
$this->url = $url;
@@ -135,18 +135,18 @@ class Readability
public function getTitle() {
return $this->articleTitle;
}
-
+
/**
* Get article content element
* @return DOMElement
*/
public function getContent() {
return $this->articleContent;
- }
-
+ }
+
/**
* Runs readability.
- *
+ *
* Workflow:
* 1. Prep the document by removing script tags, css, etc.
* 2. Build readability's DOM tree.
@@ -161,7 +161,7 @@ class Readability
if (!isset($this->dom->documentElement)) return false;
$this->removeScripts($this->dom);
//die($this->getInnerHTML($this->dom->documentElement));
-
+
// Assume successful outcome
$this->success = true;
@@ -176,7 +176,7 @@ class Readability
}
$this->prepDocument();
-
+
//die($this->dom->documentElement->parentNode->nodeType);
//$this->setInnerHTML($this->dom->documentElement, $this->getInnerHTML($this->dom->documentElement));
//die($this->getInnerHTML($this->dom->documentElement));
@@ -191,9 +191,9 @@ class Readability
$this->success = false;
$articleContent = $this->dom->createElement('div');
$articleContent->setAttribute('id', 'readability-content');
- $articleContent->innerHTML = '
Sorry, Readability was unable to parse this page for content.
';
+ $articleContent->innerHTML = '
Sorry, Readability was unable to parse this page for content.
';
}
-
+
$overlay->setAttribute('id', 'readOverlay');
$innerDiv->setAttribute('id', 'readInner');
@@ -201,7 +201,7 @@ class Readability
$innerDiv->appendChild($articleTitle);
$innerDiv->appendChild($articleContent);
$overlay->appendChild($innerDiv);
-
+
/* Clear the old HTML, insert the new content. */
$this->body->innerHTML = '';
$this->body->appendChild($overlay);
@@ -209,21 +209,21 @@ class Readability
$this->body->removeAttribute('style');
$this->postProcessContent($articleContent);
-
+
// Set title and content instance variables
$this->articleTitle = $articleTitle;
$this->articleContent = $articleContent;
-
+
return $this->success;
}
-
+
/**
* Debug
*/
protected function dbg($msg) {
if ($this->debug) echo '* ',$msg, "\n";
}
-
+
/**
* Run any post-process modifications to article content as necessary.
*
@@ -231,11 +231,11 @@ class Readability
* @return void
*/
public function postProcessContent($articleContent) {
- if ($this->convertLinksToFootnotes && !preg_match('/wikipedia\.org/', @$this->url)) {
+ if ($this->convertLinksToFootnotes && !preg_match('/wikipedia\.org/', @$this->url)) {
$this->addFootnotes($articleContent);
}
}
-
+
/**
* Get the article title as an H1.
*
@@ -248,11 +248,11 @@ class Readability
try {
$curTitle = $origTitle = $this->getInnerText($this->dom->getElementsByTagName('title')->item(0));
} catch(Exception $e) {}
-
+
if (preg_match('/ [\|\-] /', $curTitle))
{
$curTitle = preg_replace('/(.*)[\|\-] .*/i', '$1', $origTitle);
-
+
if (count(explode(' ', $curTitle)) < 3) {
$curTitle = preg_replace('/[^\|\-]*[\|\-](.*)/i', '$1', $origTitle);
}
@@ -279,17 +279,17 @@ class Readability
if (count(explode(' ', $curTitle)) <= 4) {
$curTitle = $origTitle;
}
-
+
$articleTitle = $this->dom->createElement('h1');
$articleTitle->innerHTML = $curTitle;
-
+
return $articleTitle;
}
-
+
/**
* Prepare the HTML document for readability to scrape it.
* This includes things like stripping javascript, CSS, and handling terrible markup.
- *
+ *
* @return void
**/
protected function prepDocument() {
@@ -328,13 +328,13 @@ class Readability
$footnotesWrapper = $this->dom->createElement('div');
$footnotesWrapper->setAttribute('id', 'readability-footnotes');
$footnotesWrapper->innerHTML = '
References
';
-
+
$articleFootnotes = $this->dom->createElement('ol');
$articleFootnotes->setAttribute('id', 'readability-footnotes-list');
$footnotesWrapper->appendChild($articleFootnotes);
-
+
$articleLinks = $articleContent->getElementsByTagName('a');
-
+
$linkCount = 0;
for ($i = 0; $i < $articleLinks->length; $i++)
{
@@ -346,11 +346,11 @@ class Readability
if (!$linkDomain && isset($this->url)) $linkDomain = @parse_url($this->url, PHP_URL_HOST);
//linkDomain = footnoteLink.host ? footnoteLink.host : document.location.host,
$linkText = $this->getInnerText($articleLink);
-
+
if ((strpos($articleLink->getAttribute('class'), 'readability-DoNotFootnote') !== false) || preg_match($this->regexps['skipFootnoteLink'], $linkText)) {
continue;
}
-
+
$linkCount++;
/** Add a superscript reference after the article link */
@@ -358,7 +358,7 @@ class Readability
$refLink->innerHTML = '[' . $linkCount . ']';
$refLink->setAttribute('class', 'readability-DoNotFootnote');
$refLink->setAttribute('style', 'color: inherit;');
-
+
//TODO: does this work or should we use DOMNode.isSameNode()?
if ($articleLink->parentNode->lastChild == $articleLink) {
$articleLink->parentNode->appendChild($refLink);
@@ -373,15 +373,15 @@ class Readability
$footnoteLink->innerHTML = ($footnoteLink->getAttribute('title') != '' ? $footnoteLink->getAttribute('title') : $linkText);
$footnoteLink->setAttribute('name', 'readabilityFootnoteLink-' . $linkCount);
-
+
$footnote->appendChild($footnoteLink);
if ($linkDomain) $footnote->innerHTML = $footnote->innerHTML . ' (' . $linkDomain . ')';
-
+
$articleFootnotes->appendChild($footnote);
}
if ($linkCount > 0) {
- $articleContent->appendChild($footnotesWrapper);
+ $articleContent->appendChild($footnotesWrapper);
}
}
@@ -404,7 +404,7 @@ class Readability
//}
}
}
-
+
/**
* Prepare the article node for display. Clean out any inline styles,
* iframes, forms, strip extraneous
tags, etc.
@@ -429,7 +429,7 @@ class Readability
* as a header and not a subheader, so remove it since we already have a header.
***/
if (!$this->lightClean && ($articleContent->getElementsByTagName('h2')->length == 1)) {
- $this->clean($articleContent, 'h2');
+ $this->clean($articleContent, 'h2');
}
$this->clean($articleContent, 'iframe');
@@ -448,7 +448,7 @@ class Readability
$embedCount = $articleParagraphs->item($i)->getElementsByTagName('embed')->length;
$objectCount = $articleParagraphs->item($i)->getElementsByTagName('object')->length;
$iframeCount = $articleParagraphs->item($i)->getElementsByTagName('iframe')->length;
-
+
if ($imgCount === 0 && $embedCount === 0 && $objectCount === 0 && $iframeCount === 0 && $this->getInnerText($articleParagraphs->item($i), false) == '')
{
$articleParagraphs->item($i)->parentNode->removeChild($articleParagraphs->item($i));
@@ -457,13 +457,13 @@ class Readability
try {
$articleContent->innerHTML = preg_replace('/ ]*>\s*
dbg("Cleaning innerHTML of breaks failed. This is an IE strict-block-elements bug. Ignoring.: " . $e);
}
}
-
+
/**
* Initialize a node with the readability object. Also checks the
* className/id for special names to add to its score.
@@ -474,7 +474,7 @@ class Readability
protected function initializeNode($node) {
$readability = $this->dom->createAttribute('readability');
$readability->value = 0; // this is our contentScore
- $node->setAttributeNode($readability);
+ $node->setAttributeNode($readability);
switch (strtoupper($node->tagName)) { // unsure if strtoupper is needed, but using it just in case
case 'DIV':
@@ -486,7 +486,7 @@ class Readability
case 'BLOCKQUOTE':
$readability->value += 3;
break;
-
+
case 'ADDRESS':
case 'OL':
case 'UL':
@@ -510,7 +510,7 @@ class Readability
}
$readability->value += $this->getClassWeight($node);
}
-
+
/***
* grabArticle - Using a variety of metrics (content score, classname, element types), find the content that is
* most likely to be the stuff a user wants to read. Then return it wrapped up in a div.
@@ -548,7 +548,7 @@ class Readability
$node->parentNode->removeChild($node);
$nodeIndex--;
continue;
- }
+ }
}
if ($tagName == 'P' || $tagName == 'TD' || $tagName == 'PRE') {
@@ -589,7 +589,7 @@ class Readability
}
}
}
-
+
/**
* Loop through all paragraphs, and assign a score to them based on how content-y they look.
* Then add their score to their parent node.
@@ -613,7 +613,7 @@ class Readability
}
/* Initialize readability data for the parent. */
- if (!$parentNode->hasAttribute('readability'))
+ if (!$parentNode->hasAttribute('readability'))
{
$this->initializeNode($parentNode);
$candidates[] = $parentNode;
@@ -633,15 +633,15 @@ class Readability
/* Add points for any commas within this paragraph */
$contentScore += count(explode(',', $innerText));
-
+
/* For every 100 characters in this paragraph, add another point. Up to 3 points. */
$contentScore += min(floor(strlen($innerText) / 100), 3);
-
+
/* Add the score to the parent. The grandparent gets half. */
$parentNode->getAttributeNode('readability')->value += $contentScore;
if ($grandParentNode) {
- $grandParentNode->getAttributeNode('readability')->value += $contentScore/2;
+ $grandParentNode->getAttributeNode('readability')->value += $contentScore/2;
}
}
@@ -727,12 +727,12 @@ class Readability
{
$append = true;
}
-
+
if (strtoupper($siblingNode->nodeName) == 'P') {
$linkDensity = $this->getLinkDensity($siblingNode);
$nodeContent = $this->getInnerText($siblingNode);
$nodeLength = strlen($nodeContent);
-
+
if ($nodeLength > 80 && $linkDensity < 0.25)
{
$append = true;
@@ -751,7 +751,7 @@ class Readability
$sibNodeName = strtoupper($siblingNode->nodeName);
if ($sibNodeName != 'DIV' && $sibNodeName != 'P') {
/* We have a node that isn't a common block level element, like a form or td tag. Turn it into a div so it doesn't get filtered out later by accident. */
-
+
$this->dbg('Altering siblingNode of ' . $sibNodeName . ' to div.');
$nodeToAppend = $this->dom->createElement('div');
try {
@@ -770,7 +770,7 @@ class Readability
$s--;
$sl--;
}
-
+
/* To ensure a node does not interfere with readability styles, remove its classnames */
$nodeToAppend->removeAttribute('class');
@@ -796,14 +796,14 @@ class Readability
// in the meantime, we check and create an empty element if it's not there.
if (!isset($this->body->childNodes)) $this->body = $this->dom->createElement('body');
$this->body->innerHTML = $this->bodyCache;
-
+
if ($this->flagIsActive(self::FLAG_STRIP_UNLIKELYS)) {
$this->removeFlag(self::FLAG_STRIP_UNLIKELYS);
return $this->grabArticle($this->body);
}
else if ($this->flagIsActive(self::FLAG_WEIGHT_CLASSES)) {
$this->removeFlag(self::FLAG_WEIGHT_CLASSES);
- return $this->grabArticle($this->body);
+ return $this->grabArticle($this->body);
}
else if ($this->flagIsActive(self::FLAG_CLEAN_CONDITIONALLY)) {
$this->removeFlag(self::FLAG_CLEAN_CONDITIONALLY);
@@ -815,7 +815,7 @@ class Readability
}
return $articleContent;
}
-
+
/**
* Remove script tags from document
*
@@ -829,7 +829,7 @@ class Readability
$scripts->item($i)->parentNode->removeChild($scripts->item($i));
}
}
-
+
/**
* Get the inner text of a node.
* This also strips out any excess whitespace to be found.
@@ -878,11 +878,11 @@ class Readability
$elem->removeAttribute('style');
}
}
-
+
/**
* Get the density of links as a percentage of the content
* This is the amount of text that is inside a link divided by the total text in the node.
- *
+ *
* @param DOMElement $e
* @return number (float)
*/
@@ -900,9 +900,9 @@ class Readability
return 0;
}
}
-
+
/**
- * Get an elements class/id weight. Uses regular expressions to tell if this
+ * Get an elements class/id weight. Uses regular expressions to tell if this
* element looks good or bad.
*
* @param DOMElement $e
@@ -964,7 +964,7 @@ class Readability
public function clean($e, $tag) {
$targetList = $e->getElementsByTagName($tag);
$isEmbed = ($tag == 'iframe' || $tag == 'object' || $tag == 'embed');
-
+
for ($y=$targetList->length-1; $y >= 0; $y--) {
/* Allow youtube and vimeo videos through as people usually want to see those. */
if ($isEmbed) {
@@ -972,7 +972,7 @@ class Readability
for ($i=0, $il=$targetList->item($y)->attributes->length; $i < $il; $i++) {
$attributeValues .= $targetList->item($y)->attributes->item($i)->value . '|'; // DOMAttr? (TODO: test)
}
-
+
/* First, check the elements attributes to see if any of them contain youtube or vimeo */
if (preg_match($this->regexps['video'], $attributeValues)) {
continue;
@@ -986,10 +986,10 @@ class Readability
$targetList->item($y)->parentNode->removeChild($targetList->item($y));
}
}
-
+
/**
* Clean an element of all tags of type "tag" if they look fishy.
- * "Fishy" is an algorithm based on content length, classnames,
+ * "Fishy" is an algorithm based on content length, classnames,
* link density, number of images & embeds, etc.
*
* @param DOMElement $e
@@ -1013,7 +1013,7 @@ class Readability
for ($i=$curTagsLength-1; $i >= 0; $i--) {
$weight = $this->getClassWeight($tagsList->item($i));
$contentScore = ($tagsList->item($i)->hasAttribute('readability')) ? (int)$tagsList->item($i)->getAttribute('readability') : 0;
-
+
$this->dbg('Cleaning Conditionally ' . $tagsList->item($i)->tagName . ' (' . $tagsList->item($i)->getAttribute('class') . ':' . $tagsList->item($i)->getAttribute('id') . ')' . (($tagsList->item($i)->hasAttribute('readability')) ? (' with score ' . $tagsList->item($i)->getAttribute('readability')) : ''));
if ($weight + $contentScore < 0) {
@@ -1034,13 +1034,13 @@ class Readability
$embeds = $tagsList->item($i)->getElementsByTagName('embed');
for ($ei=0, $il=$embeds->length; $ei < $il; $ei++) {
if (preg_match($this->regexps['video'], $embeds->item($ei)->getAttribute('src'))) {
- $embedCount++;
+ $embedCount++;
}
}
$embeds = $tagsList->item($i)->getElementsByTagName('iframe');
for ($ei=0, $il=$embeds->length; $ei < $il; $ei++) {
if (preg_match($this->regexps['video'], $embeds->item($ei)->getAttribute('src'))) {
- $embedCount++;
+ $embedCount++;
}
}
@@ -1058,7 +1058,7 @@ class Readability
$toRemove = true;
} else if ( $input > floor($p/3) ) {
$this->dbg(' too many elements');
- $toRemove = true;
+ $toRemove = true;
} else if ($contentLength < 25 && ($embedCount === 0 && ($img === 0 || $img > 2))) {
$this->dbg(' content length less than 25 chars, 0 embeds and either 0 images or more than 2 images');
$toRemove = true;
@@ -1082,7 +1082,7 @@ class Readability
$toRemove = true;
} else if ( $input > floor($p/3) ) {
$this->dbg(' too many elements');
- $toRemove = true;
+ $toRemove = true;
} else if ($contentLength < 25 && ($img === 0 || $img > 2) ) {
$this->dbg(' content length less than 25 chars and 0 images, or more than 2 images');
$toRemove = true;
@@ -1126,11 +1126,11 @@ class Readability
public function flagIsActive($flag) {
return ($this->flags & $flag) > 0;
}
-
+
public function addFlag($flag) {
$this->flags = $this->flags | $flag;
}
-
+
public function removeFlag($flag) {
$this->flags = $this->flags & ~$flag;
}
diff --git a/inc/Session.class.php b/inc/3rdparty/Session.class.php
similarity index 99%
rename from inc/Session.class.php
rename to inc/3rdparty/Session.class.php
index eff924cc..3162f507 100644
--- a/inc/Session.class.php
+++ b/inc/3rdparty/Session.class.php
@@ -93,7 +93,7 @@ class Session
// Force logout
public static function logout()
{
- unset($_SESSION['uid'],$_SESSION['info'],$_SESSION['expires_on'],$_SESSION['tokens'], $_SESSION['login'], $_SESSION['pass']);
+ unset($_SESSION['uid'],$_SESSION['info'],$_SESSION['expires_on'],$_SESSION['tokens'], $_SESSION['login'], $_SESSION['pass'], $_SESSION['poche_user']);
}
// Make sure user is logged in.
diff --git a/inc/class.messages.php b/inc/3rdparty/class.messages.php
old mode 100644
new mode 100755
similarity index 96%
rename from inc/class.messages.php
rename to inc/3rdparty/class.messages.php
index 6d515bf6..e60bd3a1
--- a/inc/class.messages.php
+++ b/inc/3rdparty/class.messages.php
@@ -1,231 +1,231 @@
-\n%s\n";
- var $msgBefore = '
';
- var $msgAfter = "
\n";
-
-
- /**
- * Constructor
- * @author Mike Everhart
- */
- public function __construct() {
-
- // Generate a unique ID for this user and session
- $this->msgId = md5(uniqid());
-
- // Create the session array if it doesnt already exist
- if( !array_key_exists('flash_messages', $_SESSION) ) $_SESSION['flash_messages'] = array();
-
- }
-
- /**
- * Add a message to the queue
- *
- * @author Mike Everhart
- *
- * @param string $type The type of message to add
- * @param string $message The message
- * @param string $redirect_to (optional) If set, the user will be redirected to this URL
- * @return bool
- *
- */
- public function add($type, $message, $redirect_to=null) {
-
- if( !isset($_SESSION['flash_messages']) ) return false;
-
- if( !isset($type) || !isset($message[0]) ) return false;
-
- // Replace any shorthand codes with their full version
- if( strlen(trim($type)) == 1 ) {
- $type = str_replace( array('h', 'i', 'w', 'e', 's'), array('help', 'info', 'warning', 'error', 'success'), $type );
-
- // Backwards compatibility...
- } elseif( $type == 'information' ) {
- $type = 'info';
- }
-
- // Make sure it's a valid message type
- if( !in_array($type, $this->msgTypes) ) die('"' . strip_tags($type) . '" is not a valid message type!' );
-
- // If the session array doesn't exist, create it
- if( !array_key_exists( $type, $_SESSION['flash_messages'] ) ) $_SESSION['flash_messages'][$type] = array();
-
- $_SESSION['flash_messages'][$type][] = $message;
-
- if( !is_null($redirect_to) ) {
- header("Location: $redirect_to");
- exit();
- }
-
- return true;
-
- }
-
- //-----------------------------------------------------------------------------------------------
- // display()
- // print queued messages to the screen
- //-----------------------------------------------------------------------------------------------
- /**
- * Display the queued messages
- *
- * @author Mike Everhart
- *
- * @param string $type Which messages to display
- * @param bool $print True = print the messages on the screen
- * @return mixed
- *
- */
- public function display($type='all', $print=true) {
- $messages = '';
- $data = '';
-
- if( !isset($_SESSION['flash_messages']) ) return false;
-
- if( $type == 'g' || $type == 'growl' ) {
- $this->displayGrowlMessages();
- return true;
- }
-
- // Print a certain type of message?
- if( in_array($type, $this->msgTypes) ) {
- foreach( $_SESSION['flash_messages'][$type] as $msg ) {
- $messages .= $this->msgBefore . $msg . $this->msgAfter;
- }
-
- $data .= sprintf($this->msgWrapper, $this->msgClass, $type, $messages);
-
- // Clear the viewed messages
- $this->clear($type);
-
- // Print ALL queued messages
- } elseif( $type == 'all' ) {
- foreach( $_SESSION['flash_messages'] as $type => $msgArray ) {
- $messages = '';
- foreach( $msgArray as $msg ) {
- $messages .= $this->msgBefore . $msg . $this->msgAfter;
- }
- $data .= sprintf($this->msgWrapper, $this->msgClass, $type, $messages);
- }
-
- // Clear ALL of the messages
- $this->clear();
-
- // Invalid Message Type?
- } else {
- return false;
- }
-
- // Print everything to the screen or return the data
- if( $print ) {
- echo $data;
- } else {
- return $data;
- }
- }
-
-
- /**
- * Check to see if there are any queued error messages
- *
- * @author Mike Everhart
- *
- * @return bool true = There ARE error messages
- * false = There are NOT any error messages
- *
- */
- public function hasErrors() {
- return empty($_SESSION['flash_messages']['error']) ? false : true;
- }
-
- /**
- * Check to see if there are any ($type) messages queued
- *
- * @author Mike Everhart
- *
- * @param string $type The type of messages to check for
- * @return bool
- *
- */
- public function hasMessages($type=null) {
- if( !is_null($type) ) {
- if( !empty($_SESSION['flash_messages'][$type]) ) return $_SESSION['flash_messages'][$type];
- } else {
- foreach( $this->msgTypes as $type ) {
- if( !empty($_SESSION['flash_messages']) ) return true;
- }
- }
- return false;
- }
-
- /**
- * Clear messages from the session data
- *
- * @author Mike Everhart
- *
- * @param string $type The type of messages to clear
- * @return bool
- *
- */
- public function clear($type='all') {
- if( $type == 'all' ) {
- unset($_SESSION['flash_messages']);
- } else {
- unset($_SESSION['flash_messages'][$type]);
- }
- return true;
- }
-
- public function __toString() { return $this->hasMessages(); }
-
- public function __destruct() {
- //$this->clear();
- }
-
-
-} // end class
+X\n%s\n";
+ var $msgBefore = '
';
+ var $msgAfter = "
\n";
+
+
+ /**
+ * Constructor
+ * @author Mike Everhart
+ */
+ public function __construct() {
+
+ // Generate a unique ID for this user and session
+ $this->msgId = md5(uniqid());
+
+ // Create the session array if it doesnt already exist
+ if( !array_key_exists('flash_messages', $_SESSION) ) $_SESSION['flash_messages'] = array();
+
+ }
+
+ /**
+ * Add a message to the queue
+ *
+ * @author Mike Everhart
+ *
+ * @param string $type The type of message to add
+ * @param string $message The message
+ * @param string $redirect_to (optional) If set, the user will be redirected to this URL
+ * @return bool
+ *
+ */
+ public function add($type, $message, $redirect_to=null) {
+
+ if( !isset($_SESSION['flash_messages']) ) return false;
+
+ if( !isset($type) || !isset($message[0]) ) return false;
+
+ // Replace any shorthand codes with their full version
+ if( strlen(trim($type)) == 1 ) {
+ $type = str_replace( array('h', 'i', 'w', 'e', 's'), array('help', 'info', 'warning', 'error', 'success'), $type );
+
+ // Backwards compatibility...
+ } elseif( $type == 'information' ) {
+ $type = 'info';
+ }
+
+ // Make sure it's a valid message type
+ if( !in_array($type, $this->msgTypes) ) die('"' . strip_tags($type) . '" is not a valid message type!' );
+
+ // If the session array doesn't exist, create it
+ if( !array_key_exists( $type, $_SESSION['flash_messages'] ) ) $_SESSION['flash_messages'][$type] = array();
+
+ $_SESSION['flash_messages'][$type][] = $message;
+
+ if( !is_null($redirect_to) ) {
+ header("Location: $redirect_to");
+ exit();
+ }
+
+ return true;
+
+ }
+
+ //-----------------------------------------------------------------------------------------------
+ // display()
+ // print queued messages to the screen
+ //-----------------------------------------------------------------------------------------------
+ /**
+ * Display the queued messages
+ *
+ * @author Mike Everhart
+ *
+ * @param string $type Which messages to display
+ * @param bool $print True = print the messages on the screen
+ * @return mixed
+ *
+ */
+ public function display($type='all', $print=true) {
+ $messages = '';
+ $data = '';
+
+ if( !isset($_SESSION['flash_messages']) ) return false;
+
+ if( $type == 'g' || $type == 'growl' ) {
+ $this->displayGrowlMessages();
+ return true;
+ }
+
+ // Print a certain type of message?
+ if( in_array($type, $this->msgTypes) ) {
+ foreach( $_SESSION['flash_messages'][$type] as $msg ) {
+ $messages .= $this->msgBefore . $msg . $this->msgAfter;
+ }
+
+ $data .= sprintf($this->msgWrapper, $this->msgClass, $type, $messages);
+
+ // Clear the viewed messages
+ $this->clear($type);
+
+ // Print ALL queued messages
+ } elseif( $type == 'all' ) {
+ foreach( $_SESSION['flash_messages'] as $type => $msgArray ) {
+ $messages = '';
+ foreach( $msgArray as $msg ) {
+ $messages .= $this->msgBefore . $msg . $this->msgAfter;
+ }
+ $data .= sprintf($this->msgWrapper, $this->msgClass, $type, $messages);
+ }
+
+ // Clear ALL of the messages
+ $this->clear();
+
+ // Invalid Message Type?
+ } else {
+ return false;
+ }
+
+ // Print everything to the screen or return the data
+ if( $print ) {
+ echo $data;
+ } else {
+ return $data;
+ }
+ }
+
+
+ /**
+ * Check to see if there are any queued error messages
+ *
+ * @author Mike Everhart
+ *
+ * @return bool true = There ARE error messages
+ * false = There are NOT any error messages
+ *
+ */
+ public function hasErrors() {
+ return empty($_SESSION['flash_messages']['error']) ? false : true;
+ }
+
+ /**
+ * Check to see if there are any ($type) messages queued
+ *
+ * @author Mike Everhart
+ *
+ * @param string $type The type of messages to check for
+ * @return bool
+ *
+ */
+ public function hasMessages($type=null) {
+ if( !is_null($type) ) {
+ if( !empty($_SESSION['flash_messages'][$type]) ) return $_SESSION['flash_messages'][$type];
+ } else {
+ foreach( $this->msgTypes as $type ) {
+ if( !empty($_SESSION['flash_messages']) ) return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Clear messages from the session data
+ *
+ * @author Mike Everhart
+ *
+ * @param string $type The type of messages to clear
+ * @return bool
+ *
+ */
+ public function clear($type='all') {
+ if( $type == 'all' ) {
+ unset($_SESSION['flash_messages']);
+ } else {
+ unset($_SESSION['flash_messages'][$type]);
+ }
+ return true;
+ }
+
+ public function __toString() { return $this->hasMessages(); }
+
+ public function __destruct() {
+ //$this->clear();
+ }
+
+
+} // end class
?>
\ No newline at end of file
diff --git a/inc/3rdparty/paginator.php b/inc/3rdparty/paginator.php
new file mode 100644
index 00000000..306756c0
--- /dev/null
+++ b/inc/3rdparty/paginator.php
@@ -0,0 +1,202 @@
+_instance = $instance;
+ $this->_perPage = $perPage;
+ $this->set_instance();
+ }
+
+ /**
+ * get_start
+ *
+ * creates the starting point for limiting the dataset
+ * @return numeric
+ */
+ private function get_start(){
+ return ($this->_page * $this->_perPage) - $this->_perPage;
+ }
+
+ /**
+ * set_instance
+ *
+ * sets the instance parameter, if numeric value is 0 then set to 1
+ *
+ * @var numeric
+ */
+ private function set_instance(){
+ $this->_page = (int) (!isset($_GET[$this->_instance]) ? 1 : $_GET[$this->_instance]);
+ $this->_page = ($this->_page == 0 ? 1 : $this->_page);
+ }
+
+ /**
+ * set_total
+ *
+ * collect a numberic value and assigns it to the totalRows
+ *
+ * @var numeric
+ */
+ public function set_total($_totalRows){
+ $this->_totalRows = $_totalRows;
+ }
+
+ /**
+ * get_limit
+ *
+ * returns the limit for the data source, calling the get_start method and passing in the number of items perp page
+ *
+ * @return string
+ */
+ public function get_limit(){
+ if (STORAGE == 'postgres') {
+ return "LIMIT ".$this->_perPage." OFFSET ".$this->get_start();
+ } else {
+ return "LIMIT ".$this->get_start().",".$this->_perPage;
+ }
+ }
+
+ /**
+ * page_links
+ *
+ * create the html links for navigating through the dataset
+ *
+ * @var sting $path optionally set the path for the link
+ * @var sting $ext optionally pass in extra parameters to the GET
+ * @return string returns the html menu
+ */
+ public function page_links($path='?',$ext=null)
+ {
+ $adjacents = "2";
+ $prev = $this->_page - 1;
+ $next = $this->_page + 1;
+ $lastpage = ceil($this->_totalRows/$this->_perPage);
+ $lpm1 = $lastpage - 1;
+
+ $pagination = "";
+ if($lastpage > 1)
+ {
+ $pagination .= "
\ No newline at end of file
diff --git a/tpl/_messages.twig b/tpl/_messages.twig
new file mode 100644
index 00000000..679aa098
--- /dev/null
+++ b/tpl/_messages.twig
@@ -0,0 +1 @@
+ {{ messages | raw }}
\ No newline at end of file
diff --git a/tpl/_top.twig b/tpl/_top.twig
new file mode 100644
index 00000000..ae01cc3f
--- /dev/null
+++ b/tpl/_top.twig
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/tpl/config.html b/tpl/config.html
deleted file mode 100644
index 1100d455..00000000
--- a/tpl/config.html
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
Bookmarklet
-
Thanks to the bookmarklet, you will be able to easily add a link to your poche. If you don't know how use a bookmarklet, have a look here.
-
Drag & drop this link to your bookmarks bar and have fun with poche.
\ No newline at end of file
diff --git a/tpl/config.twig b/tpl/config.twig
new file mode 100644
index 00000000..95d5d8cf
--- /dev/null
+++ b/tpl/config.twig
@@ -0,0 +1,57 @@
+{% extends "layout.twig" %}
+
+{% block title %}{% trans "config" %}{% endblock %}
+{% block menu %}
+
{% trans "Thanks to the bookmarklet, you will be able to easily add a link to your poche." %} {% trans "Have a look to this documentation:" %} inthepoche.com.
+
{% trans "Drag & drop this link to your bookmarks bar and have fun with poche." %}
+ {% endfor %}
+ {{ page_links | raw }}
+{% endblock %}
\ No newline at end of file
diff --git a/img/apple-touch-icon-144x144-precomposed.png b/tpl/img/apple-touch-icon-144x144-precomposed.png
similarity index 100%
rename from img/apple-touch-icon-144x144-precomposed.png
rename to tpl/img/apple-touch-icon-144x144-precomposed.png
diff --git a/img/apple-touch-icon-72x72-precomposed.png b/tpl/img/apple-touch-icon-72x72-precomposed.png
similarity index 100%
rename from img/apple-touch-icon-72x72-precomposed.png
rename to tpl/img/apple-touch-icon-72x72-precomposed.png
diff --git a/img/apple-touch-icon.png b/tpl/img/apple-touch-icon.png
similarity index 100%
rename from img/apple-touch-icon.png
rename to tpl/img/apple-touch-icon.png
diff --git a/img/favicon.ico b/tpl/img/favicon.ico
similarity index 100%
rename from img/favicon.ico
rename to tpl/img/favicon.ico
diff --git a/img/light/checkmark-off.png b/tpl/img/light/checkmark-off.png
similarity index 100%
rename from img/light/checkmark-off.png
rename to tpl/img/light/checkmark-off.png
diff --git a/img/light/checkmark-on.png b/tpl/img/light/checkmark-on.png
similarity index 100%
rename from img/light/checkmark-on.png
rename to tpl/img/light/checkmark-on.png
diff --git a/img/down.png b/tpl/img/light/down.png
similarity index 100%
rename from img/down.png
rename to tpl/img/light/down.png
diff --git a/tpl/img/light/envelop.png b/tpl/img/light/envelop.png
new file mode 100755
index 00000000..6be1c886
Binary files /dev/null and b/tpl/img/light/envelop.png differ
diff --git a/tpl/img/light/left.png b/tpl/img/light/left.png
new file mode 100755
index 00000000..a0a53631
Binary files /dev/null and b/tpl/img/light/left.png differ
diff --git a/img/light/remove.png b/tpl/img/light/remove.png
similarity index 100%
rename from img/light/remove.png
rename to tpl/img/light/remove.png
diff --git a/img/light/star-off.png b/tpl/img/light/star-off.png
similarity index 100%
rename from img/light/star-off.png
rename to tpl/img/light/star-off.png
diff --git a/img/light/star-on.png b/tpl/img/light/star-on.png
similarity index 100%
rename from img/light/star-on.png
rename to tpl/img/light/star-on.png
diff --git a/img/up.png b/tpl/img/light/top.png
old mode 100644
new mode 100755
similarity index 100%
rename from img/up.png
rename to tpl/img/light/top.png
diff --git a/tpl/img/light/twitter.png b/tpl/img/light/twitter.png
new file mode 100755
index 00000000..cfcfe419
Binary files /dev/null and b/tpl/img/light/twitter.png differ
diff --git a/tpl/img/logo.png b/tpl/img/logo.png
new file mode 100644
index 00000000..549b8466
Binary files /dev/null and b/tpl/img/logo.png differ
diff --git a/img/messages/close.png b/tpl/img/messages/close.png
old mode 100644
new mode 100755
similarity index 100%
rename from img/messages/close.png
rename to tpl/img/messages/close.png
diff --git a/img/messages/cross.png b/tpl/img/messages/cross.png
old mode 100644
new mode 100755
similarity index 100%
rename from img/messages/cross.png
rename to tpl/img/messages/cross.png
diff --git a/img/messages/help.png b/tpl/img/messages/help.png
old mode 100644
new mode 100755
similarity index 100%
rename from img/messages/help.png
rename to tpl/img/messages/help.png
diff --git a/img/messages/tick.png b/tpl/img/messages/tick.png
old mode 100644
new mode 100755
similarity index 100%
rename from img/messages/tick.png
rename to tpl/img/messages/tick.png
diff --git a/img/messages/warning.png b/tpl/img/messages/warning.png
old mode 100644
new mode 100755
similarity index 100%
rename from img/messages/warning.png
rename to tpl/img/messages/warning.png
diff --git a/tpl/install.html b/tpl/install.html
deleted file mode 100644
index d11a7810..00000000
--- a/tpl/install.html
+++ /dev/null
@@ -1,30 +0,0 @@
-{include="head"}
-
-
-
poche
-
-
-
-
-{include="footer"}
diff --git a/tpl/install.twig b/tpl/install.twig
new file mode 100644
index 00000000..8bcede0d
--- /dev/null
+++ b/tpl/install.twig
@@ -0,0 +1,28 @@
+{% extends "layout.twig" %}
+{% block title %}{% trans "installation" %}{% endblock %}
+{% block content %}
+
+{% endblock %}
\ No newline at end of file
diff --git a/tpl/js.html b/tpl/js.html
deleted file mode 100644
index a02212b0..00000000
--- a/tpl/js.html
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
- {if="$load_all_js == '1'"}
-
-
- {/if}
\ No newline at end of file
diff --git a/tpl/layout.twig b/tpl/layout.twig
new file mode 100644
index 00000000..c4bbe779
--- /dev/null
+++ b/tpl/layout.twig
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+ {% block title %}{% endblock %} - poche
+ {% include '_head.twig' %}
+ {% include '_bookmarklet.twig' %}
+
+
+ {% include '_top.twig' %}
+