コード例 #1
0
ファイル: model.php プロジェクト: caiwenhao/zentao
 public function getMethod($filePath, $ext = '')
 {
     $fileName = dirname($filePath);
     $className = basename(dirname(dirname($filePath)));
     if (!class_exists($className)) {
         helper::import($fileName);
     }
     $methodName = basename($filePath);
     $method = new ReflectionMethod($className . $ext, $methodName);
     $data = new stdClass();
     $data->startLine = $method->getStartLine();
     $data->endLine = $method->getEndLine();
     $data->comment = $method->getDocComment();
     $data->parameters = $method->getParameters();
     $data->className = $className;
     $data->methodName = $methodName;
     $data->fileName = $fileName;
     $data->post = false;
     $file = file($fileName);
     for ($i = $data->startLine - 1; $i <= $data->endLine; $i++) {
         if (strpos($file[$i], '$this->post') or strpos($file[$i], 'fixer::input') or strpos($file[$i], '$_POST')) {
             $data->post = true;
         }
     }
     return $data;
 }
コード例 #2
0
ファイル: Resource.php プロジェクト: wsyandy/zentao-rest-api
 /**
  * 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};
 }
コード例 #3
0
<?php

helper::import('/Users/shenpengfei/git_repository/pm_wcc/scrum_project_manage_system/module/misc/model.php');
class extmiscModel extends miscModel
{
    function hello2()
    {
        echo 'start from hello2.start.php<br>';
        echo $this->loadExtension('test')->hello();
        // Load testMisc class from test.class.php in ext/model/class.
        return $this->testMisc->hello();
        // After loading, can use $this->testMisc to call it.
    }
    public function foo()
    {
        return 'foo';
    }
    public function hello()
    {
        echo "start from hello.test.php <br>";
        echo 'start from hellp.test2.php<br>';
        return 'hello world from hello()<br />';
    }
}
コード例 #4
0
 /**
  * Get the output of one module's one method as a string, thus in one module's method, can fetch other module's content.
  * 
  * If the module name is empty, then use the current module and method. If set, use the user defined module and method.
  *
  * @param   string  $moduleName    module name.
  * @param   string  $methodName    method name.
  * @param   array   $params        params.
  * @access  public
  * @return  string  the parsed html.
  */
 public function fetch($moduleName = '', $methodName = '', $params = array())
 {
     if ($moduleName == '') {
         $moduleName = $this->moduleName;
     }
     if ($methodName == '') {
         $methodName = $this->methodName;
     }
     if ($moduleName == $this->moduleName and $methodName == $this->methodName) {
         $this->parse($moduleName, $methodName);
         return $this->output;
     }
     /* Set the pathes and files to included. */
     $modulePath = $this->app->getModulePath($moduleName);
     $moduleControlFile = $modulePath . 'control.php';
     $actionExtFile = $this->app->getModuleExtPath($moduleName, 'control') . strtolower($methodName) . '.php';
     $file2Included = file_exists($actionExtFile) ? $actionExtFile : $moduleControlFile;
     /* Load the control file. */
     if (!is_file($file2Included)) {
         $this->app->triggerError("The control file {$file2Included} not found", __FILE__, __LINE__, $exit = true);
     }
     $currentPWD = getcwd();
     chdir(dirname($file2Included));
     if ($moduleName != $this->moduleName) {
         helper::import($file2Included);
     }
     /* Set the name of the class to be called. */
     $className = class_exists("my{$moduleName}") ? "my{$moduleName}" : $moduleName;
     if (!class_exists($className)) {
         $this->app->triggerError(" The class {$className} not found", __FILE__, __LINE__, $exit = true);
     }
     /* Parse the params, create the $module control object. */
     if (!is_array($params)) {
         parse_str($params, $params);
     }
     $module = new $className($moduleName, $methodName);
     /* Call the method and use ob function to get the output. */
     ob_start();
     call_user_func_array(array($module, $methodName), $params);
     $output = ob_get_contents();
     ob_end_clean();
     /* Return the content. */
     unset($module);
     chdir($currentPWD);
     return $output;
 }
コード例 #5
0
ファイル: model.class.php プロジェクト: dyp8848/chanzhieps
 /**
  * Load the model of one module. After loaded, can use $this->modulename to visit the model object.
  * 
  * @param   string  $moduleName
  * @access  public
  * @return  object|bool  the model object or false if model file not exists.
  */
 public function loadModel($moduleName)
 {
     if (empty($moduleName)) {
         return false;
     }
     $modelFile = helper::setModelFile($moduleName);
     if (!helper::import($modelFile)) {
         return false;
     }
     $modelClass = class_exists('ext' . $moduleName . 'model') ? 'ext' . $moduleName . 'model' : $moduleName . 'model';
     if (!class_exists($modelClass)) {
         $this->app->triggerError(" The model {$modelClass} not found", __FILE__, __LINE__, $exit = true);
     }
     $this->{$moduleName} = new $modelClass();
     return $this->{$moduleName};
 }
コード例 #6
0
ファイル: model.php プロジェクト: leowh/colla
<?php

/**
 * The model file for block module of RanZhi.
 *
 * @copyright   Copyright 2009-2015 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
 * @license     ZPL (http://zpl.pub/page/zplv12.html)
 * @author      Yidong Wang <*****@*****.**>
 * @package     block
 * @version     $Id$
 * @link        http://www.ranzhico.com
 */
helper::import(realpath('../../sys/block/model.php'));
class crmblockModel extends blockModel
{
    /**
     * Get block list.
     * 
     * @access public
     * @return string
     */
    public function getAvailableBlocks()
    {
        foreach ($this->lang->block->availableBlocks as $key => $block) {
            if (!commonModel::hasPriv($key, 'browse')) {
                unset($this->lang->block->availableBlocks->{$key});
            }
        }
        return json_encode($this->lang->block->availableBlocks);
    }
    /**
コード例 #7
0
ファイル: router.class.php プロジェクト: leowh/colla
 /**
  * Load a class file.
  * 
  * @param   string $className  the class name
  * @param   bool   $static     statis class or not
  * @access  public
  * @return  object|bool the instance of the class or just true.
  */
 public function loadClass($className, $static = false)
 {
     $className = strtolower($className);
     /* Search in $coreLibRoot. */
     $classFile = $this->coreLibRoot . $className;
     if (is_dir($classFile)) {
         $classFile .= DS . $className;
     }
     $classFile .= '.class.php';
     if (!helper::import($classFile)) {
         $this->triggerError("class file {$classFile} not found", __FILE__, __LINE__, $exit = true);
     }
     /* If staitc, return. */
     if ($static) {
         return true;
     }
     /* Instance it. */
     global ${$className};
     if (!class_exists($className)) {
         $this->triggerError("the class {$className} not found in {$classFile}", __FILE__, __LINE__, $exit = true);
     }
     if (!is_object(${$className})) {
         ${$className} = new $className();
     }
     return ${$className};
 }
コード例 #8
0
ファイル: misc.php プロジェクト: fanscky/HTPMS
<?php

helper::import('F:\\xampp\\zentao\\module\\misc\\model.php');
class extmiscModel extends miscModel
{
    public function hello2()
    {
        echo 'start from hello2.start.php<br>';
        echo $this->loadExtension('test')->hello();
        // Load testMisc class from test.class.php in ext/model/class.
        return $this->testMisc->hello();
        // After loading, can use $this->testMisc to call it.
    }
    public function foo()
    {
        return 'foo';
    }
    public function hello()
    {
        echo "start from hello.test.php <br>";
        echo 'start from hellp.test2.php<br>';
        return 'hello world from hello()<br />';
    }
}
コード例 #9
0
ファイル: control.php プロジェクト: laiello/zentaoms
 /**
  * convert redmine 
  * 
  * @param  int    $version 
  * @access public
  * @return void
  */
 public function convertRedmine($version)
 {
     helper::import('./converter/redmine.php');
     helper::import("./converter/redmine{$version}.php");
     $className = "redmine11ConvertModel";
     $redmine->aimTypes = $this->post->aimTypes;
     $redmine->statusTypes['bug'] = $this->post->statusTypesOfBug;
     $redmine->statusTypes['story'] = $this->post->statusTypesOfStory;
     $redmine->statusTypes['task'] = $this->post->statusTypesOfTask;
     $redmine->priTypes['bug'] = $this->post->priTypesOfBug;
     $redmine->priTypes['story'] = $this->post->priTypesOfStory;
     $redmine->priTypes['task'] = $this->post->priTypesOfTask;
     $converter = new $className($redmine);
     $this->view->version = $version;
     $this->view->result = $converter->execute($version);
     $this->view->info = redmineConvertModel::$info;
     $this->display();
 }
コード例 #10
0
ファイル: case004.php プロジェクト: take7yo/zentaophp
 * @package     Testing
 * @version     $Id$
 * @link        http://www.zentao.net
 * @license     http://opensource.org/licenses/lgpl-3.0.html LGPL
 */
include '../../helper.class.php';
/* 首次包含。*/
helper::import('import1.php');
printIncluded();
/* 重复包含。*/
helper::import('import1.php');
printIncluded();
/* 包含第二个文件。*/
helper::import('import2.php');
printIncluded();
/* 包含不存在的文件。*/
var_dump(helper::import('noexits.php'));
/**
 * 只打印包含文件的文件名。
 * 
 * @access public
 * @return void
 */
function printIncluded()
{
    $files = get_included_files();
    foreach ($files as $file) {
        echo basename($file) . "\n";
    }
    echo "\n";
}
コード例 #11
0
ファイル: model.class.php プロジェクト: laiello/zentaoms
 /**
  * Load extension class of a model. Saved to $moduleName/ext/model/class/$extensionName.class.php.
  * 
  * @param  string $extensionName 
  * @param  string $moduleName 
  * @access public
  * @return void
  */
 public function loadExtension($extensionName, $moduleName = '')
 {
     if (empty($extensionName)) {
         return false;
     }
     /* Set extenson name and extension file. */
     $extensionName = strtolower($extensionName);
     $moduleName = $moduleName ? $moduleName : $this->getModuleName();
     $extensionFile = $this->app->getModuleExtPath($moduleName, 'model') . 'class/' . $extensionName . '.class.php';
     /* Try to import parent model file auto and then import the extension file. */
     if (!class_exists($moduleName . 'Model')) {
         helper::import($this->app->getModulePath($moduleName) . 'model.php');
     }
     if (!helper::import($extensionFile)) {
         return false;
     }
     /* Set the extension class name. */
     $extensionClass = $extensionName . ucfirst($moduleName);
     if (!class_exists($extensionClass)) {
         return false;
     }
     /* Create an instance of the extension class and return it. */
     $extensionObject = new $extensionClass();
     $extensionClass = str_replace('Model', '', $extensionClass);
     $this->{$extensionClass} = $extensionObject;
     return $extensionObject;
 }
コード例 #12
0
 private function __construct() {
     require_once($_SERVER['DOCUMENT_ROOT'] . '/inc/helper.php');
     self::getINI();
     self::loadStyles();
     helper::import(['tmpl']);
 }
コード例 #13
0
ファイル: misc.php プロジェクト: xupnge1314/sscpms
<?php

helper::import('D:\\wnmp\\nginx\\html\\zentao\\module\\misc\\model.php');
class extmiscModel extends miscModel
{
    public function hello2()
    {
        echo 'start from hello2.start.php<br>';
        echo $this->loadExtension('test')->hello();
        // Load testMisc class from test.class.php in ext/model/class.
        return $this->testMisc->hello();
        // After loading, can use $this->testMisc to call it.
    }
    public function foo()
    {
        return 'foo';
    }
    public function hello()
    {
        echo "start from hello.test.php <br>";
        echo 'start from hellp.test2.php<br>';
        return 'hello world from hello()<br />';
    }
}
コード例 #14
0
ファイル: meizai.user.php プロジェクト: mustafakarali/b2c-1
<?php

helper::import('/Users/user05/work/meizai/system/module/user/model.php');
class extuserModel extends userModel
{
    function login($account = "", $password = "")
    {
        if (!$account) {
            $account = tool::getParams('phone', '');
        }
        $password = tool::getParams('password', '');
        if (!$account || !$password) {
            $this->send(array('result' => 'fail', 'message' => '手机号或密码不能为空'));
        }
        $user = $this->identify($account, $password);
        a($user);
        exit;
        if (!$user) {
            $this->send(array('result' => 'fail', 'message' => '手机号或密码错误'));
        }
        $this->send(array('result' => 'success', 'message' => $this->lang->getSuccess, 'data' => $user));
    }
}
コード例 #15
0
ファイル: model.php プロジェクト: caiwenhao/zentao
    /**
     * Extend control.php and get file content.
     * 
     * @param  string    $filePath 
     * @access public
     * @return string
     */
    public function extendControl($filePath, $isExtends)
    {
        $className = basename(dirname(dirname($filePath)));
        if (!class_exists($className)) {
            helper::import(dirname($filePath));
        }
        $methodName = basename($filePath);
        if ($isExtends == 'yes') {
            $methodParam = $this->getParam($className, $methodName);
            return $fileContent = <<<EOD
<?php
include '../../control.php';
class my{$className} extends {$className}
{
    public function {$methodName}({$methodParam})
    {
        return parent::{$methodName}({$methodParam});
    }
}
EOD;
        } else {
            $methodCode = $this->getMethodCode($className, $methodName);
            return $fileContent = <<<EOD
<?php
class {$className} extends control
{
{$methodCode}
}
EOD;
        }
    }