Эх сурвалжийг харах

Adding login form in front page.

Julio Montoya 10 жил өмнө
parent
commit
a9b9c8d1ed

+ 0 - 2
app/Resources/views/Themes/page.html.twig

@@ -1,2 +0,0 @@
-{% extends '::base.html.twig' %}
-{% block theme 'page' %}

+ 0 - 313
app/Resources/views/base.html.twig

@@ -1,313 +0,0 @@
-{% set _preview      = block('preview') %}
-{% set _form         = block('form') %}
-{% set _show         = block('show') %}
-{% set _list_table   = block('list_table') %}
-{% set _list_filters = block('list_filters') %}
-{% set _tab_menu     = block('tab_menu') %}
-{% set _content      = block('content') %}
-{% set _title        = block('title') %}
-{% set _breadcrumb   = block('breadcrumb') %}
-{% set _actions      = block('actions') %}
-{% set _navbar_title = block('navbar_title') %}
-<!DOCTYPE html>
-<!--[if lt IE 7]> <html lang="{{ app.request.locale }}" class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
-<!--[if IE 7]>    <html lang="{{ app.request.locale }}" class="no-js lt-ie9 lt-ie8"> <![endif]-->
-<!--[if IE 8]>    <html lang="{{ app.request.locale }}" class="no-js lt-ie9"> <![endif]-->
-<!--[if gt IE 8]><!--><html lang="{{ app.request.locale }}" class="no-js"> <!--<![endif]-->
-<head>
-{% block head %}
-    <noscript>{{ "NoJavascript"|trans }}</noscript>
-    <meta charset="UTF-8" />
-    <link href="http://www.chamilo.org/documentation.php" rel="help" />
-    <link href="http://www.chamilo.org/team.php" rel="author" />
-    <link href="http://www.chamilo.org" rel="copyright" />
-    <link rel="shortcut icon" href="{{ asset('favicon.ico') }}" />
-    <link rel="shortcut icon" href="{{ asset('apple-touch-icon.png') }}" />
-    <meta name="apple-mobile-web-app-capable" content="yes" />
-    <meta name="Generator" content="{{ software_name }} {{ version }}" />
-    {#  Use the latest engine in ie8/ie9 or use google chrome engine if available  #}
-    {#  Improve usability in portal devices #}
-    <meta http-equiv="X-UA-Compatible" content="IE=edge">
-    <meta name="viewport" content="width=device-width, initial-scale=1.0">
-    <title>{% block title %}{% endblock %}</title>
-
-    {% block stylesheets %}
-        <link href="{{ asset('assetic/sonata_formatter_css.css') }}" rel="stylesheet" media="screen">
-        <link href="{{ asset('assetic/sonata_admin_css.css') }}" rel="stylesheet" media="screen">
-        <link href="{{ asset('assetic/sonata_jqueryui_css.css') }}" rel="stylesheet" media="screen">
-
-        <link href="{{ asset('ChamiloLMS/css/base.css') }}" rel="stylesheet" media="screen">
-        <link href="{{ asset('ChamiloLMS/css/themes/chamilo/default.css') }}" rel="stylesheet" media="screen">
-    {% endblock %}
-
-    {% block javascripts %}
-        <script src="{{ asset('assetic/sonata_admin_js.js') }}" type="text/javascript"></script>
-        <script src="{{ asset('assetic/sonata_formatter_js.js') }}" type="text/javascript"></script>
-        <script src="{{ asset('assetic/sonata_jqueryui_js.js') }}" type="text/javascript"></script>
-    {% endblock %}
-
-    {% block header_end %}{% endblock header_end %}
-    <script>
-    function setCheckbox(value, table_id) {
-        checkboxes = $("#"+table_id+" input:checkbox");
-        $.each(checkboxes, function(index, checkbox) {
-            checkbox.checked = value;
-            if (value) {
-                $(checkbox).parentsUntil("tr").parent().addClass("row_selected");
-            } else {
-                $(checkbox).parentsUntil("tr").parent().removeClass("row_selected");
-            }
-        });
-        return false;
-    }
-
-    function action_click(element, table_id) {
-        d = $("#"+table_id);
-        if (!confirm('{{ "ConfirmYourChoice"|trans }}')) {
-            return false;
-        } else {
-            var action =$(element).attr("data-action");
-            $('#'+table_id+' input[name="action"] ').attr("value", action);
-            d.submit();
-            return false;
-        }
-    }
-
-    /* Global chat variables */
-    {#
-    var ajax_url        = '{{ _p.web_ajax }}chat.ajax.php';
-    var online_button   = '{{ online_button |e('js') }}';
-    var offline_button  = '{{ offline_button |e('js') }}';
-        #}
-    var connect_lang    = '{{ "ChatConnected"|trans |e('js') }}';
-    var disconnect_lang = '{{ "ChatDisconnected"|trans |e('js') }}';
-
-    function get_url_params(q, attribute) {
-        var vars;
-        var hash;
-        if (q != undefined) {
-            q = q.split('&');
-            for(var i = 0; i < q.length; i++){
-                hash = q[i].split('=');
-                if (hash[0] == attribute) {
-                    return hash[1];
-                }
-            }
-        }
-    }
-
-    function check_brand() {
-        if ($('.subnav').length) {
-            if ($(window).width() >= 969) {
-                $('.subnav .brand').hide();
-            } else {
-                $('.subnav .brand').show();
-            }
-        }
-    }
-
-    $(window).resize(function() {
-        //check_brand();
-    });
-
-    $(document).scroll(function() {
-
-        // Top bar scroll effect
-        if ($('body').width() > 959) {
-            if ($('.subnav').length) {
-                if (!$('.subnav').attr('data-top')) {
-                    // If already fixed, then do nothing
-                    if ($('.subnav').hasClass('subnav-fixed')) return;
-                    // Remember top position
-                    var offset = $('.subnav').offset();
-                    $('.subnav').attr('data-top', offset.top);
-                }
-
-                if ($('.subnav').attr('data-top') - $('.subnav').outerHeight() <= $(this).scrollTop()) {
-                    $('.subnav').addClass('subnav-fixed');
-                } else {
-                    $('.subnav').removeClass('subnav-fixed');
-                }
-                //$('.subnav .brand').show();
-            }
-        } else {
-            //$('.subnav .brand').hide();
-        }
-
-        //Exercise warning fixed at the top
-        var fixed =  $("#exercise_clock_warning");
-        if (fixed.length) {
-            if (!fixed.attr('data-top')) {
-                // If already fixed, then do nothing
-                if (fixed.hasClass('subnav-fixed')) return;
-                // Remember top position
-                var offset = fixed.offset();
-                fixed.attr('data-top', offset.top);
-                fixed.css('width', '100%');
-            }
-
-            if (fixed.attr('data-top') - fixed.outerHeight() <= $(this).scrollTop()) {
-                fixed.addClass('subnav-fixed');
-                fixed.css('width', '100%');
-            } else {
-                fixed.removeClass('subnav-fixed');
-                fixed.css('width', '200px');
-            }
-        }
-
-        // Admin -> Settings toolbar.
-        if ($('body').width() > 959) {/*
-         if ($('.new_actions').length) {
-         if (!$('.new_actions').attr('data-top')) {
-         // If already fixed, then do nothing
-         if ($('.new_actions').hasClass('new_actions-fixed')) return;
-         // Remember top position
-         var offset = $('.new_actions').offset();
-
-         var more_top = 0;
-         if ($('.subnav').hasClass('new_actions-fixed')) {
-         more_top = 50;
-         }
-         $('.new_actions').attr('data-top', offset.top + more_top);
-         }
-
-         if ($('.new_actions').attr('data-top') - $('.new_actions').outerHeight() <= $(this).scrollTop()) {
-         $('.new_actions').addClass('new_actions-fixed');
-         } else {
-         $('.new_actions').removeClass('new_actions-fixed');
-         }
-         }*/
-        }
-
-        // Bottom actions.
-        if ($('.bottom_actions').length) {
-            if (!$('.bottom_actions').attr('data-top')) {
-                // If already fixed, then do nothing
-                if ($('.bottom_actions').hasClass('bottom_actions_fixed')) return;
-
-                // Remember top position
-                var offset = $('.bottom_actions').offset();
-                $('.bottom_actions').attr('data-top', offset.top);
-            }
-
-            if ($('.bottom_actions').attr('data-top') > $('body').outerHeight()) {
-                if ( ($('.bottom_actions').attr('data-top') - $('body').outerHeight() - $('.bottom_actions').outerHeight()) >= $(this).scrollTop()) {
-                    $('.bottom_actions').addClass('bottom_actions_fixed');
-                    $('.bottom_actions').css("width", "100%");
-                } else {
-                    $('.bottom_actions').css("width", "");
-                    $('.bottom_actions').removeClass('bottom_actions_fixed');
-                }
-            } else {
-                if ( ($('.bottom_actions').attr('data-top') -  $('.bottom_actions').outerHeight()) <= $(this).scrollTop()) {
-                    $('.bottom_actions').addClass('bottom_actions_fixed');
-                    $('.bottom_actions').css("width", "100%");
-                } else {
-                    $('.bottom_actions').removeClass('bottom_actions_fixed');
-                    $('.bottom_actions').css("width", "");
-                }
-            }
-        }
-    });
-
-    $(function() {
-        check_brand();
-        //Removes the yellow input in Chrome
-        if (navigator.userAgent.toLowerCase().indexOf("chrome") >= 0) {
-            $(window).load(function(){
-                $('input:-webkit-autofill').each(function(){
-                    var text = $(this).val();
-                    var name = $(this).attr('name');
-                    $(this).after(this.outerHTML).remove();
-                    //var has_string = $(name).find(":contains('[')");
-                    $('input[name=' + name + ']').val(text);
-                });
-            });
-        }
-
-        // Fixes buttons to the new btn class.
-        if (!$('#button').hasClass('btn')) {
-            $("button").addClass('btn');
-        }
-
-        // Dropdown effect.
-        $('.dropdown-toggle').dropdown();
-
-        // Responsive effect.
-        //$(".collapse").collapse();
-
-        /*$(".accordion_jquery").accordion({
-            autoHeight: false,
-            active: false, // all items closed by default
-            collapsible: true,
-            header: ".accordion-heading"
-        });*/
-
-        // Global popup
-        $('.ajax').on('click', function() {
-            var url     = this.href;
-            var dialog  = $("#dialog");
-            if ($("#dialog").length == 0) {
-                dialog  = $('<div id="dialog" style="display:none"></div>').appendTo('body');
-            }
-
-            width_value = 580;
-            height_value = 450;
-            resizable_value = true;
-
-            new_param = get_url_params(url, 'width');
-            if (new_param) {
-                width_value = new_param;
-            }
-
-            new_param = get_url_params(url, 'height')
-            if (new_param) {
-                height_value = new_param;
-            }
-
-            new_param = get_url_params(url, 'resizable');
-            if (new_param) {
-                resizable_value = new_param;
-            }
-
-            // load remote content
-            dialog.load(url,{}, function(responseText, textStatus, XMLHttpRequest) {
-                dialog.dialog({
-                    modal       : true,
-                    width       : width_value,
-                    height      : height_value,
-                    resizable   : resizable_value
-                });
-            });
-            //prevent the browser to follow the link
-            return false;
-        });
-
-        //old jquery.menu.js
-        $('#navigation a').stop().animate({
-            'marginLeft':'50px'
-        }, 1000);
-
-        $('#navigation > li').hover(
-                function () {
-                    $('a',$(this)).stop().animate({
-                        'marginLeft':'1px'
-                    },200);
-                },
-                function () {
-                    $('a',$(this)).stop().animate({
-                        'marginLeft':'50px'
-                    },200);
-                }
-        );
-    });
-    </script>
-    {% block extraHead %}
-    {% endblock %}
-{% endblock %}
-</head>
-
-<body class="{% block theme %}default{% endblock %} sonata-bc skin-black fixed">
-{% block layout %}{% endblock %}
-</body>
-</html>

+ 19 - 1
app/Resources/views/layout.html.twig

@@ -19,7 +19,25 @@
 
 {% block avanzu_sidebar %}
     {{ parent() }}
-
+    {% if is_granted('IS_AUTHENTICATED_FULLY') %}
     {{ mopa_bootstrap_menu('ChamiloLMSCoreBundle:SimpleMenuBuilder:mainMenu', {'automenu': 'pills', 'stacked':true}) }}
+    {% endif %}
+
+    {% if is_granted('IS_AUTHENTICATED_FULLY') == false %}
+        <form action="{{ path("fos_user_security_check") }}" method="post" role="form">
+            <input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}"/>
+            <div class="form-group">
+                <label for="username">{{ 'security.login.username'|trans({}, 'SonataUserBundle') }}</label>
+                <input type="text" class="form-control" id="username" name="_username" >
+            </div>
+            <div class="form-group">
+                <label for="password">{{ 'security.login.password'|trans({}, 'SonataUserBundle') }}</label>
+                <input type="password" class="form-control" id="password" name="_password">
+            </div>
+            <button type="submit" class="btn btn-default">Submit</button>
+        </form>
+    {% endif %}
+
+    {{ mopa_bootstrap_menu('ChamiloLMSCoreBundle:SimpleMenuBuilder:helpMenu', {'automenu': 'pills', 'stacked':true}) }}
 
 {% endblock %}

+ 0 - 1
app/config/config.yml

@@ -79,7 +79,6 @@ twig:
       "%kernel.root_dir%/../src/ChamiloLMS/CoreBundle/Resources/views/default": template_style
 
     globals:
-
       show_toolbar: true
       show_footer: true
       software_name:

+ 1 - 1
src/Application/Sonata/UserBundle/Resources/views/Security/base_login.html.twig

@@ -1,6 +1,6 @@
 {% extends "SonataUserBundle::layout.html.twig" %}
 
-{% block fos_user_content %}123
+{% block fos_user_content %}
     <div class="row">
         <div class="col-sm-6">
             {% block sonata_user_login %}

+ 1 - 3
src/Application/Sonata/UserBundle/Resources/views/Security/login.html.twig

@@ -17,9 +17,7 @@
                   class="form-horizontal">
 
                 <div class="body bg-gray">
-
-                    <input type="hidden" name="_csrf_token" value="{{ csrf_token }}"/>
-
+                    <input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}"/>
                     <div class="form-group">
                         <label for="username"
                                class="col-sm-4 control-label">{{ 'security.login.username'|trans({}, 'SonataUserBundle') }}</label>

+ 1 - 2
src/ChamiloLMS/CoreBundle/Controller/FrontController.php

@@ -24,10 +24,9 @@ class FrontController extends Controller
      */
     public function showLoginAction()
     {
-        $csrfToken = $this->container->get('form.csrf_provider')->generateCsrfToken('authenticate');
         return $this->render(
             'ChamiloLMSCoreBundle:Security:only_login.html.twig',
-            array('error' => null, 'csrf_token' => $csrfToken)
+            array('error' => null)
         );
     }
 

+ 1 - 2
src/ChamiloLMS/CoreBundle/Controller/IndexController.php

@@ -66,13 +66,12 @@ class IndexController extends BaseController
         }
 
         $announcementsBlock = $pageController->getAnnouncements();
-
         return $this->render(
             'ChamiloLMSCoreBundle:Index:index.html.twig',
             array(
                 'content' => 'hello',
                 'hot_courses' => $hotCourses,
-                'announcements_block' => $announcementsBlock,
+                'announcements_block' => $announcementsBlock
                 //'home_page_block' => $pageController->returnHomePage()
             )
         );

+ 17 - 4
src/ChamiloLMS/CoreBundle/Menu/SimpleMenuBuilder.php

@@ -14,6 +14,21 @@ use Symfony\Component\DependencyInjection\ContainerAware;
  */
 class SimpleMenuBuilder extends ContainerAware
 {
+    public function helpMenu(FactoryInterface $factory, array $options)
+    {
+        $menu = $factory->createItem('main');
+
+        $child = $menu->addChild(
+            'Help',
+            array(
+                'route' => 'userportal',
+                array("attributes" => array("id" => 'nav'))
+            )
+        );
+
+        return $menu;
+    }
+
     /**
      * Creates the header menu
      *
@@ -53,15 +68,13 @@ class SimpleMenuBuilder extends ContainerAware
         );
 
         $child = $menu->addChild(
-            'Administration',
+            'Settings',
             array(
-                'route' => 'sonata_admin_dashboard',
+                'uri' => '/main/admin/settings.php',
                 array("attributes" => array("id" => 'nav'))
             )
         );
 
-
-
         /*
         $dropdownExtrasOptions = $isFooter ? array(
             'uri' => "#",