Jump to content

iwato

Members
  • Posts

    1,506
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by iwato

  1. Hi Ingolme, If there were no <link> subelement for the <channel> element I could easily agree. If, however, the media file -- in my case, a podcast -- is well presented and can stand alone, the <link> subelement of the <item> element would appear unnecessary. What I currently have under consideration is a single webpage that achieves two tasks: several methods of categorization and access for each posted podcast. One method of categorization would be for the chronological order in which the podcasts appear. Two to three additional categories would be created for different methods of categorizing the same content. From each of these categories one could call up any of the podcasts in the same webpage -- say, with an iframe, include, or the like that contains a link to the podcast along with additional reference materials, a brief explanation of the podcast, and a forever changing image that would host an advertisement. In addition to my own feed I plan to create other feeds for other podcast hosts. As these other hosts generally permit images, I will include a link with each image to my own webpage. When the link is clicked the aforementioned insert containing the desired podcast would automatically appear. Although all RSS feeds require certain information some RSS feeds have their own namespace with a variety of optional elements -- the iTunes namespace, for example, as its own set of required elements. In effect, I envision three different <link> elements: 1) <link> (channel) - Points to the webpage. 2) <link> (item) - Points to the webpage and calls up the insert. 3) <link> (image) - Points to the webpage, or points to the webpage and calls up the insert. My concern, of course, is how to achieve the action "points to the webpage AND calls up the insert". How would the link be designed? Could I append a hash tag to the link that points to the website, for example. Roddy
  2. I am confused about the use of the <link> and <enclosure> subelements of the <item> subelement. The difference between the <link> subelements of the <channel> and <item> elements appears clear, but the difference between the <link> and <enclosure> subelements of the <item> subelement are difficult to understand. For example, if your RSS feed contained a long series of <item> subelements with each referring to a different podcast, why would you need both a <link> and <enclosure> for the same <item> subelement. <channel> <link></link> <item> <link></link> <enclosure></enclosure> </item> </channel>
  3. iwato

    RSS Information

    Where is the wonderful RSS Tutorial? Roddy
  4. Is this what you are trying to do? a = (-1) * ycoord * Math.sin(degree) b = (-1) * xcoord * Math.cos(degree) c = (-1) * xcoord d = a + b + c smoother * Math.pow(d, tipAdjuster) Certainly it does not match f(x).
  5. JSG: I see your point ..., but I disagree with this: According to the indication for the .on( ) method for which the .mousedown( ) is just a shortcut, the value of eventData can be anything. Only after it is entered must it be retrieved as a property of the event object. In effect, it appears to be still available for use within the event handler; simply it must be accessed via the event.data object.
  6. Yes, the following works: var mil = function(min, sec) { var millisec = ((min * 60) + sec) * 1000; return millisec; } $('#item_encllength').on('mousedown',function() { $(this).val(mil($('#min').val(), $('#sec').val())); }); and more simply, var mil = function(min, sec) { var millisec = ((min * 60) + sec) * 1000; return millisec; } $('#item_encllength').mousedown(function() { $(this).val(mil($('#min').val(), $('#sec').val())); }); Thank you everyone for your kind support. Problem resolved. Hooray, hooray!
  7. I realized this as well, when I performed an alert on the value of mil. Rather, than a number I received a functional expression. So, I tried the following, but to no avail: $('#item_encllength').on('mousedown',mil(),function() { $(this).val(mil); }); Have I confused PHP's variable function with Javascript, still again? Woe is me.
  8. Please delete this post, as it contains no new information.
  9. The Scientist: Casting does not help. I tried casting to parseFloat( ) as well. According to jQuery the .val( ) function reads numbers. According to the Mozilla Developer website the value generated by the <input type='number'> is a numerical float. It does seem to be here where the code fails, however. var mil = function(min, sec) { var millisec = ((min * 60) + sec) * 1000; return millisec; } And, I have no idea why.
  10. Further exploration has shown that the calculation is not properly consummated, and that depending on the input type I can obtain either 0 or NaN for the value of mil. Any suggestions?
  11. Ingolme: If all that I must do is set the value of the input form control, then what is likely causing the following code to fail? $(document).ready(function() { var min = $('#min').val(); var sec = $('#sec').val(); var mil = function(min, sec) { var millisec = ((min * 60) + sec) * 1000; return millisec; } $('#item_encllength').mousedown(mil, function() { $(this).val(mil); }); }); Roddy
  12. JSG: How will this make the value of mil appear in the field of the visible input control field? Are you suggesting that it will automatically appear by changing the CSS of the control field from hidden to visible? I don't get it. Is there not some way to select the text field of the #item_encllength and simply change its value from empty to mil?
  13. QUESTION ONE: Please suggest what might be entered where the three ? marks appear in order to achieve the following goal. THE GOAL: See appear the value of mil in the input control text field and have this value become the value of $_POST['item_encllength'] when the form is submitted. var min = $('#min').val(); var sec = $('#sec').val(); var mil = function(min, sec) { var millisec = ((min * 60) + sec) * 1000; return millisec; } $('#item_encllength').mousedown(mil, function() { $(this).???; }); <input id='min' type='number' value='Minutes'> <input id='sec' type='number' value='Seconds'> <input id='item_encllength' form='rss2_feed' type='text' name='item_encllength'> I have experimented in a variety of ways, but have not been able to find the code necessary to achieve my goal. Perhaps my approach to the problem is inappropriate. Roddy
  14. Oops! I thought someone would know this, so that I could avoid the experimentation. Roddy
  15. The method is there. Simply I left it out, so as not to cause unnecessary clutter. Maybe I have misunderstood the use of the constructor function. Until now I was under the impression that once the values of a constructor function's parameters are assigned to the declared properties via the $this->declared_property mechanism, they can be readily accessed in other methods of the class simply by inserting their respective variable names. By way of example consider the following line of code taken from the create_feed( ) method. $xml .= '<title>' . $this->channel_properties["title"] . '</title>' . "\n"; Had the property $channel_properties been properly declared at the outset of the class definition, then its elements and their respective values could have been directly accessed from within the create_feed( ) and other class methods without having to make use of the pseudo $this variable and the arrow operator? In other words, rather than writing the above the author could simply have written $xml .= '<title>' . $channel_properties["title"] . '</title>' . "\n"; Am I in error in this regard? Roddy
  16. Thank you for your continued clarification. Now, had the properties been declared, as you have just done, would it have been necessary for the author to use the arrow operator in the second function as well? I am referring in particular to the function called create_feed( ). As I mentioned in my original post, it appears to me that by not declaring the variables at the beginning of the class, the author has compelled an inordinate use of the arrow operator. Is this not true? Or, have I misunderstood? Roddy
  17. I regret not having asked this question sooner, but when you do not know anything, you have to begin by believing in something. Then, try it out, and see if it works. The DOMDocument class does appear to be a good deal more solid, and I will certainly make use of it in the future. Already I have included it in my notes. For the moment I do not have time to familiarize myself with an entirely new PHP class, and would be very happy, if I could simply improve upon what I already know within the indicated class. I do not wish to be a bad student, but need to begin earning money quickly, else there will be nothing to support my further study and implementation. I am dangling on a financial thread that is wearing down both my spirit and health. Please be understanding. Returning to the original question, however, I agree that the author has listed the function's parameters, and we appear to agree that he should have first declared these parameters as class properties. What then would have been the proper way to reference the properties' values in the appended strings to the $xml variable? Roddy
  18. BACKGROUND: Please find below a portion of a PHP class used to create an RSS feed. Included are only the constructor function and the function used to create the actual document. All other functions have been omitted so as to focus on the question at hand. My reason for posting this code is to better understand the proper way to create a class. As you can readily see from the __construct( ) function of this class each new instance of the class requires six parameter values. Although the author lists these parameters at the beginning of the class definition, he comments them out, rather than initializing them. QUESTION: Is this standard practice? What is to be gained by not declaring them outside of the __construct( ) function? It appears to create an unnecessary repetitious use of the pseudo $this variable. <?php /** * rss_feed (simple rss 2.0 feed creator php class) * * @author Christos Pontikis http://pontikis.net * @copyright Christos Pontikis * @license MIT http://opensource.org/licenses/MIT * @version 0.1.0 (28 July 2013) * */ class rss_feed { /** * Constructor * * @param array $a_db database settings * @param string $xmlns XML namespace * @param array $a_channel channel properties * @param string $site_url the URL of your site * @param string $site_name the name of your site * @param bool $full_feed flag for full feed (all topic content) */ public function __construct($a_db, $xmlns, $a_channel, $site_url, $site_name, $full_feed = false) { // initialize $this->db_settings = $a_db; $this->xmlns = ($xmlns ? ' ' . $xmlns : ''); $this->channel_properties = $a_channel; $this->site_url = $site_url; $this->site_name = $site_name; $this->full_feed = $full_feed; } /** * Generate RSS 2.0 feed * * @return string RSS 2.0 xml */ public function create_feed() { $xml = '<?xml version="1.0" encoding="utf-8"?>' . "\n"; $xml .= '<rss version="2.0"' . $this->xmlns . '>' . "\n"; // channel required properties $xml .= '<channel>' . "\n"; $xml .= '<title>' . $this->channel_properties["title"] . '</title>' . "\n"; $xml .= '<link>' . $this->channel_properties["link"] . '</link>' . "\n"; $xml .= '<description>' . $this->channel_properties["description"] . '</description>' . "\n"; // channel optional properties if(array_key_exists("language", $this->channel_properties)) { $xml .= '<language>' . $this->channel_properties["language"] . '</language>' . "\n"; } if(array_key_exists("image_title", $this->channel_properties)) { $xml .= '<image>' . "\n"; $xml .= '<title>' . $this->channel_properties["image_title"] . '</title>' . "\n"; $xml .= '<link>' . $this->channel_properties["image_link"] . '</link>' . "\n"; $xml .= '<url>' . $this->channel_properties["image_url"] . '</url>' . "\n"; $xml .= '</image>' . "\n"; } // get RSS channel items $now = date("YmdHis"); // get current time // configure appropriately to your environment $rss_items = $this->get_feed_items($now); foreach($rss_items as $rss_item) { $xml .= '<item>' . "\n"; $xml .= '<title>' . $rss_item['title'] . '</title>' . "\n"; $xml .= '<link>' . $rss_item['link'] . '</link>' . "\n"; $xml .= '<description>' . $rss_item['description'] . '</description>' . "\n"; $xml .= '<pubDate>' . $rss_item['pubDate'] . '</pubDate>' . "\n"; $xml .= '<category>' . $rss_item['category'] . '</category>' . "\n"; $xml .= '<source>' . $rss_item['source'] . '</source>' . "\n"; if($this->full_feed) { $xml .= '<content:encoded>' . $rss_item['content'] . '</content:encoded>' . "\n"; } $xml .= '</item>' . "\n"; } $xml .= '</channel>'; $xml .= '</rss>'; return $xml; } } ?>
  19. Got it. Thanks for the introduction to Zend_Db. Something to investigate further on.
  20. OK. I would like to thank you for your help. I believe that I understand enough now to know where to take up the problem again once I have completed the RSS feed. By the way, I just learned from my host server that Apache is the webserver application employed, but that PHP files are parsed using suPHP rather than PHP. I suppose that this is also fairly common for servers who host a large number of accounts with everyone wanting control of his or her own ability to script in PHP. Have a great evening! Roddy
  21. I work with PHP and MySQL. Would it be better to approach the problem from the PHP side using MySQLi or from the SQL side? I am more comfortable with PHP, but am learning how to write SQL statements as I go along. Roddy
  22. I recently downloaded the following PHP include and discovered an entire method of coding that I do not understand. Could someone please explain the use of the following, for me non-standard, characters in this document: - + @@ ... @@ Is this a way of designating the codes of different versions within the same script? Is it functional or is it comment? How does it work? --- feedcreator.class.php Mon Oct 11 20:12:36 2004 +++ feedcreator-ppt.class.php Mon Nov 21 18:58:50 2005 @@ -1,12 +1,14 @@ <?php /*************************************************************************** -FeedCreator class v1.7.2 +FeedCreator class v1.7.2-ppt originally (c) Kai Blankenhorn www.bitfolge.de kaib@bitfolge.de v1.3 work by Scott Reynen (scott@randomchaos.com) and Kai Blankenhorn v1.5 OPML support by Dirk Clemens +v1.7.2-mod on-the-fly feed generation by Fabian Wolf (info@f2w.de) +v1.7.2-ppt ATOM 1.0 support by Mohammad Hafiz bin Ismail (mypapit@gmail.com) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -27,6 +29,14 @@ Changelog: +v1.7.2-ppt 11-21-05 + added Atom 1.0 support + added enclosure support for RSS 2.0/ATOM 1.0 + added docs for v1.7.2-ppt only! + +v1.7.2-mod 03-12-05 + added output function outputFeed for on-the-fly feed generation + v1.7.2 10-11-04 license changed to LGPL @@ -138,6 +148,14 @@ //optional item->descriptionTruncSize = 500; item->descriptionHtmlSyndicated = true; + + //optional (enclosure) + $item->enclosure = new EnclosureItem(); + $item->enclosure->url='http://http://www.dailyphp.net/media/voice.mp3'; + $item->enclosure->length="950230"; + $item->enclosure->type='audio/x-mpeg' + + $item->date = $data->newsdate; $item->source = "http://www.dailyphp.net"; @@ -147,9 +165,12 @@ } // valid format strings are: RSS0.91, RSS1.0, RSS2.0, PIE0.1 (deprecated), -// MBOX, OPML, ATOM, ATOM0.3, HTML, JS +// MBOX, OPML, ATOM, ATOM10, ATOM0.3, HTML, JS echo $rss->saveFeed("RSS1.0", "news/feed.xml"); +//to generate "on-the-fly" +$rss->outputFeed("RSS1.0"); + *************************************************************************** * A little setup * @@ -164,7 +185,8 @@ /** * Version string. **/ -define("FEEDCREATOR_VERSION", "FeedCreator 1.7.2"); + +define("FEEDCREATOR_VERSION", "FeedCreator 1.7.2-ppt (info@mypapit.net)"); @@ -201,6 +223,17 @@ var $date; /** + * Add <enclosure> element tag RSS 2.0 + * modified by : Mohammad Hafiz bin Ismail (mypapit@gmail.com) + * + * + * display : + * <enclosure length="17691" url="http://something.com/picture.jpg" type="image/jpeg" /> + * + */ + var $enclosure; + + /** * Any additional elements to include as an assiciated array. All $key => $value pairs * will be included unencoded in the feed item in the form * <$key>$value</$key> @@ -214,6 +247,26 @@ // var $source; } +class EnclosureItem extends HtmlDescribable { + /* + * + * core variables + * + **/ + var $url,$length,$type; + + /* + * For use with another extension like Yahoo mRSS + * Warning : + * These variables might not show up in + * later release / not finalize yet! + * + */ + var $width, $height, $title, $description, $keywords, $thumburl; + + var $additionalElements = Array(); + +} /** @@ -265,6 +318,7 @@ } + /** * An FeedHtmlField describes and generates * a feed, item or image html field (probably a description). Output is @@ -333,6 +387,63 @@ class UniversalFeedCreator extends FeedCreator { var $_feed; + function _setMIME($format) { + switch (strtoupper($format)) { + + case "2.0": + // fall through + case "RSS2.0": + header('Content-type: text/xml', true); + break; + + case "1.0": + // fall through + case "RSS1.0": + header('Content-type: text/xml', true); + break; + + case "PIE0.1": + header('Content-type: text/xml', true); + break; + + case "MBOX": + header('Content-type: text/plain', true); + break; + + case "OPML": + header('Content-type: text/xml', true); + break; + + case "ATOM": + // fall through: always the latest ATOM version + case "ATOM1.0": + header('Content-type: application/xml', true); + break; + + case "ATOM0.3": + header('Content-type: application/xml', true); + break; + + + case "HTML": + header('Content-type: text/html', true); + break; + + case "JS": + // fall through + case "JAVASCRIPT": + header('Content-type: text/javascript', true); + break; + + default: + case "0.91": + // fall through + case "RSS0.91": + header('Content-type: text/xml', true); + break; + } + } + function _setFormat($format) { switch (strtoupper($format)) { @@ -368,11 +479,15 @@ case "ATOM": // fall through: always the latest ATOM version + case "ATOM1.0": + $this->_feed = new AtomCreator10(); + break; + case "ATOM0.3": $this->_feed = new AtomCreator03(); break; - + case "HTML": $this->_feed = new HTMLCreator(); break; @@ -445,6 +560,20 @@ $this->_feed->useCached($filename, $timeout); } + + /** + * Outputs feed to the browser - needed for on-the-fly feed generation (like it is done in WordPress, etc.) + * + * @param format string format the feed should comply to. Valid values are: + * "PIE0.1" (deprecated), "mbox", "RSS0.91", "RSS1.0", "RSS2.0", "OPML", "ATOM0.3". + */ + function outputFeed($format='RSS0.91') { + $this->_setFormat($format); + $this->_setMIME($format); + $this->_feed->outputFeed(); + } + + } @@ -692,6 +821,17 @@ echo "<br /><b>Error creating feed file, please check write permissions.</b><br />"; } } + + /** + * Outputs this feed directly to the browser - for on-the-fly feed generation + * @since 1.7.2-mod + * + * still missing: proper header output - currently you have to add it manually + */ + function outputFeed() { + echo $this->createFeed(); + } + } @@ -711,7 +851,7 @@ function FeedDate($dateString="") { if ($dateString=="") $dateString = date("r"); - if (is_integer($dateString)) { + if (is_numeric($dateString)) { $this->unix = $dateString; return; } @@ -770,7 +910,7 @@ /** * Gets the date stored in this FeedDate as an ISO 8601 date. * - * @return a date in ISO 8601 format + * @return a date in ISO 8601 (RFC 3339) format */ function iso8601() { $date = gmdate("Y-m-d\TH:i:sO",$this->unix); @@ -779,6 +919,7 @@ return $date; } + /** * Gets the date stored in this FeedDate as unix time stamp. * @@ -997,8 +1138,23 @@ $feed.= " <guid>".htmlspecialchars($this->items[$i]->guid)."</guid>\n"; } $feed.= $this->_createAdditionalElements($this->items[$i]->additionalElements, " "); + + if ($this->RSSVersion == "2.0" && $this->items[$i]->enclosure != NULL) + { + $feed.= " <enclosure url=\""; + $feed.= $this->items[$i]->enclosure->url; + $feed.= "\" length=\""; + $feed.= $this->items[$i]->enclosure->length; + $feed.= "\" type=\""; + $feed.= $this->items[$i]->enclosure->type; + $feed.= "\"/>\n"; + } + + + $feed.= " </item>\n"; } + $feed.= " </channel>\n"; $feed.= "</rss>\n"; return $feed; @@ -1072,7 +1228,88 @@ } } +/** + * AtomCreator10 is a FeedCreator that implements the atom specification, + * as in http://www.atomenabled.org/developers/syndication/atom-format-spec.php + * Please note that just by using AtomCreator10 you won't automatically + * produce valid atom files. For example, you have to specify either an editor + * for the feed or an author for every single feed item. + * + * Some elements have not been implemented yet. These are (incomplete list): + * author URL, item author's email and URL, item contents, alternate links, + * other link content types than text/html. Some of them may be created with + * AtomCreator10::additionalElements. + * + * @see FeedCreator#additionalElements + * @since 1.7.2-mod (modified) + * @author Mohammad Hafiz Ismail (mypapit@gmail.com) + */ + class AtomCreator10 extends FeedCreator { + + function AtomCreator10() { + $this->contentType = "application/atom+xml"; + $this->encoding = "utf-8"; + } + + function createFeed() { + $feed = "<?xml version=\"1.0\" encoding=\"".$this->encoding."\"?>\n"; + $feed.= $this->_createGeneratorComment(); + $feed.= $this->_createStylesheetReferences(); + $feed.= "<feed xmlns=\"http://www.w3.org/2005/Atom\""; + if ($this->language!="") { + $feed.= " xml:lang=\"".$this->language."\""; + } + $feed.= ">\n"; + $feed.= " <title>".htmlspecialchars($this->title)."</title>\n"; + $feed.= " <subtitle>".htmlspecialchars($this->description)."</subtitle>\n"; + $feed.= " <link rel=\"alternate\" type=\"text/html\" href=\"".htmlspecialchars($this->link)."\"/>\n"; + $feed.= " <id>".htmlspecialchars($this->link)."</id>\n"; + $now = new FeedDate(); + $feed.= " <updated>".htmlspecialchars($now->iso8601())."</updated>\n"; + if ($this->editor!="") { + $feed.= " <author>\n"; + $feed.= " <name>".$this->editor."</name>\n"; + if ($this->editorEmail!="") { + $feed.= " <email>".$this->editorEmail."</email>\n"; + } + $feed.= " </author>\n"; + } + $feed.= " <generator>".FEEDCREATOR_VERSION."</generator>\n"; + $feed.= "<link rel=\"self\" type=\"application/atom+xml\" href=\"". $this->syndicationURL . "\" />\n"; + $feed.= $this->_createAdditionalElements($this->additionalElements, " "); + for ($i=0;$i<count($this->items);$i++) { + $feed.= " <entry>\n"; + $feed.= " <title>".htmlspecialchars(strip_tags($this->items[$i]->title))."</title>\n"; + $feed.= " <link rel=\"alternate\" type=\"text/html\" href=\"".htmlspecialchars($this->items[$i]->link)."\"/>\n"; + if ($this->items[$i]->date=="") { + $this->items[$i]->date = time(); + } + $itemDate = new FeedDate($this->items[$i]->date); + $feed.= " <published>".htmlspecialchars($itemDate->iso8601())."</published>\n"; + $feed.= " <updated>".htmlspecialchars($itemDate->iso8601())."</updated>\n"; + $feed.= " <id>".htmlspecialchars($this->items[$i]->link)."</id>\n"; + $feed.= $this->_createAdditionalElements($this->items[$i]->additionalElements, " "); + if ($this->items[$i]->author!="") { + $feed.= " <author>\n"; + $feed.= " <name>".htmlspecialchars($this->items[$i]->author)."</name>\n"; + $feed.= " </author>\n"; + } + if ($this->items[$i]->description!="") { + $feed.= " <summary>".htmlspecialchars($this->items[$i]->description)."</summary>\n"; + } + if ($this->items[$i]->enclosure != NULL) { + $feed.=" <link rel=\"enclosure\" href=\"". $this->items[$i]->enclosure->url ."\" type=\"". $this->items[$i]->enclosure->type."\" length=\"". $this->items[$i]->enclosure->length . "\" />\n"; + } + $feed.= " </entry>\n"; + } + $feed.= "</feed>\n"; + return $feed; + } + +} + + /** * AtomCreator03 is a FeedCreator that implements the atom specification, * as in http://www.intertwingly.net/wiki/pie/FrontPage.
  23. Yes, this is the goal. I am not there yet. Any suggestions with regard to software would be helpful. I am at the exploration stage. Roddy
  24. JSG: It sounds like you need a database to manage the items in the feed, including posting dates, and also authorization for users that you can use to determine who has access to what. RAS: This question had more to do with the production of the XML file, but your response has told me how to resolve the problem, if I insist on separate folders for each issue and combination of newsletter and podcast. In the meantime, I have pretty much decided to store the two sets of content in separate folders and unite their elements as needed with a script. JSG: It sounds like you need a database to manage the items in the feed, including posting dates, and also authorization for users that you can use to determine who has access to what. RAS: Yes and No. Yes, I will use a MySQL data base to store the information that facilitates the handling of the content, but the content itself will be stored in folders. After some exploration on the net I discovered that using data bases to store media content for which access needs to be immediate and frequent -- protected or unprotected -- is simply inefficient. The database slows down the process of retrieval by a significant amount. In the end it appears that it is better to store media files in folders unless they are to be archived and only infrequently accessed.
×
×
  • Create New...