Your IP : 216.73.217.69


Current Path : /home/semix18/public_html/optimum-wycena.pl/core/classes/
Upload File :
Current File : /home/semix18/public_html/optimum-wycena.pl/core/classes/class.block.php

<?php
/**
*	Dobi System
*
*	Terms of use and legal restrictions:
*   PLEASE READ THESE TERMS ( www.dobi.pl/doc/license/ ) CAREFULLY BEFORE USING THIS PRODUCT. 
*	USING THIS PRODUCT INDICATES THAT YOU ACCEPT THESE TERMS. 
*	IF YOU DO NOT ACCEPT THESE TERMS , DO NOT USE THIS PRODUCT.
*
*	PHP 5.1.2 and later 
*
*	@license	www.dobi.pl/doc/license/ Dobi License 1.0
*   @copyright	Copyright (c) 2005-2006 Michał 'Cube' Daniel ( http://www.dobi.pl )
* 	@link		www.dobi.pl
*	@package	Dobi Core
*	@version 	1.0, 2006/08/10 11:57
*   @author		Michał 'Cube' Daniel cube@dobi.pl		
*
*/

class block
{
	protected $block_mixContent;
    protected $block_strPosition;
	protected $block_strLanguage;   
	protected $block_header_content = array();  	 
    protected $block_arrOrder = array();

	public function __construct( $block_position )
	{
		// setting block name
		$this->block_strPosition = $block_position;
		
		// setting language
		$language = Registry::getObject('language');
	    $this->block_strLanguage = $language->getSessionLanguage();		    
	}	

	public function getHeaderContent()
	{
		$content = '';
		foreach ($this -> block_header_content as $style)
		{
			$content .= $style;
		}
		return $content;
	}

	public function getBlockContent( $theme_name )
	{
	    $this->prepareBlockOrder();
	    $block_types = config::getSettings('block_types');
	    $content = '';
	    
	    $dbRC = Registry::getObject('dbRC');
	    
	    if ($this->block_arrOrder == 0) return $content;

	    foreach ($this->block_arrOrder as $value)
	    {
			$dbRC->rowCache( 'block_' . $value, '*', 'blocks', 'bloc_id="'.$value.'"');
			$dbRC->setName( 'block_' . $value );
	        
	        if (!$dbRC->getRow('bloc_active')) continue;
	        
			$style_path = DOBI_BLOCKS_DIR . $dbRC->getRow('bloc_type') . '/' . $dbRC->getRow('bloc_type') .'.css';
            if (!isset($this -> block_header_content[$dbRC->getRow('bloc_type')]))
            {
		    	if (file_exists($style_path)) 
            	{
                	$this -> block_header_content[$dbRC->getRow('bloc_type')] =  '<link rel="stylesheet" type="text/css" href="' . $style_path . '" />';
				}			
			}

	        if (array_key_exists($dbRC->getRow('bloc_type'), $block_types))
	        {
	          	$block_title = $dbRC->getRow('bloc_title');
			  	$block_content = $dbRC->getRow('bloc_content');
			}
            else
            {
                $file_path = DOBI_BLOCKS_DIR . $dbRC->getRow('bloc_type') . '/' . $dbRC->getRow('bloc_type') . 'Block.php';
				$translation_path = DOBI_BLOCKS_DIR . $dbRC->getRow('bloc_type') . '/languages/' . $this->block_strLanguage . '/translation.php';  

                if (file_exists($translation_path)) 
                {
                  	 require_once( $translation_path );
				}
				else Dobi::exception( 'dobiExcBlock', TRANSLATE, _DOBI_BLOCK_ERR_1_ . ' <span style="font-weight: bold;">' . $translation_path  . '</span> ' . _DOBI_BLOCK_ERR_2_ . $this->block_strPosition);
				if (file_exists($file_path)) 
                {
                	require_once( $file_path );	  
				}
				else Dobi::exception( 'dobiExcBlock', EXISTS, _DOBI_BLOCK_ERR_1_ . ' <span style="font-weight: bold;">' . $file_path  . '</span> ' . _DOBI_BLOCK_ERR_2_ . $this->block_strPosition);
								
				$block_title = $dbRC->getRow('bloc_title');
				startBufor();
                $block = $dbRC->getRow('bloc_type') . 'Block';
				$block = new $block( $dbRC->getRow('bloc_content') );
				if ($block instanceof DobiBlock)
				{
				    $block->_getBlock(); 
				}
				else
				{
				    Dobi::exception( 'dobiExcBlock', FATAL, _DOBI_BLOCK_ERR_3_ . 'DobiBlock');
				}	
				$block_content = getBufor();
	            cleanBufor();	    
			}
			
			startBufor();
		    include(DOBI_THEMES_DIR . $theme_name . '/' . $this->block_strPosition . '.php'); 
		    $content .= getBufor();
	        cleanBufor();	        
			$dbRC->clear();		  
		}
	    return $content;
	}
	
	public function prepareBlockOrder()
	{
	  	$dbC = Registry::getObject('dbC');
	  	$amount = $dbC->count( $this->block_strPosition, 'bloc_position', 'blocks_order', 'bloc_position="'.$this->block_strPosition.'" AND bloc_language="'.$this->block_strLanguage.'"');
	    if ($amount > 0)
	    { 
			$this->getBlockOrder(); 
		}
		else
		{
	    	$this->setBlockOrder(); 
		}
	}
	
	protected function getBlockOrder()
	{
	    $dbRC = Registry::getObject('dbRC');		
		$dbRC->rowCache( $this->block_strPosition, 'bloc_order_content', 'blocks_order', 'bloc_position="'.$this->block_strPosition.'" AND bloc_language="'.$this->block_strLanguage.'"');
		$dbRC->setName($this->block_strPosition);
		$this->block_arrOrder = unserialize(stripslashes($dbRC->getRow('bloc_order_content')));	
		$dbRC->clear();	  
	}
	
	protected function setBlockOrder()
	{
	    $dbRC = Registry::getObject('dbRC');
	    $dbUDECA = Registry::getObject('dbUDECA');
		$dbRC->rowCache( 'set_block_order', 'bloc_id', 'blocks', 'bloc_position="'.$this->block_strPosition.'" AND (bloc_language="'.$this->block_strLanguage.'" OR bloc_language="")', 'bloc_id ASC');
		$dbRC->setName( 'set_block_order' );
		if ($dbRC->getRowsAmount() > 0)
		{
			$this->block_arrOrder = array();
			while ($dbRC->rowExists())
			{
				$this->block_arrOrder[] = $dbRC->getRow('bloc_id');  
				$dbRC->increment();
			}
			$dbUDECA->setMapper( false );
			$dbUDECA->insert( 'blocks_order',  array('bloc_position' 	  => $this->block_strPosition,
													 'bloc_language'	  => $this->block_strLanguage,		
													 'bloc_order_content' => addslashes(serialize($this->block_arrOrder))));
			$dbUDECA->execute();
			$dbUDECA->clear();	  
		}
        else $this->block_arrOrder = 0;	
	}	
}

?>