Created
September 24, 2014 08:43
-
-
Save nielsnuebel/64ed8f24153b129867bb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * sopro | |
| * @package SOPRO | |
| * @author Niels Nübel <n.nuebel@nn-medienagentur.de> / Robert Deutz <rdeutz@gmail.com> | |
| * @copyright NN-Medienagentur.de / Robert Deutz Business Solution - www.rdbs.de | |
| * @license GNU General Public License version 2 or later | |
| **/ | |
| defined('_JEXEC') or die; | |
| /** | |
| * Build the route for the com_sopro component | |
| * @param array &$query An array of URL arguments | |
| * | |
| * @return array The URL arguments to use to assemble the subsequent URL. | |
| */ | |
| function SoproBuildRoute(&$query) | |
| { | |
| $segments = array(); | |
| if(isset($query['task'])) | |
| { | |
| $segments[] = $query['task']; | |
| unset( $query['task'] ); | |
| } | |
| if(isset( $query['layout'] )) | |
| { | |
| if($query['layout']=='item') | |
| $segments[] = 'profil'; | |
| else | |
| $segments[] = $query['layout']; | |
| unset( $query['layout'] ); | |
| }; | |
| if( isset($query['id']) ) | |
| { | |
| $segments[] = $query['id']; | |
| unset( $query['id'] ); | |
| }; | |
| if( isset($query['tagid']) ) | |
| { | |
| $segments[] = $query['tagid']; | |
| unset( $query['tagid'] ); | |
| }; | |
| if(isset($query['view']) and $query['view']=='upload') | |
| { | |
| $segments[] = $query['view']; | |
| }; | |
| unset($query['view']); | |
| return $segments; | |
| } | |
| /** | |
| * Parse the segments of a URL. | |
| * | |
| * @param array $segments The segments of the URL to parse. | |
| * | |
| * @return array The URL attributes to be used by the application. | |
| */ | |
| function SoproParseRoute($segments) | |
| { | |
| $vars = array(); | |
| $app = JFactory::getApplication(); | |
| $menu = $app->getMenu(); | |
| $item = $menu->getActive(); | |
| // Count segments | |
| $count = count( $segments ); | |
| //Handle View and Identifier | |
| switch($segments[0]) | |
| { | |
| case 'hero': | |
| $vars['layout'] = $segments[0]; | |
| $id = explode( ':', $segments[$count-1] ); | |
| $vars['id'] = (int) $id[0]; | |
| $vars['view'] = 'profile'; | |
| break; | |
| case 'list': | |
| $vars['layout'] = $segments[0]; | |
| $id = explode( ':', $segments[$count-1] ); | |
| $vars['tagid'] = (int) $id[0]; | |
| $vars['view'] = 'profiles'; | |
| break; | |
| case 'upload': | |
| $vars['layout'] = 'default'; | |
| $vars['view'] = 'upload'; | |
| break; | |
| case 'profil': | |
| $vars['layout'] = 'item'; | |
| $id = explode( ':', $segments[$count-1] ); | |
| $vars['id'] = (int) $id[0]; | |
| $vars['view'] = 'profile'; | |
| break; | |
| case 'vote': | |
| $vars['task'] = 'vote'; | |
| $id = explode( ':', $segments[$count-1] ); | |
| $vars['id'] = (int) $id[0]; | |
| $vars['view'] = 'profile'; | |
| break; | |
| } | |
| return $vars; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment