本文整理汇总了PHP中dmOs类的典型用法代码示例。如果您正苦于以下问题:PHP dmOs类的具体用法?PHP dmOs怎么用?PHP dmOs使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了dmOs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFolderCorrelations
public function testFolderCorrelations(lime_test $t)
{
$t->diag('Verify that each db folder exist in fs');
$errors = 0;
foreach ($this->folderTable->findAll() as $f) {
if (!is_dir($f->fullPath)) {
$t->diag(sprintf('folder %s does not exist in fs', $f));
$errors++;
}
}
$t->is($errors, 0, 'Each db folder exist in fs');
if ($errors > 0) {
die;
}
$t->diag('Verify that each fs folder exist in db');
$errors = 0;
foreach (sfFinder::type('dir')->discard(".*")->ignore_version_control()->maxdepth(20)->in($this->folderTable->getTree()->fetchRoot()->fullPath) as $f) {
if (strpos($f, '/.')) {
continue;
}
$f = dmOs::normalize($f);
$f = str_replace(dmOs::normalize(sfConfig::get('sf_upload_dir')) . '/', '', $f);
if (!$this->folderTable->createQuery('f')->where('f.rel_path = ?', $f)->exists()) {
$t->diag(sprintf('folder %s does not exist in db', $f));
$errors++;
}
}
$t->is($errors, 0, 'Each fs folder exist in db');
}
示例2: getMarkdownLoremText
protected static function getMarkdownLoremText()
{
if (null === self::$markdownLoremText) {
self::$markdownLoremText = implode('', file(dmOs::join(sfConfig::get("dm_core_dir"), "data/lorem/markdown")));
}
return self::$markdownLoremText;
}
示例3: media_file_image_tag
function media_file_image_tag(DmMedia $file, $options = array()) {
$options = array_merge(array(
'width' => $file->isImage() ? 128 : 64,
'height' => $file->isImage() ? 98 : 64
), dmString::toArray($options, true));
if ($file->isImage()) {
$image = _media($file);
} else {
if (file_exists(
dmOs::join(
sfConfig::get('sf_web_dir')
.
'/dmCorePlugin/images/media/'
.
dmOs::getFileExtension($file->getFile(), false)
. '.png'
)
)) {
$image = _media('/dmCorePlugin/images/media/' . dmOs::getFileExtension($file->getFile(), false) . '.png');
} else {
$image = _media('/dmCorePlugin/images/media/unknown.png');
}
}
return $image->size($options['width'], $options['height']);
}
示例4: parse
protected function parse($configFiles)
{
// parse the yaml
$rawConfig = self::getConfiguration($configFiles);
$dmFrontConfig = self::parseYamls(array(dmOs::join(sfConfig::get('dm_front_dir'), 'config/routing.yml')));
$firstConfig = array();
$lastConfig = array();
foreach ($rawConfig as $key => $value) {
if (array_key_exists($key, $dmFrontConfig)) {
$lastConfig[$key] = $value;
} else {
$firstConfig[$key] = $value;
}
}
$config = array_merge($firstConfig, $lastConfig);
// collect routes
$routes = array();
foreach ($config as $name => $params) {
if (isset($params['type']) && 'collection' == $params['type'] || isset($params['class']) && false !== strpos($params['class'], 'Collection')) {
$options = isset($params['options']) ? $params['options'] : array();
$options['name'] = $name;
$options['requirements'] = isset($params['requirements']) ? $params['requirements'] : array();
$routes[$name] = array(isset($params['class']) ? $params['class'] : 'sfRouteCollection', array($options));
} else {
$routes[$name] = array(isset($params['class']) ? $params['class'] : 'sfRoute', array($params['url'] ? $params['url'] : '/', isset($params['params']) ? $params['params'] : (isset($params['param']) ? $params['param'] : array()), isset($params['requirements']) ? $params['requirements'] : array(), isset($params['options']) ? $params['options'] : array()));
}
}
return $routes;
}
示例5: perf
protected function perf($kill = false)
{
if ($kill) {
dmDebug::killForce(dmOs::getPerformanceInfos());
}
dmDebug::showForce(dmOs::getPerformanceInfos());
}
示例6: renderGoogleAnalytics
public function renderGoogleAnalytics()
{
if (($gaKey = dmConfig::get('ga_key')) && !$this->getService('user')->can('admin') && !dmOs::isLocalhost()) {
return $this->getGoogleAnalyticsCode($gaKey);
}
return '';
}
示例7: execute
/**
* @see sfTask
*/
protected function execute($arguments = array(), $options = array())
{
parent::execute($arguments, $options);
$projectWebPath = sfConfig::get('sf_web_dir');
$filesystem = new dmFilesystem($this->dispatcher, $this->formatter);
foreach (array('dmAdminPlugin', 'dmFrontPlugin') as $plugin) {
$this->logSection('plugin', 'Configuring plugin - ' . $plugin);
$this->installPluginAssets($plugin, dm::getDir() . '/' . $plugin);
}
// remove useless doctrine assets
if (is_readable($doctrineAssetPath = dmOs::join($projectWebPath, 'sfDoctrinePlugin'))) {
if (!is_link($doctrineAssetPath)) {
$filesystem->deleteDirContent($doctrineAssetPath);
}
$filesystem->remove($doctrineAssetPath);
}
// remove web cache dir
$webCacheDir = sfConfig::get('sf_web_dir') . '/cache';
if (is_link($webCacheDir)) {
$filesystem->remove($webCacheDir);
}
// create web cache dir
$filesystem->mkdir($webCacheDir);
if (!file_exists(dmOs::join($projectWebPath, 'sf'))) {
$filesystem->relativeSymlink(realpath(sfConfig::get('sf_symfony_lib_dir') . '/../data/web/sf'), dmOs::join($projectWebPath, 'sf'), true);
}
}
示例8: __construct
/**
* Constructor.
* This method is used to construct a child class instance,
* and helps sfServiceContainer injects dependancies
*
* @param dmContext $context
* @param sfServiceContainer $container
*/
public function __construct(dmContext $context, sfServiceContainer $container, $user)
{
$this->context = $context;
$this->container = $container;
$this->user = $user;
$this->initialize(array('cache_dir' => dmOs::join(sfConfig::get('sf_cache_dir'), $this->getApplication(), 'security')));
}
示例9: writeFixture
protected function writeFixture(dmModule $module, $securityDesc)
{
$this->clear();
if ($pluginName = $module->getPluginName()) {
$root = dmContext::getInstance()->getConfiguration()->getPluginConfiguration($pluginName)->getRootDir();
} else {
$root = sfConfig::get('sf_root_dir');
}
$fixturesRootPath = dmOs::join($root, 'data', 'fixtures');
foreach (array('admin', 'front') as $app) {
foreach (array('actions', 'components') as $actionKind) {
if (isset($securityDesc[$app]) && isset($securityDesc[$app][$actionKind]) && is_array($securityDesc[$app][$actionKind])) {
foreach ($securityDesc[$app][$actionKind] as $actionName => $actionDesc) {
if (isset($actionDesc['credentials'])) {
$credentials = (array) $module->getSecurityManager()->parseCredentials($actionDesc['credentials']);
foreach ($credentials as $credential) {
$this->addPermissionFor($credential, $module->getKey(), $actionName);
}
}
}
}
}
}
$this->doWriteFixture(dmOs::join($fixturesRootPath, 'DmPermissions', $module->getKey() . '.yml'));
}
示例10: updateDatabase
/**
* Update changed documentation pages in database
*/
protected function updateDatabase($branch)
{
$types = dmDb::query('Doc d')->select('d.type')->distinct()->fetchFlat();
$cultures = sfConfig::get('dm_i18n_cultures');
$originalCulture = sfDoctrineRecord::getDefaultCulture();
foreach ($types as $type) {
foreach ($cultures as $culture) {
sfDoctrineRecord::setDefaultCulture($culture);
$dir = dmOs::join($this->repo->getDir(), $type, $culture);
$files = sfFinder::type('file')->name('/^\\d{2}\\s-\\s.+\\.markdown$/')->in($dir);
foreach ($files as $file) {
$docName = preg_replace('/^\\d{2}\\s-\\s(.+)\\.markdown$/', '$1', basename($file));
$docRecord = dmDb::query('DocPage dp')->withI18n()->innerJoin('dp.Doc doc')->innerJoin('doc.Branch branch')->where('branch.number = ?', $branch)->andWhere('doc.type = ?', $type)->andWhere('dpTranslation.name = ?', $docName)->fetchOne();
if ($docRecord) {
$docText = file_get_contents($file);
if ($docRecord->text != $docText) {
$docRecord->text = $docText;
$docRecord->save();
}
}
}
}
}
sfDoctrineRecord::setDefaultCulture($originalCulture);
}
示例11: generateLayoutTemplates
protected function generateLayoutTemplates()
{
$this->logSection('diem', 'generate layout templates');
$filesystem = $this->get('filesystem');
foreach (dmDb::query('DmLayout l')->fetchRecords() as $layout) {
$template = $layout->get('template');
$templateFile = dmProject::rootify('apps/front/modules/dmFront/templates/' . $template . 'Success.php');
if (!file_exists($templateFile)) {
if ($filesystem->mkdir(dirname($templateFile))) {
$filesystem->copy(dmOs::join(sfConfig::get('dm_front_dir'), 'modules/dmFront/templates/pageSuccess.php'), $templateFile);
$filesystem->chmod($templateFile, 0777);
} else {
$this->logBlock('Can NOT create layout template ' . $template, 'ERROR');
}
}
}
$layoutFile = dmProject::rootify('apps/front/modules/dmFront/templates/layout.php');
if (!file_exists($layoutFile)) {
if ($filesystem->mkdir(dirname($layoutFile))) {
$filesystem->copy(dmOs::join(sfConfig::get('dm_front_dir'), 'modules/dmFront/templates/layout.php'), $layoutFile);
$filesystem->chmod($layoutFile, 0777);
} else {
$this->logBlock('Can NOT create layout ' . $layoutFile, 'ERROR');
}
}
}
示例12: loadVendorLib
protected function loadVendorLib()
{
$dir = dmOs::join(sfConfig::get('dm_core_dir'), 'lib/vendor/Text_Diff');
set_include_path(get_include_path() . PATH_SEPARATOR . $dir);
require_once dmOs::join($dir, 'Text/Diff.php');
require_once dmOs::join($dir, 'Text/Diff/Renderer/inline.php');
}
示例13: loadConfiguration
protected function loadConfiguration()
{
sfConfig::add(array('sf_i18n' => true, 'sf_charset' => 'utf-8', 'sf_upload_dir_name' => str_replace(dmOs::normalize(sfConfig::get('sf_web_dir') . '/'), '', dmOs::normalize(sfConfig::get('sf_upload_dir'))), 'dm_data_dir' => dmOs::join(sfConfig::get('sf_data_dir'), 'dm'), 'dm_cache_dir' => dmOs::join(sfConfig::get('sf_cache_dir'), 'dm')));
if (extension_loaded('mbstring')) {
mb_internal_encoding('UTF-8');
}
dmConfig::initialize($this->dispatcher);
}
示例14: doClean
/**
* @see sfValidatorUrl
*/
protected function doClean($value)
{
$value = parent::doClean($value);
if ($value !== dmOs::sanitizeDirName($value)) {
throw new sfValidatorError($this, 'invalid', array('value' => $value));
}
return $value;
}
示例15: media_file_infos
function media_file_infos(DmMedia $object)
{
$infos = array(__('Size') => dmOs::humanizeSize($object->get('size')), __('Type') => $object->get('mime'), __('Created at') => format_date($object->get('created_at'), 'f'), __('Updated at') => format_date($object->get('updated_at'), 'f'), __('Url') => $object->getFullWebPath());
if ($object->isImage()) {
$infos = array_merge(array(__('Dimensions') => $object->getDimensions()), $infos);
}
return $infos;
}