Ejemplo n.º 1
0
/**
 * Функция загрузки списка из данных каталога.
 *
 * @param string $item Полный строковой идентификатор раздела.
 */
function catalog_loadlist($item)
{
    $rows = A::$DB->getAll("SELECT * FROM {$item}_catalog LIMIT 0,500");
    $rows = array_multisort_key($rows, 'name');
    $list = array();
    foreach ($rows as $row) {
        prepareValues($item, $row);
        $list[$row['id']] = $row;
    }
    return $list;
}
Ejemplo n.º 2
0
        $item = array('title' => $row['name'], 'link' => "http://" . DOMAINNAME . catalog_createItemLink($row['id'], $section), 'pubDate' => date("r", $row['date']), 'description' => strip_tags($row['description']));
        if (!empty($row['category'])) {
            $item['category'] = $row['category'];
        }
        $data['channel'][] = $item;
    }
    A::$DB->free();
} else {
    $items = array();
    $sections = getSectionsByModule('catalog');
    foreach ($sections as $section) {
        A::$DB->queryLimit("\r\r\n    SELECT a.*,c.name AS category\r\r\n    FROM {$section}_catalog AS a\r\r\n    LEFT JOIN {$section}_categories AS c ON c.id=a.idcat\r\r\n    WHERE a.active='Y'\r\r\n    ORDER BY date DESC", 0, $rssrow['rows']);
        while ($row = A::$DB->fetchRow()) {
            $row['link'] = catalog_createItemLink($row['id'], $section);
            $items[] = $row;
        }
        A::$DB->free();
    }
    $items = array_multisort_key($items, 'date', SORT_DESC);
    $items = array_slice($items, 0, $rssrow['rows']);
    foreach ($items as $row) {
        $item = array('title' => $row['name'], 'link' => "http://" . DOMAINNAME . $row['link'], 'pubDate' => date("r", $row['date']), 'description' => strip_tags($row['description']));
        if (!empty($row['category'])) {
            $item['category'] = $row['category'];
        }
        $data['channel'][] = $item;
    }
}
$serializer->serialize($data);
header("Content-type: text/xml; charset=utf-8");
die($serializer->getSerializedData());
Ejemplo n.º 3
0
 /**
  * Обработчик действия: Отдает форму пермещения элементов.
  */
 function getMovePagesForm()
 {
     if (empty($_POST['pages'])) {
         return;
     }
     $form = new A_Form("module_pages_cmove.tpl");
     $form->data['pages'] = array_values($_POST['pages']);
     $form->data['idker'] = A::$DB->getOne("SELECT idker FROM " . SECTION . " WHERE id=" . (int) current($form->data['pages']));
     $form->data['dirs'] = array();
     $cid = (int) A_Session::get(SECTION . "_cid", 0);
     $this->getDirs($form->data['dirs'], 0, $cid);
     $form->data['dirs'] = array_multisort_key($form->data['dirs'], "level_sort");
     if ($cid > 0 && count($form->data['dirs']) == 0) {
         $row = A::$DB->getRow("SELECT id,idker,name,level,sort FROM " . SECTION . " WHERE id={$cid}");
         $row['level_sort'] = sprintf("%03d_%03d", $row['level'], $row['sort']);
         $form->data['dirs'][] = $row;
     }
     if (count($form->data['dirs']) > 0) {
         $this->RESULT['html'] = $form->getContent();
     } else {
         $this->RESULT['html'] = AddLabel("Нет вариантов перемещения.");
     }
 }
Ejemplo n.º 4
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);
 }
Ejemplo n.º 5
0
 function SortName()
 {
     if (isset($_REQUEST['checkdata'])) {
         $values = array();
         $sort = array();
         foreach ($_REQUEST['checkdata'] as $id) {
             $row = A::$DB->getRowById($id, STRUCTURE);
             $sort[] = $row['sort'];
             $values[] = $row;
         }
         $values = array_multisort_key($values, 'name_' . LANG);
         foreach ($values as $i => $row) {
             A::$DB->execute("UPDATE " . STRUCTURE . " SET sort=" . $sort[$i] . " WHERE id=" . $row['id']);
         }
     }
     return true;
 }