Ejemplo n.º 1
0
 function shAppendCat($cat_id, $option, $shLangName)
 {
     $sefConfig =& Sh404sefFactory::getConfig();
     $sef = array();
     $pathWay = new mtPathWay($cat_id);
     $pathway_ids = $pathWay->getPathWay($cat_id);
     switch ($sefConfig->shMTreeInsertCategories) {
         case '1':
             // only last cat
             if ($cat_id > 0) {
                 //this is not root we must use this cat
                 $sef[] = ($sefConfig->shMTreeInsertCategoryId ? $cat_id . $sefConfig->replacement : '') . $pathWay->getCatName($cat_id);
             }
             //else // this is root, don't add cat name
             shRemoveFromGETVarsList('cat_id');
             break;
         case '0':
             // if no cat, we still put them all. This param only applies to listing links
         // if no cat, we still put them all. This param only applies to listing links
         case '2':
             // we want all cats
             foreach ($pathway_ids as $id) {
                 $sef[] = ($sefConfig->shMTreeInsertCategoryId ? $id . $sefConfig->replacement : '') . $pathWay->getCatName($id);
             }
             // If curreny category is not root, append to sefstring
             if ($cat_id > 0) {
                 $sef[] = ($sefConfig->shMTreeInsertCategoryId ? $cat_id . $sefConfig->replacement : '') . $pathWay->getCatName($cat_id);
             }
             shRemoveFromGETVarsList('cat_id');
             break;
     }
     return $sef;
 }
Ejemplo n.º 2
0
 function plugin($cat_id, $attr = null)
 {
     require_once JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_mtree' . DS . 'admin.mtree.class.php';
     $mtPathWay = new mtPathWay($cat_id);
     $cat_ids = $mtPathWay->getPathWay();
     $cat_ids[] = $cat_id;
     $cat_names = array();
     if (empty($cat_ids[0])) {
         $cat_names[] = JText::_('Root');
     }
     foreach ($cat_ids as $cid) {
         // Do not add 'Root' name since its done above already
         if ($cid > 0) {
             $cat_names[] = $mtPathWay->getCatName($cid);
         }
     }
     $html = '<a href="';
     $html .= JRoute::_('index.php?option=com_mtree&task=listcats&cat_id=' . $cat_id);
     $html .= '"';
     # Insert attributes
     if (is_array($attr)) {
         // from array
         foreach ($attr as $key => $val) {
             $key = htmlspecialchars($key);
             $val = htmlspecialchars($val);
             $html .= " {$key}=\"{$val}\"";
         }
     } elseif (!is_null($attr)) {
         // from scalar
         $html .= " {$attr}";
     }
     # set the listing text, close the tag
     $html .= '>' . htmlspecialchars(implode(JText::_('Arrow'), $cat_names)) . '</a> ';
     return $html;
 }
Ejemplo n.º 3
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}");
    }
}