-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add commandline subscriptions import, fix feed redirs
- Loading branch information
Showing
6 changed files
with
195 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<? | ||
|
||
class Task_Feeds_Import extends Minion_Task { | ||
|
||
protected $_options = array( | ||
'file' => null, | ||
'user' => null, | ||
); | ||
|
||
public function _execute(array $params) | ||
{ | ||
$xml = file_get_contents($params['file']); | ||
$user = ORM::factory('User', $params['user']); | ||
$feeds = new Feeds(); | ||
$feeds->register_callback(function ($msg) { Minion_CLI::write($msg);}); | ||
|
||
if ( ! $user->loaded()) | ||
throw new Exception('User does not exist'); | ||
|
||
$dom = new DOMDocument(); | ||
$dom->loadXML($xml); | ||
|
||
$stack = array($dom); | ||
$i = 0; | ||
|
||
while ($parent = array_shift($stack)) | ||
{ | ||
foreach ($parent->childNodes as $node) | ||
{ | ||
if ($node instanceof DOMElement | ||
&& $node->tagName == 'outline' | ||
&& $node->hasAttribute('xmlUrl')) | ||
{ | ||
Minion_CLI::write($node->getAttribute('xmlUrl')); | ||
try | ||
{ | ||
$feeds->add_feed($node->getAttribute('xmlUrl'), $user); | ||
} | ||
catch (Exception $e) | ||
{ | ||
Minion_CLI::write('Could not add feed: ' . $e->getMessage()); | ||
} | ||
} | ||
|
||
if ($node->hasChildNodes()) | ||
{ | ||
// recursion is for noobs ;) | ||
$stack[] = $node; | ||
} | ||
} | ||
} | ||
|
||
//return $dom->saveHTML(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters