Example #1
0
/**
* Notes about the spotlight :
* If you have restricted topics on index page (in fact if the program must completly respect the permissions) and if
* the news you have selected to be viewed in the spotlight can't be viewed by someone then the spotlight is not visible !
* This is available in the classical and in the tabbed view.
* But if you have uncheck the option "Restrict topics on index page", then the news will be visible but users without
* permissions will be rejected when they will try to read news content.
*
* Also, if you have selected a tabbed view and wanted to use the Spotlight but did not choosed a story, then the block
* will switch to the "most recent news" mode (the visible news will be searched according to the permissions)
*/
function nw_b_news_top_show($options) {
	global $xoopsConfig;
    include_once NW_MODULE_PATH . '/include/functions.php';
	$myts =& MyTextSanitizer::getInstance();
	$block = array();
	$displayname = nw_getmoduleoption('displayname', NW_MODULE_DIR_NAME);
	$tabskin = nw_getmoduleoption('tabskin', NW_MODULE_DIR_NAME);

	if (file_exists(NW_MODULE_PATH . '/language/'.$xoopsConfig['language'].'/main.php')) {
		include_once NW_MODULE_PATH . '/language/'.$xoopsConfig['language'].'/main.php';
	} else {
		include_once NW_MODULE_PATH . '/language/english/main.php';
	}

	$block['displayview']=$options[8];
	$block['tabskin']=$tabskin;
	$block['imagesurl']= NW_MODULE_URL . '/images/';
	
	//DNPROSSI ADDED
	$block['newsmodule_url']= NW_MODULE_URL;

	$restricted=nw_getmoduleoption('restrictindex', NW_MODULE_DIR_NAME);
	$dateformat=nw_getmoduleoption('dateformat', NW_MODULE_DIR_NAME);
	$infotips=nw_getmoduleoption('infotips', NW_MODULE_DIR_NAME);
	$newsrating=nw_getmoduleoption('ratenews', NW_MODULE_DIR_NAME);
	if($dateformat=='') {
		$dateformat='s';
	}

	$perm_verified=false;
	$news_visible=true;
	// Is the spotlight visible ?
	if($options[4]==1 && $restricted && $options[5]==0) {
		$perm_verified=true;
		$permittedtopics=nw_MygetItemIds();
		$permstory = new nw_NewsStory($options[6]);
		if(!in_array($permstory->topicid(),$permittedtopics)) {
			$usespotlight=false;
			$news_visible = false;
			$topicstitles=array();
		}
		$options[4]==0;
	}
	// Try to see what tabs are visibles (if we are in restricted view of course)
	if($options[8]==2 && $restricted && $options[14] != 0) {
		$topics2=array();
		$permittedtopics=nw_MygetItemIds();
        $topics = array_slice($options, 14);
		foreach($topics as $onetopic) {
			if(in_array($onetopic,$permittedtopics)) {
				$topics2[]=$onetopic;
			}
		}
		$before=array_slice($options, 0,14);
		$options=array_merge($before,$topics2);
	}

	if($options[8]==2) {		// Tabbed view ********************************************************************************************
		$defcolors[1]=array('#F90','#FFFFFF','#F90','#C60','#999');		// Bar Style
		$defcolors[2]=array('#F90','#FFFFFF','#F90','#AAA','#666');		// Beveled
		$defcolors[3]=array('#F90','#FFFFFF','','#789','#789');			// Classic
		$defcolors[4]=array('#F90','#FFFFFF','','','');					// Folders
		$defcolors[5]=array('#F90','#FFFFFF','#CCC','inherit','#999');	// MacOs
		$defcolors[6]=array('#F90','#FFFFFF','#FFF','#DDD','#999');		// Plain
		$defcolors[7]=array('#F90','#FFFFFF','','','');					// Rounded
		$defcolors[8]=array('#F90','#FFFFFF','#F90','#930','#C60');		// ZDnet

		$myurl=$_SERVER['PHP_SELF'];
		if(substr($myurl,strlen($myurl)-1,1) == '/') {
			$myurl.='index.php';
		}
		$myurl.='?';

		foreach($_GET as $key => $value) {
			if($key!='nwTab') {
				$myurl.=$key.'='.$value.'&';
			}
		}
		$block['url']=$myurl;

		$tabscount=0;
		$usespotlight=false;

		if(isset($_GET['nwTab'])) {
			$_SESSION['nwTab']=intval($_GET['nwTab']);
			$currenttab = intval($_GET['nwTab']);
		} elseif(isset($_SESSION['nwTab'])) {
			$currenttab = intval($_SESSION['nwTab']);
		} else {
			$currenttab=0;
		}

		$tmpstory = new nw_NewsStory();
		$topic= new nw_NewsTopic();
		$topicstitles=array();
		if($options[4]==1) {	// Spotlight enabled
			$topicstitles[0]=_MB_NW_SPOTLIGHT_TITLE;
			$tabscount++;
			$usespotlight=true;
		}

		if($options[5]==0 && $restricted) {	// Use a specific news and we are in restricted mode
			if(!$perm_verified) {
				$permittedtopics=nw_MygetItemIds();
				$permstory = new nw_NewsStory($options[6]);
				if(!in_array($permstory->topicid(),$permittedtopics)) {
					$usespotlight=false;
					$topicstitles=array();
				}
				//unset($permstory);
			} else {
				if(!$news_visible) {
					$usespotlight=false;
					$topicstitles=array();
				}
			}
		}

		$block['use_spotlight']=$usespotlight;

    	if (isset($options[14]) && $options[14] != 0) {		// Topic to use
	        $topics = array_slice($options, 14);
        	$tabscount+=count($topics);
			$topicstitles=$topic->getTopicTitleFromId($topics,$topicstitles);
    	}
    	$tabs=array();
    	if($usespotlight) {
    		$tabs[]=array('id'=>0,'title'=>_MB_NW_SPOTLIGHT_TITLE);
    	}
    	if(count($topics)>0) {
    		foreach($topics as $onetopic) {
    			if(isset($topicstitles[$onetopic])) {
	    			$tabs[]=array('id'=>$onetopic, 'title'=>$topicstitles[$onetopic]['title'], 'picture'=>$topicstitles[$onetopic]['picture']);
	    		}
    		}
    	}
    	$block['tabs']=$tabs;
    	$block['current_is_spotlight']=false;
    	$block['current_tab']=$currenttab;
    	$block['use_rating']=$newsrating;


		if($currenttab==0 && $usespotlight) {	// Spotlight or not ?
			$block['current_is_spotlight']=true;
			if($options[5]==0 && $options[6]==0) {	// If the story to use was no selected then we switch to the "recent news" mode.
				$options[5]=1;
			}

			if($options[5]==0) {	// Use a specific news
				if(!isset($permstory)) {
					$tmpstory->nw_NewsStory($options[6]);
				} else {
					$tmpstory = $permstory;
				}
			} else {				// Use the most recent news
				$stories=array();
				$stories=$tmpstory->getAllPublished(1,0,$restricted,0,1,true,$options[0]);
				if(count($stories)>0)
				{
                	$firststory=$stories[0];
                	$tmpstory->nw_NewsStory($firststory->storyid());
				} else {
					$block['use_spotlight']=false;
				}
			}
        	$spotlight = array();
			$spotlight['title'] = $tmpstory->title();
       		if ($options[7] != '') {
	        	$spotlight['image'] = sprintf("<a href='%s'>%s</a>", NW_MODULE_URL . '/article.php?storyid='.$tmpstory->storyid(),$myts->displayTarea($options[7], $tmpstory->nohtml));
			}
       		$spotlight['text'] = $tmpstory->hometext();

       		// Added 16 february 2007 *****************************************
       		$story_user = null;
			$story_user = new XoopsUser($tmpstory->uid());
			if(is_object($story_user)) {
	       		$spotlight['avatar'] = XOOPS_UPLOAD_URL.'/'.$story_user->getVar('user_avatar');
	       	}
			// ****************************************************************
       		$spotlight['id'] = $tmpstory->storyid();
       		$spotlight['date'] = formatTimestamp($tmpstory->published(), $dateformat);
       		$spotlight['hits'] = $tmpstory->counter();
       		$spotlight['rating'] = number_format($tmpstory->rating(), 2);
       		$spotlight['votes'] = $tmpstory->votes();
			if(strlen(xoops_trim($tmpstory->bodytext()))>0) {
				$spotlight['read_more']=true;
			} else {
				$spotlight['read_more']=false;
			}

       		$spotlight['readmore'] = sprintf("<a href='%s'>%s</a>", NW_MODULE_URL . '/article.php?storyid='.$tmpstory->storyid(),_MB_NW_READMORE);
       		$spotlight['title_with_link'] = sprintf("<a href='%s'>%s</a>", NW_MODULE_URL . '/article.php?storyid='.$tmpstory->storyid(),$tmpstory->title());
       		if($tmpstory->votes()==1) {
				$spotlight['number_votes']=_MA_NW_ONEVOTE;
			} else {
				$spotlight['number_votes']=sprintf(_MA_NW_NUMVOTES,$tmpstory->votes());
			}

       		$spotlight['votes_with_text']=sprintf(_MA_NW_NUMVOTES,$tmpstory->votes());
       		$spotlight['topicid'] = $tmpstory->topicid();
       		$spotlight['topic_title'] = $tmpstory->topic_title();
			// Added, topic's image and description
   			$spotlight['topic_image']=NW_TOPICS_FILES_URL . '/'.$tmpstory->topic_imgurl();
   			$spotlight['topic_description']=$myts->displayTarea($tmpstory->topic_description,1);

           	if($displayname!=3) {
        		$spotlight['author'] = sprintf("%s %s",_POSTEDBY,$tmpstory->uname());
       			$spotlight['author_with_link'] = sprintf("%s <a href='%s'>%s</a>",_POSTEDBY,XOOPS_URL.'/userinfo.php?uid='.$tmpstory->uid(),$tmpstory->uname());
       		} else {
        		$spotlight['author'] = '';
       			$spotlight['author_with_link'] = '';
       		}
       		$spotlight['author_id'] = $tmpstory->uid();

			// Create the summary table under the spotlight text
			if (isset($options[14]) && $options[14] == 0) {		// Use all topics
	        	$stories = $tmpstory->getAllPublished($options[1],0,$restricted,0,1,true,$options[0]);
   			} else {					// Use some topics
	        	$topics = array_slice($options, 14);
       			$stories = $tmpstory->getAllPublished($options[1],0,$restricted,$topics,1,true,$options[0]);
   			}
   			if(count($stories)>0) {
   				foreach ($stories as $key => $story) {
					$news = array();
	    			$title = $story->title();
					if (strlen($title) > $options[2]) {
						$title = xoops_substr($title,0,$options[2]+3);
					}
           			$news['title'] = $title;
           			$news['id'] = $story->storyid();
           			$news['date'] = formatTimestamp($story->published(), $dateformat);
           			$news['hits'] = $story->counter();
           			$news['rating'] = number_format($story->rating(), 2);
           			$news['votes'] = $story->votes();
           			$news['topicid'] = $story->topicid();
           			$news['topic_title'] = $story->topic_title();
           			$news['topic_color'] = '#'.$myts->displayTarea($story->topic_color);
           			if($displayname!=3) {
	            		$news['author']= sprintf("%s %s",_POSTEDBY,$story->uname());
           			} else {
	            		$news['author']= '';
           			}
            		if ($options[3] > 0) {
            			$html = $story->nohtml() == 1 ? 0 : 1;
		        		$news['teaser'] = nw_truncate_tagsafe($myts->displayTarea($story->hometext(), $html), $options[3]+3);
           			} else {
			        	$news['teaser'] = '';
           			}
					if($infotips>0) {
						$news['infotips'] = ' title="'.nw_make_infotips($story->hometext()).'"';
					} else {
						$news['infotips'] = '';
					}

           			$news['title_with_link'] = sprintf("<a href='%s'%s>%s</a>", NW_MODULE_URL . '/article.php?storyid='.$story->storyid(),$news['infotips'],$title);
           			$spotlight['news'][] = $news;
           		}
			}

			$block['spotlight'] = $spotlight;
		} else {
			if($tabscount>0) {
	       		$topics = array_slice($options, 14);
       			$thetopic=$currenttab;
       			$stories = $tmpstory->getAllPublished($options[1],0,$restricted,$thetopic,1,true,$options[0]);

       			$topic->getTopic($thetopic);
       			// Added, topic's image and description
       			$block['topic_image']= NW_TOPICS_FILES_URL . '/'.$topic->topic_imgurl();
       			$block['topic_description']=$topic->topic_description();

    			$smallheader=array();
    			$stats=$topic->getTopicMiniStats($thetopic);
    			$smallheader[]=sprintf("<a href='%s'>%s</a>", NW_MODULE_URL . '/index.php?storytopic='.$thetopic,_MB_NW_READMORE);
    			$smallheader[]=sprintf("%u %s",$stats['count'],_MA_NW_ARTICLES);
    			$smallheader[]=sprintf("%u %s",$stats['reads'],_READS);
				if(count($stories)>0) {
    				foreach ($stories as $key => $story) {
				        $news = array();
		        		$title = $story->title();
						if (strlen($title) > $options[2]) {
							$title = nw_truncate_tagsafe($title, $options[2]+3);
						}
            			if ($options[7] != '') {
			                $news['image'] = sprintf("<a href='%s'>%s</a>", NW_MODULE_URL . '/article.php?storyid='.$story->storyid(),$myts->displayTarea($options[7], $story->nohtml));
            			}
                		if($options[3]>0) {
		                	$html = $story->nohtml() == 1 ? 0 : 1;
		                	$news['text'] = nw_truncate_tagsafe($myts->displayTarea($story->hometext(), $html), $options[3]+3);
                		} else {
							$news['text'] = '';
                		}

		            	if($story->votes()==1) {
							$news['number_votes']=_MA_NW_ONEVOTE;
						} else {
							$news['number_votes']=sprintf(_MA_NW_NUMVOTES,$story->votes());
						}
						if($infotips>0) {
							$news['infotips'] = ' title="'.nw_make_infotips($story->hometext()).'"';
						} else {
							$news['infotips'] = '';
						}
            			$news['title']=sprintf("<a href='%s' %s>%s</a>", NW_MODULE_URL . '/article.php?storyid='.$story->storyid(),$news['infotips'],$title);
            			$news['id'] = $story->storyid();
            			$news['date'] = formatTimestamp($story->published(), $dateformat);
            			$news['hits'] = $story->counter();
            			$news['rating'] = number_format($story->rating(), 2);
            			$news['votes'] = $story->votes();
            			$news['topicid'] = $story->topicid();
            			$news['topic_title'] = $story->topic_title();
            			$news['topic_color'] = '#'.$myts->displayTarea($story->topic_color);

						if($displayname!=3) {
	            			$news['author'] = sprintf("%s %s",_POSTEDBY,$story->uname());
            			} else {
	            			$news['author'] = '';
            			}
            			$news['title_with_link'] = sprintf("<a href='%s'%s>%s</a>", NW_MODULE_URL . '/article.php?storyid='.$story->storyid(),$news['infotips'],$title);
            			$block['news'][] = $news;
            		}
            		$block['smallheader']=$smallheader;
            	}
			}
		}
    	$block['lang_on']=_ON;							// on
    	$block['lang_reads']=_READS;					// reads
    	// Default values
    	$block['color1']=$defcolors[$tabskin][0];
    	$block['color2']=$defcolors[$tabskin][1];
    	$block['color3']=$defcolors[$tabskin][2];
    	$block['color4']=$defcolors[$tabskin][3];
    	$block['color5']=$defcolors[$tabskin][4];

		if(xoops_trim($options[9])!='') {
			$block['color1']=$options[9];
		}
		if(xoops_trim($options[10])!='') {
			$block['color2']=$options[10];
		}
		if(xoops_trim($options[11])!='') {
			$block['color3']=$options[11];
		}
		if(xoops_trim($options[12])!='') {
			$block['color4']=$options[12];
		}
		if(xoops_trim($options[13])!='') {
			$block['color5']=$options[13];
		}
    } else {		// ************************ Classical view **************************************************************************************************************
		$tmpstory = new nw_NewsStory;
    	if (isset($options[14]) && $options[14] == 0) {
	        $stories = $tmpstory->getAllPublished($options[1],0,$restricted,0,1,true,$options[0]);
	    } else {
        	$topics = array_slice($options, 14);
        	$stories = $tmpstory->getAllPublished($options[1],0,$restricted,$topics,1,true,$options[0]);
    	}

    	if(!count($stories)) {
	    	return '';
	    }
	    $topic= new nw_NewsTopic();

	    foreach ($stories as $key => $story) {
        	$news = array();
        	$title = $story->title();
			if (strlen($title) > $options[2]) {
				$title = xoops_substr($title,0,$options[2]+3);
			}

        	//if spotlight is enabled and this is either the first article or the selected one
        	if (($options[5]==0) && ($options[4] == 1) && (($options[6] > 0 && $options[6] == $story->storyid()) || ($options[6] == 0 && $key == 0))) {
        		$spotlight = array();
				$visible=true;
        		if($restricted) {
        			$permittedtopics=nw_MygetItemIds();
        			if(!in_array($story->topicid(),$permittedtopics)) {
        				$visible=false;
        			}
        		}

        		if($visible) {
            		$spotlight['title'] = $title;
            		if ($options[7] != '') {
		                $spotlight['image']= sprintf("<a href='%s'>%s</a>", NW_MODULE_URL . '/article.php?storyid='.$story->storyid(),$myts->displayTarea($options[7], $story->nohtml));
            		}
		       		// Added 16 february 2007 *****************************************
       				$story_user = null;
					$story_user = new XoopsUser($story->uid());
					if(is_object($story_user)) {
	       				$spotlight['avatar'] = XOOPS_UPLOAD_URL.'/'.$story_user->getVar('user_avatar');
	       			}
					// ****************************************************************
            		$spotlight['text'] = $story->hometext();
            		$spotlight['id'] = $story->storyid();
            		$spotlight['date'] = formatTimestamp($story->published(), $dateformat);
            		$spotlight['hits'] = $story->counter();
            		$spotlight['rating'] = $story->rating();
            		$spotlight['votes'] = $story->votes();
            		$spotlight['topicid'] = $story->topicid();
            		$spotlight['topic_title'] = $story->topic_title();
            		$spotlight['topic_color'] = '#'.$myts->displayTarea($story->topic_color);
            		// Added, topic's image and description
		   			$spotlight['topic_image']= NW_TOPICS_FILES_URL . '/'.$story->topic_imgurl();
   					$spotlight['topic_description']=$myts->displayTarea($story->topic_description,1);
   					if(strlen(xoops_trim($story->bodytext()))>0) {
   						$spotlight['read_more']=true;
   					} else {
   						$spotlight['read_more']=false;
   					}

            		if($displayname!=3) {
	            		$spotlight['author'] = sprintf("%s %s",_POSTEDBY,$story->uname());
            		} else {
	            		$spotlight['author'] = '';
            		}
            	}
            	$block['spotlight'] = $spotlight;
        	} else {
	            $news['title'] = $title;
            	$news['id'] = $story->storyid();
            	$news['date'] = formatTimestamp($story->published(), $dateformat);
            	$news['hits'] = $story->counter();
            	$news['rating'] = $story->rating();
            	$news['votes'] = $story->votes();
            	$news['topicid'] = $story->topicid();
            	$news['topic_title'] = $story->topic_title();
            	$news['topic_color'] = '#'.$myts->displayTarea($story->topic_color);
            	if($displayname!=3) {
            		$news['author']= sprintf("%s %s",_POSTEDBY,$story->uname());
            	} else {
            		$news['author']= '';
            	}
            	if ($options[3] > 0) {
	                $html = $story->nohtml() == 1 ? 0 : 1;
	                $news['teaser'] = nw_truncate_tagsafe($myts->displayTarea($story->hometext(), $html), $options[3]+3);	                
                	$news['infotips'] = '';
            	} else {
	                $news['teaser'] = '';
					if($infotips>0) {
						$news['infotips'] = ' title="'.nw_make_infotips($story->hometext()).'"';
					} else {
						$news['infotips'] = '';
					}
            	}
            	$block['stories'][] = $news;
        	}
    	}

	    // If spotlight article was not in the fetched stories
	    if (!isset($spotlight) && $options[4]) {
	    	$block['use_spotlight']=true;
	    	$visible=true;
			if($options[5]==0 && $restricted) {	// Use a specific news and we are in restricted mode
       			$permittedtopics=nw_MygetItemIds();
       			$permstory = new nw_NewsStory($options[6]);
       			if(!in_array($permstory->topicid(),$permittedtopics)) {
       				$visible=false;
       			}
       			unset($permstory);
       		}

			if($options[5]==0) {	// Use a specific news
				if($visible) {
					$spotlightArticle = new nw_NewsStory($options[6]);
				} else {
					$block['use_spotlight']=false;
				}
			} else {				// Use the most recent news
				$stories=array();
				$stories=$tmpstory->getAllPublished(1,0,$restricted,0,1,true,$options[0]);
				if(count($stories)>0) {
                	$firststory=$stories[0];
                	$spotlightArticle = new nw_NewsStory($firststory->storyid());
				} else {
					$block['use_spotlight']=false;
				}
			}
            if($block['use_spotlight']==true) {
        		$spotlight = array();
        		$spotlight['title'] = xoops_substr($spotlightArticle->title(),0,($options[2]-1));;
        		if ($options[7] != '') {
		            $spotlight['image'] = sprintf("<a href='%s'>%s</a>", NW_MODULE_URL . '/article.php?storyid='.$spotlightArticle->storyid(),$myts->displayTarea($options[7], $spotlightArticle->nohtml));
        		}
	       		// Added 16 february 2007 *****************************************
   				$story_user = null;
				$story_user = new XoopsUser($spotlightArticle->uid());
				if(is_object($story_user)) {
       				$spotlight['avatar'] = XOOPS_UPLOAD_URL.'/'.$story_user->getVar('user_avatar');
       			}
				// ****************************************************************
				$spotlight['topicid'] = $spotlightArticle->topicid();
        		$spotlight['topic_title'] = $spotlightArticle->topic_title();
        		$spotlight['topic_color'] = '#'.$myts->displayTarea($spotlightArticle->topic_color);
        		$spotlight['text'] = $spotlightArticle->hometext();
        		$spotlight['id'] = $spotlightArticle->storyid();
        		$spotlight['date'] = formatTimestamp($spotlightArticle->published(), $dateformat);
        		$spotlight['hits'] = $spotlightArticle->counter();
				$spotlight['rating'] = $spotlightArticle->rating();
				$spotlight['votes'] = $spotlightArticle->votes();
				// Added, topic's image and description
	   			$spotlight['topic_image']= NW_TOPICS_FILES_URL . '/'.$spotlightArticle->topic_imgurl();
				$spotlight['topic_description']=$myts->displayTarea($spotlightArticle->topic_description,1);
				if($displayname!=3) {
	        		$spotlight['author'] = sprintf("%s %s",_POSTEDBY,$spotlightArticle->uname());
        		} else {
					$spotlight['author'] = '';
        		}
        		if(strlen(xoops_trim($spotlightArticle->bodytext()))>0) {
					$spotlight['read_more']=true;
				} else {
					$spotlight['read_more']=false;
				}
        		$block['spotlight'] = $spotlight;
        	}
    	}
	}
	if(isset($permstory)) {
		unset($permstory);
	}
   	$block['lang_read_more'] = $myts->htmlSpecialChars(_MB_NW_READMORE);			// Read More...
   	$block['lang_orderby'] = $myts->htmlSpecialChars(_MB_NW_ORDER);			// "Order By"
   	$block['lang_orderby_date'] = $myts->htmlSpecialChars(_MB_NW_DATE);		// Published date
   	$block['lang_orderby_hits'] = $myts->htmlSpecialChars(_MB_NW_HITS);		// Number of Hits
   	$block['lang_orderby_rating'] = $myts->htmlSpecialChars(_MB_NW_RATE);	// Rating
   	$block['sort'] = $options[0];						// "published" or "counter" or "rating"
    
    // DNPROSSI SEO
    $seo_enabled = nw_getmoduleoption('nw_seo_enable', NW_MODULE_DIR_NAME);
	if ( $seo_enabled == 1 ) {
		$block['urlrewrite']= "true";
	} else { 
		$block['urlrewrite']= "false"; 
	}  
    
    return $block;
}
Example #2
0
function topicsmanager()
{
    global $xoopsDB, $xoopsConfig, $xoopsModule, $myts;
    include_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php';
    xoops_cp_header();
    adminmenu(0);
    $uploadfolder=sprintf(_AM_NW_UPLOAD_WARNING, NW_TOPICS_FILES_URL);
    $uploadirectory='/uploads/' . $xoopsModule -> dirname().'/images/topics';
    $start = isset($_GET['start']) ? intval($_GET['start']) : 0;

	$xt = new XoopsTree($xoopsDB->prefix('nw_topics'), 'topic_id', 'topic_pid');
	$topics_arr = $xt->getChildTreeArray(0,'topic_title');
	$totaltopics = count($topics_arr);
	$class='';

    echo '<h4>' . _AM_NW_CONFIG . '</h4>';
	nw_collapsableBar('topicsmanager', 'toptopicsmanager');
	echo "<img onclick=\"toggle('toptable'); toggleIcon('toptableicon');\" id='toptopicsmanager' name='toptopicsmanager' src='" . NW_MODULE_URL . "/images/close12.gif' alt='' /></a>&nbsp;"._AM_NW_TOPICSMNGR . ' (' . $totaltopics . ')'."</h4>";
	echo "<div id='topicsmanager'>";
	echo '<br />';
    echo "<div style='text-align: center;'>";
    echo "<table width='100%' cellspacing='1' cellpadding='3' border='0' class='outer'><tr class='bg3'><td align='center'>" . _AM_NW_TOPIC . "</td><td align='left'>" . _AM_NW_TOPICNAME . "</td><td align='center'>" . _AM_NW_PARENTTOPIC . "</td><td align='center'>" . _AM_NW_SUB_MENU_YESNO . "</td><td align='center'>" . _AM_NW_ACTION . "</td></tr>";
	if(is_array($topics_arr) && $totaltopics) {
		$cpt=1;
		$tmpcpt=$start;
		$ok=true;
		$output='';
		while($ok) {
			if($tmpcpt < $totaltopics) {
				$linkedit = NW_MODULE_URL . '/admin/index.php?op=topicsmanager&amp;topic_id=' . $topics_arr[$tmpcpt]['topic_id'];
				$linkdelete = NW_MODULE_URL . '/admin/index.php?op=delTopic&amp;topic_id=' . $topics_arr[$tmpcpt]['topic_id'];
				$action=sprintf("<a href='%s'>%s</a> - <a href='%s'>%s</a>",$linkedit,_AM_NW_EDIT , $linkdelete, _AM_NW_DELETE);
				$parent='&nbsp;';
				if($topics_arr[$tmpcpt]['topic_pid']>0)	{
					$xttmp = new XoopsTopic($xoopsDB->prefix('nw_topics'),$topics_arr[$tmpcpt]['topic_pid']);
					$parent = $xttmp->topic_title();
					unset($xttmp);
				}
				if($topics_arr[$tmpcpt]['topic_pid']!=0) {
					$topics_arr[$tmpcpt]['prefix'] = str_replace('.','-',$topics_arr[$tmpcpt]['prefix']) . '&nbsp;';
				} else {
					$topics_arr[$tmpcpt]['prefix'] = str_replace('.','',$topics_arr[$tmpcpt]['prefix']);
				}
				$submenu=$topics_arr[$tmpcpt]['menu'] ? _YES : _NO;
				$class = ($class == 'even') ? 'odd' : 'even';
				$output  = $output . "<tr class='".$class."'><td>" . $topics_arr[$tmpcpt]['topic_id'] . "</td><td align='left'>" . $topics_arr[$tmpcpt]['prefix'] . $myts->displayTarea($topics_arr[$tmpcpt]['topic_title']) . "</td><td align='left'>" . $parent . "</td><td>" . $submenu . "</td><td>" . $action . "</td></tr>";
			} else {
				$ok=false;
			}
			if($cpt>=nw_getmoduleoption('storycountadmin', NW_MODULE_DIR_NAME)) {
				$ok=false;
			}
			$tmpcpt++;
			$cpt++;
		}
		echo $output;
	}
	$pagenav = new XoopsPageNav( $totaltopics, nw_getmoduleoption('storycountadmin', NW_MODULE_DIR_NAME), $start, 'start', 'op=topicsmanager');
	echo "</table><div align='right'>".$pagenav->renderNav().'</div><br />';
	echo "</div></div><br />\n";

	$topic_id = isset($_GET['topic_id']) ? intval($_GET['topic_id']) : 0;
	if($topic_id>0) {
		$xtmod = new nw_NewsTopic($topic_id);
		$topic_title=$xtmod->topic_title('E');
		$topic_description=$xtmod->topic_description('E');
		$topic_rssfeed=$xtmod->topic_rssurl('E');
		$op='modTopicS';
		if(xoops_trim($xtmod->topic_imgurl())!='') {
			$topicimage=$xtmod->topic_imgurl();
		} else {
			$topicimage='blank.png';
		}
		$btnlabel=_AM_NW_MODIFY;
		$parent=$xtmod->topic_pid();
		$formlabel=_AM_NW_MODIFYTOPIC;
		$submenu=$xtmod->menu();
		$topic_frontpage=$xtmod->topic_frontpage();
		$topic_color=$xtmod->topic_color();
		unset($xtmod);
	} else {
		$topic_title='';
		$topic_frontpage=1;
		$topic_description='';
		$op='addTopic';
		$topicimage='xoops.gif';
		$btnlabel=_AM_NW_ADD;
		$parent=-1;
		$submenu=0;
		$topic_rssfeed='';
		$formlabel=_AM_NW_ADD_TOPIC;
		$topic_color='000000';
	}

	$sform = new XoopsThemeForm($formlabel, 'topicform', NW_MODULE_URL . '/admin/index.php', 'post');
	$sform->setExtra('enctype="multipart/form-data"');
	$sform->addElement(new XoopsFormText(_AM_NW_TOPICNAME, 'topic_title', 50, 255, $topic_title), true);
	$editor=nw_getWysiwygForm(_AM_NW_TOPIC_DESCR,'topic_description', $topic_description, 15, 60, '100%', '350px', 'hometext_hidden');
	if($editor) {
		$sform->addElement($editor,false);
	}

	$sform->addElement(new XoopsFormHidden('op', $op), false);
	$sform->addElement(new XoopsFormHidden('topic_id', $topic_id), false);

	include_once NW_MODULE_PATH . '/class/class.newstopic.php';
	$xt = new nw_NewsTopic();
	$sform->addElement(new XoopsFormLabel(_AM_NW_PARENTTOPIC, $xt->MakeMyTopicSelBox(1, $parent,'topic_pid','',false)));
	// Topic's color
	// Code stolen to Zoullou, thank you Zoullou ;-)
	$select_color = "\n<select name='topic_color'  onchange='xoopsGetElementById(\"NewsColorSelect\").style.backgroundColor = \"#\" + this.options[this.selectedIndex].value;'>\n<option value='000000'>"._AM_NW_COLOR."</option>\n";
	$color_values = array('000000','000033','000066','000099','0000CC','0000FF','003300','003333','003366','0033CC','0033FF','006600','006633',
							'006666','006699','0066CC','0066FF','009900','009933','009966','009999','0099CC','0099FF','00CC00','00CC33','00CC66','00CC99',
							'00CCCC','00CCFF','00FF00','00FF33','00FF66','00FF99','00FFCC','00FFFF','330000','330033','330066','330099','3300CC','3300FF',
							'333300','333333','333366','333399','3333CC','3333FF','336600','336633','336666','336699','3366CC','3366FF','339900','339933',
							'339966','339999','3399CC','3399FF','33CC00','33CC33','33CC66','33CC99','33CCCC','33CCFF','33FF00','33FF33','33FF66','33FF99',
							'33FFCC','33FFFF','660000','660033','660066','660099','6600CC','6600FF','663300','663333','663366','663399','6633CC','6633FF',
							'666600','666633','666666','666699','6666CC','6666FF','669900','669933','669966','669999','6699CC','6699FF','66CC00','66CC33',
							'66CC66','66CC99','66CCCC','66CCFF','66FF00','66FF33','66FF66','66FF99','66FFCC','66FFFF','990000','990033','990066','990099',
							'9900CC','9900FF','993300','993333','993366','993399','9933CC','9933FF','996600','996633','996666','996699','9966CC','9966FF',
							'999900','999933','999966','999999','9999CC','9999FF','99CC00','99CC33','99CC66','99CC99','99CCCC','99CCFF','99FF00','99FF33',
							'99FF66','99FF99','99FFCC','99FFFF','CC0000','CC0033','CC0066','CC0099','CC00CC','CC00FF','CC3300','CC3333','CC3366','CC3399',
							'CC33CC','CC33FF','CC6600','CC6633','CC6666','CC6699','CC66CC','CC66FF','CC9900','CC9933','CC9966','CC9999','CC99CC','CC99FF',
							'CCCC00','CCCC33','CCCC66','CCCC99','CCCCCC','CCCCFF','CCFF00','CCFF33','CCFF66','CCFF99','CCFFCC','CCFFFF','FF0000','FF0033',
							'FF0066','FF0099','FF00CC','FF00FF','FF3300','FF3333','FF3366','FF3399','FF33CC','FF33FF','FF6600','FF6633','FF6666','FF6699',
							'FF66CC','FF66FF','FF9900','FF9933','FF9966','FF9999','FF99CC','FF99FF','FFCC00','FFCC33','FFCC66','FFCC99','FFCCCC','FFCCFF',
							'FFFF00','FFFF33','FFFF66','FFFF99','FFFFCC','FFFFFF');

	foreach($color_values as $color_value) {
		if($topic_color == $color_value) {
			$selected = " selected='selected'";
		} else {
			$selected = '';
		}
		$select_color .= "<option".$selected." value='".$color_value."' style='background-color:#".$color_value.";color:#".$color_value.";'>#".$color_value."</option>\n";
	}

	$select_color .= "</select>&nbsp;\n<span id='NewsColorSelect'>&nbsp;&nbsp;&nbsp;&nbsp;</span>";
	$sform->addElement( new XoopsFormLabel( _AM_NW_TOPIC_COLOR, $select_color) );
	// Sub menu ?
	$sform->addElement(new XoopsFormRadioYN(_AM_NW_SUB_MENU, 'submenu', $submenu, _YES, _NO));
	$sform->addElement(new XoopsFormRadioYN(_AM_NW_PUBLISH_FRONTPAGE, 'topic_frontpage', $topic_frontpage, _YES, _NO));
	// Unused for this moment... sorry
	//$sform->addElement(new XoopsFormText(_AM_NW_RSS_URL, 'topic_rssfeed', 50, 255, $topic_rssfeed), false);
	// ********** Picture
	$imgtray = new XoopsFormElementTray(_AM_NW_TOPICIMG,'<br />');

	$imgpath=sprintf(_AM_NW_IMGNAEXLOC, 'uploads/' . $xoopsModule -> dirname() . '/images/topics/' );
	$imageselect= new XoopsFormSelect($imgpath, 'topic_imgurl',$topicimage);
    $topics_array = XoopsLists :: getImgListAsArray( NW_TOPICS_FILES_PATH );
    foreach( $topics_array as $image ) {
        $imageselect->addOption("$image", $image);
    }
	$imageselect->setExtra( "onchange='showImgSelected(\"image3\", \"topic_imgurl\", \"" . $uploadirectory . "\", \"\", \"" . XOOPS_URL . "\")'" );
    $imgtray->addElement($imageselect,false);
    $imgtray -> addElement( new XoopsFormLabel( '', "<br /><img src='" . XOOPS_URL . "/" . $uploadirectory . "/" . $topicimage . "' name='image3' id='image3' alt='' />" ) );

    $uploadfolder=sprintf(_AM_NW_UPLOAD_WARNING, NW_TOPICS_FILES_URL);
    $fileseltray= new XoopsFormElementTray('','<br />');
    $fileseltray->addElement(new XoopsFormFile(_AM_NW_TOPIC_PICTURE , 'attachedfile', nw_getmoduleoption('maxuploadsize', NW_MODULE_DIR_NAME)), false);
    $fileseltray->addElement(new XoopsFormLabel($uploadfolder ), false);
    $imgtray->addElement($fileseltray);
    $sform->addElement($imgtray);

	// Permissions
    $member_handler = & xoops_gethandler('member');
    $group_list = &$member_handler->getGroupList();
    $gperm_handler = &xoops_gethandler('groupperm');
    $full_list = array_keys($group_list);

	$groups_ids = array();
    if($topic_id > 0) {		// Edit mode
    	$groups_ids = $gperm_handler->getGroupIds('nw_approve', $topic_id, $xoopsModule->getVar('mid'));
    	$groups_ids = array_values($groups_ids);
    	$groups_news_can_approve_checkbox = new XoopsFormCheckBox(_AM_NW_APPROVEFORM, 'groups_news_can_approve[]', $groups_ids);
    } else {	// Creation mode
    	$groups_news_can_approve_checkbox = new XoopsFormCheckBox(_AM_NW_APPROVEFORM, 'groups_news_can_approve[]', $full_list);
    }
    $groups_news_can_approve_checkbox->addOptionArray($group_list);
    $sform->addElement($groups_news_can_approve_checkbox);

	$groups_ids = array();
    if($topic_id > 0) {		// Edit mode
    	$groups_ids = $gperm_handler->getGroupIds('nw_submit', $topic_id, $xoopsModule->getVar('mid'));
    	$groups_ids = array_values($groups_ids);
    	$groups_news_can_submit_checkbox = new XoopsFormCheckBox(_AM_NW_SUBMITFORM, 'groups_news_can_submit[]', $groups_ids);
    } else {	// Creation mode
    	$groups_news_can_submit_checkbox = new XoopsFormCheckBox(_AM_NW_SUBMITFORM, 'groups_news_can_submit[]', $full_list);
    }
    $groups_news_can_submit_checkbox->addOptionArray($group_list);
    $sform->addElement($groups_news_can_submit_checkbox);

	$groups_ids = array();
    if($topic_id > 0) {		// Edit mode
    	$groups_ids = $gperm_handler->getGroupIds('nw_view', $topic_id, $xoopsModule->getVar('mid'));
    	$groups_ids = array_values($groups_ids);
    	$groups_news_can_view_checkbox = new XoopsFormCheckBox(_AM_NW_VIEWFORM, 'groups_news_can_view[]', $groups_ids);
    } else {	// Creation mode
    	$groups_news_can_view_checkbox = new XoopsFormCheckBox(_AM_NW_VIEWFORM, 'groups_news_can_view[]', $full_list);
    }
    $groups_news_can_view_checkbox->addOptionArray($group_list);
    $sform->addElement($groups_news_can_view_checkbox);

	// Submit buttons
	$button_tray = new XoopsFormElementTray('' ,'');
	$submit_btn = new XoopsFormButton('', 'post', $btnlabel, 'submit');
	$button_tray->addElement($submit_btn);
	$sform->addElement($button_tray);
	$sform->display();
	echo "<script type='text/javascript'>\n";
	echo 'xoopsGetElementById("NewsColorSelect").style.backgroundColor = "#' . $topic_color .'";';
	echo "</script>\n";
}
Example #3
0
  	    	$bodytext = $story->bodytext('InForm');
  	    	$ihome = $story -> ihome();
  	    	$description = $story->description('E');
  	    	$keywords = $story->keywords('E');
  		}

		//Display post preview
		$newsauthor=$story->uid();
		$p_title = $story->title('Preview');
		$p_hometext = $story->hometext('Preview');
		if ($approveprivilege) {
		    $p_bodytext = $story->bodytext('Preview');
	    	$p_hometext .= '<br /><br />'.$p_bodytext;
		}
		$topicalign2 = isset($story->topicalign) ? 'align="'.$story->topicalign().'"' : '';
		$p_hometext = (($xt->topic_imgurl() != '') && $topicdisplay) ? '<img src="images/topics/'.$xt->topic_imgurl().'" '.$topicalign2.' alt="" />'.$p_hometext : $p_hometext;
		themecenterposts($p_title, $p_hometext);

		//Display post edit form
		$returnside=intval($_POST['returnside']);
		include_once NW_MODULE_PATH . '/include/storyform.inc.php';
		break;

	case 'post':
		$nohtml_db = isset($_POST['nohtml']) ? $_POST['nohtml'] : 1;
		if (is_object($xoopsUser) ) {
			$uid = $xoopsUser->getVar('uid');
			if ($approveprivilege) {
			    $nohtml_db = empty($_POST['nohtml']) ? 0 : 1;
			}
			if (isset($_POST['author']) && ($approveprivilege || $xoopsUser->isAdmin($xoopsModule->mid())) ) {