Beispiel #1
0
 /**
  * Controller
  */
 public function process()
 {
     $bIsEdit = false;
     if ($iId = $this->request()->getInt('id')) {
         if ($aStyle = Theme_Service_Style_Style::instance()->getForEdit($iId)) {
             $bIsEdit = true;
             $this->template()->assign(array('aForms' => $aStyle));
         }
     }
     $this->template()->setTitle($bIsEdit ? Phpfox::getPhrase('theme.editing_style') . ': ' . $aStyle['name'] : Phpfox::getPhrase('theme.create_new_style'))->setBreadcrumb(Phpfox::getPhrase('theme.themes'), $this->url()->makeUrl('admincp.theme'));
     if ($aVals = $this->request()->getArray('val')) {
         if ($bIsEdit) {
             if (Theme_Service_Style_Process::instance()->updateStyle($aStyle['style_id'], $aVals)) {
                 $this->url()->send('admincp.theme.style.add', array('id' => $aStyle['style_id']), Phpfox::getPhrase('theme.style_successfully_updated'));
             }
         } else {
             if (Theme_Service_Style_Process::instance()->addStyle($aVals)) {
                 $this->url()->send('admincp.theme.style.add', null, Phpfox::getPhrase('theme.style_successfully_added'));
             }
         }
     }
     if ($iThemeId = $this->request()->getInt('theme')) {
         if ($aTheme = Theme_Service_Theme::instance()->getTheme($iThemeId)) {
             $this->template()->setBreadcrumb($aTheme['name'], $this->url()->makeUrl('admincp.theme'))->assign(array('aForms' => array('theme_id' => $aTheme['theme_id'])));
         }
     }
     $this->template()->setBreadcrumb($bIsEdit ? Phpfox::getPhrase('theme.editing_style') . ': ' . $aStyle['name'] : Phpfox::getPhrase('theme.create_style'), null, true)->assign(array('bIsEdit' => $bIsEdit, 'aStyles' => Theme_Service_Style_Style::instance()->get(), 'aThemes' => Theme_Service_Theme::instance()->get()));
 }
Beispiel #2
0
    /**
     * Controller
     */
    public function process()
    {
        if (Phpfox::getParam('core.phpfox_is_hosted')) {
            $this->url()->send('admincp');
        }
        if ($aVals = $this->request()->getArray('val')) {
            if (Theme_Service_Style_Process::instance()->addCss($aVals)) {
                $this->url()->send('admincp.theme.style.css.add', null, Phpfox::getPhrase('theme.css_file_successfully_added'));
            }
        }
        if (Phpfox::getParam('core.enabled_edit_area')) {
            $this->template()->setHeader(array('editarea/edit_area_full.js' => 'static_script', '<script type="text/javascript">				
						editAreaLoader.init({
							id: "js_template_content"	
							,start_highlight: true
							,allow_resize: "both"
							,allow_toggle: false
							,word_wrap: false
							,language: "en"
							,syntax: "css"
						});		
					</script>'));
        }
        $this->template()->setTitle(Phpfox::getPhrase('theme.creating_css_file'))->setBreadcrumb(Phpfox::getPhrase('theme.creating_css_file'))->assign(array('aStyles' => Theme_Service_Style_Style::instance()->get()));
    }
Beispiel #3
0
 /**
  * Controller
  */
 public function process()
 {
     if (Phpfox::getParam('core.phpfox_is_hosted')) {
         $this->url()->send('admincp');
     }
     $oArchiveImport = Phpfox::getLib('archive.import')->set(array('zip'));
     $bOverwrite = $this->request()->getInt('overwrite') ? true : false;
     $sTheme = $this->request()->get('parent-theme');
     if (($sStyleToInstall = $this->request()->get('install')) && Theme_Service_Style_Process::instance()->installStyleFromFolder($sTheme, $sStyleToInstall)) {
         $this->url()->send('admincp.theme.style.import', null, Phpfox::getPhrase('theme.style_successfully_imported'));
     }
     $this->template()->setTitle(Phpfox::getPhrase('theme.import_styles'))->setBreadcrumb(Phpfox::getPhrase('theme.themes'), $this->url()->makeUrl('admincp.theme'))->setBreadcrumb(Phpfox::getPhrase('theme.import_styles'), null, true)->assign(array('aNewStyles' => Theme_Service_Style_Style::instance()->getNewStyles()));
 }
Beispiel #4
0
 /**
  * Controller
  */
 public function process()
 {
     $this->_setMenuName('admincp.theme');
     $iId = $this->request()->getInt('id');
     $aTheme = Theme_Service_Theme::instance()->getTheme($iId);
     if (!isset($aTheme['theme_id'])) {
         return Phpfox_Error::display(Phpfox::getPhrase('theme.not_a_valid_theme'));
     }
     if ($iDeleteId = $this->request()->getInt('delete')) {
         if (Theme_Service_Style_Process::instance()->delete($iDeleteId)) {
             $this->url()->send('admincp.theme.style', array('id' => $aTheme['theme_id']), Phpfox::getPhrase('theme.style_successfully_deleted'));
         }
     }
     $this->template()->setTitle(Phpfox::getPhrase('theme.managing_styles_for') . ': ' . $aTheme['name'])->setBreadcrumb(Phpfox::getPhrase('theme.themes'), $this->url()->makeUrl('admincp.theme'))->setBreadcrumb($aTheme['name'], $this->url()->makeUrl('admincp.theme'))->setBreadcrumb(Phpfox::getPhrase('theme.styles'), null, true)->assign(array('aStyles' => Theme_Service_Style_Style::instance()->get('theme_id = ' . $this->request()->getInt('id')), 'aTheme' => $aTheme));
 }
Beispiel #5
0
 /**
  * Controller
  */
 public function process()
 {
     $this->_setMenuName('admincp.theme');
     $aStyle = Theme_Service_Style_Style::instance()->getStyle($this->request()->getInt('id'));
     if (!isset($aStyle['theme_id'])) {
         return Phpfox_Error::display(Phpfox::getPhrase('theme.not_a_valid_style'));
     }
     if ($this->request()->get('revert')) {
         if (Theme_Service_Style_Process::instance()->revertLogo($aStyle['style_id'])) {
             $this->url()->send('admincp.theme.style.logo', array('id' => $aStyle['style_id']), Phpfox::getPhrase('theme.logo_successfully_reverted'));
         }
     }
     if (!empty($_FILES['logo'])) {
         $aImage = Phpfox_File::instance()->load('logo', array('jpg', 'gif', 'png'));
         if (isset($aImage['tmp_name']) && Theme_Service_Style_Process::instance()->changeLogo($aStyle['style_id'], $aImage, $this->request()->get('resize') == '1' ? true : false)) {
             $this->url()->send('admincp.theme.style.logo', array('id' => $aStyle['style_id']), Phpfox::getPhrase('theme.logo_successfully_uploaded'));
         }
     }
     list($sCurrentStyleLogo, $bIsNewLogo, $iWidth, $iHeight) = Theme_Service_Style_Style::instance()->getCurrentLogo($aStyle['style_id']);
     $this->template()->setTitle(Phpfox::getPhrase('theme.change_site_logo'))->setBreadcrumb(Phpfox::getPhrase('theme.themes'), $this->url()->makeUrl('admincp.theme'))->setBreadcrumb($aStyle['theme_name'], $this->url()->makeUrl('admincp.theme'))->setBreadcrumb(Phpfox::getPhrase('theme.styles'), $this->url()->makeUrl('admincp.theme.style', array('id' => $aStyle['theme_id'])))->setBreadcrumb($aStyle['name'], $this->url()->makeUrl('admincp.theme.style', array('id' => $aStyle['theme_id'])))->setBreadcrumb(Phpfox::getPhrase('theme.change_logo'), null, true)->assign(array('aStyle' => $aStyle, 'sCurrentStyleLogo' => $sCurrentStyleLogo, 'bIsNewLogo' => $bIsNewLogo, 'iWidth' => 100, 'iHeight' => 100));
 }
Beispiel #6
0
 public function installThemeFromFolder($sTheme, $mForce = false)
 {
     if (!$mForce) {
         $sDir = PHPFOX_DIR_THEME . 'frontend' . PHPFOX_DS . $sTheme . PHPFOX_DS;
         if (!file_exists($sDir . 'phpfox.xml')) {
             return Phpfox_Error::set('Not a valid theme to install.');
         }
     }
     $iInstalled = (int) $this->database()->select('COUNT(*)')->from(Phpfox::getT('theme'))->where('folder = \'' . $this->database()->escape($sTheme) . '\'')->execute('getField');
     if ($iInstalled) {
         return Phpfox_Error::set('This theme is already installed.');
     }
     $aParams = Phpfox::getLib('xml.parser')->parse(file_get_contents($mForce ? PHPFOX_DIR_CACHE . $mForce . PHPFOX_DS . 'upload/theme/frontend/' . $sTheme . '/phpfox.xml' : $sDir . 'phpfox.xml'));
     $aForm = array('name' => array('type' => 'string:required', 'message' => Phpfox::getPhrase('theme.theme_requires_a_name')), 'folder' => array('type' => 'string:required', 'message' => Phpfox::getPhrase('theme.theme_requires_a_folder_name')), 'created' => array('type' => 'int'), 'creator' => array('type' => 'string'), 'website' => array('type' => 'string'), 'version' => array('type' => 'string'), 'parent_id' => array('type' => 'string'));
     $aParams['parent_id'] = 0;
     if (!empty($aParams['parent'])) {
         $aParent = Theme_Service_Theme::instance()->getTheme($aParams['parent'], true);
         if (isset($aParent['theme_id'])) {
             $aParams['parent_id'] = $aParent['theme_id'];
         }
     }
     $aParams = $this->validator()->process($aForm, $aParams);
     if (!empty($aParams['creator'])) {
         $aParams['creator'] = $this->preParse()->clean($aParams['creator'], 255);
     }
     if (!Phpfox_Error::isPassed()) {
         return false;
     }
     $aParams['is_active'] = 1;
     $aParams['is_default'] = 0;
     $iId = $this->database()->insert(Phpfox::getT('theme'), $aParams);
     // I dont think we need to clear cache for profiles here, seems to be working fine without doing this -Purefan
     if ($mForce && Phpfox::getParam('core.phpfox_is_hosted')) {
         $sStyleDir = PHPFOX_DIR_CACHE . $mForce . PHPFOX_DS . 'upload' . PHPFOX_DS . 'theme' . PHPFOX_DS . 'frontend' . PHPFOX_DS . $aParams['folder'] . PHPFOX_DS . 'style' . PHPFOX_DS;
     } else {
         $sStyleDir = PHPFOX_DIR_THEME . 'frontend' . PHPFOX_DS . $aParams['folder'] . PHPFOX_DS . 'style' . PHPFOX_DS;
     }
     $hDir = opendir($sStyleDir);
     while ($sFolder = readdir($hDir)) {
         if ($sFolder == '.' || $sFolder == '..') {
             continue;
         }
         if (!file_exists($sStyleDir . $sFolder . PHPFOX_DS . 'phpfox.xml')) {
             continue;
         }
         $iInstalled = (int) $this->database()->select('COUNT(*)')->from(Phpfox::getT('theme_style'))->where('theme_id = ' . (int) $iId . ' AND folder = \'' . $this->database()->escape($sFolder) . '\'')->execute('getField');
         if (!$iInstalled) {
             Theme_Service_Style_Process::instance()->installStyleFromFolder($aParams['folder'], $sFolder, $mForce);
         }
     }
     closedir($hDir);
     if ($mForce && Phpfox::getParam('core.phpfox_is_hosted')) {
         $aFiles = Phpfox_File::instance()->getAllFiles(PHPFOX_DIR_CACHE . $mForce . PHPFOX_DS);
         $aCssContent = array();
         foreach ($aFiles as $sFile) {
             if ($sFile == '.' || $sFile == '..' || empty($sFile)) {
                 continue;
             }
             if (substr($sFile, -4) == '.css') {
                 preg_match('/(.*)\\/style\\/(.*)\\/css\\/(.*)/i', $sFile, $aMatches);
                 if (isset($aMatches[2])) {
                     if (!isset($aCssContent[$aMatches[2]])) {
                         $aCssContent[$aMatches[2]] = '';
                     }
                     $aCssContent[$aMatches[2]] .= file_get_contents($sFile);
                 }
             } elseif (substr($sFile, -9) == '.html.php') {
                 $sTypeId = 'layout';
                 $sModuleId = null;
                 $aNameParts = explode('/', $sFile);
                 $sTemplateName = $aNameParts[count($aNameParts) - 1];
                 $sTemplateContent = file_get_contents($sFile);
                 $this->database()->insert(Phpfox::getT('theme_template'), array('is_custom' => '1', 'folder' => $sTheme, 'type_id' => $sTypeId, 'product_id' => 'phpfox', 'module_id' => $sModuleId, 'name' => $sTemplateName, 'html_data' => $sTemplateContent, 'time_stamp' => PHPFOX_TIME));
             }
         }
         if (!empty($sFile)) {
             foreach ($aCssContent as $sStyleName => $sStyleContent) {
                 $this->_sStyleDir = $sStyleDir . $sStyleName;
                 $sStyleContent = preg_replace_callback('/url\\((.*)\\)/i', array($this, 'replaceCdnImages'), $sStyleContent);
                 $iStyleId = $this->database()->select('style_id')->from(Phpfox::getT('theme_style'))->where('folder = \'' . $this->database()->escape($sStyleName) . '\'')->execute('getSlaveField');
                 if ($iStyleId) {
                     $sName = md5(PHPFOX_IS_HOSTED_SCRIPT . uniqid()) . '.css';
                     $sTempFile = PHPFOX_DIR_CACHE . $sName;
                     $hFile = fopen($sTempFile, 'w+');
                     fwrite($hFile, $sStyleContent);
                     fclose($hFile);
                     Phpfox::getLib('cdn')->put($sTempFile, 'file/static/' . $sName);
                     unlink($sTempFile);
                     $this->database()->delete(Phpfox::getT('theme_css'), 'style_id = ' . (int) $iStyleId);
                     $this->database()->insert(Phpfox::getT('theme_css'), array('module_id' => null, 'product_id' => null, 'style_id' => $iStyleId, 'file_name' => 'custom.css', 'css_data' => $sStyleContent, 'css_data_original' => $sName, 'full_name' => null, 'time_stamp' => PHPFOX_TIME));
                 }
             }
         }
         Phpfox_File::instance()->delete_directory(PHPFOX_DIR_CACHE . $mForce . PHPFOX_DS);
     }
     return $iId;
 }
Beispiel #7
0
 public function updateDesign($aVals)
 {
     Phpfox::isUser(true);
     if (isset($aVals['order'])) {
         $this->database()->delete(Phpfox::getT('user_dashboard'), 'user_id = ' . Phpfox::getUserId() . ' AND is_hidden = 0');
         foreach ($aVals['order'] as $sCacheId => $aOrder) {
             $aKey = array_keys($aOrder);
             $aValue = array_values($aOrder);
             $this->database()->insert(Phpfox::getT('user_dashboard'), array('user_id' => Phpfox::getUserId(), 'cache_id' => $sCacheId, 'block_id' => $aKey[0], 'ordering' => $aValue[0]));
         }
     }
     if (isset($aVals['cache_id'])) {
         $this->hideBlock($aVals['cache_id'], $aVals['is_installed'] ? 1 : 0);
     }
     if (isset($aVals['style_id'])) {
         if (Theme_Service_Style_Process::instance()->setStyle($aVals['style_id'])) {
         }
     }
 }
Beispiel #8
0
 public function updateStyleDefaultState()
 {
     if (Theme_Service_Style_Process::instance()->setToDefault($this->get('id'), $this->get('active'))) {
     }
 }