Example #1
0
 public function export()
 {
     if (!($this->_application = Zoo::getApplication())) {
         throw new ExportHelperException('No application selected.');
     }
     // export frontpage
     $frontpage = new Category();
     $frontpage->name = 'Root';
     $frontpage->alias = '_root';
     $frontpage->description = $this->_application->description;
     // export categories
     $categories = $this->_application->getCategories();
     $categories[0] = $frontpage;
     foreach ($categories as $category) {
         $this->_addCategory($this->_categoryToXML($category, $categories));
     }
     $this->categories = $categories;
     // export items
     $types = $this->_application->getTypes();
     $item_table = YTable::getInstance('item');
     foreach ($types as $type) {
         $items = $item_table->getByType($type->id, $this->_application->id);
         foreach ($items as $key => $item) {
             $this->_addItem($type->name, $this->_itemToXML($item));
             $item->unsetElementData();
             unset($items[$key]);
         }
     }
     return parent::export();
 }
Example #2
0
 public function export()
 {
     $db = YDatabase::getInstance();
     $query = "SELECT * FROM #__sections" . " WHERE scope='content'";
     $sections = $db->queryObjectList($query);
     // get category table
     $category_table = YTable::getInstance('category');
     // get item table
     $item_table = YTable::getInstance('item');
     // get image path
     $image_path = JComponentHelper::getParams('com_media')->get('image_path');
     foreach ($sections as $section) {
         $attributes = array();
         foreach (self::$category_attributes as $attribute) {
             if (isset($section->{$attribute})) {
                 $attributes[$attribute] = $section->{$attribute};
             }
         }
         $category_xml = $this->_buildCategory($section->alias, $section->title, $attributes);
         if ($section->image) {
             $this->_attachCategoryImage($category_xml, $image_path . '/' . $section->image, 'Image');
         }
         $this->_addCategory($category_xml);
         $query = "SELECT * FROM #__categories WHERE section = " . $section->id;
         $joomla_categories = $db->queryObjectList($query);
         foreach ($joomla_categories as $joomla_category) {
             $attributes = array();
             foreach (self::$category_attributes as $attribute) {
                 if (isset($joomla_category->{$attribute})) {
                     $attributes[$attribute] = $joomla_category->{$attribute};
                 }
             }
             $attributes['parent'] = $section->alias;
             $category_xml = $this->_buildCategory($joomla_category->alias, $joomla_category->title, $attributes);
             if ($joomla_category->image) {
                 $this->_attachCategoryImage($category_xml, $image_path . '/' . $joomla_category->image, 'Image');
             }
             $this->_addCategory($category_xml);
             $query = "SELECT * FROM #__content WHERE catid =" . $joomla_category->id;
             $articles = $db->queryObjectList($query);
             foreach ($articles as $article) {
                 if ($article->state != -2) {
                     $this->_addItem(JText::_('Joomla article'), $this->_articleToXML($article, $joomla_category->alias));
                 }
             }
         }
     }
     $query = "SELECT * FROM #__content WHERE catid = 0";
     $articles = $db->queryObjectList($query);
     foreach ($articles as $article) {
         if ($article->state != -2) {
             $this->_addItem(JText::_('Joomla article'), $this->_articleToXML($article, 0));
         }
     }
     return parent::export();
 }
Example #3
0
 public function export()
 {
     $db = YDatabase::getInstance();
     $user = JFactory::getUser();
     // get mtree categories
     $query = "SELECT *" . ", cat_parent as parent" . ", cat_created as created" . ", cat_published as published" . ", cat_name as name" . ", cat_desc as description" . ", cat_image as image" . " FROM #__mt_cats" . " WHERE cat_id != 0" . " ORDER BY cat_parent, ordering";
     $categories = $db->queryObjectList($query, 'cat_id');
     // get category table
     $category_table = YTable::getInstance('category');
     // get item table
     $item_table = YTable::getInstance('item');
     // sanatize category aliases
     $aliases = array();
     foreach ($categories as $category) {
         $i = 2;
         $alias = YString::sluggify($category->alias);
         if (empty($alias)) {
             $alias = YString::sluggify($category->name);
         }
         $category->alias = $alias;
         while (in_array($alias, $aliases)) {
             $alias = $category->alias . '-' . $i++;
         }
         $category->alias = $alias;
         // remember used aliases to ensure unique aliases
         $aliases[] = $category->alias;
     }
     // get image and file path
     $this->image_path = JComponentHelper::getParams('com_media')->get('image_path');
     $this->image_path = trim($this->image_path, '\\/') . '/';
     $this->file_path = JComponentHelper::getParams('com_media')->get('file_path');
     $this->file_path = trim($this->file_path, '\\/') . '/';
     require_once JPATH_ADMINISTRATOR . '/components/com_mtree/config.mtree.class.php';
     $mtconf = new mtConfig($db);
     $this->category_image_path = $mtconf->get('relative_path_to_cat_original_image');
     $this->category_image_path = trim($this->category_image_path, '\\/') . '/';
     $this->listing_image_path = $mtconf->get('relative_path_to_listing_original_image');
     $this->listing_image_path = trim($this->listing_image_path, '\\/') . '/';
     $this->attachement_path = $mtconf->get('relative_path_to_attachments');
     $this->attachement_path = trim($this->attachement_path, '\\/') . '/';
     $this->import_path_category_images = JPATH_ROOT . '/' . $this->image_path . 'zoo/mtree_import/cats/';
     $this->import_path_item_images = JPATH_ROOT . '/' . $this->image_path . 'zoo/mtree_import/items/';
     $this->import_path_attachments = JPATH_ROOT . '/' . $this->image_path . 'zoo/mtree_import/attachments/';
     $this->import_path_gallery = JPATH_ROOT . '/' . $this->image_path . 'zoo/mtree_import/gallery/';
     // create import folders
     if (!JFolder::exists($this->import_path_category_images)) {
         JFolder::create($this->import_path_category_images);
     }
     if (!JFolder::exists($this->import_path_item_images)) {
         JFolder::create($this->import_path_item_images);
     }
     if (!JFolder::exists($this->import_path_attachments)) {
         JFolder::create($this->import_path_attachments);
     }
     if (!JFolder::exists($this->import_path_gallery)) {
         JFolder::create($this->import_path_gallery);
     }
     // export categories
     foreach ($categories as $category) {
         // assign attributes
         $attributes = array();
         foreach (self::$category_attributes as $attribute) {
             if (isset($category->{$attribute})) {
                 $attributes[$attribute] = $category->{$attribute};
             }
         }
         // sanatize parent
         if ($category->parent && isset($categories[$category->parent])) {
             $attributes['parent'] = $categories[$category->parent]->alias;
         }
         // add category
         $category_xml = $this->_buildCategory($category->alias, $category->name, $attributes);
         if ($category->image) {
             $old_file_name = JPATH_ROOT . '/' . $this->category_image_path . $category->image;
             $file_info = pathinfo($category->image);
             $file_name = $this->import_path_category_images . $category->image;
             $i = 2;
             while (JFile::exists($file_name)) {
                 $file_name = $this->import_path_category_images . $file_info['filename'] . '-' . $i++ . '.' . $file_info['extension'];
             }
             if (JFile::copy($old_file_name, $file_name)) {
                 $image = trim(str_replace('\\', '/', preg_replace('/^' . preg_quote(JPATH_ROOT, '/') . '/i', '', $file_name)), '/');
                 $this->_attachCategoryImage($category_xml, $image, 'Image');
             }
         }
         $this->_addCategory($category_xml);
     }
     // get mtree items
     $query = "SELECT *, link_id as id" . ", link_name as name" . ", link_desc as description" . ", user_id as created_by" . ", link_hits as hits" . ", link_published as published" . ", link_created as created" . ", link_modified as modified" . " FROM #__mt_links";
     $items = $db->queryObjectList($query, 'link_id');
     // sanatize item aliases
     $aliases = array();
     foreach ($items as $item) {
         $i = 2;
         $alias = YString::sluggify($item->alias);
         while (in_array($alias, $aliases)) {
             $alias = YString::sluggify($item->alias) . '-' . $i++;
         }
         $item->alias = $alias;
         // remember used aliases to ensure unique aliases
         $aliases[] = $item->alias;
     }
     // export items
     foreach ($items as $item) {
         $this->_addItem('mtree', $this->_itemToXML($item, $categories));
     }
     return parent::export();
 }
Example #4
0
 public function export()
 {
     $db = YDatabase::getInstance();
     // get docman categories
     $query = "SELECT  c.*, c.parent_id as parent" . " FROM #__categories AS c" . " WHERE c.section = 'com_docman'" . " AND c.published != -2" . " ORDER BY c.parent_id, c.ordering";
     $categories = $db->queryObjectList($query, 'id');
     // get category table
     $category_table = YTable::getInstance('category');
     // get item table
     $item_table = YTable::getInstance('item');
     // sanatize category aliases
     $aliases = array();
     foreach ($categories as $category) {
         $i = 2;
         $alias = YString::sluggify($category->alias);
         if (empty($alias)) {
             $alias = YString::sluggify($category->title);
         }
         while (in_array($alias, $aliases)) {
             $alias = $category->alias . '-' . $i++;
         }
         $category->alias = $alias;
         // remember used aliases to ensure unique aliases
         $aliases[] = $category->alias;
     }
     // get image path
     $this->image_path = JComponentHelper::getParams('com_media')->get('image_path');
     $this->image_path = trim($this->image_path, '\\/') . '/';
     // export categories
     foreach ($categories as $category) {
         // assign attributes
         $attributes = array();
         foreach (self::$category_attributes as $attribute) {
             if (isset($category->{$attribute})) {
                 $attributes[$attribute] = $category->{$attribute};
             }
         }
         // sanatize parent
         if ($category->parent && isset($categories[$category->parent])) {
             $attributes['parent'] = $categories[$category->parent]->alias;
         }
         // add category
         $category_xml = $this->_buildCategory($category->alias, $category->name, $attributes);
         if ($category->image) {
             $this->_attachCategoryImage($category_xml, $this->image_path . $category->image, 'Image');
         }
         $this->_addCategory($category_xml);
     }
     // get docman items
     $query = "SELECT * FROM #__docman";
     $items = $db->queryObjectList($query, 'id');
     // sanatize item aliases
     $aliases = array();
     foreach ($items as $item) {
         $i = 2;
         $alias = YString::sluggify($item->dmname);
         while (in_array($alias, $aliases)) {
             $alias = YString::sluggify($item->dmname) . '-' . $i++;
         }
         $item->alias = $alias;
         // remember used aliases to ensure unique aliases
         $aliases[] = $item->alias;
     }
     require_once JPATH_ADMINISTRATOR . '/components/com_docman/docman.config.php';
     $config = new dmConfig();
     $document_path = trim(str_replace('\\', '/', preg_replace('/^' . preg_quote(JPATH_ROOT, '/') . '/i', '', $config->dmpath)), '/') . '/';
     // export items
     foreach ($items as $item) {
         if (preg_match('/^Link:/', $item->dmfilename)) {
             $type = 'Linked File';
             $item->dmfilename = preg_replace('/^Link:/', '', $item->dmfilename);
         } else {
             $type = 'File';
             $item->dmfilename = $document_path . $item->dmfilename;
         }
         $this->_addItem($type, $this->_itemToXML($item, $categories, $type));
     }
     return parent::export();
 }
Example #5
0
 public function export()
 {
     $db = YDatabase::getInstance();
     // get k2 categories
     $query = "SELECT a.*, b.name AS extra_field_group_name " . " FROM #__k2_categories AS a" . " LEFT JOIN #__k2_extra_fields_groups AS b ON b.id = a.extraFieldsGroup";
     $categories = $db->queryObjectList($query, 'id');
     // get category table
     $category_table = YTable::getInstance('category');
     // get item table
     $item_table = YTable::getInstance('item');
     // sanatize category aliases
     $aliases = array();
     foreach ($categories as $category) {
         $i = 2;
         $alias = YString::sluggify($category->alias);
         while (in_array($alias, $aliases)) {
             $alias = $category->alias . '-' . $i++;
         }
         $category->alias = $alias;
         // remember used aliases to ensure unique aliases
         $aliases[] = $category->alias;
     }
     // export categories
     foreach ($categories as $category) {
         // assign attributes
         $attributes = array();
         foreach (self::$category_attributes as $attribute) {
             if (isset($category->{$attribute})) {
                 $attributes[$attribute] = $category->{$attribute};
             }
         }
         // sanatize parent
         if ($category->parent && isset($categories[$category->parent])) {
             $attributes['parent'] = $categories[$category->parent]->alias;
         }
         // add category
         $category_xml = $this->_buildCategory($category->alias, $category->name, $attributes);
         if ($category->image) {
             $this->_attachCategoryImage($category_xml, '/media/k2/categories/' . $category->image, 'Image');
         }
         $this->_addCategory($category_xml);
     }
     // get k2 items
     $query = "SELECT * FROM #__k2_items";
     $items = $db->queryObjectList($query, 'id');
     // get k2 extra fields
     $query = "SELECT * FROM #__k2_extra_fields";
     $extra_fields = $db->queryObjectList($query, 'id');
     // get k2 tags
     $query = "SELECT a.itemID, b.name" . " FROM #__k2_tags_xref as a" . " JOIN #__k2_tags AS b ON a.tagID = b.id";
     $tag_result = $db->queryObjectList($query);
     $tags = array();
     foreach ($tag_result as $tag) {
         $tags[$tag->itemID][] = $tag->name;
     }
     // sanatize item aliases
     $aliases = array();
     foreach ($items as $item) {
         $i = 2;
         $alias = YString::sluggify($item->alias);
         while (in_array($alias, $aliases)) {
             $alias = $item->alias . '-' . $i++;
         }
         $item->alias = $alias;
         // remember used aliases to ensure unique aliases
         $aliases[] = $item->alias;
     }
     // export items
     foreach ($items as $item) {
         if (!$item->trash) {
             if (!($type = $categories[$item->catid]->extra_field_group_name)) {
                 $type = JText::_('K2-Unassigned');
             }
             $this->_addItem($type, $this->_itemToXML($item, $categories, $tags, $extra_fields));
         }
     }
     return parent::export();
 }
 public function run($addonId, $path)
 {
     $addOn = XenForo_Model::create('XenForo_Model_AddOn')->getAddonById($addonId);
     $fileExport = new ExportHelper('addon');
     $rootNode = $fileExport->getRootNode();
     $rootNode->setAttribute('addon_id', $addOn['addon_id']);
     $rootNode->setAttribute('title', $addOn['title']);
     $rootNode->setAttribute('version_string', 'Build: {@revision}');
     $rootNode->setAttribute('version_id', '{@revision}');
     $rootNode->setAttribute('url', $addOn['url']);
     $rootNode->setAttribute('install_callback_class', $addOn['install_callback_class']);
     $rootNode->setAttribute('install_callback_method', $addOn['install_callback_method']);
     $rootNode->setAttribute('uninstall_callback_class', $addOn['uninstall_callback_class']);
     $rootNode->setAttribute('uninstall_callback_method', $addOn['uninstall_callback_method']);
     $fileExport->save($path . '/addon.xml');
     $exports = array('admin_navigation', array('admin_permissions', 'XenForo_Model_Admin'), 'admin_templates', array('code_events', false, 'appendEventsAddOnXml'), array('code_event_listeners', 'XenForo_Model_CodeEvent', 'appendEventListenersAddOnXml'), array('cron', false, 'appendCronEntriesAddOnXml'), 'email_templates', array('options', false, false, 'optiongroups'), 'permissions', 'phrases', array('route_prefixes', 'XenForo_Model_RoutePrefix', 'appendPrefixesAddOnXml'), 'templates');
     foreach ($exports as $export) {
         $model = false;
         $method = false;
         $name = false;
         if (is_array($export)) {
             if (!empty($export[1])) {
                 $model = $export[1];
             }
             if (!empty($export[2])) {
                 $method = $export[2];
             }
             if (!empty($export[3])) {
                 $name = $export[3];
             }
             $export = $export[0];
         }
         $camel = Zend_Filter::filterStatic($export, 'Word_UnderscoreToCamelCase');
         if (!$model) {
             $model = 'XenForo_Model_' . $camel;
             if (substr($model, strlen($model) - 1) == 's') {
                 $model = substr($model, 0, -1);
             }
         }
         $model = XenForo_Model::create($model);
         $fileExport = new ExportHelper($name ? $name : $export);
         if (!$method) {
             $method = 'append' . $camel . 'AddonXml';
         }
         $model->{$method}($fileExport->getRootNode(), $addonId);
         $fileExport->save($path . '/' . $export . '.xml');
     }
     // Well that code was meant to be better than that... oh well, these following ones are better done seperate
     foreach (array(-1 => 'admin_', 0 => '') as $styleId => $prefix) {
         $model = XenForo_Model::create('XenForo_Model_StyleProperty');
         $fileExport = new ExportHelper($prefix . 'style_properties');
         $model->appendStylePropertyXml($fileExport->getRootNode(), $styleId, $addonId);
         $fileExport->save($path . '/' . $prefix . 'style_properties.xml');
     }
     // Hardcode for now
     $file = $path . '/../library/Merc/' . str_replace('merc', '', $addonId) . '/FileSums.php';
     if (file_exists($file)) {
         $hashes = XenForo_Helper_Hash::hashDirectory(realpath($path . '/../'), array('.js', '.php'));
         $remove = substr(realpath(dirname($file)), 0, strpos(realpath(dirname($file)), 'library'));
         foreach ($hashes as $k => $h) {
             unset($hashes[$k]);
             $hashes[str_replace($remove, '', $k)] = $h;
         }
         file_put_contents($file, XenForo_Helper_Hash::getHashClassCode('Merc_' . str_replace('merc', '', $addonId) . '_FileSums', $hashes));
     }
 }