/** * smarty_function_required */ function smarty_function_required($pParams, &$gBitSmarty) { $gBitSmarty->loadPlugin('smarty_function_biticon'); $biticon = array('ipackage' => 'icons', 'iname' => 'emblem-important', 'iexplain' => 'Required'); $ret = smarty_function_biticon($biticon, $gBitSmarty); if (!empty($pParams['legend'])) { $ret = "<p>{$ret} " . tra("Elements marked with this symbol are required.") . "</p>"; } return $ret; }
function smileys_filter(&$pData, &$pFilterHash) { global $gBitSystem, $gBitSmarty; if ($gBitSystem->isPackageActive('smileys')) { preg_match_all("/\\(:([^:]+):\\)/", $pData, $smileys); $smileys[0] = array_unique($smileys[0]); $smileys[1] = array_unique($smileys[1]); if (!empty($smileys[1])) { $gBitSmarty->loadPlugin('smarty_function_biticon'); foreach ($smileys[1] as $key => $smiley) { $biticon = array('ipackage' => 'smileys', 'iname' => $smiley, 'iexplain' => $smiley, 'iforce' => 'icon'); $pData = preg_replace("/" . preg_quote($smileys[0][$key]) . "/", smarty_function_biticon($biticon, $gBitSmarty), $pData); } } } }
function data_biticon($pData, $pParams) { global $gBitSmarty; $ret = tra('Please provide an icon name as iname parameter. You can <a href="' . THEMES_PKG_URL . 'icon_browser.php">select icons here</a>.'); if (!empty($pParams['iname'])) { $gBitSmarty->loadPlugin('smarty_function_biticon'); // sanitise biticon parameters before they are passed to the function $biticon['iname'] = $pParams['iname']; $biticon['ipackage'] = !empty($pParams['ipackage']) ? $pParams['ipackage'] : 'icons'; $biticon['iexplain'] = !empty($pParams['iexplain']) ? $pParams['iexplain'] : 'icon'; $biticon['ipath'] = !empty($pParams['ipath']) ? $pParams['ipath'] : ''; $ret = smarty_function_biticon($biticon, $gBitSmarty); $wrapper = liberty_plugins_wrapper_style($pParams, FALSE); if (!empty($wrapper['style'])) { $ret = '<' . $wrapper['wrapper'] . ' class="' . (!empty($wrapper['class']) ? $wrapper['class'] : "biticon-plugin") . '" style="' . $wrapper['style'] . '">' . $ret . '</' . $wrapper['wrapper'] . '>'; } } return $ret; }
function backtotop_postparsefilter(&$pData, &$pFilterHash) { global $gBitSmarty; if (preg_match("/\\{(backtotop[^\\}]*)\\}/i", $pData, $backtotop)) { // remove {backtotop} from page $pData = preg_replace('#(<p>)?' . preg_quote($backtotop[0], '#') . '(</p>)?(\\s*<[Bb][Rr]\\s*/?>)?#', '', $pData); // default values $params['min'] = 1; $params['max'] = 6; $params = array_merge($params, parse_xml_attributes($backtotop[1])); $gBitSmarty->loadPlugin('smarty_function_biticon'); $biticon = array('ipackage' => 'icons', 'iname' => 'go-top', 'iexplain' => 'Back to top'); // get all headers into an array preg_match_all("/<h(\\d[^>]*)>.*?<\\/h\\d>/i", $pData, $headers); $link = '<a class="backtotop" href="#content">' . smarty_function_biticon($biticon, $gBitSmarty) . '</a>'; foreach ($headers[0] as $key => $header) { if ($headers[1][$key] >= $params['min'] && $headers[1][$key] <= $params['max']) { $pData = str_replace($header, $link . $header, $pData); } } $pData .= $link; } }
/** * smarty_function_jspopup * * @param array $pParams hash of options * @param srting $pParams[href] link the popup should open * @param srting $pParams[title] title of the link * @param srting $pParams[img] source of an image that is to be displayed instead of the title * @param srting $pParams[href] * @param srting $pParams[href] * @param array $gBitSmarty * @access public * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure */ function smarty_function_jspopup($pParams, &$gBitSmarty) { global $gBitThemes; $ret = ''; if (empty($pParams['href'])) { return 'assign: missing "href" parameter'; } if (empty($pParams['title'])) { return 'assign: missing "title" parameter'; } else { $title = empty($pParams['notra']) ? $pParams['title'] : tra($pParams['title']); } if (empty($pParams['text'])) { $text = $title; } else { $text = empty($pParams['notra']) ? $pParams['text'] : tra($pParams['text']); // remove it from the hash since later the params are looped over for to formulate the a tag unset($pParams['text']); } $optionHash = array('type', 'width', 'height', 'gutsonly', 'img'); foreach ($pParams as $param => $val) { if (!in_array($param, $optionHash)) { if ($param == 'title') { $guts .= ' ' . $param . '="' . tra('This will open a new window: ') . $title . '"'; } elseif ($param == 'href' && $gBitThemes->isJavascriptEnabled()) { $guts .= ' ' . $param . '="javascript:void(0)"'; } else { $guts .= ' ' . $param . '="' . $val . '"'; } } } if (!empty($pParams['ibiticon'])) { $gBitSmarty->loadPlugin('smarty_function_biticon'); $tmp = explode('/', $pParams['ibiticon']); $ibiticon = array('ipackage' => $tmp[0], 'iname' => $tmp[1], 'iexplain' => $title); if (!empty($pParams['iforce'])) { $ibiticon['iforce'] = $pParams['iforce']; } $img = smarty_function_biticon($ibiticon, $gBitSmarty); } if (!empty($pParams['img'])) { $img_size = NULL; $file = str_replace('//', '/', BIT_BASE_PATH . str_replace(BIT_ROOT_URI, '', urldecode($pParams['img']))); if (is_file($file)) { if ($imgSizeHash = @getimagesize($file)) { $img_size = $imgSizeHash[3]; } } $img = '<img src="' . $pParams['img'] . '" alt="' . $title . '" title="' . $title . '" ' . $img_size . ' />'; } if (!empty($pParams['type']) && $pParams['type'] == 'fullscreen') { $js = 'BitBase.popUpWin(\'' . $pParams['href'] . '\',\'fullScreen\');'; } else { $js = 'BitBase.popUpWin(\'' . $pParams['href'] . '\',\'standard\',' . (!empty($pParams['width']) ? $pParams['width'] : 600) . ',' . (!empty($pParams['height']) ? $pParams['height'] : 400) . ');'; } // deprecated slated for removal - onkeypress causes focus problems with browsers - if this is an ada issue get in touch -wjames5. // $guts .= ' onkeypress="'.$js.'" onclick="'.$js.'return false;"'; $guts .= ' onclick="' . $js . 'return false;"'; if (!empty($pParams['gutsonly'])) { return $guts; } else { return '<a ' . $guts . '>' . (!empty($img) ? $img : $text) . '</a>'; } }
/** * smarty_function_biticon * * @param array $pParams['ipath'] subdirectory within icon directory * @param array $pParams['iname'] name of the icon without extension * @param array $pParams['ipackage'] package the icon should be searched for - if it's part of an icon theme, this should be set to 'icons' * @param array $gBitSmarty Referenced object * @access public * @return final <img> */ function smarty_function_biticon($pParams, &$gBitSmarty, $pCheckSmall = FALSE) { global $gBitSystem, $gBitThemes, $gSniffer; // this is needed in case everything goes horribly wrong $copyParams = $pParams; // ensure that ipath has a leading and trailing slash if (!empty($pParams['ipath'])) { $pParams['ipath'] = str_replace("//", "/", "/" . $pParams['ipath'] . "/"); } else { $pParams['ipath'] = '/'; } // try to separate iname from ipath if we've been given some sloppy naming if (strstr($pParams['iname'], '/')) { $pParams['iname'] = $pParams['ipath'] . $pParams['iname']; $boom = explode('/', $pParams['iname']); $pParams['iname'] = array_pop($boom); $pParams['ipath'] = str_replace("//", "/", "/" . implode($boom, '/') . "/"); } // if we don't have an ipath yet, we will set it here if ($pParams['ipath'] == '/') { // iforce is generally only set in menus - we might need a parameter to identify menus more accurately if (!empty($pParams['ilocation'])) { if ($pParams['ilocation'] == 'menu') { $pParams['ipath'] .= 'small/'; $pParams['iforce'] = 'icon_text'; } elseif ($pParams['ilocation'] == 'quicktag') { $pParams['ipath'] .= 'small/'; $pParams['iforce'] = 'icon'; $pParams['iclass'] = 'quicktag icon'; } } else { if (!empty($pParams['isize'])) { $pParams['ipath'] .= $pParams['isize'] . '/'; } else { $pParams['ipath'] .= $gBitSystem->getConfig('site_icon_size', 'small') . '/'; } } } // this only happens when we haven't found the original icon we've been looking for if ($pCheckSmall) { $pParams['ipath'] = preg_replace("!/.*?/\$!", "/small/", $pParams['ipath']); } // we have one special case: pkg_icons don't have a size variant if (strstr($pParams['iname'], 'pkg_') && !strstr($pParams['ipath'], 'small')) { $pParams['ipath'] = preg_replace("!/.*?/\$!", "/", $pParams['ipath']); } // make sure ipackage is set correctly if (!empty($pParams['ipackage'])) { $pParams['ipackage'] = strtolower($pParams['ipackage']); } else { $pParams['ipackage'] = 'icons'; } // if the user is using a text-browser we force text instead of icons if ($gSniffer->_browser_info['browser'] == 'lx' || $gSniffer->_browser_info['browser'] == 'li') { $pParams['iforce'] = 'text'; } // get out of here as quickly as possible if we've already cached the icon information before if (($ret = biticon_read_cache($pParams)) && !(defined('TEMPLATE_DEBUG') && TEMPLATE_DEBUG == TRUE)) { return $ret; } // first deal with most common scenario: icon style ( a selected iconset from config/iconsets/ ) if ($pParams['ipackage'] == 'icons') { // get the current icon style // istyle is a private parameter!!! - only used on theme manager page for icon preview!!! // violators will be poked with soft cushions by the Cardinal himself!!! $icon_style = !empty($pParams['istyle']) ? $pParams['istyle'] : $gBitSystem->getConfig('site_icon_style', DEFAULT_ICON_STYLE); if (FALSE !== ($matchFile = biticon_first_match(CONFIG_PKG_PATH . "iconsets/{$icon_style}" . $pParams['ipath'], $pParams['iname']))) { return biticon_output($pParams, CONFIG_PKG_URL . "iconsets/{$icon_style}" . $pParams['ipath'] . $matchFile); } if ($icon_style != DEFAULT_ICON_STYLE && FALSE !== ($matchFile = biticon_first_match(CONFIG_PKG_PATH . "iconsets/" . DEFAULT_ICON_STYLE . $pParams['ipath'], $pParams['iname']))) { return biticon_output($pParams, CONFIG_PKG_URL . "iconsets/" . DEFAULT_ICON_STYLE . $pParams['ipath'] . $matchFile); } // if that didn't work, we'll try liberty $pParams['ipath'] = '/' . $gBitSystem->getConfig('site_icon_size', 'small') . '/'; $pParams['ipackage'] = 'liberty'; } // since package icons reside in <pkg>/icons/ we don't need the small/ subdir if (strstr("/small/", $pParams['ipath'])) { $pParams['ipath'] = str_replace("small/", "", $pParams['ipath']); $small = TRUE; } // first check themes/force if (FALSE !== ($matchFile = biticon_first_match(THEMES_PKG_PATH . "force/icons/" . $pParams['ipackage'] . $pParams['ipath'], $pParams['iname']))) { return biticon_output($pParams, BIT_ROOT_URL . "themes/force/icons/" . $pParams['ipackage'] . $pParams['ipath'] . $matchFile); } //if we have site styles, look there if (FALSE !== ($matchFile = biticon_first_match($gBitThemes->getStylePath() . '/icons/' . $pParams['ipackage'] . $pParams['ipath'], $pParams['iname']))) { return biticon_output($pParams, $gBitThemes->getStyleUrl() . '/icons/' . $pParams['ipackage'] . $pParams['ipath'] . $matchFile); } //Well, then lets look in the package location if (FALSE !== ($matchFile = biticon_first_match(constant(strtoupper($pParams['ipackage']) . '_PKG_PATH') . "icons" . $pParams['ipath'], $pParams['iname']))) { return biticon_output($pParams, constant(strtoupper($pParams['ipackage']) . '_PKG_URL') . "icons" . $pParams['ipath'] . $matchFile); } // Still didn't find it! Well lets output something (return FALSE if only the url is requested) if (isset($pParams['url'])) { return FALSE; } else { // if we were looking for the large icon, we'll try the whole kaboodle again, looking for the small icon if (empty($small) && !$pCheckSmall) { return smarty_function_biticon($copyParams, $gBitSmarty, TRUE); } else { return biticon_output($pParams, "broken.icon." . $pParams['ipackage'] . "/" . $pParams['ipath'] . $pParams['iname']); } } }
/** * Get the URL to the icon for the mime type passed in. This should probably check for files of multiple image types instead of just jpg * * @param string $pMimeType Mime type of the file * @param string $pExt Extension of the file - used to get backup mime icon * @access public * @return Full image HTML tag to mime icon */ public static function getMimeThumbnailURL($pMimeType, $pExt = NULL) { $ret = NULL; $parts = explode('/', $pMimeType); if (count($parts) > 1) { global $gBitSmarty; $gBitSmarty->loadPlugin('smarty_function_biticon'); $ext = strtolower($parts[1]); $biticon = array('ipackage' => 'liberty', 'ipath' => 'mime/', 'iname' => $ext, 'iexplain' => $ext, 'url' => 'only'); if (!($ret = smarty_function_biticon($biticon, $gBitSmarty))) { $biticon['iname'] = strtolower($pExt); if (!($ret = smarty_function_biticon($biticon, $gBitSmarty))) { $biticon['iname'] = 'generic'; $ret = smarty_function_biticon($biticon, $gBitSmarty); } } } return $ret; }
/** * Smarty {smartlink} function plugin * * Type: function<br> * Name: smartlink<br> * Input:<br> * - ititle (required) words that are displayed<br> * - iatitle (optional) alternative text for the link title (rollover, etc.) <br> * - ianchor (optional) set the anchor where the link should point to<br> * - isort (optional) name of the sort column without the orientation (e.g.: title)<br> * - isort_mode(optional) this can be used to manually pass the sort mode to smartlink<br> * overrides the value given in $_REQUEST['sort_mode'], which is the default<br> * - iorder (optional) if set to asc or desc, it sets the default sorting order of this particular column<br> * asc is default<br> * - idefault (optional) if set, it will highlight this link if no $isort_mode is given<br> * this should only be set once per sorting group since it represents the default sorting column<br> * - itra (optional) if present then don't translate<br> * - itype (optional) can be set to<br> * url --> outputs only url<br> * li --> outputs link as <li><a ... ></li><br> * - ionclick (optional) pass in any actions that should occur onclick<br> * - ibiticon (optional) if you want to display an icon instead of text use ibiticon<br> * format is: '<ipackage>/<iname>'<br> * e.g.: 'liberty/edit'<br> * - iforce (optional) pass iforce parameter through to biticon * - iurl (optional) pass in a full url * - ifile (optional) set the file where the link should point (default is the current file)<br> * - ipackage (optional) set the package the link should point to (default is the current package)<br> * - icontrol (optional) the hash sent out by postGetList() * - * (optional) anything else that gets added to the pile of items is appended using &$key=$val<br> * - ihash (optional) you can pass in all the above as an array called ihash or secondary * items common to all links<br> * Output: any kind of link. especially useful when it comes to links used to sort a table, due to the simplified syntax and loss of cumbersome if clauses * also useful if the you want to display an icon as link since smartlink takes biticon parameters<br> * Example - {smartlink ititle="Page Name" isort="title"}<br> * - {smartlink ititle="Page Name" isort="title" iorder="desc" idefault=1}<br> * setting iorder and idefault here, makes this link sort in a descending order by default (iorder)<br> * and it is highlighted when $isort_mode ( or $_REQUEST['sort_mode'] ) is not set (idefault)<br> * Note Be careful if ititle is generated dynamically since it is passed through tra() by default, use itra to override<br> */ function smarty_function_smartlink($params, &$gBitSmarty) { if (!empty($params['ihash'])) { $hash = array_merge($params['ihash'], $params); $hash['ihash'] = NULL; } else { // maybe params were passed in separately $hash =& $params; } if (!isset($hash['ititle'])) { return 'You need to supply "ititle" for {smartlink} to work.'; } // work out what the url is if (!empty($hash['iurl'])) { $url = $hash['iurl']; } elseif (!empty($hash['ifile'])) { if (!empty($hash['ipackage'])) { if ($hash['ipackage'] == 'root') { $url = BIT_ROOT_URL . $hash['ifile']; } else { $url = constant(strtoupper($hash['ipackage']) . '_PKG_URL') . $hash['ifile']; } } else { $url = constant(strtoupper(ACTIVE_PACKAGE) . '_PKG_URL') . $hash['ifile']; } } else { $url = $_SERVER['SCRIPT_NAME']; } $url_params = NULL; if (isset($hash['itra']) && !empty($hash['itra'])) { // present and non-zero value $ititle = $hash['ititle']; $iatitle = empty($hash['iatitle']) ? $ititle : $hash['iatitle']; } else { $ititle = tra($hash['ititle']); $iatitle = empty($hash['iatitle']) ? $ititle : tra($hash['iatitle']); } $atitle = 'title="' . $iatitle . '"'; // if isort is set, we need to deal with all the sorting stuff if (!empty($hash['isort'])) { $isort_mode = isset($hash['isort_mode']) ? $hash['isort_mode'] : isset($_REQUEST['sort_mode']) ? $_REQUEST['sort_mode'] : NULL; $sort_asc = $hash['isort'] . '_asc'; $sort_desc = $hash['isort'] . '_desc'; $atitle = 'title="' . tra('Sort by') . ": " . $iatitle . '"'; $url .= '?'; $url_params .= 'sort_mode='; // check if we have to highlight this link, when $isort_mode isn't set if (isset($hash['idefault']) && empty($isort_mode)) { $isort_mode .= $hash['isort'] . '_' . (isset($hash['iorder']) ? $hash['iorder'] : 'asc'); } // check if sort_mode has anything to do with our link if ($sort_asc == $isort_mode) { $sorticon = array('ipackage' => 'icons', 'iname' => 'icon-sort-up', 'iexplain' => 'ascending', 'iforce' => 'icon'); $url_params .= $sort_desc; } elseif ($sort_desc == $isort_mode) { $sorticon = array('ipackage' => 'icons', 'iname' => 'icon-sort-down', 'iexplain' => 'descending', 'iforce' => 'icon'); $url_params .= $sort_asc; } else { $url_params .= $hash['isort'] . '_' . (isset($hash['iorder']) ? $hash['iorder'] : 'asc'); } } $ignore = array('iatitle', 'icontrol', 'isort', 'ianchor', 'isort_mode', 'iorder', 'ititle', 'idefault', 'ifile', 'ipackage', 'itype', 'iurl', 'ionclick', 'ibiticon', 'iforce', 'itra'); // append any other paramters that were passed in foreach ($hash as $key => $val) { if (!empty($val) && !in_array($key, $ignore)) { // normally the key is a string if (!is_array($val)) { $url_params .= empty($url_params) ? '?' : '&'; $url_params .= $key . "=" . $val; // but sometimes it can be an array } else { foreach ($val as $v) { $url_params .= empty($url_params) ? '?' : '&'; $url_params .= $key . "[]=" . $v; } } } } if (!empty($hash['icontrol']) && is_array($hash['icontrol'])) { $sep = empty($url_params) ? '?' : '&'; $url_params .= !empty($hash['icontrol']['current_page']) ? $sep . 'list_page=' . $hash['icontrol']['current_page'] : ''; $sep = empty($url_params) ? '?' : '&'; $url_params .= !empty($hash['icontrol']['find']) ? $sep . 'find=' . $hash['icontrol']['find'] : ''; if (!empty($hash['icontrol']['parameters']) && is_array($hash['icontrol']['parameters'])) { foreach ($hash['icontrol']['parameters'] as $key => $value) { if (!empty($value)) { $sep = empty($url_params) ? '?' : '&'; $url_params .= $sep . $key . "=" . $value; } } } } // encode quote marks so we not break href="" construction $url_params = preg_replace('/"/', '%22', $url_params); if (isset($hash['itype']) && $hash['itype'] == 'url') { $ret = $url . $url_params; } else { $ret = '<a class="icon" ' . $atitle . ' ' . (!empty($params['ionclick']) ? 'onclick="' . $params['ionclick'] . '" ' : '') . 'href="' . $url . $url_params . (!empty($params['ianchor']) ? '#' . $params['ianchor'] : '') . '">'; // if we want to display an icon instead of text, do that if (isset($hash['booticon'])) { if (!empty($tmp[2])) { $tmp[1] .= "/" . $tmp[2]; } $booticon = array('iname' => $hash['booticon'], 'iexplain' => $hash['ititle']); if (!empty($hash['iforce'])) { $booticon['iforce'] = $hash['iforce']; } $ret .= smarty_function_booticon($booticon, $gBitSmarty); } elseif (isset($hash['ibiticon'])) { $tmp = explode('/', $hash['ibiticon']); if (!empty($tmp[2])) { $tmp[1] .= "/" . $tmp[2]; } $ibiticon = array('ipackage' => $tmp[0], 'iname' => $tmp[1], 'iexplain' => $hash['ititle']); if (!empty($hash['iforce'])) { $ibiticon['iforce'] = $hash['iforce']; } $ret .= smarty_function_biticon($ibiticon, $gBitSmarty); } else { $ret .= $ititle; } if (isset($sorticon)) { $ret .= ' ' . smarty_function_booticon($sorticon, $gBitSmarty); } $ret .= '</a>'; } if (isset($params['itype']) && $params['itype'] == 'li') { $ret = '<li>' . $ret . '</li>'; } return $ret; }
$gBitSmarty->assign('contentPerms', $contentPerms); // if we've called this page as part of an ajax update, we output the appropriate data if ($gBitThemes->isAjaxRequest()) { if (count($contentPerms['roles'] <= 10)) { $size = 'large/'; } else { $size = 'small/'; } $gid = $_REQUEST['role_id']; $perm = $_REQUEST['perm']; // we're applying the same logic as in the template. if you fix / change anything here, please update the template as well. $biticon = array('ipackage' => 'icons', 'iname' => $size . 'media-playback-stop', 'iexplain' => '', 'iforce' => 'icon'); $action = 'assign'; if (!empty($contentPerms['roles'][$gid]['perms'][$perm])) { $biticon['iname'] = $size . 'dialog-ok'; if (!empty($contentPerms['assigned'][$gid][$perm])) { $assigned = $contentPerms['assigned'][$gid][$perm]; $biticon['iname'] = $size . 'list-add'; $action = 'negate'; } if (!empty($assigned['is_revoked'])) { $biticon['iname'] = $size . 'list-remove'; $action = 'remove'; } } $gBitSmarty->loadPlugin('smarty_function_biticon'); $ret = '<a title="' . $contentPerms['roles'][$gid]['role_name'] . " :: " . $perm . '" ' . 'href="javascript:void(0);" onclick="BitAjax.updater(' . "'{$perm}{$gid}', " . "'" . LIBERTY_PKG_URL . "content_role_permissions.php', " . "'action={$action}&content_id={$gContent->mContentId}&perm={$perm}&role_id={$gid}'" . ')">' . smarty_function_biticon($biticon, $gBitSmarty) . '</a>'; echo $ret; die; } $gBitSystem->display('bitpackage:liberty/content_role_permissions.tpl', tra('Content Permissions'), array('display_mode' => 'display'));
/** * Smarty {formhelp} function plugin * * Type: function * Name: formhelp * Input: * - note (optional) words that are displayed, can also be an array, where: 'key: value'<br /> is printed * only displayed if site_form_help is enabled * - link (optional) provide a link to an internal page (avoids the problem with links being inerpreted * prematurely by the tra() function * <package>/<path to file>/<title> * - package (optional) creates a page to 'Package'.ucfirst( $package ) and takes precedence over $page, should both be set. * only dispalyed if help is enabled * - install (optional) used for packages that require a separate installation * passed in as an array: * package => name of package to be installed * file => path to installation file e.g.: admin/install.php * - page (optional) page name on bitweaver * only dispalyed if help is enabled * - force (optional) if set, it will always dipslay this entry regardless of the feature settings */ function smarty_function_formhelp($pParams, &$gBitSmarty) { $atts = $ret_note = $ret_page = $ret_link = $ret_install = ''; if (!empty($pParams['hash'])) { $hash =& $pParams['hash']; } else { // maybe params were passed in separately $hash =& $pParams; } // we need to do some hash modification if we're in the installer if (!empty($hash['is_installer'])) { if (!empty($hash['note']['upgrade'])) { $hash['note']['version'] = $hash['note']['upgrade']; unset($hash['note']['upgrade']); } } foreach ($hash as $key => $val) { switch ($key) { case 'note': case 'warning': case 'link': case 'page': $rawHash[$key] = $val; break; case 'label': case 'package': case 'install': case 'force': ${$key} = $val; break; default: if ($val) { $atts .= $key . '="' . $val . '" '; } break; } } if (!empty($package)) { $rawHash['page'] = ucfirst($package) . 'Package'; } // if link was passed in as a string, convert it into an array if (!empty($rawHash['link']) && is_string($rawHash['link'])) { $l = explode('/', $rawHash['link']); unset($rawHash['link']); // package is first, title last, and all remaining elements file (can be 'foo/bar.php' as well) $rawHash['link']['package'] = array_shift($l); $rawHash['link']['title'] = array_pop($l); $rawHash['link']['file'] = implode('/', $l); } global $gBitSystem; if ($gBitSystem->isFeatureActive('site_online_help') || $gBitSystem->isFeatureActive('site_form_help') || $force == 'y') { if (!empty($rawHash)) { if (!empty($rawHash['page']) && ($gBitSystem->isFeatureActive('site_online_help') || $force == 'y')) { $ret_page = '<strong>' . tra('Online help') . '</strong>: <a class=\'external\' href=\'http://doc.bitweaver.org/wiki/index.php?page=' . $rawHash['page'] . '\'>' . $rawHash['page'] . '</a><br />'; } if (!empty($rawHash['link']) && ($gBitSystem->isFeatureActive('site_online_help') || $force == 'y')) { if (is_array($rawHash['link'])) { $ret_link = '<strong>' . tra('IntraLink') . '</strong>: '; $ret_link .= '<a href=\''; $ret_link .= constant(strtoupper($rawHash['link']['package']) . '_PKG_URL') . $rawHash['link']['file']; $ret_link .= '\'>' . tra($rawHash['link']['title']) . '</a>'; } } if (!empty($rawHash['note']) && $gBitSystem->isFeatureActive('site_form_help') || !empty($force) && !empty($rawHash['note'])) { if (is_array($rawHash['note'])) { foreach ($rawHash['note'] as $name => $value) { if ($name == 'install') { $ret_install = '<strong>' . tra('Install') . '</strong>: ' . tra('To use this package, you will first have to run the package specific installer') . ': '; $ret_install .= '<a href=\''; $ret_install .= constant(strtoupper($value['package']) . '_PKG_URL') . $value['file']; $ret_install .= '\'>' . ucfirst($value['package']) . '</a>'; } else { $ret_note .= '<strong>' . ucfirst(tra($name)) . '</strong>: ' . tra($value) . '<br />'; } } } else { $ret_note .= tra($rawHash['note']) . '<br />'; } } if (!empty($rawHash['warning'])) { $ret_note .= '<span class="warning">' . tra($rawHash['warning']) . '</span><br />'; } // join all the output content into one string $content = $ret_note . $ret_page . $ret_link . $ret_install; $html = ''; // using the overlib popup system if (!empty($content)) { if ($gBitSystem->isFeatureActive('site_help_popup')) { $gBitSmarty->loadPlugin('smarty_modifier_popup'); $gBitSmarty->loadPlugin('smarty_function_biticon'); $gBitSmarty->assign('title', tra('Extended Help')); $gBitSmarty->assign('content', $content); $gBitSmarty->assign('closebutton', TRUE); $text = $gBitSmarty->fetch('bitpackage:kernel/popup_box.tpl'); $text = preg_replace('/"/', "'", $text); $popup = array('trigger' => 'onclick', 'text' => $text, 'fullhtml' => '1', 'sticky' => '1', 'timeout' => '8000'); $biticon = array('ipackage' => 'icons', 'iname' => 'dialog-information', 'iforce' => 'icon', 'iexplain' => 'Extended Help'); $html .= ' <span class="formhelppopup" ' . $atts . '> '; $html .= '<a ' . smarty_function_popup($popup, $gBitSmarty) . '>'; $html .= smarty_function_biticon($biticon, $gBitSmarty); $html .= '</a>'; $html .= '</span>'; } else { $html .= '<span class="help-block" ' . $atts . '>' . $content . '</span>'; } } return $html; } } }