Skip to content

Commit

Permalink
fixed page system
Browse files Browse the repository at this point in the history
  • Loading branch information
killme committed Feb 22, 2012
1 parent 49bb5ba commit 49b76a7
Show file tree
Hide file tree
Showing 515 changed files with 242,153 additions and 205 deletions.
10 changes: 10 additions & 0 deletions application/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,5 +394,15 @@

$config['activation_type'] = 3;

$config['supported_types'] = array(
'json' => 'json',
'xml' => 'xml',
'xhtml' => 'html',
'html' => 'html'
);

$config['default_type'] = 'html';


/* End of file config.php */
/* Location: ./application/config/config.php */
4 changes: 2 additions & 2 deletions application/config/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
|
*/

$route['default_controller'] = "welcome";
$route['404_override'] = '';
$route['default_controller'] = 'page/index';
$route['404_override'] = 'page';


/* End of file routes.php */
Expand Down
20 changes: 20 additions & 0 deletions application/core/MY_Output.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class MY_Output extends CI_Output
{
function encode_output($output, $type)
{
switch($type)
{
case 'json':
$this->set_content_type('text/json');
return json_encode($output);
break;

default:
print_r(func_get_args());
break;
}
}
}

45 changes: 44 additions & 1 deletion application/core/MY_Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,47 @@
/* load the MX_Router class */
require APPPATH."third_party/MX/Router.php";

class MY_Router extends MX_Router {}
class MY_Router extends MX_Router
{
public $content_type;
public $pathstring;

public function _validate_request($segments)
{
static $types;
$this->pathstring = '/';
if (count($segments) == 0) return $segments;

if(!isset($types)) $types = $this->config->item('supported_types');

$segment_info = pathinfo(end($segments));

$content_type_request = '';

if(!isset($segment_info['extension']) || !isset($types[$segment_info['extension']]))
$content_type_request = $this->config->item('default_type');
else
{
$content_type_request = $types[$segment_info['extension']];
$segments[count($segments) - 1] = $segment_info['filename'];
}

$this->content_type = $content_type_request;

unset ($content_type_request);

$this->pathstring = '/'.implode('/', $segments);

/* locate module controller */
if ($located = $this->locate($segments)) return $located;

/* use a default 404_override controller */
if (isset($this->routes['404_override']) AND $this->routes['404_override']) {
$segments = explode('/', $this->routes['404_override']);
if ($located = $this->locate($segments)) return $located;
}

/* no controller found */
show_404();
}
}
16 changes: 16 additions & 0 deletions application/helpers/quick_escape_helper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

function quick_html_escape($input, $ignore = array())
{
if(is_array($input) || is_object($input))
{
$input = (array)$input;
foreach($input as $key => $value)
if(!in_array($key, $ignore))
$input[$key] = quick_html_escape($value);

return $input;
}
else
return htmlentities($input);
}
19 changes: 2 additions & 17 deletions application/libraries/MY_Parser.php
Original file line number Diff line number Diff line change
@@ -1,27 +1,14 @@
<?php defined('BASEPATH') or die('No direct script access allowed');

class std_template_functions
{
public $site = array(
'header' => array(
'title' => 'mynewtitle',
'full' => '<h1>SITENAME</h1>'
)
);

}

class MY_Parser extends CI_Parser {

private $CI;
// private $std;

private $data;

function __construct()
{
$this->CI =& get_instance();
//$this->std = new tag_std();
}

function parse($file, $data = array(), $return = false, $is_include = false)
Expand All @@ -37,10 +24,8 @@ function parse_string($string, $data = array(), $return = false, $is_include = f

//get view variables
$data = array_merge($data, $this->CI->load->_ci_cached_vars);
$data = array_merge($data, array('std' => (array)new std_template_functions));

$this->data = array_merge($data, (array)$this->data);

//load tag library
$this->CI->load->library('tags');

Expand Down Expand Up @@ -77,7 +62,7 @@ function parser_callback($path)

foreach($path['segments'] as $segment)
{
echo PHP_EOL.'segment: '.$segment.PHP_EOL;
if(defined('OMG_DEBUG')) echo PHP_EOL.'segment: '.$segment.PHP_EOL;
if(isset($data[$segment])) $data = $data[$segment];
}

Expand Down
2 changes: 1 addition & 1 deletion application/libraries/Tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -852,4 +852,4 @@ private function _parse_segments($segments)

}

/* End of file Tags.php */
/* End of file Tags.php */
4 changes: 4 additions & 0 deletions application/libraries/auth/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
RewriteEngine on
RewriteRule ^$ /a3m_peanutbutter/index.php [L]
RewriteCond $1 !^(index\.php|resource|system|user_guide|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ /a3m_peanutbutter/index.php/$1 [L]
98 changes: 98 additions & 0 deletions application/libraries/auth/auth_install.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?php

class Auth_install
{
function __construct()
{
$this->CI =& get_instance();
$this->CI->load->database();
$this->CI->load->dbforge();
}

function install()
{
$this->install_tables();
$this->install_data();
}

function install_tables()
{
$tables = include dirname(__file__).'/default_tables.php';

foreach($tables as $name => $table)
{
$meta = array();

if(isset($table['META']))
{
$meta = $table['META'];
unset($table['META']);
}

$this->CI->dbforge->add_field($table);

if(isset($meta['KEYS']))
foreach($meta['KEYS'] as $field => $keytype)
switch($keytype)
{
case 'PRIMARY':
$this->CI->dbforge->add_key($field, true);
break;

case 'UNIQUE':
case 'KEY':
$this->CI->dbforge->add_key($field)
break;
}


$this->CI->dbforge->create_table($name);

unset($meta);
}
}

function install_data()
{
$data = include dirname(__file__).'/default_data.php';

foreach($data as $tablename => $table)
$this->CI->db->insert_batch($tablename, $table);
}

function uninstall()
{
$this->backup();
$this->uninstall_data();
$this->uninstall_tables();
}

function uninstall_tables()
{
$tables = include dirname(__file__).'/default_tables.php';

foreach($tables as $tablename => $_)
$this->CI->dbforge->drop_table($tablename);
}

function uninstall_data()
{
$tables = include dirname(__file__).'/default_tables.php';

foreach($tables as $tablename => $_)
$this->CI->db->truncate($tablename);
}

function backup()
{
$this->CI->load->dbutil();

$backup =& $this->CI->dbutil->backup();
/*
$this->CI->load->helper('file');
write_file(dirname(__file__).'/backup.gz', $backup);
*/
$this->load->helper('download');
force_download('backup.gz', $backup);
}
}
Loading

0 comments on commit 49b76a7

Please sign in to comment.