public function printStackTrace() { $exception = is_null($this->wrappedException) ? $this : $this->wrappedException; $message = $exception->getMessage(); $response = coreContext::getInstance()->getResponse(); $response->setStatusCode(500); // clean current output buffer while (@ob_end_clean()) { } ob_start(coreConfig::get('sf_compressed') ? 'ob_gzhandler' : ''); header('HTTP/1.1 500 Internal Server Error'); header('Content-Type: text/plain'); if ($message !== '') { header('RTK-Error: ' . $message); } // during development, send back ajax request for debugging if (coreConfig::get('sf_debug')) { try { $request = coreContext::getInstance()->getRequest(); $sJson = $request->getParameter('json'); $oJson = null; if ($sJson !== null) { $oJson = coreJson::decode($sJson); } echo 'Json data = ' . "\n" . ($oJson !== null ? print_r($oJson, true) : $sJson); } catch (Exception $e) { echo 'rtkAjaxException - no Json found, $_POST = ' . "\n" . print_r($_POST, true); } } exit(1); }
/** * * * @return object $this (allows chaining calls) */ private function bind(uiSelectTableBinding $bindObj) { // check if (!$bindObj instanceof uiSelectTableBinding) { throw new coreException('Binding parameter not of required class'); } // get configuration as object, or convert from JSON if string $config = $bindObj->getConfig(); if (is_string($config)) { // read config as a json string $config = coreJson::decode($config); } //DBG::printr($config);exit; // overwrite default settings with config values if (isset($config->settings)) { $this->configureSettings($config->settings); } else { throw new coreException(__CLASS__ . '::bind() Config "settings" missing'); } // setup some default values for columns $this->columns =& $config->columns; foreach ($this->columns as $colDef) { assert('isset($colDef->colData) || isset($colDef->colDisplay)'); // columns are not editable by default if (!isset($colDef->editable)) { $colDef->editable = false; } // sort on raw or display data if sort column is not explicitly set if (!isset($colDef->colSort)) { $colDef->colSort = isset($colDef->colData) ? $colDef->colData : null; } } //DBG::printr($this->settings);exit; }
protected function reviewAction($request) { $db = $this->getContext()->getDatabase(); $options = array('fn_get_flashcard' => array('rtkLabs', 'getFlashcardData')); if ($request->getMethod() !== coreRequest::POST) { $options['items'] = rtkLabs::iVocabShuffleBegin(); $this->uiFR = new uiFlashcardReview($options); } else { // handle Ajax requests $oJson = coreJson::decode($request->getParameter('json', '{}')); if (!empty($oJson)) { $flashcardReview = new uiFlashcardReview($options); return $this->renderText($flashcardReview->handleJsonRequest($oJson)); } throw new rtkAjaxException('Empty JSON Request.'); } }
/** * Kanji Flashcard review page with uiFlashcardReview * * GET request = review page * * type = 'expired'|'untested'|'relearned'|'fresh' * box = 'all'|[1-5] * filt = ''|'rtk1'|'rtk3' * * POST request = ajax request during review * * @param object $request */ protected function reviewAction($request) { $reviewBox = $request->getParameter('box', 'all'); $reviewType = $request->getParameter('type', 'expired'); $reviewFilt = $request->getParameter('filt', ''); $reviewMerge = $request->getParameter('merge') ? true : false; // validate $this->forward404Unless(preg_match('/^(all|[1-9]+)$/', $reviewBox)); $this->forward404Unless(preg_match('/^(expired|untested|relearned|fresh)$/', $reviewType)); $this->forward404Unless($reviewFilt == '' || preg_match('/(rtk1|rtk3)/', $reviewFilt)); // pick title $this->setReviewTitle($reviewType, $reviewFilt); // $sAjaxUrl = $this->getController()->genUrl('@review'); $options = array('partial_name' => 'review/ReviewKanji', 'ajax_url' => $sAjaxUrl, 'ts_start' => ReviewsPeer::getLocalizedTimestamp(), 'fn_get_flashcard' => array('KanjisPeer', 'getFlashcardData'), 'fn_put_flashcard' => array('ReviewsPeer', 'putFlashcardData')); if ($request->getMethod() !== coreRequest::POST) { $options['items'] = ReviewsPeer::getFlashcards($reviewBox, $reviewType, $reviewFilt, $reviewMerge); $this->uiFR = new uiFlashcardReview($options); } else { /* if (rand(1,10) < 3) { sleep(6); }*/ // handle Ajax request (or throws exception) $oJson = coreJson::decode($request->getParameter('json', '{}')); if (!empty($oJson)) { $flashcardReview = new uiFlashcardReview($options); return $this->renderText($flashcardReview->handleJsonRequest($oJson)); } throw new rtkAjaxException('Empty JSON Request.'); } return coreView::SUCCESS; }