added option to set pool & source via tag
This commit is contained in:
parent
9eaebfd1c2
commit
3dd3101995
@ -476,6 +476,18 @@ class Image {
|
|||||||
$this->delete_tags_from_image();
|
$this->delete_tags_from_image();
|
||||||
// insert each new tags
|
// insert each new tags
|
||||||
foreach($tags as $tag) {
|
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(
|
$id = $database->get_one(
|
||||||
$database->scoreql_to_sql(
|
$database->scoreql_to_sql(
|
||||||
"SELECT id FROM tags WHERE SCORE_STRNORM(tag) = SCORE_STRNORM(:tag)"
|
"SELECT id FROM tags WHERE SCORE_STRNORM(tag) = SCORE_STRNORM(:tag)"
|
||||||
|
@ -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 -------------- */
|
/* -------------- Private Functions -------------- */
|
||||||
/* ------------------------------------------------- */
|
/* ------------------------------------------------- */
|
||||||
@ -362,7 +379,7 @@ class Pools extends Extension {
|
|||||||
*/
|
*/
|
||||||
private function add_pool() {
|
private function add_pool() {
|
||||||
global $user, $database;
|
global $user, $database;
|
||||||
#throw new PoolCreationException("Pool needs a title");
|
|
||||||
if($user->is_anonymous()) {
|
if($user->is_anonymous()) {
|
||||||
throw new PoolCreationException("You must be registered and logged in to add a image.");
|
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"])) {
|
if($this->get_single_pool_from_title($_POST["title"])) {
|
||||||
throw new PoolCreationException("A pool using this title already exists.");
|
throw new PoolCreationException("A pool using this title already exists.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$public = $_POST["public"] == "Y" ? "Y" : "N";
|
$public = $_POST["public"] == "Y" ? "Y" : "N";
|
||||||
$database->execute("
|
$database->execute("
|
||||||
INSERT INTO pools (user_id, public, title, description, date)
|
INSERT INTO pools (user_id, public, title, description, date)
|
||||||
|
@ -350,7 +350,7 @@ class PoolsTheme extends Themelet {
|
|||||||
"<input type='hidden' name='pool_id' value='".$pools[0]['id']."'>".
|
"<input type='hidden' name='pool_id' value='".$pools[0]['id']."'>".
|
||||||
"</form>";
|
"</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);
|
$this->display_top($pools, "Editing Pool", true);
|
||||||
$page->add_block(new Block("Editing Description", $desc_html, "main", 28));
|
$page->add_block(new Block("Editing Description", $desc_html, "main", 28));
|
||||||
$page->add_block(new Block("Editing Posts", $pool_images, "main", 30));
|
$page->add_block(new Block("Editing Posts", $pool_images, "main", 30));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user