Changeset 897

Show
Ignore:
Timestamp:
09/05/08 04:01:42 (3 months ago)
Author:
rickc
Message:

More updates. Comments sorely lacking. xspf slim player being used temporarily to have a player on the podcast post. The feed generated is still not valid for itunes due to missing the podcast duration.

Location:
plugins/podcast/trunk
Files:
3 added
1 modified

Legend:

Unmodified
Added
Removed
  • plugins/podcast/trunk/podcast.plugin.php

    r871 r897  
    1212    const PODCAST_ITUNES = 0; 
    1313 
     14 
     15    private $itunes_categories = array( 
     16        '', 
     17        'Arts',  
     18        'Arts:Design',  
     19        'Arts:Fashion & Beauty',  
     20        'Arts:Food',  
     21        'Arts:Literature',  
     22        'Arts:Performing Arts',  
     23        'Arts:Visual Arts', 
     24        'Business', 
     25        'Business:Business News',  
     26        'Business:Careers',  
     27        'Business:Investing',  
     28        'Business:Management & Marketing',  
     29        'Business:Shopping', 
     30        'Comedy', 
     31        'Education',  
     32        'Education:Education Technology',  
     33        'Education:Higher Education',  
     34        'Education:K-12',  
     35        'Education:Language Courses',  
     36        'Education:Training', 
     37        'Games & Hobbies', 
     38        'Games & Hobbies:Automotive',  
     39        'Games & Hobbies:Aviation',  
     40        'Games & Hobbies:Hobbies',  
     41        'Games & Hobbies:Other Games',  
     42        'Games & Hobbies:Video Games', 
     43        'Government & Organizations', 
     44        'Government & Organizations:Local',  
     45        'Government & Organizations:National',  
     46        'Government & Organizations:Non-Profit',  
     47        'Government & Organizations:Regional', 
     48        'Health', 
     49        'Health:Alternative Health',  
     50        'Health:Fitness & Nutrition',  
     51        'Health:Self-Help',  
     52        'Health:Sexuality', 
     53        'Kids & Family', 
     54        'Music', 
     55        'News & Politics', 
     56        'Religion & Spirituality', 
     57        'Religion & Spirituality:Buddhism',  
     58        'Religion & Spirituality:Christianity',  
     59        'Religion & Spirituality:Hinduism',  
     60        'Religion & Spirituality:Islam',  
     61        'Religion & Spirituality:Judaism',  
     62        'Religion & Spirituality:Other',  
     63        'Religion & Spirituality:Spirituality', 
     64        'Science & Medicine',  
     65        'Science & Medicine:Medicine',  
     66        'Science & Medicine:Natural Sciences',  
     67        'Science & Medicine:Social Sciences', 
     68        'Society & Culture',  
     69        'Society & Culture:History',  
     70        'Society & Culture:Personal Journals',  
     71        'Society & Culture:Philosophy',  
     72        'Society & Culture:Places & Travel', 
     73        'Sports & Recreation', 
     74        'Sports & Recreation:Amateur',  
     75        'Sports & Recreation:College & High School',  
     76        'Sports & Recreation:Outdoor',  
     77        'Sports & Recreation:Professional', 
     78        'Technology',  
     79        'Technology:Gadgets',  
     80        'Technology:Tech News',  
     81        'Technology:Podcasting',  
     82        'Technology:Software How-To', 
     83        'TV & Film', 
     84    ); 
    1485/* 
    15     private $itunes_categories = array( 
    16         '0 => '', 
    17         1 => 'Arts' => array( 'Design', 'Fashion & Beauty', 'Food', 'Literature', 'Performing Arts', 'Visual Arts' ), 
    18         2 => 'Business' => array( 'Business News', 'Careers', 'Investing', 'Management & Marketing', 'Shopping' ), 
    19         3 => 'Comedy', 
    20         4 => 'Education' => array( 'Education Technology', 'Higher Education', 'K-12', 'Language Courses', 'Training' ), 
    21         5 => 'Games & Hobbies' => array( 'Automotive', 'Aviation', 'Hobbies', 'Other Games', 'Video Games' ), 
    22         6 => 'Government & Organizations' => array( 'Local', 'National', 'Non-Profit', 'Regional' ), 
    23         7 => 'Health' => array( 'Alternative Health', 'Fitness & Nutrition', 'Self-Help', 'Sexuality' ), 
    24         8 => 'Kids & Family', 
    25         9 => 'Music', 
    26         10 => 'News & Politics', 
    27         11 => 'Religion & Spirituality' => array( 'Buddhism', 'Christianity', 'Hinduism', 'Islam', 'Judaism', 'Other', 'Spirituality' ), 
    28         12 => 'Science & Medicine' => array( 'Medicine', 'Natural Sciences', 'Social Sciences' ), 
    29         13 => 'Society & Culture' => array( 'History', 'Personal Journals', 'Philosophy', 'Places & Travel' ), 
    30         14 => 'Sports & Recreation' => array( 'Amateur', 'College & High School', 'Outdoor', 'Professional' ), 
    31         15 => 'Technology' => array( 'Gadgets', 'Tech News', 'Podcasting', 'Software How-To' ), 
    32         16 => 'TV & Film', 
    33     ); 
    34 */ 
    3586    private $itunes_categories = array( 
    3687        0 => '', 
     
    66117        'Technology' => array( 'Gadgets', 'Tech News', 'Podcasting', 'Software How-To' ), 
    67118    ); 
    68  
     119*/ 
    69120    private $itunes_explicit = array( 
    70121        0 => 'Clean', 
     
    101152        } 
    102153    } 
    103      
     154 
     155    function action_init() 
     156    { 
     157        $this->load_text_domain( 'podcast' ); 
     158    } 
     159 
    104160    /** 
    105161    * This function is incomplete 
     
    117173    add_to_{$feed}: function(fileindex, fileobj) { 
    118174        $('#enclosure_{$feedmd5}').val(fileobj.url); 
     175        habari.editor.insertSelection('<!-- file:'+fileobj.url+' -->'); 
    119176    } 
    120177}); 
     
    138195                for( $it = $feed_obj->getIterator(); $it->valid(); $it->next() ) { 
    139196                    if( $action == 'feed_' .  md5(  $it->key() ) ) { 
    140                         $ui = new FormUI( 'feed' ); 
    141                         $label = sprintf( _t( 'Edit %s iTunes options' ), $it->key() ); 
    142                         $itunes = $ui->append( 'fieldset', 'itunes', $label ); 
    143                         $ui->append( 'submit', 'submit', _t( 'Submit' ) ); 
    144                         $ui->out(); 
     197                        switch( $it->current() ) { 
     198                            case self::PODCAST_ITUNES: 
     199                                $this->itunes_options( $it ); 
     200                                break; 
     201                        } 
    145202                    } 
    146203                } 
     
    150207                    $ui = new FormUI('podcast'); 
    151208 
    152                     $addfeed = $ui->append('fieldset', 'addfeed', 'Add Feed');                   
    153                     $addfeed->append('text', 'feedname', 'null:null', 'New Feed Name:'); 
    154                     $addfeed->append('select', 'feedtype', 'null:null', 'New Feed Type:'); 
     209                    $addfeed = $ui->append('fieldset', 'addfeed', 'Add Feed'); 
     210                    $addfeed->append('text', 'feedname', 'null:null', _t( 'New Feed Name:', 'podcast' ) ); 
     211                    $addfeed->append('select', 'feedtype', 'null:null', _t( 'New Feed Type:', 'podcast' ) ); 
    155212                    $addfeed->feedtype->options = array('itunes'); 
    156213 
    157214                    $feeddata = array_keys(Options::get('podcast__feeds')); 
    158215                    if(count($feeddata) > 0) { 
    159                         $editfeed = $ui->append('fieldset', 'editfeed', _t( 'Manage Feeds' ) ); 
    160                         $editfeed->append('static', 'managelabel', '<p>' . _t('Uncheck the feeds that you wish to delete.') . '</p>'); 
    161                         $feeds = $editfeed->append('checkboxes', 'feeds', 'null:null', _t( 'Feeds' ) ); 
     216                        $editfeed = $ui->append('fieldset', 'editfeed', _t( 'Manage Feeds', 'podcast' ) ); 
     217                        $editfeed->append('static', 'managelabel', '<p>' . _t('Uncheck the feeds that you wish to delete.', 'podcast' ) . '</p>'); 
     218                        $feeds = $editfeed->append('checkboxes', 'feeds', 'null:null', _t( 'Feeds', 'podcast' ) ); 
    162219                        $feeds->options = array_combine($feeddata, $feeddata); 
    163220                        $feeds->value = $feeddata;  
     
    186243            $feeds = Options::get('podcast__feeds'); 
    187244            foreach($feeds as $feedname => $feedtype) { 
    188                 $actions['feed_' . md5($feedname)] = sprintf(_t('Edit "%s" feed'), $feedname); 
     245                $actions['feed_' . md5($feedname)] = sprintf(_t('Edit "%s" feed', 'podcast' ), $feedname); 
    189246            } 
    190247        } 
     
    228285        if( $form->content_type->value == Post::type('podcast') ) { 
    229286            $feeds = Options::get('podcast__feeds'); 
    230             $postfields = $form->publish_controls->append('fieldset', 'enclosures', _t( 'Enclosures' ) ); 
     287            $postfields = $form->publish_controls->append('fieldset', 'enclosures', _t( 'Enclosures', 'podcast' ) ); 
    231288            foreach($feeds as $feed => $feedtype) { 
    232289                switch( $feedtype ) { 
    233290                case self::PODCAST_ITUNES: 
    234                     $this->itunes_form( $form, $post, $feed ); 
     291                    $this->post_itunes_form( $form, $post, $feed ); 
    235292                    break; 
    236293                } 
    237294            } 
    238295        } 
     296    } 
     297 
     298    public function filter_post_content_out( $content ) 
     299    { 
     300        preg_match_all( '/<!-- file:(.*) -->/i', $content, $matches, PREG_PATTERN_ORDER ); 
     301        $matches_obj = new ArrayObject( $matches[1] ); 
     302 
     303        for( $it = $matches_obj->getIterator(); $it->valid(); $it->next() ){ 
     304            $content = str_ireplace( '<!-- file:' . $it->current() . ' -->', $this->embed_player( $it->current() ), $content ); 
     305        } 
     306 
     307        return $content; 
     308    } 
     309 
     310    public function embed_player( $file ) 
     311    { 
     312        $player = '<p><object width="300" height="20">'; 
     313        $player .= '<param name="movie" value="' . $this->get_url() . '/players/xspf_player_slim.swf?song_url=' . $file . '&song_title=' . basename( $file, '.mp3' ) . '&player_title=' . htmlspecialchars( Options::get( 'title' ), ENT_COMPAT, 'UTF-8' ) . '" />'; 
     314        $player .= '<param name="wmode" value="transparent" />'; 
     315        $player .= '<embed src="' . $this->get_url() . '/xspf_player_slim.swf?song_url=' . $file . '&song_title=' . basename( $file, '.mp3' ). '&player_title=' . htmlspecialchars( Options::get( 'title' ), ENT_COMPAT, 'UTF-8' ) . '" type="application/x-shockwave-flash" wmode="transparent" width="300" height="20"></embed>'; 
     316        $player .= '</object></p>'; 
     317 
     318        return $player; 
    239319    } 
    240320 
     
    254334                switch( $feedtype ) { 
    255335                    case self::PODCAST_ITUNES: 
    256                         $this->get_itunes_settings( $form, $post, $feed ); 
     336                        $this->get_post_itunes_settings( $form, $post, $feed ); 
    257337                    break; 
    258338                } 
     
    279359            'priority' => 7, 
    280360            'is_active' => 1, 
     361            'description' => 'Displays the podcast feed', 
     362        )); 
     363        $rules[] = new RewriteRule(array( 
     364            'name' => 'display_podcast', 
     365            'parse_regex' => '%^(?P<slug>[^/]+)(?:/page/(?P<page>\d+))?/?$%i', 
     366            'build_str' => '{$slug}(/page/{$page})', 
     367            'handler' => 'UserThemeHandler', 
     368            'action' => 'display_podcast', 
     369            'priority' => 7, 
     370            'is_active' => 1, 
     371            'description' => 'Displays a single podcast', 
    281372        )); 
    282373        return $rules; 
    283374    } 
    284      
     375 
     376    public function filter_theme_act_display_podcast( $handled, $theme ) 
     377    { 
     378        $default_filters= array( 
     379            'content_type' => Post::type( 'podcast' ), 
     380        ); 
     381        $theme->act_display_post( $default_filters ); 
     382        return true; 
     383    } 
     384 
     385    public function filter_template_user_filters( $where ) 
     386    { 
     387        if( is_array( $where['content_type'] ) ) { 
     388            $where['content_type'] = array_merge( $where['content_type'], array( Post::type( 'podcast' ) ) ); 
     389        } 
     390        else { 
     391            $where['content_type'] = array( $where['content_type'], Post::type('podcast') ); 
     392        } 
     393        return $where; 
     394    } 
     395 
    285396    /** 
    286397    * Respond to requests for podcasts 
     
    315426        Plugins::act( 'podcast_rss_collection', $xml, $posts, $feed_name ); 
    316427        ob_clean(); 
    317  
    318428        header( 'Content-Type: application/xml' ); 
     429        file_put_contents( 'podcast.rss', $xml->asXML() ); 
    319430        echo $xml->asXML(); 
    320431        exit; 
     
    331442        $xml->addAttribute(  'version', '2.0' ); 
    332443        $channel= $xml->addChild( 'channel' ); 
    333         $title= $channel->addChild( 'title', htmlspecialchars( Options::get('title') ) ); 
     444        $title= $channel->addChild( 'title', Options::get('title') ); 
    334445        $link= $channel->addChild( 'link', Site::get_url('habari') ); 
    335446        if ( $tagline= Options::get( 'tagline' ) ) { 
    336             $description= $channel->addChild( 'description', htmlspecialchars( $tagline ) ); 
     447            $description= $channel->addChild( 'description', $tagline ); 
    337448        } 
    338449        $pubDate= $channel->addChild( 'lastBuildDate', date( DATE_RFC822, strtotime( Post::get()->pubdate ) ) ); 
    339450        $generator= $channel->addChild( 'generator', 'Habari ' . Version::get_habariversion() . ' http://habariproject.org/' ); 
    340451 
    341         $itunes_author = $channel->addChild( 'xmlns:itunes:author', 'nothing' ); 
    342         $itunes_subtitle = $channel->addChild( 'xmlns:itunes:subtitle', 'nothing' ); 
    343         $itunes_summary = $channel->addChild( 'xmlns:itunes:summary', 'nothing' ); 
     452        $itunes = Options::get( "podcast__{$feed_name}_itunes" ); 
     453 
     454        $itunes_author = $channel->addChild( 'xmlns:itunes:author', $itunes['author'] ); 
     455        $itunes_subtitle = $channel->addChild( 'xmlns:itunes:subtitle', $itunes['subtitle'] ); 
     456        $itunes_summary = $channel->addChild( 'xmlns:itunes:summary', $itunes['subtitle'] ); 
    344457        $itunes_owner = $channel->addChild( 'xmlns:itunes:owner' ); 
    345         $itunes_owner_name = $itunes_owner->addChild( 'xmlns:itunes:name', 'nothing' ); 
    346         $itunes_owner_email = $itunes_owner->addChild( 'xmlns:itunes:email', 'nothing' ); 
    347         $itunes_explicit = $channel->addChild( 'xmlns:itunes:explicit', 'no' ); 
    348         $itunes_image = $channel->addChild( 'xmlns:itunes:image', 'nothing' ); 
    349         $itunes_image->addAttribute( 'href', 'nothing' ); 
    350         $itunes_category = $channel->addChild( 'xmlns:itunes:category' ); 
    351         $itunes_category->addAttribute( 'text', 'nothing' ); 
     458        $itunes_owner_name = $itunes_owner->addChild( 'xmlns:itunes:name', $itunes['owner_name'] ); 
     459        $itunes_owner_email = $itunes_owner->addChild( 'xmlns:itunes:email', $itunes['owner_email'] ); 
     460        $itunes_explicit = $channel->addChild( 'xmlns:itunes:explicit', $itunes['explicit'] ); 
     461        $itunes_image = $channel->addChild( 'xmlns:itunes:image' ); 
     462        $itunes_image->addAttribute( 'href', $itunes['image'] ); 
     463        if( $itunes['main_category'] ) { 
     464            $itunes_category = $channel->addChild( 'xmlns:itunes:category' ); 
     465            $categories = explode( ':', $itunes['main_category'] ); 
     466            $itunes_category->addAttribute( 'text', $categories[0] ); 
     467            if( isset( $categories[1] ) ) { 
     468                $child = $itunes_category->addChild( 'xmlns:itunes:category' ); 
     469                $child->addAttribute( 'text', $categories[1] ); 
     470            } 
     471        } 
     472        if( $itunes['category_2'] ) { 
     473            $itunes_category = $channel->addChild( 'xmlns:itunes:category' ); 
     474            $categories = explode( ':', $itunes['category_2'] ); 
     475            $itunes_category->addAttribute( 'text', $categories[0] ); 
     476            if( isset( $categories[1] ) ) { 
     477                $child = $itunes_category->addChild( 'xmlns:itunes:category' ); 
     478                $child->addAttribute( 'text', $categories[1] ); 
     479            } 
     480        } 
     481        if( $itunes['category_3'] ) { 
     482            $itunes_category = $channel->addChild( 'xmlns:itunes:category' ); 
     483            $categories = explode( ':', $itunes['category_3'] ); 
     484            $itunes_category->addAttribute( 'text', $categories[0] ); 
     485            if( isset( $categories[1] ) ) { 
     486                $child = $itunes_category->addChild( 'xmlns:itunes:category' ); 
     487                $child->addAttribute( 'text', $categories[1] ); 
     488            } 
     489        } 
     490        if ( $itunes['block'] ) { 
     491            $itunes_block = $channel->addChild( 'xmlns:itunes:block', 'Yes' ); 
     492        } 
     493        if ( isset( $itunes['redirect'] ) ) { 
     494            $itunes_redirect = $channel->addChild( 'xmlns:itunes:new-feed-url', $itunes['redirect'] ); 
     495        } 
    352496 
    353497        Plugins::act( 'podcast_create_wrapper', $xml ); 
     
    367511            if ($post instanceof Post) { 
    368512                $item= $items->addChild( 'item' ); 
    369                 $title= $item->addChild( 'title', htmlspecialchars( $post->title ) ); 
     513                $title= $item->addChild( 'title', $post->title ); 
    370514                $link= $item->addChild( 'link', $post->permalink ); 
    371                 $description= $item->addChild( 'description', htmlspecialchars( $post->content ) ); 
     515                $description= $item->addChild( 'description', $post->content ); 
    372516                $pubdate= $item->addChild ( 'pubDate', date( DATE_RFC822, strtotime( $post->pubdate ) ) ); 
    373517                $guid= $item->addChild( 'guid', $post->guid ); 
    374518                $guid->addAttribute( 'isPermaLink', 'false' ); 
    375519 
    376                 list($url, $size, $duration, $explicit, $subtitle, $keywords, $summary, $block ) = $post->info->$feed; 
     520                list($url, $size, $duration, $explicit, $subtitle, $keywords, $summary, $block ) = $post->info->$feed_name; 
    377521                $enclosure = $item->addChild( 'enclosure' ); 
    378522                $enclosure->addAttribute( 'url', $url ); 
     
    380524                $enclosure->addAttribute( 'type', 'audio/mpeg' ); 
    381525 
    382                 $itunes_author = $item->addChild( 'xmlns:itunes:author', htmlspecialchars( $post->author->displayname, ENT_COMPAT, 'UTF-8' ) ); 
     526                $itunes_author = $item->addChild( 'xmlns:itunes:author', $post->author->displayname ); 
    383527                $itunes_explicit = $item->addChild( 'xmlns:itunes:explicit', $explicit ); 
    384                 $itunes_subtitle = $item->addChild( 'xmlns:itunes:subtitle', htmlspecialchars( $subtitle, ENT_COMPAT, 'UTF-8' ) ); 
    385                 $itunes_summary = $item->addChild( 'xmlns:itunes:summary', htmlspecialchars( $summary, ENT_COMPAT, 'UTF-8' ) ); 
     528                $itunes_subtitle = $item->addChild( 'xmlns:itunes:subtitle', $subtitle ); 
     529                $itunes_summary = $item->addChild( 'xmlns:itunes:summary', $summary ); 
    386530                $itunes_duration = $item->addChild( 'xmlns:itunes:duration', $duration ); 
    387                 $itunes_keywords = $item->addChild( 'xmlns:itunes:keywords', htmlspecialchars( $keywords, ENT_COMPAT, 'UTF-8' ) ); 
     531                $itunes_keywords = $item->addChild( 'xmlns:itunes:keywords', $keywords ); 
    388532                $itunes_block = $item->addChild( 'xmlns:itunes:block', $block ); 
    389533 
     
    406550    } 
    407551 
    408     protected function itunes_form( $form, $post, $feed ) 
     552    protected function itunes_options( $it ) 
     553    { 
     554        $feed = $it->key(); 
     555        $user = User::identify(); 
     556        $options = Options::get( "podcast__{$feed}_itunes" ); 
     557 
     558        $ui = new FormUI( 'feed' ); 
     559        $label = sprintf( _t( 'Edit %s iTunes options', 'podcast' ), $feed ); 
     560        $itunes = $ui->append( 'fieldset', 'itunes', $label ); 
     561 
     562        $author = $itunes->append( 'text', 'author', 'null:null', _t( 'Podcast Author: ', 'podcast' ) ); 
     563        $author->value = $options['author'] ? $options['author'] : $user->displayname; 
     564 
     565        $subtitle = $itunes->append( 'text', 'subtitle', 'null:null', _t( 'Podcast Subtitle: ', 'podcast' ) ); 
     566        $subtitle->value = $options['subtitle'] ? $options['subtitle'] : Options::get( 'tagline' ); 
     567 
     568        $summary = $itunes->append( 'textarea', 'summary', 'null:null', _t( 'Podcast Summary: ', 'podcast' ) ); 
     569        $summary->value = $options['summary'] ? $options['summary'] : Options::get( 'tagline' ); 
     570 
     571        $owner_name = $itunes->append( 'text', 'owner_name', 'null:null', _t( 'Podcast Owner Name: ', 'podcast' ) ); 
     572        $owner_name->value = $options['owner_name'] ? $options['owner_name'] : $user->displayname; 
     573 
     574        $owner_email = $itunes->append( 'text', 'owner_email', 'null:null', _t( 'Podcast Owner EMail: ', 'podcast' ) ); 
     575        $owner_email->value = $options['owner_email'] ? $options['owner_email'] : $user->email; 
     576        $owner_email->add_validator( 'validate_email' ); 
     577 
     578        $explicit = $itunes->append( 'select', 'explicit', 'null:null', _t( 'Explicit Content: ', 'podcast' ) ); 
     579        $explicit->options = $this->itunes_explicit; 
     580        $explicit->value = $options['explicit'] ? $options['explicit'] : $this->itunes_explicit[0]; 
     581 
     582        $image = $itunes->append( 'text', 'image', 'null:null', _t( 'Podcast Artwork URL: ', 'podcast' ) ); 
     583        $image->value = $options['image'] ? $options['image'] : ''; 
     584 
     585        $block = $itunes->append( 'checkbox', 'block', 'null:null', _t( 'Block Podcast: ', 'podcast' ) ); 
     586        $block->value = $options['block'] ? $options['block'] : 0; 
     587 
     588        $main_category = $itunes->append( 'select', 'main_category', 'null:null', _t( 'Podcast Category: ', 'podcast' ) ); 
     589        $main_category->options = $this->itunes_categories; 
     590        $main_category->value = $options['main_category'] ? $options['main_category'] : $this->itunes_categories[1]; 
     591 
     592        $category_2 = $itunes->append( 'select', 'category_2', 'null:null', _t( 'Podcast Category: ', 'podcast' ) ); 
     593        $category_2->options = $this->itunes_categories; 
     594        $category_2->value = $options['category_2'] ? $options['category_2'] : $this->itunes_categories[0]; 
     595 
     596        $category_3 = $itunes->append( 'select', 'category_3', 'null:null', _t( 'Podcast Category: ', 'podcast' ) ); 
     597        $category_3->options = $this->itunes_categories; 
     598        $category_3->value = $options['category_3'] ? $options['category_3'] : $this->itunes_categories[0]; 
     599 
     600        $ui->append( 'submit', 'submit', _t( 'Submit' ) ); 
     601        $ui->on_success( array( $this, 'itunes_updated' ), $it ); 
     602        $ui->out(); 
     603    } 
     604 
     605    public function itunes_updated( $ui, $it ) 
     606    { 
     607        $options = array( 
     608        'author' => $ui->author->value, 
     609        'subtitle' => $ui->subtitle->value, 
     610        'summary' => $ui->summary->value, 
     611        'owner_name' => $ui->owner_name->value, 
     612        'owner_email' => $ui->owner_email->value, 
     613        'explicit' => $this->itunes_explicit[$ui->explicit->value], 
     614        'image' => $ui->image->value, 
     615        'block' => $ui->block->value, 
     616        'main_category' => $this->itunes_categories[$ui->main_category->value], 
     617        'category_2' => $this->itunes_categories[$ui->category_2->value], 
     618        'category_3' => $this->itunes_categories[$ui->category_3->value], 
     619        ); 
     620 
     621        Options::set( "podcast__{$it->key()}_itunes", $options ); 
     622        Session::notice( "{$it->key()} iTunes options updated." ); 
     623    } 
     624 
     625    protected function post_itunes_form( $form, $post, $feed ) 
    409626    { 
    410627        $postfields = $form->publish_controls->enclosures; 
     
    414631        $control_id = md5($feed); 
    415632        $fieldname = "{$control_id}_settings"; 
    416         $feed_fields = $postfields->append( 'fieldset', $fieldname, _t( 'Settings for ' ) . $feed ); 
     633        $feed_fields = $postfields->append( 'fieldset', $fieldname, _t( 'Settings for ', 'podcast' ) . $feed ); 
    417634        $feed_fields->class = 'podcast-settings'; 
    418635 
    419636        $fieldname = "enclosure_{$control_id}"; 
    420         $customfield = $feed_fields->append('text', $fieldname, 'null:null', _t( 'Podcast file:' ), 'tabcontrol_text' ); 
     637        $customfield = $feed_fields->append('text', $fieldname, 'null:null', _t( 'Podcast Enclosure:', 'podcast' ), 'tabcontrol_text' ); 
    421638        $customfield->value = isset( $url ) ? $url : ''; 
    422639 
     640        $fieldname = "subtitle_{$control_id}"; 
     641        $customfield = $feed_fields->append( 'text', $fieldname, 'null:null', _t( 'Subtitle:', 'podcast' ), 'tabcontrol_text' ); 
     642        $customfield->value = isset( $subtitle ) ? $subtitle : ''; 
     643 
    423644        $fieldname = "explicit_{$control_id}"; 
    424         $customfield = $feed_fields->append( 'select', $fieldname, 'null:null', _t( 'Explicit:' ) ); 
     645        $customfield = $feed_fields->append( 'select', $fieldname, 'null:null', _t( 'Explicit:', 'podcast' ) ); 
    425646        $customfield->template = 'tabcontrol_select'; 
    426647        $customfield->options = $this->itunes_explicit; 
    427648        if( isset( $explicit ) ) $customfield->value = $explicit; 
    428649 
    429 /*      $fieldname = "category_{$control_id}"; 
    430         $customfield = $feed_fields->append( 'select', $fieldname, 'null:null', _t( 'Category:' ) ); 
    431         $customfield->template = 'tabcontrol_select'; 
    432         $customfield->options = $this->itunes_categories; 
    433         $customfield->value = isset( $category ) ? $category : $this->itunes_categories[0]; 
    434 */ 
    435  
    436         $fieldname = "subtitle_{$control_id}"; 
    437         $customfield = $feed_fields->append( 'text', $fieldname, 'null:null', _t( 'Subtitle:' ), 'tabcontrol_text' ); 
    438         $customfield->value = isset( $subtitle ) ? $subtitle : ''; 
    439  
    440650        $fieldname = "keywords_{$control_id}"; 
    441         $customfield = $feed_fields->append( 'text', $fieldname, 'null:null', _t( 'Keywords:' ), 'tabcontrol_text' ); 
    442         $customfield->value = isset( $keywords ) ? $keywords : ''; 
     651        $customfield = $feed_fields->append( 'text', $fieldname, 'null:null', _t( 'Keywords:', 'podcast' ), 'tabcontrol_text' ); 
     652        $customfield->value = isset( $keywords ) ? $keywords : $post->tags ; 
    443653 
    444654        $fieldname = "summary_{$control_id}"; 
    445         $customfield = $feed_fields->append( 'textarea', $fieldname, 'null:null', _t( 'Summary:' ), 'tabcontrol_textarea' ); 
    446         $customfield->value = isset( $summary ) ? $summary : ''; 
     655        $customfield = $feed_fields->append( 'textarea', $fieldname, 'null:null', _t( 'Summary:', 'podcast' ), 'tabcontrol_textarea' ); 
     656        $customfield->value = isset( $summary) ? $summary : strip_tags(Format::summarize( Format::autop( $post->content ) ) ); 
    447657 
    448658        $fieldname = "block_{$control_id}"; 
    449         $customfield = $feed_fields->append( 'checkbox', $fieldname, 'null:null', _t( 'Summary:' ), 'tabcontrol_checkbox' ); 
     659        $customfield = $feed_fields->append( 'checkbox', $fieldname, 'null:null', _t( 'Block:', 'podcast' ), 'tabcontrol_checkbox' ); 
    450660        $customfield->value = isset( $block ) ? $block : ''; 
    451661    } 
    452662 
    453     protected function get_itunes_settings( $form, $post, $feed ) 
     663    protected function get_post_itunes_settings( $form, $post, $feed ) 
    454664    { 
    455665        $control_id = md5($feed); 
     
    459669 
    460670        $fieldname = "explicit_{$control_id}"; 
    461         $explicit = $form->$fieldname->value; 
     671        $explicit = $this->itunes_explicit[$form->$fieldname->value]; 
    462672 
    463673        $fieldname = "subtitle_{$control_id}";