Esempio n. 1
0
 /**
  * 生成面包屑
  * @return type
  */
 public static function createBreadcrumbs()
 {
     $topMenu = LsYii::getApp()->controller->topMenu;
     $sideMenu = LsYii::getApp()->controller->sideMenu;
     $lastBreadcrumb = LsYii::getApp()->controller->lastBreadcrumb;
     if ($topMenu) {
         $tModel = Menu::getMenu($topMenu);
     }
     //后台一级菜单
     if ($sideMenu) {
         $sModel = Menu::getMenu($sideMenu);
     }
     //后台三级菜单
     //获取其中的二级菜单
     if (isset($sModel) && !empty($sModel)) {
         $mModel = Menu::getMenu($sModel->pid);
     }
     //获取二级菜单
     if (isset($tModel) && !empty($sModel)) {
         $tBreadcrumbs = ['label' => $tModel->name, 'url' => [$tModel->url]];
     }
     if (isset($mModel) && !empty($mModel)) {
         $mBreadcrumbs = ['label' => $mModel->name, 'url' => [$mModel->url]];
     }
     if (isset($sModel) && !empty($sModel)) {
         $sBreadcrumbs = ['label' => $sModel->name, 'url' => [$sModel->url]];
     }
     $lBreadcrumbs = ['label' => $lastBreadcrumb];
     $arr[] = isset($tBreadcrumbs) ? $tBreadcrumbs : "";
     $arr[] = isset($mBreadcrumbs) ? $mBreadcrumbs : "";
     $arr[] = isset($sBreadcrumbs) ? $sBreadcrumbs : "";
     $arr[] = isset($lastBreadcrumb) ? ['label' => LsYii::gT($lastBreadcrumb)] : "";
     $arr = array_filter($arr);
     return $arr;
 }
Esempio n. 2
0
 /**
  * 保存记录
  * @param type $model
  */
 protected static function saveInternal($attributes)
 {
     if ($attributes) {
         foreach ($attributes as $key => $value) {
             $cmodel = Config::findOne(['`key`' => $key]);
             if (!$cmodel) {
                 $cmodel = new Config();
                 $cmodel->key = $key;
                 $cmodel->value = $value ? $value : '';
                 $cmodel->save();
             } else {
                 if ($cmodel->value != $value) {
                     $cmodel->value = $value ? $value : '';
                     $cmodel->save();
                 }
             }
             if ($key == 'site_language') {
                 //写入语言的配置文件
                 $configFile = LsYii::getWebPath('/common/config/main-local.php');
                 FileHelper::writeConfig($configFile, ['language' => $value]);
             }
             if ($key == 'datetime_timezone') {
                 //写入时间的配置文件
                 $configFile = LsYii::getWebPath('/common/config/main-local.php');
                 FileHelper::writeConfig($configFile, ['timezone' => $value]);
             }
         }
     }
     return true;
 }
Esempio n. 3
0
 /**
  * Lists all User models.
  * @return mixed
  */
 public function actionIndex()
 {
     $this->setMenus(16, "注册会员管理");
     $searchModel = new UserSearch();
     LsYii::setGetValue('role', Role::Category_Member);
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
Esempio n. 4
0
 /**
  * 生成保存与关闭的按钮
  * @param type $submitText
  * @param type $closeLink
  */
 public static function SubmitButtons($submitText, $closeLink = null)
 {
     echo Html::beginTag('div', ['class' => 'form-group center']);
     echo Html::submitButton(LsYii::gT($submitText), ['class' => 'btn btn-primary', 'name' => 'save']);
     if ($closeLink !== null) {
         echo Html::a(LsYii::gT("Return"), $closeLink, ['name' => 'close', 'class' => 'btn btn-default', 'style' => 'margin-left:10px;']);
     }
     echo Html::endTag('div');
 }
Esempio n. 5
0
 public function __get($name)
 {
     $dot = strpos($name, "Service");
     if ($dot > 0) {
         $serviceName = substr($name, 0, $dot);
         return LsYii::getService($serviceName);
     }
     return parent::__get($name);
 }
Esempio n. 6
0
 /**
  * Validates the password.
  * This method serves as the inline validation for password.
  *
  * @param string $attribute the attribute currently being validated
  * @param array $params the additional name-value pairs given in the rule
  */
 public function validatePassword($attribute, $params)
 {
     if (!$this->hasErrors()) {
         $user = $this->getUser();
         if (!$user || !$user->validatePassword($this->password, $user->password_hash)) {
             $this->addError($attribute, \source\LsYii::gT('用户名或者密码错误'));
         }
     }
 }
Esempio n. 7
0
 public static function setMenus($category = 'system')
 {
     if ($category == 'controller') {
         $sideMenu = 47;
     } else {
         $sideMenu = 48;
     }
     $item = self::getCategoryItems($category);
     LsYii::getApp()->controller->setMenus($sideMenu, $item);
 }
Esempio n. 8
0
 /**
  * 检测用户是否已经完成了安装程序[在登录安装模块时]
  * @return 返回是否已经完成了安装,如果完成了安装则返回true,否则则返回false
  */
 public static function checkIsInstalled()
 {
     $installfile = Constants::getCommonUrl(Constants::InstallFile_Url);
     $db = LsYii::getApp()->components['db'];
     if (file_exists($installfile) && isset($db['class']) && !empty($db['class'])) {
         return true;
     } else {
         return false;
     }
 }
 public function actionBaidu()
 {
     $this->setMenus(51, "百度第三方登录");
     $model = new BaiduConfig();
     if ($model->load(LsYii::getRequest()->post())) {
         $model->save($model->attributes);
         LsYii::setSuccessMessage(LsYii::gT('save success'));
     } else {
         $model = $model->initValue();
     }
     return $this->render('baidu', ['model' => $model]);
 }
Esempio n. 10
0
 /**
  * 页面输入错误消息
  * @return string
  */
 public static function getErrorMessage()
 {
     $flash = LsYii::getFlash('error');
     if (!empty($flash)) {
         $message = Html::beginTag('div', ['class' => 'alert alert-danger alert-dismissible fade in', 'role' => 'alert']);
         $message .= $flash;
         $message .= Html::endTag('div');
         LsYii::getView()->registerJs("\$(function(){\n                setTimeout(function(){\n                    \$('div.alert-danger').remove();\n                } , 3000);\n            })", BackView::POS_END);
     } else {
         $message = '';
     }
     return $message;
 }
Esempio n. 11
0
 public function beforeAction($action)
 {
     if (!parent::beforeAction($action)) {
         return fale;
     }
     //1.检查不需要验证的方法
     if (in_array($action->uniqueID, $this->ignoreLogin())) {
         return parent::beforeAction($action);
     }
     //检查用户是否登录
     if (LsYii::getIsGuest()) {
         return $this->redirect(['site/login']);
     }
     return parent::beforeAction($action);
 }
Esempio n. 12
0
 public function loadActiveModules($isAdmin)
 {
     $moduleManager = $this->modularityService;
     $this->activeModules = $moduleManager->getActiveModules($isAdmin);
     //        \source\helpers\VarDumper::dump($this->activeModules);die;
     $module = $isAdmin ? "admin\\AdminModule" : "home\\HomeModule";
     foreach ($this->activeModules as $m) {
         $moduleId = $m['id'];
         $moduleDir = $m['dir'];
         $ModuleClassName = $m['dirClass'];
         $this->setModule($moduleId, ['class' => 'source\\modules\\' . $moduleDir . '\\' . $module]);
         $serviceFile = LsYii::getAlias('@source') . '\\modules\\' . $moduleDir . '\\' . $ModuleClassName . 'Service.php';
         if (FileHelper::exist($serviceFile)) {
             $serviceClass = 'source\\modules\\' . $moduleDir . '\\' . $ModuleClassName . 'Service';
             $serviceInstance = new $serviceClass();
             $this->set($serviceInstance->getServiceId(), $serviceInstance);
         }
     }
 }
Esempio n. 13
0
 public function actionLogin()
 {
     $this->layout = 'login';
     if (!\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $model = new LoginForm();
     $message = [];
     if ($model->load(LsYii::getRequest()->post())) {
         if ($model->login()) {
             $this->redirect(\source\helpers\Url::to(['index']));
         } else {
             foreach ($model->getErrors() as $errors) {
                 foreach ($errors as $error) {
                     $message[] = $error;
                 }
             }
         }
     }
     return $this->render('login', ['model' => $model, 'message' => !empty($message) ? $message[0] : '']);
 }
Esempio n. 14
0
 public function loadAllModules()
 {
     if ($this->allModules !== null) {
         return $this->allModules;
     }
     $this->allModules = [];
     $moduleRootPath = LsYii::getAlias('@source') . '/modules';
     if ($moduleRootDir = dir($moduleRootPath)) {
         while (($moduleFolder = $moduleRootDir->read()) !== false) {
             $currentModuleDir = $moduleRootPath . '/' . $moduleFolder;
             if (preg_match('|^\\.+$|', $moduleFolder) || !is_dir($currentModuleDir)) {
                 continue;
             }
             $moduleClassName = ucwords($moduleFolder);
             if (FileHelper::exist($currentModuleDir . '/' . $moduleClassName . 'Info.php')) {
                 $class = 'source\\modules\\' . $moduleFolder . '\\' . $moduleClassName . 'Info';
             } else {
                 continue;
             }
             $instance = null;
             try {
                 $instance = new $class();
                 if (empty($instance->id)) {
                     $instance->id = $moduleFolder;
                 }
                 if (empty($instance->name)) {
                     $instance->name = $moduleFolder;
                 }
             } catch (Exception $ex) {
                 $instance = null;
             }
             if ($instance !== null) {
                 $hasAdmin = FileHelper::exist($currentModuleDir . '/admin/AdminModule.php') ? true : false;
                 $hasHome = FileHelper::exist($currentModuleDir . '/home/HomeModule.php') ? true : false;
                 $this->allModules[$instance->id] = ['id' => $instance->id, 'dir' => $moduleFolder, 'dirClass' => $moduleClassName, 'class' => $class, 'instance' => $instance, 'canInstall' => true, 'canUninstall' => true, 'hasAdmin' => $hasAdmin, 'hasHome' => $hasHome, 'canActiveAdmin' => false, 'canActiveHome' => false];
             }
         }
     }
     return $this->allModules;
 }
Esempio n. 15
0
<?php

use source\helpers\Html;
use source\LsYii;
use source\modules\rbac\models\Role;
/* @var $this yii\web\View */
/* @var $model source\modules\rbac\models\Role */
$category = LsYii::getGetValue('category');
$this->title = "新建" . Role::getCategoryItems($category);
echo source\libs\Message::getMessage();
?>
<div class="page-header">
    <h3>
        <strong><?php 
echo Html::encode($this->title);
?>
</strong>
    </h3>
</div>
<div class="role-create">
    <?php 
echo $this->render('_form', ['model' => $model]);
?>

</div>
Esempio n. 16
0
 public function init()
 {
     parent::init();
     LsYii::getResponse()->on(Response::EVENT_AFTER_SEND, [$this, 'afterResponse']);
 }
Esempio n. 17
0
                <div class="col-md-2">
                    <div class="bs-sidebar hidden-print affix-top">
                        <?php 
$topMenu = LsYii::getApp()->controller->topMenu;
$menus = Menu::getMenuArray($topMenu, 3);
$html = '';
if ($menus) {
    $html .= '<ul class="nav bs-sidenav" style="height:567px">';
    foreach ($menus as $menu) {
        $html .= '<li class="active"><a href="javascript:void(0)"> ' . $menu->name . ' </a></li>';
        //查询四级子菜单
        $childMenus = Menu::getMenuArray($menu->id, 4);
        if ($childMenus) {
            $html .= '<ul class="nav">';
            foreach ($childMenus as $childMenu) {
                if (LsYii::getApp()->controller->sideMenu == $childMenu->id) {
                    $class = 'class="active"';
                } else {
                    $class = '';
                }
                $html .= '<li ' . $class . '><a href="' . Url::to([$childMenu->url]) . '">' . $childMenu->name . '</a></li>';
            }
            $html .= '</ul>';
        }
    }
    $html .= '</ul>';
}
echo $html;
?>
                    </div>
                </div>
Esempio n. 18
0
use source\models\User;
use source\libs\Constants;
use source\modules\rbac\models\Role;
/* @var $this yii\web\View */
/* @var $searchModel source\models\search\UserSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = '注册会员';
echo source\libs\Message::getMessage();
?>
<div class="page-header">
    <h3>
        <strong><?php 
echo Html::encode($this->title);
?>
</strong>
        <div class="pull-right">
            <?php 
echo Html::a('<span class="glyphicon glyphicon-plus"></span> ' . LsYii::gT('添加' . $this->title), ['/user/member/create'], ['class' => 'btn btn-primary']);
?>
        </div>
    </h3>
</div>
<div class="user-index">
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['attribute' => 'username', 'value' => 'username'], ['attribute' => 'email', 'value' => 'email'], ['attribute' => 'status', 'filter' => Constants::getStatusItems(), 'content' => function ($model, $key, $index, $gridView) {
    return Constants::getStatusItems($model->status);
}], ['attribute' => 'role', 'value' => 'role', 'filter' => Role::getMemberItems()], ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>
Esempio n. 19
0
 public function init()
 {
     parent::init();
     $this->modularityService = LsYii::getService('modularity');
 }
Esempio n. 20
0
<?php

use source\LsYii;
use source\helpers\Html;
use source\core\widgets\ActiveForm;
use source\helpers\Url;
use source\libs\Constants;
use source\libs\Message;
/* @var $this yii\web\View */
/* @var $model backend\models\config\BasicConfig */
/* @var $form ActiveForm */
$this->title = LsYii::gT('Register And Visit');
echo Message::getMessage();
?>
<div class="page-header">
    <h3>
        <strong><?php 
echo Html::encode($this->title);
?>
</strong>
    </h3>
</div>
<div class="config-basic">
    <?php 
$form = ActiveForm::begin(['id' => 'access-config-form', 'options' => ['class' => 'form-horizontal']]);
?>

        <?php 
echo $form->field($model, 'allow_register')->checkbox([], false);
?>
Esempio n. 21
0
<?php

use source\LsYii;
use source\helpers\Html;
use source\core\widgets\ActiveForm;
use source\helpers\Url;
use source\libs\Constants;
use source\libs\Message;
use source\helpers\ArrayHelper;
/* @var $this yii\web\View */
/* @var $model backend\models\config\BasicConfig */
/* @var $form ActiveForm */
$this->title = LsYii::gT('QQ第三方登录设置');
echo Message::getMessage();
?>
<div class="page-header">
    <h3>
        <strong><?php 
echo Html::encode($this->title);
?>
</strong>
    </h3>
</div>
<div class="config-basic">
    <?php 
$form = ActiveForm::begin(['id' => 'baidu-config-form', 'options' => ['class' => 'form-horizontal']]);
?>
        <?php 
echo $form->field($model, 'baidu_appid');
?>
        <?php 
Esempio n. 22
0
?>

<div class="header">
    <div class="step_area">
        <h2>关于</h2>
    </div>
</div>
<div class="mainbody">
    <div class="agreement_area">
        <div class="agreement">
            
            <p>
                感谢您选择LsYii CMS。希望我们的努力能为您提供一个高效快速和强大的建站解决方案。
            </p>
            <p>LsYii CMS官方网站为 <?php 
echo Html::a(LsYii::getHostInfo(), LsYii::getHostInfo(), array('target' => '_blank', 'class' => 'action'));
?>
</p>
            <p>
                LsYii CMS是一款基于强大的开源框架Yii Framework 2,采用高性能的PHP5+MySql开发的多功能开源的网站内容管理系统。
具有操作简单、稳定、安全、高效、跨平台等特点。采用MVC设计模式,模板定制方便灵活,内置小挂工具,方便制作各类功能和效果.

            </p>
            <p>LsYii CMS可用于企业建站、个人博客、资讯门户、图片站等各类型站点。</p>
            
            <div class="hr_8"></div>
            
            <p>在开始前,我们需要您数据库的一些信息。请准备好如下信息。</p>
            <ol>
                <li>数据库主机</li>
                <li>数据库名</li>
Esempio n. 23
0
$attribute = 'verifyCode';
$name = $model->getAttributeLabel($attribute);
$input = Html::activeTextInput($model, $attribute, ['enter' => 'totab', 'placeholder' => $name, 'autocomplete' => 'off']);
echo Html::label("<span></span>" . $input, Html::getInputId($model, $attribute), ['class' => 'clear']);
echo Html::beginTag('div');
echo yii\captcha\Captcha::widget(['name' => 'captchaimage', 'imageOptions' => ['id' => 'captchaImg', 'title' => '换一个', 'alt' => '换一个', 'style' => 'cursor:pointer;'], 'template' => '{image}']);
echo Html::endTag('div');
?>
                    </li>
                    <li class="error-message" <?php 
echo empty($message) ? '' : 'style="display: block;"';
?>
>
                        <?php 
echo $message;
?>
                    </li>
                    <li class="admin-submit">
                        <?php 
echo Html::submitInput(LsYii::gT('Login'), ['class' => 'btn btn-default']);
?>
                 
                    </li>
                </ul>
            <?php 
ActiveForm::end();
?>
       
        </div>
    </div>
</div>
Esempio n. 24
0
 /**
  * @inheritdoc
  */
 public function attributeLabels()
 {
     return ['site_name' => LsYii::gT('Site Name', 'field'), 'site_description' => LsYii::gT('Site Description', 'field'), 'site_domain' => LsYii::gT('Site Domain', 'field'), 'site_email' => LsYii::gT('Site Email', 'field'), 'site_language' => LsYii::gT('Site Language', 'field'), 'sys_icp' => LsYii::gT('Site Icp', 'field'), 'site_about' => LsYii::gT('Site About', 'field'), 'site_status' => LsYii::gT('Site Status', 'field')];
 }
Esempio n. 25
0
 /**
  * 得到后台侧边的菜单栏
  */
 public static function getSideMenu()
 {
     $html = '';
     $topMenu = LsYii::getApp()->controller->topMenu;
     if (!isset($topMenu) || empty($topMenu)) {
         return $topMenu;
     }
     //查询三级菜单
     $menus = self::getMenuArray($topMenu, 3);
     if ($menus) {
         $html .= '<div class="sidebar">';
         $html .= '<div id="subnav" class="subnav">';
         foreach ($menus as $menu) {
             $html .= '<h3><i class="icon"></i>' . $menu->name . '</h3>';
             //查询四级子菜单
             $childMenus = self::getMenuArray($menu->id, 4);
             if ($childMenus) {
                 $html .= '<ul class="side-sub-menu subnav-off">';
                 foreach ($childMenus as $childMenu) {
                     if (LsYii::getApp()->controller->sideMenu == $childMenu->id) {
                         $class = 'class="active"';
                     } else {
                         $class = '';
                     }
                     $html .= '<li ' . $class . '><a class="item" href="' . Url::to([$childMenu->url]) . '">' . $childMenu->name . '</a></li>';
                 }
                 $html .= '</ul>';
             }
         }
         $html .= '</div>';
         $html .= '</div>';
     }
     return $html;
 }
Esempio n. 26
0
 /**
  * 获取网站名
  * @return type
  */
 public static function getName()
 {
     return LsYii::getApp()->name;
 }
Esempio n. 27
0
<?php

use source\LsYii;
use source\core\widgets\ActiveForm;
use source\helpers\Url;
use source\libs\Constants;
use source\helpers\Html;
use source\modules\system\models\config\ThemeConfig;
use source\libs\Message;
use source\modules\system\models\config\DatetimeConfig;
/* @var $this yii\web\View */
/* @var $model backend\models\config\BasicConfig */
/* @var $form ActiveForm */
$this->title = LsYii::gT("Datetime Setting");
echo Message::getMessage();
?>
<div class="page-header">
    <h3>
        <strong><?php 
echo Html::encode($this->title);
?>
</strong>
    </h3>
</div>
<div class="config-basic">

    <?php 
$form = ActiveForm::begin(['id' => 'theme-config-form', 'options' => ['class' => 'form-horizontal']]);
?>
        <?php 
echo $form->field($model, 'datetime_timezone')->dropDownList(DatetimeConfig::getTimezoneItems());
Esempio n. 28
0
?>
</label>
                        <div class="col-sm-4">
                            <span class="col-color col-color-now"><?php 
// echo $adminuserCount;
?>
</span>
                            <?php 
// echo CHtml::link("查看",array("/admin/adminuser/admin"),array('class'=>'see'))
?>
                     
                        </div>
                    </div>
                    <div class="form-group bs-form-group-index">
                        <label for="inputEmail3" class="col-sm-2 control-label"><?php 
echo LsYii::gT("广告数量");
?>
</label>
                        <div class="col-sm-4">
                            <span class="col-color col-color-now"><?php 
// echo $advertisement;
?>
</span>
                            <?php 
// echo CHtml::link("查看",array("/admin/advertisement/admin"),array('class'=>'see'))
?>
                 
                        </div>
                    </div>
                </div>
            </div>
Esempio n. 29
0
 /**
  * 得到安装模块静态资源的url地址
  * @param string $url 要传入的url路径 
  * @return  string /statics/resources/install...
  */
 public static function getCommonUrl($url = null)
 {
     $ret = LsYii::getAlias('@web/statics/resources/common');
     if ($url !== null) {
         return $ret . $url;
     }
     return $ret;
 }
Esempio n. 30
0
 /**
  * Deletes an existing Role model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param string $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     $category = LsYii::getGetValue('category');
     Role::setMenus($category);
     $model = $this->findModel($id);
     if ($model->is_system) {
         return $this->redirect(['index', 'category' => $category, 'message' => LsYii::gT('该分类还有子项,不能被删除'), 'type' => 2]);
     } else {
         $model->delete();
         return $this->redirect(['index', 'category' => $category, 'message' => LsYii::gT('删除成功')]);
     }
 }