[ Index ] [ Index ]     [ Classes ]     [ Functions ]     [ Variables ]     [ Constants ]

PHP Cross Reference of TXP stable 4.0.6

title

Body

[close]

/textpattern/lib/ -> txplib_head.php (source)

   1  <?php
   2  
   3  /*
   4  $HeadURL: http://svn.textpattern.com/releases/4.0.6/source/textpattern/lib/txplib_head.php $
   5  $LastChangedRevision: 2783 $
   6  */
   7  
   8  // -------------------------------------------------------------
   9  	function pagetop($pagetitle,$message="")
  10      {
  11          global $css_mode,$siteurl,$sitename,$txp_user,$event;
  12          $area = gps('area');
  13          $event = (!$event) ? 'article' : $event;
  14          $bm = gps('bm');
  15  
  16          $privs = safe_field("privs", "txp_users", "name = '".doSlash($txp_user)."'");
  17  
  18          $GLOBALS['privs'] = $privs;
  19  
  20          $areas = areas();
  21          $area = false;
  22  
  23          foreach ($areas as $k => $v)
  24          {
  25              if (in_array($event, $v))
  26              {
  27                  $area = $k;
  28                  break;
  29              }
  30          }
  31  
  32          if (gps('logout'))
  33          {
  34              $body_id = 'page-logout';
  35          }
  36  
  37          elseif (!$txp_user)
  38          {
  39              $body_id = 'page-login';
  40          }
  41  
  42          else
  43          {
  44              $body_id = 'page-'.$event;
  45          }
  46  
  47      ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  48      <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo LANG; ?>" lang="<?php echo LANG; ?>" dir="<?php echo gTxt('lang_dir'); ?>">
  49      <head>
  50      <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  51      <meta name="robots" content="noindex, nofollow" />
  52      <title>Txp &#8250; <?php echo htmlspecialchars($sitename) ?> &#8250; <?php echo escape_title($pagetitle) ?></title>
  53      <link href="textpattern.css" rel="Stylesheet" type="text/css" />
  54      <script type="text/javascript" src="textpattern.js"></script>
  55      <script type="text/javascript">
  56      <!--
  57  
  58          var cookieEnabled = checkCookies();
  59  
  60          if (!cookieEnabled)
  61          {
  62              confirm('<?php echo trim(gTxt('cookies_must_be_enabled')); ?>');
  63          }
  64  
  65  <?php
  66  
  67      if ($event == 'list')
  68      {
  69          $sarr = array("\n", '-');
  70          $rarr = array('', '&#45;');
  71  
  72          $sections = '';
  73  
  74          $rs = safe_column('name', 'txp_section', "name != 'default'");
  75  
  76          if ($rs)
  77          {
  78              $sections = str_replace($sarr, $rarr, addslashes(selectInput('Section', $rs, '', true)));
  79          }
  80  
  81          $category1 = '';
  82          $category2 = '';
  83  
  84          $rs = getTree('root', 'article');
  85  
  86          if ($rs)
  87          {
  88              $category1 = str_replace($sarr, $rarr, addslashes(treeSelectInput('Category1', $rs, '')));
  89              $category2 = str_replace($sarr, $rarr, addslashes(treeSelectInput('Category2', $rs, '')));
  90          }
  91  
  92          $statuses = str_replace($sarr, $rarr, addslashes(selectInput('Status', array(
  93              1 => gTxt('draft'),
  94              2 => gTxt('hidden'),
  95              3 => gTxt('pending'),
  96              4 => gTxt('live'),
  97              5 => gTxt('sticky'),
  98          ), '', true)));
  99  
 100          $comments_annotate = addslashes(onoffRadio('Annotate', safe_field('val', 'txp_prefs', "name = 'comments_on_default'")));
 101  
 102          $authors = '';
 103  
 104          $rs = safe_column('name', 'txp_users', "privs not in(0,6)");
 105  
 106          if ($rs)
 107          {
 108              $authors = str_replace($sarr, $rarr, addslashes(selectInput('AuthorID', $rs, '', true)));
 109          }
 110  
 111          // output JavaScript
 112  ?>
 113  		function poweredit(elm)
 114          {
 115              var something = elm.options[elm.selectedIndex].value;
 116  
 117              // Add another chunk of HTML
 118              var pjs = document.getElementById('js');
 119  
 120              if (pjs == null)
 121              {
 122                  var br = document.createElement('br');
 123                  elm.parentNode.appendChild(br);
 124  
 125                  pjs = document.createElement('P');
 126                  pjs.setAttribute('id','js');
 127                  elm.parentNode.appendChild(pjs);
 128              }
 129  
 130              if (pjs.style.display == 'none' || pjs.style.display == '')
 131              {
 132                  pjs.style.display = 'block';
 133              }
 134  
 135              if (something != '')
 136              {
 137                  switch (something)
 138                  {
 139                      case 'changesection':
 140                          var sections = '<?php echo $sections; ?>';
 141                          pjs.innerHTML = '<span><?php echo gTxt('section') ?>: '+sections+'</span>';
 142                      break;
 143  
 144                      case 'changecategory1':
 145                          var categories = '<?php echo $category1; ?>';
 146                          pjs.innerHTML = '<span><?php echo gTxt('category1') ?>: '+categories+'</span>';
 147                      break;
 148  
 149                      case 'changecategory2':
 150                          var categories = '<?php echo $category2; ?>';
 151                          pjs.innerHTML = '<span><?php echo gTxt('category2') ?>: '+categories+'</span>';
 152                      break;
 153  
 154                      case 'changestatus':
 155                          var statuses = '<?php echo $statuses; ?>';
 156                          pjs.innerHTML = '<span><?php echo gTxt('status') ?>: '+statuses+'</span>';
 157                      break;
 158  
 159                      case 'changecomments':
 160                          var comments = '<?php echo $comments_annotate; ?>';
 161                          pjs.innerHTML = '<span><?php echo gTxt('comments'); ?>: '+comments+'</span>';
 162                      break;
 163  
 164                      case 'changeauthor':
 165                          var authors = '<?php echo $authors; ?>';
 166                          pjs.innerHTML = '<span><?php echo gTxt('author'); ?>: '+authors+'</span>';
 167                      break;
 168  
 169                      default:
 170                          pjs.style.display = 'none';
 171                      break;
 172                  }
 173              }
 174  
 175              return false;
 176          }
 177  
 178          addEvent(window, 'load', cleanSelects);
 179  <?php
 180      }
 181  ?>
 182      -->
 183      </script>
 184      <script type="text/javascript" src="jquery.js"></script>
 185      </head>
 186      <body id="<?php echo $body_id; ?>">
 187    <table id="pagetop" cellpadding="0" cellspacing="0">
 188    <tr id="branding"><td><img src="txp_img/textpattern.gif" alt="textpattern" /></td><td id="navpop"><?php echo navPop(1); ?></td></tr>
 189    <tr id="nav-primary"><td align="center" class="tabs" colspan="2">
 190           <?php
 191           if (!$bm) {
 192              echo '<table cellpadding="0" cellspacing="0" align="center"><tr>
 193    <td valign="middle" style="width:368px">&nbsp;'.$message.'</td>',
 194  
 195              has_privs('tab.content')
 196              ? areatab(gTxt('tab_content'), 'content', 'article', $area)
 197              : '',
 198              has_privs('tab.presentation')
 199              ?    areatab(gTxt('tab_presentation'), 'presentation', 'page', $area)
 200              :    '',
 201              has_privs('tab.admin')
 202              ?    areatab(gTxt('tab_admin'), 'admin', 'admin', $area)
 203              :    '',
 204              (has_privs('tab.extensions') and !empty($areas['extensions']))
 205              ?    areatab(gTxt('tab_extensions'), 'extensions', array_shift($areas['extensions']), $area)
 206              :    '',
 207  
 208              '<td class="tabdown"><a href="'.hu.'" class="plain" target="_blank">'.gTxt('tab_view_site').'</a></td>',
 209           '</tr></table>',
 210  
 211          '</td></tr><tr id="nav-secondary"><td align="center" class="tabs" colspan="2">
 212              <table cellpadding="0" cellspacing="0" align="center"><tr>',
 213                  tabsort($area,$event),
 214              '</tr></table>';
 215          }
 216          echo '</td></tr></table>';
 217      }
 218  
 219  // -------------------------------------------------------------
 220  	function areatab($label,$event,$tarea,$area)
 221      {
 222          $tc = ($area == $event) ? 'tabup' : 'tabdown';
 223          $atts=' class="'.$tc.'"';
 224          $hatts=' href="?event='.$tarea.'" class="plain"';
 225            return tda(tag($label,'a',$hatts),$atts);
 226      }
 227  
 228  // -------------------------------------------------------------
 229  	function tabber($label,$tabevent,$event)
 230      {
 231          $tc = ($event==$tabevent) ? 'tabup' : 'tabdown2';
 232          $out = '<td class="'.$tc.'"><a href="?event='.$tabevent.'" class="plain">'.$label.'</a></td>';
 233          return $out;
 234      }
 235  
 236  // -------------------------------------------------------------
 237  
 238  	function tabsort($area, $event)
 239      {
 240          if ($area)
 241          {
 242              $areas = areas();
 243  
 244              $out = array();
 245  
 246              foreach ($areas[$area] as $a => $b)
 247              {
 248                  if (has_privs($b))
 249                  {
 250                      $out[] = tabber($a, $b, $event, 2);
 251                  }
 252              }
 253  
 254              return ($out) ? join('', $out) : '';
 255          }
 256  
 257          return '';
 258      }
 259  
 260  // -------------------------------------------------------------
 261  	function areas()
 262      {
 263          global $privs, $plugin_areas;
 264  
 265          $areas['content'] = array(
 266              gTxt('tab_organise') => 'category',
 267              gTxt('tab_write')    => 'article',
 268              gTxt('tab_list')    =>  'list',
 269              gTxt('tab_image')    => 'image',
 270              gTxt('tab_file')     => 'file',
 271              gTxt('tab_link')     => 'link',
 272              gTxt('tab_comments') => 'discuss'
 273          );
 274  
 275          $areas['presentation'] = array(
 276              gTxt('tab_sections') => 'section',
 277              gTxt('tab_pages')    => 'page',
 278              gTxt('tab_forms')    => 'form',
 279              gTxt('tab_style')    => 'css'
 280          );
 281  
 282          $areas['admin'] = array(
 283              gTxt('tab_diagnostics') => 'diag',
 284              gTxt('tab_preferences') => 'prefs',
 285              gTxt('tab_site_admin')  => 'admin',
 286              gTxt('tab_logs')        => 'log',
 287              gTxt('tab_plugins')     => 'plugin',
 288              gTxt('tab_import')      => 'import'
 289          );
 290  
 291          $areas['extensions'] = array(
 292          );
 293  
 294          if (is_array($plugin_areas))
 295              $areas = array_merge_recursive($areas, $plugin_areas);
 296  
 297          return $areas;
 298      }
 299  
 300  // -------------------------------------------------------------
 301  
 302  	function navPop($inline = '')
 303      {
 304          $areas = areas();
 305  
 306          $out = array();
 307  
 308          foreach ($areas as $a => $b)
 309          {
 310              if (!has_privs( 'tab.'.$a))
 311              {
 312                  continue;
 313              }
 314  
 315              if (count($b) > 0)
 316              {
 317                  $out[] = n.t.'<optgroup label="'.gTxt('tab_'.$a).'">';
 318  
 319                  foreach ($b as $c => $d)
 320                  {
 321                      if (has_privs($d))
 322                      {
 323                          $out[] = n.t.t.'<option value="'.$d.'">'.$c.'</option>';
 324                      }
 325                  }
 326  
 327                  $out[] = n.t.'</optgroup>';
 328              }
 329          }
 330  
 331          if ($out)
 332          {
 333              $style = ($inline) ? ' style="display: inline;"': '';
 334  
 335              return '<form method="get" action="index.php" class="navpop"'.$style.'>'.
 336                  n.'<select name="event" onchange="submit(this.form);">'.
 337                  n.t.'<option>'.gTxt('go').'&#8230;</option>'.
 338                  join('', $out).
 339                  n.'</select>'.
 340                  n.'</form>';
 341          }
 342      }
 343  
 344  // -------------------------------------------------------------
 345  	function button($label,$link)
 346      {
 347          return '<span style="margin-right:2em"><a href="?event='.$link.'" class="plain">'.$label.'</a></span>';
 348      }
 349  ?>


Generated: Mon Feb 18 03:42:45 2008 Cross-referenced by PHPXref 0.7