Пример #1
0
 public static function import($xml_file, $import_frontpage = true, $frontpage_params = array(), $import_categories = true, $category_params = array(), $element_assignment = array(), $types = array())
 {
     if ($xml = YXML::loadFile($xml_file)) {
         // get application
         if ($application = Zoo::getApplication()) {
             // import frontpage
             if ($import_frontpage) {
                 self::_importFrontpage($application, $xml->getElementByPath('categories/category[@id="_root"]'), $frontpage_params);
             }
             // import categories
             if ($import_categories) {
                 $categories = self::_importCategories($application, $xml->getElementsByPath('categories/category[not(@id="_root")]'), $category_params);
             }
             // import items
             $items = self::_importItems($application, $xml->items, $element_assignment, $types);
             // save item -> category relationship
             if ($import_categories) {
                 foreach ($items as $item) {
                     $values = array();
                     foreach ($item->categories as $category_alias) {
                         if (isset($categories[$category_alias]) || $category_alias == '_root') {
                             $values[] = $category_alias == '_root' ? 0 : (int) $categories[$category_alias]->id;
                         }
                     }
                     if (!empty($values)) {
                         CategoryHelper::saveCategoryItemRelations($item->id, $values);
                     }
                 }
             }
             return true;
         }
         throw new ImportHelperException('No application to import too.');
     }
     throw new ImportHelperException('No valid xml file.');
 }
Пример #2
0
 public function __construct($path)
 {
     if ($xml = YXML::loadFile($path)) {
         // add other character
         if ($xml->attributes()->other) {
             $this->_other = (string) $xml->attributes()->other;
         }
         // add characters
         foreach ($xml->children() as $option) {
             if (!in_array((string) $option, $this->_index)) {
                 $key = $option->attributes()->value ? (string) $option->attributes()->value : (string) $option;
                 $this->_index[$key] = (string) $option;
             }
         }
     }
 }
Пример #3
0
 public function getLayoutMetaData($layout)
 {
     // init vars
     $metadata = new YArray();
     $parts = explode($this->_separator, $layout);
     $name = array_pop($parts);
     if ($file = JPath::find($this->_getPath(implode(DIRECTORY_SEPARATOR, $parts)), $this->_metafile)) {
         if ($xml = YXML::loadFile($file)) {
             foreach ($xml->children() as $child) {
                 $attributes = $child->attributes();
                 if ($child->getName() == 'layout' && (string) $attributes->name == $name) {
                     foreach ($attributes as $key => $attribute) {
                         $metadata[$key] = (string) $attribute;
                     }
                     $metadata['layout'] = $layout;
                     $metadata['name'] = (string) $child->name;
                     $metadata['description'] = (string) $child->description;
                     break;
                 }
             }
         }
     }
     return $metadata;
 }
Пример #4
0
 public function getPositions($dir)
 {
     // init vars
     $positions = array();
     $parts = explode('.', $dir);
     $layout = array_pop($parts);
     $path = implode('/', $parts);
     // parse positions xml
     if ($xml = YXML::loadFile(JPath::find($this->_getPath($path), $this->_xml_file))) {
         foreach ($xml->children() as $pos) {
             if ((string) $pos->attributes()->layout == $layout) {
                 $positions['name'] = $layout;
                 foreach ($pos->children() as $child) {
                     if ($child->getName() == 'name') {
                         $positions['name'] = (string) $child;
                     }
                     if ($child->getName() == 'position') {
                         if ($child->attributes()->name) {
                             $name = (string) $child->attributes()->name;
                             $positions['positions'][$name] = (string) $child;
                         }
                     }
                 }
                 break;
             }
         }
     }
     return $positions;
 }
Пример #5
0
 public function getMetaXML()
 {
     if (empty($this->_metaxml)) {
         $this->_metaxml = YXML::loadFile($this->getPath() . '/' . $this->getElementType() . '.xml');
     }
     return $this->_metaxml;
 }
Пример #6
0
                if ($description = $metadata->get('description')) {
                    $link = '<span class="editlinktip hasTip" title="' . $metadata->get('name', $layout) . '::' . $description . '">' . $link . '</span>';
                }
                $links[] = $link;
            }
            echo implode(' | ', $links);
            echo '</div>';
        }
        ?>
			</td>
			<td class="plugin">
				<?php 
        foreach ($this->plugins as $plugin_type => $plugins) {
            foreach ($plugins as $plugin) {
                $plugin_name = $plugin['name'];
                if (($xml = YXML::loadFile(dirname($plugin['path']) . DIRECTORY_SEPARATOR . $plugin['name'] . '.xml')) && $xml->getName() == 'install') {
                    $plugin_name = (string) $xml->getElementByPath('name');
                }
                echo '<div>' . $plugin_name . ': ';
                $renderer = new YRenderer();
                $renderer->addPath($plugin['path']);
                $links = array();
                foreach ($renderer->getLayouts('item') as $layout) {
                    // get layout metadata
                    $metadata = $renderer->getLayoutMetaData("item.{$layout}");
                    // create link
                    $link = '<a href="' . JRoute::_($this->baseurl . '&task=assignelements&type=' . $type->id . '&plugin=' . $plugin_type . '/' . $plugin['name'] . '&layout=' . $layout) . '">' . $metadata->get('name', $layout) . '</a>';
                    // create tooltip
                    if ($description = $metadata->get('description')) {
                        $link = '<span class="editlinktip hasTip" title="' . $metadata->get('name', $layout) . '::' . $description . '">' . $link . '</span>';
                    }
Пример #7
0
 public function getMetaXML()
 {
     if (empty($this->_metaxml)) {
         $this->_metaxml = YXML::loadFile($this->getMetaXMLFile());
     }
     return $this->_metaxml;
 }
Пример #8
0
 public static function findManifest($path)
 {
     $path = rtrim($path, "\\/") . '/';
     foreach (YFile::readDirectoryFiles($path, $path, '/\\.xml$/', false) as $file) {
         if (($xml = YXML::loadFile($file)) && self::isManifest($xml)) {
             return $xml;
         }
     }
     return false;
 }