Created
April 21, 2013 16:28
-
-
Save killerwolf/5430167 to your computer and use it in GitHub Desktop.
eZ Publish - Import RSS natif de la balise enclosur url
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
<enclosure url="http://www.example.com/images/voiture.jpg" length="" type="image/jpeg"/> |
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
//extension/myextension/cronjobs/enhanced_rssimport.php | |
$fieldDefinition = eZRSSImport::rssFieldDefinition(); | |
$ini = eZINI::instance(); | |
foreach( $ini->variable( ‘RSSSettings’, ‘ActiveExtensions’ ) as $activeExtension ) | |
{ | |
if ( file_exists( eZExtension::baseDirectory() . ‘/’ . $activeExtension . ‘/rss/’ . $activeExtension . ‘rssimport.php’ ) ) | |
{ | |
include_once( eZExtension::baseDirectory() . ‘/’ . $activeExtension . ‘/rss/’ . $activeExtension . ‘rssimport.php’ ); | |
$fieldDefinition = eZRSSImport::arrayMergeRecursive( $fieldDefinition, call_user_func( array( $activeExtension . ‘rssimport’, ‘rssFieldDefinition’ ), array() ) ); | |
} | |
} |
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
//extension/myextension/rss/ezrssimage.php | |
class ezrssimagerssimport | |
{ | |
static function rssFieldDefinition() | |
{ | |
return array( ‘item’ => array( ‘elements’ => array( ‘enclosure’ => array( ‘attributes’ => array( ‘url’ ) ) ) ) ); | |
} | |
} |
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
//kernel/classes/ezrssimport.php | |
case ’2.0′: | |
case ’0.91′: | |
case ’0.92′: | |
{ | |
return array( ‘item’ => array( ‘elements’ => array( ‘title’, | |
‘link’, | |
‘description’, | |
‘author’, | |
‘category’, | |
‘comments’, | |
‘guid’, | |
‘pubDate’, | |
‘enclosure’ => array( ‘attributes’ => array( ‘url’ ) ) ) ), | |
‘channel’ => array( ‘elements’ => array( ‘title’, | |
‘link’, | |
‘description’, | |
‘copyright’, | |
‘managingEditor’, | |
‘webMaster’, | |
‘pubDate’, | |
‘lastBuildDate’, | |
‘category’, | |
‘generator’, | |
‘docs’, | |
‘cloud’, | |
‘ttl’ ) ) ); | |
} |
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
//cronjobs/rssimport.php | |
function setObjectAttributeValue( $objectAttribute, $value ) | |
{ | |
//… | |
switch( $dataType ) | |
{ | |
//… | |
case ‘ezimage’: | |
{ | |
$file = pathinfo($value); | |
$image = eZHTTPTool::getDataByURL( $value ); | |
if($image !== false) | |
{ | |
$fp = fopen(‘/tmp/’.$file[‘basename’],‘wb’); | |
fwrite($fp, $image, strlen($image)); | |
fclose($fp); | |
$objectAttribute->fromString( ‘/tmp/’.$file[‘basename’] ); | |
} | |
} break; | |
//.. | |
} | |
} |
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
//extension/myextension/settings/site.ini.append.php | |
[RSSSettings] | |
ActiveExtensions[]=ezrssimage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment