Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
Giraffaman committed Mar 23, 2024
1 parent a689e37 commit 460d7b2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
12 changes: 12 additions & 0 deletions ext/post_tags/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,25 @@ public function onSearchTermParse(SearchTermParseEvent $event): void
}
}

public function make_logentry($data) {
if (is_array($data)) {
$data = implode(',', $data);
}
return "<script>console.log('Debug: " . $data . "' );</script>";
}

public function onTagSet(TagSetEvent $event): void
{
global $user;
error_log("post_tag: new tag set!");
if ($user->can(Permissions::EDIT_IMAGE_TAG) && (!$event->image->is_locked() || $user->can(Permissions::EDIT_IMAGE_LOCK))) {
foreach($event->new_tags as $nt) {
error_log("new tag ".$nt." is normal tag");
}
$event->image->set_tags($event->new_tags);
}
foreach ($event->metatags as $tag) {
error_log("post_tag: ".$tag." is meta tag!");
send_event(new TagTermParseEvent($tag, $event->image->id));
}
}
Expand Down
20 changes: 13 additions & 7 deletions ext/rating/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ public function onInitExt(InitExtEvent $event): void
Image::$prop_types["rating"] = ImagePropType::STRING;
}

public function make_logentry($data) {
if (is_array($data)) {
$data = implode(',', $data);
}
return "<script>console.log('Debug: " . $data . "' );</script>";
}


private function check_permissions(Image $image): bool
{
global $user;
Expand Down Expand Up @@ -294,8 +302,10 @@ public function onSearchTermParse(SearchTermParseEvent $event): void

public function onTagTermCheck(TagTermCheckEvent $event): void
{
error_log("ratings: tagTermCheck...");
if (preg_match($this->search_regexp, $event->term)) {
$event->metatag = true;
error_log("ratings: ...".$event." is meta tag!");
}
}

Expand All @@ -304,15 +314,18 @@ public function onTagTermParse(TagTermParseEvent $event): void
global $user;
$matches = [];

error_log("ratings: parsing tag term ".$event->term."...");
if (preg_match($this->search_regexp, strtolower($event->term), $matches)) {
$ratings = $matches[1] ? $matches[1] : $matches[2][0];

if (count($matches) > 2 && in_array($matches[2], self::UNRATED_KEYWORDS)) {
$ratings = "?";
error_log("ratings: ...unknown rating!");
}

$ratings = array_intersect(str_split($ratings), Ratings::get_user_class_privs($user));
$rating = $ratings[0];
error_log("ratings: rating is ".$rating);
$image = Image::by_id_ex($event->image_id);
send_event(new RatingSetEvent($image, $rating));
}
Expand Down Expand Up @@ -391,13 +404,6 @@ public function onBulkAction(BulkActionEvent $event): void
}
}

public function make_logentry($data) {
if (is_array($data)) {
$data = implode(',', $data);
}
return "<script>console.log('Debug: " . $data . "' );</script>";
}

public function onPageRequest(PageRequestEvent $event): void
{
global $user, $page;
Expand Down

0 comments on commit 460d7b2

Please sign in to comment.