Example #1
0
 function display($params)
 {
     $Log_Model = new Log_Model();
     $CACHE = Cache::getInstance();
     $options_cache = Option::getAll();
     extract($options_cache);
     $page = isset($params[4]) && $params[4] == 'page' ? abs(intval($params[5])) : 1;
     $author = isset($params[1]) && $params[1] == 'author' ? intval($params[2]) : '';
     $pageurl = '';
     $user_cache = $CACHE->readCache('user');
     if (!isset($user_cache[$author])) {
         show_404_page();
     }
     $author_name = $user_cache[$author]['name'];
     //page meta
     $site_title = $author_name . ' - ' . $site_title;
     $sqlSegment = "and author={$author} order by date desc";
     $sta_cache = $CACHE->readCache('sta');
     $lognum = $sta_cache[$author]['lognum'];
     $total_pages = ceil($lognum / $index_lognum);
     if ($page > $total_pages) {
         $page = $total_pages;
     }
     $start_limit = ($page - 1) * $index_lognum;
     $pageurl .= Url::author($author, 'page');
     $Log_Model = new Log_Model();
     $logs = $Log_Model->getLogsForHome($sqlSegment, $page, $index_lognum);
     $page_url = pagination($lognum, $index_lognum, $page, $pageurl);
     include View::getView('header');
     include View::getView('log_list');
 }
Example #2
0
 function display($params)
 {
     $Log_Model = new Log_Model();
     $options_cache = Option::getAll();
     extract($options_cache);
     $page = isset($params[4]) && $params[4] == 'page' ? abs(intval($params[5])) : 1;
     $tag = isset($params[1]) && $params[1] == 'tag' ? addslashes(urldecode(trim($params[2]))) : '';
     $pageurl = '';
     //page meta
     $site_title = stripslashes($tag) . ' - ' . $site_title;
     $Tag_Model = new Tag_Model();
     $blogIdStr = $Tag_Model->getTagByName($tag);
     if ($blogIdStr === false) {
         show_404_page();
     }
     $sqlSegment = "and gid IN ({$blogIdStr}) order by date desc";
     $lognum = $Log_Model->getLogNum('n', $sqlSegment);
     $total_pages = ceil($lognum / $index_lognum);
     if ($page > $total_pages) {
         $page = $total_pages;
     }
     $pageurl .= Url::tag(urlencode($tag), 'page');
     $logs = $Log_Model->getLogsForHome($sqlSegment, $page, $index_lognum);
     $page_url = pagination($lognum, $index_lognum, $page, $pageurl);
     include View::getView('header');
     include View::getView('log_list');
 }
Example #3
0
 function display($params)
 {
     $Log_Model = new Log_Model();
     $options_cache = Option::getAll();
     extract($options_cache);
     $page = isset($params[4]) && $params[4] == 'page' ? abs(intval($params[5])) : 1;
     $record = isset($params[1]) && $params[1] == 'record' ? intval($params[2]) : '';
     $GLOBALS['record'] = $record;
     //for sidebar calendar
     $pageurl = '';
     //page meta
     $site_title = $record . ' - ' . $site_title;
     if (preg_match("/^([\\d]{4})([\\d]{2})\$/", $record, $match)) {
         $days = getMonthDayNum($match[2], $match[1]);
         $record_stime = emStrtotime($record . '01');
         $record_etime = $record_stime + 3600 * 24 * $days;
     } else {
         $record_stime = emStrtotime($record);
         $record_etime = $record_stime + 3600 * 24;
     }
     $sqlSegment = "and date>={$record_stime} and date<{$record_etime} order by date desc";
     $lognum = $Log_Model->getLogNum('n', $sqlSegment);
     $total_pages = ceil($lognum / $index_lognum);
     if ($page > $total_pages) {
         $page = $total_pages;
     }
     $start_limit = ($page - 1) * $index_lognum;
     $pageurl .= Url::record($record, 'page');
     $logs = $Log_Model->getLogsForHome($sqlSegment, $page, $index_lognum);
     $page_url = pagination($lognum, $index_lognum, $page, $pageurl);
     include View::getView('header');
     include View::getView('log_list');
 }
 static function find($option_id)
 {
     $found_option = null;
     $options = Option::getAll();
     foreach ($options as $option) {
         if ($option->getId() == $option_id) {
             $found_option = $option;
         }
     }
     return $found_option;
 }
Example #5
0
 function display($params)
 {
     $Log_Model = new Log_Model();
     $CACHE = Cache::getInstance();
     $options_cache = Option::getAll();
     extract($options_cache);
     $page = isset($params[4]) && $params[4] == 'page' ? abs(intval($params[5])) : 1;
     $sortid = '';
     if (!empty($params[2])) {
         if (is_numeric($params[2])) {
             $sortid = intval($params[2]);
         } else {
             $sort_cache = $CACHE->readCache('sort');
             foreach ($sort_cache as $key => $value) {
                 $alias = addslashes(urldecode(trim($params[2])));
                 if (array_search($alias, $value, true)) {
                     $sortid = $key;
                     break;
                 }
             }
         }
     }
     $pageurl = '';
     $sort_cache = $CACHE->readCache('sort');
     if (!isset($sort_cache[$sortid])) {
         show_404_page();
     }
     $sort = $sort_cache[$sortid];
     $sortName = $sort['sortname'];
     //page meta
     $site_title = $sortName . ' - ' . $site_title;
     if (!empty($sort_cache[$sortid]['description'])) {
         $site_description = $sort_cache[$sortid]['description'];
     }
     if ($sort['pid'] != 0 || empty($sort['children'])) {
         $sqlSegment = "and sortid={$sortid}";
     } else {
         $sortids = array_merge(array($sortid), $sort['children']);
         $sqlSegment = "and sortid in (" . implode(',', $sortids) . ")";
     }
     $sqlSegment .= " order by sortop desc, date desc";
     $lognum = $Log_Model->getLogNum('n', $sqlSegment);
     $total_pages = ceil($lognum / $index_lognum);
     if ($page > $total_pages) {
         $page = $total_pages;
     }
     $pageurl .= Url::sort($sortid, 'page');
     $logs = $Log_Model->getLogsForHome($sqlSegment, $page, $index_lognum);
     $page_url = pagination($lognum, $index_lognum, $page, $pageurl);
     $template = !empty($sort['template']) && file_exists(TEMPLATE_PATH . $sort['template'] . '.php') ? $sort['template'] : 'log_list';
     include View::getView('header');
     include View::getView($template);
 }
Example #6
0
 function display($params)
 {
     $Log_Model = new Log_Model();
     $CACHE = Cache::getInstance();
     $options_cache = Option::getAll();
     extract($options_cache);
     $page = isset($params[1]) && $params[1] == 'page' ? abs(intval($params[2])) : 1;
     $pageurl = '';
     $sqlSegment = 'ORDER BY top DESC ,date DESC';
     $sta_cache = $CACHE->readCache('sta');
     $lognum = $sta_cache['lognum'];
     $pageurl .= Url::logPage();
     $total_pages = ceil($lognum / $index_lognum);
     if ($page > $total_pages) {
         $page = $total_pages;
     }
     $logs = $Log_Model->getLogsForHome($sqlSegment, $page, $index_lognum);
     $page_url = pagination($lognum, $index_lognum, $page, $pageurl);
     include View::getView('header');
     include View::getView('log_list');
 }
Example #7
0
 function display($params)
 {
     $Log_Model = new Log_Model();
     $options_cache = Option::getAll();
     extract($options_cache);
     $page = isset($params[4]) && $params[4] == 'page' ? abs(intval($params[5])) : 1;
     $keyword = isset($params[1]) && $params[1] == 'keyword' ? trim($params[2]) : '';
     $keyword = addslashes(htmlspecialchars(urldecode($keyword)));
     $keyword = str_replace(array('%', '_'), array('\\%', '\\_'), $keyword);
     $pageurl = '';
     $sqlSegment = "and title like '%{$keyword}%' order by date desc";
     $lognum = $Log_Model->getLogNum('n', $sqlSegment);
     $total_pages = ceil($lognum / $index_lognum);
     if ($page > $total_pages) {
         $page = $total_pages;
     }
     $pageurl .= BLOG_URL . '?keyword=' . urlencode($keyword) . '&page=';
     $logs = $Log_Model->getLogsForHome($sqlSegment, $page, $index_lognum);
     $page_url = pagination($lognum, $index_lognum, $page, $pageurl);
     include View::getView('header');
     include View::getView('log_list');
 }
Example #8
0
    $duty = isset($_GET['duty']) ? intval($_GET['duty']) : '';
    if ($duty) {
        $condition = ' where duty=' . $duty;
    }
    $Viporg_Model = new Viporg_Model();
    $page = isset($_GET['page']) ? intval($_GET['page']) : 1;
    $users = $Viporg_Model->getUsers($page, $condition);
    $usernum = $Viporg_Model->getUserNum();
    $pageurl = pagination($usernum, Option::get('admin_perpage_num'), $page, "./viporg.php?page=");
    include View::getView('header');
    require_once View::getView('viporg');
    View::output();
}
if ($action == 'detail') {
    $uid = intval($_GET['uid']);
    $options_cache = Option::getAll();
    extract($options_cache);
    $Viporg_Model = new Viporg_Model();
    $user = $Viporg_Model->getUserDetail($uid);
    if ($user['duty'] == 1) {
        $user['duty'] = '理事单位';
    }
    if ($user['duty'] == 2) {
        $user['duty'] = '常务理事单位';
    }
    if ($user['duty'] == 3) {
        $user['duty'] = '会员单位';
    }
    if (empty($user['avatar'])) {
        $user['avatar'] = './admin/views/images/avatar.jpg';
    } else {
Example #9
0
$app->post('/add_restaurant_options', function () use($app) {
    $restaurant = Restaurant::find($_POST['restaurant_id']);
    $option = Option::find($_POST['option_id']);
    $restaurant->addOption($option);
    return $app['twig']->render('restaurant.html.twig', array('restaurant' => $restaurant, 'restaurant_options' => $restaurant->getOptions(), 'all_options' => Option::getAll()));
});
$app->post('/add_option_restaurants', function () use($app) {
    $option = Option::find($_POST['option_id']);
    $restaurant = Restaurant::find($_POST['restaurant_id']);
    $option->addRestaurant($restaurant);
    return $app['twig']->render('option.html.twig', array('option' => $option, 'option_restaurants' => $option->getRestaurants(), 'all_restaurants' => Restaurant::getAll()));
});
$app->get('/restaurants/{id}', function ($id) use($app) {
    $restaurant = Restaurant::find($id);
    return $app['twig']->render('restaurant.html.twig', array('restaurant' => $restaurant, 'restaurant_options' => $restaurant->getOptions(), 'all_options' => Option::getAll()));
});
$app->get('/options/{id}', function ($id) use($app) {
    $option = Option::find($id);
    return $app['twig']->render('option.html.twig', array('option' => $option, 'option_restaurants' => $option->getRestaurants(), 'all_restaurants' => Restaurant::getAll()));
});
$app->post('/restaurants/{id}/delete', function ($id) use($app) {
    $restaurant = Restaurant::find($id);
    $restaurant->delete();
    return $app['twig']->render('admin.html.twig', array('restaurants' => Restaurant::getAll(), 'options' => Option::getAll()));
});
$app->post('/options/{id}/delete', function ($id) use($app) {
    $option = Option::find($id);
    $option->delete();
    return $app['twig']->render('admin.html.twig', array('options' => Option::getAll(), 'restaurants' => Restaurant::getAll()));
});
return $app;
 function test_getAll()
 {
     //arrange
     $name = "peanut allergy";
     $id = null;
     $test_allergy = new Option($name, $id);
     $test_allergy->save();
     $name2 = "gluten allergy";
     $test_allergy2 = new Option($name2, $id);
     $test_allergy2->save();
     //act
     $result = Option::getAll();
     //assert
     $this->assertEquals([$test_allergy, $test_allergy2], $result);
 }