[ Index ]
 

Code source de CMS made simple 1.0.5

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

title

Body

[fermer]

/modules/News/ -> action.editcategory.php (source)

   1  <?php
   2  if (!isset($gCms)) exit;
   3  
   4  $detailpage = '';
   5  if (isset($params['detailpage']))
   6    {
   7      $manager =& $gCms->GetHierarchyManager();
   8      $node =& $manager->sureGetNodeByAlias($params['detailpage']);
   9      if (isset($node))
  10        {
  11      $content =& $node->GetContent();
  12      if (isset($content))
  13        {
  14          $detailpage = $content->Id();
  15        }
  16        }
  17      else
  18        {
  19      $node =& $manager->sureGetNodeById($params['detailpage']);
  20      if (isset($node))
  21        {
  22          $detailpage = $params['detailpage'];
  23        }
  24        }
  25    }
  26  
  27  
  28  if (!$this->CheckPermission('Modify News'))
  29    {
  30      echo $this->ShowErrors($this->Lang('needpermission', array('Modify News')));
  31      return;
  32    }
  33  
  34  if (isset($params['cancel']))
  35    {
  36      $this->Redirect($id, 'defaultadmin', $returnid);
  37    }
  38  
  39  $catid = '';
  40  if (isset($params['catid']))
  41    {
  42      $catid = $params['catid'];
  43    }
  44  
  45  $parentid = '-1';
  46  if (isset($params['parent']))
  47    {
  48      $parentid = $params['parent'];
  49    }
  50  
  51  $origname = '';
  52  if (isset($params['origname']))
  53    {
  54      $origname = $params['origname'];
  55    }
  56  
  57  $name = '';
  58  if (isset($params['name']))
  59    {
  60      $name = $params['name'];
  61      if ($name != '')
  62        {
  63      $query = 'UPDATE '.cms_db_prefix().'module_news_categories SET news_category_name = ?, parent_id = ?, modified_date = '.$db->DBTimeStamp(time()).' WHERE news_category_id = ?';
  64      $db->Execute($query, array($name, $parentid, $catid));
  65      $this->UpdateHierarchyPositions();
  66                          
  67      @$this->SendEvent('NewsCategoryEdited', array('category_id' => $catid, 'name' => $name, 'origname' => $origname));
  68                          
  69      $params = array('tab_message'=> 'categoryupdated', 'active_tab' => 'categories');
  70      $this->Redirect($id, 'defaultadmin', $returnid, $params);            
  71        }
  72      else
  73        {
  74          echo $this->ShowErrors($this->Lang('nonamegiven'));
  75        }
  76    }
  77   else
  78     {
  79       $query = 'SELECT * FROM '.cms_db_prefix().'module_news_categories WHERE news_category_id = ?';
  80       $row = $db->GetRow($query, array($catid));
  81  
  82       if ($row)
  83         {
  84       $name = $row['news_category_name'];
  85       $parentid = $row['parent_id'];
  86         }
  87     }
  88  
  89  #Display template
  90  $this->smarty->assign('startform', $this->CreateFormStart($id, 'editcategory', $returnid));
  91  $this->smarty->assign('endform', $this->CreateFormEnd());
  92  $this->smarty->assign('nametext', $this->Lang('name'));
  93  $this->smarty->assign('inputname', $this->CreateInputText($id, 'name', $name, 20, 255));
  94  $this->smarty->assign('parentdropdown', $this->CreateParentDropdown($id, $catid, $parentid));
  95  $this->smarty->assign('hidden', 
  96                $this->CreateInputHidden($id, 'catid', $catid).
  97                $this->CreateInputHidden($id,'origname',$name));
  98  $this->smarty->assign('submit', $this->CreateInputSubmit($id, 'submit', lang('submit')));
  99  $this->smarty->assign('cancel', $this->CreateInputSubmit($id, 'cancel', lang('cancel')));
 100  $this->smarty->assign('parenttext', lang('parent'));
 101  echo $this->ProcessTemplate('editcategory.tpl');
 102  ?>


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