Пример #1
0
<?php

define('ABS_PATH', dirname(dirname(dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME']))))) . '/');
define('OC_ADMIN', true);
require_once ABS_PATH . 'oc-load.php';
if (osc_is_admin_user_logged_in() == FALSE) {
    die;
}
$model = new GzNewsModel();
$dao = GzNewsDao::newInstance();
$redirect_url = $_SERVER['HTTP_REFERER'];
$gn_id = (int) Params::getParam('gn_id');
$from_form = (bool) Params::getParam('from_form');
if ($from_form) {
    $redirect_url = GzNewsUtils::getAdminIndexUrl();
}
$success = $dao->deleteByPrimaryKey($gn_id);
if ($success) {
    $model->removeFiles($gn_id);
    osc_add_flash_ok_message(__('The item was deleted successfully', 'gz_news'), 'admin');
} else {
    osc_add_flash_error_message('There were a problem while deleting the item', 'admin');
}
$model->redirectTo($redirect_url);
Пример #2
0
<?php

if (osc_is_admin_user_logged_in() == FALSE) {
    die;
}
GzNewsForm::initForm();
$back_url = GzNewsUtils::getAdminIndexUrl();
$item = FALSE;
$item_id = Params::getParam('gn_id');
if ($item_id) {
    $dao = GzNewsDao::newInstance();
    $item = $dao->findByPrimaryKey($item_id);
}
$title = NULL;
$description = NULL;
$tags = NULL;
$lang = NULL;
if ($item) {
    $title = $item['gn_title'];
    $description = $item['gn_description'];
    $tags = $item['gn_tags'];
    $lang = $item['gn_lang'];
}
$images = GzNewsUtils::getImagesUrl($item_id);
?>
<h2 class="render-title">
	<?php 
_e('Add New', 'gz_news');
?>
    <a class="btn btn-mini" href="<?php 
echo $back_url;
Пример #3
0
    $conn = getConnection();
    $conn->autocommit(FALSE);
    try {
        $conn->osc_dbExec('DROP TABLE %st_news', DB_TABLE_PREFIX);
    } catch (Exception $e) {
        $conn->rollback();
        echo $e->getMessage();
    }
    $conn->autocommit(TRUE);
}
/**
 * Includes stylesheets and javascript files to templates
 */
function gz_news_add_header()
{
    osc_render_file(GZ_NEWS_PLUGIN_FOLDER . 'views/news_header.php');
}
/**
 * Generate admin menu page to list news
 */
osc_add_admin_menu_page(__('News', 'gz_news'), GzNewsUtils::getAdminIndexUrl(), 'gz_news');
/**
 * Register a submenu into admin page, to add news
 */
osc_add_admin_submenu_page('gz_news', __('Add News', 'gz_news'), GzNewsUtils::getAdminAddUrl(), 'gz_news_add');
osc_add_hook('admin_header', 'gz_news_add_header');
osc_add_hook('header', 'gz_news_add_header');
/** Remove the uninstall hook to do not lose data
osc_add_hook(osc_plugin_path(__FILE__) . '_uninstall', 'gz_news_call_after_uninstall');
 */
osc_register_plugin(osc_plugin_path(__FILE__), 'gz_news_call_after_install');
Пример #4
0
<?php

if (osc_is_admin_user_logged_in() == FALSE) {
    die;
}
$add_url = GzNewsUtils::getAdminAddUrl();
$index_url = GzNewsUtils::getAdminIndexUrl();
$dao = GzNewsDao::newInstance();
$current_page = (int) Params::getParam('new_p');
$selected = 0;
if ($current_page > 0) {
    $selected = $current_page - 1;
}
$total_items = $dao->count();
$total_per_page = 10;
$total_pages = ceil($total_items / $total_per_page);
$params = array('total' => (int) $total_pages, 'selected' => $selected, 'url' => $index_url . '&new_p={PAGE}', 'sides' => 5);
// set pagination
$pagination = new Pagination($params);
$paginator_html = $pagination->doPagination();
$options = array('page' => $current_page, 'total_per_page' => $total_per_page);
$list = $dao->listItems($options);
?>

<h2 class="render-title">
	<?php 
_e('Listing News', 'gz_news');
?>
 <a class="btn btn-mini" href="<?php 
echo $add_url;
?>