User: xujiantao Date: 13-11-19 Time: 20:07
Inheritance: extends BaseModel
Ejemplo n.º 1
0
 public function actionDel()
 {
     $del = new NewsModel();
     $del->id = [':id' => $_POST['id']];
     $del->del();
     header("Location: /index.php");
 }
Ejemplo n.º 2
0
 public function actionSearch()
 {
     $search = new NewsModel();
     $search->colummn = $_POST['column'];
     $search->value = $_POST['value'];
     $view = new View();
     $view->items = $search->findByColumn($search->colummn, $search->value);
     $view->display('search.php');
 }
Ejemplo n.º 3
0
 public function actionFindByColumn()
 {
     $value = $_POST['title'];
     $findNews = new NewsModel();
     $find = $findNews->findByColumn('title', $value);
     $view = new View();
     $view->findNews = $find;
     $view->display('test.php');
 }
Ejemplo n.º 4
0
 function news_one_show($id = null)
 {
     $one_news_model = new NewsModel();
     $one_news = $one_news_model->get_one_news($id);
     //        var_dump($news);die;
     $view = new View();
     $view->set_file_name('admin_news_one');
     $params = array('news' => $one_news);
     $view->show($params);
 }
Ejemplo n.º 5
0
 function load()
 {
     parent::load();
     if (intval($this->data['new_gnews']) == 0 || $this->player->isSpy) {
         $this->redirect('village1.php');
         return null;
     }
     $m = new NewsModel();
     $this->siteNews = $m->getGlobalSiteNews();
     $m->dispose();
 }
Ejemplo n.º 6
0
 public function load()
 {
     parent::load();
     if (intval($this->data['new_gnews']) == 0 || $this->player->isSpy) {
         $this->redirect("village1.php");
     } else {
         $m = new NewsModel();
         $this->siteNews = $m->getGlobalSiteNews();
         $m->dispose();
     }
 }
Ejemplo n.º 7
0
    function viewNewsPage($user_id)
    {
        $htmlPage = "";
        $user_id = (int) $user_id;
        $newsModel = new NewsModel();
        $newsView = new NewsView();
        $aNewsSubscribe = $newsModel->getNewsSubscribeByUserId($user_id);
        if (!$aNewsSubscribe) {
            $aNewsTree = $newsView->getAllNewsTree();
            $isOnlySubscribeNewsTree = false;
        } else {
            $aNewsTree = $newsView->getNewsTreeByListNewsSubscribe($aNewsSubscribe);
            $isOnlySubscribeNewsTree = true;
        }
        $htmlPage = '<ul class="content-preview-list">';
        foreach ($aNewsTree as $newsTree) {
            /*    $newsCount = $newsView -> getNewsCountByNewsTreeId($newsTree['id'], $user_id, $isOnlySubscribeNewsTree);
                    if ($newsCount < 1) continue;
                    $htmlPage .= '
                 	<!-- Категория -->
                 	<div class="block_ee1"><div class="block_ee2"><div class="block_ee3"><div class="block_ee4">
                 		<div class="block_title">
                 			<div class="block_title_left">
                 			   <h2>
                 			   '.$newsView->ShowNewsTreeBreadCrumbByNewsTreeId($newsTree['id'], false).' (<a href="'.Project::getRequest()->createUrl('News', 'News', null, false).'/shownow:allnews/filterNewsTree:'.$newsTree['id'].'">все новости ['.$newsCount.']</a>)
                 			   </h2>
                 			</div>
                 			<div class="block_title_right"><img src="'.$this -> image_url.'close.png" width="21" height="24" onclick="ShowOrHide(this, \'rss_cat_n'.$newsTree['id'].'\')" style="cursor: pointer;" /></div>
                 		</div>'; */
            $htmlPage .= '<li class="expanded-view">
						<h3><a href="#">МИД России: Тбилиси выдает желаемое за действительное <img src="assets/i/temp/temp.1.jpg" alt="МИД России: Тбилиси выдает желаемое за действительное" /></a></h3>
						<p>В Москве опровергают сообщения о том, что якобы минувшим днем российские войска в Южной Осетии вели огонь по грузинской территории... <a href="#">»</a></p>
						<div class="meta">
							<span class="auth">Вести.Ru</span>
							<span class="date">20 минут назад</span>
						</div>
					</li>';
            /*		$htmlPage .= '<div id="rss_cat_n'.$newsTree['id'].'">'.
                          $newsView->ShowNewsListPreviewByNewsTreeId($newsTree['id'], 'full', $user_id, 4, array(), $isOnlySubscribeNewsTree).'
               		   <div class="rmb14"></div>
               		</div>
               
               	</div></div></div></div>
               	<!-- /Категория -->
                  '; */
        }
        $htmlPage .= '</ul>';
        return $htmlPage;
    }
Ejemplo n.º 8
0
 public function actionDelete()
 {
     if (empty($_GET['id'])) {
         $message = 'There is no such news ';
         $this->errMSG($message);
     } else {
         $article = new NewsModel();
         $article->id = $_GET['id'];
         if ($article->deleteRow()) {
             $this->actionAll();
         } else {
             $this->errMSG('Fail Deleting a File');
         }
     }
 }
 public function checkLog($ptable, $tstamp, $item)
 {
     switch ($ptable) {
         case 'tl_article':
             $objArticle = \ArticleModel::findById($item['pid']);
             $objPage = \PageModel::findById($objArticle->pid);
             $item['page'] = $objPage->title;
             $item['showUrl'] = $this->generateFrontendUrl($objPage->row(), '');
             break;
         case 'tl_news':
             $objNews = \NewsModel::findById($item['pid']);
             $objArchive = \NewsArchiveModel::findById($objNews->pid);
             $objPage = \PageModel::findById($objArchive->jumpTo);
             $item['page'] = $objNews->headline;
             $item['showUrl'] = ampersand($this->generateFrontendUrl($objPage->row(), (\Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/' : '/items/') . (!\Config::get('disableAlias') && $objNews->alias != '' ? $objNews->alias : $objNews->id)));
             break;
         case 'tl_calendar':
             break;
         case 'tl_faq':
             $objFAQ = \FaqModel::findById($item['id']);
             $objCategory = \FaqCategoryModel::findById($item['pid']);
             $objPage = \PageModel::findById($objCategory->jumpTo);
             $item['htmlElement'] = '<div class="ce_faq"><h1>' . $objFAQ->question . '</h1>' . $objFAQ->answer . '</div>';
             $item['page'] = $objCategory->title;
             $item['title'] = $objFAQ->question;
             $item['showUrl'] = ampersand($this->generateFrontendUrl($objPage->row(), (\Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/' : '/items/') . (!\Config::get('disableAlias') && $objFAQ->alias != '' ? $objFAQ->alias : $objFAQ->id)));
             break;
     }
     return $item;
 }
Ejemplo n.º 10
0
 /**
  * 初始化测栏数据
  *
  */
 private function FormatSildeNews($type = 0)
 {
     //最新
     $this->assign('silde_new_news', $this->_news->getList(10, $type, '', 'news_id desc', false));
     //热门
     $this->assign('silde_hot_news', $this->_news->getList(10, $type, '', 'hits desc', false));
 }
 /**
  * Generate the list in related categories mode
  *
  * Use the categories of the current news item. The module must be
  * on the same page as news reader module.
  *
  * @return string
  */
 protected function generateRelated()
 {
     // Set the item from the auto_item parameter
     if (!isset($_GET['items']) && $GLOBALS['TL_CONFIG']['useAutoItem'] && isset($_GET['auto_item'])) {
         \Input::setGet('items', \Input::get('auto_item'));
     }
     // Return if there is no item specified
     if (!\Input::get('items')) {
         return '';
     }
     $this->news_archives = $this->sortOutProtected(deserialize($this->news_archives));
     // Return if there are no archives
     if (!is_array($this->news_archives) || empty($this->news_archives)) {
         return '';
     }
     $news = \NewsModel::findPublishedByParentAndIdOrAlias(\Input::get('items'), $this->news_archives);
     // Return if the news item was not found
     if ($news === null) {
         return '';
     }
     $GLOBALS['NEWS_FILTER_CATEGORIES'] = false;
     $GLOBALS['NEWS_FILTER_DEFAULT'] = deserialize($news->categories, true);
     $GLOBALS['NEWS_FILTER_EXCLUDE'] = array($news->id);
     return parent::generate();
 }
Ejemplo n.º 12
0
 /**
  * Generate the module
  */
 protected function compile()
 {
     global $objPage;
     $this->Template->articles = '';
     $this->Template->referer = 'javascript:history.go(-1)';
     $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack'];
     // Get the news item
     $objArticle = \NewsModel::findPublishedByParentAndIdOrAlias(\Input::get('items'), $this->news_archives);
     if ($objArticle === null) {
         // Do not index or cache the page
         $objPage->noSearch = 1;
         $objPage->cache = 0;
         // Send a 404 header
         header('HTTP/1.1 404 Not Found');
         $this->Template->articles = '<p class="error">' . sprintf($GLOBALS['TL_LANG']['MSC']['invalidPage'], \Input::get('items')) . '</p>';
         return;
     }
     $arrArticle = $this->parseArticle($objArticle);
     $this->Template->articles = $arrArticle;
     // Overwrite the page title
     if ($objArticle->headline != '') {
         $objPage->pageTitle = strip_insert_tags($objArticle->headline);
     }
     // Overwrite the page description
     if ($objArticle->teaser != '') {
         $objPage->description = $this->prepareMetaDescription($objArticle->teaser);
     }
     // HOOK: comments extension required
     if ($objArticle->noComments || !in_array('comments', $this->Config->getActiveModules())) {
         $this->Template->allowComments = false;
         return;
     }
     $objArchive = $objArticle->getRelated('pid');
     $this->Template->allowComments = $objArchive->allowComments;
     // Adjust the comments headline level
     $intHl = min(intval(str_replace('h', '', $this->hl)), 5);
     $this->Template->hlc = 'h' . ($intHl + 1);
     $this->import('Comments');
     $arrNotifies = array();
     // Notify the system administrator
     if ($objArchive->notify != 'notify_author') {
         $arrNotifies[] = $GLOBALS['TL_ADMIN_EMAIL'];
     }
     // Notify the author
     if ($objArchive->notify != 'notify_admin') {
         if (($objAuthor = $objArticle->getRelated('author')) !== null && $objAuthor->email != '') {
             $arrNotifies[] = $objAuthor->email;
         }
     }
     $objConfig = new \stdClass();
     $objConfig->perPage = $objArchive->perPage;
     $objConfig->order = $objArchive->sortOrder;
     $objConfig->template = $this->com_template;
     $objConfig->requireLogin = $objArchive->requireLogin;
     $objConfig->disableCaptcha = $objArchive->disableCaptcha;
     $objConfig->bbcode = $objArchive->bbcode;
     $objConfig->moderate = $objArchive->moderate;
     $this->Comments->addCommentsToTemplate($this->Template, $objConfig, 'tl_news', $objArticle->id, $arrNotifies);
 }
Ejemplo n.º 13
0
 public function actionFormDeletenews()
 {
     $id = $_GET['id'];
     $news = NewsModel::getOneById($id);
     $view = new View();
     $view->item = $news;
     $view->display('admin/deletenews.php');
 }
Ejemplo n.º 14
0
 /**
  * Modify the palette according to the checkboxes selected
  *
  * @param mixed
  * @param DataContainer
  *
  * @return mixed
  */
 public function modifyPalettes()
 {
     $objNews = \NewsModel::findById($this->Input->get('id'));
     $dc =& $GLOBALS['TL_DCA']['tl_news'];
     if (!$objNews->addPreviewImage) {
         $dc['subpalettes']['addYouTube'] = str_replace('imgHeader,imgPreview,addPlayButton,', '', $dc['subpalettes']['addYouTube']);
     }
 }
Ejemplo n.º 15
0
 public function getNewsIntro()
 {
     $news_items = NewsModel::getLatestNews(NEWS_ITEMS);
     $random_shot = ScreenshotsModel::getRandomScreenshot();
     $this->addCSSFiles(array('intro.css', 'news.css', '../javascripts/slimbox/css/slimbox2.css'));
     $this->addJSFiles(array('jquery-1.3.2.min.js', 'slimbox/js/slimbox2.js', 'introduction.js'));
     return $this->renderPage(array('title' => 'Home', 'content_title' => 'Latest Developments', 'show_intro' => true, 'news_items' => $news_items, 'news_archive_link' => true, 'random_shot' => $random_shot), $this->_template);
 }
Ejemplo n.º 16
0
 public function index()
 {
     // get medal list
     $medal_model = new MedalModel();
     $this->assign('medals', $medal_model->select());
     // get all the numbers
     $map_data_model = D('MapData');
     $ngo_num_record = $map_data_model->query_number(array('type' => 'exngo'));
     $csr_num_record = $map_data_model->query_number(array('type' => 'excsr'));
     $case_num_record = $map_data_model->query_number(array('type' => 'case'));
     $this->assign('ngo_num', $ngo_num_record);
     $this->assign('csr_num', $csr_num_record);
     $this->assign('case_num', $case_num_record);
     $news_model = new NewsModel();
     $news_list = $news_model->limit(20)->select();
     $this->assign('news_list', $news_list);
     $this->display();
 }
Ejemplo n.º 17
0
 public static function modifyPalette()
 {
     $arrDca =& $GLOBALS['TL_DCA']['tl_news'];
     if (($objNews = \NewsModel::findByPk(\Input::get('id'))) !== null && $objNews->useMemberAuthor) {
         $arrDca['palettes']['default'] = str_replace(',author', ',', $arrDca['palettes']['default']);
     } else {
         $arrDca['palettes']['default'] = str_replace(',memberAuthor', ',', $arrDca['palettes']['default']);
     }
 }
Ejemplo n.º 18
0
 public static function generateAlias()
 {
     if (TL_MODE == 'FE') {
         if (($objNews = \NewsModel::findByPk(\Input::get('id'))) !== null && $objNews->type == 'pinboard') {
             $objNews->alias = \HeimrichHannot\Haste\Dca\General::generateAlias($objNews->alias, $objNews->id, 'tl_news', $objNews->headline);
             $objNews->save();
         }
     }
 }
Ejemplo n.º 19
0
 public function load()
 {
     parent::load();
     if ($this->data['player_type'] != PLAYERTYPE_ADMIN) {
         exit(0);
     } else {
         $m = new NewsModel();
         $this->saved = FALSE;
         if ($this->isPost() && isset($_POST['news'])) {
             $this->siteNews = $_POST['news'];
             $this->saved = TRUE;
             $m->setGlobalPlayerNews($this->siteNews);
         } else {
             $this->siteNews = $m->getGlobalSiteNews();
         }
         $m->dispose();
     }
 }
Ejemplo n.º 20
0
 public function actionOne()
 {
     $id = $_GET['id'];
     $item = NewsModel::findOneByPk($id);
     if (empty($item)) {
         throw new E404Exception('Нет такой новости');
     }
     $view = new View();
     $view->item = $item;
     $view->display('news/one.php');
 }
Ejemplo n.º 21
0
 /**
  * get all news items by page pid
  * @param array
  * @param integer
  * @param boolean
  * @return array
  */
 public static function getAllNews($arrPages, $intRoot = 0, $blnIsSitemap = false)
 {
     $arrRoot = array();
     if ($intRoot > 0) {
         $arrRoot = \Database::getInstance()->getChildRecords($intRoot, 'tl_page');
     }
     $time = time();
     $arrProcessed = array();
     // Get all news archives
     $objArchive = \NewsArchiveModel::findByProtected('');
     // Walk through each archive
     if ($objArchive !== null) {
         while ($objArchive->next()) {
             // Skip news archives without target page
             if (!$objArchive->jumpTo) {
                 continue;
             }
             // Skip news archives outside the root nodes
             if (!empty($arrRoot) && !in_array($objArchive->jumpTo, $arrRoot)) {
                 continue;
             }
             // Get the URL of the jumpTo page
             if (!isset($arrProcessed[$objArchive->jumpTo])) {
                 $objParent = \PageModel::findWithDetails($objArchive->jumpTo);
                 // The target page does not exist
                 if ($objParent === null) {
                     continue;
                 }
                 // The target page has not been published (see #5520)
                 if (!$objParent->published || $objParent->start != '' && $objParent->start > $time || $objParent->stop != '' && $objParent->stop < $time) {
                     continue;
                 }
                 // The target page is exempt from the sitemap (see #6418)
                 if ($blnIsSitemap && $objParent->sitemap == 'map_never') {
                     continue;
                 }
                 // Set the domain (see #6421)
                 // $domain = ($objParent->rootUseSSL ? 'https://' : 'http://') . ($objParent->domain ?: \Environment::get('host')) . TL_PATH . '/';
                 // Generate the URL
                 // $arrProcessed[$objArchive->jumpTo] = $domain . $this->generateFrontendUrl($objParent->row(), ((\Config::get('useAutoItem') && !\Config::get('disableAlias')) ?  '/%s' : '/items/%s'), $objParent->language);
             }
             $strUrl = $arrProcessed[$objArchive->jumpTo];
             // Get the items
             $objArticle = \NewsModel::findPublishedDefaultByPid($objArchive->id);
             if ($objArticle !== null) {
                 while ($objArticle->next()) {
                     $arrPages[] = $objArticle->id;
                 }
             }
         }
     }
     return $arrPages;
 }
 protected function compile()
 {
     $objArticle = \NewsModel::findPublishedByParentAndIdOrAlias(\Input::get('items'), $this->news_archives);
     $objAuthor = \UserModel::findById($objArticle->author);
     if ($objAuthor->addImage) {
         $objFile = \FilesModel::findByUuid($objAuthor->userSRC);
         $this->addImageToTemplate($this->Template, array('singleSRC' => $objFile->path, 'alt' => 'Screenshot of Music Academy', 'size' => $this->imgSize));
     }
     foreach ($objAuthor->row() as $k => $v) {
         $this->Template->{$k} = $v;
     }
 }
Ejemplo n.º 23
0
 public function actionAll()
 {
     $art = NewsModel::findOneByColumn('title', 'Новый заголовок');
     $art->title = 'Новый заголовок 123';
     $art->save();
     die;
     /*
     $news = News::getAll();
     $view = new View();
     $view->items = $news;
     $view->display('news/all.php');
     */
 }
Ejemplo n.º 24
0
 public function actionAll()
 {
     $article = new NewsModel();
     $article->title = 'ывапыв';
     $article->text = 'пыврыв!';
     $article->insert();
     die;
     /*
             $news=News::getAll();
             $view=new View();
     
             //$view->assign('items',$news);
             //$view->assign('items',$news);
             $view->items=$news;
     
             //foreach ($view as $k=>$v){
             //    echo $k;
             //}
     
     
             $view->display('news/all.php');*/
 }
Ejemplo n.º 25
0
 public static function addMediaToTemplate($objTemplate, $arrData, $objConfig)
 {
     $objItem = (object) $arrData;
     $objModel = \NewsModel::findByPk($objItem->id);
     if ($objModel === null) {
         return '';
     }
     $objModel->customTpl = $objConfig->media_template ? $objConfig->media_template : static::$strTemplate;
     $objModel->imgSize = $objConfig->imgSize;
     $objModel->media_posterSRC = $objConfig->media_posterSRC;
     $objElement = new ContentNewsMedia($objModel);
     $objTemplate->mediaPlayer = $objElement->generate();
 }
Ejemplo n.º 26
0
 public function actionAll()
 {
     $article = new NewsModel();
     $article = NewsModel::findOneByColumn('title', 'First News');
     //        $article->id = ['4'];
     //        $article->title = 'Hi 222222!';
     //        $article->text = 'Hi World 2!';
     $article->delete();
     //        $news = News::getAll();
     //        $view = new View();
     //        $view->items = $news;
     //        $view->display('/../views/news/all.php');
 }
Ejemplo n.º 27
0
 public function index()
 {
     $feed = $_GET['f'];
     if ($feed == 'atom') {
         $template = $this->_template_atom;
     } else {
         $template = $this->_template_rss;
     }
     $news_items = NewsModel::getLatestNews(NEWS_ITEMS, true);
     header('Content-Type: text/xml; charset=UTF-8');
     print $this->fetch($template, array('news' => $news_items));
     return True;
 }
Ejemplo n.º 28
0
 public function actionOne()
 {
     $id = $_GET['id'];
     $item = NewsModel::findOneByPk($id);
     if (!empty($item)) {
         $view = new View();
         $view->item = $item;
         $view->display('news/one.php');
     } else {
         $e_message = 'Page not found: Пустой результат выборки';
         $e_code = 1.1;
         throw new E404Exception($e_message, $e_code);
     }
 }
 /**
  * generateFrontendUrl Hook
  * checks if the parameter for the generated URL is a news alias and rewrites the URL without its page alias
  * @param array page data
  * @param string URL parameters
  * @param string current URL
  */
 public function generateFrontendUrl($arrRow, $strParams, $strUrl)
 {
     // no params, no action
     if (!$strParams) {
         return $strUrl;
     }
     // check if param is a news alias
     if (($objNews = \NewsModel::findByAlias(ltrim($strParams, '/'))) !== null) {
         // build url using only the news alias
         $strUrl = self::buildUrl($arrRow, $objNews->alias);
     }
     // return the url
     return $strUrl;
 }
Ejemplo n.º 30
0
 /**
  *
  */
 public function add()
 {
     $view = new View();
     $view->header = "Добавить новость";
     $view->render('addnews.html');
     //        include __DIR__ . '/../views/addnews.html';
     if (isset($_POST['title']) && !empty($_POST['title'])) {
         if (isset($_POST['text']) && !empty($_POST['text'])) {
             $title = $_POST['title'];
             $text = $_POST['text'];
             NewsModel::addNews($title, $text);
         }
     }
 }