Caravel CMS PHP Cross Reference Content Management Systems

Source: /apps/IncludeUrl/IncludeUrl.php - 70 lines - 2535 bytes - Summary - Text - Print

   1  <?php
   2  class IncludeUrl extends App
   3      {
   4  	function getContent()
   5          {
   6          if (isset($this->settingsVars['url']))
   7              {
   8              $url = $this->settingsVars['url'];
   9              $qstring = '';
  10              foreach($this->httpVars as $key => $val)
  11                  {
  12                  if ($key[0] != '_' && !ereg('^cv_', $key))
  13                      $qstring .= "$key=$val&";
  14                  }
  15              if ($qstring)
  16                  $url .= (ereg('\?', $url) ? '&' : '?') . $qstring;
  17              $url = Utility::substituteVariables($url);
  18              if (@$this->settingsVars['iframe'])
  19                  {
  20                  $iframe_name = $this->paramName('iframe');
  21                  $r = '<iframe name="' . $iframe_name . '" id="' . $iframe_name . '" src="' . $url . '" style="width:100%;';
  22                  if (@$this->settingsVars['height'] && $this->settingsVars['height'] != 'auto') $r .= 'height:' . $this->settingsVars['height'] . 'px;';
  23                  if (!@$this->settingsVars['border']) $r .= 'border:none;';
  24                  $r .= '"';
  25                  if (@$this->settingsVars['height'] == 'auto')
  26                      $r .= ' onload="parent.setIframeHeight(\'' . $iframe_name. '\');"';
  27                  $r .= '></iframe>';
  28                  return $r;
  29                  }
  30              else
  31                  return @implode('', @file($url));
  32              }
  33          else
  34              return '';
  35          }
  36          
  37  	function getConfig()
  38          {
  39          $f = FormWidget::init();
  40          $f->section();
  41          
  42          $f->field('URL to include:');
  43          $f->text('_url', @$this->settingsVars['url'] ? $this->settingsVars['url'] : 'http://', null, array('style' => 'width:96%;'));
  44  
  45          $f->field('Iframe?');
  46          $f->checkbox('_iframe', @$this->settingsVars['iframe'], 'Display this page in an iframe.', array('id' => 'iframeset', 'onclick' => "document.getElementById('iframe').style.display=(this.checked?'block':'none');"));
  47          
  48          $f->html('<div id="iframe" style="padding-left:2em;display:' . (@$this->settingsVars['iframe'] ? 'block' : 'none') . '">');
  49          $f->checkbox('_border', isset($this->settingsVars['border']) ? $this->settingsVars['border'] : 1, 'Give the iframe a border.');
  50          $f->html('<br>Height of the iframe:');
  51          $f->text('_height', @$this->settingsVars['height'] ? $this->settingsVars['height'] : 'auto', 3);
  52          $f->html("(pixels or 'auto' -- auto will only work for pages on the same server, because of browser security restrictions)</div>");
  53  
  54          $f->endSection();
  55          $f->defaultButtons();
  56          return $f->get();
  57          }
  58  
  59  	function onSave()
  60          {
  61          $settingNames = array('url', 'height');
  62          $checkboxNames = array('iframe', 'border');
  63          foreach ($settingNames as $name)
  64              $this->settingsVars[$name] = $this->httpVars["_$name"];
  65          foreach ($checkboxNames as $name)
  66              $this->settingsVars[$name] = isset($this->httpVars["_$name"]);
  67          $this->saveSettings($this->settingsVars);
  68          }
  69      }
  70  ?>

title

Description

title

Description

title

Description

title

title

Body