Activate plugins directly without extending Module
This commit is contained in:
parent
61fcaa57c0
commit
4974adfed0
@ -18,7 +18,7 @@ final class Album extends Module {
|
||||
public function add($title = 'Untitled') {
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 0, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 0, func_get_args());
|
||||
|
||||
# Parse
|
||||
if (strlen($title)>50) $title = substr($title, 0, 50);
|
||||
@ -33,7 +33,7 @@ final class Album extends Module {
|
||||
$result = Database::get()->query($query);
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 1, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
if (!$result) {
|
||||
Log::error(__METHOD__, __LINE__, Database::get()->error);
|
||||
@ -85,7 +85,7 @@ final class Album extends Module {
|
||||
self::dependencies(isset($this->albumIDs));
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 0, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 0, func_get_args());
|
||||
|
||||
# Get album information
|
||||
switch ($this->albumIDs) {
|
||||
@ -160,7 +160,7 @@ final class Album extends Module {
|
||||
$return['num'] = $photos->num_rows;
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 1, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
return $return;
|
||||
|
||||
@ -172,7 +172,7 @@ final class Album extends Module {
|
||||
self::dependencies(isset($public));
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 0, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 0, func_get_args());
|
||||
|
||||
# Initialize return var
|
||||
$return = array(
|
||||
@ -227,7 +227,7 @@ final class Album extends Module {
|
||||
$return['num'] = $albums->num_rows;
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 1, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
return $return;
|
||||
|
||||
@ -334,7 +334,7 @@ final class Album extends Module {
|
||||
self::dependencies(isset($this->albumIDs));
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 0, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 0, func_get_args());
|
||||
|
||||
# Illicit chars
|
||||
$badChars = array_merge(
|
||||
@ -462,7 +462,7 @@ final class Album extends Module {
|
||||
unlink($filename);
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 1, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
return true;
|
||||
|
||||
@ -474,14 +474,14 @@ final class Album extends Module {
|
||||
self::dependencies(isset($this->albumIDs));
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 0, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 0, func_get_args());
|
||||
|
||||
# Execute query
|
||||
$query = Database::prepare(Database::get(), "UPDATE ? SET title = '?' WHERE id IN (?)", array(LYCHEE_TABLE_ALBUMS, $title, $this->albumIDs));
|
||||
$result = Database::get()->query($query);
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 1, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
if (!$result) {
|
||||
Log::error(__METHOD__, __LINE__, Database::get()->error);
|
||||
@ -497,14 +497,14 @@ final class Album extends Module {
|
||||
self::dependencies(isset($this->albumIDs));
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 0, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 0, func_get_args());
|
||||
|
||||
# Execute query
|
||||
$query = Database::prepare(Database::get(), "UPDATE ? SET description = '?' WHERE id IN (?)", array(LYCHEE_TABLE_ALBUMS, $description, $this->albumIDs));
|
||||
$result = Database::get()->query($query);
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 1, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
if (!$result) {
|
||||
Log::error(__METHOD__, __LINE__, Database::get()->error);
|
||||
@ -520,7 +520,7 @@ final class Album extends Module {
|
||||
self::dependencies(isset($this->albumIDs));
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 0, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 0, func_get_args());
|
||||
|
||||
if ($this->albumIDs==='0'||$this->albumIDs==='s'||$this->albumIDs==='f') return false;
|
||||
|
||||
@ -530,7 +530,7 @@ final class Album extends Module {
|
||||
$album = $albums->fetch_object();
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 1, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
if ($album->public==1) return true;
|
||||
return false;
|
||||
@ -543,7 +543,7 @@ final class Album extends Module {
|
||||
self::dependencies(isset($this->albumIDs));
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 0, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 0, func_get_args());
|
||||
|
||||
if ($this->albumIDs==='0'||$this->albumIDs==='s'||$this->albumIDs==='f'||$this->albumIDs==='r') return false;
|
||||
|
||||
@ -553,7 +553,7 @@ final class Album extends Module {
|
||||
$album = $albums->fetch_object();
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 1, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
if ($album->downloadable==1) return true;
|
||||
return false;
|
||||
@ -566,7 +566,7 @@ final class Album extends Module {
|
||||
self::dependencies(isset($this->albumIDs));
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 0, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 0, func_get_args());
|
||||
|
||||
# Convert values
|
||||
$public = ($public==='1' ? 1 : 0);
|
||||
@ -592,7 +592,7 @@ final class Album extends Module {
|
||||
}
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 1, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
# Set password
|
||||
if (isset($password)&&strlen($password)>0) return $this->setPassword($password);
|
||||
@ -607,7 +607,7 @@ final class Album extends Module {
|
||||
self::dependencies(isset($this->albumIDs));
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 0, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 0, func_get_args());
|
||||
|
||||
if (strlen($password)>0) {
|
||||
|
||||
@ -630,7 +630,7 @@ final class Album extends Module {
|
||||
$result = Database::get()->query($query);
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 1, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
if (!$result) {
|
||||
Log::error(__METHOD__, __LINE__, Database::get()->error);
|
||||
@ -646,7 +646,7 @@ final class Album extends Module {
|
||||
self::dependencies(isset($this->albumIDs));
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 0, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 0, func_get_args());
|
||||
|
||||
# Execute query
|
||||
$query = Database::prepare(Database::get(), "SELECT password FROM ? WHERE id = '?' LIMIT 1", array(LYCHEE_TABLE_ALBUMS, $this->albumIDs));
|
||||
@ -654,7 +654,7 @@ final class Album extends Module {
|
||||
$album = $albums->fetch_object();
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 1, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
if ($album->password=='') return true;
|
||||
else if ($album->password===crypt($password, $album->password)) return true;
|
||||
@ -668,7 +668,7 @@ final class Album extends Module {
|
||||
self::dependencies(isset($this->albumIDs));
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 0, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 0, func_get_args());
|
||||
|
||||
# Convert to array
|
||||
$albumIDs = explode(',', $this->albumIDs);
|
||||
@ -693,7 +693,7 @@ final class Album extends Module {
|
||||
$result = Database::get()->query($query);
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 1, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
if (!$result) {
|
||||
Log::error(__METHOD__, __LINE__, Database::get()->error);
|
||||
@ -709,7 +709,7 @@ final class Album extends Module {
|
||||
self::dependencies(isset($this->albumIDs));
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 0, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 0, func_get_args());
|
||||
|
||||
# Init vars
|
||||
$error = false;
|
||||
@ -731,7 +731,7 @@ final class Album extends Module {
|
||||
$result = Database::get()->query($query);
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 1, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
if ($error) return false;
|
||||
if (!$result) {
|
||||
|
@ -35,7 +35,7 @@ final class Import extends Module {
|
||||
self::dependencies(isset($urls));
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 0, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 0, func_get_args());
|
||||
|
||||
$error = false;
|
||||
|
||||
@ -84,7 +84,7 @@ final class Import extends Module {
|
||||
}
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 1, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
if ($error===false) return true;
|
||||
return false;
|
||||
@ -117,7 +117,7 @@ final class Import extends Module {
|
||||
# Call plugins
|
||||
# Note that updated albumId and path explicitly passed, rather
|
||||
# than using func_get_args() which will only return original ones
|
||||
$this->plugins(__METHOD__, 0, array($albumID, $path));
|
||||
Plugins::get()->activate(__METHOD__, 0, array($albumID, $path));
|
||||
|
||||
# Get all files
|
||||
$files = glob($path . '/*');
|
||||
@ -173,7 +173,7 @@ final class Import extends Module {
|
||||
# Call plugins
|
||||
# Note that updated albumId and path explicitly passed, rather
|
||||
# than using func_get_args() which will only return original ones
|
||||
$this->plugins(__METHOD__, 1, array($albumID, $path));
|
||||
Plugins::get()->activate(__METHOD__, 1, array($albumID, $path));
|
||||
|
||||
# The following returns will be caught in the front-end
|
||||
if ($contains['photos']===false&&$contains['albums']===false) return 'Warning: Folder empty or no readable files to process!';
|
||||
|
@ -4,20 +4,6 @@ namespace Lychee\Modules;
|
||||
|
||||
abstract class Module {
|
||||
|
||||
protected function plugins($name, $location, $args) {
|
||||
|
||||
self::dependencies(isset($name, $location, $args));
|
||||
|
||||
# Parse
|
||||
$location = ($location===0 ? 'before' : 'after');
|
||||
|
||||
# Call plugins
|
||||
Plugins::get()->activate($name . ":" . $location, $args);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
final public static function dependencies($available = false) {
|
||||
|
||||
if ($available===false) exit('Error: Can not execute function. Missing parameters or variables.');
|
||||
|
@ -45,7 +45,7 @@ final class Photo extends Module {
|
||||
}
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 0, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 0, func_get_args());
|
||||
|
||||
switch($albumID) {
|
||||
|
||||
@ -247,7 +247,7 @@ final class Photo extends Module {
|
||||
}
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 1, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
return true;
|
||||
|
||||
@ -294,7 +294,7 @@ final class Photo extends Module {
|
||||
self::dependencies(isset($url, $filename, $type, $width, $height));
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 0, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 0, func_get_args());
|
||||
|
||||
# Size of the thumbnail
|
||||
$newWidth = 200;
|
||||
@ -371,7 +371,7 @@ final class Photo extends Module {
|
||||
}
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 1, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
return true;
|
||||
|
||||
@ -393,7 +393,7 @@ final class Photo extends Module {
|
||||
self::dependencies(isset($url, $filename, $width, $height));
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 0, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 0, func_get_args());
|
||||
|
||||
# Set to true when creation of medium-photo failed
|
||||
$error = false;
|
||||
@ -450,7 +450,7 @@ final class Photo extends Module {
|
||||
}
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 1, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
if ($error===true) return false;
|
||||
return true;
|
||||
@ -471,7 +471,7 @@ final class Photo extends Module {
|
||||
self::dependencies(isset($path, $info));
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 0, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 0, func_get_args());
|
||||
|
||||
$swapSize = false;
|
||||
|
||||
@ -577,7 +577,7 @@ final class Photo extends Module {
|
||||
}
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 1, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
# SwapSize should be true when the image has been rotated
|
||||
# Return new dimensions in this case
|
||||
@ -648,7 +648,7 @@ final class Photo extends Module {
|
||||
self::dependencies(isset($this->photoIDs));
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 0, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 0, func_get_args());
|
||||
|
||||
# Get photo
|
||||
$query = Database::prepare(Database::get(), "SELECT * FROM ? WHERE id = '?' LIMIT 1", array(LYCHEE_TABLE_PHOTOS, $this->photoIDs));
|
||||
@ -689,7 +689,7 @@ final class Photo extends Module {
|
||||
}
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 1, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
return $photo;
|
||||
|
||||
@ -707,7 +707,7 @@ final class Photo extends Module {
|
||||
self::dependencies(isset($url));
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 0, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 0, func_get_args());
|
||||
|
||||
$iptcArray = array();
|
||||
$info = getimagesize($url, $iptcArray);
|
||||
@ -797,7 +797,7 @@ final class Photo extends Module {
|
||||
}
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 1, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
return $return;
|
||||
|
||||
@ -814,7 +814,7 @@ final class Photo extends Module {
|
||||
self::dependencies(isset($this->photoIDs));
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 0, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 0, func_get_args());
|
||||
|
||||
# Get photo
|
||||
$query = Database::prepare(Database::get(), "SELECT title, url FROM ? WHERE id = '?' LIMIT 1", array(LYCHEE_TABLE_PHOTOS, $this->photoIDs));
|
||||
@ -861,7 +861,7 @@ final class Photo extends Module {
|
||||
readfile(LYCHEE_UPLOADS_BIG . $photo->url);
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 1, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
return true;
|
||||
|
||||
@ -880,14 +880,14 @@ final class Photo extends Module {
|
||||
self::dependencies(isset($this->photoIDs));
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 0, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 0, func_get_args());
|
||||
|
||||
# Set title
|
||||
$query = Database::prepare(Database::get(), "UPDATE ? SET title = '?' WHERE id IN (?)", array(LYCHEE_TABLE_PHOTOS, $title, $this->photoIDs));
|
||||
$result = Database::get()->query($query);
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 1, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
if (!$result) {
|
||||
Log::error(__METHOD__, __LINE__, Database::get()->error);
|
||||
@ -910,14 +910,14 @@ final class Photo extends Module {
|
||||
self::dependencies(isset($this->photoIDs));
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 0, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 0, func_get_args());
|
||||
|
||||
# Set description
|
||||
$query = Database::prepare(Database::get(), "UPDATE ? SET description = '?' WHERE id IN ('?')", array(LYCHEE_TABLE_PHOTOS, $description, $this->photoIDs));
|
||||
$result = Database::get()->query($query);
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 1, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
if (!$result) {
|
||||
Log::error(__METHOD__, __LINE__, Database::get()->error);
|
||||
@ -938,7 +938,7 @@ final class Photo extends Module {
|
||||
self::dependencies(isset($this->photoIDs));
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 0, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 0, func_get_args());
|
||||
|
||||
# Init vars
|
||||
$error = false;
|
||||
@ -961,7 +961,7 @@ final class Photo extends Module {
|
||||
}
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 1, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
if ($error===true) {
|
||||
Log::error(__METHOD__, __LINE__, Database::get()->error);
|
||||
@ -983,7 +983,7 @@ final class Photo extends Module {
|
||||
self::dependencies(isset($this->photoIDs));
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 0, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 0, func_get_args());
|
||||
|
||||
# Get photo
|
||||
$query = Database::prepare(Database::get(), "SELECT public, album FROM ? WHERE id = '?' LIMIT 1", array(LYCHEE_TABLE_PHOTOS, $this->photoIDs));
|
||||
@ -1012,7 +1012,7 @@ final class Photo extends Module {
|
||||
}
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 1, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
# Photo private
|
||||
return 0;
|
||||
@ -1030,7 +1030,7 @@ final class Photo extends Module {
|
||||
self::dependencies(isset($this->photoIDs));
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 0, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 0, func_get_args());
|
||||
|
||||
# Get public
|
||||
$query = Database::prepare(Database::get(), "SELECT public FROM ? WHERE id = '?' LIMIT 1", array(LYCHEE_TABLE_PHOTOS, $this->photoIDs));
|
||||
@ -1045,7 +1045,7 @@ final class Photo extends Module {
|
||||
$result = Database::get()->query($query);
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 1, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
if (!$result) {
|
||||
Log::error(__METHOD__, __LINE__, Database::get()->error);
|
||||
@ -1066,14 +1066,14 @@ final class Photo extends Module {
|
||||
self::dependencies(isset($this->photoIDs));
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 0, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 0, func_get_args());
|
||||
|
||||
# Set album
|
||||
$query = Database::prepare(Database::get(), "UPDATE ? SET album = '?' WHERE id IN (?)", array(LYCHEE_TABLE_PHOTOS, $albumID, $this->photoIDs));
|
||||
$result = Database::get()->query($query);
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 1, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
if (!$result) {
|
||||
Log::error(__METHOD__, __LINE__, Database::get()->error);
|
||||
@ -1096,7 +1096,7 @@ final class Photo extends Module {
|
||||
self::dependencies(isset($this->photoIDs));
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 0, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 0, func_get_args());
|
||||
|
||||
# Parse tags
|
||||
$tags = preg_replace('/(\ ,\ )|(\ ,)|(,\ )|(,{1,}\ {0,})|(,$|^,)/', ',', $tags);
|
||||
@ -1107,7 +1107,7 @@ final class Photo extends Module {
|
||||
$result = Database::get()->query($query);
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 1, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
if (!$result) {
|
||||
Log::error(__METHOD__, __LINE__, Database::get()->error);
|
||||
@ -1128,7 +1128,7 @@ final class Photo extends Module {
|
||||
self::dependencies(isset($this->photoIDs));
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 0, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 0, func_get_args());
|
||||
|
||||
# Get photos
|
||||
$query = Database::prepare(Database::get(), "SELECT id, checksum FROM ? WHERE id IN (?)", array(LYCHEE_TABLE_PHOTOS, $this->photoIDs));
|
||||
@ -1171,7 +1171,7 @@ final class Photo extends Module {
|
||||
self::dependencies(isset($this->photoIDs));
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 0, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 0, func_get_args());
|
||||
|
||||
# Get photos
|
||||
$query = Database::prepare(Database::get(), "SELECT id, url, thumbUrl, checksum FROM ? WHERE id IN (?)", array(LYCHEE_TABLE_PHOTOS, $this->photoIDs));
|
||||
@ -1229,7 +1229,7 @@ final class Photo extends Module {
|
||||
}
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 1, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
return true;
|
||||
|
||||
|
@ -75,9 +75,13 @@ final class Plugins implements SplSubject {
|
||||
|
||||
}
|
||||
|
||||
public function activate($action, $args) {
|
||||
public function activate($name, $location, array $args) {
|
||||
|
||||
if (!isset($action, $args)) return false;
|
||||
if (!isset($name, $location, $args)) return false;
|
||||
|
||||
# Parse
|
||||
$location = ($location===0 ? 'before' : 'after');
|
||||
$action = $name . ":" . $location;
|
||||
|
||||
# Save vars
|
||||
$this->action = $action;
|
||||
|
@ -10,7 +10,7 @@ final class Session extends Module {
|
||||
self::dependencies(isset($public));
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 0, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 0, func_get_args());
|
||||
|
||||
# Return settings
|
||||
$return['config'] = Settings::get();
|
||||
@ -57,7 +57,7 @@ final class Session extends Module {
|
||||
}
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 1, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
return $return;
|
||||
|
||||
@ -69,7 +69,7 @@ final class Session extends Module {
|
||||
self::dependencies(isset($username, $password));
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 0, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 0, func_get_args());
|
||||
|
||||
$username = crypt($username, Settings::get()['username']);
|
||||
$password = crypt($password, Settings::get()['password']);
|
||||
@ -86,7 +86,7 @@ final class Session extends Module {
|
||||
if ($this->noLogin()===true) return true;
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 1, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
return false;
|
||||
|
||||
@ -109,7 +109,7 @@ final class Session extends Module {
|
||||
public function logout() {
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 0, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 0, func_get_args());
|
||||
|
||||
$_SESSION['login'] = null;
|
||||
$_SESSION['identifier'] = null;
|
||||
@ -117,7 +117,7 @@ final class Session extends Module {
|
||||
session_destroy();
|
||||
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 1, func_get_args());
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
return true;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user