code/libraries/joomlatools/component/koowa/template/filter/module.php
protected function _countModules($condition)
    {
        $operators = '(\+|\-|\*|\/|==|\!=|\<\>|\<|\>|\<=|\>=|and|or|xor)';
        $words = preg_split('# ' . $operators . ' #', $condition, null, PREG_SPLIT_DELIM_CAPTURE);

        for ($i = 0, $n = count($words); $i < $n; $i += 2)
        {
            // Odd parts (blocks)
            $name = strtolower($words[$i]);
            if(!is_numeric($name)) {
                $words[$i] = count(ComKoowaModuleHelper::getModules($name));
            } else {
                $words[$i] = $name;
            }
        }

        //Use the stream buffer to evaluate the condition
        $str = '<?php return ' . implode(' ', $words) .';';
        $buffer = $this->getObject('filesystem.stream.factory')->createStream('koowa-buffer://temp', 'w+b');
        $buffer->truncate(0);
        $buffer->write($str);
        $result = include $buffer->getPath();

        return $result;
    }
protected function _countModules($condition)
    {
        $operators = '(\+|\-|\*|\/|==|\!=|\<\>|\<|\>|\<=|\>=|and|or|xor)';
        $words = preg_split('# ' . $operators . ' #', $condition, null, PREG_SPLIT_DELIM_CAPTURE);

        for ($i = 0, $n = count($words); $i < $n; $i += 2)
        {
            // Odd parts (blocks)
            $name = strtolower($words[$i]);
            if(!is_numeric($name)) {
                $words[$i] = count(ComKoowaModuleHelper::getModules($name));
            } else {
                $words[$i] = $name;
            }
        }

        //Use the stream buffer to evaluate the condition
        $str = '<?php return ' . implode(' ', $words) .';';
        $buffer = $this->getObject('filesystem.stream.factory')->createStream('koowa-buffer://temp', 'w+b');
        $buffer->truncate(0);
        $buffer->write($str);
        $result = include $buffer->getPath();

        return $result;
    }
protected function _countModules ( $ condition ) { $ operators = '(\+|\-|\*|\/|==|\!=|\<\>|\<|\>|\<=|\>=|and|or|xor)' ; $ words = preg_split ( '# ' . $ operators . ' #' , $ condition , null , PREG_SPLIT_DELIM_CAPTURE ) ; for ( $ i = 0 , $ n = count ( $ words ) ; $ i < $ n ; $ i += 2 ) { // Odd parts (blocks) $ name = strtolower ( $ words [ $ i ] ) ; if ( ! is_numeric ( $ name ) ) { $ words [ $ i ] = count ( ComKoowaModuleHelper :: getModules ( $ name ) ) ; } else { $ words [ $ i ] = $ name ; } } //Use the stream buffer to evaluate the condition $ str = '<?php return ' . implode ( ' ' , $ words ) . ';' ; $ buffer = $ this -> getObject ( 'filesystem.stream.factory' ) -> createStream ( 'koowa-buffer://temp' , 'w+b' ) ; $ buffer -> truncate ( 0 ) ; $ buffer -> write ( $ str ) ; $ result = include $ buffer -> getPath ( ) ; return $ result ; }
Count the modules based on a condition

@param  string $condition
@return integer Returns the result of the evaluated condition
Count the modules based on a condition