KXStudio Website https://kx.studio/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
2.2KB

  1. <?php
  2. class Quote extends Feathers implements Feather {
  3. public function __init() {
  4. $this->setField(array("attr" => "quote",
  5. "type" => "text_block",
  6. "rows" => 5,
  7. "label" => __("Quote", "quote"),
  8. "preview" => true,
  9. "bookmarklet" => "selection"));
  10. $this->setField(array("attr" => "source",
  11. "type" => "text_block",
  12. "rows" => 5,
  13. "label" => __("Source", "quote"),
  14. "optional" => true,
  15. "preview" => true,
  16. "bookmarklet" => "page_link"));
  17. $this->setFilter("quote", array("markup_text", "markup_post_text"));
  18. $this->setFilter("source", array("markup_text", "markup_post_text"));
  19. }
  20. public function submit() {
  21. if (empty($_POST['quote']))
  22. error(__("Error"), __("Quote can't be empty.", "quote"));
  23. return Post::add(array("quote" => $_POST['quote'],
  24. "source" => $_POST['source']),
  25. $_POST['slug'],
  26. Post::check_url($_POST['slug']));
  27. }
  28. public function update($post) {
  29. if (empty($_POST['quote']))
  30. error(__("Error"), __("Quote can't be empty."));
  31. $post->update(array("quote" => $_POST['quote'],
  32. "source" => $_POST['source']));
  33. }
  34. public function title($post) {
  35. return $post->title_from_excerpt();
  36. }
  37. public function excerpt($post) {
  38. return $post->quote;
  39. }
  40. public function add_dash($text) {
  41. return preg_replace("/(<p(\s+[^>]+)?>|^)/si", "\\1&mdash; ", $text, 1);
  42. }
  43. public function feed_content($post) {
  44. $body = "<blockquote>\n\t";
  45. $body.= $post->quote;
  46. $body.= "\n</blockquote>\n";
  47. $body.= $post->source;
  48. return $body;
  49. }
  50. }