Beispiel #1
0
 /**
  * Attempt to compare exported ACL setting with the site's existing ACL setting
  *
  * @return string
  */
 public function aclCheckUI()
 {
     $xpath = new DOMXpath($this->doc);
     $parent = $xpath->query('/contenttype');
     $importViewLevels = $xpath->query('/contenttype/viewlevels/viewlevel');
     $importGroups = $xpath->query('/contenttype/groups/group');
     $contentTypeViewLevels = array();
     $contentTypeGroups = array();
     $alteredGroups = array();
     foreach ($importGroups as $importGroup) {
         $group = FabrikContentTypHelper::domNodeAttributesToArray($importGroup);
         $contentTypeGroups[$group['id']] = $group;
     }
     foreach ($importViewLevels as $importViewLevel) {
         $viewLevel = FabrikContentTypHelper::domNodeAttributesToArray($importViewLevel);
         $rules = json_decode($viewLevel['rules']);
         foreach ($rules as &$rule) {
             $rule = array_key_exists($rule, $contentTypeGroups) ? $contentTypeGroups[$rule]['title'] : $rule;
         }
         $viewLevel['rules_labels'] = implode(', ', $rules);
         $contentTypeViewLevels[] = $viewLevel;
     }
     $viewLevels = $this->getViewLevels();
     $groups = $this->getGroups();
     foreach ($viewLevels as &$viewLevel) {
         $rules = json_decode($viewLevel['rules']);
         foreach ($rules as &$rule) {
             $rule = array_key_exists($rule, $groups) ? $groups[$rule]['title'] : $rule;
         }
         $viewLevel['rules_labels'] = implode(', ', $rules);
     }
     foreach ($groups as $group) {
         if (array_key_exists($group['id'], $contentTypeGroups)) {
             $importGroup = $contentTypeGroups[$group['id']];
             if ($group['lft'] !== $importGroup['lft'] || $group['rgt'] !== $importGroup['rgt'] || $group['parent_id'] !== $importGroup['parent_id']) {
                 $alteredGroups[] = $group;
             }
         }
     }
     $layoutData = (object) array('viewLevels' => $viewLevels, 'contentTypeViewLevels' => $contentTypeViewLevels, 'match' => true, 'groups' => $groups, 'importGroups' => $contentTypeGroups, 'alteredGroups' => $alteredGroups);
     try {
         $this->validateViewLevelXML();
     } catch (Exception $e) {
         $layoutData->match = false;
     }
     foreach ($parent as $p) {
         if ($p->getAttribute('ignoreacl') === 'true') {
             $layoutData->match = true;
         }
     }
     $this->checkVersion($xpath, $layoutData);
     $layout = FabrikHelperHTML::getLayout('fabrik-content-type-compare');
     return $layout->render($layoutData);
 }
Beispiel #2
0
 /**
  * Create content type XML from an array of group/element data
  * Used in CSV import
  *
  * @param   array $groupData
  * @param   array $elements
  *
  * @return string
  */
 public function createXMLFromArray($groupData, $elements)
 {
     $contentType = $this->doc->createElement('contenttype');
     $mainTable = $this->listModel->getTable()->get('db_table_name');
     $tables = FabrikContentTypHelper::iniTableXML($this->doc, $mainTable);
     $name = $this->doc->createElement('name', 'tmp');
     $contentType->appendChild($name);
     $contentType->appendChild($this->createFabrikGroupXML($groupData, $elements, $tables));
     $contentType->appendChild($tables);
     $contentType->appendChild($this->createViewLevelXML());
     $contentType->appendChild($this->createGroupXML());
     $this->doc->appendChild($contentType);
     return $this->doc->saveXML();
 }