示例#1
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);
        }
    }
}
/**
 * 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;
    }
}
示例#3
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;
}
示例#4
0
文件: Util.php 项目: pheski/Scribite
 /**
  * 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' => '');
 }
示例#5
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;
 }
示例#6
0
    /**
     * Change the users in select list
     * @author:     Albert Pï¿œrez Monfort (aperezm@xtec.cat)
     * @param:	args   Array with the id of the note
     * @return:	Redirect to the user main page
     */
    public function chgUsers($args) {
        if (!SecurityUtil::checkPermission('IWforums::', '::', ACCESS_ADMIN)) {
            throw new Zikula_Exception_Fatal($this->__('Sorry! No authorization to access this module.'));
        }

        $gid = $this->request->getPost()->get('gid', '');
        if (!$gid) {
            throw new Zikula_Exception_Fatal($this->__('no group id'));
        }

        // get group members
        $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
        $groupMembers = ModUtil::func('IWmain', 'user', 'getMembersGroup',
                                       array('sv' => $sv,
                                             'gid' => $gid));

        asort($groupMembers);

        if (empty($groupMembers)) {
            AjaxUtil::error($this->__('unable to get group members or group is empty for gid=') . DataUtil::formatForDisplay($gid));
        }

        $view = Zikula_View::getInstance('IWforums', false);
        $view->assign('groupMembers', $groupMembers);
        $view->assign('action', 'chgUsers');
        $content = $view->fetch('IWforums_admin_ajax.htm');
        return new Zikula_Response_Ajax(array('content' => $content));
    }
示例#7
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>';
 }
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;
}
示例#9
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;
    }
示例#10
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));
    }
示例#11
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);
        }
    }
}
示例#12
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);
 }
示例#13
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));
 }
/**
 * 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;
    }
}
示例#15
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;
 }
示例#16
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;
    }
}
/**
 * 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;
    }
}
示例#18
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;
}
function smarty_function_mediashare_mediaUrl($params, &$smarty)
{
    $result = pnModAPIFunc('mediashare', 'user', 'getMediaUrl', $params);
    if (isset($params['assign'])) {
        $smarty->assign($params['assign'], $result);
    }
    return DataUtil::formatForDisplay($result);
}
示例#20
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;
}
示例#21
0
    /**
     * Display the output of the login block.
     *
     * @param array $blockInfo A blockinfo structure.
     *
     * @return string The output.
     */
    public function display($blockInfo)
    {
        $renderedOutput = '';

        if (SecurityUtil::checkPermission('Loginblock::', $blockInfo['title'].'::', ACCESS_READ)) {
            if (!UserUtil::isLoggedIn()) {
                if (empty($blockInfo['title'])) {
                    $blockInfo['title'] = DataUtil::formatForDisplay('Login');
                }

                $authenticationMethodList = new Users_Helper_AuthenticationMethodList($this);

                if ($authenticationMethodList->countEnabledForAuthentication() > 1) {
                    $selectedAuthenticationMethod = $this->request->request->get('authentication_method', false);
                } else {
                    // There is only one (or there is none), so auto-select it.
                    $authenticationMethod = $authenticationMethodList->getAuthenticationMethodForDefault();
                    $selectedAuthenticationMethod = array(
                        'modname'   => $authenticationMethod->modname,
                        'method'    => $authenticationMethod->method,
                    );
                }

                // TODO - The order and availability should be set by block configuration
                $authenticationMethodDisplayOrder = array();
                foreach ($authenticationMethodList as $authenticationMethod) {
                    if ($authenticationMethod->isEnabledForAuthentication()) {
                        $authenticationMethodDisplayOrder[] = array(
                            'modname'   => $authenticationMethod->modname,
                            'method'    => $authenticationMethod->method,
                        );
                    }
                }

                $this->view->assign('authentication_method_display_order', $authenticationMethodDisplayOrder)
                           ->assign('selected_authentication_method', $selectedAuthenticationMethod);

                // If the current page was reached via a POST or FILES then we don't want to return here.
                // Only return if the current page was reached via a regular GET
                if ($this->request->isGet()) {
                    $this->view->assign('returnpage', System::getCurrentUri());
                } else {
                    $this->view->assign('returnpage', '');
                }

                $tplName = mb_strtolower("users_block_login_{$blockInfo['position']}.tpl");
                if ($this->view->template_exists($tplName)) {
                    $blockInfo['content'] = $this->view->fetch($tplName);
                } else {
                    $blockInfo['content'] = $this->view->fetch('users_block_login.tpl');
                }

                $renderedOutput = BlockUtil::themeBlock($blockInfo);
            }
        }

        return $renderedOutput;
    }
 /**
  * Render event handler.
  *
  * @param Zikula_Form_View $view Reference to Zikula_Form_View object.
  *
  * @return string The rendered output
  */
 function render(Zikula_Form_View $view)
 {
     $result = parent::render($view);
     if ($this->editLink && !empty($this->category) && SecurityUtil::checkPermission('Categories::', "{$this->category['id']}::", ACCESS_EDIT)) {
         $url = DataUtil::formatForDisplay(ModUtil::url('Categories', 'user', 'edit', array('dr' => $this->category['id'])));
         $result .= "<a class=\"z-formnote\" href=\"{$url}\">" . __('Edit') . '</a>';
     }
     return $result;
 }
/**
 * Zikula_View function to display the avatar of a user
 *
 * Available parameters:
 *   - uid            User uid
 *   - width, height  Width and heigt of the image (optional)
 *   - assign         The results are assigned to the corresponding variable instead of printed out (optional).
 * Gravatar parameters
 *   - size           Size of the gravtar (optional)
 *   - rating         Gravatar allows users to self-rate their images so that they can indicate if an image is appropriate for a certain audience.
 *                    [g|pg|r|x] see: http://en.gravatar.com/site/implement/images/ (optional)
 *
 * Examples:
 * {useravatar uid="2"}
 * {useravatar uid="2" width=80 height=80}
 * {useravatar uid="2" size=80 rating=g}
 *
 * @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 the avatar image.
 */
function smarty_function_useravatar($params, Zikula_View $view)
{
    if (!isset($params['uid'])) {
        $view->trigger_error("Error! Missing 'uid' attribute for useravatar.");
        return false;
    }
    $email = UserUtil::getVar('email', $params['uid']);
    $avatar = UserUtil::getVar('avatar', $params['uid']);
    $uname = UserUtil::getVar('uname', $params['uid']);
    $avatarpath = ModUtil::getVar(UsersConstant::MODNAME, UsersConstant::MODVAR_AVATAR_IMAGE_PATH, UsersConstant::DEFAULT_AVATAR_IMAGE_PATH);
    $allowgravatars = ModUtil::getVar(UsersConstant::MODNAME, UsersConstant::MODVAR_GRAVATARS_ENABLED, UsersConstant::DEFAULT_GRAVATARS_ENABLED);
    $gravatarimage = ModUtil::getVar(UsersConstant::MODNAME, UsersConstant::MODVAR_GRAVATAR_IMAGE, UsersConstant::DEFAULT_GRAVATAR_IMAGE);
    if (isset($avatar) && !empty($avatar) && $avatar != $gravatarimage && $avatar != 'blank.gif') {
        $avatarURL = System::getBaseUrl() . $avatarpath . '/' . $avatar;
    } elseif ($avatar == $gravatarimage && $allowgravatars == 1) {
        if (!isset($params['rating'])) {
            $params['rating'] = false;
        }
        if (!isset($params['size'])) {
            if (isset($params['width'])) {
                $params['size'] = $params['width'];
            }
            $params['size'] = 80;
        }
        $params['width'] = $params['size'];
        $params['height'] = $params['size'];
        $avatarURL = 'http://www.gravatar.com/avatar.php?gravatar_id=' . md5($email);
        if (isset($params['rating']) && !empty($params['rating'])) {
            $avatarURL .= "&rating=" . $params['rating'];
        }
        if (isset($params['size']) && !empty($params['size'])) {
            $avatarURL .= "&size=" . $params['size'];
        }
        $avatarURL .= "&default=" . urlencode(System::getBaseUrl() . $avatarpath . '/' . $gravatarimage);
    } else {
        // e.g. blank.gif or empty avatars
        return false;
    }
    $classString = '';
    if (isset($params['class'])) {
        $classString = "class=\"{$params['class']}\" ";
    }
    $html = '<img ' . $classString . ' src="' . DataUtil::formatForDisplay($avatarURL) . '" title="' . DataUtil::formatForDisplay($uname) . '" alt="' . DataUtil::formatForDisplay($uname);
    if (isset($params['width'])) {
        $html .= ' width="' . $params['width'] . '"';
    }
    if (isset($params['height'])) {
        $html .= ' height="' . $params['height'] . '"';
    }
    $html .= '" />';
    if (isset($params['assign'])) {
        $view->assign($params['assign'], $avatarURL);
    } else {
        return $html;
    }
}
/**
 * render plugin for fetching a particular module object
 *
 * Examples
 *   {selectmodobject module="AutoCustomer" objecttype="customer" id=4 assign="myCustomer"}
 *   {selectmodobject module="AutoCocktails" objecttype="recipe" id=12 assign="myRecipe"}
 *   {selectmodobject recordClass="AutoCocktails_Model_Recipe" id=12 assign="myRecipe"}
 *
 * Parameters:
 *  module      Name of the module storing the desired object (in DBObject mode)
 *  objecttype  Name of object type (in DBObject mode)
 *  recordClass Class name of an doctrine record. (in Doctrine mode)
 *  id          Identifier of desired object
 *  prefix      Optional prefix for class names (defaults to PN) (in DBObject mode)
 *  assign      Name of the returned object
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the Zikula_View object.
 *
 * @return void
 */
function smarty_function_selectmodobject($params, Zikula_View $view)
{
    if (isset($params['recordClass']) && !empty($params['recordClass'])) {
        $doctrineMode = true;
    } else {
        // DBObject checks
        if (!isset($params['module']) || empty($params['module'])) {
            $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'module')));
        }
        if (!isset($params['objecttype']) || empty($params['objecttype'])) {
            $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'objecttype')));
        }
        if (!isset($params['prefix'])) {
            $params['prefix'] = 'PN';
        }
        $doctrineMode = false;
    }
    if (!isset($params['id']) || empty($params['id']) || !is_numeric($params['id'])) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'id')));
    }
    if (!isset($params['assign']) || empty($params['assign'])) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'assign')));
    }
    // load object depending on mode: doctrine or dbobject
    if (!$doctrineMode) {
        if (!ModUtil::available($params['module'])) {
            $view->trigger_error(__f('Invalid %1$s passed to %2$s.', array('module', 'selectmodobject')));
        }
        ModUtil::dbInfoLoad($params['module']);
        $classname = "{$params['module']}_DBObject_" . StringUtil::camelize($params['objecttype']);
        if (!class_exists($classname) && System::isLegacyMode()) {
            // BC check for PNObject old style.
            // load the object class corresponding to $params['objecttype']
            if (!($class = Loader::loadClassFromModule($params['module'], $params['objecttype'], false, false, $params['prefix']))) {
                z_exit(__f('Unable to load class [%s] for module [%s]', array(DataUtil::formatForDisplay($params['objecttype']), DataUtil::formatForDisplay($params['module']))));
            }
        }
        // intantiate object model
        $object = new $class();
        $idField = $object->getIDField();
        // assign object data
        // this performs a new database select operation
        // while the result will be saved within the object, we assign it to a local variable for convenience
        $objectData = $object->get(intval($params['id']), $idField);
        if (!is_array($objectData) || !isset($objectData[$idField]) || !is_numeric($objectData[$idField])) {
            $view->trigger_error(__('Sorry! No such item found.'));
        }
    } else {
        $objectData = Doctrine_Core::getTable($params['recordClass'])->find($params['id']);
        if ($objectData === false) {
            $view->trigger_error(__('Sorry! No such item found.'));
        }
    }
    $view->assign($params['assign'], $objectData);
}
/**
 * Set key in $metatags array.
 *
 * Available attributes:
 *  - name  (string) The name of the configuration variable to obtain
 *  - value (string) Value.
 *
 * Examples:
 *
 * <samp><p>Welcome to {setmetatag name='description' value='Description goes here}!</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 void
 */
function smarty_function_setmetatag($params, Zikula_View $view)
{
    $name = isset($params['name']) ? $params['name'] : null;
    $value = isset($params['value']) ? $params['value'] : null;
    if (!$name) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('setmetatag', 'name')));
        return false;
    }
    $sm = $view->getContainer();
    $sm['zikula_view.metatags'][$name] = DataUtil::formatForDisplay($value);
}
示例#26
0
 /**
  * This is a standard function to modify the configuration parameters of the
  * module
  * @return string HTML string
  */
 public function modifyconfig()
 {
     // security check
     $this->throwForbiddenUnless(SecurityUtil::checkPermission('Mailer::', '::', ACCESS_ADMIN));
     // assign the module mail agent types
     $this->view->assign('mailertypes', array(1 => DataUtil::formatForDisplay($this->__("Internal PHP `mail()` function")), 2 => DataUtil::formatForDisplay($this->__('Sendmail message transfer agent')), 3 => DataUtil::formatForDisplay($this->__('QMail message transfer agent')), 4 => DataUtil::formatForDisplay($this->__('SMTP mail transfer protocol'))));
     $this->view->assign('smtpsecuremethod', $this->getVar('securemethod'));
     // assign all module vars
     $this->view->assign($this->getVars());
     return $this->view->fetch('mailer_admin_modifyconfig.tpl');
 }
示例#27
0
    function display()
    {
        if ($this->inputType == 'raw') {
            $text = DataUtil::formatForDisplay($this->text);
        } else {
            $text = DataUtil::formatForDisplayHTML($this->text);
        }

        $this->view->assign('inputType', $this->inputType);
        $this->view->assign('text', $text);

        return $this->view->fetch($this->getTemplate());
    }
/**
 * Content
 *
 * @copyright (C) 2010 Sven Strickroth, TU Clausthal
 * @link http://github.com/zikula-modules/Content
 * @license See license.txt
 */

function smarty_function_contentareatitle($params, $view) 
{
    $dom = ZLanguage::getModuleDomain('Content');
    $areatitle = DataUtil::formatForDisplay($params['page']['layoutData']['plugin']->getContentAreaTitle($params['contentArea']));
    if ($areatitle) {
        $html = "<div class='con_area'>" . __f('%s area', $areatitle, $dom) . "</div>";
    }
    if (array_key_exists('assign', $params)) {
        $view->assign($params['assign'], $html);
    } else {
        return $html;
    }
}
/**
 * Content
 *
 * @copyright (C) 2007-2010, Content Development Team
 * @link http://github.com/zikula-modules/Content
 * @license See license.txt
 */
function smarty_function_contentlabelhelp($params, $view)
{
    $text = $params['text'];
    $text = strlen($text) > 0 && $text[0] == '_' ? ModUtil::apiFunc('Content', 'History', 'contentHistoryActionTranslate', $text) : $text;
    if (!isset($params['html']) || !$params['html']) {
        $text = DataUtil::formatForDisplay($text);
    }
    $result = "<em class=\"z-sub z-formnote\">{$text}</em>";
    if (array_key_exists('assign', $params)) {
        $view->assign($params['assign'], $result);
    } else {
        return $result;
    }
}
示例#30
0
 /**
  * Set a cookie value.
  *
  * @param string  $name    Name of cookie.
  * @param string  $value   Value.
  * @param integer $expires Unix epoch date for expiry.
  * @param string  $path    Cookie path.
  * @param string  $domain  Domain must be at least .domain.tld.
  * @param boolean $secure  To set if cookie must only be set over existing https connection.
  * @param boolean $signed  Override system setting to use signatures.
  *
  * @return boolean
  */
 public static function setCookie($name, $value = '', $expires = null, $path = null, $domain = null, $secure = null, $signed = true)
 {
     if (!$name) {
         return z_exit(__f("Error! In 'setCookie', you must specify at least the cookie name '%s'.", DataUtil::formatForDisplay($name)));
     }
     if (!is_string($value)) {
         return z_exit('setCookie: ' . DataUtil::formatForDisplay($value) . ' must be a string');
     }
     if (System::getVar('signcookies') && !$signed == false) {
         // sign the cookie
         $value = SecurityUtil::signData($value);
     }
     return setcookie($name, $value, $expires, $path, $domain, $secure);
 }