mosDBTable( '#__obrens', 'id', $db ); } } # Clase de tabla mos_obrens_cab_detalles class mosenscabdet extends mosDBTable { var $id=null; var $ncol1=null; var $ncol2=null; var $ncol3=null; var $ncol4=null; var $ncol5=null; var $ncol6=null; var $ncol7=null; var $ncol8=null; //Como PHP4 no soporta sobrecarga los dos constructores que tendria la clase los hemos //hecho funciones. //Constructor 1 function mosenscabdet1($POST, $id) { $this->id = $id; $this->ncol1 = $POST['ncol1']; $this->ncol2 = $POST['ncol2']; $this->ncol3 = $POST['ncol3']; $this->ncol4 = $POST['ncol4']; $this->ncol5 = $POST['ncol5']; $this->ncol6 = $POST['ncol6']; $this->ncol7 = $POST['ncol7']; $this->ncol8 = $POST['ncol8']; echo "\n"; } //Constructor 2 function mosenscabdet2(&$db, $id) { $cadena = "SELECT * FROM #__obrens_cab_detalles " . "WHERE idobra = " . $id; $db->setQuery($cadena); $rows = $db->loadObjectList(); foreach($rows as $row1) { $this->id = $id; switch ($row1->id) { case 0: $this->ncol1 = $row1->descripcion; break; case 1: $this->ncol2 = $row1->descripcion; break; case 2: $this->ncol3 = $row1->descripcion; break; case 3: $this->ncol4 = $row1->descripcion; break; case 4: $this->ncol5 = $row1->descripcion; break; case 5: $this->ncol6 = $row1->descripcion; break; case 6: $this->ncol7 = $row1->descripcion; break; case 7: $this->ncol8 = $row1->descripcion; break; } } } //Funcion que inserta una tupla en tabla function insert(&$db, $ncol, $valor) { $cadena = "INSERT INTO #__obrens_cab_detalles ( `idobra` , `id` , `descripcion` )" . "VALUES ( " . $this->id . ", " . $ncol . ", '" . $valor . "')"; $db->setQuery($cadena); if (!$db->query()) { echo $db->getErrorMsg(); return false; } return true; } //Funcion que inserta todos los campos introducidos en backoffice function insertdet(&$db) { //Borramos todo lo que hubiera $cadena = "DELETE FROM #__obrens_cab_detalles" . " WHERE idobra =" . $this->id; $db->setQuery($cadena); $db->query(); #PENDIENTE if (!$db->query()) { echo $db->getErrorMsg(); return false; } //Insertamos cada uno de los campos introducidos if ($this->ncol1 != "") if (!$this->insert($db, 0, $this->ncol1)) return false; if ($this->ncol2 != "") if (!$this->insert($db, 1, $this->ncol2)) return false; if ($this->ncol3 != "") if (!$this->insert($db, 2, $this->ncol3)) return false; if ($this->ncol4 != "") if (!$this->insert($db, 3, $this->ncol4)) return false; if ($this->ncol5 != "") if (!$this->insert($db, 4, $this->ncol5)) return false; if ($this->ncol6 != "") if (!$this->insert($db, 5, $this->ncol6)) return false; if ($this->ncol7 != "") if (!$this->insert($db, 6, $this->ncol7)) return false; if ($this->ncol8 != "") if (!$this->insert($db, 7, $this->ncol8)) return false; return true; } }//Fin de clase ################################################################################### #FUNCIONES ################################################################################### # Dibujar Footer function RefFooter($ObrEns_version) { echo "
ÁreaEnsayo $ObrEns_version por Rodax Software S.L
"; return; } # Editar obra function editRef( $option, $uid ) { global $database, $my, $mosConfig_absolute_path, $mosConfig_live_site, $clist; //Creamos y cargamos nuestra clase con los datos detalle de la obra $row2 = new mosenscabdet($database); $row2->mosenscabdet2($database, $uid); //Tratamiento del resto de datos $row = new mosartref( $database ); # Load the row from the db table $row->load( $uid ); # Get list of categories $categories[] = mosHTML::makeOption( '0', ADM_ARTREF_WKat ); $categories[] = mosHTML::makeOption( '-1', ADM_ARTREF_AKat ); $database->setQuery( "SELECT id AS value, title AS text FROM #__categories" . "\nWHERE section='$option' ORDER BY ordering" ); $categories = array_merge( $categories, $database->loadObjectList() ); if (count( $categories ) < 1) { mosRedirect( "index2.php?option=categories§ion=$option", ADM_ARTREF_ERROR_A ); } $clist = mosHTML::selectList( $categories, 'catid', 'class="inputbox" size="1"', 'value', 'text', intval( $row->catid ) ); if (!$uid) { # Initialise new record $row->published = 0; } # Build the html select list for ordering $order = mosGetOrderingList( "SELECT ordering AS value, titulo AS text" . "\nFROM #__obrens" . "\nWHERE catid='$row->catid' ORDER BY ordering" ); $olist = mosHTML::selectList( $order, 'ordering', 'class="inputbox" size="1"', 'value', 'text', intval( $row->ordering ) ); HTML_artref::editRef( $option, $row, $clist, $olist, $row2); } # Grabar obra (Alta/Modificacion) function saveRef( $option ) { global $database, $my; //Grabamos la obra $row = new mosartref( $database ); if (!$row->bind( $_POST )) { echo "\n"; exit(); } if (!$row->store()) { echo "\n"; exit(); } $row->updateOrder( "catid='$row->catid'" ); //Grabamos los detalles $row2 = new mosenscabdet($database); if (!$_POST['id']) { //Sacamos el codigo de obra por si fuera un alta $database->setQuery( "SELECT max(id) as id FROM #__obrens"); $row = NULL; $database->loadObject( $row ); $lid = $row->id; } else $lid = $_POST['id']; //Creamos y grabamos detalles $row2->mosenscabdet1($_POST, $lid); if ($row2->insertdet($database)) echo "\n"; mosRedirect( "index2.php?option=$option" ); } # Listado de obras o categorias function showRef($option) { global $database, $mainframe; global $mosConfig_absolute_path; require($mosConfig_absolute_path."/administrator/components/com_obrens/config.obrens.php"); $catid = $mainframe->getUserStateFromRequest( "catid{$option}", 'catid', 0 ); $limit = $mainframe->getUserStateFromRequest( "viewlistlimit", 'limit', 10 ); $limitstart = $mainframe->getUserStateFromRequest( "view{$option}limitstart", 'limitstart', 0 ); $search = $mainframe->getUserStateFromRequest( "search{$option}", 'search', '' ); $search = $database->getEscaped( trim( strtolower( $search ) ) ); $where = array(); if ($catid > 0) { $where[] = "a.catid='$catid'"; } if ($search) { $where[] = "LOWER(a.name) LIKE '%$search%'"; } # Get the total number of records $database->setQuery( "SELECT count(*) FROM #__obrens AS a" . (count( $where ) ? "\nWHERE " . implode( ' AND ', $where ) : "") ); $total = $database->loadResult(); echo $database->getErrorMsg(); include_once( "includes/pageNavigation.php" ); $pageNav = new mosPageNav( $total, $limitstart, $limit ); $cadena = "SELECT a.*, cc.name AS category" . "\nFROM #__obrens AS a" . "\nLEFT JOIN #__categories AS cc ON cc.id = a.catid" . (count( $where ) ? "\nWHERE " . implode( ' AND ', $where ) : "") . "\nORDER BY a.catid"; //Orden de la lista de obras switch ($obrens_ordenlista) { case '1': $cadena .= ",a.titulo "; break; case '2': $cadena .= ",a.autor "; break; case '3': $cadena .= ",a.id "; break; } $cadena .= ", a.ordering" . "\nLIMIT $pageNav->limitstart,$pageNav->limit"; $database->setQuery($cadena); $rows = $database->loadObjectList(); if ($database->getErrorNum()) { echo $database->stderr(); return false; } # Get list of categories $categories[] = mosHTML::makeOption( '0', ADM_ARTREF_WKat ); $categories[] = mosHTML::makeOption( '-1', ADM_ARTREF_AKat ); $database->setQuery( "SELECT id AS value, title AS text FROM #__categories" . "\nWHERE section='com_obrens' ORDER BY ordering" ); $categories = array_merge( $categories, $database->loadObjectList() ); $clist = mosHTML::selectList( $categories, 'catid', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'value', 'text', $catid ); HTML_artref::showRef( $option, $rows, $clist, $search, $pageNav ); } ################################################################################### #CUERPO ################################################################################### require_once( $mainframe->getPath( 'admin_html' ) ); $cid = mosGetParam( $_POST, 'cid', array(0) ); switch ($act) { case "settings": $task = "settings"; break; case "about": $task = "about"; break; } switch ($task) { case "new": editRef( $option, 0 ); break; case "edit": editRef( $option, $cid[0] ); break; case "save": saveRef( $option ); break; case "remove": removeRef( $cid, $option ); break; case "publish": publishRef( $cid, 1, $option ); break; case "unpublish": publishRef( $cid, 0, $option ); break; case "cancel": cancelRef( $option ); break; case "orderup": orderRef( $cid[0], -1, $option ); break; case "orderdown": orderRef( $cid[0], 1, $option ); break; case "settings": showConfig( $option ); break; case "language": showLanguage($option); break; case "savelanguage": saveLanguage($file, $filecontent, $option); break; case "about": showAbout( $option ); break; case "savesettings": saveConfig ($option, $artref_showphone, $artref_showmail, $artref_showwebsite, $artref_showstatus, $artref_showbeschrlink, $artref_showpicture, $obrens_verlista, $obrens_verfooter, $artref_refperside, $obrens_rutafich, $obrens_nomfich, $obrens_extpdf, $obrens_extmid, $obrens_extmus, $rutalocal, $obrens_ordenlista); break; default: showRef($option); break; } # Footer //Global $obrens_verfooter; //if ($obrens_verfooter == "1") RefFooter($ObrEns_version); //Info Seite function showAbout( $option ) { Global $ObrEns_version; ?>
 
 
 
: ArtRef
:
: Andreas D.
     : Mamboart.de
     : webmaster@mamboart.de
Dank :
    
     : Arthur Konze
    
     : Mamboport.de
    
     : Matthias Heymann


alert('".ADM_ARTREF_ERROR_B."'); window.history.go(-1);\n"; exit; } if (count( $cid )) { $cids = implode( ',', $cid ); $database->setQuery( "DELETE FROM #__obrens WHERE id IN ($cids)" ); if (!$database->query()) { echo "\n"; } } mosRedirect( "index2.php?option=$option" ); } function publishRef( $cid=null, $publish=1, $option ) { global $database, $my; $catid = mosGetParam( $_POST, 'catid', array(0) ); if (!is_array( $cid ) || count( $cid ) < 1) { $action = $publish ? 'publish' : 'unpublish'; echo "\n"; exit; } $cids = implode( ',', $cid ); $database->setQuery( "UPDATE #__obrens SET published='$publish'WHERE id IN ($cids)" ); if (!$database->query()) { echo "\n"; exit(); } mosRedirect( "index2.php?option=$option" ); } function orderRef( $uid, $inc, $option ) { global $database; $row = new mosartref( $database ); $row->load( $uid ); $row->move( $inc, "published >= 0" ); mosRedirect( "index2.php?option=$option" ); } function cancelRef( $option ) { mosRedirect( "index2.php?option=$option" ); } function saveConfig ($option, $artref_showphone, $artref_showmail, $artref_showwebsite, $artref_showstatus, $artref_showbeschrlink, $artref_showpicture, $obrens_verlista, $obrens_verfooter, $artref_refperside, $obrens_rutafich, $obrens_nomfich, $obrens_extpdf, $obrens_extmid, $obrens_extmus, $rutalocal, $obrens_ordenlista) { $configfile = "components/com_obrens/config.obrens.php"; @chmod ($configfile, 0766); $permission = is_writable($configfile); if (!$permission) { $mosmsg = ADM_ARTREF_ERROR_D; mosRedirect("index2.php?option=$option&act=settings",$mosmsg); break; } $config = ""; if ($fp = fopen("$configfile", "w")) { fputs($fp, $config, strlen($config)); fclose ($fp); } mosRedirect("index2.php?option=$option&task=settings", ADM_ARTREF_GESPEICHERT); } function showConfig( $option ) { global $mosConfig_absolute_path; require($mosConfig_absolute_path."/administrator/components/com_obrens/config.obrens.php"); $yesno[] = mosHTML::makeOption( '0', LIT_ADM_NO ); $yesno[] = mosHTML::makeOption( '1', LIT_ADM_SI ); $listdisp[] = mosHTML::makeOption( '1', LIT_ADM_LISTAS ); $listdisp[] = mosHTML::makeOption( '2', LIT_ADM_CATEGORIAS ); $listdisp2[] = mosHTML::makeOption( '1', LIT_TITULO ); $listdisp2[] = mosHTML::makeOption( '2', LIT_AUTOR ); $listdisp2[] = mosHTML::makeOption( '3', LIT_CODIGO ); ?>
 
   
"; echo "

".ADM_ARTREF_ERROR_J."


"; echo "Language file: ".$file.".
"; echo "You need to chmod this to 766 in order for the config to be updated


"; echo ""; }else{ echo "
"; echo "

".ADM_ARTREF_ERROR_k."

"; echo "
"; } HTML_artref::showLanguage($file,$option); } function saveLanguage($file, $filecontent, $option) { @chmod ($file, 0766); $permission = is_writable($file); if (!$permission) { mosRedirect("index2.php?option=$option&task=language", "Language file not writeable!"); break; } if ($fp = fopen( $file, "w")) { fputs($fp,stripslashes($filecontent)); fclose($fp); mosRedirect( "index2.php?option=$option&task=language", "Language file saved" ); } } ?>