public function getResource($method, $identifier, array $options = array()) { $resource = parent::getResource($method, $identifier, $options); if (!$resource) { // Доступ к собственным ресурсам, даже если они не опубликованы if ($this->modx->user->id and is_numeric($this->modx->resourceIdentifier)) { $resource = $this->modx->getObject('modResource', array("id" => $this->modx->resourceIdentifier, "createdby" => $this->modx->user->id)); } } return $resource; }
/** * @param $value * @param $expected * @dataProvider providerSanitizeRequest */ public function testSanitizeRequest($value, $expected) { $this->modx->setOption('allow_tags_in_post', false); $_GET['test'] = $value; $_POST['test'] = $value; $_REQUEST['test'] = $value; $_COOKIE['test'] = $value; $this->request->sanitizeRequest(); $this->assertEquals($expected, $_GET['test'], 'Failed on GET'); $this->assertEquals($expected, $_POST['test'], 'Failed on POST'); $this->assertEquals($expected, $_REQUEST['test'], 'Failed on REQUEST'); $this->assertEquals($expected, $_COOKIE['test'], 'Failed on COOKIE'); }
/** * @param Discuss $discuss A reference to the Discuss instance */ function __construct(Discuss &$discuss) { parent::__construct($discuss->modx); $this->discuss =& $discuss; }
function __construct(Schedule &$Schedule) { parent::__construct($Schedule->modx); $this->Schedule =& $Schedule; }
function __construct(mSearch &$mSearch) { parent::__construct($mSearch->modx); $this->mSearch =& $mSearch; }
function __construct(Batcher &$batcher) { parent::__construct($batcher->modx); $this->batcher =& $batcher; }
/** * @param Sendex $Sendex */ function __construct(Sendex &$Sendex) { parent::__construct($Sendex->modx); $this->Sendex =& $Sendex; }
/** * @param StoreLocator $storelocator A reference to the StoreLocator instance */ function __construct(StoreLocator &$storelocator) { parent::__construct($storelocator->modx); $this->storelocator =& $storelocator; }
function __construct(Xdbedit &$xdbedit) { parent::__construct($xdbedit->modx); $this->xdbedit =& $xdbedit; }
/** * @param Quip $quip A reference to the Quip instance */ function __construct(Quip &$quip) { parent::__construct($quip->modx); $this->quip =& $quip; }
function __construct(UrlHistory &$UrlHistory) { parent::__construct($UrlHistory->modx); $this->UrlHistory =& $UrlHistory; }
function __construct(XFlickr &$xflickr) { parent::__construct($xflickr->modx); $this->xflickr =& $xflickr; }
function __construct(RSVPMe &$RSVPMe) { parent::__construct($RSVPMe->modx); $this->RSVPMe =& $RSVPMe; }
function __construct(miniPayment &$miniPayment) { parent::__construct($miniPayment->modx); $this->miniPayment =& $miniPayment; }
public function getResource($method, $identifier, array $options = array()) { $resource = parent::getResource($method, $identifier, $options); if (!$resource and $this->modx->user->isAuthenticated('mgr')) { $resource = $this->modx->getObject('modResource', (int) $this->modx->resourceIdentifier); } if (!$resource) { $this->modx->sendRedirect('/', array('responseCode' => 'HTTP/1.1 301 Moved Permanently')); } return $resource; }
function __construct(mSklad &$mSklad) { parent::__construct($mSklad->modx); $this->mSklad =& $mSklad; }
/** * {@inheritdoc} * * This implementation adds register logging capabilities via $_POST vars * when the error handler is loaded. */ public function loadErrorHandler($class = 'modError') { parent :: loadErrorHandler($class); $this->registerLogging($_POST); }
function __construct(modxTalks &$modxtalks) { parent::__construct($modxtalks->modx); $this->modxtalks =& $modxtalks; }
/** * Gets a requested resource and all required data. * * @param string $method The method, 'id', or 'alias', by which to perform * the resource lookup. * @param string|integer $identifier The identifier with which to search. * @param array $options An array of options for the resource fetching * @return modResource The requested modResource instance or request * is forwarded to the error page, or unauthorized page. */ public function getResource($method, $identifier, array $options = array()) { $resource = null; if ($method == 'alias') { $resourceId = $this->findResource($identifier); } else { $resourceId = $identifier; } if (!is_numeric($resourceId)) { $this->modx->sendErrorPage(); } $resource = parent::getResource($method, $identifier, $options); if ($resource) { $context = $resource->get('context_key'); $allowedContexts = $this->modx->getOption('lingua.contexts'); $allowedContexts = array_map('trim', @explode(',', $allowedContexts)); if (empty($context) || empty($allowedContexts) || !in_array($context, $allowedContexts)) { return $resource; } } $this->modx->setOption('cache_resource_key', 'lingua/resource/' . $this->modx->cultureKey); $isForward = array_key_exists('forward', $options) && !empty($options['forward']); $fromCache = false; $cacheKey = $this->modx->context->get('key') . "/resources/{$resourceId}"; $cultureKey = !empty($this->modx->cultureKey) ? $this->modx->cultureKey : $this->modx->getOption('cultureKey', null, 'en'); $cachedResource = $this->modx->cacheManager->get($cacheKey, array(xPDO::OPT_CACHE_KEY => $this->modx->getOption('cache_resource_key', null, 'lingua/resource/' . $cultureKey), xPDO::OPT_CACHE_HANDLER => $this->modx->getOption('cache_resource_handler', null, $this->modx->getOption(xPDO::OPT_CACHE_HANDLER)), xPDO::OPT_CACHE_FORMAT => (int) $this->modx->getOption('cache_resource_format', null, $this->modx->getOption(xPDO::OPT_CACHE_FORMAT, null, xPDOCacheManager::CACHE_PHP)))); if (is_array($cachedResource) && array_key_exists('resource', $cachedResource) && is_array($cachedResource['resource'])) { /** @var modResource $resource */ $resource = $this->modx->newObject($cachedResource['resourceClass']); if ($resource) { $resource->fromArray($cachedResource['resource'], '', true, true, true); $resource->_content = $cachedResource['resource']['_content']; $resource->_isForward = $isForward; if (isset($cachedResource['contentType'])) { $contentType = $this->modx->newObject('modContentType'); $contentType->fromArray($cachedResource['contentType'], '', true, true, true); $resource->addOne($contentType, 'ContentType'); } if (isset($cachedResource['resourceGroups'])) { $rGroups = array(); foreach ($cachedResource['resourceGroups'] as $rGroupKey => $rGroup) { $rGroups[$rGroupKey] = $this->modx->newObject('modResourceGroupResource', $rGroup); } $resource->addMany($rGroups); } if (isset($cachedResource['policyCache'])) { $resource->setPolicies(array($this->modx->context->get('key') => $cachedResource['policyCache'])); } if (isset($cachedResource['elementCache'])) { $this->modx->elementCache = $cachedResource['elementCache']; } if (isset($cachedResource['sourceCache'])) { $this->modx->sourceCache = $cachedResource['sourceCache']; } if ($resource->get('_jscripts')) { $this->modx->jscripts = $this->modx->jscripts + $resource->get('_jscripts'); } if ($resource->get('_sjscripts')) { $this->modx->sjscripts = $this->modx->sjscripts + $resource->get('_sjscripts'); } if ($resource->get('_loadedjscripts')) { $this->modx->loadedjscripts = array_merge($this->modx->loadedjscripts, $resource->get('_loadedjscripts')); } $isForward = $resource->_isForward; $resource->setProcessed(true); $fromCache = true; } } if (!$fromCache || !is_object($resource)) { $criteria = $this->modx->newQuery('modResource'); $criteria->select(array($this->modx->escape('modResource') . '.*')); $criteria->where(array('id' => $resourceId, 'deleted' => '0')); if (!$this->modx->hasPermission('view_unpublished') || $this->modx->getSessionState() !== modX::SESSION_STATE_INITIALIZED) { $criteria->where(array('published' => 1)); } if ($resource = $this->modx->getObject('modResource', $criteria)) { if ($resource instanceof modResource) { if ($resource->get('context_key') !== $this->modx->context->get('key')) { if (!$isForward || $isForward && !$this->modx->getOption('allow_forward_across_contexts', $options, false)) { if (!$this->modx->getCount('modContextResource', array($this->modx->context->get('key'), $resourceId))) { return null; } } } $resource->_isForward = $isForward; if (!$resource->checkPolicy('view')) { $this->modx->sendUnauthorizedPage(); } // hack the resource's content in here --------------------> $linguaLangs = $this->modx->getObject('linguaLangs', array('lang_code' => $cultureKey)); if ($this->lingua instanceof Lingua && $linguaLangs) { $linguaSiteContent = $this->modx->getObject('linguaSiteContent', array('resource_id' => $resource->get('id'), 'lang_id' => $linguaLangs->get('id'))); if ($linguaSiteContent) { $linguaSiteContentArray = $linguaSiteContent->toArray(); unset($linguaSiteContentArray['id']); foreach ($linguaSiteContentArray as $k => $v) { // exclude URI to reveal back the original URI later if (!empty($v) && $k !== 'uri') { $resource->set($k, $v); } } } } // hacking ends -------------------------------------------> if ($tvs = $resource->getMany('TemplateVars', 'all')) { /** @var modTemplateVar $tv */ /** * Override with LinguaTV when applicable */ foreach ($tvs as $tv) { $value = $tv->getValue($resource->get('id')); // hack the tv's content in here ------------------> if ($this->lingua instanceof Lingua && $linguaLangs) { $linguaTVContent = $this->modx->getObject('linguaSiteTmplvarContentvalues', array('tmplvarid' => $tv->get('id'), 'contentid' => $resourceId, 'lang_id' => $linguaLangs->get('id'))); if ($linguaTVContent) { $linguaTVContentValue = $linguaTVContent->get('value'); if (!empty($linguaTVContentValue)) { $value = $linguaTVContentValue; } } } // hacking ends -----------------------------------> $resource->set($tv->get('name'), array($tv->get('name'), $value, $tv->get('display'), $tv->get('display_params'), $tv->get('type'))); } } $this->modx->resourceGenerated = true; } } } elseif ($fromCache && $resource instanceof modResource && !$resource->get('deleted')) { if ($resource->checkPolicy('load') && ($resource->get('published') || $this->modx->getSessionState() === modX::SESSION_STATE_INITIALIZED && $this->modx->hasPermission('view_unpublished'))) { if ($resource->get('context_key') !== $this->modx->context->get('key')) { if (!$isForward || $isForward && !$this->modx->getOption('allow_forward_across_contexts', $options, false)) { if (!$this->modx->getCount('modContextResource', array($this->modx->context->get('key'), $resourceId))) { return null; } } } if (!$resource->checkPolicy('view')) { $this->modx->sendUnauthorizedPage(); } } else { return null; } $this->modx->invokeEvent('OnLoadWebPageCache'); } if ($this->modx->getOption('lingua.debug')) { $this->modx->log(modX::LOG_LEVEL_ERROR, __FILE__ . ' '); $this->modx->log(modX::LOG_LEVEL_ERROR, __METHOD__ . ' '); $this->modx->log(modX::LOG_LEVEL_ERROR, __LINE__ . ': $resourceArray: ' . print_r($resource->toArray(), 1)); } return $resource; }
function __construct(BannerY &$bannery) { parent::__construct($bannery->modx); $this->bannery =& $bannery; }
function __construct(myController &$cmpController) { parent::__construct($cmpController->modx); $this->cmpController =& $cmpController; }
function __construct(Gallery &$gallery) { parent::__construct($gallery->modx); $this->gallery =& $gallery; }
function __construct(CronManager &$cronmanager) { parent::__construct($cronmanager->modx); $this->cronmanager =& $cronmanager; }
function __construct(cmx &$cmx) { parent::__construct($cmx->modx); $this->cmx =& $cmx; }
function __construct(Orphans &$orphans) { parent::__construct($orphans->modx); $this->orphans =& $orphans; }
function __construct(mxCalendars &$mxcalendars) { parent::__construct($mxcalendars->modx); $this->mxcalendars =& $mxcalendars; }
/** * This implementation adds register logging capabilities via $_POST vars * when the error handler is loaded. * * @param string $class */ public function loadErrorHandler($class = 'modError') { parent::loadErrorHandler($class); $data = array_merge($_POST, array('register_class' => 'registry.modFileRegister')); $this->registerLogging($data); }
/** * @param FormSave $formsave A reference to the FormSave instance */ function __construct(FormSave &$formsave) { parent::__construct($formsave->modx); $this->formsave =& $formsave; }
/* * modxRepository by Fi1osof * http://community.modx-cms.ru/profile/Fi1osof/ * http://modxstore.ru */ if ($modx->context->key == 'mgr') { return; } if (!$modx->checkSiteStatus()) { return; } if (!($request_path = $modx->getOption('modxRepository.request_path', $scriptProperties, false))) { return; } $request = new modRequest($modx); $resourceIdentifier = $request->getResourceIdentifier("alias"); /* * Check for repository path */ if (strpos($resourceIdentifier, $request_path) !== 0) { return; } if (!($action = substr($resourceIdentifier, strlen($request_path)))) { return; } // Get processors path if (!($ns = $modx->getObject('modNamespace', 'modxrepository'))) { $modx->log(xPDO::LOG_LEVEL_ERROR, "Не было пролучено пространство имен modxrepository"); return; }
function __construct(Redirector &$redirector) { parent::__construct($redirector->modx); $this->redirector =& $redirector; }