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.

text.php 1.8KB

9 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. class Text extends Feathers implements Feather {
  3. public function __init() {
  4. $this->setField(array("attr" => "title",
  5. "type" => "text",
  6. "label" => __("Title", "text"),
  7. "optional" => true,
  8. "bookmarklet" => "title"));
  9. $this->setField(array("attr" => "body",
  10. "type" => "text_block",
  11. "label" => __("Body", "text"),
  12. "preview" => true,
  13. "bookmarklet" => "selection"));
  14. $this->setFilter("title", array("markup_title", "markup_post_title"));
  15. $this->setFilter("body", array("markup_text", "markup_post_text"));
  16. }
  17. public function submit() {
  18. if (empty($_POST['body']))
  19. error(__("Error"), __("Body can't be blank."));
  20. fallback($_POST['slug'], sanitize($_POST['title']));
  21. return Post::add(array("title" => $_POST['title'],
  22. "body" => $_POST['body']),
  23. $_POST['slug'],
  24. Post::check_url($_POST['slug']));
  25. }
  26. public function update($post) {
  27. if (empty($_POST['body']))
  28. error(__("Error"), __("Body can't be blank."));
  29. $post->update(array("title" => $_POST['title'],
  30. "body" => $_POST['body']));
  31. }
  32. public function title($post) {
  33. return oneof($post->title, $post->title_from_excerpt());
  34. }
  35. public function excerpt($post) {
  36. return $post->body;
  37. }
  38. public function feed_content($post) {
  39. return $post->body;
  40. }
  41. }