示例#1
0
文件: AdsStorage.php 项目: gorvic/L17
 /**
  * Instatiating of singletone
  * 
  * @return type
  */
 public static function getInstance($view)
 {
     if (empty(self::$instance)) {
         self::$instance = new AdsStorage($view);
     }
     return self::$instance;
 }
示例#2
0
文件: index.php 项目: gorvic/L15
{
    if ($class_name != 'DbSimple_Mysqli' && $class_name != 'Smarty') {
        require_once CLASS_PATH . '/class.' . $class_name . '.php';
    }
}
if (request_is_post()) {
    if (isset($_POST['cancel'])) {
        redirect_to('index.php');
    }
    $ad = new Ad(AdsStorage::sanitizeFormData($_POST));
    $ad->save();
    redirect_to('index.php');
}
$edit_id = '';
if (isset($_GET['id']) && isset($_GET['mode'])) {
    $id = (int) $_GET['id'];
    $mode = strip_tags($_GET['mode']);
    if ($mode == "show") {
        $edit_id = $id;
    } elseif ($mode == "delete") {
        Ad::delete($id);
        exit;
        //AJAX. Output isn't needed
    }
}
//could be chained methods -> -> ->
$storage = AdsStorage::getInstance();
$storage->fillStorage();
$storage->prepareFieldsOfAd($edit_id);
$storage->prepareTableOfAds();
$storage->display();
示例#3
0
文件: index.php 项目: gorvic/L16
<?php

header('Content-Type: text/html; charset=utf-8');
require_once './includes/initialize.php';
function __autoload($class_name)
{
    if ($class_name != 'DbSimple_Mysqli' && $class_name != 'Smarty') {
        require_once CLASS_PATH . '/' . $class_name . '.php';
    }
}
//AJAX. With ajax queries there is no display with smarty
//controller role - isPost isGet
if (request_is_post()) {
    //submitting unchecked checkboxes
    if (!isset($_POST['allow_mails'])) {
        $_POST['allow_mails'] = "";
    } else {
        $_POST['allow_mails'] = 1;
    }
    $ajax_result = Ad::handlePostQuery(AdsStorage::sanitizeHTTPQueriesData($_POST));
    echo json_encode($ajax_result, JSON_NUMERIC_CHECK);
} elseif (isset($_GET['id']) && isset($_GET['mode'])) {
    $ajax_result = Ad::handleGetQuery(AdsStorage::sanitizeHTTPQueriesData($_GET));
    echo json_encode($ajax_result, JSON_NUMERIC_CHECK);
} else {
    /*@var $storage AdsStorage*/
    $storage = AdsStorage::getInstance($smarty);
    $storage->fillStorage()->display();
}