本文整理汇总了PHP中helper::import方法的典型用法代码示例。如果您正苦于以下问题:PHP helper::import方法的具体用法?PHP helper::import怎么用?PHP helper::import使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类helper
的用法示例。
在下文中一共展示了helper::import方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMethod
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: loadModel
/**
* 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: foo
<?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: fetch
/**
* 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: loadModel
/**
* 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: getAvailableBlocks
<?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 <yidong@cnezsoft.com>
* @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: loadClass
/**
* 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: hello2
<?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: convertRedmine
/**
* 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: printIncluded
* @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: loadExtension
/**
* 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: __construct
private function __construct() {
require_once($_SERVER['DOCUMENT_ROOT'] . '/inc/helper.php');
self::getINI();
self::loadStyles();
helper::import(['tmpl']);
}
示例13: login
<?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));
}
}
示例14: extendControl
/**
* 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;
}
}