17 define(
'SQ_SYSTEM_ROOT', dirname(dirname(dirname(dirname($_SERVER[
'SCRIPT_FILENAME'])))));
18 require_once SQ_SYSTEM_ROOT.
'/core/include/init.inc';
19 require_once SQ_LIB_PATH.
'/html_form/html_form.inc';
20 if (!isset($_GET[
'assetid']))
return FALSE;
21 if (!isset($_GET[
'prefix']))
return FALSE;
23 $assetid = $_GET[
'assetid'];
24 if (!assert_valid_assetid($assetid)) {
28 $prefix = preg_replace(
'/[\'"\(\);\[\]{}<>=]+/',
'', $_GET[
'prefix']);
30 $asset =& $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid);
31 if (is_null($asset)) {
35 if (!$asset->writeAccess()) {
36 $GLOBALS[
'SQ_SYSTEM']->paintLogin(translate(
'login'), translate(
'cannot_access_asset', $asset->name));
40 $button_name =
'sq_asset_finder_'.$prefix.
'_tags_more_btn';
41 $labelname =
'sq_asset_finder_'.$prefix.
'_tags';
42 $idname = $prefix.
'_tags';
47 $sm =& $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'search_manager');
49 echo translate(
'tag_list_not_available');
52 $keyword_ids = Array();
53 $keyword_names = Array();
54 $current_tag_ids = Array();
55 $quoted_keyword_ids = Array();
56 $keyword_ids = $sm->getAssetidsByWordIntersection($asset->id,
'thesaurus_term');
58 $tm = $GLOBALS[
'SQ_SYSTEM']->getTagManager();
59 $current_tag_links = $tm->getTagLinks($asset->id);
61 foreach ($current_tag_links as $key => $current_tag_link) {
62 $current_tag_ids[] = $current_tag_link[
'minorid'];
65 $keyword_ids = array_values(array_diff($keyword_ids, $current_tag_ids));
66 foreach ($keyword_ids as $keyword_id) {
67 $quoted_keyword_ids[] =
"'".$keyword_id.
"'";
70 $keywords_info = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo($keyword_ids);
76 <title><?php echo
"'".$asset->attr(
'name').
"' ".translate(
'tag_suggestion'); ?></title>
79 background-color: #FFFFFF;
82 body, p, td, ul, li, input, select, textarea{
84 font-family: Arial, Verdana Helvetica, sans-serif;
89 padding: 0px 10px 5px 5px;
90 border: 1px solid #E0E0E0;
97 <script type=
"text/javascript">
98 displayedButtons =
new Array(<?php echo implode(
',', $quoted_keyword_ids); ?>);
101 function addTag(name,
id)
104 while (opener.document.getElementById(
'<?php echo $labelname ?>_'+(next_index + 1)+
'__label') != null){
107 label = opener.document.getElementById(
'<?php echo $labelname ?>_'+next_index+
'__label');
108 label.value = name+
' (id: #'+
id+
')';
109 assetid = opener.document.getElementById(
'<?php echo $idname ?>['+next_index+
'][assetid]');
111 more_btn = opener.document.getElementById(
'<?php echo $button_name ?>');
114 function hideTagButton(
id)
116 removediv = document.getElementById((
'tag'+
id));
117 removediv.style.display =
'none';
119 newArray =
new Array();
120 for (var i=0; i<displayedButtons.length; i++)
122 if(displayedButtons[i] !=
id) {
123 newArray.push(displayedButtons[i]);
126 displayedButtons = newArray;
130 function checkTagsLeft()
133 if (displayedButtons.length == 0) {
134 noMoreTags = document.getElementById(
'noMoreTags');
135 noMoreTags.style.visibility =
'visible';
137 addAll = document.getElementById(
'addAll');
138 addAll.style.display =
'none';
147 require_once dirname(__FILE__).
'/../../include/backend_outputter.inc';
149 $o->addOnLoad(
'checkTagsLeft()');
150 $o->openSection(translate(
'suggested_tags_for').
' '.get_asset_tag_line($asset->id));
153 <p><?php echo translate(
'suggested_tags_for').
' '.get_asset_tag_line($asset->id); ?></p>
154 <p><?php echo translate(
'click_to_tag'); ?></p>
158 <legend><b><?php echo
'Suggested Tags'; ?></b></legend>
162 uasort($keywords_info, create_function(
'$a,$b',
'return strcasecmp($a[\'name\'], $b[\'name\']);'));
163 foreach ($keywords_info as $keyword_info) {
165 if ($tm->isFromTaggingThesaurus($keyword_info[
'assetid'])) {
166 ?><input type=
"button" name=
"Tag" id=
"tag<?php echo $keyword_info['assetid']; ?>" value=
"<?php echo $keyword_info['name']; ?>"
168 addTag('<?php echo $keyword_info['name']; ?>', '<?php echo $keyword_info['assetid']; ?>');
169 hideTagButton('<?php echo $keyword_info['assetid']; ?>');
171 class=
"sq-form-field" />
177 ?><div
id=
"noMoreTags" style=
"visibility:hidden;">
178 <?php echo translate(
'no_tags_to_add'); ?>
180 <div
id=
"addAll" onLoad=
"javascript: checkTagsLeft();" >
181 <input type=
"button" name=
"Tag" id=
"add_all" value=
"Add all"
183 staticLength = displayedButtons.length
184 for (var i=0; i<staticLength; i++)
186 button = getElementById('tag'+displayedButtons[0]);
190 class=
"sq-form-field" />
195 $o->openField(
'',
'commit');
196 normal_button(
'cancel', translate(
'close_window'),
'window.close()');