summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorPascal Chevrel <pascal@chevrel.org>2012-02-28 18:14:19 +0100
committerPascal Chevrel <pascal@chevrel.org>2012-02-28 18:14:19 +0100
commit93e7b8c890535549793f8206a584cbdf0df91950 (patch)
tree43ad73a8c9487bda19d85d2ecabf653084b6c285 /app
parent1e217f64da4aa6e4c5ff770ff08bb09ca4da35c3 (diff)
downloadplanet-93e7b8c890535549793f8206a584cbdf0df91950.tar
planet-93e7b8c890535549793f8206a584cbdf0df91950.tar.gz
planet-93e7b8c890535549793f8206a584cbdf0df91950.tar.bz2
planet-93e7b8c890535549793f8206a584cbdf0df91950.tar.xz
planet-93e7b8c890535549793f8206a584cbdf0df91950.zip
update the OpmlManager class syntax to be more PHP5 compliant and make the load() method static so as to avoid a warning in administration.php in strict mode
Diffstat (limited to 'app')
-rw-r--r--app/lib/lib.opml.php130
1 files changed, 65 insertions, 65 deletions
diff --git a/app/lib/lib.opml.php b/app/lib/lib.opml.php
index 8670f5e..21890d2 100644
--- a/app/lib/lib.opml.php
+++ b/app/lib/lib.opml.php
@@ -1,90 +1,91 @@
-<?php
-class opml
-{
+<?php
+class opml
+{
var $_xml = null;
var $_currentTag = '';
- var $title = '';
- var $entries = array();
- var $map =
- array(
- 'URL' => 'website',
- 'HTMLURL' => 'website',
- 'TEXT' => 'name',
- 'TITLE' => 'name',
- 'XMLURL' => 'feed',
- 'DESCRIPTION' => 'description'
- );
-
-
- function parse($data)
- {
- $this->_xml = xml_parser_create('UTF-8');
+ var $title = '';
+ var $entries = array();
+ var $map =
+ array(
+ 'URL' => 'website',
+ 'HTMLURL' => 'website',
+ 'TEXT' => 'name',
+ 'TITLE' => 'name',
+ 'XMLURL' => 'feed',
+ 'DESCRIPTION' => 'description'
+ );
+
+
+ function parse($data)
+ {
+ $this->_xml = xml_parser_create('UTF-8');
//xml_parser_set_option($this->_xml, XML_OPTION_CASE_FOLDING, false);
- //xml_parser_set_option($this->_xml, XML_OPTION_SKIP_WHITE, true);
- xml_set_object($this->_xml, $this);
+ //xml_parser_set_option($this->_xml, XML_OPTION_SKIP_WHITE, true);
+ xml_set_object($this->_xml, $this);
xml_set_element_handler($this->_xml,'_openTag','_closeTag');
- xml_set_character_data_handler ($this->_xml, '_cData');
-
- xml_parse($this->_xml,$data);
- xml_parser_free($this->_xml);
- return $this->entries;
- }
-
-
- function _openTag($p,$tag,$attrs)
+ xml_set_character_data_handler ($this->_xml, '_cData');
+
+ xml_parse($this->_xml,$data);
+ xml_parser_free($this->_xml);
+ return $this->entries;
+ }
+
+
+ function _openTag($p,$tag,$attrs)
{
$this->_currentTag = $tag;
-
- if ($tag == 'OUTLINE')
- {
- $i = count($this->entries);
- foreach (array_keys($this->map) as $key)
- {
- if (isset($attrs[$key])) {
- $this->entries[$i][$this->map[$key]] = $attrs[$key];
- }
- }
- }
+
+ if ($tag == 'OUTLINE')
+ {
+ $i = count($this->entries);
+ foreach (array_keys($this->map) as $key)
+ {
+ if (isset($attrs[$key])) {
+ $this->entries[$i][$this->map[$key]] = $attrs[$key];
+ }
+ }
+ }
}
-
+
function _closeTag($p, $tag){
$this->_currentTag = '';
}
-
+
function _cData($p, $cdata){
if ($this->_currentTag == 'TITLE'){
$this->title = $cdata;
}
}
-
+
function getTitle(){
return $this->title;
}
-
+
function getPeople(){
return $this->entries;
- }
-}
-
-class OpmlManager {
- function load($file) {
- if (@file_exists($file)) {
+ }
+}
+
+class OpmlManager
+{
+ public function load($file) {
+ if (@file_exists($file)) {
$opml = new opml();
-
+
//Remove BOM if needed
$BOM = '/^/';
$fileContent = file_get_contents($file);
$fileContent = preg_replace($BOM, '', $fileContent, 1);
-
+
//Parse
- $opml->parse($fileContent);
-
- return $opml;
- }
+ $opml->parse($fileContent);
+
+ return $opml;
+ }
}
-
- function save($opml, $file){
+
+ public function save($opml, $file){
$out = '<?xml version="1.0"?>'."\n";
$out.= '<opml version="1.1">'."\n";
$out.= '<head>'."\n";
@@ -98,12 +99,11 @@ class OpmlManager {
}
$out.= '</body>'."\n";
$out.= '</opml>';
-
+
file_put_contents($file, $out);
}
-
- function backup($file){
+
+ public function backup($file){
copy($file, $file.'.bak');
- }
-}
-?>
+ }
+}