当前位置: 首页>>代码示例>>PHP>>正文


PHP modX::getIterator方法代码示例

本文整理汇总了PHP中modX::getIterator方法的典型用法代码示例。如果您正苦于以下问题:PHP modX::getIterator方法的具体用法?PHP modX::getIterator怎么用?PHP modX::getIterator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在modX的用法示例。


在下文中一共展示了modX::getIterator方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loadSettingsFromNamespace

 /**
  * Loads all system settings that start with the configured namespace.
  *
  * @return array
  */
 public function loadSettingsFromNamespace()
 {
     $ns = $this->namespace;
     $config = array();
     $corePath = $this->modx->getOption($ns . '.core_path', null, MODX_CORE_PATH . 'components/' . $ns . '/');
     $config['core_path'] = $corePath;
     $config['templates_path'] = $corePath . 'templates/';
     $config['controllers_path'] = $corePath . 'controllers/';
     $config['model_path'] = $corePath . 'model/';
     $config['processors_path'] = $corePath . 'processors/';
     $config['elements_path'] = $corePath . 'elements/';
     $assetsUrl = $this->modx->getOption($ns . '.assets_url', null, MODX_ASSETS_URL . 'components/' . $ns . '/');
     $config['assets_url'] = $assetsUrl;
     $config['connector_url'] = $assetsUrl . ' connector.php';
     $c = $this->modx->newQuery('modSystemSetting');
     $c->where(array('key:LIKE' => $ns . '.%'));
     $c->limit(0);
     /** @var \modSystemSetting[] $iterator */
     $iterator = $this->modx->getIterator('modSystemSetting', $c);
     foreach ($iterator as $setting) {
         $key = $setting->get('key');
         $key = substr($key, strlen($ns) + 1);
         $config[$key] = $setting->get('value');
     }
     return $config;
 }
开发者ID:hansek,项目名称:Alpacka,代码行数:31,代码来源:Alpacka.php

示例2: refreshURIs

 /**
  * Refresh Resource URI fields for children of the specified parent.
  *
  * @static
  * @param modX &$modx A reference to a valid modX instance.
  * @param int $parent The id of a Resource parent to start from (default is 0, the root)
  * @param array $options An array of various options for the method:
  *      - resetOverrides: if true, Resources with uri_override set to true will be included
  *      - contexts: an optional array of context keys to limit the refresh scope
  * @return void
  */
 public static function refreshURIs(modX &$modx, $parent = 0, array $options = array())
 {
     $resetOverrides = array_key_exists('resetOverrides', $options) ? (bool) $options['resetOverrides'] : false;
     $contexts = array_key_exists('contexts', $options) ? explode(',', $options['contexts']) : null;
     $criteria = $modx->newQuery('linguaSiteContent');
     $criteria->where(array('lang_id' => $options['lang_id'], 'parent' => $parent));
     if (!$resetOverrides) {
         $criteria->where(array('uri_override' => false));
     }
     if (!empty($contexts)) {
         $criteria->where(array('context_key:IN' => $contexts));
     }
     /** @var Resource $resource */
     $resources = $modx->getIterator('linguaSiteContent', $criteria);
     foreach ($resources as $resource) {
         $resource->set('refreshURIs', true);
         if ($resetOverrides) {
             $resource->set('uri_override', false);
         }
         if (!$resource->get('uri_override')) {
             $resource->set('uri', '');
         }
         $resource->save();
     }
 }
开发者ID:DeFi-ManriquezLuis,项目名称:MTLTransfer,代码行数:36,代码来源:linguasitecontent.class.php

示例3: loadContextSettingsFromNamespace

 /**
  * Grabs context specific settings from the current namespace, and loads them into $this->config.
  * Also returns the newly overridden values in an array.
  *
  * @param $contextKey
  * @return array
  */
 public function loadContextSettingsFromNamespace($contextKey)
 {
     $config = array();
     $c = $this->modx->newQuery('modContextSetting');
     $c->where(array('context_key' => $contextKey, 'key:LIKE' => $this->namespace . '.%'));
     $c->limit(0);
     /** @var \modSystemSetting[] $iterator */
     $iterator = $this->modx->getIterator('modContextSetting', $c);
     foreach ($iterator as $setting) {
         $key = $setting->get('key');
         $key = substr($key, strlen($this->namespace) + 1);
         $config[$key] = $setting->get('value');
     }
     $this->config = array_merge($this->config, $config);
     return $config;
 }
开发者ID:modmore,项目名称:alpacka,代码行数:23,代码来源:Alpacka.php

示例4: clearLinks

 /**
  * @param bool|string $link_type
  * @param bool|int $parent
  */
 public function clearLinks($link_type = false, $parent = false)
 {
     $c = $this->modx->newQuery('modDevToolsLink');
     if ($link_type) {
         $c->where(array('link_type:LIKE' => $link_type . '-%'));
     }
     if ($parent) {
         $c->where(array('parent' => $parent));
     }
     $links = $this->modx->getIterator('modDevToolsLink', $c);
     /**
      * @var modDevToolsLink $link
      */
     foreach ($links as $link) {
         $link->remove();
     }
 }
开发者ID:Jako,项目名称:modDevTools,代码行数:21,代码来源:moddevtools.class.php

示例5: findResolution

 /**
  * Search for package to satisfy a dependency.
  *
  * @param string $package The name of the dependent package.
  * @param string $constraint The version constraint the package must satisfy.
  * @param modTransportProvider|null $provider A reference which is set to the
  * modTransportProvider which satisfies the dependency.
  *
  * @return array|bool The metadata for the package version which satisfies the dependency, or FALSE.
  */
 public function findResolution($package, $constraint, &$provider = null)
 {
     $resolution = false;
     $conditions = array('active' => true);
     switch (strtolower($package)) {
         case 'php':
             /* you must resolve php dependencies manually */
             $this->xpdo->log(xPDO::LOG_LEVEL_WARN, "PHP version dependencies must be resolved manually", '', __METHOD__, __FILE__, __LINE__);
             break;
         case 'modx':
         case 'revo':
         case 'revolution':
             /* resolve core dependencies manually for now */
             $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, "MODX core version dependencies must be resolved manually", '', __METHOD__, __FILE__, __LINE__);
             break;
         default:
             /* TODO: scan for local packages to satisfy dependency */
             /* see if current provider can satisfy dependency */
             /** @var modTransportProvider $provider */
             $provider = $this->Provider;
             if ($provider) {
                 $resolution = $provider->latest($package, $constraint);
             }
             /* loop through active providers if all else fails */
             if ($resolution === false) {
                 $query = $this->xpdo->newQuery('transport.modTransportProvider', $conditions);
                 $query->sortby('priority', 'ASC');
                 /** @var modTransportProvider $p */
                 foreach ($this->xpdo->getIterator('transport.modTransportProvider', $query) as $p) {
                     $resolution = $p->latest($package, $constraint);
                     if ($resolution) {
                         $provider = $p;
                         break;
                     }
                 }
             }
             if ($resolution === false) {
                 $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, "Could not find package to satisfy dependency {$package} @ {$constraint} from your currently active providers", '', __METHOD__, __FILE__, __LINE__);
             }
             break;
     }
     return $resolution;
 }
开发者ID:ChrstnMgcn,项目名称:revolution,代码行数:53,代码来源:modtransportpackage.class.php

示例6: refreshURIs

 /**
  * Refresh Resource URI fields for children of the specified parent.
  *
  * @static
  * @param modX &$modx A reference to a valid modX instance.
  * @param int $parent The id of a Resource parent to start from (default is 0, the root)
  * @param array $options An array of various options for the method:
  *      - resetOverrides: if true, Resources with uri_override set to true will be included
  *      - contexts: an optional array of context keys to limit the refresh scope
  * @return void
  */
 public static function refreshURIs(modX &$modx, $parent = 0, array $options = array()) {
     $resetOverrides = array_key_exists('resetOverrides', $options) ? (boolean) $options['resetOverrides'] : false;
     $contexts = array_key_exists('contexts', $options) ? explode(',', $options['contexts']) : null;
     $criteria = $modx->newQuery('modResource', array('parent' => $parent));
     if (!$resetOverrides) {
         $criteria->where(array('uri_override' => false));
     }
     if (!empty($contexts)) {
         $criteria->where(array('context_key:IN' => $contexts));
     }
     $criteria->sortby('menuindex', 'ASC');
     foreach ($modx->getIterator('modResource', $criteria) as $resource) {
         $resource->set('refreshURIs', true);
         if ($resetOverrides) {
             $resource->set('uri_override', false);
         }
         if (!$resource->get('uri_override')) {
             $resource->set('uri', '');
         }
         $resource->save();
     }
 }
开发者ID:raf3600,项目名称:revolution,代码行数:33,代码来源:modresource.class.php

示例7: foreach

/* load Discuss */
$discuss = $modx->getService('discuss', 'Discuss', $modx->getOption('discuss.core_path', null, $modx->getOption('core_path') . 'components/discuss/') . 'model/discuss/');
if (!$discuss instanceof Discuss) {
    return '';
}
/* setup mem limits */
ini_set('memory_limit', '1024M');
set_time_limit(0);
@ob_end_clean();
echo '<pre>';
/* load and run importer */
if ($discuss->loadImporter('disSmfImport')) {
    $c = $modx->newQuery('disPost');
    $total = $modx->getCount('disPost', $c);
    $c->sortby('thread', 'DESC');
    $posts = $modx->getIterator('disPost', $c);
    $discuss->import->log('Found ' . $total . ' threads: ' . $total);
    /** @var disThread $thread */
    $thread = null;
    /** @var disPost $post */
    foreach ($posts as $post) {
        if (!$thread || $post->get('thread') != $thread->get('id')) {
            $thread = $post->getOne('Thread');
        }
        if ($thread) {
            $thread->addParticipant($post->get('author'));
            $discuss->import->log('Fixing participants for: ' . $thread->get('title'));
        }
    }
} else {
    $modx->log(xPDO::LOG_LEVEL_ERROR, 'Failed to load Import class.');
开发者ID:oneismore,项目名称:Discuss,代码行数:31,代码来源:fix.participants.php

示例8: switch

 if (!XPDO_CLI_MODE && !ini_get('safe_mode')) {
     set_time_limit(0);
 }
 $instances = 0;
 $classCriteria = null;
 $classAttributes = $attributes;
 switch ($class) {
     case 'modSession':
         /* skip sessions */
         continue 2;
     case 'modSystemSetting':
         $classCriteria = array('key:!=' => 'extension_packages');
         break;
     case 'modWorkspace':
         /** @var modWorkspace $object */
         foreach ($modx->getIterator('modWorkspace', $classCriteria) as $object) {
             if (strpos($object->path, $core_path) === 0) {
                 $object->set('path', str_replace($core_path, '{core_path}', $object->path));
             } elseif (strpos($object->path, $assets_path) === 0) {
                 $object->set('path', str_replace($assets_path, '{assets_path}', $object->path));
             } elseif (strpos($object->path, $manager_path) === 0) {
                 $object->set('path', str_replace($manager_path, '{manager_path}', $object->path));
             } elseif (strpos($object->path, $base_path) === 0) {
                 $object->set('path', str_replace($base_path, '{base_path}', $object->path));
             }
             if ($package->put($object, $classAttributes)) {
                 $instances++;
             } else {
                 $modx->log(modX::LOG_LEVEL_WARN, "Could not package {$class} instance with pk: " . print_r($object->getPrimaryKey()));
             }
         }
开发者ID:Tramp1357,项目名称:atlasorg,代码行数:31,代码来源:vapor.php

示例9: message

}
if ($params['debug']) {
    print message("Debug SQL query.", 'HELP');
    $c->prepare();
    print $c->toSQL();
    print "\n";
    exit;
}
// see http://www.webhostingtalk.com/showthread.php?t=1043707
// http://www.webdeveloper.com/forum/showthread.php?208676-Remote-site-loading-time
print "STARTING " . date('Y-m-d H:i:s') . "\n";
$mtime = explode(" ", microtime());
$tstart = $mtime[1] + $mtime[0];
$pg_cnt = 0;
$e_cnt = 0;
$collection = $modx->getIterator('modResource', $c);
foreach ($collection as $obj) {
    $url = $modx->makeUrl($obj->get('id'), '', '', 'full');
    if (!$url) {
        print 'ERROR empty URL for page ' . $obj->get('id') . "\n";
        continue;
    }
    if (!($loadtime = request_url($url))) {
        print 'ERROR requesting ' . $url . "\n";
        $e_cnt++;
    } else {
        print $url . ' Load Time: ' . $loadtime . "s\n";
        $pg_cnt++;
    }
    wait($params['sleep']);
}
开发者ID:idcooldi,项目名称:modx_utils,代码行数:31,代码来源:cacher.php

示例10: foreach

$discuss = $modx->getService('discuss', 'Discuss', $modx->getOption('discuss.core_path', null, $modx->getOption('core_path') . 'components/discuss/') . 'model/discuss/');
if (!$discuss instanceof Discuss) {
    return '';
}
/* setup mem limits */
ini_set('memory_limit', '1024M');
set_time_limit(0);
@ob_end_clean();
echo '<pre>';
/* load and run importer */
if ($discuss->loadImporter('disSmfImport')) {
    $c = $modx->newQuery('disThread');
    $c->innerJoin('disPost', 'FirstPost');
    $c->select(array('disThread.*', 'FirstPost.title AS post_title'));
    $c->sortby('disThread.id', 'DESC');
    $threads = $modx->getIterator('disThread', $c);
    foreach ($threads as $thread) {
        $pt = $thread->get('post_title');
        if (!empty($pt)) {
            $thread->set('title', $pt);
            $discuss->import->log('Setting title to: ' . $pt);
            $thread->save();
        }
    }
} else {
    $modx->log(xPDO::LOG_LEVEL_ERROR, 'Failed to load Import class.');
}
$mtime = microtime();
$mtime = explode(" ", $mtime);
$mtime = $mtime[1] + $mtime[0];
$tend = $mtime;
开发者ID:oneismore,项目名称:Discuss,代码行数:31,代码来源:fix.title.php

示例11: foreach

if (!$discuss instanceof Discuss) {
    return '';
}
/* setup mem limits */
ini_set('memory_limit', '1024M');
set_time_limit(0);
@ob_end_clean();
echo '<pre>';
/* load and run importer */
if ($discuss->loadImporter('disSmfImport')) {
    $modx->getCacheManager();
    $sourceAttachmentsPath = $discuss->import->config['attachments_path'];
    $discuss->import->getConnection();
    $c = $modx->newQuery('disPostAttachment');
    $c->sortby('post', 'DESC');
    $attachments = $modx->getIterator('disPostAttachment', $c);
    /** @var disPostAttachment $attachment */
    foreach ($attachments as $attachment) {
        $found = false;
        $target = $attachment->getPath();
        $source = $sourceAttachmentsPath . $attachment->get('filename');
        $discuss->import->log('Looking for: ' . $source);
        if (file_exists($source)) {
            $found = true;
        } else {
            $cleanName = $attachment->get('filename');
            $cleanName = strtr($cleanName, '�����ְֱֲֳִֵַָֹ�ֻּֽ־ֿׁׂ׃װױײ״�����אבגדהוחטיךכלםמןסעףפץצרשת��‎�', 'SZszYAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy');
            $cleanName = strtr($cleanName, array('�' => 'TH', '‏' => 'th', '׀' => 'DH', 'נ' => 'dh', '�' => 'ss', '�' => 'OE', '�' => 'oe', 'ֶ' => 'AE', 'ז' => 'ae', 'µ' => 'u'));
            $cleanName = preg_replace(array('/\\s/', '/[^\\w_\\.\\-]/'), array('_', ''), $cleanName);
            $hash = md5($cleanName);
            $cleanName = strtr($cleanName, '.', '_');
开发者ID:oneismore,项目名称:Discuss,代码行数:31,代码来源:move.attachments.php

示例12: process


//.........这里部分代码省略.........
                             } elseif (strpos($path, $assets_path) === 0) {
                                 $path = str_replace($assets_path, '[[++assets_path]]', $path);
                             } elseif (strpos($path, $manager_path) === 0) {
                                 $path = str_replace($manager_path, '[[++manager_path]]', $path);
                             } elseif (strpos($path, $base_path) === 0) {
                                 $path = str_replace($base_path, '[[++base_path]]', $path);
                             }
                             $pkg['path'] = $path;
                         }
                     }
                 }
                 $modx->log(modX::LOG_LEVEL_INFO, "Setting extension packages to: " . print_r($extPackages, true));
                 $object->set('value', $modx->toJSON($extPackages));
                 $package->put($object, array_merge($attributes, array('resolve' => array(array('type' => 'php', 'source' => VAPOR_DIR . 'scripts/resolve.extension_packages.php')))));
             }
         }
         /* loop through the classes and package the objects */
         foreach ($classes as $class) {
             if (!XPDO_CLI_MODE && !ini_get('safe_mode')) {
                 set_time_limit(0);
             }
             $instances = 0;
             $classCriteria = null;
             $classAttributes = $attributes;
             switch ($class) {
                 case 'modSession':
                     /* skip sessions */
                     continue 2;
                 case 'modSystemSetting':
                     $classCriteria = array('key:!=' => 'extension_packages');
                     break;
                 case 'modWorkspace':
                     /** @var modWorkspace $object */
                     foreach ($modx->getIterator('modWorkspace', $classCriteria) as $object) {
                         if (strpos($object->path, $core_path) === 0) {
                             $object->set('path', str_replace($core_path, '{core_path}', $object->path));
                         } elseif (strpos($object->path, $assets_path) === 0) {
                             $object->set('path', str_replace($assets_path, '{assets_path}', $object->path));
                         } elseif (strpos($object->path, $manager_path) === 0) {
                             $object->set('path', str_replace($manager_path, '{manager_path}', $object->path));
                         } elseif (strpos($object->path, $base_path) === 0) {
                             $object->set('path', str_replace($base_path, '{base_path}', $object->path));
                         }
                         if ($package->put($object, $classAttributes)) {
                             $instances++;
                         } else {
                             $modx->log(modX::LOG_LEVEL_WARN, "Could not package {$class} instance with pk: " . print_r($object->getPrimaryKey(), true));
                         }
                     }
                     $modx->log(modX::LOG_LEVEL_INFO, "Packaged {$instances} of {$class}");
                     continue 2;
                 case 'transport.modTransportPackage':
                     $modx->loadClass($class);
                     $response = $modx->call('modTransportPackage', 'listPackages', array(&$modx, $workspace->get('id')));
                     if (isset($response['collection'])) {
                         foreach ($response['collection'] as $object) {
                             $packagesDir = MODX_CORE_PATH . 'packages/';
                             if ($object->getOne('Workspace')) {
                                 $packagesDir = $object->Workspace->get('path') . 'packages/';
                             }
                             $pkgSource = $object->get('source');
                             $folderPos = strrpos($pkgSource, '/');
                             $sourceDir = $folderPos > 1 ? substr($pkgSource, 0, $folderPos + 1) : '';
                             $source = realpath($packagesDir . $pkgSource);
                             $target = 'MODX_CORE_PATH . "packages/' . $sourceDir . '"';
                             $classAttributes = array_merge($attributes, array('resolve' => array(array('type' => 'file', 'source' => $source, 'target' => "return {$target};"))));
开发者ID:Tramp1357,项目名称:atlasorg,代码行数:67,代码来源:create.class.php


注:本文中的modX::getIterator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。