<?php //1. Init zikula engine $time = time(); include 'lib/bootstrap.php'; $core->init(); ModUtil::load('IWmain', 'admin'); $langcode = ModUtil::getVar('ZConfig', 'language_i18n'); ZLanguage::setLocale($langcode); ZLanguage::bindCoreDomain(); $dom = ZLanguage::getModuleDomain('IWmain'); //2. Checking cron password $passwordActive = ModUtil::getVar('IWmain','cronPasswordActive'); if ($passwordActive) { $passwordString = ModUtil::getVar('IWmain','cronPasswordString'); $passwordSended = FormUtil::getPassedValue('password',null,'GET'); if ($passwordString !== $passwordSended) { print __("You can't execute iwcron", $dom); cronShutdown(); } } //3. Cron actions $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $lastCronSuccessfull = ModUtil::func('IWmain', 'user', 'userGetVar', array('uid' => -100, 'name' => 'lastCronSuccessfull', 'module' => 'IWmain_cron', 'sv' => $sv)); $dateTimeFrom = (int)$lastCronSuccessfull;
protected function newBlockPositions() { $positions = ModUtil::apiFunc('Blocks', 'user', 'getallpositions'); // create the search block position if doesn't exists if (!isset($positions['search'])) { $searchpid = ModUtil::apiFunc('Blocks', 'admin', 'createposition', array('name' => 'search', 'description' => $this->__('Search block'))); } else { $searchpid = $positions['search']['pid']; } // restores the search block if not present $dbtable = DBUtil::getTables(); $blockscolumn = $dbtable['blocks_column']; $searchblocks = DBUtil::selectObjectArray('blocks', "$blockscolumn[bkey] = 'Search'"); if (empty($searchblocks)) { $block = array('bkey' => 'Search', 'collapsable' => 1, 'defaultstate' => 1, 'language' => '', 'mid' => ModUtil::getIdFromName('Search'), 'title' => $this->__('Search box'), 'description' => '', 'positions' => array($searchpid)); $block['bid'] = ModUtil::apiFunc('Blocks', 'admin', 'create', $block); ModUtil::apiFunc('Blocks', 'admin', 'update', $block); } else { // assign the block to the search position $blockplacement = array('bid' => $searchblocks[0]['bid'], 'pid' => $searchpid); DBUtil::insertObject($blockplacement, 'block_placements'); } // create new block positions if they don't exist if (!isset($positions['header'])) { $header = ModUtil::apiFunc('Blocks', 'admin', 'createposition', array('name' => 'header', 'description' => $this->__('Header block'))); } if (!isset($positions['footer'])) { $footer = ModUtil::apiFunc('Blocks', 'admin', 'createposition', array('name' => 'footer', 'description' => $this->__('Footer block'))); } if (!isset($positions['bottomnav'])) { $bottomnav = ModUtil::apiFunc('Blocks', 'admin', 'createposition', array('name' => 'bottomnav', 'description' => $this->__('Bottom navigation block'))); } if (!isset($positions['topnav'])) { $topnav = ModUtil::apiFunc('Blocks', 'admin', 'createposition', array('name' => 'topnav', 'description' => $this->__('Top navigation block'))); // Build content for the top navigation menu $languages = ZLanguage::getInstalledLanguages(); $saveLanguage = ZLanguage::getLanguageCode(); foreach ($languages as $lang) { ZLanguage::setLocale($lang); ZLanguage::bindCoreDomain(); $topnavcontent = array(); $topnavcontent['displaymodules'] = '0'; $topnavcontent['stylesheet'] = 'extmenu.css'; $topnavcontent['template'] = 'blocks_block_extmenu_topnav.tpl'; $topnavcontent['blocktitles'][$lang] = $this->__('Top navigation'); $topnavcontent['links'][$lang][] = array('name' => $this->__('Home'), 'url' => '{homepage}', 'title' => $this->__("Go to the site's home page"), 'level' => 0, 'parentid' => null, 'image' => '', 'active' => '1'); $topnavcontent['links'][$lang][] = array('name' => $this->__('My Account'), 'url' => '{Users}', 'title' => $this->__('Go to your account panel'), 'level' => 0, 'parentid' => null, 'image' => '', 'active' => '1'); $topnavcontent['links'][$lang][] = array('name' => $this->__('Site search'), 'url' => '{Search}', 'title' => $this->__('Search this site'), 'level' => 0, 'parentid' => null, 'image' => '', 'active' => '1'); } ZLanguage::setLocale($saveLanguage); $topnavcontent = serialize($topnavcontent); $topnavblock = array('bkey' => 'Extmenu', 'collapsable' => 1, 'defaultstate' => 1, 'language' => '', 'mid' => ModUtil::getIdFromName('Blocks'), 'title' => $this->__('Top navigation'), 'description' => '', 'content' => $topnavcontent, 'positions' => array($topnav)); $topnavblock['bid'] = ModUtil::apiFunc('Blocks', 'admin', 'create', $topnavblock); ModUtil::apiFunc('Blocks', 'admin', 'update', $topnavblock); } }
/** * 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); }