Plugin "Newsfeed" - Printable Version +- GetSimple Support Forum (http://get-simple.info/forums) +-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3) +--- Forum: Developer Discussions (http://get-simple.info/forums/forumdisplay.php?fid=8) +--- Thread: Plugin "Newsfeed" (/showthread.php?tid=1458) |
Plugin "Newsfeed" - polyfragmented - 2011-03-29 Alright, I'm joining the fray and will try to create a plugin. I'm opening this thread in order to post questions and snapshots. I'm a newbie so please bear with me. I don't expect any ready-made solutions as replies to my questions, a simple "RTFM at [link]" and a few hints here and there will mostly do I believe. My goal is to create a plugin which maintains an ATOM newsfeed and syncs feed items on creation/modification/deletion of pages. I will update this thread irregularly. 04.04.2011 → Progress on basic file and folder checks, setting up the environment so SimpleXML can enter the stage soon 09.04.2011 → Handling the XML and stuff Plugin "Newsfeed" - polyfragmented - 2011-03-29 My first question is if I can somehow check for creation of a page with a hook? I saw a page-delete and a changedata-save hook in the wiki docs, but none for when a page is created. Have I overlooked it? Can I maybe use changedata-save with some additional check if the page already had a respective xml file in /data/pages? I'm thinking of reading in the existing pages into an array and then check for existence. Plugin "Newsfeed" - mvlcek - 2011-03-29 polyfragmented Wrote:My first question is if I can somehow check for creation of a page with a hook? If I remember correctly, check for isset($_POST['post-id']) on changedata-save: if it's not set, it's a new page. Plugin "Newsfeed" - polyfragmented - 2011-03-29 mvlcek Wrote:If I remember correctly, check for isset($_POST['post-id']) on changedata-save: if it's not set, it's a new page. Thanks, will look into it. Plugin "Newsfeed" - polyfragmented - 2011-03-30 I'm having problems with the check, it always returns that the variable is set, so the message always is "Existing page has been modified". PHP version is 5.2.12, all GS requirements in health check are met. Code: # Check if an existing page has been modified or a new page has been page created Additionally, my page-delete event function doesn't display anything after deleting a page. I have set up the page-delete hook to fire my function. Code: # Existing page has been deleted Code: function thp_newsfeed_page_deleted() { Suggestions? Plugin "Newsfeed" - mvlcek - 2011-03-30 I just checked changedata.php. post-id is set but empty thus the condition is Code: if ($_POST['post-id']) { /* changed */ } else { /* new */ } You won't see any output on page-delete as there is a redirect at the end - outputing text might prevent the redirect from happening, though. Plugin "Newsfeed" - polyfragmented - 2011-03-30 Thanks, the check is working now. Nice. \o/ Plugin "Newsfeed" - polyfragmented - 2011-04-05 Currently implementing basic file and folder checks, almost done: create a GSDATAOTHER/myplugin folder and copy a barebones atom.xml template file from GSDATAPLUGIN/myplugin folder. That template file will later be modified using SimpleXML (insertions of entries, update feed modification date,...) My thinking is to use GSDATAOTHER/myplugin as a tmp folder where manipulations to the ATOM file are being staged. If no errors raise their ugly heads, a final copy to GSROOTPATH will be done. On to SimpleXML goodness next! Plugin "Newsfeed" - ccagle8 - 2011-04-05 polyfragmented Wrote:On to SimpleXML goodness next!It's fun isn't it? Some nights I just cant step away from the computer screen... Plugin "Newsfeed" - polyfragmented - 2011-04-05 ccagle8 Wrote:Yes, it is fun, especially if what you do scratches an itch. I expected plugin development to be much harder, I'm glad it appears to be easier than I thought. I found it to be very satisfying when the checks and copy command worked tonight, hehe.polyfragmented Wrote:On to SimpleXML goodness next!It's fun isn't it? Some nights I just cant step away from the computer screen... Plugin "Newsfeed" - polyfragmented - 2011-04-06 As an aside, I just performed a Google search for 'basic atom newsfeed file', because I had forgotton what's in a barebones ATOM file... and found this thread to be on spot 7 of the results, hehe. Funny. Plugin "Newsfeed" - polyfragmented - 2011-04-06 I'm currently learning how to use SimpleXML and would like a hint on how to save modifications back to a XML file? Let's take this example with (still) hard-coded element content: Code: # Load the feed file I read up on asXML(), but I don't get it. In example 1 given at php.net, the output includes <?xml version="1.0"?> which is not what I want. Example 2 doesn't have it, but uses XPath. Is example 2 possibly what I want? Plugin "Newsfeed" - polyfragmented - 2011-04-06 Another development question: how do I debug my PHP code best without echoing stuff to the screen? As Martin Vlcek pointed out, it may mess up GS. I'm currently getting stuck on changedata.php without page modifications being saved (because my code contains errors) How do you guys debug your PHP code? Any opensource tools available? Does anybody use FirePHP? Or Aptana Studio? Plugin "Newsfeed" - mvlcek - 2011-04-06 polyfragmented Wrote:I read up on asXML(), but I don't get it. I always used XMLsave from admin/inc/basic.php, there you see that the usage is Code: $success = $xml->asXML($file) === TRUE; where $file is the file name including path. polyfragmented Wrote:How do you guys debug your PHP code? Any opensource tools available? Does anybody use FirePHP? Or Aptana Studio? Debug mode on and echo and print_r($variable) (for arrays and more complex structures) are my friends ;-) Plugin "Newsfeed" - polyfragmented - 2011-04-07 I couldn't find a function or variable to get the current user. Searched the wiki and here on the forum. Have I overlooked it? (it does happen *cough*) I need this info for the author element in the ATOM feed. Plugin "Newsfeed" - RobA - 2011-04-08 polyfragmented Wrote:I couldn't find a function or variable to get the current user. Searched the wiki and here on the forum. Have I overlooked it? (it does happen *cough*) In admin/template/include-nav.php it uses $USR I tried global $USR; and it seems to work in the back end. -Rob A> Plugin "Newsfeed" - mvlcek - 2011-04-08 polyfragmented Wrote:I couldn't find a function or variable to get the current user. Searched the wiki and here on the forum. Have I overlooked it? (it does happen *cough*) The author of the Feed? It shouldn't be the current user - especially in GetSimple 3.0, where we have multiple users, but rather the name of the web site from the settings, compare heise.de: Code: <?xml version="1.0" encoding="utf-8"?> Plugin "Newsfeed" - polyfragmented - 2011-04-08 mvlcek Wrote:The author of the Feed? It shouldn't be the current user - especially in GetSimple 3.0, where we have multiple users, but rather the name of the web site from the settings, compare heise.de: <snip>Well, heise.de, as in the example, *is* the author, only it's a pool of authors for the website under a catch-all if you will. The AtomEnabled website says: Quote:<author> and <contributor> describe a person, corporation, or similar entity. It has one required element, name, and two optional elements: uri, email. Code: <author> There are link elements reserved for the main feed URL and entries' URLs. I'd say the user who created/modified the page should be mentioned. I'll try Rob's approach soon and report back. Plugin "Newsfeed" - polyfragmented - 2011-04-09 Slowly getting a grip on handling the XML. I can load the file (easy), iterate through it (medium), edit elements plus their attributes (easy) and save to file (easy). asXML() was much easier than I thought, I just read up on it on some other tutorial site and it clicked. While doing this I'm optimising my code writing which slows down progress of course -- I find it hard to resist though. I started off with speaking variables and functions which were "namespaced" (read prefixed), but too long/detailed and I didn't use constants for oft-used stuff like paths to data/plugin folders. I heavily comment my code which is partly for me and partly for others who might have a look-see at some point in the future -- this takes some time as well, but seems well-worth the effort. Started making a list of system variables I can use for the main feed elements like site name, site url, page date, etc. I set up folder and file checks and catch creation/modification of pages now. So, things are progressing slowly, but I take tremendous satisfaction from completed and working functions. (yay.) I may have a first snapshot for review sometime next week. Plugin "Newsfeed" - polyfragmented - 2011-04-09 RobA Wrote:global $USR;Rob, Chris just revealed this in another thread: Code: get_cookie('GS_ADMIN_USERNAME') Plugin "Newsfeed" - RobA - 2011-04-10 Thanks for the follow-up. I hadn't seen that other thread. -Rob A> Plugin "Newsfeed" - polyfragmented - 2011-04-10 Note to self: don't forget to put code in include files inside <?php ... ?>... Plugin "Newsfeed" - polyfragmented - 2011-04-21 I have an XML file which, for testing purposes, I'm reading in, then echoing. It seems not all nodes/elements are read in/echoed back though, one is missing. The code Code: <?php The file Code: <?xml version="1.0" encoding="utf-8"?> Any idea why <title> is missing from the output? Code: http://www.test.de 000001 now |