public function editAction() { //TODO change to unpriviledged user \Ip\Internal\Admin\Service::setAdminLogin('admin'); /** * @var $pageManager \ImpressPages\ImpressPagesBundle\Renderer\EditorRenderer */ $editorRenderer = $this->get('impresspages_bundle.renderer.editor'); $renderedManager = $editorRenderer->render(5); echo $renderedManager; exit; }
/** * Used when management is needed in controller routed using routes. * @param $info * @return null */ public static function ipBeforeController_70($info) { if (empty($info['page']) || empty($info['management']) || !ipIsManagementState()) { return null; } //find current page $page = $info['page']; // change layout if safe mode if (\Ip\Internal\Admin\Service::isSafeMode()) { ipSetLayout(ipFile('Ip/Internal/Admin/view/safeModeLayout.php')); } else { ipSetLayout($page->getLayout()); } // initialize management if (!ipRequest()->getQuery('ipDesignPreview') && !ipRequest()->getQuery('disableManagement')) { Helper::initManagement(); } //show page content $response = ipResponse(); $response->setDescription(\Ip\ServiceLocator::content()->getDescription()); $response->setKeywords(ipContent()->getKeywords()); $response->setTitle(ipContent()->getTitle()); }
/** * @ignore * @param Request $request * @param array $options * @param bool $subrequest * @return Response\Json|Response\PageNotFound|Response\Redirect * @throws Exception * @ignore */ public function _handleOnlyRequest(\Ip\Request $request, $options = array(), $subrequest = true) { if (empty($options['skipInitEvents'])) { \Ip\ServiceLocator::dispatcher()->_bindApplicationEvents(); } $result = ipJob('ipRouteLanguage', array('request' => $request, 'relativeUri' => $request->getRelativePath())); if ($result) { $requestLanguage = $result['language']; $routeLanguage = $requestLanguage->getCode(); ipRequest()->_setRoutePath($result['relativeUri']); } else { $routeLanguage = null; $requestLanguage = ipJob('ipRequestLanguage', array('request' => $request)); ipRequest()->_setRoutePath($request->getRelativePath()); } //find out and set locale $locale = $requestLanguage->getCode(); if (strlen($locale) == '2') { $locale = strtolower($locale) . '_' . strtoupper($locale); } else { $locale = str_replace('-', '_', $locale); } $locale .= '.utf8'; if ($locale == "tr_TR.utf8" && (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 5)) { //Overcoming this bug https://bugs.php.net/bug.php?id=18556 setlocale(LC_COLLATE, $locale); setlocale(LC_MONETARY, $locale); setlocale(LC_NUMERIC, $locale); setlocale(LC_TIME, $locale); setlocale(LC_MESSAGES, $locale); setlocale(LC_CTYPE, "en_US.utf8"); } else { setLocale(LC_ALL, $locale); } setlocale(LC_NUMERIC, "C"); //user standard C syntax for numbers. Otherwise you will get funny things with when autogenerating CSS, etc. ipContent()->_setCurrentLanguage($requestLanguage); $_SESSION['ipLastLanguageId'] = $requestLanguage->getId(); if (empty($options['skipTranslationsInit'])) { if (!empty($options['translationsLanguageCode'])) { $languageCode = $options['translationsLanguageCode']; } else { $languageCode = $requestLanguage->getCode(); } $this->initTranslations($languageCode); } if (empty($options['skipModuleInit'])) { $this->modulesInit(); } ipEvent('ipInitFinished'); $routeAction = ipJob('ipRouteAction', array('request' => $request, 'relativeUri' => ipRequest()->getRoutePath(), 'routeLanguage' => $routeLanguage)); if (!empty($routeAction)) { if (!empty($routeAction['page'])) { ipContent()->_setCurrentPage($routeAction['page']); } if (!empty($routeAction['environment'])) { ipRoute()->setEnvironment($routeAction['environment']); } else { if (!empty($routeAction['controller']) && $routeAction['controller'] == 'AdminController') { ipRoute()->setEnvironment(\Ip\Route::ENVIRONMENT_ADMIN); } else { ipRoute()->setEnvironment(\Ip\Route::ENVIRONMENT_PUBLIC); } } if (!empty($routeAction['controller'])) { ipRoute()->setController($routeAction['controller']); } if (!empty($routeAction['plugin'])) { ipRoute()->setPlugin($routeAction['plugin']); } if (!empty($routeAction['name'])) { ipRoute()->setName($routeAction['name']); } if (!empty($routeAction['action'])) { ipRoute()->setAction($routeAction['action']); } } //check for CSRF attack if (empty($options['skipCsrfCheck']) && $request->isPost() && $request->getPost('securityToken') != $this->getSecurityToken() && (empty($routeAction['controller']) || $routeAction['controller'] != 'PublicController')) { ipLog()->error('Core.possibleCsrfAttack', array('post' => ipRequest()->getPost())); $data = array('status' => 'error'); if (ipConfig()->isDevelopmentEnvironment()) { $data['errors'] = array('securityToken' => __('Possible CSRF attack. Please pass correct securityToken.', 'Ip-admin')); } // TODO JSONRPC return new \Ip\Response\Json($data); } if (empty($routeAction)) { $routeAction = array('plugin' => 'Core', 'controller' => 'PublicController', 'action' => 'pageNotFound'); } $eventInfo = $routeAction; if (!empty($routeAction['plugin'])) { $plugin = $routeAction['plugin']; $controller = $routeAction['controller']; if (in_array($plugin, \Ip\Internal\Plugins\Model::getModules())) { $controllerClass = 'Ip\\Internal\\' . $plugin . '\\' . $controller; } else { if (!in_array($plugin, \Ip\Internal\Plugins\Service::getActivePluginNames())) { throw new \Ip\Exception("Plugin '" . esc($plugin) . "' doesn't exist or isn't activated."); } $controllerClass = 'Plugin\\' . $plugin . '\\' . $controller; } if (!class_exists($controllerClass)) { throw new \Ip\Exception('Requested controller doesn\'t exist. ' . esc($controllerClass)); } // check if user is logged in if ($controller == 'AdminController' && !\Ip\Internal\Admin\Backend::userId()) { if (ipConfig()->get('rewritesDisabled')) { return new \Ip\Response\Redirect(ipConfig()->baseUrl() . 'index.php/admin'); } else { return new \Ip\Response\Redirect(ipConfig()->baseUrl() . 'admin'); } } if ($controller == 'AdminController') { if (!ipAdminPermission($plugin)) { throw new \Ip\Exception('User has no permission to access ' . esc($plugin) . ''); } } $eventInfo['controllerClass'] = $controllerClass; $eventInfo['controllerType'] = $controller; } if (empty($eventInfo['page'])) { $eventInfo['page'] = null; } // change layout if safe mode if (\Ip\Internal\Admin\Service::isSafeMode()) { ipSetLayout(ipFile('Ip/Internal/Admin/view/safeModeLayout.php')); } else { if ($eventInfo['page']) { ipSetLayout($eventInfo['page']->getLayout()); } } ipEvent('ipBeforeController', $eventInfo); $controllerAnswer = ipJob('ipExecuteController', $eventInfo); return $controllerAnswer; }
public function generateJavascript() { $cacheVersion = $this->getCacheVersion(); $javascriptFiles = $this->getJavascript(); $javascriptFilesSorted = array(); foreach ($javascriptFiles as $level) { foreach ($level as &$file) { if ($file['type'] == 'file' && $file['cacheFix']) { $file['value'] .= (strpos($file['value'], '?') !== false ? '&' : '?') . $cacheVersion; } } $javascriptFilesSorted = array_merge($javascriptFilesSorted, $level); } $revision = $this->getCurrentRevision(); $page = ipContent()->getCurrentPage(); $javascriptFilesSorted = ipFilter('ipJs', $javascriptFilesSorted); $language = ipContent()->getCurrentLanguage(); $data = array('ip' => array('baseUrl' => ipConfig()->baseUrl(), 'safeMode' => \Ip\Internal\Admin\Service::isSafeMode(), 'languageId' => $language->getId(), 'languageUrl' => $language->getLink(), 'languageCode' => $language->getCode(), 'languageTextDirection' => $language->getTextDirection(), 'theme' => ipConfig()->theme(), 'pageId' => $page ? $page->getId() : null, 'revisionId' => $revision['revisionId'], 'securityToken' => \Ip\ServiceLocator::application()->getSecurityToken(), 'developmentEnvironment' => ipConfig()->isDevelopmentEnvironment(), 'debugMode' => ipconfig()->isDebugMode(), 'isManagementState' => ipIsManagementState(), 'isAdminState' => ipAdminId() ? 1 : 0, 'isAdminNavbarDisabled' => ipRequest()->getQuery('disableAdminNavbar') ? 1 : 0), 'javascriptVariables' => $this->getJavascriptVariables(), 'javascript' => $javascriptFilesSorted); $javascript = ipView('Ip/Internal/Config/view/javascript.php', $data)->render(); $javascript = ipFilter('ipJavaScript', $javascript); return $javascript; }
public static function getActivePluginNames() { if (\Ip\Internal\Admin\Service::isSafeMode()) { return array(); } $dbh = ipDb()->getConnection(); $sql = ' SELECT `name` FROM ' . ipTable('plugin') . ' WHERE `isActive` = 1 '; $params = array(); $q = $dbh->prepare($sql); $q->execute($params); $data = $q->fetchAll(\PDO::FETCH_COLUMN); //fetch all rows as an array return $data; }
/** * Get currently logged-in administrator ID * * @return int|bool Administrator ID. Returns false if not logged-in as administrator. */ function ipAdminId() { return \Ip\Internal\Admin\Service::adminId(); }