init.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. class Query_Headlines extends Plugin {
  3. // example of the use of the HOOK_QUERY_HEADLINES
  4. // this example will change the author and tags to be empty string so they don't display
  5. // the arguements are:
  6. // - the array of elements that are returned by queryFeedHeadlines
  7. // - the length that the caller wants to truncate the content preview to
  8. // - a boolean that indicates if the caller is from an API call
  9. // The field content_preview has been shortened and sanitized, as appropriate
  10. // before the plugin is called. If you want to do your own preview handling
  11. // use the content field and create the preview from that
  12. //NOTE:**** You have to make this a system plugin if you want it to also work
  13. // on API calls. If you just make it a user plugin it will work on web page output
  14. // but not on API calls
  15. private $host;
  16. function about() {
  17. return array(1.0,
  18. "Example of use of HOOK_QUERY_HEADLINES",
  19. "justauser" );
  20. }
  21. function init($host) {
  22. $this->host = $host;
  23. $host->add_hook($host::HOOK_QUERY_HEADLINES, $this);
  24. }
  25. // passes in the array for an item
  26. // second argument is the length of the preview the caller is using
  27. // create a key called "modified_preview" if you change the preview and don't want
  28. // caller to override with their default
  29. function hook_query_headlines($line, $preview_length = 100,$api_call=false) {
  30. //make the author field empty
  31. $line["author"] = "";
  32. // and toss tags, since I don't use
  33. $line["tag_cache"] = "";
  34. return $line;
  35. }
  36. function api_version() {
  37. return 2;
  38. }
  39. }
  40. ?>