Changeset 21916
- Timestamp:
- 09/11/09 15:05:45 (4 years ago)
- Files:
-
- plugins/diemPlugin/trunk/TODO (modified) (2 diffs)
- plugins/diemPlugin/trunk/dmAdminPlugin/config/dm/services.yml (added)
- plugins/diemPlugin/trunk/dmAdminPlugin/lib/context/dmAdminContext.php (modified) (1 diff)
- plugins/diemPlugin/trunk/dmAdminPlugin/lib/dmFilter/dmAdminSeoValidationFilter.php (modified) (1 diff)
- plugins/diemPlugin/trunk/dmAdminPlugin/lib/sitemap/dmSitemap.php (copied) (copied from plugins/diemPlugin/trunk/dmAdminPlugin/lib/sitemap/base/dmSitemapGenerator.php) (4 diffs)
- plugins/diemPlugin/trunk/dmAdminPlugin/lib/sitemap/mySitemapGenerator.php (deleted)
- plugins/diemPlugin/trunk/dmAdminPlugin/modules/dmAdmin/actions/actions.class.php (modified) (1 diff)
- plugins/diemPlugin/trunk/dmAdminPlugin/modules/dmCodeEditor/actions/actions.class.php (modified) (6 diffs)
- plugins/diemPlugin/trunk/dmAdminPlugin/modules/dmSearchEngine/actions/actions.class.php (modified) (2 diffs)
- plugins/diemPlugin/trunk/dmAdminPlugin/modules/dmSeoValidation/actions/actions.class.php (modified) (1 diff)
- plugins/diemPlugin/trunk/dmAdminPlugin/modules/dmSitemap/actions/actions.class.php (modified) (3 diffs)
- plugins/diemPlugin/trunk/dmAdminPlugin/modules/dmSitemap/templates/indexSuccess.php (modified) (2 diffs)
- plugins/diemPlugin/trunk/dmAdminPlugin/modules/dmUserLog/actions/actions.class.php (modified) (4 diffs)
- plugins/diemPlugin/trunk/dmCorePlugin/config/dm/services.yml (added)
- plugins/diemPlugin/trunk/dmCorePlugin/config/dmCorePluginConfiguration.class.php (modified) (2 diffs)
- plugins/diemPlugin/trunk/dmCorePlugin/lib/cache/dmAPCCache.class.php (modified) (1 diff)
- plugins/diemPlugin/trunk/dmCorePlugin/lib/cache/dmCacheManager.php (modified) (3 diffs)
- plugins/diemPlugin/trunk/dmCorePlugin/lib/config/dmApplicationConfiguration.php (modified) (1 diff)
- plugins/diemPlugin/trunk/dmCorePlugin/lib/config/dmProjectConfiguration.php (modified) (1 diff)
- plugins/diemPlugin/trunk/dmCorePlugin/lib/context/dmContext.php (modified) (8 diffs)
- plugins/diemPlugin/trunk/dmCorePlugin/lib/dmFilter/dmInitFilter.php (modified) (1 diff)
- plugins/diemPlugin/trunk/dmCorePlugin/lib/doctrine/cache/Doctrine_Cache_Dm.php (modified) (2 diffs)
- plugins/diemPlugin/trunk/dmCorePlugin/lib/doctrine/config/dmDoctrineConfiguration.php (modified) (2 diffs)
- plugins/diemPlugin/trunk/dmCorePlugin/lib/doctrine/database/dmDb.php (modified) (1 diff)
- plugins/diemPlugin/trunk/dmCorePlugin/lib/log/user/dmUserLog.php (modified) (2 diffs)
- plugins/diemPlugin/trunk/dmCorePlugin/lib/model/doctrine/media/PluginDmMedia.class.php (modified) (2 diffs)
- plugins/diemPlugin/trunk/dmCorePlugin/lib/model/doctrine/media/PluginDmMediaFolder.class.php (modified) (3 diffs)
- plugins/diemPlugin/trunk/dmCorePlugin/lib/model/doctrine/page/PluginDmPage.class.php (modified) (1 diff)
- plugins/diemPlugin/trunk/dmCorePlugin/lib/page/dmPageTreeWatcher.php (modified) (2 diffs)
- plugins/diemPlugin/trunk/dmCorePlugin/lib/project/dmFileBackup.php (moved) (moved from plugins/diemPlugin/trunk/dmCorePlugin/lib/project/dmBackup.php) (2 diffs)
- plugins/diemPlugin/trunk/dmCorePlugin/lib/project/dmProject.php (modified) (2 diffs)
- plugins/diemPlugin/trunk/dmCorePlugin/lib/search/dmSearchHit.php (copied) (copied from plugins/diemPlugin/trunk/dmCorePlugin/lib/search/plugin/dmSearchHit.php)
- plugins/diemPlugin/trunk/dmCorePlugin/lib/search/dmSearchIndex.php (copied) (copied from plugins/diemPlugin/trunk/dmCorePlugin/lib/search/plugin/dmSearchIndex.php) (3 diffs)
- plugins/diemPlugin/trunk/dmCorePlugin/lib/search/dmSearchIndexCommon.php (copied) (copied from plugins/diemPlugin/trunk/dmCorePlugin/lib/search/plugin/dmSearchIndexCommon.php)
- plugins/diemPlugin/trunk/dmCorePlugin/lib/search/dmSearchIndexGroup.php (copied) (copied from plugins/diemPlugin/trunk/dmCorePlugin/lib/search/plugin/dmSearchIndexGroup.php) (2 diffs)
- plugins/diemPlugin/trunk/dmCorePlugin/lib/search/dmSearchPageDocument.php (copied) (copied from plugins/diemPlugin/trunk/dmCorePlugin/lib/search/plugin/dmSearchPageDocument.php) (1 diff)
- plugins/diemPlugin/trunk/dmCorePlugin/lib/search/dmSearchPager.php (copied) (copied from plugins/diemPlugin/trunk/dmCorePlugin/lib/search/plugin/dmSearchPager.php)
- plugins/diemPlugin/trunk/dmCorePlugin/lib/search/mySearchIndex.php (deleted)
- plugins/diemPlugin/trunk/dmCorePlugin/lib/search/mySearchIndexGroup.php (deleted)
- plugins/diemPlugin/trunk/dmCorePlugin/lib/search/mySearchPagedocument.php (deleted)
- plugins/diemPlugin/trunk/dmCorePlugin/lib/service/dmAdminGenerateService.php (modified) (1 diff)
- plugins/diemPlugin/trunk/dmCorePlugin/lib/service/dmClearCacheService.php (modified) (1 diff)
- plugins/diemPlugin/trunk/dmCorePlugin/lib/task/dmFrontPageIndexableContentTask.class.php (modified) (1 diff)
- plugins/diemPlugin/trunk/dmCorePlugin/lib/task/dmSearchUpdateTask.class.php (modified) (1 diff)
- plugins/diemPlugin/trunk/dmCorePlugin/lib/view/css/dmSpriteGenerator.php (modified) (1 diff)
- plugins/diemPlugin/trunk/dmCorePlugin/lib/view/dmOoHelper.php (modified) (3 diffs)
- plugins/diemPlugin/trunk/dmCorePlugin/lib/view/html/media/dmMediaImageTag.php (modified) (1 diff)
- plugins/diemPlugin/trunk/dmCorePlugin/modules/dmCore/actions/actions.class.php (modified) (1 diff)
- plugins/diemPlugin/trunk/dmCorePlugin/test/unit/dmCacheTest.php (modified) (1 diff)
- plugins/diemPlugin/trunk/dmFrontPlugin/config/dm/services.yml (modified) (1 diff)
- plugins/diemPlugin/trunk/dmFrontPlugin/lib/context/dmFrontContext.php (modified) (2 diffs)
- plugins/diemPlugin/trunk/dmFrontPlugin/lib/dmWidget/base/dmWidgetBaseView.php (modified) (1 diff)
- plugins/diemPlugin/trunk/dmFrontPlugin/lib/dmWidget/search/dmWidgetAdvancedSearchResultsView.php (modified) (1 diff)
- plugins/diemPlugin/trunk/dmFrontPlugin/lib/dmWidgetType/dmWidgetTypeManager.php (modified) (7 diffs)
- plugins/diemPlugin/trunk/dmFrontPlugin/lib/generator/dmFrontModuleGenerator.php (modified) (1 diff)
- plugins/diemPlugin/trunk/dmFrontPlugin/lib/view/html/page/dmFrontPageHelper.php (modified) (4 diffs)
- plugins/diemPlugin/trunk/dmFrontPlugin/modules/dmCodeEditor/actions/actions.class.php (modified) (1 diff)
- plugins/diemPlugin/trunk/dmFrontPlugin/modules/dmInterface/actions/components.class.php (modified) (1 diff)
- plugins/diemPlugin/trunk/dmFrontPlugin/modules/dmWidget/actions/actions.class.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/diemPlugin/trunk/TODO
r21823 r21916 164 164 * DmMail : allow to activate/desactivate a mail 165 165 166 * consider using Symfony Components Dependency Injection Container 166 * [DONE] consider using Symfony Components Dependency Injection Container 167 168 * [DONE] Implement Symfony Components Dependency Injection Container everywhere it makes sense 167 169 168 170 * consider feed dmDataService with fixtures … … 179 181 180 182 * convert this TODO to trac tickets 183 184 * consider using http://www.quasipartikel.at/multiselect/ for admin multiselect plugins/diemPlugin/trunk/dmAdminPlugin/lib/context/dmAdminContext.php
r21833 r21916 7 7 $moduleSpace; 8 8 9 /** 10 * Loads the diem services 11 */ 12 public function loadServiceContainer() 13 { 14 $name = 'dm'.md5(dmProject::getRootDir().sfConfig::get('sf_app')).'ServiceContainer'; 15 16 $file = dmOs::join(sys_get_temp_dir(), $name.'.php'); 17 18 if (!sfConfig::get('sf_debug') && file_exists($file)) 19 { 20 require_once $file; 21 $sc = new $name; 22 } 23 else 24 { 25 // build the service container dynamically 26 $sc = new sfServiceContainerBuilder(); 27 $loader = new sfServiceContainerLoaderFileYaml($sc); 28 $loader->load(dmOs::join(sfConfig::get('dm_core_plugin'), 'config/dm/services.yml')); 29 30 if (!$isDebug) 31 { 32 $dumper = new sfServiceContainerDumperPhp($sc); 33 file_put_contents($file, $dumper->dump(array('class' => $name))); 34 } 35 } 36 37 $this->serviceContainer = $sc; 38 } 9 public function getSitemap() 10 { 11 return $this->serviceContainer->getService('sitemap'); 12 } 39 13 40 14 public function isModuleAction($module, $action) plugins/diemPlugin/trunk/dmAdminPlugin/lib/dmFilter/dmAdminSeoValidationFilter.php
r21516 r21916 55 55 ); 56 56 57 dmCacheManager::getCache('dm/seo/validation')->set('duplicated', $duplicated);57 $this->dmContext->getCacheManager()->getCache('dm/seo/validation')->set('duplicated', $duplicated); 58 58 } 59 59 } plugins/diemPlugin/trunk/dmAdminPlugin/lib/sitemap/dmSitemap.php
r21557 r21916 1 1 <?php 2 2 3 class dmSitemap Generator3 class dmSitemap 4 4 { 5 5 protected 6 $ file,6 $dispatcher, 7 7 $filesystem, 8 $baseUrl; 8 $baseUrl, 9 $path; 9 10 10 public function __construct( $to = 'sitemap.xml')11 public function __construct(sfEventDispatcher $dispatcher, dmFilesystem $filesystem, array $options) 11 12 { 12 $this->file = dmOs::join(sfConfig::get('sf_web_dir'), $to); 13 $this->dispatcher = $dispatcher; 14 15 $this->filesystem = $filesystem; 13 16 14 $this->filesystem = new dmFilesystem(); 15 16 $this->baseUrl = dm::getRequest()->getAbsoluteUrlRoot().'/'; 17 18 $this->configure(); 19 20 $this->checkPermissions(); 17 $this->initialize($options); 21 18 } 22 19 23 protected function configure()20 protected function initialize(array $options) 24 21 { 22 $this->setPath(dmArray::get($options, 'file', 'sitemap.xml')); 23 24 if(isset($options['baseUrl'])) 25 { 26 $this->setBaseUrl($options['base_url']); 27 } 28 29 $this->checkPermissions(); 25 30 } 26 31 27 public function setBaseUrl($baseUrl) 28 { 29 $this->baseUrl = trim($baseUrl, '/').'/'; 30 } 32 public function setBaseUrl($baseUrl) 33 { 34 $this->baseUrl = trim($baseUrl, '/').'/'; 35 } 36 37 public function setPath($path) 38 { 39 $this->path = trim(dmOs::join($path), '/'); 40 } 41 42 public function getPath() 43 { 44 return $this->path; 45 } 46 47 public function getFullPath() 48 { 49 return dmOs::join(sfConfig::get('sf_web_dir'), $this->getPath()); 50 } 31 51 32 52 /* … … 36 56 protected function getPages($culture) 37 57 { 38 $query = dmDb::query('DmPage p')->withI18n($culture); 39 40 $query 41 ->where('p.is_secure = ?', false) 58 $query = dmDb::query('DmPage p')->withI18n($culture) 59 ->where('p.is_secure = ?', false) 42 60 ->addWhere('translation.is_active = ?', true) 43 ->addWhere('p.action != ?', 'error404'); 44 45 $query 61 ->addWhere('p.action != ?', 'error404') 46 62 ->orderBy('p.lft asc'); 47 63 … … 51 67 /* 52 68 * Generates a sitemap 53 * and save i n sf_web_dir./.$to69 * and save it in fullPath 54 70 */ 55 public function generate($culture = null)71 public function generate($culture) 56 72 { 57 $xml = $this->getXml(is_null($culture) ? dm::getUser()->getCulture() : $culture); 73 $this->checkBaseUrl(); 74 75 $xml = $this->getXml($culture); 58 76 59 if(!file_put_contents($this-> file, $xml))77 if(!file_put_contents($this->getFullPath(), $xml)) 60 78 { 61 throw new dmException('Can not save to '.dmProject::unRootify($this-> file));79 throw new dmException('Can not save to '.dmProject::unRootify($this->getFullPath())); 62 80 } 63 81 } … … 90 108 %s 91 109 </loc> 92 </url>', $this->baseUrl.$page-> slug);110 </url>', $this->baseUrl.$page->_getI18n('slug')); 93 111 } 94 112 113 public function fileExists() 114 { 115 return file_exists($this->getFullPath()); 116 } 117 118 public function getFileContent() 119 { 120 $this->checkFileExists(); 121 return file_get_contents($this->getFullPath()); 122 } 123 124 public function getUpdatedAt() 125 { 126 $this->checkFileExists(); 127 return filemtime($this->getFullPath()); 128 } 129 130 public function countUrls() 131 { 132 $this->checkFileExists(); 133 return substr_count($this->getFileContent(), '<url>'); 134 } 135 136 public function getFileSize() 137 { 138 $this->checkFileExists(); 139 return filesize($this->getFullPath()); 140 } 141 142 public function getWebPath() 143 { 144 $this->checkBaseUrl(); 145 return $this->baseUrl.$this->getPath(); 146 } 147 148 protected function checkFileExists() 149 { 150 if (!$this->fileExists()) 151 { 152 throw new dmException(sprintf('The sitemap file does not exists')); 153 } 154 } 155 95 156 protected function checkPermissions() 96 157 { 97 if (!$this->filesystem->mkdir(dirname($this-> file)))158 if (!$this->filesystem->mkdir(dirname($this->getFullPath()))) 98 159 { 99 throw new dmException(sprintf('%s is not writable', dirname($this-> file)));160 throw new dmException(sprintf('%s is not writable', dirname($this->getFullPath()))); 100 161 } 101 162 102 if (file_exists($this-> file) && !is_writable($this->file))163 if (file_exists($this->getFullPath()) && !is_writable($this->getFullPath())) 103 164 { 104 throw new dmException(sprintf('%s is not writable', $this-> file));165 throw new dmException(sprintf('%s is not writable', $this->getFullPath())); 105 166 } 106 167 } 107 168 169 protected function checkBaseUrl() 170 { 171 if (!$this->baseUrl) 172 { 173 throw new dmException('You must pass a baseUrl'); 174 } 175 } 108 176 } plugins/diemPlugin/trunk/dmAdminPlugin/modules/dmAdmin/actions/actions.class.php
r21824 r21916 33 33 require_once(dmOs::join(sfConfig::get('dm_admin_dir'), 'modules/dmUserLog/lib/dmUserLogViewLittle.php')); 34 34 35 $this->userLogView = new dmUserLogViewLittle( new dmUserLog, $this->getUser()->getCulture());35 $this->userLogView = new dmUserLogViewLittle($this->getDmContext()->getUserLog(), $this->getUser()->getCulture()); 36 36 37 37 $this->userLogOptions = array( plugins/diemPlugin/trunk/dmAdminPlugin/modules/dmCodeEditor/actions/actions.class.php
r21423 r21916 142 142 try 143 143 { 144 $backup = new dmBackup(); 145 $backup->save($file); 144 $this->getDmContext()->getFileBackup()->save($file); 146 145 } 147 146 catch(dmException $e) … … 189 188 public function executePaste(sfWebRequest $request) 190 189 { 190 $filesystem = $this->dmContext->getFilesystem(); 191 191 192 $id = $request->getParameter("id"); 192 193 $this->rootDir = sfConfig::get('sf_root_dir'); … … 200 201 if($copyDir = $this->getUser()->getAttribute('code_editor_file_copy_cut')) 201 202 { 202 if(! dmFilesystem::get()->copyRecursive(dmCodeEditorTools::decodeUrlTreeForCopy($copyDir),dmCodeEditorTools::decodeUrlTreeForCopy($pasteDir)))203 if(!$this->getDmContext()->getFilesystem()->copyRecursive(dmCodeEditorTools::decodeUrlTreeForCopy($copyDir),dmCodeEditorTools::decodeUrlTreeForCopy($pasteDir))) 203 204 { 204 205 return $this->renderText('[KO] | An error occurred '); … … 206 207 if($this->getUser()->getAttribute('code_editor_is_cut') == 'cut') 207 208 { 208 if(! dmFilesystem::get()->unlink($copyDir))209 if(!$this->getDmContext()->getFilesystem()->unlink($copyDir)) 209 210 { 210 211 return $this->renderText('[KO] | An error occurred while deleting the file or dir : '.$copyDir); … … 243 244 if(file_exists($deleteDir) && is_writable($deleteDir)) 244 245 { 245 if( dmFilesystem::get()->unlink($deleteDir))246 if($this->getDmContext()->getFilesystem()->unlink($deleteDir)) 246 247 { 247 248 return $this->renderText('[OK] | Successfully deleted'); … … 294 295 if($request->getParameter('create') == 'file') 295 296 { 296 if( dmFilesystem::get()->touch($newName))297 if($this->getDmContext()->getFilesystem()->touch($newName)) 297 298 { 298 299 return $this->renderText('[OK] | Succefully created new file : '.basename($newName)); plugins/diemPlugin/trunk/dmAdminPlugin/modules/dmSearchEngine/actions/actions.class.php
r21423 r21916 6 6 public function executeIndex(dmWebRequest $request) 7 7 { 8 $this->index = new mySearchIndexGroup;8 $this->index = $this->getDmContext()->getSearchEngine(); 9 9 10 10 $this->form = $this->getSearchForm(); … … 23 23 public function executeReload() 24 24 { 25 $filesystem = dmFilesystem::get(); 26 27 $filesystem->sf('dm:search-update'); 25 $this->getDmContext()->getFilesystem()->sf('dm:search-update'); 28 26 29 27 return $this->redirect('dmSearchEngine/index'); plugins/diemPlugin/trunk/dmAdminPlugin/modules/dmSeoValidation/actions/actions.class.php
r21423 r21916 6 6 public function executeIndex(sfWebRequest $request) 7 7 { 8 $this->duplicated = dmCacheManager::getCache('dm/seo/validation')->get('duplicated');8 $this->duplicated = $this->getDmContext()->getCacheManager()->getCache('dm/seo/validation')->get('duplicated'); 9 9 } 10 10 plugins/diemPlugin/trunk/dmAdminPlugin/modules/dmSitemap/actions/actions.class.php
r21423 r21916 4 4 { 5 5 6 public function preExecute() 7 { 8 $this->sitemap = $this->getDmContext()->getSitemap(); 9 10 $this->sitemap->setBaseUrl($this->getRequest()->getAbsoluteUrlRoot()); 11 } 12 6 13 public function executeIndex(dmWebRequest $request) 7 14 { 8 if ( file_exists($this->getFile()))15 if ($this->sitemap->fileExists()) 9 16 { 10 $this->sitemap = file_get_contents($this->getFile()); 11 $this->updatedAt = filemtime($this->getFile()); 12 $this->nbLinks = substr_count($this->sitemap, '<url>'); 13 $this->size = dmOs::humanizeSize($this->getFile()); 14 $this->sitemapWebPath = $this->getRequest()->getAbsoluteUrlRoot().'/'.$this->getFileName(); 17 $this->exists = true; 18 $this->xml = $this->sitemap->getFileContent(); 19 $this->updatedAt = $this->sitemap->getUpdatedAt(); 20 $this->nbLinks = $this->sitemap->countUrls(); 21 $this->size = dmOs::humanizeSize($this->sitemap->getFileSize()); 22 $this->webPath = $this->sitemap->getWebPath(); 15 23 } 16 24 else 17 25 { 18 $this->sitemap =false;26 $this->exists = false; 19 27 } 20 28 } … … 22 30 public function executeGenerate(dmWebRequest $request) 23 31 { 24 $sitemapGenerator = new mySitemapGenerator($this->getFileName());25 26 32 try 27 33 { 28 $ sitemapGenerator->generate();34 $this->sitemap->generate($this->getUser()->getCulture()); 29 35 $this->getUser()->logInfo('The sitemap has been successfully generated'); 30 36 } … … 42 48 } 43 49 44 protected function getFile()45 {46 return dmOs::join(sfConfig::get('sf_web_dir'), $this->getFileName());47 }48 49 protected function getFileName()50 {51 return trim(dmArray::get(sfConfig::get('dm_seo_sitemap'), 'path', 'sitemap.xml'), '/');52 }53 50 } plugins/diemPlugin/trunk/dmAdminPlugin/modules/dmSitemap/templates/indexSuccess.php
r21423 r21916 13 13 echo £o('div.dm_box_inner'); 14 14 15 if ($ sitemap)15 if ($exists) 16 16 { 17 17 echo £('div.clearfix.mb10', 18 18 definition_list(array( 19 'Position' => £link($ sitemapWebPath),19 'Position' => £link($webPath), 20 20 'Urls' => $nbLinks, 21 21 'Size' => $size, … … 25 25 ); 26 26 27 echo £('pre', array('style' => 'background: #fff; padding: 10px; border: 1px solid #ddd;'), htmlentities($ sitemap));27 echo £('pre', array('style' => 'background: #fff; padding: 10px; border: 1px solid #ddd;'), htmlentities($xml)); 28 28 } 29 29 else plugins/diemPlugin/trunk/dmAdminPlugin/modules/dmUserLog/actions/actions.class.php
r21779 r21916 3 3 class dmUserLogActions extends dmAdminBaseActions 4 4 { 5 6 public function preExecute() 7 { 8 $this->log = $this->getDmContext()->getUserLog(); 9 } 5 10 6 11 public function executeClear(dmWebRequest $request) 7 12 { 8 $log = new dmUserLog; 9 $log->clear(); 13 $this->log->clear(); 10 14 $this->getUser()->logInfo(dm::getI18n()->__('User log cleared')); 11 15 return $this->redirect('dmUserLog/index'); … … 14 18 public function executeRefresh(dmWebRequest $request) 15 19 { 16 $log = new dmUserLog; 17 18 $responseHash = md5(dmArray::first($log->getEntries(1))->toJson()); 20 $responseHash = md5(dmArray::first($this->log->getEntries(1))->toJson()); 19 21 20 22 if ($responseHash == $request->getParameter('hash')) … … 25 27 $viewClass = 'dmUserLogView'.dmString::camelize($request->getParameter('view')); 26 28 27 $view = new $viewClass($ log, $this->getUser()->getCulture());29 $view = new $viewClass($this->log, $this->getUser()->getCulture()); 28 30 29 31 return $this->renderText( … … 36 38 public function executeIndex(dmWebRequest $request) 37 39 { 38 $log = new dmUserLog; 39 $this->view = new dmUserLogView($log, $this->getUser()->getCulture()); 40 $this->filesize = $log->getSize(); 40 $this->view = new dmUserLogView($this->log, $this->getUser()->getCulture()); 41 $this->filesize = $this->log->getSize(); 41 42 } 42 43 plugins/diemPlugin/trunk/dmCorePlugin/config/dmCorePluginConfiguration.class.php
r21833 r21916 21 21 $this->enableHelpers(); 22 22 23 $this->initCacheManager();24 25 23 $this->connectEvents(); 26 24 … … 33 31 } 34 32 35 protected function initCacheManager()36 {37 dmCacheManager::createInstance($this->dispatcher);38 }39 33 40 34 protected function loadConfiguration() plugins/diemPlugin/trunk/dmCorePlugin/lib/cache/dmAPCCache.class.php
r21631 r21916 65 65 if (!is_null($val)) 66 66 { 67 throw new dmException('No supported yet : need to reset all cache'); 67 68 self::$enabled = (boolean) $val && self::isAvailable(); 68 dmCacheManager::getInstance()->reset();69 69 } 70 70 plugins/diemPlugin/trunk/dmCorePlugin/lib/cache/dmCacheManager.php
r21607 r21916 3 3 class dmCacheManager 4 4 { 5 protected static6 $instance;7 8 5 protected 9 6 $dispatcher, 10 7 $caches; 11 8 9 public function __construct(sfEventDispatcher $dispatcher) 10 { 11 $this->dispatcher = $dispatcher; 12 13 $this->initialize(); 14 } 15 12 16 public function initialize() 13 17 { 14 18 $this->reset(); 15 // event listeners16 19 } 17 20 18 public function get ($cacheName)21 public function getCache($cacheName) 19 22 { 20 23 $cacheName = dmString::modulize($cacheName); … … 56 59 } 57 60 58 protected staticfunction clearApc()61 protected function clearApc() 59 62 { 60 63 apc_clear_cache('opcode'); … … 62 65 } 63 66 64 protected staticfunction clearFile()67 protected function clearFile() 65 68 { 66 69 sfToolkit::clearDirectory(sfConfig::get("sf_cache_dir")); 67 70 } 68 71 69 public function __construct(sfEventDispatcher $dispatcher)70 {71 $this->dispatcher = $dispatcher;72 }73 72 74 /*75 * Static methods76 */77 78 public static function getCache($cacheName)79 {80 return self::getInstance()->get($cacheName);81 }82 83 84 /*85 * @return dmCacheManager instance86 */87 public static function getInstance()88 {89 if (is_null(self::$instance))90 {91 throw new dmException('No instance of dmCacheManager were created');92 }93 94 return self::$instance;95 }96 97 public static function createInstance(sfEventDispatcher $dispatcher, $class = __CLASS__)98 {99 $manager = new $class($dispatcher);100 if (!$manager instanceof dmCacheManager)101 {102 throw new dmException('Cache manager must be an instance of dmCacheManager');103 }104 $manager->initialize();105 self::$instance = $manager;106 }107 73 } plugins/diemPlugin/trunk/dmCorePlugin/lib/config/dmApplicationConfiguration.php
r21423 r21916 11 11 abstract class dmApplicationConfiguration extends sfApplicationConfiguration 12 12 { 13 /*14 * Override this method in your application configuration class15 * to change site for this request16 */17 public function getCurrentSite()18 {19 return dmDb::table('DmSite')->getInstance();20 }21 22 13 /* 23 14 * Wich dmPlugins are usefull for this application ? plugins/diemPlugin/trunk/dmCorePlugin/lib/config/dmProjectConfiguration.php
r21423 r21916 27 27 public function configureDoctrine(Doctrine_Manager $manager) 28 28 { 29 include_once(dm::getDir().'/dmCorePlugin/lib/doctrine/config/dmDoctrineConfiguration.php'); 30 31 dmDoctrineConfiguration::createInstance($manager, $this->dispatcher)->initialize(); 29 Doctrine::debug(sfConfig::get("sf_debug")); 30 31 /* 32 * Set up doctrine extensions dir 33 */ 34 Doctrine::setExtensionsPath(sfConfig::get('dm_core_dir').'/lib/doctrine/extension'); 35 36 /* 37 * I want Doctrine to autoload table classes 38 */ 39 $manager->setAttribute(Doctrine::ATTR_AUTOLOAD_TABLE_CLASSES, true); 40 41 /* 42 * make $record->setSomething($value) override $record->_set('something', $value); 43 */ 44 $manager->setAttribute(Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, true); 45 46 /* 47 * Enable doctrine validators 48 */ 49 $manager->setAttribute(Doctrine::ATTR_VALIDATE, Doctrine::VALIDATE_ALL); 50 51 /* 52 * Configure inheritance 53 */ 54 $manager->setAttribute(Doctrine::ATTR_QUERY_CLASS, 'myDoctrineQuery'); 55 $manager->setAttribute(Doctrine::ATTR_COLLECTION_CLASS, 'myDoctrineCollection'); 56 57 /* 58 * Configure charset 59 */ 60 $manager->setCharset('utf8'); 61 $manager->setCollate('utf8_unicode_ci'); 62 63 /* 64 * Configure hydrators 65 */ 66 $manager->registerHydrator('dmFlat', 'Doctrine_Hydrator_dmFlat'); 67 $manager->registerHydrator('dmAssoc', 'Doctrine_Hydrator_dmAssoc'); 68 69 /* 70 * Configure builder 71 */ 72 sfConfig::set('doctrine_model_builder_options', array( 73 'generateTableClasses' => true, 74 'baseClassName' => 'myDoctrineRecord', 75 'baseTableClassName' => 'myDoctrineTable', 76 'suffix' => '.class.php' 77 )); 32 78 } 33 79 plugins/diemPlugin/trunk/dmCorePlugin/lib/context/dmContext.php
r21833 r21916 11 11 $dmConfiguration, 12 12 $helper, 13 $sfContext, 14 $pageTreeWatcher; 13 $sfContext; 15 14 16 15 abstract public function getModule(); … … 31 30 { 32 31 $this->loadServiceContainer(); 33 } 34 35 abstract public function loadServiceContainer(); 36 37 protected function doLoadServiceContainer($configFiles) 32 33 $this->getDoctrineConfig(); 34 35 $this->getPageTreeWatcher(); 36 } 37 38 /** 39 * Loads the diem services 40 */ 41 protected function loadServiceContainer() 38 42 { 39 43 $name = 'dm'.dmString::camelize(sfConfig::get('sf_app')).'ServiceContainer'; 40 44 41 45 $file = dmOs::join(sfConfig::get('dm_cache_dir'), 'services', $name.'.php'); 42 46 47 if (!is_dir(sfConfig::get('dm_cache_dir'))) 48 { 49 mkdir(sfConfig::get('dm_cache_dir'), 0777); 50 } 43 51 if (!is_dir(dirname($file))) 44 52 { … … 46 54 } 47 55 48 if ( !sfConfig::get('sf_debug') &&file_exists($file))56 if (/*!sfConfig::get('sf_debug') && */file_exists($file)) 49 57 { 50 58 require_once $file; … … 54 62 { 55 63 $sc = new sfServiceContainerBuilder; 64 65 $configFiles = $this->getSfContext()->getConfiguration()->getConfigPaths('config/dm/services.yml'); 56 66 57 67 $loader = new sfServiceContainerLoaderFileYaml($sc); 58 68 $loader->load($configFiles); 59 69 60 if (true || !sfConfig::get('sf_debug'))70 if (true/* || !sfConfig::get('sf_debug')*/) 61 71 { 62 72 $dumper = new sfServiceContainerDumperPhp($sc); 63 73 file_put_contents($file, $dumper->dump(array('class' => $name))); 74 chmod($file, 0777); 64 75 } 65 76 … … 70 81 71 82 $this->serviceContainer->addParameters(array( 72 'dispatcher' => $sfContext->getEventDispatcher(), 73 'user' => $sfContext->getUser() 83 'dispatcher' => $sfContext->getEventDispatcher(), 84 'user' => $sfContext->getUser(), 85 'context' => $sfContext, 86 'dm_context' => $this, 87 'doctrine_manager' => Doctrine_Manager::getInstance() 74 88 )); 75 89 } 76 90 77 91 /* 92 * @return dmSearchIndexGroup 93 */ 94 public function getSearchEngine() 95 { 96 return $this->serviceContainer->getService('search_engine'); 97 } 98 99 /* 100 * @return dmDoctrineConfiguration 101 */ 102 public function getDoctrineConfig() 103 { 104 return $this->serviceContainer->getService('doctrine_config'); 105 } 106 107 /* 108 * @return dmCacheManager 109 */ 110 public function getCacheManager() 111 { 112 return $this->serviceContainer->getService('cache_manager'); 113 } 114 115 /* 78 116 * @return dmFilesystem 79 117 */ … … 84 122 85 123 /* 124 * @return dmFileBackup 125 */ 126 public function getFileBackup() 127 { 128 return $this->serviceContainer->getService('file_backup'); 129 } 130 131 /* 86 132 * @return dmUserLog 87 133 */ … … 96 142 public function getPageTreeWatcher() 97 143 { 98 return $this-> pageTreeWatcher;144 return $this->serviceContainer->getService('page_tree_watcher'); 99 145 } 100 146 … … 104 150 public function getHelper() 105 151 { 106 return $this->serviceContainer->getService('filesystem'); 107 if (is_null($this->helper)) 108 { 109 $this->helper = new dmOoHelper($this); 110 } 111 112 return $this->helper; 152 return $this->serviceContainer->getService('helper'); 113 153 } 114 154 plugins/diemPlugin/trunk/dmCorePlugin/lib/dmFilter/dmInitFilter.php
r21833 r21916 39 39 protected function saveHtml() 40 40 { 41 dmCacheManager::getCache("dm/view/html/validate")->set(41 $this->dmContext->getCacheManager()->getCache("dm/view/html/validate")->set( 42 42 session_id(), 43 43 $this->context->getResponse()->getContent(), plugins/diemPlugin/trunk/dmCorePlugin/lib/doctrine/cache/Doctrine_Cache_Dm.php
r21423 r21916 5 5 class Doctrine_Cache_Dm extends Doctrine_Cache_Driver 6 6 { 7 protected 8 $cache; 7 protected 8 $cache; 9 10 /** 11 * Configure cache driver with an array of options 12 * 13 * @param array $_options an array of options 14 */ 15 public function __construct($options = array()) 16 { 17 $this->_options = $options; 18 19 if (!isset($options['cache_manager'])) 20 { 21 throw new dmException('Not supported yet'); 22 } 23 } 9 24 10 25 public function getCache() 11 26 { 12 if (is_null($this->cache))13 {14 $this->cache = dmCacheManager::getCache('dm/doctrine');15 }27 if (is_null($this->cache)) 28 { 29 $this->cache = $this->_options['cache_manager']->getCache('dm/doctrine'); 30 } 16 31 17 return $this->cache;32 return $this->cache; 18 33 } 19 34 … … 29 44 if ($results = $this->getCache()->_get($id)) 30 45 { 31 return $results;46 return $results; 32 47 } 33 48 else plugins/diemPlugin/trunk/dmCorePlugin/lib/doctrine/config/dmDoctrineConfiguration.php
r21768 r21916 3 3 class dmDoctrineConfiguration 4 4 { 5 protected static6 $instance;7 8 5 protected 9 6 $manager, 10 $dispatcher; 7 $dispatcher, 8 $cacheManager; 11 9 12 public static function getInstance()10 public function __construct(Doctrine_Manager $manager, sfEventDispatcher $dispatcher, dmCacheManager $cacheManager) 13 11 { 14 if(is_null(self::$instance)) 15 { 16 throw new dmException('dmDoctrineConfiguration has no instance'); 17 } 18 19 return self::$instance; 20 } 21 22 public static function createInstance(Doctrine_Manager $manager, sfEventDispatcher $dispatcher) 23 { 24 return self::$instance = new self($manager, $dispatcher); 25 } 26 27 public function __construct(Doctrine_Manager $manager, sfEventDispatcher $dispatcher) 28 { 29 $this->manager = $manager; 30 $this->dispatcher = $dispatcher; 12 $this->manager = $manager; 13 $this->dispatcher = $dispatcher; 14 $this->cacheManager = $cacheManager; 15 16 $this->initialize(); 31 17 } 32 18 33 19 public function initialize() 34 20 { 35 Doctrine::debug(sfConfig::get("sf_debug")); 36 37 /* 38 * I want Doctrine to autoload table classes 39 */ 40 $this->manager->setAttribute(Doctrine::ATTR_AUTOLOAD_TABLE_CLASSES, true); 41 42 /* 43 * make $record->setSomething($value) override $record->_set('something', $value); 44 */ 45 $this->manager->setAttribute(Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, true); 46 47 /* 48 * Enable doctrine validators 49 */ 50 $this->manager->setAttribute(Doctrine::ATTR_VALIDATE, Doctrine::VALIDATE_ALL); 51 52 /* 53 * Set up doctrine extensions dir 54 */ 55 Doctrine::setExtensionsPath(sfConfig::get('sf_root_dir').'/plugins/dmCorePlugin/lib/doctrine/extension'); 56 57 $this 58 ->configureInheritance() 59 ->configureCharset() 60 ->configureBuilder() 61 ->configureHydrator(); 62 63 $this->dispatcher->connect('context.load_factories', array($this, 'configureCache')); 64 65 return $this; 21 $this->configureCache(); 66 22 } 67 23 68 protected function configureInheritance() 69 { 70 $this->manager->setAttribute(Doctrine::ATTR_QUERY_CLASS, 'myDoctrineQuery'); 71 $this->manager->setAttribute(Doctrine::ATTR_COLLECTION_CLASS, 'MyDoctrineCollection'); 72 73 return $this; 74 } 75 76 protected function configureCharset() 77 { 78 $this->manager->setCharset('utf8'); 79 $this->manager->setCollate('utf8_unicode_ci'); 80 81 return $this; 82 } 83 84 protected function configureBuilder() 85 { 86 sfConfig::set('doctrine_model_builder_options', array( 87 'generateTableClasses' => true, 88 'baseClassName' => 'myDoctrineRecord', 89 'baseTableClassName' => 'myDoctrineTable', 90 'suffix' => '.class.php' 91 )); 92 93 return $this; 94 } 95 96 protected function configureHydrator() 97 { 98 $this->manager->registerHydrator('dmFlat', 'Doctrine_Hydrator_dmFlat'); 99 $this->manager->registerHydrator('dmAssoc', 'Doctrine_Hydrator_dmAssoc'); 100 101 return $this; 102 } 103 104 /* 105 * Needs diem project config to be loaded 106 */ 107 public function configureCache() 24 protected function configureCache() 108 25 { 109 26 if (!sfConfig::get('dm_orm_cache_enabled', true)) … … 136 53 public function desactivateCache() 137 54 { 138 self::activateCache(false);55 $this->activateCache(false); 139 56 } 140 57 141 58 protected function getCacheDriver() 142 59 { 143 return new Doctrine_Cache_Dm(); 60 return new Doctrine_Cache_Dm(array( 61 'cache_manager' => $this->cacheManager 62 )); 144 63 } 145 64 } plugins/diemPlugin/trunk/dmCorePlugin/lib/doctrine/database/dmDb.php
r21423 r21916 56 56 public static function cache($val) 57 57 { 58 dm DoctrineConfiguration::getInstance()->activateCache((bool) $val);58 dmContext::getInstance()->getDoctrineConfig()->activateCache((bool) $val); 59 59 } 60 60 } plugins/diemPlugin/trunk/dmCorePlugin/lib/log/user/dmUserLog.php
r21833 r21916 6 6 $dispatcher, 7 7 $filesystem, 8 $dir,9 8 $file; 10 9 11 public function __construct(sfEventDispatcher $dispatcher, dmFileSystem $filesystem )10 public function __construct(sfEventDispatcher $dispatcher, dmFileSystem $filesystem, array $options = array()) 12 11 { 13 12 $this->dispatcher = $dispatcher; 14 13 $this->filesystem = $filesystem; 15 14 16 $this->initialize( );15 $this->initialize($options); 17 16 } 18 17 19 public function initialize( )18 public function initialize(array $options = array()) 20 19 { 21 $this->dir = dmOs::join(sfConfig::get('dm_data_dir'), 'log'); 22 $this->file = dmOs::join($this->dir, 'user.log'); 20 $this->file = dmProject::rootify(dmArray::get($options, 'file', 'data/dm/log/user.log')); 23 21 } 24 22 … … 61 59 protected function checkFile() 62 60 { 63 if (!$this->filesystem->mkdir( $this->dir))61 if (!$this->filesystem->mkdir(dirname($this->file))) 64 62 { 65 throw new dmException(sprintf('User log dir %s can not be created', $this->dir));63 throw new dmException(sprintf('User log dir %s can not be created', dirname($this->file))); 66 64 } 67 65 plugins/diemPlugin/trunk/dmCorePlugin/lib/model/doctrine/media/PluginDmMedia.class.php
r21648 r21916 280 280 { 281 281 // dmDebug::kill('unlink '.$this->fullPath, $this); 282 dm Filesystem::get()->unlink($this->fullPath);282 dmContext::getInstance()->getFilesystem()->unlink($this->fullPath); 283 283 } 284 284 … … 299 299 ->in(dmOs::join($this->Folder->getFullPath(), '.thumbs')); 300 300 301 return dm Filesystem::get()->unlink($thumbs);301 return dmContext::getInstance()->getFilesystem()->unlink($thumbs); 302 302 } 303 303 plugins/diemPlugin/trunk/dmCorePlugin/lib/model/doctrine/media/PluginDmMediaFolder.class.php
r21423 r21916 171 171 public function create() 172 172 { 173 return dm Filesystem::get()->mkdir($this->getFullPath());173 return dmContext::getInstance()->getFilesystem()->mkdir($this->getFullPath()); 174 174 } 175 175 … … 193 193 $oldName = $this->name; 194 194 195 $fs = dm Filesystem::get();195 $fs = dmContext::getInstance()->getFilesystem(); 196 196 197 197 if(!$fs->exec(sprintf('cd %s && mv %s %s', … … 403 403 if(!$this->getNode()->isRoot() && $this->dirExists()) 404 404 { 405 dm Filesystem::get()->deleteDir($this->fullPath);405 dmContext::getInstance()->getFilesystem()->deleteDir($this->fullPath); 406 406 } 407 407 plugins/diemPlugin/trunk/dmCorePlugin/lib/model/doctrine/page/PluginDmPage.class.php
r21593 r21916 300 300 $command = sprintf('dmFront:page-indexable-content %d %s', $this->get('id'), self::getDefaultCulture()); 301 301 302 $filesystem = dm Filesystem::get();302 $filesystem = dmContext::getInstance()->getFilesystem(); 303 303 304 304 $filesystem->sf($command); plugins/diemPlugin/trunk/dmCorePlugin/lib/page/dmPageTreeWatcher.php
r21633 r21916 4 4 { 5 5 protected 6 $d mContext,6 $dispatcher, 7 7 $modifiedTables; 8 8 9 public function __construct( dmContext $dmContext)9 public function __construct(sfEventDispatcher $dispatcher) 10 10 { 11 $this->dmContext = $dmContext; 12 13 $this->dmContext->getSfContext()->getEventDispatcher()->connect('dm.controller.redirect', array($this, 'listenRedirection')); 14 15 $this->initialize(); 11 $this->dispatcher = $dispatcher; 12 13 $this->initialize(); 16 14 } 17 15 … … 19 17 { 20 18 $this->modifiedTables = array(); 19 20 $this->dispatcher->connect('dm.controller.redirect', array($this, 'listenRedirection')); 21 21 } 22 23 22 24 23 public function addModifiedTable(myDoctrineTable $table) plugins/diemPlugin/trunk/dmCorePlugin/lib/project/dmFileBackup.php
r21823 r21916 1 1 <?php 2 2 3 class dm Backup3 class dmFileBackup 4 4 { 5 5 protected 6 $dir, 7 $filesystem; 6 $dispatcher, 7 $filesystem, 8 $dir; 8 9 9 public function __construct( $dir)10 public function __construct(sfEventDispatcher $dispatcher, dmFilesystem $filesystem, array $options = array()) 10 11 { 11 $this->dir = is_null($dir) 12 ? dmOs::join(sfConfig::get('dm_data_dir'), 'backup/fs') 13 : $dir; 12 $this->dispatcher = $dispatcher; 13 $this->filesystem = $filesystem; 14 14 15 $this->filesystem = new dmFilesystem; 15 $this->initialize($options); 16 } 17 18 public function initialize(array $options = array()) 19 { 20 $this->dir = dmProject::rootify(dmArra::get($options, 'dir', 'data/dm/backup/filesystem')); 16 21 17 22 $this->checkDirIsWritable(); … … 75 80 if (!$this->filesystem->mkdir($this->getDir())) 76 81 { 77 throw new dmException('dm Backup dir is not writable : '.$this->getDir());82 throw new dmException('dmFileBackup dir is not writable : '.$this->getDir()); 78 83 } 79 84 } plugins/diemPlugin/trunk/dmCorePlugin/lib/project/dmProject.php
r21833 r21916 45 45 sfConfig::get('sf_cache_dir'), 46 46 sfConfig::get('dm_cache_dir'), 47 dmOs::join(sfConfig::get('dm_cache_dir'), 'services'), 47 48 sfConfig::get('sf_log_dir'), 48 sfConfig::get('dm_data_dir'),49 dmOs::join(sfConfig::get('dm_data_dir'), 'backup'),50 dmOs::join(sfConfig::get('dm_data_dir'), 'index'),51 dmOs::join(sfConfig::get('dm_data_dir'), 'log'),49 // sfConfig::get('dm_data_dir'), 50 // dmOs::join(sfConfig::get('dm_data_dir'), 'backup'), 51 // dmOs::join(sfConfig::get('dm_data_dir'), 'index'), 52 // dmOs::join(sfConfig::get('dm_data_dir'), 'log'), 52 53 sfConfig::get('sf_upload_dir'), 53 dmOs::join(sfConfig::get('sf_lib_dir'), 'migration/doctrine'), 54 dmOs::join(sfConfig::get('dm_cache_dir'), 'services') 54 dmOs::join(sfConfig::get('sf_lib_dir'), 'migration/doctrine') 55 55 ); 56 57 $fs = dmFilesystem::get();58 56 59 57 $messages = array(); … … 61 59 foreach($requiredWritableDirs as $requiredWritableDir) 62 60 { 63 if(!$fs->mkdir($requiredWritableDir)) 61 if (!is_dir($requiredWritableDir)) 62 { 63 $oldUmask = umask(0); 64 mkdir($requiredWritableDir, 0777, true); 65 umask($oldUmask); 66 } 67 68 if(!is_writable($requiredWritableDir)) 64 69 { 65 70 $messages[] = sprintf( plugins/diemPlugin/trunk/dmCorePlugin/lib/search/dmSearchIndex.php
r21823 r21916 3 3 require_once('Zend/Search/Lucene.php'); 4 4 5 abstractclass dmSearchIndex extends dmSearchIndexCommon5 class dmSearchIndex extends dmSearchIndexCommon 6 6 { 7 7 protected … … 96 96 { 97 97 $this->getLogger()->log($page->get('slug'), 'Indexing page'); 98 $this->index->addDocument(new mySearchPageDocument($page));98 $this->index->addDocument(new dmSearchPageDocument($page)); 99 99 } 100 100 … … 146 146 protected function erase() 147 147 { 148 dmFilesystem::get()->deleteDirContent($this->location);148 $this->filesystem->deleteDirContent($this->location); 149 149 $this->index = Zend_Search_Lucene::create($this->location); 150 150 } plugins/diemPlugin/trunk/dmCorePlugin/lib/search/dmSearchIndexGroup.php
r21423 r21916 1 1 <?php 2 2 3 abstractclass dmSearchIndexGroup extends dmSearchIndexCommon3 class dmSearchIndexGroup extends dmSearchIndexCommon 4 4 { 5 5 /** … … 48 48 foreach(sfConfig::get('dm_i18n_cultures') as $culture) 49 49 { 50 $index = new mySearchIndex($culture);50 $index = new dmSearchIndex($culture); 51 51 $this->addIndex($index->getName(), $index); 52 52 } plugins/diemPlugin/trunk/dmCorePlugin/lib/search/dmSearchPageDocument.php
r21423 r21916 1 1 <?php 2 2 3 abstractclass dmSearchPageDocument extends Zend_Search_Lucene_Document3 class dmSearchPageDocument extends Zend_Search_Lucene_Document 4 4 { 5 5 protected static plugins/diemPlugin/trunk/dmCorePlugin/lib/service/dmAdminGenerateService.php
r21423 r21916 55 55 $moduleDir = sfConfig::get('sf_app_module_dir').'/'.$moduleKey; 56 56 57 dm Filesystem::get()->unlink(dmOs::join($moduleDir, 'generator.yml'));57 dmContext::getInstance()->getFilesystem()->unlink(dmOs::join($moduleDir, 'generator.yml')); 58 58 } 59 59 } plugins/diemPlugin/trunk/dmCorePlugin/lib/service/dmClearCacheService.php
r21607 r21916 8 8 $this->log("clear cache"); 9 9 10 dmC acheManager::getInstance()->clearAll();10 dmContext::getInstance()->getCacheManager()->clearAll(); 11 11 12 12 if(count($survivors = $this->filesystem->find()->maxdepth(0)->in(sfConfig::get("sf_cache_dir")))) plugins/diemPlugin/trunk/dmCorePlugin/lib/task/dmFrontPageIndexableContentTask.class.php
r21516 r21916 70 70 if (!in_array($widget['module'].'.'.$widget['action'], self::$skipWidgets)) 71 71 { 72 $widgetViewClass = dmWidgetTypeManager::getWidgetType($widget['module'], $widget['action'])->getViewClass();72 $widgetViewClass = $dmContext->getWidgetTypeManager()->getWidgetType($widget['module'], $widget['action'])->getViewClass(); 73 73 74 74 $widgetView = new $widgetViewClass($widget); plugins/diemPlugin/trunk/dmCorePlugin/lib/task/dmSearchUpdateTask.class.php
r21423 r21916 34 34 $this->log('Search engine index update'); 35 35 36 $index = new mySearchIndexGroup;36 $index = dmContext::getInstance()->getSearchEngine(); 37 37 $index->setLogger(new dmLoggerTask($this->dispatcher, $this->formatter)); 38 38 plugins/diemPlugin/trunk/dmCorePlugin/lib/view/css/dmSpriteGenerator.php
r21423 r21916 10 10 public function __construct(sfEventDispatcher $dispatcher) 11 11 { 12 $this->filesystem = dm Filesystem::get();12 $this->filesystem = dmContext::getInstance()->getFilesystem(); 13 13 } 14 14 plugins/diemPlugin/trunk/dmCorePlugin/lib/view/dmOoHelper.php
r21423 r21916 3 3 class dmOoHelper 4 4 { 5 protected 6 $context; 5 7 6 protected 7 $dmContext; 8 9 public function __construct(dmContext $dmContext) 8 public function __construct(sfContext $context) 10 9 { 11 $this-> dmContext = $dmContext;10 $this->context = $context; 12 11 } 13 12 … … 24 23 25 24 $class = sfConfig::get('mod_'.strtolower($moduleName).'_partial_view_class', 'sf').'PartialView'; 26 $view = new $class($this-> dmContext->getSfContext(), $moduleName, $actionName, '');25 $view = new $class($this->context, $moduleName, $actionName, ''); 27 26 $view->setPartialVars($vars); 28 27 … … 32 31 public function renderComponent($moduleName, $componentName, $vars = array()) 33 32 { 34 sfContext::getInstance()->getConfiguration()->loadHelpers('Partial');33 $this->context->getConfiguration()->loadHelpers('Partial'); 35 34 return get_component($moduleName, $componentName, $vars); 36 35 } plugins/diemPlugin/trunk/dmCorePlugin/lib/view/html/media/dmMediaImageTag.php
r21833 r21916 129 129 } 130 130 131 if(!dm Filesystem::get()->mkdir($thumbDir = dmOs::join($media->Folder->fullPath, '.thumbs')))131 if(!dmContext::getInstance()->getFilesystem()->mkdir($thumbDir = dmOs::join($media->Folder->fullPath, '.thumbs'))) 132 132 { 133 133 dm::getUser()->logAlert(dm::getI18n()->__('Thumbnails can not be created in %1%', array('%1%' => $media->Folder->relPath)), false); plugins/diemPlugin/trunk/dmCorePlugin/modules/dmCore/actions/actions.class.php
r21423 r21916 18 18 $this->doctype = sfConfig::get('dm_w3c_doctype', 'XHTML'); 19 19 20 $this->validator = new dmHtmlValidator( dmCacheManager::getCache("dm/view/html/validate")->get(session_id()));20 $this->validator = new dmHtmlValidator($this->dmContext->getCache("dm/view/html/validate")->get(session_id())); 21 21 } 22 22 plugins/diemPlugin/trunk/dmCorePlugin/test/unit/dmCacheTest.php
r21423 r21916 5 5 $t = new lime_test(7, new lime_output_color()); 6 6 7 $cache = dmC acheManager::getInstance("dm/test");7 $cache = dmContext::getInstance()->getCacheManager()->getCache("dm/test"); 8 8 9 9 $t->ok( plugins/diemPlugin/trunk/dmFrontPlugin/config/dm/services.yml
r21833 r21916 1 1 parameters: 2 filesystem.class: dmFilesystem 3 user_log.class: dmUserLog 4 page_helper.class: dmFrontPageHelper 2 page_helper.class: dmFrontPageHelper 3 widget_type_manager.class: dmWidgetTypeManager 4 widget_type_manager.options: 5 config_files: 'config/dm/widget_types.yml' 5 6 6 7 services: 7 8 8 filesystem:9 class: %filesystem.class%10 shared: true9 page_helper: 10 class: %page_helper.class% 11 shared: true 11 12 arguments: 12 dispatcher: %dispatcher% 13 14 user_log: 15 class: %user_log.class% 16 shared: true 13 dispatcher: %dispatcher% 14 dm_context: %dm_context% 15 filesystem: @filesystem 16 17 widget_type_manager: 18 class: %widget_type_manager.class% 19 shared: true 17 20 arguments: 18 dispatcher: %dispatcher% 19 filesystem: @filesystem 20 21 page_helper: 22 class: %page_helper.class% 23 shared: true 24 arguments: 25 dispatcher: %dispatcher% 26 page: %page% 27 filesystem: @filesystem 21 dispatcher: %dispatcher% 22 cache_manager: @cache_manager 23 context: %context% 24 options: %widget_type_manager.options% plugins/diemPlugin/trunk/dmFrontPlugin/lib/context/dmFrontContext.php
r21833 r21916 7 7 protected 8 8 $page; 9 10 /**11 * Loads the diem services12 */13 public function loadServiceContainer()14 {15 $configFiles = dmOs::join(sfConfig::get('dm_front_dir'), 'config/dm/services.yml');16 17 parent::doLoadServiceContainer($configFiles);18 }19 9 20 10 public function getPage() 21 11 { 22 return $this-> serviceContainer->getParameter('page');12 return $this->page; 23 13 } 24 14 25 15 public function getPageHelper() 26 16 { 27 return $this->serviceContainer->getService('page_helper'); 17 return $this->serviceContainer->getService('page_helper'); 18 } 19 20 public function getWidgetTypeManager() 21 { 22 return $this->serviceContainer->getService('widget_type_manager'); 28 23 } 29 24 … … 42 37 public function setPage(DmPage $page = null) 43 38 { 44 $this->serviceContainer->addParameters(array( 45 'page' => $page 46 )); 39 $this->page = $page; 47 40 48 $this->getPageHelper()-> setPage($page);41 $this->getPageHelper()->initialize(); 49 42 } 50 43 plugins/diemPlugin/trunk/dmFrontPlugin/lib/dmWidget/base/dmWidgetBaseView.php
r21516 r21916 5 5 6 6 protected 7 $dmContext, 7 8 $widget, 8 9 $widgetType, 9 10 $requiredVars = array(); 10 11 11 public function __construct(array $widget )12 public function __construct(array $widget, dmContext $dmContext) 12 13 { 14 $this->dmContext = $dmContext; 13 15 $this->widget = $widget; 14 $this->widgetType = dmWidgetTypeManager::getWidgetType($widget['module'], $widget['action']);16 $this->widgetType = $dmContext->getWidgetTypeManager()->getWidgetType($widget['module'], $widget['action']); 15 17 16 18 $this->configure(); plugins/diemPlugin/trunk/dmFrontPlugin/lib/dmWidget/search/dmWidgetAdvancedSearchResultsView.php
r21489 r21916 26 26 protected function getResultsPager(array $vars) 27 27 { 28 $this->index = new mySearchIndexGroup;28 $this->index = $this->dmContext->getSearchEngine(); 29 29 30 30 if(count($results = $this->index->search($vars['query']))) plugins/diemPlugin/trunk/dmFrontPlugin/lib/dmWidgetType/dmWidgetTypeManager.php
r21516 r21916 4 4 { 5 5 6 protected static 7 $configFile = 'config/dm/widget_types.yml', 6 protected 7 $dispatcher, 8 $cacheManager, 9 $context, 10 $configFile, 8 11 $widgetTypes; 9 12 10 public static function getWidgetTypes() 13 public function construct(sfEventDispatcher $dispatcher, dmCacheManager $cacheManager, sfContext $context, array $options = array()) 14 { 15 $this->dispatcher = $dispatcher; 16 $this->cacheManager = $cacheManager; 17 $this->context = $context; 18 19 $this->initialize($options); 20 } 21 22 public function initialize(array $options = array()) 23 { 24 $this->configFile = dmArray::get($options, 'config_files', 'config/dm/widget_types.yml'); 25 26 $this->widgetTypes = null; 27 } 28 29 public function getWidgetTypes() 11 30 { 12 31 $timer = dmDebug::timer('dmWidgetTypeManager::getWidgetTypes'); 13 if (is_null(self::$widgetTypes)) 32 33 if (is_null($this->widgetTypes)) 14 34 { 15 if (! self::$widgetTypes = dmCacheManager::getCache('dm/widget')->get('types'))35 if (!$this->widgetTypes = $this->cacheManager->getCache('dm/widget')->get('types')) 16 36 { 17 $internalConfig = include( sfContext::getInstance()->getConfigCache()->checkConfig(self::$configFile));37 $internalConfig = include($this->context->getConfigCache()->checkConfig($this->configFile)); 18 38 19 $sfController = sfContext::getInstance()->getController();39 $sfController = $this->context->getController(); 20 40 21 self::$widgetTypes = array();41 $this->widgetTypes = array(); 22 42 23 43 foreach($internalConfig as $moduleKey => $actions) 24 44 { 25 self::$widgetTypes[$moduleKey] = array();45 $this->widgetTypes[$moduleKey] = array(); 26 46 27 47 foreach($actions as $actionKey => $action) … … 36 56 ); 37 57 38 self::$widgetTypes[$moduleKey][$actionKey] = new dmWidgetType($moduleKey, $actionKey, $widgetTypeConfig);58 $this->widgetTypes[$moduleKey][$actionKey] = new dmWidgetType($moduleKey, $actionKey, $widgetTypeConfig); 39 59 } 40 60 } … … 44 64 $moduleName = $module->getName(); 45 65 46 self::$widgetTypes[$moduleKey] = array();66 $this->widgetTypes[$moduleKey] = array(); 47 67 48 68 foreach($module->getActions() as $actionKey => $action) … … 57 77 ); 58 78 59 self::$widgetTypes[$moduleKey][$actionKey] = new dmWidgetType($moduleKey, $actionKey, $widgetTypeConfig);79 $this->widgetTypes[$moduleKey][$actionKey] = new dmWidgetType($moduleKey, $actionKey, $widgetTypeConfig); 60 80 } 61 81 } 62 82 } 63 dmCacheManager::getCache('dm/widget')->set('types', self::$widgetTypes);83 $dmContext->getCacheManager()->getCache('dm/widget')->set('types', $this->widgetTypes); 64 84 } 65 85 66 86 $timer->addTime(); 67 return self::$widgetTypes;87 return $this->widgetTypes; 68 88 } 69 89 70 public staticfunction getWidgetType($moduleOrWidget, $action = null, $orNull = false)90 public function getWidgetType($moduleOrWidget, $action = null, $orNull = false) 71 91 { 72 92 if ($moduleOrWidget instanceof DmWidget) … … 79 99 } 80 100 81 $widgetType = dmArray::get(dmArray::get( self::getWidgetTypes(), dmString::modulize($module), array()), dmString::modulize($action));101 $widgetType = dmArray::get(dmArray::get($this->getWidgetTypes(), dmString::modulize($module), array()), dmString::modulize($action)); 82 102 83 103 if (!$widgetType) … … 88 108 } 89 109 // dmDebug::stack(); 90 // dmDebug::kill( self::getWidgetTypes());110 // dmDebug::kill($this->getWidgetTypes()); 91 111 throw new dmException(sprintf("The %s.%s module does not exist", $module, $action)); 92 112 } … … 95 115 } 96 116 97 public staticfunction getWidgetTypeOrNull($moduleOrWidget, $action = null)117 public function getWidgetTypeOrNull($moduleOrWidget, $action = null) 98 118 { 99 return self::getWidgetType($moduleOrWidget, $action, true);119 return $this->getWidgetType($moduleOrWidget, $action, true); 100 120 } 101 121 plugins/diemPlugin/trunk/dmFrontPlugin/lib/generator/dmFrontModuleGenerator.php
r21665 r21916 13 13 $this->module = $module; 14 14 $this->dispatcher = $dispatcher; 15 $this->filesystem = new dmFilesystem;15 $this->filesystem = dmContext::getInstance()->getFilesystem(); 16 16 } 17 17 plugins/diemPlugin/trunk/dmFrontPlugin/lib/view/html/page/dmFrontPageHelper.php
r21833 r21916 5 5 protected 6 6 $dispatcher, 7 $ page,7 $dmContext, 8 8 $areas; 9 9 10 public function __construct(sfEventDispatcher $dispatcher, DmPage $page)10 public function __construct(sfEventDispatcher $dispatcher, dmContext $dmContext) 11 11 { 12 12 $this->dispatcher = $dispatcher; 13 $this->page = $page; 14 } 15 16 public function setPage(DmPage $page) 17 { 18 $this->page = $page; 13 $this->dmContext = $dmContext; 14 15 $this->initialize(); 16 } 17 18 public function initialize() 19 { 20 $this->areas = null; 21 } 22 23 public function getPage() 24 { 25 return $this->dmContext->getPage(); 19 26 } 20 27 … … 25 32 $this->areas = dmDb::query('DmArea a INDEXBY a.type, a.Zones z, z.Widgets w') 26 33 ->select('a.type, z.width, z.css_class, w.module, w.action, w.value, w.css_class') 27 ->where('a.dm_layout_id = ? OR a.dm_page_view_id = ?', array($this-> page->getPageView()->get('Layout')->get('id'), $this->page->getPageView()->get('id')))34 ->where('a.dm_layout_id = ? OR a.dm_page_view_id = ?', array($this->getPage()->getPageView()->get('Layout')->get('id'), $this->getPage()->getPageView()->get('id'))) 28 35 ->orderBy('z.position asc, w.position asc') 29 36 ->fetchArray(); … … 39 46 if (!isset($this->areas[$type])) 40 47 { 41 throw new dmException(sprintf('Page %s with layout %s has no area for type %s', $this-> page, $this->page->Layout, $type));48 throw new dmException(sprintf('Page %s with layout %s has no area for type %s', $this->getPage(), $this->getPage()->Layout, $type)); 42 49 return null; 43 50 } … … 196 203 if (is_null($widgetType)) 197 204 { 198 $widgetType = dmWidgetTypeManager::getWidgetType($widget['module'], $widget['action']);205 $widgetType = $dmContext->getWidgetTypeManager()->getWidgetType($widget['module'], $widget['action']); 199 206 } 200 207 201 208 $widgetViewClass = $widgetType->getViewClass(); 202 209 203 $widgetView = new $widgetViewClass($widget );210 $widgetView = new $widgetViewClass($widget, $this->dmContext); 204 211 205 212 $html = $widgetView->render(); plugins/diemPlugin/trunk/dmFrontPlugin/modules/dmCodeEditor/actions/actions.class.php
r21423 r21916 57 57 try 58 58 { 59 $backup = new dmBackup(); 60 $backup->save($file); 59 $this->getDmContext()->getFileBackup()->save($file); 61 60 } 62 61 catch(dmException $e) plugins/diemPlugin/trunk/dmFrontPlugin/modules/dmInterface/actions/components.class.php
r21768 r21916 37 37 ); 38 38 } 39 40 foreach( dmWidgetTypeManager::getWidgetTypes() as $space => $widgetTypes)39 40 foreach($this->getDmContext()->getWidgetTypeManager()->getWidgetTypes() as $space => $widgetTypes) 41 41 { 42 42 if (empty($widgetTypes)) plugins/diemPlugin/trunk/dmFrontPlugin/modules/dmWidget/actions/actions.class.php
r21726 r21916 14 14 ); 15 15 16 if (!$widgetType = dmWidgetTypeManager::getWidgetTypeOrNull($widget))16 if (!$widgetType = $this->getDmContext()->getWidgetTypeManager()->getWidgetTypeOrNull($widget)) 17 17 { 18 18 return $this->renderText(sprintf('<p class="s16 s16_error">%s</p><div class="clearfix mt30"><a class="dm cancel close_dialog button mr10">%s</a><a class="dm delete button red" title="%s">%s</a></div>', … … 142 142 ); 143 143 144 $widgetType = dmWidgetTypeManager::getWidgetType($widgetModule, $widgetAction);144 $widgetType = $this->getDmContext()->getWidgetTypeManager()->getWidgetType($widgetModule, $widgetAction); 145 145 146 146 $formClass = $widgetType->getFormClass();