/** * 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())); }
/** * 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())); }
/** * Controller */ public function process() { if (!defined('PHPFOX_IN_DESIGN_MODE') || defined('PHPFOX_PROFILE_INFO_PAGE')) { return false; } $aDesigner = $this->getParam('aDesigner', false); if ($this->request()->get('reset_form')) { if (Phpfox::getService('theme.process')->resetCss($aDesigner['type_id'], $this->request()->getArray('css'))) { $this->url()->forward($aDesigner['design_page'] . 'advanced/#' . $this->request()->get('reset_group')); } } if ($this->request()->get('resetblock')) { if (Phpfox::getService('theme.process')->resetBlock($aDesigner['type_id'])) { $this->url()->forward($aDesigner['design_page'] . 'block/'); } } $aStlyes = Theme_Service_Style_Style::instance()->getStyles(); $this->template()->assign(array('aStlyes' => $aStlyes, 'aDesigner' => $aDesigner, 'aFonts' => Phpfox::getLib('parse.css')->getFonts(), 'aFontSizes' => Phpfox::getLib('parse.css')->getFontSizes(), 'aFontWeights' => Phpfox::getLib('parse.css')->getFontWeights(), 'aFontStyles' => Phpfox::getLib('parse.css')->getFontStyles(), 'aPositions' => Phpfox::getLib('parse.css')->getPositions(), 'aBorderWidths' => Phpfox::getLib('parse.css')->getBorderWidths(), 'aBorderStyles' => Phpfox::getLib('parse.css')->getBorderStyles(), 'aPaddingSizes' => Phpfox::getLib('parse.css')->getPaddingSizes(), 'aTextAlign' => Phpfox::getLib('parse.css')->getTextAlign(), 'aTextTransforms' => Phpfox::getLib('parse.css')->getTextTransforms(), 'aTextDecorations' => Phpfox::getLib('parse.css')->getTextDecorations(), 'iTestStyleId' => $this->request()->get('test_style_id'), 'sResetGroup' => 'body', 'sResetJs' => '')); if ($this->request()->get('req3') == 'advanced') { $this->template()->assign('sResetJs', '<script type="text/javascript">$Behavior.theme_block_design = function() { if (!empty(window.location.hash)) { rebuilt_menu_design(window.location.hash); } };</script>'); } if (isset($aDesigner['block'])) { $this->template()->assign('aBlocks', Phpfox::getService('core')->getBlocks($aDesigner['block'], $aDesigner['item_id'], $aDesigner['type_id'])); } }
/** * Controller */ public function process() { $oArchiveExport = Phpfox::getLib('archive.export')->set(array('zip')); if ($aData = Theme_Service_Style_Style::instance()->export($this->request()->getInt('id'))) { $oArchiveExport->download('phpfox-style-' . $aData['name'] . '', 'zip', $aData['folder']); } }
/** * Controller */ public function process() { $aSubBlocks = Admincp_Service_Block_Block::instance()->get($this->request()->get('m_connection'), $this->request()->get('style_id', 0)); $aModules = array(); foreach ($aSubBlocks as $iKey => $aRow) { $aModules[$aRow['location']][] = $aRow; } $this->template()->assign(array('aModules' => $aModules, 'aStyles' => Theme_Service_Style_Style::instance()->get(), 'sConnection' => $this->request()->get('m_connection'), 'iStyleId' => $this->request()->get('style_id', 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())); }
/** * Controller */ public function process() { $aTheme = Theme_Service_Theme::instance()->getTheme($this->request()->getInt('theme')); if (!isset($aTheme['theme_id'])) { return Phpfox_Error::display(Phpfox::getPhrase('theme.theme_is_not_valid')); } $oArchiveExport = Phpfox::getLib('archive.export')->set(array('zip')); if ($aVals = $this->request()->get('val')) { if ($aData = Theme_Service_Theme::instance()->export($aVals)) { $oArchiveExport->download('phpfox-theme-' . $aData['name'] . '', 'zip', $aData['folder']); } } $this->template()->setTitle(Phpfox::getPhrase('theme.export_theme'))->setBreadcrumb(Phpfox::getPhrase('theme.themes'), $this->url()->makeUrl('admincp.theme'))->setBreadCrumb(Phpfox::getPhrase('theme.export_theme'), $this->url()->makeUrl('current'))->setBreadcrumb($aTheme['name'], null, true)->assign(array('aStyles' => Theme_Service_Style_Style::instance()->get(array('theme_id = ' . $aTheme['theme_id'])), 'aTheme' => $aTheme)); }
/** * 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)); }
/** * Controller */ public function process() { Phpfox::getUserParam('admincp.can_add_new_block', true); $bIsEdit = false; if (($iEditId = $this->request()->getInt('id')) || ($iEditId = $this->request()->getInt('block_id'))) { $aRow = Admincp_Service_Block_Block::instance()->getForEdit($iEditId); $bIsEdit = true; $this->template()->assign(array('aForms' => $aRow, 'aAccess' => empty($aRow['disallow_access']) ? null : unserialize($aRow['disallow_access']))); } $aValidation = array('product_id' => Phpfox::getPhrase('admincp.select_product'), 'location' => Phpfox::getPhrase('admincp.select_block_placement'), 'is_active' => Phpfox::getPhrase('admincp.specify_block_active')); $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation)); if ($aVals = $this->request()->getArray('val')) { if ($oValid->isValid($aVals)) { if ($bIsEdit) { $sMessage = Phpfox::getPhrase('admincp.successfully_updated'); $aUrl = array('block', 'add', 'id' => $aRow['block_id']); Phpfox::getService('admincp.block.process')->update($aRow['block_id'], $aVals); } else { $sMessage = Phpfox::getPhrase('admincp.block_successfully_added'); $aUrl = array('block'); Phpfox::getService('admincp.block.process')->add($aVals); } $this->url()->send('admincp', $aUrl, $sMessage); } } 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: "source_code" ,start_highlight: true ,allow_resize: "both" ,allow_toggle: false ,word_wrap: false ,language: "en" ,syntax: "php" }); </script>')); } $aStyles = Theme_Service_Style_Style::instance()->getStyles(); if ($bIsEdit) { foreach ($aStyles as $iKey => $aStyle) { if (isset($aRow['style_id']) && isset($aRow['style_id'][$aStyle['style_id']])) { $aStyles[$iKey]['block_is_selected'] = $aRow['style_id'][$aStyle['style_id']]; } } } $this->template()->assign(array('aProducts' => Admincp_Service_Product_Product::instance()->get(), 'aControllers' => Phpfox::getService('admincp.component')->get(true), 'aComponents' => Phpfox::getService('admincp.component')->get(), 'aUserGroups' => Phpfox::getService('user.group')->get(), 'sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(), 'bIsEdit' => $bIsEdit, 'aStyles' => $aStyles))->setTitle(Phpfox::getPhrase('admincp.block_manager'))->setBreadcrumb(Phpfox::getPhrase('admincp.block_manager'), $this->url()->makeUrl('admincp.block'))->setBreadcrumb($bIsEdit ? Phpfox::getPhrase('admincp.editing') . ': ' . (empty($aRow['m_connection']) ? Phpfox::getPhrase('admincp.site_wide') : $aRow['m_connection']) . (empty($aRow['component']) ? '' : '::' . rtrim(str_replace('|', '::', $aRow['component']), '::')) . (empty($aRow['title']) ? '' : ' (' . Phpfox_Locale::instance()->convert($aRow['title']) . ')') : Phpfox::getPhrase('admincp.add_new_block'), $this->url()->makeUrl('admincp.block.add'), true)->setTitle(Phpfox::getPhrase('admincp.add_new_block')); }
/** * 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)); }
/** * 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 (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" ,plugins: "phpfox" }); </script>')); } $this->template()->setTitle(Phpfox::getPhrase('theme.edit_css'))->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.edit_css'), null, true)->setHeader(array('template.css' => 'style_css', 'style.js' => 'module_theme'))->assign(array('aFiles' => Theme_Service_Style_Style::instance()->getFiles($aStyle['theme_folder'], $aStyle['folder'], $aStyle['style_id']), 'aStyle' => $aStyle, 'aProducts' => Admincp_Service_Product_Product::instance()->get(), 'aCustomDataContent' => defined('PHPFOX_IS_HOSTED_SCRIPT') ? Theme_Service_Style_Style::instance()->getStyleContent($aStyle['style_id']) : '')); }
public function getCssFile($bRevert = false) { if ($aData = Theme_Service_Style_Style::instance()->getFile($this->get('style_id'), $this->get('file_name'), $this->get('module_id'))) { if (is_array($aData['modified'])) { $this->call('$(\'#js_last_modified\').show();')->hide('.js_theme_last_modified')->remove('#modify_' . $aData['id'] . '')->call('$(\'#js_last_modified_info\').append(\'<div id="modify_' . $aData['id'] . '" class="js_theme_last_modified extra_info"><i>' . Phpfox::getPhrase('theme.last_modified_time_stamp_by_full_name', array('phpfox_squote' => true, 'time_stamp' => Phpfox::getTime(Phpfox::getParam('core.global_update_time'), $aData['modified']['time_stamp']), 'full_name' => $aData['modified']['full_name'])) . '</i></div>\');'); $sProduct = $aData['product_id']; } else { $this->call('$(\'#js_last_modified\').hide();')->hide('.js_theme_last_modified'); $sProduct = 'phpfox'; } if ($aData['is_custom']) { $this->show('#js_delete_custom'); } else { $this->hide('#js_delete_custom'); } if ($bRevert) { $this->call('editAreaLoader.closeFile(\'js_template_content\', \'' . $aData['id'] . '\');'); $this->call('$(\'.js_link_cache_' . $aData['id'] . '\').removeClass(\'modified\');'); $this->call('$(\'#js_last_modified\').hide();')->hide('.js_theme_last_modified'); } $this->call('editAreaLoader.openFile(\'js_template_content\', {id:\'' . $aData['id'] . '\', text:"' . str_replace('"', '\\"', $aData['content']) . '", title:\'' . $aData['title'] . '\'});')->hide('#js_template_content_loader')->val('#js_css_style_id', $this->get('style_id'))->val('#js_css_file', $this->get('file_name'))->val('#js_css_module', $this->get('module_id'))->remove('#' . $aData['id'])->val('#js_template_product_id', $sProduct)->call('$(\'#js_theme_cache_info\').append("<div class=\'js_append_theme_layer\' id=\'' . $aData['id'] . '\'>{style_id: \'' . $this->get('style_id') . '\', file: \'' . $this->get('file_name') . '\', module: \'' . $this->get('module_id') . '\', product: \'' . $sProduct . '\', custom: \'' . $aData['is_custom'] . '\'}</div>");')->hide('.js_css_ajax_' . str_replace('.', '_', $aData['title'])); } }
public function installStyleFromFolder($sTheme, $sStyle, $mForce = false) { if ($mForce && Phpfox::getParam('core.phpfox_is_hosted')) { $sDir = PHPFOX_DIR_CACHE . $mForce . PHPFOX_DS . 'upload' . PHPFOX_DS . 'theme' . PHPFOX_DS . 'frontend' . PHPFOX_DS . $sTheme . PHPFOX_DS . 'style' . PHPFOX_DS . $sStyle . PHPFOX_DS; } else { $sDir = PHPFOX_DIR_THEME . 'frontend' . PHPFOX_DS . $sTheme . PHPFOX_DS . 'style' . PHPFOX_DS . $sStyle . PHPFOX_DS; } if (!file_exists($sDir . 'phpfox.xml')) { return Phpfox_Error::set('Not a valid theme to install.'); } $aParams = Phpfox::getLib('xml.parser')->parse(file_get_contents($sDir . 'phpfox.xml')); $aForm = array('name' => array('type' => 'string:required', 'message' => Phpfox::getPhrase('theme.style_requires_a_name')), 'folder' => array('type' => 'string:required', 'message' => Phpfox::getPhrase('theme.style_requires_a_folder_name')), 'theme_id' => array('type' => 'int:required', 'message' => Phpfox::getPhrase('theme.select_a_parent_theme_for_this_style')), 'parent_id' => array('type' => 'int'), 'created' => array('type' => 'int'), 'creator' => array('type' => 'string'), 'website' => array('type' => 'string'), 'version' => array('type' => 'string'), 'logo_image' => array('type' => 'string:required', 'message' => Phpfox::getPhrase('theme.provide_a_default_logo_name'))); $aTheme = Theme_Service_Theme::instance()->getTheme($sTheme, true); $aParams['theme_id'] = isset($aTheme['theme_id']) ? $aTheme['theme_id'] : 0; $aParams['parent_id'] = 0; if (!empty($aParams['parent_style'])) { $aStyleParentParts = explode('::', $aParams['parent_style']); $aTheme = Theme_Service_Theme::instance()->getTheme($aStyleParentParts[0], true); if (isset($aTheme['theme_id'])) { $aStyleParent = Theme_Service_Style_Style::instance()->getStyleParent($aTheme['theme_id'], $aStyleParentParts[1]); if (isset($aStyleParent['style_id'])) { $aParams['parent_id'] = $aStyleParent['style_id']; } } } $aParams = $this->validator()->process($aForm, $aParams); if (!Phpfox_Error::isPassed()) { return false; } $aParams['is_active'] = 1; $aParams['is_default'] = 0; $iId = $this->database()->insert(Phpfox::getT('theme_style'), $aParams); return $iId; }
public function export($iStyleId, $bIncludeParent = false, $bMultiple = false, $sNewHomeFolder = null, $sDirectoryId = null) { if ($bMultiple === false) { define('PHPFOX_XML_SKIP_STAMP', true); } $oXmlBuilder = Phpfox::getLib('xml.builder'); $aStyle = Theme_Service_Style_Style::instance()->getStyle($iStyleId); if (isset($aStyle['style_id'])) { $sCacheHash = md5(serialize($aStyle) . PHPFOX_TIME); if ($sDirectoryId === null) { $sDirectoryIdReturn = 'theme_' . $aStyle['style_id'] . '_' . uniqid(); if (is_dir(PHPFOX_DIR_CACHE . $sDirectoryIdReturn)) { Phpfox_File::instance()->delete_directory(PHPFOX_DIR_CACHE . $sDirectoryIdReturn . PHPFOX_DS); } $sDirectoryId = $sDirectoryIdReturn . PHPFOX_DS . 'upload' . PHPFOX_DS; Phpfox_File::instance()->mkdir(PHPFOX_DIR_CACHE . $sDirectoryId, true); $sNewHomeFolder = PHPFOX_DIR_CACHE . $sDirectoryId . PHPFOX_DS . 'theme' . PHPFOX_DS . 'frontend' . PHPFOX_DS . $aStyle['theme_folder'] . PHPFOX_DS; } $sThemePath = $sNewHomeFolder . 'style' . PHPFOX_DS . $aStyle['folder'] . PHPFOX_DS; Phpfox_File::instance()->mkdir($sThemePath, true); Phpfox_File::instance()->mkdir($sThemePath . 'css' . PHPFOX_DS, true); Phpfox_File::instance()->mkdir($sThemePath . 'image' . PHPFOX_DS, true); Phpfox_File::instance()->mkdir($sThemePath . 'jscript' . PHPFOX_DS, true); Phpfox_File::instance()->mkdir($sThemePath . 'php' . PHPFOX_DS, true); $oXmlBuilder->addGroup('style', array('name' => $aStyle['name'], 'folder' => $aStyle['folder'], 'parent_style' => $aStyle['parent_theme_folder'] . '::' . $aStyle['parent_style_folder'], 'parent_theme' => $aStyle['theme_folder'], 'created' => $aStyle['created'], 'logo_image' => $aStyle['logo_image'])); // Display Logo $oXmlBuilder->addTag('creator', $aStyle['creator']); $oXmlBuilder->addTag('website', $aStyle['website']); $oXmlBuilder->addTag('version', $aStyle['version']); $oXmlBuilder->closeGroup(); Phpfox_File::instance()->write($sThemePath . 'phpfox.xml', $oXmlBuilder->output()); $sLogoPath = Theme_Service_Style_Style::instance()->getStyleDisplayLogo($aStyle['theme_folder'], $aStyle['folder'], $aStyle['style_id'], $bIncludeParent); if (file_exists($sLogoPath) && is_readable($sLogoPath)) { Phpfox_File::instance()->write($sThemePath . 'phpfox.gif', file_get_contents($sLogoPath)); } // Css $aFiles = Theme_Service_Style_Style::instance()->getFiles($aStyle['theme_folder'], $aStyle['folder'], $aStyle['style_id'], true, $bIncludeParent); foreach ($aFiles as $sModule => $aCssFiles) { foreach ($aCssFiles as $sFile) { $aCss = Theme_Service_Style_Style::instance()->getFile($aStyle['style_id'], $sFile, $sModule, $bIncludeParent); if (empty($sModule)) { Phpfox_File::instance()->write($sThemePath . 'css' . PHPFOX_DS . $sFile, $aCss['content']); } else { Phpfox_File::instance()->mkdir(PHPFOX_DIR_CACHE . $sDirectoryId . PHPFOX_DS . 'module' . PHPFOX_DS . $sModule . PHPFOX_DS . 'static' . PHPFOX_DS . 'css' . PHPFOX_DS . $aStyle['theme_folder'] . PHPFOX_DS . $aStyle['folder'] . PHPFOX_DS, true); Phpfox_File::instance()->write(PHPFOX_DIR_CACHE . $sDirectoryId . PHPFOX_DS . 'module' . PHPFOX_DS . $sModule . PHPFOX_DS . 'static' . PHPFOX_DS . 'css' . PHPFOX_DS . $aStyle['theme_folder'] . PHPFOX_DS . $aStyle['folder'] . PHPFOX_DS . $sFile, $aCss['content']); } } } // Images $aImages = Theme_Service_Style_Style::instance()->getImages($aStyle['theme_folder'], $aStyle['folder'], $aStyle['style_id'], $bIncludeParent); foreach ($aImages as $sImagePath => $mImages) { if (is_numeric($sImagePath)) { $mImages = array($mImages); } foreach ($mImages as $aNewImage) { $sNewFileName = str_replace(PHPFOX_DIR, '', $aNewImage['file']); $aParts = explode(PHPFOX_DS, $sNewFileName); unset($aParts[count($aParts) - 1]); $sDirPath = implode(PHPFOX_DS, $aParts); Phpfox_File::instance()->mkdir(PHPFOX_DIR_CACHE . $sDirectoryId . PHPFOX_DS . $sDirPath . PHPFOX_DS, true); Phpfox_File::instance()->write(PHPFOX_DIR_CACHE . $sDirectoryId . PHPFOX_DS . $sDirPath . PHPFOX_DS . $aNewImage['name'], file_get_contents($aNewImage['file'])); } } // JavaScript $aScripts = Theme_Service_Style_Style::instance()->getScript($aStyle['theme_folder'], $aStyle['folder'], $aStyle['style_id'], $bIncludeParent); foreach ($aScripts as $aScript) { $sNewFileName = str_replace(PHPFOX_DIR, '', $aScript['file']); $aParts = explode(PHPFOX_DS, $sNewFileName); unset($aParts[count($aParts) - 1]); $sDirPath = implode(PHPFOX_DS, $aParts); Phpfox_File::instance()->mkdir(PHPFOX_DIR_CACHE . $sDirectoryId . PHPFOX_DS . $sDirPath . PHPFOX_DS, true); Phpfox_File::instance()->write(PHPFOX_DIR_CACHE . $sDirectoryId . PHPFOX_DS . $sDirPath . PHPFOX_DS . $aScript['name'], file_get_contents($aScript['file'])); } $sPhpHeaderFile = PHPFOX_DIR_THEME . 'frontend' . PHPFOX_DS . $aStyle['theme_folder'] . PHPFOX_DS . 'style' . PHPFOX_DS . $aStyle['folder'] . PHPFOX_DS . 'php' . PHPFOX_DS . 'header.php'; if (file_exists($sPhpHeaderFile)) { Phpfox_File::instance()->write($sThemePath . 'php' . PHPFOX_DS . 'header.php', file_get_contents($sPhpHeaderFile)); } $sSamplePngFile = PHPFOX_DIR_THEME . 'frontend' . PHPFOX_DS . $aStyle['theme_folder'] . PHPFOX_DS . 'style' . PHPFOX_DS . $aStyle['folder'] . PHPFOX_DS . 'sample.png'; if (file_exists($sSamplePngFile)) { Phpfox_File::instance()->write($sThemePath . 'sample.png', file_get_contents($sSamplePngFile)); } if ($bMultiple === false) { Phpfox_File::instance()->writeToCache('theme_styles_' . $sCacheHash . '.xml', $oXmlBuilder->output()); return array('name' => $aStyle['theme_folder'] . '-' . $aStyle['folder'] . (empty($aStyle['version']) ? '' : '-' . $aStyle['version']), 'folder' => $sDirectoryIdReturn); } } if ($bMultiple === false) { return Phpfox_Error::set(Phpfox::getPhrase('theme.not_a_valid_style')); } }
public function export($aVals) { $aXmlFiles = array(); define('PHPFOX_XML_SKIP_STAMP', true); $oXmlBuilder = Phpfox::getLib('xml.builder'); $sCacheHash = md5(serialize($aVals) . PHPFOX_TIME); $aTheme = $this->getTheme($aVals['theme_id']); $bIncludeParent = false; $oXmlBuilder->addGroup('theme'); $oXmlBuilder->addTag('name', $aTheme['name']); $oXmlBuilder->addTag('folder', $aTheme['folder']); $oXmlBuilder->addTag('created', $aTheme['created']); $oXmlBuilder->addTag('creator', $aTheme['creator']); $oXmlBuilder->addTag('website', $aTheme['website']); $oXmlBuilder->addTag('version', $aTheme['version']); $oXmlBuilder->addTag('total_column', $aTheme['total_column']); $aParent = $this->getTheme($aTheme['parent_id']); if (isset($aParent['theme_id'])) { $oXmlBuilder->addTag('parent', $aParent['folder']); } $oXmlBuilder->closeGroup(); $sDirectoryIdReturn = 'theme_' . $aVals['theme_id'] . '_' . uniqid(); if (is_dir(PHPFOX_DIR_CACHE . $sDirectoryIdReturn)) { Phpfox_File::instance()->delete_directory(PHPFOX_DIR_CACHE . $sDirectoryIdReturn . PHPFOX_DS); } $sDirectoryId = $sDirectoryIdReturn . PHPFOX_DS . 'upload' . PHPFOX_DS; Phpfox_File::instance()->mkdir(PHPFOX_DIR_CACHE . $sDirectoryId, true); $bPass = false; $sXmlDir = PHPFOX_DIR_THEME . 'frontend' . PHPFOX_DS . $aTheme['folder'] . PHPFOX_DS . 'xml' . PHPFOX_DS . 'phpfox.xml.php'; if (file_exists($sXmlDir)) { $bPass = true; } if ($bPass === false && $bIncludeParent) { if (isset($aParent['theme_id'])) { if (file_exists(PHPFOX_DIR_THEME . 'frontend' . PHPFOX_DS . $aParent['folder'] . PHPFOX_DS . 'xml' . PHPFOX_DS . 'phpfox.xml.php')) { $sXmlDir = PHPFOX_DIR_THEME . 'frontend' . PHPFOX_DS . $aParent['folder'] . PHPFOX_DS . 'xml' . PHPFOX_DS . 'phpfox.xml.php'; $bPass = true; } } } $sNewHomeFolder = PHPFOX_DIR_CACHE . $sDirectoryId . PHPFOX_DS . 'theme' . PHPFOX_DS . 'frontend' . PHPFOX_DS . $aTheme['folder'] . PHPFOX_DS; Phpfox_File::instance()->mkdir($sNewHomeFolder, true); Phpfox_File::instance()->mkdir($sNewHomeFolder . 'style' . PHPFOX_DS, true); Phpfox_File::instance()->mkdir($sNewHomeFolder . 'template' . PHPFOX_DS, true); Phpfox_File::instance()->mkdir($sNewHomeFolder . 'xml' . PHPFOX_DS, true); if ($bPass) { copy($sXmlDir, PHPFOX_DIR_CACHE . $sDirectoryId . PHPFOX_DS . 'theme' . PHPFOX_DS . 'frontend' . PHPFOX_DS . $aTheme['folder'] . PHPFOX_DS . 'xml' . PHPFOX_DS . 'phpfox.xml.php'); } Phpfox_File::instance()->write($sNewHomeFolder . 'phpfox.xml', $oXmlBuilder->output()); $aTemplates = Phpfox::getService('theme.template')->get($aTheme['folder'], true, $bIncludeParent); foreach ($aTemplates as $sKey => $aFiles) { unset($aFiles['modified']); foreach ($aFiles as $sSubKey => $aSubFiles) { foreach ($aSubFiles as $sFile) { $sContent = Phpfox::getService('theme.template')->getTemplate($aTheme['folder'], $sKey == 'layout' ? $sKey : $sSubKey, $sFile, $sKey == 'layout' ? null : $sKey, $bIncludeParent); if ($sKey == 'layout') { if (is_array($sContent)) { $sContent = $sContent[0]; } Phpfox_File::instance()->write($sNewHomeFolder . 'template' . PHPFOX_DS . $sFile, $sContent); } else { Phpfox_File::instance()->mkdir(PHPFOX_DIR_CACHE . $sDirectoryId . 'module' . PHPFOX_DS . $sKey . PHPFOX_DS . 'template' . PHPFOX_DS . $aTheme['folder'] . PHPFOX_DS . 'block', true); Phpfox_File::instance()->mkdir(PHPFOX_DIR_CACHE . $sDirectoryId . 'module' . PHPFOX_DS . $sKey . PHPFOX_DS . 'template' . PHPFOX_DS . $aTheme['folder'] . PHPFOX_DS . 'controller', true); if (strpos($sFile, PHPFOX_DS)) { $aParts = explode(PHPFOX_DS, $sFile); Phpfox_File::instance()->mkdir(PHPFOX_DIR_CACHE . $sDirectoryId . 'module' . PHPFOX_DS . $sKey . PHPFOX_DS . 'template' . PHPFOX_DS . $aTheme['folder'] . PHPFOX_DS . $sSubKey . PHPFOX_DS . $aParts[0], true); } if (is_array($sContent) && isset($sContent[0])) { Phpfox_File::instance()->write(PHPFOX_DIR_CACHE . $sDirectoryId . 'module' . PHPFOX_DS . $sKey . PHPFOX_DS . 'template' . PHPFOX_DS . $aTheme['folder'] . PHPFOX_DS . $sSubKey . PHPFOX_DS . $sFile, $sContent[0]); } else { Phpfox_File::instance()->write(PHPFOX_DIR_CACHE . $sDirectoryId . 'module' . PHPFOX_DS . $sKey . PHPFOX_DS . 'template' . PHPFOX_DS . $aTheme['folder'] . PHPFOX_DS . $sSubKey . PHPFOX_DS . $sFile, $sContent); } } } } } if (isset($aVals['styles'])) { foreach ($aVals['styles'] as $iStyleId) { Theme_Service_Style_Style::instance()->export($iStyleId, $bIncludeParent, true, $sNewHomeFolder, $sDirectoryId); } } return array('name' => $aTheme['folder'] . (empty($aTheme['version']) ? '' : '-' . $aTheme['version']), 'folder' => $sDirectoryIdReturn); }