Created
July 22, 2008 03:49
-
-
Save vito/634 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Text extends Feathers implements Feather { | |
public function __construct() { | |
$this->setField(array("attr" => "title", | |
"type" => "text", | |
"label" => __("Title", "text"), | |
"optional" => true, | |
"bookmarklet" => "title")); | |
$this->setField(array("attr" => "body", | |
"type" => "text_block", | |
"label" => __("Body", "text"), | |
"preview" => true, | |
"bookmarklet" => "selection")); | |
$this->setFilter("body", "markup_post_text"); | |
$this->setFilter("title", "markup_post_title"); | |
} | |
public function submit() { | |
if (empty($_POST['body'])) | |
error(__("Error"), __("Body can't be blank.")); | |
fallback($_POST['slug'], sanitize($_POST['title'])); | |
return Post::add(array("title" => $_POST['title'], | |
"body" => $_POST['body']), | |
$_POST['slug'], | |
Post::check_url($_POST['slug'])); | |
} | |
public function update() { | |
if (empty($_POST['body'])) | |
error(__("Error"), __("Body can't be blank.")); | |
$post = new Post($_POST['id']); | |
$post->update(array("title" => $_POST['title'], | |
"body" => $_POST['body'])); | |
} | |
public function title($post) { | |
return fallback($post->title, $post->title_from_excerpt(), true); | |
} | |
public function excerpt($post) { | |
return $post->body; | |
} | |
public function feed_content($post) { | |
return $post->body; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Quote extends Feathers implements Feather { | |
public function __construct() { | |
$this->setField(array("attr" => "quote", | |
"type" => "text_block", | |
"rows" => 5, | |
"label" => __("Quote", "quote"), | |
"bookmarklet" => "selection")); | |
$this->setField(array("attr" => "source", | |
"type" => "text_block", | |
"rows" => 5, | |
"label" => __("Source", "quote"), | |
"optional" => true, | |
"preview" => true, | |
"bookmarklet" => "page_title")); | |
$this->setFilter("quote", "markup_post_text"); | |
$this->setFilter("source", "markup_post_text"); | |
} | |
public function submit() { | |
if (empty($_POST['quote'])) | |
error(__("Error"), __("Quote can't be empty.", "quote")); | |
return Post::add(array("quote" => $_POST['quote'], | |
"source" => $_POST['source']), | |
$_POST['slug'], | |
Post::check_url($_POST['slug'])); | |
} | |
public function update() { | |
if (empty($_POST['quote'])) | |
error(__("Error"), __("Quote can't be empty.")); | |
$post = new Post($_POST['id']); | |
$post->update(array("quote" => $_POST['quote'], | |
"source" => $_POST['source'])); | |
} | |
public function title($post) { | |
return $post->title_from_excerpt(); | |
} | |
public function excerpt($post) { | |
return $post->quote; | |
} | |
public function add_dash($text) { | |
return preg_replace("/(<p(\s+[^>]+)?>|^)/si", "\\1— ", $text, 1); | |
} | |
public function feed_content($post) { | |
$body = "<blockquote>\n\t"; | |
$body.= $post->quote; | |
$body.= "\n</blockquote>\n"; | |
$body.= $post->source; | |
return $body; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment