Esempio n. 1
0
 /**
  * Prepares the stream items for mosets tree
  *
  * @since   1.3
  * @access  public
  * @param   string
  * @return  
  */
 public function onPrepareStream(SocialStreamItem &$stream, $includePrivacy = true)
 {
     if (!$this->exists() || $stream->context != 'mtree') {
         return;
     }
     // Decorate the stream
     $stream->display = SOCIAL_STREAM_DISPLAY_FULL;
     $stream->color = '#6f90b5';
     $stream->fonticon = 'ies-comments-2';
     $stream->label = JText::_('APP_USER_MTREE_STREAM_LABEL');
     // Get the link object
     $db = JFactory::getDbo();
     $link = new mtLinks($db);
     $link->load($stream->contextId);
     $this->decorate($link);
     $this->set('actor', $stream->actor);
     $this->set('link', $link);
     $stream->title = parent::display('streams/title');
     $stream->content = parent::display('streams/content');
 }
Esempio n. 2
0
             $title = shAppendListing($mtLink->link_name, $mtLink->link_id, false, $shLangIso, $option, $shLangName);
         } else {
             $title = array_merge($title, shAppendListing($mtLink->link_name, $mtLink->link_id, false, $shLangIso, $option, $shLangName));
         }
         $title[] = $sh_LANG[$shLangIso]['_MT_SEF_EDIT_LISTING'];
     } else {
         $dosef = false;
     }
     break;
     # Delete listing
 # Delete listing
 case 'deletelisting':
     if (!empty($link_id)) {
         $database = JFactory::getDbo();
         $mtLink = new mtLinks($database);
         $mtLink->load($link_id);
         if ($sefConfig->shMTreeInsertCategories > 0) {
             if (empty($title)) {
                 $title = shAppendCat($mtLink->cat_id, $option, $shLangName);
             } else {
                 $title = array_merge($title, shAppendCat($mtLink->cat_id, $option, $shLangName));
             }
         }
         if (empty($title)) {
             $title = shAppendListing($mtLink->link_name, $mtLink->link_id, false, $shLangIso, $option, $shLangName);
         } else {
             $title = array_merge($title, shAppendListing($mtLink->link_name, $mtLink->link_id, false, $shLangIso, $option, $shLangName));
         }
         $title[] = $sh_LANG[$shLangIso]['_MT_SEF_DELETE_LISTING'];
     } else {
         $dosef = false;
Esempio n. 3
0
function editlisting($link_id, $option)
{
    global $savantConf, $Itemid, $mtconf;
    $database =& JFactory::getDBO();
    $my =& JFactory::getUser();
    $document =& JFactory::getDocument();
    require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'mfields.class.php';
    # Get cat_id if user is adding new listing.
    $cat_id = JRequest::getInt('cat_id', 0);
    // This var retrieve the link_id for adding listing
    $link_id_passfromurl = JRequest::getInt('link_id', 0);
    if ($link_id_passfromurl > 0 && $cat_id == 0) {
        $database->setQuery("SELECT cat_id FROM (#__mt_links AS l, #__mt_cl AS cl) WHERE l.link_id ='" . $link_id_passfromurl . "' AND cl.link_id = l.link_id");
        $cat_id = $database->loadResult();
    }
    $link = new mtLinks($database);
    # Do not allow Guest to edit listing
    if ($link_id > 0 && $my->id <= 0) {
        $link->load(0);
    } else {
        $link->load($link_id);
    }
    # Load all published CORE & custom fields
    $sql = "SELECT cf.*, " . ($link_id ? $link_id : 0) . " AS link_id, cfv.value AS value, cfv.attachment, cfv.counter, ft.ft_class FROM #__mt_customfields AS cf " . "\nLEFT JOIN #__mt_cfvalues AS cfv ON cf.cf_id=cfv.cf_id AND cfv.link_id = " . $link_id . "\nLEFT JOIN #__mt_fieldtypes AS ft ON ft.field_type=cf.field_type" . "\nWHERE cf.hidden ='0' AND cf.published='1' ORDER BY ordering ASC";
    $database->setQuery($sql);
    $fields = new mFields();
    $fields->setCoresValue($link->link_name, $link->link_desc, $link->address, $link->city, $link->state, $link->country, $link->postcode, $link->telephone, $link->fax, $link->email, $link->website, $link->price, $link->link_hits, $link->link_votes, $link->link_rating, $link->link_featured, $link->link_created, $link->link_modified, $link->link_visited, $link->publish_up, $link->publish_down, $link->metakey, $link->metadesc, $link->user_id, '');
    $fields->loadFields($database->loadObjectList());
    # Load images
    $database->setQuery("SELECT img_id, filename FROM #__mt_images WHERE link_id = '" . $link_id . "' ORDER BY ordering ASC");
    $images = $database->loadObjectList();
    # Get current category's template
    $database->setQuery("SELECT cat_name, cat_parent, cat_template, metakey, metadesc FROM #__mt_cats WHERE cat_id='" . $cat_id . "' AND cat_published='1' LIMIT 1");
    $cat = $database->loadObject();
    if ($link->link_id == 0) {
        if ($cat) {
            $document->setTitle(sprintf(JText::_('Add listing2'), $cat->cat_name));
        } else {
            $document->setTitle(JText::_('Add listing'));
        }
    } else {
        $document->setTitle(sprintf(JText::_('Edit listing2'), $link->link_name));
    }
    if (isset($cat->cat_template) && $cat->cat_template != '') {
        loadCustomTemplate(null, $savantConf, $cat->cat_template);
    }
    # Get other categories
    $database->setQuery("SELECT cl.cat_id FROM #__mt_cl AS cl WHERE cl.link_id = '{$link_id}' AND cl.main = '0'");
    $other_cats = $database->loadResultArray();
    # Pathway
    $pathWay = new mtPathWay($cat_id);
    $pw_cats = $pathWay->getPathWayWithCurrentCat($cat_id);
    $pathWayToCurrentCat = '';
    $mtCats = new mtCats($database);
    $pathWayToCurrentCat = ' <a href="' . JRoute::_("index.php?option=com_mtree&task=listcats&Itemid=" . $Itemid) . '">' . JText::_('Root') . "</a>";
    foreach ($pw_cats as $pw_cat) {
        $pathWayToCurrentCat .= JText::_('Arrow') . ' <a href="' . JRoute::_("index.php?option=com_mtree&task=listcats&cat_id=" . $pw_cat . "&Itemid=" . $Itemid) . '">' . $mtCats->getName($pw_cat) . "</a>";
    }
    # Savant Template
    $savant = new Savant2($savantConf);
    assignCommonVar($savant);
    $savant->assign('pathway', $pathWay);
    $savant->assign('pathWayToCurrentCat', $pathWayToCurrentCat);
    $savant->assign('cat_id', $link_id == 0 ? $cat_id : $link->cat_id);
    $savant->assign('other_cats', $other_cats);
    $savant->assignRef('link', $link);
    $savant->assignRef('fields', $fields);
    $savant->assignRef('images', $images);
    if ($mtconf->get('image_maxsize') > 1048576) {
        $savant->assign('image_size_limit', round($mtconf->get('image_maxsize') / 1048576, 1) . 'MB');
    } else {
        $savant->assign('image_size_limit', round($mtconf->get('image_maxsize') / 1024) . 'KB');
    }
    # Check permission
    if ($mtconf->get('user_addlisting') == 1 && $my->id < 1 || $link_id > 0 && $my->id == 0) {
        $savant->assign('error_msg', JText::_('Please login before addlisting'));
        $savant->display('page_error.tpl.php');
    } elseif ($link_id > 0 && $my->id != $link->user_id || $mtconf->get('user_allowmodify') == 0 && $link_id > 0 || $mtconf->get('user_addlisting') == -1 && $link_id == 0 || $mtconf->get('user_addlisting') == 1 && $my->id == 0) {
        echo _NOT_EXIST;
    } else {
        // OK, you can edit
        $database->setQuery("SELECT CONCAT('cust_',cf_id) as varname, caption As value, field_type, prefix_text_mod, suffix_text_mod FROM #__mt_customfields WHERE hidden <> '1' AND published = '1'");
        $custom_fields = $database->loadObjectList('varname');
        $savant->assign('custom_fields', $custom_fields);
        # Load custom fields' value from #__mt_cfvalues to $link
        $database->setQuery("SELECT CONCAT('cust_',cf_id) as varname, value FROM #__mt_cfvalues WHERE link_id = '" . $link_id . "'");
        $cfvalues = $database->loadObjectList('varname');
        foreach ($custom_fields as $cfkey => $value) {
            if (isset($cfvalues[$cfkey])) {
                $savant->custom_data[$cfkey] = $cfvalues[$cfkey]->value;
            } else {
                $savant->custom_data[$cfkey] = '';
            }
        }
        // Get category's tree
        if ($mtconf->get('allow_changing_cats_in_addlisting')) {
            getCatsSelectlist($cat_id, $cat_tree, 1);
            if ($cat_id > 0) {
                $cat_options[] = JHTML::_('select.option', $cat->cat_parent, JText::_('Arrow back'));
            }
            if ($mtconf->get('allow_listings_submission_in_root')) {
                $cat_options[] = JHTML::_('select.option', '0', JText::_('Root'));
            }
            if (count($cat_tree) > 0) {
                foreach ($cat_tree as $ct) {
                    if ($ct["cat_allow_submission"] == 1) {
                        $cat_options[] = JHTML::_('select.option', $ct["cat_id"], str_repeat("&nbsp;", $ct["level"] * 3) . ($ct["level"] > 0 ? " -" : '') . $ct["cat_name"]);
                    } else {
                        $cat_options[] = JHTML::_('select.option', $ct["cat_id"] * -1, str_repeat("&nbsp;", $ct["level"] * 3) . ($ct["level"] > 0 ? " -" : '') . "(" . $ct["cat_name"] . ")");
                    }
                }
            }
            $catlist = JHTML::_('select.genericlist', $cat_options, 'new_cat_id', 'size=8 class="inputbox"', 'value', 'text', '', 'browsecat');
            $savant->assignRef('catlist', $catlist);
        }
        // Give warning is there is already a pending approval for modification.
        if ($link_id > 0) {
            $database->setQuery("SELECT link_id FROM #__mt_links WHERE link_approved = '" . -1 * $link_id . "'");
            if ($database->loadResult() > 0) {
                $savant->assign('warn_duplicate', 1);
            } else {
                $savant->assign('warn_duplicate', 0);
            }
        }
        $savant->assign('pathWay', $pathWay);
        $savant->display('page_addListing.tpl.php');
    }
}
Esempio n. 4
0
function MtreeBuildRoute(&$query)
{
    global $mtconf, $listing_tasks;
    $segments = array();
    $db =& JFactory::getDBO();
    if (!class_exists('mtLinks')) {
        require_once $mtconf->getjconf('absolute_path') . '/administrator/components/com_mtree/admin.mtree.class.php';
    }
    if (!isset($query['task'])) {
        return $segments;
    }
    switch ($query['task']) {
        case 'listcats':
            if (isset($query['cat_id'])) {
                $segments = appendCat($query['cat_id']);
                unset($query['cat_id']);
                if (isset($query['start'])) {
                    $page = getPage($query['start'], $mtconf->get('fe_num_of_links'));
                    $segments[] = $mtconf->get('sef_category_page') . $page;
                }
            }
            break;
        case 'viewlink':
            $mtLink = new mtLinks($db);
            $mtLink->load($query['link_id']);
            $segments = array_merge($segments, appendCat($mtLink->cat_id));
            if (isset($query['start'])) {
                //	http://example.com/c/mtree/Computer/Games/Donkey_Kong/reviews23
                $page = getPage($query['start'], $mtconf->get('fe_num_of_reviews'));
                $segments = array_merge($segments, appendListing($mtLink->link_name, $mtLink->link_id, $mtLink->alias, false));
                $segments[] = $mtconf->get('sef_reviews_page') . $page;
            } else {
                $segments = array_merge($segments, appendListing($mtLink->link_name, $mtLink->link_id, $mtLink->alias, false));
            }
            unset($query['link_id']);
            break;
        case 'mypage':
            $segments[] = $mtconf->get('sef_mypage');
            if (isset($query['start'])) {
                $page = getPage($query['start'], $mtconf->get('fe_num_of_links'));
                $segments[] = $mtconf->get('sef_category_page') . $page;
            }
            break;
        case 'listfeatured':
        case 'listnew':
        case 'listupdated':
        case 'listfavourite':
        case 'listpopular':
        case 'listmostrated':
        case 'listtoprated':
        case 'listmostreview':
            $type = strtoupper(substr($query['task'], 4));
            $cat_id = getId('cat', $query);
            $segments = appendCat($cat_id);
            $segments[] = $mtconf->get('sef_' . strtolower($type));
            if (isset($query['start'])) {
                $page = getPage($query['start'], $mtconf->get('fe_num_of_' . strtolower($type)));
                $segments[] = $mtconf->get('sef_category_page') . $page;
            }
            break;
        case 'advsearch':
            $segments[] = $mtconf->get('sef_advsearch');
            break;
        case 'advsearch2':
            $segments[] = $mtconf->get('sef_advsearch2');
            $search_id = getId('search', $query);
            $page = 1;
            if (isset($query['start'])) {
                $page = getPage($query['start'], $mtconf->get('fe_num_of_searchresults'));
                $segments[] = $search_id;
                $segments[] = $page;
            } else {
                $segments[] = $search_id;
            }
            break;
        case 'listalpha':
            $cat_id = getId('cat', $query);
            $segments = appendCat($cat_id);
            $segments[] = $mtconf->get('sef_listalpha');
            $segments[] = urlencode($query['alpha']);
            unset($query['alpha']);
            if (isset($query['start'])) {
                $page = getPage($query['start'], $mtconf->get('fe_num_of_links'));
                $segments[] = $page;
            }
            break;
        case 'viewowner':
        case 'viewusersreview':
        case 'viewusersfav':
            $user_id = getId('user', $query);
            $db->setQuery("SELECT username FROM #__users WHERE id= " . $db->quote($user_id) . " AND block='0'");
            $username = $db->loadResult();
            if (!empty($username)) {
                switch ($query['task']) {
                    default:
                        $segments[] = $mtconf->get('sef_owner');
                        break;
                    case 'viewusersreview':
                        $segments[] = $mtconf->get('sef_reviews');
                        break;
                    case 'viewusersfav':
                        $segments[] = $mtconf->get('sef_favourites');
                        break;
                }
                $segments[] = murlencode($username);
            }
            if (isset($query['start'])) {
                $page = getPage($query['start'], $mtconf->get('fe_num_of_links'));
                $segments[] = $page;
            }
            break;
        case 'viewimage':
            $segments[] = $mtconf->get('sef_image');
            $segments[] = getId('img', $query);
            break;
        case 'replyreview':
            $segments[] = $mtconf->get('sef_replyreview');
            $segments[] = getId('rev', $query);
            break;
        case 'reportreview':
            $segments[] = $mtconf->get('sef_reportreview');
            $segments[] = getId('rev', $query);
            break;
            // Listing's tasks
        // Listing's tasks
        case array_key_exists($query['task'], $listing_tasks) !== false:
            $mtLink = new mtLinks($db);
            $mtLink->load($query['link_id']);
            $segments = appendCatListing($mtLink, false);
            $segments[] = $listing_tasks[$query['task']];
            unset($query['link_id']);
            break;
        case 'addlisting':
        case 'addcategory':
            if (isset($query['link_id'])) {
                $mtLink = new mtLinks($db);
                $mtLink->load(getId('link', $query));
                $segments = appendCat($mtLink->cat_id);
            } elseif (isset($query['cat_id'])) {
                $segments = appendCat(getId('cat', $query));
            }
            if ($query['task'] == 'addlisting') {
                $segments[] = $mtconf->get('sef_addlisting');
            } else {
                $segments[] = $mtconf->get('sef_addcategory');
            }
            break;
        case 'searchby':
            $cf_id = getId('cf', $query);
            $cat_id = getId('cat', $query);
            $segments = appendCat($cat_id);
            $segments[] = $mtconf->get('sef_searchby');
            $segments[] = appendTag($cf_id);
            $segments[] = $query['value'];
            if (isset($query['start'])) {
                $page = getPage($query['start'], $mtconf->get('fe_num_of_searchresults'));
                $segments[] = $page;
            }
            unset($query['value']);
            break;
        case 'search':
            $cat_id = getId('cat', $query);
            $segments = appendCat($cat_id);
            $segments[] = $mtconf->get('sef_search');
            $badchars = array('#', '>', '<', '\\');
            $searchword = urldecode(trim(str_replace($badchars, '', $query['searchword'])));
            // limit searchword to 20 characters
            if (JString::strlen($searchword) > 20) {
                $searchword = JString::substr($searchword, 0, 19);
            }
            if (strpos($searchword, '?') !== false or strpos($searchword, '%') !== false or strpos($searchword, '/') !== false) {
                $searchword = urlencode($searchword);
            }
            $searchword = urlencode($searchword);
            if (isset($searchword) && !empty($searchword)) {
                $segments[] = $searchword;
            }
            // Retrieve configuration options - needed to know which SEF URLs are used
            $app =& JFactory::getApplication();
            // Allows for searching on strings that include ".xxx" that appear to Apache as an extension
            if ($app->getCfg('sef') && $app->getCfg('sef_rewrite') && !$app->getCfg('sef_suffix') && strpos($searchword, '.') !== false) {
                $segments[] .= '/';
            }
            unset($query['searchword']);
            break;
        case 'rss':
            $cat_id = getId('cat', $query);
            $segments = appendCat($cat_id);
            $segments[] = $mtconf->get('sef_rss');
            if (isset($query['type']) && $query['type'] == 'new') {
                $segments[] = $mtconf->get('sef_rss_new');
            } else {
                $segments[] = $mtconf->get('sef_rss_updated');
            }
            unset($query['type']);
            break;
    }
    if ($query['task'] != 'search') {
        unset($query['start']);
    }
    unset($query['limit']);
    unset($query['task']);
    return $segments;
}
Esempio n. 5
0
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);
    }
}
Esempio n. 6
0
function mtAppendPathWay($option, $task, $cat_id = 0, $link_id = 0, $img_id = 0)
{
    global $mainframe, $Itemid;
    $database =& JFactory::getDBO();
    $mtPathWay = new mtPathWay();
    $pathway =& $mainframe->getPathway();
    switch ($task) {
        case "listcats":
        case "addcategory":
            // Show "Add Category Path?"
            $cids = $mtPathWay->getPathWay($cat_id);
            break;
        case "viewlink":
        case "writereview":
        case "rate":
        case "recommend":
        case "viewgallery":
            $mtLink = new mtLinks($database);
            $mtLink->load($link_id);
            $cat_id = $mtLink->getCatID();
            $cids = $mtPathWay->getPathWay($cat_id);
            break;
        case "viewimage":
            if ($img_id > 0) {
                $database->setQuery('SELECT link_id FROM #__mt_images WHERE img_id = \'' . $img_id . '\' LIMIT 1');
                $link_id = $database->loadResult();
                if (!is_null($link_id)) {
                    $mtLink = new mtLinks($database);
                    $mtLink->load($link_id);
                    $cat_id = $mtLink->getCatID();
                    $cids = $mtPathWay->getPathWay($cat_id);
                }
            }
            break;
            // Adding listing from a category
        // Adding listing from a category
        case "addlisting":
            if ($cat_id > 0) {
                $cids = $mtPathWay->getPathWay($cat_id);
            } elseif ($link_id > 0) {
                $mtLink = new mtLinks($database);
                $mtLink->load($link_id);
                $cat_id = $mtLink->getCatID();
                $cids = $mtPathWay->getPathWay($cat_id);
            }
            // Show "Add Listing" Path?
            break;
        case "listnew":
            $pathway->addItem(JText::_('New listing'));
            break;
        case "listfeatured":
            $pathway->addItem(JText::_('Featured listing'));
            break;
        case "listpopular":
            $pathway->addItem(JText::_('Popular listing'));
            break;
        case "listmostrated":
            $pathway->addItem(JText::_('Most rated listing'));
            break;
        case "listtoprated":
            $pathway->addItem(JText::_('Top rated listing'));
            break;
        case "listmostreview":
            $pathway->addItem(JText::_('Most reviewed listing'));
            break;
        case "advsearch":
            $pathway->addItem(JText::_('Advanced search'));
            break;
        case "advsearch2":
            $pathway->addItem(JText::_('Advanced search results'));
            break;
        case "search":
            $pathway->addItem(JText::_('Search results'));
            break;
    }
    if (isset($cids) && is_array($cids) && count($cids) > 0) {
        foreach ($cids as $cid) {
            $pathway->addItem($mtPathWay->getCatName($cid), "index.php?option={$option}&task=listcats&cat_id={$cid}");
        }
        // Append the curreny category name
        $pathway->addItem($mtPathWay->getCatName($cat_id), "index.php?option={$option}&task=listcats&cat_id={$cat_id}");
    } elseif ($cat_id > 0) {
        $pathway->addItem($mtPathWay->getCatName($cat_id), "index.php?option={$option}&task=listcats&cat_id={$cat_id}");
    }
    if (in_array($task, array("viewlink", "writereview", "rate", "recommend", "viewgallery"))) {
        $pathway->addItem($mtLink->link_name, "index.php?option={$option}&task=viewlink&link_id={$link_id}");
    }
}
Esempio n. 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 
    }