Blame view

libraries/nextend2/nextend/library/applications/system/backend/controllers/Settings.php 2.51 KB
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
<?php

class N2SystemBackendSettingsController extends N2BackendController
{

    protected function initLayout() {
        if (N2Request::getVar('layout') == 'modal') {
            $this->layoutName = 'modal';
        }
        parent::initLayout();
    }

    public function actionIndex() {
        if ($this->canDo('nextend_config')) {

            $data = N2Post::getVar('global');
            if (is_array($data)) {
                if ($this->validateToken()) {
                    N2Settings::setAll($data);
                } else {
                    $this->refresh();
                }
            }


            $this->addView("../../inline/sidebar/settings", array(
                "appObj" => $this
            ), "sidebar");

            $this->addView("index");
            $this->render();
        } else {
            $this->noAccess();
        }
    }

    public function actionAviary() {
        if ($this->canDo('nextend_config')) {
            N2Loader::import('libraries.image.aviary');
            $aviary = N2Request::getVar('aviary', false);
            if ($aviary) {
                if ($this->validateToken()) {
                    N2ImageAviary::storeSettings($aviary);
                    N2Message::success(n2_('Saved.'));
                    N2Request::redirect($this->appType->router->createUrl(array(
                        "settings/aviary",
                        array(
                            'layout' => N2Request::getCmd('layout', '')
                        )
                    )));
                } else {
                    $this->refresh();
                }
            }

            $this->addView("../../inline/sidebar/settings", array(
                "appObj" => $this
            ), "sidebar");

            $this->addView("aviary");
            $this->render();
        }
    }

    public function actionFonts() {
        if ($this->canDo('nextend_config')) {
            $fonts = N2Request::getVar('fonts', false);
            if ($fonts) {
                if ($this->validateToken()) {
                    N2Fonts::storeSettings($fonts);
                    N2Message::success(n2_('Saved.'));
                    N2Request::redirect($this->appType->router->createUrl(array("settings/fonts")));
                } else {
                    $this->refresh();
                }
            }

            $this->addView("../../inline/sidebar/settings", array(
                "appObj" => $this
            ), "sidebar");

            $this->addView("fonts");
            $this->render();
        }
    }

}