layout.php 9.32 KB
Newer Older
Яков's avatar
first  
Яков committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <title><?php include_slot('title', sfConfig::get('app_arm_title')); ?></title>
    <?php
//    <link rel="shortcut icon" href="/i/favicon.ico" type="image/x-icon"/>
    ?>
    <script type="text/javascript">
        var sf_app = '<?php echo sfConfig::get('sf_app');?>';
        var sf_prefix = '<?php echo isset($_SERVER['PATH_PREFIX']) ? $_SERVER['PATH_PREFIX'] : '';?>';
        var sf_user = <?php echo $sf_user->isAuthenticated() ? $sf_user->getUserId() : 'false';?>;
        var sf_user_root = <?php echo ($sf_user->isAuthenticated() ? ($sf_user->getUsername() == 'root' ? 'true' : 'false') : 'false');?>;
        var sf_ws_pub = '<?php echo sfConfig::get('app_ws_pub');?>';
    </script>

    <?php
    include_http_metas();
    include_stylesheets();
    include_javascripts();
    $module_image_sizes = sfConfig::get('app_' . $this->getModuleName() . '_sizes');
    if(is_array($module_image_sizes) && count($module_image_sizes) > 0 && $this->getModuleName() != 'cat'){
        unset($module_image_sizes['min']);
        foreach ($module_image_sizes as $size_key => $size){
            $module_image_size = $size_key;
        }
        if($module_image_size == 'S' || isset($module_image_sizes['equal'])){
            $module_image_size = '';
        }
    }
    if(isset($module_image_size)){
        echo '<script type="text/javascript">ftm.openSize = \'' . $module_image_size . '\';</script>';
    }
    ?>
    <link rel="icon" href="/i/favicon.png" type="image/x-icon">
</head>
<body>
<div class="lui__root">
    <div class="ftm_wrap ftm" onclick="$(this).hide();">
        <div class="ftm__actions">
            <div class="ftm__close"></div>
            <div class="ftm__rotate" title="Повернуть по часовой стрелке" onclick="ftm.rotate(this);event.stopPropagation();return false;"></div>
        </div>
        <table width="100%" height="100%" cellpadding="0" cellspacing="0">
            <tr>
                <td valign="middle" align="center">
                    <div class="fotorama" data-auto="false" onclick="event.stopPropagation();"></div>
                </td>
            </tr>
        </table>
    </div>
    <?php
    if (!$sf_user->isAuthenticated()) {
        echo $sf_content;
    } else {
        ?>
        <table class="lui__desktop" border="0" cellspacing="0" cellpadding="0" width="100%">
            <tr valign="top">
                <td class="lui__desktop_left invert" style="padding-top:20px;">
                    <div class="lui__desktop_left__wrapper">
                        <a href="/" target="_blank"><img class="logo__full" src="/i/logo.svg" hspace="20" width="100" height="51" style="margin: 0 auto; display: block;"/></a>
                        <i class="br20" style="border-bottom:1px solid #393f41"></i>
                        <b class="br20"></b>
                        <div class="lui__nav__wrapper" style="position:relative;">
                            <ul class="lui__nav">
                                <?php
                                function menu_cmp($a, $b)
                                {
                                    if ($a['order'] == $b['order']) {
                                        return 0;
                                    }
                                    return ($a['order'] < $b['order']) ? -1 : 1;
                                }

                                $parser = new sfYamlParser();
                                $modules = glob(sfConfig::get('sf_app_module_dir') . '/*');
                                $links = array();


                                foreach ($modules as $k => $v) {
                                    if (file_exists($v . '/config/generator.yml')) {
                                        $p = $parser->parse(file_get_contents($v . '/config/generator.yml'));
                                        $module = basename($v);

                                        if (!$sf_user->hasCredential($module . '_index') || @$p['generator']['param']['skip'] || @$p['generator']['param']['config']['list']['title'] == '') {
                                            continue;
                                        }


                                        if ($sf_user->getUsername() != 'root' && basename($v) == 'manager') {
                                            continue;
                                        }

                                        $model = str_replace(' ', '', ucwords(str_replace('_', ' ', $module)));

                                        $count = '';

                                        if (class_exists($model) && method_exists($model, 'getMenuCount')) {
                                            $countc = $module::getMenuCount($sf_user);
                                            if ($countc > 0) {
                                                $count = '&nbsp;<span class="lui__nav_menu__count">' . $countc . '</span>';
                                            }
                                        }


                                        $links[] = array(
                                            'm' => $module,
                                            'title' => $p['generator']['param']['config']['list']['title'] . $count,
                                            'order' => isset($p['generator']['param']['order']) ? $p['generator']['param']['order'] : 0,
                                            'group' => isset($p['generator']['param']['group']) ? $p['generator']['param']['group'] : false,
                                            'add' => isset($p['generator']['param']['add']) ? $p['generator']['param']['add'] : true,
                                            'hr' => isset($p['generator']['param']['hr']),
                                        );
                                    }
                                }
                                usort($links, 'menu_cmp');
                                foreach ($links as $k => $v) {
                                    if ($sf_user->hasCredential($v['m'] . '_index')) {
                                        if ($v['group']) {
                                            echo '<i class="br10"></i>';
                                            if ($v['group'] != '-') {
                                                echo '<li><b>' . $v['group'] . '</b></li>';
                                            }
                                        }
                                        echo '<li' . ($this->getModuleName() == $v['m'] ? ' class="current"' : '') . '>';
                                        echo '<a class="lui__nav_a_' . $v['m'] . '" href="' . url_for('@' . $v['m']) . '">' . $v['title'] . '</a>';
                                        echo '</li>';
                                        if ($v['hr'] && $k != count($links) - 1) {
                                            echo '<i class="hr20" style="margin:10px 0;background:#2d3436;"></i>';
                                        }
                                    }
                                }
                                echo '</ul>';
                                echo '</div>';
                                echo '<div class="fixed_user_menu">';
                                echo '<a href="' . url_for('@cs_setting') . '" class="sprite_link sprite_link_settings">Настройки</a><i class="br10"></i>';
                                echo '<a href="' . url_for('@signout') . '" class="sprite_link sprite_link_logout">Выйти</a>';
                                echo '</div>';
                                ?>
                        </div>
                </td>
                <td width="100%" class="lui__desktop_right" height="100%">
                    <div class="lui__desktop_right__wrapper <?php echo sfConfig::get('sf_app') . '_' . $this->getModuleName(); ?>">
                        <?php
                        echo $sf_content;
                        ?>
                    </div>
                </td>
            </tr>
        </table>
        <?php
    }
    ?>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        var calc_lui__nav__wrapper = function () {
            $('.lui__nav__wrapper').height($(window).height() - 200);
            $('.lui__nav__wrapper').perfectScrollbar('update');
        };
        $('.lui__nav__wrapper').perfectScrollbar();
        $('.lui__nav__wrapper').scroll(function () {

            var top = $(this).scrollTop();
            var bottom = $('.lui__nav').outerHeight() - $(this).outerHeight();


            $(this).removeClass('lui__nav__wrapper__sh_top');
            $(this).removeClass('lui__nav__wrapper__sh_bottom');
            $(this).removeClass('lui__nav__wrapper__sh_bottom_top');

            if (bottom < 0) {
                return false;
            }

            if (top == 0) {
                $(this).addClass('lui__nav__wrapper__sh_bottom');
            } else if (top == bottom) {
                $(this).addClass('lui__nav__wrapper__sh_top');
            } else {
                $(this).addClass('lui__nav__wrapper__sh_bottom_top');
            }
        }).scroll();

        $(window).resize(function () {
            calc_lui__nav__wrapper();
            $('.lui__nav__wrapper').scroll();
        }).resize();

    });
</script>
</body>
</html>