JSztuczki
-
Upload
tomasz-dziuda -
Category
Technology
-
view
581 -
download
0
Transcript of JSztuczki
https://mydomain.com/index.php?tmpl=special
special.phpw katalogu szablonu
Uwaga! Niektóre rozszerzenia, takie jakAdmin Tools mogą blokować niestandardowewywołania parametru tmpl. Należy wtedy takąwartość dodać do listy dozwolonych wywołań.
Podział na linie i wyróżnianie słów
Lorem[br]ipsum[br]dolor
Lorem __ipsum__ dolor
Lorem **ipsum** dolor
$title = str_replace('[br]', '<br />', $module->title);
$title = preg_replace('/__(.*?)__/i', ’<em>${1}</em>', $title);
Podział na linie i wyróżnianie słów
$app = JFactory::getApplication();$path = JPATH_THEMES . '/' . $this->template;$less = new JLess;$less->setFormatter(new JLessFormatterJoomla);
$app = JFactory::getApplication();$path = JPATH_THEMES . '/' . $this->template;$less = new JLess;$less->setFormatter(new JLessFormatterJoomla);
try {$less->compileFile($path.'/main.less', $path.'/main.css');
}
$app = JFactory::getApplication();$path = JPATH_THEMES . '/' . $this->template;$less = new JLess;$less->setFormatter(new JLessFormatterJoomla);
try {$less->compileFile($path.'/main.less', $path.'/main.css');
} catch (Exception $e) {$app->enqueueMessage($e->getMessage(), 'error');
}
<?php $msgList = $displayData['msgList']; ?><div id="system-message-container">
<?php if (is_array($msgList) && !empty($msgList)) : ?><div id="system-message">
<?php foreach ($msgList as $type => $msgs) : ?><div class="alert alert-<?php echo $type; ?>">
<a class="close" data-dismiss="alert">×</a><?php if (!empty($msgs)) : ?><h4 class="alert-heading"><?php echo JText::_($type); ?></h4>
<div><?php foreach ($msgs as $msg) : ?><p class="alert-message"><?php echo $msg; ?></p><?php endforeach; ?>
</div><?php endif; ?>
</div><?php endforeach; ?>
</div><?php endif; ?>
</div>
Plik: layouts/joomla/system/message.php
$layout = new JLayoutFile('joomla.content.tags', null, array('debug' => true)
);
echo $layout->render(null);
$layout = new JLayoutFile('joomla.content.tags', null, array('debug' => true)
);
echo $layout->render(null);
Layout: joomla.content.tagsInclude Paths: Array (
[0] => /www/test/templates/gk_technews/html/layouts/com_content[1] => /www/test/components/com_content/layouts [2] => /www/test/templates/gk_technews/html/layouts [3] => /www/test/layouts
) Searching layout for: joomla/content/tags.phpFound layout: /www/test/layouts/joomla/content/tags.php
$layout = new JLayoutFile('joomla.content.tags', JPATH_SITE . '/components/com_custom/layouts', array('debug' => true)
);
$layout = new JLayoutFile('joomla.content.tags', JPATH_SITE . '/components/com_custom/layouts', array('debug' => true)
);
Layout: joomla.content.tagsInclude Paths: Array (
[0] => /www/test/components/com_custom/layouts[1] => /www/test/templates/gk_technews/html/layouts/com_content[2] => /www/test/components/com_content/layouts [3] => /www/test/templates/gk_technews/html/layouts [4] => /www/test/jqi/layouts
) Searching layout for: joomla/content/tags.phpFound layout: /www/test/layouts/joomla/content/tags.php
$layout = new JLayoutFile('joomla.content.tags', null,array(
'debug' => true,'component' => ‘com_tags','client' => 1,'suffixes' => array('rtl', 'j34')
));
$layout = new JLayoutFile('joomla.content.tags', null,array(
'debug' => true,'component' => ‘com_tags','client' => 1,'suffixes' => array('rtl', 'j34')
));
Layout: joomla.content.tagsInclude Paths: Array (
[0] => /www/test/templates/gk_technews/html/layouts/com_tags[1] => /www/test/administrator/components/com_tags/layouts[2] => /www/test/templates/gk_technews/html/layouts [3] => /www/test/layouts
) Suffixes: Array (
[0] => rtl[1] => j34
)Searching layout for: joomla/content/tags.rtl.phpSearching layout for: joomla/content/tags.j34.php Searching layout for: joomla/content/tags.phpFound layout: /www/test/layouts/joomla/content/tags.php
class plgSystemPlg_Custom_Params extends JPlugin {var $_pluginPath;
function __construct($subject) {parent::__construct($subject);$this->_plugin = JPluginHelper::getPlugin('system', 'plg_custom_params');$this->_pluginPath = JPATH_PLUGINS."/system/plg_custom_params/";
}
}
class plgSystemPlg_Custom_Params extends JPlugin {var $_pluginPath;
function __construct($subject) {parent::__construct($subject);$this->_plugin = JPluginHelper::getPlugin('system', 'plg_custom_params');$this->_pluginPath = JPATH_PLUGINS."/system/plg_custom_params/";
}
function onContentPrepareForm($form, $data) {if ($form->getName()=='com_content.article') {
JForm::addFormPath($this->_pluginPath);$form->loadFile('parameters', false);return true;
}}
}
class plgSystemPlg_Custom_Params extends JPlugin {var $_pluginPath;
function __construct($subject) {parent::__construct($subject);$this->_plugin = JPluginHelper::getPlugin('system', 'plg_custom_params');$this->_pluginPath = JPATH_PLUGINS."/system/plg_custom_params/";
}
function onContentPrepareForm($form, $data) {if ($form->getName()=='com_content.article') {
JForm::addFormPath($this->_pluginPath);$form->loadFile('parameters', false);return true;
}}
}
<?xml version="1.0" encoding="utf-8"?><form>
<fields name="attribs"><fieldset name="basic" label="Test">
<field name="custom_field1" type="text" default="" label="Field 1" /><field name="custom_field2" type="text" default="" label="Field 2" />
</fieldset></fields>
</form>
<?xml version="1.0" encoding="utf-8"?><form>
<fields name="attribs"><fieldset name=“test" label="Test">
<field name="custom_field1" type="text" default="" label="Field 1" /><field name="custom_field2" type="text" default="" label="Field 2" />
</fieldset></fields>
</form>
$author_obj = JFactory::getUser($this->item->created_by);$author_email = $author_obj->email;
$avatar_hash = md5(strtolower(trim($author_email)));$avatar_size = 120;
$author_obj = JFactory::getUser($this->item->created_by);$author_email = $author_obj->email;
$avatar_hash = md5(strtolower(trim($author_email)));$avatar_size = 120;
$avatar_url = ‘//www.gravatar.com/avatar/’.$avatar_hash .‘.jpg’;$avatar_url .= ‘?s=‘ . $avatar_size;
public function onAfterRoute() {$app = JFactory::getApplication();
if ($app instanceof JApplicationSite) {$jinput = $app->input;$option = $jinput->getCmd('option', '');$view = $jinput->getCmd('view', '');$params = new JRegistry();$params->def('templateColor', '#f00');$params->def('templateBackgroundColor', '#000');
if($option === 'com_content' && $view === 'article’) {
$app->setTemplate('protostar', $params);}
}}
public function onAfterRoute() {$app = JFactory::getApplication();
if ($app instanceof JApplicationSite) {$jinput = $app->input;$option = $jinput->getCmd('option', '');$view = $jinput->getCmd('view', '');$params = new JRegistry();$params->def('templateColor', '#f00');$params->def('templateBackgroundColor', '#000');
if($option === 'com_content' && $view === 'article’) {
$app->setTemplate('protostar', $params);}
}}
public function onAfterRoute() {$app = JFactory::getApplication();
if ($app instanceof JApplicationSite) {$jinput = $app->input;$option = $jinput->getCmd('option', '');$view = $jinput->getCmd('view', '');$params = new JRegistry();$params->def('templateColor', '#f00');$params->def('templateBackgroundColor', '#000');
if($option === 'com_content' && $view === 'article’) {$app->setTemplate('protostar', $params);
}}
}
public function onAfterRoute() {$app = JFactory::getApplication();
if ($app instanceof JApplicationSite) {$jinput = $app->input;$option = $jinput->getCmd('option', '');$view = $jinput->getCmd('view', '');$params = new JRegistry();$params->def('templateColor', '#f00');$params->def('templateBackgroundColor', '#000');
if($option === 'com_content' && $view === 'article’) {$app->setTemplate('protostar', $params);
}}
}
$dispatcher = JEventDispatcher::getInstance();
$dispatcher->register('onAfterRender', 'CustomParser');
$dispatcher = JEventDispatcher::getInstance();
$dispatcher->register('onAfterRender', 'CustomParser');
function CustomParser(){$body = JResponse::getBody();
JResponse::setBody($body);}
$dispatcher = JEventDispatcher::getInstance();
$dispatcher->register('onAfterRender', 'CustomParser');
function CustomParser(){$body = JResponse::getBody();$body = str_replace('ABC', 'XYZ', $body);JResponse::setBody($body);
}
$img = new JImage(__DIR__ . '/images/logo.png');
$img->resize(320, 320, false, JImage::SCALE_FILL);
$img->crop(160, 160, 80, 80, false);
$img = new JImage(__DIR__ . '/images/logo.png');
$img->resize(320, 320, false, JImage::SCALE_FILL);
$img->crop(160, 160, 80, 80, false);
$img->rotate(45, 0x000000, false);
$img = new JImage(__DIR__ . '/images/logo.png');
$img->resize(320, 320, false, JImage::SCALE_FILL);
$img->crop(160, 160, 80, 80, false);
$img->rotate(45, 0x000000, false);
$img->filter('negate');
$img = new JImage(__DIR__ . '/images/logo.png');
$img->resize(320, 320, false, JImage::SCALE_FILL);
$img->crop(160, 160, 80, 80, false);
$img->rotate(45, 0x000000, false);
$img->filter('negate');
$img->toFile(__DIR__ . '/images/new.jpg', IMAGETYPE_JPEG);
Warto sprawdzić czy sesja nie wygasła
$config = \JFactory::getConfig(); $session_lifetime = $config->get('lifetime’);
function onUserAuthenticate($credentials, $options, &$response) {
// kod obsługujący autoryzację
return $response;}
$user = JUser::getInstance($result->id);
$response->email = $user->email; $response->username = $user->username; $response->fullname = $user->name;
$user = JUser::getInstance($result->id);
$response->email = $user->email; $response->username = $user->username; $response->fullname = $user->name;
if(JFactory::getApplication()->isAdmin()) { $response->language = $user->getParam('admin_language');
} else { $response->language = $user->getParam('language');
}
// Poprawne zalogowanie$response->status = JAuthentication::STATUS_SUCCESS;
// Błędne zalogowanie$response->status = JAuthenticaton::STATUS_FAILURE;