/** * get available admin panel links * @return array array of admin links */ public function getlinks() { $links = array(); if (SecurityUtil::checkPermission('SecurityCenter::', '::', ACCESS_ADMIN)) { $links[] = array('url' => ModUtil::url('SecurityCenter', 'admin', 'modifyconfig'), 'text' => $this->__('Settings'), 'class' => 'z-icon-es-config'); $links[] = array('url' => ModUtil::url('SecurityCenter', 'admin', 'allowedhtml'), 'text' => $this->__('Allowed HTML settings'), 'class' => 'z-icon-es-options'); $links[] = array('url' => ModUtil::url('SecurityCenter', 'admin', 'viewidslog'), 'text' => $this->__('View IDS Log'), 'class' => 'z-icon-es-log', 'links' => array( array('url' => ModUtil::url('SecurityCenter', 'admin', 'viewidslog'), 'text' => $this->__('View IDS Log')), array('url' => ModUtil::url('SecurityCenter', 'admin', 'exportidslog'), 'text' => $this->__('Export IDS Log')), array('url' => ModUtil::url('SecurityCenter', 'admin', 'purgeidslog'), 'text' => $this->__('Purge IDS Log')) )); $outputfilter = System::getVar('outputfilter'); if ($outputfilter == 1) { $links[] = array('url' => ModUtil::url('SecurityCenter', 'admin', 'purifierconfig'), 'text' => $this->__('HTMLPurifier settings'), 'class' => 'z-icon-es-options'); } } return $links; }
/** * Zikula_View outputfilter to add a title to all admin pages * * @param string $source Output source. * @param Zikula_View_Theme $view Reference to Zikula_View_Theme instance. * * @return string */ function smarty_outputfilter_admintitle($source, $view) { // get the first heading tags // module - usually display module preg_match("/<h2>([^<]*)<\\/h2>/", $source, $header2); // function pagetitle preg_match("/<h3>([^<]*)<\\/h3>/", $source, $header3); // init the args $titleargs = array(); // checks for header level 3 if ($header3 && isset($header3[1]) && $header3[1]) { $titleargs[] = $header = strip_tags($header3[1]); // put its value on any z-adminpage-func element $source = preg_replace('/z-admin-pagefunc">(.*?)</', 'z-adminpage-func">' . $header . '<', $source, 1); } // checks for header level 2 if ($header2 && isset($header2[1]) && $header2[1]) { $titleargs[] = $header = strip_tags($header2[1]); // put its value on any z-adminpage-func element $source = preg_replace('/z-admin-pagemodule">(.*?)</', 'z-admin-pagemodule">' . $header . '<', $source, 1); } if (!empty($titleargs)) { $titleargs[] = __('Administration'); $titleargs[] = System::getVar('sitename'); $title = implode(' - ', $titleargs); $source = preg_replace('/<title>(.*?)<\\/title>/', '<title>' . $title . '</title>', $source, 1); } // return the modified page source return $source; }
/** * Zikula_View function to create manual link. * * This function creates a manual link from some parameters. * * Available parameters: * - manual: name of manual file, manual.html if not set * - chapter: an anchor in the manual file to jump to * - newwindow: opens the manual in a new window using javascript * - width: width of the window if newwindow is set, default 600 * - height: height of the window if newwindow is set, default 400 * - title: name of the new window if newwindow is set, default is modulename * - class: class for use in the <a> tag * - assign: if set, the results ( array('url', 'link') are assigned to the corresponding variable instead of printed out * * Example * {manuallink newwindow=1 width=400 height=300 title=rtfm } * * @param array $params All attributes passed to this function from the template. * @param Zikula_View $view Reference to the Zikula_View object. * * @return string|void */ function smarty_function_manuallink($params, Zikula_View $view) { LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated.', array('manuallink')), E_USER_DEPRECATED); $userlang = ZLanguage::transformFS(ZLanguage::getLanguageCode()); $stdlang = System::getVar('language_i18n'); $title = isset($params['title']) ? $params['title'] : 'Manual'; $manual = isset($params['manual']) ? $params['manual'] : 'manual.html'; $chapter = isset($params['chapter']) ? '#' . $params['chapter'] : ''; $class = isset($params['class']) ? 'class="' . $params['class'] . '"' : ''; $width = isset($params['width']) ? $params['width'] : 600; $height = isset($params['height']) ? $params['height'] : 400; $modname = ModUtil::getName(); $possibleplaces = array("modules/{$modname}/docs/{$userlang}/manual/{$manual}", "modules/{$modname}/docs/{$stdlang}/manual/{$manual}", "modules/{$modname}/docs/en/manual/{$manual}", "modules/{$modname}/docs/{$userlang}/{$manual}", "modules/{$modname}/docs/{$stdlang}/{$manual}", "modules/{$modname}/docs/lang/en/{$manual}"); foreach ($possibleplaces as $possibleplace) { if (file_exists($possibleplace)) { $url = $possibleplace . $chapter; break; } } if (isset($params['newwindow'])) { $link = "<a {$class} href='#' onclick=\"window.open( '" . DataUtil::formatForDisplay($url) . "' , '" . DataUtil::formatForDisplay($modname) . "', 'status=yes,scrollbars=yes,resizable=yes,width={$width},height={$height}'); picwin.focus();\">" . DataUtil::formatForDisplayHTML($title) . "</a>"; } else { $link = "<a {$class} href=\"" . DataUtil::formatForDisplay($url) . "\">" . DataUtil::formatForDisplayHTML($title) . "</a>"; } if (isset($params['assign'])) { $ret = array('url' => $url, 'link' => $link); $view->assign($params['assign'], $ret); return; } else { return $link; } }
/** * Obtain and display a configuration variable from the Zikula system. * * Available attributes: * - name (string) The name of the configuration variable to obtain * - html (bool) If set, the output is prepared for display by * DataUtil::formatForDisplayHTML instead of * DataUtil::formatForDisplay * - assign (string) the name of a template variable to assign the * output to, instead of returning it to the template. (optional) * * <i>Note that if the the result is assigned to a template variable, it is not * prepared for display by either DataUtil::formatForDisplayHTML or * DataUtil::formatForDisplay. If it is to be displayed, the safetext * modifier should be used.</i> * * Examples: * * <samp><p>Welcome to {configgetvar name='sitename'}!</p></samp> * * <samp>{configgetvar name='sitename' assign='thename'}</samp><br> * <samp><p>Welcome to {$thename|safetext}!</p></samp> * * @param array $params All attributes passed to this function from the template. * @param Zikula_View $view Reference to the {@link Zikula_View} object. * * @return mixed The value of the configuration variable. */ function smarty_function_configgetvar($params, $view) { LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated.', array('configgetvar')), E_USER_DEPRECATED); $name = isset($params['name']) ? $params['name'] : null; $default = isset($params['default']) ? $params['default'] : null; $html = isset($params['html']) ? $params['html'] : null; $assign = isset($params['assign']) ? $params['assign'] : null; if (!$name) { $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('configgetvar', 'name'))); return false; } $result = System::getVar($name, $default); if ($assign) { $view->assign($assign, $result); } else { if (is_bool($html) && $html) { return DataUtil::formatForDisplayHTML($result); } else { return DataUtil::formatForDisplay($result); } } }
/** * Initialise the url routes for this application. * * @return Zikula_Routing_UrlRouter The router instance treating all initialised routes */ protected function initUrlRoutes() { $fieldRequirements = $this->requirements; $isDefaultModule = System::getVar('shorturlsdefaultmodule', '') == 'MUBoard'; $defaults = array(); $modulePrefix = ''; if (!$isDefaultModule) { $defaults['module'] = 'MUBoard'; $modulePrefix = ':module/'; } $defaults['func'] = 'view'; $viewFolder = 'view'; // normal views (e.g. orders/ or customers.xml) $this->router->set('va', new Zikula_Routing_UrlRoute($modulePrefix . $viewFolder . '/:ot:viewending', $defaults, $fieldRequirements)); $defaults['func'] = 'search'; $viewFolder = 'search'; // normal views (e.g. orders/ or customers.xml) $this->router->set('se', new Zikula_Routing_UrlRoute($modulePrefix . $viewFolder . '/:ot:viewending', $defaults, $fieldRequirements)); // TODO filter views (e.g. /orders/customer/mr-smith.csv) // $this->initRouteForEachSlugType('vn', $modulePrefix . $viewFolder . '/:ot/:filterot/', ':viewending', $defaults, $fieldRequirements); $defaults['func'] = 'display'; // normal display pages including the group folder corresponding to the object type $this->initRouteForEachSlugType('dn', $modulePrefix . ':ot/', ':displayending', $defaults, $fieldRequirements); // additional rules for the leading object type (where ot is omitted) $defaults['ot'] = 'category'; $this->initRouteForEachSlugType('dl', $modulePrefix . '', ':displayending', $defaults, $fieldRequirements); return $this->router; }
/** * This function e-mails the site administrator with an error. */ function send_email() { /* send error reporting email to admin */ $adminmail = System::getVar('adminmail'); $notify_from = System::getVar('notify_from'); $sitename = System::getVar('sitename'); $errortime = date("m/j/Y at g:i a"); $doc = System::serverGetVar('REDIRECT_URL'); $server = System::serverGetVar('HTTP_HOST'); $doc = "http://{$server}{$doc}"; $headers = "ATTN: Fatal Error at {$doc} (" . System::serverGetVar('REDIRECT_STATUS') . ")\n"; $headers .= "From: {$sitename} Error Tools {$adminmail}\n"; $headers .= "X-Sender: <{$notify_from}>\n"; $headers .= "X-Mailer-Version: " . Zikula_Core::VERSION_ID . " " . Zikula_Core::VERSION_NUM . "\n"; $headers .= "X-Priority: 1\n"; $body = "Webmaster, the following item was not found on your website:\n\n"; $body .= " at " . $errortime; $body .= "WEBSITE\n-- " . System::serverGetVar('SERVER_NAME') . ':' . System::serverGetVar('SERVER_PORT') . "\n\n"; $body .= "REASON\n-- " . System::serverGetVar('$REDIRECT_ERRORSOR_NOTES') . "\n\n"; $body .= "PROBLEM URL\n-- {$doc}\n\n"; $body .= "REFERRER\n-- " . System::serverGetVar('HTTP_REFERER') . "\n\n"; $body .= "REQUEST\n-- Host: " . System::serverGetVar('HTTP_HOST') . "\n-- Query String: " . System::serverGetVar('REDIRECT_QUERY_STRING') . "\n"; $body .= "-- Method: " . System::serverGetVar('$REQUEST_METHOD') . "\n\n"; $body .= "USER\n-- Host: " . System::serverGetVar('REMOTE_HOST') . "\n-- IP: " . System::serverGetVar('REMOTE_ADDR') . "\n-- User: "******"\n-- Agent: " . System::serverGetVar('HTTP_USER_AGENT') . "\n-- Cookies: " . System::serverGetVar('HTTP_COOKIE') . "\n\n"; $body .= "Envolution\n-- version: " . Zikula_Core::VERSION_NUM; // Send the mail message. System::mail($adminmail, $headers, $body); }
function display() { // call ZFeed that provides SimplePie $this->feed = new ZFeed($this->url, System::getVar('temp'), $this->refreshTime * 60); $items = $this->feed->get_items(); //$items = $this->feed->get_items(0, $this->maxNoOfItems); $itemsData = array(); foreach ($items as $item) { if (count($itemsData) < $this->maxNoOfItems) { $itemsData[] = array( 'title' => $this->decode($item->get_title()), 'description' => $this->decode($item->get_description()), 'permalink' => $item->get_permalink()); } } $this->feedData = array( 'title' => $this->decode($this->feed->get_title()), 'description' => $this->decode($this->feed->get_description()), 'permalink' => $this->feed->get_permalink(), 'items' => $itemsData); $this->view->assign('feed', $this->feedData); $this->view->assign('includeContent', $this->includeContent); return $this->view->fetch($this->getTemplate()); }
/** * display theme changing user interface */ public function main() { // check if theme switching is allowed if (!System::getVar('theme_change')) { LogUtil::registerError($this->__('Notice: Theme switching is currently disabled.')); $this->redirect(ModUtil::url('Users', 'user', 'main')); } if (!SecurityUtil::checkPermission('Theme::', '::', ACCESS_COMMENT)) { return LogUtil::registerPermissionError(); } // get our input $startnum = FormUtil::getPassedValue('startnum', isset($args['startnum']) ? $args['startnum'] : 1, 'GET'); // we need this value multiple times, so we keep it $itemsperpage = $this->getVar('itemsperpage'); // get some use information about our environment $currenttheme = ThemeUtil::getInfo(ThemeUtil::getIDFromName(UserUtil::getTheme())); // get all themes in our environment $allthemes = ThemeUtil::getAllThemes(ThemeUtil::FILTER_USER); $previewthemes = array(); $currentthemepic = null; foreach ($allthemes as $key => $themeinfo) { $themename = $themeinfo['name']; if (file_exists($themepic = 'themes/'.DataUtil::formatForOS($themeinfo['directory']).'/images/preview_medium.png')) { $themeinfo['previewImage'] = $themepic; $themeinfo['largeImage'] = 'themes/'.DataUtil::formatForOS($themeinfo['directory']).'/images/preview_large.png'; } else { $themeinfo['previewImage'] = 'system/Theme/images/preview_medium.png'; $themeinfo['largeImage'] = 'system/Theme/images/preview_large.png'; } if ($themename == $currenttheme['name']) { $currentthemepic = $themepic; unset($allthemes[$key]); } else { $previewthemes[$themename] = $themeinfo; } } $previewthemes = array_slice($previewthemes, $startnum-1, $itemsperpage); $this->view->setCaching(Zikula_View::CACHE_DISABLED); $this->view->assign('currentthemepic', $currentthemepic) ->assign('currenttheme', $currenttheme) ->assign('themes', $previewthemes) ->assign('defaulttheme', ThemeUtil::getInfo(ThemeUtil::getIDFromName(System::getVar('Default_Theme')))); // assign the values for the pager plugin $this->view->assign('pager', array('numitems' => sizeof($allthemes), 'itemsperpage' => $itemsperpage)); // Return the output that has been generated by this function return $this->view->fetch('theme_user_main.tpl'); }
/** * Performs the actual search processing. */ public function search($args) { ModUtil::dbInfoLoad('Search'); $dbtables = DBUtil::getTables(); $pageTable = $dbtables['content_page']; $pageColumn = $dbtables['content_page_column']; $contentTable = $dbtables['content_content']; $contentColumn = $dbtables['content_content_column']; $contentSearchTable = $dbtables['content_searchable']; $contentSearchColumn = $dbtables['content_searchable_column']; $translatedPageTable = $dbtables['content_translatedpage']; $translatedPageColumn = $dbtables['content_translatedpage_column']; $sessionId = session_id(); // check whether we need to search also in translated content $multilingual = System::getVar('multilingual'); $currentLanguage = ZLanguage::getLanguageCode(); $searchWhereClauses = array(); $searchWhereClauses[] = '(' . Search_Api_User::construct_where($args, array($pageColumn['title']), $pageColumn['language']) . ')'; if ($multilingual) { $searchWhereClauses[] = '(' . Search_Api_User::construct_where($args, array($translatedPageColumn['title']), $translatedPageColumn['language']) . ')'; } $searchWhereClauses[] = '(' . Search_Api_User::construct_where($args, array($contentSearchColumn['text']), $contentSearchColumn['language']) . ')'; // add default filters $whereClauses = array(); $whereClauses[] = '(' . implode(' OR ', $searchWhereClauses) . ')'; $whereClauses[] = $pageColumn['active'] . ' = 1'; $whereClauses[] = "({$pageColumn['activeFrom']} IS NULL OR {$pageColumn['activeFrom']} <= NOW())"; $whereClauses[] = "({$pageColumn['activeTo']} IS NULL OR {$pageColumn['activeTo']} >= NOW())"; $whereClauses[] = $contentColumn['active'] . ' = 1'; $whereClauses[] = $contentColumn['visiblefor'] . (UserUtil::isLoggedIn() ? ' <= 1' : ' >= 1'); $titleFields = $pageColumn['title']; $additionalJoins = ''; if ($multilingual) { // if searching in non-default languages, we need the translated title $titleFields .= ', ' . $translatedPageColumn['title'] . ' AS translatedTitle'; // join also the translation table if required $additionalJoins = "LEFT OUTER JOIN {$translatedPageTable} ON {$translatedPageColumn['pageId']} = {$pageColumn['id']} AND {$translatedPageColumn['language']} = '{$currentLanguage}'"; // prevent content snippets in other languages $whereClauses[] = $contentSearchColumn['language'] . ' = \'' . $currentLanguage . '\''; } $where = implode(' AND ', $whereClauses); $sql = "\n SELECT DISTINCT {$titleFields},\n {$contentSearchColumn['text']} AS description,\n {$pageColumn['id']} AS pageId,\n {$pageColumn['cr_date']} AS createdDate\n FROM {$pageTable}\n JOIN {$contentTable}\n ON {$contentColumn['pageId']} = {$pageColumn['id']}\n JOIN {$contentSearchTable}\n ON {$contentSearchColumn['contentId']} = {$contentColumn['id']}\n {$additionalJoins}\n WHERE {$where}\n "; $result = DBUtil::executeSQL($sql); if (!$result) { return LogUtil::registerError($this->__('Error! Could not load items.')); } $objectArray = DBUtil::marshallObjects($result); foreach ($objectArray as $object) { $pageTitle = $object['page_title']; if ($object['translatedTitle'] != '') { $pageTitle = $object['translatedTitle']; } $searchItemData = array('title' => $pageTitle, 'text' => $object['description'], 'extra' => $object['pageId'], 'created' => $object['createdDate'], 'module' => 'Content', 'session' => $sessionId); if (!\DBUtil::insertObject($searchItemData, 'search_result')) { return \LogUtil::registerError($this->__('Error! Could not save the search results.')); } } return true; }
/** * Get a cookie. * * @param string $name Name of cookie. * @param boolean $signed Override system setting to use signatures. * @param boolean $default Default value. * * @return mixed Cookie value as string or bool false. */ public static function getCookie($name, $signed = true, $default = '') { $cookie = FormUtil::getPassedValue($name, $default, 'COOKIE'); if (System::getVar('signcookies') && !$signed == false) { return SecurityUtil::checkSignedData($cookie); } return $cookie; }
/** * Listen on 'core.init' module. * * @param Zikula_Event $event Event. * * @return void */ public function setupCsfrProtection(Zikula_Event $event) { if ($event['stage'] & Zikula_Core::STAGE_MODS) { // todo - handle this in DIC later // inject secret $def = $this->serviceManager->get('token.generator'); $def->setSecret(System::getVar('signingkey')); } }
/** * Template plugin to display timezone list. * * Example {timezoneselect selected='Timezone'}. * * @param array $params All attributes passed to this function from the template. * @param Zikula_View $view The Zikula_View. * * @see function.timezoneselect.php::smarty_function_timezoneselect(). * * @return string The results of the module function. */ function smarty_function_timezoneselect($params, Zikula_View $view) { require_once $view->_get_plugin_filepath('function', 'html_options'); $timezones = DateUtil::getTimezones(); if (!isset($params['selected']) || empty($params['selected']) || !isset($timezones[$params['selected']])) { $params['selected'] = System::getVar('timezone_offset'); } return smarty_function_html_options(array('options' => $timezones, 'selected' => $params['selected'], 'print_result' => false), $view); }
/** * Zikula_View function to display the sitename * * Available parameters: * - assign if set, the title will be assigned to this variable * * Example * {sitename} * * @param array $params All attributes passed to this function from the template. * @param Zikula_View $view Reference to the Zikula_View object. * * @see function.sitename.php::smarty_function_sitename() * @return string The sitename. */ function smarty_function_sitename($params, $view) { LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated, please use {%2$s} instead.', array('sitename', '$modvars.ZConfig.sitename')), E_USER_DEPRECATED); $sitename = System::getVar('sitename'); if (isset($params['assign'])) { $view->assign($params['assign'], $sitename); } else { return $sitename; } }
/** * Smarty function to generate a valid atom ID for the feed * * Example * * <id>{id}</id> * * @return string the atom ID */ function smarty_function_id($params, &$smarty) { $baseurl = System::getBaseUrl(); $parts = parse_url($baseurl); $starttimestamp = strtotime(System::getVar('startdate')); $startdate = strftime('%Y-%m-%d', $starttimestamp); $sitename = System::getVar('sitename'); $sitename = preg_replace('/[^a-zA-Z0-9-\\s]/', '', $sitename); $sitename = DataUtil::formatForURL($sitename); return "tag:{$parts['host']},{$startdate}:{$sitename}"; }
/** * Create a directory below zikula's local cache directory. * * @param string $dir The name of the directory to create. * @param mixed $mode The (UNIX) mode we wish to create the files with. * @param bool $absolute Whether to process the passed dir as an absolute path or not. * * @return boolean true if successful, false otherwise. */ public static function createLocalDir($dir, $mode = null, $absolute = true) { $sm = ServiceUtil::getManager(); $base = $sm['kernel.cache_dir'] . '/ztemp'; $path = $base . '/' . $dir; $mode = isset($mode) ? (int) $mode : System::getVar('system.chmod_dir'); if (!FileUtil::mkdirs($path, $mode, $absolute)) { return false; } return true; }
/** * Get a cookie. * * @param string $name Name of cookie. * @param boolean $signed Override system setting to use signatures. * @param boolean $default Default value. * * @return mixed Cookie value as string or bool false. */ public static function getCookie($name, $signed = true, $default = '') { $request = \ServiceUtil::get('request'); if (!$request->cookies->has($name)) { return $default; } $cookie = $request->cookies->get($name); if (System::getVar('signcookies') && !$signed == false) { return SecurityUtil::checkSignedData($cookie); } return $cookie; }
/** * Reloads the multilingual routing settings by reading system variables and checking installed languages. * * @param array $args No arguments available. * * @return bool */ public function reloadMultilingualRoutingSettings($args) { unset($args); $defaultLocale = \System::getVar('language_i18n', $this->getContainer()->getParameter('locale')); $installedLanguages = \ZLanguage::getInstalledLanguages(); $isRequiredLangParameter = \System::getVar('languageurl', 0); $configDumper = $this->get('zikula.dynamic_config_dumper'); $configDumper->setConfiguration('jms_i18n_routing', array('default_locale' => $defaultLocale, 'locales' => $installedLanguages, 'strategy' => $isRequiredLangParameter ? 'prefix' : 'prefix_except_default')); $cacheClearer = $this->get('zikula.cache_clearer'); $cacheClearer->clear('symfony'); return true; }
/** * Generate a configuration for javascript and return script tag to embed in HTML HEAD. * * @return string HTML code with script tag */ public static function getJSConfig() { /* @var \Symfony\Component\HttpFoundation\Request $request */ $request = ServiceUtil::getManager()->get('request'); $basePath = $request->getBasePath(); $baseUrl = $request->getBaseUrl(); $return = ''; $config = array('entrypoint' => System::getVar('entrypoint', 'index.php'), 'baseURL' => $baseUrl, 'baseURI' => $basePath, 'ajaxtimeout' => (int) System::getVar('ajaxtimeout', 5000), 'lang' => ZLanguage::getLanguageCode(), 'sessionName' => session_name()); $config = DataUtil::formatForDisplay($config); $return .= "<script type=\"text/javascript\">/* <![CDATA[ */ \n"; $return .= "if (typeof(Zikula) == 'undefined') {var Zikula = {};}\n"; $return .= "Zikula.Config = " . json_encode($config) . "\n"; $return .= ' /* ]]> */</script>' . "\n"; return $return; }
/** * Generate a configuration for javascript and return script tag to embed in HTML HEAD. * * @return string HTML code with script tag */ public static function getJSConfig() { $return = ''; $config = array('entrypoint' => System::getVar('entrypoint', 'index.php'), 'baseURL' => System::getBaseUrl(), 'baseURI' => System::getBaseUri() . '/', 'ajaxtimeout' => (int) System::getVar('ajaxtimeout', 5000), 'lang' => ZLanguage::getLanguageCode(), 'sessionName' => session_name()); $config = DataUtil::formatForDisplay($config); $return .= "<script type=\"text/javascript\">/* <![CDATA[ */ \n"; if (System::isLegacyMode()) { $return .= 'document.location.entrypoint="' . $config['entrypoint'] . '";'; $return .= 'document.location.ajaxtimeout=' . $config['ajaxtimeout'] . ";\n"; } $return .= "if (typeof(Zikula) == 'undefined') {var Zikula = {};}\n"; $return .= "Zikula.Config = " . json_encode($config) . "\n"; $return .= ' /* ]]> */</script>' . "\n"; return $return; }
/** * Display an error * This function displays a generic error form * The template used is based on the error type passed * * @param string $args['type'] error type '404' or 'module' * @param string $args['message'] custom error message * * @return string HTML string */ public function main($args) { $type = FormUtil::getPassedValue('errtype', isset($args['type']) ? $args['type'] : LogUtil::getErrorType(), 'GET'); $exception = isset($args['exception']) ? $args['exception'] : null; $message = isset($args['message']) ? $args['message'] : ''; // perform any error specific tasks $protocol = System::serverGetVar('SERVER_PROTOCOL'); switch ($type) { case 301: header("{$protocol} 301 Moved Permanently"); break; case 403: header("{$protocol} 403 Access Denied"); break; case 404: header("{$protocol} 404 Not Found"); break; case 500: header("{$protocol} 500 Internal Server Error"); default: } // load the stylesheet PageUtil::addVar('stylesheet', 'system/Errors/style/style.css'); $this->view->setCaching(Zikula_View::CACHE_DISABLED); // assign the document info $this->view->assign('reportlevel', System::getVar('reportlevel'))->assign('currenturi', System::getCurrentUri())->assign('localreferer', System::localReferer())->assign('sitename', System::getVar('sitename'))->assign('reportlevel', System::getVar('reportlevel'))->assign('funtext', System::getVar('funtext')); $messages = LogUtil::getErrorMessages(); // show the detailed error message for admins only if (System::isDevelopmentMode() || SecurityUtil::checkPermission('::', '::', ACCESS_ADMIN)) { $message ? $messages[] = $message : null; } $trace = array(); if (System::isDevelopmentMode() && $exception instanceof Exception) { $line = $exception->getLine(); $file = $exception->getFile(); $trace = array(0 => '#0 ' . $this->__f('Exception thrown in %1$s, line %2$s.', array($file, $line))); $trace += explode("\n", $exception->getTraceAsString()); } // assign the list of registered errors // and the trace (if development mode is enabled) $this->view->assign('messages', $messages)->assign('trace', $trace); // return the template output if ($this->view->template_exists($template = "errors_user_{$type}.tpl")) { return $this->view->fetch($template); } else { return $this->view->fetch('errors_user_main.tpl'); } }
/** * Return an array of items to show in the your account panel. * * @param array $array The arguments to pass to the function. * * @return array indexed array of items */ public function getall($args) { $items = array(); // check if theme switching is allowed if (System::getVar('theme_change')) { // create an array of links to return $items['0'] = array('url' => ModUtil::url('Theme', 'user', 'main'), 'module' => 'Theme', 'title' => $this->__('Theme switcher'), 'icon' => 'admin.png'); } // Return the items return $items; }
/** * Display the list of allowed HTML tags. * * Available parameters: * - assign (string) (optional) If set, the results are assigned to the * corresponding variable instead of printed out * * Example: * * <samp>{news_allowedhtml}</samp> * * @param array $params All attributes passed to this function from the template. * @param Smarty &$smarty Reference to the {@link Zikula_View} object. * * @return string A string containing the allowable HTML tags. */ function smarty_function_news_allowedhtml($params, &$smarty) { $AllowableHTML = System::getVar('AllowableHTML'); $allowedhtml = ''; foreach ($AllowableHTML as $key => $access) { if ($access > 0) { $allowedhtml .= '<' . htmlspecialchars($key) . '> '; } } if (isset($params['assign'])) { $smarty->assign($params['assign'], $allowedhtml); } else { return $allowedhtml; } }
/** * Add default pagevar settings to every page * @param GetResponseEvent $event */ public function setDefaultPageVars(GetResponseEvent $event) { if (!$event->isMasterRequest()) { return; } // set some defaults $this->pageVars->set('lang', \ZLanguage::getLanguageCode()); $this->pageVars->set('langdirection', \ZLanguage::getDirection()); $this->pageVars->set('title', \System::getVar('defaultpagetitle')); $this->pageVars->set('meta.charset', \ZLanguage::getDBCharset()); $this->pageVars->set('meta.description', \System::getVar('defaultmetadescription')); $this->pageVars->set('meta.keywords', \System::getVar('metakeywords')); $schemeAndHost = $event->getRequest()->getSchemeAndHttpHost(); $baseUrl = $event->getRequest()->getBaseUrl(); $this->pageVars->set('homepath', $schemeAndHost . $baseUrl); }
/** * Display the list of allowed HTML tags. * * Available parameters: * - assign (string) (optional) If set, the results are assigned to the * corresponding variable instead of printed out * * Example: * * <samp>{allowedhtml}</samp> * * @param array $params All attributes passed to this function from the template. * @param Smarty &$smarty Reference to the {@link Zikula_View} object. * * @return string A string containing the allowable HTML tags. */ function smarty_function_allowedhtml($params, &$smarty) { LogUtil::log(__f('Warning! Template plugin {%s} is deprecated.', array('allowedhtml')), E_USER_DEPRECATED); $AllowableHTML = System::getVar('AllowableHTML'); $allowedhtml = ''; foreach ($AllowableHTML as $key => $access) { if ($access > 0) { $allowedhtml .= '<' . htmlspecialchars($key) . '> '; } } if (isset($params['assign'])) { $smarty->assign($params['assign'], $allowedhtml); } else { return $allowedhtml; } }
function display() { $flickr = new phpFlickr(ModUtil::getVar('Content', 'flickrApiKey')); $flickr->enableCache("fs", System::getVar('temp')); // Find the NSID of the username $person = $flickr->people_findByUsername($this->userName); // Get the photos //$photos = $flickr->people_getPublicPhotos($person['id'], NULL, $this->photoCount); $photos = $flickr->photos_search(array('user_id' => $person['id'], 'tags' => $this->tags, 'per_page' => $this->photoCount)); $photoData = array(); foreach ((array) $photos['photo'] as $photo) { $photoData[] = array('title' => DataUtil::formatForDisplayHTML($this->decode($photo['title'])), 'src' => $flickr->buildPhotoURL($photo, "Square"), 'url' => "http://www.flickr.com/photos/{$photo['owner']}/{$photo['id']}"); } $this->view->assign('photos', $photoData); return $this->view->fetch($this->getTemplate()); }
/** * Zikula_View function to get current URI/URL to change language, handling in proper way short URLs * * This function obtains the current request URI and returns URI/URL with parameter to change language. * The results of this function are already sanitized to display, so it should not be passed to the safetext modifier. * * Available parameters: * - assign: If set, the results are assigned to the corresponding variable instead of printed out * - lang: Language code to change to * - fqurl: Fully Qualified URL. True to get full URL, otherwise return URI * * Example * {langchange lang='de'} * * @param array $params All attributes passed to this function from the template. * @param Zikula_View $view Reference to the Zikula_View object. * * @return string The changed current URI. */ function smarty_function_langchange($params, Zikula_View $view) { $assign = null; if (isset($params['assign'])) { $assign = $params['assign']; unset($params['assign']); } $lang = null; if (isset($params['lang'])) { $lang = $params['lang']; } $fqurl = false; if (isset($params['fqurl'])) { $fqurl = $params['fqurl']; unset($params['fqurl']); } // Handling short URL's similar to Language selector block $shorturls = System::getVar('shorturls', false); if (isset($lang) && $shorturls) { $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); if (isset($module) && isset($type) && isset($func)) { // build URL based on module URL $result = ModUtil::url($module, $type, $func, $_GET, null, null, $fqurl, false, $lang); } else { // to homepage with language set in terms of short url's if ($fqurl) { $result = System::getVar('entrypoint', 'index.php') . "?lang=" . $lang; } else { $result = $lang; } } } else { if ($fqurl) { $result = htmlspecialchars(System::getCurrentUrl($params)); } else { $result = htmlspecialchars(System::getCurrentUri($params)); } } if ($assign) { $view->assign($assign, $result); } else { return $result; } }
function smarty_modifier_zikularoutesmodulePathToString($path, \Zikula\RoutesModule\Entity\RouteEntity $route) { $options = $route->getOptions(); $prefix = ''; if (isset($options['i18n_prefix'])) { $prefix = '/' . $options['i18n_prefix']; } if (!isset($options['i18n']) || $options['i18n']) { $languages = ZLanguage::getInstalledLanguages(); $isRequiredLangParam = ZLanguage::isRequiredLangParam(); if (!$isRequiredLangParam) { $defaultLanguage = System::getVar('language_i18n'); unset($languages[array_search($defaultLanguage, $languages)]); } if (count($languages) > 0) { $prefix = ($isRequiredLangParam ? "/" : "{/") . implode('|', $languages) . ($isRequiredLangParam ? "" : "}"); } } $prefix = \DataUtil::formatForDisplay($prefix); $path = \DataUtil::formatForDisplay($route->getPathWithBundlePrefix()); $container = \ServiceUtil::getManager(); $path = preg_replace_callback('#%(.*?)%#', function ($matches) use($container) { return "<abbr title=\"" . \DataUtil::formatForDisplay($matches[0]) . "\">" . \DataUtil::formatForDisplay($container->getParameter($matches[1])) . "</abbr>"; }, $path); $defaults = $route->getDefaults(); $requirements = $route->getRequirements(); $dom = ZLanguage::getModuleDomain('ZikulaRoutesModule'); $path = preg_replace_callback('#{(.*?)}#', function ($matches) use($container, $defaults, $requirements, $dom) { $title = ""; if (isset($defaults[$matches[1]])) { $title .= __f('Default: %s', array(\DataUtil::formatForDisplay($defaults[$matches[1]])), $dom); } if (isset($requirements[$matches[1]])) { if ($title != "") { $title .= " | "; } $title .= __f('Requirement: %s', array(\DataUtil::formatForDisplay($requirements[$matches[1]])), $dom); } if ($title == "") { return $matches[0]; } return "<abbr title=\"{$title}\">" . $matches[0] . "</abbr>"; }, $path); return "{$prefix}<strong>{$path}</strong>"; }
/** * initialise the module * * @author Francesc Bassas i Bullich * @return bool true on success, false otherwise */ public function Install() { // Set default module variables $this->setVar('enabled', 0) ->setVar('idApp', 'SIRIUS') ->setVar('replyAddress', System::getVar('adminmail')) ->setVar('sender', 'educacio') ->setVar('environment', 'PRO') // Referent a l'entorn (INT, ACC, PRO, FRM) ->setVar('contenttype', 2) ->setVar('log', 0) ->setVar('debug', 0) ->setVar('logpath', ''); EventUtil::registerPersistentModuleHandler('SiriusXtecMailer', 'module.mailer.api.sendmessage', array('SiriusXtecMailer_Listeners', 'sendMail')); // Initialisation successful return true; }
/** * Zikula_View function to display some user links * * Example * {userlinks start="[" end="]" seperator="|"} * * Parameters: * start Start delimiter * end End delimiter * seperator Seperator * * @param array $params All attributes passed to this function from the template. * @param Zikula_View $view Reference to the Zikula_View object. * * @see function.userlinks.php::smarty_function_userlinks() * * @return string User links. */ function smarty_function_userlinks($params, Zikula_View $view) { $start = isset($params['start']) ? $params['start'] : '['; $end = isset($params['end']) ? $params['end'] : ']'; $seperator = isset($params['seperator']) ? $params['seperator'] : '|'; if (UserUtil::isLoggedIn()) { $links = "{$start} "; $profileModule = System::getVar('profilemodule', ''); if (!empty($profileModule) && ModUtil::available($profileModule)) { $links .= "<a href=\"" . DataUtil::formatForDisplay(ModUtil::url($profileModule, 'user', 'view')) . '">' . __('Your Account') . "</a> {$seperator} "; } else { $links .= "<a href=\"" . DataUtil::formatForDisplay(ModUtil::url('ZikulaUsersModule', 'user', 'index')) . '">' . __('Your Account') . "</a> {$seperator} "; } $links .= "<a href=\"" . DataUtil::formatForDisplay(ModUtil::url('ZikulaUsersModule', 'user', 'logout')) . '">' . __('Log out') . "</a> {$end}"; } else { $links = "{$start} <a href=\"" . DataUtil::formatForDisplay(ModUtil::url('ZikulaUsersModule', 'user', 'register')) . '">' . __('Register new account') . "</a> {$seperator} " . "<a href=\"" . DataUtil::formatForDisplay(ModUtil::url('ZikulaUsersModule', 'user', 'login')) . '">' . __('Login') . "</a> {$end}"; } return DataUtil::formatForDisplayHTML($links); }
private function sendEmailToAdmin(Request $request, $admin) { $url = $request->getSchemeAndHttpHost() . $request->getBasePath(); $body = <<<EOF <html> <head></head> <body> <h1>Hi {$admin['uname']}!</h1> <p>Zikula has been successfully installed at <a href="{$url}">{$url}</a>. If you have further questions, visit <a href="http://zikula.org">zikula.org</a></p> </body> EOF; $message = \Swift_Message::newInstance()->setSubject(__('Zikula installation completed!'))->setFrom(\System::getVar('adminmail'))->setTo($admin['email'])->setBody($body)->setContentType('text/html'); /** * @var Swift_Mailer $mailer */ $mailer = $this->container->get('mailer'); return $mailer->send($message); }