Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin olson authored and acidjazz committed Jan 30, 2012
0 parents commit 1892e45
Show file tree
Hide file tree
Showing 36 changed files with 2,730 additions and 0 deletions.
Empty file added README
Empty file.
76 changes: 76 additions & 0 deletions ajx/add.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?

require_once 'ajax.php';

$error = false;
$html = false;

if (isset($_REQUEST['type']) && !empty($_REQUEST['type'])) {

switch ($_REQUEST['type']) {

case 'ingredient' :

$data = json_decode($_REQUEST['data'], true);

if ($data['title'] == '') {
$error = 'You must specify an ingredient';
} else {

$ingredient = new ingredient($data['recipe_id'], $data['title']);
$ingredient->save();
$ingredients = ingredient::gets('WHERE recipe_id = %n', $data['recipe_id']);
$newone = $data['title'];

ob_start();
require_once '../tpl/listing_ingredient.php';
$html = ob_get_contents();
ob_end_clean();
}

break;

case 'instruction' :

$data = json_decode($_REQUEST['data'], true);

if ($data['title'] == '') {
$error = 'You must specify an instruction';
} else {

$instruction = new instruction($data['recipe_id'], $data['step']);
$instruction->title = $data['title'];
$instruction->save();
$instructions = instruction::gets('WHERE recipe_id = %n', $data['recipe_id']);
$newone = $data['title'];

ob_start();
require_once '../tpl/listing_instruction.php';
$html = ob_get_contents();
ob_end_clean();

}

break;

case 'detail' :

$data = json_decode($_REQUEST['data'], true);

$dr = new detail_recipe($data['recipe_id'], $data['type'], $data['value']);
$dr->save();
$detail_recipe = detail_recipe::gets('WHERE recipe_id = %n', $data['recipe_id']);
$newone = $data['value'];

ob_start();
require_once '../tpl/listing_detail.php';
$html = ob_get_contents();
ob_end_clean();
break;

}

}

echo json_encode(array('error' => $error, 'html' => $html));

7 changes: 7 additions & 0 deletions ajx/ajax.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?

require_once 'ajax.php';
define('KDEBUG_JSON', true);
require_once '../config.php';

?>
34 changes: 34 additions & 0 deletions ajx/details.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?

require_once 'ajax.php';

$error = false;

if (isset($_REQUEST['action'])) {

switch ($_REQUEST['action']) {

case 'add' :

$data = json_decode($_REQUEST['data'], true);

if (empty($data['type'])) {
$error = 'You must specify a type';
break;
}

if (empty($data['value'])) {
$error = 'You must specify a value';
break;
}

$detail = new detail($data['site'], $data['type'], $data['value']);
$detail->save();

break;

}

}

echo json_encode(array('error' => $error));
53 changes: 53 additions & 0 deletions config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?

define('G_PATH', '/var/www/tribal/');
define('LIB_PATHS', '/var/www/tribal/lib/,/var/www/tribal/klib/');
define('G_URL', 'http://tribal.ssugar.com/');

/* kdebug */
define('KDEBUG', true);
define('KDEBUG_SQL', true);
define('KDEBUG_SQL_HIGHLIGHT', true);
define('KDEBUG_HANDLER', true);

/* database */
define('DB_DATABASE', 'tribal');
define('DB_HOST', 'localhost');
define('DB_USER', 'root');
define('DB_PASSWORD', '1s0b4r');

/* ignore past this line */
set_include_path(get_include_path().PATH_SEPARATOR.G_PATH);

if (defined('KDEBUG') && KDEBUG == true && php_sapi_name() != 'cli') {
if (!defined('KDEBUG_JSON') || KDEBUG_JSON == false) {
register_shutdown_function(array('kdebug', 'init'));
if (defined('KDEBUG_HANDLER') && KDEBUG_HANDLER == true) {
set_error_handler(array('kdebug', 'handler'), E_ALL);
}
}
}

function __autoload($class) {

foreach (explode(',', LIB_PATHS) as $libdir) {
foreach (array('.class.php','.interface.php') as $file) {
if ($libdir{0} == '/' && is_file($libdir.$class.$file)) {
require_once $libdir.$class.$file;
return true;
}
if (is_file(G_PATH.$libdir.$class.$file)) {
require_once $libdir.$class.$file;
return true;
}
}
}

return false;

}

function hpr() { return call_user_func_array(array('k','hpr'), func_get_args()); }
function cpr() { return call_user_func_array(array('k','cpr'), func_get_args()); }
function highlight() { return call_user_func_array(array('k','highlight'), func_get_args()); }
function xmlindent() { return call_user_func_array(array('k','xmlindent'), func_get_args()); }
Loading

0 comments on commit 1892e45

Please sign in to comment.