Exemple #1
0
function stocks_eshop($params)
{
    global $tpl, $template, $twig, $mysql, $SYSTEM_FLAGS, $config, $userROW, $CurrentHandler, $lang;
    $url = pluginGetVariable('eshop', 'url');
    switch ($CurrentHandler['handlerParams']['value']['pluginName']) {
        case 'core':
            if (isset($url) && !empty($url)) {
                return redirect_eshop(generateLink('eshop', 'stocks'));
            }
            break;
        case 'eshop':
            if (empty($url)) {
                return redirect_eshop(generateLink('core', 'plugin', array('plugin' => 'eshop')));
            }
            break;
    }
    $SYSTEM_FLAGS['info']['title']['group'] = $lang['eshop']['name_plugin'];
    $SYSTEM_FLAGS['info']['title']['others'] = $lang['eshop']['name_stocks'];
    $SYSTEM_FLAGS['template.main.name'] = pluginGetVariable('eshop', 'main_template') ? pluginGetVariable('eshop', 'main_template') : 'main';
    $SYSTEM_FLAGS['meta']['description'] = pluginGetVariable('eshop', 'description') ? pluginGetVariable('eshop', 'description') : $SYSTEM_FLAGS['meta']['description'];
    $SYSTEM_FLAGS['meta']['keywords'] = pluginGetVariable('eshop', 'keywords') ? pluginGetVariable('eshop', 'keywords') : $SYSTEM_FLAGS['meta']['keywords'];
    $tpath = locatePluginTemplates(array('stocks_eshop'), 'eshop', pluginGetVariable('eshop', 'localsource'), pluginGetVariable('eshop', 'localskin'));
    $xt = $twig->loadTemplate($tpath['stocks_eshop'] . 'stocks_eshop.tpl');
    if (isset($_REQUEST['mode']) && $_REQUEST['mode']) {
        $mode = filter_var($_REQUEST['mode'], FILTER_SANITIZE_STRING);
    } else {
        $mode = "stocks";
    }
    $conditions = array();
    array_push($conditions, "p.active = 1 ");
    switch ($mode) {
        case "stocks":
            array_push($conditions, "p.stocked = 1");
            $orderby = " ORDER BY p.editdate DESC ";
            break;
        default:
            array_push($conditions, "p.stocked = 1");
            $orderby = " ORDER BY p.editdate DESC ";
            break;
    }
    $limitCount = pluginGetVariable('eshop', 'count_stocks');
    $pageNo = intval($params['page']) ? intval($params['page']) : intval($_REQUEST['page']);
    if ($pageNo < 1) {
        $pageNo = 1;
    }
    if (!$limitStart) {
        $limitStart = ($pageNo - 1) * $limitCount;
    }
    $fSort = " GROUP BY p.id ORDER BY p.id DESC";
    $sqlQPart = "FROM " . prefix . "_eshop_products p LEFT JOIN " . prefix . "_eshop_products_categories pc ON p.id = pc.product_id LEFT JOIN " . prefix . "_eshop_categories c ON pc.category_id = c.id  " . (count($conditions) ? "WHERE " . implode(" AND ", $conditions) : '') . $fSort;
    $sqlQ = "SELECT p.id AS id, p.url as url, p.code AS code, p.name AS name, p.annotation AS annotation, p.body AS body, p.active AS active, p.featured AS featured, p.position AS position, p.meta_title AS meta_title, p.meta_keywords AS meta_keywords, p.meta_description AS meta_description, p.date AS date, p.editdate AS editdate, p.views AS views, c.id AS cid, c.url as curl, c.name AS category " . $sqlQPart;
    $sqlQCount = "SELECT COUNT(*) as CNT FROM (" . $sqlQ . ") AS T ";
    $count = $mysql->result($sqlQCount);
    $countPages = ceil($count / $limitCount);
    if ($countPages < $pageNo) {
        return msg(array("type" => "error", "text" => "Подстраницы не существует"));
    }
    if ($countPages > 1 && $countPages >= $pageNo) {
        $paginationParams = checkLinkAvailable('eshop', '') ? array('pluginName' => 'eshop', 'pluginHandler' => 'stocks', 'params' => array('keywords' => $get_url), 'xparams' => array(), 'paginator' => array('page', 0, false)) : array('pluginName' => 'core', 'pluginHandler' => 'plugin', 'params' => array('plugin' => 'eshop'), 'xparams' => array('keywords' => $get_url), 'paginator' => array('page', 1, false));
        $navigations = LoadVariables();
        $pages = generatePagination($pageNo, 1, $countPages, 10, $paginationParams, $navigations);
    }
    $cmp_array = array();
    foreach ($SYSTEM_FLAGS["eshop"]["compare"]["entries"] as $cmp_row) {
        $cmp_array[] = $cmp_row['linked_fld'];
    }
    foreach ($mysql->select($sqlQ . ' LIMIT ' . $limitStart . ', ' . $limitCount) as $row) {
        $fulllink = checkLinkAvailable('eshop', 'show') ? generateLink('eshop', 'show', array('alt' => $row['url'])) : generateLink('core', 'plugin', array('plugin' => 'eshop', 'handler' => 'show'), array('alt' => $row['url']));
        $catlink = checkLinkAvailable('eshop', '') ? generateLink('eshop', '', array('alt' => $row['curl'])) : generateLink('core', 'plugin', array('plugin' => 'eshop'), array('alt' => $row['curl']));
        $cmp_flag = in_array($row['id'], $cmp_array);
        $entries[$row['id']] = array('id' => $row['id'], 'code' => $row['code'], 'name' => $row['name'], 'annotation' => $row['annotation'], 'body' => $row['body'], 'active' => $row['active'], 'featured' => $row['featured'], 'price' => $row['price'], 'compare_price' => $row['compare_price'], 'stock' => $row['stock'], 'meta_title' => $row['meta_title'], 'meta_keywords' => $row['meta_keywords'], 'meta_description' => $row['meta_description'], 'fulllink' => $fulllink, 'date' => empty($row['date']) ? '' : $row['date'], 'editdate' => empty($row['editdate']) ? '' : $row['editdate'], 'views' => $row['views'], 'cat_name' => $row['category'], 'cid' => $row['cid'], 'catlink' => $catlink, 'compare' => $cmp_flag, 'home' => home, 'image_filepath' => $row['image_filepath'], 'tpl_url' => home . '/templates/' . $config['theme']);
    }
    $entries_array_ids = array_keys($entries);
    if (isset($entries_array_ids) && !empty($entries_array_ids)) {
        $entries_string_ids = implode(',', $entries_array_ids);
        foreach ($mysql->select('SELECT * FROM ' . prefix . '_eshop_images i WHERE i.product_id IN (' . $entries_string_ids . ') ORDER BY i.position, i.id') as $irow) {
            $entries[$irow['product_id']]['images'][] = $irow;
        }
        foreach ($mysql->select('SELECT * FROM ' . prefix . '_eshop_variants v WHERE v.product_id IN (' . $entries_string_ids . ') ORDER BY v.position, v.id') as $vrow) {
            $entries[$vrow['product_id']]['variants'][] = $vrow;
        }
    }
    $tVars = array('info' => isset($info) ? $info : '', 'entries' => isset($entries) ? $entries : '', 'pages' => array('true' => isset($pages) && $pages ? 1 : 0, 'print' => isset($pages) ? $pages : ''), 'prevlink' => array('true' => !empty($limitStart) ? 1 : 0, 'link' => str_replace('%page%', "\$1", str_replace('%link%', checkLinkAvailable('eshop', '') ? generatePageLink(array('pluginName' => 'eshop', 'pluginHandler' => 'stocks', 'params' => array(), 'xparams' => array(), 'paginator' => array('page', 0, false)), $prev = floor($limitStart / $limitCount)) : generatePageLink(array('pluginName' => 'core', 'pluginHandler' => 'plugin', 'params' => array('plugin' => 'eshop'), 'xparams' => array(), 'paginator' => array('page', 1, false)), $prev = floor($limitStart / $limitCount)), isset($navigations['prevlink']) ? $navigations['prevlink'] : ''))), 'nextlink' => array('true' => $prev + 2 <= $countPages ? 1 : 0, 'link' => str_replace('%page%', "\$1", str_replace('%link%', checkLinkAvailable('eshop', '') ? generatePageLink(array('pluginName' => 'eshop', 'pluginHandler' => 'stocks', 'params' => array(), 'xparams' => array(), 'paginator' => array('page', 0, false)), $prev + 2) : generatePageLink(array('pluginName' => 'core', 'pluginHandler' => 'plugin', 'params' => array('plugin' => 'eshop'), 'xparams' => array(), 'paginator' => array('page', 1, false)), $prev + 2), isset($navigations['nextlink']) ? $navigations['nextlink'] : ''))), 'tpl_url' => home . '/templates/' . $config['theme'], 'tpl_home' => admin_url);
    $template['vars']['mainblock'] .= $xt->render($tVars);
}
} else {
    ?>
                        <h4>Nie znaleziono postów </h4>
                    <?php 
}
?>
                    <!-- #endregion -->

                <!-- #endregion -->

                <!-- #region PAGINACJA -->                
                <div class="row">
                    <div class="medium-12 column text-center">
                        <div class="pagination-centered">
                            <?php 
generatePagination(get_query_var('paged'), $loop);
?>
                            
                        </div>
                    </div>
                </div>
                <!-- #endregion -->
                
            </div>
            <!-- #endregion -->

            <!-- #region Sidebar -->
            <?php 
get_sidebar('restaurants-archive');
?>
            <!-- #endregion -->
Exemple #3
0
    }
    if ($first_page && ($parity - 1) % 2 != 0 || !$first_page && ($parity - 1) % 2 != 1) {
        echo '</div>';
    }
    // Zabezpieczenie przed brakiem zamknięcia div.row gdy nie mamy 2 wpisów w jednym wierszu.
}
wp_reset_query();
?>
                <!-- #endregion -->

                <!-- #region Pagination -->                
                <div class="row">
                    <div class="medium-12 column text-center">
                        <div class="pagination-centered">
                            <?php 
generatePagination(get_query_var('paged'), $recipes_query);
?>
                            
                        </div>
                    </div>
                </div>
                <!-- #endregion -->

            </div>
            <!-- #endregion -->

            <!-- #region Sidebar-->
            <?php 
get_sidebar('index');
?>
            <!-- #endregion -->
function guestbook_list($params = array())
{
    global $template, $tpl, $twig, $userROW, $ip, $config, $mysql, $SYSTEM_FLAGS, $TemplateCache, $CurrentHandler, $lang;
    $SYSTEM_FLAGS['info']['title']['group'] = $lang['guestbook']['title'];
    require_once root . "/plugins/guestbook/lib/recaptchalib.php";
    $publickey = pluginGetVariable('guestbook', 'public_key');
    $privatekey = pluginGetVariable('guestbook', 'private_key');
    // ADD notication
    if (isset($params['act']) && $params['act'] == 'add' || isset($_REQUEST['add']) && $_REQUEST['add']) {
        $success_add[] = pluginGetVariable('guestbook', 'approve_msg') ? $lang['guestbook']['success_add_wo_approve'] : $lang['guestbook']['success_add'];
    }
    // EDIT notication
    if (isset($params['act']) && $params['act'] == 'upd' || isset($_REQUEST['upd']) && $_REQUEST['upd']) {
        $success_add[] = $lang['guestbook']['success_edit'];
    }
    // DELETE notication
    if (isset($params['act']) && $params['act'] == 'del' || isset($_REQUEST['del']) && $_REQUEST['del']) {
        $success_add[] = $lang['guestbook']['success_delete'];
    }
    // pagination
    $perpage = intval(pluginGetVariable('guestbook', 'perpage'));
    if ($perpage < 1 or $perpage > 5000) {
        $perpage = 10;
    }
    $page = intval(isset($CurrentHandler['params']['page']) ? $CurrentHandler['params']['page'] : (isset($_REQUEST['page']) ? $_REQUEST['page'] : 0));
    if ($page < 1) {
        $page = 1;
    }
    if (!$start) {
        $start = ($page - 1) * $perpage;
    }
    $total_count = $mysql->result("SELECT COUNT(*) AS num FROM " . prefix . "_guestbook WHERE status = 1");
    $PagesCount = ceil($total_count / $perpage);
    $paginationParams = checkLinkAvailable('guestbook', '') ? array('pluginName' => 'guestbook', 'pluginHandler' => '', 'params' => array(), 'xparams' => array(), 'paginator' => array('page', 0, false)) : array('pluginName' => 'core', 'pluginHandler' => 'plugin', 'params' => array('plugin' => 'guestbook'), 'xparams' => array(), 'paginator' => array('page', 1, false));
    $tpath = locatePluginTemplates(array(':'), 'guestbook', pluginGetVariable('guestbook', 'localsource'));
    $navigations = parse_ini_file($tpath[':'] . '/variables.ini', true);
    $order = pluginGetVariable('guestbook', 'order');
    // get fields
    $fields = $mysql->select("select * from " . prefix . "_guestbook_fields");
    $tEntries = array();
    foreach ($fields as $fNum => $fRow) {
        $tEntry = array('id' => $fRow['id'], 'name' => $fRow['name'], 'placeholder' => $fRow['placeholder'], 'default_value' => $fRow['default_value'], 'required' => intval($fRow['required']));
        $tEntries[$fRow['id']] = $tEntry;
    }
    $tVars = array('entries' => _guestbook_records($order, $start, $perpage), 'pages' => generatePagination($page, 1, $PagesCount, 10, $paginationParams, $navigations), 'total_count' => $total_count, 'perpage' => $perpage, 'errors' => $errors, 'success' => $success_add, 'ip' => $ip, 'smilies' => pluginGetVariable('guestbook', 'usmilies') ? InsertSmilies('', 10) : "", 'bbcodes' => pluginGetVariable('guestbook', 'ubbcodes') ? BBCodes() : "", 'use_captcha' => pluginGetVariable('guestbook', 'ecaptcha'), 'captcha' => pluginGetVariable('guestbook', 'ecaptcha') && !is_array($userROW) ? recaptcha_get_html($publickey) : '', 'use_guests' => !is_array($userROW) && !pluginGetVariable('guestbook', 'guests'), 'fields' => $tEntries);
    $tpath = locatePluginTemplates(array('guestbook.list'), 'guestbook', pluginGetVariable('guestbook', 'localsource'));
    $xt = $twig->loadTemplate($tpath['guestbook.list'] . 'guestbook.list.tpl');
    $template['vars']['mainblock'] = $xt->render($tVars);
}