예제 #1
0
 /** {@inheritdoc} */
 public function showFront(Curry_Twig_Template $template = null)
 {
     if (is_array($this->languages) && count($this->languages)) {
         // allowed languages
         $allowedLanguages = array();
         foreach ($this->languages as $lang) {
             $allowedLanguages[$lang['code']] = $lang;
         }
         // find preferred language
         reset($this->languages);
         $language = current($this->languages);
         foreach ($this->getLanguage() as $lang => $quality) {
             if (array_key_exists($lang, $allowedLanguages)) {
                 $language = $allowedLanguages[$lang];
                 break;
             }
         }
         $page = PageQuery::create()->findPk($language['page_id']);
         if ($page) {
             url($page->getUrl(), $_GET)->redirect();
         } else {
             Curry_Core::log('Redirect page not found', Zend_Log::WARN);
         }
     } else {
         Curry_Core::log('No languages found', Zend_Log::WARN);
     }
     return '';
 }
예제 #2
0
 /**
  * This is the main function called by Curry_Admin.
  * 
  * This will call the show{X}() function, where X is specified
  * by the GET-variable 'view'. It will then render the backend using
  * the render() function, and return the content.
  *
  * @return string
  */
 public function show()
 {
     try {
         $this->preShow();
         $view = empty($_GET['view']) ? 'Main' : $_GET['view'];
         $func = 'show' . $view;
         if (method_exists($this, $func)) {
             $this->{$func}();
         } elseif (isset($this->proxyViews[$view])) {
             $callback = $this->proxyViews[$view]['callback'];
             call_user_func($callback);
         } else {
             throw new Exception('Invalid view');
         }
         $this->postShow();
     } catch (Exception $e) {
         if (!headers_sent()) {
             header("HTTP/1.0 500 Internal server error: " . str_replace("\n", "  ", $e->getMessage()));
         }
         Curry_Core::log($e->getMessage());
         $this->addMessage($e->getMessage(), self::MSG_ERROR);
         if (Curry_Core::$config->curry->developmentMode) {
             $this->addMainContent("<pre>" . htmlspecialchars($e->getTraceAsString()) . "</pre>");
         }
     }
     return $this->render();
 }
예제 #3
0
 /**
  * Function to execute after generating page.
  */
 protected function postGeneration()
 {
     if (Curry_Core::$config->curry->developmentMode) {
         $totalTime = 0;
         foreach ($this->moduleDebugInfo as $mdi) {
             $totalTime += $mdi[5];
         }
         $labels = array('Name', 'Class', 'Template', 'Target', 'Cached', 'Time (ms)', 'Cpu (ms)', 'Memory Delta', 'Memory Peak', 'Queries');
         Curry_Core::log(array("Modules(" . count($this->moduleDebugInfo) . "): " . round($totalTime / 1000.0, 3) . "s", array_merge(array($labels), $this->moduleDebugInfo)), Curry_Core::LOG_TABLE);
     }
 }
예제 #4
0
 /**
  * Render the specified page revision.
  *
  * @param PageRevision $pageRevision
  * @param Curry_Request $request
  * @param array $vars
  * @param array $options
  */
 protected function render(PageRevision $pageRevision, Curry_Request $request, array $vars, array $options)
 {
     Curry_Core::log('Showing page ' . $pageRevision->getPage()->getName() . ' (PageRevisionId: ' . $pageRevision->getPageRevisionId() . ')', Zend_Log::NOTICE);
     $time = microtime(true);
     $queries = Curry_Propel::getQueryCount();
     $cacheName = __CLASS__ . '_Page_' . md5($request->getUri());
     $cacheLifetime = $pageRevision->getPage()->getCacheLifetime();
     $doCache = $request->getMethod() === 'GET' && $cacheLifetime !== 0;
     if ($doCache) {
         ob_start();
     }
     $generator = self::createPageGenerator($pageRevision, $request);
     $generator->display($vars, $options);
     if ($doCache) {
         $cache = array('page_id' => $pageRevision->getPageId(), 'page_revision_id' => $pageRevision->getPageRevisionId(), 'headers' => headers_list(), 'content' => ob_get_flush());
         Curry_Core::$cache->save($cache, $cacheName, array(), $cacheLifetime < 0 ? false : $cacheLifetime);
     }
     if (Curry_Core::$config->curry->updateTranslationStrings) {
         Curry_Language::updateLanguageStrings();
     }
     $time = microtime(true) - $time;
     $queries = $queries !== null ? Curry_Propel::getQueryCount() - $queries : null;
     Curry_Core::triggerHook('Curry_Application::render', $pageRevision->getPageId(), $pageRevision->getPageRevisionId(), $time, $queries);
 }
예제 #5
0
파일: Core.php 프로젝트: varvanin/currycms
/**
 * Global helper function for logging messages or objects, with level set to error.
 *
 * @param mixed $value
 */
function trace_error($value)
{
    Curry_Core::log($value, 3);
}
예제 #6
0
 /**
  * Main routing function.
  * 
  * @see parent::show()
  *
  * @return string
  */
 public function show()
 {
     try {
         $this->preShow();
         $func = 'show' . (isset($_GET['view']) ? $_GET['view'] : 'Main');
         if (method_exists($this, $func)) {
             $this->{$func}();
         } else {
             if (in_array($_GET['view'], $this->modelClasses)) {
                 $this->editModel($_GET['view']);
             } else {
                 if (in_array(substr($_GET['view'], 0, -1), $this->modelClasses) && substr($_GET['view'], -1) == 's') {
                     $this->showGrid(substr($_GET['view'], 0, -1));
                 } else {
                     if (in_array(substr($_GET['view'], 0, -4), $this->modelClasses) && substr($_GET['view'], -4) == 'Json') {
                         $this->showGridJson(substr($_GET['view'], 0, -4));
                     } else {
                         throw new Exception('Invalid view');
                     }
                 }
             }
         }
         $this->postShow();
     } catch (Exception $e) {
         if (!headers_sent()) {
             header("HTTP/1.0 500 Internal server error: " . str_replace("\n", "  ", $e->getMessage()));
         }
         Curry_Core::log($e);
         $this->addMessage($e->getMessage(), self::MSG_ERROR);
         $this->addMainContent("<pre>" . htmlspecialchars($e->getTraceAsString()) . "</pre>");
     }
     return $this->render();
 }