Next Generation CMS :: Форум поддержки

Заинтересовала наша система? Тогда этот форум для Вас!

Вы не зашли.

#1 2011-02-20 10:51:14

Евгений
Модератор
Откуда Россия
Зарегистрирован: 2009-04-08
Сообщений: 1,014
Рейтинг :   38 
Сайт

Ссылка на редактирование и удаление новости

Всем привет, в шаблонах news.short.tpl и news.full.tpl есть обработчики [edit-news] ... [/edit-news] и [del-news] ... [/del-news] они оборачивают объекты внутри себя в ссылки, но у меня возник момент, где нужно использовать не обработчики, а просто переменные с ссылкой на редактирование и удалении. Пример: {del-link} {edit-link}. Можно ли это реализовать? Если да, то очень прошу помочь.
Выглядит все это дело уже сгенерированно вот так:

<a onclick="confirmit('http://sitename.ru/engine/admin.php?mod=editnews&subaction=do_mass_delete&selected_news[]=934', 'Вы уверены что хотите удалить эту статью?')" target="_blank" style="cursor: pointer;">Удалить</a> <a href="http://sitename.ru/engine/admin.php?mod=editnews&action=editnews&id=934" target="_blank">Изменить</a>

Все бы ничего, в принципе можно взять {news-id} и вставить его в шаблон вместе с ссылками, но тогда это будет видно всем, так как закрыть при помощи того же [if-have-perm] нельзя, этот обработчик в шаблонах новостей не поддерживается. sad

Надеюсь что это реально теперь сделать посредством новых возможностей твига. smile


I NGeneration CMS

Не в сети

#2 2011-02-20 11:12:47

Wolverine
Модератор
Откуда Домодедово
Зарегистрирован: 2008-10-13
Сообщений: 3,538
Рейтинг :   160 
Сайт

Re: Ссылка на редактирование и удаление новости

Нереально, так как пока глобальные переменные пользователя не работают.

\engine\includes\news.php

Оба вхождения

	if (is_array($userROW) && ($row['author_id'] == $userROW['id'] || $userROW['status'] == "1" || $userROW['status'] == "2")) {
		$tvars['vars']['[edit-news]'] = "<a href=\"".admin_url."/admin.php?mod=editnews&action=editnews&id=".$row['id']."\" target=\"_blank\">";
		$tvars['vars']['[/edit-news]'] = "</a>";
		$tvars['vars']['[del-news]'] = "<a onclick=\"confirmit('".admin_url."/admin.php?mod=editnews&subaction=do_mass_delete&selected_news[]=".$row['id']."', '".$lang['sure_del']."')\" target=\"_blank\" style=\"cursor: pointer;\">";
		$tvars['vars']['[/del-news]'] = "</a>";
	} else {
		$tvars['regx']["'\\[edit-news\\].*?\\[/edit-news\\]'si"] = "";
		$tvars['regx']["'\\[del-news\\].*?\\[/del-news\\]'si"] = "";
	}

заменить на

   

if (is_array($userROW) && ($row['author_id'] == $userROW['id'] || $userROW['status'] == "1" || $userROW['status'] == "2")) {
		$tvars['vars']['[edit-news]'] = "<a href=\"".admin_url."/admin.php?mod=editnews&action=editnews&id=".$row['id']."\" target=\"_blank\">";
		$tvars['vars']['[/edit-news]'] = "</a>";
		$tvars['vars']['[del-news]'] = "<a onclick=\"confirmit('".admin_url."/admin.php?mod=editnews&subaction=do_mass_delete&selected_news[]=".$row['id']."', '".$lang['sure_del']."')\" target=\"_blank\" style=\"cursor: pointer;\">";
		$tvars['vars']['[/del-news]'] = "</a>";
		$tvars['vars']['[if-have-perm]'] = '';
		$tvars['vars']['[/if-have-perm]'] = '';
	} else {
		$tvars['regx']["'\\[edit-news\\].*?\\[/edit-news\\]'si"] = "";
		$tvars['regx']["'\\[del-news\\].*?\\[/del-news\\]'si"] = "";
		$tvars['regx']['#\[if-have-perm\].*?\[\/if-have-perm\]#si'] = '';
	}

Теперь доступен блок if-have-perm

Не в сети

#3 2011-02-20 11:28:28

Евгений
Модератор
Откуда Россия
Зарегистрирован: 2009-04-08
Сообщений: 1,014
Рейтинг :   38 
Сайт

Re: Ссылка на редактирование и удаление новости

Wolverine, жаль, но за if-have-perm огромное спасибо! wink


I NGeneration CMS

Не в сети

#4 2011-02-20 14:24:40

Евгений
Модератор
Откуда Россия
Зарегистрирован: 2009-04-08
Сообщений: 1,014
Рейтинг :   38 
Сайт

Re: Ссылка на редактирование и удаление новости

Wolverine, не желает падла работать)

Вот код:

<?php

//
// Copyright (C) 2006-2010 Next Generation CMS (http://ngcms.ru/)
// Name: news.php
// Description: News display sub-engine
// Author: Vitaly Ponomarev
//

// Protect against hack attempts
if (!defined('NGCMS')) die ('HAL');

$lang = LoadLang('news', 'site');
$situation = "news";


//
// Show one news
// Params (newsID or alt_name should be filled)
// $newsID - ID of the news
// $alt_name - alt name of the news
// $callingParams
//		'style'	  => mode for which we're called
//			* short		- short new display
//			* full		- full news display
//			* export	- export data [ for plugins or so on. No counters are updated ]
//			* export_body	- export ONLY BODY short+full [ for plugins or so on... ]
//			* export_short	- export ONLY BODY short      [ for plugins or so on... ]
//			* export_full	- export ONLY BODY full       [ for plugins or so on... ]
//      	'emulate' => array with "fake" emulated row [ used for preview or so ... ]
//		'plugin'  => if is called from plugin - ID of plugin
//		'overrideTemplateName' => alternative template for display
//		'overrideTemplatePath' => alternative path for searching of template
//		'customCategoryTemplate' => automatically override custom category templates
//		'setCurrentCategory' => update Current Category in system flags
//
//		Returns:
//			false    - when news is not found
//			data     - when news is found && export is used
//			news row - when news is found
function news_showone($newsID, $alt_name, $callingParams = array()) {
	global $mysql, $tpl, $userROW, $catz, $catmap, $config, $template, $parse, $vars, $lang, $SYSTEM_FLAGS, $PFILTERS;
	global $timer;
	global $year, $month, $day, $SUPRESS_TEMPLATE_SHOW;

	if (isset($callingParams['emulate']) && is_array($callingParams['emulate'])) {
		$row = $callingParams['emulate'];
		$callingParams['emulateMode'] = 1;
	} else {

		if ($newsID) {
			$filter = array('id='.db_squote($newsID));
		} elseif ($alt_name) {
			$filter = array('alt_name='.db_squote($alt_name));
		} else {
			return false;
		}

		if ($year) {
			array_push($filter, 'postdate >= '.db_squote(mktime(0,0,0,$month?$month:1, $day?$day:1, $year)));
			array_push($filter, 'postdate <= '.db_squote(mktime(23,59,59,$month?$month:12, $day?$day:31, $year)));
		}

		if (!is_array($row = $mysql->record("select * from ".prefix."_news where approve=1".(count($filter)?' and '.implode(" and ",$filter):'')))) {
			if (!$params['FFC']) {
				error404();
			}
			return false;
		}

		// Save some significant news flags for plugin processing
		$SYSTEM_FLAGS['news']['db.id'] = $row['id'];
		$SYSTEM_FLAGS['news']['db.categories'] = array();
		foreach (explode(',', $row['catid']) as $cid) {
			if (isset($catmap[$cid]))
				array_push($SYSTEM_FLAGS['news']['db.categories'], intval($cid));
		}
	}

	if ($callingParams['setCurrentCategory']) {
		// Fetch category ID from news
		$cid = intval(array_shift(explode(',', $row['catid'])));
		if ($cid && isset($catmap[$cid])) {
			// Save current category identifier
			$SYSTEM_FLAGS['news']['currentCategory.alt']	= $catz[$catmap[$cid]]['alt'];
			$SYSTEM_FLAGS['news']['currentCategory.id']		= $catz[$catmap[$cid]]['id'];
			$SYSTEM_FLAGS['news']['currentCategory.name']	= $catz[$catmap[$cid]]['name'];
		}
	}


	// preload plugins
	load_extras('news:show');
	load_extras('news:show:one');

	// Calculate exec time
        $tX1 = $timer->stop(4);

	// Execute filters
	if (is_array($PFILTERS['news']))
		foreach ($PFILTERS['news'] as $k => $v) { $v->showNewsPre($row['id'], $row, $callingParams); }

    $tX2 = $timer->stop(4);

	$tvars = newsFillVariables($row, 1, isset($_REQUEST['page'])?$_REQUEST['page']:0, (substr($callingParams['style'], 0, 6) == 'export')?1:0);

	$tX3 = $timer->stop(4);
	$timer->registerEvent('call showNewsPre() for [ '.($tX2 - $tX1).' ] sec');
	$timer->registerEvent('call newsFillVariables() for [ '.($tX3 - $tX2).' ] sec');

	$tvars['vars']['date']		=	LangDate(timestamp, $row['postdate']);
	$tvars['vars']['views']		=	$row['views'];
	$tvars['vars']['comnum']	=	$row['com'];

	// Show icon of `MAIN` category for current news
	$masterCatID = intval(array_shift(explode(",", $row['catid'])));
	if (!isset($catmap[$masterCatID]))
		$masterCatID = 0;

	if ($masterCatID && isset($catmap[$masterCatID]) && trim($catz[$catmap[$masterCatID]]['icon'])) {
		$tvars['vars']['icon']		= trim($catz[$catmap[$masterCatID]]['icon']);
		$tvars['vars']['[icon]']	= '';
		$tvars['vars']['[/icon]']	= '';
	} else {
		$tvars['vars']['icon']		=	'';
		$tvars['regx']["'\[icon\].*?\[/icon\]'si"] = '';
	}

	// Show edit/detele news buttons
if (is_array($userROW) && ($row['author_id'] == $userROW['id'] || $userROW['status'] == "1" || $userROW['status'] == "2")) {
        $tvars['vars']['[edit-news]'] = "<a href=\"".admin_url."/admin.php?mod=editnews&action=editnews&id=".$row['id']."\" target=\"_blank\">";
        $tvars['vars']['[/edit-news]'] = "</a>";
        $tvars['vars']['[del-news]'] = "<a onclick=\"confirmit('".admin_url."/admin.php?mod=editnews&subaction=do_mass_delete&selected_news[]=".$row['id']."', '".$lang['sure_del']."')\" target=\"_blank\" style=\"cursor: pointer;\">";
        $tvars['vars']['[/del-news]'] = "</a>";
        $tvars['vars']['[if-have-perm]'] = '';
        $tvars['vars']['[/if-have-perm]'] = '';
    } else {
        $tvars['regx']["'\\[edit-news\\].*?\\[/edit-news\\]'si"] = "";
        $tvars['regx']["'\\[del-news\\].*?\\[/del-news\\]'si"] = "";
        $tvars['regx']['#\[if-have-perm\].*?\[\/if-have-perm\]#si'] = '';
    }

	$newsid				=	$row['id'];
	$allow_comments		=	$row['allow_com'];
	$row['views']		=	$row['views']+1;

	exec_acts('news_full', '', $row, &$tvars);

	// Calculate exec time
	$tX1 = $timer->stop(4);

	// Execute filters
	if (is_array($PFILTERS['news']))
		foreach ($PFILTERS['news'] as $k => $v) {
			$timer->registerEvent('exec showNews // '.$k);
			$v->showNews($row['id'], $row, $tvars, $callingParams);
		}

	$tX2 = $timer->stop(4);
	$timer->registerEvent('call showNews() for [ '.($tX2 - $tX1).' ] sec');

	// Check if we need only to export body
	if ($callingParams['style'] == 'export_body')
		return $tvars['vars']['short-story'].' '.$tvars['vars']['full-story'];

	if ($callingParams['style'] == 'export_short')
		return $tvars['vars']['short-story'];

	if ($callingParams['style'] == 'export_full')
		return $tvars['vars']['full-story'];


	// Update visits counter if we're not in emulation mode
	if ((!$callingParams['emulate'])&&($callingParams['style'] == 'full')&&(intval($_REQUEST['page'])<2))
		$mysql->query("update ".prefix."_news set views=views+1 where id = ".db_squote($row['id']));


	// Make temlate procession - auto/manual overriding
	// -> calling style
	if (!$callingParams['style']) $callingParams['style'] = 'full';

	// -> desired template - override template if needed
	if ($callingParams['overrideTemplateName']) {
		$templateName = $callingParams['overrideTemplateName'];
	} else {
		// -> generate template name for selected style
		switch ($callingParams['style']) {
			case 'short' : $templateName = 'news.short'; break;
			case 'full'  : $templateName = 'news.full'; break;
			case 'print' : $templateName = 'news.print'; break;
			default      : $templateName = '';
		}
	}

	// Set default template path
	$templatePath = tpl_dir.$config['theme'];

	// -> desired template path - override path if needed
	if ($callingParams['overrideTemplatePath']) {
		$templatePath = $callingParams['overrideTemplatePath'];
	} else if ($callingParams['customCategoryTemplate']) {
		// -> check for custom category templates
		// Find first category
		$fcat = array_shift(explode(",", $row['catid']));
		// Check if there is a custom mapping
		if ($fcat && $catmap[$fcat] && ($ctname = $catz[$catmap[$fcat]]['tpl'])) {
			// Check if directory exists
			if (is_dir($templatePath.'/ncustom/'.$ctname))
				$templatePath = $templatePath.'/ncustom/'.$ctname;
		}
	}

	// Load & configure template
	$tpl -> template($templateName, $templatePath);
	$tpl -> vars($templateName, $tvars);

	// No comments/meta in emulation or export mode
	if ((is_array($callingParams['emulate']))||($callingParams['style'] == 'export'))
		return $tpl -> show($templateName);

	// Set meta tags for news page
	$SYSTEM_FLAGS['meta']['description'] = ($row['description'] != '')?$row['description']:$catz[$catmap[$masterCatID]]['description'];
	$SYSTEM_FLAGS['meta']['keywords']    = ($row['keywords'] != '')?$row['keywords']:$catz[$catmap[$masterCatID]]['keywords'];

	// Prepare title
	//$SYSTEM_FLAGS['info']['title']['group']	= $config["category_link"]?GetCategories($row['catid'], true):LangDate(timestamp, $row['postdate']);
	$SYSTEM_FLAGS['info']['title']['group']	= GetCategories($row['catid'], true);
	$SYSTEM_FLAGS['info']['title']['item']	= secure_html($row['title']);

	// We are in short or full mode. Add data into {mainblock}
	$template['vars']['mainblock'] .= $tpl -> show($templateName);

	return $row;
}


//
// Show news list
// [PROCESS FILTER]
function newsProcessFilter($conditions) {
	//print "CALL newsProcessFilter(".var_export($conditions, true).")<br/>\n";

	if (!is_array($conditions))
		return '';

	switch (strtoupper($conditions[0])) {
		case 'AND' :
		case 'OR'  :
			$list = array();
			for($i = 1; $i < count($conditions); $i++) {
				$rec = newsProcessFilter($conditions[$i]);
				//print ".result: ".var_export($rec, true)."<br/>\n";
				if ($rec != '')
					$list []= '('.$rec.')';
			}
			return join(' '.strtoupper($conditions[0]).' ', $list);
		case 'DATA':
			if ($conditions[1] == 'category') {
				switch ($conditions[2]) {
					case '=':
						return "`catid` regexp '[[:<:]](".intval($conditions[3]).")[[:>:]]'";
					default:
						return '';
				}
			} else {
				switch (strtoupper($conditions[2])) {
					case '=':
					case '>=':
					case '<=':
					case '>':
					case '<':
					case 'LIKE':
						return '`'.$conditions[1].'` '.$conditions[2].' '.db_squote($conditions[3]);
					case 'IN':
						if (is_array($conditions[3])) {
							$xt = array();
							foreach ($conditions[3] as $r)
								$xt[]= db_squote($r);

							return '`'.$conditions[1].'` IN ('.join(',', $xt).') ';
						}
						return '';
					case 'BETWEEN':
						if (is_array($conditions[3])) {
							return '`'.$conditions[1].'` BETWEEN '.db_squote($conditions[3][0]).' AND '.db_squote($conditions[3][1]);
						}
						return '';
				}
			}
			//
			break;
		case 'SQL' :
			return '('.$conditions[1].')';
		default: return '';
	}
}


// Params (newsID or alt_name should be filled)
// $filterConditions - conditions for filtering
// $paginationParams - config params for page display
//		'pluginName'	- name of plugin for call
//		'pluginHandler'	- handler for call
//		'params'		- standart param list for generateLink() call
//		'xparams'		- standart param list for generateLink() call
//		'paginator'		- set up for pagination
//			[0]		- variable name
//			[1]		- variable location 0 - params / 1 - xparams
//			[2]		- zero show flag 0 - don't show if zero / 1 - show anytime
// $callingParams
//		'style'	  => mode for which we're called
//			* short		- short new display
//			* full		- full news display
//			* export	- export data [ for plugins or so on. No counters are updated ]
//		'plugin'  => if is called from plugin - ID of plugin
//		'overrideTemplateName' => alternative template for display
//		'overrideTemplatePath' => alternative path for searching of template
//		'customCategoryTemplate' => flag automatically override custom category templates
//			[!!!] USES CUSTOM TEMPLATE FOR FIRST CATEGORY FROM NEWS [!!!]
//		'regenShortNews' =>
//			'mode' 		=> If we should generate `on the fly` short news from long one
//				* ''		- Leave short news as is [ default ]
//				* 'auto'	- Generate ShortNews from long only if ShortNews is empty
//				* 'force'	- Generate ShortNews from long in any case
//			'len'  			=> Length in chars of part of LongNews that will be used for regeneration (in case if regeneration is active)
//			'finisher'		=> chars that will be added into the end to indicate that this is truncated line ( default = '...' )
//		'showNumber'	=> set number of news to show per page
//		'newsOrder'		=> set news order
//		'overrideSQLquery' => array - sets if PLUGIN wants to run it's own query
//		'page'		=> page number to show
//		'extendedReturn' => flag if we need to return an extended array:
//			'count' - count of found news
//			'data'  - data to be showed
//		'searchFlag'	=> flag if we want to use non-mondatory template 'news.search.tpl' [!!only for style = 'short' !!]
//
function news_showlist($filterConditions = array(), $paginationParams = array(), $callingParams = array()){
	global $mysql, $tpl, $userROW, $catz, $catmap, $config, $vars, $parse, $template, $lang, $PFILTERS;
	global $year, $month, $day;
	global $timer;
	global $SYSTEM_FLAGS, $TemplateCache;


	$categoryList = array();

	// Generate SQL filter for 'WHERE' using filterConditions parameter
	$query['filter'] = newsProcessFilter(array('AND', array('DATA', 'approve', '=', '1'), $filterConditions));
	//print "<pre>".var_export($filterConditions, true)."</pre>";
	//print "<pre>".$query['filter']."</pre>";

	// Make temlate procession - auto/manual overriding
	// -> calling style
	if (!$callingParams['style']) $callingParams['style'] = 'short';

	// -> desired template - override template if needed
	if (isset($callingParams['overrideTemplateName']) && $callingParams['overrideTemplateName']) {
		$templateName = $callingParams['overrideTemplateName'];
	} else {
		// -> generate template name for selected style
		switch ($callingParams['style']) {
			case 'short': $templateName = 'news.short'; break;
			case 'full' : $templateName = 'news.full'; break;
			default     : $templateName = '';
		}
	}

	// Set default template path
	$templatePath = tpl_dir.$config['theme'];

	$cstart = $start_from = intval($callingParams['page']);

	if ($cstart < 1) { $cstart = 1; }

	$i			= $start_from?$start_from:0;

	$showNumber = ($config['number']>=1)?$config['number']:5;
	if (isset($callingParams['showNumber']) && (intval($callingParams['showNumber'])>0))
			$showNumber = intval($callingParams['showNumber']);

	$limit_start = $cstart?($cstart-1)*$showNumber:0;
	$limit_count = $showNumber;

	$orderBy = isset($callingParams['newsOrder'])?$callingParams['newsOrder']:'id desc';
	if (!in_array($orderBy, array('id desc', 'id asc', 'postdate desc', 'postdate asc', 'title desc', 'title asc')))
		$orderBy = 'id desc';

	$orderBy = 'pinned desc, '.$orderBy;
	$query['orderby'] = " order by ".$orderBy." limit ".$limit_start.",".$limit_count;

	// ===================================================================
	$query['count']		=	"SELECT count(*) as count FROM ".prefix."_news WHERE ".$query['filter'];
	$query['result']	=	"SELECT * FROM ".prefix."_news WHERE ".$query['filter'].$query['orderby'];

	// preload plugins
	load_extras('news:show');
	load_extras('news:show:list');

	$nCount = 0;
	$output = '';

	foreach ($mysql->select($query['result']) as $row) {
		$i++;
		$nCount++;

		// Give 'news in order' field to plugins
		$callingParams['nCount'] = $nCount;

		// Execute filters
		if (is_array($PFILTERS['news']))
			foreach ($PFILTERS['news'] as $k => $v) { $v->showNewsPre($row['id'], $row, $callingParams); }

		$tvars = newsFillVariables($row, 0, isset($_REQUEST['page'])?intval($_REQUEST['page']):0, 0, isset($callingParams['regenShortNews'])?$callingParams['regenShortNews']:array());

		$tvars['vars']['alternating'] = ($i%2)?'odd':'even';

		$tvars['vars']['date'] = LangDate(timestamp, $row['postdate']);
		$tvars['vars']['views'] = $row['views'];

		// Print icon if only one parent category

		if (isset($row['catid']) && $row['catid'] && !stristr(",", $row['catid']) && isset($catmap[$row['catid']]) && ($catalt = $catmap[$row['catid']]) && isset($catz[$catalt]['icon']) && $catz[$catalt]['icon']) {
			$tvars['vars']['icon'] = $catz[$catalt]['icon'];
			$tvars['vars']['[icon]'] = '';
			$tvars['vars']['[/icon]'] = '';
		} else {
			$tvars['vars']['icon'] = '';
			$tvars['regx']["'\\[icon\\].*?\\[/icon\\]'si"] = '';
		}

		if (is_array($userROW) && ($userROW['id'] == $row['author_id'] || ($userROW['status'] == 1 || $userROW['status'] == 2))) {
			$tvars['vars']['[edit-news]'] = "<a href=\"".admin_url."/admin.php?mod=editnews&action=editnews&id=".$row['id']."\" target=\"_blank\">";
			$tvars['vars']['[/edit-news]'] = "</a>";
			$tvars['vars']['[del-news]'] = "<a onclick=\"confirmit('".admin_url."/admin.php?mod=editnews&subaction=do_mass_delete&selected_news[]=".$row['id']."', '".$lang['sure_del']."')\" target=\"_blank\" style=\"cursor: pointer;\">";
			$tvars['vars']['[/del-news]'] = "</a>";
		} else {
			$tvars['regx']["'\[edit-news\].*?\[/edit-news\]'si"] = "";
			$tvars['regx']["'\[del-news\].*?\[/del-news\]'si"] = "";
		}
		exec_acts('news_short', '', $row, &$tvars);

		// Execute filters
		if (is_array($PFILTERS['news'])) {
			foreach ($PFILTERS['news'] as $k => $v) { $v->showNews($row['id'], $row, $tvars, $callingParams); }
		}

		// Set default template path
		$templatePath = tpl_dir.$config['theme'];

		// -> desired template path - override path if needed
		if (isset($callingParams['overrideTemplatePath']) && $callingParams['overrideTemplatePath']) {
			$templatePath = $callingParams['overrideTemplatePath'];
		} else if (isset($callingParams['customCategoryTemplate']) && $callingParams['customCategoryTemplate']) {
			// -> check for custom category templates
			// Find first category
			$fcat = array_shift(explode(",", $row['catid']));
			// Check if there is a custom mapping
			if ($fcat && $catmap[$fcat] && ($ctname = $catz[$catmap[$fcat]]['tpl'])) {
				// Check if directory exists
				if (is_dir($templatePath.'/ncustom/'.$ctname))
					$templatePath = $templatePath.'/ncustom/'.$ctname;
			}
		}

		// Hack for 'automatic search mode'
		$currentTemplateName = $templateName;
		// switch to `search` template if no templateName was overrided AND style is search AND searchFlag is set AND search template file exists
		if (isset($callingParams['searchFlag']) && ($callingParams['searchFlag']) && (!isset($callingParams['overrideTemplatePath'])) && ($callingParams['style'] == 'short') && (@file_exists($templatePath.'/news.search.tpl'))) {
			$currentTemplateName = 'news.search';
		}

		$tpl -> template($currentTemplateName, $templatePath);
		$tpl -> vars($currentTemplateName, $tvars);
		$output .= $tpl -> show($currentTemplateName);
	}
	unset($tvars);

	// Return output if we're in export mode
	if ($callingParams['style'] == 'export')
		return $output;

	// Print "no news" if we didn't find any news [ DON'T PRINT IN EXTENDED MODE ]
	if (!$nCount) {
		if (!isset($callingParams['extendedReturn']) || !$callingParams['extendedReturn']) {
			msg(array("type" => "info", "info" => $lang['msgi_no_news']));
		}
		$limit_start = 2;
	}

	// Make navigation bar
	templateLoadVariables(true);
	$navigations = $TemplateCache['site']['#variables']['navigation'];
	$tpl -> template('pages', tpl_dir.$config['theme']);

	// Prev page link
	if ($limit_start && $nCount) {
		$prev = floor($limit_start / $showNumber);
		$tvars['regx']["'\[prev-link\](.*?)\[/prev-link\]'si"] = str_replace('%page%',"$1",str_replace('%link%',generatePageLink($paginationParams, $prev), $navigations['prevlink']));
	} else {
		$tvars['regx']["'\[prev-link\](.*?)\[/prev-link\]'si"] = "";
		$prev = 0;
		$no_prev = true;
	}

	// List of pages
	$newsCount = $mysql->result($query['count']);
	$pages_count = ceil($newsCount / $showNumber);

	$maxNavigations 		= $config['newsNavigationsCount'];
	if ($maxNavigations < 1)
		$maxNavigations = 10;

	$tvars['vars']['pages'] = generatePagination($cstart, 1, $pages_count, $maxNavigations, $paginationParams, $navigations);

	// Next page link
	if (($prev + 2 <= $pages_count) && $nCount) {
		$tvars['regx']["'\[next-link\](.*?)\[/next-link\]'si"] = str_replace('%page%',"$1",str_replace('%link%',generatePageLink($paginationParams, $prev+2), $navigations['nextlink']));
	} else {
		$tvars['regx']["'\[next-link\](.*?)\[/next-link\]'si"] = "";
		$no_next = true;
	}

	if ($nCount && ($pages_count>1)){
		$tpl -> vars('pages', $tvars);
		$output .= $tpl -> show('pages');
	}

	// Add collected news into {mainlock}
	return (isset($callingParams['extendedReturn']) && $callingParams['extendedReturn'])?array('count' => $newsCount, 'data' => $output):$output;
}



// ================================================================= //
// Module code                                                       //
// ================================================================= //

// Default "show news" function
function showNews($handlerName, $params) {
 global $catz, $catmap, $template, $config, $userROW, $PFILTERS, $lang, $SYSTEM_FLAGS, $SUPRESS_TEMPLATE_SHOW, $tpl, $parse;
 // preload plugins
 load_extras('news');

 // Init array with configuration parameters
 $callingParams = array('customCategoryTemplate' => 1, 'customCategoryNumber' => 1, 'setCurrentCategory' => 1);
 $callingCommentsParams = array();

 // Set default template path
 $templatePath = tpl_dir.$config['theme'];

 // Check for FULL NEWS mode
 if (($handlerName == 'news')||($handlerName == 'print')) {
 	$flagPrint = ($handlerName == 'print')?true:false;
	if ($flagPrint)
		$SUPRESS_TEMPLATE_SHOW = true;

	$callingParams['style'] = $flagPrint?'print':'full';

	// Execute filters [ onBeforeShow ] ** ONLY IN 'news' mode. In print mode we don't use it
	if (!$flagPrint && is_array($PFILTERS['news'])) {
		foreach ($PFILTERS['news'] as $k => $v) { $v->onBeforeShow('full'); }
	}

	// Determine passed params
	$vars = array('id' => 0, 'altname' => '');
	if (isset($params['id'])) {
		$vars['id'] = $params['id'];
	} else if (isset($params['altname'])) {
		$vars['altname'] = $params['altname'];
	} else if (isset($_REQUEST['id'])) {
		$vars['id'] = intval($_REQUEST['id']);
	} else {
		$vars['altname'] = $_REQUEST['altname'];
	}

 	// Try to show news
	if (($row = news_showone($vars['id'], $vars['altname'], $callingParams)) !== false) {
		// Execute filters [ onAfterShow ] ** ONLY IN 'news' mode. In print mode we don't use it
		if (!$flagPrint && is_array($PFILTERS['news'])) {
			foreach ($PFILTERS['news'] as $k => $v) { $v->onAfterNewsShow($row['id'], $row, array('style' => 'full')); }
		}
	 }
} else {
 	$callingParams['style'] = 'short';
 	$callingParams['page']  = (isset($params['page']) && intval($params['page']))?intval($params['page']):(isset($_REQUEST['page'])?intval($_REQUEST['page']):0);

	// Execute filters [ onBeforeShow ]
	if (is_array($PFILTERS['news'])) {
		foreach ($PFILTERS['news'] as $k => $v) { $v->onBeforeShow('short'); }
	}

	switch ($handlerName) {
		case 'main':
			$SYSTEM_FLAGS['info']['title']['group'] = $lang['mainpage'];
		    $paginationParams = checkLinkAvailable('news', 'main')?
		    			array('pluginName' => 'news', 'pluginHandler' => 'main', 'params' => array(), 'xparams' => array(), 'paginator' => array('page', 0, false)):
		    			array('pluginName' => 'core', 'pluginHandler' => 'plugin', 'params' => array('plugin' => 'news', 'handler' => 'main'), 'xparams' => array(), 'paginator' => array('page', 1, false));

			if ($config['default_newsorder'] != '')
				$callingParams['newsOrder'] = $config['default_newsorder'];

			$template['vars']['mainblock'] .= news_showlist(array('DATA', 'mainpage', '=', '1'), $paginationParams, $callingParams);
			break;

		case 'by.category':
			$category = '';
			if (isset($params['catid'])) {
				$category = $params['catid'];
			} else if (isset($params['category']) && isset($catz[$params['category']])) {
				$category = $catz[$params['category']]['id'];
			} else if (isset($_REQUEST['catid'])) {
				$category = $params['catid'];
			} else if (isset($_REQUEST['category']) && isset($catz[$_REQUEST['category']])) {
				$category = $catz[$_REQUEST['category']]['id'];
			}

			// We can't show unexisted categories
			if (!$category || !isset($catmap[$category])) {
				if (!$params['FFC']) {
					error404();
				}
				return false;
			}
			$currentCategory = $catz[$catmap[$category]];

			// Save current category identifier
			$SYSTEM_FLAGS['news']['currentCategory.alt']	= $currentCategory['alt'];
			$SYSTEM_FLAGS['news']['currentCategory.id']		= $currentCategory['id'];
			$SYSTEM_FLAGS['news']['currentCategory.name']	= $currentCategory['name'];

			// Set title
			$SYSTEM_FLAGS['info']['title']['group'] = $currentCategory['name'];

			// Set meta tags for category page
			if ($currentCategory['description'])
				$SYSTEM_FLAGS['meta']['description'] = $currentCategory['description'];
			if ($currentCategory['keywords'])
				$SYSTEM_FLAGS['meta']['keywords']    = $currentCategory['keywords'];

			// Set personal `order by` for category
			if ($currentCategory['number'])
					$callingParams['showNumber'] = $currentCategory['number'];

			// Set number of `news per page` if this parameter is filled in category
			if ($currentCategory['orderby'])
				$callingParams['newsOrder'] = $currentCategory['orderby'];

			$paginationParams = checkLinkAvailable('news', 'by.category')?
		    			array('pluginName' => 'news', 'pluginHandler' => 'by.category', 'params' => array('category' => $catmap[$category]), 'xparams' => array(), 'paginator' => array('page', 0, false)):
		    			array('pluginName' => 'core', 'pluginHandler' => 'plugin', 'params' => array('plugin' => 'news', 'handler' => 'by.category'), 'xparams' => array('category' => $catmap[$category]), 'paginator' => array('page', 1, false));

			// Generate news content
			$newsContent = news_showlist(array('DATA', 'category', '=', $category), $paginationParams, $callingParams);

			// Check if template 'news.table.tpl' exists [first check custom category template (if set), after that - common template for the whole site
			$ntTemplatePath = '';
			$ntTemplateFound = false;
			if ($currentCategory['tpl'] && file_exists(tpl_dir.$config['theme'].'/'.$currentCategory['tpl'].'/news.table.tpl')) {
				$ntTemplateFound	= true;
				$ntTemplatePath		= tpl_dir.$config['theme'].'/'.$currentCategory['tpl'];
			} else if (file_exists(tpl_dir.$config['theme'].'/news.table.tpl')) {
				$ntTemplateFound	= true;
				$ntTemplatePath		= tpl_dir.$config['theme'];
			}

			if ($ntTemplateFound) {
				$tpl->template('news.table', $ntTemplatePath);
				$tnvars = array('vars' => array(
					'category.id'	=> $currentCategory['id'],
					'category.alt'	=> secure_html($currentCategory['alt']),
					'category.name'	=> secure_html($currentCategory['name']),
					'category.info'	=> ($config['use_bbcodes'])?$parse -> bbcodes($currentCategory['info']):$currentCategory['info'],
					'entries'		=> $newsContent,
				));

				if ($currentCategory['image_id'] && $currentCategory['icon_id']) {
					$tnvars['regx']['#\[icon\](.*?)\[\/icon\]#is'] = '$1';
					$tnvars['vars']['icon.url']				= $config['attach_url'].'/'.$currentCategory['icon_folder'].'/'.$currentCategory['icon_name'];;
					$tnvars['vars']['icon.width']			= $row['icon_width'];
					$tnvars['vars']['icon.height']			= $row['icon_height'];
					if ($currentCategory['icon_preview']) {
						$tnvars['regx']['#\[icon\.preview\](.*?)\[\/icon.preview\]#is'] = '$1';
						$tnvars['regx']['#\[icon\.nopreview\](.*?)\[\/icon.nopreview\]#is'] = '';
						$tnvars['vars']['icon.preview.url']		= $config['attach_url'].'/'.$currentCategory['icon_folder'].'/thumb/'.$currentCategory['icon_name'];;
						$tnvars['vars']['icon.preview.width']	= $currentCategory['icon_pwidth'];
						$tnvars['vars']['icon.preview.height']	= $currentCategory['icon_pheight'];
					} else {
						$tnvars['regx']['#\[icon\.preview\](.*?)\[\/icon.preview\]#is'] = '';
						$tnvars['regx']['#\[icon\.nopreview\](.*?)\[\/icon.nopreview\]#is'] = '$1';
					}
				} else {
					$tnvars['regx']['#\[icon\](.*?)\[\/icon\]#is'] = '';
					$tnvars['regx']['#\[icon\.preview\](.*?)\[\/icon.preview\]#is'] = '';
					$tnvars['regx']['#\[icon\.nopreview\](.*?)\[\/icon.nopreview\]#is'] = '';
				}

				$tpl->vars('news.table', $tnvars);
				$template['vars']['mainblock'] .= $tpl->show('news.table');
			} else {
				$template['vars']['mainblock'] .= $newsContent;
			}

			break;

		case 'by.day':
			$year	= intval(isset($params['year'])?$params['year']:$_REQUEST['year']);
			$month	= intval(isset($params['month'])?$params['month']:$_REQUEST['month']);
			$day	= intval(isset($params['day'])?$params['day']:$_REQUEST['day']);

			if (($year < 1970)||($year > 2100)||($month < 1)||($month > 12)||($day < 1)||($day > 31))
				return false;

			$SYSTEM_FLAGS['info']['title']['group'] = LangDate("j Q Y", mktime("0", "0", "0", $month, $day, $year));
		    $paginationParams = checkLinkAvailable('news', 'by.day')?
		    			array('pluginName' => 'news', 'pluginHandler' => 'by.day', 'params' => array('day' => sprintf('%02u', $day), 'month' => sprintf('%02u', $month), 'year' => $year), 'xparams' => array(), 'paginator' => array('page', 0, false)):
		    			array('pluginName' => 'core', 'pluginHandler' => 'plugin', 'params' => array('plugin' => 'news', 'handler' => 'by.day'), 'xparams' => array('day' => sprintf('%02u', $day), 'month' => sprintf('%02u', $month), 'year' => $year), 'paginator' => array('page', 1, false));

			$template['vars']['mainblock'] .= news_showlist(array('DATA', 'postdate', 'BETWEEN', array(mktime(0,0,0,$month,$day,$year), mktime(23,59,59,$month,$day,$year))), $paginationParams, $callingParams);
			break;

		case 'by.month':
			$year	= intval(isset($params['year'])?$params['year']:$_REQUEST['year']);
			$month	= intval(isset($params['month'])?$params['month']:$_REQUEST['month']);

			if (($year < 1970)||($year > 2100)||($month < 1)||($month > 12))
				return false;

			$SYSTEM_FLAGS['info']['title']['group'] = LangDate("F Y", mktime(0,0,0, $month, 1, $year));
		    $paginationParams = checkLinkAvailable('news', 'by.month')?
		    			array('pluginName' => 'news', 'pluginHandler' => 'by.month', 'params' => array('month' => sprintf('%02u', $month), 'year' => $year), 'xparams' => array(), 'paginator' => array('page', 0, false)):
		    			array('pluginName' => 'core', 'pluginHandler' => 'plugin', 'params' => array('plugin' => 'news', 'handler' => 'by.month'), 'xparams' => array('month' => sprintf('%02u', $month), 'year' => $year), 'paginator' => array('page', 1, false));

			$template['vars']['mainblock'] .= news_showlist(array('DATA', 'postdate', 'BETWEEN', array(mktime(0,0,0,$month,1,$year), mktime(23,59,59,$month,date("t",mktime(0,0,0,$month,1,$year)),$year))), $paginationParams, $callingParams);
			break;

		case 'by.year':
			$year	= intval(isset($params['year'])?$params['year']:$_REQUEST['year']);

			if (($year < 1970)||($year > 2100))
				return false;

			$SYSTEM_FLAGS['info']['title']['group'] = LangDate("Y", mktime(0,0,0, 1, 1, $year));
		    $paginationParams = checkLinkAvailable('news', 'by.year')?
		    			array('pluginName' => 'news', 'pluginHandler' => 'by.year', 'params' => array('year' => $year), 'xparams' => array(), 'paginator' => array('page', 0, false)):
		    			array('pluginName' => 'core', 'pluginHandler' => 'plugin', 'params' => array('plugin' => 'news', 'handler' => 'by.year'), 'xparams' => array('year' => $year), 'paginator' => array('page', 1, false));

			$template['vars']['mainblock'] .= news_showlist(array('DATA', 'postdate', 'BETWEEN', array(mktime(0,0,0,1,1,$year), mktime(23,59,59,12,31,$year))), $paginationParams, $callingParams);
			break;
	}

	// Execute filters [ onAfterShow ]
	if (is_array($PFILTERS['news'])) {
		foreach ($PFILTERS['news'] as $k => $v) { $v->onAfterShow('short'); }
	}
 }
}

Вроде бы все как ты написал сделал.(


I NGeneration CMS

Не в сети

#5 2011-02-20 14:29:46

Wolverine
Модератор
Откуда Домодедово
Зарегистрирован: 2008-10-13
Сообщений: 3,538
Рейтинг :   160 
Сайт

Re: Ссылка на редактирование и удаление новости

А что ты вставляешь в news.*.tpl

Не в сети

#6 2011-02-20 17:49:11

Евгений
Модератор
Откуда Россия
Зарегистрирован: 2009-04-08
Сообщений: 1,014
Рейтинг :   38 
Сайт

Re: Ссылка на редактирование и удаление новости

Wolverine, вот:

<div class="post-admin">[if-have-perm]<a onclick="confirmit('/engine/admin.php?mod=editnews&subaction=do_mass_delete&selected_news[]={news-id}', 'Вы уверены что хотите удалить эту статью?')" target="_blank" class="postdelete">Удалить</a> <a href="/engine/admin.php?mod=editnews&action=editnews&id={news-id}" target="_blank" class="postedit">Изменить</a>[/if-have-perm] [isplugin bookmarks]{bookmarks}[/isplugin]</div>

И получаю на выходе:
edbc35765b4072223a471d3632658e9b_pv.png


I NGeneration CMS

Не в сети

#7 2011-02-20 17:57:41

Wolverine
Модератор
Откуда Домодедово
Зарегистрирован: 2008-10-13
Сообщений: 3,538
Рейтинг :   160 
Сайт

Re: Ссылка на редактирование и удаление новости

Не в той функции заменил, надо в news_showlist

Не в сети

#8 2011-02-20 18:03:03

Евгений
Модератор
Откуда Россия
Зарегистрирован: 2009-04-08
Сообщений: 1,014
Рейтинг :   38 
Сайт

Re: Ссылка на редактирование и удаление новости

Wolverine, ага, точно) спасибо, помогло. smile


I NGeneration CMS

Не в сети

#9 2011-02-20 18:19:49

Евгений
Модератор
Откуда Россия
Зарегистрирован: 2009-04-08
Сообщений: 1,014
Рейтинг :   38 
Сайт

Re: Ссылка на редактирование и удаление новости

Wolverine, в полной новости не работает(

Это наверное из-за этого:

if (is_array($userROW) && ($row['author_id'] == $userROW['id'] || $userROW['status'] == "1" || $userROW['status'] == "2")) {
        $tvars['vars']['[edit-news]'] = "<a href=\"".admin_url."/admin.php?mod=editnews&action=editnews&id=".$row['id']."\" target=\"_blank\">";
        $tvars['vars']['[/edit-news]'] = "</a>";
        $tvars['vars']['[del-news]'] = "<a onclick=\"confirmit('".admin_url."/admin.php?mod=editnews&subaction=do_mass_delete&selected_news[]=".$row['id']."', '".$lang['sure_del']."')\" target=\"_blank\" style=\"cursor: pointer;\">";
        $tvars['vars']['[/del-news]'] = "</a>";
        $tvars['vars']['[if-have-perm]'] = '';
        $tvars['vars']['[/if-have-perm]'] = '';
    } else {
        $tvars['regx']["'\\[edit-news\\].*?\\[/edit-news\\]'si"] = "";
        $tvars['regx']["'\\[del-news\\].*?\\[/del-news\\]'si"] = "";
        $tvars['regx']['#\[if-have-perm\].*?\[\/if-have-perm\]#si'] = '';
    }
		exec_acts('news_short', '', $row, &$tvars);
		exec_acts('news_short', '', $row, &$tvars);

I NGeneration CMS

Не в сети

#10 2011-02-20 18:31:28

Wolverine
Модератор
Откуда Домодедово
Зарегистрирован: 2008-10-13
Сообщений: 3,538
Рейтинг :   160 
Сайт

Re: Ссылка на редактирование и удаление новости

А если вернуть и в news_showone? smile

Не в сети

#11 2011-02-20 19:42:01

Евгений
Модератор
Откуда Россия
Зарегистрирован: 2009-04-08
Сообщений: 1,014
Рейтинг :   38 
Сайт

Re: Ссылка на редактирование и удаление новости

Wolverine, и вправду если вернуть помогает) теперь уж точно все окей)


I NGeneration CMS

Не в сети

Подвал раздела

Работает на FluxBB