<?php
/*======================================================================================
Module: Articles
======================================================================================*/

// Check authorisation
if (!isset($gCms)) exit;

// Set needed objects
#$db = cmsms()->GetDb();
#$smarty = cmsms()->GetSmarty();

// Insert content operations class
$contentops = \ContentOperations::get_instance();

// Get Tab Redirect action
$tabto = isset($params['tabto']) ? preg_replace('/[^0-9a-zA-Z_]/','',$params['tabto']) : 'articles';

// Other things
$is_cart = (int)$this->GetPreference('cart_use');
$payment_modes = array ( 0=>$this->Lang('payment_advance'), 1=>$this->Lang('payment_cash_on_delivery'), 2=>$this->Lang('payment_direct_debit'), 3=>$this->Lang('payment_creadit_card') );
$salutation_modes = array ( 0=>$this->Lang('mr'), 1=>$this->Lang('ms') );
echo $this->donate;

// Show messages or errors
if (isset($params['errors'])) {
	if ($params['errors']) echo '<div style="border:3px solid #ff3333; margin:5px; padding:5px; font-weight:bold;">'.str_replace(',','<br />',$params['errors']).'</div>';
}
if (isset($params['message'])) {
	if ($params['message']) echo '<div style="border:3px solid #33ff33; margin:5px; padding:5px; font-weight:bold;">'.$params['message'].'</div>';
}

// Displays the Tabs
echo $this->StartTabHeaders();
if ( $this->CheckPermission('Articles: show orders') && $is_cart ) {
	echo $this->SetTabHeader('orders','<span style="color:#c00;">'.$this->Lang('orders').'</span>',$tabto=='orders'?true:false);
}
if ( $this->CheckPermission('Articles: modify articles') ) {
	echo $this->SetTabHeader('articles',$this->Lang('articles'),$tabto=='articles'?true:false);
}
if ( $this->CheckPermission('Articles: modify categories') ) {
	echo $this->SetTabHeader('categories',$this->Lang('categories'),$tabto=='categories'?true:false);
}
if ( $this->CheckPermission('Modify Templates') ) {
	echo $this->SetTabHeader('templates',$this->Lang('templates'),$tabto=='templates'?true:false);
}
if ( $this->CheckPermission('Articles: modify settings') ) {
	echo $this->SetTabHeader('prefs',$this->Lang('preferences'),$tabto=='prefs'?true:false);
}
echo $this->EndTabHeaders();

// Display the content of the tabs
echo $this->StartTabContent();
if ( $this->CheckPermission('Articles: show orders') && $is_cart ) {
	echo $this->StartTab('orders');
	include(dirname(__FILE__).'/function.admin_orders.php');
	echo $this->EndTab();
}
if ( $this->CheckPermission('Articles: modify articles') ) {
	echo $this->StartTab('articles');
	include(dirname(__FILE__).'/function.admin_articles.php');
	echo $this->EndTab();
}
if ( $this->CheckPermission('Articles: modify categories') ) {
	echo $this->StartTab('categories');
	include(dirname(__FILE__).'/function.admin_categories.php');
	echo $this->EndTab();
}
if ( $this->CheckPermission('Modify Templates') ) {
	echo $this->StartTab('templates');
	include(dirname(__FILE__).'/function.admin_templates.php');
	echo $this->EndTab();
}
if ( $this->CheckPermission('Articles: modify settings') ) {
	echo $this->StartTab('prefs');
	include(dirname(__FILE__).'/function.admin_prefs.php');
	echo $this->EndTab();
}
echo $this->EndTabContent();

// EOF