[ Index ]
 

Code source de eGroupWare 1.2.106-2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/sitemgr/sitemgr-site/inc/ -> phpnuke.compat.inc.php (source)

   1  <?php
   2      /**************************************************************************\
   3      * eGroupWare SiteMgr - Web Content Management                              *
   4      * http://www.egroupware.org                                                *
   5      * --------------------------------------------                             *
   6      *  This program is free software; you can redistribute it and/or modify it *
   7      *  under the terms of the GNU General Public License as published by the   *
   8      *  Free Software Foundation; either version 2 of the License, or (at your  *
   9      *  option) any later version.                                              *
  10      \**************************************************************************/
  11  
  12      /* $Id: phpnuke.compat.inc.php 20295 2006-02-15 12:31:25Z  $ */
  13  
  14      /******************************************************\
  15      * These functions are my attempt to improve on the     *
  16      * butt ugly phpNuke themes implementation.  Yes, I     *
  17      * know I'd be better off starting from scratch.        *
  18      \******************************************************/
  19  
  20      /******************************************************\
  21      * So here's the deal.  A theme file can have one of a  *
  22      * few different variables.  It can have a plain $var   *
  23      * variable in it that gets eval'ed to whatever.  There *
  24      * can be a phplib style {var}.  Then there can be link *
  25      * vars which look like this: {?sitemgr:page_id=1} or       *
  26      * {?phpgw:/sitemgr/index.php,cat_id=3}.  These resolve to  *
  27      * the appropriate link(file,extravars) function calls. *
  28      \******************************************************/
  29  	function add_theme_var($var, $value)
  30      {
  31          switch($var)
  32          {
  33              case 'xheader':
  34              case 'xuser':
  35              case 'xsite_name':
  36              case 'sitename':
  37                  globalize_var($var, $value);
  38                  break;
  39              case 'footer':
  40                  globalize_var('foot1',$value);
  41                  break;
  42              default:
  43                  $GLOBALS['theme_vars'][$var] = $value;
  44                  break;
  45          }
  46      }
  47  
  48  	function parse_theme_vars($html_file)
  49      {
  50          return preg_replace_callback("/\{([^{ ]+)\}/",'replace_var',$html_file);
  51      }
  52  
  53  	function replace_var($vars)
  54      {
  55          $var = $vars[1];
  56          if (substr($var,0,9)=='?sitemgr:')
  57          {
  58              $params=explode(',',substr($var,9));
  59              switch(count($params))
  60              {
  61                  case 0:
  62                      $val = '';
  63                      break;
  64                  case 1:
  65                      $val = sitemgr_link2('',$params[0]);
  66                      break;
  67                  case 2:
  68                      $val = sitemgr_link2($params[0],$params[1]);
  69                      break;
  70                  default:
  71                      $val = $var;
  72              }
  73          }
  74          elseif (substr($var,0,7)=='?phpgw:')
  75          {
  76              $params=explode(',',substr($var,7));
  77              switch(count($params))
  78              {
  79                  case 0:
  80                      $val = '';
  81                      break;
  82                  case 1:
  83                      $val = phpgw_link('',$params[0]);
  84                      break;
  85                  case 2:
  86                      $val = phpgw_link($params[0],$params[1]);
  87                      break;
  88                  default:
  89                      $val = $var;
  90              }
  91          }
  92          elseif (substr($var,0,1)=='?')
  93          {
  94              $val = sitemgr_link2('/index.php',substr($var,1));
  95          }
  96          elseif ($var == 'news')
  97          {
  98              $ui =& new ui;
  99              $val = $ui->get_news();
 100              unset($ui);
 101          }
 102          elseif (substr($var,0,6) == 'block-')
 103          {
 104              if (file_exists('blocks/'.$var.'.php'))
 105              {
 106                  $title=ereg_replace('_',' ',substr($var,6));
 107                  include 'blocks/'.$var.'.php';
 108              }
 109              else
 110              {
 111                  $title = lang('Block not found.');
 112                  $content = lang('Contact the administrator.');
 113              }
 114  
 115              add_theme_var('block_title',$title);
 116              add_theme_var('block_content',$content);
 117  
 118              if(function_exists('themecenterbox'))
 119              {
 120                  $val = themecenterbox($title, $content);
 121              }
 122              else
 123              {
 124                  $val = parse_theme_vars(implode("",file('templates/'.$GLOBALS['sitemgr_info']['themesel'].'/centerblock.tpl')));
 125              }
 126          }
 127          else
 128          {
 129              /* Check for reserved vars first, otherwise
 130                   get from the global theme_vars
 131              */
 132              switch (strtolower($var))
 133              {
 134                  case 'opentable':
 135                      $val = OpenTable();
 136                      break;
 137                  case 'opentable2':
 138                      $val = OpenTable2();
 139                      break;
 140                  case 'closetable':
 141                      $val = CloseTable();
 142                      break;
 143                  case 'closetable2':
 144                      $val = CloseTable2();
 145                      break;
 146                  default:
 147                      $val = $GLOBALS['theme_vars'][$var];
 148              }
 149          }
 150          return $val;
 151      }
 152  
 153  	function globalize_var($var, $value)
 154      {
 155          $GLOBALS[$var] = $value;
 156      }
 157  
 158      /******************************************************\
 159      * These functions are callbacks that get or put text   *
 160      * for the themes.  They're ascinine and used only      *
 161      * sporadically.
 162      \******************************************************/
 163  	function title($text) 
 164      {
 165          OpenTable();
 166          echo '<center><font class="title"><b>'.$text.'</b></font></center>';
 167          CloseTable();
 168          echo '<br>';
 169      }
 170  	function footmsg()
 171      {
 172          $objbo =& new bo;
 173          echo $objbo->get_footer();
 174      }
 175  
 176      /******************************************************\
 177      * These functions mostly just return dummy values to   *
 178      * keep the themes from complaining.                    *
 179      \******************************************************/
 180  	function is_admin()
 181      {
 182          $acl =& CreateObject('sitemgr.ACL_BO');
 183          $retval = $acl->is_admin();
 184          unset($acl);
 185          return $retval;
 186      }
 187  	function is_user()
 188      {
 189          global $sitemgr_info;
 190          if ($GLOBALS['egw_info']['user']['account_lid'] != $sitemgr_info['login'])
 191          {
 192              return true;
 193          }
 194          else
 195          {
 196              return false;
 197          }
 198      }
 199  
 200  	function get_lang()
 201      {
 202          return '';
 203      }
 204  	function translate()
 205      {
 206          return '';
 207      }
 208  	function sql_num_rows()
 209      {
 210          return '';
 211      }
 212  	function cookiedecode($user)
 213      {
 214          return '';
 215      }
 216  	function sql_query()
 217      {
 218          return '';
 219      }
 220  	function sql_fetch_row()
 221      {
 222          return '';
 223      }
 224  	function is_active($module) 
 225      {
 226          return false;
 227          }
 228  	function message_box() 
 229      {
 230          // For displaying news
 231          return '';
 232      }
 233  	function online() 
 234      {
 235          //used to setup session stuff
 236          return '';
 237      }
 238  	function selectlanguage() 
 239      {
 240          return '';
 241      }
 242  	function delQuotes($string)
 243      {
 244          return $string;
 245      }
 246  	function searchblock() 
 247      {
 248          return '';
 249      }
 250  	function FixQuotes ($what = "") 
 251      {
 252          $what = ereg_replace("'","''",$what);
 253          while (eregi("\\\\'", $what)) 
 254          {
 255              $what = ereg_replace("\\\\'","'",$what);
 256          }
 257          return $what;
 258      }
 259  	function check_words($Message) 
 260      {
 261              return ($Message);
 262      }
 263  	function getusrinfo($user)
 264      {
 265          $userinfo = array(
 266              'uid' => $GLOBALS['egw_info']['user']['account_id'],
 267              'name' => $GLOBALS['egw_info']['user']['account_lid'],
 268              'uname' => '',
 269              'email' => '',
 270              'femail' => '',
 271              'url' => '',
 272              'user_avatar' => '',
 273              'user_icq' => '',
 274              'user_occ' => '',
 275              'user_from' => '',
 276              'user_interest' => '',
 277              'user_sig' => '',
 278              'user_viewemail' => '',
 279              'user_theme' => '',
 280              'user_aim' => '',
 281              'user_yim' => '',
 282              'user_msnm' => '',
 283              'pass' => '',
 284              'storynum' => '',
 285              'umode' => '',
 286              'uorder' => '',
 287              'thold' => '',
 288              'noscore' => '',
 289              'bio' => '',
 290              'ublockon' => '',
 291              'ublock' => '',
 292              'theme' => '',
 293              'commentmax' => '',
 294              'newsletter' => 0
 295          );
 296  
 297              return $userinfo;
 298      }
 299      
 300      /******************************************************\
 301      * These functions are used for displaying blocks       *
 302      \******************************************************/
 303  	function render_blocks($side, $blockfile, $title, $content, $bid, $url) 
 304      {
 305              if ($url == '') 
 306          {
 307              if ($blockfile == "") 
 308              {
 309                      if ($side == "c") 
 310                  {
 311                      themecenterbox($title, $content);
 312                      } 
 313                  else 
 314                  {
 315                      themesidebox($title, $content);
 316                      }
 317              } 
 318              else 
 319              {
 320                      if ($side == "c") 
 321                  {
 322                      blockfileinc($title, $blockfile, 1);
 323                      } 
 324                  else 
 325                  {
 326                      blockfileinc($title, $blockfile);
 327                      }
 328              }
 329              } 
 330          else 
 331          {
 332              if ($side == "c") 
 333              {
 334                  headlines($bid,1);
 335              } 
 336              else 
 337              {
 338                  headlines($bid);
 339              }
 340              }
 341      }
 342  
 343  	function blocks($side) 
 344      {
 345              global $blocks;
 346  
 347          //switch(strtolower(substr($side,0,1)))
 348          switch(strtolower(substr($side,0,1)))
 349          {
 350              case 'l':
 351              case 'r':
 352              case 'c':
 353                  $side = strtolower(substr($side,0,1));
 354                  break;
 355              default:
 356                  echo "<h1>something wierd</h1>";
 357          }
 358          for ($i=0; $i<count($blocks);$i++)
 359          {
 360              if ($side == $blocks[$i]['position'])
 361              {
 362                  $bid=$i;
 363                  $bkey=$blocks[$i]['bkey'];
 364                  $title=$blocks[$i]['title'];
 365                  $content=$blocks[$i]['content'];
 366                  $url=$blocks[$i]['url'];
 367                  $blockfile=$blocks[$i]['blockfile'];
 368                  $view=$blocks[$i]['view'];
 369  
 370                  if ($bkey == 'admin') 
 371                  {
 372                          adminblock();
 373                  } 
 374                  elseif ($bkey == 'userbox') 
 375                  {
 376                          userblock();
 377                  } 
 378                  elseif ($bkey == '') 
 379                  {
 380                          if ($view==0) 
 381                      {
 382                          render_blocks($side, $blockfile, $title, $content, $bid, $url);
 383                          } 
 384                      elseif ($view==1 && is_user()) 
 385                      {
 386                          render_blocks($side, $blockfile, $title, $content, $bid, $url);
 387                          } 
 388                      elseif ($view==2 && is_admin()) 
 389                      {
 390                          render_blocks($side, $blockfile, $title, $content, $bid, $url);
 391                          } 
 392                      elseif (($view==3) && (!is_user()))
 393                      {
 394                          render_blocks($side, $blockfile, $title, $content, $bid, $url);
 395                          }
 396                  }
 397              }
 398              }
 399      }
 400  
 401  
 402  	function blockfileinc($title, $blockfile, $side=0) 
 403      {
 404              $blockfiletitle = $title;
 405              $file = @file("blocks/$blockfile");
 406              if (!$file) 
 407          {
 408              $content = lang('Block not found.');
 409              } 
 410          else 
 411          {
 412              include("blocks/$blockfile");
 413              }
 414              if ($content == '') 
 415          {
 416              $content = lang('Block returned no content.');
 417              }
 418              if ($side == 1) 
 419          {
 420              themecenterbox($blockfiletitle, $content);
 421              } 
 422          else 
 423          {
 424              themesidebox($blockfiletitle, $content);
 425              }
 426      }
 427  
 428  	function adminblock() 
 429      {
 430              if (is_admin()) 
 431          {
 432              global $blocks;
 433  
 434              foreach($blocks as $block)
 435              {
 436                  if ($block['bkey']=='admin')
 437                  {
 438                          $content = '<font class="content">'.$block['content'].'</font>';
 439                      $title = $block['title'];
 440                          themesidebox($title, $content);
 441                  }
 442              }
 443              }
 444      }
 445  
 446  	function loginbox() {
 447              if (!is_user()) 
 448          {
 449              $title = 'Login';
 450              $boxstuff = '<form name="login" action="'.$GLOBALS['egw_info']['server']['webserver_url'].'/login.php" method="post">';
 451              $boxstuff .= '<input type="hidden" name="passwd_type" value="text">';
 452              $boxstuff .= '<center><font class="content">Login Name<br>';
 453              $boxstuff .= '<input type="text" name="login" size="8" value=""><br>';
 454              $boxstuff .= 'Password<br>';
 455              $boxstuff .= '<input name="passwd" size="8" type="password"><br>';
 456              $boxstuff .= '<input type="submit" value="Login" name="submitit">';
 457              $boxstuff .= '</font></center></form>';
 458              $boxstuff .= "<center><font class=\"content\">Don't have an account?  Maybe in a future version you can create one. :-)</font></center>";
 459              themesidebox($title, $boxstuff);
 460              }
 461      }
 462  
 463  	function userblock() 
 464      {
 465              if(is_user())
 466          {
 467              //this is a handy function to allow the user to 
 468              //have their own custom block.  too bad we don't
 469              //have that feature (yet).
 470          }
 471          }
 472  
 473  
 474      /*
 475      function themecenterbox($title, $content) 
 476      {
 477              $contents = OpenTable();
 478              $contents.='<center><font class="option"><b>'.
 479              $title.'</b></font></center><br>'."$content";
 480              $contents.=CloseTable();
 481              $contents.= "<br>";
 482          echo $contents;
 483      }
 484      */
 485  
 486  ?>


Généré le : Sun Feb 25 17:20:01 2007 par Balluche grâce à PHPXref 0.7