예제 #1
0
/**
 * Add an html tag for the given asset(s)
 * 
 * @param array $params
 * @param Template $smarty
 * @return string
 */
function smarty_function_asset($params, &$smarty)
{
    if (!isset($params['href'])) {
        throw new SmartyException('No parameter href is set');
    }
    // Getting files list
    $files = explode(',', $params['href']);
    if (empty($files)) {
        throw new SmartyException('href parameter is empty');
    }
    $dir = '';
    if (isset($params['dir'])) {
        $dir = '/' . trim($params['dir'], '/') . '/';
    }
    // Getting file type
    if (!isset($params['type'])) {
        $ext = substr($files[0], strrpos($files[0], '.') + 1);
        switch ($ext) {
            case 'less':
            case 'css':
                $type = 'css';
                break;
            case 'js':
                $type = 'js';
                break;
        }
    } else {
        $type = $params['type'];
    }
    if (!isset($type) || $type !== 'js' && $type !== 'css') {
        throw new SmartyException('Type is not defined');
    }
    if (Config::get('asset.combine', true) === false || count($files) === 1) {
        foreach ($files as $file) {
            $timestamp = Asset::getInstance()->add($dir . $file)->getLastModified();
            if ($type === 'css') {
                echo '<link rel="stylesheet" type="text/css" href="/' . $timestamp . $dir . $file . '" />' . PHP_EOL;
            } else {
                echo '<script src="/' . $timestamp . $dir . $file . '"></script>' . PHP_EOL;
            }
        }
    } else {
        $asset = Asset::getInstance();
        foreach ($files as $file) {
            $asset->add($dir . $file);
        }
        $uid = isset($params['name']) ? str_replace('.' . $type, '', $params['name']) : $asset->getUid();
        $timestamp = $asset->getLastModified();
        $asset->compile($uid);
        if ($type === 'css') {
            echo '<link rel="stylesheet" type="text/css" href="/' . $timestamp . '/' . $uid . '.css" />' . PHP_EOL;
        } else {
            echo '<script src="/' . $timestamp . '/' . $uid . '.js"></script>' . PHP_EOL;
        }
    }
}
예제 #2
0
 public function finishDynamicArea()
 {
     if (self::$curDynamicId !== $this->id) {
         return false;
     }
     echo '<!--\'end_frame_cache_' . $this->id . '\'-->';
     self::$curDynamicId = false;
     Asset::getInstance()->stopTarget($this->getAssetId());
     return true;
 }
 /**
  * setup initial game data when player play the game for the first time.
  * invoked by: Controller.GameServer.setup_data()
  * @param $game_data
  * @return bool
  */
 public function setup_game_data($game_data)
 {
     $game_data["gme_player"] = $_SESSION['ply_id'];
     $this->Create(Utility::TABLE_GAME_DATA, $game_data);
     $product = Product::getInstance();
     $product->initialize_product();
     $asset = Asset::getInstance();
     $asset->initialize_asset();
     return true;
 }
예제 #4
0
<?php

/**
 * This file is part of the PHP Oxygen package.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @copyright   Copyright (c) 2011-2012 Sébastien HEYD <*****@*****.**>
 * @author      Sébastien HEYD <*****@*****.**>
 * @package     PHP Oxygen
 */
// Load the framework
require_once '../oxygen/bootstrap.php';
if (isset($_GET['asset'])) {
    $asset = Asset::getInstance();
    $assets = explode(',', $_GET['asset']);
    foreach ($assets as $a) {
        $asset->add($a);
    }
    $asset->output();
} else {
    // Run the dispatcher
    Controller::getInstance()->dispatch();
}
 /**
  * show player details, show achievement and statistic.
  * role: administrator
  * redirected from: Controller.Player.suspend() whatever suspend result
  *                  Controller.Player.reactivate() whatever reactivate result
  */
 public function detail()
 {
     if (Authenticate::is_authorized()) {
         $model_player = Player::getInstance();
         $model_journal = Journal::getInstance();
         $model_achievement = Achievement::getInstance();
         $model_asset = Asset::getInstance();
         $model_material = Material::getInstance();
         $model_employee = Employee::getInstance();
         $model_memorycard = Memorycard::getInstance();
         $id = $this->framework->url->url_part(3);
         $this->framework->view->page = "player";
         $this->framework->view->content = "/backend/pages/player_detail";
         $this->framework->view->player_detail = $model_player->player_detail($id);
         $this->framework->view->player_summary = $model_player->fetch($id);
         $this->framework->view->player_performance = $model_player->performance($id);
         $this->framework->view->player_finance = $model_journal->finance_summaries($id);
         $this->framework->view->player_achievements = $model_achievement->get_achievement($id);
         $this->framework->view->player_assets = $model_asset->get_player_asset($id);
         $this->framework->view->player_employees = $model_employee->get_player_employee($id);
         $this->framework->view->player_materials = $model_material->get_player_material($id);
         $this->framework->view->player_game = $model_memorycard->load_game_data($id);
         $this->framework->view->show("backend/template");
     } else {
         transport("administrator");
     }
 }
 /**
  * role: player
  */
 public function repair_asset()
 {
     if (Authenticate::is_player()) {
         if (isset($_POST['token']) && Authenticate::is_valid_token($_POST['token'])) {
             $this->model_asset = Asset::getInstance();
             $result = $this->model_asset->repair_asset();
             $binding = array("result_var" => "session_ready", "status_var" => $result);
             binding_data($binding);
         } else {
             transport("error404");
         }
     } else {
         $binding = array("result_var" => "no_session");
         binding_data($binding);
     }
 }
 /**
  * role: player
  * @return string
  */
 public function insert_simulation()
 {
     if (Authenticate::is_player()) {
         if (isset($_POST['token']) && Authenticate::is_valid_token($_POST['token'])) {
             $this->model_memorycard = Memorycard::getInstance();
             $day = $_POST['day'];
             $served = $_POST['served'];
             $loss = $_POST['loss'];
             $stress = $_POST['stress'];
             $work = $_POST['work'];
             $location = $_POST['location'];
             $popularity = $_POST['popularity'];
             $overview = $_POST['overview'];
             $result = $this->model_memorycard->insert_simulation($day, $served, $loss, $stress, $work, $location, $popularity, $overview);
             $this->model_asset = Asset::getInstance();
             $this->model_asset->increase_depreciation();
             $log = Log::getInstance();
             $log->logging_game_simulation(json_encode(array($day, $served, $loss, $stress, $work, $location, $popularity, $overview)));
             $binding = array("result_var" => "session_ready", "simulation_var" => $result);
             binding_data($binding);
         } else {
             transport("error404");
         }
     } else {
         $binding = array("result_var" => "no_session");
         binding_data($binding);
     }
 }