예제 #1
0
파일: boot.php 프로젝트: HaakonME/redmatrix
/**
 * @brief Loads a page definition file for a module.
 *
 * If there is no parsed Comanche template already load a module's pdl file
 * and parse it with Comanche.
 *
 * @param App &$a global application object
 */
function load_pdl(&$a)
{
    require_once 'include/comanche.php';
    if (!count($a->layout)) {
        $n = 'mod_' . $a->module . '.pdl';
        $u = comanche_get_channel_id();
        if ($u) {
            $s = get_pconfig($u, 'system', $n);
        }
        if (!$s && ($p = theme_include($n)) != '') {
            $s = @file_get_contents($p);
        }
        if ($s) {
            comanche_parser($a, $s);
            $a->pdl = $s;
        }
    }
}
예제 #2
0
파일: boot.php 프로젝트: Mauru/red
function construct_page(&$a)
{
    require_once 'include/comanche.php';
    // in case a page has overloaded a module, see if we already have a layout defined
    // otherwise, if a pdl file exists for this module, use it
    if (!count($a->layout)) {
        $n = 'mod_' . $a->module . '.pdl';
        $u = comanche_get_channel_id();
        if ($u) {
            $s = get_pconfig($u, 'system', $n);
        }
        if (!$s && ($p = theme_include($n)) != '') {
            $s = @file_get_contents($p);
        }
        if ($s) {
            comanche_parser($a, $s);
        }
    }
    $comanche = count($a->layout) ? true : false;
    /**
     * Build the page - now that we have all the components
     */
    require_once theme_include('theme_init.php');
    $installing = false;
    if ($a->module == 'setup') {
        $installing = true;
    } else {
        nav($a);
    }
    if ($comanche) {
        if ($a->layout['nav']) {
            $a->page['nav'] = get_custom_nav($a->layout['nav']);
        }
    }
    if (($p = theme_include(current_theme() . '.js')) != '') {
        head_add_js($p);
    }
    if (($p = theme_include('mod_' . $a->module . '.php')) != '') {
        require_once $p;
    }
    require_once 'include/js_strings.php';
    if (x($a->page, 'template_style')) {
        head_add_css($a->page['template_style'] . '.css');
    } else {
        head_add_css((x($a->page, 'template') ? $a->page['template'] : 'default') . '.css');
    }
    head_add_css('mod_' . $a->module . '.css');
    head_add_css(current_theme_url($installing));
    head_add_js('mod_' . $a->module . '.js');
    $a->build_pagehead();
    $arr = $a->get_widgets();
    ksort($arr, SORT_NUMERIC);
    if (count($arr)) {
        foreach ($arr as $x) {
            if (!array_key_exists($x['location'], $a->page)) {
                $a->page[$x['location']] = '';
            }
            $a->page[$x['location']] .= $x['html'];
        }
    }
    // Let's say we have a comanche declaration '[region=nav][/region][region=content]$nav $content[/region]'.
    // The text 'region=' identifies a section of the layout by that name. So what we want to do here is leave
    // $a->page['nav'] empty and put the default content from $a->page['nav'] and $a->page['section']
    // into a new region called $a->data['content']. It is presumed that the chosen layout file for this comanche page
    // has a '<content>' element instead of a '<section>'.
    // This way the Comanche layout can include any existing content, alter the layout by adding stuff around it or changing the
    // layout completely with a new layout definition, or replace/remove existing content.
    if ($comanche) {
        $arr = array('module' => $a->module, 'layout' => $a->layout);
        call_hooks('construct_page', $arr);
        $a->layout = $arr['layout'];
        foreach ($a->layout as $k => $v) {
            if (strpos($k, 'region_') === 0 && strlen($v)) {
                if (strpos($v, '$region_') !== false) {
                    $v = preg_replace_callback('/\\$region_([a-zA-Z0-9]+)/ism', 'comanche_replace_region', $v);
                }
                // And a couple of convenience macros
                if (strpos($v, '$nav') !== false) {
                    $v = str_replace('$nav', $a->page['nav'], $v);
                }
                if (strpos($v, '$content') !== false) {
                    $v = str_replace('$content', $a->page['content'], $v);
                }
                $a->page[substr($k, 7)] = $v;
            }
        }
    }
    if ($a->is_mobile || $a->is_tablet) {
        if (isset($_SESSION['show_mobile']) && !$_SESSION['show_mobile']) {
            $link = $a->get_baseurl() . '/toggle_mobile?f=&address=' . curPageURL();
        } else {
            $link = $a->get_baseurl() . '/toggle_mobile?f=&off=1&address=' . curPageURL();
        }
        if (isset($_SESSION) && $_SESSION['mobile_theme'] != '' && $_SESSION['mobile_theme'] != '---' || isset($a->config['system']['mobile_theme']) && !isset($_SESSION['mobile_theme'])) {
            $a->page['footer'] .= replace_macros(get_markup_template("toggle_mobile_footer.tpl"), array('$toggle_link' => $link, '$toggle_text' => t('toggle mobile')));
        }
    }
    $page = $a->page;
    $profile = $a->profile;
    header("Content-type: text/html; charset=utf-8");
    require_once theme_include((x($a->page, 'template') ? $a->page['template'] : 'default') . '.php');
    return;
}
예제 #3
0
function comanche_block($s, $class = '')
{
    $var = array();
    $matches = array();
    $name = $s;
    $class = $class ? $class : 'bblock widget';
    $cnt = preg_match_all("/\\[var=(.*?)\\](.*?)\\[\\/var\\]/ism", $s, $matches, PREG_SET_ORDER);
    if ($cnt) {
        foreach ($matches as $mtch) {
            $var[$mtch[1]] = $mtch[2];
            $name = str_replace($mtch[0], '', $name);
        }
    }
    $o = '';
    $channel_id = comanche_get_channel_id();
    if ($channel_id) {
        $r = q("select * from item inner join item_id on iid = item.id and item_id.uid = item.uid and item.uid = %d and service = 'BUILDBLOCK' and sid = '%s' limit 1", intval($channel_id), dbesc($name));
        if ($r) {
            //check for eventual menus in the block and parse them
            $cnt = preg_match_all("/\\[menu\\](.*?)\\[\\/menu\\]/ism", $r[0]['body'], $matches, PREG_SET_ORDER);
            if ($cnt) {
                foreach ($matches as $mtch) {
                    $r[0]['body'] = str_replace($mtch[0], comanche_menu(trim($mtch[1])), $r[0]['body']);
                }
            }
            $cnt = preg_match_all("/\\[menu=(.*?)\\](.*?)\\[\\/menu\\]/ism", $r[0]['body'], $matches, PREG_SET_ORDER);
            if ($cnt) {
                foreach ($matches as $mtch) {
                    $r[0]['body'] = str_replace($mtch[0], comanche_menu(trim($mtch[2]), $mtch[1]), $r[0]['body']);
                }
            }
            //emit the block
            $o .= $var['wrap'] == 'none' ? '' : '<div class="' . $class . '">';
            if ($r[0]['title'] && trim($r[0]['body']) != '$content') {
                $o .= '<h3>' . $r[0]['title'] . '</h3>';
            }
            if (trim($r[0]['body']) === '$content') {
                $o .= get_app()->page['content'];
            } else {
                $o .= prepare_text($r[0]['body'], $r[0]['mimetype']);
            }
            $o .= $var['wrap'] == 'none' ? '' : '</div>';
        }
    }
    return $o;
}
예제 #4
0
파일: comanche.php 프로젝트: redmatrix/red
function comanche_block($name)
{
    $o = '';
    $channel_id = comanche_get_channel_id();
    if ($channel_id) {
        $r = q("select * from item inner join item_id on iid = item.id and item_id.uid = item.uid and item.uid = %d and service = 'BUILDBLOCK' and sid = '%s' limit 1", intval($channel_id), dbesc($name));
        if ($r) {
            $o = '<div class="widget bblock">';
            if ($r[0]['title']) {
                $o .= '<h3>' . $r[0]['title'] . '</h3>';
            }
            $o .= prepare_text($r[0]['body'], $r[0]['mimetype']);
            $o .= '</div>';
        }
    }
    return $o;
}
예제 #5
0
파일: boot.php 프로젝트: Gillesq/hubzilla
/**
 * @brief Loads a page definition file for a module.
 *
 * If there is no parsed Comanche template already load a module's pdl file
 * and parse it with Comanche.
 *
 * @param App &$a global application object
 */
function load_pdl(&$a)
{
    require_once 'include/comanche.php';
    if (!count($a->layout)) {
        $arr = array('module' => $a->module, 'layout' => '');
        call_hooks('load_pdl', $arr);
        $layout = $arr['layout'];
        $n = 'mod_' . $a->module . '.pdl';
        $u = comanche_get_channel_id();
        if ($u) {
            $s = get_pconfig($u, 'system', $n);
        }
        if (!$s) {
            $s = $layout;
        }
        if (!$s && ($p = theme_include($n)) != '') {
            $s = @file_get_contents($p);
        }
        if ($s) {
            comanche_parser($a, $s);
            $a->pdl = $s;
        }
    }
}