本文整理汇总了PHP中Core::import方法的典型用法代码示例。如果您正苦于以下问题:PHP Core::import方法的具体用法?PHP Core::import怎么用?PHP Core::import使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Core
的用法示例。
在下文中一共展示了Core::import方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
public function process()
{
$params = Toolkit::i()->request->getParams();
if (count($params) < 2) {
echo "Please specify module and command\n";
} else {
$module = $params[0];
$controller = $params[1];
Core::import('Modules.' . $module);
$sController = $module . $controller . 'Command';
$sControllerFull = 'ruxon\\modules\\' . $module . '\\commands\\' . $sController;
if (class_exists($sControllerFull)) {
$oController = new $sControllerFull();
} else {
$oController = new $sController();
}
unset($params[0]);
unset($params[1]);
$par = array_values($params);
$action_params = array();
if (count($par)) {
foreach ($par as $k => $val) {
if (substr_count($val, "=") > 0) {
$tmp = explode("=", $val);
$action_params[$tmp[0]] = trim($tmp[1]);
} else {
$action_params[] = $val;
}
}
}
$oController->run('Execute', $action_params);
}
}
示例2: __construct
public function __construct($inputs = array(), $action = false, $method = 'post', $view = 'forms/_table_form')
{
Core::import('helpers/html', 'helpers/text');
$this->setInputs($inputs);
$this->action = $action ? $action : $_SERVER['REQUEST_URI'];
$this->method = strtolower($method);
$this->view = $view;
}
示例3: loadCommonExtensions
protected function loadCommonExtensions()
{
$aExtensions = $this->config()->getExtensions();
if (count($aExtensions)) {
foreach ($aExtensions as $ext) {
Core::import(array('Extensions', $ext));
}
}
}
示例4: get
public function get(Object $oObject, $aParams = array())
{
if (isset($this->aParams['ToModuleAlias'])) {
Core::import('Modules.' . $this->aParams['ToModuleAlias']);
}
$oMapper = Manager::getInstance()->getMapper($this->aParams['ToMapperAlias']);
$aParams['Criteria'][$this->aParams['Field']] = $oObject->getId();
return $oMapper->findFirst($aParams);
}
示例5: result403
public function result403()
{
Core::import('Modules.Main');
$oController = new SiteController();
$oResult = $oController->run('403', array());
Core::app()->response()->setStatus(403);
Core::app()->theme()->getLayout()->setContent($oResult->getHtml());
Core::app()->response()->setResponseText(Core::app()->theme()->fetch());
Core::app()->end();
Core::app()->hardEnd();
}
示例6: eagerFetching
public function eagerFetching(DbFetcher $oQuery, ObjectMapper $oParentMapper, $sPrefix, $aParams = array(), $aLocalParams = array())
{
if (isset($this->aParams['ToModuleAlias'])) {
Core::import('Modules.' . $this->aParams['ToModuleAlias']);
}
$oMapper = Manager::getInstance()->getMapper($this->aParams['ToMapperAlias']);
//echo '<pre>', print_r($oMapper, true), '</pre>'; die();
$aContainer = $oMapper->getContainer();
if ($oMapper) {
$oParentFields = $oParentMapper->getFields();
$oQuery->addJoinTable($aContainer['TableName'], $sPrefix . '_' . $this->getAlias(), DbFetcher::JOIN_LEFT, $sPrefix . '.' . $oParentFields->get($this->getField())->getField() . ' = ' . $sPrefix . '_' . $this->getAlias() . '.id');
$oFields = $oMapper->getFields();
foreach ($oFields as $alias => $field) {
if ($field->getType() != 'Object' && $field->getField()) {
$oQuery->addSelectField($sPrefix . '_' . $this->getAlias() . '.' . $field->getField(), $sPrefix . '_' . $this->getAlias() . '_' . $field->getField());
}
}
// Условия выборки
if (isset($aLocalParams['Criteria']) && is_object($aLocalParams['Criteria'])) {
$oQuery->addCriteria(call_user_func(array($aLocalParams['Criteria'], 'renderWhere')));
}
if (isset($aLocalParams['Criteria']) && is_array($aLocalParams['Criteria']) && count($aLocalParams['Criteria']) > 0) {
$oCriteria = new CriteriaGroup(Criteria::TYPE_AND);
foreach ($aLocalParams['Criteria'] as $k => $itm) {
if (is_object($itm)) {
$oCriteria->addElement($itm);
} else {
if (is_array($itm)) {
$oCriteria->addElement(new CriteriaElement($k, $itm['Type'], $itm['Value']));
} else {
$oCriteria->addElement(new CriteriaElement($k, '=', $itm));
}
}
}
$oQuery->addCriteria($oMapper->parseFindCriteria($oCriteria->renderWhere(), $sPrefix . '_' . $this->getAlias()));
}
if (isset($aLocalParams['Criteria']) && is_string($aLocalParams['Criteria'])) {
$oQuery->addCriteria($oMapper->parseFindCriteria($aLocalParams['Criteria'], $sPrefix . '_' . $this->getAlias()));
}
// Сортировка
if (isset($aLocalParams['Order']) && is_array($aLocalParams['Order']) && count($aLocalParams['Order']) > 0) {
foreach ($aLocalParams['Order'] as $k => $itm) {
$oQuery->addOrder($oMapper->parseFindField($k, $sPrefix . '_' . $this->getAlias()), $itm);
}
}
if (isset($aLocalParams['With']) && is_array($aLocalParams['With']) && count($aLocalParams['With'])) {
// TODO: Вложенные JOINы
}
}
return $oQuery;
}
示例7: get
public function get(Object $oObject, $aParams = array())
{
if (isset($this->aParams['ToModuleAlias'])) {
Core::import('Modules.' . $this->aParams['ToModuleAlias']);
}
$oMapper = Manager::getInstance()->getMapper($this->aParams['ToMapperAlias']);
$aLocCriteria = array($this->aParams['Field'] => $oObject->getId());
if (!empty($aParams)) {
if (isset($aParams['Criteria'])) {
foreach ($aParams['Criteria'] as $key => $val) {
$aLocCriteria[$key] = $val;
}
}
}
$nRelation = $oMapper->findStat('count', 'c', isset($this->aParams['FunctionParams']) ? $this->aParams['FunctionParams'] : '*', array('Criteria' => $aLocCriteria));
return $nRelation;
}
示例8: set
public function set(Object $oObject, $mValue)
{
if (isset($this->aParams['ToModuleAlias'])) {
Core::import('Modules.' . $this->aParams['ToModuleAlias']);
}
if (is_array($mValue)) {
$oObject->aForSaveRelationsData[$this->aParams['Alias']] = array('Delete' => 'all', 'Add' => $mValue);
}
/*if (!$oObject->isNew())
{
$oMapper = Manager::getInstance()->getMapper($this->aParams['ToMapper']);
$aContainer = $oMapper->getContainer();
$sClassName = $aContainer['Object'];
if (is_array($mValue))
{
// Удаляем все что есть
$oQuery = new DbUpdater(DbUpdater::TYPE_DELETE, $aContainer['TableName'], $sClassName, $this->getDbConnectionAlias());
$oCriteria = new CriteriaElement($this->aParams['Field'], Criteria::EQUAL, (int)$oObject->getId());
$oQuery->addCriteria($this->parseUpdateCriteria($oCriteria->renderWhere()));
return $oQuery->delete();
if (count($mValue))
{
foreach ($mValue as $val)
{
// сохраняем в базу
$oQuery = new DbUpdater(DbUpdater::TYPE_INSERT, $aContainer['TableName'], $sClassName, $this->getDbConnectionAlias());
$oQuery->setElement(array(
$this->aParams['Field'] => (int)$oObject->getId(),
$this->aParams['Field2'] => $val
));
return $oQuery->insert();
}
}
}
return true;
}*/
return false;
}
示例9: set
public function set(Object $oObject, $mValue)
{
if (is_array($mValue) && count($mValue)) {
if (isset($this->aParams['ToModuleAlias'])) {
Core::import('Modules.' . $this->aParams['ToModuleAlias']);
}
if (is_array($mValue)) {
$oObject->aForSaveRelationsData[$this->aParams['Alias']] = array('Set' => $mValue);
}
/*$result = new SimpleCollection;
$oMapper = Manager::getInstance()->getMapper($this->aParams['ToMapperAlias']);
foreach ($mValue as $k => $itm)
{
if (!empty($itm['Id']))
{
$obj = $oMapper->findById($itm['Id']);
} else {
$obj = $oMapper->create();
}
unset($itm['Id']);
$obj->import($itm);
$obj->set($this->aParams['Field'], $oObject->getId());
$obj->save();
//Core::p($obj);
$result->add($obj);
}
$oObject->simpleSet($this->getAlias(), $result);*/
}
return true;
}
示例10: renderPackages
public function renderPackages()
{
if (Core::app()->checkInstalledModule($this->assetsModule)) {
Core::import("Modules." . $this->assetsModule);
$assetsUrl = Manager::getInstance()->getModule($this->assetsModule)->publishAssets();
$assetsPath = Manager::getInstance()->getModule($this->assetsModule)->pathAssets();
$sResult = '';
if (count($this->aPackages)) {
foreach ($this->aPackages as $package) {
$aPackage = Loader::loadConfigFile($assetsPath . '/' . $package, 'package');
if (isset($aPackage['Includes']) && count($aPackage['Includes'])) {
foreach ($aPackage['Includes'] as $file) {
$sExt = mb_substr($file, mb_strrpos($file, ".") + 1);
$file_path = str_replace("~/", $assetsPath . '/' . $package . '/', $file);
$file = str_replace("~/", $assetsUrl . '/' . $package . '/', $file);
switch ($sExt) {
case 'js':
$sResult .= '<script type="text/javascript" src="' . $file . '"></script>';
$sResult .= "\n\t";
break;
case 'css':
$sResult .= '<link href="' . $file . '" type="text/css" rel="stylesheet" />';
$sResult .= "\n\t";
break;
case 'tpl':
$sResult .= file_get_contents($file_path);
$sResult .= "\n\t";
break;
}
}
}
}
}
return $sResult;
}
}
示例11: component
public function component($sModuleAlias, $sComponentAlias, $aParams = array())
{
Core::import('Components.' . $sModuleAlias . '.' . $sComponentAlias);
$sFullClassName = 'ruxon\\modules\\' . $sModuleAlias . '\\components\\' . $sComponentAlias . '\\classes\\' . $sComponentAlias . 'Component';
$sClassName = $sModuleAlias . $sComponentAlias . 'Component';
$oComponent = class_exists($sFullClassName) ? new $sFullClassName() : new $sClassName();
$oComponent->init($aParams);
$oComponent->run();
$bLayout = $this->sLayout === false ? false : true;
$oResponse = new ActionResponse($bLayout);
$oResponse->setHtml($oComponent->fetch());
return $oResponse;
}
示例12: init
public function init()
{
if (Core::app()->checkInstalledModule($this->module_alias)) {
Core::import('Modules.' . $this->module_alias);
}
}
示例13: init
protected function init()
{
Core::import('Modules.' . $this->_module);
$this->_path = RX_PATH . '/ruxon/modules/' . $this->_module . '/migrations';
if ($this->getDbConnection()->tableExists('main_module')) {
$this->_currentVersion = (int) Manager::getInstance()->getModule($this->_module)->dbRevision();
} else {
$this->_currentVersion = 0;
}
$this->_versions = array();
if (is_dir($this->_path)) {
$files = scandir($this->_path);
natsort($files);
foreach ($files as $file) {
if ($file[0] == '.' || $file[0] == '..') {
continue;
}
$info = pathinfo($file);
$tmpData = array('id' => substr($info['filename'], 0, strpos($info['filename'], "_")), 'name' => $info['filename']);
if (strrpos($info['filename'], ".class") !== false) {
// Class
include_once $this->_path . '/' . $file;
$tmpClassName = substr($file, strpos($file, "_") + 1);
$tmpData['className'] = str_replace(".class.php", "", $tmpClassName);
} else {
// Simple
$tmpData['migration'] = (include $this->_path . '/' . $file);
}
$this->_versions[] = (object) $tmpData;
}
}
}
示例14: executeRequest
protected function executeRequest($nStatusCode, $aParams)
{
$sModule = $aParams['Module'];
$sController = 'ruxon\\modules\\' . $sModule . '\\controllers\\' . $aParams['Controller'] . 'Controller';
$sAction = $aParams['Action'];
Core::import('Modules.' . $sModule);
if (!class_exists($sController)) {
$sController = $aParams['Controller'] . 'Controller';
}
Core::app()->theme()->getLayout()->setMetaTitle($aParams['Action'] . ' - ' . $aParams['Controller'] . ' - ' . $aParams['Module']);
$oController = new $sController($sModule, $aParams['Controller']);
unset($aParams['Action']);
unset($aParams['Controller']);
unset($aParams['Module']);
$oResult = $oController->run($sAction, $aParams);
Core::app()->response()->setStatus($nStatusCode);
if (is_object($oResult)) {
if ($oResult->getLayout()) {
Core::app()->theme()->getLayout()->setContent($oResult->getHtml());
$fullcontent = Core::app()->theme()->fetch();
Core::app()->response()->setResponseText($fullcontent);
} else {
$res = Toolkit::getInstance()->client->renderAjaxScriptFiles();
$res .= Toolkit::getInstance()->client->renderAjaxCssFiles();
Core::app()->response()->setResponseText($res . $oResult->getHtml());
}
}
return true;
}
示例15: execute
protected function execute($url, $class, $method, $parameters = NULL, $cache = NULL)
{
global $config;
if ($cache === NULL) {
$cache = $config['cache']['level'] == 'url';
$cache_expiry = $config['cache']['expiry'];
}
try {
if ($cache) {
$cache_file = $config['cache']['directory'] . '/' . sha1($url);
$buffering = false;
}
if ($cache && file_exists($cache_file) && time() - filemtime($cache_file) < $cache_expiry) {
readfile($cache_file);
return true;
} else {
if ($cache) {
ob_start();
$buffering = true;
}
Core::import($class);
$controller_name = $class . 'Controller';
$controller = new $controller_name($parameters);
if (isset($parameters[0])) {
unset($parameters[0]);
}
# Don't pass the complete match
call_user_func_array(array(&$controller, $method), $parameters);
if ($cache) {
file_put_contents($cache_file, ob_get_flush());
$buffering = false;
}
return $controller;
}
} catch (MissingResource $e) {
if ($cache && $buffering) {
ob_end_flush();
$buffering = false;
}
return false;
}
}