<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
- <list default="true" id="530ffb50-16c9-4bb3-ad22-e76f531eb78c" name="Default" comment="wait #7244 @1">
- <change afterPath="$PROJECT_DIR$/.docker/config/composer/.htaccess" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/.docker/config/composer/auth.json" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/.docker/config/cron/crontab" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/.docker/config/cron/host" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/.docker/config/httpd/httpd.conf" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/.docker/config/imagemagick/policy.xml" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/.docker/config/mariadb/charset.cnf" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/.docker/config/mariadb/connections.cnf" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/.docker/config/mariadb/finetuning.cnf" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/.docker/config/mariadb/json.cnf" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/.docker/config/mariadb/logs.cnf" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/.docker/config/mariadb/sql_mode.cnf" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/.docker/config/passwords" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/.docker/config/php.ini" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/.docker/config/rsyslog/50-default.conf" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/.docker/config/rsyslog/init.d" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/.docker/config/rsyslog/rsyslog.conf" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/.docker/config/ssh/root/authorized_keys2" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/.docker/config/ssh/server/moduli" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/.docker/config/ssh/server/ssh_config" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/.docker/config/ssh/server/ssh_host_dsa_key" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/.docker/config/ssh/server/ssh_host_dsa_key.pub" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/.docker/config/ssh/server/ssh_host_ecdsa_key" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/.docker/config/ssh/server/ssh_host_ecdsa_key.pub" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/.docker/config/ssh/server/ssh_host_ed25519_key" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/.docker/config/ssh/server/ssh_host_ed25519_key.pub" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/.docker/config/ssh/server/ssh_host_rsa_key" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/.docker/config/ssh/server/ssh_host_rsa_key.pub" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/.docker/config/ssh/server/sshd_config" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/.docker/config/ssh/user/authorized_keys2" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/.docker/config/sudoers" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/.docker/dev/build" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/.docker/dev/docker-compose.yml" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/.docker/dev/update" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/.docker/images/httpd/Dockerfile" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/.docker/images/php-fpm/Dockerfile" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/.docker/images/php-fpm/overrides.conf" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/.docker/images/php-fpm/startup" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/.docker/production/build" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/.docker/production/docker-compose.yml" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/.docker/production/update" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/.idea/dataSources.local.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/dataSources.local.xml" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/.idea/deployment.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/deployment.xml" afterDir="false" />
+ <list default="true" id="530ffb50-16c9-4bb3-ad22-e76f531eb78c" name="Default" comment="wip #7257 @0.75">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/framework/application/configs/application.ini" beforeDir="false" afterPath="$PROJECT_DIR$/framework/application/configs/application.ini" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/framework/library/Zend/Registry.php" beforeDir="false" afterPath="$PROJECT_DIR$/framework/library/Zend/Registry.php" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/framework/application/views/scripts/common/body.phtml" beforeDir="false" afterPath="$PROJECT_DIR$/framework/application/views/scripts/common/body.phtml" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/framework/library/CubeIT/Bootstrap/Db.php" beforeDir="false" afterPath="$PROJECT_DIR$/framework/library/CubeIT/Bootstrap/Db.php" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/framework/library/CubeIT/Bootstrap/Navigation.php" beforeDir="false" afterPath="$PROJECT_DIR$/framework/library/CubeIT/Bootstrap/Navigation.php" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/framework/library/Zend/View/Helper/Navigation/Sitemap.php" beforeDir="false" afterPath="$PROJECT_DIR$/framework/library/Zend/View/Helper/Navigation/Sitemap.php" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/framework/library/Zend/Xml/Security.php" beforeDir="false" afterPath="$PROJECT_DIR$/framework/library/Zend/Xml/Security.php" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
"git-widget-placeholder": "master",
"ignore.virus.scanning.warn.message": "true",
"kotlin-language-version-configured": "true",
- "last_opened_file_path": "D:/Works/FluidbookWebV3/framework/library/Zend",
+ "last_opened_file_path": "D:/Works/FluidbookWebV3/framework/library/CubeIT/Bootstrap",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
}]]></component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
+ <recent name="D:\Works\FluidbookWebV3\framework\library\CubeIT\Bootstrap" />
+ <recent name="D:\Works\FluidbookWebV3\framework\library\Zend\Xml" />
<recent name="D:\Works\FluidbookWebV3\framework\library\Zend" />
<recent name="H:\Works\FluidbookWebV3\framework\application\views\scripts\templates" />
<recent name="H:\Works\FluidbookWebV3\images\exemples\publications" />
- <recent name="H:\Works\FluidbookWebV3\framework\application\forms\CMS" />
</key>
<key name="MoveFile.RECENT_KEYS">
<recent name="D:\Works\FluidbookWebV3\.docker" />
<workItem from="1728998686616" duration="8507000" />
<workItem from="1731579305063" duration="12263000" />
<workItem from="1739209041347" duration="1137000" />
- <workItem from="1739539005844" duration="1549000" />
+ <workItem from="1739539005844" duration="4203000" />
</task>
<task id="LOCAL-00117" summary="fix #1407 @1">
<created>1494411210038</created>
<option name="project" value="LOCAL" />
<updated>1682409989659</updated>
</task>
- <option name="localTasksCounter" value="173" />
+ <option name="localTasksCounter" value="174" />
<servers>
<Redmine shared="true" url="https://team.cubedesigners.com/redmine">
<option name="APIKey" value="ee454486fcd47aa38e5c99d5a7dc44cff1f65597" />
<component name="VcsManagerConfiguration">
<option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" />
<option name="CHECK_NEW_TODO" value="false" />
- <MESSAGE value="fix #3663" />
<MESSAGE value="wait #3669 @0.5" />
<MESSAGE value="wait #3693 @2" />
<MESSAGE value="fix #3701 @0:05" />
<MESSAGE value="wait #7079 @0.75" />
<MESSAGE value="." />
<MESSAGE value="wait #7244 @1" />
- <option name="LAST_COMMIT_MESSAGE" value="wait #7244 @1" />
+ <MESSAGE value="wip #7257 @0.75" />
+ <option name="LAST_COMMIT_MESSAGE" value="wip #7257 @0.75" />
<option name="NON_MODAL_COMMIT_POSTPONE_SLOW_CHECKS" value="false" />
</component>
<component name="XDebuggerManager">
class CubeIT_Bootstrap_Db extends CubeIT_Bootstrap_Base {
- protected function _initDoctrine() {
- profile(__FILE__, __LINE__, 'Init Doctrine');
- CubeIT_Library::Doctrine();
-
- // Connect with application.ini
- $ini = $this->getOption('database');
- $config = new \Doctrine\DBAL\Configuration();
- $params = array('driver' => $ini['adapter'], 'dbname' => $ini['params']['dbname']);
-
- if (isset($ini['params']['username'])) {
- $params['user'] = $ini['params']['username'];
- }
- if (isset($ini['params']['password'])) {
- $params['password'] = $ini['params']['password'];
- }
- if (isset($ini['params']['unix_socket'])) {
- $params['unix_socket'] = $ini['params']['unix_socket'];
- } else if (isset($ini['params']['host'])) {
- $params['host'] = $ini['params']['host'];
- }
-
- $params['options']['charset'] = 'utf8';
- $params['options']['collate'] = 'utf8_unicode_ci';
- $params['options']['engine'] = 'MyISAM';
-
- if ($params['driver'] == 'pdo_sqlite') {
- $params['path'] = $params['dbname'];
- }
-
- $doctrine = Doctrine\DBAL\DriverManager::getConnection($params, $config);
- return $doctrine;
- }
-
- protected function _initSyncDb() {
- profile(__FILE__, __LINE__, 'Init Sync Db');
- // Find the final class which instantiate _defineSchema
- $reflection = new ReflectionObject($this);
- $method = $reflection->getMethod('_defineSchema');
- $class = $method->getDeclaringClass();
- $file = $class->getFilename();
- $done = CACHE_PATH . '/' . APPLICATION_ENV . '/CubeIT_SYNCDB_DONE';
- $sync = false;
-
- $time = max(filemtime(__FILE__), filemtime($file));
-
- // Check mtime of models
- $modelsSource = CubeIT_Model::getModelSources();
- $time = max(CubeIT_Files::dirmtime($modelsSource, true), $time);
-
- // Compare last mod of final class file and done time
- // If db is synced skip sync process
-
- if (file_exists($done) && filemtime($done) >= $time) {
- return;
- }
- profile(__FILE__, __LINE__, 'Sync DB');
- $sync = true;
-
- /* @var $doctrine Doctrine\DBAL\Connection */
- $doctrine = $this->getDoctrine();
-
- // Init schema
- $schema = new Doctrine\DBAL\Schema\Schema();
- // Define the schema
- $options = array('engine' => 'MyISAM', 'charset' => 'utf8', 'collate' => 'utf8_unicode_ci');
- // Get Schema from bootstrap
- $this->_defineSchema($schema, $options);
- // Get Schema from model
- foreach ($this->_getModels() as $c) {
- $skipCallback = array($c, 'skipSchemaSync');
- if (is_callable($skipCallback) && call_user_func($skipCallback)) {
- continue;
- }
- $callback = array($c, 'getSchema');
-
- if (is_callable($callback)) {
- call_user_func($callback, $schema);
- }
- }
-
- // Sync it
- $comparator = new Doctrine\DBAL\Schema\Comparator();
- $currentSchema = $doctrine->getSchemaManager()->createSchema();
- $diff = $comparator->compare($currentSchema, $schema);
-
- if (stristr($doctrine->getDriver()->getName(), 'mysql')) {
- $platform = new CubeIT_Db_MysqlPlatform();
- } else {
- $platform = $doctrine->getDatabasePlatform();
- }
-
- $queries = $diff->toSaveSql($platform);
- foreach ($queries as $q) {
- $doctrine->exec($q);
- }
-
- touch($done);
- return $sync;
- }
protected function _initDbViews() {
profile(__FILE__, __LINE__, 'Create Db views');
}
- /**
- *
- * @param \Doctrine\DBAL\Schema\Schema $schema
- * @param array $options
- */
- protected function _defineSchema(&$schema, $options) {
- profile(__FILE__, __LINE__, '_defineSchema');
- $this->getFrameworkCache()->clean();
-
- $url = $schema->createTable('cubeit_url');
- $url->addColumn('id', 'string', array('length' => 64));
- $url->addColumn('uri', 'string', array('length' => 256));
- $url->addColumn('locale', 'string', array('length' => 8));
- $url->setPrimaryKey(array('uri', 'locale'));
- $url->addIndex(array('id'));
-
- $page = $schema->createTable('cubeit_page');
- $page->addColumn('id', 'integer', array('unsigned' => true));
- $page->addColumn('variant', 'integer', array('unsigned' => true));
- $page->setPrimaryKey(array('id', 'variant'));
- $page->addColumn('label', 'string', array('length' => 64));
- $page->addColumn('parentPage', 'integer');
- $page->addColumn('template', 'string', array('length' => 32, 'default' => 'default'));
- $page->addColumn('acl', 'string', array('length' => 128, 'default' => 'inherit'));
- $page->addColumn('online', 'boolean', array('default' => 1));
- $page->addColumn('ordre', 'integer', array('unsigned' => true));
- $page->addColumn('level', 'integer', array('unsigned' => true));
- $page->addIndex(array('online'));
- $page->addIndex(array('level'));
- $page->addIndex(array('ordre'));
- $page->addIndex(array('variant'));
-
- $content = $schema->createTable('cubeit_content');
- $content->addColumn('id', 'integer', array('unsigned' => true));
- $content->addColumn('locale', 'string', array('length' => 6));
- $content->addColumn('label', 'string', array('length' => 256));
- $content->addColumn('variant', 'integer');
- $content->setPrimaryKey(array('id', 'locale', 'label', 'variant'));
- $content->addIndex(array('locale'));
- $content->addIndex(array('label'));
- $content->addIndex(array('variant'));
- $content->addColumn('content', 'text');
-
- $mailqueue = $schema->createTable('cubeit_mailqueue');
- $mailqueue->addColumn('id', 'integer', array('unsigned' => true, 'autoincrement' => true));
- $mailqueue->setPrimaryKey(array('id'));
- $mailqueue->addColumn('mail', 'text');
- $mailqueue->addColumn('transport', 'text');
- $mailqueue->addColumn('added', 'datetime');
- $mailqueue->addColumn('recipients', 'text');
- $mailqueue->addColumn('error', 'string', array('length' => 256));
- $mailqueue->addColumn('sent', 'boolean');
- $mailqueue->addIndex(array('sent'));
- $mailqueue->addIndex(array('added'));
-
- $session = $schema->createTable('cubeit_session');
- $session->addColumn('id', 'string', array('length' => 32));
- $session->setPrimaryKey(array('id'));
- $session->addColumn('modified', 'integer', array('unsigned' => true));
- $session->addIndex(array('modified'));
- $session->addColumn('lifetime', 'integer', array('unsigned' => true));
- $session->addIndex(array('lifetime'));
- $session->addColumn('data', 'text');
-
- $geocode = $schema->createTable('cubeit_geocode');
- $geocode->addColumn('id', 'integer', array('unsigned' => true, 'autoincrement' => true));
- $geocode->setPrimaryKey(array('id'));
- $geocode->addColumn('address', 'string', array('length' => 256));
- $geocode->addUniqueIndex(array('address'));
- $geocode->addColumn('response', 'text');
- $geocode->addColumn('valid', 'datetime');
-
- $group = $schema->createTable('cubeit_group');
- $group->addColumn('id', 'integer', array('unsigned' => true, 'autoincrement' => true));
- $group->setPrimaryKey(array('id'));
- $group->addColumn('name', 'string', array('length' => 64));
-
- $group_content = $schema->createTable('cubeit_group_content');
- $group_content->addColumn('group_id', 'integer', array('unsigned' => true));
- $group_content->addIndex(array('group_id'));
- $group_content->addColumn('user_id', 'integer', array('unsigned' => true));
- $group_content->addIndex(array('user_id'));
- $group_content->setPrimaryKey(array('group_id', 'user_id'));
-
- CubeIT_Model_Registry::getSchema($schema);
- }
protected function _initDb() {
profile(__FILE__, __LINE__, 'Init DB');
Zend_Db_Table::setDefaultAdapter($db);
Zend_Db_Table_Abstract::setDefaultMetadataCache($this->getFrameworkCache());
- $this->bootstrap('syncDb');
- if ($this->getResource('syncDb')) {
- $this->bootstrap('dbViews');
- }
-
return $db;
}
return $this->getResource('formerDb');
}
- /**
- * @return Doctrine\DBAL\Connection
- */
- public function getDoctrine() {
- $this->bootstrap('doctrine');
- return $this->getResource('doctrine');
- }
-
}
<?php
-class CubeIT_Bootstrap_Navigation extends CubeIT_Bootstrap_Locale {
-
- protected $_urls = array();
- protected $_cacheNavigation = true;
-
- protected function _getNavigationCacheId($isAdmin, $full = false) {
- $res = 'navigation_' . APPLICATION_ENV . '_' . CubeIT_Text::str2URL(SITE_URL) . '_' . $this->getVariant();
- if ($isAdmin) {
- $res .= '_admin';
- }
- if ($full) {
- $res .= '_full';
- }
- $res = str_replace('-', '_', $res);
- return $res;
- }
-
- protected function _makeNavigation($refresh = false, $full = false) {
- profile(__FILE__, __LINE__, 'Make Application navigation');
-
- $cache = $this->getCoreCache();
-
- $isAdmin = $this->isAllowed('administration');
- $cacheId = $this->_getNavigationCacheId($isAdmin, $full);
-
- $mtime = max(filemtime(CubeIT_Util_PHP::getFileDeclaring($this)), filemtime(__FILE__));
- $meta = $cache->getMetadatas($cacheId);
-
- if (!$this->_cacheNavigation || $refresh || !$cache->test($cacheId) || $mtime > $meta['mtime']) {
- $navigation = $this->_createNavigation($isAdmin);
-
- $r = $this->navRoot;
- if ($full) {
- $r = null;
- }
-
- if ($this->isMultilang()) {
- $this->_makeNavigationMultiLocale($navigation, $isAdmin, $r);
- } else {
- $this->_makeNavigationMonoLocale($navigation, $isAdmin, $r);
- }
-
- if (!$isAdmin) {
- foreach ($this->_getNextRedirectionTemplates() as $template) {
- foreach ($navigation->findAllByTemplate($template) as $p) {
- $p->setUri($p->getFinalUri());
- }
- }
- foreach ($navigation->findAllByTemplate('pageredirection') as $p) {
- $p->setUri($p->getFinalUri());
- }
- foreach ($navigation->findAllByTemplate('subredirection') as $p) {
- $p->setUri($p->getFinalUri());
- }
- }
- if ($this->_cacheNavigation) {
- $cache->save($navigation, $cacheId, array('navigation'));
- $navigation->archive($this->getDb());
- }
- } else {
- $navigation = $cache->load($cacheId, false);
- }
- return $navigation;
- }
-
- public function _getNextRedirectionTemplates() {
- return array('nextredirection');
- }
-
- /**
- *
- * @return CubeIT_Navigation
- */
- protected function _createNavigation($isAdmin = false) {
- $containers = true;
- if ($this->hasOption('navigation')) {
- $navOptions = $this->getOption('navigation');
- if (isset($navOptions['containers'])) {
- $containers = $navOptions['containers'];
- }
- }
-
- if ($this->isMultilang()) {
- $navigation = new CubeIT_Navigation_Locale($this->getNavigationLocales($isAdmin), null, $containers);
- } else {
- $navigation = new CubeIT_Navigation(null, $containers);
- }
- return $navigation;
- }
-
- public function isMultilang() {
- return count($this->getAppLocales()) > 1;
- }
-
- protected function _makeNavigationMonoLocale(&$navigation, $isAdmin, $root = null) {
- // Get titles
- $titles = $this->_getNavigationPagesTitlesFromDb();
- // Construct navigation
- $rows = $this->_getNavigationPagesFromDb($isAdmin);
-
- $this->_navAcceptedPages = array();
- foreach ($rows as $r) {
- if (!$this->_isNavAcceptedPage($r, $root)) {
- continue;
- }
- $t = isset($titles[$r->id]) ? $titles[$r->id] : array();
- $this->_makeNavigationOnePage($navigation, $r, $t, $isAdmin);
- }
- }
-
- public function getLocaleNavigationByDomain() {
- $navigation = $this->getResource('navigation');
- $domains = $this->getLocaleDomains();
- $httphost = $_SERVER['HTTP_HOST'];
-
- if (!($navigation instanceof Zend_Navigation)) {
- profile(__FILE__, __LINE__, 'Get current page :: getLocaleNavigationByDomain :: not navigation');
- $navigation = $this->getNavigation(true);
- }
- foreach ($domains as $locale => $d) {
- if ($d['domain'] == $httphost) {
-
- return $navigation->getLocaleContainer($locale);
- }
- }
-
- return $navigation;
- }
-
- protected function _makeNavigationMultiLocale(&$navigation, $isAdmin, $root = null) {
- $locales = $this->getNavigationLocales($isAdmin);
- // Get titles
- $titles = $this->_getNavigationPagesTitlesFromDb($locales);
-
- // Construct navigation
- $rows = $this->_getNavigationPagesFromDb($isAdmin);
-
- $this->_navAcceptedPages = array();
- foreach ($rows as $r) {
- if (!$this->_isNavAcceptedPage($r, $root)) {
- continue;
- }
- foreach ($locales as $locale) {
- $t = isset($titles[$locale][$r->id]) ? $titles[$locale][$r->id] : array();
- $this->_makeNavigationOnePage($navigation, $r, $t, $isAdmin, $locale);
- }
- }
- }
-
- protected function _isNavAcceptedPage($page, $root) {
- $res = false;
- if (null === $root) {
- $res = true;
- } else if ($page->id == $root) {
- $this->_navAcceptedPages[$page->id] = true;
- } else if (isset($this->_navAcceptedPages[$page->parentPage])) {
- $this->_navAcceptedPages[$page->id] = true;
- $res = true;
- }
-
- if ($res && $page->parentPage == $root) {
- $page->parentPage = 0;
- }
-
- return $res;
- }
-
- /**
- *
- * @param type $navigation
- * @param type $r
- * @param type $t
- * @param type $isAdmin
- * @param type $locale
- * @return CubeIT_Navigation_Page
- */
- protected function _makeNavigationOnePage(&$navigation, $r, $t, $isAdmin, $locale = false) {
- if ($locale) {
- $parent = $navigation->findOneBy('id', $locale . '/' . $r->parentPage);
- } else {
- $parent = $navigation->findOneBy('id', $r->parentPage);
- }
-
- if (null == $parent) {
- // Maybe parent is offline
- return;
- }
-
- $title = isset($t['shortTitle']) && $t['shortTitle'] != '' ? $t['shortTitle'] : $r->label;
- $longTitle = isset($t['longTitle']) && $t['longTitle'] != '' ? $t['longTitle'] : $title;
- $seoUrl = isset($t['seourl']) && $t['seourl'] != '' ? $t['seourl'] : '';
- $robots = isset($t['robots']) ? $t['robots'] == true : true;
-
- if ($locale) {
- $domain = $this->getLocaleDomain($locale);
- $page = new CubeIT_Navigation_Page_Locale();
- $page->setId($locale . '/' . $r->id);
- $url = $this->_makeURL($r, $seoUrl, $locale, $title, $parent, $isAdmin);
- } else {
- $domain = array('domain' => '', 'segment' => '', 'first' => false);
- $page = new CubeIT_Navigation_Page();
- $page->setId($r->id);
- $url = $this->_makeURL($r, $seoUrl, false, $title, $parent, $isAdmin);
- }
-
- $url = $this->_checkUniqueURL($url, $domain, $page->getId());
-
- if (!isset($r->online)) {
- $r->online = 1;
- }
- $page->setOnline($r->online);
- $page->setTitle($title);
- $page->setLongTitle($longTitle);
- $page->setTemplate($r->template);
- $page->setLabel($title);
- $page->setEditable(true);
- $page->setName($r->label);
- $page->setUri($url);
- $page->setSitemap($robots);
- $page->setVariant($this->getVariant());
- if ($domain['domain']) {
- $page->setDomain($domain['domain']);
- }
- if (isset($t['redirection'])) {
- $page->setRedirection($t['redirection']);
- }
- if (!$isAdmin && strpos($r->template, 'popup_') === 0) {
- $page->setClass('popup');
- }
-
- $parent->addPage($page);
-
- if (!$isAdmin) {
- if (stristr($r->template, 'externalredirection') && isset($t['url'])) {
- $page->setUri($t['url']);
- if (isset($t['target'])) {
- $page->setTarget($t['target']);
- }
- }
- }
-
- return $page;
- }
-
- protected function _checkUniqueURL($url, $domain, $id) {
- while (true) {
- if ($domain['domain']) {
- if (isset($this->_urls[$domain['domain']])) {
- $haystack = $this->_urls[$domain['domain']];
- } else {
- break;
- }
- } else {
- if (in_array($url, $this->_urls)) {
- $haystack = $this->_urls;
- } else {
- break;
- }
- }
- $id_found = array_search($url, $haystack);
- if ($id_found === false || $id_found == $id) {
- break;
- }
- $url = $this->_makeURLUnique($url);
- }
- if ($domain['domain']) {
- $this->_urls[$domain['domain']][] = $url;
- } else {
- $this->_urls[] = $url;
- }
- return $url;
- }
-
- protected function _makeURL($r, $seoUrl, $locale, $title, $parent, $isAdmin) {
-
- if ($seoUrl) {
- $page = $this->_escapeSeoUrl($seoUrl);
- } else {
- $page = CubeIT_Text::str2URL($title);
- }
-
-
- if ($locale) {
- $redirect = $this->getOpt('locales.redirect', true);
-
- $navLocales = $this->getNavigationLocales($isAdmin);
- $domain = $this->getLocaleDomain($locale);
-
- if (!$domain['domain']) {
- if ($redirect) {
- $base = '/' . $locale;
- } else {
- $base = '/';
- }
-
- } else {
- $base = '/' . $domain['segment'];
- }
-
- if ($r->label == 'home') {
- if ($domain['first'] == true) {
- $url = '';
- } else {
- $url = $base;
- }
- } else {
- $url = rtrim($base, "/") . '/' . $page;
- }
- } else {
- if ($r->label == 'home') {
- $url = '/';
- } else {
- $url = '/' . $page;
- }
- }
-
- return $url;
- }
-
- protected function _makeURLUnique($url) {
- if (stristr($url, '.')) {
- $e = explode('.', $url);
- $e[0] .= '-';
- $url = implode('.', $e);
- } else {
- return $url . '-';
- }
- }
-
- protected function _escapeSeoUrl($u) {
- $u = CubeIT_Text::removeAccents($u);
- $u = preg_replace('|[^a-z0-9\.-]|i', '-', $u);
- $u = preg_replace('|-+|', '-', $u);
- return $u;
- }
-
- protected function _getNavigationFields() {
- return array('shortTitle', 'longTitle', 'url', 'target', 'redirection', 'seourl', 'robots');
- }
-
- protected function _getNavigationPagesTitlesFromDb($locales = null) {
- $titles = array();
- $s = $this->getDb()->select();
- $s->from('cubeit_content')
- ->where('variant = ?', $this->getOption('variant'))
- ->where('label IN (?)', $this->_getNavigationFields());
- if (null !== $locales) {
- $s->where('locale IN (?)', $locales);
- }
- $rows = $s->query()
- ->fetchAll();
-
- foreach ($rows as $r) {
- if (null === $locales) {
- $t = &$titles;
- } else {
- if (!isset($titles[$r->locale])) {
- $titles[$r->locale] = array();
- }
- $t = &$titles[$r->locale];
- }
-
- if (!isset($t[$r->id])) {
- $t[$r->id] = array();
- }
- $t[$r->id][$r->label] = $r->content;
- }
- return $titles;
- }
-
- protected function _getNavigationPagesFromDb($all = false) {
- $s = $this->getDb()->select()->from('cubeit_page')
- ->where('variant = ?', $this->getOption('variant'))
- ->order('ordre ASC');
- if (!$all) {
- $s->where('online = ?', 1);
- }
-
- $q = $s->query();
- if ($q->rowCount()) {
- return $q->fetchAll();
- }
-
- $p = new stdClass();
- $p->id = 1;
- $p->order = 0;
- $p->parentPage = CubeIT_Navigation::MAIN;
- $p->label = 'home';
- $p->template = '';
-
- return array($p);
- }
-
- protected function getNavigationLocales($isAdmin) {
- if ($isAdmin) {
- return $this->getAppLocales();
- } else {
- return $this->getAppLocalesEnabled();
- }
- }
-
- protected function _initNavigation() {
- profile(__FILE__, __LINE__, 'Init Navigation');
-
- $navigation = $this->_makeNavigation();
- // Set navigation container helper
- if ($navigation instanceof Zend_Navigation_Container) {
- $this->getView()->navigation()->setContainer($navigation);
- }
-
- return $navigation;
- }
-
- /**
- * @param bool $refresh
- * @return CubeIT_Navigation
- */
- public function getNavigation($refresh = false) {
- if ($refresh) {
- $this->setResource('navigation', $this->_makeNavigation($refresh));
- }
- return parent::getNavigation($refresh);
- }
-
-
- /**
- *
- * @return array
- */
- public function getCMSTemplates() {
- $templates = array();
- $templates['home'] = 'Page d\'accueil';
- $templates['Redirections'] = array(
- 'externalredirection' => 'Redirection externe',
- 'nextredirection' => 'Redirection vers la première sous-rubrique',
- 'pageredirection' => 'Redirection interne',
- 'subredirection' => 'Redirection vers une sous-rubrique');
- return $templates;
- }
-
- /**
- *
- * @param boolean $refresh
- * @return CubeIT_Navigation
- */
- public function getFullNavigation($refresh = false) {
- return $this->_makeNavigation($refresh, true);
- }
-
- /**
- *
- * @param CubeIT_Navigation_Page $page
- * @return array
- */
- public function getCMSDatasOfNavigationPage($page) {
- if ($page instanceof CubeIT_Navigation_Page) {
- $form = $page->getFormInstance($this->getDb());
- }
- if (null !== $form) {
- return $form->getValues();
- }
- }
-
- /**
- *
- * @param integer|string $id
- * @param string $locale
- * @return array
- */
- public function getCMSDatasOfPage($id, $locale = null) {
- $container = $this->getNavigation()->getLocaleContainer($locale);
-
- $page = $container->findOneBy('name', $id);
- if (null === $page) {
- $page = $container->findOneBy('pageId', $id);
- }
-
- return $this->getCMSDatasOfNavigationPage($page);
- }
-
- public function getInternalLinkCacheId() {
- return '_';
- }
+class CubeIT_Bootstrap_Navigation extends CubeIT_Bootstrap_Locale
+{
+
+ protected $_urls = array();
+ protected $_cacheNavigation = false;
+
+ protected function _getNavigationCacheId($isAdmin, $full = false)
+ {
+ $res = 'navigation_' . APPLICATION_ENV . '_' . CubeIT_Text::str2URL(SITE_URL) . '_' . $this->getVariant() . "_";
+ if ($isAdmin) {
+ $res .= '_admin';
+ }
+ if ($full) {
+ $res .= '_full';
+ }
+ $res = str_replace('-', '_', $res);
+ return $res;
+ }
+
+ protected function _makeNavigation($refresh = false, $full = false)
+ {
+ profile(__FILE__, __LINE__, 'Make Application navigation');
+
+
+ $cache = $this->getCoreCache();
+
+ $isAdmin = $this->isAllowed('administration');
+ $cacheId = $this->_getNavigationCacheId($isAdmin, $full);
+
+ $mtime = max(filemtime(CubeIT_Util_PHP::getFileDeclaring($this)), filemtime(__FILE__));
+ $meta = $cache->getMetadatas($cacheId);
+
+ if (!$this->_cacheNavigation || $refresh || !$cache->test($cacheId) || $mtime > $meta['mtime']) {
+ $navigation = $this->_createNavigation($isAdmin);
+
+ $r = $this->navRoot;
+ if ($full) {
+ $r = null;
+ }
+
+ if ($this->isMultilang()) {
+ $this->_makeNavigationMultiLocale($navigation, $isAdmin, $r);
+ } else {
+ $this->_makeNavigationMonoLocale($navigation, $isAdmin, $r);
+ }
+
+ if (!$isAdmin) {
+ foreach ($this->_getNextRedirectionTemplates() as $template) {
+ foreach ($navigation->findAllByTemplate($template) as $p) {
+ $p->setUri($p->getFinalUri());
+ }
+ }
+ foreach ($navigation->findAllByTemplate('pageredirection') as $p) {
+ $p->setUri($p->getFinalUri());
+ }
+ foreach ($navigation->findAllByTemplate('subredirection') as $p) {
+ $p->setUri($p->getFinalUri());
+ }
+ }
+ if ($this->_cacheNavigation) {
+ $cache->save($navigation, $cacheId, array('navigation'));
+ $navigation->archive($this->getDb());
+ }
+ } else {
+ $navigation = $cache->load($cacheId, false);
+ }
+ return $navigation;
+ }
+
+ public function _getNextRedirectionTemplates()
+ {
+ return array('nextredirection');
+ }
+
+ /**
+ *
+ * @return CubeIT_Navigation
+ */
+ protected function _createNavigation($isAdmin = false)
+ {
+ $containers = true;
+ if ($this->hasOption('navigation')) {
+ $navOptions = $this->getOption('navigation');
+ if (isset($navOptions['containers'])) {
+ $containers = $navOptions['containers'];
+ }
+ }
+
+ if ($this->isMultilang()) {
+ $navigation = new CubeIT_Navigation_Locale($this->getNavigationLocales($isAdmin), null, $containers);
+ } else {
+ $navigation = new CubeIT_Navigation(null, $containers);
+ }
+ return $navigation;
+ }
+
+ public function isMultilang()
+ {
+ return count($this->getAppLocales()) > 1;
+ }
+
+ protected function _makeNavigationMonoLocale(&$navigation, $isAdmin, $root = null)
+ {
+ // Get titles
+ $titles = $this->_getNavigationPagesTitlesFromDb();
+ // Construct navigation
+ $rows = $this->_getNavigationPagesFromDb($isAdmin);
+
+ $this->_navAcceptedPages = array();
+ foreach ($rows as $r) {
+ if (!$this->_isNavAcceptedPage($r, $root)) {
+ continue;
+ }
+ $t = isset($titles[$r->id]) ? $titles[$r->id] : array();
+ $this->_makeNavigationOnePage($navigation, $r, $t, $isAdmin);
+ }
+ }
+
+ public function getLocaleNavigationByDomain()
+ {
+ $navigation = $this->getResource('navigation');
+ $domains = $this->getLocaleDomains();
+ $httphost = $_SERVER['HTTP_HOST'];
+
+ if (!($navigation instanceof Zend_Navigation)) {
+ profile(__FILE__, __LINE__, 'Get current page :: getLocaleNavigationByDomain :: not navigation');
+ $navigation = $this->getNavigation(true);
+ }
+ foreach ($domains as $locale => $d) {
+ if ($d['domain'] == $httphost) {
+
+ return $navigation->getLocaleContainer($locale);
+ }
+ }
+
+ return $navigation;
+ }
+
+ protected function _makeNavigationMultiLocale(&$navigation, $isAdmin, $root = null)
+ {
+ $locales = $this->getNavigationLocales($isAdmin);
+ // Get titles
+ $titles = $this->_getNavigationPagesTitlesFromDb($locales);
+
+ // Construct navigation
+ $rows = $this->_getNavigationPagesFromDb($isAdmin);
+
+ $this->_navAcceptedPages = array();
+ foreach ($rows as $r) {
+ if (!$this->_isNavAcceptedPage($r, $root)) {
+ continue;
+ }
+ foreach ($locales as $locale) {
+ $t = isset($titles[$locale][$r->id]) ? $titles[$locale][$r->id] : array();
+ $this->_makeNavigationOnePage($navigation, $r, $t, $isAdmin, $locale);
+ }
+ }
+ }
+
+ protected function _isNavAcceptedPage($page, $root)
+ {
+ $res = false;
+ if (null === $root) {
+ $res = true;
+ } else if ($page->id == $root) {
+ $this->_navAcceptedPages[$page->id] = true;
+ } else if (isset($this->_navAcceptedPages[$page->parentPage])) {
+ $this->_navAcceptedPages[$page->id] = true;
+ $res = true;
+ }
+
+ if ($res && $page->parentPage == $root) {
+ $page->parentPage = 0;
+ }
+
+ return $res;
+ }
+
+ /**
+ *
+ * @param type $navigation
+ * @param type $r
+ * @param type $t
+ * @param type $isAdmin
+ * @param type $locale
+ * @return CubeIT_Navigation_Page
+ */
+ protected function _makeNavigationOnePage(&$navigation, $r, $t, $isAdmin, $locale = false)
+ {
+ if ($locale) {
+ $parent = $navigation->findOneBy('id', $locale . '/' . $r->parentPage);
+ } else {
+ $parent = $navigation->findOneBy('id', $r->parentPage);
+ }
+
+ if (null == $parent) {
+ // Maybe parent is offline
+ return;
+ }
+
+ $title = isset($t['shortTitle']) && $t['shortTitle'] != '' ? $t['shortTitle'] : $r->label;
+ $longTitle = isset($t['longTitle']) && $t['longTitle'] != '' ? $t['longTitle'] : $title;
+ $seoUrl = isset($t['seourl']) && $t['seourl'] != '' ? $t['seourl'] : '';
+ $robots = isset($t['robots']) ? $t['robots'] == true : true;
+
+ if ($locale) {
+ $domain = $this->getLocaleDomain($locale);
+ $page = new CubeIT_Navigation_Page_Locale();
+ $page->setId($locale . '/' . $r->id);
+ $url = $this->_makeURL($r, $seoUrl, $locale, $title, $parent, $isAdmin);
+ } else {
+ $domain = array('domain' => '', 'segment' => '', 'first' => false);
+ $page = new CubeIT_Navigation_Page();
+ $page->setId($r->id);
+ $url = $this->_makeURL($r, $seoUrl, false, $title, $parent, $isAdmin);
+ }
+
+ $url = $this->_checkUniqueURL($url, $domain, $page->getId());
+
+ if (!isset($r->online)) {
+ $r->online = 1;
+ }
+ $page->setOnline($r->online);
+ $page->setTitle($title);
+ $page->setLongTitle($longTitle);
+ $page->setTemplate($r->template);
+ $page->setLabel($title);
+ $page->setEditable(true);
+ $page->setName($r->label);
+ $page->setUri($url);
+ $page->setSitemap($robots);
+ $page->setVariant($this->getVariant());
+ if ($domain['domain']) {
+ $page->setDomain($domain['domain']);
+ }
+ if (isset($t['redirection'])) {
+ $page->setRedirection($t['redirection']);
+ }
+ if (!$isAdmin && strpos($r->template, 'popup_') === 0) {
+ $page->setClass('popup');
+ }
+
+ $parent->addPage($page);
+
+ if (!$isAdmin) {
+ if (stristr($r->template, 'externalredirection') && isset($t['url'])) {
+ $page->setUri($t['url']);
+ if (isset($t['target'])) {
+ $page->setTarget($t['target']);
+ }
+ }
+ }
+
+ return $page;
+ }
+
+ protected function _checkUniqueURL($url, $domain, $id)
+ {
+ while (true) {
+ if ($domain['domain']) {
+ if (isset($this->_urls[$domain['domain']])) {
+ $haystack = $this->_urls[$domain['domain']];
+ } else {
+ break;
+ }
+ } else {
+ if (in_array($url, $this->_urls)) {
+ $haystack = $this->_urls;
+ } else {
+ break;
+ }
+ }
+ $id_found = array_search($url, $haystack);
+ if ($id_found === false || $id_found == $id) {
+ break;
+ }
+ $url = $this->_makeURLUnique($url);
+ }
+ if ($domain['domain']) {
+ $this->_urls[$domain['domain']][] = $url;
+ } else {
+ $this->_urls[] = $url;
+ }
+ return $url;
+ }
+
+ protected function _makeURL($r, $seoUrl, $locale, $title, $parent, $isAdmin)
+ {
+
+ if ($seoUrl) {
+ $page = $this->_escapeSeoUrl($seoUrl);
+ } else {
+ $page = CubeIT_Text::str2URL($title);
+ }
+
+
+ if ($locale) {
+ $redirect = $this->getOpt('locales.redirect', true);
+
+ $navLocales = $this->getNavigationLocales($isAdmin);
+ $domain = $this->getLocaleDomain($locale);
+
+ if (!$domain['domain']) {
+ if ($redirect) {
+ $base = '/' . $locale;
+ } else {
+ $base = '/';
+ }
+
+ } else {
+ $base = '/' . $domain['segment'];
+ }
+
+ if ($r->label == 'home') {
+ if ($domain['first'] == true) {
+ $url = '';
+ } else {
+ $url = $base;
+ }
+ } else {
+ $url = rtrim($base, "/") . '/' . $page;
+ }
+ } else {
+ if ($r->label == 'home') {
+ $url = '/';
+ } else {
+ $url = '/' . $page;
+ }
+ }
+
+ return $url;
+ }
+
+ protected function _makeURLUnique($url)
+ {
+ if (stristr($url, '.')) {
+ $e = explode('.', $url);
+ $e[0] .= '-';
+ $url = implode('.', $e);
+ } else {
+ return $url . '-';
+ }
+ }
+
+ protected function _escapeSeoUrl($u)
+ {
+ $u = CubeIT_Text::removeAccents($u);
+ $u = preg_replace('|[^a-z0-9\.-]|i', '-', $u);
+ $u = preg_replace('|-+|', '-', $u);
+ return $u;
+ }
+
+ protected function _getNavigationFields()
+ {
+ return array('shortTitle', 'longTitle', 'url', 'target', 'redirection', 'seourl', 'robots');
+ }
+
+ protected function _getNavigationPagesTitlesFromDb($locales = null)
+ {
+ $titles = array();
+ $s = $this->getDb()->select();
+ $s->from('cubeit_content')
+ ->where('variant = ?', $this->getOption('variant'))
+ ->where('label IN (?)', $this->_getNavigationFields());
+ if (null !== $locales) {
+ $s->where('locale IN (?)', $locales);
+ }
+ $rows = $s->query()
+ ->fetchAll();
+
+ foreach ($rows as $r) {
+ if (null === $locales) {
+ $t = &$titles;
+ } else {
+ if (!isset($titles[$r->locale])) {
+ $titles[$r->locale] = array();
+ }
+ $t = &$titles[$r->locale];
+ }
+
+ if (!isset($t[$r->id])) {
+ $t[$r->id] = array();
+ }
+ $t[$r->id][$r->label] = $r->content;
+ }
+ return $titles;
+ }
+
+ protected function _getNavigationPagesFromDb($all = false)
+ {
+ $s = $this->getDb()->select()->from('cubeit_page')
+ ->where('variant = ?', $this->getOption('variant'))
+ ->order('ordre ASC');
+ if (!$all) {
+ $s->where('online = ?', 1);
+ }
+
+ $q = $s->query();
+ if ($q->rowCount()) {
+ return $q->fetchAll();
+ }
+
+ $p = new stdClass();
+ $p->id = 1;
+ $p->order = 0;
+ $p->parentPage = CubeIT_Navigation::MAIN;
+ $p->label = 'home';
+ $p->template = '';
+
+ return array($p);
+ }
+
+ protected function getNavigationLocales($isAdmin)
+ {
+ if ($isAdmin) {
+ return $this->getAppLocales();
+ } else {
+ return $this->getAppLocalesEnabled();
+ }
+ }
+
+ protected function _initNavigation()
+ {
+ profile(__FILE__, __LINE__, 'Init Navigation');
+
+ $navigation = $this->_makeNavigation();
+ // Set navigation container helper
+ if ($navigation instanceof Zend_Navigation_Container) {
+ $this->getView()->navigation()->setContainer($navigation);
+ }
+
+ return $navigation;
+ }
+
+ /**
+ * @param bool $refresh
+ * @return CubeIT_Navigation
+ */
+ public function getNavigation($refresh = false)
+ {
+ if ($refresh) {
+ $this->setResource('navigation', $this->_makeNavigation($refresh));
+ }
+ return parent::getNavigation($refresh);
+ }
+
+
+ /**
+ *
+ * @return array
+ */
+ public function getCMSTemplates()
+ {
+ $templates = array();
+ $templates['home'] = 'Page d\'accueil';
+ $templates['Redirections'] = array(
+ 'externalredirection' => 'Redirection externe',
+ 'nextredirection' => 'Redirection vers la première sous-rubrique',
+ 'pageredirection' => 'Redirection interne',
+ 'subredirection' => 'Redirection vers une sous-rubrique');
+ return $templates;
+ }
+
+ /**
+ *
+ * @param boolean $refresh
+ * @return CubeIT_Navigation
+ */
+ public function getFullNavigation($refresh = false)
+ {
+ return $this->_makeNavigation($refresh, true);
+ }
+
+ /**
+ *
+ * @param CubeIT_Navigation_Page $page
+ * @return array
+ */
+ public function getCMSDatasOfNavigationPage($page)
+ {
+ if ($page instanceof CubeIT_Navigation_Page) {
+ $form = $page->getFormInstance($this->getDb());
+ }
+ if (null !== $form) {
+ return $form->getValues();
+ }
+ }
+
+ /**
+ *
+ * @param integer|string $id
+ * @param string $locale
+ * @return array
+ */
+ public function getCMSDatasOfPage($id, $locale = null)
+ {
+ $container = $this->getNavigation()->getLocaleContainer($locale);
+
+ $page = $container->findOneBy('name', $id);
+ if (null === $page) {
+ $page = $container->findOneBy('pageId', $id);
+ }
+
+ return $this->getCMSDatasOfNavigationPage($page);
+ }
+
+ public function getInternalLinkCacheId()
+ {
+ return '_';
+ }
}