Source for file content_blog_section.class.php

Documentation is available at content_blog_section.class.php

  1. <?php
  2. /**
  3. @package Mambo
  4. @subpackage Menus
  5. @copyright  Refer to copyright.php
  6. @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
  7. @author Mambo Foundation Inc see README.php
  8. */ 
  9.  
  10. /** ensure this file is being included by a parent file */
  11. defined'_VALID_MOS' or die'Direct Access to this location is not allowed.' );
  12.  
  13.  
  14.     /**
  15.     * @param database A database connector object
  16.     * @param integer The unique id of the section to edit (0 if new)
  17.     */
  18.     function edit$uid$menutype$option {
  19.         global $database$my$mainframe;
  20.         global $mosConfig_absolute_path;
  21.  
  22.         $menu new mosMenu$database );
  23.         $menu->load$uid );
  24.  
  25.         // fail if checked out not by 'me'
  26.         if ($menu->checked_out && $menu->checked_out <> $my->id{
  27.             echo "<script>alert('".sprintf(T_('The module % is currently being edited by another administrator')$menu->title)."'); document.location.href='index2.php?option=$option'</script>\n";
  28.             exit(0);
  29.         }
  30.  
  31.         if ($uid{
  32.             $menu->checkout$my->id );
  33.             // get previously selected Categories
  34.             $params =new mosParameters$menu->params );
  35.             $secids $params->def'sectionid''' );
  36.             if $secids {
  37.                 $query "SELECT s.id AS `value`, s.id AS `id`, s.title AS `text`"
  38.                 . "\n FROM #__sections AS s"
  39.                 . "\n WHERE s.scope = 'content'"
  40.                 . "\n AND s.id IN ( "$secids ")"
  41.                 . "\n ORDER BY s.name"
  42.                 ;
  43.                 $database->setQuery$query );
  44.                 $lookup $database->loadObjectList();
  45.             else {
  46.                 $lookup             '';
  47.             }
  48.         else {
  49.             $menu->type             'content_blog_section';
  50.             $menu->menutype         $menutype;
  51.             $menu->ordering         9999;
  52.             $menu->parent             intvalmosGetParam$_POST'parent') );
  53.             $menu->published         1;
  54.             $lookup                 '';
  55.         }
  56.  
  57.         // build the html select list for section
  58.         $rows[mosHTML::makeOption''T_('All Sections') );
  59.         $query "SELECT s.id AS `value`, s.id AS `id`, s.title AS `text`"
  60.         . "\n FROM #__sections AS s"
  61.         . "\n WHERE s.scope = 'content'"
  62.         . "\n ORDER BY s.name"
  63.         ;
  64.         $database->setQuery$query );
  65.         $rows array_merge$rows$database->loadObjectList() );
  66.         $section mosHTML::selectList$rows'secid[]''class="inputbox" size="10" multiple="multiple"''value''text'$lookup );
  67.         $lists['sectionid']        $section;
  68.  
  69.         // build the html select list for ordering
  70.         $lists['ordering']         mosAdminMenus::Ordering$menu$uid );
  71.         // build the html select list for the group access
  72.         $lists['access']         mosAdminMenus::Access$menu );
  73.         // build the html select list for paraent item
  74.         $lists['parent']         mosAdminMenus::Parent$menu );
  75.         // build published button option
  76.         $lists['published']     mosAdminMenus::Published$menu );
  77.         // build the url link output
  78.         $lists['link']         mosAdminMenus::Link$menu$uid );
  79.  
  80.         // get params definitions
  81.         $params =new mosAdminParameters$menu->params$mainframe->getPath'menu_xml'$menu->type )'menu' );
  82.  
  83.         content_blog_section_html::edit$menu$lists$params$option );
  84.     }
  85.  
  86.     function saveMenu$option$task {
  87.         global $database;
  88.  
  89.         $params mosGetParam$_POST'params''' );
  90.         $secids    mosGetParam$_POST'secid'array() );
  91.         $secid    implode','$secids );
  92.         
  93.         $params[sectionid]    $secid;
  94.         if (is_array$params )) {
  95.             $txt array();
  96.             foreach ($params as $k=>$v{
  97.                $txt["$k=$v";
  98.             }
  99.             $_POST['params'mosParameters::textareaHandling$txt );
  100.         }
  101.  
  102.         $row new mosMenu$database );
  103.  
  104.         if (!$row->bind$_POST )) {
  105.             echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
  106.             exit();
  107.         }
  108.         
  109.         if count$secids )== && $secids[0!= '' {
  110.             $row->link str_replace'id=0','id='$secids[0]$row->link );
  111.             $row->componentid $secids[0];
  112.         }
  113.         
  114.         if (!$row->check()) {
  115.             echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
  116.             exit();
  117.         }
  118.         if (!$row->store()) {
  119.             echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
  120.             exit();
  121.         }
  122.         $row->checkin();
  123.         $row->updateOrder"menutype='$row->menutype' AND parent='$row->parent');
  124.         
  125.         $msg 'Menu item Saved';
  126.         switch $task {
  127.             case 'apply':
  128.                 mosRedirect'index2.php?option='$option .'&menutype='$row->menutype .'&task=edit&id='$row->id$msg );
  129.                 break;
  130.         
  131.             case 'save':
  132.             default:
  133.                 mosRedirect'index2.php?option='$option .'&menutype='$row->menutype$msg );
  134.             break;
  135.         }
  136.     }
  137.  
  138. }
  139. ?>

Documentation generated on Mon, 05 May 2008 16:18:40 +0400 by phpDocumentor 1.4.0