ACC SHELL

Path : /srv/www/vhosts/marevva/crossroadsfoundation/admin/page/
File Upload :
Current File : /srv/www/vhosts/marevva/crossroadsfoundation/admin/page/class.pageItemContent10.php

<?php

// functions
require_once( $serverFullPath.'functions.php' );
// ETS
require_once( $serverFullPath.'ets.php' );
	
class pageItemContent10 extends pageItemContent
{
	private $_pageItemType = 10;
	protected $_db;
	private $_pageID;
	private $_pathPage;
	
	// --------------------------------------------------------------------------------
	
	public function __construct( $db, $pageID, $_pathPage )
	{
		$this->_db = $db;
		$this->_pageID = $pageID;
		$this->_pathPage = '..' . $_pathPage . '/';
	}
	
	// --------------------------------------------------------------------------------
	
	public function insert( $position )
	{
		$return = array();
		
		if ( $this->_db->insertItem( 'pageItem', array( 'pageID'=>$this->_pageID, 'type'=>$this->_pageItemType, 'position'=>$position ) ) )
		{
			$newPageItemID = $this->_db->getLastID();
			
			if ( $this->_db->insertItem( 'pageItemContent'.$this->_pageItemType, array() ) )
			{
				$newPageItemContentID = $this->_db->getLastID();
				$this->_db->setItem( 'pageItem', $newPageItemID, array( 'pageItemContentID'=>$newPageItemContentID ) );
				$return['statusOK'] = 'Změny byly uloženy.';
			}
			else
			{
				$this->_db->deleteItem( 'pageItem', $newPageItemID );
				$return['statusError'] = 'Při ukládání dat(položky) vznikla chyba.';
			}				
		}
		else
		{
			$return['statusError'] = 'Při ukládání dat vznikla chyba.';
		}
		
			
		return $return;
	}
	
	// --------------------------------------------------------------------------------

	public function delete( $pageItemID )
	{
		$return = array();
		
		$pageItem = $this->_db->getItem( 'pageItem', $pageItemID );
		$pageItemContent = $this->_db->getItem( 'pageItemContent'.$this->_pageItemType, $pageItem['pageItemContentID'] );
		
		if ( isset( $pageItem['ID'] ) && isset( $pageItemContent['ID'] ) )
		{
			if ( $this->_db->deleteItem( 'pageItem', $pageItem['ID'] ) && 
				 $this->_db->deleteItem( 'pageItemContent'.$this->_pageItemType, $pageItemContent['ID'] ) )
			{					
				$return['statusOK'] = 'Položka byla smazána.';		
			}
			else
			{
				$return['statusError'] = 'Při mazání dat vznikla chyba.';
			}
		}
		else
		{
			$return['statusError'] = 'Při pokuse o mazání dat vznikla chyba.';
		}
			
		return $return;
	}
	
	// --------------------------------------------------------------------------------
	
	public function show( $pageItemID, $serverFullPath = '', $isAdmin = false )
	{		
		$pageItem = $this->_db->getItem( 'pageItem', $pageItemID );
		$pageItemContent = $this->_db->getItem( 'pageItemContent'.$this->_pageItemType, $pageItem['pageItemContentID'] );
		
		$htmlPageItem = new stdClass();
		
		$htmlPageItem->pageItemID = $pageItemID;
		
		$htmlPageItem->isAdmin = $isAdmin;
		
		if ( $isAdmin == false )
		{
			include_once( 'class.crProductList.php' );
			include( 'init-path.php' );
			$serverFullPath .= 'admin/page/';
			
			// setting
			//$settings = $this->_db->getItem( 'settings', 1 );
			
			$category = $this->_db->getItem( 'category', $pageItemContent['categoryID'] );
			
			$productList = new crProductList($this->_db);
			$productList->load( $category['url'] );
			$htmlPageItem->title = $category['title'];
			
			//$htmlPageItem->content = $productList->show( 'parts/productList.html', $productImageDir, $productImagesDir, 4 );
			if ( $productList->getType() == 1 )
			{
				$htmlPageItem->content = $productList->show( 'parts/productList.html', $productImageDir, $productImagesDir, 3, false );	
			}
			
			if ( $productList->getType() == 2 )
			{
				$htmlPageItem->content = $productList->show( 'parts/productList2.html', $productImageDir, $productImagesDir, 4, false );	
			}
			
			if ( $productList->getType() == 3 )
			{
				$htmlPageItem->content = $productList->show( 'parts/productList3.html', $productImageDir, $productImagesDir, 3, false );	
			}
			
			if ( $productList->getType() == 4 )
			{
				$htmlPageItem->content = $productList->show( 'parts/productList4.html', $productImageDir, $productImagesDir, 4, false );	
			}
			
		}
		else
		{
			$category = $this->_db->getItem( 'category', $pageItemContent['categoryID'] );
			
			$htmlPageItem->title = $category['title'];
		}
		
		// fixed save buttons
		$htmlPageItem->fixedSaveButtons = $this->fixedSaveButtonsBeforeEdit();
		
		return sprintt( $htmlPageItem, $serverFullPath . 'class.pageItemContent' . $this->_pageItemType . '-show.html' );
	}
	
	// --------------------------------------------------------------------------------
	
	public function edit( $pageItemID )
	{
		$pageItem = $this->_db->getItem( 'pageItem', $pageItemID );
		$pageItemContent = $this->_db->getItem( 'pageItemContent'.$this->_pageItemType, $pageItem['pageItemContentID'] );
		
		$htmlPageItem = new stdClass();
		
		$htmlPageItem->pageID = $this->_pageID;
		$htmlPageItem->pageItemID = $pageItemID;
		$htmlPageItem->pageItemType = $this->_pageItemType;
		
		$htmlPageItem->categoryID = $pageItemContent['categoryID'];
		
		$categories = $this->_db->getAllItems( 'category', " WHERE `categoryType`='product' ORDER BY `title` ASC " );
		if ( count( $categories ) > 0 )
		{
			$pi = 1;
			foreach ( $categories as $category )
			{
				$htmlPageItem->category[ $pi ]->ID = $category['ID'];
				$htmlPageItem->category[ $pi ]->title = $category['title'];
				
				$pi++;
			}
		}
		
		return sprintt( $htmlPageItem, 'page/class.pageItemContent' . $this->_pageItemType . '-edit.html' );
	}
	
	// --------------------------------------------------------------------------------
	
	public function save( $pageItemID )
	{
		$pageItem = $this->_db->getItem( 'pageItem', $pageItemID );
		$pageItemContent = $this->_db->getItem( 'pageItemContent'.$this->_pageItemType, $pageItem['pageItemContentID'] );
		
		// save data
		$this->_db->setItem( 'pageItemContent'.$this->_pageItemType, $pageItem['pageItemContentID'], array(
			'categoryID' => $_POST['categoryID']
		) );
		
		return 1;
	}
}

?>

ACC SHELL 2018