Completed
Push — master ( d674d6...6c0c4d )
by Michael
04:12 queued 02:03
created

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * Main page for the Xoops Partners Module
4
 *
5
 * LICENSE
6
 *
7
 * You may not change or alter any portion of this comment or credits
8
 * of supporting developers from this source code or any supporting source code
9
 * which is considered copyrighted (c) material of the original comment or credit authors.
10
 *
11
 * @copyright   The XOOPS Project http://sourceforge.net/projects/xoops/
12
 * @license     http://www.fsf.org/copyleft/gpl.html GNU public license
13
 * @author      Andricq Nicolas (AKA MusS)
14
 * @version     $Id: index.php 9326 2012-04-14 21:53:58Z beckmi $
15
 * @since       2.3.0
16
 */
17
 
18
// Include header
19
include_once 'header.php';
20
// Get class handler
21
$category_handler = &xoops_getModuleHandler( 'category' );
22
$partners_handler = &xoops_getModuleHandler( 'partners' );
23
24
$cat_id = xoopsPartners_CleanVars( $_REQUEST, 'cat_id', 0, 'int' );
25
if ( $cat_id < 1 ) {
26
    // Define template file
27
    $xoopsOption['template_main'] = 'xoopspartners_index.html';
28
    // Include Xoops header
29
    include XOOPS_ROOT_PATH . '/header.php';
30
    // Add module stylesheet and scripts
31
    $xoTheme->addStylesheet( XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/css/class.css', null );
32
    $xoTheme->addStylesheet( XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/css/module.css', null );
33
    $xoTheme->addScript( XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/js/functions.js', null, '' );
34
    
35
    $xoopsTpl->assign('module_name', $xoopsModule->getVar('name', 's'));
36
    
37
    $objects = $category_handler->getObj();
38 View Code Duplication
    if ( $objects['count'] > 0 ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
39
        foreach( $objects['list'] as $object ) {
40
            $category = array();
41
            $category['id']   = $object->getVar( 'cat_id' );
42
            $category['name'] = $object->getVar( 'cat_title' );
43
            $category['desc'] = $object->getVar( 'cat_description' );
44
45
            $contentsObj = $partners_handler->getActive( $object->getVar( 'cat_id' ) );
46
            if ( $contentsObj['count'] ) {
47
                foreach( $contentsObj['list'] as $content ) {
48
                    $category['partners'][] = $content->toArray();
49
                }
50
            }
51
            $xoopsTpl->append_by_ref( 'categories', $category );
52
            unset( $category );
53
        }
54
    }
55
56
} else {
57
    // Define template file
58
    $xoopsOption['template_main'] = 'xoopspartners_category.html';
59
    // Include Xoops header
60
    include XOOPS_ROOT_PATH . '/header.php';
61
    // Add module stylesheet and scripts
62
    $xoTheme->addStylesheet( XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/css/class.css', null );
63
    $xoTheme->addStylesheet( XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/css/module.css', null );
64
    $xoTheme->addScript( XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/js/functions.js', null, '' );
65
    // Template variables
66
    $xoopsTpl->assign('module_name', $xoopsModule->getVar('name', 's'));
67
    $cat = $category_handler->get( $cat_id );
68
    $xoopsTpl->assign('category', $cat->toArray());
69
    $partners = $partners_handler->getActive( $cat_id );
70
    if ( $partners['count'] > 0 ) {
71
        foreach( $partners['list'] as $partner ) {
72
            $xoopsTpl->append_by_ref( 'list', $partner->toArray() );
73
        }
74
    }
75
}
76
// Include Xoops footer
77
include_once XOOPS_ROOT_PATH . '/footer.php';
78