<?php 

defined('_JEXEC') or die;

//JLoader::register('ContentHelper', JPATH_ADMINISTRATOR . '/components/com_content/helpers/content.php');
//JLoader::register('CategoryHelperAssociation', JPATH_ADMINISTRATOR . '/components/com_categories/helpers/association.php');

//abstract class Os_cckHelperAssociation extends CategoryAssociationHelper{
abstract class Os_cckHelperAssociation{


    public static function getAssociations($id = 0, $view = null){
        $input = JFactory::getApplication()->input;
        
        if($input->get('task', '') != '' || $input->get('view', '') != ''){
            
            $task = ($input->get('task', '') != '') ? $input->get('task', '') : $input->get('view', '');
            
            JLoader::import('helpers.route', JPATH_COMPONENT_SITE);
            $lid = intval(mosGetParam($_REQUEST, 'lid', 0));
            if($task == 'category'){

                $catid = intval(mosGetParam($_REQUEST, 'catid', 0));
                if($catid == 0){
                    $menu = new JTableMenu(JFactory::getDBO());
                    $menu->load(protectInjectionWithoutQuote('Itemid', 0, 'INT'));
                    $params = new JRegistry;
                    if($menu->params){
                      $params->loadString($menu->params);
                    }                    
                    $catid = $params->get('category', 0);
                    $lid = $params->get('category_layout', 0);
                }
                
                if($catid){
                    $rederectUrlArr = OSCCKHelperRoute::getCCKAssocCategoryRoute($catid, $lid);
                    return $rederectUrlArr;
                }                       
            }

            if($task == 'instance'){                


                $id = intval(mosGetParam($_REQUEST, 'eiid', 0));
                        
                if ($id){
                    $rederectUrlArr = OSCCKHelperRoute::getCCKAssocPropertyRoute($id, $lid);
                    return $rederectUrlArr;
                }
            }
            
            if($task == 'parent_child'){                


                $id = intval(mosGetParam($_REQUEST, 'eiid', 0));
                        
                if ($id){
                    $rederectUrlArr = OSCCKHelperRoute::getCCKAssocParentChildRoute($id, $lid);
                    return $rederectUrlArr;
                }
            }

            if($task == 'cart'){                


                                
                if ($lid){
                    
                    $rederectUrlArr = OSCCKHelperRoute::getCCKAssocCartRoute($lid);
                    return $rederectUrlArr;
                }
            }
        }
        return array();  
    }
}
