/** * Display the block. * * @param array $blockinfo A blockinfo structure. * * @return string The rendered block. */ public function display($blockinfo) { // Check if the Profile module is available or saving of login dates are disabled if (!ModUtil::available('Profile')) { return false; } // Security check if (!SecurityUtil::checkPermission('Profile:LastSeenblock:', "$blockinfo[title]::", ACCESS_READ)) { return false; } // Get variables from content block $vars = BlockUtil::varsFromContent($blockinfo['content']); $this->view->setCaching(false); // get last x logged in user id's $users = ModUtil::apiFunc('Profile', 'memberslist', 'getall', array( 'sortby' => 'lastlogin', 'numitems' => $vars['amount'], 'sortorder' => 'DESC', )); $this->view->assign('users', $users); $blockinfo['content'] = $this->view->fetch('profile_block_lastseen.tpl'); return BlockUtil::themeBlock($blockinfo); }
/** * display block * * @param array $blockinfo a blockinfo structure * @return output the rendered bock */ public function display($blockinfo) { if (!SecurityUtil::checkPermission('xsltblock::', "{$blockinfo['title']}::", ACCESS_OVERVIEW)) { return; } // Get our block vars $vars = BlockUtil::varsFromContent($blockinfo['content']); if ((!isset($vars['docurl']) || !isset($vars['styleurl'])) && (!isset($vars['doccontents']) || !isset($vars['stylecontents']))) { return; } // create new objects $doc = new DOMDocument(); $xsl = new XSLTProcessor(); // load stylesheet if (isset($vars['styleurl']) && !empty($vars['styleurl'])) { $doc->load($vars['styleurl']); } else { $doc->loadXML($vars['stylecontents']); } $xsl->importStyleSheet($doc); // load xml source if (isset($vars['docurl']) && !empty($vars['docurl'])) { $doc->load($vars['docurl']); } else { $doc->loadXML($vars['doccontents']); } // apply stylesheet and return output $blockinfo['content'] = $xsl->transformToXML($doc); return BlockUtil::themeBlock($blockinfo); }
/** * Display block. * * @param array $blockinfo Blockinfo structure. * * @return output Rendered block. */ public function display($blockinfo) { if (!SecurityUtil::checkPermission('PendingContent::', "{$blockinfo['title']}::", ACCESS_OVERVIEW)) { return; } // trigger event $event = new Zikula_Event('get.pending_content', new Zikula_Collection_Container('pending_content')); $pendingCollection = EventUtil::getManager()->notify($event)->getSubject(); $content = array(); // process results foreach ($pendingCollection as $collection) { $module = $collection->getName(); foreach ($collection as $item) { $link = ModUtil::url($module, $item->getController(), $item->getMethod(), $item->getArgs()); $content[] = array('description' => $item->getDescription(), 'link' => $link, 'number' => $item->getNumber()); } } if (!empty($content)) { $this->view->assign('content', $content); $blockinfo['content'] = $this->view->fetch('blocks_block_pendingcontent.tpl'); } else { $blockinfo['content'] = ''; } return BlockUtil::themeBlock($blockinfo); }
/** * Display the block. * * @param array $blockinfo the blockinfo structure * * @return string output of the rendered block */ public function display($blockinfo) { // only show block content if the user has the required permissions if (!SecurityUtil::checkPermission('Reviews:ModerationBlock:', "{$blockinfo['title']}::", ACCESS_OVERVIEW)) { return false; } // check if the module is available at all if (!ModUtil::available('Reviews')) { return false; } if (!UserUtil::isLoggedIn()) { return false; } ModUtil::initOOModule('Reviews'); $this->view->setCaching(Zikula_View::CACHE_DISABLED); $template = $this->getDisplayTemplate($vars); $workflowHelper = new Reviews_Util_Workflow($this->serviceManager); $amounts = $workflowHelper->collectAmountOfModerationItems(); // assign block vars and fetched data $this->view->assign('moderationObjects', $amounts); // set a block title if (empty($blockinfo['title'])) { $blockinfo['title'] = $this->__('Moderation'); } $blockinfo['content'] = $this->view->fetch($template); // return the block to the theme return BlockUtil::themeBlock($blockinfo); }
/** * Display block. * * @param array $blockInfo A blockinfo structure. * * @return string The rendered block. */ public function display($blockInfo) { $renderedOutput = ''; if (SecurityUtil::checkPermission('Accountlinks::', $blockInfo['title']."::", ACCESS_READ)) { // Get variables from content block $vars = BlockUtil::varsFromContent($blockInfo['content']); // Call the modules API to get the items if (ModUtil::available($this->name)) { $accountlinks = ModUtil::apiFunc($this->name, 'user', 'accountLinks'); // Check for no items returned if (!empty($accountlinks)) { $this->view->setCaching(Zikula_View::CACHE_DISABLED) ->assign('accountlinks', $accountlinks); // Populate block info and pass to theme $blockInfo['content'] = $this->view->fetch('users_block_accountlinks.tpl'); $renderedOutput = BlockUtil::themeBlock($blockInfo); } } } return $renderedOutput; }
/** * display block * * @param array $blockinfo a blockinfo structure * @return output the rendered bock */ public function display($blockinfo) { // Security check if (!SecurityUtil::checkPermission('Searchblock::', "{$blockinfo['title']}::", ACCESS_READ)) { return; } // Get current content $vars = BlockUtil::varsFromContent($blockinfo['content']); // set some defaults if (!isset($vars['displaySearchBtn'])) { $vars['displaySearchBtn'] = 0; } if (!isset($vars['active'])) { $vars['active'] = array(); } // assign the block vars array $this->view->assign('vars', $vars); // set a title if one isn't present if (empty($blockinfo['title'])) { $blockinfo['title'] = __('Search'); } // return the rendered block $blockinfo['content'] = $this->view->fetch('search_block_search.tpl'); return BlockUtil::themeBlock($blockinfo); }
/** * Display block */ public function display($blockinfo) { if (!SecurityUtil::checkPermission('Zgoodies:marqueeblock:', "{$blockinfo['bid']}::", ACCESS_OVERVIEW)) { return; } if (!ModUtil::available('Zgoodies')) { return; } $vars = BlockUtil::varsFromContent($blockinfo['content']); $lang = ZLanguage::getLanguageCode(); // block title if (isset($vars['block_title'][$lang]) && !empty($vars['block_title'][$lang])) { $blockinfo['title'] = $vars['block_title'][$lang]; } // marquee content if (isset($vars['marquee_content'][$lang]) && !empty($vars['marquee_content'][$lang])) { $vars['marquee_content_lang'] = $vars['marquee_content'][$lang]; } if (!isset($vars['marquee_content'])) { $vars['marquee_content_lang'] = ''; } $this->view->assign('vars', $vars); $this->view->assign('bid', $blockinfo['bid']); $blockinfo['content'] = $this->view->fetch('blocks/' . $vars['block_template']); if (isset($vars['block_wrap']) && !$vars['block_wrap']) { if (empty($blockinfo['title'])) { return $blockinfo['content']; } else { return '<h4>' . DataUtil::formatForDisplayHTML($blockinfo['title']) . '</h4>' . "\n" . $blockinfo['content']; } } return BlockUtil::themeBlock($blockinfo); }
public function display($blockinfo) { // security check $this->throwForbiddenUnless(SecurityUtil::checkPermission('Content:menublock:', "{$blockinfo['title']}::", ACCESS_READ), LogUtil::getErrorMsgPermission()); // Break out options from our content field $vars = BlockUtil::varsFromContent($blockinfo['content']); // --- Setting of the Defaults if (!isset($vars['usecaching'])) { $vars['usecaching'] = false; } if (!isset($vars['root'])) { $vars['root'] = 0; } $this->view->setCacheId($blockinfo['bid']); $this->view->setCaching($vars['usecaching']); if (!$vars['usecaching'] || $vars['usecaching'] && !$this->view->is_cached('block/menu.tpl')) { $options = array('orderBy' => 'setLeft', 'makeTree' => true, 'filter' => array()); if ($vars['root'] > 0) { $options['filter']['superParentId'] = $vars['root']; } // checkInMenu, checkActive is done implicitely $options['filter']['checkInMenu'] = true; $pages = ModUtil::apiFunc('Content', 'Page', 'getPages', $options); if ($pages === false) { return false; } $this->view->assign('subPages', $pages); } $blockinfo['content'] = $this->view->fetch('block/menu.tpl'); return BlockUtil::themeBlock($blockinfo); }
/** * display block * * @param array $blockinfo a blockinfo structure * @return output the rendered bock */ public function display($blockinfo) { if (!SecurityUtil::checkPermission('HTMLblock::', "{$blockinfo['title']}::", ACCESS_OVERVIEW)) { return; } return BlockUtil::themeBlock($blockinfo); }
/** * display block * * @param array $blockinfo a blockinfo structure * @return output the rendered bock */ public function display($blockinfo) { if (!SecurityUtil::checkPermission('Textblock::', "{$blockinfo['title']}::", ACCESS_OVERVIEW)) { return; } $blockinfo['content'] = nl2br($blockinfo['content']); return BlockUtil::themeBlock($blockinfo); }
/** * Display block. * * @param array $blockInfo A blockinfo structure. * * @return string|void The rendered block. */ public function display($blockInfo) { if (!SecurityUtil::checkPermission('Userblock::', $blockInfo['title']."::", ACCESS_READ)) { return; } if (UserUtil::isLoggedIn() && UserUtil::getVar('ublockon') == 1) { if (!isset($blockInfo['title']) || empty($blockInfo['title'])) { $blockInfo['title'] = $this->__f('Custom block content for %s', UserUtil::getVar('name')); } $blockInfo['content'] = nl2br(UserUtil::getVar('ublock')); return BlockUtil::themeBlock($blockInfo); } return; }
public function display($blockinfo) { // security check $this->throwForbiddenUnless(SecurityUtil::checkPermission('Content:OnePageBlock:', "{$blockinfo['title']}::", ACCESS_READ), LogUtil::getErrorMsgPermission()); // Break out options from our content field $vars = BlockUtil::varsFromContent($blockinfo['content']); // --- Setting of the Defaults if (!isset($vars['page'])) { $vars['page'] = 0; } if ($vars['page'] > 0) { $blockinfo['content'] = ModUtil::func('Content', 'user', 'view', array('pid' => $vars['page'])); } else { $blockinfo['content'] = $this->__('No page selected'); } return BlockUtil::themeBlock($blockinfo); }
/** * display block */ public function display($blockinfo) { // Security check if (!SecurityUtil::checkPermission('Admin:adminnavblock', "{$blockinfo['title']}::{$blockinfo['bid']}", ACCESS_ADMIN)) { return; } // Get variables from content block $vars = BlockUtil::varsFromContent($blockinfo['content']); // Call the modules API to get the items if (!ModUtil::available('Admin')) { return; } $items = ModUtil::apiFunc('Admin', 'admin', 'getall'); // Check for no items returned if (empty($items)) { return; } // get admin capable modules $adminmodules = ModUtil::getAdminMods(); $adminmodulescount = count($adminmodules); // Display each item, permissions permitting $admincategories = array(); foreach ($items as $item) { if (SecurityUtil::checkPermission('Admin::', "{$item['catname']}::{$item['cid']}", ACCESS_READ)) { $adminlinks = array(); foreach ($adminmodules as $adminmodule) { // Get all modules in the category $catid = ModUtil::apiFunc('Admin', 'admin', 'getmodcategory', array('mid' => ModUtil::getIdFromName($adminmodule['name']))); if ($catid == $item['cid'] || $catid == false && $item['cid'] == $this->getVar('defaultcategory')) { $modinfo = ModUtil::getInfoFromName($adminmodule['name']); $menutexturl = ModUtil::url($modinfo['name'], 'admin'); $menutexttitle = $modinfo['displayname']; $adminlinks[] = array('menutexturl' => $menutexturl, 'menutexttitle' => $menutexttitle); } } $admincategories[] = array('url' => ModUtil::url('Admin', 'admin', 'adminpanel', array('cid' => $item['cid'])), 'title' => DataUtil::formatForDisplay($item['catname']), 'modules' => $adminlinks); } } $this->view->assign('admincategories', $admincategories); // Populate block info and pass to theme $blockinfo['content'] = $this->view->fetch('admin_block_adminnav.tpl'); return BlockUtil::themeBlock($blockinfo); }
/** * display block * * @param array $blockinfo a blockinfo structure * @return output the rendered bock */ public function display($blockinfo) { if (!SecurityUtil::checkPermission('fincludeblock::', "{$blockinfo['title']}::", ACCESS_READ)) { return; } // Get current content $vars = BlockUtil::varsFromContent($blockinfo['content']); // Defaults if (empty($vars['filo'])) { $vars['filo'] = 'relative/path/to/file.txt'; } if (empty($vars['typo'])) { $vars['typo'] = 0; } if (!file_exists($vars['filo'])) { if (SecurityUtil::checkPermission('fincludeblock::', "{$blockinfo['title']}::", ACCESS_EDIT)) { $blockinfo['content'] = $this->__f("Error! The file '%s' was not found.", $vars['filo']); return BlockUtil::themeBlock($blockinfo); } else { return; } } $blockinfo['content'] = ''; switch ($vars['typo']) { case 0: $blockinfo['content'] = file_get_contents($vars['filo']); // #155 (Blocktype finclude creates not needed line breaks) break; case 1: $blockinfo['content'] = DataUtil::formatForDisplay(file_get_contents($vars['filo'])); break; case 2: ob_start(); include DataUtil::formatForOS($vars['filo']); $blockinfo['content'] = ob_get_clean(); break; default: return; } return BlockUtil::themeBlock($blockinfo); }
public function display($blockinfo) { // security check $this->throwForbiddenUnless(SecurityUtil::checkPermission('Content:SubPagesBlock:', "{$blockinfo['title']}::", ACCESS_READ), LogUtil::getErrorMsgPermission()); // Break out options from our content field $vars = BlockUtil::varsFromContent($blockinfo['content']); // --- Setting of the Defaults if (!isset($vars['usecaching'])) { $vars['usecaching'] = false; } if (!isset($vars['checkinmenu'])) { $vars['checkinmenu'] = true; } // decode the query string (works with and without shorturls) System::queryStringDecode(); $query['module'] = isset($_REQUEST['module']) ? $_REQUEST['module'] : 'notcontent'; $query['func'] = isset($_REQUEST['func']) ? $_REQUEST['func'] : 'notview'; $query['pid'] = isset($_REQUEST['pid']) ? $_REQUEST['pid'] : 0; $this->view->setCacheId($blockinfo['bid']); $this->view->setCaching($vars['usecaching']); if (!$vars['usecaching'] || $vars['usecaching'] && !$this->view->is_cached('block/subpages.tpl')) { $modinfo = ModUtil::getInfoFromName('content'); if (strtolower($query['module']) == $modinfo['url'] && strtolower($query['func']) == 'view' && $query['pid'] > 0) { $options = array('orderBy' => 'setLeft', 'makeTree' => true, 'includeContent' => false, 'enableEscape' => false, 'filter' => array()); // checkInMenu, checkActive is done implicitely $options['filter']['checkInMenu'] = $vars['checkinmenu']; $options['filter']['parentId'] = $query['pid']; $pages = ModUtil::apiFunc('Content', 'Page', 'getPages', $options); if ($pages === false) { return false; } } else { $pages = null; } $this->view->assign('subPages', $pages); } $blockinfo['content'] = $this->view->fetch('block/subpages.tpl'); return BlockUtil::themeBlock($blockinfo); }
/** * Display block. * * @param array $blockInfo a blockinfo structure * * @return string html block */ public function display($blockInfo) { if (!SecurityUtil::checkPermission('Dashboard::', "::", ACCESS_READ)) { return; } // Break out options from our content field $vars = BlockUtil::varsFromContent($blockInfo['content']); if ($this->view->getCaching()) { $this->view->setCacheId($blockInfo['bkey'] . '/bid' . $blockInfo['bid'] . '/' . UserUtil::getGidCacheString()); if ($this->view->is_cached('Block/dashboard.html.tpl')) { $blockInfo['content'] = $this->view->fetch('Block/dashboard.html.tpl'); return BlockUtil::themeBlock($blockInfo); } } $uid = $this->request->getSession()->get('uid'); $helper = new Dashboard_Helper_WidgetHelper($this->entityManager); $dashboard = $helper->getUserWidgets($uid); $this->view->assign('userWidgets', $dashboard); // get the block content $blockInfo['content'] = $this->view->fetch('Block/dashboard.html.tpl'); // pass the block array back to the theme for display return BlockUtil::themeBlock($blockInfo); }
/** * Display the block. * * @param array $blockinfo A blockinfo structure. * * @return string The rendered block. */ public function display($blockinfo) { // Check if the Profile module is available. if (!ModUtil::available('Profile')) { return false; } // Security check if (!SecurityUtil::checkPermission('Profile:MembersOnlineblock:', "$blockinfo[title]::", ACCESS_READ)) { return false; } // Get variables from content block $vars = BlockUtil::varsFromContent($blockinfo['content']); // Defaults if (empty($vars['lengthmax'])) { $vars['lengthmax'] = 30; } $uid = (int)UserUtil::getVar('uid'); $users = ModUtil::apiFunc('Profile', 'memberslist', 'getallonline'); $usersonline = array(); if ($users) { foreach ($users['unames'] as $user) { $usersonline[] = $user; } } $this->view->setCaching(false) ->setCacheId($uid); // check which messaging module is available and add the necessary info $msgmodule = ModUtil::apiFunc('Profile', 'memberslist', 'getmessagingmodule'); if (!empty($msgmodule) && UserUtil::isLoggedIn()) { $this->view->assign('messages', ModUtil::apiFunc($msgmodule, 'user', 'getmessagecount')); } $this->view->assign('msgmodule', $msgmodule); $this->view->assign('maxLength', $vars['lengthmax']); $this->view->assign('usersonline', $usersonline); $this->view->assign('membonline', $users['numusers']); $this->view->assign('anononline', $users['numguests']); $this->view->assign('uid', $uid); $blockinfo['content'] = $this->view->fetch('profile_block_membersonline.tpl'); return BlockUtil::themeBlock($blockinfo); }
/** * Display block. * * @param array $blockinfo A blockinfo structure. * * @return string|void The rendered block. */ public function display($blockinfo) { // Security check if (!SecurityUtil::checkPermission('Pages:pageblock:', "$blockinfo[title]::", ACCESS_READ)) { return; } // Get variables from content block $vars = BlockUtil::varsFromContent($blockinfo['content']); // return if no pid if (empty($vars['pid'])) { return; } // get the page $item = ModUtil::apiFunc('Pages', 'user', 'get', array('pageid' => $vars['pid'])); // check for a valid item if (!$item) { return; } if (!SecurityUtil::checkPermission('Pages::', "{$item['title']}::{$item['pageid']}", ACCESS_READ)) { return; } // Create output object if (!isset($item['content'])) { return; } // create the output object $this->view->setCacheId($item['pageid']); // assign the item $this->view->assign($item); // Populate block info and pass to theme $blockinfo['content'] = $this->view->fetch('block/pageblock_display.tpl'); return BlockUtil::themeBlock($blockinfo); }
/** * display block * * @author The Zikula Development Team * @param array $blockinfo a blockinfo structure * @return output the rendered bock */ public function display($blockinfo) { // security check if (!SecurityUtil::checkPermission('Pastblock::', "$blockinfo[bid]::", ACCESS_READ)) { return; } // get the number of stories shown on the frontpage $storyhome = $this->getVar('storyhome', 10); // Break out options from our content field $vars = BlockUtil::varsFromContent($blockinfo['content']); // Defaults if (empty($vars['limit'])) { $vars['limit'] = 10; } if ($this->getVar('enablecategorization')) { $catregistry = CategoryRegistryUtil::getRegisteredModuleCategories('News', 'news'); } // call the API $articles = ModUtil::apiFunc('News', 'user', 'getall', array( 'displayonindex' => 1, 'order' => 'from', 'status' => News_Api_User::STATUS_PUBLISHED, 'startnum' => $storyhome + 1, 'numitems' => $vars['limit'], 'catregistry' => isset($catregistry) ? $catregistry : null)); if (($articles === false) || (empty($articles))) { return; } // loop round the return articles grouping by date $count = 0; $news = array(); $newscumul = array(); $limitreached = false; foreach ($articles as $article) { $info = ModUtil::apiFunc('News', 'user', 'getArticleInfo', $article); $links = ModUtil::apiFunc('News', 'user', 'getArticleLinks', $info); if (SecurityUtil::checkPermission('News::', "$info[cr_uid]::$info[sid]", ACCESS_READ)) { $preformat['title'] = "<a href=\"$links[fullarticle]\">$info[title]</a>"; } else { $preformat['title'] = $info['title']; } $daydate = DateUtil::formatDatetime(strtotime($info['from']), '%Y-%m-%d'); // Reset the time if (!isset($currentday)) { $currentday = $daydate; } // If it's a different date, save the cumul and continue if ($currentday != $daydate) { $news[$currentday] = $newscumul; $newscumul = array(); $currentday = $daydate; } $newscumul[] = array('info' => $info, 'links' => $links, 'preformat' => $preformat); } if (!isset($news[$currentday])) { $news[$currentday] = $newscumul; } $this->view->assign('news', $news); if (empty($blockinfo['title'])) { //! default past block title $blockinfo['title'] = $this->__('Past articles'); } $blockinfo['content'] = $this->view->fetch('block/past.tpl'); return BlockUtil::themeBlock($blockinfo); }
/** * display block * * @param array $blockinfo a blockinfo structure * @return output the rendered bock */ public function display($blockinfo) { // security check if (!SecurityUtil::checkPermission('ExtendedMenublock::', $blockinfo['bid'] . '::', ACCESS_READ)) { return; } // Break out options from our content field $vars = BlockUtil::varsFromContent($blockinfo['content']); // template to use if (empty($vars['template'])) { $vars['template'] = 'blocks_block_extmenu.tpl'; } // stylesheet to use if (empty($vars['stylesheet'])) { $vars['stylesheet'] = 'extmenu.css'; } // add the stylesheet to the header PageUtil::addVar('stylesheet', ThemeUtil::getModuleStylesheet('Blocks', $vars['stylesheet'])); // if cache is enabled, checks for a cached output if ($this->view->getCaching()) { // set the cache id $this->view->setCacheId($blockinfo['bkey'] . '/bid' . $blockinfo['bid'] . '/' . UserUtil::getGidCacheString()); // check out if the contents are cached if ($this->view->is_cached($vars['template'])) { $blockinfo['content'] = $this->view->fetch($vars['template']); return BlockUtil::themeBlock($blockinfo); } } // create default block variables if (!isset($vars['blocktitles'])) { $vars['blocktitles'] = array(); } if (!isset($vars['links'])) { $vars['links'] = array(); } if (!isset($vars['stylesheet'])) { $vars['stylesheet'] = ''; } if (!isset($vars['menuid'])) { $vars['menuid'] = 0; } // get language and default to en $thislang = ZLanguage::getLanguageCode(); if (!array_key_exists($thislang, $vars['links'])) { $thislang = 'en'; } // if specific blocktitle for selected language exists, use it if (array_key_exists($thislang, $vars['blocktitles']) && !empty($vars['blocktitles'][$thislang])) { $blockinfo['title'] = $vars['blocktitles'][$thislang]; } // Content $menuitems = array(); if (!empty($vars['links'][$thislang])) { $blocked = array(); foreach ($vars['links'][$thislang] as $linkid => $link) { $link['parentid'] = isset($link['parentid']) ? $link['parentid'] : null; $denied = !SecurityUtil::checkPermission('ExtendedMenublock::', $blockinfo['bid'] . ':' . $linkid . ':', ACCESS_READ); if ($denied || !is_null($link['parentid']) && in_array($link['parentid'], $blocked)) { $blocked[] = $linkid; } elseif (!isset($link['active']) || $link['active'] != '1') { $blocked[] = $linkid; } else { // pre zk1.2 check if (!isset($link['id'])) { $link['id'] = $linkid; } $link['url'] = ModUtil::apiFunc('Blocks', 'user', 'encodebracketurl', $link['url']); // check for multiple options in image $this->checkImage($link); $menuitems[] = $link; } } } // Modules if (!empty($vars['displaymodules'])) { $newmods = ModUtil::getUserMods(); $mods = array(); foreach ($newmods as $module) { if (!preg_match('#(?:error|blocks)#', strtolower($module['name']))) { $mods[] = $module; } } // Separate from current content, if any if (count($menuitems) > 0) { $menuitems[] = array('name' => ' ', 'url' => '', 'title' => '', 'level' => 0, 'parentid' => null, 'image' => ''); if (SecurityUtil::checkPermission('ExtendedMenublock::', $blockinfo['bid'] . '::', ACCESS_ADMIN)) { $menuitems[] = array('name' => $this->__('--Installed modules--'), 'url' => ModUtil::url('Blocks', 'admin', 'modify', array('bid' => $blockinfo['bid'])), 'title' => '', 'level' => 0, 'parentid' => null, 'image' => ''); } } foreach ($mods as $mod) { // prepare image if (SecurityUtil::checkPermission("{$mod['name']}::", '::', ACCESS_OVERVIEW)) { $menuitems[] = array('name' => $mod['displayname'], 'url' => ModUtil::url($mod['name'], 'user', 'main'), 'title' => $mod['description'], 'level' => 0, 'parentid' => null, 'image' => ''); } } } // check for any empty result set if (empty($menuitems)) { return; } $currenturi = urlencode(str_replace(System::getBaseUri() . '/', '', System::getCurrentUri())); // assign the items $this->view->assign('menuitems', $menuitems)->assign('blockinfo', $blockinfo)->assign('currenturi', $currenturi)->assign('access_edit', Securityutil::checkPermission('ExtendedMenublock::', $blockinfo['bid'] . '::', ACCESS_EDIT)); // get the block content $blockinfo['content'] = $this->view->fetch($vars['template']); // pass the block array back to the theme for display return BlockUtil::themeBlock($blockinfo); }
/** * display block * * @param array $blockinfo a blockinfo structure * @return output the rendered bock */ public function display($blockinfo) { // Security check if (!SecurityUtil::checkPermission('Searchblock::', "$blockinfo[title]::", ACCESS_READ)) { return; } // Get current content $vars = BlockUtil::varsFromContent($blockinfo['content']); // set some defaults if (!isset($vars['displaySearchBtn'])) { $vars['displaySearchBtn'] = 0; } if (!isset($vars['active'])) { $vars['active'] = array(); } // set a title if one isn't present if (empty($blockinfo['title'])) { $blockinfo['title'] = __('Search'); } $plugin_options = array(); foreach (array_keys($vars['active']) as $mod) { $plugin_options[$mod] = ModUtil::apiFunc($mod, 'search', 'options', $vars); } // assign the block vars and the plgin options $this->view->assign('vars', $vars) ->assign('plugin_options', $plugin_options); // return the rendered block $blockinfo['content'] = $this->view->fetch('search_block_search.tpl'); return BlockUtil::themeBlock($blockinfo); }
public function display($blockinfo) { // check if the module is available if (!ModUtil::available('Theme')) { return; } // check if theme switching is allowed if (!System::getVar('theme_change')) { return; } // security check if (!SecurityUtil::checkPermission( "Themeswitcherblock::", "$blockinfo[title]::", ACCESS_READ)) { return; } // Get variables from content block $vars = BlockUtil::varsFromContent($blockinfo['content']); // Defaults if (empty($vars['format'])) { $vars['format'] = 1; } // get some use information about our environment $currenttheme = UserUtil::getTheme(); // get all themes in our environment $themes = ThemeUtil::getAllThemes(); // get some use information about our environment $currenttheme = ThemeUtil::getInfo(ThemeUtil::getIDFromName(UserUtil::getTheme())); // get all themes in our environment $themes = ThemeUtil::getAllThemes(ThemeUtil::FILTER_USER); $previewthemes = array(); $currentthemepic = null; foreach ($themes as $themeinfo) { $themename = $themeinfo['name']; if (file_exists($themepic = 'themes/'.DataUtil::formatForOS($themeinfo['directory']).'/images/preview_small.png')) { $themeinfo['previewImage'] = $themepic; } else { $themeinfo['previewImage'] = 'system/Theme/images/preview_small.png'; } $previewthemes[$themename] = $themeinfo; if ($themename == $currenttheme['name']) { $currentthemepic = $themeinfo['previewImage']; } } $this->view->assign($vars) ->assign('currentthemepic', $currentthemepic) ->assign('currenttheme', $currenttheme) ->assign('themes', $previewthemes); $blockinfo['content'] = $this->view->fetch('theme_block_themeswitcher.tpl'); return BlockUtil::themeBlock($blockinfo); }
/** * Display a block based on the current theme * * @deprecated * @see BlockUtil::themeBlock() */ function pnBlockThemeBlock($row) { LogUtil::log(__f('Warning! Function %1$s is deprecated. Please use %2$s instead.', array(__FUNCTION__, 'BlockUtil::themeBlock()')), E_USER_DEPRECATED); return BlockUtil::themeBlock($row); }
/** * display block */ public function display($blockinfo) { // Security check if (!Securityutil::checkPermission('Menutree:menutreeblock:', "{$blockinfo['bid']}::", ACCESS_READ)) { return false; } // Get variables from content block $vars = BlockUtil::varsFromContent($blockinfo['content']); // stylesheet if (file_exists($vars['menutree_stylesheet'])) { PageUtil::addVar('stylesheet', $vars['menutree_stylesheet']); } // template to use if (!isset($vars['menutree_tpl']) || empty($vars['menutree_tpl']) || !$this->view->template_exists($vars['menutree_tpl'])) { $vars['menutree_tpl'] = 'menutree/blocks_block_menutree_default.tpl'; } // if cache is enabled, checks for a cached output if ($this->view->getCaching()) { // set the cache id $this->view->setCacheId($blockinfo['bkey'].'/bid'.$blockinfo['bid'].'/'.UserUtil::getGidCacheString()); // check out if the contents are cached if ($this->view->is_cached($vars['menutree_tpl'])) { $blockinfo['content'] = $this->view->fetch($vars['menutree_tpl']); return BlockUtil::themeBlock($blockinfo); } } // set default block vars $vars['menutree_content'] = isset($vars['menutree_content']) ? $vars['menutree_content'] : array(); $vars['menutree_titles'] = isset($vars['menutree_titles']) ? $vars['menutree_titles'] : array(); $vars['menutree_stylesheet'] = isset($vars['menutree_stylesheet']) ? $vars['menutree_stylesheet'] : ''; $vars['menutree_editlinks'] = isset($vars['menutree_editlinks']) ? $vars['menutree_editlinks'] : false; // set current user lang $lang = ZLanguage::getLanguageCode(); $deflang = 'en'; if (!in_array($lang, array_keys(current($vars['menutree_content'])))) { $lang = $deflang; } if (!empty($vars['menutree_content'])) { // select current lang, check permissions for each item and exclude unactive nodes $newTree = array(); $blocked = array(); foreach ($vars['menutree_content'] as $id => $item) { $item = $item[$lang]; // check the permission access to the current link $hasperms = Securityutil::checkPermission('Menutree:menutreeblock:',"$blockinfo[bid]:$item[name]:$item[id]", ACCESS_READ); // checks if has no access to it or the link is not active if (!$hasperms || in_array($item['parent'], $blocked) || $item['state'] != 1) { $blocked[] = $item['id']; } else { // dynamic components if (strpos($item['href'],'{ext:') === 0) { $dynamic = explode(':', substr($item['href'], 1, - 1)); $modname = $dynamic[1]; $func = $dynamic[2]; // plugin $extrainfo = (isset($dynamic[3]) && !empty($dynamic[3])) ? $dynamic[3] : null; if (!empty($modname) && !empty($func)) { $args = array( 'item' => $item, 'lang' => $lang, 'bid' => $blockinfo['bid'], 'extrainfo' => $extrainfo, ); $node = ModUtil::apiFunc($modname, 'menutree', $func, $args); if (!is_array($node)) { $node = array(array($lang => $item)); } } } else { $node = array(array($lang => $item)); } $newTree = array_merge($newTree,(array)$node); } } // bulid structured array $langs = array('ref' => $lang, 'list' => $lang, 'flat' => true); $tree = new Blocks_MenutreeTree(); $tree->setOption('langs',(array)$langs['list']); $tree->setOption('flat',$langs['flat']); $tree->setOption('parseURL',true); $tree->loadArrayData($newTree); $newTree = $tree->getData(); } else { $newTree = array(); } // block title if (!empty($vars['menutree_titles'][$lang])) { $blockinfo['title'] = $vars['menutree_titles'][$lang]; } $this->view->assign('menutree_editlinks', $vars['menutree_editlinks'] && Securityutil::checkPermission('Blocks::', "$blockinfo[bkey]:$blockinfo[title]:$blockinfo[bid]", ACCESS_EDIT)) ->assign('menutree_content', $newTree) ->assign('blockinfo', $blockinfo); $blockinfo['content'] = $this->view->fetch($vars['menutree_tpl']); return BlockUtil::themeBlock($blockinfo); }
/** * Display the block * * @param row blockinfo array */ public function display($blockinfo) { // security check if (!SecurityUtil::checkPermission('Languageblock::', "$blockinfo[title]::", ACCESS_OVERVIEW)) { return; } // if the site's not an ML site don't display the block if (!System::getVar('multilingual')) { return; } $currentlanguage = ZLanguage::getLanguageCode(); $languages = ZLanguage::getInstalledLanguages(); // Get current content $vars = BlockUtil::varsFromContent($blockinfo['content']); $vars['bid'] = $blockinfo['bid']; // Defaults if (empty($vars['format'])) { $vars['format'] = 2; } if (empty($vars['fulltranslation'])) { $vars['fulltranslation'] = 1; } if ($vars['fulltranslation'] == 2) { foreach ($languages as $code) { // bind all languages, we'll need them later. ZLanguage::setLocale($code); ZLanguage::bindCoreDomain(); } ZLanguage::setLocale($currentlanguage); } if (!isset($vars['languages']) || empty($vars['languages']) || !is_array($vars['languages'])) { $vars['languages'] = $this->getAvailableLanguages($vars['fulltranslation']); } $this->view->setCaching(Zikula_View::CACHE_DISABLED); // assign the block vars $this->view->assign($vars); $this->view->assign('currentlanguage', $currentlanguage); // set a block title if (empty($blockinfo['title'])) { $blockinfo['title'] = $this->__('Choose a language'); } // prepare vars for ModUtil::url $module = FormUtil::getPassedValue('module', null, 'GET', FILTER_SANITIZE_STRING); $type = FormUtil::getPassedValue('type', null, 'GET', FILTER_SANITIZE_STRING); $func = FormUtil::getPassedValue('func', null, 'GET', FILTER_SANITIZE_STRING); $get = $_GET; if (isset($get['module'])) { unset($get['module']); } if (isset($get['type'])) { unset($get['type']); } if (isset($get['func'])) { unset($get['func']); } if (isset($get['lang'])) { unset($get['lang']); } if (System::isLegacyMode()) { if (!isset($type)) { $type = 'user'; } if (!isset($func)) { $func = 'main'; } } // make homepage calculations $shorturls = System::getVar('shorturls', false); if ($shorturls) { $homepage = System::getBaseUrl().System::getVar('entrypoint', 'index.php'); $forcefqdn = true; } else { $homepage = System::getVar('entrypoint', 'index.php'); $forcefqdn = false; } // build URLS $urls = array(); foreach ($languages as $code) { if (isset($module) && isset($type) && isset($func)) { $thisurl = ModUtil::url($module, $type, $func, $get, null, null, $forcefqdn, !$shorturls, $code); } else { $thisurl = ($shorturls ? $code : "$homepage?lang=$code"); } $codeFS = ZLanguage::transformFS($code); $flag = ''; if ($vars['format']) { $flag = "images/flags/flag-$codeFS.png"; if (!file_exists($flag)) { $flag = ''; } $flag = (($flag && $shorturls) ? System::getBaseUrl() . $flag : $flag); } if ($vars['fulltranslation'] == 2) { ZLanguage::setLocale($code); } $urls[] = array('code' => $code, 'name' => ZLanguage::getLanguageName($code), 'url' => $thisurl, 'flag' => $flag); if ($vars['fulltranslation'] == 2) { ZLanguage::setLocale($currentlanguage); } } usort($urls, '_blocks_thelangblock_sort'); $this->view->assign('urls', $urls); // get the block content from the template then end the templating $blockinfo['content'] = $this->view->fetch('blocks_block_thelang.tpl'); // return the block to the theme return BlockUtil::themeBlock($blockinfo); }
/** * display block */ public function display($blockinfo) { // Security check if (!SecurityUtil::checkPermission('Feeds:NewsFeed:', "$blockinfo[title]::", ACCESS_READ)) { return; } // Get variables from content block $vars = BlockUtil::varsFromContent($blockinfo['content']); // Defaults if (empty($vars['feedid'])) { $vars['feedid'] = 1; } if (empty($vars['displayimage'])) { $vars['displayimage'] = 0; } if (empty($vars['displaydescription'])) { $vars['displaydescription'] = 0; } if (empty($vars['alternatelayout'])) { $vars['alternatelayout'] = 0; } // Get the feed item $item = ModUtil::apiFunc('Feeds', 'user', 'get', array('fid' => $vars['feedid'])); if (!$item) { return; } // Check if the block is cached if ($this->view->is_cached('block/displayfeed.tpl', $item['fid'])) { $blockinfo['content'] = $this->view->fetch('block/displayfeed.tpl', $item['fid']); return BlockUtil::themeBlock($blockinfo); } // Get the feed source $fullfeed = ModUtil::apiFunc('Feeds', 'user', 'getfeed', array('furl' => $item['url'])); // Assign the item and feed $this->view->assign($item); $this->view->assign('feed', $fullfeed); // assign the block vars $this->view->assign($vars); // Populate block info and pass to theme $blockinfo['content'] = $this->view->fetch('block/displayfeed.tpl', $item['fid']); return BlockUtil::themeBlock($blockinfo); }
/** * display block * * @param array $blockinfo a blockinfo structure * @return output the rendered bock */ public function display($blockinfo) { // security check if (!SecurityUtil::checkPermission('Menublock::', "$blockinfo[title]::", ACCESS_READ)) { return; } // Break out options from our content field $vars = BlockUtil::varsFromContent($blockinfo['content']); // add the stylesheet to the header if (isset($vars['stylesheet'])) { PageUtil::addVar('stylesheet', ThemeUtil::getModuleStyleSheet('Blocks', $vars['stylesheet'])); } // if cache is enabled, checks for a cached output if ($this->view->getCaching()) { // set the cache id $this->view->setCacheId($blockinfo['bkey'].'/bid'.$blockinfo['bid'].'/'.UserUtil::getGidCacheString()); // check out if the contents are cached if ($this->view->is_cached('blocks_block_menu.tpl')) { $blockinfo['content'] = $this->view->fetch('blocks_block_menu.tpl'); return BlockUtil::themeBlock($blockinfo); } } // Styling - this is deprecated and is only to support old menu for now if (empty($vars['style'])) { $vars['style'] = 1; } // Content $menuitems = array(); if (!empty($vars['content'])) { $contentlines = explode('LINESPLIT', $vars['content']); foreach ($contentlines as $contentline) { list($url, $title, $comment) = explode('|', $contentline); if (SecurityUtil::checkPermission('Menublock::', "$blockinfo[title]:$title:", ACCESS_READ)) { $menuitems[] = self::addMenuItem($title, $url, $comment); $content = true; } } } // Modules if (!empty($vars['displaymodules'])) { $mods = ModUtil::getUserMods(); // Separate from current content, if any if ($vars['content'] == 1) { $menuitems[] = self::addMenuItem('', '', ''); } foreach ($mods as $mod) { if (SecurityUtil::checkPermission("$mod[name]::", '::', ACCESS_OVERVIEW)) { $menuitems[] = self::addMenuItem($mod['displayname'], ModUtil::url($mod['name'], 'user', 'main'), $mod['description']); $content = true; } } } // check for any empty result set if (empty($menuitems)) { return; } // assign the items $this->view->assign('menuitems', $menuitems); // get the block content $blockinfo['content'] = $this->view->fetch('blocks_block_menu.tpl'); // pass the block array back to the theme for display return BlockUtil::themeBlock($blockinfo); }
/** * display block * * @author The Zikula Development Team * @param array $blockinfo a blockinfo structure * @return output the rendered bock */ public function display($blockinfo) { // security check if (!SecurityUtil::checkPermission('Bigblock::', "$blockinfo[bid]::", ACCESS_READ)) { return; } // get todays date $today = getdate(); $day = $today['mday']; if ($day < 10) { $day = "0$day"; } $month = $today['mon']; if ($month < 10) { $month = "0$month"; } $year = $today['year']; $tdate = "$year-$month-$day"; // call the API $articles = ModUtil::apiFunc('News', 'user', 'getall', array( 'tdate' => $tdate, 'displayonindex' => 1, 'order' => 'counter', 'status' => News_Api_User::STATUS_PUBLISHED, 'numitems' => 1)); if (empty($articles)) { return; } else { $info = ModUtil::apiFunc('News', 'user', 'getArticleInfo', $row = $articles[0]); if (SecurityUtil::checkPermission('News::', "$info[cr_uid]::$info[sid]", ACCESS_OVERVIEW)) { $links = ModUtil::apiFunc('News', 'user', 'getArticleLinks', $info); $preformat = ModUtil::apiFunc('News', 'user', 'getArticlePreformat', array('info' => $info, 'links' => $links)); } else { return; } } if (empty($blockinfo['title'])) { $blockinfo['title'] = $this->__('Today\'s most-read article'); } $this->view->assign(array('info' => $info, 'links' => $links, 'preformat' => $preformat)); $blockinfo['content'] = $this->view->fetch('block/big.tpl'); return BlockUtil::themeBlock($blockinfo); }
/** * display block * @author Jim McDonald <*****@*****.**> * @link http://www.mcdee.net * @param 'row' blockinfo array * @return string HTML output string */ function Admin_Messages_messagesblock_display($row) { // set default values // The default is to remove the title so that a specific block template override for the admin // messages block isn't required (one that doesn't display the standard block title0 since this // module provides it's own title to items. if (!empty($row['title'])) { $row['title'] = ''; } //security check if (!SecurityUtil::checkPermission('Admin_Messages:messagesblock:', "{$row['title']}::", ACCESS_READ)) { return; } // Check the module is available if (!ModUtil::available('Admin_Messages')) { return; } // Create output object $view = Zikula_View::getInstance('Admin_Messages'); // Define the cacheid $view->cache_id = UserUtil::getVar('uid'); // check out if the contents are cached. if ($view->is_cached('admin_messages_block_messages.htm')) { // Populate block info and pass to theme $row['content'] = $view->fetch('admin_messages_block_messages.htm'); return BlockUtil::themeBlock($row); } // call the api function $messages = ModUtil::apiFunc('Admin_Messages', 'user', 'getactive'); if (!$messages) { $messages = array(); } $messagestodisplay = array(); foreach ($messages as $message) { $show = 0; // Since the API has already done the permissions check // there's no need to duplicate the checks here. // We'll still the support admin panel 'permission' settings // as these are still useful as a quick solution switch ($message['view']) { case 1: // Message for everyone $show = 1; break; case 2: // Message for users if (UserUtil::isLoggedIn()) { $show = 1; } break; case 3: // Messages for non-users if (!UserUtil::isLoggedIn()) { $show = 1; } break; case 4: // Messages for administrators of any description if (SecurityUtil::checkPermission('::', '::', ACCESS_ADMIN)) { $show = 1; } break; } if ($show) { $messagestodisplay[] = $message; } } // check for an empty result set if (empty($messagestodisplay)) { return; } $view->assign('messages', $messagestodisplay); // Populate block info and pass to theme $row['content'] = $view->fetch('admin_messages_block_messages.htm'); return BlockUtil::themeBlock($row); }
/** * display block * * @author The Zikula Development Team * @param array $blockinfo a blockinfo structure * @return output the rendered bock */ public function display($blockinfo) { // security check if (!SecurityUtil::checkPermission('Storiesblock::', $blockinfo['bid'].'::', ACCESS_OVERVIEW)) { return; } // Break out options from our content field $vars = BlockUtil::varsFromContent($blockinfo['content']); // Defaults if (!isset($vars['storiestype'])) { $vars['storiestype'] = 2; } if (!isset($vars['limit'])) { $vars['limit'] = 10; } // work out the paraemters for the api all $apiargs = array(); switch ($vars['storiestype']) { case 1: // non index page articles $apiargs['displayonindex'] = 0; break; case 3: // index page articles $apiargs['displayonindex'] = 1; break; // all - doesn't need displayonindex } $apiargs['numitems'] = $vars['limit']; $apiargs['status'] = News_Api_User::STATUS_PUBLISHED; $apiargs['ignorecats'] = true; if (isset($vars['category']) && !empty($vars['category'])) { $cat = CategoryUtil::getCategoryByID($vars['category']); $categories = CategoryUtil::getCategoriesByPath($cat['path'], '', 'path'); $catstofilter = array(); foreach ($categories as $category) { $catstofilter[] = $category['id']; } $apiargs['category'] = array('Main' => $catstofilter); } $apiargs['filterbydate'] = true; // call the api $items = ModUtil::apiFunc('News', 'user', 'getall', $apiargs); // check for an empty return if (empty($items)) { return; } // create the output object $this->view->setCaching(false); // loop through the items $storiesoutput = array(); foreach ($items as $item) { $storyreadperm = false; if (SecurityUtil::checkPermission('News::', "$item[cr_uid]::$item[sid]", ACCESS_READ)) { $storyreadperm = true; } $this->view->assign('readperm', $storyreadperm); $this->view->assign($item); $storiesoutput[] = $this->view->fetch('block/stories_row.tpl', $item['sid'], null, false, false); } // assign the results $this->view->assign('stories', $storiesoutput); $blockinfo['content'] = $this->view->fetch('block/stories.tpl'); return BlockUtil::themeBlock($blockinfo); }