コード例 #1
0
ファイル: mtree.php プロジェクト: rsemedo/Apply-Within
function addcategory2($option)
{
    global $Itemid, $mtconf, $mainframe;
    // Check for request forgeries
    JRequest::checkToken() or jexit('Invalid Token');
    $database =& JFactory::getDBO();
    $my =& JFactory::getUser();
    $jdate = JFactory::getDate();
    $now = $jdate->toMySQL();
    # Get cat_parent
    $cat_parent = JRequest::getInt('cat_parent', 0);
    # Check if any malicious user is trying to submit link
    if ($mtconf->get('user_addcategory') == 1 && $my->id <= 0) {
        echo _NOT_EXIST;
    } else {
        # Allowed
        $post = JRequest::get('post');
        $row = new mtCats($database);
        if (!$row->bind($post)) {
            echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        $isNew = $row->cat_id < 1;
        # Assignment for new record
        if ($isNew) {
            $jdate = JFactory::getDate();
            $row->cat_created = $now;
            // Required approval
            if ($mtconf->get('needapproval_addcategory')) {
                $row->cat_approved = '0';
            } else {
                $row->cat_approved = 1;
                $row->cat_published = 1;
                $cache =& JFactory::getCache('com_mtree');
                $cache->clean();
            }
        } else {
            # Assignment for exsiting record
            $row->cat_modified = $now;
        }
        # OK. Store new category into database
        if (!$row->store()) {
            echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        if ($isNew && !$mtconf->get('needapproval_addcategory')) {
            $row->updateLftRgt();
            $row->updateCatCount(1);
        }
        $mainframe->redirect(JRoute::_("index.php?option={$option}&task=listcats&cat_id={$cat_parent}&Itemid={$Itemid}"), $mtconf->get('needapproval_addcategory') ? JText::_('Category will be reviewed') : JText::_('Category have been added'));
    }
}
コード例 #2
0
 function getTemplate()
 {
     if ($this->link_template != '') {
         return $this->link_template;
     } else {
         $cat = new mtCats($this->_db);
         $cat->load($this->cat_id);
         if ($cat->cat_template != '') {
             return $cat->cat_template;
         } else {
             return false;
         }
     }
 }
コード例 #3
0
ファイル: rss.php プロジェクト: rsemedo/Apply-Within
function rss($option, $type, $cat_id = 0)
{
    global $mtconf;
    $database =& JFactory::getDBO();
    $info = null;
    $rss = null;
    $jdate = JFactory::getDate();
    $now = $jdate->toMySQL();
    $nullDate = $database->getNullDate();
    $rss = new MTRSSCreator20();
    if ($type == 'new') {
        $filename = $mtconf->getjconf('cachepath') . '/mtreeNew' . ($cat_id ? '-' . $cat_id : '') . '.xml';
    } else {
        $filename = $mtconf->getjconf('cachepath') . '/mtreeUpdated' . ($cat_id ? '-' . $cat_id : '') . '.xml';
    }
    $rss->useCached($filename);
    switch ($type) {
        case 'updated':
            $rss->title = $mtconf->getjconf('sitename') . $mtconf->get('rss_title_separator') . JText::_('Recently updated listing');
            break;
        case 'new':
        default:
            $rss->title = $mtconf->getjconf('sitename') . $mtconf->get('rss_title_separator') . JText::_('New listing');
            break;
    }
    if ($cat_id > 0) {
        $mtCats = new mtCats($database);
        $cat_name = $mtCats->getName($cat_id);
        $rss->title .= $mtconf->get('rss_title_separator') . $cat_name;
    }
    $rss->link = JURI::root();
    $rss->cssStyleSheet = NULL;
    $rss->feedURL = $mtconf->getjconf('live_site') . $_SERVER['PHP_SELF'];
    $database->setQuery("SELECT id FROM #__menu WHERE link='index.php?option=com_mtree' AND published='1' LIMIT 1");
    $Itemid = $database->loadResult();
    $sql = "SELECT l.*, u.username, u.name AS owner, c.cat_id, c.cat_name FROM (#__mt_links AS l, #__mt_cl AS cl, #__users AS u, #__mt_cats AS c) " . "WHERE link_published='1' && link_approved='1' " . "\n AND ( publish_up = " . $database->Quote($nullDate) . " OR publish_up <= '{$now}'  ) " . "\n AND ( publish_down = " . $database->Quote($nullDate) . " OR publish_down >= '{$now}' ) " . "\n AND l.link_id = cl.link_id " . "\n AND cl.main = 1 " . "\n AND cl.cat_id = c.cat_id " . "\n AND l.user_id = u.id ";
    if ($cat_id > 0) {
        $subcats = getSubCats_Recursive($cat_id);
        if (count($subcats) > 1) {
            $sql .= ' AND cl.cat_id IN (' . implode(',', $subcats) . ')';
        }
    }
    switch ($type) {
        case 'updated':
            $sql .= "ORDER BY l.link_modified DESC ";
            break;
        case 'new':
        default:
            $sql .= "ORDER BY l.link_created DESC ";
            break;
    }
    if ($mtconf->get('rss_' . $type . '_limit') > 0) {
        $sql .= "LIMIT " . intval($mtconf->get('rss_' . $type . '_limit'));
    }
    $database->setQuery($sql);
    $links = $database->loadObjectList();
    # Get first image of each listings
    if ($mtconf->get('show_image_rss') && !empty($links)) {
        foreach ($links as $link) {
            $link_ids[] = $link->link_id;
        }
        $database->setQuery('SELECT link_id, filename FROM #__mt_images WHERE link_id IN (' . implode(', ', $link_ids) . ') AND ordering = 1 LIMIT ' . count($link_ids));
        $link_images = $database->loadObjectList('link_id');
    }
    # Get arrays if link_ids
    foreach ($links as $link) {
        $link_ids[] = $link->link_id;
    }
    # Additional elements from core fields
    $core_fields = array('cat_name', 'cat_url', 'link_votes', 'link_rating', 'address', 'city', 'postcode', 'state', 'country', 'email', 'website', 'telephone', 'fax', 'metakey', 'metadesc');
    $additional_elements = array();
    foreach ($core_fields as $core_field) {
        if ($mtconf->get('rss_' . $core_field)) {
            $additional_elements[] = $core_field;
        }
    }
    # Additional elements from custom fields
    $custom_fields = trim($mtconf->get('rss_custom_fields'));
    $custom_fields_values = array();
    if (!empty($custom_fields) && count($link_ids) > 0) {
        $array_custom_fields = explode(',', $custom_fields);
        foreach ($array_custom_fields as $key => $value) {
            if (intval($value) > 0) {
                $array_custom_fields[$key] = intval($value);
                $additional_elements[] = 'cust_' . $array_custom_fields[$key];
            } else {
                unset($array_custom_fields[$key]);
            }
        }
        if (count($array_custom_fields) > 0) {
            $database->setQuery('SELECT cf_id, link_id, value FROM #__mt_cfvalues WHERE cf_id IN (' . implode(',', $array_custom_fields) . ') AND link_id IN (' . implode(',', $link_ids) . ') LIMIT ' . count($array_custom_fields) * count($link_ids));
            $array_custom_fields_values = $database->loadObjectList();
            foreach ($array_custom_fields_values as $array_custom_fields_value) {
                $custom_fields_values[$array_custom_fields_value->link_id][$array_custom_fields_value->cf_id] = $array_custom_fields_value->value;
            }
        }
    }
    $uri =& JURI::getInstance(JURI::base());
    $host = $uri->toString(array('scheme', 'host', 'port'));
    $thumbnail_path = $mtconf->get('relative_path_to_listing_small_image');
    foreach ($links as $link) {
        $item = new FeedItem();
        $item->title = $link->link_name;
        $item->link = $host . JRoute::_("index.php?option=com_mtree&task=viewlink&link_id=" . $link->link_id . "&Itemid=" . $Itemid);
        $item->guid = $host . JRoute::_("index.php?option=com_mtree&task=viewlink&link_id=" . $link->link_id . "&Itemid=" . $Itemid);
        $item->description = '';
        if ($mtconf->get('show_image_rss') && isset($link_images[$link->link_id]) && !empty($link_images[$link->link_id]->filename)) {
            $item->description .= '<img align="right" src="' . $mtconf->getjconf('live_site') . $thumbnail_path . $link_images[$link->link_id]->filename . '" alt="' . $link->link_name . '" />';
        }
        $item->description .= $link->link_desc;
        //optional
        $item->descriptionHtmlSyndicated = true;
        switch ($type) {
            case 'updated':
                $item->date = strtotime($link->link_modified);
                break;
            case 'new':
            default:
                $item->date = strtotime($link->link_created);
                break;
        }
        $item->source = $mtconf->getjconf('live_site');
        // $item->author = $link->owner;
        $item->author = $link->username;
        if (count($additional_elements) > 0) {
            $ae = array();
            foreach ($additional_elements as $additional_element) {
                if (in_array($additional_element, $core_fields)) {
                    if ($additional_element == 'cat_url') {
                        $ae['mtree:' . $additional_element] = htmlspecialchars(JRoute::_('index.php?option=com_mtree&task=listcats&cat_id=' . $link->cat_id . '&Itemid=' . $Itemid));
                    } else {
                        $ae['mtree:' . $additional_element] = '<![CDATA[' . $link->{$additional_element} . ']]>';
                    }
                } else {
                    $cf_id = substr($additional_element, 5);
                    if (array_key_exists($link->link_id, $custom_fields_values) && array_key_exists($cf_id, $custom_fields_values[$link->link_id])) {
                        $ae['mtree:' . $additional_element] = '<![CDATA[' . str_replace('|', ',', $custom_fields_values[$link->link_id][$cf_id]) . ']]>';
                    }
                }
            }
            $item->additionalElements = $ae;
        }
        $rss->addItem($item);
    }
    echo $rss->saveFeed($filename);
}
コード例 #4
0
ファイル: admin.mtree.php プロジェクト: rsemedo/Apply-Within
function search($option)
{
    global $mainframe, $mtconf;
    $database =& JFactory::getDBO();
    $search_text = JRequest::getVar('search_text', '', 'post');
    $search_where = JRequest::getInt('search_where', 0, 'post');
    // 1: Listing, 2: Category
    $limit = $mainframe->getUserStateFromRequest("viewlistlimit", 'limit', $mtconf->getjconf('list_limit'));
    $limitstart = $mainframe->getUserStateFromRequest("viewcli{$option}limitstart", 'limitstart', 0);
    # Detect search command
    # Quick Go
    $id_found = 0;
    if (substr($search_text, 0, 3) == "id:") {
        $temp = explode(":", $search_text);
        if (is_numeric($temp[1])) {
            $id_found = $temp[1];
        }
    }
    # Search query
    if ($search_where == 1) {
        if ($id_found) {
            $link = new mtLinks($database);
            $link->load($id_found);
            if (!empty($link->link_name)) {
                $mainframe->redirect("index2.php?option=com_mtree&task=editlink&link_id=" . $id_found);
            } else {
                $mainframe->redirect("index2.php?option=com_mtree", JText::_('Your search does not return any result'));
            }
        } else {
            // Total Results
            $database->setQuery('SELECT COUNT(*) FROM #__mt_links ' . "\nWHERE link_name LIKE '%" . $database->getEscaped($search_text, true) . "%'");
            $total = $database->loadResult();
            // Page Navigation
            jimport('joomla.html.pagination');
            $pageNav = new JPagination($total, $limitstart, $limit);
            // Links
            $database->setQuery("SELECT l.*, COUNT(r.rev_id) AS reviews FROM #__mt_links AS l" . "\nLEFT JOIN #__mt_reviews AS r ON r.link_id = l.link_id" . "\nWHERE l.link_name LIKE '%" . $database->getEscaped($search_text, true) . "%'" . "\nGROUP BY l.link_id" . "\nORDER BY l.link_name ASC" . "\nLIMIT " . $pageNav->limitstart . ', ' . $pageNav->limit);
        }
    } else {
        if ($id_found) {
            $cat = new mtCats($database);
            $cat->load($id_found);
            if (!empty($cat->cat_name)) {
                $mainframe->redirect("index2.php?option=com_mtree&task=editcat&cat_id=" . $id_found);
            } else {
                $mainframe->redirect("index2.php?option=com_mtree", JText::_('Your search does not return any result'));
            }
        } else {
            // Total Results
            $database->setQuery("SELECT COUNT(*) FROM #__mt_cats WHERE cat_name LIKE '%" . $database->getEscaped($search_text, true) . "%'");
            $total = $database->loadResult();
            // Page Navigation
            jimport('joomla.html.pagination');
            $pageNav = new JPagination($total, $limitstart, $limit);
            // Categories
            $database->setQuery("SELECT * FROM #__mt_cats WHERE cat_name LIKE '%" . $database->getEscaped($search_text, true) . "%' ORDER BY cat_name ASC LIMIT {$pageNav->limitstart}, {$pageNav->limit}");
        }
    }
    $results = $database->loadObjectList();
    # Get Pathway
    $pathWay = new mtPathWay();
    # Results Output
    if ($search_where == 1) {
        // Links
        HTML_mtree::searchresults_links($results, $pageNav, $pathWay, $search_where, $search_text, $option);
    } else {
        // Categories
        HTML_mtree::searchresults_categories($results, $pageNav, $pathWay, $search_where, $search_text, $option);
    }
}
コード例 #5
0
ファイル: mtree.php プロジェクト: kosmosby/medicine-prof
function addcategory2( $option ) {
	global $Itemid, $mtconf;

	$app		= JFactory::getApplication('site');

	// Check for request forgeries
	JRequest::checkToken() or jexit( 'Invalid Token' );

	$database	=& JFactory::getDBO();
	$my			=& JFactory::getUser();
	$jdate		= JFactory::getDate();
	$now		= $jdate->toMySQL();

	# Get cat_parent
	$cat_parent	= JRequest::getInt('cat_parent', 0);

	# Check if any malicious user is trying to submit link
	if ( $mtconf->get('user_addcategory') == 1 && $my->id <= 0 ) {
		echo JText::_( 'NOT_EXIST' );

	} elseif( $mtconf->get('user_addcategory') == '-1' ) {
		# Add category is disabled
		JError::raiseError(404, JText::_('Resource Not Found'));

	} else {
	# Allowed

		$post = JRequest::get( 'post' );
		$row = new mtCats( $database );
		if (!$row->bind( $post )) {
			echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
			exit();
		}
		$isNew = $row->cat_id < 1;

		# Assignment for new record
		if ($isNew) {
			$jdate		= JFactory::getDate();
			$row->cat_created = $now;
			$row->alias 	= JFilterOutput::stringURLSafe($row->cat_name);

			// Required approval
			if ( $mtconf->get('needapproval_addcategory') ) {
				$row->cat_approved = '0';
			} else {
				$row->cat_approved = 1;
				$row->cat_published = 1;
				$cache = &JFactory::getCache('com_mtree');
				$cache->clean();
			}

		} else {
		# Assignment for exsiting record
			$row->cat_modified = $now;
		}

		# OK. Store new category into database
		if (!$row->store()) {
			echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
			exit();
		}

		if ( $isNew && !$mtconf->get('needapproval_addcategory')) {
			$row->updateLftRgt();
			$row->updateCatCount( 1 );
		}

		$app->redirect( JRoute::_("index.php?option=$option&task=listcats&cat_id=$cat_parent&Itemid=$Itemid"), ( ($mtconf->get('needapproval_addcategory')) ?  JText::_( 'Category will be reviewed' ) : JText::_( 'Category have been added' )) );

	}
}
コード例 #6
0
ファイル: mtree.tools.php プロジェクト: rsemedo/Apply-Within
function loadCustomTemplate($cat_id = null, &$savantConf, $template = '')
{
    global $mtconf;
    $database =& JFactory::getDBO();
    if (!empty($template)) {
        $templateDir = $mtconf->getjconf('absolute_path') . '/components/com_mtree/templates/' . $template;
        if (is_dir($templateDir)) {
            $savantConf["template_path"] = $templateDir . '/';
            $mtconf->set('template', $template);
        }
    } else {
        $mtCats = new mtCats($database);
        $mtCats->load($cat_id);
        if (!empty($mtCats->cat_template)) {
            $savantConf['template_path'] = $mtconf->getjconf('absolute_path') . "/components/com_mtree/templates/" . $mtCats->cat_template . "/";
            $mtconf->set('template', $mtCats->cat_template);
        }
    }
}
コード例 #7
0
    function print_startmenu($task, $cat_parent)
    {
        global $mtconf;
        $database =& JFactory::getDBO();
        # Count the number of pending links/cats/reviews/reports/claims
        $database->setQuery("SELECT COUNT(*) FROM #__mt_cats WHERE cat_approved='0'");
        $pending_cats = $database->loadResult();
        $database->setQuery("SELECT COUNT(*) FROM #__mt_links WHERE link_approved <= 0");
        $pending_links = $database->loadResult();
        $database->setQuery("SELECT COUNT(*) FROM #__mt_reviews WHERE rev_approved='0'");
        $pending_reviews = $database->loadResult();
        $database->setQuery("SELECT COUNT(*) FROM #__mt_reports WHERE rev_id = 0 && link_id > 0");
        $pending_reports = $database->loadResult();
        $database->setQuery("SELECT COUNT(*) FROM #__mt_reviews WHERE ownersreply_text != '' AND ownersreply_approved = '0'");
        $pending_reviewsreply = $database->loadResult();
        $database->setQuery("SELECT COUNT(*) FROM #__mt_reports WHERE rev_id > 0 && link_id > 0");
        $pending_reviewsreports = $database->loadResult();
        $database->setQuery("SELECT COUNT(*) FROM #__mt_claims");
        $pending_claims = $database->loadResult();
        HTML_mtree::print_style();
        ?>
	<table cellpadding="3" cellspacing="0" border="0" width="100%">
	<tr>
		<td align="left" valign="top" width="160" height="0">

			<style type="text/css">

			</style>

			<table cellpadding="2" cellspacing="0" border="0" width="160" height="100%" align="left" style="border: 1px solid #cccccc;">
				<tr><td colspan="2" style="background: #DDE1E6; border-bottom: 1px solid #cccccc;font-weight:bold;"><?php 
        echo JText::_('Title');
        ?>
</td></tr>
				
				<?php 
        if (!$mtconf->get('admin_use_explorer')) {
            ?>
				<tr>
					<td width="20" align="center" style="background-color:#DDE1E6"><img src="../includes/js/ThemeOffice/home.png" width="16" height="16" /></td>
					<td width="100%" style="background-color:#F1F3F5"> <a class="mt_menu<?php 
            echo $task == "listcats" || $task == "editcat" || $task == "" ? "_selected" : "";
            ?>
" href="index2.php?option=com_mtree&task=listcats"><?php 
            echo JText::_('Navigate tree');
            ?>
</a></td>
				</tr>
				<?php 
        }
        ?>
				<tr>
					<td align="center" style="background-color:#DDE1E6"><img src="../components/com_mtree/img/page_white_add.png" width="16" height="16" /></td>
					<td style="background-color:#F1F3F5"> <a class="mt_menu<?php 
        echo $task == "newlink" ? "_selected" : "";
        ?>
" href="index2.php?option=com_mtree&amp;task=newlink&amp;cat_parent=<?php 
        echo $cat_parent;
        ?>
"><?php 
        echo JText::_('Add listing');
        ?>
</a></td>
				</tr>

				<tr>
					<td align="center" style="background-color:#DDE1E6"><img src="../components/com_mtree/img/folder_add.png" width="16" height="16" /></td>
					<td style="background-color:#F1F3F5"> <a class="mt_menu<?php 
        echo $task == "newcat" ? "_selected" : "";
        ?>
" href="index2.php?option=com_mtree&amp;task=newcat&amp;cat_parent=<?php 
        echo $cat_parent;
        ?>
"><?php 
        echo JText::_('Add cat');
        ?>
</a></td>
				</tr>
				<?php 
        # Pending Approvals
        if ($pending_links > 0 or $pending_cats > 0 or $pending_reviews > 0 or $pending_reports > 0 or $pending_reviewsreply > 0 or $pending_reviewsreports > 0 or $pending_claims > 0) {
            ?>
				<tr><td colspan="2" style="background: #DDE1E6; border-bottom: 1px solid #cccccc;border-top: 1px solid #cccccc;font-weight:bold;"><?php 
            echo JText::_('Pending approval');
            ?>
</td></tr>
					
				<?php 
            if ($pending_cats > 0) {
                ?>
				<tr>
					<td style="background-color:#DDE1E6"><img src="../components/com_mtree/img/folder.png" width="18" height="18" /></td>
					<td style="background-color:#F1F3F5">&nbsp;<a class="mt_menu<?php 
                echo $task == "listpending_cats" ? "_selected" : "";
                ?>
" href="index2.php?option=com_mtree&task=listpending_cats"><?php 
                echo JText::_('Categories');
                ?>
 (<?php 
                echo $pending_cats;
                ?>
)</a></td>
				</tr>
					<?php 
            }
            if ($pending_links > 0) {
                ?>
				<tr>
					<td style="background-color:#DDE1E6"><img src="../components/com_mtree/img/page_white.png" width="16" height="16" /></td>
					<td style="background-color:#F1F3F5">&nbsp;<a class="mt_menu<?php 
                echo $task == "listpending_links" ? "_selected" : "";
                ?>
" href="index2.php?option=com_mtree&task=listpending_links"><?php 
                echo JText::_('Listings');
                ?>
 (<?php 
                echo $pending_links;
                ?>
)</a></td>
				</tr>
				<?php 
            }
            if ($pending_reviews > 0) {
                ?>
				<tr>
					<td style="background-color:#DDE1E6"><img src="../components/com_mtree/img/comment.png" width="16" height="16" /></td>
					<td style="background-color:#F1F3F5">&nbsp;<a class="mt_menu<?php 
                echo $task == "listpending_reviews" ? "_selected" : "";
                ?>
" href="index2.php?option=com_mtree&task=listpending_reviews"><?php 
                echo JText::_('Reviews');
                ?>
 (<?php 
                echo $pending_reviews;
                ?>
)</a></td>
				</tr>
				<?php 
            }
            if ($pending_reports > 0) {
                ?>
				<tr>
					<td style="background-color:#DDE1E6"><img src="../components/com_mtree/img/error.png" width="16" height="16" /></td>
					<td style="background-color:#F1F3F5">&nbsp;<a class="mt_menu<?php 
                echo $task == "listpending_reports" ? "_selected" : "";
                ?>
" href="index2.php?option=com_mtree&task=listpending_reports"><?php 
                echo JText::_('Reports');
                ?>
 (<?php 
                echo $pending_reports;
                ?>
)</a></td>
				</tr>
				<?php 
            }
            if ($pending_reviewsreply > 0) {
                ?>
				<tr>
					<td style="background-color:#DDE1E6"><img src="../components/com_mtree/img/user_comment.png" width="16" height="16" /></td>
					<td style="background-color:#F1F3F5">&nbsp;<a class="mt_menu<?php 
                echo $task == "listpending_reviewsreply" ? "_selected" : "";
                ?>
" href="index2.php?option=com_mtree&task=listpending_reviewsreply"><?php 
                echo JText::_('Owners replies');
                ?>
 (<?php 
                echo $pending_reviewsreply;
                ?>
)</a></td>
				</tr>
				<?php 
            }
            if ($pending_reviewsreports > 0) {
                ?>
				<tr>
					<td style="background-color:#DDE1E6"><img src="../components/com_mtree/img/error.png" width="16" height="16" /></td>
					<td style="background-color:#F1F3F5">&nbsp;<a class="mt_menu<?php 
                echo $task == "listpending_reviewsreports" ? "_selected" : "";
                ?>
" href="index2.php?option=com_mtree&task=listpending_reviewsreports"><?php 
                echo JText::_('Reviews reports');
                ?>
 (<?php 
                echo $pending_reviewsreports;
                ?>
)</a></td>
				</tr>
				<?php 
            }
            if ($pending_claims > 0) {
                ?>
				<tr>
					<td style="background-color:#DDE1E6"><img src="../components/com_mtree/img/user_green.png" width="16" height="16" /></td>
					<td style="background-color:#F1F3F5">&nbsp;<a class="mt_menu<?php 
                echo $task == "listpending_claims" ? "_selected" : "";
                ?>
" href="index2.php?option=com_mtree&task=listpending_claims"><?php 
                echo JText::_('Claims');
                ?>
 (<?php 
                echo $pending_claims;
                ?>
)</a></td>
				</tr>
				<?php 
            }
        }
        # End of Pending Approvals
        # dTree
        if ($mtconf->get('admin_use_explorer')) {
            ?>
				<tr><td colspan="2" style="background: #DDE1E6; border-bottom: 1px solid #cccccc;border-top: 1px solid #cccccc;font-weight:bold;"><?php 
            echo JText::_('Explorer');
            ?>
</td></tr>
				<tr><td colspan="2" style="background-color:#F1F3F5;">
				<?php 
            $cats = HTML_mtree::getChildren(0, $mtconf->get('explorer_tree_level'));
            ?>
				<link rel="StyleSheet" href="components/com_mtree/dtree.css" type="text/css" />
				<script type="text/javascript" src="../components/com_mtree/js/dtree.js"></script>

				<script type="text/javascript">
					<!--
					
					fpath = '../components/com_mtree/img/dtree/folder.gif';
					d = new dTree('d');

					d.config.closeSameLevel = true; 

					d.icon.root = '../includes/js/ThemeOffice/home.png',
					d.icon.folder = '../components/com_mtree/img/dtree/folder.gif',
					d.icon.folderOpen = '../components/com_mtree/img/dtree/folderopen.gif',
					d.icon.node = '../components/com_mtree/img/dtree/page.gif',
					d.icon.empty = '../components/com_mtree/img/dtree/empty.gif',
					d.icon.line = '../components/com_mtree/img/dtree/line.png',
					d.icon.join = '../components/com_mtree/img/dtree/join.png',
					d.icon.joinBottom = '../components/com_mtree/img/dtree/joinbottom.png',
					d.icon.plus = '../components/com_mtree/img/dtree/plus.png',
					d.icon.plusBottom = '../components/com_mtree/img/dtree/plusbottom.png',
					d.icon.minus = '../components/com_mtree/img/dtree/minus.gif',
					d.icon.minusBottom = '../components/com_mtree/img/dtree/minusbottom.gif',
					d.icon.nlPlus = '../components/com_mtree/img/dtree/nolines_plus.gif',
					d.icon.nlMinus = '../components/com_mtree/img/dtree/nolines_minus.gif'

					d.add(0,-1,'<?php 
            echo JText::_('Root');
            ?>
', 'index2.php?option=com_mtree');
					<?php 
            foreach ($cats as $cat) {
                echo "\nd.add(";
                echo $cat->cat_id . ",";
                echo $cat->cat_parent . ",";
                // Print Category Name
                echo "'" . addslashes(htmlspecialchars($cat->cat_name, ENT_QUOTES));
                echo "',";
                echo "pp(" . $cat->cat_id . "),";
                echo "'','',";
                echo "fpath";
                echo ");";
            }
            ?>
					document.write(d);
					
					function pp(cid) {
						return 'index2.php?option=com_mtree&task=listcats&cat_id='+cid;
					}
					//-->
				</script>

				</td></tr>
				<?php 
        }
        # End of  dTree
        # This Directory
        if ($task == 'listcats' || $task == 'editcat' || $task == 'editcat_browse_cat' || $task == 'editcat_add_relcat' || $task == 'editcat_remove_relcat') {
            if ($cat_parent > 0) {
                # Lookup all information about this directory
                $thiscat = new mtCats($database);
                $thiscat->load($cat_parent);
                ?>
				<tr><td colspan="2" align="left" style="color: black; padding-left: 20px;font-weight:bold;background: #DDE1E6 url(../components/com_mtree/img/dtree/folderopen.gif) no-repeat center left; border-bottom: 1px solid #cccccc;border-top: 1px solid #cccccc;"><?php 
                echo JText::_('This category');
                ?>
</td></tr>
				<tr class="row0"><td colspan="2" style="background-color:#F1F3F5">
					<?php 
                $published_img = $thiscat->cat_published ? 'tick.png' : 'publish_x.png';
                $featured_img = $thiscat->cat_featured ? 'tick.png' : 'publish_x.png';
                $tcat = new mtDisplay();
                $tcat->add(JText::_('Name'), '<a href="index2.php?option=com_mtree&task=editcat&cat_id=' . $thiscat->cat_id . '&cat_parent=' . $thiscat->cat_parent . '">' . $thiscat->cat_name . '</a>');
                $tcat->add(JText::_('Cat id'), $thiscat->cat_id);
                $tcat->add(JText::_('Listings'), $thiscat->cat_links);
                $tcat->add(JText::_('Categories'), $thiscat->cat_cats);
                $tcat->add(JText::_('Related categories2'), $thiscat->getNumOfRelCats());
                $tcat->add(JText::_('Published'), '<img src="images/' . $published_img . '" width="12" height="12" border="0" alt="" />');
                $tcat->add(JText::_('Featured'), '<img src="images/' . $featured_img . '" width="12" height="12" border="0" alt="" />');
                $tcat->display();
                ?>
				</td></tr>

				<?php 
            }
            # This Listing
        } elseif ($task == 'editlink' || $task == 'editlink_change_cat' || $task == 'reviews_list' || $task == 'newreview' || $task == 'editreview' || $task == 'editlink_browse_cat' || $task == 'editlink_add_cat' || $task == 'editlink_remove_cat') {
            global $link_id;
            if ($link_id[0] > 0) {
                $thislink = new mtLinks($database);
                $thislink->load($link_id[0]);
                $database->setQuery('SELECT COUNT(*) FROM #__mt_reviews WHERE link_id = ' . $database->quote($link_id[0]) . ' AND rev_approved = 1');
                $reviews = $database->loadResult();
                ?>
				<tr><td colspan="2" align="left" style="color: black; padding-left: 20px;font-weight:bold;background: #DDE1E6 url(../includes/js/ThemeOffice/document.png) no-repeat center left; border-bottom: 1px solid #cccccc;border-top: 1px solid #cccccc;"><?php 
                echo JText::_('This listing');
                ?>
</td></tr>
				<tr class="row0"><td colspan="2" style="background-color:#F1F3F5">
					<?php 
                $tlisting = new mtDisplay();
                $tlisting->add(JText::_('Name'), '<a href="index2.php?option=com_mtree&task=editlink&link_id=' . $thislink->link_id . '">' . $thislink->link_name . '</a>');
                $tlisting->add(JText::_('Listing id'), $thislink->link_id);
                $tlisting->add(JText::_('Category'), '<a href="index2.php?option=com_mtree&task=listcats&cat_id=' . $thislink->cat_id . '">' . $thislink->getCatName() . '</a>');
                $tlisting->add(JText::_('Reviews'), '<a href="index2.php?option=com_mtree&task=reviews_list&link_id=' . $thislink->link_id . '">' . $reviews . '</a>');
                $tlisting->add(JText::_('Hits'), $thislink->link_hits);
                $tlisting->add(JText::_('Modified2'), tellDateTime($thislink->link_modified));
                $tlisting->display();
                ?>
				</td></tr>
						<?php 
            }
        }
        // Search
        $search_text = JRequest::getVar('search_text', '', 'post');
        $search_where = JRequest::getInt('search_where', 0, 'post');
        // 1: Listing, 2: Category
        ?>

				<tr><td colspan="2" style="background: #DDE1E6; border-bottom: 1px solid #cccccc;border-top: 1px solid #cccccc;font-weight:bold;"><?php 
        echo JText::_('Search');
        ?>
</td></tr>
				<tr><td colspan="2" align="left" style="background-color:#F1F3F5">
					<form action="index2.php" method="post">
					<input class="text_area" type="text" name="search_text" size="10" maxlength="250" value="<?php 
        echo $search_text;
        ?>
" /> <input type="submit" value="<?php 
        echo JText::_('Search');
        ?>
" class="button" />
					<select name="search_where" class="inputbox" size="1">
						<option value="1"<?php 
        echo $search_where == 1 ? ' selected' : '';
        ?>
><?php 
        echo JText::_('Listings');
        ?>
</option>
						<option value="2"<?php 
        echo $search_where == 2 ? ' selected' : '';
        ?>
><?php 
        echo JText::_('Categories');
        ?>
</option>
					</select>
					<a href="index2.php?option=com_mtree&task=advsearch"><?php 
        echo JText::_('Advanced search short');
        ?>
</a>
					<input type="hidden" name="option" value="com_mtree" />
					<input type="hidden" name="task" value="search" />
					<input type="hidden" name="limitstart" value="0" />
					</form>
				</td></tr>

				<tr><td colspan="2" style="background: #DDE1E6; border-bottom: 1px solid #cccccc;border-top: 1px solid #cccccc;font-weight:bold;"><?php 
        echo JText::_('More');
        ?>
</td></tr>
				<tr>
					<td style="background: #DDE1E6;"><img src="../components/com_mtree/img/zoom.png" width="16" height="16" /></td>
					<td style="background-color:#F1F3F5">&nbsp;<a class="mt_menu" href="index2.php?option=com_mtree&task=spy"><?php 
        echo JText::_('Spy directory');
        ?>
</a></td>
				</tr>
				<tr>
					<td style="background: #DDE1E6;"><img src="../includes/js/ThemeOffice/config.png" width="16" height="16" /></td>
					<td style="background-color:#F1F3F5">&nbsp;<a class="mt_menu<?php 
        echo $task == "config" ? "_selected" : "";
        ?>
" href="index2.php?option=com_mtree&task=config"><?php 
        echo JText::_('Configuration');
        ?>
</a></td>
				</tr>
				<?php 
        /* ?>
        			<tr>
        				<td style="background: #DDE1E6;"><img src="../components/com_mtree/img/table_link.png" width="16" height="16" /></td>
        				<td style="background-color:#F1F3F5">&nbsp;<a class="mt_menu<?php echo ($task=="linkchecker") ? "_selected": ""; ?>" href="index2.php?option=com_mtree&task=linkchecker"><?php echo JText::_( 'Link checker' ) ?></a></td>
        			</tr>
        			<?php */
        ?>
				<tr>
					<td style="background: #DDE1E6;"><img src="../includes/js/ThemeOffice/template.png" width="16" height="16" /></td>
					<td style="background-color:#F1F3F5">&nbsp;<a class="mt_menu<?php 
        echo $task == "templates" ? "_selected" : "";
        ?>
" href="index2.php?option=com_mtree&task=templates"><?php 
        echo JText::_('Templates');
        ?>
</a></td>
				</tr>
				<tr>
					<td style="background: #DDE1E6;"><img src="../includes/js/ThemeOffice/content.png" width="16" height="16" /></td>
					<td style="background-color:#F1F3F5">&nbsp;<a class="mt_menu<?php 
        echo $task == "customfields" ? "_selected" : "";
        ?>
" href="index2.php?option=com_mtree&task=customfields"><?php 
        echo JText::_('Custom fields');
        ?>
</a></td>
				</tr>

				<tr>
					<td style="background: #DDE1E6;"><img src="../includes/js/ThemeOffice/query.png" width="16" height="16" /></td>
					<td style="background-color:#F1F3F5">&nbsp;<a class="mt_menu<?php 
        echo $task == "csv" ? "_selected" : "";
        ?>
" href="index2.php?option=com_mtree&task=csv"><?php 
        echo JText::_('Export');
        ?>
</a></td>
				</tr>
				<tr>
					<td style="background: #DDE1E6;"><img src="../includes/js/ThemeOffice/globe3.png" width="16" height="16" /></td>
					<td style="background-color:#F1F3F5">&nbsp;<a class="mt_menu" href="index.php?option=com_mtree&amp;task=geocode"><?php 
        echo JText::_('Locate Listings in Map');
        ?>
</a></td>
				</tr>
				<tr>
					<td style="background: #DDE1E6;"><img src="../includes/js/ThemeOffice/globe3.png" width="16" height="16" /></td>
					<td style="background-color:#F1F3F5">&nbsp;<a class="mt_menu" href="index2.php?option=com_mtree&amp;task=globalupdate"><?php 
        echo JText::_('Recount categories listings');
        ?>
</a></td>
				</tr>
				<tr>
					<td style="background: #DDE1E6;"><img src="../includes/js/ThemeOffice/credits.png" width="16" height="16" /></td>
					<td style="background-color:#F1F3F5">&nbsp;<a class="mt_menu<?php 
        echo $task == "about" ? "_selected" : "";
        ?>
" href="index2.php?option=com_mtree&task=about"><?php 
        echo JText::_('About mosets tree');
        ?>
</a></td>
				</tr>

			</table>		
		</td>
		<td valign="top">
		<?php 
    }