Example #1
0
 public static function get($param, $def = null)
 {
     if (self::$instance == null) {
         self::$instance = new self();
     }
     return isset(self::$instance->params[$param]) ? self::$instance->params[$param] : $def;
 }
Example #2
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 #3
0
<?php

/**
 * @version		$Id: admin.mtree.php 764 2009-08-14 05:25:43Z CY $
 * @package		Mosets Tree
 * @copyright	(C) 2005-2009 Mosets Consulting. All rights reserved.
 * @license		GNU General Public License
 * @author		Lee Cher Yeong <*****@*****.**>
 * @url			http://www.mosets.com/tree/
 */
defined('_JEXEC') or die('Restricted access');
require_once JPATH_COMPONENT . DS . 'config.mtree.class.php';
global $mtconf;
$database =& JFactory::getDBO();
$mtconf = new mtConfig($database);
if ($task != 'upgrade') {
    require_once JPATH_COMPONENT . DS . 'admin.mtree.html.php';
    require_once JPATH_COMPONENT . DS . 'admin.mtree.class.php';
    require_once JPATH_COMPONENT . DS . 'tools.mtree.php';
    require_once JPATH_COMPONENT . DS . 'mfields.class.php';
    DEFINE('_E_START_PUB', JText::_('Start Publishing'));
    DEFINE('_E_FINISH_PUB', JText::_('Finish Publishing'));
}
// global $task;
$task = JRequest::getCmd('task', '');
# Cache
$cache =& JFactory::getCache('com_mtree');
# Categories name cache
$cache_cat_names = array();
$id = JRequest::getInt('id', 0);
/* Cat ID 
Example #4
0
function com_install()
{
    $my =& JFactory::getUser();
    $database =& JFactory::getDBO();
    $mtconf = new mtConfig($database);
    // Assign current user's email as Mosets Tree admin
    $database->setQuery("UPDATE #__mt_config SET value='" . $my->email . "' WHERE varname='admin_email' LIMIT 1");
    $database->query();
    // Change Admin Icon to Mosets icon
    $database->setQuery("UPDATE #__components SET admin_menu_img='../components/com_mtree/img/icon-16-mosetstree.png' WHERE admin_menu_link='option=com_mtree'");
    $database->query();
    // Rename htaccess.txt to .htaccess in attachments directory
    jimport('joomla.filesystem.file');
    if (!JFile::move(JPATH_SITE . $mtconf->get('relative_path_to_attachments') . 'htaccess.txt', JPATH_SITE . $mtconf->get('relative_path_to_attachments') . '.htaccess')) {
        $htaccess_rename_status = false;
    } else {
        $htaccess_rename_status = true;
    }
    ?>
	<div>
		<div class="t">
			<div class="t">
				<div class="t"></div>
			</div>
		</div>
		<div class="m" style="overflow:hidden;padding-bottom:12px;">
			<div style="padding: 20px;border-right:1px solid #ccc;float:left">
			<img src="../components/com_mtree/img/logo.png" alt="Mosets Tree" style="float:left;padding-right:15px;" />
			</div>
			<div style="margin-left:350px;">
				<h2 style="margin-bottom:0;">Mosets Tree <?php 
    echo $mtconf->get('version');
    ?>
</h2>
				<strong>A flexible directory component for Joomla!</strong>
				<br /><br />
				&copy; Copyright 2005-<?php 
    echo date('Y');
    ?>
 by Mosets Consulting. <a href="http://www.mosets.com/">www.mosets.com</a><br />
				<input type="button" value="Go to Mosets Tree now" onclick="location.href='index.php?option=com_mtree'" style="margin-top:13px;cursor:pointer;width:200px;font-weight:bold" />
			</div>
		</div>
	</div>	
	<table class="adminlist">
		<tbody>
			<?php 
    echo getHtaccessRenameRow($htaccess_rename_status);
    ?>
			<?php 
    echo getWritableRow($mtconf->getjconf('absolute_path') . $mtconf->get('relative_path_to_cat_original_image'));
    ?>
			<?php 
    echo getWritableRow($mtconf->getjconf('absolute_path') . $mtconf->get('relative_path_to_cat_small_image'));
    ?>
			<?php 
    echo getWritableRow($mtconf->getjconf('absolute_path') . $mtconf->get('relative_path_to_listing_original_image'));
    ?>
			<?php 
    echo getWritableRow($mtconf->getjconf('absolute_path') . $mtconf->get('relative_path_to_listing_medium_image'));
    ?>
			<?php 
    echo getWritableRow($mtconf->getjconf('absolute_path') . $mtconf->get('relative_path_to_listing_small_image'));
    ?>
		</tbody>
	</table>

	<?php 
    return true;
}