Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Third batch of module tmpl codestyle #17855

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 46 additions & 80 deletions modules/mod_menu/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,83 +19,49 @@
// The menu class is deprecated. Use nav instead
?>
<ul class="nav menu<?php echo $class_sfx; ?>"<?php echo $id; ?>>
<?php foreach ($list as $i => &$item)
{
$class = 'item-' . $item->id;

if ($item->id == $default_id)
{
$class .= ' default';
}

if ($item->id == $active_id || ($item->type === 'alias' && $item->params->get('aliasoptions') == $active_id))
{
$class .= ' current';
}

if (in_array($item->id, $path))
{
$class .= ' active';
}
elseif ($item->type === 'alias')
{
$aliasToId = $item->params->get('aliasoptions');

if (count($path) > 0 && $aliasToId == $path[count($path) - 1])
{
$class .= ' active';
}
elseif (in_array($aliasToId, $path))
{
$class .= ' alias-parent-active';
}
}

if ($item->type === 'separator')
{
$class .= ' divider';
}

if ($item->deeper)
{
$class .= ' deeper';
}

if ($item->parent)
{
$class .= ' parent';
}

echo '<li class="' . $class . '">';

switch ($item->type) :
case 'separator':
case 'component':
case 'heading':
case 'url':
require JModuleHelper::getLayoutPath('mod_menu', 'default_' . $item->type);
break;

default:
require JModuleHelper::getLayoutPath('mod_menu', 'default_url');
break;
endswitch;

// The next item is deeper.
if ($item->deeper)
{
echo '<ul class="nav-child unstyled small">';
}
// The next item is shallower.
elseif ($item->shallower)
{
echo '</li>';
echo str_repeat('</ul></li>', $item->level_diff);
}
// The next item is on the same level.
else
{
echo '</li>';
}
}
?></ul>
<?php foreach ($list as $i => &$item) : ?>
<?php $class = 'item-' . $item->id; ?>
<?php if ($item->id == $default_id) : ?>
<?php $class .= ' default'; ?>
<?php endif; ?>
<?php if ($item->id == $active_id || ($item->type === 'alias' && $item->params->get('aliasoptions') == $active_id)) : ?>
<?php $class .= ' current'; ?>
<?php endif; ?>
<?php if (in_array($item->id, $path)) : ?>
<?php $class .= ' active'; ?>
<?php elseif ($item->type === 'alias') : ?>
<?php $aliasToId = $item->params->get('aliasoptions'); ?>
<?php if (count($path) > 0 && $aliasToId == $path[count($path) - 1]) : ?>
<?php $class .= ' active'; ?>
<?php elseif (in_array($aliasToId, $path)) : ?>
<?php $class .= ' alias-parent-active'; ?>
<?php endif; ?>
<?php endif; ?>
<?php if ($item->type === 'separator') : ?>
<?php $class .= ' divider'; ?>
<?php endif; ?>
<?php if ($item->deeper) : ?>
<?php $class .= ' deeper'; ?>
<?php endif; ?>
<?php if ($item->parent) : ?>
<?php $class .= ' parent'; ?>
<?php endif; ?>
<li class=" <?php echo $class; ?>">
<?php if (in_array($item->type, array('separator', 'component', 'heading', 'url'))) : ?>
<?php require JModuleHelper::getLayoutPath('mod_menu', 'default_' . $item->type); ?>
<?php else : ?>
<?php require JModuleHelper::getLayoutPath('mod_menu', 'default_url'); ?>
<?php endif; ?>
<?php // The next item is deeper. ?>
<?php if ($item->deeper) : ?>
<?php echo '<ul class="nav-child unstyled small">'; ?>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use HTML only

<?php elseif ($item->shallower) : ?>
<?php // The next item is shallower. ?>
<?php echo '</li>'; ?>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use HTML only

<?php echo str_repeat('</ul></li>', $item->level_diff); ?>
<?php else : ?>
<?php // The next item is on the same level. ?>
<?php echo '</li>'; ?>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use HTML only

<?php endif; ?>
<?php endforeach; ?>
</ul>
4 changes: 3 additions & 1 deletion modules/mod_menu/tmpl/default_heading.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@
}

?>
<span class="nav-header <?php echo $anchor_css; ?>"<?php echo $title; ?>><?php echo $linktype; ?></span>
<span class="nav-header <?php echo $anchor_css; ?>"<?php echo $title; ?>>
<?php echo $linktype; ?>
</span>
4 changes: 3 additions & 1 deletion modules/mod_menu/tmpl/default_separator.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@
}

?>
<span class="separator <?php echo $anchor_css; ?>"<?php echo $title; ?>><?php echo $linktype; ?></span>
<span class="separator <?php echo $anchor_css; ?>"<?php echo $title; ?>>
<?php echo $linktype; ?>
</span>
17 changes: 10 additions & 7 deletions modules/mod_random_image/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
*/

defined('_JEXEC') or die;

$image = JHtml::_('image', $image->folder . '/' . $image->name, $image->name, array('width' => $image->width, 'height' => $image->height));

?>
<div class="random-image<?php echo $moduleclass_sfx; ?>">
<?php if ($link) : ?>
<a href="<?php echo $link; ?>">
<?php endif; ?>
<?php echo JHtml::_('image', $image->folder . '/' . $image->name, $image->name, array('width' => $image->width, 'height' => $image->height)); ?>
<?php if ($link) : ?>
</a>
<?php endif; ?>
<?php if ($link) : ?>
<a href="<?php echo $link; ?>">
<?php echo $image; ?>
</a>
<?php else : ?>
<?php echo $image; ?>
<?php endif; ?>
</div>
18 changes: 11 additions & 7 deletions modules/mod_related_items/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@
*/

defined('_JEXEC') or die;

?>
<ul class="relateditems<?php echo $moduleclass_sfx; ?>">
<?php foreach ($list as $item) : ?>
<li>
<a href="<?php echo $item->route; ?>">
<?php if ($showDate) echo JHtml::_('date', $item->created, JText::_('DATE_FORMAT_LC4')) . ' - '; ?>
<?php echo $item->title; ?></a>
</li>
<?php endforeach; ?>
<?php foreach ($list as $item) : ?>
<li>
<a href="<?php echo $item->route; ?>">
<?php if ($showDate) : ?>
<?php echo JHtml::_('date', $item->created, JText::_('DATE_FORMAT_LC4')) . ' - '; ?>
<?php endif; ?>
<?php echo $item->title; ?>
</a>
</li>
<?php endforeach; ?>
</ul>