Esempio n. 1
0
 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);
 }
Esempio n. 2
0
 public function execute($request)
 {
     $user_id = coreContext::getInstance()->getUser()->getUserId();
     $this->filter = $this->getUser()->getLocalPrefs()->get('review.graph.filter', '');
     $carddata = ReviewsPeer::getLeitnerBoxCounts($this->filter);
     $this->restudy_cards = $carddata[0]['expired_cards'];
     // count untested cards and add to graph
     $this->untested_cards = ReviewsPeer::getCountUntested($user_id, $this->filter);
     $carddata[0]['fresh_cards'] = $this->untested_cards;
     $carddata[0]['total_cards'] += $this->untested_cards;
     // count totals (save a database query)
     //$this->total_cards = 0;
     $this->expired_total = 0;
     for ($i = 0; $i < count($carddata); $i++) {
         $box =& $carddata[$i];
         //$this->total_cards += $box['total_cards'];
         // count expired cards, EXCEPT the red stack
         if ($i > 0) {
             $this->expired_total += $box['expired_cards'];
         }
     }
     $this->chart_data = $this->makeChartData($carddata);
     //DBG::printr($this->chart_data);exit;
     $this->me = $this;
     return coreView::SUCCESS;
 }
Esempio n. 3
0
 /**
  * Adds a unique version identifier to the css and javascript file names,
  * (using the local file modified times from build script), to prevent client
  * browsers from using the cache when a css/js file is updated.
  * 
  * The .htaccess files redirects those "versioned" files to a php script that
  * will strip the version number to get the actual file, and return the file
  * gzipped if possible to minimized download size.
  * 
  * @param  string  $url   Css or Javascript url
  * @return string  Resource url with version number in it
  */
 protected function getVersionUrl($url)
 {
     // leave absolute URLs (usually from CDNs like Google and Yahoo) unchanged
     if (stripos($url, 'http:') === 0) {
         return $url;
     }
     if (coreContext::getInstance()->getConfiguration()->getEnvironment() === 'dev') {
         // do not use minified javascript/css in development environment
         $url = str_replace('.min.', '.', $url);
         // show the url that would be run by mod_rewrite
         $url = '/version/cache.php?env=dev&app=' . CORE_APP . '&path=' . urlencode($url);
     } else {
         // in production, "juicy" files should be precompiled and minified with a script
         if (($pos = strpos($url, '.juicy.')) !== false) {
             // replace the '.juicy' part with '.min' (eg: /css/main.juicy.css => /css/main.min.css)
             //$len = strlen($url);
             //$url = substr($url, 0, $pos) . substr($url, $pos + 6);
             $url = str_replace('.juicy.', '.min.', $url);
         }
         // add version string
         $versions = $this->getResourceVersion();
         $path = pathinfo($url);
         $ver = isset($versions[$url]) ? '_v' . $versions[$url] : '';
         preg_match('/(.+)(\\.[a-z]+)/', $path['basename'], $matches);
         $url = $path['dirname'] . '/' . $matches[1] . $ver . $matches[2];
     }
     return $url;
 }
Esempio n. 4
0
/**
 * Quick solution to include proprietary or sensitive content for the production
 * build, such as PayPal, advertising, and so on. Some of these are viewable in
 * the public site html source, but are better left out of the Open Source
 * repository to avoid misuse of tracking ids, emails and so on.
 * 
 * If the asset to include is not found, a box displays a message instead.
 * 
 * Those assets use a file naming pattern excluded from commits (.gitignore)
 * 
 * TODO: find way to handle a "production site" branch, instead of run time mode.
 * 
 * @author  Fabrice Denis
 */
function get_local_content($fromTemplate, $assetName)
{
    ob_start();
    if (coreConfig::get('koohii_build')) {
        $assetFile = '__' . $assetName . 'View.php';
        $assetPath = dirname(realpath($fromTemplate));
        $file = $assetPath . DIRECTORY_SEPARATOR . $assetFile;
        if (file_exists($file)) {
            // render as a partial so we have access to the default template variables
            $view = new coreView(coreContext::getInstance());
            $view->setTemplate($file);
            echo $view->render();
        } else {
            echo <<<EOD
<div style="background:red;color:yellow;padding:10px;">
koohii_build content NOT FOUND: <strong>{$assetName}</strong>
</div>
EOD;
        }
    } else {
        // show a little box with the name of the local asset
        echo <<<EOD
<div style="border-radius:5px;-moz-border-radius:5px;border:none;background:#b2d2e3;color:#42697e;padding:10px;margin:0 0 1em;">
Public site content: <strong>{$assetName}</strong>
</div>
EOD;
    }
    return ob_get_clean();
}
Esempio n. 5
0
/**
 * Returns a routed URL based on the module/action passed as argument
 * and the routing configuration.
 *
 * Examples:
 *   echo url_for('my_module/my_action');
 *    => /path/to/my/action
 *
 * @param  string 'module/action'
 * @param  bool   Return absolute path?
 * @return string Routed URL
 */
function url_for($internal_uri, $absolute = false)
{
    static $controller;
    if (!isset($controller)) {
        $controller = coreContext::getInstance()->getController();
    }
    return $controller->genUrl($internal_uri, $absolute);
}
Esempio n. 6
0
 private function createUser($username, $raw_password)
 {
     $userinfo = array('username' => $username, 'password' => coreContext::getInstance()->getUser()->getSaltyHashedPassword($raw_password), 'userlevel' => $this->getOption('level', UsersPeer::USERLEVEL_USER), 'email' => trim($this->getOption('email', 'created@localhost')), 'location' => trim($this->getOption('location', 'localhost')));
     //die(print_r($userinfo, true));
     if (false === UsersPeer::createUser($userinfo)) {
         $this->throwError('Could not create user.');
     }
 }
Esempio n. 7
0
 /**
  * Updates any column data for given user id.
  *
  * 'raw_password' will be hashed as required and stored into 'password' column.
  * 
  * @param int   $userid
  * @param array $data 
  * @return boolean
  */
 private function updateUser($userid, $data)
 {
     if (isset($data['raw_password'])) {
         $data['password'] = coreContext::getInstance()->getUser()->getSaltyHashedPassword($data['raw_password']);
         unset($data['raw_password']);
     }
     if (false === UsersPeer::updateUser($userid, $data)) {
         $this->throwError('Could not update user id %s', $userid);
     }
     return true;
 }
Esempio n. 8
0
/**
 * Add 1000 user records in dummy database WITHOUT prepared statement: avg. 700ms
 * With table locking, avg. 660ms (minimal difference!)
 * 
 * @return 
 */
function withoutStatementTest()
{
    $db = coreContext::getInstance()->getDatabase();
    $db->query("LOCK TABLES users WRITE");
    for ($i = 0; $i < 1000; $i++) {
        $s = 'framenum' . $i;
        $level = $i & 0xf;
        $db->query("INSERT users (username, userlevel, joindate) VALUES (?, ?, NOW())", array($s, $level));
    }
    $db->query("UNLOCK TABLES");
}
Esempio n. 9
0
/**
 * Output all validation errors.
 * 
 * @return 
 */
function form_errors()
{
    $request = coreContext::getInstance()->getRequest();
    $s = '';
    if ($request->hasErrors()) {
        foreach ($request->getErrors() as $key => $message) {
            $s .= "<strong>{$message}</strong><br />\n";
        }
        $s = content_tag('div', $s, array('class' => 'formerrormessage'));
    }
    return $s;
}
Esempio n. 10
0
/**
 * Return a confirmation message box html code, if any confirmation messages
 * were set in the Request object.
 * 
 * @return string  Html code to echo
 */
function form_confirmations()
{
    $request = coreContext::getInstance()->getRequest();
    $s = '';
    if ($request->hasConfirmations()) {
        $s = implode("<br/>\n", array_values($request->getConfirmations()));
        $s = content_tag('p', $s);
        $s = content_tag('div', $s, array('class' => 'messagebox msgbox-success'));
        $s .= '<div class="clear"></div>';
    }
    return $s;
}
Esempio n. 11
0
 public function printStackTrace()
 {
     $exception = is_null($this->wrappedException) ? $this : $this->wrappedException;
     if (coreConfig::get('sf_debug')) {
         $response = coreContext::getInstance()->getResponse();
         $response->setStatusCode(404);
         return parent::printStackTrace();
     } else {
         // debug message
         //echo $exception->getMessage();
         coreContext::getInstance()->getController()->forward(coreConfig::get('error_404_module'), coreConfig::get('error_404_action'));
     }
 }
Esempio n. 12
0
/**
 * uiChartVs
 * 
 * Options:
 *   labelLeft, labelRight   Labels on each side
 * 	 valueLeft, valueRight   Values, will be summed up to calculate percentage
 *   labelLeftMax            Label to use when value of the other side is 0 (OPTIONAL)
 *   labelRightMax
 * 
 * @see /doc/slicing/RevTK/charts/uiChartVs.html
 */
function ui_chart_vs(array $options)
{
    $valueTotal = $options['valueLeft'] + $options['valueRight'];
    $pctLeft = ceil($options['valueLeft'] * 100 / $valueTotal);
    $pctRight = 100 - $pctLeft;
    $captionLeft = isset($options['labelLeftMax']) && $options['valueRight'] == 0 ? $options['labelLeftMax'] : $options['labelLeft'];
    $captionRight = isset($options['labelRightMax']) && $options['valueLeft'] == 0 ? $options['labelRightMax'] : $options['labelRight'];
    $options = array_merge($options, array('pctLeft' => $pctLeft, 'pctRight' => $pctRight, 'bZeroLeft' => $pctLeft == 0, 'bZeroRight' => $pctRight == 0, 'captionLeft' => $captionLeft, 'captionRight' => $captionRight));
    $view = new coreView(coreContext::getInstance());
    $view->getParameterHolder()->add($options);
    $view->setTemplate(dirname(__FILE__) . '/templates/ui_chart_vs.php');
    return $view->render();
}
Esempio n. 13
0
 /**
  * 
  * Options
  * 	  partial_name      The full partial name (module/partial) to use for rendering
  * 
  * @return 
  */
 public function __construct($options = array())
 {
     $this->options = (object) $options;
     $this->partialName = $this->options->partial_name;
     $this->user_id = coreContext::getInstance()->getUser()->getUserId();
     //testing
     /*
     if (isset($this->options->items))
     {
     	$x = array();
     	for ($i = 1; $i<=3007; $i++) {
     		$x[] = 3008 - $i;
     	}
     	$this->options->items = $x; //array_slice($this->options->items, 0, 4);
     }
     */
 }
Esempio n. 14
0
 public function __construct(array $options)
 {
     $this->db = coreContext::getInstance()->getDatabase();
     if (!isset($options['internal_uri'])) {
         throw new coreException("Must set 'internal_uri' in uiSelectPager options.");
     }
     $this->setUrl($options['internal_uri']);
     if (isset($options['select'])) {
         $this->setSelect($options['select']);
     }
     if (isset($options['query_params'])) {
         $this->setQueryParams($options['query_params']);
     }
     if (isset($options['max_per_page'])) {
         $this->setMaxPerPage((int) $options['max_per_page']);
     }
     if (isset($options['page'])) {
         $this->setPage($options['page']);
     }
 }
Esempio n. 15
0
 /**
  * Remember to call parent::init() first when you override this!
  *
  */
 public function init()
 {
     $this->args = new SimpleArgs();
     if (!$this->args->getCount() || $this->args->flag('help')) {
         $this->showHelp();
         exit;
     }
     $coreApp = $this->getOption('app', DEFAULT_APP);
     $coreEnv = $this->getOption('env', DEFAULT_ENV);
     // Bootstrap framework
     define('CORE_APP', $coreApp);
     define('CORE_ENVIRONMENT', $coreEnv);
     define('CORE_DEBUG', true);
     require_once CORE_ROOT_DIR . '/apps/' . CORE_APP . '/config/config.php';
     $configurationClass = CORE_APP . 'Configuration';
     $configuration = new $configurationClass(CORE_ENVIRONMENT, CORE_DEBUG, CORE_ROOT_DIR);
     coreContext::createInstance($configuration);
     $this->isVerbose = $this->args->flag('v') !== false;
     $this->verbose("Verbose: ON (CORE_APP '%s', CORE_ENVIRONMENT '%s')", CORE_APP, CORE_ENVIRONMENT);
 }
Esempio n. 16
0
 public function execute($request)
 {
     $queryParams = $this->getUser()->getLocalPrefs()->syncRequestParams('mystorieslist', array(uiSelectPager::QUERY_ROWSPERPAGE => 10));
     // pager
     $this->pager = new uiSelectPager(array('select' => StoriesPeer::getMyStoriesSelect($this->getUser()->getUserId()), 'internal_uri' => 'study/mystories', 'query_params' => array(uiSelectTable::QUERY_SORTCOLUMN => $request->getParameter(uiSelectTable::QUERY_SORTCOLUMN, 'framenum'), uiSelectTable::QUERY_SORTORDER => $request->getParameter(uiSelectTable::QUERY_SORTORDER, 1), uiSelectPager::QUERY_ROWSPERPAGE => $queryParams[uiSelectPager::QUERY_ROWSPERPAGE]), 'max_per_page' => $queryParams[uiSelectPager::QUERY_ROWSPERPAGE], 'page' => $request->getParameter(uiSelectPager::QUERY_PAGENUM, 1)));
     $this->pager->init();
     // order by
     $order_by = array('framenum' => 'framenum ASC', 'keyword' => 'keyword ASC', 'lastedit' => 'updated_on DESC', 'votes' => 'stars DESC');
     $sortkey = $request->getParameter('sort', 'lastedit');
     $this->getController()->getActionInstance()->forward404Unless(!$sortkey || preg_match('/^[a-z]+$/', $sortkey));
     $orderClause = isset($order_by[$sortkey]) ? $order_by[$sortkey] : $order_by['framenum'];
     // get row data
     $get_select = clone $this->pager->getSelect();
     $get_select->order($orderClause);
     $rows = coreContext::getInstance()->getDatabase()->fetchAll($get_select);
     foreach ($rows as &$R) {
         $R['stars'] = $R['stars'] ? '<span class="star">' . $R['stars'] . '</span>' : '<span>&nbsp;</span>';
         $R['kicks'] = $R['kicks'] ? '<span class="report">' . $R['kicks'] . '</span>' : '<span>&nbsp;</span>';
         $R['story'] = StoriesPeer::getFormattedStory($R['story'], $R['keyword'], false);
     }
     $this->rows = $rows;
     return coreView::SUCCESS;
 }
Esempio n. 17
0
 /**
  * Initialize this table peer instance.
  * 
  * The only reason we instantiate the class is that static variables
  * can not be overriden in the extending class as of Php 5.2.
  * 
  * @param coreDatabase $db    coreDatabase instance.
  * @param string $tableName   Table name obtained from the class name without 'Peer' suffix
  * @return 
  */
 public function __construct($peerclass)
 {
     // static reference for convenience
     self::$db = coreContext::getInstance()->getDatabase();
     // check naming of model and determine the default table name
     if (!preg_match('/^(\\w+)Peer$/', $peerclass, $matches)) {
         throw new coreException('Invalid coreDatabaseTable class name: ' . $peerclass);
     }
     // if not explicitly set, the table name is derived from the class name, in lowercase
     if ($this->tableName === null) {
         $this->tableName = strtolower($matches[1]);
     }
     // columns check
     if (empty($this->columns)) {
         throw new coreException('coreDatabaseTable table ' . $this->getName() . ' columns not set.');
     }
     $this->initialize();
 }
Esempio n. 18
0
<?php

define('CORE_ROOT_DIR', realpath(dirname(__FILE__) . '/..'));
define('CORE_APP', 'revtk');
define('CORE_ENVIRONMENT', 'dev');
define('CORE_DEBUG', true);
require_once CORE_ROOT_DIR . '/apps/' . CORE_APP . '/config/config.php';
$configuration = new revtkConfiguration(CORE_ENVIRONMENT, CORE_DEBUG, CORE_ROOT_DIR);
coreContext::createInstance($configuration);
coreContext::getInstance()->getController()->dispatch();
Esempio n. 19
0
function nav_active($nav_id)
{
    $_request = coreContext::getInstance()->getRequest();
    $_page_id = $_request->getParameter('module') . '-' . $_request->getParameter('action');
    return $nav_id == $_page_id ? true : false;
}
Esempio n. 20
0
 /**
  * Class constructor.
  *
  */
 public function __construct()
 {
     coreContext::getInstance()->set('request', $this);
     // initialize parameter holder
     $this->parameterHolder = new sfParameterHolder();
 }
Esempio n. 21
0
 /**
  * Create an instance for the current action.
  * 
  * @param  object       AbstractController implementation.
  * @return coreContext  coreContext instance
  */
 public static function createInstance(coreProjectConfiguration $configuration)
 {
     $class = __CLASS__;
     self::$instance = new $class($configuration);
 }
Esempio n. 22
0
 * 
 * Common options:
 *   --v         Verbose mode
 *   --help      Show help
 * 
 * 
 * @author  Fabrice Denis
 */
// This block of code is the bootstrap for Core based apps
define('CORE_ROOT_DIR', realpath(dirname(__FILE__) . '/../..'));
define('CORE_APP', 'revtk');
define('CORE_ENVIRONMENT', 'dev');
define('CORE_DEBUG', true);
require_once CORE_ROOT_DIR . '/apps/' . CORE_APP . '/config/config.php';
$configuration = new revtkConfiguration(CORE_ENVIRONMENT, CORE_DEBUG, CORE_ROOT_DIR);
coreContext::createInstance($configuration);
require_once CORE_ROOT_DIR . '/lib/args/SimpleArgs.php';
class Command_CLI
{
    protected $isVerbose = true, $args = null;
    public function init()
    {
        $this->args = new SimpleArgs();
        if (!$this->args->getCount() || $this->args->flag('help')) {
            $this->showHelp();
            exit;
        }
        $this->isVerbose = $this->args->flag('v') !== false;
        $this->verbose("Verbose: ON");
    }
    /**
Esempio n. 23
0
 /**
  * Returns a SQL statement which returns a date+time adjusted to the
  * timezone of the user ($session->timezone).
  * 
  * The date returned by this statement will switch at midnight time
  * of the user's timezone (assuming the user set the timezone properly).
  * (the user's timezone range is -12...+14)
  * 
  * @param string  If set, 
  * 
  * @todo  Move to RevTK extension of core class
  */
 public function localTime($column = 'NOW()')
 {
     $timezone = coreContext::getInstance()->get('auth')->getTimezone();
     $timediff = $timezone - coreConfig::get('server_timezone', 0);
     $hours = floor($timediff);
     $minutes = $hours != $timediff ? '30' : '0';
     // some timezones have half-hour precision, convert to minutes
     $s = sprintf('ADDDATE(%s, INTERVAL \'%d:%d\' HOUR_MINUTE)', $column, $hours, $minutes);
     return $s;
 }
Esempio n. 24
0
 /**
  * Returns active user session.
  * 
  * @return coreUser
  */
 public static function getUser()
 {
     if (self::$user === null) {
         self::$user = coreContext::getInstance()->getUser();
     }
     return self::$user;
 }
Esempio n. 25
0
 /**
  * Redirect unauthenticated user to login action.
  * 
  * Options:
  * 
  *   username => Fill in the user name of the login form
  *   referer  => Page to return the user to after signing in
  * 
  * @param array $params  Options to pass to the login page
  */
 public function redirectToLogin($options = array())
 {
     if (isset($options['referer'])) {
         $this->setAttribute('login_referer', $options['referer']);
     }
     if (isset($options['username'])) {
         $this->setAttribute('login_username', $options['username']);
     }
     $login_url = coreConfig::get('login_module') . '/' . coreConfig::get('login_action');
     coreContext::getInstance()->getActionInstance()->redirect($login_url);
 }
Esempio n. 26
0
 /**
  * Render template file using PHP as the templating engine.
  * 
  * @param  string Filename
  * @return string A string representing the rendered presentation
  */
 protected function renderFile($templateFile)
 {
     // load core and standard helpers
     $helpers = array_unique(array_merge(array('Core', 'Url', 'Asset', 'Tag'), coreConfig::get('standard_helpers')));
     coreToolkit::loadHelpers($helpers);
     extract($this->parameterHolder->toArray(), EXTR_REFS);
     // template shortcuts
     $_context = coreContext::getInstance();
     $_request = $_context->getRequest();
     $_params = $_request->getParameterHolder();
     $_user = $_context->getUser();
     $_response = $_context->getResponse();
     // render
     ob_start();
     ob_implicit_flush(0);
     require $templateFile;
     return ob_get_clean();
 }
Esempio n. 27
0
 /**
  * Returns a timestamp localized to the user.
  * 
  * Currently, this timestamp corresponds to the adjusted flashcard's "lastreview" timestamp.
  * 
  * @return  int   Server's MySQL timestamp adjusted to user's local time.
  */
 public static function getLocalizedTimestamp()
 {
     $user = coreContext::getInstance()->getUser();
     $ts = self::$db->fetchOne('SELECT UNIX_TIMESTAMP(?)', new coreDbExpr($user->sqlLocalTime()));
     if (!$ts) {
         throw new coreException('getLocalizedTimestamp() failed');
     }
     return $ts;
 }
Esempio n. 28
0
 /**
  * Change Password.
  *
  * Update the user's password on the RevTK site AND the corresponding PunBB forum account.
  *   
  */
 public function executePassword($request)
 {
     if ($request->getMethod() != coreRequest::POST) {
         return coreView::SUCCESS;
     }
     // handle the form submission
     $validator = new coreValidator($this->getActionName());
     if ($validator->validate($request->getParameterHolder()->getAll())) {
         // verify old password
         $oldpassword = trim($request->getParameter('oldpassword'));
         $user = $this->getUser()->getUserDetails();
         if ($user && $this->getUser()->getSaltyHashedPassword($oldpassword) == $user['password']) {
             // proceed with password update
             $new_raw_password = trim($request->getParameter('newpassword'));
             $user = $this->getUser()->getUserDetails();
             // update the password on main site and forum
             $this->getUser()->changePassword($user['username'], $new_raw_password);
             // save username before signing out
             $this->username = $this->getUser()->getUserName();
             // log out user (sign out, clear cookie, clear punbb cookie(not on staging website))
             $this->getUser()->signOut();
             $this->getUser()->clearRememberMeCookie();
             if (coreContext::getInstance()->getConfiguration()->getEnvironment() !== 'staging' && coreConfig::get('app_path_to_punbb') !== null) {
                 PunBBUsersPeer::signOut();
             }
             try {
                 // send email confirmation
                 $mailer = new rtkMail();
                 $mailer->sendUpdatePasswordConfirmation($user['email'], $user['username'], $new_raw_password);
             } catch (coreException $e) {
                 $request->setError('mail_error', 'Oops, we tried sending you a confirmation email but the mail server didn\'t respond. Your password has been updated though!');
             }
             return 'Done';
         } else {
             $request->setError('login_invalid', "Old password doesn't match.");
         }
     }
     // clear the password fields (avoid input mistakes)
     $request->setParameter('oldpassword', '');
     $request->setParameter('newpassword', '');
     $request->setParameter('newpassword2', '');
 }
Esempio n. 29
0
 /**
  * Bridge between the Core framework configuration and Symfony 1.1 Url Routing.
  * 
  * Load the url routing config from settings.php, and add the routes to
  * Symfony's sfRouting object with the connect() method.
  * 
  * @todo   Use a cache with sfPatternRouting and evaluate speed gains.
  * 
  * @return sfPatternRouting
  */
 protected function initializeSymfonyRouting()
 {
     $dispatcher = new sfEventDispatcher();
     $sf_routing = new sfPatternRouting($dispatcher);
     coreContext::getInstance()->set('sfPatternRouting', $sf_routing);
     $app_routes = coreConfig::get('routing_config');
     // Add routes to the sfPatternRouting object
     foreach ($app_routes['routes'] as $name => $route) {
         $defaults = isset($route['param']) ? $route['param'] : array();
         $requirements = isset($route['requirements']) ? $route['requirements'] : array();
         $sf_routing->connect($name, $route['url'], $defaults, $requirements);
     }
     return $sf_routing;
 }
Esempio n. 30
0
 /**
  * Static function callback for uiFlashcardReview 'fn_get_flashcard'.
  * 
  * Returns flashcard data that was already loaded into the session,
  * given a unique flashcard id, which was used as the key for the
  * session array 'uifr'.
  * 
  * @return object   Object to be returned as JSON data
  */
 public static function getFlashcardData($id)
 {
     $sess = coreContext::getInstance()->getUser()->getAttribute(self::FLASHCARDREVIEW_SESS);
     if (!$sess) {
         throw new rtkAjaxException('getFlashcardData(): No session?');
     }
     if (isset($sess[$id - 1])) {
         // grab the flashcard data from the session
         $card = (object) $sess[$id - 1];
         //new stdClass();
         // uiFlashcardReview frontend requires this to match JSON response with its selection
         $card->id = $id;
         $card->dispword = self::getKeywordizedCompound($card->compound);
         return $card;
     }
     return null;
 }