本文整理汇总了PHP中dmOs::normalize方法的典型用法代码示例。如果您正苦于以下问题:PHP dmOs::normalize方法的具体用法?PHP dmOs::normalize怎么用?PHP dmOs::normalize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dmOs
的用法示例。
在下文中一共展示了dmOs::normalize方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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);
}
示例3: getWidgetInnersForFile
protected function getWidgetInnersForFile($file)
{
/*
* Find widgets affected by this php file
*/
$module = preg_replace('|^/([^/]+)/.+|', '$1', str_replace(dmOs::normalize(sfConfig::get('sf_app_module_dir')), '', $file));
$widgets = array();
foreach ($this->getService('page_helper')->getAreas() as $areaArray) {
foreach ($areaArray['Zones'] as $zoneArray) {
foreach ($zoneArray['Widgets'] as $widgetArray) {
if ($widgetArray['module'] === $module) {
ob_start();
$widgets[$widgetArray['id']] = $this->getService('page_helper')->renderWidgetInner($widgetArray);
// include debugging output
if ($output = ob_get_clean()) {
$widgets[$widgetArray['id']] = $output . $widgets[$widgetArray['id']];
}
}
}
}
}
return $widgets;
}
示例4: isInProject
public static function isInProject($path)
{
return strpos(dmOs::normalize($path), self::getRootDir()) === 0;
}
示例5: prepareMediaAttributes
protected function prepareMediaAttributes(array $attributes)
{
$media = $this->resource->getSource();
if (!$media->checkFileExists()) {
throw new dmException('The media file does not exist : ' . $media->relPath);
}
$validImage = true;
if ($this->hasSize() && !sfConfig::get('dm_search_populating')) {
try {
$mediaFullPath = $this->getResizedMediaFullPath($attributes);
} catch (Exception $e) {
$this->context->getLogger()->err($e->getMessage());
if (sfConfig::get('dm_debug')) {
throw $e;
}
$validImage = false;
$mediaFullPath = $media->getFullPath();
}
} else {
$mediaFullPath = $media->getFullPath();
}
if (@($infos = getimagesize($mediaFullPath))) {
if ($validImage) {
$attributes['width'] = $infos[0];
$attributes['height'] = $infos[1];
}
} else {
throw new dmException('The image is not readable : ' . dmProject::unRootify($mediaFullPath));
}
$attributes['src'] = (!$this->options['absolute'] ? $this->context->getRequest()->getRelativeUrlRoot() : $this->context->getRequest()->getAbsoluteUrlRoot()) . str_replace(dmOs::normalize(sfConfig::get('sf_web_dir')), '', dmOs::normalize($mediaFullPath));
if (!isset($attributes['alt']) && $media->get('legend')) {
$attributes['alt'] = $media->get('legend');
}
return $attributes;
}
示例6: dirname
require_once dirname(__FILE__) . '/helper/dmMediaUnitTestHelper.php';
$helper = new dmMediaUnitTestHelper();
$helper->boot();
$t = new lime_test(58);
$mediaTable = dmDb::table('DmMedia');
$folderTable = dmDb::table('DmMediaFolder');
$t->diag('Media tests');
$folderTable->checkRoot();
$root = $folderTable->getTree()->fetchRoot();
$t->diag('syncing root');
$root->sync();
$helper->checkTreeIntegrity($t);
$helper->testFolderCorrelations($t);
$t->isa_ok($root, 'DmMediaFolder', 'root is a media folder');
$t->is($root->fullPath, dmOs::normalize(sfConfig::get('sf_upload_dir')), 'root full path is ' . $root->fullPath);
$t->diag('add a folder in root');
$folder = new DmMediaFolder();
$folder->relPath = 'test_' . dmString::random(8);
$folder->getNode()->insertAsLastChildOf($root);
$helper->checkTreeIntegrity($t);
$t->ok($folder->exists(), 'folder ' . $folder->name . ' has been created');
$t->is($folder->getNode()->getParent(), $root, 'folder\'s parent is root');
$t->is($folder->fullPath, dmOs::join(sfConfig::get('sf_upload_dir'), $folder->name), 'folder\'s full path is ' . $folder->fullPath);
$t->ok(is_dir($folder->fullPath), 'folder exists in filesystem');
$t->diag('add a file in folder');
$fileName = dmString::random(8) . '_' . basename(__FILE__);
$filePath = dmOs::join($folder->fullPath, $fileName);
copy(__FILE__, $filePath);
$media = $mediaTable->create(array('file' => basename($filePath), 'author' => 'Thibault D.', 'legend' => 'dmMedia test cases', 'dm_media_folder_id' => $folder->id))->saveGet();
$t->ok($media->exists(), 'media has been saved');
示例7: upgradeToFixBaseFormFilterDoctrineSetup
protected function upgradeToFixBaseFormFilterDoctrineSetup()
{
// base file path
$file = dmOs::normalize(sfConfig::get('sf_lib_dir') . '/filter/doctrine/BaseFormFilterDoctrine.class.php');
/// get content
$content = file_get_contents($file);
// remove empty setup method
$content = preg_replace('#\\s+public function setup\\(\\)\\s+\\{\\s+\\}#i', '', $content);
// push new content
file_put_contents($file, $content);
}