Location: PHPKode > projects > QuickTalk Forum > quicktalk/qtf_adm_tags.php
<?php



/**

* PHP versions 4 and 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    QuickTalk

* @author     Philippe Vandenberghe <hide@address.com>

* @copyright  2008-2012 The PHP Group

* @version    2.5 build:20100924

*/



session_start();

require_once('bin/qtf_init.php');

require_once('bin/qtf_fn_tags.php');

include(Translate('qtf_adm.php'));



if ( $oVIP->role!='A' ) die($L['E_admin']);





// DEFINE LANG SET TO EDIT



$tt='en';

if ( isset($_GET['tt']) ) $tt = strip_tags($_GET['tt']);



// INITIALISE



$oVIP->selfurl = 'qtf_adm_tags.php';

$oVIP->selfname = '<span class="upper">'.$L['Adm_content'].'</span><br/>'.$L['Tags'];



// --------

// SUBMITTED

// --------



$strAction = '';

$strFile = '';

$strSection = '*';



if ( isset($_GET['s']) ) $strSection = strip_tags($_GET['s']);

if ( isset($_GET['a']) ) $strAction = strip_tags($_GET['a']);



// --------

// HTML START

// --------



$bJava=true;



include('qtf_adm_p_header.php');



if ( $_SESSION[QT]['tags']=='0' ) 

{

  HtmlMsg(0);

  echo $L['R_security'];

  echo '<p><a href="qtf_adm_secu.php">&laquo; ',$L['Adm_security'],'</a></p>';

  HtmlMsg(1);

  include('qtf_adm_p_footer.php');

  exit;

}



$arrDomains = GetDomains();

$arrTabs = array();



if ( file_exists('bin/qtf_lang.php') )

{

  include('bin/qtf_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" summary="tags">

<tr class="pan">

<td class="pan">

<div class="pan_top">',$L['Edit'],': ',$arrTabs[$tt],'</div>

';



echo '<table class="data_s" cellspacing="0" summary="tags">

<colgroup span="4"><col width="50"></col><col></col><col></col><col></col></colgroup>

<tr class="data_s">

<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_s">';

  echo '<td class="colct" style="text-align:center">&nbsp;</td>';

  echo '<td class="colct bold">',$L['Common_all_sections'],'</td>';

  echo '<td class="colct" style="text-align:center">',$strSectionTags,'&nbsp;</td>';

  echo '<td class="colct" style="text-align:center">';

  if ( $bFile )

  {

  echo '<a class="small" href="'.$oVIP->selfurl.'?tt=',$tt,'&amp;s=*&amp;a=view">',$L['Preview'],'</a> &middot; <a class="small" href="upload/',$strSectionTags,'">',$L['Download'],'</a> &middot; <a class="small" href="qtf_adm_tags_upload.php?tt=',$tt,'&amp;v=tags_',$tt,'.csv">',$L['Upload'],'</a> &middot; <a class="small" href="qtf_adm_change.php?tt=',$tt,'&amp;a=tags_del&amp;v=',$strSectionTags,'">',$L['Delete'],'</a>';

  }

  else

  {

  echo '<span class="disabled">',$L['Preview'],'</span> &middot; <span class="disabled">',$L['Download'],'</span> &middot; <a class="small" href="qtf_adm_tags_upload.php?tt=',$tt,'&amp;v=tags_',$tt,'.csv">',$L['Upload'],'</a> &middot; <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_s">',N;

  echo '<td class="colgroup" colspan="2">',$strDomtitle,'</td>',N;

  echo '<td class="colgroup">&nbsp;</td>',N;

  echo '<td class="colgroup">&nbsp;</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_s">';

    echo '<td class="colct" style="text-align:center">',AsImg($oSEC->GetLogo(),'S',$L['Ico_section_'.$oSEC->type.'_'.$oSEC->status],'ico ico_s','','qtf_adm_section.php?d='.$intDomid.'&amp;s='.$oSEC->id),'</td>';

    echo '<td class="colct"><span class="bold">',$oSEC->name,'</span><br/><span class="small">id ',$intSecid,'</span> &middot; ';

    if ( $oSEC->Count('tags')>0 )

    {

    echo '<a class="small" href="qtf_adm_tags.php?tt=',$tt,'&amp;s=',$intSecid,'&amp;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,'&nbsp;</td>';

    echo '<td class="colct" style="text-align:center">';

    if ( $bFile )

    {

    echo '<a class="small" href="'.$oVIP->selfurl.'?tt=',$tt,'&amp;s=',$oSEC->id,'&amp;a=view">',$L['Preview'],'</a> &middot; <a class="small" href="upload/',$strSectionTags,'">',$L['Download'],'</a> &middot; <a class="small" href="qtf_adm_tags_upload.php?tt=',$tt,'&amp;v=tags_',$tt,'_',$intSecid.'.csv">',$L['Upload'],'</a> &middot; <a class="small" href="qtf_adm_change.php?tt=',$tt,'&amp;a=tags_del&amp;v=',$strSectionTags,'">',$L['Delete'],'</a>';

    }

    else

    {

    echo '<span class="disabled">',$L['Preview'],'</span> &middot; <span class="disabled">',$L['Download'],'</span> &middot; <a class="small" href="qtf_adm_tags_upload.php?tt=',$tt,'&amp;v=tags_',$tt,'_',$intSecid.'.csv">',$L['Upload'],'</a> &middot; <span class="disabled">',$L['Delete'],'</span>';

    }

    echo '</td></tr>',N;

  }

}

echo '</table>

';



// END TABS



echo '

</td>

</tr>

</table>

';



// PREVIEW FILE



if ( empty($strAction) ) 

{

  echo '<h2>',$L['Preview'],'</h2>';

  echo '<p class="disabled">',$L['E_nothing_selected'],'</p>';

}



if ( $strAction=='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" summary="tags">',N;

      foreach($arrTags as $strKey=>$strValue)

      {

      echo '<tr class="hidden rowlight">',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="qtf_find.php?a=tst&amp;s=',$intSection,'&amp;y=',date('Y'),'&amp;k1=-1&amp;k2=-1&amp;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 ( $strAction=='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 class="hidden rowlight">',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] : '&nbsp;'),'</td>',N;

    echo '<td class="hidden"><a class="small" href="qtf_find.php?a=tst&amp;s=',$strSection,'&amp;y=',date('Y'),'&amp;k1=-1&amp;k2=-1&amp;k3=',$strValue,'" title="',$L['Find_topic_tag'],'">',$L['Search'],'</a></td>',N;

    echo '</tr>';

    }

    echo '</table>',N;

    echo '</div>';

  }

}



// HTML END



include('qtf_adm_p_footer.php');



?>
Return current item: QuickTalk Forum