Professional Documents
Culture Documents
Overzicht Presentatie
Introductie OOP 1.
Module zonder MVC met 2 bestanden 2. Module met MVC 3. Module uitbreidingen Vragen
>>> Sheets digitaal beschikbaar <<<
OOP
Object
Oriented Programming
Een programma wordt opgebouwd uit objecten Een object bevat een blauwdruk (Class) met variabelen en functie(s) (methode) De objecten worden aangeroepen (geinstantieerd) en kunnen dan gebruikt worden
Voordelen:
OOP
OOP
Informatie verbergen
Werking
Overerven
Versnellingsbak?
Modulariteit
Accu
vervangen?
OOP
Analogie:
Informatie verbergen
Database
object
Overerven
Joomla's
Modulariteit
Gebruik
OOP ModelViewController
MVC
architectuur:
Model zorgt voor de data View zorgt voor de weergave Controller zorgt voor de besturing
Class
require_once 'fpdf.php';
Object Object
class FPDF { var $page; //current page number var $n; //current object number [..] function FPDF($orientation='P', $unit='mm', $format='A4') function SetMargins($left, $top, $right=null) function Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='') etc.
Peter Martin joomladagen.nl 21+22 april 2012
10
11
12
13
bestanden:
.xml voor installatie en parameters
/modules/mod_db8brc/mod_db8brc.xml
14
/modules/mod_db8brc/mod_db8brc.xml
<?xml version="1.0" encoding="utf-8"?> <extension type="module" version="2.5" client="site" method="upgrade"> <name>db8BRC</name> <author>Peter Martin</author> <creationDate>April 2012</creationDate> <copyright>Copyright 2012 by Peter Martin / db8.nl.</copyright> <license>GNU/GPL</license> <authorEmail>joomla@db8.nl</authorEmail> <authorUrl>www.db8.nl</authorUrl> <version>j2.5-v1</version> <description>DB8BRC</description> </extension>
15
/modules/mod_db8brc/mod_db8brc.php
defined( '_JEXEC' ) or die; $db = Jfactory::getDbo(); // OOP! Instantieren van database object :-) $query = $db->getQuery(true); // Maak query string leeg $query->select('content.*, rating.rating_sum as sum, rating.rating_count as count'); $query->from('#__content_rating AS rating'); $query->leftJoin('#__content AS content ON content.id = rating.content_id'); $query->order('(sum/count) DESC'); $query->order('count DESC'); $db->setQuery($query->__toString()); $results = $db->loadObjectList(); echo "<ul>"; foreach ($results as $result){ echo "<li>$result->title (".($result->sum/$result->count).")</li>"; } echo "</ul>";
16
17
18
op voorzijde website
19
verbergen
20
21
22
helper.php
defined('_JEXEC') or die; abstract class modDb8BestRatedContentHelper { public static function getBestRatedContent(&$params) { $db = Jfactory::getDbo(); $query = $db->getQuery(true); $query->select('content.*, rating.rating_sum as sum, rating.rating_count as count'); $query->from('#__content_rating AS rating'); $query->leftJoin('#__content AS content ON content.id = rating.content_id'); $query->order('(sum/count) DESC'); $query->order('count DESC'); $db->setQuery($query->__toString()); $results = $db->loadObjectList(); return $results; } }
23
/tmpl/default.php
defined('_JEXEC') or die; ?> <ul> <?php foreach ($results as $result){ ?> <li><?php echo $result->title." (".($result->sum/$result->count).")";?></li> <?php } ?> </ul>
24
mod_db8bestratedcontent.php
defined( '_JEXEC' ) or die; // Class opvragen (Include the helper file only once) require_once dirname(__FILE__).'/helper.php'; // instantieer object "results" $results = modDb8BestRatedContentHelper::getBestRatedContent($params); // Laat Joomla een layout file opvragen, 'default' = default.php require JModuleHelper::getLayoutPath('mod_db8bestratedcontent', $params->get('layout', 'default'));
25
26
27
op voorzijde website
28
/templates/beez_20/html/mod_db8bestratedcontent/
Kopieer
Wijzig
29
3. Module uitbreidingen
30
3. Module uitbreidingen
Parameters
a)Vormgeving Module (moduleclass_sfx) b)Layout file (ul/ol keuze ipv template override) c) Lengte van lijst d)Toon alleen bepaalde categorie e)Cache functionaliteit
Taalbestand Distributie
31
3. Module: Parameters
32
3. Module: Parameters
Parameters
33
34
/tmpl/default.php
35
HTML Output <ul class="db8bestratedcontent"> <li>Professionals (5)</li> <li>Search (5)</li> <li>Water is H<sub>2</sub>O (4)</li> <li>Content (4)</li> <li>Beginners (3.2)</li> </ul>
36
/tmpl/default.php /tmpl/ordered.php
37
file (ul/ol keuze ipv template override) Joomla genereert automatisch dropdown box op basis van bestanden in /tmpl/
38
helper.php
Verander $db->setQuery($query->__toString());
$db->setQuery($query->__toString(), 0, $params->get('count'));
39
van lijst
40
description="MOD_BEST_RATED_CONTENT_FIELD_CATEGORY_DESC" >
41
42
43
44
cache functie
45
3. Module uitbreidingen:Taalbestand
46
3. Module uitbreidingen:Taalbestand
Per
/language/en-GB/ /language/nl-NL/
Taal
en-GB.mod_db8bestratedcontent.sys.ini nl-NL.mod_db8bestratedcontent.sys.ini
Taal
en-GB.mod_db8bestratedcontent.ini nl-NL.mod_db8bestratedcontent.ini
47
3. Module uitbreidingen:Taalbestand
en-GB.mod_db8bestratedcontent.sys.ini
MOD_DB8BESTRATEDCONTENT="db8 Best Rated Content" DB8BESTRATEDCONTENT="Installation of db8 Best Rated Content succeeded." MOD_DB8BESTRATEDCONTENT="db8 Best Rated Content" MOD_BEST_RATED_CONTENT_FIELD_CATEGORY_DESC="Selects Articles from one or more Categories. If no selection will show all categories as default" MOD_BEST_RATED_CONTENT_FIELD_COUNT_LABEL="Count" MOD_BEST_RATED_CONTENT_FIELD_COUNT_DESC="The number of Articles to display (the default is 5)"
en-GB.mod_db8bestratedcontent.ini
48
49
Bevat alle aanwijzingen (referenties naar bestanden) voor installatie: <files> & <languages> <files> <filename module=" mod_db8bestratedcontent"> mod_db8bestratedcontent.php</filename> <folder>tmpl</folder> <filename>helper.php</filename> <filename>index.html</filename> <filename>mod_db8bestratedcontent.xml </filename> </files>
50
<languages folder="language">
<language tag="en-GB">en-GB/enGB.mod_db8bestratedcontent.ini</language> <language tag="en-GB">en-GB/enGB.mod_db8bestratedcontent.sys.ini</language> <language tag="nl-NL">nl-NL/nlNL.mod_db8bestratedcontent.ini</language> <language tag="nl-NL">nl-NL/nlNL.mod_db8bestratedcontent.sys.ini</language>
</languages>
51
bestand
Bestanden in Archive bestand plaatsen, bijv .zip Handige naam gebruiken, bijv mod_db8bestratedcontent_j25_v1.zip
modmodule db8bestratedcontent(developer) j25Joomla
+ naam extensie
52
Conclusie
53
Conclusie
Gebruik
Scheiding HTML Output (voor designers) en logica (developers) Template overrides Layout selectie
Opmerking
status (published/unpublished) artikel en categorie Toegangsniveau bezoeker & artikel en categorie Geen (SEF) hyperlinks naar artikelen
54
Vragen?
55
Vragen?
Presentatie
56
Gebruikte foto's
digital dreams - Flavio Takemoto, http://www.sxc.hu/photo/1160562 Home cinema setup 2 - "Ambrozjo", http://www.sxc.hu/photo/1361428 Home cinema setup 3 - "Ambrozjo", http://www.sxc.hu/photo/1361429 Remote Control - Asif Akbar, http://www.sxc.hu/photo/1025175 Code - Mario Alberto Magallanes Trejo, http://www.sxc.hu/photo/468319 ram Mohamed Riffath,http://www.sxc.hu/photo/487296 Blank E-Box for Software etc 6 - Przemyslaw Szczepanski, http://www.sxc.hu/photo/950048 digicity 1 - gerard79, http://www.sxc.hu/photo/1151540 switches - "trhaynes", http://www.sxc.hu/photo/56670 Bengali Keyborad - Mohammad Jobaed Adnan, http://www.sxc.hu/photo/676844 Box - Billy Alexander, http://www.sxc.hu/photo/1301543 signs signs - Jason Antony, http://www.sxc.hu/photo/751034 Face - Questions - Bob Smith, http://www.sxc.hu/photo/418215
57