Skip to content

Instantly share code, notes, and snippets.

@jsfernando
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsfernando/91af2c8dbb9d0ca65731 to your computer and use it in GitHub Desktop.
Save jsfernando/91af2c8dbb9d0ca65731 to your computer and use it in GitHub Desktop.
Arquivo index.php do Template Seb_table do CCK Seblod
<?php
/**
* @version SEBLOD 3.x Core
* @package SEBLOD (App Builder & CCK) // SEBLOD nano (Form Builder)
* @url http://www.seblod.com
* @editor Octopoos - www.octopoos.com
* @editor2 JSFernando - jsfernando.com
* @copyright Copyright (C) 2013 SEBLOD. All Rights Reserved.
* @license GNU General Public License version 2.1 or later; see _LICENSE.php
**/
/**
* Alterardo em 11/2013
* TEm diferença no código para versão atual da index.php do seb_table...
* https://github.com/Octopoos/SEBLOD/blob/dev/templates/seb_table/index.php
*/
defined( '_JEXEC' ) or die;
// -- Initialize
require_once dirname(__FILE__).'/config.php';
$cck = CCK_Rendering::getInstance( $this->template );
if ( $cck->initialize() === false ) { return; }
$table_layout = $cck->getStyleParam( 'table_layout', '' );
$isFixed = ( $table_layout == 'fixed' ) ? 1 : 0;
$class_table = ( $isFixed ) ? $class_table.' fixed' : $class_table;
$class_table = trim( $cck->getStyleParam( 'class_table', 'category zebra table' ) );
$class_table = $class_table ? ' class="'.$class_table.'"' : '';
$class_row0 = trim( $cck->getStyleParam( 'class_table_tr_even', 'cat-list-row%i' ) );
$class_row0 = $class_row0 ? ' class="'.str_replace( '%i', '0', $class_row0 ).'"' : '';
$class_row1 = trim( $cck->getStyleParam( 'class_table_tr_odd', 'cat-list-row%i' ) );
$class_row1 = $class_row1 ? ' class="'.str_replace( '%i', '1', $class_row1 ).'"' : '';
$doc = JFactory::getDocument();
$doc->addStyleSheet( JURI::root( true ).'/templates/'.$cck->template. '/css/'.'style.css' );
// -- Render
?>
<div id="<?php echo $cck->id; ?>" class="<?php echo $cck->id_class; ?>cck-f100 cck-pad-<?php echo $cck->getStyleParam( 'position_margin', '10' ); ?>">
<div>
<?php
$css = array();
$items = $cck->getItems();
$positions = $cck->getPositions();
unset( $positions['hidden'] );
if ( count( $items ) ) { ?>
<table<?php echo $class_table; ?>>
<?php
$head = '';
$thead = false;
foreach ( $positions as $name=>$position ) {
$class = $position->css;
$css[$name] = $class ? ' class="'.$class.'"' : '';
$legend = ( $position->legend ) ? $position->legend : ( ( $position->legend2 ) ? $position->legend2 : '' );
$width = $cck->w( $name );
$width = ( $width ) ? ' width="'.$width.'"' : '';
if ( $legend || $width ) {
if ( $legend ) {
$thead = true;
}
$head .= '<th'.$css[$name].$width.'>'.$legend.'</th>';
}
}
?>
<?php if ( $head && $thead ) { ?>
<thead>
<tr><?php echo $head; ?></tr>
</thead>
<?php } ?>
<tbody>
<?php
$i = 0;
foreach ( $items as $item ) {
?>
<tr <?php echo ${'class_row'.($i % 2)}; ?>>
<?php
foreach ( $positions as $name=>$position ) {
$fieldnames = $cck->getFields( $name, '', false );
echo '<td'.$css[$name].'>';
foreach ( $fieldnames as $fieldname ) {
// Botão Excluir - Validar Botão ****************************************************************/
if ($fieldname == 'salaaula_id') {
$salaaula_id = $item->renderField( $fieldname );
$html = "<a href=\"$salaaula_id\" target=\"_blank\" class=\"salaaula_id\"><button type=\"button\" class=\"btn btn-mini btn-danger\"><i class=\"icon-trash icon-white\"></i></button></a>";
/* ************************************************************************************************ */
} else {
$html = $item->renderField( $fieldname );
}
if ( $html != '' ) {
echo '<div style="clear:left;">'.$html.'</div>'; //todo: markup
}
}
echo '</td>';
}
?>
</tr>
<?php $i++; } ?>
</tbody>
</table>
<?php } ?>
</div>
</div>
<?php
// -- Finalize
$cck->finalize();
?>
<!--//
// Chamada jQuery Ajax para o Botão Excluir
//-->
<script type="text/javascript" src="/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('.salaaula_id').click(function(event){
event.preventDefault();
var id = jQuery(this).attr("href");
if(confirm('Tem certeza de que deseja excluir a Reserva de Sala de Sala de Aula ?')){
jQuery.ajax({
type: "POST" ,
url: "<?php echo JURI::base();?>/includes/delete_reservasalaaula.php",
data: { xid: id },
dataType: "html",
success: function( data ) {
jQuery("#system").fadeOut(100).html(data).slideDown('slow');
}
});
}
return false;
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment