Esempio n. 1
0
 /**
  * nv_block_global_rss()
  *
  * @param mixed $block_config
  * @return
  *
  */
 function nv_block_global_rss($block_config)
 {
     global $global_config;
     if (file_exists(NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/feeds/global.rss.tpl')) {
         $block_theme = $global_config['module_theme'];
     } elseif (file_exists(NV_ROOTDIR . '/themes/' . $global_config['site_theme'] . '/modules/feeds/global.rss.tpl')) {
         $block_theme = $global_config['site_theme'];
     } else {
         $block_theme = 'default';
     }
     $a = 1;
     $xtpl = new XTemplate('global.rss.tpl', NV_ROOTDIR . '/themes/' . $block_theme . '/modules/feeds');
     $array_rrs = nv_get_rss($block_config['url']);
     $title_length = isset($block_config['title_length']) ? intval($block_config['title_length']) : 0;
     foreach ($array_rrs as $item) {
         if ($a <= $block_config['number']) {
             $item['description'] = $block_config['ishtml'] ? $item['description'] : strip_tags($item['description']);
             $item['target'] = $block_config['istarget'] ? " onclick=\"this.target='_blank'\" " : "";
             $item['class'] = $a % 2 == 0 ? 'second' : '';
             if ($title_length > 0) {
                 $item['text'] = nv_clean60($item['title'], $title_length);
             } else {
                 $item['text'] = $item['title'];
             }
             $xtpl->assign('DATA', $item);
             if ($block_config['isdescription']) {
                 $xtpl->parse('main.loop.description');
             }
             if ($block_config['ispubdate']) {
                 $xtpl->parse('main.loop.pubDate');
             }
             $xtpl->parse('main.loop');
             ++$a;
         } else {
             break;
         }
     }
     $xtpl->parse('main');
     return $xtpl->text('main');
 }
/**
 * nv_blocks_get_content()
 * 
 * @return
 */
function nv_blocks_content()
{
    global $db, $module_info, $op, $global_config, $lang_global, $module_name, $module_file, $my_head, $user_info;
    $__blocks = array();
    $__blocks_return = array();
    #dev version theme control
    $xml = simplexml_load_file(NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/config.ini');
    $content = $xml->xpath('positions');
    //array
    $position = $content[0]->position;
    //object
    $array_position = array();
    for ($i = 0; $i < count($position); $i++) {
        $__pos = (string) $position[$i]->tag;
        if (!empty($__pos)) {
            $array_position[] = $__pos;
            $__blocks_return[$__pos] = "";
        }
    }
    if (!empty($array_position)) {
        #dev version theme control
        $sql_bl = "SELECT * FROM `" . NV_BLOCKS_TABLE . "` WHERE func_id='" . $module_info['funcs'][$op]['func_id'] . "' AND `theme` ='" . $global_config['module_theme'] . "' AND `active`=1 ORDER BY `weight` ASC";
        $list = nv_db_cache($sql_bl, '', 'themes');
        foreach ($list as $row_bl) {
            $__pos = $row_bl['position'];
            if (isset($__blocks_return[$__pos]) and ($__pos['exp_time'] == 0 or $__pos['exp_time'] > " . NV_CURRENTTIME . ")) {
                $groups_view = (string) $row_bl['groups_view'];
                $allowed = false;
                if ($groups_view == "0") {
                    $allowed = true;
                }
                if ($groups_view == "1" and defined('NV_IS_USER')) {
                    $allowed = true;
                } elseif ($groups_view == "2" and defined('NV_IS_MODADMIN')) {
                    $allowed = true;
                } elseif (defined('NV_IS_SPADMIN')) {
                    $allowed = true;
                } elseif (defined('NV_IS_USER') and nv_is_in_groups($user_info['in_groups'], $groups_view)) {
                    $allowed = true;
                }
                if ($allowed) {
                    $title = $row_bl['title'];
                    if (!empty($title) and !empty($row_bl['link'])) {
                        $title = "<a href=\"" . $row_bl['link'] . "\">" . $title . "</a>";
                    }
                    # comment this line
                    $__blocks[$__pos][] = array('bid' => $row_bl['bid'], 'weight' => $row_bl['weight'], 'func_id' => $row_bl['func_id'], 'title' => $title, 'type' => $row_bl['type'], 'file_path' => $row_bl['file_path'], 'template' => $row_bl['template']);
                }
            }
        }
        foreach (array_keys($__blocks) as $__pos) {
            if (!empty($__blocks[$__pos])) {
                foreach ($__blocks[$__pos] as $__values) {
                    $content = "";
                    if ($__values['type'] == "banner") {
                        $content = showBanners($__values['file_path']);
                    } elseif ($__values['type'] == "html") {
                        $content = $__values['file_path'];
                    } elseif ($__values['type'] == "rss") {
                        $array_rrs = explode("#@#", $__values['file_path']);
                        $content = nv_get_rss($array_rrs[0]);
                    } elseif (preg_match($global_config['check_block_global'], $__values['file_path']) and file_exists(NV_ROOTDIR . "/includes/blocks/" . $__values['file_path'])) {
                        include NV_ROOTDIR . "/includes/blocks/" . $__values['file_path'];
                    } elseif (preg_match($global_config['check_block_module'], $__values['file_path']) and file_exists(NV_ROOTDIR . "/modules/" . $module_file . "/blocks/" . $__values['file_path'])) {
                        include NV_ROOTDIR . "/modules/" . $module_file . "/blocks/" . $__values['file_path'];
                    }
                    if (!empty($content) or defined('NV_IS_DRAG_BLOCK')) {
                        $block_theme = "";
                        $__values['template'] = empty($__values['template']) ? "default" : $__values['template'];
                        if (!empty($module_info['theme']) and file_exists(NV_ROOTDIR . "/themes/" . $module_info['theme'] . "/layout/block." . $__values['template'] . ".tpl")) {
                            $block_theme = $module_info['theme'];
                        } elseif (!empty($global_config['module_theme']) and file_exists(NV_ROOTDIR . "/themes/" . $global_config['module_theme'] . "/layout/block." . $__values['template'] . ".tpl")) {
                            $block_theme = $global_config['module_theme'];
                        } elseif (!empty($global_config['site_theme']) and file_exists(NV_ROOTDIR . "/themes/" . $global_config['site_theme'] . "/layout/block." . $__values['template'] . ".tpl")) {
                            $block_theme = $global_config['site_theme'];
                        } elseif (file_exists(NV_ROOTDIR . "/themes/default/layout/block." . $__values['template'] . ".tpl")) {
                            $block_theme = "default";
                        }
                        if (!empty($block_theme) and $__values['type'] != "rss") {
                            $xtpl = new XTemplate("block." . $__values['template'] . ".tpl", NV_ROOTDIR . "/themes/" . $block_theme . "/layout");
                            $xtpl->assign('BLOCK_TITLE', $__values['title']);
                            $xtpl->assign('BLOCK_CONTENT', $content);
                            $xtpl->parse('mainblock');
                            $b_content = $xtpl->text('mainblock');
                        } elseif (!empty($block_theme) and $__values['type'] == "rss") {
                            $rss_setting_number = intval($array_rrs[1]);
                            $rss_setting_description = intval($array_rrs[2]);
                            $rss_setting_html = intval($array_rrs[3]);
                            $rss_setting_pubdate = intval($array_rrs[4]);
                            $rss_setting_target = intval($array_rrs[5]);
                            $xtpl = new XTemplate("block." . $__values['template'] . ".tpl", NV_ROOTDIR . "/themes/" . $block_theme . "/layout");
                            $xtpl->assign('BLOCK_TITLE', $__values['title']);
                            $a = 1;
                            foreach ($content as $item) {
                                if ($a <= $rss_setting_number) {
                                    $item['description'] = $rss_setting_html ? $item['description'] : strip_tags($item['description']);
                                    $item['target'] = $rss_setting_target ? " onclick=\"this.target='_blank'\" " : "";
                                    $xtpl->assign('DATA_RSS', $item);
                                    if ($rss_setting_description) {
                                        $xtpl->parse('mainblock.looprss.description');
                                    }
                                    if ($rss_setting_pubdate) {
                                        $xtpl->parse('mainblock.looprss.pubDate');
                                    }
                                    $xtpl->parse('mainblock.looprss');
                                    $a++;
                                } else {
                                    break;
                                }
                            }
                            $xtpl->parse('mainblock');
                            $b_content = $xtpl->text('mainblock');
                        } else {
                            $b_content = $__values['title'] . "<br>" . $content . "<br>";
                        }
                        if (defined('NV_IS_DRAG_BLOCK')) {
                            $b_content = '<div class="portlet" id="bl_' . $__values['bid'] . '">
                            <p>
                            <a href="javascript:void(0)" class="editblock" name="' . $__values['bid'] . '">
                                <img src="' . NV_BASE_SITEURL . 'images/edit.png" style="border:none"/> ' . $lang_global['edit_block'] . '</a> | <a href="javascript:void(0)" class="delblock" name="' . $__values['bid'] . '">
                                <img src="' . NV_BASE_SITEURL . 'images/delete.png" style="border:none"/> ' . $lang_global['delete_block'] . '</a> | <a href="javascript:void(0)" class="outgroupblock" name="' . $__values['bid'] . '">
                                <img src="' . NV_BASE_SITEURL . 'images/outgroup.png" style="border:none"/> ' . $lang_global['outgroup_block'] . '</a>
                            </p>
                            ' . $b_content . '</div>';
                        }
                        $__blocks_return[$__pos] .= $b_content;
                    }
                }
            }
        }
    }
    if (defined('NV_IS_DRAG_BLOCK')) {
        #dev version theme control
        foreach ($__blocks_return as $__pos => $b_content) {
            $__blocks_return[$__pos] = '<div class="column" id="' . preg_replace('#\\[|\\]#', '', $__pos) . '">';
            $__blocks_return[$__pos] .= $b_content;
            $__blocks_return[$__pos] .= '	<span><a class="addblock" id="' . $__pos . '" href="javascript:void(0)"><img src="' . NV_BASE_SITEURL . 'images/add.png" style="border:none"/> ' . $lang_global['add_block'] . '</a></span>';
            $__blocks_return[$__pos] .= '</div>';
        }
        #end dev version theme control
    }
    return $__blocks_return;
}