/** * Embed iframe for url. * * @param string $url */ public function showPage($url) { $url .= '?curry_inline_admin=true'; Curry_Admin::getInstance()->addBodyClass('tpl-fullscreen'); url($url)->redirect(); $this->addMainContent('<iframe id="inline-admin-preview" src="' . $url . '" frameborder="0" width="100%" height="100%"></iframe>'); }
/** * Get the singleton instance. * * @return Curry_Admin */ public static function getInstance() { if (!self::$instance) { self::$instance = new Curry_Admin(); } return self::$instance; }
public function testBackend() { ob_start(); self::setupRequest('post', '/admin.php', array(), array('login_username' => 'admin', 'login_password' => 'admin')); $admin = \Curry_Admin::getInstance(); $admin->show(); $content = ob_get_clean(); $this->assertNotEmpty($content); }
/** * Log to backend instance. * * @param string $msg * @param string $class */ public static function log($msg, $class = Curry_Backend::MSG_NOTICE) { Curry_Admin::getInstance()->getBackend()->addMessage($msg, $class); }
/** * Edit file view. * * @throws Exception */ public function showEdit() { $files = self::getFileList(); $file = $_GET['file']; if (!isset($files[$file])) { throw new Exception('File not found'); } $file = $files[$file]; $form = $this->getEditForm($file); if (isPost()) { $ajax = array('success' => 1); if ($form->isValid($_POST)) { // Save content and preserve EOL style $values = $form->getValues(); $code = $values['content']; $eol = Curry_Util::getStringEol($code); $targetEol = urldecode($values['eol']); if ($eol !== $targetEol) { $code = str_replace($eol, $targetEol, $code); } file_put_contents($file->getPathname(), $code); $form = $this->getEditForm($file); } else { $error = "Validation error!"; foreach ($form->getMessages() as $element => $messages) { $error .= "\n{$element}: " . join(', ', $messages); } $ajax['success'] = 0; $ajax['error'] = $error; } if ($_POST['_ajaxsubmit']) { $form->render(); // fixes issue with csrf-token $ajax['values'] = $form->getValues(); Curry_Application::returnJson($ajax); } } Curry_Admin::getInstance()->addBodyClass('tpl-fullscreen'); Curry_Admin::getInstance()->addBodyClass('tpl-fileeditor'); $this->addMenu($_GET['file']); $this->addMainContent($form); }
/** * Use template to render the backend. * * @return string */ protected function render() { if (isset($_GET['curry_context']) && $_GET['curry_context'] == 'main') { Curry_Application::returnPartial($this->mainContent); } $twig = Curry_Admin::getInstance()->getTwig(); $template = $twig->loadTemplate('backend.html'); return $template->render(array('breadcrumbs' => $this->breadcrumbs, 'commands' => $this->commands, 'menuItems' => $this->menuItems, 'mainContent' => $this->mainContent, 'menuContent' => $this->menuContent, 'moduleName' => $this->getName() ? $this->getName() : substr(get_class($this), 14))); }
/** * Show page properties form. */ public function showPageProperties() { $ses = new Zend_Session_Namespace(__CLASS__); $ses->pageView = 'PageProperties'; $page = self::getPage(PageAccessPeer::PERM_PROPERTIES); $form = Curry_Backend_PageHelper::getPagePropertiesForm($page); if (isPost('pid_properties') && $form->isValid($_POST)) { $values = $form->getValues(); Curry_Backend_PageHelper::savePageProperties($page, $values); $form = Curry_Backend_PageHelper::getPagePropertiesForm($page); Curry_Admin::getInstance()->addBodyClass('live-edit-close'); self::updateIndex($page); } $this->addPageMenu($page); $this->addMainContent($form); }
public function showEdit(Curry_PageModuleWrapper $wrapper, $backend) { $form = $this->getModuleForm($wrapper); if (!$form) { $backend->addMessage('This module doesn\'t have a backend.'); return; } if (isPost('pid_editmodule') && $form->isValid($_POST)) { $modified = false; $moduleForm = $form->getSubForm('module' . $wrapper->getPageModuleId()); if ($moduleForm) { $module = $wrapper->createObject(); if ($module->saveBack($moduleForm) !== false) { $modified = $module->saveModule(); } $backend->createModelUpdateEvent('PageModule', $wrapper->getPageModuleId(), 'update'); Curry_Admin::getInstance()->addBodyClass('live-edit-close'); } if ($form->delete && $form->delete->isChecked()) { $wrapper->getModuleData()->delete(); $modified = true; } else { if ($form->create && $form->create->isChecked() && !$wrapper->hasData()) { $wrapper->createData(); $modified = true; } } if ($modified) { $wrapper->reload(); $pageRevision = $wrapper->getPageRevision(); $pageRevision->setUpdatedAt(time()); $pageRevision->save(); if ($pageRevision->getPage()->getActivePageRevisionId() == $pageRevision->getPageRevisionId()) { Curry_Backend_Page::updateIndex($pageRevision->getPage()); } } $form = $this->getModuleForm($wrapper); } if (!$wrapper->hasData()) { $moduleData = $wrapper->getDataSource(); if ($moduleData) { $page = $moduleData->getPageRevision()->getPage(); $backend->addMainContent('<p>Content is inherited from <strong title="' . $page->getUrl() . '">' . htmlspecialchars($page->getName()) . '</strong> page.</p>'); } else { $backend->addMainContent('<p>No content has been set for this page.</p>'); } } $backend->addMainContent($form); }
/** * Get the currently active backend module. * * @return Curry_Backend */ public function getBackend() { return Curry_Admin::getInstance()->getBackend(); }