@package serendipity
@version
class serendipity_event_podcast extends serendipity_event{
**/
var $title = PLUGIN_PODCAST_NAME;
// Array of extensions => shorttype filled by configuration
var $supportedFiletypes = null;
// Array of shorttype => player filled by configuration
var $supportedPlayers = null;
// Array of fileurls replaced with player code
var $playerUrlsAdded = array();
// Enable debug messages?
var $debug = false;
/**
@access public
*/
function introspect(&$propbag)
{
$events = array(
'frontend_display:rss-1.0:per_entry' => true,
'frontend_display:rss-2.0:per_entry' => true,
'frontend_display:rss-1.0:namespace' => true,
'frontend_display:rss-2.0:namespace' => true,
'frontend_display' => true,
'frontend_header' => true,
'css' => true
);
$propbag->add('name', PLUGIN_PODCAST_NAME);
$propbag->add('description', PLUGIN_PODCAST_DESC);
$propbag->add('stackable', false);
$propbag->add('license', 'GPL');
$propbag->add('cachable_events', $events);
$propbag->add('event_hooks', $events);
$propbag->add('configuration', array(
'info',
'easy',
'use_player',
'automatic_size',
'width',
'height',
'align',
'firstmedia_only',
'nopodcasting_class',
'epheader',
'extendet_enclosure_attributes',
'extendet_enclosure_position',
'ep_automatic_size',
'ep_align',
'ep_asure_enc',
'mergemulti',
'downloadlink',
'expert',
'itunes_meta',
/* players */
'extflow',
'extflow_player',
'extquicktime',
'extquicktime_player',
'extwinmedia',
'extwinmedia_player',
'extflash',
'extflash_player',
'extxspf',
'extxspf_player',
'extaudio',
'extaudio_player',
'exthtml5_audio',
'exthtml5_audio_player',
'exthtml5_video',
'exthtml5_video_player',
/* exotic options */
'use_cache',
'plugin_http_path'
));
$propbag->add('author', 'Grischa Brockhaus, Hannes Gassert, Garvin Hicking');
$propbag->add('version', SERENDIPITY_EVENT_PODCAST_VERSION);
$propbag->add('requirements', array(
'serendipity' => '0.7',
'smarty' => '2.6.7',
'php' => '4.1.0'
));
$propbag->add('groups', array('BACKEND_EDITOR'));
}
/**
@access public
*/
function introspect_config_item($name, &$propbag) {
global $serendipity;
switch($name) {
case 'info':
$propbag->add('type', 'content');
$propbag->add('default', nl2br((function_exists('serendipity_specialchars') ? serendipity_specialchars(PLUGIN_PODCAST_USAGE) : htmlspecialchars(PLUGIN_PODCAST_USAGE, ENT_COMPAT, LANG_CHARSET)) . "\n" . PLUGIN_PODCAST_USAGE_RSS));
break;
case 'easy':
$propbag->add('type', 'content');
$propbag->add('default', nl2br(PLUGIN_PODCAST_EASY));
break;
case 'expert':
$propbag->add('type', 'content');
$propbag->add('default', nl2br(PLUGIN_PODCAST_EXPERT . "\n" . PLUGIN_PODCAST_EXPERT_HINT));
break;
case 'epheader':
$propbag->add('type', 'content');
$propbag->add('default', nl2br(PLUGIN_PODCAST_EXTATTRSETTINGS));
break;
case 'seperator':
$propbag->add('type', 'seperator');
break;
case 'use_player':
$propbag->add('type', 'boolean');
$propbag->add('name', PLUGIN_PODCAST_USEPLAYER);
$propbag->add('description', '');
$propbag->add('default', 'true');
break;
case 'automatic_size':
$propbag->add('type', 'boolean');
$propbag->add('name', PLUGIN_PODCAST_AUTOSIZE);
$propbag->add('description', PLUGIN_PODCAST_AUTOSIZE_DESC);
$propbag->add('default', 'false');
break;
case 'mergemulti':
$propbag->add('type', 'boolean');
$propbag->add('name', PLUGIN_PODCAST_MERGEMULTI);
$propbag->add('description', '');
$propbag->add('default', 'true');
break;
case 'downloadlink':
$propbag->add('type', 'boolean');
$propbag->add('name', PLUGIN_PODCAST_DOWNLOADLINK);
$propbag->add('description', PLUGIN_PODCAST_DOWNLOADLINK_DESC);
$propbag->add('default', 'true');
break;
case 'ep_automatic_size':
$propbag->add('type', 'boolean');
$propbag->add('name', PLUGIN_PODCAST_AUTOSIZE);
$propbag->add('description', PLUGIN_PODCAST_AUTOSIZE_DESC);
$propbag->add('default', 'false');
break;
case 'width':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_PODCAST_WIDTH);
$propbag->add('description', PLUGIN_PODCAST_WIDTH_DESC);
$propbag->add('default', '200');
break;
case 'height':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_PODCAST_HEIGHT);
$propbag->add('description', PLUGIN_PODCAST_HEIGHT_DESC);
$propbag->add('default', '200');
break;
case 'align':
$propbag->add('type', 'select');
$propbag->add('name', PLUGIN_PODCAST_ALIGN);
$propbag->add('description', PLUGIN_PODCAST_ALIGN_DESC);
$propbag->add('select_values', $this->GetAlignOptionsArray());
$propbag->add('default', 'left');
break;
case 'nopodcasting_class':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_PODCAST_NOPODCASTING_CLASS);
$propbag->add('description', PLUGIN_PODCAST_NOPODCASTING_CLASS_DESC);
$propbag->add('default', 'nopodcast');
break;
case 'firstmedia_only':
$propbag->add('type', 'boolean');
$propbag->add('name', PLUGIN_PODCAST_FIRSTMEDIAONLY);
$propbag->add('description', PLUGIN_PODCAST_FIRSTMEDIAONLY_DESC);
$propbag->add('default', 'false');
break;
case 'ep_align':
$propbag->add('type', 'select');
$propbag->add('name', PLUGIN_PODCAST_ALIGN);
$propbag->add('description', PLUGIN_PODCAST_ALIGN_DESC);
$propbag->add('select_values', $this->GetAlignOptionsArray());
$propbag->add('default', 'center');
break;
case 'extendet_enclosure_attributes':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_PODCAST_EXTATTR);
$propbag->add('description', PLUGIN_PODCAST_EXTATTR_DESC);
$propbag->add('default', 'Podcast,Video');
break;
case 'extendet_enclosure_position':
$positions = array(
'none' => PLUGIN_PODCAST_EXTPOS_NONE,
'body_top' => PLUGIN_PODCAST_EXTPOS_BT,
'body_botton' => PLUGIN_PODCAST_EXTPOS_BB,
'ext_top' => PLUGIN_PODCAST_EXTPOS_ET,
'ext_botton' => PLUGIN_PODCAST_EXTPOS_EB,
);
$propbag->add('type', 'select');
$propbag->add('name', PLUGIN_PODCAST_EXTPOS);
$propbag->add('description', PLUGIN_PODCAST_EXTPOS_DESC);
$propbag->add('select_values', $positions);
$propbag->add('default', 'none');
break;
case 'ep_asure_enc':
$propbag->add('type', 'boolean');
$propbag->add('name', PLUGIN_PODCAST_ASURE_FEEDENC);
$propbag->add('description', PLUGIN_PODCAST_ASURE_FEEDEENC_DESC);
$propbag->add('default', 'true');
break;
/* PLAYERS */
case 'extflow':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_PODCAST_FLOWEXT);
$propbag->add('description', PLUGIN_PODCAST_FLOWEXT_DESC);
$propbag->add('default', PLUGIN_PODCAST_FLOWEXT_DEFAULT);
break;
case 'exthtml5_audio':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_PODCAST_HTML5_AUDIO);
$propbag->add('description', PLUGIN_PODCAST_HTML5_AUDIO_DESC);
$propbag->add('default', PLUGIN_PODCAST_HTML5_AUDIO_DEFAULT);
break;
case 'exthtml5_video':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_PODCAST_HTML5_VIDEO);
$propbag->add('description', PLUGIN_PODCAST_HTML5_VIDEO_DESC);
$propbag->add('default', PLUGIN_PODCAST_HTML5_VIDEO_DEFAULT);
break;
case 'extquicktime':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_PODCAST_QTEXT);
$propbag->add('description', PLUGIN_PODCAST_QTEXT_DESC);
$propbag->add('default', PLUGIN_PODCAST_QTEXT_DEFAULT);
break;
case 'extwinmedia':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_PODCAST_WMEXT);
$propbag->add('description', PLUGIN_PODCAST_WMEXT_DESC);
$propbag->add('default', PLUGIN_PODCAST_WMEXT_DEFAULT);
break;
case 'extflash':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_PODCAST_MFEXT);
$propbag->add('description', PLUGIN_PODCAST_MFEXT_DESC);
$propbag->add('default', PLUGIN_PODCAST_MFEXT_DEFAULT);
break;
case 'extxspf':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_PODCAST_XSPFEXT);
$propbag->add('description', PLUGIN_PODCAST_XSPFEXT_DESC);
$propbag->add('default', PLUGIN_PODCAST_XSPFEXT_DEFAULT);
break;
case 'extaudio':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_PODCAST_AUEXT);
$propbag->add('description', PLUGIN_PODCAST_AUEXT_DESC);
$propbag->add('default', PLUGIN_PODCAST_AUEXT_DEFAULT);
break;
case 'extflow_player':
$propbag->add('type', 'text');
$propbag->add('name', PLUGIN_PODCAST_FLOWEXT_HTML);
$propbag->add('description', '');
$propbag->add('default', PLUGIN_PODCAST_FLOWPLAYER);
break;
case 'exthtml5_audio_player':
$propbag->add('type', 'text');
$propbag->add('name', PLUGIN_PODCAST_HTML5_AUDIO_HTML);
$propbag->add('description', '');
$propbag->add('default', PLUGIN_PODCAST_HTML5_AUDIOPLAYER);
break;
case 'exthtml5_video_player':
$propbag->add('type', 'text');
$propbag->add('name', PLUGIN_PODCAST_HTML5_VIDEO_HTML);
$propbag->add('description', '');
$propbag->add('default', PLUGIN_PODCAST_HTML5_VIDEOPLAYER);
break;
case 'extquicktime_player':
$propbag->add('type', 'text');
$propbag->add('name', PLUGIN_PODCAST_QTEXT_HTML);
$propbag->add('description', '');
$propbag->add('default', PLUGIN_PODCAST_QUICKTIMEPLAYER);
break;
case 'extwinmedia_player':
$propbag->add('type', 'text');
$propbag->add('name', PLUGIN_PODCAST_WMEXT_HTML);
$propbag->add('description', '');
$propbag->add('default', PLUGIN_PODCAST_WMPLAYER);
break;
case 'extflash_player':
$propbag->add('type', 'text');
$propbag->add('name', PLUGIN_PODCAST_MFEXT_HTML);
$propbag->add('description', '');
$propbag->add('default', PLUGIN_PODCAST_FLASHPLAYER);
break;
case 'extxspf_player':
$propbag->add('type', 'text');
$propbag->add('name', PLUGIN_PODCAST_XSPFEXT_HTML);
$propbag->add('description', '');
$propbag->add('default', PLUGIN_PODCAST_XSPFPLAYER);
break;
case 'extaudio_player':
$propbag->add('type', 'text');
$propbag->add('name', PLUGIN_PODCAST_AUEXT_HTML);
$propbag->add('description', '');
$propbag->add('default', PLUGIN_PODCAST_MP3PLAYER);
break;
/* exotic */
case 'use_cache':
$propbag->add('type', 'boolean');
$propbag->add('name', PLUGIN_PODCAST_USECACHE);
$propbag->add('description', PLUGIN_PODCAST_USECACHE_DESC);
$propbag->add('default', 'true');
break;
case 'itunes_meta':
$propbag->add('type', 'text');
$propbag->add('name', PLUGIN_PODCAST_ITUNES);
$propbag->add('description', PLUGIN_PODCAST_ITUNES_DESC);
$propbag->add('default', "
" . (function_exists('serendipity_specialchars') ? serendipity_specialchars($serendipity['blogTitle']) : htmlspecialchars($serendipity['blogTitle'], ENT_COMPAT, LANG_CHARSET)) . "
" . (function_exists('serendipity_specialchars') ? serendipity_specialchars($serendipity['blogTitle']) : htmlspecialchars($serendipity['blogTitle'], ENT_COMPAT, LANG_CHARSET)) . "
" . (function_exists('serendipity_specialchars') ? serendipity_specialchars($serendipity['blogDescription']) : htmlspecialchars($serendipity['blogDescription'], ENT_COMPAT, LANG_CHARSET)) . "
");
break;
case 'plugin_http_path':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_PODCAST_HTTPREL);
$propbag->add('description', PLUGIN_PODCAST_HTTPREL_DESC);
$propbag->add('default', $serendipity['serendipityHTTPPath'] . 'plugins/serendipity_event_podcast');
break;
}
return true;
}
function iTunify(&$eventData) {
$eventData['per_entry_display_dat'] .= '' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($eventData['author']) : htmlspecialchars($eventData['author'], ENT_COMPAT, LANG_CHARSET)) . '' . "\n";
$eventData['per_entry_display_dat'] .= '' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($eventData['title']) : htmlspecialchars($eventData['title'], ENT_COMPAT, LANG_CHARSET)) . '' . "\n";
$eventData['per_entry_display_dat'] .= '' . (function_exists('serendipity_specialchars') ? serendipity_specialchars(strip_tags($eventData['feed_body'])) : htmlspecialchars(strip_tags($eventData['feed_body']), ENT_COMPAT, LANG_CHARSET)) . '' . "\n";
}
/**
@access public
*/
function event_hook($event, &$bag, &$eventData, $addData = null){
global $serendipity;
static $use_player = null;
static $firstmedia_only = null;
static $patterns = null;
$this->log("EventHook: " . $event);
$this->InitializeSupportedFiletypes();
if ($patterns == null) {
//yes indeed, we wont find links like "download.php?file=rock.mp3&foo=bar"
$patterns = array(
//'mediaLinkPattern' => '@href\s*=\s*(\'|")([^>]+\.(' . implode('|', array_keys($this->supportedFiletypes)) . '))\1@Usie',
'playerRewritePattern' => '@]*?href\s*=\s*(\'|")([^\'"]+\.('
. implode('|', array_keys($this->supportedFiletypes))
. '))\1[^>]*?>.*?@si', //won't match nested tags, like .. . but that's ugly anyway.
'embeddedObjectPattern' => '@