Download - Joomla! Components - Uma visão geral
![Page 1: Joomla! Components - Uma visão geral](https://reader034.vdocuments.pub/reader034/viewer/2022052618/554f5fd1b4c9058a148b46b7/html5/thumbnails/1.jpg)
Joomla!Components
(Uma Visão Geral)
René MunizDesenvolvedor Joomla!Fábrica Livre
![Page 2: Joomla! Components - Uma visão geral](https://reader034.vdocuments.pub/reader034/viewer/2022052618/554f5fd1b4c9058a148b46b7/html5/thumbnails/2.jpg)
Por que?
![Page 3: Joomla! Components - Uma visão geral](https://reader034.vdocuments.pub/reader034/viewer/2022052618/554f5fd1b4c9058a148b46b7/html5/thumbnails/3.jpg)
• PHP (Doh!)
• OOP (Programação Orientada a Objetos)
• MVC (Model-View-Controller)
• Joomla! Framework
Conceitos
![Page 4: Joomla! Components - Uma visão geral](https://reader034.vdocuments.pub/reader034/viewer/2022052618/554f5fd1b4c9058a148b46b7/html5/thumbnails/4.jpg)
Programação Orientada a Objetos (OOP)
![Page 5: Joomla! Components - Uma visão geral](https://reader034.vdocuments.pub/reader034/viewer/2022052618/554f5fd1b4c9058a148b46b7/html5/thumbnails/5.jpg)
Objeto
![Page 6: Joomla! Components - Uma visão geral](https://reader034.vdocuments.pub/reader034/viewer/2022052618/554f5fd1b4c9058a148b46b7/html5/thumbnails/6.jpg)
Classe StarFighter
class StarFighter{
public $size;public $color;public $wings;public $droid;public $guns = array();
function accelerate() {/* Procedure to accelerate here */
}
function shoot() {/* Procedure to shoot something here */
}}
$XWing = new StarFighter();$XWing->size = "2.2 metters";$XWing->color = "#FFFFFF";$XWing->wings = "4";$XWing->droid = "1";$XWing->guns = array("regular" => 4, "bomb" => 1);
![Page 7: Joomla! Components - Uma visão geral](https://reader034.vdocuments.pub/reader034/viewer/2022052618/554f5fd1b4c9058a148b46b7/html5/thumbnails/7.jpg)
Model-View-Controller
![Page 8: Joomla! Components - Uma visão geral](https://reader034.vdocuments.pub/reader034/viewer/2022052618/554f5fd1b4c9058a148b46b7/html5/thumbnails/8.jpg)
Modelo == Objeto
![Page 9: Joomla! Components - Uma visão geral](https://reader034.vdocuments.pub/reader034/viewer/2022052618/554f5fd1b4c9058a148b46b7/html5/thumbnails/9.jpg)
View == Interface
![Page 10: Joomla! Components - Uma visão geral](https://reader034.vdocuments.pub/reader034/viewer/2022052618/554f5fd1b4c9058a148b46b7/html5/thumbnails/10.jpg)
Controller == Regras
![Page 11: Joomla! Components - Uma visão geral](https://reader034.vdocuments.pub/reader034/viewer/2022052618/554f5fd1b4c9058a148b46b7/html5/thumbnails/11.jpg)
Joomla! Framework
![Page 12: Joomla! Components - Uma visão geral](https://reader034.vdocuments.pub/reader034/viewer/2022052618/554f5fd1b4c9058a148b46b7/html5/thumbnails/12.jpg)
Joomla!
![Page 13: Joomla! Components - Uma visão geral](https://reader034.vdocuments.pub/reader034/viewer/2022052618/554f5fd1b4c9058a148b46b7/html5/thumbnails/13.jpg)
Joomla’s API(http://api.joomla.org)
JFactory, JRoute, JText, JVersion, JApplication, JApplicationHelper, JComponentHelper, JController, JMenu, JModel, JModuleHelper, JPathway, JRouter, JView, JObject, JObservable, JObserver, JTree, JNode, JCache, JCacheCallback, JCacheOutput, JCachePage, JCacheStorage, JCacheStorageApc, JCacheStorageEaccelerator, JCacheStorageFile, JCacheStorageMemcache, JCacheStorageXCache, JCacheView, JClientHelper, JFTP, JLDAP, JDatabase, JDatabaseMySQL, JDatabaseMySQLi, JRecordSet, JTable, JTableARO, JTableAROGroup, JTableCategory, JTableComponent, JTableContent, JTableMenu, JTableMenuTypes, JTableModule, JTablePlugin, JTableSection, JTableSession, JTableUser, JDocument, JDocumentError, JDocumentFeed, JDocumentHTML, JDocumentPDF, JDocumentRaw, JDocumentRenderer, JDocumentRendererAtom, JDocumentRendererComponent, JDocumentRendererHead, J D o c u m e n t R e n d e r e r M e s s a g e , JDocumentRendererModule, JDocumentRendererModules, JDocumentRendererRSS, JBrowser, JRequest, JResponse, JURI, JError, JException, JLog, JProfiler, JDispatcher, JEvent, JArchive, JArchiveBzip2, JArchiveGzip, JArchiveTar, JArchiveZip, JFile, JFolder, JPath, JFilterInput, JFilterOutput, JButton, JButtonConfirm, JButtonCustom, JButtonHelp, JButtonLink, JButtonPopup, JButtonSeparator, JButtonStandard, JEditor, JElement, JElementCalendar, JElementCategory, JElementEditors, JElementFileList, JElementFolderList, JElementHelpsites, JElementHidden, JElementImageList, JElementLanguages, JElementList, JElementMenu, JElementMenuItem, JElementPassword, JElementRadio, JElementSection, JElementSpacer, JElementSQL, JElementText, JElementTextarea, JElementTimezones, JElementUserGroup, JHtml, JHtmlBehavior, JHtmlContent, JHtmlEmail, JHtmlForm, JHtmlGrid, JHtmlImage, JHtmlList, JHtmlMenu, JHtmlSelect, JPagination, JPane, JParameter, JToolBar, JInstaller, JInstallerComponent, JInstallerHelper, JInstallerLanguage, JInstallerModule, JInstallerPlugin, JInstallerTemplate, JHelp, JLanguageHelper, JLanguage, JMailHelper, JMail, JPluginHelper, JPlugin, JRegistry, JRegistryFormat, JRegistryFormatINI, JRegistryFormatPHP, JRegistryFormatXML, JSession, JSessionStorage, JSessionStorageApc, JSessionStorageDatabase, JSessionStorageEaccelerator, JSessionStorageMemcache, JSessionStorageNone, JSessionStorageXcache, JAuthentication, JAuthorization, JUserHelper, JUser, JArrayHelper, JBuffer, JDate, JSimpleCrypt, JSimpleXML, JSimpleXMLElement, JString, JUtility
![Page 14: Joomla! Components - Uma visão geral](https://reader034.vdocuments.pub/reader034/viewer/2022052618/554f5fd1b4c9058a148b46b7/html5/thumbnails/14.jpg)
Getting StartedHello World!
![Page 15: Joomla! Components - Uma visão geral](https://reader034.vdocuments.pub/reader034/viewer/2022052618/554f5fd1b4c9058a148b46b7/html5/thumbnails/15.jpg)
Criando um componente
• site/hello.php
• site/controller.php
• site/views/hello/view.html.php
• site/views/hello/tmpl/default.php
• hello.xml
Para um componente básicosão necessários 5 arquivos
![Page 16: Joomla! Components - Uma visão geral](https://reader034.vdocuments.pub/reader034/viewer/2022052618/554f5fd1b4c9058a148b46b7/html5/thumbnails/16.jpg)
/** * @package Joomla.Tutorials * @subpackage Components * components/com_hello/hello.php * @link http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_1 * @license GNU/GPL*/ // No direct accessdefined( '_JEXEC' ) or die( 'Restricted access' ); // Require the base controller
require_once( JPATH_COMPONENT.DS.'controller.php' ); // Require specific controller if requestedif($controller = JRequest::getWord('controller')) { $path = JPATH_COMPONENT.DS.'controllers'.DS.$controller.'.php'; if (file_exists($path)) { require_once $path; } else { $controller = ''; }} // Create the controller$classname = 'HelloController'.$controller;$controller = new $classname( ); // Perform the Request task$controller->execute( JRequest::getVar( 'task' ) ); // Redirect if set by the controller$controller->redirect();
index.php?option=com_hello&view=hello
site/hello.php
![Page 17: Joomla! Components - Uma visão geral](https://reader034.vdocuments.pub/reader034/viewer/2022052618/554f5fd1b4c9058a148b46b7/html5/thumbnails/17.jpg)
/** * @package Joomla.Tutorials * @subpackage Components * @link http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_1 * @license GNU/GPL */ // No direct accessdefined( '_JEXEC' ) or die( 'Restricted access' );
jimport('joomla.application.component.controller'); /** * Hello World Component Controller * * @package Joomla.Tutorials * @subpackage Components */class HelloController extends JController{ /** * Method to display the view * * @access public */ function display() { parent::display(); }}
site/controller.php
![Page 18: Joomla! Components - Uma visão geral](https://reader034.vdocuments.pub/reader034/viewer/2022052618/554f5fd1b4c9058a148b46b7/html5/thumbnails/18.jpg)
/** * @package Joomla.Tutorials * @subpackage Components * @link http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_1 * @license GNU/GPL*/ // no direct accessdefined( '_JEXEC' ) or die( 'Restricted access' ); jimport( 'joomla.application.component.view' ); /** * HTML View class for the HelloWorld Component * * @package HelloWorld */class HelloViewHello extends JView{ function display($tpl = null) { $greeting = "Hello World!"; $this->assignRef( 'greeting', $greeting ); parent::display($tpl); }}
site/views/hello/view.html.php
![Page 19: Joomla! Components - Uma visão geral](https://reader034.vdocuments.pub/reader034/viewer/2022052618/554f5fd1b4c9058a148b46b7/html5/thumbnails/19.jpg)
<?php// No direct accessdefined( '_JEXEC' ) or die( 'Restricted access' );?>
<h1><?php echo $this->greeting; ?></h1>
site/views/hello/tmpl/default.php
![Page 20: Joomla! Components - Uma visão geral](https://reader034.vdocuments.pub/reader034/viewer/2022052618/554f5fd1b4c9058a148b46b7/html5/thumbnails/20.jpg)
<?xml version="1.0" encoding="utf-8"?><install type="component" version="1.5.0"> <name>Hello</name> <!-- The following elements are optional and free of formatting constraints --> <creationDate>2007-02-22</creationDate> <author>John Doe</author> <authorEmail>[email protected]</authorEmail> <authorUrl>http://www.example.org</authorUrl> <copyright>Copyright Info</copyright> <license>License Info</license> <!-- The version string is recorded in the components table --> <version>1.01</version> <!-- The description is optional and defaults to the name --> <description>Description of the component ...</description> <!-- Site Main File Copy Section --> <!-- Note the folder attribute: This attribute describes the folder to copy FROM in the package to install therefore files copied in this section are copied from /site/ in the package --> <files folder="site"> <filename>controller.php</filename> <filename>hello.php</filename> <filename>index.html</filename> <filename>views/index.html</filename> <filename>views/hello/index.html</filename> <filename>views/hello/view.html.php</filename> <filename>views/hello/tmpl/default.php</filename> <filename>views/hello/tmpl/index.html</filename> </files></install>
site/views/hello/tmpl/default.php
![Page 21: Joomla! Components - Uma visão geral](https://reader034.vdocuments.pub/reader034/viewer/2022052618/554f5fd1b4c9058a148b46b7/html5/thumbnails/21.jpg)
http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_1