|
@@ -3,29 +3,47 @@
|
|
|
class tags
|
|
class tags
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
- public static function getAll(float $_idTag = NULL) {
|
|
|
|
|
|
|
+ public static function getAll(?float $_idTag = NULL) {
|
|
|
|
|
|
|
|
if($_idTag == NULL){
|
|
if($_idTag == NULL){
|
|
|
- db::query("SELECT "
|
|
|
|
|
- . "* "
|
|
|
|
|
- . "FROM " . DB_T_TAGS . " "
|
|
|
|
|
- . "ORDER BY label ASC");
|
|
|
|
|
|
|
+ db::query("SELECT"
|
|
|
|
|
+ . " *"
|
|
|
|
|
+ . " FROM " . DB_T_TAGS
|
|
|
|
|
+ . " ORDER BY label ASC");
|
|
|
} else {
|
|
} else {
|
|
|
- db::query("SELECT "
|
|
|
|
|
- . "* "
|
|
|
|
|
- . "FROM " . DB_T_TAGS
|
|
|
|
|
- . " WHERE id_type = :idTag"
|
|
|
|
|
|
|
+ db::query("SELECT"
|
|
|
|
|
+ . " *"
|
|
|
|
|
+ . " FROM " . DB_T_TAGS
|
|
|
|
|
+ . " WHERE id_type = :idTag"
|
|
|
. " ORDER BY label ASC");
|
|
. " ORDER BY label ASC");
|
|
|
db::bind(':idTag', $_idTag);
|
|
db::bind(':idTag', $_idTag);
|
|
|
}
|
|
}
|
|
|
return db::resultset();
|
|
return db::resultset();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public static function cleanTags(){
|
|
|
|
|
- db::query("");
|
|
|
|
|
|
|
+ public static function getTag(float $_idTag) {
|
|
|
|
|
+ db::query("SELECT"
|
|
|
|
|
+ . " *"
|
|
|
|
|
+ . " FROM " . DB_T_TAGS
|
|
|
|
|
+ . " WHERE id = :idTag");
|
|
|
|
|
+ db::bind(':idTag', $_idTag);
|
|
|
|
|
+ return db::single();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ public static function getAllAttachment(?float $_idTag = NULL) {
|
|
|
|
|
+
|
|
|
|
|
+ db::query("SELECT"
|
|
|
|
|
+ . " COUNT(*) AS nbDocuments"
|
|
|
|
|
+ . " FROM " . DB_T_DOCUMENT_TAGS
|
|
|
|
|
+ . " WHERE id_tags = :idTag");
|
|
|
|
|
+ db::bind(':idTag', $_idTag);
|
|
|
|
|
+ return db::single()["nbDocuments"];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static function cleanTags(){
|
|
|
|
|
+ db::query("DELETE FROM tags WHERE id_type = 2 AND NOT EXISTS (SELECT 1 FROM documents_tags WHERE documents_tags.id_tags = tags.id)");
|
|
|
try {
|
|
try {
|
|
|
-
|
|
|
|
|
|
|
+ db::execute();
|
|
|
return TRUE;
|
|
return TRUE;
|
|
|
} catch (Exception $ex) {
|
|
} catch (Exception $ex) {
|
|
|
return FALSE;
|
|
return FALSE;
|
|
@@ -58,6 +76,19 @@ class tags
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public static function merge(float $_idMaster, float $_idSlave) {
|
|
|
|
|
+ db::query("UPDATE " . DB_T_DOCUMENT_TAGS . " SET id_tags = :idMaster WHERE id_tags = :idSlave; ");
|
|
|
|
|
+ db::bind(':idMaster', $_idMaster);
|
|
|
|
|
+ db::bind(':idSlave', $_idSlave);
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ db::execute();
|
|
|
|
|
+ return TRUE;
|
|
|
|
|
+ } catch (Exception $ex) {
|
|
|
|
|
+ return FALSE;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
static public function findAndCreate(string $_tags, float $_idTag = 2){
|
|
static public function findAndCreate(string $_tags, float $_idTag = 2){
|
|
|
$find = [];
|
|
$find = [];
|
|
|
$tmp = explode(",", $_tags);
|
|
$tmp = explode(",", $_tags);
|
|
@@ -74,7 +105,7 @@ class tags
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public static function getJquery(float $_idTag = NULL) {
|
|
|
|
|
|
|
+ public static function getJquery(?float $_idTag = NULL) {
|
|
|
$tmp = "[";
|
|
$tmp = "[";
|
|
|
foreach (self::getAll($_idTag) as $tags) {
|
|
foreach (self::getAll($_idTag) as $tags) {
|
|
|
$tmp .= "'".addslashes($tags["label"])."', ";
|
|
$tmp .= "'".addslashes($tags["label"])."', ";
|
|
@@ -83,7 +114,7 @@ class tags
|
|
|
return $tmp;
|
|
return $tmp;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public static function textToId(string $_tags = NULL, float $_idTag = NULL) {
|
|
|
|
|
|
|
+ public static function textToId(?string $_tags = NULL, ?float $_idTag = NULL) {
|
|
|
$return = NULL;
|
|
$return = NULL;
|
|
|
if($_tags != NULL) {
|
|
if($_tags != NULL) {
|
|
|
|
|
|
|
@@ -107,7 +138,7 @@ class tags
|
|
|
return $return;
|
|
return $return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public static function findUsersTags(string $_tags = NULL){
|
|
|
|
|
|
|
+ public static function findUsersTags(?string $_tags = NULL){
|
|
|
|
|
|
|
|
$tmp = explode(",", $_tags);
|
|
$tmp = explode(",", $_tags);
|
|
|
|
|
|
|
@@ -136,7 +167,7 @@ class tags
|
|
|
return db::resultset();
|
|
return db::resultset();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public static function compareUserDocument(string $_tag_user = NULL, string $_tag_document = NULL){
|
|
|
|
|
|
|
+ public static function compareUserDocument(?string $_tag_user = NULL, ?string $_tag_document = NULL){
|
|
|
if($_tag_user == NULL OR $_tag_document == NULL){
|
|
if($_tag_user == NULL OR $_tag_document == NULL){
|
|
|
return FALSE;
|
|
return FALSE;
|
|
|
}
|
|
}
|