Exemplo n.º 1
0
 function init()
 {
     $this->_initConf();
     $this->_initWebObject();
     $this->_initEnv();
     $this->_initLogger();
     $this->requestId = $this->genRequestId();
     //do self-define module initial process
     $mClassName = ucfirst(App::getModule()) . 'Module';
     if (class_exists($mClassName)) {
         $notUsed = new $mClassName();
         call_user_func($mClassName . '::initModule');
     } else {
         throw new Exception("initModule class not exists");
     }
     //统计执行时间
     $module = App::getModule();
     $interface = App::getController() . '_' . App::getAction();
     Statis_Client::startTick($module, $interface);
     App::getTimer()->set('framework init');
 }
Exemplo n.º 2
0
 function dispatch_url($url)
 {
     $moduleRoot = ROOT . EnvConf::$moduleRoot . "/" . App::getModule();
     $classFile = "{$moduleRoot}/controllers/";
     $subDir = App::getSubDir();
     if (!empty($subDir)) {
         $classFile .= $subDir . '/';
     }
     $className = ucfirst(App::getController()) . 'Controller';
     $func = ucfirst(App::getAction()) . 'Action';
     KC_LOG_DEBUG("hit controller: {$className}, action: {$func}.");
     $classFile .= strtolower(substr($className, 0, -10)) . '.php';
     if (!is_readable($classFile)) {
         KC_LOG_DEBUG("not_found invalid controller which is unavailable [ file: {$classFile} ]");
         throw new Exception("not_found invalid controller which is unavailable.");
     }
     require_once $classFile;
     if (!class_exists($className)) {
         KC_LOG_DEBUG("not_found invalid controller which is unavailable [ file: {$classFile}, class: {$className} ]");
         throw new Exception("not_found invalid controller which is unavailable.");
     }
     $obj = new $className();
     $obj->request = $this->app->request;
     $obj->response = $this->app->response;
     $obj->encoding = $this->app->encoding;
     $obj->debug = $this->app->debug;
     try {
         $this->_callmethod($obj, '_before');
         if (!$this->_callmethod($obj, $func, array())) {
             throw new Exception("not_found call method failed [ method name: {$func} ]");
         }
     } catch (Exception $ex) {
         $this->_callmethod($obj, '_after');
         throw $ex;
     }
     $this->_callmethod($obj, '_after');
 }
Exemplo n.º 3
0
 function send()
 {
     $data = $this->_formatResponse();
     $this->sendHeaders();
     //获取缓冲数据
     $ob = ini_get('output_buffering');
     if ($ob && strtolower($ob) !== 'off') {
         $str = ob_get_clean();
         //忽略前后空白
         $data = trim($str) . $data;
     }
     if ($data) {
         if (EnvConf::$debug) {
             KC_LOG_DEBUG("[RETURNED DATA]\n\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" . $data . "\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n");
         }
         //统计模块
         if (true) {
             $success = true;
             $code = 0;
             $msg = "succ";
             $module = App::getModule();
             $interface = App::getController() . '_' . App::getAction();
             $dataArr = json_decode($data, true);
             if (isset($dataArr['error_code']) && $dataArr['error_code'] == 0) {
                 $msg = $dataArr['error_msg'];
             } else {
                 $success = false;
                 $code = isset($dataArr['error_code']) ? $dataArr['error_code'] : -1;
                 $msg = (isset($dataArr['error_msg']) ? $dataArr['error_msg'] : "failed") . " ,requestid:" . $this->app->requestId;
                 $msg .= ', ip:' . App::getClientIp();
             }
             $do_not_report_code = array('100801');
             if (!in_array($code, $do_not_report_code)) {
                 Statis_Client::report($module, $interface, $success, $code, $msg);
             }
         }
         //support for return format -- jsonp
         if ('json' === $this->app->request->of) {
             $cb = $this->app->request->get('callback', '');
             $cb = trim($cb);
             if (!empty($cb)) {
                 $data = $cb . "({$data})";
             }
         }
         echo $data;
     }
 }
Exemplo n.º 4
0
                    <li><a href="<?php 
    echo App::getLink('Catalog', array('brand' => $brand->getId()));
    ?>
"><?php 
    echo $brand->name;
    ?>
</a></li>
                <?php 
}
?>
            </ul>
        </div>
    </div>

    <?php 
if (App::getController() != 'ProductController' && $this->filter_price['min'] != $this->filter_price['max']) {
    ?>
        <div class="price-range">
            <h2>Цены</h2>
            <div class="well text-center">
                <input type="text" class="span2" value="" data-slider-min="<?php 
    echo floor($this->filter_price['min']);
    ?>
" data-slider-max="<?php 
    echo ceil($this->filter_price['max']);
    ?>
" data-slider-step="1" data-slider-value="[<?php 
    echo $this->filter_price['min'];
    ?>
,<?php 
    echo $this->filter_price['max'];
Exemplo n.º 5
0
"><?php 
echo App::t('Товары');
?>
</a></li>
            <li><a class="<?php 
echo App::getController() == 'AdminCategories' ? 'active' : '';
?>
" href="<?php 
echo App::getlink('AdminCategories');
?>
"><?php 
echo App::t('Категории');
?>
</a></li>
            <li><a class="<?php 
echo App::getController() == 'AdminBrands' ? 'active' : '';
?>
" href="<?php 
echo App::getLink('AdminBrands');
?>
"><?php 
echo App::t('Производители');
?>
</a></li>
            <li class="logout"><a href=""><?php 
echo App::t('Logout');
?>
</a></li>
        </ul>
    </nav>
Exemplo n.º 6
0
<?php

require_once '../app/init.php';
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(-1);
$app = new App();
$renderOutput = $app->getController();
$layout = new Layout();
$layout->render($renderOutput);
Exemplo n.º 7
0
 public static function run()
 {
     // Подключение переводов
     App::setTranslation('controllers/' . App::getController());
     // Подготовка контроллера
     static::init();
     // Запуск необходимого для обработки запроса action - метода
     $method = 'action' . App::getAction();
     if (method_exists(get_called_class(), $method)) {
         return static::$method();
     } else {
         return static::actionDefault();
     }
 }