You are on page 1of 1

/com_auto/administration/tables/auto.

php

<?php /com_boxoffice/administration/models/revues.php /com_boxoffice/administration/models/revue.php


/**
* Boxoffice Administrator revues table <?php
* <?php /**
* @package com_boxoffice /** * Boxoffice Administrator revue model
* @subpackage components * Boxoffice Administrator revues model *
* @link http://www.packtpub.com * * @package com_boxoffice
* @license GNU/GPL * @package com_boxoffice * @subpackage components
*/ * @subpackage components * @link http://www.packtpub.com
// no direct access * @link http://www.packtpub.com * @license GNU/GPL
defined( '_JEXEC' ) or die( 'Restricted access' ); * @license GNU/GPL */
/** */ // no direct access
* Revue Table class // no direct access defined( '_JEXEC' ) or die( 'Restricted access' );
* defined( '_JEXEC' ) or die( 'Restricted access' ); // Import the JModel class
* @package com_boxoffice // Import the JModel class jimport( 'joomla.application.component.model' );
/com_auto/auto.php * @subpackage components jimport( 'joomla.application.component.model' ); /**
*/ /** * Boxoffice Revue Model
class TableRevue extends JTable * Boxoffice Revues Model *
<?php
{ * * @package com_boxoffice
/com_boxoffice/administration/admin.boxoffice.php /** @var int Primary key */ * @package com_boxoffice * @subpackage components
defined('_JEXEC') or die('Restricted access');
var $id = 0; * @subpackage components */
/com_auto/controller.php require_once (JPATH_COMPONENT.DS.'controller.php');
/** @var string */ */ class BoxofficeModelRevue extends JModel
var $title = ''; class BoxofficeModelRevues extends JModel {
/** /** @var string */ { /**
<?php $controller = new AutoController(); * Method to get a revue
* Boxoffice Administrator entry point var $rating = ''; /**
* /** @var string */ * Revues data array of objects *
defined('_JEXEC') or die(); $controller->execute(JRequest::getCmd('task')); * @access public
* @package com_boxoffice var $quikquip = ''; *
* @subpackage components /** @var string */ * @access private * @return object
jimport('joomla.application.component.controller'); $controller->redirect(); var $revuer = ''; * @var array */
* @license GNU/GPL
*/ /** @var datetime */ */ function getRevue( $id )
class AutoController extends JController ?> var $revued = ''; var $_revues; {
{ /** @var string */ /** $db = $this->getDBO();
// no direct access
function display() var $revue = ''; * Method to get a list of revues $table = $db->nameQuote( '#__boxoffice_revues' );
defined( '_JEXEC' ) or die( 'Restricted access' );
{ /** @var string */ * $key = $db->nameQuote( 'id' );
parent::display(); var $stars = ''; * @access public $query = " SELECT * FROM " . $table
// Require the base controller
} /** @var int */ * @return array of objects . " WHERE " . $key . " = " . $id;
require_once( JPATH_COMPONENT.DS.'controller.php' );
} var $checked_out = 0; */ $db->setQuery($query);
/** @var datetime */ function getRevues() $revue = $db->loadObject();
// Create the controller if($revue === null)
?> var $checked_out_time = ''; {
$controller = new BoxofficeController(); {
/** @var int */ $db =& $this->getDBO();
var $ordering = 0; $table = $db->nameQuote( '#__boxoffice_revues' ); JError::raiseError(500, 'Revue ['.$id.'] not found.');
/com_auto/models/auto.php //Perform the requested task, use 'display' if no task is specified
/** @var int */ $query = "SELECT * FROM " . $table; }
$controller->execute(JRequest::getVar('task', 'display')); var $published = 0; else
$db->setQuery( $query );
<?php /** @var int */ $this->_revues = $db->loadObjectList(); {

defined('_JEXEC') or die(); Crear el Punto de Entrada.


FRONT-END //Redirect if set by the controller
$controller->redirect();
var $hits = 0;
/**
// Return the list of revues
return $this->_revues;
// Return the revue data
return $revue;
* @param database A database connector object } }
jimport('joomla.application.component.model'); */ } }
function __construct( &$db ) /**
class AutoModelAuto extends JModel { /** * Method that returns an empty revue with id of 0
{ parent::__construct('#__boxoffice_revues','id',$db); * Method to delete record(s) *
function _getAutoQuery( &$options ) } * * @access public
Crear el Controlador Principal. } * @access public * @return object
{
* @param array of revue ids */
$db = JFactory::getDBO();
*/ function getNewRevue()
$id = @$options['id'];
function delete( $cids ) {
$select = 'a.*';
{ $newRevue =& $this->getTable( 'revue' );
$from = '#__auto AS a'; $newRevue->id = 0;
$wheres[] = 'a.published = 1'; $db = $this->getDBO();
$table = $db->nameQuote('#__boxoffice_revues'); return $newRevue;
$query = "SELECT " . $select . }
Sumario de Registros. Crear los Modelos. $id = $db->nameQuote('id');
"\n FROM " . $from . /**
$query = ' DELETE FROM ' . $table
"\n WHERE " . implode( "\n AND ", $wheres ); * Method to store a revue
. ' WHERE ' . $id
return $query; *
} CREAR UN COMPONENTE . ' IN (' . implode( ',', $cids ) . ') ';
$db->setQuery( $query ); * @access public

function getAutoList( $options=array() ) BACK-END if( !$db->query() )


{
* @return Boolean true on success
*/
{ Crear el Punto de Entrada $errorMessage = $this->getDBO()->getErrorMsg(); function store()
Sumario de Registros. Crear las Vistas.
$query = $this->_getAutoQuery( $options ); JError::raiseError(500, 'Error deleting revues: ' {
$result = $this->_getList( $query ); . $errorMessage ); // Get the table
return @$result; } $table =& $this->getTable();
} } $revue = JRequest::get('post');
// Convert the date to a form that the database can understand
} jimport('joomla.utilities.date');
Sumario de Registros. Crear las Plantillas. $date = new JDate( JRequest::getVar( 'revued', '', 'post' ));
?> Crear las Tablas $revue['revued'] = $date->toMySQL();

Crear el Panel de Administración // Make sure the table buffer is empty


$table->reset();
// Close order gaps
(BACK-END) COMPONENTE $table->reorder();
// Determine the next order position for the revue
/com_auto/views/auto/view.html.php $table->set( 'ordering', $table->getNextOrder());
Crear los Modelos Sumario de Registros. // Bind the data to the table
<?php if( !$table->bind($revue))
{
jimport('joomla.application.component.view'); $this->setError( $this->_db->getErrorMsg());
Registro Individual.

class AutoViewAuto extends JView


/com_auto/views/auto/tmpl/default.php
COMPONENTE Crear las Páginas Web return false;
}
// Validate the data
{
function display($tpl = null)
<?php
defined('_JEXEC') or die('Restricted access');
(FRONT-END) if( !$table->check())
{
{ ?> Crear las Vistas Mostrar un Sumario de Registros. $this->setError( $this->_db->getErrorMsg());
$model = &$this->getModel(); <script type="text/javascript"> return false;
$rows = $model->getAutoList(); function OpenWindow (Adresse) { }
$this->assignRef('rows' , $rows); MyWindow = window.open (Adress, "Auto", "width=400,height=300,left=100,top=200"); // Store the revue
Mostrar un Registro Individual.
parent::display($tpl); MyWindow.focus(); if( !$table->store())
} } {
} </script> // An error occurred, update the model error message

?>
<h1><?php echo "&Uuml;berschrift";?></h1>
<ul>
Empaquetar el Componente Crear las Plantillas Sumario de Registros.
$this->setError( $table->getErrorMsg());
return false;
<? }
foreach ($this->rows as $row) { // Reading of the data sets in the array // Checkin the revue
?> Registro Individual. if( !$table->checkin())
<li> {
<?php echo $row->text;?> // An error occurred, update the model error message
<small><em>(<?php echo $row->manufacturer;?>)</em></small> $this->setError( $table->getErrorMsg());
Crear los Controladores Crear el Controlador Principal. return false;
<br>
<a href="<?php echo $row->photo_large;?>" onclick="OpeWindow(this.href); return false"> COMPONENTE }
return true;
<img src=<?php echo $row->photo_small;?>>
}
</a> }
</li>
<?php
}
?>
</ul> /com_auto/administration/tables/auto.php

/com_boxoffice/administration/BoxofficeController.php /com_auto/administration/views/auto/tmpl/form.php /com_auto/administration/views/autos/tmpl/default.php

<?php

/**
/com_auto/install.sql * Boxoffice Administrator Controller
*
DROP TABLE IF EXISTS `#__auto`; * @package com_boxoffice

CREATE TABLE `#__auto` (


PAQUETE * @subpackage components
* @link http://www.packtpub.com
/com_auto/administration/tables/auto.php
`id` int(11) NOT NULL auto_increment, * @license GNU/GPL
`text` text character set utf8 NOT NULL, */
`hersteller` varchar(100) character set utf8 NOT NULL,
`photo_gross` varchar(200) character set utf8 NOT NULL, // no direct access
`photo_klein` varchar(200) character set utf8 NOT NULL, Crear el Manifiesto de Instalación. defined( '_JEXEC' ) or die( 'Restricted access' );
`published` tinyint(1) NOT NULL,
PRIMARY KEY (`id`) // Load the base JController class
) ENGINE=MyISAM AUTO_INCREMENT=5 ; jimport( 'joomla.application.component.controller' );

INSERT INTO `#__auto` (`id`, `text`, `manufacturer`, `photo_large`, `photo_small`, `published`) /**
Instalar Crear los ficheros de Instalación.
VALUES (2, 'Smart fortwo', 'Smart', * Boxoffice Component Administrator Controller
'http://localhost/joomla/images/stories/com_auto/smart_large.jpg', *
'http://localhost/joomla/images/stories/com_auto/smart_small.jpg', 1), * @package com_boxoffice
(4, 'Roadster', 'Smart', * @subpackage components
'http://localhost/joomla/images/stories/com_auto/roadster_large.jpg', Desinstalar
*/
'http://localhost/joomla/images/stories/com_auto/roadster_small.jpg', 1);
class BoxofficeController extends JController
{
Comprimir todo el componente
dentro de un único Fichero. /**
* Method to display the list view
*
/com_auto/uninstall.sql * @access public
*
*/
DROP TABLE IF EXISTS `#__auto`;
function display()
{
/com_auto/auto.xml // We override the JController default display
//method which expects a view named boxoffice.
// We want a view of 'revues' that uses the 'default' layout.
<?xml version="1.0" encoding="utf-8"?> // Set the view and the model
<!DOCTYPE install SYSTEM "http://dev.joomla.org/xml/1.5/component-install.dtd">
$view =& $this->getView( 'revues', 'html' );
<install type="component" version="1.5.0"> $model =& $this->getModel( 'revues' );
$view->setModel( $model, true );
<name>Auto</name>
<creationDate>November 2007</creationDate> // Use the View display method
<author>Hagen Graf</author>
<authorEmail>hagen.graf@gmail.com</authorEmail> $view->display();
<authorUrl>http://www.cocoate.com</authorUrl>
<copyright>All rights reserved</copyright> }
<license>GNU/GPL</license>
<version>Component Version String</version> /**
<description>description of the component ... </description> * Method to display the edit view
*
<files folder="site"> * @access public
<filename>index.html</filename> *
<filename>auto.php</filename> */
<filename>controller.php</filename>
<filename>views/index.html</filename> function edit()
<filename>views/auto/index.html</filename> {
<filename>views/auto/view.html.php</filename>
<filename>views/auto/tmpl/index.html</filename> // Get the requested id(s) as an array of ids
<filename>views/auto/tmpl/default.php</filename> $cids = JRequest::getVar('cid', null, 'default', 'array');
<filename>models/auto.php</filename> if( $cids === null )
</files> {
// Report an error if there was no cid parameter in the request
<install> JError::raiseError( 500,
<sql> 'cid parameter missing from the request' );
<file charset="utf8" driver="mysql">install.sql</file> }
</sql>
</install> // Get the first revue to be edited
$revueId = (int)$cids[0];
<uninstall>
<sql> // Set the view and model for a single revue
<file charset="utf8" driver="mysql">uninstall.sql</file> $view =& $this->getView( JRequest::getVar( 'view', 'revue' ), 'html' );
</sql> $model =& $this->getModel( 'revue' );
</uninstall> $view->setModel( $model, true );
<administration> // Display the edit form for the requested revue
<menu>Joomla! 1.5 Book Auto</menu> $view->edit( $revueId );
<files folder="admin">
<filename>index.html</filename> }
<filename>admin.auto.php</filename>
<filename>controller.php</filename> /**
<filename>controllers/auto.php</filename> * Method to add a new revue
<filename>controllers/index.html</filename> *
<filename>models/auto.php</filename> * @access public
<filename>models/autos.php</filename> *
<filename>models/index.html</filename> */
<filename>views/autos/view.html.php</filename> function add()
<filename>views/autos/index.html</filename> {
<filename>views/autos/tmpl/default.php</filename> // Set the view for a single revue
<filename>views/autos/tmpl/index.html</filename> $view =& $this->getView( JRequest::getVar( 'view', 'revue' ), 'html' );
<filename>views/auto/view.html.php</filename> $model =& $this->getModel( 'revue' );
<filename>views/auto/tmpl/form.php</filename> $view->setModel( $model, true );
<filename>views/auto/index.html</filename> $view->add();
<filename>views/auto/tmpl/index.html</filename> }
<filename>tables/auto.php</filename>
<filename>tables/index.html</filename> /**
<filename>install.sql</filename> * Method to save the revue
<filename>uninstall.sql</filename> *
</files> * @access public
</administration> *
*/
</install> function save()
{
$model =& $this->getModel( 'revue' );
$model->store();
$redirectTo = Jroute::_('index.php?option='.JRequest::getVar('option').'&task=display');
$this->setRedirect( $redirectTo, 'Revue Saved' );
}

/**
* Method to cancel
*
* @access public
*
*/
function cancel()
{
$redirectTo = Jroute::_('index.php?option='.JRequest::getVar('option').'&task=display');

$this->setRedirect ($redirectTo, 'Cancelled');


}

/**
* Method to remove one or more revenues
*
* @access public
*
*/
function remove()
{
// Retrieve the ids to be removed
$cids = JRequest::getVar ('cid', null, 'default', 'array');
if( $cids === null )
{
// Make sure there were records to be removed
JError::raiseError( 500, 'No revues were selected for removal' );
}
$model =& $this->getModel( 'revues');
$model->delete( $cids);
$redirectTo =
JRoute::_('index.php?option='.JRequest::getVar( 'option' ).'&task=display');
$this->setRedirect( $redirectTo, 'Revues Deleted' );
}

You might also like