Last commit for src/views/elements/WelcomemenuElement.php: 2addb500315b7393a90fe66431d7832b1e7386c7

Adjust copyrights years

Chris Pollett [2024-01-03 21:Jan:rd]
Adjust copyrights years
<?php
/**
 * SeekQuarry/Yioop --
 * Open Source Pure PHP Search Engine, Crawler, and Indexer
 *
 * Copyright (C) 2009 - 2023  Chris Pollett chris@pollett.org
 *
 * LICENSE:
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *
 * END LICENSE
 *
 * @author Chris Pollett chris@pollett.org
 * @license https://www.gnu.org/licenses/ GPL3
 * @link https://www.seekquarry.com/
 * @copyright 2009 - 2023
 * @filesource
 */
namespace seekquarry\yioop\views\elements;

use seekquarry\yioop as B;
use seekquarry\yioop\configs as C;
use seekquarry\yioop\library as L;

/**
 * Element responsible for drawing the side menu portion of an admin
 * page. This allows the user to signout or select from among allowed admin
 * activities
 *
 * @author Chris Pollett
 */
class WelcomemenuElement extends Element
{
    /**
     * Method responsible for drawing the side menu portion of welcome
     * part of an admin  page. This allows the user to signout or go to
     * the account home
     *
     * @param array $data has info draw activity links on page
     */
    public function render($data)
    {
        $logged_in = !empty($data["ADMIN"]);
        $token_string = ($logged_in) ? C\CSRF_TOKEN . "=" . $data[C\CSRF_TOKEN]
            : "";
        $logo = C\LOGO_MEDIUM;
        $register_url = htmlentities(B\controllerUrl('register', true));
        if ($_SERVER["MOBILE"]) {
            $logo = C\LOGO_SMALL;
        }?>
        <?php
        if (!$logged_in) {?>
            <nav id="welcome-menu-options" class="menu-options">
            <?php $this->view->helper("hamburger")->render(
                $logged_in, false); ?>
            <h2><a href="<?=C\SHORT_BASE_URL ?><?php
            ?>"><img src="<?= C\SHORT_BASE_URL . $logo ?>" alt="<?=
            $this->view->logo_alt_text ?>" ></a></h2>
            <h2 class="menu-option-heading"><?=
                tl('welcomehmenu_element_welcome') ?></h2>
                <ul class='square-list'>
                <li><a href="<?= B\controllerUrl('admin') ?>"><?=
                tl('welcomemenu_element_signin') ?></a></li><?php
                if (in_array(C\REGISTRATION_TYPE, ['no_activation',
                    'email_registration', 'admin_activation'])) { ?>
                    <li><a href="<?=rtrim($register_url .
                        "a=createAccount&amp;" .
                        $token_string, "?&amp;") ?>"><?=
                        tl('welcomemenu_element_create_account')
                        ?></a></li>
                    <?php
                }?>
                </ul>
            </nav><?php
            return;
        }?>
        <nav id="welcome-menu-options" class="menu-options">
            <?php $this->view->helper("hamburger")->render(
                $logged_in, false); ?>
            <h2><a href="<?=C\SHORT_BASE_URL ?><?php
            if ($logged_in) {
                e("?$token_string");
            }
            ?>"><img src="<?= C\SHORT_BASE_URL . $logo ?>" alt="<?=
            $this->view->logo_alt_text ?>" ></a></h2>
            <?php
            $activities = array_shift($data['COMPONENT_ACTIVITIES']);
            if (empty($activities[0]['METHOD_NAME']) ||
                $activities[0]['METHOD_NAME'] != 'manageAccount') {
                return;
            }
            $component_name = tl('welcomemenu_element_welcome_user',
                $_SESSION['USER_NAME']);
            $count = count($activities);
            ?>
            <h2 class="menu-option-heading"><?=$component_name ?></h2>
            <ul class='square-list'>
            <li><a href='<?= B\controllerUrl("admin", true) .
                C\CSRF_TOKEN . "=" . $data[C\CSRF_TOKEN] . "&amp;a=" .
                $activities[0]['METHOD_NAME']?>' ><?=
                tl('welcomemenu_element_account_home');
            ?></a></li>
            <li><b><a href="<?=C\SHORT_BASE_URL ?>?a=signout"><?=
                tl('welcomemenu_element_signout') ?></a></b></li>
            </ul>
        </nav>
        <?php
    }
}
ViewGit