Ejemplo n.º 1
0
/**
 * Wright Flex Grid
 * (i.e. <w:module type="{row/row-fluid}" name="position" chrome="wrightflexgrid" extradivs="{optional}" extraclass="{optional}" />
 */
function modChrome_wrightflexgrid($module, &$params, &$attribs)
{
    $app = JFactory::getApplication();
    $templatename = $app->getTemplate();
    $document = JFactory::getDocument();
    static $modulenumbera = array();
    if (!isset($modulenumbera[$attribs['name']])) {
        $modulenumbera[$attribs['name']] = 1;
    }
    $spanWidth = getPositionAutospanWidth($attribs['name']);
    $robModules = JModuleHelper::getModules($attribs['name']);
    $extradivs = explode(',', $attribs['extradivs']);
    $extraclass = $attribs['extraclass'] != '' ? ' ' . $attribs['extraclass'] : '';
    $class = $params->get('moduleclass_sfx');
    static $modulenumber = 1;
    $matches = array();
    if (preg_match('/span([0-9]{1,2})/', $class, $matches)) {
        // user assigned span width in module parameters
        $params->set('moduleclass_sfx', preg_replace('/span([0-9]{1,2})/', '', $class));
        $class = $params->get('moduleclass_sfx');
        $spanWidth = (int) $matches[1];
        $module->content = preg_replace('/<([^>]+)class="([^""]*)span' . $spanWidth . '([^""]*)"([^>]*)>/sU', '<$1class="$2 $3"$4>', $module->content);
    }
    $featured = false;
    $featuredLinkImg = preg_match("/featured-link-img/", $class) ? true : false;
    $featuredImg = '';
    $featuredSubtitle = '';
    $moduleTitle = '';
    if (preg_match("/featured/", $class)) {
        $featured = true;
        $linkTitle = '';
        $classold = $class;
        $class = preg_replace("/featured/", "", $class);
        $params->set('moduleclass_sfx', $class);
        if (preg_match('/<a([^>]*)href=\\"([^\\"]*)\\"([^>]*)>Title<\\/a>/i', $module->content, $matches)) {
            $module->content = preg_replace('/<a([^>]*)href=\\"([^\\"]*)\\"([^>]*)>Title<\\/a>/i', '', $module->content, 1);
            $linkTitle = $matches[2];
            $moduleTitle = '<h3><a href="' . $linkTitle . '">' . $module->title . '</a></h3>';
        }
        if (preg_match('/<img([^>]*)>/i', $module->content, $matches)) {
            $module->content = preg_replace('/<img([^>]*)>/i', '', $module->content, 1);
            if ($featuredLinkImg && $linkTitle != '') {
                $featuredImg = '<div class="wrightmodule-imgfeatured">' . '<a href="' . $linkTitle . '">' . '<img' . $matches[1] . '>' . '</a>' . '</div>';
            } else {
                $featuredImg = '<div class="wrightmodule-imgfeatured">' . '<img' . $matches[1] . '>' . '</div>';
            }
        }
        if (preg_match('/<h4([^>]*)>(.+?)<\\/h4>/ims', $module->content, $matches)) {
            $module->content = preg_replace('/<h4([^>]*)>(.+?)<\\/h4>/ims', '', $module->content, 1);
            $featuredSubtitle = '<h4' . $matches[1] . ' class="wrightmodule-subtitle">' . $matches[2] . '</h4>';
        }
    }
    if ($moduleTitle == '') {
        $moduleTitle = '<h3>' . $module->title . '</h3>';
    }
    $class .= ' mod_' . $modulenumbera[$attribs['name']];
    $modulenumber++;
    if ($modulenumbera[$attribs['name']] == 1) {
        $class .= ' first';
        // for 5 modules with span2 first and last modules will have 3 columns width
        if (count($robModules) == 5 && $spanWidth == 2) {
            $spanWidth = 3;
        }
    }
    if ($modulenumbera[$attribs['name']] == $document->countModules($attribs['name'])) {
        $class .= ' last';
        $modulenumbera[$attribs['name']] = 0;
        // for 5 modules with span2 first and last modules will have 3 columns width
        if (count($robModules) == 5 && $spanWidth == 2) {
            $spanWidth = 3;
        }
    }
    $modulenumbera[$attribs['name']]++;
    ?>
<div class="module<?php 
    echo $class;
    if (!$module->showtitle) {
        ?>
 no_title<?php 
    }
    ?>
 span<?php 
    echo $spanWidth . $extraclass;
    ?>
">
<?php 
    if (in_array('module', $extradivs)) {
        ?>
    <div class="module-inner">
<?php 
    }
    if ($featured) {
        echo $featuredImg . '<div class="wrightmodule-content">' . $featuredSubtitle;
    }
    if ($module->showtitle) {
        ?>
	<?php 
        if (in_array('title', $extradivs)) {
            ?>
	<div class="module_title"> <?php 
        }
        ?>
    <?php 
        echo $moduleTitle;
        ?>
    <?php 
        if (in_array('in-title', $extradivs)) {
            ?>
 <div class="module_title_in"></div> <?php 
        }
        ?>
	<?php 
        if (in_array('title', $extradivs)) {
            ?>
	</div> <?php 
        }
    }
    echo $module->content;
    if ($featured) {
        echo '</div>';
    }
    if (in_array('module', $extradivs)) {
        ?>
    </div>
<?php 
    }
    ?>
</div>
<?php 
}
Ejemplo n.º 2
0
/**
 * WRIGHT FLEX GRID
 * (i.e. <jdoc:include type="modules" name="user1" grid="<?php echo $user2gridcount;?>" style="wrightflexgrid" />)
 */
function modChrome_wrightflexgrid($module, &$params, &$attribs)
{
    $app = JFactory::getApplication();
    $templatename = $app->getTemplate();
    $document = JFactory::getDocument();
    static $modulenumbera = array();
    if (!isset($modulenumbera[$attribs['name']])) {
        $modulenumbera[$attribs['name']] = 1;
    }
    $spanWidth = getPositionAutospanWidth($attribs['name']);
    $robModules = JModuleHelper::getModules($attribs['name']);
    $extradivs = explode(',', $attribs['extradivs']);
    $class = $params->get('moduleclass_sfx');
    static $modulenumber = 1;
    if (stripos($params->get('moduleclass_sfx'), 'span') === false) {
        $grid = '';
        if (isset($attribs['grid'])) {
            $grid = $attribs['grid'];
        }
        // user assigned span width in module parameters
    } else {
        $grid = preg_replace('/\\D/', '', $params->get('moduleclass_sfx'));
        $spanWidth = $grid;
    }
    $class .= ' mod_' . $modulenumbera[$attribs['name']];
    $modulenumber++;
    if ($modulenumbera[$attribs['name']] == 1) {
        $class .= ' first';
        // for 5 modules with span2 first and last modules will have 3 columns width
        if (count($robModules) == 5 && $spanWidth == 2) {
            $spanWidth = 3;
        }
    }
    if ($modulenumbera[$attribs['name']] == $document->countModules($attribs['name'])) {
        $class .= ' last';
        $modulenumbera[$attribs['name']] = 0;
        // for 5 modules with span2 first and last modules will have 3 columns width
        if (count($robModules) == 5 && $spanWidth == 2) {
            $spanWidth = 3;
        }
    }
    $modulenumbera[$attribs['name']]++;
    ?>
<div class="module<?php 
    echo $class;
    ?>
 <?php 
    if (!$module->showtitle) {
        ?>
no_title <?php 
    }
    ?>
span<?php 
    echo $spanWidth;
    ?>
">
<?php 
    if ($module->showtitle) {
        ?>
	<?php 
        if (in_array('title', $extradivs)) {
            ?>
	<div class="module_title"> <?php 
        }
        ?>
		<h3><?php 
        echo $module->title;
        ?>
</h3>		
	<?php 
        if (in_array('title', $extradivs)) {
            ?>
	</div> <?php 
        }
    }
    echo $module->content;
    ?>
</div>
<?php 
}