|
From: Verdon V. <ve...@us...> - 2008-01-06 00:35:11
|
Update of /cvsroot/phpwebsite-comm/modules/podcaster/class In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4231/class Modified Files: PCR_Channel.php PCR_Episode.php PCR_Forms.php Podcaster.php Added Files: PCR_Runtime.php Log Message: getting ready for 1.0.4 and release Index: PCR_Episode.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/podcaster/class/PCR_Episode.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PCR_Episode.php 2 Jan 2008 04:34:55 -0000 1.1 --- PCR_Episode.php 6 Jan 2008 00:34:43 -0000 1.2 *************** *** 37,41 **** var $update_user_id = 0; var $updated_user = null; ! var $approved = 0; var $active = 1; var $_error = null; --- 37,41 ---- var $update_user_id = 0; var $updated_user = null; ! var $approved = 1; var $active = 1; var $_error = null; *************** *** 104,108 **** ! function getChannel($print=false) { if (empty($this->channel_id)) { --- 104,108 ---- ! function getChannel($print=false, $icon=false) { if (empty($this->channel_id)) { *************** *** 113,118 **** PHPWS_Core::initModClass('podcaster', 'PCR_Channel.php'); $channel = new Podcaster_Channel($this->channel_id); ! // return PHPWS_Text::parseOutput($channel->title); ! return PHPWS_Text::rewriteLink($channel->title, 'podcaster', $this->channel_id); } else { return $this->channel_id; --- 113,122 ---- PHPWS_Core::initModClass('podcaster', 'PCR_Channel.php'); $channel = new Podcaster_Channel($this->channel_id); ! if ($icon) { ! $link = '<a href="./index.php?module=podcaster&id=' . $this->channel_id . '&uop=view_rss"><img src="./images/mod/podcaster/rss_sm.png" width="14" height="14" border="0" alt="' . dgettext('podcaster', 'Subscribe RSS') . '" title="' . dgettext('podcaster', 'Subscribe RSS') . '" /></a>'; ! return $link . ' ' . PHPWS_Text::rewriteLink($channel->title, 'podcaster', $this->channel_id); ! } else { ! return PHPWS_Text::rewriteLink($channel->title, 'podcaster', $this->channel_id); ! } } else { return $this->channel_id; *************** *** 327,332 **** $vars2['episode_id'] = $this->id; - // $vars2['uop'] = 'play_episode'; - // $links[] = PHPWS_Text::moduleLink(dgettext('podcaster', 'Play'), 'podcaster', $vars2); $links[] = $this->getMedia(true,false,dgettext('podcaster', 'Play')); --- 331,334 ---- *************** *** 422,426 **** $template['TITLE'] = $this->getTitle(true); $template['DESCRIPTION'] = PHPWS_Text::parseTag($this->getDescription(true)); - // vv $template['IMAGE'] = $this->getImage(true); if (Current_User::allow('podcaster', 'edit_episode')) { --- 424,427 ---- *************** *** 438,442 **** $template['MEDIA'] = $this->getMedia(true,true); $template['EPISODE_LINKS'] = $this->episodeLinks(); - // print_r($this->getMedia()); return PHPWS_Template::process($template, 'podcaster', 'view_episode.tpl'); --- 439,442 ---- Index: Podcaster.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/podcaster/class/Podcaster.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Podcaster.php 2 Jan 2008 04:34:55 -0000 1.1 --- Podcaster.php 6 Jan 2008 00:34:43 -0000 1.2 *************** *** 68,72 **** PHPWS_Core::reroute('index.php?module=podcaster&aop=list'); } else { ! $this->forwardMessage(dgettext('podcaster', 'Channel saved successfully.')); PHPWS_Core::reroute('index.php?module=podcaster&aop=edit_episode&id=' . $this->channel->id); } --- 68,72 ---- PHPWS_Core::reroute('index.php?module=podcaster&aop=list'); } else { ! $this->forwardMessage(dgettext('podcaster', 'Channel saved successfully.') . ' ' . dgettext('podcaster', 'Add an episode below.')); PHPWS_Core::reroute('index.php?module=podcaster&aop=edit_episode&id=' . $this->channel->id); } *************** *** 123,127 **** } else { if (!$this->episode->approved) { ! $this->forwardMessage(dgettext('podcaster', 'Episode submitted successfully.')); } else { $this->forwardMessage(dgettext('podcaster', 'Episode saved successfully.')); --- 123,127 ---- } else { if (!$this->episode->approved) { ! $this->forwardMessage(dgettext('podcaster', 'Episode submitted for approval successfully.')); } else { $this->forwardMessage(dgettext('podcaster', 'Episode saved successfully.')); *************** *** 130,135 **** PHPWS_Core::reroute('index.php?module=podcaster&uop=view_channel&id=' . $this->channel->id); } ! // vv javascript('close_refresh'); ! // vv Layout::nakedDisplay(); } else { $this->loadForm('edit_episode'); --- 130,135 ---- PHPWS_Core::reroute('index.php?module=podcaster&uop=view_channel&id=' . $this->channel->id); } ! // vv huh? javascript('close_refresh'); ! // vv huh? Layout::nakedDisplay(); } else { $this->loadForm('edit_episode'); *************** *** 166,171 **** $this->episode->approved = 1; $this->episode->save(); - // $this->message = dgettext('podcaster', 'Podcaster episode approved.'); - // $this->content = $this->channel->view(); $this->forwardMessage(dgettext('podcaster', 'Podcaster episode approved.')); PHPWS_Core::reroute('index.php?module=podcaster&aop=menu&tab=approvals'); --- 166,169 ---- *************** *** 179,184 **** $this->episode->approved = 0; $this->episode->save(); - // $this->message = dgettext('podcaster', 'Podcaster episode unapproved.'); - // $this->content = $this->channel->view(); $this->forwardMessage(dgettext('podcaster', 'Podcaster episode unapproved.')); PHPWS_Core::reroute('index.php?module=podcaster&aop=menu&tab=approvals'); --- 177,180 ---- *************** *** 197,201 **** if ($this->postSettings()) { $this->forwardMessage(dgettext('podcaster', 'Podcaster settings saved.')); - // $this->loadForm('settings'); PHPWS_Core::reroute('index.php?module=podcaster&aop=menu'); } else { --- 193,196 ---- *************** *** 406,409 **** --- 401,408 ---- 'link'=>$link); } + if (Current_User::allow('podcaster', 'edit_channel') || Current_User::allow('podcaster', 'edit_episode')){ + $tags['info'] = array('title'=>dgettext('podcaster', '? Info'), + 'link'=>$link); + } $this->panel->quickSetTabs($tags); } *************** *** 450,456 **** $this->episode->setApproved(0); } ! } //else { ! // } ! if (isset($errors)) { --- 449,453 ---- $this->episode->setApproved(0); } ! } if (isset($errors)) { *************** *** 517,524 **** --- 514,537 ---- } + $cache_timeout = (int)$_POST['cache_timeout']; + if ((int)$cache_timeout <= 7200) { + PHPWS_Settings::set('podcaster', 'cache_timeout', $cache_timeout); + } else { + PHPWS_Settings::reset('podcaster', 'cache_timeout'); + } + + isset($_POST['show_block']) ? + PHPWS_Settings::set('podcaster', 'show_block', 1) : + PHPWS_Settings::set('podcaster', 'show_block', 0); + isset($_POST['req_approval']) ? PHPWS_Settings::set('podcaster', 'req_approval', 1) : PHPWS_Settings::set('podcaster', 'req_approval', 0); + PHPWS_Settings::set('podcaster', 'block_order_by_rand', $_POST['block_order_by_rand']); + + isset($_POST['block_on_home_only']) ? + PHPWS_Settings::set('podcaster', 'block_on_home_only', 1) : + PHPWS_Settings::set('podcaster', 'block_on_home_only', 0); --- NEW FILE: PCR_Runtime.php --- <?php /** * podcaster - phpwebsite module * * See docs/AUTHORS and docs/COPYRIGHT for relevant info. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * @version $Id $ * @author Verdon Vaillancourt <verdonv at users dot sourceforge dot net> */ class PCR_Runtime { function showBlock() { if (PHPWS_Settings::get('podcaster', 'show_block')) { if (PHPWS_Settings::get('podcaster', 'block_on_home_only')) { $key = Key::getCurrent(); if (!empty($key) && $key->isHomeKey()) { PCR_Runtime::showPodcasterBlock(); } } else { PCR_Runtime::showPodcasterBlock(); } } } function showPodcasterBlock() { $db = new PHPWS_DB('podcaster_episode'); $db->addColumn('id'); $db->addWhere('active', 1); $db->addWhere('approved', 1); if (PHPWS_Settings::get('podcaster', 'block_order_by_rand')) { $db->addOrder('rand'); } else { $db->addOrder('date_created desc'); } $db->setLimit(1); $result = $db->select(); if (!PHPWS_Error::logIfError($result) && !empty($result)) { $tpl['TITLE'] = dgettext('podcaster', 'Podcaster'); if (PHPWS_Settings::get('podcaster', 'block_order_by_rand')) { $tpl['EPISODE_LABEL'] = dgettext('podcaster', 'Random Episode'); } else { $tpl['EPISODE_LABEL'] = dgettext('podcaster', 'Most Recent Episode'); } $tpl['CHANNEL_LABEL'] = dgettext('podcaster', 'From the channel...'); PHPWS_Core::initModClass('podcaster', 'PCR_Episode.php'); $episode = new Podcaster_Episode($result[0]['id']); $tpl['EPISODE_TITLE'] = $episode->viewLink(); $tpl['CHANNEL_TITLE'] = $episode->getChannel(true, true); PHPWS_Core::initModClass('layout', 'Layout.php'); Layout::add(PHPWS_Template::process($tpl, 'podcaster', 'block_home.tpl'), 'podcaster', 'pcr_sidebox'); } } } ?> Index: PCR_Forms.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/podcaster/class/PCR_Forms.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PCR_Forms.php 2 Jan 2008 04:34:55 -0000 1.1 --- PCR_Forms.php 6 Jan 2008 00:34:43 -0000 1.2 *************** *** 62,65 **** --- 62,70 ---- break; + case 'info': + $this->podcaster->panel->setCurrentTab('info'); + $this->showInfo(); + break; + } *************** *** 122,128 **** $tpl['DETAILS_LABEL'] = dgettext('podcaster', 'Details'); $tpl['SETTINGS_LABEL'] = dgettext('podcaster', 'Settings'); - // $vars['aop'] = 'itunes_cats_example'; - // $js['address'] = PHPWS_Text::linkAddress('podcaster', $vars, true); $js['address'] = 'mod/podcaster/inc/itunescatscomplete.txt'; $js['label'] = dgettext('podcaster', 'Complete official list'); --- 127,133 ---- $tpl['DETAILS_LABEL'] = dgettext('podcaster', 'Details'); $tpl['SETTINGS_LABEL'] = dgettext('podcaster', 'Settings'); + $tpl['ITUNES_INFO_LABEL'] = dgettext('podcaster', 'A note on iTunes categories:'); + $tpl['ITUNES_INFO'] = dgettext('podcaster', 'iTunes categories are used to classify your podcasts in the iTunes podcast directory. They are limited and specific. Although it is OK to leave this field empty, choosing the correct categories is good for your feed and may be used by other podcast directories and readers too. I have not polished the interface for choosing iTunes categories yet. It will come in the next version of podcaster. For now, you must carefully enter these yourself when creating a channel. I have provided a few examples in the categories field, and you can click on the link in the channel settings area of an add/edit channel form, to see a complete official list that you can copy and paste from.'); $js['address'] = 'mod/podcaster/inc/itunescatscomplete.txt'; $js['label'] = dgettext('podcaster', 'Complete official list'); *************** *** 176,179 **** --- 181,186 ---- $tpl['INFO_LABEL'] = dgettext('podcaster', 'Information'); $tpl['MEDIA_LABEL'] = dgettext('podcaster', 'Media'); + $tpl['MEDIA_NOTE_LABEL'] = dgettext('podcaster', 'Special Note:'); + $tpl['MEDIA_NOTE'] = dgettext('podcaster', 'In a future version of podcaster, there will be a media "mini-app" embedded in add/edit episode forms, like the image mini-app in the add/edit channel forms. This is dependant on changes coming to filecabinet. Until then, use filecabinet directly to upload your media file into a Multimedia folder, make note of the multimedia_id value there, and then return and enter it here in the episode\'s Media_id field. One way you can find the multimedia_id is to mouse over the "Clip" link for your multimedia file and look in your browser\'s status bar.'); if (Current_User::isUnrestricted('podcaster')) { $tpl['SETTINGS_LABEL'] = dgettext('podcaster', 'Settings'); *************** *** 198,201 **** --- 205,219 ---- $pager->setTemplate('list_channel.tpl'); $pager->addRowTags('rowTag'); + $num = $pager->getTotalRows(); + if ($num == '0') { + if (Current_User::allow('podcaster', 'edit_channel')) { + $vars['aop'] = 'menu'; + $vars['tab'] = 'settings'; + $vars2['aop'] = 'edit_channel'; + $ptags['EMPTY_MESSAGE'] = sprintf(dgettext('podcaster', 'Check your %s then create a %s to begin'), PHPWS_Text::secureLink(dgettext('podcaster', 'Settings'), 'podcaster', $vars), PHPWS_Text::secureLink(dgettext('podcaster', 'New Channel'), 'podcaster', $vars2)); + } else { + $ptags['EMPTY_MESSAGE'] = dgettext('podcaster', 'Sorry, no channels are available at this time.'); + } + } $pager->addPageTags($ptags); $pager->addToggle('class="toggle1"'); *************** *** 257,264 **** $form->setLabel('channel_limit', dgettext('podcaster', 'Show current episodes per channel limit (1-50)')); $form->addCheckbox('req_approval', 1); $form->setMatch('req_approval', PHPWS_Settings::get('podcaster', 'req_approval')); ! $form->setLabel('req_approval', dgettext('podcaster', 'Require approval')); ! $form->addText('editor', PHPWS_Settings::get('podcaster', 'editor')); --- 275,297 ---- $form->setLabel('channel_limit', dgettext('podcaster', 'Show current episodes per channel limit (1-50)')); + $form->addText('cache_timeout', PHPWS_Settings::get('podcaster', 'cache_timeout')); + $form->setSize('cache_timeout', 4, 4); + $form->setLabel('cache_timeout', dgettext('podcaster', 'Cache duration in seconds for rss feed (0-7200, set to 0 to disable cache)')); + + $form->addCheckbox('show_block', 1); + $form->setMatch('show_block', PHPWS_Settings::get('podcaster', 'show_block')); + $form->setLabel('show_block', dgettext('podcaster', 'Show podcaster block')); + + $form->addRadio('block_order_by_rand', array(0, 1)); + $form->setLabel('block_order_by_rand', array(dgettext('podcaster', 'Most recent'), dgettext('podcaster', 'Random'))); + $form->setMatch('block_order_by_rand', PHPWS_Settings::get('podcaster', 'block_order_by_rand')); + + $form->addCheckbox('block_on_home_only', 1); + $form->setMatch('block_on_home_only', PHPWS_Settings::get('podcaster', 'block_on_home_only')); + $form->setLabel('block_on_home_only', dgettext('podcaster', 'Show on home only')); + $form->addCheckbox('req_approval', 1); $form->setMatch('req_approval', PHPWS_Settings::get('podcaster', 'req_approval')); ! $form->setLabel('req_approval', dgettext('podcaster', 'Require approval for new episodes')); $form->addText('editor', PHPWS_Settings::get('podcaster', 'editor')); *************** *** 302,305 **** --- 335,356 ---- + function showInfo() + { + + $tpl['TITLE'] = dgettext('podcaster', 'Important Information'); + $tpl['INFO_1_LABEL'] = dgettext('podcaster', 'A note on this module:'); + $tpl['INFO_1'] = dgettext('podcaster', 'This is the first rewriting of podcaster for the new 1.x series phpwebsite. Although I believe it to be pretty stable, there are still a few things that should be pointed out. There are a couple rough edges and a feature that is waiting for planned core filecabinet updates. I will release updated podcaster versions as they are available. Updating will be easy for the end user.'); + $tpl['INFO_2_LABEL'] = dgettext('podcaster', 'A note on media files:'); + $tpl['INFO_2'] = dgettext('podcaster', 'In a future version of podcaster, there will be a media "mini-app" embedded in add/edit episode forms, like the image mini-app in the add/edit channel forms. This is dependant on changes coming to filecabinet. Until then, use filecabinet directly to upload your media file into a Multimedia folder, make note of the multimedia_id value there, and then return and enter it here in the episode\'s Media_id field. One way you can find the multimedia_id is to mouse over the "Clip" link for your multimedia file and look in your browser\'s status bar.'); + $tpl['INFO_3_LABEL'] = dgettext('podcaster', 'A note on iTunes categories:'); + $tpl['INFO_3'] = dgettext('podcaster', 'iTunes categories are used to classify your podcasts in the iTunes podcast directory. They are limited and specific. Although it is OK to leave this field empty, choosing the correct categories is good for your feed and may be used by other podcast directories and readers too. I have not polished the interface for choosing iTunes categories yet. It will come in the next version of podcaster. For now, you must carefully enter these yourself when creating a channel. I have provided a few examples in the categories field, and you can click on the link in the channel settings area of an add/edit channel form, to see a complete official list that you can copy and paste from.'); + $tpl['INFO_4_LABEL'] = dgettext('podcaster', 'A note on permissons:'); + $tpl['INFO_4'] = dgettext('podcaster', 'Honestly, I\'m still working on understanding the new system completely. I\'ve done a basic security audit and although I am sure there is no gross holes, I\'m sure I may have something wrong too ;-) I wanted to get this rewrite out asap and will do a more thorough permissioning review for the next podcaster release.'); + + $this->podcaster->title = dgettext('podcaster', '? Info'); + $this->podcaster->content = PHPWS_Template::process($tpl, 'podcaster', 'info.tpl'); + } + + } Index: PCR_Channel.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/podcaster/class/PCR_Channel.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PCR_Channel.php 2 Jan 2008 04:34:55 -0000 1.1 --- PCR_Channel.php 6 Jan 2008 00:34:43 -0000 1.2 *************** *** 176,180 **** return $image; } - // return $image->getTag(); } --- 176,179 ---- *************** *** 238,243 **** } ! //PRINT_R($this->loadFeeds()); ! /* not sure if I need the key stuff */ $key = new Key($this->key_id); --- 237,241 ---- } ! /* not sure if I need the key stuff */ $key = new Key($this->key_id); *************** *** 245,253 **** Current_User::requireLogin(); } ! //$home_http = PHPWS_Core::getHomeHttp(); ! //$image = $this->getImage(); ! //$path = $home_http.$image->file_directory.$image->file_name; ! //echo $path; ! ///print_r($image); Layout::addPageTitle($this->getTitle()); $template['TITLE'] = $this->getTitle(true); --- 243,247 ---- Current_User::requireLogin(); } ! Layout::addPageTitle($this->getTitle()); $template['TITLE'] = $this->getTitle(true); *************** *** 315,322 **** PHPWS_Core::initModClass('podcaster', 'PCR_Episode.php'); $result = $db->getObjects('Podcaster_Episode'); ! foreach ($result as $episode) { ! $media = $episode->getMedia(); ! if ($media) { ! $media->delete(); } } --- 309,318 ---- PHPWS_Core::initModClass('podcaster', 'PCR_Episode.php'); $result = $db->getObjects('Podcaster_Episode'); ! if ($result) { ! foreach ($result as $episode) { ! $media = $episode->getMedia(); ! if ($media) { ! $media->delete(); ! } } } *************** *** 354,358 **** $vars2['uop'] = 'view_rss'; - // $links[] = PHPWS_Text::moduleLink(dgettext('podcaster', 'Subscribe RSS'), 'podcaster', $vars2); $links[] = '<a href="./index.php?module=podcaster&id=' . $this->id . '&uop=view_rss"><img src="./images/mod/podcaster/rss.gif" width="80" height="15" border="0" alt="' . dgettext('podcaster', 'Subscribe RSS') . '" title="' . dgettext('podcaster', 'Subscribe RSS') . '" /></a>'; --- 350,353 ---- *************** *** 404,408 **** $vars2['uop'] = 'view_rss'; - // $links[] = PHPWS_Text::moduleLink(dgettext('podcaster', 'Subscribe RSS'), 'podcaster', $vars2); $links[] = '<a href="./index.php?module=podcaster&id=' . $this->id . '&uop=view_rss"><img src="./images/mod/podcaster/rss.gif" width="80" height="15" border="0" alt="' . dgettext('podcaster', 'Subscribe RSS') . '" title="' . dgettext('podcaster', 'Subscribe RSS') . '" /></a>'; --- 399,402 ---- *************** *** 542,550 **** function viewRSS() { - // $cache_key = 'pcrchannel_'. $this->id .'_cache_key'; - // $content = PHPWS_Cache::get($cache_key); ! if (!empty($content)) { ! return $content; } --- 536,546 ---- function viewRSS() { ! if (PHPWS_Settings::get('podcaster', 'cache_timeout') > 0) { ! $cache_key = 'pcrchannel_'. $this->id .'_cache_key'; ! $content = PHPWS_Cache::get($cache_key, PHPWS_Settings::get('podcaster', 'cache_timeout')); ! if (!empty($content)) { ! return $content; ! } } *************** *** 599,603 **** $content = PHPWS_Template::process($template, 'podcaster', 'view_rss.tpl'); ! // PHPWS_Cache::save($cache_key, $content, PCR_CACHE_TIMEOUT); return $content; } --- 595,601 ---- $content = PHPWS_Template::process($template, 'podcaster', 'view_rss.tpl'); ! if (PHPWS_Settings::get('podcaster', 'cache_timeout') > 0) { ! PHPWS_Cache::save($cache_key, $content); ! } return $content; } |