/home
/u1249
/dev.ko-kirov.ru
/src
/Mindy
/Http
/Traits
/HttpErrors.php
{
$t = Translate::getInstance();
$codes = [
400 => $t->t('main', 'Invalid request. Please do not repeat this request again.'),
403 => $t->t('main', 'You are not authorized to perform this action.'),
404 => $t->t('main', 'The requested page does not exist.'),
500 => $t->t('main', 'Error'),
];
return isset($codes[$code]) ? $codes[$code] : 'Unknown error';
}
/**
* @param $code
* @param null $message
* @throws HttpException
*/
public function error($code, $message = null)
{
// CoreModule::t($message === null ? $codes[$code] : $message, [], 'errors')
throw new HttpException($code, $message === null ? $this->errorMessage($code) : $message);
}
}
/home
/u1249
/dev.ko-kirov.ru
/app
/Modules
/Catalog
/Controllers
/CategoryController.php
'pager' => $pager,
]);
Mindy::app()->cache->set('catalog/category_list/index', $content, 604800);
}
echo $this->render('catalog/category_list_content.html', [
'content' => $content,
]);
}
public function actionList($url)
{
if (substr($url, -1) == '/') { // TODO: рекламщики мудаки урлы расставили как мудилы
$this->request->redirect('/'.substr($url, 0, strlen($url) - 1), null, 301);
}
$category = Category::objects()->filter(['url' => $url])->get();
if ($category === null) {
$this->error(404);
}
$r = $this->getRequest();
$city = $r->cookies->get('city');
if ($city !== null) {
$newDomain = '//'.$city;
if (!DomainHelper::isMainDomain($r->getDomain(), $newDomain)) {
$r->redirect($newDomain.$category->getAbsoluteUrl());
}
}
if (!($content = Mindy::app()->cache->get($url))) {
$parents = $category->objects()->ancestors()->order(['lft'])->all();
$parents[] = $category;
$breadcrumbs = [
['name' => CatalogModule::t('Shop'), 'url' => Mindy::app()->urlManager->reverse('ko:index')],
];
foreach ($parents as $parent) {
$breadcrumbs[] = [
'url' => $parent->getAbsoluteUrl(),
/home
/u1249
/dev.ko-kirov.ru
/src
/Mindy
/Controller
/Action.php
protected function runWithParamsInternal($object, $method, $params)
{
$ps = [];
foreach ($method->getParameters() as $i => $param) {
$name = $param->getName();
if (isset($params[$name])) {
if ($param->isArray()) {
$ps[] = is_array($params[$name]) ? $params[$name] : [$params[$name]];
} elseif (!is_array($params[$name])) {
$ps[] = $params[$name];
} else {
return false;
}
} elseif ($param->isDefaultValueAvailable()) {
$ps[] = $param->getDefaultValue();
} else {
return false;
}
}
$method->invokeArgs($object, $ps);
return true;
}
}
/home
/u1249
/dev.ko-kirov.ru
/src
/Mindy
/Controller
/InlineAction.php
public function run()
{
$method = 'action' . $this->getId();
$this->getController()->$method();
}
/**
* Runs the action with the supplied request parameters.
* This method is internally called by {@link CController::runAction()}.
* @param array $params the request parameters (name=>value)
* @return boolean whether the request parameters are valid
* @since 1.1.7
*/
public function runWithParams($params)
{
$methodName = 'action' . $this->getId();
$controller = $this->getController();
$method = new ReflectionMethod($controller, $methodName);
if ($method->getNumberOfParameters() > 0) {
return $this->runWithParamsInternal($controller, $method, $params);
} else {
return $controller->$methodName();
}
}
}
/home
/u1249
/dev.ko-kirov.ru
/src
/Mindy
/Controller
/BaseController.php
$this->_action = $priorAction;
}
}
/**
* Runs the action after passing through all filters.
* This method is invoked by {@link runActionWithFilters} after all possible filters have been executed
* and the action starts to run.
* @param Action $action action to run
* @param array $params
*/
public function runAction($action, $params = [])
{
$priorAction = $this->_action;
$this->_action = $action;
$signal = Mindy::app()->signal;
$results = $signal->send($this, 'beforeAction', $this, $action);
if ($results->getLast()->value) {
ob_start();
if ($action->runWithParams($params) === false) {
ob_end_clean();
$this->invalidActionParams($action);
} else {
$signal->send($this, 'afterAction', $action, ob_get_clean());
}
}
$this->_action = $priorAction;
}
/**
* This method is invoked when the request parameters do not satisfy the requirement of the specified action.
* The default implementation will throw a 400 HTTP exception.
* @param Action $action the action being executed
* @throws \Mindy\Exception\HttpException
* @since 1.1.7
*/
public function invalidActionParams($action)
{
throw new HttpException(400, Mindy::t('base', 'Your request is invalid.'));
}
/home
/u1249
/dev.ko-kirov.ru
/src
/Mindy
/Controller
/BaseController.php
} else {
$this->missingAction($actionID);
}
}
/**
* Runs an action with the specified filters.
* A filter chain will be created based on the specified filters
* and the action will be executed then.
* @param Action $action the action to be executed.
* @param array $filters list of filters to be applied to the action.
* @param array $params
* @see filters
* @see createAction
* @see runAction
*/
public function runActionWithFilters($action, $filters, $params = [])
{
if (empty($filters)) {
$this->runAction($action, $params);
} else {
$priorAction = $this->_action;
$this->_action = $action;
FilterChain::create($this, $action, $filters)->run($params);
$this->_action = $priorAction;
}
}
/**
* Runs the action after passing through all filters.
* This method is invoked by {@link runActionWithFilters} after all possible filters have been executed
* and the action starts to run.
* @param Action $action action to run
* @param array $params
*/
public function runAction($action, $params = [])
{
$priorAction = $this->_action;
$this->_action = $action;
$signal = Mindy::app()->signal;
/home
/u1249
/dev.ko-kirov.ru
/src
/Mindy
/Controller
/BaseController.php
{
return [];
}
/**
* Runs the named action.
* Filters specified via {@link filters()} will be applied.
* @param string $actionID action ID
* @param array $params
* @see filters
* @see createAction
* @see runAction
*/
public function run($actionID, $params = [])
{
if (($action = $this->createAction($actionID)) !== null) {
$signal = Mindy::app()->signal;
$signal->send($this, 'beforeAction', $this, $action);
ob_start();
$this->runActionWithFilters($action, $this->filters(), $params);
$signal->send($this, 'afterAction', $action, ob_get_clean());
} else {
$this->missingAction($actionID);
}
}
/**
* Runs an action with the specified filters.
* A filter chain will be created based on the specified filters
* and the action will be executed then.
* @param Action $action the action to be executed.
* @param array $filters list of filters to be applied to the action.
* @param array $params
* @see filters
* @see createAction
* @see runAction
*/
public function runActionWithFilters($action, $filters, $params = [])
{
if (empty($filters)) {
/home
/u1249
/dev.ko-kirov.ru
/src
/Mindy
/Application
/Application.php
* @throws HttpException if the controller could not be created.
*/
public function runController($route)
{
if (($ca = $this->createController($route)) !== null) {
/** @var \Mindy\Controller\BaseController $controller */
list($controller, $actionID, $params) = $ca;
$_GET = array_merge($_GET, $params);
$csrfExempt = $controller->getCsrfExempt();
if (Console::isCli() === false && in_array($actionID, $csrfExempt) === false) {
/** @var \Mindy\Http\Request $request */
$request = $this->getComponent('request');
if ($request->enableCsrfValidation) {
$request->csrf->validate();
}
}
$oldController = $this->_controller;
$this->_controller = $controller;
$controller->init();
$controller->run($actionID, $params);
$this->_controller = $oldController;
} else {
throw new HttpException(404, Mindy::t('base', 'Unable to resolve the request "{route}".', [
'{route}' => $this->request->getPath()
]));
}
}
/**
* Creates a controller instance based on a route.
* The route should contain the controller ID and the action ID.
* It may also contain additional GET variables. All these must be concatenated together with slashes.
*
* This method will attempt to create a controller in the following order:
* <ol>
* <li>If the first segment is found in {@link controllerMap}, the corresponding
* controller configuration will be used to create the controller;</li>
* <li>If the first segment is found to be a module ID, the corresponding module
* will be used to create the controller;</li>
* <li>Otherwise, it will search under the {@link controllerPath} to create
/home
/u1249
/dev.ko-kirov.ru
/src
/Mindy
/Application
/Application.php
* @var \Mindy\Controller\BaseController
*/
private $_controller;
/**
* Processes the current request.
* It first resolves the request into controller and action,
* and then creates the controller to perform the action.
*/
public function processRequest()
{
$this->signal->send($this, 'onProcessRequest');
if (Console::isCli()) {
$exitCode = $this->_runner->run($_SERVER['argv']);
if (is_int($exitCode)) {
$this->end($exitCode);
}
} else {
$this->runController($this->parseRoute());
}
}
/**
* @return \Mindy\Router\Route
*/
public function parseRoute()
{
return $this->getUrlManager()->parseUrl($this->getRequest());
}
/**
* @throws \Mindy\Exception\Exception
* @return \Modules\User\Models\User instance the user session information
*/
public function getUser()
{
/** @var \Modules\User\Components\Auth $auth */
$auth = $this->getComponent('auth');
if (!$auth) {
/home
/u1249
/dev.ko-kirov.ru
/src
/Mindy
/Application
/BaseApplication.php
public function __get($name)
{
if ($this->getLocator()->has($name)) {
return $this->getLocator()->get($name);
} else {
return $this->__getInternal($name);
}
}
/**
* Runs the application.
* This method loads static application components. Derived classes usually overrides this
* method to do more application-specific tasks.
* Remember to call the parent implementation so that static application components are loaded.
*/
public function run()
{
$this->signal->send($this, 'beginRequest', $this);
register_shutdown_function([$this, 'end'], 0, false);
$this->processRequest();
$this->signal->send($this, 'endRequest', $this);
}
/**
* Terminates the application.
* This method replaces PHP's exit() function by calling
* {@link onEndRequest} before exiting.
* @param integer $status exit status (value 0 means normal exit while other values mean abnormal exit).
* @param boolean $exit whether to exit the current request. This parameter has been available since version 1.1.5.
* It defaults to true, meaning the PHP's exit() function will be called at the end of this method.
*/
public function end($status = 0, $exit = true)
{
$this->signal->send($this, 'endRequest', $this);
if ($exit) {
exit($status);
}
}
/**
/home
/u1249
/dev.ko-kirov.ru
/WWW
/index.php
$debug = is_file($config.'_local.php');
if (is_file($config.'_local.php')) {
$config .= '_local';
define('MAIN_DOMAIN', 'http://localhost');
} else {
define('MAIN_DOMAIN', '//ko-kirov.ru');
}
}
defined('MINDY_DEBUG') or define('MINDY_DEBUG', $debug);
$debug = true;
if ($debug || $_SERVER['REMOTE_ADDR'] == '92.39.76.2') {
ini_set('error_reporting', -1);
(new \Whoops\Run())
->pushHandler(new \Whoops\Handler\PrettyPageHandler())
->register();
}
\Mindy\Base\Mindy::getInstance($config.'.php')->run();