\n";
$str = $objSession->GetVariable("Env_News");
n_ParseEnv($str);
}
function n_SaveEnv($str="")
{
global $objSession;
$str = $objSession->SetVariable("Env_News",$str);
}
function n_BuildEnv($dbg=0)
{
$module_vars = Array('id','p','rp');
return GenerateModuleEnv('n', $module_vars);
}
function n_BuildEnv_NEW($dbg=0)
{
$module_vars = Array('id' => 'n_id', 'p' => 'n_Page', 'rp' => 'n_Reviews_Page');
return GenerateModuleEnv_NEW('n', $module_vars);
}
/*
@description: returns the date of the last modification to the news article table
@attrib: _Part:: part of the date to display
@attrib: _local:bool: If set, returns the modified date for the current category (and subcats)
@example:
*/
function n_article_modified($attribs)
{
global $objConfig, $objCatList;
$ret='';
$CachedValue = GetTagCache("innews","n_article_modified",$attribs,"");
if(strlen($CachedValue))
{
return $CachedValue;
}
$ado = &GetADODBConnection();
if( getArrayValue($attribs,'_local') && $objCatList->CurrentCategoryID() != 0)
{
$c = $objCatList->GetItem($objCatList->CurrentCategoryID());
$catlist = $c->GetSubCatIds();
$catwhere = "CategoryId IN (".explode(",",$catlist).")";
$sql = "SELECT MAX(Modified) as ModDate,MAX(CreatedOn) as NewDate FROM ".GetTablePrefix()."News ";
$sql .= "INNER JOIN ".GetTablePrefix()."CategoryItems ON (".GetTablePrefix()."News.ResourceId=".GetTablePrefix()."CategoryItems.ItemResourceId) ";
$sql .= "WHERE Status=1 AND $catwhere LIMIT 1";
}
else
{
$sql = "SELECT MAX(Modified) as ModDate, MAX(CreatedOn) As NewDate FROM ".GetTablePrefix()."News WHERE Status=1 LIMIT 1";
}
$rs = $ado->Execute($sql);
if($rs && ! $rs->EOF)
{
$new = $rs->fields["NewDate"];
$mod = $rs->fields["ModDate"];
if($new>$mod)
$mod = $new;
if($mod)
{
$part = strtolower(getArrayValue($attribs, '_part'));
$ret=$part?ExtractDatePart($part,$mod):LangDate($mod);
}
}
if($ret) SaveTagCache("innews","n_article_modified",$attribs,"",$ret);
return $ret;
}
/*
@description: returns a link to the news root category
@attrib: _Category:int: Override the In-News root category
@attrib: _Template:tpl: The template to link to
@example:
*/
function n_root_link($attribs = array())
{
global $objConfig, $n_var_list_update, $objModules;
//$RootCat = (int)$objConfig->Get("Article_Root");
$RootCat = $objModules->GetModuleRoot("In-News");
if($RootCat != -1)
$attribs["_category"] = $RootCat;
$n_var_list_update["p"] = 0;
$n_var_list_update["id"] = 0;
$n_var_list_update["rp"] = 0;
unset($n_var_list_update["p"],$n_var_list_update["id"],$n_var_list_update["rp"]);
$o = m_template_link($attribs);
unset($n_var_list_update["p"],$n_var_list_update["id"],$n_var_list_update["rp"]);
return $o;
}
/* not a tag, used to load article lists */
function LoadArticleList($attribs=array())
{
global $objArticleList, $objSession, $n_var_list,$n_var_list_update;
static $PagingList, $original_page = null;
if (is_null($original_page)) {
$original_page = $n_var_list['p'];
}
$ListType = strtolower( getArrayValue($attribs,'_listtype') );
$force_paging = getArrayValue($attribs,'_forcepaging');
if(!strlen($ListType)) $ListType="category";
$LastList = $objSession->GetVariable("NewsListType");
$LastShortType = (int)$objSession->GetVariable("NewsShortList");
$NoPaging = ( getArrayValue($attribs,'_paging')=='0' | getArrayValue($attribs,'_paging')=='false');
//echo "Paging: $NoPaging
";
if(!$NoPaging && !strlen($PagingList))
{
$PagingList=$ListType;
}
//echo "Last: $LastList, Short: $LastShortType Current: $ListType, Short:".$attribs["_shortlist"]." PageList: $PagingList
\n";
if($ListType==$PagingList)
{
$objArticleList->EnablePaging = true;
if($LastList != $ListType || $LastShortType != (int)$attribs["_shortlist"])
{
//echo "Resetting Page..
\n";
$n_var_list_update["p"] = 0;
$n_var_list["p"] = 1;
// $original_page = 1;
$objArticleList->Page = 1;
$objSession->SetVariable("NewsListType",$ListType);
$objSession->SetVariable("NewsShortList",(int)$attribs["_shortlist"]);
}
else {
$objArticleList->Page = $original_page;
}
}
else
{
if(is_numeric( getArrayValue($attribs,'_maxcount') ))
{
$objArticleList->MaxListCount = $attribs["_maxcount"];
}
else
{
$objArticleList->MaxListCount = 10;
}
$objArticleList->EnablePaging = false;
if ($force_paging == 1)
{
$objArticleList->EnablePaging = true;
$objArticleList->Page = $original_page;
}
}
$objArticleList->ListType = $ListType;
$objArticleList->Clear();
//echo "ListType: $ListType
\n";
switch($ListType)
{
case "category":
$objArticleList->LoadListCategory($attribs);
break;
case "leadstory":
$objArticleList->LoadLeadStories($attribs);
break;
case "pop":
$objArticleList->LoadPopItems($attribs);
break;
case "hot":
$objArticleList->LoadHotItems($attribs);
break;
case "pick":
$objArticleList->LoadPickItems($attribs);
break;
case "new":
$objArticleList->LoadNewItems($attribs);
break;
case "my_new":
$scope = $objSession->CurrentUser->Vars["LastLogin"];
$attribs["_scope"] = $scope;
$attribs["_show_since_last"] = 1;
//print_pre($objSession->CurrentUser);
if (is_numeric($scope) && $scope > 0) {
$objArticleList->LoadNewItems($attribs);
}
break;
case "myitems":
$objArticleList->LoadMyItems($attribs);
break;
case "favorites":
$objArticleList->LoadFavorites($attribs);
break;
case "search":
$attribs['multiple'] = 'articles';
$objArticleList->LoadSearchItems($attribs);
break;
}
}
/*
@description: Used in conjuction with n_list_news. This function generates the page navigation
for the list. If this tag is called before the list tag, this function will load
the articles. For that reason, the _ListType attribute is required if the pagnav
tag preceeds the l_list_news tag in the template. Generally, it is good practice to
duplicate all attributes set for n_list_news.
@attrib: _PagesToList:int: Number of pages to list (default is 10)
@attrib: _ShortList:bool: If set, uses the shortlist configuration value for articles
@attrib: _Template:tpl: Template page links should redirect to (defaults to current template)
@attrib: _label:lang: language tag to include in the output if there are pages to list. If there are no pages
listed, this text will not be included (resulting in an empty output)
*/
function n_news_pagenav($attribs = array())
{
global $objArticleList, $objCatList, $objSession, $objConfig;
$DestTemplate = $attribs["_template"];
$PagesToList = $attribs["_pagestolist"];
$image = $attribs["_PageIcon"];
if(!is_numeric($PagesToList))
$PagesToList = 10;
$CatId = $attribs["_catid"];
if(!is_numeric($CatId))
$CatId = $objCatList->CurrentCategoryID();
if ($attribs['_shortlist'] && $objConfig->Get('Perpage_News_Short') ) {
$objArticleList->PerPageVar = 'Perpage_News_Short';
}
else {
$objArticleList->PerPageVar = 'Perpage_News';
}
$ListType = strtolower($attribs["_listtype"]);
if(!strlen($ListType))
$ListType="category";
if($objArticleList->ListType != $ListType)
LoadArticleList($attribs);
$o = $objArticleList->GetPageLinkList($DestTemplate,'',10,true,'', ExtraAttributes($attribs));
if (strlen($image)) {
$o_i = ' ';
}
if(strlen($o) && strlen($attribs["_label"]))
$o = $o_i.language($attribs["_label"]).' '.$o;
return $o;
}
/*
@description: Used in conjuction with n_list_news. This function generates a navigation link which is
used to switch from a short list to a longer list. The page number is not changed.
If this tag is called before the list tag, this function will load the article list.
For that reason, the _ListType attribute is required if the pagnav
tag preceeds the n_list_news tag in the template. Generally, it is good practice to
duplicate all attributes set for n_list_news.
@attrib: _root:bool: If set, the current category is set to In-News's root category
@attrib: _text:lang: language tag to include as text for the anchor tag
@attrib: _ShortList:bool: If set, uses the shortlist configuration value for links
@attrib: _plaintext:: plain text to include as text for the anchor tag. The _text attribute takes presedence
if both are included.
@attrib: _image:: URL to an image to include inside the anchor tag.
*/
function n_link_more($attribs = array())
{
global $objArticleList, $objConfig,$n_var_list_update;
$n_var_list_update['id'] = 0;
$html_attribs = ExtraAttributes($attribs);
$DestTemplate = $attribs["_template"];
if ($attribs['_shortlist'] && $objConfig->Get('Perpage_News_Short') ) {
$objArticleList->PerPageVar = 'Perpage_News_Short';
}
else {
$objArticleList->PerPageVar = 'Perpage_News';
}
$ListType = strtolower($attribs["_listtype"]);
if(!strlen($ListType))
$ListType="category";
if($objArticleList->ListType != $ListType)
LoadArticleList($attribs);
if($objArticleList->QueryItemCount > $objConfig->Get($objArticleList->PerPageVar))
{
if($attribs["_root"])
{
$url = n_root_link($attribs);
}
else
{
$n_var_list_update["p"]=0;
$url = m_template_link($attribs);
unset($n_var_list_update["p"]);
}
$o = "";
$text = $attribs["_text"];
if(!strlen($text))
{
$text = $attribs["_plaintext"];
if(!strlen($text))
{
}
$o .= $text."";
}
else
$o .= language($text);
if(strlen($attribs["_image"]))
{
$o .= "";
}
$o .= "";
}
return $o;
}
/*
@description: returns a list of news articles
@attrib: _CatId:int: Override the current category
@attrib: _useroot:bool: If set, the current category is changed to In-News's root category
@attrib: _ShortList:bool: If set, the Perpage_News_Short setting is used instead of Perpage_news
@attrib: _Paging:bool: If set to 0 or false, paging will not be allowed for this list (only one paging list is allowed per item type per page load)
@attrib: _maxcount:int: If paging is not used on this list, this value determines how many items to load
@attrib: _ListType::Determines the type of list to generate
Possible values:
- Category: List links from the current category (default)
- Top: Most Popular & highest rated links
- Pop: Most Popular links
- New: List new links
- Hot: List links with the most click-throughs
- Pick: List editor's picks
- myitems: List topics created by the current user
- favorites: List topics marked as favorites by the current user
- search: List search results
@attrib: _FirstItemTemplate:tpl: Template used for the first article listed
@attrib: _LastItemTemplate:tpl: Template used for the last article listed
@attrib: _EdItemTemplate:tpl: Editors Pick template used for article list items
@attrib: _ItemTemplate:tpl: default template used for article list items
@example:
*/
function n_list_news($attribs = array())
{
global $objConfig, $objSession, $var_list, $var_list_update, $n_var_list, $n_var_list_update, $objArticleList, $objCatList, $content_set;
$template = getArrayValue($attribs,'_itemtemplate');
$force_paging = getArrayValue($attribs,'_forcepaging');
if(!strlen($template))
{
$content_set = 0;
return "ERROR -1";
}
if ($attribs['_shortlist'] && $objConfig->Get('Perpage_News_Short') ) {
$objArticleList->PerPageVar = 'Perpage_News_Short';
}
else {
$objArticleList->PerPageVar = 'Perpage_News';
}
$CatId = getArrayValue($attribs,'_catid');
if(!is_numeric($CatId)) $CatId = $objCatList->CurrentCategoryID();
$ListType = strtolower($attribs["_listtype"]);
if(!strlen($ListType)) $ListType="category";
if($ListType != "search")
{
$evar = $evar = $_GET["env"]; //m_BuildEnv().$objSession->GetVariable("Env_Link");
$tagname = "n_list_news-".$ListType."-".(int)$attribs["_shortlist"];
$CachedList = GetTagCache("innews",$tagname,$attribs,$evar);
if(strlen($CachedList))
{
return $CachedList;
}
}
if(($objArticleList->ListType != $ListType) || ($objCatList->CurrentCategoryID() != $attribs["_catid"]) || $force_paging == 1)
{
LoadArticleList($attribs);
}
if($objArticleList->NumItems()== 0)
{
$content_set = 0;
return "";
}
$keywords = $objSession->GetVariable("Search_Keywords");
$max_articles = min($objConfig->Get($objArticleList->PerPageVar), $objArticleList->NumItems());
$articles_showed = 0; //nl
//$max_articles = $objConfig->Get($objArticleList->PerPageVar); //nl
foreach($objArticleList->Items as $index => $news)
{
$objArticleList->CurrentItem = $index;
$parsed = 0;
if($row==0 && strlen($attribs["_firstitemtemplate"]))
{
$o .= $news->ParseTemplate($attribs["_firstitemtemplate"]);
$parsed = 1;
}
if($row==$objArticleList->NumItems()-1 && !$parsed && strlen($attribs["_lastitemtemplate"])>0)
{
$o .= $news->ParseTemplate($attribs["_lastitemtemplate"]);
$parsed = 1;
}
if(!$parsed)
{
if (getArrayValue($attribs, '_editemtemplate') && (int)$news->Get('EditorsPick'))
{
$o .= $news->ParseTemplate($attribs["_editemtemplate"]);
}
else
{
$o .= $news->ParseTemplate($attribs['_itemtemplate']);
}
}
$articles_showed++; // nl
if($articles_showed == $max_articles) break; //nl
}
$objArticleList->SetCurrentItem();
if(strlen($o)) {
SaveTagCache("innews",$tagname,$attribs,$evar,$o);
}
return $o;
}
/*
@description: returns a list of news articles
@attrib: _CatId:int: Override the current category
@attrib: _useroot:bool: If set, the current category is changed to In-News's root category
@attrib: _ShortList:bool: If set, the Perpage_Links_Short setting is used instead of Perpage_links
@attrib: _ListType::Determines the type of list to generate
Possible values:
- Category: List links from the current category (default)
- Top: Most Popular & highest rated links
- Pop: Most Popular links
- New: List new links
- Hot: List links with the most click-throughs
- Pick: List editor's picks
- myitems: List topics created by the current user
- favorites: List topics marked as favorites by the current user
- search: List search results
@example:
*/
function n_list_count($attribs = array())
{
global $objCatList, $objArticleList, $objConfig, $objSession;
if ($attribs['_shortlist'] && $objConfig->Get('Perpage_News_Short') ) {
$objArticleList->PerPageVar = 'Perpage_News_Short';
}
else {
$objArticleList->PerPageVar = 'Perpage_News';
}
$ListType = strtolower($attribs["_listtype"]);
if(!strlen($ListType))
$ListType="category";
if(!$attribs["_today"])
{
if($objArticleList->ListType != $ListType)
LoadArticleList($attribs);
$o = 0;
$keywords = $objSession->GetVariable("Search_Keywords");
if ($keywords || ($_REQUEST['Action']=='m_adv_search')) {
/* foreach ($objArticleList->Items as $cat) {
if (strstr(strip_tags(strtolower($cat->Data['Title'])), strtolower($keywords)) || strstr(strip_tags(strtolower($cat->Data['Body'])), strtolower($keywords)) || strstr(strip_tags(strtolower($cat->Data['Excerpt'])), strtolower($keywords))) {
$o++;
}
}
}
else {*/
}
$o = $objArticleList->QueryItemCount;
}
else
{
$o = $objArticleList->PerformItemCount($attribs);
}
if ($o == '') {
$o = 0;
}
return $o;
}
/*
@description: Parse an article field and return the value
@attrib: _Field:: Article field to parse
@attrib: _ArticleId:int: Article ID to parse (uses current article if not set)
*/
function n_news_field($attribs = array())
{
global $objArticleList;
$o = "";
$field = $attribs["_field"];
$NewsId = (int)$attribs["_articleid"];
if($NewsId)
{
$a = $objArticleList->GetItem($NewsId);
}
else
{
$a = $objArticleList->GetCurrentItem();
}
if(strlen($field))
{
if(is_object($a))
{
$element = new clsHtmlTag();
$element->name = $a->TagPrefix;
$element->attributes = $attribs;
$o = $a->ParseObject($element);
}
else
$o = "";
}
return $o;
}
/*
@description: Parse an article item template
@attrib: _ItemTemplate:tpl: Article template to parse
@attrib: _ArticleId:: Article ID to parse (uses current article if not set)
*/
function n_news_detail($attribs = array())
{
global $objArticleList,$n_var_list;
$t = $attribs["_itemtemplate"];
if(strlen($t))
{
$NewsId = (int)$attribs["_articleid"];
if($NewsId)
{
$news =& $objArticleList->GetItem($NewsId);
}
else
$news =& $objArticleList->GetItem($n_var_list["id"]);
if(is_object($news))
{
$o = $news->ParseTemplate($t);
}
}
return $o;
}
/*
@description: returns the date of the last review for an article
@attrib: _Part:: part of the date to display
@attrib: _ArticleId:int: if set, the link to display the review modified date
@example:
*/
function n_review_modified($attribs)
{
global $objConfig, $objArticleList;
$NewsId = (int)$attribs["_articleid"];
if($NewsId)
{
$a = $objArticleList->GetItem($NewsId);
}
else
$a = $objArticleList->GetCurrentItem();
if(is_object($a))
{
$ado = &GetADODBConnection();
$ResId = $a->Get("ResourceId");
$sql = "SELECT MAX(CreatedOn) as ModDate FROM ".GetTablePrefix()."ItemReview WHERE ItemId=$ResId AND Status=1 LIMIT 1";
$rs = $ado->Execute($sql);
if($rs && ! $rs->EOF)
{
$mod = $rs->fields["ModDate"];
if($mod)
{
$part = strtolower($attribs["_part"]);
if(strlen($part))
{
$ret = ExtractDatePart($part,$mod);
}
else
{
$ret = LangDate($mod);
}
}
}
}
return $ret;
}
/*
@description: Returns a list of reviews for an article
@attrib: _ArticleId:int: the link to use (If not set, the current article is used)
@attrib: _ShortList:bool: If set, uses the shortlist configuration value for article reviews
@attrib: _ReviewTemplate:tpl: template used to display the reviews
*/
function n_list_reviews($attribs = array())
{
global $objArticleList,$content_set, $n_var_list;
$NewsId = (int)$attribs["_articleid"];
if($NewsId)
{
$a =& $objArticleList->GetItem($NewsId);
}
else
$a =& $objArticleList->GetCurrentItem();
if(is_object($a))
{
if($a->ReviewsLoaded()==0)
{
if($attribs["_shortlist"])
{
$a->ReviewPerPageVar = "Perpage_NewsReviews_Short";
}
else
{
$a->ReviewPerPageVar = "Perpage_NewsReviews";
}
$ReviewList =& $a->GetItemReviews($n_var_list["rp"]);
}
else
$ReviewList =& $a->Reviews;
$o = "";
$t = $attribs["_reviewtemplate"];
if($ReviewList->NumItems()>0 && strlen($t))
{
foreach($ReviewList->Items as $r)
{
$o .= $r->ParseTemplate($t);
$i++;
}
}
}
if(!strlen($o))
$content_set =0;
return $o;
}
/*
@description: Used in conjuction with n_list_reviews. This function generates a navigation link which is
used to switch from a short list to a longer list. The page number is not changed.
If this tag is called before the list tag, this function will load the review list.
Any extra HTML attributes are passed to the anchor tag used to create the link.
@attrib: _ArticleId:: If set, the this value is used for a Article ID (default to the current link)
@attrib: _root:bool: If set, the current category is set to In-News's root category
@attrib: _text:lang: language tag to include as text for the anchor tag
@attrib: _Template:tpl: Destination template of More link
@attrib: _plaintext:: plain text to include as text for the anchor tag. The _text attribute takes presedence
if both are included.
@attrib: _ShortList:bool: If set, uses the shortlist configuration value for article reviews
@attrib: _image:: URL to an image to include inside the anchor tag.
*/
function n_review_more($attribs)
{
global $objArticleList, $objConfig;
$html_attribs = ExtraAttributes($attribs);
$DestTemplate = $attribs["_template"];
$NewsId = (int)$attribs["_articleid"];
if($NewsId)
{
$a =& $objArticleList->GetItem($NewsId);
}
else
$a =& $objArticleList->GetCurrentItem();
if(is_object($a))
{
if($a->ReviewsLoaded()==0)
{
if($attribs["_shortlist"])
{
$a->ReviewPerPageVar = "Perpage_NewsReviews_Short";
}
else
{
$a->ReviewPerPageVar = "Perpage_NewsReviews";
}
$ReviewList =& $a->GetItemReviews($n_var_list["rp"]);
}
else
$ReviewList =& $a->Reviews;
if($ReviewList->ItemCount() < $ReviewList->QueryItemCount)
{
if($attribs["_root"])
{
$url = n_root_link($attribs);
}
else
$url = m_template_link($attribs);
$o = "";
$text = $attribs["_text"];
if(!strlen($text))
{
$text = $attribs["_plaintext"];
if(!strlen($text))
{
}
$o .= $text."";
}
else
$o .= language($text);
if(strlen($attribs["_image"]))
{
$o .= "";
}
$o .= "";
}
}
return $o;
}
/*
@description: Used in conjuction with n_list_reviews. This function generates the page navigation
for the list of reviews. If this tag is called before the list tag, this function will load
the reviews. For that reason, the _ListType attribute is required if the pagnav
tag preceeds the n_list_reviews tag in the template. Generally, it is good practice to
duplicate all attributes set for n_list_reviews.
@attrib: _PagesToList:int: Number of pages to list (default is 10)
@attrib: _Template:tpl: destination template for page links (defaults to current template)
@attrib: _ShortList:bool: If set, uses the shortlist configuration value for article reviews
@attrib: _ArticleId:int: If set, the this value is used for an Article ID (default to the current link)
@attrib: _label:lang: language tag to include in the output if there are pages to list. If there are no pages
listed, this text will not be included (resulting in an empty output)
*/
function n_review_pagenav($attribs)
{
global $l_var_list, $n_var_list_update, $objArticleList;
$DestTemplate = $attribs["_template"];
$PagesToList = $attribs["_pagestolist"];
if(!is_numeric($PagesToList))
$PagesToList = 10;
$NewsId = (int)$attribs["_articleid"];
if($NewsId)
{
$a =& $objArticleList->GetItem($NewsId);
}
else
$a =& $objArticleList->GetCurrentItem();
if(is_object($a))
{
if($a->ReviewsLoaded()==0)
{
if($attribs["_shortlist"])
{
$a->ReviewPerPageVar = "Perpage_NewsReviews_Short";
}
else
{
$a->ReviewPerPageVar = "Perpage_NewsReviews";
}
$ReviewList =& $a->GetItemReviews($n_var_list["rp"]);
}
else
$ReviewList =& $a->Reviews;
$o = $ReviewList->GetPageLinkList($n_var_list_update,$DestTemplate);
}
if(strlen($o) && strlen($attribs["_label"]))
$o = language($attribs["_label"]).$o;
return $o;
}
/*
@description: Returns the number of items related to the current article
@attrib: _ItemId:int: the article to use (If not set, the current article is used)
@attrib: _ItemType:: Name of item to count (ie: _ItemType="Category,Topic")
@example:
*/
function n_related_count($attribs)
{
global $objItemTypes, $objArticleList, $content_set;
global $ArticleRelations;
$id = $attribs["_itemid"];
$item_type = strtolower($attribs["_itemtype"]);
$count = 0;
if(!is_numeric($id))
{
$c =& $objArticleList->GetCurrentItem();
}
else
$c =& $objArticleList->GetItem($id);
if(is_object($c))
{
$ResourceId = $c->Get("ResourceId");
if(!is_object($ArticleRelations))
{
$ArticleRelations = new clsMultiTypeList();
LoadRelatedItems($Related, $ArticleRelations,$c->Get("ResourceId"));
}
if(strlen($attribs["_itemtype"]))
{
$objType = $objItemTypes->GetTypeByName($item_type);
if(is_object($objType))
{
$TargetType = $objType->Get("ItemType");
}
else
$TargetType="";
}
if($ArticleRelations->NumItems()>0)
{
for($x=0;$x<$ArticleRelations->NumItems();$x++)
{
$a = $ArticleRelations->GetItemByIndex($x);
if($a->type == $TargetType || !strlen($TargetType))
{
$count++;
}
}
}
}
return $count;
}
/*
@description: List items related to the current article
@attrib: _ItemId:int: the article to use (If not set, the current article is used)
@attrib: _ListItems:: List of item types to include (ie: _ListItems="Category,Topic")
@attrib: _*Template:none: For each item type lsted in _ListItems, an item type template must be included
(ie: _CategoryTemplate=".." _TopicTemplate="..")
@example:
*/
function n_related_items($attribs)
{
global $objItemTypes, $objArticleList, $objCatList, $content_set, $objSession;
static $Related;
global $ArticleRelations;
// echo ""; print_r($ArticleRelations); echo "
";
$id = $attribs["_itemid"];
if(!is_numeric($id))
{
$c =& $objArticleList->GetCurrentItem();
}
else
$c =& $objArticleList->GetItem($id);
$data_sent=0;
if(is_object($c))
{
$ResourceId = $c->Get("ResourceId");
$IncludeList = explode(",",trim(strtolower($attribs["_listitems"])));
$o = "";
if(!is_object($ArticleRelations))
{
$ArticleRelations = new clsMultiTypeList();
LoadRelatedItems($Related, $ArticleRelations,$c->Get("ResourceId"));
}
if($ArticleRelations->NumItems()>0)
{
for($inc=0;$incGetTypeByName($item_type);
if(is_object($objType))
{
foreach($ArticleRelations->Items as $item)
{
if(is_object($item))
{
if(strtolower($objType->Get("ItemName")) == strtolower($item_type) && $item->type==$objType->Get("ItemType"))
{
if(strlen($item->BasePermissionName))
{
$perm = $item->BasePermissionName.".VIEW";
$haspem = $objSession->HasCatPermission($perm,$item->Get("CategoryId"));
}
else
$hasperm = 1;
if($hasperm)
{
$data_sent =1;
$classname = $objType->Get("ClassName");
if(strlen($classname))
{
$l = new $classname;
$l->Data = $item->Data;
$o .= $l->ParseTemplate($t);
}
}
}
}
$item = NULL;
}
}
else
echo $item_type." not found
\n";
}
}
if($data_sent)
{
return $o;
}
else
{
$content_set=0;
return "";
}
}
else
{
$content_set = 0;
return "";
}
}
else
{
$content_set = 0;
return "";
}
}
/*
@description: Generates the ACTTION property for a FORM tag used by In-Link
@attrib: _Template:tpl: If set, this is the template the form submits to (default is the current template)
@attrib: _Form:: The form name
Possible Values:
- n_rate: Form used to rate an article
- n_rate_confirm: Confirm for rate article
- n_addreview: add a review for an article
- n_review_confirm: Review confirmation
- n_sort_articles: Sort articles
- n_getting_rated: Form for external rating
@example: ">
*/
function n_form_action($attribs = array())
{
global $var_list_update, $var_list, $n_var_list_update, $objSession, $objArticleList;
$var_list_update['t'] = getArrayValue($attribs, '_template') ? $attribs['_template'] : $var_list['t'];
if( is_object($objArticleList) && $objArticleList->CurrentItem ) $n_var_list_update['id'] = $objArticleList->CurrentItem;
$ret = '';
$form = strtolower( $attribs['_form'] );
$url_params = Array();
switch($form)
{
case 'n_addreview':
if( !$objSession->SessionEnabled() )
{
$var_list_update['t'] = 'error_session';
}
else
{
$url_params = Array( 'Action' => 'n_add_review', 'DestTemplate' => $attribs['_finishtemplate'] );
if ( $objSession->HasCatPermission('NEWS.REVIEW.PENDING') )
{
$url_params['Confirm'] = $attribs[ getArrayValue($attribs, '_confirmpending') ? '_confirmpending' : '_confirm' ];
}
if ( $objSession->HasCatPermission('NEWS.REVIEW') )
{
$url_params['Confirm'] = $attribs['_confirm'];
}
$n_var_list_update['id'] = $objArticleList->CurrentItem;
if( !$url_params['Confirm'] ) unset($url_params['Confirm']);
}
break;
case 'n_review_confirm':
$var_list_update['t'] = getArrayValue($_GET, 'DestTemplate') ? $_GET['DestTemplate'] : $var_list['t'];
$n_var_list_update['id'] = $objArticleList->CurrentItem;
break;
case 'n_rate':
if( !$objSession->SessionEnabled() )
{
$var_list_update['t'] = 'error_session';
}
else
{
$url_params = Array( 'Action' => 'n_rate_news', 'DestTemplate' => $attribs['_finishtemplate'] );
if ( $objSession->HasCatPermission('NEWS.RATE') && getArrayValue($attribs, '_confirm') ) $url_params['Confirm'] = $attribs['_confirm'];
$n_var_list_update['id'] = $objArticleList->CurrentItem;
if( getArrayValue($attribs, '_duplicate') ) $url_params['Duplicate'] = $attribs['_duplicate'];
}
break;
case 'n_getting_rated':
if( !$objSession->SessionEnabled() )
{
$var_list_update['t'] = 'error_session';
}
else
{
$url_params = Array( 'Action' => 'n_rate_news', 'DestTemplate' => $attribs['_finishtemplate'] );
if ( $objSession->HasCatPermission('NEWS.RATE') && getArrayValue($attribs, '_confirm') ) $url_params['Confirm'] = $attribs['_confirm'];
$n_var_list_update['id'] = $objArticleList->CurrentItem;
$var_list_update['t'] = 'innews/rate';
if( getArrayValue($attribs, '_duplicate') ) $url_params['Duplicate'] = $attribs['_duplicate'];
}
break;
case 'n_rate_confirm':
$var_list_update['t'] = getArrayValue($_GET, 'DestTemplate') ? $_GET['DestTemplate'] : $var_list['t'];
$n_var_list_update['id'] = $objArticleList->CurrentItem;
break;
case 'n_sort_articles':
$url_params = Array('Action' => 'n_sort_articles');
break;
}
return HREF_Wrapper('', $url_params);
}
?>