public function __construct($name = null) { $this->_cache = \Phpfox_Cache::instance(); if ($name !== null) { $this->_name = $name; $this->_id = $this->_cache->set($name); } }
/** * Loads and outputs the current page based on the controller we loaded with the method setController(). * * @see self::setController() */ public function getController() { // Get the component $this->_oController = $this->getComponent($this->_sModule . '.' . $this->_sController, array('bNoTemplate' => true), 'controller'); if (!Phpfox::isAdminPanel() && !defined('PHPFOX_INSTALLER') || defined('PHPFOX_DEBUG') && PHPFOX_DEBUG) { $db = Phpfox_Database::instance(); $cache = Phpfox_Cache::instance(); $name = Phpfox_Module::instance()->getFullControllerName(); $pageMeta = $cache->set('page_meta_' . $name); $meta = $cache->get($pageMeta); if (PHPFOX_DEBUG) { $meta = false; } if ($meta === false) { $query = function ($name) use($db) { return $db->select('*')->from(':theme_template')->where(['type_id' => 'meta', 'name' => $name])->get(); }; $theme = $query(['LIKE' => $name . '/' . Phpfox_Request::instance()->segment(3)]); if (!$theme) { $theme = $query($name); } $cache->save($pageMeta, isset($theme['template_id']) ? json_decode($theme['html_data']) : []); $meta = $cache->get($pageMeta); } // $this->_meta = $meta; // d($theme); exit; Phpfox_Template::instance()->setPageMeta($meta); } }
/** * Loads and outputs the current page based on the controller we loaded with the method setController(). * * @see self::setController() */ public function getController() { // Get the component $this->_oController = $this->getComponent($this->_sModule . '.' . $this->_sController, array('bNoTemplate' => true), 'controller'); if (!Phpfox::isAdminPanel() && !defined('PHPFOX_INSTALLER')) { $db = Phpfox_Database::instance(); $cache = Phpfox_Cache::instance(); $name = Phpfox_Module::instance()->getFullControllerName(); $pageMeta = $cache->set('page_meta_' . $name); $meta = $cache->get($pageMeta); if ($meta === false) { $theme = $db->select('*')->from(':theme_template')->where(['type_id' => 'meta', 'name' => $name])->get(); $cache->save($pageMeta, isset($theme['template_id']) ? json_decode($theme['html_data']) : []); $meta = $cache->get($pageMeta); } // $this->_meta = $meta; Phpfox_Template::instance()->setPageMeta($meta); } }
public function delete() { (new \Core\Home(PHPFOX_LICENSE_ID, PHPFOX_LICENSE_KEY))->uninstall(['product_id' => $this->internal_id]); $path = $this->path; if (is_dir($path)) { \Phpfox_File::instance()->delete_directory($path); } \Phpfox_Cache::instance()->remove(); }
public function process() { $Theme = new Core\Theme(); $file = null; if ($this->request()->get('type') == 'in-app') { $product = json_decode($this->request()->get('product')); $app = (new Core\App())->getByInternalId($this->request()->get('parent_id')); $this->url()->send('admincp.app', ['id' => $app->id, 'child_id' => $product->id]); exit; } if ($this->request()->get('type') == 'language') { $dir = PHPFOX_DIR_FILE . 'static/' . uniqid() . '/'; mkdir($dir); $file = $dir . 'import.zip'; file_put_contents($file, file_get_contents($this->request()->get('download'))); register_shutdown_function(function () use($dir) { // Phpfox_File::instance()->delete_directory($dir); }); $Zip = new \ZipArchive(); $Zip->open($file); $Zip->extractTo($dir); $Zip->close(); $pack = ''; $path = $dir . 'upload/include/xml/language/'; foreach (scandir($path) as $newDir) { if ($newDir == '.' || $newDir == '..') { continue; } $pack = $newDir; $path .= $newDir . '/'; break; } \Language_Service_Process::instance()->installPackFromFolder($pack, $path); Phpfox_Cache::instance()->remove(); echo '<script>window.top.location.href = \'' . $this->url()->makeUrl('admincp.language.import', ['dir' => base64_encode($path)]) . '\';</script>'; exit; } if ($this->request()->get('type') == 'theme') { $product = json_decode($this->request()->get('product')); $dir = PHPFOX_DIR_FILE . 'static/' . uniqid() . '/'; mkdir($dir); $file = $dir . 'import.zip'; file_put_contents($file, file_get_contents($this->request()->get('download'))); register_shutdown_function(function () use($dir) { Phpfox_File::instance()->delete_directory($dir); }); // Phpfox::addMessage('Theme successfully installed.'); $id = $Theme->import($file, $product); // $this->url()->send('admincp.theme'); Phpfox_Cache::instance()->remove(); echo '<script>window.top.location.href = \'' . $this->url()->makeUrl('admincp.theme.manage', ['id' => is_numeric($id) ? $id : $id->theme_id]) . '\';</script>'; exit; } if (isset($_SERVER['HTTP_X_FILE_NAME']) || $this->request()->get('download')) { $App = (new Core\App())->import($this->request()->get('download'), $this->request()->get('download') ? true : false); Phpfox_Cache::instance()->remove(); if ($this->request()->get('download')) { // $this->url()->send('admincp.app', ['id' => $App->id]); echo '<script>window.top.location.href = \'' . $this->url()->makeUrl('admincp.app', ['id' => $App->id]) . '\';</script>'; exit; } return ['redirect' => $this->url()->makeUrl('admincp.app', ['id' => $App->id])]; } if ($val = $this->request()->getArray('val')) { $App = (new Core\App())->make($val['name']); Phpfox::addMessage('App successfully created.'); Phpfox_Cache::instance()->remove(); return ['redirect' => $this->url()->makeUrl('admincp.app', ['id' => $App->id])]; } $this->template()->setBreadCrumb('New App', $this->url()->current(), true); }
public function delete() { if ($this->menu && isset($this->menu->url)) { \Phpfox_Database::instance()->delete(':menu', ['m_connection' => 'main', 'url_value' => $this->menu->url]); } (new \Core\Home(PHPFOX_LICENSE_ID, PHPFOX_LICENSE_KEY))->uninstall(['product_id' => $this->internal_id]); $path = $this->path; /*https://github.com/moxi9/phpfox/issues/523*/ $json_path = $path . 'app.json'; if (file_exists($json_path)) { $json = json_decode(file_get_contents($json_path)); //remove menu if exist if (isset($json->menu)) { \Admincp_Service_Menu_Process::instance()->delete($json->menu->url, true); } } if (is_dir($path)) { \Phpfox_File::instance()->delete_directory($path); } \Phpfox_Cache::instance()->remove(); }