Skip to content

Instantly share code, notes, and snippets.

View philsturgeon's full-sized avatar
🌳
Planting Trees

Phil Sturgeon philsturgeon

🌳
Planting Trees
View GitHub Profile
/**
* Force Array
*
* Take a totally mixed item and parse it into an array compatible with EE's Template library
*
* @access private
* @param mixed
* @return string
*/
private function _force_array($var, $level = 1)
preg_match('/^\/(cms|admin|manage)/', $_SERVER['REQUEST_URI'], $matches);
if ( ! empty($matches[1]))
{
$config['sess_cookie_name'] = $matches[1].'_session';
}
else
{
$config['sess_cookie_name'] = 'user_session';
@philsturgeon
philsturgeon / gist:497631
Created July 29, 2010 08:38
Controller_Api
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Api extends Controller {
/**
* Handle a response from an api
*/
public function response($status = 'success', $data = array())
{
$data = array_merge(array('status' => $status), $data);
class Manage extends REST_Controller
{
protected $rest_permissions = array(
'key_post' => 9
);
function key_post()
{
$this->response(array('foo' => 'BAR'), 200);
}
if ($handle = fopen($csv_file, 'r'))
{
$all_headings = array_unique(explode(',', trim(fgets($handle))));
foreach ($all_headings as $heading)
{
if ( ! $heading)
{
break;
}
class Template
{
private $theme = 'default';
function set_theme($theme)
{
$this->theme = $theme;
}
function build($view, $data)
<?php
// Need to add 'activerecord' to your packages in config.php
namespace Fuel\Application;
use ActiveRecord;
class Model_User extends ActiveRecord\Model {}
$route['default_controller'] = 'pages';
$route['404'] = 'pages';
<?php defined('BASEPATH') OR exit('No direct script access allowed');
class Pages extends CI_Controller {
public function _remap()
{
$method = $this->uri->segment(1, 'home');
@philsturgeon
philsturgeon / gist:958755
Created May 6, 2011 11:00
Cells Processor for Fuel
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
*
* @package Fuel
* @version 1.0
* @author Fuel Development Team
* @license MIT License
@philsturgeon
philsturgeon / gist:1299544
Created October 19, 2011 20:19
Fuel Boxfile
web1:
################################################
## GENERAL SETTINGS
################################################
shared_writable_dirs: [/fuel/app/cache, /fuel/app/logs]
local_writable_dirs: [/fuel/app/tmp]
################################################
## WEB SPECIFIC SETTINGS