require __DIR__ . '/vendor/autoload.php';
require __DIR__ . '/inc/zentao/nb/Autoloader.php';
\zentao\nb\Autoloader::register();
$app = \zentao\core\Application::app(dirname(ZTNB_ROOT)); //禅道的router
$slim = new \Slim\Slim();
$routes = require __DIR__ . '/data/config/routes.php';
foreach ($routes as $method => $_routes) {
if ($_routes) {
foreach ($_routes as $rule => $map) {
$slim->$method($rule, '\\zentao\\nb\\resource\\' . $map);
}
}
}
$slim->run();
<?php
namespace zentao\nb;
/**
* 资源类 父类
*/
class Resource {
public function __construct() {
}
/**
* Load the model file of one module.
*
* @param string $methodName The method name, if empty, use current module's name.
* @access public
* @return object|bool If no model file, return false. Else return the model object.
*/
protected function loadModel($moduleName) {
$modelFile = \helper::setModelFile($moduleName);
/* If no model file, try load config. */
if (!\helper::import($modelFile)) {
$this->app->loadConfig($moduleName, false);
$this->app->loadLang($moduleName);
$this->dao = new dao();
return false;
}
$modelClass = class_exists('ext' . $moduleName . 'model') ? 'ext' . $moduleName . 'model' : $moduleName . 'model';
$modelClass = '\\' . $modelClass;
if (!class_exists($modelClass))
$this->app->triggerError(" The model $modelClass not found", __FILE__, __LINE__, $exit = true);
$this->$moduleName = new $modelClass();
$this->dao = $this->$moduleName->dao;
return $this->$moduleName;
}
<?php
namespace zentao\nb\resource;
use zentao\nb\enum\BugType;
/**
* 项目自行定义的问题分类
*/
class IssueCategory extends \zentao\nb\resource {
public function fetchAll($format = 'json') {
global $app;
$types = $app->loadLang('bug')->bug->typeList;
$issue_categories = array();
foreach ($types as $key => $name) {
$issue_categories[] = array('id' => BugType::getIdByInterId($key), 'name' => $name);
}
echo json_encode(array('issue_categories' => $issue_categories));
}
/**
* 根据项目来取其中定义的分类
* @param int $projectId
* @param string $format
*/
public function fetchAllByProjectId($projectId, $format = 'json') {
$model = $this->loadModel('project');
$project = $model->getById($projectId);//TODO 支持按项目代号查找
if (!$project) {
$this->responseNotExixted();
}
global $app;
$types = $app->loadLang('bug')->bug->typeList;
$issue_categories = array();
foreach ($types as $key => $name) {
$issue_categories[] = array('id' => BugType::getIdByInterId($key), 'project' => array('id' => $projectId, 'name' => $project->name), 'name' => $name);
}
echo json_encode(array(
'issue_categories' => $issue_categories,
'total_count' => 2
));
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有