Giter VIP home page Giter VIP logo

admin's Introduction

CakePHP Admin Plugin

CakePHP Plugin for automagic admin using Twitter Bootstrap. Version 1.0 for CakePHP 2.x

This plugin uses the cake scaffolding to create admin panel automagically!

Restore

Installation

  1. Copy or clone plugin to app/Plugin/Admin
  2. Enable the plugin in app/Config/bootstrap.php !make sure to enable bootstrap true. Example code:
CakePlugin::load('Admin',array('bootstrap' => true));
  1. The plugin uses CakePHP's Session Component, so if you haven't already, make sure it's added to app/Controller/AppController.php. Example code:
public $components = array('Session');

Database Tables

Create the database tables

CREATE TABLE IF NOT EXISTS `users` (
  `id` int(11) NOT NULL,
  `username` varchar(50) NOT NULL,
  `password` varchar(40) NOT NULL,
  `email` varchar(150) NOT NULL,
  `first_name` varchar(40) DEFAULT NULL,
  `middle_name` varchar(40) DEFAULT NULL,
  `last_name` varchar(40) DEFAULT NULL,
  `group_id` int(4) DEFAULT '4',
  `is_active` tinyint(1) DEFAULT '1',
  `created_date` datetime DEFAULT NULL,
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
);

-- 
-- Data for table `users`
-- 

INSERT INTO `users` (
	`id`, 
	`username`, 
	`password`, 
	`email`, 
	`first_name`, 
	`middle_name`, 
	`last_name`, 
	`group_id`, 
	`is_active`, 
	`created_date`, 
	`timestamp`) 
	VALUES (
	'1',
	'admin',
	'21232f297a57a5a743894a0e4a801fc3',
	'[email protected]',
	'Admin', '', '',
	'1',
	'1',
	NULL,
	''
);

CREATE TABLE IF NOT EXISTS `groups` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(100) NOT NULL,
  `created` datetime DEFAULT NULL,
  `modified` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
);

-- 
-- Data for table `groups`
-- 

INSERT INTO `groups` (`id`, `name`, `created`, `modified`) VALUES
  ('1', 'administrators', '2012-07-05 17:16:24', '2012-07-05 17:16:24'),
  ('2', 'managers', '2012-07-05 17:16:34', '2012-07-05 17:16:34'),
  ('3', 'users', '2012-07-05 17:16:45', '2012-07-05 17:16:45');

Usage/Quick Start

  1. Go to http://site-url/admin
  2. Login to your admin panel: Both username/password: admin

NOTE: Make sure your table relationships are correctly set in the Models for dropdowns.

Customization/Advanced Settings (not so advance though!)

$displayFieldTypes

You can define a variable $displayFieldTypes in any of the models to specify how the field should be displayed. This var accept a list of field names with the type of display, that includes:

  • wysihtml
  • image
  • file
  • checkbox

The feature adds a class to the view field which is manipulated via javascript.

example usage:

var $displayFieldTypes = array(
		'introduction' => 'wysihtml',
		'image' => 'image',
		'image1' => 'image',
		'image2' => 'image',
		'image3' => 'image',
		'image4' => 'image',
		'is_active' => 'checkbox'
		);
wysihtml

wysihtml uses https://github.com/jhollingworth/bootstrap-wysihtml5 and the wysihtml5 is initialized inside /app/Plugin/Admin/webroot/js/script.js

You can change the toolbar features/buttons of wysihtml5 inside script.js:

The defaults are:

$('.textarea').wysihtml5({
		"font-styles": true, //Font styling, e.g. h1, h2, etc. Default true
		"emphasis": true, //Italics, bold, etc. Default true
		"lists": true, //(Un)ordered lists, e.g. Bullets, Numbers. Default true
		"html": false, //Button which allows you to edit the generated HTML. Default false
		"link": true, //Button to insert a link. Default true
		"image": true, //Button to insert an image. Default true,
		"color": false //Button to change color of font
	});

For the font color to work on the front end make sure to include the color style file wysiwyg-color.css in your front end.

<?php echo $this->Html->css('/Admin/css/wysiwyg-color.css'); ?>

$upLoads

You can define a variable $uploads in any of the models to specify upload path. Variable accepts two arrays imgDir & itemDir, imgDir can only be a string and itemDir can be a string or an array. The array should hold the name of the table field name which has the folder name

example usage:

var $upLoads = array(
	'imgDir' => 'library',
	'itemDir' => array('field' => 'param_url'),
	);

$ignoreFieldList

You can define a variable $ignoreFieldList in any of the models to ignore fields from the list view. The list view can be huge at times with many unwanted fields, here you can give a list of fields to be ignored from the list view

example usage:

var $ignoreFieldList = array(
		'perm_url',
		'commencing_date',
		'termination_date',
		'longitude',
		'latitude',
		'slogan',
		'id',
		'location',
		);

$ignoreModelList

You can define a variable $ignoreModelList in your application AppModel.php file inside model folder. The models are pursed from the application Model directory, some times you might have a model eg: a tableless model that you want to ignore. A list of models to be ignored can be defined in this variable $ignoreModelList

example usage:

var $ignoreModelList = array(
	'Country',
	)

$adminSetting, array key icon

Admin dashboard icons

Admin dashboard icons can be customized using the $adminSetting variable inside each Model using an array with key value of 'icon'. EXCLUDE the extension '.png' All the files are stored in app/Plugin/Admin/webroot/img/admin_icons/ folder. If you do not specify an icon explicitly it will choose an icon from the folder in folder listing order. You can place an icon/image of .png inside this folder and explicitly define it in your model.

example usage

var $adminSettings = array(
		'icon' => 'blog',
		);

Requirements

PHP version: PHP 5.2+ CakePHP version: 2.1

Support

For support and feature request, please create an issue: https://github.com/Maldicore/Admin/issues

We are not actively using this plugin as most of our current projects are done using Laravel.

So support and development will be limited to as and when need and respect to time available.

Contributing to this Plugin

Please feel free to contribute to the plugin with new issues, requests, unit tests and code fixes or new features.

If you want to develop, manage and continue supporting this plugin drop us an email [email protected]

Good Luck!

License

Copyright 2012, Maldicore Group Pvt Ltd

Licensed under The MIT License: http://www.opensource.org/licenses/mit-license.php

admin's People

Contributors

awwam avatar mattbilson avatar yusuf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

admin's Issues

Admin panel not displaying correctly

Hello,

Thank you for providing a very nice admin panel plugin.

Just having an issue with it however. When I login to the admin panel this is all I see:
image

This is a long way from the very nice panel that is shown in the screenshot.

Thanks for any help you can provide,
Duncan Lewis

Bootstrap CSS link is incorrect

Simple fix. Remove the old Bootstrap CSS in lieu of

//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css

Conditions are not considered in admin panel.

I have defined a model like

class Product extends AppModel {
    public $adminSettings = array( 'icon' => 'product');
    public $belongsTo = array(
        'Category' => array(
            'className' => 'Category',
            'conditions' => array('Category.active' => 1),
            'order' => 'Category.name'
        )
    );
}

but unfortunatly the 'conditions' or 'order' is not considered when creating a new Product.

Issue when: App model -> hasMany -> plugin model

I have a model, called User, with the following relation(s):

class User extends AppModel {
    public $hasMany = array('Forum.Access');
}

Errors:

Missing Database Table
Error: Table accesses for model Access was not found in datasource default.

Notice: If you want to customize this error message, create studentskit\View\Errors\missing_table.ctp

Stack Trace
CORE\Cake\Model\Model.php line 3179 → Model->setSource(string)
CORE\Cake\Model\Model.php line 1301 → Model->getDataSource()
CORE\Cake\Model\Model.php line 1325 → Model->schema()
APP\Model\Behavior\TimeBehavior.php line 160 → Model->getColumnTypes()
APP\Model\Behavior\TimeBehavior.php line 19 → TimeBehavior->getAllFieldsOfType(AppModel, string)
CORE\Cake\Model\BehaviorCollection.php line 148 → TimeBehavior->setup(AppModel, array)
CORE\Cake\Model\BehaviorCollection.php line 68 → BehaviorCollection->load(string, array)
CORE\Cake\Model\Model.php line 733 → BehaviorCollection->init(string, array)
CORE\Cake\Utility\ClassRegistry.php line 174 → Model->__construct(array)
APP\Plugin\Admin\Controller\AdminAppController.php line 101 → ClassRegistry::init(string)
[internal function] → AdminAppController->beforeFilter(CakeEvent)
CORE\Cake\Event\CakeEventManager.php line 246 → call_user_func(array, CakeEvent)
CORE\Cake\Controller\Controller.php line 669 → CakeEventManager->dispatch(CakeEvent)
CORE\Cake\Routing\Dispatcher.php line 183 → Controller->startupProcess()
CORE\Cake\Routing\Dispatcher.php line 161 → Dispatcher->_invoke(UsersController, CakeRequest, CakeResponse)
APP\webroot\index.php line 92 → Dispatcher->dispatch(CakeRequest, CakeResponse)

To fix that

  1. Open AdminAppController.php
  2. Locate on line 101 $subModel = ClassRegistry::init($key);
  3. Replace with: $subModel = ClassRegistry::init($value['className']);

Done.
Thank you and Good Luck with your plugin!

Any reason why the defaultOptions.html = false?

Good work on the plugin! I downloaded and worked great on my app automagically as you said.

I made a change to it to enable users to view HTML source when using the wysihtml5.

Just wondering, Any reason why the defaultOptions.html = false?

problem with uploading files

there is a problem with uploading files, you have to change the way that you create the form in form.ctp from:

BSForm->create($modelClass); ?>

to:

BSForm->create($modelClass, array('type' => 'file')); ?>

to make i t work

Checkbox and Combobox

Hello,

First of all thanks by your admin is super!!!

I'm trying to create a combobox in the admin to let the user select one value and I have not idea how to create this in the model:
public $validate = array(
'language' => array(
'inList' => array(
'rule' => array('inList', array('es','cat','Home','null')),
'allowEmpty' => true,
)
)
);
this works but not shows the options in Combobox to the user, only validate the result,
Do someone know how to do it????

Thanks in advance,

Error: Call to a member function check() on a non-object

I've just installed the plugin and on accessing /admin, I get the following error :

Error: Call to a member function check() on a non-object
File: [[....]]/app/Plugin/Admin/Controller/AdminAppController.php
Line: 45

Does this plugin have any dependencies on other plugins? Or on any user management/authentication code being in place?

Thanks!

Admin layout is not working

Hi Team,
I have newly installed cakePHP2.6 and it is this plugin as per you given steps. But admin layout is not working properly. Plz help me more , what should I do settings in cakePHP

capture

Logout problem

I am using cakephp 2.1 and call this plugins but after logout,we are able to go through internal page.

Collision with debug_kit plugin

After few hours of debug, I've found that your plugin is incompatible with debug_kit - which is one of the most common plugins for Cake.

To fix that issue:

  1. I change the 'Form' into 'BSForm' in AdminAppController.php :
public $helpers = array(
        'BSForm' => array(
            'className' => 'Admin.BootstrapForm'
        ),
        'Html',
        'Session' => array(
            'className' => 'Admin.BootstrapSession'
        ),
        'Paginator' => array(
            'className' => 'Admin.BootstrapPaginator'
        )
    );
  1. in form.ctp and login_form.ctp I search and replaced ->Form-> into ->BSForm->

Good Luck with your plugin!

Incompatible with Plugins Behavior

I have this model:

class Subject extends AppModel {
    public $name = 'Subject';
    public $useTable = 'subjects';
    public $primaryKey = 'subject_id';
    public $actsAs = array(
        'Lock',
        'LanguageFilter',
        'Uploader.Attachment' => array(
            'videoUpload'=>array(
                'uploadDir'             => 'vid/subjects/about_videos/',
                'appendNameToUploadDir' => true,
                'name'                  => 'formatFileName',
                'dbColumn'              => 'video_source'
            )
    );
}

I'm usig Miles' Uploader:
http://milesj.me/code/cakephp/uploader

Error I'm getting:
Class 'Uploader' not found

Changing the View elements

Hi,

I am new to CakePHP so I don't know if this is the correct place to ask this question but i have tried your plugin and it works great. But I am having an issues while creating forms.

I have created DB tables as products and categories. and the categories works great. But now when i see the add products form i want it such that it has a dropdownlist(select) of all the categories inserted. Right now all i get is a input text.

I have the foreign key for the categories in the products table as well.

So how can i acheive that i.e override the view to generate the select box.

//Wilson

Change user password

This is most like a feature for the plugin, How can I make to change the user password ?
I have added the User model, but the password are plain-text, they are not encrypted with md5.

Table for model was not found in datasource default.

After installing the plugin and going to /admin, I get the following error message:

Error: Table for model was not found in datasource default.

Stack Trace

CORE\Cake\Model\Model.php line 3231 → Model->setSource(string)
APP\Plugin\Admin\Config\bootstrap.php line 65 → Model->getDataSource()
CORE\Cake\Core\CakePlugin.php line 249 → include(string)
CORE\Cake\Core\CakePlugin.php line 169 → CakePlugin::_includeFile(string, boolean)
CORE\Cake\Core\CakePlugin.php line 101 → CakePlugin::bootstrap(string)
APP\Config\bootstrap.php line 74 → CakePlugin::load(string, array)
CORE\Cake\Core\Configure.php line 93 → include(string)
CORE\Cake\bootstrap.php line 164 → Configure::bootstrap(boolean)
APP\webroot\index.php line 91 → include(string)

What exactly am I doing wrong?

EDIT: I used the following line

CakePlugin::load('Admin' ,array('bootstrap' => true));

in bootstrap.php, like you told me. If I change it to this

CakePlugin::load('Admin');

it works.

Regarding setup of Admin Panel

My cake php version is - 2.2.4

I cant configure the Model - Fpllowing errors are shown -

Undefined variable: navbar [ROOT\plugins\Admin\View\Admin\index.ctp, line 17]
Invalid argument supplied for foreach() [ROOT\plugins\Admin\View\Admin\index.ctp, line 17]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.