/**
  * Index action
  */
 function indexAction()
 {
     $filepath = CACHE_DIR . '/analytics/report-' . Fox_Core_Model_Date::getCurrentDate('Y-m-d') . '.xml';
     $xDom = new Uni_Data_XDOMDocument();
     $xDom->load($filepath);
     header('Content-Type: text/xml');
     echo $xDom->saveXML();
 }
 /**
  * Load cache settings
  * @return array
  */
 public static function loadCacheSettings()
 {
     if (!empty(self::$cacheArr)) {
         return self::$cacheArr;
     }
     $cacheDoc = new Uni_Data_XDOMDocument();
     $ds = DIRECTORY_SEPARATOR;
     $cacheSettingsPath = CACHE_DIR . $ds . 'cache.settings';
     if (file_exists($cacheSettingsPath)) {
         $cacheDoc->load($cacheSettingsPath);
         if ($cacheDoc->documentElement->hasChildNodes()) {
             $nodeList = $cacheDoc->documentElement->childNodes;
             foreach ($nodeList as $n) {
                 if ($n->nodeType == XML_ELEMENT_NODE && ($key = $n->getAttribute('key'))) {
                     self::$cacheArr[$key] = $n->nodeValue;
                 }
             }
         }
     } else {
         self::createCacheSettings();
     }
     return self::$cacheArr;
 }
 /**
  * Get Selected tree nodes
  *
  * @return array
  */
 public function getSelectedTreeNodes()
 {
     $treeSelected = array();
     $data = Fox::getModel('extensionmanager/session')->getFormData();
     if (isset($data['content_tree_data']) && $data['content_tree_data']) {
         $treeDom = Uni_Data_XDOMDocument::loadXML($data['content_tree_data']);
         foreach ($treeDom->documentElement->childNodes as $node) {
             if ($node->nodeName == "#text") {
                 continue;
             }
             $treeSelected[] = $node->getAttribute("path");
         }
     }
     return $treeSelected;
 }
 /**
  * Load module settings data
  * 
  * @param boolean $forceCreate
  * @return array 
  */
 public static function loadPreferences($forceCreate = FALSE)
 {
     if (!$forceCreate && !empty(self::$preferences)) {
         self::$preferences;
     }
     $ds = DIRECTORY_SEPARATOR;
     $preferenceFilePath = CACHE_DIR . $ds . Fox_Core_Model_Cache::CACHE_CODE_PREFERENCE;
     $fileName = 'preference.xml';
     self::$preferences = array();
     $xDom = new Uni_Data_XDOMDocument();
     $cacheSettings = Uni_Core_CacheManager::loadCacheSettings();
     $isCacheEnabled = isset($cacheSettings[Fox_Core_Model_Cache::CACHE_CODE_PREFERENCE]) ? $cacheSettings[Fox_Core_Model_Cache::CACHE_CODE_PREFERENCE] : FALSE;
     if ($forceCreate || !$isCacheEnabled || !file_exists($preferenceFilePath . $ds . $fileName)) {
         if (!file_exists($preferenceFilePath)) {
             if (!@mkdir($preferenceFilePath, 0777, TRUE)) {
                 throw new Exception('"' . $preferenceFilePath . '" not found');
             }
         }
         $xDom->preserveWhiteSpace = false;
         $xDom->formatOutput = true;
         $preferenceModel = Fox::getModel('core/preference');
         $collection = $preferenceModel->getCollection();
         $root = $xDom->createElement('preferences');
         foreach ($collection as $preference) {
             self::$preferences[$preference['name']] = $preference['value'];
             $cData = $xDom->createCDATASection('');
             $cData->appendData($preference['value']);
             $entry = $xDom->createElement('entry');
             $entry->setAttribute('key', $preference['name']);
             $root->appendChild($entry);
             $entry->appendChild($cData);
         }
         $xDom->appendChild($root);
         $doc = $xDom->save($preferenceFilePath . $ds . $fileName);
         @chmod($preferenceFilePath, 0777);
     } else {
         $xDom->load($preferenceFilePath . $ds . $fileName);
         if ($xDom->documentElement->hasChildNodes()) {
             $nodeList = $xDom->documentElement->childNodes;
             foreach ($nodeList as $n) {
                 if ($n->nodeType == XML_ELEMENT_NODE && ($key = $n->getAttribute('key'))) {
                     self::$preferences[$key] = $n->nodeValue;
                 }
             }
         }
     }
     unset($xDom);
     return self::$preferences;
 }
 /**
  * Prepares final menu html
  * 
  * @param DOMElement $menu
  */
 protected function getFinalMenuTree($menu)
 {
     if (NULL == $this->mnuPaths) {
         $this->mnuPaths = array();
     }
     $sourceQueue = array(array('menu' => $menu, 'path' => 'root'));
     $targetQueue = array($this->root);
     while (count($sourceQueue) > 0) {
         $mnuItem = array_shift($sourceQueue);
         $menu = $mnuItem['menu'];
         $parentPath = $mnuItem['path'];
         $parent = array_shift($targetQueue);
         if ($mChs = $menu->childNodes) {
             foreach ($mChs as $mCh) {
                 if ($mCh->nodeName == 'item') {
                     if (Fox::getHelper('admin/acl')->isAllowed($mCh->getAttribute('action'))) {
                         $node = Uni_Data_XDOMDocument::createNode('item', array('action' => $mCh->getAttribute('action'), 'order' => ($order = $mCh->getAttribute('order')) ? $order : '0'), $this->finalMenuTree);
                         $node->appendChild($this->finalMenuTree->createTextNode($mCh->nodeValue));
                         $parent->appendChild($node);
                     }
                 } else {
                     if ($mCh->nodeName == 'menu') {
                         $label = $mCh->getAttribute('label');
                         $menuPath = $parentPath . '/' . str_replace('/', '_', $label);
                         if (isset($this->mnuPaths[$menuPath])) {
                             $item = $this->mnuPaths[$menuPath];
                         } else {
                             $item = Uni_Data_XDOMDocument::createNode('menu', array('label' => $label, 'order' => ($order = $mCh->getAttribute('order')) ? $order : '0'), $this->finalMenuTree);
                             $parent->appendChild($item);
                             $this->mnuPaths[$menuPath] = $item;
                         }
                         $targetQueue[] = $item;
                         $sourceQueue[] = array('menu' => $mCh, 'path' => $menuPath);
                     }
                 }
             }
         }
     }
 }
 /**
  * Get menu html
  * 
  * @param string $key Menu group key
  * @return string 
  */
 public function getMenu($key)
 {
     $menuHTML = '';
     $cacheSettings = Uni_Core_CacheManager::loadCacheSettings();
     $isCacheEnabled = isset($cacheSettings[Fox_Core_Model_Cache::CACHE_CODE_LAYOUT]) ? $cacheSettings[Fox_Core_Model_Cache::CACHE_CODE_LAYOUT] : FALSE;
     $package = Fox::getPreference(Uni_Controller_Action::MODE_ADMIN . '/package');
     $theme = Fox::getPreference(Uni_Controller_Action::MODE_ADMIN . '/theme');
     $cacheMenuBasePath = CACHE_DIR . DIRECTORY_SEPARATOR . Fox_Core_Model_Cache::CACHE_CODE_LAYOUT . DIRECTORY_SEPARATOR . Uni_Controller_Action::MODE_WEB . DIRECTORY_SEPARATOR . $package . DIRECTORY_SEPARATOR . $theme . DIRECTORY_SEPARATOR . self::CACHE_MENU_FOLDER;
     file_exists($cacheMenuBasePath) && is_dir($cacheMenuBasePath) || mkdir($cacheMenuBasePath, 0777, TRUE);
     $cacheMenuPath = $cacheMenuBasePath . DIRECTORY_SEPARATOR . $key . '.menu';
     if ($isCacheEnabled && file_exists($cacheMenuPath)) {
         $cacheMenuDoc = new DOMDocument();
         $cacheMenuDoc->loadHTMLFile($cacheMenuPath);
         $menuHTML = $cacheMenuDoc->saveXML();
         unset($cacheMenuDoc);
     } else {
         $menuGroupModel = Fox::getModel('navigation/menugroup');
         $menuGroupModel->load($key, 'key');
         if ($menuGroupModel->getId() && $menuGroupModel->getStatus() == Fox_Navigation_Model_Menugroup::STATUS_ENABLED) {
             $menuModel = Fox::getModel('navigation/menu');
             $menuList = $menuModel->getMenuItemsByGroup($key);
             $mnuDoc = new DOMDocument();
             $mnuDoc->formatOutput = true;
             $mnuRoot = NULL;
             if (count($menuList)) {
                 $mnuRoot = Uni_Data_XDOMDocument::createNode(self::ROOT_TAG, array('class' => 'menu_container'), $mnuDoc);
                 $mnuDoc->appendChild($mnuRoot);
                 foreach ($menuList as $menu) {
                     $node = Uni_Data_XDOMDocument::createNode(self::LEAF_TAG, array('class' => 'menu_nav' . ($menu['style_class'] ? ' ' . $menu['style_class'] : '')), $mnuDoc);
                     if (strpos($menu['link'], 'http://', 0) === 0 || strpos($menu['link'], 'https://', 0) === 0) {
                         $link = $menu['link'];
                     } else {
                         $link = Fox::getUrl($menu['link']);
                     }
                     $link = Uni_Data_XDOMDocument::createNode('a', array('href' => $link, 'target' => $menu['open_window'], 'class' => $menu['style_class']), $mnuDoc);
                     $link->appendChild($mnuDoc->createTextNode($menu['title']));
                     $node->appendChild($link);
                     $mnuRoot->appendChild($node);
                 }
             }
             if (isset($mnuDoc)) {
                 $menuHTML = $mnuDoc->saveXML($mnuRoot);
                 if ($isCacheEnabled) {
                     $mnuDoc->saveHTMLFile($cacheMenuPath);
                     @chmod($cacheMenuPath, 0777);
                 }
             }
             unset($mnuDoc);
         }
     }
     return $menuHTML;
 }
 /**
  * Uninstall package
  * 
  * @param string $key valid package key
  */
 public function uninstallPackage($key)
 {
     $config = $this->getConfig();
     if (!file_exists($config->getInstalledPkgPath() . DS . $key . '.xml')) {
         throw new Exception("Installation not found.");
     }
     $this->setStatus(Fox_Extensionmanager_Model_Package_Status::UNINSTALLING);
     $packageXml = $config->getInstalledPkgPath() . DS . $key . '.xml';
     $document = new Uni_Data_XDOMDocument();
     $document->load($packageXml);
     /*removing package files*/
     $xpath = new DomXpath($document);
     foreach ($xpath->query('//item[@rel="file"]') as $file) {
         $filePath = Fox::getDirectoryPath() . $file->getAttribute("path");
         if (file_exists($filePath) && !is_dir($filePath)) {
             try {
                 @unlink($filePath);
             } catch (Exception $e) {
             }
         }
     }
     /*listing directories to remove*/
     $dirs = array();
     foreach ($xpath->query('//item[@rel="dir"]') as $file) {
         $dirPath = Fox::getDirectoryPath() . $file->getAttribute("path");
         if (file_exists($dirPath) && is_dir($dirPath)) {
             try {
                 $dirs[] = $dirPath;
             } catch (Exception $e) {
             }
         }
     }
     /*removing empty directories in $dir list*/
     if ($dirs) {
         $dirs = array_reverse($dirs);
         foreach ($dirs as $dir) {
             @rmdir($dir);
         }
     }
     /*removing package from installed directory*/
     @unlink($packageXml);
     $this->clearCache();
     $this->setStatus(Fox_Extensionmanager_Model_Package_Status::UNINSTALLED);
 }
 /**
  * Loades layout defined for particular action
  *
  * @param string $layoutUpdate
  * @param string $updateKey 
  * @return void
  */
 public function load($layoutUpdate = NULL, $updateKey = NULL)
 {
     $this->finalLayout = new Uni_Data_XDOMDocument();
     $this->finalLayout->preserveWhiteSpace = FALSE;
     $this->finalLayout->formatOutput = TRUE;
     $ds = DIRECTORY_SEPARATOR;
     $debug = FALSE;
     if (Uni_Core_Installer::isInstalled()) {
         $cacheSettings = Uni_Core_CacheManager::loadCacheSettings();
         $isCacheEnabled = isset($cacheSettings[Fox_Core_Model_Cache::CACHE_CODE_LAYOUT]) ? $cacheSettings[Fox_Core_Model_Cache::CACHE_CODE_LAYOUT] : FALSE;
         $cacheLayoutBasePath = CACHE_DIR . $ds . Fox_Core_Model_Cache::CACHE_CODE_LAYOUT . $ds . $this->mode . $ds . $this->package . $ds . $this->theme;
         file_exists($cacheLayoutBasePath) && is_dir($cacheLayoutBasePath) || @mkdir($cacheLayoutBasePath, 0777, TRUE);
         $cacheLayoutPath = $cacheLayoutBasePath . $ds . strtolower($this->module) . '_' . strtolower($this->controller) . '_' . strtolower($this->action) . (isset($updateKey) ? '_' . urlencode($updateKey) : '') . '.lxml';
     } else {
         $isCacheEnabled = FALSE;
     }
     if (!$isCacheEnabled || $isCacheEnabled && !file_exists($cacheLayoutPath)) {
         $debug || ob_start();
         $this->layout = new Uni_Core_Layout();
         $this->layout->init();
         $lPaths[] = 'application' . $ds . 'views' . $ds . $this->mode . $ds . $this->package . $ds . $this->theme . $ds . 'layout';
         $lPaths[] = 'application' . $ds . 'views' . $ds . $this->mode . $ds . $this->defaultPackage . $ds . $this->defaultTheme . $ds . 'layout';
         $loadLayout = FALSE;
         foreach ($lPaths as $lBPath) {
             if (file_exists($lBPath . $ds . 'fox.xml')) {
                 $lDPath = $lBPath . $ds . 'fox.xml';
                 break;
             }
         }
         if (isset($lDPath)) {
             $this->xDomFox = new Uni_Data_XDOMDocument();
             $this->xDomFox->load($lDPath);
         } else {
             throw new Exception('Layout not found "' . $lDPath . '"');
         }
         $this->layout->setLayout($this->xDomFox);
         /*             * **************Parsing default Section from all other layouts************** */
         $modules = array_keys(Uni_Fox::getModules());
         foreach ($modules as $module) {
             if ($module != $this->module) {
                 foreach ($lPaths as $lBPath) {
                     if (file_exists($lBPath . $ds . lcfirst($module) . '.xml')) {
                         $lPath = $lBPath . $ds . lcfirst($module) . '.xml';
                         break;
                     }
                 }
                 if (isset($lPath)) {
                     $mLXmlDoc = new Uni_Data_XDOMDocument();
                     $mLXmlDoc->load($lPath);
                     $xpMLXmlDoc = new DOMXPath($mLXmlDoc);
                     $defMLXml = $xpMLXmlDoc->query('/' . self::ROOT . '/global');
                     if ($defMLXml->length > 0) {
                         $this->layout->mergeLayout($defMLXml->item(0), TRUE);
                         $this->layout->showXML();
                     }
                     unset($lPath);
                 }
             }
         }
         foreach ($lPaths as $lBPath) {
             if (file_exists($lBPath . $ds . lcfirst($this->module) . '.xml')) {
                 $lPath = $lBPath . $ds . lcfirst($this->module) . '.xml';
                 break;
             }
         }
         if (isset($lPath)) {
             $this->xDomMain = new Uni_Data_XDOMDocument();
             $this->xDomMain->load($lPath);
         } else {
             throw new Exception('Layout not found "' . $lPath . '"');
         }
         $xpMain = new DOMXPath($this->xDomMain);
         $defGlobal = $xpMain->query('/' . self::ROOT . '/global');
         if ($defGlobal->length > 0) {
             $this->layout->mergeLayout($defGlobal->item(0), TRUE);
         }
         $defMain = $xpMain->query('/' . self::ROOT . '/default');
         if ($defMain->length > 0) {
             $this->layout->mergeLayout($defMain->item(0), TRUE);
         }
         $actMain = $xpMain->query('/' . self::ROOT . '/' . $this->controller . '_' . $this->action);
         if ($actMain->length > 0) {
             $this->layout->mergeLayout($actMain->item(0), TRUE);
         }
         if (isset($layoutUpdate) && isset($updateKey)) {
             $domUpdate = new Uni_Data_XDOMDocument();
             if (!$domUpdate->loadXML('<layout>' . $layoutUpdate . '</layout>')) {
             }
             $this->layout->mergeLayout($domUpdate->documentElement, TRUE);
         }
         $this->layout->prepareHead();
         $this->layout->showXML();
         $this->finalLayout->loadXML($this->layout->saveXML());
         if ($isCacheEnabled) {
             $this->finalLayout->save($cacheLayoutPath);
             @chmod($cacheLayoutPath, 0777);
         }
         unset($this->layout);
         $debug || ob_clean();
     } else {
         if (file_exists($cacheLayoutPath)) {
             $this->finalLayout->load($cacheLayoutPath);
         }
     }
     $this->parse($this->finalLayout);
 }
 /**
  * @return string the XML, or false if an error occurred
  */
 function getMenuMarkup()
 {
     $menuQueue = array();
     $menuTree = new Uni_Data_XDOMDocument();
     $root = Uni_Data_XDOMDocument::createNode('div', array('id' => 'setting-menu', 'class' => 'accordion'), $menuTree);
     $xPath = new DOMXPath($this->finalMenuTree);
     $menus = $xPath->query('/settings/menu');
     $menus = $this->getSortedNodes($menus);
     foreach ($menus as $menu) {
         $h3 = Uni_Data_XDOMDocument::createNode('h3', array('class' => 'accordion-header'), $menuTree);
         $a = Uni_Data_XDOMDocument::createNode('a', array('href' => '#'), $menuTree);
         $a->appendChild($menuTree->createTextNode($menu->getAttribute('label')));
         $h3->appendChild($a);
         $div = Uni_Data_XDOMDocument::createNode('div', array('class' => 'accordion-content'), $menuTree);
         $ul = Uni_Data_XDOMDocument::createNode('ul', NULL, $menuTree);
         $div->appendChild($ul);
         $root->appendChild($h3);
         $root->appendChild($div);
         $menuQueue[$menu->getAttribute('name')] = $ul;
     }
     $items = $xPath->query('/settings/item');
     $items = $this->getSortedNodes($items);
     foreach ($items as $item) {
         $li = Uni_Data_XDOMDocument::createNode('li', NULL, $menuTree);
         $a = Uni_Data_XDOMDocument::createNode('a', array('href' => Fox::getUrl('admin/system_setting/edit', array('item' => $item->getAttribute('name'), 'lbl' => urlencode($item->getAttribute('label'))))), $menuTree);
         $a->appendChild($menuTree->createTextNode($item->getAttribute('label')));
         $li->appendChild($a);
         if ($parent = $menuQueue[$item->getAttribute('menu')]) {
             $parent->appendChild($li);
         }
     }
     return $menuTree->saveXML($root);
 }
 /**
  * Generate package compressed file
  * 
  * @return bool
  */
 public function generate()
 {
     $data = $this->getSession()->getFormData();
     $conf = $this->getConfig()->getConfiguration();
     if (!($data && isset($data["name"]) && $data["name"])) {
         throw new Exception("No package loaded.");
     }
     $path = $this->getGeneratedPkgCompressedDir();
     if (!file_exists($path)) {
         mkdir($path, 0777, true);
     }
     $pkgFileName = $path . DS . str_replace(' ', '_', $data["name"]) . '-' . $data["version"] . '.zip';
     if (!extension_loaded('zip')) {
         throw new Exception("Extension zip is not loaded.");
     }
     /* Opening zip file */
     $zip = new ZipArchive();
     if (!$zip->open($pkgFileName, ZIPARCHIVE::CREATE)) {
         return false;
     }
     $treeDom = Uni_Data_XDOMDocument::loadXML($data["content_tree_data"]);
     foreach ($treeDom->documentElement->childNodes as $target) {
         $this->zipIt($zip, $target->getAttribute("path"));
     }
     $pkgXml = str_replace('\\', DS, realpath($this->getGeneratedPkgDir() . DS . str_replace(' ', '_', $data["name"]) . '-' . $data["version"] . '.xml'));
     $zip->addFromString($conf->package_file, file_get_contents($pkgXml));
     @chmod($pkgFileName, 0777);
     $zip->close();
     return true;
 }
 /**
  * Constructs the resources XML and Dumps tree back into a string
  * 
  * @param int $roleId
  * @param int $parentId
  * @return string the XML, or false if an error occurred 
  */
 public function getTreeData($roleId, $parentId = 0)
 {
     $catData = array();
     $model = Fox::getModel('admin/role/resource');
     $roleModel = Fox::getModel('admin/role');
     $roleModel->load($roleId);
     $roleResources = explode(',', $roleModel->getResourceIds());
     $sourceNodes[] = array('id' => $parentId);
     $mnuDoc = new DOMDocument();
     $mnuRoot = Uni_Data_XDOMDocument::createNode('root', array(), $mnuDoc);
     $mnuDoc->appendChild($mnuRoot);
     while (count($sourceNodes) > 0) {
         $parentData = array_pop($sourceNodes);
         $parentId = $parentData['id'];
         $rootNodes = $this->getCollection("parent_id={$parentId}", '*', 'sort_order ASC');
         foreach ($rootNodes as $rootNode) {
             $itemNode = Uni_Data_XDOMDocument::createNode('item', array('id' => $rootNode['access_all'] == 1 ? $rootNode['resource_ids'] : 'cat_' . $rootNode['id'], 'parent_id' => isset($parentData['treeId']) ? $parentData['treeId'] : 0, 'rel' => 'resource_category', 'state' => 'open'), $mnuDoc);
             $contentNode = Uni_Data_XDOMDocument::createNode('content', array(), $mnuDoc);
             $dataNode = Uni_Data_XDOMDocument::createNode('name', array(), $mnuDoc);
             $dataNode->appendChild($mnuDoc->createTextNode($rootNode['name']));
             $contentNode->appendChild($dataNode);
             $itemNode->appendChild($contentNode);
             $mnuRoot->appendChild($itemNode);
             if ($rootNode['resource_ids']) {
                 $resourceCollection = $model->getCollection('id IN(' . $rootNode['resource_ids'] . ') AND display_in_tree=1', '*', 'sort_order ASC');
                 foreach ($resourceCollection as $resource) {
                     $itemNode = Uni_Data_XDOMDocument::createNode('item', array('id' => $resource['id'], 'rel' => 'resource', 'parent_id' => $rootNode['access_all'] == 1 ? $rootNode['resource_ids'] : 'cat_' . $rootNode['id'], 'state' => 'open'), $mnuDoc);
                     $contentNode = Uni_Data_XDOMDocument::createNode('content', array(), $mnuDoc);
                     $dataNode = Uni_Data_XDOMDocument::createNode('name', array(), $mnuDoc);
                     $dataNode->appendChild($mnuDoc->createCDATASection($resource['resource_path']));
                     $contentNode->appendChild($dataNode);
                     $itemNode->appendChild($contentNode);
                     $mnuRoot->appendChild($itemNode);
                 }
             }
             array_push($sourceNodes, array('id' => $rootNode['id'], 'treeId' => $rootNode['access_all'] == 1 ? $rootNode['resource_ids'] : 'cat_' . $rootNode['id']));
         }
     }
     return $mnuDoc->saveXML($mnuRoot);
 }
 /**
  * Writes xml data to cache file
  *
  * @param array $dataArray
  */
 public function writeData($dataArray)
 {
     $filePath = $this->getReportsFilePath();
     $xDom = new Uni_Data_XDOMDocument();
     $xDom->preserveWhiteSpace = FALSE;
     $xDom->formatOutput = TRUE;
     $root = $xDom->createElement('root');
     foreach ($dataArray as $key => $value) {
         $info = $xDom->createElement('record');
         foreach ($value as $name => $values) {
             if ($name == 'value') {
                 $info->setAttribute('date', $values);
             } else {
                 $detail = $xDom->createElement($name, $values);
                 $info->appendChild($detail);
             }
         }
         $root->appendChild($info);
     }
     $xDom->appendChild($root);
     $xDom->save($filePath);
 }
 /**
  * Parses XML Layout files used to configure and render views
  *
  * @param DOMElement $ele
  * @param boolean $updateContainer 
  * @return void
  */
 private function parse(DOMElement $ele, $updateContainer)
 {
     $this->eleStack = array($ele);
     if (empty($this->eleList)) {
         $this->eleList = array('root' => $this->root);
     }
     for ($i = 0; count($this->eleStack) > 0; $i++) {
         $cont = TRUE;
         $node = array_shift($this->eleStack);
         if ($pKey = $node->getAttribute('key')) {
             if (!array_key_exists($pKey, $this->eleList)) {
                 $cont = FALSE;
             }
         } else {
             $pKey = 'root';
         }
         if ($cont) {
             $parent = $this->eleList[$pKey];
             if ($node->hasChildNodes()) {
                 $nList = $node->childNodes;
                 $tempQ = array();
                 foreach ($nList as $n) {
                     if ($n->nodeName == Uni_Core_LayoutManager::VIEW) {
                         $cpNode = Uni_Data_XDOMDocument::createNodeIn($n, $this);
                         $parent->appendChild($cpNode);
                         if ($key = $cpNode->getAttribute('key')) {
                             if (array_key_exists($key, $this->eleList)) {
                                 throw new Exception('Duplicte key was found:"' . $key . '"');
                             }
                             $tempQ[$key] = $n;
                             $this->eleList[$key] = $cpNode;
                         }
                     } else {
                         if ($updateContainer && $n->nodeName == Uni_Core_LayoutManager::CONTAINER) {
                             if ($n->hasAttributes()) {
                                 $nKey = $n->attributes->getNamedItem('key');
                                 if ($nKey) {
                                     $this->setContainer($this->defContainer[$nKey->nodeValue]);
                                 }
                             }
                         } else {
                             if ($n->nodeName == Uni_Core_LayoutManager::HEAD) {
                                 $this->parseHead($n);
                             } else {
                                 if ($n->nodeName == self::REF && ($key = $n->getAttribute('key'))) {
                                     $tempQ[] = $n;
                                 } else {
                                     if ($n->nodeName == self::REMOVE && ($key = $n->getAttribute('key'))) {
                                         if (array_key_exists($key, $this->eleList)) {
                                             try {
                                                 $parent->removeChild($this->eleList[$key]);
                                                 unset($this->eleList[$key]);
                                                 if (array_key_exists($key, $tempQ)) {
                                                     unset($tempQ[$key]);
                                                 }
                                             } catch (Exception $e) {
                                             }
                                         } else {
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 $this->eleStack = array_merge($this->eleStack, array_values($tempQ));
             }
         }
     }
 }