{"id":13824980,"url":"https://github.com/CakeDC/utils","last_synced_at":"2025-07-08T21:30:40.591Z","repository":{"id":60774258,"uuid":"865311","full_name":"CakeDC/utils","owner":"CakeDC","description":"Utils Plugin for CakePHP","archived":true,"fork":false,"pushed_at":"2017-01-12T21:50:26.000Z","size":892,"stargazers_count":304,"open_issues_count":7,"forks_count":142,"subscribers_count":40,"default_branch":"master","last_synced_at":"2024-11-17T18:08:28.157Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://cakedc.com","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CakeDC.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-08-27T00:48:30.000Z","updated_at":"2024-11-01T13:41:35.000Z","dependencies_parsed_at":"2022-10-04T15:27:50.678Z","dependency_job_id":null,"html_url":"https://github.com/CakeDC/utils","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CakeDC%2Futils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CakeDC%2Futils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CakeDC%2Futils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CakeDC%2Futils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CakeDC","download_url":"https://codeload.github.com/CakeDC/utils/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225449383,"owners_count":17476098,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T09:01:12.987Z","updated_at":"2024-11-20T03:30:33.536Z","avatar_url":"https://github.com/CakeDC.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"# Utils Plugin for CakePHP #\n\nfor cake 2.x\n\nThe utils plugin contain a lot of reusable components, behaviors and helpers. Here we will list and detail \neach component.\n\n## Behaviors \n\n* Btree          - \n* CsvImport      - adds the ability to import csv data to the model.\n* Inheritable    - \n* Keyvalue       - allows to get and save group of settings in key/value representation.\n* List           - provide a way to make collection ordered\n* Lookupable     - looks up associated records up based on a given field and its value\n* Pingbackable   - \n* Publishable    - \n* Serializable   - allows serialize/deserialize array data into large text field.\n* Sluggable      - implement slugs for model.\n* SoftDelete     - soft deleting for model.\n* TinySluggable  - creates tiny slugs similar to known url shorteners like bit.ly\n* Toggleable     - toggle field values\n\n## Libraries\n\n* Languages      - List of languages that can be used in selects\n\n## Components\n\n* Archive        - Creates the data for \"archive\" date ranges that can be used to generated links like \"May 2010\", \"March 2010\",...\n* FormPreserver  - Allow to keep form data between login redirect and returning back after login.\n* Pingbacks      - \n* Referer        - Allow to keep referer url inside the add/edit form to reuse it for redirect on success POST or submit.\n* Utils          - \n\n## Helpers\n\n* Cleaner        - Allow to strip tags from input markup\n* Gravatar       - Gravatar Helper\n* Tree           - Generates nested representations of hierarchial data\n* Place          - Allows to display image and text placeholders\n\n### CsvImport Behavior\n\nYou can configure the Importable behavior using these options:\n\n* delimiter      - The delimiter for the values, default is ;\n* enclosure      - The enclosure, default is \"\n* hasHeader      - Parse the header of the CSV file if it has one, default is true\n\nThe main method of this behavior is\n```php\n\u003c?php\n$this-\u003eModel-\u003eimportCSV('myFile.csv');\n```\n\nIt 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\n```php\n\u003c?php\n$this-\u003eModel-\u003egetImportErrors();\n```\n\n### Keyvalue Behavior\n\nYou can configure the Importable behavior using these options:\n\n* foreignKey     - The foreign key field, default is user_id\n* scope          - Find condition like array to define a scope\n\n### List Behavior \n\nThe list behavior allows you to have records act like a list, for example a tracklist and to move records in this list.\n\n* positionColumn - The column in the table used to store the positiot, default is 'position'.\n* scope          - Find condition like array to define a scope, default is empty string ''.\n* validate       - validate the data when the behavior is saving the changes, default is false.\n* callbacks      - use callbacks when the behavior saves the data, default is false.\n\n### SoftDelete Behavior \n\nThe 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. \n\nSince \"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:\n\n```php\n\u003c?php\npublic function exists($id = null) {\n\tif ($this-\u003eBehaviors-\u003eloaded('SoftDelete')) {\n\t\treturn $this-\u003eexistsAndNotDeleted($id);\n\t} else {\n\t\treturn parent::exists($id);\n\t}\n}\n```\n\nIt will call SoftDelete::existsAndNotDeleted() for models that use SoftDelete Behavior and Model:exists for models that do not use it\n\nWhen 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.\n\n```php\n\u003c?php\npublic function delete($id = null, $cascade = true) {\n    $result = parent::delete($id, $cascade);\n    if ($result === false \u0026\u0026 $this-\u003eBehaviors-\u003eenabled('SoftDelete')) {\n       return (bool)$this-\u003efield('deleted', array('deleted' =\u003e 1));\n    }\n    return $result;\n}\n```\n\n## Languages Lib\n\nThe languages lib is basically just a helper lib that extends I10n to get a three character language code =\u003e country name array.\n\n```php\n\u003c?php\nApp::import('Lib', 'Utils.Languages');\n$Languages = new Languages();\n$languageList = $Languages-\u003elists();\n```\n\n`$languageList` will contain the three character code mapped to a country. This list can be used in language selects for example.\n\n## Archive Component\n\n## Referer Component\n\nAllow to keep referer url inside the add/edit form to reuse it for redirect on success POST or submit.\n\n## Requirements ##\n\n* PHP version: PHP 5.2+\n* CakePHP version: 1.3 Stable\n\n## Support ##\n\nTo report bugs or request features, please visit the [CakeDC/Utils Issue Tracker](https://github.com/CakeDC/utils/issues).\n\nFor more information about our Professional CakePHP Services please visit the [Cake Development Corporation website](http://cakedc.com).\n\n## Branch strategy ##\n\nThe master branch holds the STABLE latest version of the plugin. \nDevelop branch is UNSTABLE and used to test new features before releasing them. \n\nPrevious maintenance versions are named after the CakePHP compatible version, for example, branch 1.3 is the maintenance version compatible with CakePHP 1.3.\nAll versions are updated with security patches.\n\n## Contributing to this Plugin ##\n\nPlease 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. \n\n## License ##\n\nCopyright 2009-2010, [Cake Development Corporation](http://cakedc.com)\n\nLicensed under [The MIT License](http://www.opensource.org/licenses/mit-license.php)\u003cbr/\u003e\nRedistributions of files must retain the above copyright notice.\n\n## Copyright ###\n\nCopyright 2009-2011\u003cbr/\u003e\n[Cake Development Corporation](http://cakedc.com)\u003cbr/\u003e\n1785 E. Sahara Avenue, Suite 490-423\u003cbr/\u003e\nLas Vegas, Nevada 89104\u003cbr/\u003e\nhttp://cakedc.com\u003cbr/\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCakeDC%2Futils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FCakeDC%2Futils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCakeDC%2Futils/lists"}