Пример #1
0
 /**
  * Redirect user to the first page of pagination
  *
  * @param $isAjax
  *
  * @return string
  */
 public function redirectToFirst($isAjax = false)
 {
     unset($_GET[$this->pdoTools->config['pageVarKey']]);
     unset($_GET[$this->modx->getOption('request_param_alias', null, 'q')]);
     if (!$isAjax) {
         $this->modx->sendRedirect($this->modx->makeUrl($this->modx->resource->id, $this->modx->context->key, $_GET, 'full'));
         return '';
     } else {
         $_GET[$this->pdoTools->config['pageVarKey']] = 1;
         $_REQUEST = $_GET;
         return $this->modx->runSnippet('pdoPage', $this->pdoTools->config);
     }
 }
<?php

require_once '../../../core/config/config.inc.php';
require_once MODX_CORE_PATH . 'model/modx/modx.class.php';
$modx = new modX();
$modx->initialize('mgr');
$modx->getService('error', 'error.modError', '', '');
set_include_path(MODX_CORE_PATH . '../php/');
require_once 'lib/testing/assert_extension.php';
$result = $modx->runSnippet('getGalAlbumIdsByName', array('name' => 11));
$total = sizeof($result);
assert('$total == 0', 'getGalAlbumIdsByName :: Просто число вместо имени.');
//----------------------------------------------------------------------------
$result = $modx->runSnippet('getGalAlbumIdsByName', array('name' => 'wrong name'));
$total = sizeof($result);
assert('$total == 0', 'getGalAlbumIdsByName :: Нет такого имени альбома.');
//----------------------------------------------------------------------------
$result = $modx->runSnippet('getGalAlbumIdsByName', array('name' => 'test1'));
$total = sizeof($result);
$id = $result[0];
assert('$total == 2', 'getGalAlbumIdsByName :: Два альбома с один именем.');
assert('($id == 4)||($id == 5)', 'getGalAlbumIdsByName :: id альбомов 4 и 5.');
//----------------------------------------------------------------------------
$result = $modx->runSnippet('getGalAlbumIdsByName', array('name' => 'test2'));
$total = sizeof($result);
$id = $result[0];
assert('$total == 1', 'getGalAlbumIdsByName :: Только 1 альбом.');
assert('$id == 7', 'getGalAlbumIdsByName :: id альбома 7.');
//----------------------------------------------------------------------------
if ($errors_total == 0) {
    echo 'All tests passed.';
 /**
  * Runs snippet that checks permission of user to upload files
  *
  * @return bool|string
  */
 function checkAuth()
 {
     return !empty($this->config['authSnippet']) ? $this->modx->runSnippet($this->config['authSnippet'], $this->config) : true;
 }
Пример #4
0
$modx->resource = $modx->getObject('modResource', $criteria);
if (!is_object($modx->resource) || !$modx->resource->checkPolicy('view')) {
    echo json_encode($output);
    exit;
}
$modx->resourceIdentifier = $modx->resource->get('id');
$modx->getService('error', 'error.modError');
$modx->getRequest();
$modx->getParser();
$modx->resourceMethod = 'id';
$modx->resource->_contextKey = $modx->context->get('key');
$modx->invokeEvent('OnLoadWebDocument');
require_once MODX_CORE_PATH . "components/tag_manager2/model/tm_base.class.php";
$tag_manager = new tagManagerBase($modx);
$properties = $tag_manager->getSnippetProperties();
$output['prod_list'] = $modx->runSnippet('tmCatalog', $properties);
$output['prod_list'] .= '<div class="clearfix"></div>';
$output['onPageLimit'] = intval($properties['limit']);
if (isset($modx->placeholders[$properties['pageNavVar']])) {
    $output['pages'] = $modx->placeholders[$properties['pageNavVar']];
    if (isset($modx->sanitizePatterns['tags1'])) {
        $output['pages'] = preg_replace($modx->sanitizePatterns['tags1'], '', $output['pages']);
    }
    if (isset($modx->sanitizePatterns['tags2'])) {
        $output['pages'] = preg_replace($modx->sanitizePatterns['tags2'], '', $output['pages']);
    }
}
if (isset($modx->placeholders['pageCount'])) {
    $output['pageCount'] = $modx->placeholders['pageCount'];
}
if (isset($modx->placeholders[$properties['totalVar']])) {
Пример #5
0
        /* be sure this has a trailing slash */
        define('MODX_CORE_PATH', dirname(dirname(dirname(dirname(__FILE__)))) . '/');
    }
    /* get the MODX class file */
    require_once MODX_CORE_PATH . 'model/modx/modx.class.php';
    /* instantiate the $modx object */
    $modx = new modX();
    if (!$modx || !$modx instanceof modX) {
        echo 'Could not create MODX class';
    }
    /* initialize MODX and set current context */
    $modx->initialize('web');
    /* load the error handler */
    $modx->getService('error', 'error.modError', '', '');
    /* Set up logging */
    $modx->setLogLevel(xPDO::LOG_LEVEL_INFO);
    /* Set log target */
    $modx->setLogTarget('ECHO');
    // Is CronJob allowed?
    if ($modx->getOption($pkg . '.use_cronjob') && $modx->getOption($pkg . '.activated') && $modx->getOption($pkg . '.seofriendly')) {
        // Clear Cache
        //$cm = $modx->getCacheManager();
        //$cm->refresh();
        // Run Import Snippet - Cached Version
        $modx->runSnippet($pkg . '_import', array());
        exit(1);
    }
    exit(0);
}
echo 'This is an command line script for cronjobs';
exit(0);