]> _ Git - fluidbook-v3.git/commitdiff
try #7257 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 7 Apr 2025 08:42:20 +0000 (10:42 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 7 Apr 2025 08:42:20 +0000 (10:42 +0200)
.idea/workspace.xml
framework/library/CubeIT/Bootstrap/Navigation.php
framework/library/CubeIT/Navigation/Page.php

index aa9f6f805fd5d64d200f7361c70e16ea521df72f..72d471b6ead99a84c136b8df4e48b7cc328456e7 100644 (file)
@@ -4,9 +4,10 @@
     <option name="autoReloadType" value="SELECTIVE" />
   </component>
   <component name="ChangeListManager">
-    <list default="true" id="530ffb50-16c9-4bb3-ad22-e76f531eb78c" name="Default" comment="wip #3702 @0.25">
-      <change beforePath="$PROJECT_DIR$/.idea/dataSources.local.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/dataSources.local.xml" afterDir="false" />
+    <list default="true" id="530ffb50-16c9-4bb3-ad22-e76f531eb78c" name="Default" comment="#7257">
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" 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/CubeIT/Navigation/Page.php" beforeDir="false" afterPath="$PROJECT_DIR$/framework/library/CubeIT/Navigation/Page.php" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
     <option name="hideEmptyMiddlePackages" value="true" />
     <option name="showLibraryContents" value="true" />
   </component>
-  <component name="PropertiesComponent">{
-  &quot;keyToString&quot;: {
-    &quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
-    &quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;,
-    &quot;WebServerToolWindowFactoryState&quot;: &quot;true&quot;,
-    &quot;WebServerToolWindowPanel.toolwindow.highlight.mappings&quot;: &quot;true&quot;,
-    &quot;WebServerToolWindowPanel.toolwindow.highlight.symlinks&quot;: &quot;true&quot;,
-    &quot;WebServerToolWindowPanel.toolwindow.show.date&quot;: &quot;false&quot;,
-    &quot;WebServerToolWindowPanel.toolwindow.show.permissions&quot;: &quot;false&quot;,
-    &quot;WebServerToolWindowPanel.toolwindow.show.size&quot;: &quot;false&quot;,
-    &quot;git-widget-placeholder&quot;: &quot;master&quot;,
-    &quot;ignore.virus.scanning.warn.message&quot;: &quot;true&quot;,
-    &quot;kotlin-language-version-configured&quot;: &quot;true&quot;,
-    &quot;last_opened_file_path&quot;: &quot;D:/Works/FluidbookWebV3/framework/library/CubeIT/Bootstrap&quot;,
-    &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
-    &quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
-    &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
-    &quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
-    &quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
-    &quot;project.structure.last.edited&quot;: &quot;Project&quot;,
-    &quot;project.structure.proportion&quot;: &quot;0.0&quot;,
-    &quot;project.structure.side.proportion&quot;: &quot;0.2&quot;,
-    &quot;ruby.rails.projectView.checked&quot;: &quot;true&quot;,
-    &quot;settings.editor.selected.configurable&quot;: &quot;project.propVCSSupport.DirectoryMappings&quot;,
-    &quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
+  <component name="PropertiesComponent"><![CDATA[{
+  "keyToString": {
+    "RunOnceActivity.OpenProjectViewOnStart": "true",
+    "RunOnceActivity.ShowReadmeOnStart": "true",
+    "RunOnceActivity.git.unshallow": "true",
+    "WebServerToolWindowFactoryState": "true",
+    "WebServerToolWindowPanel.toolwindow.highlight.mappings": "true",
+    "WebServerToolWindowPanel.toolwindow.highlight.symlinks": "true",
+    "WebServerToolWindowPanel.toolwindow.show.date": "false",
+    "WebServerToolWindowPanel.toolwindow.show.permissions": "false",
+    "WebServerToolWindowPanel.toolwindow.show.size": "false",
+    "git-widget-placeholder": "master",
+    "ignore.virus.scanning.warn.message": "true",
+    "kotlin-language-version-configured": "true",
+    "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)",
+    "node.js.selected.package.tslint": "(autodetect)",
+    "nodejs_package_manager_path": "npm",
+    "project.structure.last.edited": "Project",
+    "project.structure.proportion": "0.0",
+    "project.structure.side.proportion": "0.2",
+    "ruby.rails.projectView.checked": "true",
+    "settings.editor.selected.configurable": "project.propVCSSupport.DirectoryMappings",
+    "vue.rearranger.settings.migration": "true"
   }
-}</component>
+}]]></component>
   <component name="RecentsManager">
     <key name="CopyFile.RECENT_KEYS">
       <recent name="D:\Works\FluidbookWebV3\framework\library\CubeIT\Bootstrap" />
       <workItem from="1739800972227" duration="9576000" />
       <workItem from="1739875492260" duration="818000" />
       <workItem from="1743588153623" duration="6412000" />
+      <workItem from="1743685828952" duration="2161000" />
+      <workItem from="1744010760355" duration="3307000" />
     </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="178" />
+    <option name="localTasksCounter" value="179" />
     <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="wip #3703 @0.75" />
     <MESSAGE value="wip #3726 @0.5" />
     <MESSAGE value="wip #3853 @0.5" />
     <MESSAGE value="wait #3693 @1.5" />
     <MESSAGE value="wip #7257 @3" />
     <MESSAGE value="wip #7257 @2" />
     <MESSAGE value="wip #3702 @0.25" />
-    <option name="LAST_COMMIT_MESSAGE" value="wip #3702 @0.25" />
+    <MESSAGE value="#7257" />
+    <option name="LAST_COMMIT_MESSAGE" value="#7257" />
     <option name="NON_MODAL_COMMIT_POSTPONE_SLOW_CHECKS" value="false" />
   </component>
   <component name="XDebuggerManager">
index c7b74c5f31e6159a53271300f691ca8aa3b4abd8..65152486d94f37c0f225b76f15af2a73111caa32 100644 (file)
@@ -4,7 +4,7 @@ class CubeIT_Bootstrap_Navigation extends CubeIT_Bootstrap_Locale
 {
 
     protected $_urls = array();
-    protected $_cacheNavigation = false;
+    protected $_cacheNavigation = true;
 
     protected function _getNavigationCacheId($isAdmin, $full = false)
     {
index 58c77f7f960544ad08b5bb8611eefdfe1a4a2201..ef16e88f7b07051476df552571d8eacfd00f286e 100644 (file)
 <?php
 
-class CubeIT_Navigation_Page extends Zend_Navigation_Page_Uri implements Zend_Acl_Resource_Interface {
-
-       protected $_editable = false;
-       protected $_name;
-       protected $_sitemap = true;
-       protected $_breadcrumbs = true;
-       protected $_controller;
-       protected $_action = 'index';
-       protected $_params;
-       protected $_menu = true;
-       protected $_aclEdit = 'inherit';
-       protected $_resourceId = 'page';
-       protected $_template = 'default';
-       protected $_redirection = '';
-       protected $_longTitle = '';
-       protected $_isRedirection = false;
-       protected $_online = true;
-       protected $_domain = '';
-       protected $_hidden = false;
-       protected $_translate = true;
-       protected $_variant = 0;
-       protected static $_autoUrlDatas;
-
-       public function getOnline() {
-               return $this->_online;
-       }
-
-       public function setOnline($online) {
-               $this->_online = $online;
-               if (!$online) {
-                       $this->setCustomHtmlAttrib('data-offline', '1');
-               } else {
-                       $this->removeCustomHtmlAttrib('data-offline');
-               }
-               return $this;
-       }
-
-       /**
-        * @return int
-        */
-       public function getVariant() {
-               return $this->_variant;
-       }
-
-       /**
-        * @param int $variant
-        * @return CubeIT_Navigation_Page
-        */
-       public function setVariant($variant) {
-               $this->_variant = $variant;
-               return $this;
-       }
-
-
-       /**
-        * @return boolean
-        */
-       public function getTranslate() {
-               return $this->_translate;
-       }
-
-       /**
-        * @param boolean $translate
-        * @return $this
-        */
-       public function setTranslate($translate) {
-               $this->_translate = $translate;
-               return $this;
-       }
-
-
-       public function getDomain() {
-               return $this->_domain;
-       }
-
-       public function setDomain($domain) {
-               $this->_domain = $domain;
-               return $this;
-       }
-
-       function getBreadcrumbs() {
-               return $this->_breadcrumbs;
-       }
-
-       function setBreadcrumbs($breadcrumbs) {
-               $this->_breadcrumbs = $breadcrumbs;
-               return $this;
-       }
-
-       public function getLongTitle() {
-               return $this->_longTitle;
-       }
-
-       public function setLongTitle($longTitle) {
-               $this->_longTitle = $longTitle;
-               return $this;
-       }
-
-       public function getRedirection() {
-               return $this->_redirection;
-       }
-
-       public function setRedirection($redirection) {
-               $this->_redirection = $redirection;
-               return $this;
-       }
-
-       public function getResourceId() {
-               return $this->_resourceId;
-       }
-
-       public function setResourceId($resourceId) {
-               $this->_resourceId = $resourceId;
-               return $this;
-       }
-
-       public function getTemplate() {
-               return $this->_template;
-       }
-
-       public function setTemplate($template) {
-               $this->_template = $template;
-               return $this;
-       }
-
-       public function getAclEdit() {
-               if ($this->_aclEdit == 'inherit') {
-                       if (null !== $this->getParent() && $this->getParent() instanceof CubeIT_Navigation_Page) {
-                               return $this->getParent()->getAclEdit();
-                       } else {
-                               return array();
-                       }
-               }
-               return explode(',', $this->_aclEdit);
-       }
-
-       public function setAclEdit($aclEdit) {
-               $this->_aclEdit = $aclEdit;
-               return $this;
-       }
-
-       public function getMenu() {
-               return $this->_menu;
-       }
-
-       public function setMenu($_menu) {
-               $this->_menu = $_menu;
-               return $this;
-       }
-
-       public function getSitemap() {
-               return $this->_sitemap;
-       }
-
-       public function setSitemap($_sitemap) {
-               $this->_sitemap = $_sitemap;
-               return $this;
-       }
-
-       public function getEditable() {
-               return $this->_editable;
-       }
-
-       public function setEditable($_editable) {
-               $this->_editable = $_editable;
-               return $this;
-       }
-
-       public function isEditable() {
-               return $this->getEditable();
-       }
-
-       public function getName() {
-               return $this->_name;
-       }
-
-       public function setName($_name) {
-               $this->_name = $_name;
-               return $this;
-       }
-
-       public function getController() {
-               return $this->_controller;
-       }
-
-       public function setController($_controller) {
-               $this->_controller = $_controller;
-
-               return $this;
-       }
-
-       public function getAction() {
-               return $this->_action;
-       }
-
-       public function setAction($_action) {
-               $this->_action = $_action;
-               return $this;
-       }
-
-       public function getParams() {
-               return $this->_params;
-       }
-
-       public function setParams($_params) {
-               $this->_params = $_params;
-               return $this;
-       }
-
-       /**
-        * @return bool
-        */
-       public function getHidden() {
-               return $this->_hidden;
-       }
-
-       /**
-        * @param bool $hidden
-        * @return self
-        */
-       public function setHidden($hidden) {
-               $this->_hidden = $hidden;
-               if ($hidden) {
-                       $this->setCustomHtmlAttrib('data-hidden', '1');
-               } else {
-                       $this->removeCustomHtmlAttrib('data-hidden');
-               }
-               return $this;
-       }
-
-       public function getPageId() {
-               return $this->getId();
-       }
-
-       public function getFirstEditablePageId() {
-               if ($this->isEditable()) {
-                       return $this->getPageId();
-               }
-               if ($this->getParent() instanceof CubeIT_Navigation_Page) {
-                       return $this->getParent()->getFirstEditablePageId();
-               }
-               return null;
-       }
-
-       /**
-        *
-        * @return array
-        */
-       public function getContents() {
-               profile(__FILE__, __LINE__, 'Get page contents');
-               $form = $this->getFormInstance();
-               if (is_null($form)) {
-                       return null;
-               }
-               $res = array();
-
-               profile(__FILE__, __LINE__, 'Get static values');
-               foreach ($form->getStaticValues() as $key => $value) {
-                       $res[$key] = $value;
-               }
-
-               profile(__FILE__, __LINE__, 'Get dynamic values');
-               foreach ($form as $element) {
-                       $k = $element->getName();
-                       $v = $form->getValue($k);
-
-                       $res[$k] = $v;
-               }
-
-
-               return $res;
-       }
-
-       /**
-        * @return CubeIT_Form_CMS
-        */
-       public function getFormInstance() {
-               if ($this instanceof CubeIT_Navigation_Page_Locale) {
-                       $locale = $this->getLocale();
-                       $cacheId = 'form_instance_' . $locale . '_' . sha1($this->getFinalUri());
-               } else {
-                       $cacheId = 'form_instance_' . sha1($this->getFinalUri());
-               }
-
-               $bootstrap = Bootstrap::getInstance();
-               $cache = $bootstrap->getCoreCache();
-               if (!($form = $cache->load($cacheId))) {
-                       profile(__FILE__, __LINE__, 'Get form instance::init');
-
-                       $db = $bootstrap->getDb();
-                       if ($this->getTemplate() == '') {
-                               profile(__FILE__, __LINE__, 'Get form instance::no template');
-                               $parent = $this->getParent();
-                               if ($parent instanceof CubeIT_Navigation_Page) {
-                                       return $parent->getFormInstance($db);
-                               }
-                               return new CubeIT_Form_CMS();
-                       }
-
-                       profile(__FILE__, __LINE__, 'Get form instance::find class name');
-                       $suffix = "_Form_CMS_";
-                       $e = explode('_', $this->getTemplate());
-                       foreach ($e as $k => $v) {
-                               $suffix .= ucfirst($v);
-                       }
-
-                       $prefixs = array($bootstrap->getAppNamespace(), 'CubeIT');
-                       /* @var $form CubeIT_Form_CMS */
-                       foreach ($prefixs as $p) {
-                               $class = $p . $suffix;
-                               if (class_exists($class, true)) {
-                                       profile(__FILE__, __LINE__, 'Get form instance::instanciate ' . $class);
-                                       $form = new $class();
-                                       break;
-                               }
-                       }
-
-                       if (!isset($form) || is_null($form) || !$form) {
-                               return null;
-                       }
-
-                       if (!is_null($db)) {
-                               profile(__FILE__, __LINE__, 'Get form instance::get data');
-                               if ($this instanceof CubeIT_Navigation_Page_Locale) {
-                                       $form->setLocale($locale);
-                               }
-                               $form->setVariant($this->getVariant());
-                               $form->setPageId($this->getPageId());
-                               $form->loadDatasFromDatabase($db);
-                       }
-                       $cache->save($form, $cacheId, ['contents', 'forms']);
-               }
-
-               return $form;
-       }
-
-       public function saveContents($data, $skipConsistencyChecks = false) {
-               $subtree = array($data['id']);
-               $it = new RecursiveIteratorIterator($this, RecursiveIteratorIterator::CHILD_FIRST);
-               foreach ($it as $sub) {
-                       if ($sub instanceof CubeIT_Navigation_Page && $sub->isEditable()) {
-                               $subtree[] = $sub->getPageId();
-                       }
-               }
-               $subtree = array_unique($subtree);
-
-               $form = $this->getFormInstance();
-               $form->setDefaults($data);
-
-               if (!$skipConsistencyChecks) {
-                       // If the form supports it, do extra consistency checks on it before saving
-                       if ($form instanceof CubeIT_Form_CMSBase) {
-
-                               if (!$form->canBeSaved()) {
-                                       fb('saveContents() aborted due to consistency check failure...');
-                                       return false;
-                               }
-                       }
-               }
-
-               $db = Bootstrap::getInstance()->getDb();
-
-               // Get the list of existing datas
-               $exists = array();
-               $rows = $db->select()->from('cubeit_content')->query()->fetchAll();
-               foreach ($rows as $r) {
-                       $exists[$r->locale][$r->id][$r->label][$r->variant] = true;
-               }
-
-               $toInsert = array();
-
-               foreach ($form->getValues() as $k => $v) {
-                       $propagatelocale = isset($data['propagatelocale'][$k]) && $data['propagatelocale'][$k] == 1;
-                       $propagatesubtree = isset($data['propagatesubtree'][$k]) && $data['propagatesubtree'][$k] == 1;
-
-                       if ($k == 'id' || $k == 'locale' || $k == 'variant') {
-                               continue;
-                       }
-
-                       if (is_array($v) || is_object($v)) {
-                               if (isset($v['cubeitbase'])) {
-                                       unset($v['cubeitbase']);
-                                       $v = json_encode(array_values($v));
-                               } else {
-                                       $v = json_encode($v);
-                               }
-                       }
-
-                       if ($propagatelocale) {
-                               $localesToPropagate = Bootstrap::getInstance()->getAppLocales();
-                       } else {
-                               $localesToPropagate = array($data['locale']);
-                       }
-
-                       if ($propagatesubtree) {
-                               $idsToPropagate = $subtree;
-                       } else {
-                               $idsToPropagate = array($data['id']);
-                       }
-
-                       foreach ($localesToPropagate as $locale) {
-                               foreach ($idsToPropagate as $id) {
-                                       $toInsert[] = array('label' => $k, 'content' => $v, 'id' => $id, 'locale' => $locale, 'variant' => $data['variant']);
-                               }
-                       }
-               }
-
-               foreach ($toInsert as $datas) {
-
-                       try {
-                               if (!isset($exists[$datas['locale']][$datas['id']][$datas['label']][$datas['variant']])) {
-                                       $exists[$datas['locale']][$datas['id']][$datas['label']][$datas['variant']] = true;
-                                       $db->insert('cubeit_content', $datas);
-                               } else {
-                                       $where = $db->quoteInto('locale = ?', $datas['locale']);
-                                       $where .= ' AND ' . $db->quoteInto('id = ?', $datas['id']);
-                                       $where .= ' AND ' . $db->quoteInto('label = ?', $datas['label']);
-                                       $where .= ' AND ' . $db->quoteInto('variant = ?', $datas['variant']);
-
-                                       $db->update('cubeit_content', $datas, $where);
-                               }
-                       } catch (Exception $e) {
-
-                       }
-               }
-       }
-
-       /**
-        *
-        * @param string $uri
-        * @param Zend_Db_Adapter_Abstract $db
-        * @return Zend_Navigation_Page
-        */
-       public function findOneByFormerUri($uri, Zend_Db_Adapter_Abstract $db = null) {
-               if (is_null($db)) {
-                       $db = Bootstrap::getInstance()->getDb();
-               }
-               $r = $db->select()->from('cubeit_url')->where('uri = ?', $uri)->query()->fetch();
-               die($r->id);
-
-               if (!is_null($r) && is_object($r)) {
-                       return $this->findOneBy('id', $r->id);
-               }
-               return null;
-       }
-
-       /**
-        * @return int
-        */
-       public function getLevel() {
-               $level = 0;
-               $page = $this;
-               while ($page instanceof Zend_Navigation_Page && !is_null($page->getParent())) {
-                       $page = $page->getParent();
-                       $level++;
-               }
-               return $level;
-       }
-
-       /**
-        *
-        * @param int $level
-        * @return Zend_Navigation_Page
-        */
-       public function getParentAt($level) {
-               $page = $this;
-
-               for ($i = $this->getLevel() - 1; $i > $level; $i--) {
-                       $parent = $page->getParent();
-                       if (null === $parent) {
-                               return $page;
-                       }
-                       $page = $parent;
-               }
-               return $page;
-       }
-
-       public function getFinalUri() {
-               if (in_array($this->getTemplate(), Bootstrap::getInstance()->_getNextRedirectionTemplates())) {
-                       $pages = $this->getPages();
-                       foreach ($pages as $p) {
-                               return $p->getUri();
-                       }
-               } else {
-                       $root = $this->getParentAt(-1);
-                       $id = $this->_makeFullId($this->getRedirection());
-                       $p = $root->findOneById($id);
-                       if (null !== $p) {
-                               return $p->getUri();
-                       }
-               }
-               return $this->getUri();
-       }
-
-       protected function _makeFullId($id) {
-               return trim($id, '/');
-       }
-
-       /**
-        *
-        * @return array
-        */
-       public function getSiblings() {
-               $parent = $this->getParent();
-               return $parent->getPages();
-       }
-
-       /**
-        * @return Zend_Navigation_Page
-        */
-       public function getNextSibling() {
-               $siblings = array_values($this->getSiblings());
-               $k = array_search($this, $siblings, true);
-               if (isset($siblings[$k + 1])) {
-                       return $siblings[$k + 1];
-               }
-               return null;
-       }
-
-       /**
-        * @return Zend_Navigation_Page
-        */
-       public function getPrevSibling() {
-               $siblings = array_values($this->getSiblings());
-               $k = array_search($this, $siblings, true);
-               if (isset($siblings[$k - 1])) {
-                       return $siblings[$k - 1];
-               }
-               return null;
-       }
-
-       /**
-        * @return Zend_Navigation_Page
-        */
-       public function getFirstChild() {
-               $children = $this->getPages();
-               if (is_null($children)) {
-                       return null;
-               }
-               foreach ($children as $child) {
-                       return $child;
-               }
-               return null;
-       }
-
-       /**
-        * @return this[]
-        */
-       public function getParents($reverse = false) {
-               $parents = array();
-               $page = $this;
-               while ($page instanceof Zend_Navigation_Page) {
-                       $parent = $page->getParent();
-                       if (is_null($parent)) {
-                               break;
-                       }
-                       $parents[] = $parent;
-                       $page = $parent;
-               }
-               if ($reverse) {
-                       $parents = array_reverse($parents);
-               }
-
-               return $parents;
-       }
-
-       /**
-        * return boolean
-        */
-       public function findInParents($key, $value) {
-               $parents = $this->getParents();
-               foreach ($parents as $page) {
-                       /* @var $page Zend_Navigation_Page */
-
-                       if ($page instanceof Zend_Navigation_Page && $page->get($key) == $value) {
-                               return $page;
-                       }
-               }
-               return false;
-       }
-
-       public function findClosestBy($key, $value) {
-               $page = $this;
-               while (true) {
-                       if (!$page instanceof Zend_Navigation_Page) {
-                               return false;
-                       }
-                       if ($page->get($key) == $value) {
-                               return $page;
-                       }
-                       $page = $page->getParent();
-               }
-       }
-
-       public function setAutoUri($datas, $template, $locale = null) {
-               return $this->setUri(self::generateAutoUri($datas, $template, $locale));
-       }
-
-       public static function generateAutoUri($datas, $template, $locale = null) {
-               self::$_autoUrlDatas = CubeIT_Util_Cms::unserialize($datas, $locale);
-
-               $u = preg_replace_callback('|\%([a-z]+)\%|', array('self', '_replaceAutoUrl'), $template);
-               if (!is_null($locale)) {
-                       $domain = Bootstrap::getInstance()->getLocaleDomain($locale);
-                       if ($domain['domain']) {
-                               $res = '';
-                               if ($domain['segment']) {
-                                       $res = '/' . $domain['segment'];
-                               }
-                               $res .= '/' . $u;
-                               return $res;
-                       } else {
-                               return '/' . $locale . '/' . $u;
-                       }
-               } else {
-                       return $u;
-               }
-       }
-
-       protected static function _replaceAutoUrl($m) {
-
-               $key = $m[1];
-
-               if (is_object(self::$_autoUrlDatas)) {
-                       $url = self::$_autoUrlDatas->$key;
-               } else {
-                       $url = self::$_autoUrlDatas[$m[1]];
-               }
-
-               return CubeIT_Text::str2URL($url);
-       }
-
-       public function getHref() {
-               $href = parent::getHref();
-               if (CubeIT_Util_Url::isDistant($href) || strpos($href, 'http') === 0) {
-                       return $href;
-               }
-               $domain = $this->getDomain();
-               if (!$domain) {
-                       return $href;
-               }
-               return SITE_PROTOCOL . $domain . $href;
-       }
-
-       public function getAbsoluteHref() {
-               $href = $this->getHref();
-               if (CubeIT_Util_Url::isDistant($href) || strpos($href, 'http') === 0) {
-                       return $href;
-               }
-               return SITE_PROTOCOL . Bootstrap::getInstance()->getOption('webhost') . $href;
-       }
-
-
-       /**
-        * @param $locale
-        * @return $this
-        */
-       public function getLocaleVariant($locale) {
-               return $this;
-       }
-
-       public function isRoot() {
-               return !$this->hasParent();
-       }
-
-       public function hasParent() {
-               return null !== $this->getParent();
-       }
-
-
-       /**
-        * @return CubeIT_Navigation
-        */
-       public function getRoot() {
-               return $this->getParentAt(0)->getParent();
-       }
+class CubeIT_Navigation_Page extends Zend_Navigation_Page_Uri implements Zend_Acl_Resource_Interface
+{
+
+    protected $_editable = false;
+    protected $_name;
+    protected $_sitemap = true;
+    protected $_breadcrumbs = true;
+    protected $_controller;
+    protected $_action = 'index';
+    protected $_params;
+    protected $_menu = true;
+    protected $_aclEdit = 'inherit';
+    protected $_resourceId = 'page';
+    protected $_template = 'default';
+    protected $_redirection = '';
+    protected $_longTitle = '';
+    protected $_isRedirection = false;
+    protected $_online = true;
+    protected $_domain = '';
+    protected $_hidden = false;
+    protected $_translate = true;
+    protected $_variant = 0;
+    protected static $_autoUrlDatas;
+
+    public function getOnline()
+    {
+        return $this->_online;
+    }
+
+    public function setOnline($online)
+    {
+        $this->_online = $online;
+        if (!$online) {
+            $this->setCustomHtmlAttrib('data-offline', '1');
+        } else {
+            $this->removeCustomHtmlAttrib('data-offline');
+        }
+        return $this;
+    }
+
+    /**
+     * @return int
+     */
+    public function getVariant()
+    {
+        return $this->_variant;
+    }
+
+    /**
+     * @param int $variant
+     * @return CubeIT_Navigation_Page
+     */
+    public function setVariant($variant)
+    {
+        $this->_variant = $variant;
+        return $this;
+    }
+
+
+    /**
+     * @return boolean
+     */
+    public function getTranslate()
+    {
+        return $this->_translate;
+    }
+
+    /**
+     * @param boolean $translate
+     * @return $this
+     */
+    public function setTranslate($translate)
+    {
+        $this->_translate = $translate;
+        return $this;
+    }
+
+
+    public function getDomain()
+    {
+        return $this->_domain;
+    }
+
+    public function setDomain($domain)
+    {
+        $this->_domain = $domain;
+        return $this;
+    }
+
+    function getBreadcrumbs()
+    {
+        return $this->_breadcrumbs;
+    }
+
+    function setBreadcrumbs($breadcrumbs)
+    {
+        $this->_breadcrumbs = $breadcrumbs;
+        return $this;
+    }
+
+    public function getLongTitle()
+    {
+        return $this->_longTitle;
+    }
+
+    public function setLongTitle($longTitle)
+    {
+        $this->_longTitle = $longTitle;
+        return $this;
+    }
+
+    public function getRedirection()
+    {
+        return $this->_redirection;
+    }
+
+    public function setRedirection($redirection)
+    {
+        $this->_redirection = $redirection;
+        return $this;
+    }
+
+    public function getResourceId()
+    {
+        return $this->_resourceId;
+    }
+
+    public function setResourceId($resourceId)
+    {
+        $this->_resourceId = $resourceId;
+        return $this;
+    }
+
+    public function getTemplate()
+    {
+        return $this->_template;
+    }
+
+    public function setTemplate($template)
+    {
+        $this->_template = $template;
+        return $this;
+    }
+
+    public function getAclEdit()
+    {
+        if ($this->_aclEdit == 'inherit') {
+            if (null !== $this->getParent() && $this->getParent() instanceof CubeIT_Navigation_Page) {
+                return $this->getParent()->getAclEdit();
+            } else {
+                return array();
+            }
+        }
+        return explode(',', $this->_aclEdit);
+    }
+
+    public function setAclEdit($aclEdit)
+    {
+        $this->_aclEdit = $aclEdit;
+        return $this;
+    }
+
+    public function getMenu()
+    {
+        return $this->_menu;
+    }
+
+    public function setMenu($_menu)
+    {
+        $this->_menu = $_menu;
+        return $this;
+    }
+
+    public function getSitemap()
+    {
+        return $this->_sitemap;
+    }
+
+    public function setSitemap($_sitemap)
+    {
+        $this->_sitemap = $_sitemap;
+        return $this;
+    }
+
+    public function getEditable()
+    {
+        return $this->_editable;
+    }
+
+    public function setEditable($_editable)
+    {
+        $this->_editable = $_editable;
+        return $this;
+    }
+
+    public function isEditable()
+    {
+        return $this->getEditable();
+    }
+
+    public function getName()
+    {
+        return $this->_name;
+    }
+
+    public function setName($_name)
+    {
+        $this->_name = $_name;
+        return $this;
+    }
+
+    public function getController()
+    {
+        return $this->_controller;
+    }
+
+    public function setController($_controller)
+    {
+        $this->_controller = $_controller;
+
+        return $this;
+    }
+
+    public function getAction()
+    {
+        return $this->_action;
+    }
+
+    public function setAction($_action)
+    {
+        $this->_action = $_action;
+        return $this;
+    }
+
+    public function getParams()
+    {
+        return $this->_params;
+    }
+
+    public function setParams($_params)
+    {
+        $this->_params = $_params;
+        return $this;
+    }
+
+    /**
+     * @return bool
+     */
+    public function getHidden()
+    {
+        return $this->_hidden;
+    }
+
+    /**
+     * @param bool $hidden
+     * @return self
+     */
+    public function setHidden($hidden)
+    {
+        $this->_hidden = $hidden;
+        if ($hidden) {
+            $this->setCustomHtmlAttrib('data-hidden', '1');
+        } else {
+            $this->removeCustomHtmlAttrib('data-hidden');
+        }
+        return $this;
+    }
+
+    public function getPageId()
+    {
+        return $this->getId();
+    }
+
+    public function getFirstEditablePageId()
+    {
+        if ($this->isEditable()) {
+            return $this->getPageId();
+        }
+        if ($this->getParent() instanceof CubeIT_Navigation_Page) {
+            return $this->getParent()->getFirstEditablePageId();
+        }
+        return null;
+    }
+
+    /**
+     *
+     * @return array
+     */
+    public function getContents()
+    {
+        profile(__FILE__, __LINE__, 'Get page contents');
+        $form = $this->getFormInstance();
+        if (is_null($form)) {
+            return null;
+        }
+        $res = array();
+
+        profile(__FILE__, __LINE__, 'Get static values');
+        foreach ($form->getStaticValues() as $key => $value) {
+            $res[$key] = $value;
+        }
+
+        profile(__FILE__, __LINE__, 'Get dynamic values');
+        foreach ($form as $element) {
+            $k = $element->getName();
+            $v = $form->getValue($k);
+
+            $res[$k] = $v;
+        }
+
+
+        return $res;
+    }
+
+    /**
+     * @return CubeIT_Form_CMS
+     */
+    public function getFormInstance()
+    {
+        if ($this instanceof CubeIT_Navigation_Page_Locale) {
+            $locale = $this->getLocale();
+//            $cacheId = 'form_instance_' . $locale . '_' . sha1($this->getFinalUri());
+//        } else {
+        }
+//            $cacheId = 'form_instance_' . sha1($this->getFinalUri());
+//        }
+//        if (Bootstrap::getInstance()->isAllowed('administration')) {
+//            $cacheId .= '_admin';
+//        }else{
+//            $cacheId .= '_user';
+//        }
+
+        $bootstrap = Bootstrap::getInstance();
+//        $cache = $bootstrap->getCoreCache();
+//        if (!($form = $cache->load($cacheId))) {
+            profile(__FILE__, __LINE__, 'Get form instance::init');
+
+            $db = $bootstrap->getDb();
+            if ($this->getTemplate() == '') {
+                profile(__FILE__, __LINE__, 'Get form instance::no template');
+                $parent = $this->getParent();
+                if ($parent instanceof CubeIT_Navigation_Page) {
+                    return $parent->getFormInstance($db);
+                }
+                return new CubeIT_Form_CMS();
+            }
+
+            profile(__FILE__, __LINE__, 'Get form instance::find class name');
+            $suffix = "_Form_CMS_";
+            $e = explode('_', $this->getTemplate());
+            foreach ($e as  $v) {
+                $suffix .= ucfirst($v);
+            }
+
+            $prefixs = array($bootstrap->getAppNamespace(), 'CubeIT');
+            /* @var $form CubeIT_Form_CMS */
+            foreach ($prefixs as $p) {
+                $class = $p . $suffix;
+                if (class_exists($class, true)) {
+                    profile(__FILE__, __LINE__, 'Get form instance::instanciate ' . $class);
+                    $form = new $class();
+                    break;
+                }
+            }
+
+            if (!isset($form) || is_null($form) || !$form) {
+                return null;
+            }
+
+            if (!is_null($db)) {
+                profile(__FILE__, __LINE__, 'Get form instance::get data');
+                if ($this instanceof CubeIT_Navigation_Page_Locale) {
+                    $form->setLocale($locale);
+                }
+                $form->setVariant($this->getVariant());
+                $form->setPageId($this->getPageId());
+                $form->loadDatasFromDatabase($db);
+            }
+  //          $cache->save($form, $cacheId, ['contents', 'forms']);
+  //      }
+
+        return $form;
+    }
+
+    public function saveContents($data, $skipConsistencyChecks = false)
+    {
+        $subtree = array($data['id']);
+        $it = new RecursiveIteratorIterator($this, RecursiveIteratorIterator::CHILD_FIRST);
+        foreach ($it as $sub) {
+            if ($sub instanceof CubeIT_Navigation_Page && $sub->isEditable()) {
+                $subtree[] = $sub->getPageId();
+            }
+        }
+        $subtree = array_unique($subtree);
+
+        $form = $this->getFormInstance();
+        $form->setDefaults($data);
+
+        if (!$skipConsistencyChecks) {
+            // If the form supports it, do extra consistency checks on it before saving
+            if ($form instanceof CubeIT_Form_CMSBase) {
+
+                if (!$form->canBeSaved()) {
+                    fb('saveContents() aborted due to consistency check failure...');
+                    return false;
+                }
+            }
+        }
+
+        $db = Bootstrap::getInstance()->getDb();
+
+        // Get the list of existing datas
+        $exists = array();
+        $rows = $db->select()->from('cubeit_content')->query()->fetchAll();
+        foreach ($rows as $r) {
+            $exists[$r->locale][$r->id][$r->label][$r->variant] = true;
+        }
+
+        $toInsert = array();
+
+        foreach ($form->getValues() as $k => $v) {
+            $propagatelocale = isset($data['propagatelocale'][$k]) && $data['propagatelocale'][$k] == 1;
+            $propagatesubtree = isset($data['propagatesubtree'][$k]) && $data['propagatesubtree'][$k] == 1;
+
+            if ($k == 'id' || $k == 'locale' || $k == 'variant') {
+                continue;
+            }
+
+            if (is_array($v) || is_object($v)) {
+                if (isset($v['cubeitbase'])) {
+                    unset($v['cubeitbase']);
+                    $v = json_encode(array_values($v));
+                } else {
+                    $v = json_encode($v);
+                }
+            }
+
+            if ($propagatelocale) {
+                $localesToPropagate = Bootstrap::getInstance()->getAppLocales();
+            } else {
+                $localesToPropagate = array($data['locale']);
+            }
+
+            if ($propagatesubtree) {
+                $idsToPropagate = $subtree;
+            } else {
+                $idsToPropagate = array($data['id']);
+            }
+
+            foreach ($localesToPropagate as $locale) {
+                foreach ($idsToPropagate as $id) {
+                    $toInsert[] = array('label' => $k, 'content' => $v, 'id' => $id, 'locale' => $locale, 'variant' => $data['variant']);
+                }
+            }
+        }
+
+        foreach ($toInsert as $datas) {
+
+            try {
+                if (!isset($exists[$datas['locale']][$datas['id']][$datas['label']][$datas['variant']])) {
+                    $exists[$datas['locale']][$datas['id']][$datas['label']][$datas['variant']] = true;
+                    $db->insert('cubeit_content', $datas);
+                } else {
+                    $where = $db->quoteInto('locale = ?', $datas['locale']);
+                    $where .= ' AND ' . $db->quoteInto('id = ?', $datas['id']);
+                    $where .= ' AND ' . $db->quoteInto('label = ?', $datas['label']);
+                    $where .= ' AND ' . $db->quoteInto('variant = ?', $datas['variant']);
+
+                    $db->update('cubeit_content', $datas, $where);
+                }
+            } catch (Exception $e) {
+
+            }
+        }
+    }
+
+    /**
+     *
+     * @param string $uri
+     * @param Zend_Db_Adapter_Abstract $db
+     * @return Zend_Navigation_Page
+     */
+    public function findOneByFormerUri($uri, Zend_Db_Adapter_Abstract $db = null)
+    {
+        if (is_null($db)) {
+            $db = Bootstrap::getInstance()->getDb();
+        }
+        $r = $db->select()->from('cubeit_url')->where('uri = ?', $uri)->query()->fetch();
+        die($r->id);
+
+        if (!is_null($r) && is_object($r)) {
+            return $this->findOneBy('id', $r->id);
+        }
+        return null;
+    }
+
+    /**
+     * @return int
+     */
+    public function getLevel()
+    {
+        $level = 0;
+        $page = $this;
+        while ($page instanceof Zend_Navigation_Page && !is_null($page->getParent())) {
+            $page = $page->getParent();
+            $level++;
+        }
+        return $level;
+    }
+
+    /**
+     *
+     * @param int $level
+     * @return Zend_Navigation_Page
+     */
+    public function getParentAt($level)
+    {
+        $page = $this;
+
+        for ($i = $this->getLevel() - 1; $i > $level; $i--) {
+            $parent = $page->getParent();
+            if (null === $parent) {
+                return $page;
+            }
+            $page = $parent;
+        }
+        return $page;
+    }
+
+    public function getFinalUri()
+    {
+        if (in_array($this->getTemplate(), Bootstrap::getInstance()->_getNextRedirectionTemplates())) {
+            $pages = $this->getPages();
+            foreach ($pages as $p) {
+                return $p->getUri();
+            }
+        } else {
+            $root = $this->getParentAt(-1);
+            $id = $this->_makeFullId($this->getRedirection());
+            $p = $root->findOneById($id);
+            if (null !== $p) {
+                return $p->getUri();
+            }
+        }
+        return $this->getUri();
+    }
+
+    protected function _makeFullId($id)
+    {
+        return trim($id, '/');
+    }
+
+    /**
+     *
+     * @return array
+     */
+    public function getSiblings()
+    {
+        $parent = $this->getParent();
+        return $parent->getPages();
+    }
+
+    /**
+     * @return Zend_Navigation_Page
+     */
+    public function getNextSibling()
+    {
+        $siblings = array_values($this->getSiblings());
+        $k = array_search($this, $siblings, true);
+        if (isset($siblings[$k + 1])) {
+            return $siblings[$k + 1];
+        }
+        return null;
+    }
+
+    /**
+     * @return Zend_Navigation_Page
+     */
+    public function getPrevSibling()
+    {
+        $siblings = array_values($this->getSiblings());
+        $k = array_search($this, $siblings, true);
+        if (isset($siblings[$k - 1])) {
+            return $siblings[$k - 1];
+        }
+        return null;
+    }
+
+    /**
+     * @return Zend_Navigation_Page
+     */
+    public function getFirstChild()
+    {
+        $children = $this->getPages();
+        if (is_null($children)) {
+            return null;
+        }
+        foreach ($children as $child) {
+            return $child;
+        }
+        return null;
+    }
+
+    /**
+     * @return this[]
+     */
+    public function getParents($reverse = false)
+    {
+        $parents = array();
+        $page = $this;
+        while ($page instanceof Zend_Navigation_Page) {
+            $parent = $page->getParent();
+            if (is_null($parent)) {
+                break;
+            }
+            $parents[] = $parent;
+            $page = $parent;
+        }
+        if ($reverse) {
+            $parents = array_reverse($parents);
+        }
+
+        return $parents;
+    }
+
+    /**
+     * return boolean
+     */
+    public function findInParents($key, $value)
+    {
+        $parents = $this->getParents();
+        foreach ($parents as $page) {
+            /* @var $page Zend_Navigation_Page */
+
+            if ($page instanceof Zend_Navigation_Page && $page->get($key) == $value) {
+                return $page;
+            }
+        }
+        return false;
+    }
+
+    public function findClosestBy($key, $value)
+    {
+        $page = $this;
+        while (true) {
+            if (!$page instanceof Zend_Navigation_Page) {
+                return false;
+            }
+            if ($page->get($key) == $value) {
+                return $page;
+            }
+            $page = $page->getParent();
+        }
+    }
+
+    public function setAutoUri($datas, $template, $locale = null)
+    {
+        return $this->setUri(self::generateAutoUri($datas, $template, $locale));
+    }
+
+    public static function generateAutoUri($datas, $template, $locale = null)
+    {
+        self::$_autoUrlDatas = CubeIT_Util_Cms::unserialize($datas, $locale);
+
+        $u = preg_replace_callback('|\%([a-z]+)\%|', array('self', '_replaceAutoUrl'), $template);
+        if (!is_null($locale)) {
+            $domain = Bootstrap::getInstance()->getLocaleDomain($locale);
+            if ($domain['domain']) {
+                $res = '';
+                if ($domain['segment']) {
+                    $res = '/' . $domain['segment'];
+                }
+                $res .= '/' . $u;
+                return $res;
+            } else {
+                return '/' . $locale . '/' . $u;
+            }
+        } else {
+            return $u;
+        }
+    }
+
+    protected static function _replaceAutoUrl($m)
+    {
+
+        $key = $m[1];
+
+        if (is_object(self::$_autoUrlDatas)) {
+            $url = self::$_autoUrlDatas->$key;
+        } else {
+            $url = self::$_autoUrlDatas[$m[1]];
+        }
+
+        return CubeIT_Text::str2URL($url);
+    }
+
+    public function getHref()
+    {
+        $href = parent::getHref();
+        if (CubeIT_Util_Url::isDistant($href) || strpos($href, 'http') === 0) {
+            return $href;
+        }
+        $domain = $this->getDomain();
+        if (!$domain) {
+            return $href;
+        }
+        return SITE_PROTOCOL . $domain . $href;
+    }
+
+    public function getAbsoluteHref()
+    {
+        $href = $this->getHref();
+        if (CubeIT_Util_Url::isDistant($href) || strpos($href, 'http') === 0) {
+            return $href;
+        }
+        return SITE_PROTOCOL . Bootstrap::getInstance()->getOption('webhost') . $href;
+    }
+
+
+    /**
+     * @param $locale
+     * @return $this
+     */
+    public function getLocaleVariant($locale)
+    {
+        return $this;
+    }
+
+    public function isRoot()
+    {
+        return !$this->hasParent();
+    }
+
+    public function hasParent()
+    {
+        return null !== $this->getParent();
+    }
+
+
+    /**
+     * @return CubeIT_Navigation
+     */
+    public function getRoot()
+    {
+        return $this->getParentAt(0)->getParent();
+    }
 }