• This repository has been archived on 20/Oct/2023
  • Stars
    star
    304
  • Rank 136,869 (Top 3 %)
  • Language
    PHP
  • License
    Other
  • Created about 14 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Utils Plugin for CakePHP

Utils Plugin for CakePHP

for cake 2.x

The utils plugin contain a lot of reusable components, behaviors and helpers. Here we will list and detail each component.

Behaviors

  • Btree -
  • CsvImport - adds the ability to import csv data to the model.
  • Inheritable -
  • Keyvalue - allows to get and save group of settings in key/value representation.
  • List - provide a way to make collection ordered
  • Lookupable - looks up associated records up based on a given field and its value
  • Pingbackable -
  • Publishable -
  • Serializable - allows serialize/deserialize array data into large text field.
  • Sluggable - implement slugs for model.
  • SoftDelete - soft deleting for model.
  • TinySluggable - creates tiny slugs similar to known url shorteners like bit.ly
  • Toggleable - toggle field values

Libraries

  • Languages - List of languages that can be used in selects

Components

  • Archive - Creates the data for "archive" date ranges that can be used to generated links like "May 2010", "March 2010",...
  • FormPreserver - Allow to keep form data between login redirect and returning back after login.
  • Pingbacks -
  • Referer - Allow to keep referer url inside the add/edit form to reuse it for redirect on success POST or submit.
  • Utils -

Helpers

  • Cleaner - Allow to strip tags from input markup
  • Gravatar - Gravatar Helper
  • Tree - Generates nested representations of hierarchial data
  • Place - Allows to display image and text placeholders

CsvImport Behavior

You can configure the Importable behavior using these options:

  • delimiter - The delimiter for the values, default is ;
  • enclosure - The enclosure, default is "
  • hasHeader - Parse the header of the CSV file if it has one, default is true

The main method of this behavior is

<?php
$this->Model->importCSV('myFile.csv');

It will read the csv file and try to save the records to the model. In the case of errors you'll get them by calling

<?php
$this->Model->getImportErrors();

Keyvalue Behavior

You can configure the Importable behavior using these options:

  • foreignKey - The foreign key field, default is user_id
  • scope - Find condition like array to define a scope

List Behavior

The list behavior allows you to have records act like a list, for example a tracklist and to move records in this list.

  • positionColumn - The column in the table used to store the positiot, default is 'position'.
  • scope - Find condition like array to define a scope, default is empty string ''.
  • validate - validate the data when the behavior is saving the changes, default is false.
  • callbacks - use callbacks when the behavior saves the data, default is false.

SoftDelete Behavior

The SoftDelete behavior allows you to keep records on database and do not show them to users having a "deleted" flag. By default you should have "deleted" and "deleted_date" fields on your database table.

Since "exists" method in Model disable callbacks you may experience problems using it. To avoid these problems you can use the "existsAndNotDeleted" method from the behavior and we provide the following code to be put into AppModel to make this transparent:

<?php
public function exists($id = null) {
	if ($this->Behaviors->loaded('SoftDelete')) {
		return $this->existsAndNotDeleted($id);
	} else {
		return parent::exists($id);
	}
}

It will call SoftDelete::existsAndNotDeleted() for models that use SoftDelete Behavior and Model:exists for models that do not use it

When deleting an item the SoftDelete behavior will override the delete() and update the record instead. This means that the response to the delete() will be false. In order to override this and return true, you will need to include the following in your AppModel.php file.

<?php
public function delete($id = null, $cascade = true) {
    $result = parent::delete($id, $cascade);
    if ($result === false && $this->Behaviors->enabled('SoftDelete')) {
       return (bool)$this->field('deleted', array('deleted' => 1));
    }
    return $result;
}

Languages Lib

The languages lib is basically just a helper lib that extends I10n to get a three character language code => country name array.

<?php
App::import('Lib', 'Utils.Languages');
$Languages = new Languages();
$languageList = $Languages->lists();

$languageList will contain the three character code mapped to a country. This list can be used in language selects for example.

Archive Component

Referer Component

Allow to keep referer url inside the add/edit form to reuse it for redirect on success POST or submit.

Requirements

  • PHP version: PHP 5.2+
  • CakePHP version: 1.3 Stable

Support

To report bugs or request features, please visit the CakeDC/Utils Issue Tracker.

For more information about our Professional CakePHP Services please visit the Cake Development Corporation website.

Branch strategy

The master branch holds the STABLE latest version of the plugin. Develop branch is UNSTABLE and used to test new features before releasing them.

Previous maintenance versions are named after the CakePHP compatible version, for example, branch 1.3 is the maintenance version compatible with CakePHP 1.3. All versions are updated with security patches.

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 contribute some code, create a feature branch from develop, and send us your pull request. Unit tests for new features and issues detected are mandatory to keep quality high.

License

Copyright 2009-2010, Cake Development Corporation

Licensed under The MIT License
Redistributions of files must retain the above copyright notice.

Copyright

Copyright 2009-2011
Cake Development Corporation
1785 E. Sahara Avenue, Suite 490-423
Las Vegas, Nevada 89104
http://cakedc.com

More Repositories

1

users

Users Plugin for CakePHP
PHP
521
star
2

search

Search Plugin for CakePHP
PHP
355
star
3

migrations

Migrations Plugin for CakePHP
PHP
344
star
4

oven

Welcome to Oven. The easiest way to install CakePHP.
PHP
141
star
5

tags

Tags Plugin for CakePHP
PHP
132
star
6

TinyMCE

TinyMCE Javascript HTML WYSIWYG Plugin for CakePHP
PHP
108
star
7

recaptcha

Recaptcha plugin for CakePHP
PHP
101
star
8

comments

Comments Plugin for CakePHP
PHP
94
star
9

i18n

Internationalization Plugin for CakePHP
PHP
73
star
10

ratings

Ratings Plugin for CakePHP
PHP
71
star
11

cakephp-api

API Plugin for CakePHP
PHP
61
star
12

categories

Categories Plugin for CakePHP
PHP
56
star
13

favorites

Favorites Plugin for CakePHP
PHP
54
star
14

templates

Templates Plugin for CakePHP
PHP
46
star
15

mixer

A plugin to discover and manage CakePHP plugins.
JavaScript
45
star
16

cakephp-oracle-driver

CakePHP 3 Driver for Oracle Database
PHP
40
star
17

oauth_lib

CakePHP Oauth Library Plugin
PHP
40
star
18

auth

Auth objects for CakePHP
PHP
32
star
19

cakephp-phpstan

CakePHP extension for PHPStan
PHP
31
star
20

markup_parsers

Markup Parsers Plugin for CakePHP
PHP
30
star
21

OAuth2

OAuth2 plugin for CakePHP
PHP
28
star
22

Enum

Enumeration list for CakePHP
PHP
27
star
23

problems

Problems Plugin for CakePHP
PHP
26
star
24

cakephp-phppm

PHPPM Bridge for CakePHP
PHP
22
star
25

cakephp-forum

Forum plugin for CakePHP
PHP
22
star
26

Ec2

Amazon EC2 plugin for CakePHP
PHP
16
star
27

Config

CakePHP database driven Config plugin
PHP
16
star
28

bitly

Bit.ly Plugin for CakePHP
PHP
16
star
29

cakephp-realworld-example-app

PHP
16
star
30

oauth2-cognito

Amazon Cognito Provider for the OAuth 2.0 Client
PHP
14
star
31

cakephp-roadrunner

Roadrunner bridge and worker for CakePHP
PHP
14
star
32

cakephp-nav-auth

CakePHP plugin for authenticating against Navisionยฎ service using SOAP or OData services using NTLM.
PHP
10
star
33

cakephp-db-test

CakePHP Fixture manager based on a test template database, instead of files
PHP
10
star
34

cakephp-datatables

Quick integration with jquery datatables
JavaScript
8
star
35

cakephp-inertia

Twig
7
star
36

getting-started-session

Getting Started with CakePHP 3 training session
PHP
7
star
37

Intl

Simple replacement for Intl extension if not installed on server.
PHP
6
star
38

adsense

PHP
6
star
39

cakephp-email-toolkit

Debug email transport issues
PHP
4
star
40

cakephp4-getting-started-session

Getting started with CakePHP 4 training session related code and examples
PHP
4
star
41

cakephp-cached-routing

Provides a cached version of the RoutingMiddleware to improve the load time of routes
PHP
3
star
42

Book

CakeDC Book plugin for CakePHP
PHP
2
star
43

cakephp-api-example

Example application to show how to integrate & customize the CakeDC/Api plugin
PHP
2
star
44

slim-cakephp4-packages

Sample app using slim framework and cakephp 4 package (orm)
PHP
2
star
45

cakephp4-unit-tests

Contents for the CakePHP 4 Unit Tests training session
PHP
2
star
46

cakephp5-unit-tests

Contents for the CakePHP 5 Unit Tests training session
PHP
1
star
47

cakephp-queue-monitor

CakeDC Queue Monitor Plugin for CakePHP
PHP
1
star
48

cakephp-uppy

CakeDC Uppy Plugin
PHP
1
star
49

money

Opinionated wrapper for moneyphp/money in CakePHP
PHP
1
star
50

phpqa-app-example

PHP
1
star
51

sandbox

1
star
52

cakephp-clamav

Clamav integration via Validator to check uploaded files for viruses
PHP
1
star