<?php
/**
* PHP versions 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://www.php.net/license. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to hide@address.com so we can mail you a copy immediately.
*
* @package QuickTicket
* @author Philippe Vandenberghe <hide@address.com>
* @copyright 2008-2012 The PHP Group
* @version 2.5 build:20101222
*/
session_start();
require_once('bin/qti_init.php');
require_once('bin/qti_fn_tags.php');
include(Translate('qti_adm.php'));
if ( $oVIP->role!='A' ) die(Error(13));
// DEFINE LANG SET TO EDIT
$tt='en';
if ( isset($_GET['tt']) ) $tt = strip_tags($_GET['tt']);
// INITIALISE
$oVIP->selfurl = 'qti_adm_tags.php';
$oVIP->selfname = '<span class="upper">'.$L['Adm_content'].'</span><br />'.$L['Tags'];
// --------
// SUBMITTED
// --------
$a = '';
$strFile = '';
$strSection = '*';
if ( isset($_GET['s']) ) $strSection = strip_tags($_GET['s']);
if ( isset($_GET['a']) ) $a = strip_tags($_GET['a']);
// --------
// HTML START
// --------
include('qti_adm_p_header.php');
if ( $_SESSION[QT]['tags']=='0' )
{
$oHtml->Msgbox('!');
echo $L['R_security'];
echo '<p><a href="qti_adm_secu.php">« ',$L['Adm_security'],'</a></p>';
$oHtml->Msgbox();
include('qti_adm_p_footer.php');
exit;
}
// CONTENT
$arrDomains = GetDomains();
$arrTabs = array();
if ( file_exists('bin/qti_lang.php') )
{
include('bin/qti_lang.php');
foreach($arrLang as $strKey=>$arrDef)
{
$arrTabs[$strKey]=$arrDef[1];
}
}
else
{
$arrTabs = array('*'=>'No language file');
}
// DISPLAY TABS
echo HtmlTabs($arrTabs, $oVIP->selfurl, $tt, 6, true, true, $L['E_editing']);
// DISPLAY TAB PANEL
echo '<table class="pan" cellspacing="0">
<tr class="pan">
<td class="pan">
<div class="pan_top">',$L['Edit'],': ',$arrTabs[$tt],'</div>
';
echo '<table class="data_o" cellspacing="0">
<colgroup span="4"><col width="50"></col><col></col><col></col><col></col></colgroup>
<tr class="data_o">
<td class="colhd" colspan="2">',$L['Domain'],'/',$L['Section'],'</td>
<td class="colhd">',$L['File'],'</td>
<td class="colhd">',$L['Action'],'</td>
</tr>
';
// common tags
$strSectionTags = '';
$bFile = false;
if ( file_exists( 'upload/tags_'.$tt.'.csv' ) )
{
$strSectionTags = 'tags_'.$tt.'.csv';
$bFile = true;
}
echo '<tr class="data_o">';
echo '<td class="colct" style="text-align:center"> </td>';
echo '<td class="colct bold">',$L['Common_all_sections'],'</td>';
echo '<td class="colct" style="text-align:center">',$strSectionTags,' </td>';
echo '<td class="colct" style="text-align:center">';
if ( $bFile )
{
echo '<a class="small" href="'.Href().'?tt=',$tt,'&s=*&a=view">',$L['Preview'],'</a> · <a class="small" href="upload/',$strSectionTags,'">',$L['Download'],'</a> · <a class="small" href="qti_adm_tags_upload.php?tt=',$tt,'&v=tags_',$tt,'.csv">',$L['Upload'],'</a> · <a class="small" href="qti_adm_change.php?tt=',$tt,'&a=tags_del&v=',$strSectionTags,'">',$L['Delete'],'</a>';
}
else
{
echo '<span class="disabled">',$L['Preview'],'</span> · <span class="disabled">',$L['Download'],'</span> · <a class="small" href="qti_adm_tags_upload.php?tt=',$tt,'&v=tags_',$tt,'.csv">',$L['Upload'],'</a> · <span class="disabled">',$L['Delete'],'</span>';
}
echo '</td></tr>',N;
$i=0;
foreach($arrDomains as $intDomid=>$strDomtitle)
{
// GET SECTIONS (with hidden)
$arrSections = QTarrget(GetSections('A',$intDomid));
// DISPLAY
echo '<tr class="data_o">',N;
echo '<td class="colgroup" colspan="2">',$strDomtitle,'</td>',N;
echo '<td class="colgroup"> </td>',N;
echo '<td class="colgroup"> </td>',N;
echo '</tr>';
// tags per section
foreach($arrSections as $intSecid=>$strSectitle)
{
// GET SECTIONS
$oSEC = new cSection($intSecid);
$strSectionTags = '';
$bFile = false;
if ( file_exists( 'upload/tags_'.$tt.'_'.$intSecid.'.csv' ) )
{
$strSectionTags = 'tags_'.$tt.'_'.$intSecid.'.csv';
$bFile = true;
}
echo '<tr class="data_o">';
echo '<td class="colct" style="text-align:center">',AsImg($oSEC->GetLogo(),'S',$L['Ico_section_'.$oSEC->type.'_'.$oSEC->status],'ico ico_s','','qti_adm_section.php?d='.$intDomid.'&s='.$oSEC->id),'</td>';
echo '<td class="colct"><span class="bold">',$oSEC->name,'</span><br /><span class="small">id ',$intSecid,'</span> · ';
if ( $oSEC->tags>0 )
{
echo '<a class="small" href="qti_adm_tags.php?tt=',$tt,'&s=',$intSecid,'&a=used">',$L['Find_used_tags'],'</a></span>';
}
else
{
echo '<span class="disabled">',$L['E_no_tag'],'</span>';
}
echo '</td>';
echo '<td class="colct" style="text-align:center">',$strSectionTags,' </td>';
echo '<td class="colct" style="text-align:center">';
if ( $bFile )
{
echo '<a class="small" href="'.Href().'?tt=',$tt,'&s=',$oSEC->id,'&a=view">',$L['Preview'],'</a> · <a class="small" href="upload/',$strSectionTags,'">',$L['Download'],'</a> · <a class="small" href="qti_adm_tags_upload.php?tt=',$tt,'&v=tags_',$tt,'_',$intSecid.'.csv">',$L['Upload'],'</a> · <a class="small" href="qti_adm_change.php?tt=',$tt,'&a=tags_del&v=',$strSectionTags,'">',$L['Delete'],'</a>';
}
else
{
echo '<span class="disabled">',$L['Preview'],'</span> · <span class="disabled">',$L['Download'],'</span> · <a class="small" href="qti_adm_tags_upload.php?tt=',$tt,'&v=tags_',$tt,'_',$intSecid.'.csv">',$L['Upload'],'</a> · <span class="disabled">',$L['Delete'],'</span>';
}
echo '</td></tr>',N;
}
}
echo '</table>
';
// END TABS
echo '
</td>
</tr>
</table>
';
// PREVIEW FILE
if ( empty($a) )
{
echo '<h2>',$L['Preview'],'</h2>';
echo '<p class="disabled">',$L['E_nothing_selected'],'</p>';
}
if ( $a=='view' )
{
$strFile = 'tags_'.$tt.($strSection=='*' ? '' : '_'.$strSection).'.csv';
if ( !empty($strFile) ) { if ( !file_exists('upload/'.$strFile) ) $strFile=''; }
echo '<h2>',$L['Preview'],(empty($strFile) ? '' : ': '.$L['Proposed_tags'].' ['.$strFile.']'),'</h2>
';
if ( empty($strFile) )
{
echo '<p class="disabled">',$L['E_nothing_selected'],'</p>';
}
else
{
if ( file_exists('upload/'.$strFile) )
{
$intSection = -1; if ( $strSection!='*' ) $intSection = intval($strSection);
// read csv
$arrTags = TagsRead($tt,$strSection);
// display
echo '<div class="scrollmessage">';
echo '<table class="hidden" width="90%" cellspacing="2">',N;
foreach($arrTags as $strKey=>$strValue)
{
echo '<tr class="hidden" onmouseover="this.style.backgroundColor=\'#eeeeee\';" onmouseout="this.style.backgroundColor=\'#ffffff\';">',N;
echo '<td class="hidden" style="width:100px;background-color:#eeeeee;text-align:right">',$strKey,'</td>',N;
echo '<td class="hidden small">',$strValue,'</td>',N;
echo '<td class="hidden"><a class="small" href="qti_find.php?a=tst&s=',$intSection,'&y=',date('Y'),'&k1=-1&k2=-1&k3=',$strKey,'" title="',$L['Find_topic_tag'],'">',$L['Search'],'</a></td>',N;
echo '</tr>';
}
echo '</table>',N;
echo '</div>';
}
else
{
echo '<p class="disabled">File not found...</p>';
}
}
}
// PREVIEW FIND
if ( $a=='used' && $strSection!='*' )
{
$intSection = intval($strSection);
// search used tags
$arrUsed = cSection::GetTagsUsed($intSection,100);
if ( count($arrUsed)>=100 ) $arrUsed[]='...';
// display
echo '<h2>',$L['Preview'],': ',$L['Used_tags'],' ',strtolower($L['In_section']),' ',$intSection,'</h2>
';
if ( count($arrUsed)==0 )
{
echo '<p class="disabled">',$L['E_no_result'],'</p>';
}
else
{
// search proposed tags
$arrTags = TagsRead($tt,'*');
$arrTags2 = TagsRead($tt,$intSection);
foreach($arrTags2 as $strKey=>$strValue)
{
if ( !isset($arrTags[$strKey]) ) $arrTags[$strKey]=$strValue;
}
// display
echo '<div class="scrollmessage">';
echo '<table class="hidden" width="90%" cellspacing="2">',N;
foreach($arrUsed as $strValue)
{
echo '<tr onmouseover="this.style.backgroundColor=\'#eeeeee\';" onmouseout="this.style.backgroundColor=\'#ffffff\';">',N;
echo '<td class="hidden" style="width:100px;background-color:#eeeeee;text-align:right">',$strValue,'</td>',N;
echo '<td class="hidden small">',(isset($arrTags[$strValue]) ? $arrTags[$strValue] : ' '),'</td>',N;
echo '<td class="hidden"><a class="small" href="qti_find.php?a=tst&s=',$strSection,'&y=',date('Y'),'&k1=-1&k2=-1&k3=',$strValue,'" title="',$L['Find_topic_tag'],'">',$L['Search'],'</a></td>',N;
echo '</tr>';
}
echo '</table>',N;
echo '</div>';
}
}
// HTML END
include('qti_adm_p_footer.php');
?>