本文整理汇总了PHP中Loader::import方法的典型用法代码示例。如果您正苦于以下问题:PHP Loader::import方法的具体用法?PHP Loader::import怎么用?PHP Loader::import使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Loader
的用法示例。
在下文中一共展示了Loader::import方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
$this->start();
\Loader::import('Modules.Blog');
$aResult = array();
$objectId = $this->getComponentRequest()->getObjectId();
$aResult['Model'] = new \ruxon\modules\Blog\models\BlogComment();
if (!empty($_POST)) {
// добавление комментария
$object = new \ruxon\modules\Blog\models\BlogComment();
$object->import($_POST);
$object->setPostId($objectId);
$object->on($object::EVENT_NEW_COMMENT, array('\\ruxon\\modules\\Blog\\classes\\' . $this->sModuleAlias . 'Module', 'onNewComment'));
if (!$object->save()) {
$aResult['Errors'] = $object->getErrors();
$aResult['Model'] = $object;
} else {
$aResult['Success'] = true;
$this->redirect(array('index', 'view'), array('id' => $objectId));
}
} else {
$aResult['Success'] = false;
}
$this->end($aResult, true);
}
示例2: run
public function run()
{
$this->start();
\Loader::import('Modules.Blog');
$aResult = array();
$objectId = $this->getComponentRequest()->getObjectId();
$comments = $this->mapper('\\ruxon\\modules\\Blog\\models\\mappers\\BlogCommentMapper')->find(['Criteria' => ['PostId' => $objectId], 'Order' => ['PostDate' => 'Desc']]);
$aResult['Items'] = $comments;
$this->end($aResult, true);
}
示例3: actionExecute
public function actionExecute($params = array())
{
if (!empty($params['module'])) {
\Loader::import('Modules.' . $params['module']);
$migrator = new MysqlDbMigrator($params['module']);
$migrator->migrateTo('last');
echo "Done!\n";
} else {
echo "Please specify module name!\n";
}
}
示例4: getExcelData
function getExcelData($uploadfile = '')
{
global $log;
$log->log('处理file开始');
if (is_readable($uploadfile) == false) {
$log->log('文件不可读');
return FALSE;
}
$data = array();
Loader::import(PHPEXCEL_ROOT);
try {
$objReader = PHPExcel_IOFactory::createReader('Excel5');
$objReader->setReadDataOnly(TRUE);
$objPHPExcel = $objReader->load($uploadfile);
$sheet = $objPHPExcel->getSheet(0);
$highestRow = $sheet->getHighestRow();
$highestColumn = $sheet->getHighestColumn();
$fieldAndTitle = getFieldAndTitle();
$log->log('处理file结束');
$fields = array();
for ($j = 1; $j <= $highestRow; $j++) {
for ($k = 'A'; $k <= $highestColumn; $k++) {
$value = $objPHPExcel->getActiveSheet()->getCell("{$k}{$j}")->getValue();
if ($j == 1) {
$field = array_search($value, $fieldAndTitle);
if (false !== $field) {
$fields[$k] = $field;
} else {
// ("模板有误,请从新生存模板");
}
} else {
$key = $fields[$k];
$data[$j][$key] = $value == NUll ? '' : $value;
if ($key == 'name') {
$data[$j]['firstChater'] = Sp_Dictionary::getFirstCharter($value);
}
}
}
}
$log->log('返回数据成功');
} catch (Exception $e) {
$log->log('处理错误: ' . $e->__toString());
}
return $data;
}
示例5: raise
public function raise($alias, $recipients, $params = array())
{
Loader::import('Modules.Main');
if (!is_array($recipients)) {
$recipients = array($recipients);
}
$event = Manager::getInstance()->getMapper('EmailObjectMapper')->findFirst(array('Criteria' => array('IsActive' => true, 'Alias' => $alias)));
if ($event->getId()) {
Toolkit::getInstance()->mail->ClearAddresses();
Toolkit::getInstance()->mail->From = Manager::getInstance()->getModule('Main')->config('FromEmail');
Toolkit::getInstance()->mail->FromName = Manager::getInstance()->getModule('Main')->config('FromName');
foreach ($recipients as $email) {
Toolkit::getInstance()->mail->AddAddress($email);
}
Toolkit::getInstance()->mail->Subject = $event->getSubject();
$emailTemplate = new MailTemplate($params);
Toolkit::getInstance()->mail->SetHtmlBody($emailTemplate->fetch($event->getAlias()));
return Toolkit::getInstance()->mail->Send();
}
return false;
}
示例6: actionExecute
public function actionExecute($params = array())
{
if (!empty($params['module']) && !empty($params[0])) {
$module = $params['module'];
\Loader::import('Modules.' . $module);
switch ($params[0]) {
// Установка модуля
case 'install':
\Loader::import('Modules.' . $module);
$className = $module . 'ModuleInstaller';
$classNameWithNamespaces = '\\ruxon\\modules\\' . $module . '\\classes\\' . $className;
$mod = class_exists($classNameWithNamespaces) ? new $classNameWithNamespaces() : new $className();
$mod->install();
echo "Module installed!\n";
break;
// Обновление
// Обновление
case 'update':
\Loader::import('Modules.' . $module);
$className = $module . 'ModuleInstaller';
$classNameWithNamespaces = '\\ruxon\\modules\\' . $module . '\\classes\\' . $className;
$mod = class_exists($classNameWithNamespaces) ? new $classNameWithNamespaces() : new $className();
$mod->update();
echo "Module updated!\n";
break;
// Удаление
// Удаление
case 'uninstall':
\Loader::import('Modules.' . $module);
$className = $module . 'ModuleInstaller';
$classNameWithNamespaces = '\\ruxon\\modules\\' . $module . '\\classes\\' . $className;
$mod = class_exists($classNameWithNamespaces) ? new $classNameWithNamespaces() : new $className();
$mod->uninstall();
echo "Module uninstalled!\n";
break;
}
} else {
echo "Please specify module name and action!\n";
}
}
示例7: bootstrap
public function bootstrap()
{
$bootstrapClass = Bootstrap_Abstract::YAF_DEFAULT_BOOTSTRAP;
if (isset($this->_options['bootstrap'])) {
$bootstrap = $this->_options['bootstrap'];
} else {
$bootstrap = $this->getAppDirectory() . DIRECTORY_SEPARATOR . $bootstrapClass . '.' . G::get('ext');
}
$loader = Loader::getInstance();
if (Loader::import($bootstrap)) {
if (!class_exists($bootstrapClass)) {
throw new Exception('Couldn\'t find class Bootstrap in ' . $bootstrap);
} else {
$bootstrap = new $bootstrapClass();
if (!$bootstrap instanceof Bootstrap_Abstract) {
throw new Exception('Expect a Yaf_Bootstrap_Abstract instance, ' . get_class($bootstrap) . ' give ');
}
if (version_compare(PHP_VERSION, '5.2.6') === -1) {
$class = new \ReflectionObject($bootstrap);
$classMethods = $class->getMethods();
$methodNames = array();
foreach ($classMethods as $method) {
$methodNames[] = $method->getName();
}
} else {
$methodNames = get_class_methods($bootstrap);
}
$initMethodLength = strlen(Bootstrap_Abstract::YAF_BOOTSTRAP_INITFUNC_PREFIX);
foreach ($methodNames as $method) {
if ($initMethodLength < strlen($method) && Bootstrap_Abstract::YAF_BOOTSTRAP_INITFUNC_PREFIX === substr($method, 0, $initMethodLength)) {
$bootstrap->{$method}($this->_dispatcher);
}
}
}
} else {
throw new Exception('Couldn\'t find bootstrap file ' . $bootstrap);
}
return $this;
}
示例8: getAction
private function getAction($appDir, Controller_Abstract $controller, $action, $module)
{
$nameSeparator = G::iniGet('yaf.name_separator');
if (isset($controller->actions[$action])) {
$actionPath = $appDir . DIRECTORY_SEPARATOR . $controller->actions[$action];
if (Loader::import($actionPath)) {
$actionMethod = $action . 'Action';
if (G::iniGet('yaf.name_suffix') == true) {
$classname = $controller . $nameSeparator . 'Action';
} else {
$classname = 'Action' . $nameSeparator . $controller;
}
if (!class_exists($classname, false)) {
throw new Exception\LoadFailed\Action('Could not find action ' . $classname . ' in ' . $actionPath);
}
$object = new $classname();
if (!$object instanceof Action_Abstract) {
throw new Exception\TypeError('Action ' . $classname . ' must extends from Yaf_Action_Abstract');
}
return $object;
} else {
throw new Exception\LoadFailed\Action('Could not find action script ' . $actionPath);
}
} else {
$actionrDir = '';
if ($this->_default_module == $module) {
$actionrDir = $appDir . DIRECTORY_SEPARATOR . 'actions';
} else {
$actionrDir = $appDir . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . 'actions';
}
if (G::iniGet('yaf.name_suffix') == true) {
$classname = $controller . $nameSeparator . 'Action';
} else {
$classname = 'Action' . $nameSeparator . $controller;
}
if (!class_exists($classname, false)) {
if (!Loader::getInstance()->internal_autoload($classname, $actionrDir)) {
throw new Exception\LoadFailed\Action('Could not find action script ' . $actionrDir);
}
}
if (!class_exists($classname, false)) {
throw new Exception\LoadFailed\LoadFailed('Could not find class ' . $classname . ' in action script ' . $actionrDir);
}
$object = new $classname();
if (!$object instanceof Action_Abstract) {
throw new Exception\TypeError('Action must be an instance of Yaf_Action_Abstract');
}
return $object;
}
return null;
}
示例9: define
<?php
/*
* editor by Carten 2015.7.31
*/
define('ROOT_PATH', __DIR__ . '/../../');
include_once ROOT_PATH . 'config/init.php';
Loader::import(WEB_ROOT . 'www/_class');
class User extends PHPUnit_Framework_TestCase
{
/**
* @dataProvider additionProvider
*/
public function testCheck($email, $mobile, $passwd, $confirm_passwd, $code, $expect)
{
$register = new User_Register();
$return = $register->check($email, $mobile, $passwd, $confirm_passwd, $code, $expect);
$this->assertEquals($expect, $return['status']);
//$this->expectOutputString('1');
//print "{$return['status']}";
//$this->assertEquals($expected, $a + $b);
}
public function additionProvider()
{
//array(email,mobile,passwd,confirm_passwd,captcha,expect);
return array(array('12163.com', '18612848103', '12345678', '12345678', '1234', -120), array('12@163.com', '1861284810', '12345678', '12345678', '123456', -121), array('12@163.com', '18612848103', '12345', '12345', '123456', -122), array('12@163.com', '18612848103', 'ww123456789', '123456', '123456', -123), array('12@163.com', '18612848103', 'ww123456789', 'ww123456789', '123456', -124));
}
}
示例10: model
/**
* 加载modelDao
* @param string $modelName
* @return \herosphp\model\IModel
*/
public static function model($modelName)
{
$modelName = ucfirst($modelName);
$modelPath = 'configs.models';
//如果定义了models路径,则优先使用定义的models路径
if (MODELS_PATH != false) {
$modelPath = MODELS_PATH;
}
Loader::import($modelPath . '.' . $modelName, IMPORT_CUSTOM, EXT_MODEL);
$className = 'models\\' . $modelName . 'Model';
return new $className();
}
示例11:
<?php
namespace ruxon\modules\Ruxon\components\Form\classes;
\Loader::import('Components.Ruxon.FormView');
class FormComponent extends \ruxon\modules\Ruxon\components\FormView\classes\FormViewComponent
{
protected $sModuleAlias = 'Ruxon';
protected $sComponentAlias = 'Form';
}
示例12: microtime
if (PHP_VERSION < '4.1.0') {
$_SERVER =& $HTTP_SERVER_VARS;
$_GET =& $HTTP_GET_VARS;
$_POST =& $HTTP_POST_VARS;
$_COOKIE =& $HTTP_COOKIE_VARS;
$_FILES =& $HTTP_POST_FILES;
$_ENV =& $HTTP_ENV_VARS;
$_REQUEST = false;
$_SESSION =& $HTTP_SESSION_VARS;
}
// A harmless way for you to say "Thanks Simian Systems, we like you."
//if (! headers_sent ()) {
// header ('X-Powered-By: SAF/' . SAF_VERSION);
//}
// Seed the "better" random number generator
mt_srand((double) microtime() * 1000000);
// Include the Loader
include_once SAF_DIR . '/lib/Loader/Loader.php';
// Create the $loader object and define the 'saf' namespace.
$loader = new Loader(array('saf' => SAF_DIR . '/lib', 'ext' => SAF_DIR . '/lib/Ext', 'pear' => SAF_DIR . '/lib/PEAR'));
// Include saf.functions, which defines some basic functions that are
// used occasionally within SAF packages.
$loader->import('saf.Functions');
// For those pear and ext packages that use the include_path:
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$join = ';';
} else {
$join = ':';
}
ini_set('include_path', SAF_DIR . $join . SAF_DIR . '/lib/PEAR' . $join . SAF_DIR . '/lib/Ext' . $join . '.');
//ini_get ('include_path'));
示例13: model
/**
* 加载modelDao
* @param string $modelName
* @return \herosphp\model\IModel
*/
public static function model($modelName)
{
$modelName = ucfirst($modelName);
$modelPath = APP_NAME . '.configs.models';
Loader::import($modelPath . '.' . $modelName, IMPORT_CUSTOM, EXT_MODEL);
$className = APP_NAME . '\\models\\' . $modelName . 'Model';
return new $className();
}
示例14: import
public static function import($mPath)
{
return Loader::import($mPath);
}
示例15: getTemplate
public function getTemplate()
{
try {
Loader::import(PHPEXCEL_ROOT);
$resultPHPExcel = new PHPExcel();
$fieldAndTitle = $this->getFieldAndTitle();
$n = 65;
foreach ($fieldAndTitle as $val) {
$coloum = chr($n) . '1';
$resultPHPExcel->getActiveSheet()->setCellValue($coloum, $val);
$n++;
}
$outputFileName = 'apply_data.xls';
$xlsWriter = PHPExcel_IOFactory::createWriter($resultPHPExcel, 'Excel5');
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition:inline;filename="' . $outputFileName . '"');
header("Content-Transfer-Encoding: binary");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: no-cache");
$xlsWriter->save("php://output");
} catch (Exception $e) {
echo $e->__toString();
}
}