Example #1
0
 /**
  * Render the links into a list and return html.
  * @return string
  */
 private function renderFootnotes()
 {
     $text = '';
     if (!empty($this->links)) {
         $text .= '<div><strong>' . __('Links') . '</strong>';
         $text .= '<ol>';
         $this->links = array_unique($this->links);
         foreach ($this->links as $key => $link) {
             // check for an e-mail address
             if (preg_match("/^([a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,4}\$/i", $link)) {
                 $linkText = $link;
                 $link = 'mailto:' . $link;
             } else {
                 $linkText = $link;
             }
             $linkText = \DataUtil::formatForDisplay($linkText);
             $link = \DataUtil::formatForDisplay($link);
             // output link
             $text .= '<li><a class="print-normal" href="' . $link . '">' . $linkText . '</a></li>' . "\n";
         }
         $text .= '</ol>';
         $text .= '</div>';
     }
     return $text;
 }
 public static function calcularPercentilMargens($imc, $sexo, $nascimento)
 {
     $curva = new Curva();
     // Margens dos percentis baseado no cálculo inicial.
     $margemIMCInferior = $imc - MARGEM_LIMITE_PERCENTIL;
     $margemIMCSuperior = $imc + MARGEM_LIMITE_PERCENTIL;
     // Valores crescentes e decrescentes do IMC.
     $imcDecrescente = $imc;
     $imcCrescente = $imc;
     $idadeMeses = DataUtil::calcularIdadeMeses($nascimento);
     $db = new DbHandler();
     // Verificação do percentil inferior.
     $percentilInferior = NULL;
     while (empty($percentilInferior) && $imcDecrescente >= $margemIMCInferior) {
         // Decrescer gradativamente os valores do IMC na escala.
         $imcDecrescente = $imcDecrescente - ESCALA_IMC_PERCENTIL;
         $percentilInferior = $db->selecionarPercentil($imcDecrescente, $sexo, $idadeMeses);
     }
     $curva->setPercentilInferior($percentilInferior);
     // Verificação do percentil superior.
     $percentilSuperior = NULL;
     while (empty($percentilSuperior) && $imcCrescente <= $margemIMCSuperior) {
         // Crescer gradativamente os valores do IMC na escala.
         $imcCrescente = $imcCrescente + ESCALA_IMC_PERCENTIL;
         $percentilSuperior = $db->selecionarPercentil($imcCrescente, $sexo, $idadeMeses);
     }
     $curva->setPercentilSuperior($percentilSuperior);
     return $curva;
 }
/**
 * 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;
    }
}
Example #4
0
 /**
  * Utility method for managing view templates.
  *
  * @param Zikula_View $view       Reference to view object.
  * @param string      $type       Current type (admin, user, ...).
  * @param string      $objectType Name of treated entity type.
  * @param string      $func       Current function (main, view, ...).
  * @param array       $args       Additional arguments.
  *
  * @return mixed Output.
  */
 public static function processTemplate($view, $type, $objectType, $func, $args = array())
 {
     // create the base template name
     $template = DataUtil::formatForOS($type . '/' . $objectType . '/' . $func);
     // check for template extension
     $templateExtension = self::determineExtension($view, $type, $objectType, $func, $args);
     // check whether a special template is used
     $tpl = isset($args['tpl']) && !empty($args['tpl']) ? $args['tpl'] : FormUtil::getPassedValue('tpl', '', 'GETPOST', FILTER_SANITIZE_STRING);
     if (!empty($tpl) && $view->template_exists($template . '_' . DataUtil::formatForOS($tpl) . '.' . $templateExtension)) {
         $template .= '_' . DataUtil::formatForOS($tpl);
     }
     $template .= '.' . $templateExtension;
     // look whether we need output with or without the theme
     $raw = (bool) (isset($args['raw']) && !empty($args['raw'])) ? $args['raw'] : FormUtil::getPassedValue('raw', false, 'GETPOST', FILTER_VALIDATE_BOOLEAN);
     if (!$raw && in_array($templateExtension, array('csv', 'rss', 'atom', 'xml', 'pdf', 'vcard', 'ical', 'json'))) {
         $raw = true;
     }
     if ($raw == true) {
         // standalone output
         if ($templateExtension == 'pdf') {
             return self::processPdf($view, $template);
         } else {
             $view->display($template);
         }
         System::shutDown();
     }
     // normal output
     return $view->fetch($template);
 }
Example #5
0
 /**
  * called near end of loader() before template is fetched
  * @return array 
  */
 public static function addParameters()
 {
     // get plugins for tinymce
     $tinymce_listplugins = ModUtil::getVar('moduleplugin.scribite.tinymce', 'activeplugins');
     $tinymce_buttonmap = array('paste' => 'pastetext,pasteword,selectall', 'insertdatetime' => 'insertdate,inserttime', 'table' => 'tablecontrols,table,row_props,cell_props,delete_col,delete_row,col_after,col_before,row_after,row_before,split_cells,merge_cells', 'directionality' => 'ltr,rtl', 'layer' => 'moveforward,movebackward,absolute,insertlayer', 'save' => 'save,cancel', 'style' => 'styleprops', 'xhtmlxtras' => 'cite,abbr,acronym,ins,del,attribs', 'searchreplace' => 'search,replace');
     if (is_array($tinymce_listplugins)) {
         // Buttons/controls: http://www.tinymce.com/wiki.php/Buttons/controls
         // We have some plugins with the button name same as plugin name
         // and a few plugins with custom button names, so we have to check the mapping array.
         $tinymce_buttons = array();
         foreach ($tinymce_listplugins as $tinymce_button) {
             if (array_key_exists($tinymce_button, $tinymce_buttonmap)) {
                 $tinymce_buttons = array_merge($tinymce_buttons, explode(",", $tinymce_buttonmap[$tinymce_button]));
             } else {
                 $tinymce_buttons[] = $tinymce_button;
             }
         }
         // TODO: I really would like to split this into multiple row, but I do not know how
         //    $tinymce_buttons_splitted = array_chunk($tinymce_buttons, 20);
         //    foreach ($tinymce_buttons_splitted as $key => $tinymce_buttonsrow) {
         //        $tinymce_buttonsrows[] = DataUtil::formatForDisplay(implode(',', $tinymce_buttonsrow));
         //    }
         $tinymce_buttons = DataUtil::formatForDisplay(implode(',', $tinymce_buttons));
         return array('buttons' => $tinymce_buttons);
     }
     return array('buttons' => '');
 }
Example #6
0
 /**
  * include a template file - in the current template (transparently)
  * @param string file | path to the template file - relative from view/
  */
 protected function tagInclude($attrs, $view)
 {
     $include = new View($attrs->file);
     $result = $include->render($view->data);
     $view->data = DataUtil::merge($view->data, $include->data);
     return $result;
 }
Example #7
0
/**
 * Content needle
 * @param $args['nid'] needle id
 * @return array()
 */
function content_needleapi_content($args)
{
    $dom = ZLanguage::getModuleDomain('Content');
    // Get arguments from argument array
    $nid = $args['nid'];
    unset($args);
    // cache the results
    static $cache;
    if (!isset($cache)) {
        $cache = array();
    }
    if (!empty($nid)) {
        if (!isset($cache[$nid])) {
            // not in cache array
            if (ModUtil::available('Content')) {
                $contentpage = ModUtil::apiFunc('Content', 'Page', 'getPage', array('id' => $nid, 'includeContent' => false));
                if ($contentpage != false) {
                    $cache[$nid] = '<a href="' . DataUtil::formatForDisplay(ModUtil::url('Content', 'user', 'view', array('pid' => $nid))) . '" title="' . DataUtil::formatForDisplay($contentpage['title']) . '">' . DataUtil::formatForDisplay($contentpage['title']) . '</a>';
                } else {
                    $cache[$nid] = '<em>' . DataUtil::formatForDisplay(__('Unknown id', $dom)) . '</em>';
                }
            } else {
                $cache[$nid] = '<em>' . DataUtil::formatForDisplay(__('Content not available', $dom)) . '</em>';
            }
        }
        $result = $cache[$nid];
    } else {
        $result = '<em>' . DataUtil::formatForDisplay(__('No needle id', $dom)) . '</em>';
    }
    return $result;
}
Example #8
0
 /**
  * transform text to images
  * 
  * @param string $args['text']
  */
 function transform($args)
 {
     $text = $args['text'];
     // check the user agent - if it is a bot, return immediately
     $robotslist = array("ia_archiver", "googlebot", "mediapartners-google", "yahoo!", "msnbot", "jeeves", "lycos");
     $useragent = System::serverGetVar('HTTP_USER_AGENT');
     for ($cnt = 0; $cnt < count($robotslist); $cnt++) {
         if (strpos(strtolower($useragent), $robotslist[$cnt]) !== false) {
             return $text;
         }
     }
     $smilies = $this->getVar('smilie_array');
     $remove_inactive = $this->getVar('remove_inactive');
     if (is_array($smilies) && count($smilies) > 0) {
         // sort smilies, see http://code.zikula.org/BBSmile/ticket/1
         uasort($smilies, array($this, 'cmp_smiliesort'));
         $imagepath = System::getBaseUrl() . DataUtil::formatForOS($this->getVar('smiliepath'));
         $imagepath_auto = System::getBaseUrl() . DataUtil::formatForOS($this->getVar('smiliepath_auto'));
         $auto_active = $this->getVar('activate_auto');
         // pad it with a space so we can distinguish between FALSE and matching the 1st char (index 0).
         // This is important!
         $text = ' ' . $text;
         foreach ($smilies as $smilie) {
             // check if smilie is active
             if ($smilie['active'] == 1) {
                 // check if alt is a define
                 $smilie['alt'] = defined($smilie['alt']) ? constant($smilie['alt']) : $smilie['alt'];
                 if ($smilie['type'] == 0) {
                     $text = str_replace($smilie['short'], ' <img src="' . $imagepath . '/' . $smilie['imgsrc'] . '" alt="' . $smilie['alt'] . '" /> ', $text);
                 } else {
                     if ($auto_active == 1) {
                         $text = str_replace($smilie['short'], ' <img src="' . $imagepath_auto . '/' . $smilie['imgsrc'] . '" alt="' . $smilie['alt'] . '" /> ', $text);
                     }
                 }
                 if (!empty($smilie['alias'])) {
                     $aliases = explode(",", trim($smilie['alias']));
                     if (is_array($aliases) && count($aliases) > 0) {
                         foreach ($aliases as $alias) {
                             if ($smilie['type'] == 0) {
                                 $text = str_replace($alias, ' <img src="' . $imagepath . '/' . $smilie['imgsrc'] . '" alt="' . $smilie['alt'] . '" /> ', $text);
                             } else {
                                 if ($auto_active == 1) {
                                     $text = str_replace($alias, ' <img src="' . $imagepath_auto . '/' . $smilie['imgsrc'] . '" alt="' . $smilie['alt'] . '" /> ', $text);
                                 }
                             }
                         }
                     }
                 }
             } else {
                 // End of if smilie is active
                 $text = str_replace($smilie['short'], '', $text);
             }
         }
         // foreach
         // Remove our padding from the string..
         $text = substr($text, 1);
     }
     // End of if smilies is array and not empty
     return $text;
 }
function smarty_function_mediashare_breadcrumb($params, &$smarty)
{
    $dom = ZLanguage::getModuleDomain('mediashare');
    if (!isset($params['albumId'])) {
        $smarty->trigger_error(__f('Missing [%1$s] in \'%2$s\'', array('albumId', 'mediashare_breadcrumb'), $dom));
        return false;
    }
    $mode = isset($params['mode']) ? $params['mode'] : 'view';
    $breadcrumb = pnModAPIFunc('mediashare', 'user', 'getAlbumBreadcrumb', array('albumId' => (int) $params['albumId']));
    if ($breadcrumb === false) {
        $smarty->trigger_error(LogUtil::getErrorMessagesText());
        return false;
    }
    $urlType = $mode == 'edit' ? 'edit' : 'user';
    $url = pnModUrl('mediashare', $urlType, 'view', array('aid' => 0));
    $result = "<div class=\"mediashare-breadcrumb\">";
    $first = true;
    foreach ($breadcrumb as $album) {
        $url = DataUtil::formatForDisplay(pnModUrl('mediashare', $urlType, 'view', array('aid' => $album['id'])));
        $result .= ($first ? '' : ' &raquo; ') . "<a href=\"{$url}\">" . htmlspecialchars($album['title']) . "</a>";
        $first = false;
    }
    $result .= "</div>";
    if (isset($params['assign'])) {
        $smarty->assign($params['assign'], $result);
    }
    return $result;
}
Example #10
0
/**
 * Zikula_View function to get module variable
 *
 * This function obtains a module-specific variable from the Zikula system.
 *
 * Note that the results should be handled by the safetext or the safehtml
 * modifier before being displayed.
 *
 *
 * Available parameters:
 *   - module:   The well-known name of a module from which to obtain the variable
 *   - name:     The name of the module variable to obtain
 *   - assign:   If set, the results are assigned to the corresponding variable instead of printed out
 *   - html:     If true then result will be treated as html content
 *   - default:  The default value to return if the config variable is not set
 *
 * Example
 *   {modgetvar module='Example' name='foobar' assign='foobarOfExample'}
 *
 * @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 module variable.
 */
function smarty_function_modgetvar($params, Zikula_View $view)
{
    $assign = isset($params['assign']) ? $params['assign'] : null;
    $default = isset($params['default']) ? $params['default'] : null;
    $module = isset($params['module']) ? $params['module'] : null;
    $html = isset($params['html']) ? (bool) $params['html'] : false;
    $name = isset($params['name']) ? $params['name'] : null;
    if (!$module) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('modgetvar', 'module')));
        return false;
    }
    if (!$name && !$assign) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('modgetvar', 'name')));
        return false;
    }
    if (!$name) {
        $result = ModUtil::getVar($module);
    } else {
        $result = ModUtil::getVar($module, $name, $default);
    }
    if ($assign) {
        $view->assign($assign, $result);
    } else {
        if ($html) {
            return DataUtil::formatForDisplayHTML($result);
        } else {
            return DataUtil::formatForDisplay($result);
        }
    }
}
/**
 * Smarty function to display a link to the next post
 *
 * Example
 * <!--[nextpostlink sid=$info.sid layout='%link% <span class="news_metanav">&raquo;</span>']-->
 *
 * @author Mark West
 * @since 20/10/03
 * @see function.nextpostlink.php::smarty_function_nextpostlink()
 * @param array $params All attributes passed to this function from the template
 * @param object &$smarty Reference to the Smarty object
 * @param integer $sid article id
 * @param string $layout HTML string in which to insert link
 * @return string the results of the module function
 */
function smarty_function_nextpostlink($params, &$smarty)
{
    if (!isset($params['sid'])) {
        // get the info template var
        $info = $smarty->get_template_vars('info');
        $params['sid'] = $info['sid'];
    }

    if (!isset($params['layout'])) {
        $params['layout'] = '%link% <span class="news_metanav">&raquo;</span>';
    }

    $article = ModUtil::apiFunc('News', 'user', 'getall',
                            array('query' => array(array('sid', '>', $params[sid])),
                                  'orderdir' => 'ASC',
                                  'numitems' => 1));

    if (!$article) {
        return;
    }

    $articlelink = '<a href="'.DataUtil::formatForDisplay(ModUtil::url('News', 'user', 'display', array('sid' => $article[0]['sid']))).'">'.DataUtil::formatForDisplay($article[0]['title']).'</a>';
    $articlelink = str_replace('%link%', $articlelink, $params['layout']);

    if (isset($params['assign'])) {
        $smarty->assign($params['assign'], $articlelink);
    } else {
        return $articlelink;
    }
}
Example #12
0
/**
 * Do the migration
 * 
 * With this function, the actual migration is done.
 * 
 * @return   boolean   true on sucessful migration, false else
 * @since    0.2
 */
function EZComments_migrateapi_pnFlashGames()
{
    // Security check
    if (!SecurityUtil::checkPermission('EZComments::', '::', ACCESS_ADMIN)) {
        return LogUtil::registerError('pnFlashGames comments migration: Not Admin');
    }
    // Get datbase setup
    $tables = DBUtil::getTables();
    $Commentstable = $tables['pnFlashGames_comments'];
    $Commentscolumn = $tables['pnFlashGames_comments_column'];
    $Usertable = $tables['users'];
    $Usercolumn = $tables['users_column'];
    $sql = "SELECT {$Commentscolumn['gid']},\n                   {$Commentscolumn['uname']},\n                   {$Commentscolumn['date']},\n                   {$Commentscolumn['comment']},\n                   {$Usercolumn['uid']}\n             FROM  {$Commentstable}\n         LEFT JOIN {$Usertable}\n                ON {$Commentscolumn['uname']} = {$Usercolumn['uname']}";
    $result = DBUtil::executeSQL($sql);
    if ($result == false) {
        return LogUtil::registerError('pnFlashGames migration: DB Error: ' . $sql . ' -- ' . mysql_error());
    }
    // loop through the old comments and insert them one by one into the DB
    $items = DBUtil::marshalObjects($result, array('gid', 'uname', 'date', 'comment', 'uid'));
    foreach ($items as $item) {
        // set the correct user id for anonymous users
        if (empty($item['uid'])) {
            $item['uid'] = 1;
        }
        $id = ModUtil::apiFunc('EZComments', 'user', 'create', array('mod' => 'pnFlashGames', 'objectid' => DataUtil::formatForStore($item['gid']), 'url' => ModUtil::url('pnFlashGames', 'user', 'display', array('id' => $item['gid'])), 'comment' => $item['comment'], 'subject' => '', 'uid' => $item['uid'], 'date' => $item['date']));
        if (!$id) {
            return LogUtil::registerError('pnFlashGames migration: Error creating comment');
        }
    }
    return LogUtil::registerStatus('pnFlashGames migration successful');
}
/**
 * Zikula_View function to display a drop down list of languages
 *
 * Available parameters:
 *   - assign:   If set, the results are assigned to the corresponding variable instead of printed out
 *   - name:     Name for the control
 *   - id:       ID for the control
 *   - selected: Selected value
 *   - installed: if set only show languages existing in languages folder
 *   - all:      show dummy entry '_ALL' on top of the list with empty value
 *
 * Example
 *   {html_select_languages name=language selected=en}
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the Zikula_View object.
 *
 * @deprecated smarty_function_html_select_locales()
 * @return string The value of the last status message posted, or void if no status message exists.
 */
function smarty_function_html_select_languages($params, Zikula_View $view)
{
    if (!isset($params['name']) || empty($params['name'])) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('html_select_languages', 'name')));
        return false;
    }
    require_once $view->_get_plugin_filepath('function', 'html_options');
    $params['output'] = array();
    $params['values'] = array();
    if (isset($params['all']) && $params['all']) {
        $params['values'][] = '';
        $params['output'][] = DataUtil::formatForDisplay(__('All'));
        unset($params['all']);
    }
    if (isset($params['installed']) && $params['installed']) {
        $languagelist = ZLanguage::getInstalledLanguageNames();
        unset($params['installed']);
    } else {
        $languagelist = ZLanguage::languageMap();
    }
    $params['output'] = array_merge($params['output'], DataUtil::formatForDisplay(array_values($languagelist)));
    $params['values'] = array_merge($params['values'], DataUtil::formatForDisplay(array_keys($languagelist)));
    $assign = isset($params['assign']) ? $params['assign'] : null;
    unset($params['assign']);
    $html_result = smarty_function_html_options($params, $view);
    if (!empty($assign)) {
        $view->assign($assign, $html_result);
    } else {
        return $html_result;
    }
}
Example #14
0
function mediashare_mediahandlerapi_getHandlerInfo($args)
{
    $dom = ZLanguage::getModuleDomain('mediashare');
    $mimeType = strtolower($args['mimeType']);
    $filename = strtolower($args['filename']);
    if (!empty($filename)) {
        $dotPos = strpos($filename, '.');
        if ($dotPos === false) {
            $fileType = '';
        } else {
            $fileType = substr($filename, $dotPos + 1);
        }
    } else {
        $fileType = '';
    }
    $pntable = pnDBGetTables();
    $handlersTable = $pntable['mediashare_mediahandlers'];
    $handlersColumn = $pntable['mediashare_mediahandlers_column'];
    $sql = "SELECT DISTINCT {$handlersColumn['handler']},\r\n                            {$handlersColumn['foundMimeType']},\r\n                            {$handlersColumn['foundFileType']}\r\n                       FROM {$handlersTable}\r\n                      WHERE {$handlersColumn['mimeType']} = '" . DataUtil::formatForStore($mimeType) . "'\r\n                         OR {$handlersColumn['fileType']} = '" . DataUtil::formatForStore($fileType) . "'\r\n\t\t\t\t\t\t\t\t\t\t\t\tAND {$handlersColumn['active']} =\t1 ";
    $result = DBUtil::executeSQL($sql);
    $errormsg = __f('Unable to locate media handler for \'%1$s\' (%2$s)', array($filename, $mimeType), $dom);
    if ($result === false) {
        return LogUtil::registerError(__f('Error in %1$s: %2$s.', array('mediahandlerapi.getHandlerInfo', $errormsg), $dom));
    }
    if (!$result) {
        return LogUtil::registerError($errormsg);
    }
    $colArray = array('handlerName', 'mimeType', 'fileType');
    $handler = DBUtil::marshallObjects($result, $colArray);
    return $handler[0];
}
Example #15
0
 /**
  * Load a file from the specified location in the file tree
  *
  * @param fileName    The name of the file to load
  * @param path        The path prefix to use (optional) (default=null)
  * @param exitOnError whether or not exit upon error (optional) (default=true)
  * @param returnVar   The variable to return from the sourced file (optional) (default=null)
  *
  * @return string The file which was loaded
  */
 public static function loadFile($fileName, $path = null, $exitOnError = true, $returnVar = null)
 {
     if (!$fileName) {
         return z_exit(__f("Error! Invalid file specification '%s'.", $fileName));
     }
     $file = null;
     if ($path) {
         $file = "{$path}/{$fileName}";
     } else {
         $file = $fileName;
     }
     $file = DataUtil::formatForOS($file);
     if (is_file($file) && is_readable($file)) {
         if (include_once $file) {
             if ($returnVar) {
                 return ${$returnVar};
             } else {
                 return $file;
             }
         }
     }
     if ($exitOnError) {
         return z_exit(__f("Error! Could not load the file '%s'.", $fileName));
     }
     return false;
 }
Example #16
0
 /**
  * Change the category a module belongs to by ajax.
  *
  * @return AjaxUtil::output Output to the calling ajax request is returned.
  *                          response is a string moduleid on sucess.
  */
 public function changeModuleCategory()
 {
     $this->checkAjaxToken();
     $this->throwForbiddenUnless(SecurityUtil::checkPermission('Admin::', '::', ACCESS_ADMIN));
     $moduleID = $this->request->getPost()->get('modid');
     $newParentCat = $this->request->getPost()->get('cat');
     //get info on the module
     $module = ModUtil::getInfo($moduleID);
     if (!$module) {
         //deal with couldnt get module info
         throw new Zikula_Exception_Fatal($this->__('Error! Could not get module name for id %s.'));
     }
     //get the module name
     $displayname = DataUtil::formatForDisplay($module['displayname']);
     $module = $module['name'];
     $oldcid = ModUtil::apiFunc('Admin', 'admin', 'getmodcategory', array('mid' => $moduleID));
     //move the module
     $result = ModUtil::apiFunc('Admin', 'admin', 'addmodtocategory', array('category' => $newParentCat, 'module' => $module));
     if (!$result) {
         throw new Zikula_Exception_Fatal($this->__('Error! Could not add module to module category.'));
     }
     $output = array();
     $output['response'] = $moduleID;
     $output['newParentCat'] = $newParentCat;
     $output['oldcid'] = $oldcid;
     $output['modulename'] = $displayname;
     $output['url'] = ModUtil::url($module, 'admin', 'main');
     return new Zikula_Response_Ajax($output);
 }
Example #17
0
/**
 * Smarty function to display footnotes caculated by earlier modifier
 *
 * Example
 *   {footnotes}
 *
 * @param       array       $params      All attributes passed to this function from the template
 * @param       object      $smarty     Reference to the Smarty object
 */
function smarty_function_footnotes($params, $smarty)
{
    // globalise the links array
    global $link_arr;
    $text = '';
    if (is_array($link_arr) && !empty($link_arr)) {
        $text .= '<ol>';
        $link_arr = array_unique($link_arr);
        foreach ($link_arr as $key => $link) {
            // check for an e-mail address
            if (preg_match("/^([a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,4}\$/i", $link)) {
                $linktext = $link;
                $link = 'mailto:' . $link;
                // append base URL for local links (not web links)
            } elseif (!preg_match("/^http:\\/\\//i", $link)) {
                $link = System::getBaseUrl() . $link;
                $linktext = $link;
            } else {
                $linktext = $link;
            }
            $linktext = DataUtil::formatForDisplay($linktext);
            $link = DataUtil::formatForDisplay($link);
            // output link
            $text .= '<li><a class="print-normal" href="' . $link . '">' . $linktext . '</a></li>' . "\n";
        }
        $text .= '</ol>';
    }
    if (isset($params['assign'])) {
        $smarty->assign($params['assign'], $text);
    } else {
        return $text;
    }
}
Example #18
0
 /**
  * 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);
 }
Example #19
0
    /**
     * Toggleblock.
     *
     * This function toggles active/inactive.
     *
     * @param bid int  id of block to toggle.
     *
     * @return mixed true or Ajax error
     */
    public function toggleblock()
    {
        $this->checkAjaxToken();
        $this->throwForbiddenUnless(SecurityUtil::checkPermission('Blocks::', '::', ACCESS_ADMIN));

        $bid = $this->request->request->get('bid', -1);

        if ($bid == -1) {
            throw new Zikula_Exception_Fatal($this->__('No block ID passed.'));
        }

        // read the block information
        $blockinfo = BlockUtil::getBlockInfo($bid);
        if ($blockinfo == false) {
            throw new Zikula_Exception_Fatal($this->__f('Error! Could not retrieve block information for block ID %s.', DataUtil::formatForDisplay($bid)));
        }

        if ($blockinfo['active'] == 1) {
            ModUtil::apiFunc('Blocks', 'admin', 'deactivate', array('bid' => $bid));
        } else {
            ModUtil::apiFunc('Blocks', 'admin', 'activate', array('bid' => $bid));
        }

        return new Zikula_Response_Ajax(array('bid' => $bid));
    }
Example #20
0
 /**
  * Returns the the HTML code of the content panel.
  *
  * @return string HTML
  */
 public function getPanelContent()
 {
     $rows = array();
     foreach ($this->_log as $log) {
         $hasFileAndLine = isset($log['errfile']) && $log['errfile'] && isset($log['errline']) && $log['errline'];
         $rows[] = '<tr class="DebugToolbarType' . $log['type'] . '">
                        <td class="DebugToolbarLogsType">' . $this->getImageForErrorType($log['type']) . ' ' . $this->errorTypeToString($log['type']) . '</td>
                        <td class="DebugToolbarLogsMessage">' . DataUtil::formatForDisplay($log['errstr']) . '</td>
                        <td class="DebugToolbarLogsFile">' . ($hasFileAndLine ? $log['errfile'] . ':' . $log['errline'] : '-') . '</td>
                    </tr>';
     }
     if (empty($rows)) {
         $rows[] = '<tr>
                        <td colspan="3">' . __('No items found.') . '</td>
                    </tr>';
     }
     return '<table class="DebugToolbarTable">
                 <tr>
                     <th class="DebugToolbarLogsType">' . __('Type') . '</th>
                     <th class="DebugToolbarLogsMessage">' . __('Message') . '</th>
                     <th class="DebugToolbarLogsFile">' . __('File: Line') . '</th>
                 </tr>
                 ' . implode(' ', $rows) . '
             </table>';
 }
Example #21
0
 /**
  * This function sets active/inactive status.
  *
  * @param eid
  *
  * @return mixed true or Ajax error
  */
 public function setstatus()
 {
     $this->checkAjaxToken();
     $this->throwForbiddenUnless(SecurityUtil::checkPermission('Ephemerides::', '::', ACCESS_ADMIN));
     $eid = $this->request->request->get('eid', 0);
     $status = $this->request->request->get('status', 0);
     $alert = '';
     if ($eid == 0) {
         $alert .= $this->__('No ID passed.');
     } else {
         $item = array('eid' => $eid, 'status' => $status);
         $res = DBUtil::updateObject($item, 'ephem', '', 'eid');
         if (!$res) {
             $alert .= $item['eid'] . ', ' . $this->__f('Could not change item, ID %s.', DataUtil::formatForDisplay($eid));
             if ($item['status']) {
                 $item['status'] = 0;
             } else {
                 $item['status'] = 1;
             }
         }
     }
     // get current status to return
     $item = ModUtil::apiFunc($this->name, 'user', 'get', array('eid' => $eid));
     if (!$item) {
         $alert .= $this->__f('Could not get data, ID %s.', DataUtil::formatForDisplay($eid));
     }
     return new Zikula_Response_Ajax(array('eid' => $eid, 'status' => $item['status'], 'alert' => $alert));
 }
Example #22
0
    public function initialize(Zikula_Form_View $view)
    {
        if (!SecurityUtil::checkPermission('Mailer::', '::', ACCESS_ADMIN)) {
            throw new Zikula_Exception_Forbidden(LogUtil::getErrorMsgPermission());
        }

        // assign the module mail agent types
        $view->assign('mailertypeItems', array(
            array('value' => 1, 'text' => DataUtil::formatForDisplay($this->__("Internal PHP `mail()` function"))),
            array('value' => 2, 'text' => DataUtil::formatForDisplay($this->__('Sendmail message transfer agent'))),
            array('value' => 3, 'text' => DataUtil::formatForDisplay($this->__('QMail message transfer agent'))),
            array('value' => 4, 'text' => DataUtil::formatForDisplay($this->__('SMTP mail transfer protocol'))),
            array('value' => 5, 'text' => DataUtil::formatForDisplay($this->__('Development/debug mode (Redirect e-mails to LogUtil)')))
        ));

        $view->assign('encodingItems', array(
            array('value' => '8bit', 'text' => '8bit'),
            array('value' => '7bit', 'text' => '7bit'),
            array('value' => 'binary', 'text' => 'binary'),
            array('value' => 'base64', 'text' => 'base64'),
            array('value' => 'quoted-printable', 'text' => 'quoted-printable')
        ));

        $view->assign('smtpsecuremethodItems', array(
            array('value' => '', 'text' => 'None'),
            array('value' => 'ssl', 'text' => 'SSL'),
            array('value' => 'tls', 'text' => 'TLS')
        ));

        // assign all module vars
        $this->view->assign($this->getVars());

        return true;
    }
Example #23
0
 /**
  * Search
  *
  * do the actual search and display the results
  *
  * @return output the search results
  */
 public function search($args)
 {
     if (!SecurityUtil::checkPermission('EZComments::', '::', ACCESS_READ)) {
         return true;
     }
     $minlen = 3;
     $maxlen = 30;
     if (strlen($args['q']) < $minlen || strlen($args['q']) > $maxlen) {
         return LogUtil::registerStatus($this->__f('The comments can only be searched for words that are longer than %1$s and less than %2$s characters!', array($minlen, $maxlen)));
     }
     ModUtil::dbInfoLoad('Search');
     $tables = DBUtil::getTables();
     // ezcomments tables
     $ezcommentstable = $tables['EZComments'];
     $ezcommentscolumn = $tables['EZComments_column'];
     // our own tables
     $searchTable = $tables['search_result'];
     $searchColumn = $tables['search_result_column'];
     // where
     $where = Search_Api_User::construct_where($args, array($ezcommentscolumn['subject'], $ezcommentscolumn['comment']));
     $where .= " AND " . $ezcommentscolumn['url'] . " != ''";
     $sessionId = session_id();
     $insertSql = "INSERT INTO {$searchTable}\n              ({$searchColumn['title']},\n               {$searchColumn['text']},\n               {$searchColumn['extra']},\n               {$searchColumn['module']},\n               {$searchColumn['created']},\n               {$searchColumn['session']})\n            VALUES\n            ";
     $comments = DBUtil::selectObjectArray('EZComments', $where);
     foreach ($comments as $comment) {
         $sql = $insertSql . '(' . '\'' . DataUtil::formatForStore($comment['subject']) . '\', ' . '\'' . DataUtil::formatForStore($comment['comment']) . '\', ' . '\'' . DataUtil::formatForStore($comment['url']) . '\', ' . '\'' . 'EZComments' . '\', ' . '\'' . DataUtil::formatForStore($comment['date']) . '\', ' . '\'' . DataUtil::formatForStore($sessionId) . '\')';
         $insertResult = DBUtil::executeSQL($sql);
         if (!$insertResult) {
             return LogUtil::registerError($this->__('Error! Could not load items.'));
         }
     }
     return true;
 }
Example #24
0
/**
 * 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);
        }
    }
}
Example #25
0
 /**
  * Render event handler.
  *
  * @param Zikula_Form_View $view Reference to Form render object.
  *
  * @return string The rendered output
  */
 public function render(Zikula_Form_View $view)
 {
     $validators =& $view->validators;
     $html = '';
     foreach ($validators as $validator) {
         if (!$validator->isValid) {
             $label = '';
             if (get_class($validator) == 'Zikula_Form_Plugin_RadioButton') {
                 foreach ($view->plugins as $plugin) {
                     if (get_class($plugin) == 'Zikula_Form_Plugin_Label' && $plugin->for == $validator->dataField) {
                         $label = $plugin->text;
                         break;
                     }
                 }
             }
             $label = !empty($label) ? $label : $validator->myLabel;
             $html .= "<li><label for=\"{$validator->id}\">" . DataUtil::formatForDisplay($label) . ': ';
             $html .= DataUtil::formatForDisplay($validator->errorMessage) . "</label></li>\n";
         }
     }
     if ($html != '') {
         $html = "<div class=\"{$this->cssClass}\">\n<ul>\n{$html}</ul>\n</div>\n";
     }
     return $html;
 }
Example #26
0
    /**
     * 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');
    }
Example #27
0
 /**
  * Update attributes of a block.
  *
  * @param int $args ['bid'] the ID of the block to update.
  * @param string $args ['title'] the new title of the block.
  * @param string $args ['description'] the new description of the block.
  * @param string $args ['positions'] the new positions of the block.
  * @param string $args ['url'] the new URL of the block.
  * @param string $args ['language'] the new language of the block.
  * @param string $args ['content'] the new content of the block.
  *
  * @return bool true on success, false on failure.
  */
 public function update($args)
 {
     // Optional arguments
     if (!isset($args['url'])) {
         $args['url'] = '';
     }
     if (!isset($args['content'])) {
         $args['content'] = '';
     }
     // Argument check
     if (!isset($args['bid']) || !is_numeric($args['bid']) || !isset($args['content']) || !isset($args['title']) || !isset($args['description']) || !isset($args['language']) || !isset($args['collapsable']) || !isset($args['defaultstate'])) {
         return LogUtil::registerArgsError();
     }
     $block = DBUtil::selectObjectByID('blocks', $args['bid'], 'bid');
     // Security check
     // this function is called durung the init process so we have to check in _ZINSTALLVER
     // is set as alternative to the correct permission check
     if (!System::isInstalling() && !SecurityUtil::checkPermission('Blocks::', "{$block['bkey']}:{$block['title']}:{$block['bid']}", ACCESS_EDIT)) {
         return LogUtil::registerPermissionError();
     }
     $item = array('bid' => isset($args['bid']) ? $args['bid'] : $block['bid'], 'content' => isset($args['content']) ? $args['content'] : $block['content'], 'title' => isset($args['title']) ? $args['title'] : $block['title'], 'description' => isset($args['description']) ? $args['description'] : $block['description'], 'filter' => isset($args['filter']) ? serialize($args['filter']) : $block['filter'], 'url' => isset($args['url']) ? $args['url'] : $block['url'], 'refresh' => isset($args['refresh']) ? $args['refresh'] : $block['refresh'], 'language' => isset($args['language']) ? $args['language'] : $block['language'], 'collapsable' => isset($args['collapsable']) ? $args['collapsable'] : $block['collapsable'], 'defaultstate' => isset($args['defaultstate']) ? $args['defaultstate'] : $block['defaultstate']);
     $res = DBUtil::updateObject($item, 'blocks', '', 'bid');
     if (!$res) {
         return LogUtil::registerError($this->__('Error! Could not save your changes.'));
     }
     // leave unchanged positions as is, delete removed positions from placements table
     // and add placement for new positions
     if (isset($args['positions'])) {
         // Get all existing block positions. We do not use the userapi function here because we need
         // an associative array for the next steps: key = pid (position id)
         $allblockspositions = DBUtil::selectObjectArray('block_positions', null, 'pid', -1, -1, 'pid', null);
         foreach ($allblockspositions as $positionid => $blockposition) {
             if (in_array($positionid, $args['positions'])) {
                 // position name is present in the array submitted from the user
                 $where = "WHERE pid = '" . DataUtil::formatForStore($positionid) . '\'';
                 $blocksinposition = DBUtil::selectObjectArray('block_placements', $where, 'sortorder', -1, -1, 'bid');
                 if (array_key_exists($item['bid'], $blocksinposition)) {
                     // block is already in this position, placement did not change, this means we do nothing
                 } else {
                     // add the block to the given position as last entry (max(sortorder) +1
                     $newplacement = array('pid' => $blockposition['pid'], 'bid' => $item['bid'], 'order' => count($blocksinpositions));
                     $res = DBUtil::insertObject($newplacement, 'block_placements', 'bid', true);
                     if (!$res) {
                         return LogUtil::registerError($this->__('Error! Could not perform the insertion.'));
                     }
                 }
             } else {
                 // position name is NOT present in the array submitted from the user
                 // delete the block id from the placements table for this position
                 $where = '(bid = \'' . DataUtil::formatForStore($item['bid']) . '\' AND pid = \'' . DataUtil::formatForStore($blockposition['pid']) . '\')';
                 $res = DBUtil::deleteWhere('block_placements', $where);
                 if (!$res) {
                     return LogUtil::registerError($this->__('Error! Could not save your changes.'));
                 }
             }
         }
     }
     return true;
 }
Example #28
0
/**
 * Zikula_View function to display admin links for a module.
 *
 * Example:
 * {moduleadminlinks modname=Example start="[" end="]" seperator="|" class="z-menuitem-title"}
 *
 * Available parameters:
 *   - modname   Module name to display links for.
 *   - start     Start string (optional).
 *   - end       End string (optional).
 *   - seperator Link seperator (optional).
 *   - class     CSS class (optional).
 *
 * @param array       $params  All attributes passed to this function from the template.
 * @param Zikula_View $view    Reference to the Zikula_View object.
 *
 * @return string A formatted string containing navigation for the module admin panel.
 */
function smarty_function_moduleadminlinks($params, $view)
{
    LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated, please use {%2$s} instead.', array('moduleadminlinks', 'modulelinks')), E_USER_DEPRECATED);

    // set some defaults
    $start     = isset($params['start'])    ? $params['start']    : '[';
    $end       = isset($params['end'])      ? $params['end']      : ']';
    $seperator = isset($params['seperator'])? $params['seperator']: '|';
    $class     = isset($params['class'])    ? $params['class']    : 'z-menuitem-title';

    $modname = $params['modname'];
    unset ($params['modname']);

    if (!isset($modname) || !ModUtil::available($modname)) {
        $modname = ModUtil::getName();
    }

    // check our module name
    if (!ModUtil::available($modname)) {
        $view->trigger_error('moduleadminlinks: '.__f("Error! The '%s' module is not available.", DataUtil::formatForDisplay($modname)));
        return false;
    }

    // get the links from the module API
    $links = ModUtil::apiFunc($modname, 'admin', 'getlinks', $params);

    // establish some useful count vars
    $linkcount = count($links);

    $adminlinks = "<span class=\"$class\">$start ";
    foreach ($links as $key => $link) {
        $id = '';
        if (isset($link['id'])) {
            $id = 'id="' . $link['id'] . '"';
        }
        if (!isset($link['title'])) {
            $link['title'] = $link['text'];
        }
        if (isset($link['disabled']) && $link['disabled'] == true) {
            $adminlinks .= "<span $id>" . '<a class="z-disabledadminlink" title="' . DataUtil::formatForDisplay($link['title']) . '">' . DataUtil::formatForDisplay($link['text']) . '</a> ';
        } else {
            $adminlinks .= "<span $id><a href=\"" . DataUtil::formatForDisplay($link['url']) . '" title="' . DataUtil::formatForDisplay($link['title']) . '">' . DataUtil::formatForDisplay($link['text']) . '</a> ';
        }
        if ($key == $linkcount-1) {
            $adminlinks .= '</span>';
            continue;
        }
        // linebreak
        if (isset($link['linebreak']) && $link['linebreak'] == true) {
            $adminlinks .= "</span>\n ";
            $adminlinks .= "$end</span><br /><span class=\"$class\">$start ";
        } else {
            $adminlinks .= "$seperator</span>\n ";
        }
    }
    $adminlinks .= "$end</span>\n";

    return $adminlinks;
}
Example #29
0
 /**
  * @param int args[uid]     userid
  */
 public function userOnline($args)
 {
     $uid = $args['uid'];
     $tables = DBUtil::getTables();
     $columns = $tables['session_info_column'];
     $where = "{$columns['uid']} = '" . DataUtil::formatForStore($uid) . "'";
     return DBUtil::selectObject('session_info', $where);
 }
Example #30
0
/**
 * Smarty function to display the theme info
 *
 * Example
 * {themeinfo}
 *
 * @see          function.themeinfo.php::smarty_function_themeinfo()
 * @param        array       $params      All attributes passed to this function from the template
 * @param        object      $smarty     Reference to the Smarty object
 * @return       string      the themeinfo
 */
function smarty_function_themeinfo($params, $smarty)
{
    LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated, please use {%2$s} instead.', array('themeinfo', '$themeinfo')), E_USER_DEPRECATED);
    $thistheme = UserUtil::getTheme();
    $themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName($thistheme));
    $themecredits = '<!-- ' . __f('Theme: %1$s by %2$s - %3$s', array(DataUtil::formatForDisplay($themeinfo['display']), DataUtil::formatForDisplay($themeinfo['author']), DataUtil::formatForDisplay($themeinfo['contact']))) . ' -->';
    return $themecredits;
}