[ Index ]
 

Code source de CMS made simple 1.0.5

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

title

Body

[fermer]

/plugins/ -> function.content.php (source)

   1  <?php
   2  #CMS - CMS Made Simple
   3  #(c)2004 by Ted Kulp (wishy@users.sf.net)
   4  #This project's homepage is: http://cmsmadesimple.sf.net
   5  #
   6  #This program is free software; you can redistribute it and/or modify
   7  #it under the terms of the GNU General Public License as published by
   8  #the Free Software Foundation; either version 2 of the License, or
   9  #(at your option) any later version.
  10  #
  11  #This program is distributed in the hope that it will be useful,
  12  #but WITHOUT ANY WARRANTY; without even the implied warranty of
  13  #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14  #GNU General Public License for more details.
  15  #You should have received a copy of the GNU General Public License
  16  #along with this program; if not, write to the Free Software
  17  #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  18  
  19  function smarty_cms_function_content($params, &$smarty)
  20  {
  21      global $gCms;
  22      $pageinfo =& $gCms->variables['pageinfo'];
  23      if (isset($pageinfo) && $pageinfo !== FALSE && isset($pageinfo->content_id) )
  24      {
  25          $id = '';
  26          $modulename = '';
  27          $action = '';
  28          $inline = false;
  29          if (isset($_REQUEST['module'])) $modulename = $_REQUEST['module'];
  30          if (isset($_REQUEST['id']))
  31          {
  32              $id = $_REQUEST['id'];
  33          }
  34          elseif (isset($_REQUEST['mact']))
  35          {
  36              $ary = explode(',', $_REQUEST['mact'], 4);
  37              $modulename = (isset($ary[0])?$ary[0]:'');
  38              $id = (isset($ary[1])?$ary[1]:'');
  39              $action = (isset($ary[2])?$ary[2]:'');
  40              $inline = (isset($ary[3]) && $ary[3] == 1?true:false);
  41          }
  42          if (isset($_REQUEST[$id.'action'])) $action = $_REQUEST[$id.'action'];
  43          else if (isset($_REQUEST['action'])) $action = $_REQUEST['action'];
  44  
  45          //Only consider doing module processing if
  46          //a. There is no block parameter
  47          //b. then
  48          //   1. $id is cntnt01
  49          //   2. or inline is false
  50          if (!isset($params['block']) && ($id == 'cntnt01' || ($id != '' && $inline == false)))
  51          {
  52              $cmsmodules = &$gCms->modules;
  53          
  54              if (isset($cmsmodules))
  55              {
  56                  foreach ($cmsmodules as $key=>$value)
  57                  {
  58                      if (strtolower($modulename) == strtolower($key))
  59                      {
  60                          $modulename = $key;
  61                      }
  62                  }
  63          
  64                  if (isset($modulename))
  65                  {
  66                      if (isset($cmsmodules[$modulename]))
  67                      {
  68                          if (isset($cmsmodules[$modulename]['object'])
  69                              && $cmsmodules[$modulename]['installed'] == true
  70                              && $cmsmodules[$modulename]['active'] == true
  71                              && $cmsmodules[$modulename]['object']->IsPluginModule())
  72                          {
  73                              @ob_start();
  74                              $params = array_merge($params, GetModuleParameters($id));
  75  
  76                              $returnid = '';
  77                              if (isset($params['returnid']))
  78                              {
  79                                  $returnid = $params['returnid'];
  80                              }
  81                              else
  82                              {
  83                                  $returnid = $pageinfo->content_id;
  84                              }
  85                              $result = $cmsmodules[$modulename]['object']->DoActionBase($action, $id, $params, $returnid);
  86                              if ($result !== FALSE)
  87                              {
  88                                  echo $result;
  89                              }
  90                              $modresult = @ob_get_contents();
  91                              @ob_end_clean();
  92                              return _smarty_cms_function_content_return($modresult, $params, $smarty);
  93                          }
  94                          else
  95                          {
  96                            return _smarty_cms_function_content_return("<!-- Not a tag module -->\n", $params, $smarty);
  97                          }
  98                      }
  99                  }
 100              }
 101          }
 102          else
 103          {
 104              $result = '';
 105              $oldvalue = $smarty->caching;
 106              $smarty->caching = false;
 107              $result = $smarty->fetch(str_replace(' ', '_', 'content:' . (isset($params['block'])?$params['block']:'content_en')), '', $pageinfo->content_id);
 108              $smarty->caching = $oldvalue;
 109              return _smarty_cms_function_content_return($result, $params, $smarty);
 110          }
 111      }
 112      return _smarty_cms_function_content_return('', $params, $smarty);
 113  }
 114  
 115  function _smarty_cms_function_content_return($result, &$params, &$smarty)
 116  {
 117      if ( empty($params['assign']) )
 118      {
 119          return $result;
 120      }
 121      else
 122      {
 123          $smarty->assign($params['assign'], $result);
 124          return '';
 125      }
 126  }
 127  
 128  function smarty_cms_help_function_content()
 129  {
 130      ?>
 131      <h3>What does this do?</h3>
 132      <p>This is where the content for your page will be displayed.  It's inserted into the template and changed based on the current page being displayed.</p>
 133      <h3>How do I use it?</h3>
 134      <p>Just insert the tag into your template like: <code>{content}</code>.</p>
 135      <h3>What parameters does it take?</h3>
 136      <ul>
 137          <li><em>(optional)</em>block - Allows you to have more than one content block per page.  When multiple content tags are put on a template, that number of edit boxes will be displayed when the page is edited.
 138  <p>Example:</p>
 139  <pre>{content block="Second Content Block"}</pre>
 140  <p>Now, when you edit a page there will a textarea called "Second Content Block".</li>
 141          <li><em>(optional)</em>wysiwyg (true/false) - If set to false, then a wysiwyg will never be used while editing this block.  If true, then it acts as normal.  Only works when block parameter is used.</li>
 142          <li><em>(optional)</em>oneline (true/false) - If set to true, then only one edit line will be shown while editing this block.  If false, then it acts as normal.  Only works when block parameter is used.</li>
 143          <li><em>(optional)</em>assign - Assigns the content to a smarty parameter, which you can then use in other areas of the page, or use to test whether content exists in it or not.
 144  <p>Example of passing page content to a User Defined Tag as a parameter:</p>
 145  <pre>
 146           {content assign=pagecontent}
 147           {table_of_contents thepagecontent="$pagecontent"}
 148  </pre>
 149  </li>
 150      </ul>
 151      <?php
 152  }
 153  
 154  function smarty_cms_about_function_content()
 155  {
 156      ?>
 157      <p>Author: Ted Kulp&lt;tedkulp@users.sf.net&gt;</p>
 158      <p>Version: 1.1</p>
 159      <p>
 160      Change History:<br/>
 161      1.1 - Added assign parameter from djnz's patch in the forge<br />
 162      1.0 - Initial version
 163      </p>
 164      <?php
 165  }
 166  
 167  # vim:ts=4 sw=4 noet
 168  ?>


Généré le : Tue Apr 3 18:50:37 2007 par Balluche grâce à PHPXref 0.7