Exemplo n.º 1
0
 /**
  * Формирование данных доступных в шаблоне.
  */
 function createData()
 {
     $items = array();
     $pager = new A_Pager(A::$OPTIONS['rows']);
     if (!empty($_GET['idsec'])) {
         if (is_array($_GET['idsec'])) {
             foreach ($_GET['idsec'] as $i => $id) {
                 $idsec[$i] = (int) $id;
             }
         } else {
             $idsec = array((int) $_GET['idsec']);
         }
     }
     $imodules = array('feedback');
     if (!empty($_GET['query'])) {
         $_GET['query'] = mb_substr($_GET['query'], 0, 50);
         $stems = $_stems = array();
         $words = $_words = array();
         $query = explode(" ", $_GET['query']);
         foreach ($query as $word) {
             if (mb_strlen($word) > 2) {
                 $word = mb_strtolower($word);
                 $words[] = $word;
                 $_words[] = empty($_words) ? "+>{$word}" : ">{$word}";
                 if ($stem = A_SearchEngine::getInstance()->getStem($word)) {
                     if (mb_strlen($stem) > 3) {
                         $stems[] = $stem;
                         $_stems[] = empty($_stems) ? "+<{$stem}" : "<{$stem}";
                     }
                 }
             }
         }
         $_words = A::$DB->real_escape_string(implode(" ", $_words));
         $_stems = A::$DB->real_escape_string(implode(" ", $_stems));
         if (!empty($_words)) {
             $pager->query("\r\r\n\t    SELECT `date`,`idsec`,`iditem`,`name`,`content`,`idtags`,\r\r\n\t    MATCH(`name`) AGAINST('{$_words}')+MATCH(`content`) AGAINST('{$_words}')+MATCH(`stems`) AGAINST('{$_stems}') AS relevant\r\r\n\t    FROM " . SECTION . "\r\r\n\t    WHERE " . (!empty($idsec) ? "idsec IN(" . implode(",", $idsec) . ") AND " : "") . "\r\r\n\t    ( MATCH(`name`) AGAINST ('{$_words}' IN BOOLEAN MODE)\r\r\n\t      OR\r\r\n\t\t  MATCH(`content`) AGAINST ('{$_words}' IN BOOLEAN MODE)\r\r\n\t\t  OR\r\r\n\t\t  MATCH(`stems`) AGAINST ('{$_stems}' IN BOOLEAN MODE)\r\r\n\t    )\r\r\n\t    ORDER BY `relevant` DESC, `date` DESC");
             while ($row = $pager->fetchRow()) {
                 $row['num'] = $pager->begin + count($items);
                 $row['description'] = A_SearchEngine::getInstance()->getFindedText($words, $stems, $row['content']);
                 if ($srow = A::$DB->getRowById($row['idsec'], DOMAIN . "_sections")) {
                     $section = DOMAIN . '_' . $srow['lang'] . '_' . $srow['name'];
                     if (!empty($row['name']) && !in_array($srow['module'], $imodules)) {
                         if (!empty($srow['caption_' . LANG])) {
                             $row['name'] = $srow['caption_' . LANG] . " - " . $row['name'];
                         }
                     } else {
                         $row['name'] = $srow['caption_' . LANG];
                     }
                     if ($row['iditem'] > 0) {
                         $row['link'] = function_exists($srow['module'] . '_createItemLink') ? call_user_func($srow['module'] . '_createItemLink', $row['iditem'], $section) : getSectionLink($section);
                     } else {
                         $row['link'] = function_exists($srow['module'] . '_createCategoryLink') ? call_user_func($srow['module'] . '_createCategoryLink', -$row['iditem'], $section) : getSectionLink($section);
                     }
                     $row['images'] = A::$DB->getAll("SELECT * FROM " . DOMAIN . "_images WHERE idsec=? AND iditem=? ORDER BY sort", array($row['idsec'], $row['iditem']));
                     $row['idimg'] = isset($row['images'][0]['id']) ? $row['images'][0]['id'] : 0;
                     $row['tags'] = A_SearchEngine::getInstance()->getTags($row['idtags']);
                     $items[] = $row;
                 }
             }
             $pager->free();
         }
     } elseif (!empty($_GET['tag'])) {
         if ($_GET['tag'] = mb_substr(mb_strtolower(trim($_GET['tag'])), 0, 50)) {
             if ($idtag = A::$DB->getOne("SELECT id FROM " . SECTION . "_tags WHERE tag=?", $_GET['tag'])) {
                 $idtag = sprintf("%04d", $idtag);
                 $pager->query("\r\r\n\t    SELECT `date`,`idsec`,`iditem`,`name`,`content`,`idtags`\r\r\n\t    FROM " . SECTION . "\r\r\n\t    WHERE " . (!empty($idsec) ? "idsec IN(" . implode(",", $idsec) . ") AND " : "") . "\r\r\n\t    MATCH(`idtags`) AGAINST ('{$idtag}' IN BOOLEAN MODE)\r\r\n\t    ORDER BY `date` DESC");
                 while ($row = $pager->fetchRow()) {
                     $row['num'] = $pager->begin + count($items);
                     $row['description'] = truncate($row['content'], 350);
                     if ($srow = A::$DB->getRowById($row['idsec'], DOMAIN . "_sections")) {
                         $section = DOMAIN . '_' . $srow['lang'] . '_' . $srow['name'];
                         if (!empty($row['name']) && !in_array($srow['module'], $imodules)) {
                             if (!empty($srow['caption_' . LANG])) {
                                 $row['name'] = $srow['caption_' . LANG] . " - " . $row['name'];
                             }
                         } else {
                             $row['name'] = $srow['caption_' . LANG];
                         }
                         if ($row['iditem'] > 0) {
                             $row['link'] = function_exists($srow['module'] . '_createItemLink') ? call_user_func($srow['module'] . '_createItemLink', $row['iditem'], $section) : getSectionLink($section);
                         } else {
                             $row['link'] = function_exists($srow['module'] . '_createCategoryLink') ? call_user_func($srow['module'] . '_createCategoryLink', -$row['iditem'], $section) : getSectionLink($section);
                         }
                         $row['images'] = A::$DB->getAll("SELECT * FROM " . DOMAIN . "_images WHERE idsec=? AND iditem=? ORDER BY sort", array($row['idsec'], $row['iditem']));
                         $row['idimg'] = isset($row['images'][0]['id']) ? $row['images'][0]['id'] : 0;
                         $row['tags'] = A_SearchEngine::getInstance()->getTags($row['idtags']);
                         $items[] = $row;
                     }
                 }
                 $pager->free();
             }
         }
     }
     $this->Assign("items", $items);
     $this->Assign("items_pager", $pager);
     $this->Assign("sections", A_SearchEngine::getInstance()->getSections());
     $this->AddNavigation(SECTION_NAME);
 }
Exemplo n.º 2
0
    include 'A/Pager/Array.php';
    // initialize an array for testing
    $first = 0;
    $last = 75;
    for ($i = $first; $i <= $last; ++$i) {
        $myarray[$i]['id'] = $i;
        $myarray[$i]['text'] = 'This is row ' . $i;
        $myarray[$i]['sort'] = $last - $i;
    }
    #$myarray = null;
    // create a data object that has the interface needed by the Pager object
    $datasource = new A_Pager_Array($myarray);
    $datasource->orderBy('text');
}
// create pager using values from datasource and request params
$pager = new A_Pager($datasource);
$pager->setPageSize(25);
// change from default of 10 of you want
$pager->setOrderByFields(array('id', 'text', 'sort'), 'text');
// allowed orderby fields and starting sort
// create a request processor to set pager from GET parameters
#$request = new PagerRequest($pager);
$request = new A_Pager_Request_Session($pager);
$request->process();
if ($pager->hasPages()) {
    // create a HTML writer to output
    $writer = new A_Pager_HTMLWriter($pager);
    // get rows of data
    $start_row = $pager->getStartRow();
    $end_row = $pager->getEndRow();
    $rows = $datasource->getRows($start_row, $end_row);
Exemplo n.º 3
0
 /**
  * Формирование данных доступных в шаблоне страницы альбома.
  */
 function AlbumPage()
 {
     $this->supportCached();
     $this->addCacheParam_Get('page');
     if ($this->idcat > 0) {
         $this->category['link'] = gallery_createCategoryLink($this->category['id'], SECTION);
         if (A::$OPTIONS['usetags']) {
             $this->category['tags'] = A_SearchEngine::getInstance()->convertTags($this->category['tags']);
         }
         $this->Assign("category", $this->category);
     }
     $album = $this->album;
     $album['vote'] = $album['cvote'] > 0 ? round($album['svote'] / $album['cvote'], 2) : 0;
     $album['images'] = A::$DB->getAll("SELECT * FROM " . DOMAIN . "_images WHERE idsec=? AND iditem=? ORDER BY sort", array(SECTION_ID, $album['id']));
     if (A::$OPTIONS['usetags']) {
         $album['tags'] = A_SearchEngine::getInstance()->convertTags($album['tags']);
     }
     prepareValues(SECTION, $album);
     $album = A::$OBSERVER->Modifier('gallery_prepareValues', SECTION, $album);
     $this->Assign("album", $album);
     $irows = (int) (!empty($_GET['irows'])) ? (int) $_GET['irows'] : A::$OPTIONS['irows'];
     $this->Assign("irows", $irows);
     $pager = new A_Pager($irows);
     $images = $pager->setItems($album['images']);
     $this->Assign("images", $images);
     $this->Assign("images_pager", $pager);
     $sort = escape_order_string(!empty(A::$OPTIONS['mysort']) ? A::$OPTIONS['mysort'] : A::$OPTIONS['sort']);
     $albums = A::$DB->getCol("\r\r\n\tSELECT id FROM " . SECTION . "_albums\r\r\n\tWHERE active='Y' AND idcat={$album['idcat']} ORDER BY {$sort}");
     $i = array_search($album['id'], $albums);
     if ($i !== false) {
         $previd = isset($albums[$i - 1]) ? $albums[$i - 1] : 0;
         $nextid = isset($albums[$i + 1]) ? $albums[$i + 1] : 0;
         if ($previd) {
             $this->Assign("prevalbum", gallery_createItemLink($previd, SECTION));
         }
         if ($nextid) {
             $this->Assign("nextalbum", gallery_createItemLink($nextid, SECTION));
         }
     }
     if (A::$OPTIONS['usecomments']) {
         $comments = array();
         A::$DB->query("SELECT * FROM " . DOMAIN . "_comments WHERE idsec=" . SECTION_ID . " AND iditem={$this->idalb} AND active='Y' ORDER BY date");
         while ($row = A::$DB->fetchRow()) {
             if ($row['iduser'] > 0 && A::$AUTH->section) {
                 if ($row['user'] = A::$DB->getRowById($row['iduser'], A::$AUTH->section)) {
                     prepareValues(A::$AUTH->section, $row['user']);
                 }
             }
             $comments[] = $row;
         }
         A::$DB->free();
         $this->Assign("comments", $comments);
         $form = array();
         $form['name'] = !empty($_REQUEST['name']) ? $_REQUEST['name'] : (A::$AUTH->isLogin() ? A::$AUTH->data['name'] : "");
         $form['message'] = !empty($_REQUEST['message']) ? $_REQUEST['message'] : "";
         $this->Assign("form", $form);
         $this->Assign("captcha", $captcha = substr(time(), rand(0, 6), 4));
         A_Session::set("captcha", md5($captcha));
     }
     if (A::$OPTIONS['usevote']) {
         $this->Assign("isvote", A_Session::get(SECTION . "_vote_" . $this->idalb, false));
         $this->addCacheParam_Session(SECTION . "_vote_" . $this->idalb);
     }
     $this->AddNavigation(SECTION_NAME, getSectionLink(SECTION));
     if (isset($this->category)) {
         $this->AddNavCategories($this->category['id']);
     }
     $this->title = $this->album['name'] . (!empty($this->title) ? " - " . $this->title : "");
     $this->description = $this->album['description'];
 }
Exemplo n.º 4
0
 /**
  * Формирование данных доступных в шаблоне страницы "мои заказы".
  */
 function MyOrdersPage()
 {
     if (!A::$AUTH->isLogin()) {
         A::goUrl(getSectionLink(SECTION));
     }
     $orders = array();
     $pager = new A_Pager(20);
     $pager->tab = "orders";
     $pager->query("SELECT * FROM " . SECTION . "_orders WHERE iduser=? ORDER BY date DESC", A::$AUTH->id);
     while ($row = $pager->fetchRow()) {
         if ($section = getSectionByModule('robopay')) {
             $row['paylink'] = getSectionLink($section) . "?action=pay&code=" . md5($section . $row['date']);
         }
         $row['pay'] = function_exists('pay_getname') ? pay_getname($row['pay']) : "Наличные";
         $row['basket'] = !empty($row['basket']) ? unserialize($row['basket']) : array();
         $row['sum'] = round($row['sum'], 2);
         $orders[] = $row;
     }
     $pager->free();
     $this->Assign("orders", $orders);
     $this->Assign("orders_pager", $pager);
     $this->AddNavigation(SECTION_NAME, getSectionLink(SECTION));
 }
Exemplo n.º 5
0
 function createData()
 {
     $categories = array();
     A::$DB->query("SELECT * FROM " . STRUCTURE . "_categories ORDER BY sort");
     while ($row = A::$DB->fetchRow()) {
         $row['count'] = A::$DB->getCount(STRUCTURE, "idcat=" . $row['id']);
         $row['selected'] = isset($_GET['idcat']) && $_GET['idcat'] == $row['id'];
         $categories[] = $row;
     }
     A::$DB->free();
     $this->Assign("categories", $categories);
     if (empty($_GET['tab']) && !empty($_COOKIE[STRUCTURE . '_idcat'])) {
         $_GET['idcat'] = (int) $_COOKIE[STRUCTURE . '_idcat'];
         $_REQUEST['tab'] = "banners";
     }
     if (!empty($_GET['idcat'])) {
         if ($row = A::$DB->getRowById($idcat = (int) $_GET['idcat'], STRUCTURE . "_categories")) {
             $this->Assign("category", $row);
             $rows = (int) A_Session::get(STRUCTURE . "_rows", isset($_COOKIE[STRUCTURE . '_rows']) ? $_COOKIE[STRUCTURE . '_rows'] : 10);
             $banners = array();
             $pager = new A_Pager($rows);
             $pager->tab = "banners";
             $pager->query("\r\r\n\t\tSELECT * FROM " . STRUCTURE . "\r\r\n\t\tWHERE idcat={$idcat}\r\r\n\t\tORDER BY " . A_Session::get(STRUCTURE . "_sort", isset($_COOKIE[STRUCTURE . '_sort']) ? A::$DB->real_escape_string($_COOKIE[STRUCTURE . '_sort']) : "sort"));
             while ($row = $pager->fetchRow()) {
                 $row['link'] = "http://" . DOMAINNAME . "/getfile/" . SNAME . "/click/?id=" . $row['id'];
                 $row['close'] = $row['active'] == 'N' || $row['date'] == 'Y' && !($row['date1'] < time() && time() < $row['date2']);
                 $banners[] = $row;
             }
             $pager->free();
             $this->Assign("banners", $banners);
             $this->Assign("banners_pager", $pager);
             setcookie(STRUCTURE . "_idcat", $idcat, time() + 31104000);
         } else {
             setcookie(STRUCTURE . "_idcat", 0, time() - 3600);
         }
     }
     $this->Assign("sort", A_Session::get(STRUCTURE . "_sort", isset($_COOKIE[STRUCTURE . '_sort']) ? A::$DB->real_escape_string($_COOKIE[STRUCTURE . '_sort']) : "sort"));
     $this->Assign("rows", A_Session::get(STRUCTURE . "_rows", isset($_COOKIE[STRUCTURE . '_rows']) ? $_COOKIE[STRUCTURE . '_rows'] : 10));
 }
Exemplo n.º 6
0
 /**
  * Формирование данных доступных в шаблоне.
  */
 function createData()
 {
     if (!A_Session::is_set(SECTION . "_filter")) {
         $this->unFilter();
     }
     $fields = A::$DB->getFields(SECTION . "_orders");
     if (!in_array('pay', $fields)) {
         A::$DB->execute("ALTER TABLE `" . SECTION . "_orders` ADD `pay` int(11) NOT NULL default '0'");
     }
     $categories = A::$DB->getAll("SELECT id,idker,name FROM " . SECTION . "_categories ORDER BY level,sort");
     $this->Assign("categories", $categories);
     if (!empty($_GET['idcat'])) {
         $this->Assign("category", A::$DB->getRowById($_GET['idcat'], SECTION . "_categories"));
         $idcat = (int) $_GET['idcat'];
         $childcats = array($idcat);
         getTreeSubItems(SECTION . "_categories", $idcat, $childcats);
         $where = "(c.idcat IN(" . implode(",", $childcats) . ") OR c.idcat1 IN(" . implode(",", $childcats) . ") OR c.idcat2 IN(" . implode(",", $childcats) . "))";
         $this->Assign("childcats", $childcats = count($childcats));
     } else {
         $where = "";
     }
     if ($filter = $this->getFilter()) {
         $where = !empty($where) ? "{$where} AND {$filter}" : $filter;
     }
     $this->Assign("treebox", new A_CategoriesTree("items"));
     $rows = A_Session::get(SECTION . "_rows", isset($_COOKIE[SECTION . '_rows']) ? $_COOKIE[SECTION . '_rows'] : 20);
     $sort = escape_order_string(A_Session::get(SECTION . "_sort", isset($_COOKIE[SECTION . '_sort']) ? $_COOKIE[SECTION . '_sort'] : A::$OPTIONS['sort']));
     $items = array();
     $pager = new A_Pager($rows);
     $pager->tab = "items";
     $pager->query("\r\r\n\tSELECT c.*,c.svote/c.cvote AS vote,cc.name AS category\r\r\n\tFROM " . SECTION . "_catalog AS c\r\r\n\tLEFT JOIN " . SECTION . "_categories AS cc ON cc.id=c.idcat\r\r\n\t" . (!empty($where) ? " WHERE {$where}" : "") . "\r\r\n\tORDER BY {$sort}");
     while ($row = $pager->fetchRow()) {
         $row['link'] = shoplite_createItemLink($row['id'], SECTION);
         $row['catpath'] = "";
         if (empty($_GET['idcat']) || $childcats > 1) {
             $row['catpath'] .= getTreePath(SECTION . "_categories", $row['idcat']);
         }
         if (!empty($row['idcat1'])) {
             $row['catpath'] .= '<br>' . getTreePath(SECTION . "_categories", $row['idcat1']);
         }
         if (!empty($row['idcat2'])) {
             $row['catpath'] .= '<br>' . getTreePath(SECTION . "_categories", $row['idcat2']);
         }
         $row['vote'] = round($row['vote'], 2);
         if (A::$OPTIONS['useimages']) {
             $row['images'] = A::$DB->getAll("SELECT * FROM " . DOMAIN . "_images WHERE idsec=? AND iditem=? ORDER BY sort", array(SECTION_ID, $row['id']));
             $row['idimg'] = isset($row['images'][0]['id']) ? $row['images'][0]['id'] : 0;
         }
         if (A::$OPTIONS['usefiles']) {
             $row['files'] = A::$DB->getAll("SELECT * FROM " . DOMAIN . "_files WHERE idsec=? AND iditem=? ORDER BY sort", array(SECTION_ID, $row['id']));
             $row['idfile'] = isset($row['files'][0]['id']) ? $row['files'][0]['id'] : 0;
         }
         $items[] = $row;
     }
     $pager->free();
     $this->Assign("items", $items);
     $this->Assign("items_pager", $pager);
     $this->Assign("rows", $rows);
     $this->Assign("sort", $sort);
     $this->Assign("filter", !empty($filter));
     if (A::$OPTIONS['usecomments']) {
         $this->Assign("commbox", new A_CommentsEditor(SECTION . "_catalog"));
     }
     $rows = (int) A_Session::get(SECTION . "_rows2", 20);
     $idpays = A::$DB->getCol("SELECT DISTINCT pay FROM " . SECTION . "_orders ORDER BY pay");
     $pays = array();
     foreach ($idpays as $idpay) {
         $pays[$idpay] = function_exists('pay_getname') ? pay_getname($idpay) : "Наличные";
     }
     $pays = array_unique($pays);
     $this->Assign("pays", $pays);
     $where = array();
     if (isset($_GET['date'])) {
         if (!empty($_GET['from'])) {
             $where[] = "date>=" . (int) $_GET['from'];
         }
         if (!empty($_GET['to'])) {
             $where[] = "date<=" . (int) $_GET['to'];
         }
     }
     if (!empty($_GET['sum1'])) {
         $where[] = "sum>=" . (int) $_GET['sum1'];
     }
     if (!empty($_GET['sum2'])) {
         $where[] = "sum<=" . (int) $_GET['sum2'];
     }
     if (isset($_GET['status']) && $_GET['status'] >= 0) {
         $where[] = "status=" . (int) $_GET['status'];
     }
     if (isset($_GET['pay']) && $_GET['pay'] >= 0) {
         $where[] = "pay=" . (int) $_GET['pay'];
     }
     $where = implode(" AND ", $where);
     $orders = array();
     $pager2 = new A_Pager($rows);
     $pager2->tab = "orders";
     $pager2->query("SELECT * FROM " . SECTION . "_orders " . ($where ? "WHERE {$where}" : "") . " ORDER BY status,date DESC");
     while ($row = $pager2->fetchRow()) {
         $row['pay'] = function_exists('pay_getname') ? pay_getname($row['pay']) : "Наличные";
         $row['sum'] = round($row['sum'], 2);
         $orders[] = $row;
     }
     $pager2->free();
     $this->Assign("orders", $orders);
     $this->Assign("orders_pager", $pager2);
     $this->Assign("rows2", $rows);
     $this->Assign("optbox1", new A_OptionsBox("Внешний вид на сайте:", array("idgroup" => 1)));
     $this->Assign("optbox2", new A_OptionsBox("Файлы:", array("idgroup" => 2)));
     $this->Assign("optbox3", new A_OptionsBox("Заказ:", array("idgroup" => 3)));
     $this->Assign("optbox4", new A_OptionsBox("Комментирование и голосование:", array("idgroup" => 4)));
     $this->Assign("optbox5", new A_OptionsBox("Дополнительно:", array("idgroup" => 5)));
     $this->Assign("fieldsbox", new A_FieldsEditor(SECTION . "_catalog", array('tab' => 'opt', 'tab_opt' => 'fields'), false, true));
     $types = array('string' => 'Строка', 'int' => 'Целое число', 'float' => 'Дробное число', 'bool' => 'Логический (Да/Нет)', 'text' => 'Текст', 'select' => 'Значение из списка', 'mselect' => 'Множество значений из списка', 'mprice' => 'Модификатор цены', 'image' => 'Изображение', 'file' => 'Файл');
     $nums = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
     $cols = array();
     A::$DB->query("SELECT * FROM " . SECTION . "_cols ORDER BY sort");
     while ($row = A::$DB->fetchRow()) {
         $row['num'] = array_shift($nums);
         $row['type'] = isset($types[$row['type']]) ? $types[$row['type']] : $row['type'];
         $cols[] = $row;
     }
     A::$DB->free();
     $this->Assign("cols", $cols);
 }
Exemplo n.º 7
0
 /**
  * Формирование данных доступных в шаблоне.
  */
 function createData()
 {
     $this->Assign("maincontent", getTextOption(SECTION, 'content'));
     $types = array('string' => 'Строка', 'int' => 'Целое число', 'float' => 'Дробное число', 'bool' => 'Логический (Да/Нет)', 'date' => 'Дата', 'text' => 'Текст', 'format' => 'Форматированный текст', 'select' => 'Значение из списка', 'mselect' => 'Множество значений из списка', 'image' => 'Изображение', 'file' => 'Файл');
     $fields = array();
     A::$DB->query("SELECT * FROM " . DOMAIN . "_fields WHERE item='" . SECTION . "' ORDER BY sort");
     while ($row = A::$DB->fetchRow()) {
         $row['name'] = $row['name_' . DEFAULTLANG];
         $row['type'] = isset($types[$row['type']]) ? $types[$row['type']] : "";
         $fields[] = $row;
     }
     A::$DB->free();
     $this->Assign("fields", $fields);
     $arch = array();
     $pager = new A_Pager(20);
     $pager->tab = "arch";
     $pager->query("SELECT * FROM " . SECTION . "_arch ORDER BY date DESC");
     while ($row = $pager->fetchRow()) {
         $arch[] = $row;
     }
     $this->Assign("arch", $arch);
     $this->Assign("arch_pager", $pager);
     $this->Assign("optbox", new A_OptionsBox("", array("idgroup" => 1)));
 }
Exemplo n.º 8
0
 /**
  * Формирование данных доступных в шаблоне.
  */
 function createData()
 {
     $this->supportCached();
     $this->addCacheParam_Get('page');
     if ($this->month == 0) {
         $this->month = date('m');
     }
     if ($this->year == 0) {
         $this->year = date('Y');
     }
     $checkeds = !empty(A::$OPTIONS['sections']) ? unserialize(A::$OPTIONS['sections']) : array();
     $srows = $sections = array();
     foreach ($checkeds as $idsec) {
         if ($srow = A::$DB->getRowById($idsec, DOMAIN . "_sections")) {
             $section = DOMAIN . "_" . $srow['lang'] . "_" . $srow['name'];
             $sections[$section] = $srow['module'];
             $srows[$section] = $srow;
         }
     }
     $calendar = new A_Calendar($sections);
     $this->Assign("calendar", $calendar->getMonthHTML($this->day, $this->month, $this->year));
     if ($this->day > 0) {
         $date1 = mktime(0, 0, 0, $this->month, $this->day, $this->year);
         $date2 = mktime(23, 59, 59, $this->month, $this->day, $this->year);
         $this->Assign("date", $date1);
     } else {
         $date1 = mktime(0, 0, 0, $this->month, 1, $this->year);
         $date2 = mktime(0, 0, 0, $this->month + 1 > 12 ? 1 : $this->month + 1, 1, $this->month + 1 > 12 ? $this->year + 1 : $this->year) - 1;
         $this->Assign("date1", $date1);
         $this->Assign("date2", $date2);
     }
     $items = array();
     foreach ($sections as $section => $module) {
         $srows[$section]['caption'] = $srows[$section]['caption_' . LANG];
         $srows[$section]['link'] = getSectionLink($section);
         A::$DB->query("SELECT *,svote/cvote AS vote FROM {$section}_catalog WHERE date>={$date1} AND date<={$date2} AND active='Y' ORDER BY date");
         while ($row = A::$DB->fetchRow()) {
             $row['section'] = $section;
             $items[] = $row;
         }
         A::$DB->free();
     }
     $items = array_multisort_key($items, 'date');
     $pager = new A_Pager(A::$OPTIONS['rows']);
     $items = $pager->setItems($items);
     foreach ($items as $i => $row) {
         $section = $row['section'];
         $row['section'] = $srows[$section];
         $row['section_name'] = $srows[$section]['caption'];
         $row['section_link'] = $srows[$section]['link'];
         $row['link'] = catalog_createItemLink($row['id'], $section);
         $row['vote'] = round($row['vote'], 2);
         $row['category'] = getTreePath("{$section}_categories", $row['idcat']);
         $row['images'] = A::$DB->getAll("SELECT * FROM " . DOMAIN . "_images WHERE idsec=? AND iditem=? ORDER BY sort", array($srows[$section]['id'], $row['id']));
         $row['idimg'] = isset($row['images'][0]['id']) ? $row['images'][0]['id'] : 0;
         $row['files'] = A::$DB->getAll("SELECT * FROM " . DOMAIN . "_files WHERE idsec=? AND iditem=? ORDER BY sort", array($srows[$section]['id'], $row['id']));
         foreach ($row['files'] as $i => $data) {
             $row['files'][$i]['link'] = (LANG == DEFAULTLANG ? "" : "/" . LANG) . "/getfile/" . $data['id'] . "/" . $data['name'];
             $row['files'][$i]['size'] = sizestring($data['size']);
         }
         $row['idfile'] = isset($row['files'][0]['id']) ? $row['files'][0]['id'] : 0;
         if (!empty($row['tags'])) {
             $row['tags'] = A_SearchEngine::getInstance()->convertTags($row['tags']);
         }
         prepareValues($section, $row);
         $items[$i] = $row;
     }
     $this->Assign("items", $items);
     $this->Assign("items_pager", $pager);
     $this->AddNavigation(SECTION_NAME);
 }
Exemplo n.º 9
0
 /**
  * Формирование данных доступных в шаблоне страницы категории.
  */
 function CategoryPage()
 {
     if (empty($_GET['filter'])) {
         $this->supportCached();
         $this->addCacheParam_Get('filter');
         $this->addCacheParam_Get('page');
     }
     if (A::$OPTIONS['usetags']) {
         $this->category['tags'] = A_SearchEngine::getInstance()->convertTags($this->category['tags']);
     }
     $this->category = A::$OBSERVER->Modifier('fcategory_prepareValues', SECTION, $this->category);
     $this->Assign("category", $this->category);
     $categories = array();
     A::$DB->query("SELECT * FROM " . SECTION . "_categories WHERE idker={$this->idcat} AND active='Y' ORDER BY sort");
     while ($row = A::$DB->fetchRow()) {
         $row['link'] = catalog_createCategoryLink($row['id'], SECTION);
         $row['subcategories'] = array();
         A::$DB->query("SELECT * FROM " . SECTION . "_categories WHERE idker={$row['id']} AND active='Y' ORDER BY sort");
         while ($subrow = A::$DB->fetchRow()) {
             $subrow['link'] = catalog_createCategoryLink($subrow['id'], SECTION);
             $row['subcategories'][] = $subrow;
         }
         A::$DB->free();
         $categories[] = $row;
     }
     A::$DB->free();
     $this->Assign("categories", $categories);
     if (!empty($_REQUEST['sort'])) {
         A_Session::set(SECTION . '_csort', $_REQUEST['sort']);
     }
     if (!empty($_REQUEST['rows'])) {
         A_Session::set(SECTION . '_crows', $_REQUEST['rows']);
     }
     $sort = escape_order_string(A_Session::get(SECTION . '_csort', !empty(A::$OPTIONS['mysort']) ? A::$OPTIONS['mysort'] : A::$OPTIONS['sort']));
     $rows = (int) A_Session::get(SECTION . '_crows', A::$OPTIONS['crows']);
     $this->Assign("rows", $rows);
     $this->Assign("sort", $sort);
     $where = $this->frontfilter();
     $items = array();
     $pager = new A_Pager($rows);
     $pager->query("SELECT *,svote/cvote AS vote FROM " . SECTION . "_catalog WHERE idcat={$this->idcat} AND active='Y'{$where} ORDER BY {$sort}");
     while ($row = $pager->fetchRow()) {
         $row['link'] = catalog_createItemLink($row['id'], SECTION);
         $row['category'] = getTreePath(SECTION . "_categories", $row['idcat']);
         $row['vote'] = round($row['vote'], 2);
         if (A::$OPTIONS['useimages']) {
             $row['images'] = A::$DB->getAll("SELECT * FROM " . DOMAIN . "_images WHERE idsec=? AND iditem=? ORDER BY sort", array(SECTION_ID, $row['id']));
             $row['idimg'] = isset($row['images'][0]['id']) ? $row['images'][0]['id'] : 0;
         }
         if (A::$OPTIONS['usefiles']) {
             $row['files'] = A::$DB->getAll("SELECT * FROM " . DOMAIN . "_files WHERE idsec=? AND iditem=? ORDER BY sort", array(SECTION_ID, $row['id']));
             foreach ($row['files'] as $i => $data) {
                 $row['files'][$i]['link'] = (LANG == DEFAULTLANG ? "" : "/" . LANG) . "/getfile/" . $data['id'] . "/" . $data['name'];
                 $row['files'][$i]['size'] = sizestring($data['size']);
             }
             $row['idfile'] = isset($row['files'][0]['id']) ? $row['files'][0]['id'] : 0;
         }
         if (A::$OPTIONS['usetags']) {
             $row['tags'] = A_SearchEngine::getInstance()->convertTags($row['tags']);
         }
         prepareValues(SECTION, $row);
         $row = A::$OBSERVER->Modifier('catalog_prepareValues', SECTION, $row);
         $items[] = $row;
     }
     $pager->free();
     $this->Assign("items", $items);
     $this->Assign("items_pager", $pager);
     $this->AddNavigation(SECTION_NAME, getSectionLink(SECTION));
     $this->AddNavCategories($this->category['idker']);
     $this->AddNavigation($this->category['name']);
     $this->title = $this->category['name'] . (!empty($this->title) ? " - " . $this->title : "");
     $this->description = $this->category['description'];
 }
Exemplo n.º 10
0
$collection->add('eighteen', 'diez y ocho');
$collection->add('ninetten', 'diez y nueve');
$collection->add('twenty', 'viente');
$collection->add('twenty one', 'viente uno');
$collection->add('twenty two', 'viente dos');
$collection->add('twenty three', 'viente tres');
$collection->add('twenty four', 'viente cuatro');
$collection->add('twenty five', 'viente cinco');
$collection->add('twenty six', 'viente seis');
$collection->add('twenty seven', 'viente siete');
$collection->add('twenty eight', 'viente ocho');
$collection->add('twenty nine', 'viente nueve');
$collection->add('thirty', 'treinte');
$datasource = new A_Pager_Array($collection->toArray());
// temporary hack until pager supports Collections
$pager = new A_Pager($datasource);
$pager->setPageSize(3);
// create a request processor to set pager from GET parameters
$request = new A_Pager_Request($pager);
$request->process();
$template = new A_Template_Include('templates/standard_pagination.tpl');
// create a HTML writer to output
#$helper = new A_Pager_HTMLWriter($pager);
// get rows of data
$start_row = $pager->getStartRow();
$end_row = $pager->getEndRow();
$rows = $datasource->getRows($start_row, $end_row);
$helper = new PagerHelper($pager, $template, 2);
?>

<p><?php 
Exemplo n.º 11
0
 /**
  * Обработчик действия: Отдает таблицу с элементами текущего уровня.
  */
 function getGrid()
 {
     $form = new A_Form("module_pages_grid.tpl");
     $curdir = (int) A_Session::get(SECTION . "_cid", 0);
     $rows = (int) A_Session::get(SECTION . "_rows", isset($_COOKIE[SECTION . '_rows']) ? $_COOKIE[SECTION . '_rows'] : 20);
     $form->data['seo'] = getStructureByPlugin('seo');
     $form->data['title'] = $this->getPath($curdir);
     $form->data['pages'] = array();
     $pager = new A_Pager($rows, "gopage");
     $pager->query("SELECT * FROM " . SECTION . " WHERE idker={$curdir} ORDER BY sort");
     if ($curdir > 0 && ($row = A::$DB->getRowById($curdir, SECTION))) {
         $grow[0] = "&nbsp;";
         $grow[1] = AddImageButton("/templates/admin/images/back.gif", "indir({$row['idker']})", "Уровень выше", 16, 16);
         $grow[2] = AddClickText("...", "indir({$row['idker']})");
         $grow[3] = $grow[5] = $grow[6] = $grow[7] = $grow[8] = "&nbsp;";
         $grow[4] = 0;
         $form->data['sub'] = true;
         $form->data['pages'][] = $grow;
     } else {
         $form->data['sub'] = false;
     }
     $crows = 0;
     while ($row = $pager->fetchRow()) {
         $grow[0] = "<input type=\"checkbox\" id=\"checkp{$crows}\" name=\"checkpages[]\" value=\"{$row['id']}\"/>";
         $grow['link'] = pages_createItemLink($row['id'], SECTION);
         if ($row['type'] == 'dir') {
             $grow[1] = AddImage("/templates/admin/images/dir.gif", 16, 16);
             $grow[2] = AddLink(truncate($row['name'], 100), "javascript:indir({$row['id']})", "Войти в подраздел");
             $grow[3] = "&nbsp;";
             $grow[4] = $row['date'];
             $grow[5] = AddImageButton("/templates/admin/images/edit.gif", "geteditdirform({$row['id']})", "Редактировать", 16, 16);
             $grow[6] = AddImageButtonLink("/templates/admin/images/browse.gif", $grow['link'], "Просмотр на сайте", 16, 16, ' target="_blank"');
         } else {
             $grow[1] = AddImage("/templates/admin/images/text.gif", 16, 16);
             $grow[2] = AddLink(truncate($row['name'], 100), "javascript:geteditpageform({$row['id']})", "Редактировать");
             $grow[3] = "<a href=\"javascript:edittpl('{$row['template']}')\" title=\"Редактировать шаблон\">{$row['template']}</a>";
             $grow[4] = $row['date'];
             $grow[5] = "&nbsp;";
             $grow[6] = AddImageButtonLink("/templates/admin/images/browse.gif", $grow['link'], "Просмотр на сайте", 16, 16, ' target="_blank"');
         }
         $grow[7] = AddImageButton("/templates/admin/images/move.gif", "getmoveform({$row['id']})", "Переместить", 16, 16);
         $grow[8] = AddImageButton("/templates/admin/images/del.gif", "delitem({$row['id']},'{$row['urlname']}')", "Удалить", 16, 16);
         $grow['id'] = $row['id'];
         $grow['active'] = $row['active'];
         $form->data['pages'][] = $grow;
         $crows++;
     }
     $pager->free();
     $form->data['pager'] = $pager;
     $this->RESULT['html'] = $form->getContent();
 }
Exemplo n.º 12
0
 /**
  * Формирование данных доступных в шаблоне.
  */
 function createData()
 {
     if (!A_Session::is_set(SECTION . "_filter")) {
         $this->unFilter();
     }
     $categories = A::$DB->getAll("SELECT id,idker,name FROM " . SECTION . "_categories ORDER BY level,sort");
     $this->Assign("categories", $categories);
     if (!empty($_GET['idcat'])) {
         $this->Assign("category", A::$DB->getRowById($_GET['idcat'], SECTION . "_categories"));
         $idcat = (int) $_GET['idcat'];
         $childcats = array($idcat);
         getTreeSubItems(SECTION . "_categories", $idcat, $childcats);
         $where = "c.idcat IN(" . implode(",", $childcats) . ")";
         $this->Assign("childcats", $childcats = count($childcats));
     } else {
         $where = "";
     }
     if ($filter = $this->getFilter()) {
         $where = !empty($where) ? "{$where} AND {$filter}" : $filter;
     }
     $rows = (int) A_Session::get(SECTION . "_rows", isset($_COOKIE[SECTION . '_rows']) ? $_COOKIE[SECTION . '_rows'] : 10);
     $sort = escape_order_string(A_Session::get(SECTION . "_sort", isset($_COOKIE[SECTION . '_sort']) ? $_COOKIE[SECTION . '_sort'] : A::$OPTIONS['sort']));
     $items = array();
     $pager = new A_Pager($rows);
     $pager->tab = "items";
     $pager->query("\r\r\n\tSELECT c.*,c.svote/c.cvote AS vote,cc.name AS category\r\r\n\tFROM " . SECTION . "_catalog AS c\r\r\n\tLEFT JOIN " . SECTION . "_categories AS cc ON cc.id=c.idcat\r\r\n\t" . (!empty($where) ? " WHERE {$where}" : "") . "\r\r\n\tORDER BY {$sort}");
     while ($row = $pager->fetchRow()) {
         $row['link'] = catalog_createItemLink($row['id'], SECTION);
         $row['vote'] = round($row['vote'], 2);
         if (A::$OPTIONS['useimages']) {
             $row['images'] = A::$DB->getAll("SELECT * FROM " . DOMAIN . "_images WHERE idsec=? AND iditem=? ORDER BY sort", array(SECTION_ID, $row['id']));
             $row['idimg'] = isset($row['images'][0]['id']) ? $row['images'][0]['id'] : 0;
         }
         if (A::$OPTIONS['usefiles']) {
             $row['files'] = A::$DB->getAll("SELECT * FROM " . DOMAIN . "_files WHERE idsec=? AND iditem=? ORDER BY sort", array(SECTION_ID, $row['id']));
             $row['idfile'] = isset($row['files'][0]['id']) ? $row['files'][0]['id'] : 0;
         }
         $row['tags'] = A_SearchEngine::getInstance()->convertTags($row['tags']);
         if (empty($_GET['idcat']) || $childcats > 1) {
             $row['catpath'] = getTreePath(SECTION . "_categories", $row['idcat']);
         }
         $items[] = $row;
     }
     $pager->free();
     $this->Assign("items", $items);
     $this->Assign("items_pager", $pager);
     $this->Assign("treebox", new A_CategoriesTree("items"));
     if (A::$OPTIONS['usecomments']) {
         $this->Assign("commbox", new A_CommentsEditor(SECTION . "_catalog"));
     }
     $this->Assign("optbox1", new A_OptionsBox("Внешний вид на сайте:", array('idgroup' => 1)));
     $this->Assign("optbox2", new A_OptionsBox("Файлы:", array('idgroup' => 2)));
     $this->Assign("optbox3", new A_OptionsBox("Комментирование и голосование:", array('idgroup' => 3)));
     $this->Assign("optbox4", new A_OptionsBox("Дополнительно:", array('idgroup' => 4)));
     $this->Assign("fieldsbox", new A_FieldsEditor(SECTION . "_catalog", array('tab' => 'opt', 'tab_opt' => 'fields'), false, true));
     $this->Assign("rows", $rows);
     $this->Assign("sort", $sort);
     $this->Assign("filter", !empty($filter));
 }
Exemplo n.º 13
0
 function createData()
 {
     $pages = array();
     $pager = new A_Pager(20);
     $pager->query("SELECT * FROM " . STRUCTURE . " ORDER BY url");
     while ($row = $pager->fetchRow()) {
         $pages[] = $row;
     }
     $pager->free();
     $this->Assign("pages", $pages);
     $this->Assign("pages_pager", $pager);
 }
Exemplo n.º 14
0
<?php

include 'config.php';
include 'A/Pager.php';
include 'A/Pager/Array.php';
// initialize an array for testing
for ($i = 0; $i <= 75; ++$i) {
    $myarray[$i] = 'This is row ' . $i;
}
#$myarray = null;
// create a data object that has the interface needed by the Pager object
$datasource = new A_Pager_Array($myarray);
// create pager using values from datasource and request params
$pager = new A_Pager($datasource);
$pager->setRangeSize(5);
// create a request processor to set pager from GET parameters
$request = new A_Pager_Request($pager);
$request->process();
if ($pager->getLastRow() > 0) {
    // create a HTML writer to output
    $writer = new A_Pager_HTMLWriter($pager);
    // get rows of data
    $start_row = $pager->getStartRow();
    $end_row = $pager->getEndRow();
    $rows = $datasource->getRows($start_row, $end_row);
    // display the data
    echo '<table border="1">';
    $n = $start_row;
    foreach ($rows as $value) {
        echo '<tr>';
        echo '<td>' . $n++ . '.</td><td>' . $value . '</td>';
<?php

include 'config.php';
include 'A/Pager.php';
include 'A/Pager/Array.php';
// initialize an array to testing
for ($i = 43; $i <= 75; ++$i) {
    $myarray[$i] = 'This is row ' . $i;
}
// create a data object that has the interface needed by the Pager object
$datasource = new A_Pager_Array($myarray);
// create pager using values from datasource and request params
$pager = new A_Pager($datasource);
$pager->setRangeSize(5);
$request = new A_Pager_Request($pager);
$request->process();
$writer = new A_Pager_HTMLWriter($pager);
$start_row = $pager->getStartRow();
$end_row = $pager->getEndRow();
$pager2 = new A_Pager($datasource);
$pager2->setPageSize(5);
$pager2->setRangeSize(3);
$pager2->setPageParameter('page2');
$pager2->setPageSizeParameter('page_size2');
$pager2->setLastRowParameter('last_row2');
$request->__construct($pager2);
$request->process();
$writer2 = new A_Pager_HTMLWriter($pager2);
$start_row2 = $pager2->getStartRow();
$end_row2 = $pager2->getEndRow();
$writer->setExtraParameters($writer2->getParameters($pager2->getCurrentPage()));