Skip to content
Snippets Groups Projects
Commit 52d34664 authored by Florian Azizian's avatar Florian Azizian
Browse files

FEAT refactoring

parent f286d28a
No related branches found
No related tags found
No related merge requests found
......@@ -20,7 +20,7 @@
/**
* Module : Tags
*
*
* This module is used to store ressources with any keywords
* V: 1.0
*
......@@ -31,52 +31,33 @@
*/
try{
try {
require_once 'core/class/ActionControler.php';
require_once 'core/class/ObjectControlerAbstract.php';
require_once 'core/class/ObjectControlerIF.php';
require_once 'core/class/class_request.php' ;
require_once 'modules/tags/class/TagControler.php' ;
require_once 'modules/tags/class/TagControler.php' ;
} catch (Exception $e) {
functions::xecho($e->getMessage());
}
$core = new core_tools();
$core->load_lang();
$p_tag_label = $_REQUEST['p_tag_label'];
if(!isset($_REQUEST['p_tag_label']) || empty($_REQUEST['p_tag_label']))
{
echo "{status : 1, error_txt : '".addslashes( TAG_LABEL.' '._IS_EMPTY)."'}";
exit();
}
//$p_res_id = $_REQUEST['p_res_id'];
//if(!isset($_REQUEST['p_res_id']) || empty($_REQUEST['p_res_id']))
//{
// echo "{status : 1, error_txt : '".addslashes( RES_ID.' '._IS_EMPTY)."'}";
// exit();
//}
//$p_coll_id = $_REQUEST['p_coll_id'];
//if(!isset($_REQUEST['p_coll_id']) || empty($_REQUEST['p_coll_id']))
//{
// echo "{status : 1, error_txt : '".addslashes( COLL_ID.' '._IS_EMPTY)."'}";
// exit();
//}
if (!isset($_REQUEST['p_tag_label']) || empty($_REQUEST['p_tag_label'])) {
echo "{status : 1, error_txt : '".addslashes(TAG_LABEL.' '._IS_EMPTY)."'}";
exit();
}
$tag = new tag_controler;
$result = $tag->remove_this_tags_in_session($p_tag_label);
if ($result){
echo "{status : 0, value : '".addslashes($p_tag_label)."'}";
exit();
}
else
{
echo "{status : 1, error_txt : '".addslashes( _RESTAG.' '._DOESNTEXISTS)."'}";
exit();
if ($result) {
echo "{status : 0, value : '".addslashes($p_tag_label)."'}";
exit();
} else {
echo "{status : 1, error_txt : '".addslashes(_RESTAG.' '._DOESNTEXISTS)."'}";
exit();
}
?>
......@@ -74,7 +74,7 @@ abstract class tag_controler_Abstract extends ObjectControler
* Return a complete list of tags in Maarch
*/
$return = array();
$return = array();
$where_what = array();
$db = new Database();
......@@ -140,9 +140,9 @@ abstract class tag_controler_Abstract extends ObjectControler
if($stmt->rowCount() > 0){
while($tag=$stmt->fetchObject()){
$tougue['tag_id'] = $tag->tag_id;
$tougue['tag_id'] = $tag->tag_id;
$tougue['tag_label'] = $tag->tag_label;
$tougue['coll_id'] = $tag->coll_id;
$tougue['coll_id'] = $tag->coll_id;
array_push($return, $tougue);
}
return $return;
......
......@@ -29,58 +29,35 @@
*/
include_once 'modules/tags/route.php';
if (!$tag_customsize)
{
$tag_customsize = '400px';
if (!$tag_customsize) {
$tag_customsize = '400px';
}
if (!$tag_customsize)
{
$tag_customcols = '35';
if (!$tag_customsize) {
$tag_customcols = '35';
}
if (!is_array($_SESSION['tagsuser'])) {
$_SESSION['tagsuser'] = array();
$_SESSION['tagsuser'] = array();
}
//if ($core_tools->test_service('add_tag_to_res', 'tags',false) == 1)
//{
$tags_list=$tags->get_all_tags();
//print_r($tags_list);
if($modify_keyword){
$frm_str .='<select id="tag_userform" name="tag_userform[]" multiple="" data-placeholder=" ">';
}else{
$frm_str .='<select disabled="disabled" id="tag_userform" title="Vous n\'avez pas le droit d\'associer de mots-clés" name="tag_userform[]" multiple="" data-placeholder=" ">';
}
if (!empty($tags_list)) {
foreach ($tags_list as $key => $value) {
if (in_array($value['tag_id'], $_SESSION['tagsuser'])) {
$frm_str .= '<option selected="selected" value="'.$value['tag_id'].'">'.$value['tag_label'].'</option>';
}else{
$frm_str .= '<option value="'.$value['tag_id'].'">'.$value['tag_label'].'</option>';
}
}
}
$tags_list=$tags->get_all_tags();
if ($modify_keyword) {
$frm_str .='<select id="tag_userform" name="tag_userform[]" multiple="" data-placeholder=" ">';
} else {
$frm_str .='<select disabled="disabled" id="tag_userform" title="Vous n\'avez pas le droit d\'associer de mots-clés" name="tag_userform[]" multiple="" data-placeholder=" ">';
}
$frm_str .='</select>';
/*$frm_str .='<textarea rows="2" cols="'.$tag_customcols.'" id="tag_userform" '
.'style="width:'.$tag_customsize.';" >'.$tag.'</textarea>&nbsp;';
$frm_str .='<div id="show_tags" class="autocomplete"></div>';
if($_SESSION['user']['services']['create_tag'] == 1){
$frm_str .='<input type="button" class="button tagbutton" value="'._ADD.'" onclick="add_this_tags('.$route_tag_add_tags_from_res.', '.$route_tag_ui_script.')">';
}else{
$frm_str .='<input type="button" class="button tagbutton" value="'._ADD.'" onclick="add_this_tags('.$route_tag_just_add_tags_from_res.', '.$route_tag_ui_script.')">';
if (!empty($tags_list)) {
foreach ($tags_list as $key => $value) {
if (in_array($value['tag_id'], $_SESSION['tagsuser'])) {
$frm_str .= '<option selected="selected" value="'.$value['tag_id'].'">'.$value['tag_label'].'</option>';
} else {
$frm_str .= '<option value="'.$value['tag_id'].'">'.$value['tag_label'].'</option>';
}
}
}
$frm_str .='<p class="tinyminihelp" align="center">'._TAG_SEPARATOR_HELP.'</p>';
$frm_str .= '<script type="text/javascript">launch_autocompleter_tags(\''
. $_SESSION['config']['businessappurl'] . 'index.php?display='
. 'true&module=tags&page=autocomplete_tags\','
. ' \'tag_userform\');</script>';*/
//}
?>
\ No newline at end of file
$frm_str .='</select>';
......@@ -35,14 +35,13 @@ include_once 'modules/tags/templates/init.php';
if (!$core_tools)
{
$core_tools = new core_tools();
if (!$core_tools) {
$core_tools = new core_tools();
}
$_SESSION['tagsuser'] = array();
$tags = new tag_controler();
$tags->load_sessiontag($s_id,$coll_id);
$tags->load_sessiontag($s_id, $coll_id);
//--------------------------------------
$frm_str .= '<tr><th class="picto" align="left">';
$frm_str .= '<i class="fa fa-tags fa-2x"></i></th>';
......@@ -52,23 +51,21 @@ $frm_str .= '<td align="left" width="200px">'._TAGS.'</td>';
$frm_str .= '<td colspan="6">';
if ($modify_doc)
{
$modify_keyword = true;
if ($modify_doc) {
$modify_keyword = true;
}
$tag_customsize = '950px';
$tag_customcols = '120';
include_once 'modules/tags/templates/addtag_userform.php'; //CHARGEMENT DU FORMULAIRE D'AJOUT DE DROITS
include_once 'modules/tags/templates/addtag_userform.php'; //CHARGEMENT DU FORMULAIRE D'AJOUT DE DROITS
$frm_str .= '</td></tr><style>#tag_userform_chosen{width:auto;}</style>';
if (!$modify_doc){
$rttagfinaldetail = $route_tag_ui_script_without_modif;
}
else{
$rttagfinaldetail = $route_tag_ui_script;
if (!$modify_doc) {
$rttagfinaldetail = $route_tag_ui_script_without_modif;
} else {
$rttagfinaldetail = $route_tag_ui_script;
}
$frm_str .= '<input type="hidden" id="new_tag_label" name="new_tag_label"/>';
$frm_str .= '<script type="text/javascript">load_tags('.$rttagfinaldetail.', \''.$s_id.'\', \''.$coll_id.'\');';
......@@ -79,4 +76,3 @@ if ($core_tools->test_service('create_tag', 'tags', false) == 1) {
$frm_str .= '</script>';
echo $frm_str;
?>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment