|
From: Verdon V. <ve...@us...> - 2008-01-09 21:41:50
|
Update of /cvsroot/phpwebsite-comm/modules/podcaster/class In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17620/class Modified Files: PCR_Channel.php PCR_Forms.php Podcaster.php Added Files: PCR_Category.php Log Message: getting ready for 1.0.5 itunes cats changes --- NEW FILE: PCR_Category.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 Podcaster_Category { var $id = 0; var $title = null; var $parent_id = 0; var $_error = null; function Podcaster_Category($id=0) { if (!$id) { return; } $this->id = (int)$id; $this->init(); } function init() { $db = new PHPWS_DB('podcaster_category'); $result = $db->loadObject($this); if (PEAR::isError($result)) { $this->_error = & $result; $this->id = 0; } elseif (!$result) { $this->id = 0; } } function setTitle($title) { $this->title = strip_tags($title); } function setParent_id($parent_id) { $this->parent_id = $parent_id; } function getTitle($print=false) { if (empty($this->title)) { return null; } if ($print) { return PHPWS_Text::parseOutput($this->title); } else { return $this->title; } } function view() { if (!$this->id) { PHPWS_Core::errorPage(404); } $template['TITLE'] = $this->getTitle(true); $template['PARENT'] = $this->getParent(true); return PHPWS_Template::process($template, 'podcaster', 'view_category.tpl'); } function delete() { if (!$this->id) { return; } $db = new PHPWS_DB('podcaster_category'); $db->addWhere('id', $this->id); PHPWS_Error::logIfError($db->delete()); PHPWS_Error::logIfError($db->delete()); } function rowTag() { $vars['id'] = $this->id; $vars2['id'] = $this->id; $vars2['uop'] = 'view_rss'; $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>'; if (Current_User::allow('podcaster', 'edit_episode')){ $vars['aop'] = 'new_episode'; $links[] = PHPWS_Text::secureLink(dgettext('podcaster', 'New Episode'), 'podcaster', $vars); } if (Current_User::allow('podcaster', 'edit_channel')){ $vars['aop'] = 'edit_channel'; $links[] = PHPWS_Text::secureLink(dgettext('podcaster', 'Edit'), 'podcaster', $vars); } if (Current_User::isUnrestricted('podcaster')) { if ($this->active) { $vars['aop'] = 'deactivate_channel'; $active = PHPWS_Text::secureLink(dgettext('podcaster', 'Deactivate'), 'podcaster', $vars); } else { $vars['aop'] = 'activate_channel'; $active = PHPWS_Text::secureLink(dgettext('podcaster', 'Activate'), 'podcaster', $vars); } $links[] = $active; } else { if (Current_User::allow('podcaster')) $links[] = $this->active ? dgettext('podcaster', 'Active') : dgettext('podcaster', 'Not Active'); } if (Current_User::allow('podcaster', 'delete_channel')){ $vars['aop'] = 'delete_channel'; $js['ADDRESS'] = PHPWS_Text::linkAddress('podcaster', $vars, true); $js['QUESTION'] = sprintf(dgettext('podcaster', 'Are you sure you want to delete the channel %s?\nAll related episodes and channel information will be permanently removed.'), $this->getTitle()); $js['LINK'] = dgettext('podcaster', 'Delete'); $links[] = javascript('confirm', $js); } $tpl['TITLE'] = $this->viewLink(); $tpl['DATE_UPDATED'] = $this->getDateUpdated(); $tpl['DESCRIPTION'] = $this->getListDescription(120); if($links) $tpl['ACTION'] = implode(' | ', $links); return $tpl; } function save() { $db = new PHPWS_DB('podcaster_category'); $result = $db->saveObject($this); if (PEAR::isError($result)) { return $result; } } } ?> Index: Podcaster.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/podcaster/class/Podcaster.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Podcaster.php 6 Jan 2008 04:29:39 -0000 1.3 --- Podcaster.php 9 Jan 2008 21:41:12 -0000 1.4 *************** *** 485,488 **** --- 485,490 ---- if (isset($_POST['itunes_category'])) { $this->channel->setItunes_category($_POST['itunes_category']); + } else { + $this->channel->setItunes_category(0); } Index: PCR_Forms.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/podcaster/class/PCR_Forms.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PCR_Forms.php 7 Jan 2008 03:41:54 -0000 1.4 --- PCR_Forms.php 9 Jan 2008 21:41:12 -0000 1.5 *************** *** 118,126 **** $form->setMatch('itunes_explicit', $channel->getItunes_explicit()); ! $form->addTextArea('itunes_category', $channel->getItunes_category()); ! $form->setRows('itunes_category', '10'); ! $form->setCols('itunes_category', '50'); ! $form->setLabel('itunes_category', dgettext('podcaster', 'iTunes Category(s)')); $tpl = $form->getTemplate(); --- 118,137 ---- $form->setMatch('itunes_explicit', $channel->getItunes_explicit()); ! PHPWS_Core::initModClass('podcaster', 'PCR_Category.php'); ! $db = new PHPWS_DB('podcaster_category'); ! $db->addOrder('id asc'); ! $result = $db->getObjects('Podcaster_Category'); ! foreach ($result as $cat) { ! if ($cat->parent_id > 0) { ! $iTunesCats[$cat->id] = ' - ' . $cat->title; ! } else { ! $iTunesCats[$cat->id] = $cat->title; ! } ! } + $catsMatch = $channel->itunes_category; + $form->addMultiple('itunes_category', $iTunesCats); + $form->setLabel('itunes_category', dgettext('podcaster', 'iTunes Category(s)')); + $form->setMatch('itunes_category', $catsMatch); $tpl = $form->getTemplate(); *************** *** 128,138 **** $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'); ! $js['width'] = 500; ! $js['height'] = 400; ! $tpl['ITUNES_CATEGORY_EXAMPLE'] = javascript('open_window', $js); $this->podcaster->content = PHPWS_Template::process($tpl, 'podcaster', 'edit_channel.tpl'); --- 139,143 ---- $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.'); $this->podcaster->content = PHPWS_Template::process($tpl, 'podcaster', 'edit_channel.tpl'); *************** *** 343,348 **** $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.'); --- 348,355 ---- $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_3_LABEL'] = null; ! $tpl['INFO_3'] = null; $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.'); Index: PCR_Channel.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/podcaster/class/PCR_Channel.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PCR_Channel.php 6 Jan 2008 00:34:43 -0000 1.2 --- PCR_Channel.php 9 Jan 2008 21:41:12 -0000 1.3 *************** *** 99,103 **** function setItunes_category($itunes_category) { ! $this->itunes_category = PHPWS_Text::parseInput($itunes_category); } --- 99,103 ---- function setItunes_category($itunes_category) { ! $this->itunes_category = serialize($itunes_category); } *************** *** 211,221 **** { if (empty($this->itunes_category)) { ! // return null; ! $example = file_get_contents(PHPWS_SOURCE_DIR . 'mod/podcaster/inc/itunescats.txt'); ! return htmlspecialchars($example); } if ($print) { ! return PHPWS_Text::parseOutput($this->itunes_category); } else { return $this->itunes_category; --- 211,232 ---- { if (empty($this->itunes_category)) { ! return null; } if ($print) { ! PHPWS_Core::initModClass('podcaster', 'PCR_Category.php'); ! $cats = NULL; ! foreach ($this->itunes_category as $cat_id) { ! $cat = new Podcaster_Category($cat_id); ! if ($cat->parent_id > 0) { ! $parent = new Podcaster_Category($cat->parent_id); ! $cats .= '<itunes:category text="' . htmlentities($parent->getTitle()) . '">' . "\n"; ! $cats .= '<itunes:category text="' . htmlentities($cat->getTitle()) . '" />' . "\n"; ! $cats .= '</itunes:category>' . "\n"; ! } else { ! $cats .= '<itunes:category text="' . htmlentities($cat->getTitle()) . '" />' . "\n"; ! } ! } ! return $cats; } else { return $this->itunes_category; *************** *** 224,234 **** - function getItunes_cat_examples() - { - $example = file_get_contents(PHPWS_SOURCE_DIR . 'mod/podcaster/inc/itunescatscomplete.txt'); - return htmlspecialchars($example); - } - - function view() { --- 235,238 ---- *************** *** 569,573 **** $template['LAST_BUILD_DATE'] = gmstrftime('%a, %d %b %Y %R GMT', mktime()); $template['ITUNES_EXPLICIT'] = $this->getItunes_explicit(true); ! $template['ITUNES_CATEGORY'] = htmlspecialchars_decode($this->getItunes_category(false)); if ($this->_feeds) { --- 573,577 ---- $template['LAST_BUILD_DATE'] = gmstrftime('%a, %d %b %Y %R GMT', mktime()); $template['ITUNES_EXPLICIT'] = $this->getItunes_explicit(true); ! $template['ITUNES_CATEGORY'] = $this->getItunes_category(true); if ($this->_feeds) { |