php source-LuLu类(方法)实例源码

下面列出了php source-LuLu 类(方法)源码代码实例,从而了解它的用法。

作者:phpson    项目:lulucms   
public function initService()
 {
     $this->modularityService = LuLu::getService('modularity');
     $this->rbacService = LuLu::getService('rbac');
     $this->taxonomyService = LuLu::getService('taxonomy');
     $this->menuService = LuLu::getService('menu');
 }

作者:merlinxi    项目:lulublo   
public function setTheme()
 {
     $currentTheme = LuLu::getAppParam('adminTheme');
     $moduleId = LuLu::$app->controller->module->id;
     $config = ['pathMap' => ['@app/views' => ['@static/admin/' . $currentTheme . '/views'], '@source/modules/' . $moduleId . '/admin/views' => ['@static/admin/' . $currentTheme . '/modules/' . $moduleId]], 'baseUrl' => '@static/admin/' . $currentTheme];
     $this->theme = new Theme($config);
 }

作者:huasxi    项目:lulucms   
public function loadActiveModules($isAdmin)
 {
     $moduleManager = LuLu::getService('modularityService');
     
     $this->activeModules = $moduleManager->getActiveModules($isAdmin);
     
     $module = $isAdmin ? 'AdminModule' : 'HomeModule';
     foreach ($this->activeModules as $m)
     {
         $moduleId = $m['id'];
         $moduleDir = $m['dir'];
         $ModuleClassName = $m['dir_class'];
         
         $this->setModule($moduleId, [
             'class' => 'source\modules\\' . $moduleDir . '\\' . $module
         ]);
         
         
         $serviceFile= LuLu::getAlias('@source').'\modules\\' .$moduleDir.'\\'.$ModuleClassName.'Service.php';
         
         if(FileHelper::exist($serviceFile))
         {
             $serviceClass = 'source\modules\\' .$moduleDir.'\\'.$ModuleClassName.'Service.php';
             $serviceInstance = new $serviceClass();
             $this->set($serviceInstance->getServiceId(), $serviceInstance);
         }
     }
 }

作者:hucongyan    项目:lulucms   
public function init()
 {
     parent::init();
     $this->modularityService = LuLu::getService('modularity');
     $this->rbacService = LuLu::getService('rbac');
     $this->taxonomyService = LuLu::getService('taxonomy');
 }

作者:sym66    项目:lulucms   
public function beforeAction($action)
 {
     if (!parent::beforeAction($action)) {
         return false;
     }
     //检查不需要登录的action uniqueID,如 site/login, site/captcha
     if (in_array($action->uniqueID, $this->ignoreLogin())) {
         return parent::beforeAction($action);
     }
     if (\Yii::$app->user->isGuest) {
         LuLu::go(['/site/login']);
     }
     if (!$this->rbacService->checkPermission('manager_admin')) {
         return $this->showMessage();
     }
     //return parent::beforeAction($action);
     if (in_array($action->uniqueID, $this->ingorePermission())) {
         return parent::beforeAction($action);
     }
     if (!$this->rbacService->checkPermission()) {
         return $this->showMessage();
     } else {
         return parent::beforeAction($action);
     }
 }

作者:cookedstea    项目:lulucms   
public function handleRequest($request)
 {
     if (empty($this->catchAll)) {
         list($route, $params) = $request->resolve();
     } else {
         $route = $this->catchAll[0];
         $params = array_splice($this->catchAll, 1);
     }
     try {
         LuLu::trace("Route requested: '{$route}'", __METHOD__);
         $this->requestedRoute = $route;
         $actionsResult = $this->runAction($route, $params);
         $result = $actionsResult instanceof ActionResult ? $actionsResult->result : $actionsResult;
         if ($result instanceof \yii\web\Response) {
             return $result;
         } else {
             $response = $this->getResponse();
             if ($result !== null) {
                 $response->data = $result;
             }
             return $response;
         }
     } catch (InvalidRouteException $e) {
         throw new NotFoundHttpException(Yii::t('yii', 'Page not found.'), $e->getCode(), $e);
     }
 }

作者:merlinxi    项目:lulublo   
public function actionIndex()
 {
     $query = Content::leftJoinWith('takonomy');
     $locals = LuLu::getPagedRows($query, ['orderBy' => 'created_at desc', 'pageSize' => 6]);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 5]]);
     $locals['dataProvider'] = $dataProvider;
     return $this->render('index', $locals);
 }

作者:merlinxi    项目:lulublo   
/**
  * Lists all Permission models.
  * @return mixed
  */
 public function actionIndex()
 {
     $categoryId = LuLu::getGetValue('category_id');
     //$searchModel = new PermissionSearch();
     $query = Permission::find();
     $query->andFilterWhere(['category_id' => $categoryId]);
     $dataProvider = $dataProvider = $this->getDataProvider($query);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }

作者:sym66    项目:lulucms   
/**
  * 
  * @param string $where
  * @param string $orderBy
  * @param number $pageSize
  * @param array $options
  * --recommend
  * --headline
  * --sticky
  * --flag
  * --is_pic
  * --content_type
  * --page
  * --taxonomy:array or number
  * 
  * @return array:['rows','pager']
  */
 public static function getPagedContents($where = null, $orderBy = null, $pageSize = 10, $options = [])
 {
     $query = self::buildContentQuery($where, $options);
     $query->joinWith('taxonomy', true, 'LEFT JOIN');
     $page = isset($options['page']) ? $options['page'] : null;
     $orderBy = empty($orderBy) ? 'created_at desc' : $orderBy;
     $locals = LuLu::getPagedRows($query, ['page' => $page, 'pageSize' => $pageSize, 'orderBy' => $orderBy]);
     return $locals;
 }

作者:huasxi    项目:lulucms   
public static function exist($path)
 {
     if (is_array($path))
     {
         $path = self::buildPath($path);
     }
     LuLu::info($path);
     return file_exists($path);
 }

作者:qq44314081    项目:lulucms   
public function __get($name)
 {
     $dot = strpos($name, 'Service');
     if ($dot > 0) {
         $serviceName = substr($name, 0, $dot);
         return LuLu::getService($serviceName);
     }
     return parent::__get($name);
 }

作者:sym66    项目:lulucms   
public static function clearCachedData($id)
 {
     $fragment = self::findOne(['id' => $id]);
     if ($fragment === null) {
         return;
     }
     $cacheKey = self::CachePrefix . $fragment->code;
     LuLu::deleteCache($cacheKey);
 }

作者:snowba    项目:lulucms   
private function loadAllModules()
 {
     if ($this->allModules !== null) {
         return $this->allModules;
     }
     $this->allModules = [];
     $moduleRootPath = LuLu::getAlias('@source') . '/modules';
     if ($moduleRootDir = @dir($moduleRootPath)) {
         while (($moduleFolder = $moduleRootDir->read()) !== false) {
             $modulePath = $moduleRootPath . '/' . $moduleFolder;
             if (preg_match('|^\\.+$|', $moduleFolder) || !is_dir($modulePath)) {
                 continue;
             }
             if ($moduleDir = @dir($modulePath)) {
                 $moduleClassName = ucwords($moduleFolder);
                 $class = null;
                 $instance = null;
                 $has_admin = false;
                 $has_home = false;
                 while (($item = $moduleDir->read()) !== false) {
                     $itemPath = $moduleRootPath . '/' . $moduleFolder . '/' . $item;
                     if (preg_match('|^\\.+$|', $item) || is_dir($itemPath)) {
                         continue;
                     }
                     if ($item === $moduleClassName . 'Info.php') {
                         $class = 'source\\modules\\' . $moduleFolder . '\\' . $moduleClassName . 'Info';
                     }
                     if ($item === 'AdminModule.php') {
                         $has_admin = true;
                     }
                     if ($item === 'HomeModule.php') {
                         $has_home = true;
                     }
                 }
                 if ($class !== null) {
                     try {
                         // $moduleObj = LuLu::createObject($class);
                         $instance = new $class();
                         if (empty($instance->id)) {
                             $instance->id = $moduleFolder;
                         }
                         if (empty($instance->name)) {
                             $instance->name = $moduleFolder;
                         }
                     } catch (Exception $e) {
                         // $instance=$e;
                     }
                 }
                 if ($instance !== null) {
                     $this->allModules[$instance->id] = ['id' => $instance->id, 'dir' => $moduleFolder, 'dir_class' => $moduleClassName, 'class' => $class, 'instance' => $instance, 'can_install' => true, 'can_uninstall' => true, 'has_admin' => $has_admin, 'has_home' => $has_home, 'can_active_admin' => false, 'can_active_home' => false];
                 }
             }
         }
     }
     return $this->allModules;
 }

作者:huasxi    项目:lulucms   
public function actionIndex()
 {
     $query = Content::leftJoinWith('takonomy');
     $locals = LuLu::getPagedRows($query, [
         'orderBy' => 'created_at desc', 
         'pageSize' => 6
     ]);
     
     return $this->render('index', $locals);
 }

作者:qq44314081    项目:lulucms   
/**
  * 内容页
  * @param unknown $id
  * @return \yii\base\string
  */
 public function actionDetail($id)
 {
     Content::updateAllCounters(['view_count' => 1], ['id' => $id]);
     $locals = $this->getDetail($id);
     $taxonomyModel = $this->taxonomyService->getTaxonomyById($locals['model']['taxonomy_id']);
     LuLu::setViewParam(['taxonomyModel' => $taxonomyModel]);
     $locals['taxonomyModel'] = $taxonomyModel;
     $vars = $this->getDetailVars($locals['taxonomyModel'], $locals['model']);
     $this->layout = $vars['layout'];
     return $this->render($vars['view'], $locals);
 }

作者:ruzuoju    项目:lulucms   
public function actionList()
 {
     $takonomy = LuLu::getGetValue('takonomy');
     $takonomyModel = Takonomy::getOneOrDefault($takonomy);
     $query = Content::find();
     $query->where(['content_type' => $this->content_type]);
     $query->andFilterWhere(['takonomy_id' => $takonomy]);
     $locals = LuLu::getPagedRows($query, ['orderBy' => 'created_at desc', 'pageSize' => 10]);
     $locals['takonomyModel'] = $takonomyModel;
     return $this->render('list_default', $locals);
 }

作者:sym66    项目:lulucms   
public function init()
 {
     parent::init();
     $this->getView()->on(BaseView::EVENT_BEGIN_PAGE, [$this, 'beginPage']);
     $this->getView()->on(BaseView::EVENT_BEGIN_BODY, [$this, 'beginBody']);
     $this->getView()->on(BaseView::EVENT_BEFORE_RENDER, [$this, 'beforeRender']);
     $this->getView()->on(BaseView::EVENT_AFTER_RENDER, [$this, 'afterRender']);
     $this->getView()->on(BaseView::EVENT_END_BODY, [$this, 'endBody']);
     $this->getView()->on(BaseView::EVENT_END_PAGE, [$this, 'endPage']);
     $this->getView()->on(BaseView::EVENT_AFTER_PAGE, [$this, 'afterPage']);
     LuLu::getResponse()->on(Response::EVENT_AFTER_SEND, [$this, 'afterResponse']);
 }

作者:hucongyan    项目:lulucms   
public static function AddBatchItems($role, $permissions)
 {
     self::deleteAll(['role' => $role]);
     LuLu::deleteCache(RbacService::CachePrefix . $role);
     foreach ($permissions as $key => $value) {
         $newRelation = new Relation();
         $newRelation->role = $role;
         $newRelation->permission = $key;
         $newRelation->value = is_string($value) ? $value : implode(',', $value);
         $newRelation->save();
     }
 }

作者:snowba    项目:lulucms   
/**
  * Lists all Relation models.
  * @return mixed
  */
 public function actionIndex($role)
 {
     if (\Yii::$app->request->isPost) {
         $selectedPermissions = LuLu::getPostValue('Permission');
         Relation::AddBatchItems($role, $selectedPermissions);
         return $this->redirect(['index', 'role' => $role]);
     }
     $allPermissions = Permission::getAllPermissionsGroupedByCategory();
     $rolePermissions = Relation::find()->select(['permission', 'value'])->where(['role' => $role])->indexBy('permission')->all();
     $categories = Permission::getCategoryItems();
     $role = Role::findOne(['id' => $role]);
     return $this->render('index', ['rolePermissions' => $rolePermissions, 'allPermissions' => $allPermissions, 'categories' => $categories, 'role' => $role]);
 }

作者:sym66    项目:lulucms   
public function getMessagePrefix($message)
 {
     if ($this->prefix !== null) {
         return call_user_func($this->prefix, $message);
     }
     $ip = Utility::getIp();
     $userID = LuLu::getIdentity()->username;
     if (empty($userID)) {
         return "[{$ip}]";
     } else {
         return "[{$ip}]<br/>[{$userID}]";
     }
 }


问题


面经


文章

微信
公众号

扫码关注公众号