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

cms/widgets/slider/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 }
00022 global $sourceFolder;
00023 require_once("$sourceFolder/widgetFramework.class.php");
00024 
00025 class slider extends widgetFramework
00026 {
00027         public $configs;
00028         public $images;
00029         public $slidertype;
00030         public $width;
00031         public $height;
00032         public $speed;
00033         public $effect;
00034         public $gjs;
00035         public $makeunique;
00036         public $divid;
00037         public $divclass;
00038         public $ulclass;
00039         public $ulid;
00040         
00041         public function __construct($widgetId,$widgetInstanceId,$pageId)
00042         {
00043                 $this->configs = array (
00044                         array (
00045                         'name' => 'images',
00046                         'type' => 'textarea',
00047                         'displaytext' => 'Image (Specify the images like image_text [image_link]) (Use | to separate two images)',
00048                         'default' => 'Image_text [http://pragyan.org/home/a.jpg] | [http://pragyan.org/home/b.jpg]',
00049                         'global' => 0
00050                         ),
00051                         array (
00052                         'name' => 'slidertype',
00053                         'type' => 'select',
00054                         'options' => 'None|Advanced Slider',
00055                         'displaytext' => 'Select the slider type',
00056                         'default' => 'None',
00057                         'global' => 0
00058                         ),
00059                         array (
00060                         'name' => 'width',
00061                         'type' => 'text',
00062                         'displaytext' => 'Image Width',
00063                         'default' => '',
00064                         'global' => 0
00065                         ),
00066                         array (
00067                         'name' => 'height',
00068                         'type' => 'text',
00069                         'displaytext' => 'Image Height',
00070                         'default' => '',
00071                         'global' => 0
00072                         ),
00073                         array (
00074                         'name' => 'speed',
00075                         'type' => 'text',
00076                         'displaytext' => 'Speed of the slider',
00077                         'default' => '3000',
00078                         'global' => 0
00079                         ),
00080                         array (
00081                         'name' => 'effect',
00082                         'type' => 'select',
00083                         'options' => 'random|swirl|rain|straight',
00084                         'displaytext' => 'Select the effect',
00085                         'default' => 'random',
00086                         'global' => 0
00087                         ),
00088                         array (
00089                         'name' => 'noinput1',
00090                         'type' => 'noinput',
00091                         'displaytext' => '<b>Below is the list of advanced options for Advance Slider. If you are not using it, please leave them as it is.</b>',
00092                         'global' => 0
00093                         ),
00094                         
00095                         array (
00096                         'name' => 'makeunique',
00097                         'type' => 'bool',
00098                         'displaytext' => 'Make the IDs unique automatically by appending a unique number ?',
00099                         'default' => '1',
00100                         'global' => 0
00101                         ),
00102                         array (
00103                         'name' => 'divclass',
00104                         'type' => 'text',
00105                         'displaytext' => 'DIV Class',
00106                         'default' => '',
00107                         'global' => 0
00108                         ),
00109                         array (
00110                         'name' => 'divid',
00111                         'type' => 'text',
00112                         'displaytext' => 'DIV ID',
00113                         'default' => 'slider_',
00114                         'global' => 0
00115                         ),
00116                         array (
00117                         'name' => 'ulclass',
00118                         'type' => 'text',
00119                         'displaytext' => 'UL Class',
00120                         'default' => '',
00121                         'global' => 0
00122                         ),
00123                         array (
00124                         'name' => 'ulid',
00125                         'type' => 'text',
00126                         'displaytext' => 'UL ID',
00127                         'default' => '',
00128                         'global' => 0
00129                         ),
00130                         array (
00131                         'name' => 'global_disable',
00132                         'type' => 'bool',
00133                         'displaytext' => 'Disable Slider',
00134                         'default' => '0',
00135                         'global' => 1
00136                         ),
00137                         array (
00138                         'name' => 'global_jsenable',
00139                         'type' => 'select',
00140                         'options' => 'yes|no',
00141                         'displaytext' => 'Enable Javascript?',
00142                         'default' => 'yes',
00143                         'global' => 1
00144                         )
00145                 );
00146                 parent::__construct($widgetId,$widgetInstanceId,$pageId,$this->configs);
00147                 
00148         }
00149         
00150         
00151         public function initWidget()
00152         {
00153                 $this->images = $this->settings['images'];
00154                 $this->slidertype = $this->settings['slidertype'];
00155                 $this->width = $this->settings['width'];
00156                 $this->height = $this->settings['height'];
00157                 $this->speed = $this->settings['speed'];
00158                 $this->effect = $this->settings['effect'];
00159                 $this->makeunique = $this->settings['makeunique'];      
00160                 $this->divid = $this->settings['divid'];        
00161                 $this->divclass = $this->settings['divclass'];
00162                 $this->ulid = $this->settings['ulid'];
00163                 $this->ulclass = $this->settings['ulclass'];
00164                 $this->globaldisable = $this->settings['global_disable'];
00165                 $this->gjs = $this->settings['global_jsenable'];
00166         }       
00167         public function getCommonHTML()
00168         {
00169 
00170         }
00171         public function getHTML()
00172         {
00173                 global $urlRequestRoot,$cmsFolder;
00174                 $jsenable = 0;
00175                 if($this->globaldisable=='1' || $this->globaldisable=='Yes') return "";
00176                 if($this->gjs=='yes') $jsenable = 1;
00177                 $ran = '';
00178                 if($this->makeunique=='1' || $this->makeunique=='Yes')
00179                         $ran = $this->widgetInstanceId;
00180                 $divid = $this->divid.$ran;
00181                 $ulid = $this->ulid.$ran;
00182                 $script = '';
00183                 if($this->slidertype=="Advanced Slider")
00184                         {
00185                         $script =<<<SCRIPT
00186 <link rel="stylesheet" type="text/css" href='$urlRequestRoot/$cmsFolder/widgets/slider/coin_sloder/coin-slider-styles.css'/>
00187 <script src='$urlRequestRoot/$cmsFolder/widgets/slider/coin_slider/coin-slider.min.js' type='text/javascript'></script>
00188 <script type="text/javascript">
00189         $(document).ready(function() {
00190                 $('#$divid').coinslider({width:$this->width,height:$this->height,delay:$this->speed,effect:'$this->effect'});
00191         });
00192 </script>
00193 SCRIPT;
00194                         }
00195                 $image=explode('|',$this->images);
00196                 $imageHtml = "";                
00197                 $imageHtml .= "<div id='slider_container'>";
00198                 if($jsenable==1)
00199                         $imageHtml .= $script;          
00200                 $imageHtml .="<div class='{$this->divclass}' id='$divid'><ul id='$ulid' class='{$this->ulclass}'>";
00201                 for($i = 0; $i < count($image); $i++) {
00202                         $str = explode('[',$image[$i],2);
00203                         if(isset($str[1]))
00204                                 $link = explode(']',$str[1],2);
00205                         $imageHtml .= "<li><a href =\"#\"><img src='$link[0]' alt='$str[0]' width='$this->width' height='$this->height' >";
00206                         if($str[0]!='')
00207                                 $imageHtml .= "<span>$str[0]</span>";
00208                         $imageHtml .= "</a></li>";
00209                 }
00210                         $imageHtml .= "</ul></div></div>";
00211                         return $imageHtml;
00212         }       
00213 }
00214 
00215 ?>

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