Project

General

Profile

« Previous | Next » 

Revision 62691

add joomla 4 folder, add module custom_login

View differences:

modules/uoa-joomla/trunk/joomla-4/modules/mod_custom_login/Helper/Helper.php
1
<?php
2
/**
3
 * @package Joomla.Site
4
 * @subpackage mod_hello
5
 *
6
 * @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
7
 * @license GNU General Public License version 2 or later; see LICENSE.txt
8
 */
9

  
10
namespace Joomla\Module\CustomLogin\Site\Helper;
11
use Joomla\CMS\Factory as JF;
12
// No direct access to this file
13
defined('_JEXEC') or die;
14

  
15
class Helper
16
{
17
    public static function getText()
18
    {
19
        return 'FooHelpertest';
20
    }
21

  
22
    public static function getModules($params)
23
    {
24
        $user = JF::getUser();
25
        if ($user->get('guest')) return '';
26

  
27
        $document = JF::getDocument();
28
        $moduleRender = $document->loadRenderer('module');
29
        $positionRender = $document->loadRenderer('modules');
30

  
31
        $html = '';
32

  
33
        $db = JF::getDbo();
34
        $i = 0;
35
        $module_id = $params->get('module_id', array());
36
        if (count($module_id) > 0) {
37
            $sql = "SELECT * FROM #__modules WHERE id IN (" . implode(',', $module_id) . ") ORDER BY ordering";
38
            $db->setQuery($sql);
39
            $modules = $db->loadObjectList();
40
            foreach ($modules as $module) {
41

  
42
                if ($module->module != 'mod_aai') {
43
                    $i++;
44
                    $html = $html . $moduleRender->render($module->module, array('title' => $module->title, 'style' => 'xhtml'));
45
                    //$html = $html .$moduleRender->render($module->module, array('title' => $module->title, 'style' => 'rounded'));
46
                    //if($i%2==0) $html.="<br clear='both'>";
47
                }
48
            }
49
        }
50
        $module_position = $params->get('module_position', array());
51
        if (count($module_position) > 0) {
52
            foreach ($module_position as $position) {
53
                $modules = JModuleHelper::getModules($position);
54
                foreach ($modules as $module) {
55
                    if ($module->module != 'mod_aai') {
56
                        $i++;
57
                        $html = $html . $moduleRender->render($module, array('style' => 'xhtml'));
58
                        //if($i%2==0) $html.="<br clear='both'>";
59
                    }
60
                }
61
            }
62
        }
63
        if ($html == '') {
64
            $html = $moduleRender->render('mod_menu', array('title' => 'User Menu', 'style' => 'xhtml'));
65
        }
66
        return $html;
67
    }
68
}
modules/uoa-joomla/trunk/joomla-4/modules/mod_custom_login/language/en-GB/en-GB.mod_custom_login.ini
1
MOD_HELLO="[PROJECT_NAME]"
2
MOD_HELLO_XML_DESCRIPTION="Hello Module"
modules/uoa-joomla/trunk/joomla-4/modules/mod_custom_login/mod_custom_login.php
1

  
2

  
3
<?php
4
/**
5
 * @package Custom Login
6
 *
7
 * @author Argiro Kokogiannaki
8
 * @copyright [COPYRIGHT]
9
 * @license GNU General Public License version 2 or later; see LICENSE.txt
10
 */
11

  
12

  
13
// No direct access to this file
14
defined('_JEXEC') or die;
15

  
16
use Joomla\CMS\Helper\ModuleHelper;
17
use Joomla\Module\CustomLogin\Site\Helper\Helper;
18
use Joomla\CMS\Factory as JF;
19

  
20
$test = Helper::getText();
21
$user = JF::getUser();
22
$loggedInHtml = Helper::getModules ( $params );
23
$url = $params->get('LOGIN_URL','1');
24
$user = JFactory::getUser();
25
// $type	= modLoginHelper::getType();
26
require JModuleHelper::getLayoutPath('mod_custom_login');
modules/uoa-joomla/trunk/joomla-4/modules/mod_custom_login/mod_custom_login.xml
1
<?xml version="1.0" encoding="utf-8"?>
2
<extension type="module" version="4.0" client="site" method="upgrade">
3
    <name>Custom login</name>
4
    <creationDate>May 2023</creationDate>
5
    <author>Argiro Kokogiannaki</author>
6
    <authorEmail>argirok@athenarc.gr</authorEmail>
7
    <copyright>[COPYRIGHT]</copyright>
8
    <license>GNU General Public License version 2 or later; see LICENSE.txt</license>
9
    <version>1.0</version>
10
    <description>This modules  can be added in the site header. Shows a login url, and if user is logged in, shows a welcome message, the user name and the user menu.</description>
11
    <namespace>Joomla\Module\CustomLogin</namespace>
12
    <files>
13
        <filename module="mod_custom_login">mod_custom_login.php</filename>
14
        <folder>tmpl</folder>
15
        <folder>Helper</folder>
16
        <folder>language</folder>
17
        <filename>mod_custom_login.xml</filename>
18
    </files>
19
    <config>
20
        <fields name="params">
21
            <fieldset name="basic">
22
                <field type="text" name="LOGIN_TEXT" label="LOGIN TEXT" size="15" required="true" default="Sign In"/>
23
                <field type="text" name="LOGIN_URL" label="LOGIN URL" size="64" required="true"
24
                       default="https://beta.openaire.eu/?morequest=oauthredirect&amp;app_name=other"/>
25
                <field type="text" name="WELCOME_TEXT" label="WELCOME TEXT" size="15" required="true"
26
                       default="Hi, "/>
27
                <field name="name" type="list" label="User info shown in welcome" default="false">
28
                    <option value="true">Name</option>
29
                    <option value="false">Username</option>
30
                </field>
31
            </fieldset>
32
        </fields>
33
    </config>
34
</extension>
modules/uoa-joomla/trunk/joomla-4/modules/mod_custom_login/tmpl/default.php
1
<?php
2
/**
3
 * @package Custom Login
4
 *
5
 * @author Argiro Kokogiannaki
6
 * @copyright [COPYRIGHT]
7
 * @license GNU General Public License version 2 or later; see LICENSE.txt
8
 */
9

  
10
// No direct access to this file
11
defined('_JEXEC') or die;
12

  
13
if ($user->id != 0) {
14
//do user logged out stuff
15
    echo('<ul id="custom_login_link" class="uk-navbar-nav"><li class="uk-parent"><a>');
16
    if ($params->get('name')) : {
17
        echo $params->get('WELCOME_TEXT') . ' ' . $user->get('name');
18
    } else : {
19
        echo $params->get('WELCOME_TEXT') . ' ' . $user->get('username');
20
    } endif;
21
    echo('</a>');
22

  
23

  
24
    echo('<div uk-dropdown>');
25

  
26
    if ($loggedInHtml) {
27
        echo('<ul class="uk-nav uk-dropdown-nav">');
28
        echo $loggedInHtml;
29
        echo('</ul>');
30
    }
31
    echo('</div></li></ul>');
32

  
33
} else {
34
//do user logged in stuff
35
    echo('<ul id="custom_login_user_menu" class="uk-navbar-nav"><li class="uk-parent"><a href="' . $params->get('LOGIN_URL') . '" style="padding-left: 20px; padding-right: 5px;">' . $params->get('LOGIN_TEXT') . '</a></li></ul>');
36

  
37
}
38
?>

Also available in: Unified diff