From e1124161263e9fd3090785e7d29616a16f58a4a8 Mon Sep 17 00:00:00 2001 From: yiifans Date: Sun, 22 Feb 2015 17:58:17 +0800 Subject: [PATCH] rbac --- components/rbac/Assignment.php | 57 ++ components/rbac/DbManager.php | 648 ++++++++++++++++++ components/rbac/Item.php | 52 ++ components/rbac/ItemChild.php | 63 ++ components/rbac/Permission.php | 11 + components/rbac/Role.php | 84 +++ components/rbac/Rule.php | 60 ++ config/web.php | 8 + controllers/SiteController.php | 31 +- core/LuLu.php | 2 + core/base/BaseController.php | 16 +- core/base/BaseModel.php | 1 + core/base/RbacManager.php | 32 + core/helpers/TFileHelper.php | 104 +++ core/helpers/TStringHelper.php | 120 ++++ core/helpers/TTimeHelper.php | 17 + core/lib/CacheUtility.php | 319 +++++++++ core/lib/Common.php | 10 + data/cache/cachedTakonomies.php | 300 ++++++++ models/Content.php | 14 + models/Takonomy.php | 74 +- models/search/ContentSearch.php | 24 +- models/search/TakonomySearch.php | 16 +- modules/admin/AdminModule.php | 2 +- .../admin/controllers/ContentController.php | 21 +- modules/admin/controllers/SiteController.php | 18 + .../admin/controllers/TakonomyController.php | 33 +- modules/admin/modules/rbac/RbacModule.php | 15 + .../rbac/controllers/AssignmentController.php | 125 ++++ .../rbac/controllers/BaseController.php | 22 + .../rbac/controllers/DefaultController.php | 13 + .../rbac/controllers/ItemController.php | 82 +++ .../rbac/controllers/PermissionController.php | 46 ++ .../rbac/controllers/RoleController.php | 104 +++ .../rbac/controllers/RuleController.php | 121 ++++ .../modules/rbac/models/AssignmentForm.php | 58 ++ .../modules/rbac/models/ItemChildForm.php | 63 ++ .../admin/modules/rbac/models/ItemForm.php | 53 ++ .../modules/rbac/models/PermissionForm.php | 17 + .../admin/modules/rbac/models/RoleForm.php | 15 + .../admin/modules/rbac/models/RuleForm.php | 61 ++ .../modules/rbac/views/assignment/_form.php | 27 + .../modules/rbac/views/assignment/_search.php | 31 + .../modules/rbac/views/assignment/create.php | 21 + .../modules/rbac/views/assignment/index.php | 36 + .../modules/rbac/views/assignment/update.php | 21 + .../modules/rbac/views/assignment/view.php | 37 + .../modules/rbac/views/default/index.php | 12 + .../modules/rbac/views/permission/_form.php | 36 + .../modules/rbac/views/permission/_search.php | 39 ++ .../modules/rbac/views/permission/create.php | 21 + .../modules/rbac/views/permission/index.php | 27 + .../modules/rbac/views/permission/update.php | 21 + .../modules/rbac/views/permission/view.php | 41 ++ .../admin/modules/rbac/views/role/_form.php | 34 + .../admin/modules/rbac/views/role/_search.php | 39 ++ .../admin/modules/rbac/views/role/create.php | 22 + .../admin/modules/rbac/views/role/index.php | 29 + .../admin/modules/rbac/views/role/update.php | 22 + .../admin/modules/rbac/views/role/view.php | 41 ++ .../admin/modules/rbac/views/rule/_form.php | 29 + .../admin/modules/rbac/views/rule/_search.php | 33 + .../admin/modules/rbac/views/rule/create.php | 21 + .../admin/modules/rbac/views/rule/index.php | 37 + .../admin/modules/rbac/views/rule/update.php | 21 + .../admin/modules/rbac/views/rule/view.php | 38 + modules/admin/views/content/_form.php | 95 ++- modules/admin/views/content/index.php | 17 +- modules/admin/views/default/about.php | 17 + modules/admin/views/layouts/main.php | 1 + modules/admin/views/site/about.php | 17 + modules/admin/views/takonomy/_form.php | 29 +- modules/admin/views/takonomy/create.php | 8 +- modules/admin/views/takonomy/index.php | 8 +- modules/admin/views/takonomy/update.php | 9 +- views/default/contact.php | 17 + views/layouts/column-2.php | 23 + views/layouts/main.php | 7 + views/layouts/test-main.php | 59 ++ views/site/about.php | 60 +- views/site/index.php | 4 + views/user/testview.php | 17 + web/css/site.css | 56 ++ 83 files changed, 3963 insertions(+), 149 deletions(-) create mode 100644 components/rbac/Assignment.php create mode 100644 components/rbac/DbManager.php create mode 100644 components/rbac/Item.php create mode 100644 components/rbac/ItemChild.php create mode 100644 components/rbac/Permission.php create mode 100644 components/rbac/Role.php create mode 100644 components/rbac/Rule.php create mode 100644 core/base/RbacManager.php create mode 100644 core/helpers/TFileHelper.php create mode 100644 core/helpers/TStringHelper.php create mode 100644 core/helpers/TTimeHelper.php create mode 100644 core/lib/CacheUtility.php create mode 100644 core/lib/Common.php create mode 100644 data/cache/cachedTakonomies.php create mode 100644 modules/admin/controllers/SiteController.php create mode 100644 modules/admin/modules/rbac/RbacModule.php create mode 100644 modules/admin/modules/rbac/controllers/AssignmentController.php create mode 100644 modules/admin/modules/rbac/controllers/BaseController.php create mode 100644 modules/admin/modules/rbac/controllers/DefaultController.php create mode 100644 modules/admin/modules/rbac/controllers/ItemController.php create mode 100644 modules/admin/modules/rbac/controllers/PermissionController.php create mode 100644 modules/admin/modules/rbac/controllers/RoleController.php create mode 100644 modules/admin/modules/rbac/controllers/RuleController.php create mode 100644 modules/admin/modules/rbac/models/AssignmentForm.php create mode 100644 modules/admin/modules/rbac/models/ItemChildForm.php create mode 100644 modules/admin/modules/rbac/models/ItemForm.php create mode 100644 modules/admin/modules/rbac/models/PermissionForm.php create mode 100644 modules/admin/modules/rbac/models/RoleForm.php create mode 100644 modules/admin/modules/rbac/models/RuleForm.php create mode 100644 modules/admin/modules/rbac/views/assignment/_form.php create mode 100644 modules/admin/modules/rbac/views/assignment/_search.php create mode 100644 modules/admin/modules/rbac/views/assignment/create.php create mode 100644 modules/admin/modules/rbac/views/assignment/index.php create mode 100644 modules/admin/modules/rbac/views/assignment/update.php create mode 100644 modules/admin/modules/rbac/views/assignment/view.php create mode 100644 modules/admin/modules/rbac/views/default/index.php create mode 100644 modules/admin/modules/rbac/views/permission/_form.php create mode 100644 modules/admin/modules/rbac/views/permission/_search.php create mode 100644 modules/admin/modules/rbac/views/permission/create.php create mode 100644 modules/admin/modules/rbac/views/permission/index.php create mode 100644 modules/admin/modules/rbac/views/permission/update.php create mode 100644 modules/admin/modules/rbac/views/permission/view.php create mode 100644 modules/admin/modules/rbac/views/role/_form.php create mode 100644 modules/admin/modules/rbac/views/role/_search.php create mode 100644 modules/admin/modules/rbac/views/role/create.php create mode 100644 modules/admin/modules/rbac/views/role/index.php create mode 100644 modules/admin/modules/rbac/views/role/update.php create mode 100644 modules/admin/modules/rbac/views/role/view.php create mode 100644 modules/admin/modules/rbac/views/rule/_form.php create mode 100644 modules/admin/modules/rbac/views/rule/_search.php create mode 100644 modules/admin/modules/rbac/views/rule/create.php create mode 100644 modules/admin/modules/rbac/views/rule/index.php create mode 100644 modules/admin/modules/rbac/views/rule/update.php create mode 100644 modules/admin/modules/rbac/views/rule/view.php create mode 100644 modules/admin/views/default/about.php create mode 100644 modules/admin/views/site/about.php create mode 100644 views/default/contact.php create mode 100644 views/layouts/column-2.php create mode 100644 views/layouts/test-main.php create mode 100644 views/user/testview.php diff --git a/components/rbac/Assignment.php b/components/rbac/Assignment.php new file mode 100644 index 0000000..ed9a72c --- /dev/null +++ b/components/rbac/Assignment.php @@ -0,0 +1,57 @@ + 64] + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'item_name' => 'Item Name', + 'user_id' => 'User ID', + 'created_at' => 'Created At', + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getItemName() + { + return $this->hasOne(AuthItem::className(), ['name' => 'item_name']); + } +} diff --git a/components/rbac/DbManager.php b/components/rbac/DbManager.php new file mode 100644 index 0000000..9fdefb9 --- /dev/null +++ b/components/rbac/DbManager.php @@ -0,0 +1,648 @@ +db = Instance::ensure($this->db, Connection::className()); + } + + /** + * @inheritdoc + */ + public function checkAccess($userId, $permissionName, $params = []) + { + $assignments = $this->getAssignments($userId); + return $this->checkAccessRecursive($userId, $permissionName, $params, $assignments); + } + + + protected function checkAccessRecursive($user, $itemName, $params, $assignments) + { + if (($item = $this->getItem($itemName)) === null) { + return false; + } + + Yii::trace($item instanceof Role ? "Checking role: $itemName" : "Checking permission: $itemName", __METHOD__); + + if (!$this->executeRule($user, $item, $params)) { + return false; + } + + if (isset($assignments[$itemName]) || in_array($itemName, $this->defaultRoles)) { + return true; + } + + $query = new Query; + $parents = $query->select(['parent']) + ->from($this->itemChildTable) + ->where(['child' => $itemName]) + ->column($this->db); + foreach ($parents as $parent) { + if ($this->checkAccessRecursive($user, $parent, $params, $assignments)) { + return true; + } + } + + return false; + } + + protected function supportsCascadeUpdate() + { + return strncmp($this->db->getDriverName(), 'sqlite', 6) !== 0; + } + + protected function addItem($item) + { + $time = time(); + if ($item->created_at === null) { + $item->created_at = $time; + } + if ($item->updated_at === null) { + $item->updated_at = $time; + } + $this->db->createCommand() + ->insert($this->itemTable, [ + 'name' => $item->name, + 'type' => $item->type, + 'description' => $item->description, + 'rule_name' => $item->rule_name, + 'data' => $item->data === null ? null : serialize($item->data), + 'created_at' => $item->created_at, + 'updated_at' => $item->updated_at, + ])->execute(); + + return true; + } + + protected function getItem($name,$type) + { + $row = (new Query)->from($this->itemTable) + ->where(['name' => $name,'type'=>$type]) + ->one($this->db); + + if ($row === false) { + return null; + } + + if (!isset($row['data']) || ($data = @unserialize($row['data'])) === false) { + $row['data'] = null; + } + + return $this->populateItem($row); + } + protected function getItems($type) + { + $query = (new Query) + ->from($this->itemTable) + ->where(['type' => $type]); + + $items = []; + foreach ($query->all($this->db) as $row) { + $items[$row['name']] = $this->populateItem($row); + } + + return $items; + } + + + protected function removeItem($item) + { + if (!$this->supportsCascadeUpdate()) { + $this->db->createCommand() + ->delete($this->itemChildTable, ['or', '[[parent]]=:name', '[[child]]=:name'], [':name' => $item->name]) + ->execute(); + $this->db->createCommand() + ->delete($this->assignmentTable, ['item_name' => $item->name]) + ->execute(); + } + + $this->db->createCommand() + ->delete($this->itemTable, ['name' => $item->name]) + ->execute(); + + return true; + } + + + protected function updateItem($name, $item) + { + if (!$this->supportsCascadeUpdate() && $item->name !== $name) { + $this->db->createCommand() + ->update($this->itemChildTable, ['parent' => $item->name], ['parent' => $name]) + ->execute(); + $this->db->createCommand() + ->update($this->itemChildTable, ['child' => $item->name], ['child' => $name]) + ->execute(); + $this->db->createCommand() + ->update($this->assignmentTable, ['item_name' => $item->name], ['item_name' => $name]) + ->execute(); + } + + $item->updatedAt = time(); + + $this->db->createCommand() + ->update($this->itemTable, [ + 'name' => $item->name, + 'description' => $item->description, + 'rule_name' => $item->ruleName, + 'data' => $item->data === null ? null : serialize($item->data), + 'updated_at' => $item->updatedAt, + ], [ + 'name' => $name, + ])->execute(); + + return true; + } + + protected function populateItem($row) + { + $class = $row['type'] == Item::TYPE_PERMISSION ? Permission::className() : Role::className(); + + if (!isset($row['data']) || ($data = @unserialize($row['data'])) === false) { + $data = null; + } + + return new $class([ + 'name' => $row['name'], + 'type' => $row['type'], + 'description' => $row['description'], + 'ruleName' => $row['rule_name'], + 'data' => $data, + 'createdAt' => $row['created_at'], + 'updatedAt' => $row['updated_at'], + ]); + } + + + public function addRole($role) + { + return $this->addItem($role); + } + + public function getRole($name) + { + return $this->getItem($name, Item::TYPE_ROLE); + } + + public function getRule($name) + { + $row = (new Query)->select(['data']) + ->from($this->ruleTable) + ->where(['name' => $name]) + ->one($this->db); + return $row === false ? null : unserialize($row['data']); + } + + + public function getRules() + { + $query = (new Query)->from($this->ruleTable); + + $rules = []; + foreach ($query->all($this->db) as $row) { + $rules[$row['name']] = unserialize($row['data']); + } + + return $rules; + } + + protected function addRule($rule) + { + $time = time(); + if ($rule->createdAt === null) { + $rule->createdAt = $time; + } + if ($rule->updatedAt === null) { + $rule->updatedAt = $time; + } + $this->db->createCommand() + ->insert($this->ruleTable, [ + 'name' => $rule->name, + 'data' => serialize($rule), + 'created_at' => $rule->createdAt, + 'updated_at' => $rule->updatedAt, + ])->execute(); + + return true; + } + + + protected function updateRule($name, $rule) + { + if (!$this->supportsCascadeUpdate() && $rule->name !== $name) { + $this->db->createCommand() + ->update($this->itemTable, ['rule_name' => $rule->name], ['rule_name' => $name]) + ->execute(); + } + + $rule->updatedAt = time(); + + $this->db->createCommand() + ->update($this->ruleTable, [ + 'name' => $rule->name, + 'data' => serialize($rule), + 'updated_at' => $rule->updatedAt, + ], [ + 'name' => $name, + ])->execute(); + + return true; + } + + protected function removeRule($rule) + { + if (!$this->supportsCascadeUpdate()) { + $this->db->createCommand() + ->update($this->itemTable, ['rule_name' => null], ['rule_name' => $rule->name]) + ->execute(); + } + + $this->db->createCommand() + ->delete($this->ruleTable, ['name' => $rule->name]) + ->execute(); + + return true; + } + + + + + /** + * @inheritdoc + */ + public function getRolesByUser($userId) + { + if (empty($userId)) { + return []; + } + + $query = (new Query)->select('b.*') + ->from(['a' => $this->assignmentTable, 'b' => $this->itemTable]) + ->where('{{a}}.[[item_name]]={{b}}.[[name]]') + ->andWhere(['a.user_id' => (string) $userId]); + + $roles = []; + foreach ($query->all($this->db) as $row) { + $roles[$row['name']] = $this->populateItem($row); + } + return $roles; + } + + /** + * @inheritdoc + */ + public function getPermissionsByRole($roleName) + { + $childrenList = $this->getChildrenList(); + $result = []; + $this->getChildrenRecursive($roleName, $childrenList, $result); + if (empty($result)) { + return []; + } + $query = (new Query)->from($this->itemTable)->where([ + 'type' => Item::TYPE_PERMISSION, + 'name' => array_keys($result), + ]); + $permissions = []; + foreach ($query->all($this->db) as $row) { + $permissions[$row['name']] = $this->populateItem($row); + } + return $permissions; + } + + /** + * @inheritdoc + */ + public function getPermissionsByUser($userId) + { + if (empty($userId)) { + return []; + } + + $query = (new Query)->select('item_name') + ->from($this->assignmentTable) + ->where(['user_id' => (string) $userId]); + + $childrenList = $this->getChildrenList(); + $result = []; + foreach ($query->column($this->db) as $roleName) { + $this->getChildrenRecursive($roleName, $childrenList, $result); + } + + if (empty($result)) { + return []; + } + + $query = (new Query)->from($this->itemTable)->where([ + 'type' => Item::TYPE_PERMISSION, + 'name' => array_keys($result), + ]); + $permissions = []; + foreach ($query->all($this->db) as $row) { + $permissions[$row['name']] = $this->populateItem($row); + } + return $permissions; + } + + /** + * Returns the children for every parent. + * @return array the children list. Each array key is a parent item name, + * and the corresponding array value is a list of child item names. + */ + protected function getChildrenList() + { + $query = (new Query)->from($this->itemChildTable); + $parents = []; + foreach ($query->all($this->db) as $row) { + $parents[$row['parent']][] = $row['child']; + } + return $parents; + } + + /** + * Recursively finds all children and grand children of the specified item. + * @param string $name the name of the item whose children are to be looked for. + * @param array $childrenList the child list built via [[getChildrenList()]] + * @param array $result the children and grand children (in array keys) + */ + protected function getChildrenRecursive($name, $childrenList, &$result) + { + if (isset($childrenList[$name])) { + foreach ($childrenList[$name] as $child) { + $result[$child] = true; + $this->getChildrenRecursive($child, $childrenList, $result); + } + } + } + + + + + + public function getAssignment($roleName, $userId) + { + if (empty($userId)) { + return null; + } + + $row = (new Query)->from($this->assignmentTable) + ->where(['user_id' => (string) $userId, 'item_name' => $roleName]) + ->one($this->db); + + if ($row === false) { + return null; + } + + return new Assignment([ + 'userId' => $row['user_id'], + 'roleName' => $row['item_name'], + 'createdAt' => $row['created_at'], + ]); + } + + + public function getAssignments($userId) + { + if (empty($userId)) { + return []; + } + + $query = (new Query) + ->from($this->assignmentTable) + ->where(['user_id' => (string) $userId]); + + $assignments = []; + foreach ($query->all($this->db) as $row) { + $assignments[$row['item_name']] = new Assignment([ + 'userId' => $row['user_id'], + 'roleName' => $row['item_name'], + 'createdAt' => $row['created_at'], + ]); + } + + return $assignments; + } + + public function removeAllAssignments() + { + $this->db->createCommand()->delete($this->assignmentTable)->execute(); + } + + + public function addChild($parent, $child) + { + if ($parent->name === $child->name) { + throw new InvalidParamException("Cannot add '{$parent->name}' as a child of itself."); + } + + if ($parent instanceof Permission && $child instanceof Role) { + throw new InvalidParamException("Cannot add a role as a child of a permission."); + } + + if ($this->detectLoop($parent, $child)) { + throw new InvalidCallException("Cannot add '{$child->name}' as a child of '{$parent->name}'. A loop has been detected."); + } + + $this->db->createCommand() + ->insert($this->itemChildTable, ['parent' => $parent->name, 'child' => $child->name]) + ->execute(); + + return true; + } + + + public function removeChild($parent, $child) + { + return $this->db->createCommand() + ->delete($this->itemChildTable, ['parent' => $parent->name, 'child' => $child->name]) + ->execute() > 0; + } + + + public function removeChildren($parent) + { + return $this->db->createCommand() + ->delete($this->itemChildTable, ['parent' => $parent->name]) + ->execute() > 0; + } + + + public function hasChild($parent, $child) + { + return (new Query) + ->from($this->itemChildTable) + ->where(['parent' => $parent->name, 'child' => $child->name]) + ->one($this->db) !== false; + } + + + public function getChildren($name) + { + $query = (new Query) + ->select(['name', 'type', 'description', 'rule_name', 'data', 'created_at', 'updated_at']) + ->from([$this->itemTable, $this->itemChildTable]) + ->where(['parent' => $name, 'name' => new Expression('[[child]]')]); + + $children = []; + foreach ($query->all($this->db) as $row) { + $children[$row['name']] = $this->populateItem($row); + } + + return $children; + } + + + protected function detectLoop($parent, $child) + { + if ($child->name === $parent->name) { + return true; + } + foreach ($this->getChildren($child->name) as $grandchild) { + if ($this->detectLoop($parent, $grandchild)) { + return true; + } + } + return false; + } + + + public function assign($role, $userId) + { + $assignment = new Assignment([ + 'userId' => $userId, + 'roleName' => $role->name, + 'createdAt' => time(), + ]); + + $this->db->createCommand() + ->insert($this->assignmentTable, [ + 'user_id' => $assignment->userId, + 'item_name' => $assignment->roleName, + 'created_at' => $assignment->createdAt, + ])->execute(); + + return $assignment; + } + + + public function revoke($role, $userId) + { + if (empty($userId)) { + return false; + } + + return $this->db->createCommand() + ->delete($this->assignmentTable, ['user_id' => (string) $userId, 'item_name' => $role->name]) + ->execute() > 0; + } + + + public function revokeAll($userId) + { + if (empty($userId)) { + return false; + } + + return $this->db->createCommand() + ->delete($this->assignmentTable, ['user_id' => (string) $userId]) + ->execute() > 0; + } + + + public function removeAll() + { + $this->removeAllAssignments(); + $this->db->createCommand()->delete($this->itemChildTable)->execute(); + $this->db->createCommand()->delete($this->itemTable)->execute(); + $this->db->createCommand()->delete($this->ruleTable)->execute(); + } + + + public function removeAllPermissions() + { + $this->removeAllItems(Item::TYPE_PERMISSION); + } + + + public function removeAllRoles() + { + $this->removeAllItems(Item::TYPE_ROLE); + } + + + protected function removeAllItems($type) + { + if (!$this->supportsCascadeUpdate()) { + $names = (new Query) + ->select(['name']) + ->from($this->itemTable) + ->where(['type' => $type]) + ->column($this->db); + if (empty($names)) { + return; + } + $key = $type == Item::TYPE_PERMISSION ? 'child' : 'parent'; + $this->db->createCommand() + ->delete($this->itemChildTable, [$key => $names]) + ->execute(); + $this->db->createCommand() + ->delete($this->assignmentTable, ['item_name' => $names]) + ->execute(); + } + $this->db->createCommand() + ->delete($this->itemTable, ['type' => $type]) + ->execute(); + } + + + public function removeAllRules() + { + if (!$this->supportsCascadeUpdate()) { + $this->db->createCommand() + ->update($this->itemTable, ['ruleName' => null]) + ->execute(); + } + + $this->db->createCommand()->delete($this->ruleTable)->execute(); + } + + /** + * @inheritdoc + */ + +} diff --git a/components/rbac/Item.php b/components/rbac/Item.php new file mode 100644 index 0000000..1291de6 --- /dev/null +++ b/components/rbac/Item.php @@ -0,0 +1,52 @@ +hasMany(AuthAssignment::className(), ['item_name' => 'name']); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getRuleName() + { + return $this->hasOne(AuthRule::className(), ['name' => 'rule_name']); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getAuthItemChildren() + { + return $this->hasMany(AuthItemChild::className(), ['child' => 'name']); + } +} diff --git a/components/rbac/ItemChild.php b/components/rbac/ItemChild.php new file mode 100644 index 0000000..6cd3bd1 --- /dev/null +++ b/components/rbac/ItemChild.php @@ -0,0 +1,63 @@ + 64] + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'parent' => 'Parent', + 'child' => 'Child', + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getParent0() + { + return $this->hasOne(AuthItem::className(), ['name' => 'parent']); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getChild0() + { + return $this->hasOne(AuthItem::className(), ['name' => 'child']); + } +} diff --git a/components/rbac/Permission.php b/components/rbac/Permission.php new file mode 100644 index 0000000..08b64b7 --- /dev/null +++ b/components/rbac/Permission.php @@ -0,0 +1,11 @@ + 64] + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'name' => 'Name', + 'type' => 'Type', + 'description' => 'Description', + 'rule_name' => 'Rule Name', + 'data' => 'Data', + 'created_at' => 'Created At', + 'updated_at' => 'Updated At', + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getAuthAssignments() + { + return $this->hasMany(AuthAssignment::className(), ['item_name' => 'name']); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getRuleName() + { + return $this->hasOne(AuthRule::className(), ['name' => 'rule_name']); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getAuthItemChildren() + { + return $this->hasMany(AuthItemChild::className(), ['child' => 'name']); + } +} diff --git a/components/rbac/Rule.php b/components/rbac/Rule.php new file mode 100644 index 0000000..e4ae96f --- /dev/null +++ b/components/rbac/Rule.php @@ -0,0 +1,60 @@ + 64] + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'name' => 'Name', + 'data' => 'Data', + 'created_at' => 'Created At', + 'updated_at' => 'Updated At', + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getAuthItems() + { + return $this->hasMany(AuthItem::className(), ['rule_name' => 'name']); + } +} diff --git a/config/web.php b/config/web.php index afa50ef..df88473 100644 --- a/config/web.php +++ b/config/web.php @@ -40,11 +40,19 @@ ], ], 'db' => require(__DIR__ . '/db.php'), + 'authManager'=>[ + 'class'=>'yii\rbac\DbManager', + ], ], 'params' => $params, 'modules' => [ 'admin' => [ 'class' => 'app\modules\admin\AdminModule', + 'modules'=>[ + 'rbac' => [ + 'class' => 'app\modules\admin\modules\rbac\RbacModule', + ], + ] ], ], ]; diff --git a/controllers/SiteController.php b/controllers/SiteController.php index b8822a7..4b69b15 100644 --- a/controllers/SiteController.php +++ b/controllers/SiteController.php @@ -15,6 +15,16 @@ class SiteController extends BaseFrontController { + public $testData='my data'; + + public $testData2='my data2'; + + public function init() + { + parent::init(); + + } + public function behaviors() { return [ @@ -86,6 +96,8 @@ public function actionLogout() public function actionContact() { + + $model = new ContactForm(); if ($model->load(Yii::$app->request->post()) && $model->contact(Yii::$app->params['adminEmail'])) { Yii::$app->session->setFlash('contactFormSubmitted'); @@ -100,6 +112,23 @@ public function actionContact() public function actionAbout() { - return $this->render('about'); + + + /* return $this->render('/default/contact',['test'=>5]); + + $content = $this->renderPartial('about',['test'=>5]); + + $this->renderContent($content); + + $this->renderFile('full file name',['test'=>5]); + + $this->renderAjax('about',['test'=>'test']); + */ + + //$this->layout='main'; + + + + return $this->render('about',['test'=>5,'testData'=>$this->testData]); } } diff --git a/core/LuLu.php b/core/LuLu.php index 2adc66e..f23283c 100644 --- a/core/LuLu.php +++ b/core/LuLu.php @@ -2,6 +2,7 @@ namespace app\core; +use yii\helpers\VarDumper; class LuLu extends \Yii { @@ -164,6 +165,7 @@ public static function setErrorMessage($message) public static function info($var, $category = 'application') { + $dump = VarDumper::dumpAsString($var); self::info($dump, $category); } diff --git a/core/base/BaseController.php b/core/base/BaseController.php index 5a942be..13deea1 100644 --- a/core/base/BaseController.php +++ b/core/base/BaseController.php @@ -11,8 +11,20 @@ use yii\db\ActiveRecord; use yii\base\Model; - class BaseController extends Controller { - + + public function behaviors() + { + return [ + 'verbs' => [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => [ + 'post' + ] + ] + ] + ]; + } } diff --git a/core/base/BaseModel.php b/core/base/BaseModel.php index 2548aa2..7c32c6e 100644 --- a/core/base/BaseModel.php +++ b/core/base/BaseModel.php @@ -15,4 +15,5 @@ class BaseModel extends Model { + public $isNewRecord; } diff --git a/core/base/RbacManager.php b/core/base/RbacManager.php new file mode 100644 index 0000000..3907819 --- /dev/null +++ b/core/base/RbacManager.php @@ -0,0 +1,32 @@ +') + { + $source = explode($itemSep, $str); + if(empty($source)) + { + return []; + } + + $items = []; + + foreach ($source as $itemString ) + { + if(empty($itemString)) + { + continue; + } + + $itemArray=explode($valueSep, $itemString); + $count = count($itemArray); + if($count==0) + { + continue; + } + + if($count==2) + { + $items[$itemArray[0]]=$itemArray[1]; + } + else + { + $items[$itemArray[0]]=$itemArray[0]; + } + } + return $items; + } + + public static function quotString($str) + { + return '\''.$str.'\''; + } + + public static function isNullOrEmpty($var) + { + if(!isset($var)) + { + return true; + } + if($var==='') + { + return true; + } + return false; + } + + public static function startWith($str,$needle) + { + return strpos($str, $needle)===0; + } + + + /* + * 中文截取,支持gb2312,gbk,utf-8,big5 + * @param string $str 要截取的字串 + * @param int $start 截取起始位置 + * @param int $length 截取长度 + * @param string $charset utf-8¦gb2312¦gbk¦big5 编码 + * @param $suffix 尾缀 + */ + public static function subStr($str, $length=-1, $charset="", $start=0, $suffix=null) { + if($length<1) + { + return $str; + } + if($str==null||empty($str)) + { + return ''; + } + + if (empty($charset)) + { + $charset = 'utf-8'; + } + + if (function_exists('mb_substr')) + { + if (mb_strlen($str, $charset) <= $length) + return $str; + $slice = mb_substr($str, $start, $length, $charset); + } + else + { + $re['utf-8'] = "/[\x01-\x7f]¦[\xc2-\xdf][\x80-\xbf]¦[\xe0-\xef][\x80-\xbf]{2}¦[\xf0-\xff][\x80-\xbf]{3}/"; + $re['gb2312'] = "/[\x01-\x7f]¦[\xb0-\xf7][\xa0-\xfe]/"; + $re['gbk'] = "/[\x01-\x7f]¦[\x81-\xfe][\x40-\xfe]/"; + $re['big5'] = "/[\x01-\x7f]¦[\x81-\xfe]([\x40-\x7e]¦\xa1-\xfe])/"; + preg_match_all($re[$charset], $str, $match); + if (count($match[0]) <= $length) + return $str; + $slice = join("", array_slice($match[0], $start, $length)); + } + if ($suffix!=null&&!empty($suffix)) + { + return $slice . $suffix; + } + + return $slice; + } +} \ No newline at end of file diff --git a/core/helpers/TTimeHelper.php b/core/helpers/TTimeHelper.php new file mode 100644 index 0000000..ca06dd7 --- /dev/null +++ b/core/helpers/TTimeHelper.php @@ -0,0 +1,17 @@ + $cachedTables,' . self::$newLine; + $content .= ' \'cachedFields\' => $cachedFields,' . self::$newLine; + $content .= ' \'cachedChannels\' => $cachedChannels,' . self::$newLine; + $content .= ' \'cachedConfigs\' => $cachedConfigs,' . self::$newLine; + $content .= ' \'cachedContentFlags\' => $cachedContentFlags,' . self::$newLine; + $content .= ' \'cachedVariables\' => $cachedVariables,' . self::$newLine; + $content .= ' \'cachedDicts\' => $cachedDicts,' . self::$newLine; + $content .= '];' . self::$newLine; + + self::writeFile('cachedData.php', $content); + } + + public static function createTableCache() + { + self::createCacheFile(); + + $content = ' $tableName]); + + foreach($dataList as $row) + { + $content .= '$cachedFields[\'' . $tableName . '\'][\'' . $row['field_name'] . '\']=[' . self::$newLine; + + $content .= self::getCacheItem('id', $row, 'int'); + $content .= self::getCacheItem('table', $row); + $content .= self::getCacheItem('field_name', $row); + $content .= self::getCacheItem('name', $row); + $content .= self::getCacheItem('type', $row); + $content .= self::getCacheItem('length', $row, 'int'); + + $content .= self::getCacheItem('is_null', $row, 'bool'); + $content .= self::getCacheItem('is_main', $row, 'bool'); + $content .= self::getCacheItem('is_sys', $row, 'bool'); + $content .= self::getCacheItem('sort_num', $row, 'int'); + $content .= self::getCacheItem('note', $row); + + $content .= self::getCacheItem('front_status', $row, 'bool'); + $content .= self::getCacheItem('front_fun_add', $row); + $content .= self::getCacheItem('front_fun_update', $row); + $content .= self::getCacheItem('front_fun_show', $row); + $content .= self::getCacheItem('front_form_type', $row); + $content .= self::getCacheItem('front_form_option', $row); + $content .= self::getCacheItem('front_form_default', $row); + $content .= self::getCacheItem('front_form_source', $row); + $content .= self::getCacheItem('front_form_html', $row); + $content .= self::getCacheItem('front_note', $row); + + $content .= self::getCacheItem('back_status', $row, 'bool'); + $content .= self::getCacheItem('back_fun_add', $row); + $content .= self::getCacheItem('back_fun_update', $row); + $content .= self::getCacheItem('back_fun_show', $row); + $content .= self::getCacheItem('back_form_type', $row); + $content .= self::getCacheItem('back_form_option', $row); + $content .= self::getCacheItem('back_form_default', $row); + $content .= self::getCacheItem('back_form_source', $row); + $content .= self::getCacheItem('back_form_html', $row); + $content .= self::getCacheItem('back_note', $row); + + $content .= "];" . self::$newLine; + } + } + + self::writeFile('cachedFields.php', $content); + } + + public static function createTakonomyCache() + { + self::createCacheFile(); + + $content = '[' . self::$newLine; + $content .=' '. self::getCacheItem('id', $row,'int'); + $content .=' '. self::getCacheItem('parent_id', $row,'int'); + $content .= ' '. self::getCacheItemValue('child_ids', implode(',', $childrenIds)); + $content .=' '. self::getCacheItem('category_id', $row); + $content .=' '. self::getCacheItem('name', $row); + $content .=' '. self::getCacheItem('value', $row); + $content .=' '. self::getCacheItem('level', $row,'int'); + $content .=' '. self::getCacheItem('sort_num', $row,'int'); + $content .= " ]," . self::$newLine; + } + + $content .= "];" . self::$newLine; + } + + self::writeFile('cachedDicts.php', $content); + } + + private static function getCacheItem($name, $row, $dataType = null) + { + return self::getCacheItemValue($name, $row[$name], $dataType); + } + + private static function getCacheItemValue($name, $value, $dataType = null) + { + if($dataType == null) + { + $value = '\'' . $value . '\''; + } + else if($dataType == 'int') + { + $value = intval($value); + } + else if($dataType == 'bool') + { + if(strtolower($value) === 'true' || $value === '1' || $value === 1) + { + $value = 'true'; + } + else + { + $value = 'false'; + } + } + + return ' \'' . $name . '\' => ' . $value . ',' . self::$newLine; + } + + private static function writeFile($fileName, $content) + { + $rootData = \Yii::getAlias('@data'); + TFileHelper::writeFile([$rootData, 'cache', $fileName], $content); + } +} \ No newline at end of file diff --git a/core/lib/Common.php b/core/lib/Common.php new file mode 100644 index 0000000..8dff8ec --- /dev/null +++ b/core/lib/Common.php @@ -0,0 +1,10 @@ + 95, + 'parent_id' => 0, + 'parent_ids' => '0', + 'child_ids' => '102', + 'leaf_ids' => '102', + 'name' => '下载', + 'name_alias' => '下载', + 'name_url' => '', + 'redirect_url' => '', + 'level' => 0, + 'is_leaf' => false, + 'is_nav' => false, + 'sort_num' => 0, + 'table' => 'model_download', + 'channel_tpl' => 'channel_default.php', + 'list_tpl' => 'list_default.php', + 'detail_tpl' => 'detail_default.php', + 'page_size' => 0, + 'seo_title' => '', + 'seo_keywords' => '', + 'seo_description' => '', +]; +$cachedChannels['102']=[ + 'id' => 102, + 'parent_id' => 95, + 'parent_ids' => '0,95', + 'child_ids' => '', + 'leaf_ids' => '102', + 'name' => '软件', + 'name_alias' => '软件', + 'name_url' => '', + 'redirect_url' => '', + 'level' => 1, + 'is_leaf' => true, + 'is_nav' => false, + 'sort_num' => 0, + 'table' => 'model_download', + 'channel_tpl' => 'channel_default.php', + 'list_tpl' => 'list_default.php', + 'detail_tpl' => 'detail_default.php', + 'page_size' => 0, + 'seo_title' => '', + 'seo_keywords' => '', + 'seo_description' => '', +]; +$cachedChannels['103']=[ + 'id' => 103, + 'parent_id' => 0, + 'parent_ids' => '0', + 'child_ids' => '104,105,106,107', + 'leaf_ids' => '104,105,106,110,111', + 'name' => '新闻中心', + 'name_alias' => '新闻中心', + 'name_url' => 'news', + 'redirect_url' => '', + 'level' => 0, + 'is_leaf' => false, + 'is_nav' => false, + 'sort_num' => 0, + 'table' => 'model_news', + 'channel_tpl' => 'channel_default.php', + 'list_tpl' => 'list_default.php', + 'detail_tpl' => 'detail_default.php', + 'page_size' => 0, + 'seo_title' => '', + 'seo_keywords' => '', + 'seo_description' => '', +]; +$cachedChannels['104']=[ + 'id' => 104, + 'parent_id' => 103, + 'parent_ids' => '0,103', + 'child_ids' => '', + 'leaf_ids' => '104', + 'name' => '国际人物', + 'name_alias' => '国际人物', + 'name_url' => '', + 'redirect_url' => '', + 'level' => 1, + 'is_leaf' => true, + 'is_nav' => false, + 'sort_num' => 0, + 'table' => 'model_news', + 'channel_tpl' => 'channel_default.php', + 'list_tpl' => 'list_default.php', + 'detail_tpl' => 'detail_default.php', + 'page_size' => 0, + 'seo_title' => '', + 'seo_keywords' => '', + 'seo_description' => '', +]; +$cachedChannels['105']=[ + 'id' => 105, + 'parent_id' => 103, + 'parent_ids' => '0,103', + 'child_ids' => '', + 'leaf_ids' => '105', + 'name' => '体育新闻', + 'name_alias' => '体育新闻', + 'name_url' => '', + 'redirect_url' => '', + 'level' => 1, + 'is_leaf' => true, + 'is_nav' => false, + 'sort_num' => 0, + 'table' => 'model_news', + 'channel_tpl' => 'channel_default.php', + 'list_tpl' => 'list_default.php', + 'detail_tpl' => 'detail_default.php', + 'page_size' => 0, + 'seo_title' => '', + 'seo_keywords' => '', + 'seo_description' => '', +]; +$cachedChannels['106']=[ + 'id' => 106, + 'parent_id' => 103, + 'parent_ids' => '0,103', + 'child_ids' => '', + 'leaf_ids' => '106', + 'name' => '娱乐新闻', + 'name_alias' => '娱乐新闻', + 'name_url' => '', + 'redirect_url' => '', + 'level' => 1, + 'is_leaf' => true, + 'is_nav' => false, + 'sort_num' => 0, + 'table' => 'model_news', + 'channel_tpl' => 'channel.php', + 'list_tpl' => 'list.php', + 'detail_tpl' => 'detail.php', + 'page_size' => 0, + 'seo_title' => '', + 'seo_keywords' => '', + 'seo_description' => '', +]; +$cachedChannels['107']=[ + 'id' => 107, + 'parent_id' => 103, + 'parent_ids' => '0,103', + 'child_ids' => '110,111', + 'leaf_ids' => '110,111', + 'name' => '国内新闻', + 'name_alias' => '国内新闻', + 'name_url' => '', + 'redirect_url' => '', + 'level' => 1, + 'is_leaf' => false, + 'is_nav' => false, + 'sort_num' => 0, + 'table' => 'model_news', + 'channel_tpl' => 'channel.php', + 'list_tpl' => 'list.php', + 'detail_tpl' => 'detail.php', + 'page_size' => 0, + 'seo_title' => '', + 'seo_keywords' => '', + 'seo_description' => '', +]; +$cachedChannels['110']=[ + 'id' => 110, + 'parent_id' => 107, + 'parent_ids' => '0,103,107', + 'child_ids' => '', + 'leaf_ids' => '110', + 'name' => '时政新闻', + 'name_alias' => '时政新闻', + 'name_url' => '', + 'redirect_url' => '', + 'level' => 2, + 'is_leaf' => true, + 'is_nav' => false, + 'sort_num' => 0, + 'table' => 'model_news', + 'channel_tpl' => 'channel.php', + 'list_tpl' => 'list.php', + 'detail_tpl' => 'detail.php', + 'page_size' => 0, + 'seo_title' => '', + 'seo_keywords' => '', + 'seo_description' => '', +]; +$cachedChannels['111']=[ + 'id' => 111, + 'parent_id' => 107, + 'parent_ids' => '0,103,107', + 'child_ids' => '', + 'leaf_ids' => '111', + 'name' => '港澳台新闻', + 'name_alias' => '港澳台新闻', + 'name_url' => '', + 'redirect_url' => '', + 'level' => 2, + 'is_leaf' => true, + 'is_nav' => false, + 'sort_num' => 0, + 'table' => 'model_news', + 'channel_tpl' => 'channel.php', + 'list_tpl' => 'list.php', + 'detail_tpl' => 'detail.php', + 'page_size' => 0, + 'seo_title' => '', + 'seo_keywords' => '', + 'seo_description' => '', +]; +$cachedChannels['112']=[ + 'id' => 112, + 'parent_id' => 0, + 'parent_ids' => '0', + 'child_ids' => '118,119', + 'leaf_ids' => '118,119', + 'name' => '视频', + 'name_alias' => '视频', + 'name_url' => '', + 'redirect_url' => '', + 'level' => 0, + 'is_leaf' => false, + 'is_nav' => false, + 'sort_num' => 0, + 'table' => 'model_video', + 'channel_tpl' => 'channel.php', + 'list_tpl' => 'list.php', + 'detail_tpl' => 'detail.php', + 'page_size' => 0, + 'seo_title' => '', + 'seo_keywords' => '', + 'seo_description' => '', +]; +$cachedChannels['118']=[ + 'id' => 118, + 'parent_id' => 112, + 'parent_ids' => '0,112', + 'child_ids' => '', + 'leaf_ids' => '118', + 'name' => '爱情', + 'name_alias' => '爱情', + 'name_url' => '', + 'redirect_url' => '', + 'level' => 1, + 'is_leaf' => true, + 'is_nav' => false, + 'sort_num' => 0, + 'table' => 'model_video', + 'channel_tpl' => 'channel.php', + 'list_tpl' => 'list.php', + 'detail_tpl' => 'detail.php', + 'page_size' => 0, + 'seo_title' => '', + 'seo_keywords' => '', + 'seo_description' => '', +]; +$cachedChannels['119']=[ + 'id' => 119, + 'parent_id' => 112, + 'parent_ids' => '0,112', + 'child_ids' => '', + 'leaf_ids' => '119', + 'name' => '恐怖', + 'name_alias' => '恐怖', + 'name_url' => '', + 'redirect_url' => '', + 'level' => 1, + 'is_leaf' => true, + 'is_nav' => false, + 'sort_num' => 0, + 'table' => 'model_video', + 'channel_tpl' => 'channel.php', + 'list_tpl' => 'list.php', + 'detail_tpl' => 'detail.php', + 'page_size' => 0, + 'seo_title' => '', + 'seo_keywords' => '', + 'seo_description' => '', +]; +$cachedChannels['120']=[ + 'id' => 120, + 'parent_id' => 0, + 'parent_ids' => '0', + 'child_ids' => '', + 'leaf_ids' => '', + 'name' => 'yyyy', + 'name_alias' => 'yyyy', + 'name_url' => '', + 'redirect_url' => '', + 'level' => 0, + 'is_leaf' => false, + 'is_nav' => false, + 'sort_num' => 0, + 'table' => 'model_news', + 'channel_tpl' => 'channel_default.php', + 'list_tpl' => 'list_default.php', + 'detail_tpl' => 'detail_default.php', + 'page_size' => 0, + 'seo_title' => '', + 'seo_keywords' => '', + 'seo_description' => '', +]; diff --git a/models/Content.php b/models/Content.php index fdd80f4..4476e0d 100644 --- a/models/Content.php +++ b/models/Content.php @@ -43,6 +43,20 @@ class Content extends \app\core\base\BaseActiveRecord const STATUS_DRAFT='2'; const STATUS_PENDING='3'; + public static function getTypes($type=null) + { + $ret = [ + self::TYPE_POST => '文章', + self::TYPE_PAGE => '页面', + ]; + if($type!=null) + { + return $ret[$type]; + } + return $ret; + // return ['public'=>'公开','hidden'=>'回复可见','password'=>'密码保护','private'=>'私有']; + } + public static function getVisibilities() { return [ diff --git a/models/Takonomy.php b/models/Takonomy.php index 6ae2f74..c3993a9 100644 --- a/models/Takonomy.php +++ b/models/Takonomy.php @@ -22,6 +22,16 @@ class Takonomy extends \app\core\base\BaseActiveRecord const TYPE_PAGE = 2; const TYPE_TAG = 3; + public static function getTypes($type=null) + { + $ret = [self::TYPE_PAGE=>'页面分类',self::TYPE_POST=>'文章分类',self::TYPE_TAG=>'Tag分类' ]; + if($type!=null) + { + return $ret[$type]; + } + return $ret; + } + /** * @inheritdoc */ @@ -49,14 +59,62 @@ public function rules() public function attributeLabels() { return [ - 'id' => 'ID', - 'type' => 'Type ID', - 'parent_id' => 'Parent ID', - 'name' => 'Name', - 'alias' => 'Alias', - 'description' => 'Description', - 'contents' => 'Contents', - 'sort_num' => 'Sort Num', + 'id' => '编号', + 'type' => '类别', + 'parent_id' => '父结点', + 'name' => '名称', + 'alias' => '别名', + 'description' => '描述', + 'contents' => '内容数量', + 'sort_num' => '排序', ]; } + + private $_level; + + public function getLevel() + { + return $this->_level; + } + + public function setLevel($value) + { + $this->_level = $value; + } + + + + private static function getArrayTreeInternal($takonomies, $parentId = 0, $level = 0) + { + $ret = []; + + $dataList=[]; + foreach ($takonomies as $takonomy) + { + if($takonomy['parent_id']===$parentId) + { + $dataList[$takonomy['id']]=$takonomy; + } + } + + if($dataList == null || empty($dataList)) + { + return $ret; + } + + foreach($dataList as $key => $value) + { + $value->level = $level; + $ret[] = $value; + + $temp = self::getArrayTreeInternal($takonomies,$value['id'], $level + 1); + $ret = array_merge($ret, $temp); + } + return $ret; + } + public static function getArrayTree($type) + { + $takonomies = Takonomy::findAll(['type'=>$type],'sort_num desc'); + return self::getArrayTreeInternal($takonomies,0,0); + } } diff --git a/models/search/ContentSearch.php b/models/search/ContentSearch.php index 212b7a0..ef90dd4 100644 --- a/models/search/ContentSearch.php +++ b/models/search/ContentSearch.php @@ -55,29 +55,7 @@ public function search($params) return $dataProvider; } - $query->andFilterWhere([ - 'id' => $this->id, - 'user_id' => $this->user_id, - 'created_at' => $this->created_at, - 'updated_at' => $this->updated_at, - 'allow_comment' => $this->allow_comment, - 'comments' => $this->comments, - 'views' => $this->views, - 'diggs' => $this->diggs, - 'burys' => $this->burys, - 'sticky' => $this->sticky, - 'visibility' => $this->visibility, - 'status' => $this->status, - ]); - - $query->andFilterWhere(['like', 'password', $this->password]) - ->andFilterWhere(['like', 'thumb', $this->thumb]) - ->andFilterWhere(['like', 'title', $this->title]) - ->andFilterWhere(['like', 'alias', $this->alias]) - ->andFilterWhere(['like', 'excerpt', $this->excerpt]) - ->andFilterWhere(['like', 'content', $this->content]) - ->andFilterWhere(['like', 'content_type', $this->content_type]) - ->andFilterWhere(['like', 'template', $this->template]); + $query->andFilterWhere($params); return $dataProvider; } diff --git a/models/search/TakonomySearch.php b/models/search/TakonomySearch.php index 15f0265..fc4a785 100644 --- a/models/search/TakonomySearch.php +++ b/models/search/TakonomySearch.php @@ -47,21 +47,7 @@ public function search($params) 'query' => $query, ]); - $this->load($params); - - if (!$this->validate()) { - // uncomment the following line if you do not want to any records when validation fails - // $query->where('0=1'); - return $dataProvider; - } - - $query->andFilterWhere([ - 'id' => $this->id, - 'type' => $this->type, - 'parent_id' => $this->parent_id, - 'contents' => $this->contents, - 'sort_num' => $this->sort_num, - ]); + $query->andFilterWhere($params); $query->andFilterWhere(['like', 'name', $this->name]) ->andFilterWhere(['like', 'alias', $this->alias]) diff --git a/modules/admin/AdminModule.php b/modules/admin/AdminModule.php index af5941a..9d06af3 100644 --- a/modules/admin/AdminModule.php +++ b/modules/admin/AdminModule.php @@ -15,7 +15,7 @@ public function init() //false:不使用布局文件 //null:使用父级布局文件 //file name:使用当前Module 中 的布局文件 - $this->layout = 'main'; + $this->layout = '/main'; // custom initialization code goes here } } diff --git a/modules/admin/controllers/ContentController.php b/modules/admin/controllers/ContentController.php index c89d012..4826856 100644 --- a/modules/admin/controllers/ContentController.php +++ b/modules/admin/controllers/ContentController.php @@ -30,10 +30,10 @@ public function behaviors() * Lists all Content models. * @return mixed */ - public function actionIndex() + public function actionIndex($type) { $searchModel = new ContentSearch(); - $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + $dataProvider = $searchModel->search(['content_type'=>$type]); return $this->render('index', [ 'searchModel' => $searchModel, @@ -41,24 +41,13 @@ public function actionIndex() ]); } - /** - * Displays a single Content model. - * @param integer $id - * @return mixed - */ - public function actionView($id) - { - return $this->render('view', [ - 'model' => $this->findModel($id), - ]); - } /** * Creates a new Content model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ - public function actionCreate() + public function actionCreate($type) { $model = new Content(); $model->user_id=1; @@ -66,7 +55,7 @@ public function actionCreate() $model->loadDefaultValues(); if ($model->load(Yii::$app->request->post()) && $model->save()) { - return $this->redirect(['view', 'id' => $model->id]); + return $this->redirect(['index', 'type' => $type]); } else { return $this->render('create', [ 'model' => $model, @@ -85,7 +74,7 @@ public function actionUpdate($id) $model = $this->findModel($id); if ($model->load(Yii::$app->request->post()) && $model->save()) { - return $this->redirect(['view', 'id' => $model->id]); + return $this->redirect(['index', 'type' => $type]); } else { return $this->render('update', [ 'model' => $model, diff --git a/modules/admin/controllers/SiteController.php b/modules/admin/controllers/SiteController.php new file mode 100644 index 0000000..40b0a61 --- /dev/null +++ b/modules/admin/controllers/SiteController.php @@ -0,0 +1,18 @@ +render('index'); + } + + public function actionAbout() + { + return $this->render('about',['test'=>6]); + } +} diff --git a/modules/admin/controllers/TakonomyController.php b/modules/admin/controllers/TakonomyController.php index 65975a7..8ede15d 100644 --- a/modules/admin/controllers/TakonomyController.php +++ b/modules/admin/controllers/TakonomyController.php @@ -14,26 +14,16 @@ */ class TakonomyController extends BaseBackController { - public function behaviors() - { - return [ - 'verbs' => [ - 'class' => VerbFilter::className(), - 'actions' => [ - 'delete' => ['post'], - ], - ], - ]; - } + /** * Lists all Takonomy models. * @return mixed */ - public function actionIndex() + public function actionIndex($type) { $searchModel = new TakonomySearch(); - $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + $dataProvider = $searchModel->search(['type'=>$type]); return $this->render('index', [ 'searchModel' => $searchModel, @@ -46,7 +36,7 @@ public function actionIndex() * @param integer $id * @return mixed */ - public function actionView($id) + public function actionView($id,$type) { return $this->render('view', [ 'model' => $this->findModel($id), @@ -58,12 +48,13 @@ public function actionView($id) * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ - public function actionCreate() + public function actionCreate($type) { $model = new Takonomy(); - + $model->type=$type; + $model->loadDefaultValues(); if ($model->load(Yii::$app->request->post()) && $model->save()) { - return $this->redirect(['view', 'id' => $model->id]); + return $this->redirect(['index', 'type'=>$type]); } else { return $this->render('create', [ 'model' => $model, @@ -77,12 +68,12 @@ public function actionCreate() * @param integer $id * @return mixed */ - public function actionUpdate($id) + public function actionUpdate($id,$type) { $model = $this->findModel($id); if ($model->load(Yii::$app->request->post()) && $model->save()) { - return $this->redirect(['view', 'id' => $model->id]); + return $this->redirect(['index', 'type'=>$type]); } else { return $this->render('update', [ 'model' => $model, @@ -96,11 +87,11 @@ public function actionUpdate($id) * @param integer $id * @return mixed */ - public function actionDelete($id) + public function actionDelete($id,$type) { $this->findModel($id)->delete(); - return $this->redirect(['index']); + return $this->redirect(['index', 'type'=>$type]); } /** diff --git a/modules/admin/modules/rbac/RbacModule.php b/modules/admin/modules/rbac/RbacModule.php new file mode 100644 index 0000000..1180e17 --- /dev/null +++ b/modules/admin/modules/rbac/RbacModule.php @@ -0,0 +1,15 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['post'], + ], + ], + ]; + } + + /** + * Lists all Assignment models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new AssignmentSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single Assignment model. + * @param string $item_name + * @param string $user_id + * @return mixed + */ + public function actionView($item_name, $user_id) + { + return $this->render('view', [ + 'model' => $this->findModel($item_name, $user_id), + ]); + } + + /** + * Creates a new Assignment model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new Assignment(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'item_name' => $model->item_name, 'user_id' => $model->user_id]); + } else { + return $this->render('create', [ + 'model' => $model, + ]); + } + } + + /** + * Updates an existing Assignment model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param string $item_name + * @param string $user_id + * @return mixed + */ + public function actionUpdate($item_name, $user_id) + { + $model = $this->findModel($item_name, $user_id); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'item_name' => $model->item_name, 'user_id' => $model->user_id]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + /** + * Deletes an existing Assignment model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * @param string $item_name + * @param string $user_id + * @return mixed + */ + public function actionDelete($item_name, $user_id) + { + $this->findModel($item_name, $user_id)->delete(); + + return $this->redirect(['index']); + } + + /** + * Finds the Assignment model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param string $item_name + * @param string $user_id + * @return Assignment the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($item_name, $user_id) + { + if (($model = Assignment::findOne(['item_name' => $item_name, 'user_id' => $user_id])) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/modules/admin/modules/rbac/controllers/BaseController.php b/modules/admin/modules/rbac/controllers/BaseController.php new file mode 100644 index 0000000..73cbbc3 --- /dev/null +++ b/modules/admin/modules/rbac/controllers/BaseController.php @@ -0,0 +1,22 @@ +authManager=\Yii::$app->authManager; + } + + public function actionIndex() + { + return $this->render('index'); + } +} diff --git a/modules/admin/modules/rbac/controllers/DefaultController.php b/modules/admin/modules/rbac/controllers/DefaultController.php new file mode 100644 index 0000000..680721c --- /dev/null +++ b/modules/admin/modules/rbac/controllers/DefaultController.php @@ -0,0 +1,13 @@ +render('index'); + } +} diff --git a/modules/admin/modules/rbac/controllers/ItemController.php b/modules/admin/modules/rbac/controllers/ItemController.php new file mode 100644 index 0000000..b6ad5b8 --- /dev/null +++ b/modules/admin/modules/rbac/controllers/ItemController.php @@ -0,0 +1,82 @@ +findModel($id); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->name]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + /** + * 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) + { + $this->findModel($id)->delete(); + + return $this->redirect(['index']); + } + + /** + * Finds the Role model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param string $id + * @return Role the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Role::findOne(['name'=>$id])) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/modules/admin/modules/rbac/controllers/PermissionController.php b/modules/admin/modules/rbac/controllers/PermissionController.php new file mode 100644 index 0000000..5e70d94 --- /dev/null +++ b/modules/admin/modules/rbac/controllers/PermissionController.php @@ -0,0 +1,46 @@ +authManager->getPermissions(); + + return $this->render('index', [ + 'permissions' => $permissions, + ]); + } + + public function actionCreate() + { + $model = new PermissionForm(); + + + if ($model->load(Yii::$app->request->post())) { + + $role = new \yii\rbac\Permission(); + $role->name=$model->name; + $role->type=$model->type; + + $this->authManager->add($role); + return $this->redirect(['index', 'id' => $model->name]); + } else { + return $this->render('create', [ + 'model' => $model, + ]); + } + } +} diff --git a/modules/admin/modules/rbac/controllers/RoleController.php b/modules/admin/modules/rbac/controllers/RoleController.php new file mode 100644 index 0000000..fddf431 --- /dev/null +++ b/modules/admin/modules/rbac/controllers/RoleController.php @@ -0,0 +1,104 @@ +authManager->getRoles(); + + return $this->render('index', [ + 'roles' => $roles, + ]); + } + + public function actionCreate() + { + $model = new RoleForm(); + + if ($model->load(Yii::$app->request->post())) { + + $role = new \yii\rbac\Role(); + $role->name=$model->name; + $role->type=$model->type; + $this->authManager->add($role); + + foreach ($model->child as $permissionName) + { + $permissionObj = $this->authManager->getPermission($permissionName); + $this->authManager->addChild($role, $permissionObj); + } + + return $this->redirect(['index', 'id' => $model->name]); + } else { + $permission = $this->authManager->getPermissions(); + return $this->render('create', [ + 'model' => $model, + 'permissions'=>$permission + ]); + } + } + + public function actionUpdate($id) + { + $role = $this->authManager->getRole($id); + + $model = new RoleForm(); + $model->name=$role->name; + + if ($model->load(Yii::$app->request->post())) { + $role = new \yii\rbac\Role(); + $role->name=$model->name; + $role->type=$model->type; + $this->authManager->update($id, $role); + + $this->authManager->removeChildren($role); + foreach ($model->child as $permissionName) + { + $permissionObj = $this->authManager->getPermission($permissionName); + $this->authManager->addChild($role, $permissionObj); + } + + return $this->redirect(['index', 'id' => $model->name]); + } else { + $selectedPermissions = $this->authManager->getPermissionsByRole($id); + + if($selectedPermissions!=null) + { + foreach ($selectedPermissions as $p) + { + $model->child[] = $p->name; + } + } + + $permission = $this->authManager->getPermissions(); + return $this->render('update', [ + 'model' => $model, + 'permissions'=>$permission + ]); + } + } + + protected function findModel($id) + { + if (($model = Role::findOne(['name'=>$id])) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/modules/admin/modules/rbac/controllers/RuleController.php b/modules/admin/modules/rbac/controllers/RuleController.php new file mode 100644 index 0000000..c111339 --- /dev/null +++ b/modules/admin/modules/rbac/controllers/RuleController.php @@ -0,0 +1,121 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['post'], + ], + ], + ]; + } + + /** + * Lists all Rule models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new RuleSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single Rule model. + * @param string $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Rule model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new Rule(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->name]); + } else { + return $this->render('create', [ + 'model' => $model, + ]); + } + } + + /** + * Updates an existing Rule model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param string $id + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->name]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + /** + * Deletes an existing Rule model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * @param string $id + * @return mixed + */ + public function actionDelete($id) + { + $this->findModel($id)->delete(); + + return $this->redirect(['index']); + } + + /** + * Finds the Rule model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param string $id + * @return Rule the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Rule::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/modules/admin/modules/rbac/models/AssignmentForm.php b/modules/admin/modules/rbac/models/AssignmentForm.php new file mode 100644 index 0000000..6f0566c --- /dev/null +++ b/modules/admin/modules/rbac/models/AssignmentForm.php @@ -0,0 +1,58 @@ + 64] + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'item_name' => 'Item Name', + 'user_id' => 'User ID', + 'created_at' => 'Created At', + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getItemName() + { + return $this->hasOne(AuthItem::className(), ['name' => 'item_name']); + } +} diff --git a/modules/admin/modules/rbac/models/ItemChildForm.php b/modules/admin/modules/rbac/models/ItemChildForm.php new file mode 100644 index 0000000..4aa560c --- /dev/null +++ b/modules/admin/modules/rbac/models/ItemChildForm.php @@ -0,0 +1,63 @@ + 64] + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'parent' => 'Parent', + 'child' => 'Child', + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getParent0() + { + return $this->hasOne(AuthItem::className(), ['name' => 'parent']); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getChild0() + { + return $this->hasOne(AuthItem::className(), ['name' => 'child']); + } +} diff --git a/modules/admin/modules/rbac/models/ItemForm.php b/modules/admin/modules/rbac/models/ItemForm.php new file mode 100644 index 0000000..46847c0 --- /dev/null +++ b/modules/admin/modules/rbac/models/ItemForm.php @@ -0,0 +1,53 @@ + 64], + [['child'],'safe'] + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'name' => 'Name', + 'type' => 'Type', + 'description' => 'Description', + 'rule_name' => 'Rule Name', + 'data' => 'Data', + 'created_at' => 'Created At', + 'updated_at' => 'Updated At', + ]; + } + + +} diff --git a/modules/admin/modules/rbac/models/PermissionForm.php b/modules/admin/modules/rbac/models/PermissionForm.php new file mode 100644 index 0000000..f8a547d --- /dev/null +++ b/modules/admin/modules/rbac/models/PermissionForm.php @@ -0,0 +1,17 @@ +type = \yii\rbac\Item::TYPE_PERMISSION; + } +} diff --git a/modules/admin/modules/rbac/models/RoleForm.php b/modules/admin/modules/rbac/models/RoleForm.php new file mode 100644 index 0000000..ea4fcad --- /dev/null +++ b/modules/admin/modules/rbac/models/RoleForm.php @@ -0,0 +1,15 @@ +type = \yii\rbac\Item::TYPE_ROLE; + } +} diff --git a/modules/admin/modules/rbac/models/RuleForm.php b/modules/admin/modules/rbac/models/RuleForm.php new file mode 100644 index 0000000..2acb709 --- /dev/null +++ b/modules/admin/modules/rbac/models/RuleForm.php @@ -0,0 +1,61 @@ + 64] + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'name' => 'Name', + 'data' => 'Data', + 'created_at' => 'Created At', + 'updated_at' => 'Updated At', + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getAuthItems() + { + return $this->hasMany(AuthItem::className(), ['rule_name' => 'name']); + } +} diff --git a/modules/admin/modules/rbac/views/assignment/_form.php b/modules/admin/modules/rbac/views/assignment/_form.php new file mode 100644 index 0000000..b8b4085 --- /dev/null +++ b/modules/admin/modules/rbac/views/assignment/_form.php @@ -0,0 +1,27 @@ + + +
+ + + + field($model, 'item_name')->textInput(['maxlength' => 64]) ?> + + field($model, 'user_id')->textInput(['maxlength' => 64]) ?> + + field($model, 'created_at')->textInput() ?> + +
+ isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> +
+ + + +
diff --git a/modules/admin/modules/rbac/views/assignment/_search.php b/modules/admin/modules/rbac/views/assignment/_search.php new file mode 100644 index 0000000..5dc37c7 --- /dev/null +++ b/modules/admin/modules/rbac/views/assignment/_search.php @@ -0,0 +1,31 @@ + + + diff --git a/modules/admin/modules/rbac/views/assignment/create.php b/modules/admin/modules/rbac/views/assignment/create.php new file mode 100644 index 0000000..dda098f --- /dev/null +++ b/modules/admin/modules/rbac/views/assignment/create.php @@ -0,0 +1,21 @@ +title = 'Create Assignment'; +$this->params['breadcrumbs'][] = ['label' => 'Assignments', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/modules/admin/modules/rbac/views/assignment/index.php b/modules/admin/modules/rbac/views/assignment/index.php new file mode 100644 index 0000000..f6dec0e --- /dev/null +++ b/modules/admin/modules/rbac/views/assignment/index.php @@ -0,0 +1,36 @@ +title = 'Assignments'; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ render('_search', ['model' => $searchModel]); ?> + +

+ 'btn btn-success']) ?> +

+ + $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + 'item_name', + 'user_id', + 'created_at', + + ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> + +
diff --git a/modules/admin/modules/rbac/views/assignment/update.php b/modules/admin/modules/rbac/views/assignment/update.php new file mode 100644 index 0000000..e770973 --- /dev/null +++ b/modules/admin/modules/rbac/views/assignment/update.php @@ -0,0 +1,21 @@ +title = 'Update Assignment: ' . ' ' . $model->item_name; +$this->params['breadcrumbs'][] = ['label' => 'Assignments', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->item_name, 'url' => ['view', 'item_name' => $model->item_name, 'user_id' => $model->user_id]]; +$this->params['breadcrumbs'][] = 'Update'; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/modules/admin/modules/rbac/views/assignment/view.php b/modules/admin/modules/rbac/views/assignment/view.php new file mode 100644 index 0000000..11ffdf1 --- /dev/null +++ b/modules/admin/modules/rbac/views/assignment/view.php @@ -0,0 +1,37 @@ +title = $model->item_name; +$this->params['breadcrumbs'][] = ['label' => 'Assignments', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

+ $model->item_name, 'user_id' => $model->user_id], ['class' => 'btn btn-primary']) ?> + $model->item_name, 'user_id' => $model->user_id], [ + 'class' => 'btn btn-danger', + 'data' => [ + 'confirm' => 'Are you sure you want to delete this item?', + 'method' => 'post', + ], + ]) ?> +

+ + $model, + 'attributes' => [ + 'item_name', + 'user_id', + 'created_at', + ], + ]) ?> + +
diff --git a/modules/admin/modules/rbac/views/default/index.php b/modules/admin/modules/rbac/views/default/index.php new file mode 100644 index 0000000..bdf5f33 --- /dev/null +++ b/modules/admin/modules/rbac/views/default/index.php @@ -0,0 +1,12 @@ +
+

context->action->uniqueId ?>

+

+ This is the view content for action "context->action->id ?>". + The action belongs to the controller "context) ?>" + in the "context->module->id ?>" module. +

+

+ You may customize this page by editing the following file:
+ +

+
diff --git a/modules/admin/modules/rbac/views/permission/_form.php b/modules/admin/modules/rbac/views/permission/_form.php new file mode 100644 index 0000000..5759891 --- /dev/null +++ b/modules/admin/modules/rbac/views/permission/_form.php @@ -0,0 +1,36 @@ + + +
+ + + + field($model, 'name')->textInput(['maxlength' => 64]) ?> + + field($model, 'type')->textInput() ?> + + field($model, 'description')->textarea(['rows' => 6]) ?> + + field($model, 'rule_name')->textInput(['maxlength' => 64]) ?> + + field($model, 'data')->textarea(['rows' => 6]) ?> + + field($model, 'created_at')->textInput() ?> + + field($model, 'updated_at')->textInput() ?> + + +
+ isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> +
+ + + +
diff --git a/modules/admin/modules/rbac/views/permission/_search.php b/modules/admin/modules/rbac/views/permission/_search.php new file mode 100644 index 0000000..28b3e8a --- /dev/null +++ b/modules/admin/modules/rbac/views/permission/_search.php @@ -0,0 +1,39 @@ + + + diff --git a/modules/admin/modules/rbac/views/permission/create.php b/modules/admin/modules/rbac/views/permission/create.php new file mode 100644 index 0000000..865488f --- /dev/null +++ b/modules/admin/modules/rbac/views/permission/create.php @@ -0,0 +1,21 @@ +title = 'Create Permission'; +$this->params['breadcrumbs'][] = ['label' => 'Permissions', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/modules/admin/modules/rbac/views/permission/index.php b/modules/admin/modules/rbac/views/permission/index.php new file mode 100644 index 0000000..b2c9e93 --- /dev/null +++ b/modules/admin/modules/rbac/views/permission/index.php @@ -0,0 +1,27 @@ +title = 'Permissions'; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ render('_search', ['model' => $searchModel]); ?> + +

+ 'btn btn-success']) ?> +

+ + +
  • name?>
  • + + + +
    diff --git a/modules/admin/modules/rbac/views/permission/update.php b/modules/admin/modules/rbac/views/permission/update.php new file mode 100644 index 0000000..bfc6cdb --- /dev/null +++ b/modules/admin/modules/rbac/views/permission/update.php @@ -0,0 +1,21 @@ +title = 'Update Permission: ' . ' ' . $model->name; +$this->params['breadcrumbs'][] = ['label' => 'Permissions', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->name]]; +$this->params['breadcrumbs'][] = 'Update'; +?> +
    + +

    title) ?>

    + + render('_form', [ + 'model' => $model, + ]) ?> + +
    diff --git a/modules/admin/modules/rbac/views/permission/view.php b/modules/admin/modules/rbac/views/permission/view.php new file mode 100644 index 0000000..31c3c36 --- /dev/null +++ b/modules/admin/modules/rbac/views/permission/view.php @@ -0,0 +1,41 @@ +title = $model->name; +$this->params['breadcrumbs'][] = ['label' => 'Permissions', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
    + +

    title) ?>

    + +

    + $model->name], ['class' => 'btn btn-primary']) ?> + $model->name], [ + 'class' => 'btn btn-danger', + 'data' => [ + 'confirm' => 'Are you sure you want to delete this item?', + 'method' => 'post', + ], + ]) ?> +

    + + $model, + 'attributes' => [ + 'name', + 'type', + 'description:ntext', + 'rule_name', + 'data:ntext', + 'created_at', + 'updated_at', + ], + ]) ?> + +
    diff --git a/modules/admin/modules/rbac/views/role/_form.php b/modules/admin/modules/rbac/views/role/_form.php new file mode 100644 index 0000000..794d47b --- /dev/null +++ b/modules/admin/modules/rbac/views/role/_form.php @@ -0,0 +1,34 @@ + + +
    + + + + field($model, 'name')->textInput(['maxlength' => 64]) ?> + + + field($model, 'description')->textarea(['rows' => 6]) ?> + + field($model, 'rule_name')->textInput(['maxlength' => 64]) ?> + + field($model, 'data')->textarea(['rows' => 6]) ?> + + field($model, 'child')->listBox(ArrayHelper::map($permissions, 'name', 'name'),['multiple'=>'true'])?> + + child)?> +
    + isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> +
    + + + +
    diff --git a/modules/admin/modules/rbac/views/role/_search.php b/modules/admin/modules/rbac/views/role/_search.php new file mode 100644 index 0000000..8504908 --- /dev/null +++ b/modules/admin/modules/rbac/views/role/_search.php @@ -0,0 +1,39 @@ + + + diff --git a/modules/admin/modules/rbac/views/role/create.php b/modules/admin/modules/rbac/views/role/create.php new file mode 100644 index 0000000..9118e94 --- /dev/null +++ b/modules/admin/modules/rbac/views/role/create.php @@ -0,0 +1,22 @@ +title = 'Create Role'; +$this->params['breadcrumbs'][] = ['label' => 'Roles', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
    + +

    title) ?>

    + + render('_form', [ + 'model' => $model, + 'permissions'=>$permissions + ]) ?> + +
    diff --git a/modules/admin/modules/rbac/views/role/index.php b/modules/admin/modules/rbac/views/role/index.php new file mode 100644 index 0000000..b579353 --- /dev/null +++ b/modules/admin/modules/rbac/views/role/index.php @@ -0,0 +1,29 @@ +title = 'Roles'; +$this->params['breadcrumbs'][] = $this->title; +?> +
    + +

    title) ?>

    + render('_search', ['model' => $searchModel]); ?> + +

    + 'btn btn-success']) ?> +

    + + + + +
    diff --git a/modules/admin/modules/rbac/views/role/update.php b/modules/admin/modules/rbac/views/role/update.php new file mode 100644 index 0000000..43d6bb8 --- /dev/null +++ b/modules/admin/modules/rbac/views/role/update.php @@ -0,0 +1,22 @@ +title = 'Update Role: ' . ' ' . $model->name; +$this->params['breadcrumbs'][] = ['label' => 'Roles', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->name]]; +$this->params['breadcrumbs'][] = 'Update'; +?> +
    + +

    title) ?>

    + + render('_form', [ + 'model' => $model, + 'permissions'=>$permissions + ]) ?> + +
    diff --git a/modules/admin/modules/rbac/views/role/view.php b/modules/admin/modules/rbac/views/role/view.php new file mode 100644 index 0000000..11c3939 --- /dev/null +++ b/modules/admin/modules/rbac/views/role/view.php @@ -0,0 +1,41 @@ +title = $model->name; +$this->params['breadcrumbs'][] = ['label' => 'Roles', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
    + +

    title) ?>

    + +

    + $model->name], ['class' => 'btn btn-primary']) ?> + $model->name], [ + 'class' => 'btn btn-danger', + 'data' => [ + 'confirm' => 'Are you sure you want to delete this item?', + 'method' => 'post', + ], + ]) ?> +

    + + $model, + 'attributes' => [ + 'name', + 'type', + 'description:ntext', + 'rule_name', + 'data:ntext', + 'created_at', + 'updated_at', + ], + ]) ?> + +
    diff --git a/modules/admin/modules/rbac/views/rule/_form.php b/modules/admin/modules/rbac/views/rule/_form.php new file mode 100644 index 0000000..65a01a5 --- /dev/null +++ b/modules/admin/modules/rbac/views/rule/_form.php @@ -0,0 +1,29 @@ + + +
    + + + + field($model, 'name')->textInput(['maxlength' => 64]) ?> + + field($model, 'data')->textarea(['rows' => 6]) ?> + + field($model, 'created_at')->textInput() ?> + + field($model, 'updated_at')->textInput() ?> + +
    + isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> +
    + + + +
    diff --git a/modules/admin/modules/rbac/views/rule/_search.php b/modules/admin/modules/rbac/views/rule/_search.php new file mode 100644 index 0000000..83ece86 --- /dev/null +++ b/modules/admin/modules/rbac/views/rule/_search.php @@ -0,0 +1,33 @@ + + + diff --git a/modules/admin/modules/rbac/views/rule/create.php b/modules/admin/modules/rbac/views/rule/create.php new file mode 100644 index 0000000..c3d9d16 --- /dev/null +++ b/modules/admin/modules/rbac/views/rule/create.php @@ -0,0 +1,21 @@ +title = 'Create Rule'; +$this->params['breadcrumbs'][] = ['label' => 'Rules', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
    + +

    title) ?>

    + + render('_form', [ + 'model' => $model, + ]) ?> + +
    diff --git a/modules/admin/modules/rbac/views/rule/index.php b/modules/admin/modules/rbac/views/rule/index.php new file mode 100644 index 0000000..60cfe25 --- /dev/null +++ b/modules/admin/modules/rbac/views/rule/index.php @@ -0,0 +1,37 @@ +title = 'Rules'; +$this->params['breadcrumbs'][] = $this->title; +?> +
    + +

    title) ?>

    + render('_search', ['model' => $searchModel]); ?> + +

    + 'btn btn-success']) ?> +

    + + $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + 'name', + 'data:ntext', + 'created_at', + 'updated_at', + + ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> + +
    diff --git a/modules/admin/modules/rbac/views/rule/update.php b/modules/admin/modules/rbac/views/rule/update.php new file mode 100644 index 0000000..cfba4ff --- /dev/null +++ b/modules/admin/modules/rbac/views/rule/update.php @@ -0,0 +1,21 @@ +title = 'Update Rule: ' . ' ' . $model->name; +$this->params['breadcrumbs'][] = ['label' => 'Rules', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->name]]; +$this->params['breadcrumbs'][] = 'Update'; +?> +
    + +

    title) ?>

    + + render('_form', [ + 'model' => $model, + ]) ?> + +
    diff --git a/modules/admin/modules/rbac/views/rule/view.php b/modules/admin/modules/rbac/views/rule/view.php new file mode 100644 index 0000000..fce6b85 --- /dev/null +++ b/modules/admin/modules/rbac/views/rule/view.php @@ -0,0 +1,38 @@ +title = $model->name; +$this->params['breadcrumbs'][] = ['label' => 'Rules', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
    + +

    title) ?>

    + +

    + $model->name], ['class' => 'btn btn-primary']) ?> + $model->name], [ + 'class' => 'btn btn-danger', + 'data' => [ + 'confirm' => 'Are you sure you want to delete this item?', + 'method' => 'post', + ], + ]) ?> +

    + + $model, + 'attributes' => [ + 'name', + 'data:ntext', + 'created_at', + 'updated_at', + ], + ]) ?> + +
    diff --git a/modules/admin/views/content/_form.php b/modules/admin/views/content/_form.php index 3dab5d1..a8c4c9b 100644 --- a/modules/admin/views/content/_form.php +++ b/modules/admin/views/content/_form.php @@ -1,5 +1,4 @@ "{label}{input}\n{error}", + 'labelOptions' => [ + 'class' => 'control-label' + ] +] +; ?> -
    +
    - -
    -
    - field($model, 'title')->textInput(['maxlength' => 256,'placeholder'=>'请输入标题'])->label(false) ?> - field($model, 'alias')->textInput(['maxlength' => 128,'placeholder'=>'Url 地址']) ?> - field($model, 'content')->textarea(['rows' => 12]) ?> + [ + 'template' => "{label}
    {input}
    \n{error}", + 'labelOptions' => [ + 'class' => 'col-md-3 control-label no-padding-left no-padding-right align-left' + ] + ], + + ]); + ?> - field($model, 'excerpt')->textarea(['rows' => 6]) ?> -
    +
    +
    + field($model, 'title',$filedOptions)->textInput(['maxlength' => 256,'placeholder'=>'请输入标题'])->label(false)?> + + field($model, 'alias',$filedOptions)->textInput(['maxlength' => 128,'placeholder'=>'Url 地址'])?> + + field($model, 'content',$filedOptions)->textarea(['rows' => 12]) ?> + + field($model, 'excerpt',$filedOptions)->textarea(['rows' => 6])?> +
    + +
    -
    - - field($model, 'visibility')->dropDownList(Content::getVisibilities()) ?> + field($model, 'visibility')->dropDownList(Content::getVisibilities())?> + + field($model, 'password')->passwordInput(['maxlength' => 64])?> + + field($model, 'status')->dropDownList(Content::getStatuses())?> + + field($model, 'allow_comment')->checkbox([],false)?> + + field($model, 'sticky')->checkbox([],false)?> + + field($model, 'thumb')->textInput(['maxlength' => 256])?> - field($model, 'password')->passwordInput(['maxlength' => 64]) ?> - - field($model, 'status')->dropDownList(Content::getStatuses()) ?> - field($model, 'allow_comment')->checkbox() ?> - - field($model, 'sticky')->checkbox() ?> - - field($model, 'thumb')->textInput(['maxlength' => 256]) ?> - - field($model, 'template')->textInput(['maxlength' => 64]) ?> - - field($model, 'comments')->textInput() ?> - - field($model, 'views')->textInput() ?> - - field($model, 'diggs')->textInput() ?> - - field($model, 'burys')->textInput() ?> - -
    - isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> -
    + field($model, 'template')->textInput(['maxlength' => 64])?> + field($model, 'comments')->textInput()?> + + field($model, 'views')->textInput()?> + + field($model, 'diggs')->textInput()?> + + field($model, 'burys')->textInput()?> + +
    + isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary'])?> +
    -
    - +
    +
    diff --git a/modules/admin/views/content/index.php b/modules/admin/views/content/index.php index 55fb9a9..95b3c02 100644 --- a/modules/admin/views/content/index.php +++ b/modules/admin/views/content/index.php @@ -2,24 +2,25 @@ use yii\helpers\Html; use yii\grid\GridView; +use app\core\LuLu; +use app\models\Content; /* @var $this yii\web\View */ /* @var $searchModel app\models\search\ContentSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ - -$this->title = 'Contents'; +$type=LuLu::getGetValue('type'); +$this->title = Content::getTypes($type); $this->params['breadcrumbs'][] = $this->title; + + ?>
    -
    -admin content index view -

    title) ?>

    render('_search', ['model' => $searchModel]); ?>

    - 'btn btn-success']) ?> + $type], ['class' => 'btn btn-success']) ?>

    title = 'About'; +$this->params['breadcrumbs'][] = $this->title; +?> +
    +

    title) ?>

    + +

    + This is the About page. You may modify the following file to customize its content: +

    + + + +
    diff --git a/modules/admin/views/layouts/main.php b/modules/admin/views/layouts/main.php index 3db7e62..f113501 100644 --- a/modules/admin/views/layouts/main.php +++ b/modules/admin/views/layouts/main.php @@ -71,6 +71,7 @@ ?>
    + admin layout isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [], ]) ?> diff --git a/modules/admin/views/site/about.php b/modules/admin/views/site/about.php new file mode 100644 index 0000000..e90c20a --- /dev/null +++ b/modules/admin/views/site/about.php @@ -0,0 +1,17 @@ +title = 'About'; +$this->params['breadcrumbs'][] = $this->title; +?> +
    +

    title) ?>

    + +

    + This is the About page. You may modify the following file to customize its content: +

    + + + +
    diff --git a/modules/admin/views/takonomy/_form.php b/modules/admin/views/takonomy/_form.php index 44de11d..3d0fcd1 100644 --- a/modules/admin/views/takonomy/_form.php +++ b/modules/admin/views/takonomy/_form.php @@ -2,19 +2,42 @@ use yii\helpers\Html; use yii\widgets\ActiveForm; +use app\models\Takonomy; +use app\core\helpers\TStringHelper; /* @var $this yii\web\View */ /* @var $model app\models\Takonomy */ /* @var $form yii\widgets\ActiveForm */ + + +$options = ''; +$takonomies = Takonomy::getArrayTree($type); +foreach($takonomies as $row) +{ + $style = ''; + + if($model['parent_id'] == intval($row['id'])) + { + $style = ' selected'; + } + $options .= ''; +} + ?>
    - field($model, 'type')->textInput() ?> - field($model, 'parent_id')->textInput() ?> +
    + + + +
    +
    field($model, 'name')->textInput(['maxlength' => 64]) ?> @@ -22,8 +45,6 @@ field($model, 'description')->textInput(['maxlength' => 256]) ?> - field($model, 'contents')->textInput() ?> - field($model, 'sort_num')->textInput() ?>
    diff --git a/modules/admin/views/takonomy/create.php b/modules/admin/views/takonomy/create.php index 8f43fe3..935fde7 100644 --- a/modules/admin/views/takonomy/create.php +++ b/modules/admin/views/takonomy/create.php @@ -1,13 +1,16 @@ title = 'Create Takonomy'; -$this->params['breadcrumbs'][] = ['label' => 'Takonomies', 'url' => ['index']]; +$this->title = '新建'.Common::getTakonomyArray($type); +$this->params['breadcrumbs'][] = ['label' => Common::getTakonomyArray($type), 'url' => ['index','type'=>$type]]; $this->params['breadcrumbs'][] = $this->title; ?>
    @@ -16,6 +19,7 @@ render('_form', [ 'model' => $model, + 'type'=>$type, ]) ?>
    diff --git a/modules/admin/views/takonomy/index.php b/modules/admin/views/takonomy/index.php index 091515b..db08ba9 100644 --- a/modules/admin/views/takonomy/index.php +++ b/modules/admin/views/takonomy/index.php @@ -2,12 +2,16 @@ use yii\helpers\Html; use yii\grid\GridView; +use app\core\LuLu; +use app\core\lib\Common; +use app\models\Takonomy; /* @var $this yii\web\View */ /* @var $searchModel app\models\search\TakonomySearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ -$this->title = 'Takonomies'; +$type=LuLu::getGetValue('type'); +$this->title = Takonomy::getTypes($type); $this->params['breadcrumbs'][] = $this->title; ?>
    @@ -16,7 +20,7 @@ render('_search', ['model' => $searchModel]); ?>

    - 'btn btn-success']) ?> + LuLu::getGetValue('type')], ['class' => 'btn btn-success']) ?>

    title = 'Update Takonomy: ' . ' ' . $model->name; -$this->params['breadcrumbs'][] = ['label' => 'Takonomies', 'url' => ['index']]; +$type=LuLu::getGetValue('type'); + +$this->title = '更新: '.Common::getTakonomyArray($type) . ' ' . $model->name; +$this->params['breadcrumbs'][] = ['label' => Common::getTakonomyArray($type), 'url' => ['index','type'=>$type]]; $this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]]; $this->params['breadcrumbs'][] = 'Update'; ?> @@ -16,6 +20,7 @@ render('_form', [ 'model' => $model, + 'type'=>$type ]) ?>
    diff --git a/views/default/contact.php b/views/default/contact.php new file mode 100644 index 0000000..6e5c3e4 --- /dev/null +++ b/views/default/contact.php @@ -0,0 +1,17 @@ +title = 'Contact'; +$this->params['breadcrumbs'][] = $this->title; +?> +
    +

    title) ?>

    + + render('/site/error',['name'=>'test','message'=>'message'])?> +
    diff --git a/views/layouts/column-2.php b/views/layouts/column-2.php new file mode 100644 index 0000000..a7e5358 --- /dev/null +++ b/views/layouts/column-2.php @@ -0,0 +1,23 @@ + + + + //指定view 文件(别名或者路径) + beginContent('@app/views/layouts/main.php'); ?> + + + + endContent(); ?> + + \ No newline at end of file diff --git a/views/layouts/main.php b/views/layouts/main.php index 84bf87d..459bf37 100644 --- a/views/layouts/main.php +++ b/views/layouts/main.php @@ -9,6 +9,8 @@ /* @var $content string */ AppAsset::register($this); + + ?> beginPage() ?> @@ -19,6 +21,8 @@ <?= Html::encode($this->title) ?> head() ?> + + registerLinkTag(['rel'=>'archives','title'=>'Yii2|Yii爱好者中文社区门户','href'=>'test']);?> @@ -49,10 +53,13 @@ ?>
    + isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [], ]) ?> + +
    diff --git a/views/layouts/test-main.php b/views/layouts/test-main.php new file mode 100644 index 0000000..c252754 --- /dev/null +++ b/views/layouts/test-main.php @@ -0,0 +1,59 @@ + viewFile === null) + { + throw new InvalidConfigException('InhritLayout::viewFile must be set.'); + } + ob_start(); + ob_implicit_flush(false); + } + + public function run() + { + $params = $this->params; + if(! isset($params['content'])) + { + $params['content'] = ob_get_clean(); + } + if(count($this->blocks) > 0) + { + foreach($this->blocks as $id) + { + if(in_array($id, $this->view->blocks)) + { + $params[$id] = $this->view->blocks[$id]; + unset($this->view->blocks[$id]); + } + } + } + else + { + foreach($this->view->blocks as $id => $block) + { + $params[$id] = $block; + unset($this->view->blocks[$id]); + } + } + echo $this->view->renderFile($this->viewFile, $params); + } + } \ No newline at end of file diff --git a/views/site/about.php b/views/site/about.php index 13d85a6..7fc515e 100644 --- a/views/site/about.php +++ b/views/site/about.php @@ -1,16 +1,62 @@ title = 'About'; $this->params['breadcrumbs'][] = $this->title; + +$this->registerLinkTag(['rel'=>'archives','title'=>'Yii2|Yii爱好者中文社区门户','href'=>'2'],'addlink'); +$this->registerLinkTag(['rel'=>'archives','title'=>'Yii2|Yii爱好者中文社区门户','href'=>'1'],'addlink'); + + +$this->registerMetaTag(['name'=>'generator','content'=>'Discuz! X3.2']); +$this->registerMetaTag(['name'=>'author','content'=>'Discuz! Team and Comsenz UI Team']); + + +$cssString='body{margin:0px;padding:0px;}'; +$this->registerCss($cssString); +$this->registerCssFile('css/site.css'); + +$jsString='$("#id").height(5)'; +$this->registerJs($jsString,View::POS_READY); +$this->registerJsFile('assets/35aad32d/gii.js',['depends'=>['yii\web\YiiAsset'],'position'=>View::POS_HEAD]); + +$this->blocks['content']=''; +$this->blocks['sidebar']=''; + +$context = $this->context; +$context->actionAbout(); ?> -
    -

    title) ?>

    -

    - This is the About page. You may modify the following file to customize its content: -

    - -
    +
    +

    title) ?>

    + +

    + This is the About page. You may modify the following file to customize its content: +

    +
    + test data is + testData2;?>
    + +
    + + + + + + + + + + + + + + + + + diff --git a/views/site/index.php b/views/site/index.php index ffd8cf4..9534ae0 100644 --- a/views/site/index.php +++ b/views/site/index.php @@ -1,6 +1,10 @@ title = 'My Yii Application'; + + + ?>
    diff --git a/views/user/testview.php b/views/user/testview.php new file mode 100644 index 0000000..063c5bd --- /dev/null +++ b/views/user/testview.php @@ -0,0 +1,17 @@ +title = 'Users'; +$this->params['breadcrumbs'][] = $this->title; +?> +
    + + aaaaa + +
    diff --git a/web/css/site.css b/web/css/site.css index 698be70..8e49c07 100644 --- a/web/css/site.css +++ b/web/css/site.css @@ -89,3 +89,59 @@ a.desc:after { padding: 10px 20px; margin: 0 0 15px 0; } + +.lighter{font-weight:lighter} +.bolder{font-weight:bolder} + +.inline{display:inline-block!important} +.block{display:block!important} + +.center,.align-center{text-align:center!important} +.align-left{text-align:left!important} +.align-right{text-align:right!important} + +.middle,.align-middle{vertical-align:middle!important} +.align-top{vertical-align:top!important} +.align-bottom{vertical-align:bottom!important} + +.position-relative{position:relative} +.position-absolute{position:absolute} + +.line-height-normal{line-height:normal!important} +.line-height-1{line-height:1!important} + +.width-auto{width:auto!important} +.height-auto{height:auto!important} + +.no-padding{padding:0!important} +.no-padding-bottom{padding-bottom:0!important} +.no-padding-top{padding-top:0!important} +.no-padding-left{padding-left:0!important} +.no-padding-right{padding-right:0!important} + +.no-margin{margin:0!important} +.no-margin-bottom{margin-bottom:0!important} +.no-margin-top{margin-top:0!important} +.no-margin-left{margin-left:0!important} +.no-margin-right{margin-right:0!important} + +.no-border{border:0} +.no-border-bottom{border-bottom:0} +.no-border-top{border-top:0} +.no-border-left{border-left:none} +.no-border-right{border-right:0} + +.no-underline{text-decoration:none!important} +.no-hover-underline:hover{text-decoration:none!important} +.no-shadow,.no-box-shadow{-webkit-box-shadow:none!important;box-shadow:none!important} +.no-text-shadow{text-shadow:none!important} + +.overflow-hidden{overflow:hidden!important} +.overflow-auto{overflow:auto!important} +.overflow-scroll{overflow:scroll!important} +.overflow-visible{overflow:visible!important} + +.hr{display:block;height:0;overflow:hidden;font-size:0;border-top:1px solid #e3e3e3;margin:12px 0} +.hr-double{height:3px;border-top:1px solid #e3e3e3;border-bottom:1px solid #e3e3e3} +.hr.dotted,.hr-dotted{border-top-style:dotted} +.hr-double.dotted{border-bottom-style:dotted}