HEX
Server: Apache
System: Linux sg241.singhost.net 2.6.32-896.16.1.lve1.4.51.el6.x86_64 #1 SMP Wed Jan 17 13:19:23 EST 2018 x86_64
User: honghock (909)
PHP: 8.0.30
Disabled: passthru,system,shell_exec,show_source,exec,popen,proc_open
Upload Files
File: //opt/alt/php55/usr/share/pear/RVSeagullMod/modules/tryout/classes/TemplateCategoryMgr.php
<?php
//require_once SGL_MOD_DIR . '/default/classes/DA_Default.php';
require_once 'Config.php';
require_once( SGL_MOD_DIR . '/tryout/classes/WebDao/SitebuilderDao.php');
require_once( SGL_MOD_DIR . '/tryout/classes/SitebuilderDao/DbWrapper.php');
include_once( 'TemplateList.php' );

/**
 * Template Category
 *
 * @package rvglobalsoft
 * @author  amarin - 20060628
 */
class TemplateCategoryMgr extends SGL_Manager
{
    var $oTemplateList;
    function TemplateCategoryMgr()
    {
        parent::SGL_Manager();
        
        $this->pageTitle    = 'Template Category';
        $this->template     = 'Category.html';
        //$this->da           = DA_Default::singleton();
        $this->_aActionsMapping =  array(
            'view'      => array('view')
            );
        $this->oTemplateList = new TemplateList();   
        ///fix PHP 5.3
        $this->oTemplateList = &$this->oTemplateList;
    }
    
    function validate($req, &$input)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        
        $oSitebuilder = new SitebuilderDao();
        $aSitebuilderConfig = $oSitebuilder->getSitebuilderConfig();
        $dbh = $oSitebuilder->rvsConnectDb();
        $aSitebuilderConfig['tryoutlogin'] = $this->conf['tryoutlogin'];
        $this->oTemplateList->registRvsConf($aSitebuilderConfig, $dbh);
             
        require_once( SGL_MOD_DIR . '/tryout/classes/SitebuilderDao/TemplateDao.php');
        require_once( SGL_MOD_DIR . '/tryout/classes/SitebuilderDao/TemplateImportDao.php');
        require_once( SGL_MOD_DIR . '/tryout/classes/SitebuilderDao/CategoryDao.php');
        $oCategoryDao = CategoryDao::singleton($autoload = false);
        $oCategoryDao->registRvsConf($aSitebuilderConfig, $dbh);
        $oTemplateDao = TemplateDao::singleton($autoload = false);
        $oTemplateDao->registRvsConf($aSitebuilderConfig, $dbh);
        $oTemplateImportDao = TemplateImportDao::singleton($autoload = false);
        $oTemplateImportDao->registRvsConf($aSitebuilderConfig, $dbh);
        // Initialise Db DataObject
        $oSitebuilder->rvsInitialiseDbDataObject();
       
        $aTotalTemplate = $this->oTemplateList->_getAllTemplateData($input);
        $input->totalTemplate = count($aTotalTemplate);
   
        $this->validated        = true;
        $input->pageTitle       = $this->pageTitle;
        $input->masterTemplate  = 'masterMinimal.html';
        $input->template        = $this->template;
         $input->action = ($req->get('action')) ? $req->get('action') : 'view';
        $input->template_type_id = $req->get('templatestyle') ? $req->get('templatestyle') : '0';
        $input->category_id = $req->get('select_category_id') ? $req->get('select_category_id') : '0';
        $input->picture_style = $req->get('nowshow') ? $req->get('nowshow') : '0';
        $input->getNumPage = $req->get('getNumPage');
        $input->managerName = $req->get('managerName');
        $input->submitUserImport = $req->get('submitUserImport');
        $categoryId = $req->get('select_category_id');
        $input->select_category_id = $categoryId ? $categoryId : 0;
        $input->ref_category_id = $input->category_id;
        $input->ref_template_item_id = '';
        $input->tryoutWebsite = ($req->get('moduleName') == 'tryout') ? true : false;
        $input->productIdSearch = $req->get('productIdSearch');
        
        $aInput = $this->getFileSystemPath();
        $input->rvs_url_www = $aInput['rvs_url_www']; 
        $input->rvs_url_css = (isset($aInput['url_php_suexec'])) ? $aInput['url_php_suexec'] : $input->rvs_url_www;
        $input->pagerUrl = $aInput['pagerUrl'];
        $input->noLink = '1';
        $input->tryoutMode = '1';
      
        define('CPMODE','tryout');
        define('RVSITEBUILDER_URL_WWW', $aInput['pagerUrl']);
        define('INDEX_PHPSU', $this->conf['site']['frontScriptName']);
        
     
        
     $input->aShowData = $this->oTemplateList->_generateCodeHTMLCategory($input, $dbh);
        // Show Current Template or Category Image
        $input->categoryData = $this->oTemplateList->_getCurrentTemplate($input, $dbh);
         
        // Generate Selecton
        $input->templateTypeOptions = $this->oTemplateList->_listTemplateType($input, $dbh);
        $input->categoryOptions = $this->oTemplateList->_listCategory($input->category_id, $dbh);

        //Generate select category per page
        $input->listNumPageOption = $this->oTemplateList->listNumPageCategory($input->path, $input->getNumPage);

        ///Start Get TemplateType AND ListCategory
        $aTemplateType = $this->oTemplateList->getListTemplateType();
        $aTemplateType = $this->oTemplateList->unSetDownloadTemplate($aTemplateType, $input->submitUserImport);
        $aTemplateType[0] = 'All Style' ;
         $key = array_search("DIY Template",$aTemplateType);
         
        $aTemplateType = $this->oTemplateList->getTranslation($aTemplateType);  
        ksort($aTemplateType);
        $input->aTemplateType = $this->setFocus($aTemplateType, $input->template_type_id);
         if (isset($input->aTemplateType[$key])) {
             unset($input->aTemplateType[$key]);
         }
        $aCategory = $this->oTemplateList->getCategoryList();
        $aCategory[0] = 'All Categories'; 
        $aCategory = $this->oTemplateList->getTranslation($aCategory);
        ksort($aCategory);
        $input->aCategory = $this->setFocus($aCategory, $input->select_category_id);

        $input->selectCategoryName = $aCategory[$input->select_category_id];
        $input->isAllCategory = ($input->select_category_id == 0) ? true : false;
        ///End Get TemplateType AND ListCategory*/
  
        //$input->siteUrl = SGL_BASE_URL;
        if (isset($aErrors) && count($aErrors)) {
            SGL::raiseMsg('Please fill in the indicated fields');
            $input->error = $aErrors;
            $this->validated = false;
        }
    }
    
    function _cmd_view(&$input, &$output)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
    }
    
    
    function setFocus($aCategoryFocus , $focusID)
    {
     $aSetFocusN = array();
        foreach ($aCategoryFocus as $kCategoryFocus => $vCategoryFocus){
         $aSetFocusN[$kCategoryFocus]['name'] = $vCategoryFocus;   
        }
        $aSetFocusN[$focusID]['focus'] = true;
        return $aSetFocusN;
    }
    
    function getFileSystemPath()
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        
        if (preg_match('/^192\.168\.1\./i',$_SERVER['HTTP_HOST'])) {
            $aInput['templateUrl'] = SGL_BASE_URL . '/../../../rvsitebuilder/template';
            $aInput['templatePath'] = SGL_PATH  . '/../../../rvsitebuilder/template';               
            $aInput['rvs_url_www'] = SGL_BASE_URL  . '/../../../rvsitebuilder/www';
            $aInput['pagerUrl'] = SGL_BASE_URL . '/index.php/tryout/templatecategory';
        } else {
            $aInput['templateUrl'] = SGL_BASE_URL . '/../../template';
            $aInput['templatePath'] = SGL_PATH  . '/../../template';     
            $aInput['rvs_url_www'] = SGL_BASE_URL  . '/../../www';     
            $aInput['pagerUrl'] = SGL_BASE_URL . '/' . $this->conf['site']['frontScriptName'] . '/tryout/templatecategory';
            if ($this->conf['site']['frontScriptName'] == "index.php?" || preg_match("/cgi|apache2filter/i", php_sapi_name())) {
                $aInput['url_php_suexec'] = SGL_BASE_URL  . '/../../phpsuexec/www';
            }
        }
        define('TEMPLATE_PATH', $aInput['templatePath']);
        define('TEMPLATE_URL', $aInput['templateUrl']);        
        return $aInput;
    }
    
    
}
?>