Viewing file: module.php (10.09 KB) -rwxrwxrwx Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<? class Actual { var $UserMode = true; var $AdminMode = true; var $SearchMode = true; var $PanelMode = true; var $AdminAsynchMode = true; var $Table; var $ClassName = 'Actual'; var $Photomanager; var $Directory; function Actual() { $this->Directory = dirname(__FILE__); $this->Table = new AMTable2('AMCMS_actual'); $this->Table->Module($this->ClassName); $this->Table->AddIndexField("actual_id"); $this->Table->AddPositionField("actual_position"); $params['main'] = GetParam("ActualMainPhotoSize"); $params['text']['small'] = GetParam("ActualSmallPhotoSize"); $params['text']['big'] = GetParam("ActualBigPhotoSize"); $this->Photomanager = new AMPhotomanager($params); } function User() { global $ulang, $ULANG; if (isset($_GET['actual_id'])) { $row = $this->Table->GetRowById($_GET['actual_id']); if ($row == null) return; $modName = GetParam('Module'.$this->ClassName, $ulang); $modArchiveName = GetParam("Module{$this->ClassName}Archive", $ulang); $smarty = GetUserSmarty($this->ClassName); $smarty->assign('row', $row); $smarty->assign('Photomanager', $this->Photomanager); $smarty->assign('mod', $this->ClassName); $navigator = new AMNavigator(); if ($row['actual_type'] == '1') $navigator->AddLink($modName, "/actual"); else { $year = DateExplode($row['actual_date']); $navigator->AddLink($modArchiveName, "/actual/archive/".$year[0]); } $navigator->AddLink($row['actual_title_'.$ulang], "/actual/{$row['actual_id']}"); $result['Title'] = $row['actual_title_'.$ulang]; $result['Content'] = $smarty->fetch("user-page.tpl"); $result['GlobalParams']['Navigator'] = $navigator->Fetch(); $result['GlobalParams']['PageTitle'] = $navigator->GetTitleForPage(); $result['Module'] = $this->ClassName; $result['Print'] = true; return $result; } if (isset($_GET['list'])) { $year = 0; if ($_GET['list'] >= GetParam("StartYear") && $_GET['list'] <= GetCurrentYear()) $year = $_GET['list']; if ($year != 0) { $date1 = $year."-01-01"; $date2 = ($year+1)."-01-01"; $rows = $this->Table->GetRows("actual_position DESC", array("actual_type = '2'", "actual_date >= '$date1'", "actual_date < '$date2'")); } else $rows = $this->Table->GetRows("actual_position DESC", array("actual_type = '1'")); $smarty = GetUserSmarty($this->ClassName); $smarty->assign('rows', $rows); $smarty->assign('Photomanager', $this->Photomanager); $smarty->assign('mod', $this->ClassName); $result['Content'] = $smarty->fetch("user-year-form.tpl"). $smarty->fetch("user-row.tpl"); $modName = GetParam('Module'.$this->ClassName, $ulang); $modArchiveName = GetParam("Module{$this->ClassName}Archive", $ulang); $navigator = new AMNavigator(); if ($year == 0) $navigator->AddLink($modName, "/actual"); else { $year = DateExplode($row['actual_date']); $navigator->AddLink($modArchiveName, "/actual/archive/".$year[0]); } $result['GlobalParams']['Navigator'] = $navigator->Fetch(); $result['GlobalParams']['PageTitle'] = $navigator->GetTitleForPage(); $result['Module'] = $this->ClassName; $result['Print'] = true; $result['Title'] = ($year == 0) ? $modName : $modArchiveName; return $result; } } function Menu() { global $ALANG; return array( array('title' => $ALANG['ActualMenuAdd'], 'link' => '?mod='.$this->ClassName.'&add'), array('title' => $ALANG['ActualMenuList'], 'link' => '?mod='.$this->ClassName.'&list'), array('title' => $ALANG['ActualMenuArchive'], 'link' => '?mod='.$this->ClassName.'&archive') ); } function Admin() { global $ALANG, $DefaultAdminLanguage, $_LANG_ID; $smarty = GetAdminSmarty($this->ClassName); if (isset($_GET['list'])) { $fields = array("actual_date", "actual_title_".GetParam("DefaultLanguage")); $captions = array($ALANG['Actual_actual_date'], $ALANG['Actual_actual_title']); $conditions = "actual_type = '1'"; $order = "actual_position DESC"; $links = array("checkbox", "delete", "edit", "toarhive"); $multiple = array("delete", "toarhive"); $params = array("sortable" => "yes", "id" => "actual"); $html = $this->Table->GetAdminTable($fields, $captions, $conditions, $order, $links, $multiple, $params); $result['Title'] = $ALANG['ActualList']; $result['Content'] = $html; return $result; } if (isset($_GET['archive'])) { $year = $_GET['year']; if ($year < 2000) $year = GetCurrentYear(); if (isset($_POST['year'])) $year = $_POST['year']; $smarty = GetAdminSmarty($this->ClassName); $smarty->assign("year", $year); $date1 = "{$year}-01-01"; $date2 = ($year + 1)."-01-01"; $fields = array("actual_date", "actual_title_".GetParam("DefaultLanguage")); $captions = array($ALANG['Actual_actual_date'], $ALANG['Actual_actual_title']); $conditions = array("actual_type = '2'", "actual_date >= '{$date1}'", "actual_date < '{$date2}'"); $order = "actual_position DESC"; $multiple = array("delete", "fromarhive"); $links = array("checkbox", "delete", "edit", "fromarhive"); $params = array("sortable" => "yes", "id" => "actual"); $html = $smarty->fetch("year.tpl").$this->Table->GetAdminTable($fields, $captions, $conditions, $order, $links, $multiple, $params); $result['Title'] = $ALANG['ActualArchive']; $result['Content'] = $html; return $result; } if (isset($_GET['add'])) { if (isset($_POST['oper']) && ($_POST['oper'] == 'add')) { $_POST['actual_date_of_creation'] = GetCurrentDateAndTime(); $_POST['actual_date_of_edition'] = GetCurrentDateAndTime(); $id = $this->Table->Insert($_POST); $this->Photomanager->Run($_POST, $_FILES, $this->ClassName, ($this->Table->IndexField."=".$id)); header("Location: ?mod=".$this->ClassName."&list"); } $smarty = GetAdminSmarty($this->ClassName); foreach($_POST as $key => $value) $smarty->assign($key, $value); $smarty->assign('oper', 'add'); $smarty->assign('actual_show_title', 'Y'); $smarty->assign('actual_show_read_more_link', 'Y'); $smarty->assign('actual_show_date', 0); $smarty->assign('actual_date', GetCurrentDateAndTime()); $photo_admin_table1 = $this->Photomanager->GetAdminTable( $this->ClassName, ($this->Table->IndexField."=".$id),'main'); $photo_admin_table2 = $this->Photomanager->GetAdminTable( $this->ClassName, ($this->Table->IndexField."=".$id),'photos'); $smarty->assign('photo_admin_table1', $photo_admin_table1); $smarty->assign('photo_admin_table2', $photo_admin_table2); $result['Title'] = $ALANG['ActualAddition']; $result['Content'] = $smarty->fetch('actual.tpl'); return $result; } if (isset($_GET['edit']) && isset($_GET['actual_id'])) { $id = $_GET['actual_id']; $row = $this->Table->GetRowById($id); if (isset($_POST['oper']) && ($_POST['oper'] == 'edit')) { $_POST['actual_date_of_edition'] = GetCurrentDateAndTime(); $this->Table->Update($_POST, $id); $this->Photomanager->Run($_POST, $_FILES, $this->ClassName, ($this->Table->IndexField."=".$id)); if ($row['actual_type'] == 1) header("Location: ?mod=".$this->ClassName."&list"); else header("Location: ?mod=".$this->ClassName."&archive&year=".$_POST['actual_date_year']); } foreach($row as $key => $value) $smarty->assign($key, $value); $smarty->assign('oper', 'edit'); $photo_admin_table1 = $this->Photomanager->GetAdminTable( $this->ClassName, ($this->Table->IndexField."=".$id),'main'); $photo_admin_table2 = $this->Photomanager->GetAdminTable( $this->ClassName, ($this->Table->IndexField."=".$id),'photos'); $smarty->assign('photo_admin_table1', $photo_admin_table1); $smarty->assign('photo_admin_table2', $photo_admin_table2); $result['Title'] = $ALANG['ActualEdition']; $result['Content'] = $smarty->fetch('actual.tpl'); return $result; } } function Panel() { global $ULANG, $ulang; $rows = $this->Table->GetRows("actual_position DESC", array("actual_type = '1'")); $smarty = GetUserSmarty($this->ClassName); $smarty->assign('rows', $rows); $smarty->assign('Photomanager', $this->Photomanager); $smarty->assign('mod', $this->ClassName); $result[$this->ClassName] = array( 'Title' => GetParam("Module".$this->ClassName."Panel", $ulang), 'Content' => $smarty->fetch("user-row.tpl"), 'Module' => $this->ClassName, /* 'Link' => array("Address" => "/actual", "Title" => $ULANG['ActualArchiveLinkTitle'], "Class" => "archive")*/); return $result; } function Search($words) { global $ulang, $ULANG; $fields = array("actual_title_".$ulang, "actual_short_text_".$ulang, "actual_description_".$ulang, "actual_text_".$ulang, "actual_keywords_".$ulang); $rows = SearchOnSite($words, array('actual_title_'.$ulang, "actual_date_of_creation"), 'actual_id', $fields, 'AMCMS_actual'); $searchRows = array(); if ($rows) foreach($rows as $key => $value) { $row['Module'] = $this->ClassName; $row['Date'] = $value['actual_date_of_creation']; $row['Title'] = $value['actual_title_'.$ulang]; $row['Link'] = $row['NewWindowLink'] = "/actual/{$value['actual_id']}"; $row['Relev'] = $value['relev']; $searchRows [] = $row; } return $searchRows; } function AdminAsynch() { global $DefaultAdminLanguage, $ALANG; if (isset($_POST['oper']) && ($_POST['oper'] == 'toarchive')) { $id = $_POST['id']; $row['actual_date_of_archiving'] = GetCurrentDateAndTime(); $row['actual_type'] = 2; $this->Table->Update($row, $id); $res["status"] = "ok"; $res["code"] = $id; echo json_encode($res); die; } if (isset($_POST['oper']) && ($_POST['oper'] == 'fromarchive')) { $id = $_POST['id']; $row['actual_date_of_archiving'] = ""; $row['actual_type'] = 1; $this->Table->Update($row, $id); $res["status"] = "ok"; $res["code"] = $id; echo json_encode($res); die; } $this->Table->Run($_POST); } }
$Modules ['Actual'] = new Actual(); ?>
|