Skip to content

Instantly share code, notes, and snippets.

function add_lang_string()
{
die();
$final = "\n".'
/* Added in version 1.2.2 */
$lang[\'form_save_and_go_back\'] = \'Save and go back to list\';
$lang[\'form_update_and_go_back\']= \'Update and go back to list\';';
$this->load->helper('file');
<?php
/* load the MX_Loader class */
require APPPATH."third_party/MX/Loader.php";
/**
* PHP Codeigniter Simplicity
*
* Copyright (C) 2013 John Skoumbourdis.
*
* GROCERY CRUD LICENSE
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Base_Controller extends CI_Controller {
function __construct()
{
parent::__construct();
$this->output->set_template('default');
}
@scoumbourdis
scoumbourdis / view.php
Created January 9, 2017 17:20
This is an example of Grocery CRUD Enterprise to load a simple template
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<?php
foreach($css_files as $file): ?>
<link type="text/css" rel="stylesheet" href="<?php echo $file; ?>" />
<?php endforeach; ?>
/**
* @param GroceryCrud $crud
*/
function crud_apply_texteditor($crud) {
$ci = &get_instance();
$db = $ci->db;
$texteditors = [];
$fields = $db->field_data($crud->getDbTableName());
<?php
use GroceryCrud\Core\Model;
class CodeigniterSimpleModel extends Model {
protected $ci;
protected $db;
function __construct($databaseConfig) {
---
src/GroceryCrud/Core/State/EditFormState.php | 3 ++-
src/GroceryCrud/Core/State/ReadFormState.php | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/GroceryCrud/Core/State/EditFormState.php b/src/GroceryCrud/Core/State/EditFormState.php
index 1524f49..33b02e3 100644
--- a/src/GroceryCrud/Core/State/EditFormState.php
+++ b/src/GroceryCrud/Core/State/EditFormState.php
@@ -46,8 +46,9 @@ class EditFormState extends StateAbstract {
--- a/src/GroceryCrud/Core/State/StateAbstract.php
+++ b/src/GroceryCrud/Core/State/StateAbstract.php
@@ -224,7 +224,9 @@ class StateAbstract
$columnValue = $callbackColumns[$columnName]($columnValue, $result);
} else {
$columnValue = strip_tags($columnValue);
- $columnValue = $char_limiter > 0 && (strlen($columnValue) > $char_limiter) ? substr($columnValue, 0 , $char_limiter - 1) . '...' : $columnValue;
+ if ($char_limiter > 0 && (mb_strlen($columnValue, 'UTF-8') > $char_limiter)) {
+ $columnValue = mb_substr($columnValue, 0 , $char_limiter - 1, 'UTF-8') . '...';
+ }
@scoumbourdis
scoumbourdis / initial-code-of-grocery-crud.php
Last active December 30, 2017 12:49
Grocery CRUD was initially started with 90 lines of code! Now Grocery CRUD is doing the exact same thing with only 2 lines!
<?php
// Real code that it's still working on production environment by the way :)
function faq_management($value1 = "",$value2 = "",$value3 = 0)
{
$this->load->library('TableControlPackage');
$object_name = records_management;
$this->records_management = new TableControlPackage(__FUNCTION__);
$this->records_management->insert_table_name('faq');
$this->records_management->insert_subject_name('Faqs');
@scoumbourdis
scoumbourdis / benchmarking.js
Created March 4, 2018 05:52
Comparing IndexOf with native object finder in JavaScript
// Benchmarking code for: https://jsperf.com/objectsearch/1
Benchmark.prototype.setup = function() {
arc = ['dog','cat','eagle','human','mouse','flea','wasp','bee','chicken','tortoise','hare','coyote','hummingbird','ostrich','eagle','human'];
obs = {
"dog": true,
"cat": true,
"eagle": true,
"human": true,
"mouse": true,