added option to set pool & source via tag

This commit is contained in:
Daku 2013-12-30 08:15:10 +00:00
parent 9eaebfd1c2
commit 3dd3101995
3 changed files with 32 additions and 2 deletions

View File

@ -476,6 +476,18 @@ class Image {
$this->delete_tags_from_image();
// insert each new tags
foreach($tags as $tag) {
if(preg_match("/^source=(.*)$/i", $tag, $matches)) {
$this->set_source($matches[1]);
continue;
}
if(preg_match("/^pool=(.*)$/i", $tag, $matches)) {
if(class_exists("Pools")) {
$pls = new Pools();
$pls->add_post_from_tag($matches[1], $this->id);
}
continue;
}
$id = $database->get_one(
$database->scoreql_to_sql(
"SELECT id FROM tags WHERE SCORE_STRNORM(tag) = SCORE_STRNORM(:tag)"

View File

@ -293,6 +293,23 @@ class Pools extends Extension {
}
}
public function add_post_from_tag(/*str*/ $poolTag, /*int*/ $imageID){
$poolTag = str_replace("_", " ", $poolTag);
//First check if pool tag is a title
if(ctype_digit($poolTag)){
//If string only contains numeric characters, assume it is $poolID
if($this->get_single_pool($poolTag)){ //Make sure pool exists
$this->add_post($poolTag, $imageID);
}
}else{
//If string doesn't contain only numeric characters, check to see if tag is title.
$pool = $this->get_single_pool_from_title($poolTag);
if($pool){
$this->add_post($pool['id'], $imageID);
}
}
}
/* ------------------------------------------------- */
/* -------------- Private Functions -------------- */
/* ------------------------------------------------- */
@ -362,7 +379,7 @@ class Pools extends Extension {
*/
private function add_pool() {
global $user, $database;
#throw new PoolCreationException("Pool needs a title");
if($user->is_anonymous()) {
throw new PoolCreationException("You must be registered and logged in to add a image.");
}
@ -372,6 +389,7 @@ class Pools extends Extension {
if($this->get_single_pool_from_title($_POST["title"])) {
throw new PoolCreationException("A pool using this title already exists.");
}
$public = $_POST["public"] == "Y" ? "Y" : "N";
$database->execute("
INSERT INTO pools (user_id, public, title, description, date)

View File

@ -350,7 +350,7 @@ class PoolsTheme extends Themelet {
"<input type='hidden' name='pool_id' value='".$pools[0]['id']."'>".
"</form>";
$pools[0]['description'] = ""; //This is a rogue fix to avoid showing the description twice.
$pools[0]['description'] = ""; //This is a rough fix to avoid showing the description twice.
$this->display_top($pools, "Editing Pool", true);
$page->add_block(new Block("Editing Description", $desc_html, "main", 28));
$page->add_block(new Block("Editing Posts", $pool_images, "main", 30));