12.1 Angaben in der Template-Sprachdatei /de-DE.tpl_ihrtemplate.sys.ini
COM_CONTENT_CATEGORY_VIEW_PORTFOLIO_TITLE="Portfolio Ansicht"
COM_CONTENT_CATEGORY_VIEW_PORTFOLIO_OPTION="Portfolio"
COM_CONTENT_CATEGORY_VIEW_PORTFOLIO_DESC="Mit dieser Auswahl legen Sie ein Blog mit Portfolio Layout an"
12.2 Basisangaben in der portfolio.xml-Datei
COM_CONTENT_CATEGORY_VIEW_PORTFOLIO_DESC
12.3 Einfache Modul-Chrome-Funktion in der modules.php-Datei
function modChrome_meinstil($module, &$params, &$attribs)
{
if ($module->content)
{
echo $module->content;
}
}
12.4 Überschreiben der Dateien aus dem media/jui/js/-Ordner
paula2017Elisa Foltynbook@coolcat-creations.comhttp://www.coolcat-creations.comCopyright 2013-2016 Blackrock Digital LLCCode released under the [MIT]
(https://github.com/BlackrockDigital/startbootstrap-creative/blob/gh-pages/LICENSE) license.
1.0TPL_PAULA_DESC
12.9 Datei- und Ordnerstrukturauflistung in der templateDetails.xml-Datei
12.12 Auflistung der Template-Parameter in der templateDetails.xml-Datei
12.13 Übersetzung der Template-Parameter in der de-DE.tpl_paula.ini-Datei
TPL_PAULA_FIELD_THEME="Templatefarbe"
TPL_PAULA_FIELD_THEME_DESC="Wählen Sie hier die Templatefarbe aus"
TPL_PAULA_FIELD_THEME_ORANGE="Orange"
TPL_PAULA_FIELD_THEME_BLUE="Blau"
TPL_PAULA_FIELD_LOGOTYPE="Logoart"
TPL_PAULA_FIELD_LOGOTYPE_DESC="Wählen Sie hier aus ob Sie das Logo als Text oder Bild darstellen wollen"
TPL_PAULA_FIELD_LOGOTYPE_TEXT="Textlogo"
TPL_PAULA_FIELD_LOGOTYPE_IMG="Bildlogo"
TPL_PAULA_FIELD_LOGOTEXT="Logotext"
TPL_PAULA_FIELD_LOGOTEXT_DESC="Tragen Sie hier den Text ein, der als Logo erscheinen soll"
TPL_PAULA_FIELD_LOGOIMG="Bild hochladen"
TPL_PAULA_FIELD_LOGOIMG_DESC="Laden Sie hier ein Bild im Format 200 x 20px hoch"
TPL_PAULA_FIELD_LOGOIMG_ALT="Logo Alt Text"
TPL_PAULA_FIELD_IMGUPLOAD_ALT_DESC="Tragen Sie hier den Alt-tag für das Logobild ein"
12.14 Auflistung der Sprachdateien in der templateDetails.xml-Datei
12.15 Vollständige templateDetails.xml für unser Template.
paula2017Elisa Foltynbook@coolcat-creations.comhttp://www.coolcat-creations.comCopyright 2013-2016 Blackrock Digital LLCCode released under the [MIT]
(https://github.com/BlackrockDigital/startbootstrap-creative/blob/gh-pages/LICENSE) license.
1.0TPL_PAULA_DESCindex.phptemplateDetails.xmltemplate_preview.pngtemplate_thumbnail.pngfavicon.icoLICENSEcsshtmlimagesjslanguagelessvendormainnavheaderteasertopbreadcrumbsrightportfolioactioncontacten-GB/en-GB.tpl_paula.inien-GB/en-GB.tpl_paula.sys.inide-DE/de-DE.tpl_paula.inide-DE/de-DE.tpl_paula.sys.ini
12.16 Style-Angaben in der index.php-Datei
// Laden der Bootstrap CSS
$this->addStyleSheet($tplpath . '/vendor/bootstrap/css/bootstrap.min.css');
// Schriften laden
$this->addStyleSheet($tplpath . '/vendor/font-awesome/css/font-awesome.min.css');
$this->addStyleSheet('https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800');
$this->addStyleSheet('https://fonts.googleapis.com/css?family=Merriweather:400,300,300italic,400italic,700,700italic,900,900italic');
// CSS Datei für die Portfolio Popups laden
$this->addStyleSheet($tplpath . '/vendor/magnific-popup/magnific-popup.css');
// CSS Dateien für das Template laden
$this->addStyleSheet($tplpath . '/css/creative.css');
12.17 Skript-Angaben in der index.php Datei
// Skripte laden
// HTML5 Unterstützung aktivieren
$this->setHtml5(true);
// jQuery Skript von Joomla! laden
JHtml::_('jquery.framework');
// Bootstrap von Joomla! einbinden
// (Die Bootstrap Datei muss nicht extra geladen werden, nur in den richtigen Ordner verschoben werden)
JHtml::_('bootstrap.framework');
// Laden der Skriptdateien für Easing, Scrolling und Popups
$this->addScript('https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js', 'text/javascript', array('defer'=>'defer'));
$this->addScript($tplpath. '/vendor/scrollreveal/scrollreveal.min.js', 'text/javascript', array('defer'=>'defer'));
$this->addScript($tplpath. '/vendor/magnific-popup/jquery.magnific-popup.min.js', 'text/javascript', array('defer'=>'defer'));
// Laden der Skriptdateien für das Template
$this->addScript($tplpath . '/js/creative.min.js', 'text/javascript', array('defer'=>'defer'));
12.18 CustomTag und Meta-Angaben in der index.php-Datei
// nur für den IE 9 nutzen wir hier customTags
// Custom Tags für den IE9 definieren
$stylelink = '' . "\n";
// Custom Tags für den IE9 hinzufügen
$this->addCustomTag($stylelink);
// MetaTag für den Viewport definieren
$this->setMetaData('viewport', 'width=device-width, initial-scale=1');
12.19 Einleitung der index.php-Datei
<?php defined('_JEXEC') or die('Restricted access');
// Hier definieren wir eine kurze Variable fÃŒr den aktuellen Templatepfad
$tplpath = $this->baseurl . '/templates/' . $this->template;
// Laden der Joomla! System CSS
$this->addStyleSheet($this->baseurl . '/templates/system/css/system.css');
// Laden der Bootstrap Core CSS
$this->addStyleSheet($tplpath . '/vendor/bootstrap/css/bootstrap.min.css');
// Schriften laden
$this->addStyleSheet($tplpath . '/vendor/font-awesome/css/font-awesome.min.css');
$this->addStyleSheet('https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800');
$this->addStyleSheet('https://fonts.googleapis.com/css?family=Merriweather:400,300,300italic,400italic,700,700italic,900,900italic');
// CSS Datei fÃŒr die Portfolio Popups laden
$this->addStyleSheet($tplpath . '/vendor/magnific-popup/magnific-popup.css');
// CSS Datei fÃŒr das Template laden
$this->addStyleSheet ($this->baseurl . '/templates/' . $this->template . '/css/creative.css');
// Skripte laden
// jQuery Skript von Joomla! laden
JHtml::_('jquery.framework');
// Bootstrap von Joomla! einbinden
// (Die Bootstrap Datei muss nicht extra geladen werden, nur in den richtigen Ordner verschoben werden)
JHtml::_('bootstrap.framework');
// Laden der Skriptdateien fÃŒr Easing, Scrolling und Popups
$this->addScript('http://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js', 'text/javascript', true, false);
$this->addScript($tplpath. '/vendor/scrollreveal/scrollreveal.min.js', 'text/javascript', true, false);
$this->addScript($tplpath . '/vendor/magnific-popup/jquery.magnific-popup.min.js', 'text/javascript', true, false);
// Laden der Skriptdateien fÃŒr das Template
$this->addScript($tplpath . '/js/creative.min.js', 'text/javascript', true, false);
// Dokument Objekt laden //
$doc = JFactory::getDocument();
// nur fÃŒr den IE 9 nutzen wir hier customTags
// Custom Tags fÃŒr den IE9 definieren
$stylelink = '<!--[if lte IE 9]>' . "\n";
$stylelink .= '<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>' . "\n";
$stylelink .= '<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>' . "\n";
$stylelink .= '<![endif]-->' . "\n";
// Custom Tags fÃŒr den IE9 hinzufÃŒgen
$this->addCustomTag($stylelink);
// MetaTag fÃŒr den Viewport definieren
$this->setMetaData('viewport', 'width=device-width, initial-scale=1');
?>
12.20 Dynamischer Abruf des Template-Stils in der index.php-Datei
// Falls im Stil „orange“ als Farbe ausgewählt ist, lade creative.css
if ($this->params->get('templatecolor', 'orange') == 'orange' )
{
$this->addStyleSheet ('$tplpath . '/css/creative.css');
}
// Andernfalls ist die blaue CSS-Datei zu laden
else
{
$this->addStyleSheet ($tplpath . '/css/creative-blue.css');
}
12.21 Dynamischer Abruf der Template-Parameter für das Logo in der index.php
12.33 Code der Datei templates/paula/html/mod_custom/clean.php
<?php defined('_JEXEC') or die; ?>
<?php echo $module->content;?>
12.34 Code des Teaser-Bereichs in der Template-Vorlage
<section class="bg-primary" id="about">
<div class="container">
<div class="row">
<div class="col-lg-8 col-lg-offset-2 text-center">
<h2 class="section-heading">We've got what you need!</h2>
<hr class="light">
<p class="text-faded">Start Bootstrap has everything you need to get your new website up and running inno time! All of the templates and themes on Start Bootstrap are open source, free to download, and easy to use. No strings attached!</p>
<a href="#services" class="page-scroll btn btn-default btn-xl sr-button">Get Started!</a>
</div>
</div>
</div>
12.35 Erster Teil des Modul Chrome für den Teaser-Bereich in der Datei modules.php
<section id="contact">
<div class="container">
<div class="row">
<div class="col-lg-8 col-lg-offset-2 text-center">
<h2 class="section-heading">Let's Get In Touch!</h2>
<hr class="primary">
<p>Ready to start your next project with us? That's great! Give us a call or
send us an email and we will get back to you as soon as possible!</p>
</div>
<div class="col-lg-4 col-lg-offset-2 text-center">
<i class="fa fa-phone fa-3x sr-contact"></i>
<p>123-456-6789</p>
</div>
<div class="col-lg-4 text-center">
<i class="fa fa-envelope-o fa-3x sr-contact"></i>
<p>
<a href="mailto:your-email@your-domain.com">
feedback@startbootstrap.com
</a>
</p>
</div>
</div>
</div>
</section>
12.46 Aufruf des Kontaktbereichs in der index.php-Datei
12.49 Ergänzung der Template-Parameterübersetzungen in der de-De.tpl_paula.xml-Datei
TPL_PAULA_FIELD_MAINOUTPUT="Komponentenbereich ausgeben"
TPL_PAULA_FIELD_MAINOUTPUT_DESC="WÀhlen Sie aus ob die Komponente und die rechte Seitenleiste angezeigt werden sollen."
12.50 Fertiggestellte index.php-Datei
<?php defined('_JEXEC') or die('Restricted access');
// Hier definieren wir eine kurze Variable fÃŒr den aktuellen Templatepfad
$tplpath = $this->baseurl . '/templates/' . $this->template;
// Laden der Bootstrap CSS
$this->addStyleSheet($tplpath . '/vendor/bootstrap/css/bootstrap.min.css');
// Schriften laden
$this->addStyleSheet($tplpath . '/vendor/font-awesome/css/font-awesome.min.css');
$this->addStyleSheet('https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800');
$this->addStyleSheet('https://fonts.googleapis.com/css?family=Merriweather:400,300,300italic,400italic,700,700italic,900,900italic');
// CSS Datei fÃŒr die Portfolio Popups laden
$this->addStyleSheet($tplpath . '/vendor/magnific-popup/magnific-popup.css');
// CSS Dateien fÃŒr das Template laden und hinterlegten Parameter prÃŒfen.
// Bevor die CSS Dateien per Parameter eingebunden wurden, wurden die CSS folgenderma�en geladen:
// $this->addStyleSheet($tplpath . '/css/creative.css');
if ($this->params->get('templatecolor', 'orange') == 'orange')
{
$this->addStyleSheet($tplpath . '/css/creative.css');
}
else
{
$this->addStyleSheet($tplpath . '/css/creative-blue.css');
}
// Skripte laden
// HTML5 UnterstÃŒtzung aktivieren
$this->setHtml5(true);
// jQuery Skript von Joomla! laden
JHtml::_('jquery.framework');
// Bootstrap von Joomla! einbinden
// (Die Bootstrap Datei muss nicht extra geladen werden, nur in den richtigen Ordner verschoben werden)
JHtml::_('bootstrap.framework');
// Laden der Skriptdateien fÃŒr Easing, Scrolling und Popups
$this->addScript('https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js', 'text/javascript', array('defer'=>'defer'));
$this->addScript($tplpath. '/vendor/scrollreveal/scrollreveal.min.js', 'text/javascript', array('defer'=>'defer'));
$this->addScript($tplpath. '/vendor/magnific-popup/jquery.magnific-popup.min.js', 'text/javascript', array('defer'=>'defer'));
// Laden der Skriptdateien fÃŒr das Template
$this->addScript($tplpath . '/js/creative.min.js', 'text/javascript', array('defer'=>'defer'));
// Custom Tags fÃŒr den IE9 definieren
$stylelink = '<!--[if lte IE 9]>' . "\n";
$stylelink .= '<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>' . "\n";
$stylelink .= ' <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>' . "\n";
$stylelink .= '<![endif]-->' . "\n";
// Custom Tags fÃŒr den IE9 hinzufÃŒgen
$this->addCustomTag($stylelink);
// MetaTag fÃŒr den Viewport definieren
$this->setMetaData('viewport', 'width=device-width, initial-scale=1');
?>
<!DOCTYPE html>
<html xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>">
<head>
<!-- Hier werden die Joomla! Headerdaten geladen -->
<jdoc:include type="head"/>
</head>
<body id="page-top">
<nav id="mainNav" class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span> Menu <i class="fa fa-bars"></i>
</button>
<a class="navbar-brand page-scroll" href="#page-top">
<!-- Abfrage der Parameter fÃŒr das Logo -->
<?php if ($this->params->get('logotype', 'text') == 'image')
{ ?>
<!-- Ausgabe des Logo-Bildes -->
<img src="<?php echo $this->params->get('logoimg', ''); ?>"
alt="<?php echo $this->params->get('logoimgalt', ''); ?>" width="200px" height="20px"/>
<?php }
else
{ ?>
<!-- Ausgabe des Logo-Textes -->
<?php echo $this->params->get('logotext', ''); ?>
<?php } ?>
</a>
</div>
<!-- Hier laden wir nun die Position mainnav mit dem Stil navigation -->
<jdoc:include type="modules" name="mainnav" style="navigation"/>
</div>
<!-- /.container-fluid -->
</nav>
<!-- Hier laden wir die Position header mit dem Stil header-->
<jdoc:include type="modules" name="header" style="header"/>
<!-- Hier laden wir die Position teaser mit dem Stil primary -->
<jdoc:include type="modules" name="teaser" style="primary"/>
<!-- Hier laden wir die Position top mit dem Stil primary -->
<jdoc:include type="modules" name="top" style="no"/>
<!-- Hier folgt der Inhaltsbereich -->
<?php if ($this->params->get('mainoutput', 'yes') == 'yes') : ?>
<main class="container" id="maincontent">
<div class="row">
<?php
/* Variable fÃŒr SpaltenprÃŒfung */
$rechtespalte = ($this->countModules('right'));
/* Wenn die rechte Spalte existiert, dann wird der Inhalt nicht verschoben */
if ($rechtespalte == '1'):
$inhaltsklasse = 'class="col-lg-8"';
/* Wenn die rechte Spalte nicht existiert, dann wird der Inhalt um 2 Spalten verschoben */
else :
$inhaltsklasse = 'class="col-lg-8 col-lg-offset-2"';
endif;
?>
<div <?php echo $inhaltsklasse; ?>>
<!� Hier wird die Systemnachricht ausgegeben �>
<jdoc:include type="message"/>
<!� Navigationspfad�>
<jdoc:include type="modules" name="breadcrumbs" style="none"/>
<!� Bereich fÌr die Komponentenausgabe �>
<jdoc:include type="component"/>
</div>
<?php if ($rechtespalte) : ?>
<div class="col-lg-4">
<jdoc:include type="modules" name="right" style="xhtml"/>
</div>
<?php endif; ?>
</div>
</main>
<?php endif; ?>
<!-- Hier laden wir die Position portfolio mit dem Stil none -->
<jdoc:include type="modules" name="portfolio" style="none"/>
<!-- Hier laden wir die Position action mit dem Stil dark -->
<jdoc:include type="modules" name="action" style="dark"/>
<!-- Hier prÌfen wir ob ein Modul auf der Position contact veröffentlicht wurde -->
<?php if ($this->countModules('contact')) : ?>
<section id="contact">
<div class="container">
<div class="row">
<!-- Hier laden wir die Position contact mit dem Stil none -->
<jdoc:include type="modules" name="contact" style="none"/>
</div>
</div>
</section>
<?php endif; ?>
</body>
</html>
12.51 Darstellung des Hauptinhalts einer vereinfachten component.php-Datei
16.1 – Ausschnitt aus der Datei /components/com_users/views/profile/tmpl/default_custom.php – hier werden die Feld-Namen der Variable $customFields zugeordnet
//Abfrage des Parameters id aus dem $_REQUEST Array
$input = JFactory::getApplication()->input;
$id = $input->get('id','0','INT');
//Abfrage des Parameters name aus dem $_POST Array
$input = JFactory::getApplication()->input;
$name = $input->post->get('name','','STRING');
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.7.0" method="upgrade">
<name>COM_JOBS</name>
<creationDate>March 2017</creationDate>
<author>David Jardin</author>
<authorEmail>d.jardin@djumla.de</authorEmail>
<authorUrl>http://www.djumla.de</authorUrl>
<copyright>Copyright 2017 David Jardin</copyright>
<license>GPL v2 or later</license>
<version>0.0.1</version>
<description>COM_JOBS_DESCRIPTION</description>
<!-- PHP-Skript wird ausgeführt bei Installation, Deinstallation und Update -->
<scriptfile>script.php</scriptfile>
<!-- SQL-Skript für die Installation -->
<install>
<sql>
<file driver="mysql" charset="utf8">sql/install.mysql.utf8.sql</file>
</sql>
</install>
<!-- SQL-Skript für die Deinstallation -->
<uninstall>
<sql>
<file driver="mysql" charset="utf8">sql/uninstall.mysql.utf8.sql</file>
</sql>
</uninstall>
<!-- SQL-Skripte für die Aktualisierung der Erweiterung -->
<update>
<schemas>
<schemapath type="mysql">sql/updates/mysql</schemapath>
</schemas>
</update>
<!-- Kopieranweisungen für das Frontend -->
<files folder="site">
<filename>jobs.php</filename>
<filename>controller.php</filename>
<folder>views</folder>
<folder>models</folder>
<folder>language</folder>
</files>
<!-- Kopieranweisungen für das Media-Verzeichnis -->
<media destination="com_jobs" folder="media">
<filename>index.html</filename>
<folder>images</folder>
</media>
<languages folder="site">
<language tag="de-DE">language/de-DE/de-DE.com_jobs.ini</language>
</languages>
<administration>
<!-- Administrations Menü -->
<menu img="../media/com_jobs/images/jobs-16x16.png">COM_JOBS</menu>
<!-- Kopieranweisungen für das Backend -->
<files folder="admin">
<filename>config.xml</filename>
<filename>access.xml</filename>
<filename>jobs.php</filename>
<filename>controller.php</filename>
<folder>sql</folder>
<folder>tables</folder>
<folder>models</folder>
<folder>views</folder>
<folder>controllers</folder>
<folder>helpers</folder>
</files>
<languages folder="admin">
<language tag="de-DE">language/de-DE/de-DE.com_jobs.ini</language>
<language tag="de-DE">language/de-DE/de-DE.com_jobs.sys.ini</language>
</languages>
</administration>
<!-- UPDATESERVER DEFINITION -->
<updateservers>
<server type="extension" priority="1" name="Jobs Update Site">http://yourdomain.com/update/jobs-update.xml</server>
</updateservers>
</extension>
17.9 script.php
<?php
defined('_JEXEC') or die;
/**
* Installation class to perform additional changes during install/uninstall/update
*
* @since 0.0.1
*/
class Com_JobsInstallerScript
{
/**
* Function to perform changes during install
*
* @param JInstallerAdapterComponent $parent The class calling this method
*
* @return void
*/
public function install($parent)
{
// Initialize a new category
/** @type JTableCategory $category */
$category = JTable::getInstance('Category');
// Check if the Uncategorised category exists before adding it
if (!$category->load(array('extension' => 'com_jobs', 'title' => 'Uncategorised')))
{
$category->extension = 'com_jobs';
$category->title = 'Uncategorised';
$category->description = '';
$category->published = 1;
$category->access = 1;
$category->params = '{"category_layout":"","image":""}';
$category->metadata = '{"author":"","robots":""}';
$category->metadesc = '';
$category->metakey = '';
$category->language = '*';
$category->checked_out_time = JFactory::getDbo()->getNullDate();
$category->version = 1;
$category->hits = 0;
$category->modified_user_id = 0;
$category->checked_out = 0;
// Set the location in the tree
$category->setLocation(1, 'last-child');
// Check to make sure our data is valid
if (!$category->check())
{
JFactory::getApplication()->enqueueMessage($category->getError());
return;
}
// Now store the category
if (!$category->store(true))
{
JFactory::getApplication()->enqueueMessage($category->getError());
return;
}
// Build the path for our category
$category->rebuildPath($category->id);
}
}
/**
* method to uninstall the component
*
* @param JInstallerAdapterComponent $parent The class calling this method
*
* @return void
*/
public function uninstall($parent)
{
// $parent is the class calling this method
echo '<p>' . JText::_('COM_JOBS_UNINSTALL_TEXT') . '</p>';
}
/**
* method to update the component
*
* @param JInstallerAdapterComponent $parent The class calling this method
*
* @return void
*/
public function update($parent)
{
// $parent is the class calling this method
echo '<p>' . JText::_('COM_JOBS_UPDATE_TEXT') . '</p>';
}
/**
* method to run before an install/update/uninstall method
*
* @param string $type process type
* @param JInstallerAdapterComponent $parent The class calling this method
*
* @return void
*/
public function preflight($type, $parent)
{
// $parent is the class calling this method
// $type is the type of change (install, update or discover_install)
echo '<p>' . JText::_('COM_JOBS_PREFLIGHT_' . $type . '_TEXT') . '</p>';
}
/**
* method to run after an install/update/uninstall method
*
* @param string $type process type
* @param JInstallerAdapterComponent $parent The class calling this method
*
* @return void
*/
public function postflight($type, $parent)
{
// $parent is the class calling this method
// $type is the type of change (install, update or discover_install)
echo '<p>' . JText::_('COM_JOBS_POSTFLIGHT_' . $type . '_TEXT') . '</p>';
}
}
17.10 install.mysql.utf8.sql
DROP TABLE IF EXISTS `#__jobs`;
CREATE TABLE `#__jobs` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(25) NOT NULL,
`description` mediumtext NOT NULL,
`catid` int(11) NOT NULL DEFAULT '0',
`params` TEXT NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
17.11 uninstall.mysql.utf8.sql
DROP TABLE IF EXISTS `#__jobs`;
17.12 Backend-Dispatcher jobs.php
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// Access check.
if (!JFactory::getUser()->authorise('core.manage', 'com_jobs'))
{
new RuntimeException(JText::_('JERROR_ALERTNOAUTHOR'), 403);
}
// Require helper file
JLoader::register('JobsHelper', dirname(__FILE__) . '/helpers/jobs.php');
// Import joomla controller library
jimport('joomla.application.component.controller');
// Get an instance of the controller prefixed by Jobs
$controller = JControllerLegacy::getInstance('Jobs');
// Perform the Request task
$controller->execute(JFactory::getApplication()->input->get('task', '', 'CMD'));
// Redirect if set by the controller
$controller->redirect();
17.13 Backend-Controller controller.php
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
/**
* General Controller of Jobs component
*
* @since 0.0.1
*/
class JobsController extends JControllerLegacy
{
/**
* The generic display task
*
* @param bool $cachable is this view a cachabel one
* @param array $urlparams url parameters
*
* @return void
*/
public function display($cachable = false, $urlparams = array())
{
$input =& JFactory::getApplication()->input;
// Set default view if not set
$input->set('view', $input->get("view", "Jobs", "CMD"));
// Call parent behavior
parent::display($cachable, $urlparams);
}
}
17.14 Listen-Controller jobs.php
<?php
/**
* @package ComJobs
* @copyright 2017 David Jardin
* @license GNU GPLv2 <http://www.gnu.org/licenses/gpl.html>
* @link http://www.djumla.de
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
/**
* Jobs Controller
*
* @since 0.0.1
*/
class JobsControllerJobs extends JControllerAdmin
{
/**
* Description
*
* @param string $name model name
* @param string $prefix model prefix
*
* @return bool|JModelLegacy
*/
public function getModel($name = 'Job', $prefix = 'JobsModel')
{
$model = parent::getModel($name, $prefix, array('ignore_request' => true));
return $model;
}
}
17.15 Eintrags-Controller job.php
<?php
/**
* @package ComJobs
* @copyright 2017 David Jardin
* @license GNU GPLv2 <http://www.gnu.org/licenses/gpl.html>
* @link http://www.djumla.de
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
/**
* Job Controller
*
* @since 0.0.1
*/
class JobsControllerJob extends JControllerForm
{
}
17.16 Listen-Model jobs.php
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
/**
* JobsList Model
*
* @since 0.0.1
*/
class JobsModelJobs extends JModelList
{
/**
* Method to build an SQL query to load the list data.
*
* @return string An SQL query
*/
protected function getListQuery()
{
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
// Select some fields
$query->select('*');
// From the jobs table
$query->from('#__jobs');
// Filter by category.
$categoryId = $this->getState('filter.category_id');
if (is_numeric($categoryId))
{
$query->where('catid = ' . (int) $categoryId);
}
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering');
$orderDirn = $this->state->get('list.direction');
$query->order($db->escape($orderCol . ' ' . $orderDirn));
return $query;
}
/**
* Method to auto-populate the model state.
*
* @param string $ordering name if column that should be used for order
* @param string $direction ordering direction
*
* @return void
*
* @note Calling getState in this method will result in recursion.
*/
protected function populateState($ordering = null, $direction = null)
{
// Load the filter state.
$categoryId = $this->getUserStateFromRequest($this->context . '.filter.category_id', 'filter_category_id', '');
$this->setState('filter.category_id', $categoryId);
// List state information.
parent::populateState('title', 'asc');
}
}
17.17 Eintrags-Models job.php
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
/**
* Job Model
*
* @since 0.0.1
*/
class JobsModelJob extends JModelAdmin
{
/**
* Returns a reference to the a Table object, always creating it.
*
* @param string $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable A database table object
*/
public function getTable($type = 'Jobs', $prefix = 'JobsTable', $config = array())
{
return JTable::getInstance($type, $prefix, $config);
}
/**
* Method to get the record form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data (default case), false if not.
*
* @return mixed A JForm object on success, false on failure
*/
public function getForm($data = array(), $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_jobs.job', 'job', array('control' => 'jform', 'load_data' => $loadData));
if (empty($form))
{
return false;
}
return $form;
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data = JFactory::getApplication()->getUserState('com_jobs.edit.job.data', array());
if (empty($data))
{
$data = $this->getItem();
// Prime some default values.
if ($this->getState('job.id') == 0)
{
$app = JFactory::getApplication();
$data->set('catid', $app->input->get('catid', $app->getUserState('com_jobs.jobs.filter.category_id'), 'int'));
}
}
$this->preprocessData('com_jobs.job', $data);
return $data;
}
}
17.18 job.xml XML-Definition des Formulars für die Validierung mittels JForm
17.19 title.php Validierungsregel zur serverseitigen Validierung
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
/**
* Form Rule class for the Joomla Framework.
*
* @since 0.0.1
*/
class JFormRuleTitle extends JFormRule
{
/**
* The regular expression.
*
* @access protected
* @var string
* @since 1.6
*/
protected $regex = '^[^0-9]+$';
}
17.20 Table-Klasse für die Jobs-Tabelle
<?php
// No direct access
defined('_JEXEC') or die('Restricted access');
/**
* Jobs Table class
*
* @since 0.0.1
*/
class JobsTableJobs extends JTable
{
/**
* Ensure the params and metadata in json encoded in the bind method
*
* @var array
*/
protected $_jsonEncode = array('params');
/**
* Constructor
*
* @param JDatabaseDriver &$db connector object
*/
public function __construct(&$db)
{
parent::__construct('#__jobs', 'id', $db);
}
}
17.21 Listenansicht im Backend
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
/**
* Jobs View
*
* @since 1.0.0
*/
class JobsViewJobs extends JViewLegacy
{
protected $items;
protected $pagination;
protected $state;
/**
* Jobs view display method
*
* @param string $tpl templae name
*
* @return void
*/
public function display($tpl = null)
{
// Get data from the model
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
throw new RuntimeException(implode('<br />', $errors), 500);
}
// Set the toolbar
JobsHelper::addSubmenu('jobs');
$this->addToolBar();
$this->sidebar = JHtmlSidebar::render();
// Add CSS for icon
JFactory::getDocument()->addStyleDeclaration('.icon-jobs {background:url(../media/com_jobs/images/jobs-16x16.png)}');
// Display the template
parent::display($tpl);
}
/**
* Setting the toolbar
*
* @return void
*/
protected function addToolBar()
{
$state = $this->get('State');
$canDo = JHelperContent::getActions('com_jobs', 'category', $state->get('filter.category_id'));
$user = JFactory::getUser();
JToolBarHelper::title(JText::_('COM_JOBS_MANAGER_JOBS'), 'jobs');
if ($canDo->get('core.create'))
{
JToolBarHelper::addNew('job.add');
}
if ($canDo->get('core.edit'))
{
JToolBarHelper::editList('job.edit');
}
if ($canDo->get('core.delete'))
{
JToolBarHelper::deleteList('', 'jobs.delete');
}
if ($user->authorise('core.admin', 'com_jobs') || $user->authorise('core.options', 'com_jobs'))
{
JToolBarHelper::divider();
JToolBarHelper::preferences('com_jobs');
}
JHtmlSidebar::setAction('index.php?option=com_jobs&view=jobs');
JHtmlSidebar::addFilter(
JText::_('JOPTION_SELECT_CATEGORY'),
'filter_category_id',
JHtml::_('select.options', JHtml::_('category.options', 'com_jobs'), 'value', 'text', $state->get('filter.category_id'))
);
}
}
17.22 Backend-Template für die Listenansicht default.php
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted Access');
$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));
?>
<tr>
<th width="1%" class="hidden-phone center">
<?php echo JHtml::_('grid.checkall'); ?>
</th>
<th class="title">
<?php echo JHtml::_('grid.sort', 'JGLOBAL_TITLE', 'title', $listDirn, $listOrder); ?>
</th>
<th width="1%" class="nowrap center hidden-phone">
<?php echo JHtml::_('grid.sort', 'JGRID_HEADING_ID', 'id', $listDirn, $listOrder); ?>
</th>
</tr>
17.24 Listenfooter default_foot.php
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted Access');
?>
<tr>
<td colspan="3"><?php echo $this->pagination->getListFooter(); ?></td>
</tr>
<?php
// No direct access to this file
defined('_JEXEC') or die;
/**
* Class JobsHelper
*
* @since 0.0.1
*/
abstract class JobsHelper
{
/**
* Configure the Linkbar.
*
* @param string $vName The name of the active view.
*
* @return void
*/
public static function addSubmenu($vName = 'jobs')
{
JHtmlSidebar::addEntry(
JText::_('COM_JOBS_SUBMENU_MESSAGES'),
'index.php?option=com_jobs',
$vName == 'jobs'
);
JHtmlSidebar::addEntry(
JText::_('COM_JOBS_SUBMENU_CATEGORIES'),
'index.php?option=com_categories&extension=com_jobs',
$vName == 'categories'
);
}
}
17.31 System-Sprachdatei
COM_JOBS="Jobsverwaltung"
COM_JOBS_DESCRIPTION="Dies ist die Jobsverwaltung"
COM_JOBS_JOB_VIEW_DEFAULT_DESC="Diese Ansicht zeigt ein Jobangebot an"
COM_JOBS_JOB_VIEW_DEFAULT_TITLE="Jobangebot"
COM_JOBS_INSTALL_TEXT="Jobs - Installations Skript"
COM_JOBS_MENU="Jobsverwaltung"
COM_JOBS_POSTFLIGHT_DISCOVER_INSTALL_TEXT="Jobs - Nach-Installationsprüfung bei Discover Installation"
COM_JOBS_POSTFLIGHT_INSTALL_TEXT="Jobs - Nach-Installationsprüfung bei Installation"
COM_JOBS_POSTFLIGHT_UNINSTALL_TEXT="Jobs - Nach-Installationsprüfung bei Deinstallation"
COM_JOBS_POSTFLIGHT_UPDATE_TEXT="Jobs - Nach-Installationsprüfung bei Update"
COM_JOBS_PREFLIGHT_DISCOVER_INSTALL_TEXT="Jobs - Vor-Installationsprüfung bei Discover Installation"
COM_JOBS_PREFLIGHT_INSTALL_TEXT="Jobs - Vor-Installationsprüfung bei Installation"
COM_JOBS_PREFLIGHT_UNINSTALL_TEXT="Jobs - Vor-Installationsprüfung bei Deinstallation"
COM_JOBS_PREFLIGHT_UPDATE_TEXT="Jobs - Vor-Installationsprüfung bei Update"
COM_JOBS_UNINSTALL_TEXT="Jobs - Deinstallations Skript"
COM_JOBS_UPDATE_TEXT="Jobs - Update Skript"
17.32 Komponenten-Sprachdatei im Backend
COM_JOBS="Jobverwaltung"
COM_JOBS_ADMINISTRATION="Jobs - Administration"
COM_JOBS_ADMINISTRATION_CATEGORIES="Jobs - Kategorien"
COM_JOBS_JOB_CREATING="Job - Hinzufügen"
COM_JOBS_JOB_DETAILS="Details"
COM_JOBS_JOB_PARAMS="Parameter"
COM_JOBS_JOB_EDITING="Job - Bearbeiten"
COM_JOBS_JOB_ERROR_UNACCEPTABLE="Bitte prüfen Sie ihre Eingaben"
COM_JOBS_JOB_FIELD_CATID_DESC="Die Kategorie des Jobangebots"
COM_JOBS_JOB_FIELD_CATID_LABEL="Kategorie"
COM_JOBS_JOB_FIELD_TITLE_DESC="Titel des Jobangebot"
COM_JOBS_JOB_FIELD_TITLE_LABEL="Titel"
COM_JOBS_JOB_FIELD_DESCRIPTION_DESC="Beschreibung des Jobangebot"
COM_JOBS_JOB_FIELD_DESCRIPTION_LABEL="Beschreibung"
COM_JOBS_JOB_FIELD_SHOW_TITLE_LABEL="Zeige Titel"
COM_JOBS_JOB_FIELD_SHOW_TITLE_DESC="Zeigt den Titel des jeweiligen Jobangebots."
COM_JOBS_JOB_FIELD_SHOW_CATEGORY_LABEL="Zeige Kategorie"
COM_JOBS_JOB_FIELD_SHOW_CATEGORY_DESC="Zeigt die Kategorie des jeweiligen Jobangebots."
COM_JOBS_JOB_HEADING_TITLE="Titel"
COM_JOBS_JOB_HEADING_ID="ID"
COM_JOBS_MANAGER_JOB_EDIT="Jobs Manager: Bearbeite Job"
COM_JOBS_MANAGER_JOB_NEW="Jobs Manager: Neuen Job"
COM_JOBS_MANAGER_JOBS="Jobs Manager"
COM_JOBS_N_ITEMS_DELETED_1="Einen Job gelöscht"
COM_JOBS_N_ITEMS_DELETED_MORE="%d Jobs gelöscht"
COM_JOBS_SUBMENU_MESSAGES="Jobs"
COM_JOBS_SUBMENU_CATEGORIES="Kategorien"
COM_JOBS_CONFIGURATION="Jobs Konfiguration"
COM_JOBS_CONFIG_TITLE_SETTINGS_LABEL="Job Einstellungen"
COM_JOBS_CONFIG_TITLE_SETTINGS_DESC="Einstellungen, welche standardmäßig auf alle Jobs angewendet werden"
17.33 Frontend-Dispatcher
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// Get an instance of the controller prefixed by HelloWorld
$controller = JControllerLegacy::getInstance('Jobs');
// Perform the Request task
$controller->execute(JFactory::getApplication()->input->get('task', '', 'CMD'));
// Redirect if set by the controller
$controller->redirect();
17.34 Frontend-Controller
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
/**
* Jobs Component Controller
*
* @since 0.0.1
*/
class JobsController extends JControllerLegacy
{
}
17.35 Frontend-Model
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
/**
* Job Model
*
* @since 1.0.0
*/
class JobsModelJob extends JModelItem
{
protected $item;
/**
* populate internal state
*
* @return void
*/
protected function populateState()
{
$app = JFactory::getApplication();
// Get the job id
$id = $app->input->get('id', '', 'INT');
$this->setState('job.id', $id);
// Load the parameters.
$params = $app->getParams();
$this->setState('params', $params);
parent::populateState();
}
/**
* Returns a reference to the a Table object, always creating it.
*
* @param string $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for table. Optional.
*
* @return JTable A database object
*/
public function getTable($type = 'Jobs', $prefix = 'JobsTable', $config = array())
{
return JTable::getInstance($type, $prefix, $config);
}
/**
* Get the job
*
* @return object The job to be displayed to the user
*/
public function getItem()
{
if (!isset($this->item))
{
$db = JFactory::getDbo();
$id = $this->getState('job.id');
$query = $db->getQuery(true)->from('#__jobs as j')
->leftJoin('#__categories as c ON j.catid=c.id')
->select('j.title AS title, j.params, j.description, c.title as category')
->where('j.id=' . (int) $id);
$db->setQuery($query);
$this->item = $db->loadObject();
// Load the JSON encoded params
$params = new \Joomla\Registry\Registry;
$params->loadString($this->item->params, 'JSON');
$this->item->params = $params;
// Merge global params with item params
$params = clone $this->getState('params');
$params->merge($this->item->params);
$this->item->params = $params;
}
return $this->item;
}
}
17.36 Frontend-View
<?php
/**
* @package ComJobs
* @copyright 2017 David Jardin
* @license GNU GPLv2 <http://www.gnu.org/licenses/gpl.html>
* @link http://www.djumla.de
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// Import Joomla view library
jimport('joomla.application.component.view');
/**
* HTML View class for the Jobs Component
*
* @since 0.0.1
*/
class JobsViewJob extends JViewLegacy
{
/**
* Display job item
*
* @param string $tpl template name
*
* @return void
*/
public function display($tpl = null)
{
// Assign data to the view
$this->item = $this->get('Item');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
throw new RuntimeException(implode('<br />', $errors), 500);
}
// Display the view
parent::display($tpl);
}
}
17.37 Frontend-Template
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
?>
<?php if($this->item->params->get('show_title')): ?>
<h1>
<?php echo $this->item->title.(($this->item->params->get('show_category')) ? (' ('.$this->item->category.')') : ''); ?>
</h1>
<?php endif; ?>
<?php echo $this->item->description ?>
17.39 Selbstdefiniertes Formularfeld für die Auswahl des Jobangebots
<?php
// No direct access to this file
defined('_JEXEC') or die;
JFormHelper::loadFieldClass('list');
/**
* Job Form Field class for the Jobs component
*
* @since 0.0.1
*/
class JFormFieldJob extends JFormFieldList
{
/**
* The field type.
*
* @var string
*/
protected $type = 'Job';
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function getOptions()
{
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select('#__jobs.id as id, #__jobs.title as title, #__categories.title as category,catid');
$query->from('#__jobs');
$query->leftJoin('#__categories on catid=#__categories.id');
$db->setQuery((string) $query);
$jobs = $db->loadObjectList();
$options = array();
if ($jobs)
{
foreach ($jobs as $job)
{
$options[] = JHtml::_('select.option', $job->id, $job->title . ($job->catid ? ' (' . $job->category . ')' : ''));
}
}
$options = array_merge(parent::getOptions(), $options);
return $options;
}
}
17.40 Frontend-Sprachdatei
COM_JOBS="Jobverwaltung"
COM_JOBS_DESCRIPTION="Dies ist die Jobverwaltung"
17.41 datedisplay.xml
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.7" type="plugin" group="content">
<name>Date-Display</name>
<author>David Jardin</author>
<creationDate>March 2017</creationDate>
<copyright>Copyright (C) 2017 David Jardin. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>info@djumla.de</authorEmail>
<authorUrl>www.djumla.de</authorUrl>
<version>1.0.0</version>
<description>Zeigt das aktuelle Abrufdatum des Beitrags an</description>
<files>
<filename plugin="datedisplay">datedisplay.php</filename>
</files>
</extension>
17.42 datedisplay.php
<?php
// No direct access.
defined('_JEXEC') or die;
class plgContentDatedisplay extends JPlugin
{
public function onContentPrepare($context, &$row, &$params, $page = 0)
{
$canProceed = $context == 'com_content.article';
if (!$canProceed) {
return;
}
$date = JFactory::getDate();
$row->text = "<p>Sie betrachten diesen Inhalt am "
. $date->format("d.m.y") . "</p>"
. $row->text;
}
}
17.43 Beispiel-App für die CLI-Schnittstelle
<?php
// Initialize Joomla framework
const _JEXEC = 1;
// Load system defines
if (file_exists(dirname(__DIR__) . '/defines.php'))
{
require_once dirname(__DIR__) . '/defines.php';
}
if (!defined('_JDEFINES'))
{
define('JPATH_BASE', dirname(__DIR__));
require_once JPATH_BASE . '/includes/defines.php';
}
// Get the framework.
require_once JPATH_LIBRARIES . '/import.legacy.php';
// Bootstrap the CMS libraries.
require_once JPATH_LIBRARIES . '/cms.php';
class SetPassword extends JApplicationCli
{
public function __construct()
{
parent::__construct();
$this->loadConfiguration($this->fetchConfigurationData("../configuration.php"));
}
//Set Password
public function set_password( $username, $password )
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select("id")->from("#__users")->where("username = " . $db->quote($username));
$db->setQuery($query);
$userid = $db->loadResult();
$user = JUser::getInstance($userid);
if($user->id)
{
$password = JUserHelper::hashPassword($password);
$query = $db->getQuery(true);
$query->update("#__users")->set("password = ".$db->quote($password))->where("id = ".$user->id);
$db->setQuery($query)->query();
return true;
}
else
{
return false;
}
}
public function execute()
{
$this->out( 'What is your username?' );
$username = $this->in( );
$this->out( 'Enter your new password?' );
$password = $this->in( );
if($this->set_password( $username, $password ))
{
$this->out( "Password successfully changed" );
}
else
{
$this->out( "Invalid Username" );
}
}
}
JCli::getInstance('SetPassword')->execute();
Kapitel 19
19.1 pfadfinder.php
<?php echo dirname(__FILE__); ?>
19.2 Relevante Einträge in der configuration.php
<?php
class JConfig {
[...]
public $host = 'DATENBANKSERVER';
public $user = 'DATENBANKBENUTZER';
public $password = 'DATENBANKPASSWORT';
public $db = 'DATENBANKNAME';
[...]
public $log_path = 'AUSGABE VON PFADFINDER/logs';
public $tmp_path = 'AUSGABE VON PFADFINDER/tmp';