• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

cms/widgets/news/widget.class.php

Go to the documentation of this file.
00001 <?php
00002 if(!defined('__PRAGYAN_CMS'))
00003 { 
00004         header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden');
00005         echo "<h1>403 Forbidden<h1><h4>You are not authorized to access the page.</h4>";
00006         echo '<hr/>'.$_SERVER['SERVER_SIGNATURE'];
00007         exit(1);
00008 }
00019 global $sourceFolder;
00020 require_once("$sourceFolder/widgetFramework.class.php");
00021 
00022 class news extends widgetFramework
00023 {
00024         public $configs;
00025         public $timeformat;
00026         public $globaldisable;
00027         public $news;
00028         public $js;
00029         public $num;
00030         public $gjs;
00031         public $makeunique;
00032         public $divid;
00033         public $divclass;
00034         public $ulclass;
00035         public $ulid;
00036         
00037         public function __construct($widgetId,$widgetInstanceId,$pageId)
00038         {
00039                 $this->configs = array (
00040                         array (
00041                         'name' => 'news',
00042                         'type' => 'textarea',
00043                         'displaytext' => 'News (Specify the link like News[link]) (Use | to separate two events items)',
00044                         'default' => 'News 1 : Google[http://www.google.com] | News 2 | News 3 | News 4',
00045                         'global' => 0
00046                         ),
00047                         array (
00048                         'name' => 'jsenable',
00049                         'type' => 'select',
00050                         'options' => 'yes|no',
00051                         'displaytext' => 'Enable Javascript (Ticker)?',
00052                         'default' => 'yes',
00053                         'global' => 0
00054                         ),
00055                         array (
00056                         'name' => 'number',
00057                         'type' => 'integer',
00058                         'displaytext' => 'Number of news items in one block (if js enabled)',
00059                         'default' => '3',
00060                         'global' => 0
00061                         ),
00062                         array (
00063                         'name' => 'noinput1',
00064                         'type' => 'noinput',
00065                         'displaytext' => '<b>Below is the list of advanced options. If you don\'t know how to configure them, please leave them as it is.</b>',
00066                         'global' => 0
00067                         ),
00068                         array (
00069                         'name' => 'makeunique',
00070                         'type' => 'bool',
00071                         'displaytext' => 'Make the IDs unique automatically by appending a unique number ?',
00072                         'default' => '1',
00073                         'global' => 0
00074                         ),
00075                         array (
00076                         'name' => 'divclass',
00077                         'type' => 'text',
00078                         'displaytext' => 'DIV Class',
00079                         'default' => '',
00080                         'global' => 0
00081                         ),
00082                         array (
00083                         'name' => 'divid',
00084                         'type' => 'text',
00085                         'displaytext' => 'DIV ID',
00086                         'default' => 'news_',
00087                         'global' => 0
00088                         ),
00089                         array (
00090                         'name' => 'ulclass',
00091                         'type' => 'text',
00092                         'displaytext' => 'UL Class',
00093                         'default' => '',
00094                         'global' => 0
00095                         ),
00096                         array (
00097                         'name' => 'ulid',
00098                         'type' => 'text',
00099                         'displaytext' => 'UL ID',
00100                         'default' => '',
00101                         'global' => 0
00102                         ),
00103                         array (
00104                         'name' => 'global_disable',
00105                         'type' => 'bool',
00106                         'displaytext' => 'Disable News',
00107                         'default' => '0',
00108                         'global' => 1
00109                         ),
00110                         array (
00111                         'name' => 'global_jsenable',
00112                         'type' => 'select',
00113                         'options' => 'yes|no',
00114                         'displaytext' => 'Enable Javascript (Ticker)?',
00115                         'default' => 'yes',
00116                         'global' => 1
00117                         )
00118                 );
00119                 parent::__construct($widgetId,$widgetInstanceId,$pageId,$this->configs);
00120                 
00121         }
00122         
00123         
00124         public function initWidget()
00125         {
00126                 $this->news = $this->settings['news'];
00127                 $this->js = $this->settings['jsenable'];
00128                 $this->num = $this->settings['number'];
00129                 $this->makeunique = $this->settings['makeunique'];      
00130                 $this->divid = $this->settings['divid'];        
00131                 $this->divclass = $this->settings['divclass'];
00132                 $this->ulid = $this->settings['ulid'];
00133                 $this->ulclass = $this->settings['ulclass'];
00134         
00135                 $this->globaldisable = $this->settings['global_disable'];
00136                 $this->gjs = $this->settings['global_jsenable'];
00137         }       
00138         
00139 
00140         public function getCommonHTML()
00141         {
00142         global $urlRequestRoot,$cmsFolder;
00143         $scripts ="<script src='$urlRequestRoot/$cmsFolder/templates/common/scripts/jcarousellite_1.0.1.js' type='text/javascript'></script> ";
00144         return $scripts;
00145 
00146         }
00147         public function getHTML()
00148         {
00149                 global $urlRequestRoot,$cmsFolder;
00150                 $jsenable = 0;
00151                 if($this->globaldisable=='1' || $this->globaldisable=='Yes') return "";
00152                 if($this->js=='yes' && $this->gjs=='yes') $jsenable = 1;
00153                         
00154                 $num = $this->num;
00155                 
00156                 $ran = '';
00157                 if($this->makeunique=='1' || $this->makeunique=='Yes')
00158                         $ran = $this->widgetInstanceId;
00159         
00160                 
00161                 $divid = $this->divid.$ran;
00162                 $ulid = $this->ulid.$ran;
00163                 
00164                 $style =<<<STYLE
00165 <style type="text/css">
00166 #$divid ul {
00167 list-style:none;
00168 }
00169 #$divid ul a{
00170 text-decoration:none;
00171 }
00172 </style>
00173 STYLE;
00174                 $script =<<<SCRIPT
00175 <script type="text/javascript">  
00176 $(function() {  
00177 $("#$divid").jCarouselLite({  
00178         vertical: true,  
00179         visible: $num,  
00180         auto:500,  
00181         speed:1000  
00182     });  
00183 });  
00184 </script>  
00185 SCRIPT;
00186                 $news=explode('|',$this->news);
00187                 $newsHtml = "";         
00188                 $newsHtml .= $style."<div id='news_container'>";
00189                 if($jsenable==1)
00190                         $newsHtml .= $script;           
00191                 $newsHtml .="<div class='{$this->divclass}' id='$divid'><ul id='$ulid' class='{$this->ulclass}'>";
00192                 for($i = 0; $i < count($news); $i++) {
00193                         $str = explode('[',$news[$i],2);
00194                         if(isset($str[1]))
00195                                 $link = explode(']',$str[1],2);
00196                         else
00197                                 $link = '#';
00198                         $newsHtml .= "<li><a href =\"$link[0]\">$str[0]</a><br /></li>";
00199                 }
00200                         $newsHtml .= "</ul></div></div>";
00201                         return $newsHtml;
00202         }       
00203 }
00204 
00205 ?>

Generated on Sun Jan 2 2011 04:55:32 for Pragyan CMS by  doxygen 1.7.1