コード例 #1
0
/**
 * Zikula_View function to check for the availability of a module
 *
 * This function calls ModUtil::isHooked to determine if two Zikula modules are
 * hooked together. True is returned if the modules are hooked, false otherwise.
 * The result can also be assigned to a template variable.
 *
 * Available parameters:
 *   - tmodname:  The well-known name of the hook module
 *   - smodname:  The well-known name of the calling module
 *   - assign:    The name of a variable to which the results are assigned
 *
 * Examples
 *   {modishooked tmodname='Ratings' smodname='News'}
 *
 *   {modishooked tmodname='bar' smodname='foo' assign='barishookedtofoo'}
 *   {if $barishookedtofoo}.....{/if}
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the Zikula_View object.
 *
 * @see    function.modishooked.php::smarty_function_modishooked()
 *
 * @return boolean True if the module is available; false otherwise.
 */
function smarty_function_modishooked($params, $view)
{
    LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated.', array('modishooked')), E_USER_DEPRECATED);

    $assign   = isset($params['assign'])   ? $params['assign']   : null;
    $smodname = isset($params['smodname']) ? $params['smodname'] : null;
    $tmodname = isset($params['tmodname']) ? $params['tmodname'] : null;

    if (!$tmodname) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('modishooked', 'tmodname')));
        return false;
    }

    if (!$smodname) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('modishooked', 'smodname')));
        return false;
    }

    $result = ModUtil::isHooked($tmodname, $smodname);

    if ($assign) {
        $view->assign($params['assign'], $result);
    } else {
        return $result;
    }
}
コード例 #2
0
/**
 * Implement permissions checks in a template.
 *
 * Available attributes:
 *  - component (string) The component to be tested, e.g., 'ModuleName::'
 *  - instance  (string) The instance to be tested, e.g., 'name::1'
 *  - level     (int)    The level of access required, e.g., ACCESS_READ
 *
 * Example:
 * <pre>
 * {secauthaction_block component='News::' instance='1::' level=ACCESS_COMMENT}
 *   do some stuff now that we have permission
 * {/secauthaction_block}
 * </pre>.
 *
 * @param array  $params  All attributes passed to this function from the template.
 * @param string $content The content between the block tags.
 * @param Smarty &$smarty Reference to the {@link Zikula_View} object.
 *
 * @return mixed The content of the block, if the user has the specified
 *               access level for the component and instance, otherwise null;
 *               false on an error.
 *
 * @deprecated See {@link smarty_block_securityutil_checkpermission_block}.
 */
function smarty_block_secauthaction_block($params, $content, &$smarty)
{
    LogUtil::log(__f('Warning! Template block {%1$s} is deprecated, please use {%2$s} instead.', array('secauthaction_block', 'checkpermissionblock')), E_USER_DEPRECATED);
    if (is_null($content)) {
        return;
    }

    // check our input
    if (!isset($params['component'])) {
        $smarty->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('smarty_block_secauthaction_block', 'component')));
        return false;
    }
    if (!isset($params['instance'])) {
        $smarty->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('smarty_block_secauthaction_block', 'instance')));
        return false;
    }
    if (!isset($params['level'])) {
        $smarty->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('smarty_block_secauthaction_block', 'level')));
        return false;
    }

    if (!SecurityUtil::checkPermission($params['component'], $params['instance'], constant($params['level']))) {
        return;
    }

    return $content;
}
コード例 #3
0
/**
 * Example:
 * {securityutil_checkpermission component='Users::' instance='.*' level='ACCESS_ADMIN' assign='auth'}
 *
 * true/false will be returned.
 *
 * This file is a plugin for Zikula_View, the Zikula implementation of Smarty
 * @param        array       $params      All attributes passed to this function from the template
 * @param        object      $smarty      Reference to the Smarty object
 * @return       boolean     authorized?
 */
function smarty_function_securityutil_checkpermission($params, $smarty)
{
    LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated, please use {%2$s} instead.', array('securityutil_checkpermission', 'checkpermission')), E_USER_DEPRECATED);

    if (!isset($params['component'])) {
        $smarty->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('securityutil_checkpermission', 'component')));
        return false;
    }

    if (!isset($params['instance'])) {
        $smarty->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('securityutil_checkpermission', 'instance')));
        return false;
    }

    if (!isset($params['level'])) {
        $smarty->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('securityutil_checkpermission', 'level')));
        return false;
    }

    $result = SecurityUtil::checkPermission($params['component'], $params['instance'], constant($params['level']));

    if (isset($params['assign'])) {
        $smarty->assign($params['assign'], $result);
    } else {
        return $result;
    }
}
コード例 #4
0
/**
 * Check if an array element (subscript) is set.
 *
 * Available attributes:
 *  - array         (array)     an array template variable
 *  - field         (string)    the value of a key in the array specified above
 *  - returnValue   (bool|int)  if set, then the contents of the array element
 *                              $array[$field] is returned if it is set, otherwise false is returned
 *  - assign        (string)    (optional) if provided, a template variable with
 *                              the specified name is set with the return value,
 *                              instead of returning the value to the template
 *
 * Examples:
 *
 *  Return true to the template if the template variable $myarray['arraykey']
 *  is set, otherwise return false to the template:
 *
 *  <samp>{array_field_isset array=$myarray field='arraykey'}</samp>
 *
 *  Return the value of the template variable $myarray['arraykey'] to the
 *  template if it is set, otherwise return false to the template:
 *
 *  <samp>{array_field_isset array=$myarray field='arraykey' returnValue=1}</samp>
 *
 *  Assign true to the template variable $myValue if the template variable
 *  $myarray['arraykey'] is set, otherwise set $myValue to false:
 *
 *  <samp>{array_field_isset array=$myarray field='arraykey' assign='myValue'}</samp>
 *
 *  Assign the value of the template variable $myarray['arraykey'] to the
 *  template variable $myValue if it is set, otherwise assign false to $myValue:
 *
 *  <samp>{array_field_isset array=$myarray field='arraykey' returnValue=1 assign='myValue'}</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 boolean|mixed if returnValue is not set, then returns true if the array
 *                       element is set, otherwise false; if returnValue is set,
 *                       then returns the value of the array element if it is set,
 *                       otherwise false.
 */
function smarty_function_array_field_isset($params, Zikula_View $view)
{
    LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated, please use {%2$s} instead.', array('array_field_isset returnValue=1 ...', 'array_field ...')), E_USER_DEPRECATED);

    $array       = isset($params['array'])       ? $params['array']        : null;
    $field       = isset($params['field'])       ? $params['field']        : null;
    $returnValue = isset($params['returnValue']) ? $params['returnValue']  : null;
    $assign      = isset($params['assign'])      ? $params['assign']       : null;

    if ($array === null) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('array_field_isset', 'array')));
        return false;
    }

    if ($field === null) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('array_field_isset', 'field')));
        return false;
    }

    $result = isset($array[$field]);
    if ($result && $returnValue) {
        $result = $array[$field];
    }

    if ($assign) {
        $view->assign($assign, $result);
    } else {
        return $result;
    }
}
コード例 #5
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);
        }
    }
}
コード例 #6
0
 /**
  * Get version metadata for a module.
  *
  * @param string $moduleName Module Name.
  * @param string $rootdir    Root directory of the module (default: modules).
  *
  * @return Zikula_AbstractVersion|array
  */
 public static function getVersionMeta($moduleName, $rootdir = 'modules')
 {
     $modversion = array();
     $class = "{$moduleName}_Version";
     if (class_exists($class)) {
         try {
             $modversion = new $class();
         } catch (Exception $e) {
             LogUtil::log(__f('%1$s threw an exception reporting: "%2$s"', array($class, $e->getMessage())), Zikula_AbstractErrorHandler::CRIT);
             throw new InvalidArgumentException(__f('%1$s threw an exception reporting: "%2$s"', array($class, $e->getMessage())), 0, $e);
         }
         if (!$modversion instanceof Zikula_AbstractVersion) {
             LogUtil::registerError(__f('%s is not an instance of Zikula_AbstractVersion', get_class($modversion)));
         }
     } elseif (is_dir("{$rootdir}/{$moduleName}/lib")) {
         LogUtil::registerError(__f('Could not find %1$s for module %2$s', array("{$moduleName}_Version", $moduleName)));
     } else {
         // pre 1.3 modules
         $legacyVersionPath = "{$rootdir}/{$moduleName}/pnversion.php";
         if (!file_exists($legacyVersionPath)) {
             if (!System::isUpgrading()) {
                 LogUtil::log(__f("Error! Could not load the file '%s'.", $legacyVersionPath), Zikula_AbstractErrorHandler::CRIT);
                 LogUtil::registerError(__f("Error! Could not load the file '%s'.", $legacyVersionPath));
             }
             $modversion = array('name' => $moduleName, 'description' => '', 'version' => 0);
         } else {
             include $legacyVersionPath;
         }
     }
     return $modversion;
 }
コード例 #7
0
/**
 * 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;
    }
}
コード例 #8
0
/**
 * Example:
 * {secauthaction comp="Stories::" inst=".*" level="ACCESS_ADMIN" assign="auth"}
 *
 * true/false will be returned.
 *
 * This file is a plugin for Zikula_View, the Zikula implementation of Smarty
 * @param        array       $params      All attributes passed to this function from the template
 * @param        object      &$smarty     Reference to the Smarty object
 * @return       boolean     authorized?
 */
function smarty_function_secauthaction($params, &$smarty)
{
    LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated, please use {%2$s} instead.', array('secauthaction', 'checkpermission')), E_USER_DEPRECATED);

    $assign = isset($params['assign']) ? $params['assign'] : null;
    $comp   = isset($params['comp'])   ? $params['comp']   : null;
    $inst   = isset($params['inst'])   ? $params['inst']   : null;
    $level  = isset($params['level'])  ? $params['level']  : null;

    if (!$comp) {
        $smarty->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('smarty_function_secauthaction', 'comp')));
        return false;
    }

    if (!$inst) {
        $smarty->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('smarty_function_secauthaction', 'inst')));
        return false;
    }

    if (!$level) {
        $smarty->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('smarty_function_secauthaction', 'level')));
        return false;
    }

    $result = SecurityUtil::checkPermission($comp, $inst, constant($level));

    if ($assign) {
        $smarty->assign($assign, $result);
    } else {
        return $result;
    }
}
コード例 #9
0
/**
 * Zikula_View function return and unset an array field if set.
 *
 * Available attributes:
 *  - array     (string)    The name of an array template variable
 *  - field     (string)    The name of an array key in the array template variable above
 *  - unset     (bool|int)  If true, the array element will be unset, if false the
 * \                        array element will remain unchanged
 *  - assign    (string)    The name of a template variable that the value of
 *                          $array['field'] will be assigned to
 *
 * Examples:
 *
 *  Assign the value of the template variable $myarray['arraykey'] to the
 *  template variable $myValue if it is set, otherwise assign false to $myValue.
 *  The template variable $myarray['arraykey'] is NOT unset:
 *
 *  <samp>{array_field_pop array='myarray' field='arraykey' assign='myValue'}</samp>
 *
 *  Assign the value of the template variable $myarray['arraykey'] to the
 *  template variable $myValue if it is set, otherwise assign false to $myValue.
 *  The template variable $myarray['arraykey'] IS unset:
 *
 *  <samp>{array_field_pop array='myarray' field='arraykey' unset=1 assign='myValue'}</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 null The value of the specified array element is return
 *              in the specified template variable if it is set,
 *              otherwise the template variable is set to false; no output to the template.
 */
function smarty_function_array_field_pop($params, Zikula_View $view)
{
    LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated, please use {%2$s} instead.', array('array_field_pop', 'array_pop')), E_USER_DEPRECATED);
    $array = isset($view->_tpl_vars[$params['array']]);
    $field = isset($params['field']) ? $params['field'] : null;
    $unset = isset($params['unset']) ? $params['unset'] : false;
    $assign = isset($params['assign']) ? $params['assign'] : null;
    if (!$array) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('array_field_pop', 'array')));
        return false;
    }
    if (!is_array($view->_tpl_vars[$params['array']])) {
        $view->trigger_error(__f('Non-array passed to %s.', 'array_field_pop'));
        return false;
    }
    if ($field === null) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('array_field_pop', 'field')));
        return false;
    }
    $result = false;
    if (isset($view->_tpl_vars[$params['array']][$field])) {
        $result = $view->_tpl_vars[$params['array']][$field];
        if ($unset) {
            unset($view->_tpl_vars[$params['array']][$field]);
        }
    }
    if ($assign) {
        $view->assign($assign, $result);
    } else {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified to get the required field.', array('array_field_pop', 'assign')));
        return false;
    }
}
コード例 #10
0
/**
 * Smarty function to display a drop down list of languages.
 *
 * This plugin as been superceded by html_select_languages.
 *
 * @deprecated
 * @param array  $params  All attributes passed to this function from the template.
 * @param object $smarty Reference to the Smarty object.
 *
 * @return string The value of the last status message posted, or void if no status message exists.
 */
function smarty_function_languagelist($params, $smarty)
{
    LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated, please use {%2$s} instead.', array('languagelist', 'html_select_languages')), E_USER_DEPRECATED);

    require_once $smarty->_get_plugin_filepath('function','html_select_languages');
    return smarty_function_html_select_languages($params, $smarty);
}
コード例 #11
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;
}
コード例 #12
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;
}
コード例 #13
0
/**
 * Assign a template variable with the value found in an array element at the specified key.
 *
 * Available attributes:
 *  - array     (array)         The array template variable in which to retrieve the value
 *  - key       (string|int)    The key into the specified array where the value is to be retrieved from
 *  - assign    (string)        The name of the template variable to assign the value to (required)
 *
 * Examples:
 *
 *  Assign the template variable $myVar with the value found in the template
 *  variable $myArray['myKey']:
 *
 *  <samp>{assign_arrayval array=$myArray key='myKey' assign='myVar'}</samp>
 *
 *  Assign the template variable $myVar with the value found in the template
 *  variable $myArray[3]:
 *
 *  <samp>{assign_arrayval array=$myArray key=3 assign='myVar'}</samp>
 *
 *  In the following example, assume the template variable $myArray[4] is not
 *  set (isset would return false). In this case $myVar is set to null:
 *
 *  <samp>{assign_arrayval array=$myArray key=4 assign='myVar'}</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_assign_arrayval($params, Zikula_View $view)
{
    LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated, please use {%2$s} instead.', array('assign_arrayval key="X" ...', 'array_field field="X" ...')), E_USER_DEPRECATED);
    $array = isset($params['array']) ? $params['array'] : array();
    $key = isset($params['key']) ? $params['key'] : '';
    $assign = isset($params['assign']) ? $params['assign'] : $key;
    $val = isset($array[$key]) ? $array[$key] : null;
    $view->assign($assign, $val);
}
コード例 #14
0
/**
 * Zikula_View function to create a zikula.orgpatible URL for a specific module function.
 *
 * This function returns a module URL string if successful. Unlike the API
 * function ModURL, this is already sanitized to display, so it should not be
 * passed to the safetext modifier.
 *
 * Available parameters:
 *   - modname:  The well-known name of a module for which to create the URL (required)
 *   - type:     The type of function for which to create the URL; currently one of 'user' or 'admin' (default is 'user')
 *   - func:     The actual module function for which to create the URL (default is 'main')
 *   - fragment: The fragement to target within the URL
 *   - ssl:      See below
 *   - fqurl:    Make a fully qualified URL
 *   - forcelongurl: Do not create a short URL (forced)
 *   - forcelang (boolean|string) Force the inclusion of the $forcelang or default system language in the generated url
 *   - append:   (optional) A string to be appended to the URL
 *   - assign:   If set, the results are assigned to the corresponding variable instead of printed out
 *   - all remaining parameters are passed to the module function
 *
 * Example
 * Create a URL to the News 'view' function with parameters 'sid' set to 3
 *   <a href="{modurl modname='News' type='user' func='display' sid='3'}">Link</a>
 *
 * Example SSL
 * Create a secure https:// URL to the News 'view' function with parameters 'sid' set to 3
 * ssl - set to constant null,true,false NOTE: $ssl = true not $ssl = 'true'  null - leave the current status untouched, true - create a ssl url, false - create a non-ssl url
 *   <a href="{modurl modname='News' type='user' func='display' sid='3' ssl=true}">Link</a>
 *
 * @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 URL.
 */
function smarty_function_modurl($params, Zikula_View $view)
{
    $assign = isset($params['assign']) ? $params['assign'] : null;
    $append = isset($params['append']) ? $params['append'] : '';
    $fragment = isset($params['fragment']) ? $params['fragment'] : null;
    $fqurl = isset($params['fqurl']) ? $params['fqurl'] : null;
    $forcelongurl = isset($params['forcelongurl']) ? (bool) $params['forcelongurl'] : false;
    if (isset($params['func']) && $params['func']) {
        $func = $params['func'];
    } else {
        if (System::isLegacyMode()) {
            $func = 'main';
            LogUtil::log(__f('{modurl} - %1$s is a required argument, you must specify it explicitly in %2$s', array('func', $view->template)), E_USER_DEPRECATED);
        } else {
            $view->trigger_error(__f('{modurl} - %1$s is a required argument, you must specify it explicitly in %2$s', array('func', $view->template)));
            return false;
        }
    }
    if (isset($params['type']) && $params['type']) {
        $type = $params['type'];
    } else {
        if (System::isLegacyMode()) {
            $type = 'user';
            LogUtil::log(__f('{modurl} - %1$s is a required argument, you must specify it explicitly in %2$s', array('type', $view->template)), E_USER_DEPRECATED);
        } else {
            $view->trigger_error(__f('{modurl} - %1$s is a required argument, you must specify it explicitly in %2$s', array('type', $view->template)));
            return false;
        }
    }
    $modname = isset($params['modname']) ? $params['modname'] : null;
    $ssl = isset($params['ssl']) ? (bool) $params['ssl'] : null;
    $forcelang = isset($params['forcelang']) && $params['forcelang'] ? $params['forcelang'] : false;
    // avoid passing these to ModUtil::url
    unset($params['modname']);
    unset($params['type']);
    unset($params['func']);
    unset($params['fragment']);
    unset($params['ssl']);
    unset($params['fqurl']);
    unset($params['assign']);
    unset($params['append']);
    unset($params['forcelang']);
    unset($params['forcelongurl']);
    if (!$modname) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('modurl', 'modname')));
        return false;
    }
    $result = ModUtil::url($modname, $type, $func, $params, $ssl, $fragment, $fqurl, $forcelongurl, $forcelang);
    if ($append && is_string($append)) {
        $result .= $append;
    }
    if ($assign) {
        $view->assign($assign, $result);
    } else {
        return DataUtil::formatForDisplay($result);
    }
}
コード例 #15
0
ファイル: function.title.php プロジェクト: projectesIF/Sirius
/**
 * Zikula_View function to generate the title for the page
 *
 * Available parameters:
 *  - assign     if set, the title will be assigned to this variable
 *
 * Example
 * {title}
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the Zikula_View object.
 *
 * @see    function.title.php::smarty_function_title()
 *
 * @return string The title.
 */
function smarty_function_title($params, $view)
{
    LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated, please use {%2$s} instead.', array('title', "pagegetvar name='title'")), E_USER_DEPRECATED);
    $title = PageUtil::getVar('title');
    if (isset($params['assign'])) {
        $view->assign($params['assign'], $title);
    } else {
        return $title;
    }
}
コード例 #16
0
/**
 * Zikula_View function to display the sitename
 *
 * Available parameters:
 *  - assign     if set, the title will be assigned to this variable
 *
 * Example
 * {sitename}
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the Zikula_View object.
 *
 * @see    function.sitename.php::smarty_function_sitename()
 * @return string The sitename.
 */
function smarty_function_sitename($params, $view)
{
    LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated, please use {%2$s} instead.', array('sitename', '$modvars.ZConfig.sitename')), E_USER_DEPRECATED);
    $sitename = System::getVar('sitename');
    if (isset($params['assign'])) {
        $view->assign($params['assign'], $sitename);
    } else {
        return $sitename;
    }
}
コード例 #17
0
/**
 * Zikula_View function to get the meta keywords
 *
 * This function will take the contents of the page and transfer it
 * into a keyword list. If stopwords are defined, they are filtered out.
 * The keywords are sorted by count.
 * As a default, the whole page contents are taken as a base for keyword
 * generation. If set, the contents of "contents" are taken.
 * Beware that the function always returns the site keywords if "generate
 * meta keywords" is turned off.
 *
 * available parameters:
 *  - contents    if set, this wil be taken as a base for the keywords
 *  - dynamic     if set, the keywords will be created from the content / mainconent
 *                oterwise we use the page vars. The rules are:
 *                1) If dynamic keywords disabled in admin settings then use static keywords
 *                2) if parameter "dynamic" not set or empty then always use main content (default),
 *                3) if parameter "dynamic" set and not empty then use page vars if any set - otherwise use content.
 *  - assign      if set, the keywords will be assigned to this variable
 *
 * Example
 * <meta name="KEYWORDS" content="{keywords}">
 *
 * @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 keywords.
 */
function smarty_function_keywords($params, $view)
{
    LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated.', array('keywords')), E_USER_DEPRECATED);
    $metatags = $view->getServiceManager()->getArgument('zikula_view.metatags');
    if (isset($params['assign'])) {
        $view->assign($params['assign'], $metatags['keywords']);
    } else {
        return $metatags['keywords'];
    }
}
コード例 #18
0
/**
 * Zikula_View modifier to apply transform hooks
 *
 * This modifier will run the transform hooks that are enabled for the
 * corresponding module (like Autolinks, bbclick and others).
 *
 * Available parameters:
 *   - modname:  The well-known name of the calling module; passed to the hook function
 *               in the extrainfo array
 * Example
 *
 *   {$MyVar|modcallhooks}
 *
 * @param mixed  $string  The contents to transform.
 * @param string $modname Module name.
 *
 * @return string The modified output.
 */
function smarty_modifier_modcallhooks($string, $modname = '')
{
    LogUtil::log(__f('Warning! Template modifier {$var|%1$s} is deprecated.', array('modcallhooks')), E_USER_DEPRECATED);
    $extrainfo = array($string);
    if (!empty($modname)) {
        $extrainfo['module'] = $modname;
    }
    list($string) = ModUtil::callHooks('item', 'transform', '', $extrainfo);
    return $string;
}
コード例 #19
0
/**
 * Smarty function to provide easy access to a stylesheet.
 *
 * This function provides an easy way to include a stylesheet. The function will add the stylesheet
 * file to the 'stylesheet' pagevar by default
 *
 * This plugin is obsolete since Zikula 1.1.0. The stylesheets are loaded automatically whenever a module
 * or block is loaded. We keep this file for the sake of backwards compatibility so that themes do not break.
 *
 * @param array  $params  All attributes passed to this function from the template.
 * @param object &$smarty Reference to the Smarty object.
 *
 * @return void But Add Js header if admin
 */
function smarty_function_modulestylesheet($params, &$smarty)
{
    LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated.', array('modulestylesheet')), E_USER_DEPRECATED);
    // do nothing unless we are admin
    if (SecurityUtil::checkPermission('::', '::', ACCESS_ADMIN)) {
        PageUtil::addVar('javascript', 'javascript/ajax/prototype.js');
        PageUtil::addVar('header', '<script type="text/javascript">/* <![CDATA[ */ Event.observe(window, "load", function() { alert("' . __('You can safely remove the modulestylesheet plugin from your theme. It is obsolete since Zikula 1.1.0. The adding of stylesheet files has been automated and does not need user interference. This note is shown to Administrators only.') . '");}); /* ]]> */</script>');
    }
    return;
}
コード例 #20
0
/**
 * Smarty function to get the users language
 *
 * This function determines the recent users language
 *
 * Available parameters:
 *   - assign:  If set, the result is assigned to the corresponding variable instead of printed out
 *
 * Example
 *   {usergetlang name="foobar"}
 *
 * @param        array       $params      All attributes passed to this function from the template
 * @param        object      $smarty     Reference to the Smarty object
 * @param        string      $assign      (optional) The name of the variable to assign the result to
 * @return       string      The recent users language
 */
function smarty_function_usergetlang($params, $smarty)
{
    LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated, please use {%2$s} instead.', array('usergetlang', 'lang')), E_USER_DEPRECATED);
    $assign = isset($params['assign']) ? $params['assign'] : null;
    $result = ZLanguage::getLanguageCodeLegacy();
    if ($assign) {
        $smarty->assign($assign, $result);
        return;
    }
    return $result;
}
コード例 #21
0
/**
 * Zikula_View function to obtain base URL for this site
 *
 * This function obtains the base URL for the site. The base url is defined as the
 * full URL for the site minus any file information  i.e. everything before the
 * 'index.php' from your start page.
 * Unlike the API function System::getBaseUrl, the results of this function are already
 * sanitized to display, so it should not be passed to the safetext modifier.
 *
 * Available parameters:
 *   - assign:   If set, the results are assigned to the corresponding variable instead of printed out
 *
 * Example
 *   {getbaseurl}
 *
 * @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 base URL of the site.
 */
function smarty_function_getbaseurl($params, Zikula_View $view)
{
    LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated, please use {%2$s} instead.', array('getbaseurl', '$baseurl')), E_USER_DEPRECATED);
    $assign = isset($params['assign']) ? $params['assign'] : null;
    $result = htmlspecialchars(System::getBaseUrl());
    if ($assign) {
        $view->assign($assign, $result);
    } else {
        return $result;
    }
}
コード例 #22
0
/**
 * Zikula_View insert function to dynamically generated an authorisation key
 *
 * Available parameters:
 *   - module:   The well-known name of a module to execute a function from (required)
 *   - assign:   If set, the results are assigned to the corresponding variable instead of printed out
 *
 * Example
 * <input type="hidden" name="authid" value="{insert name='generateauthkey' module='Users'}" />
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the Zikula_View object.
 *
 * @return string
 */
function smarty_insert_generateauthkey($params, $view)
{
    LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated, please use {%2$s} instead.', array('insert name="secgenauthkey" ...', "insert name='csrftoken' ...")), E_USER_DEPRECATED);
    $module = isset($params['module']) ? $params['module'] : null;
    if (!$module) {
        $module = ModUtil::getName();
    }
    $result = SecurityUtil::generateAuthKey($module);
    // NOTE: assign parameter is handled by the smarty_core_run_insert_handler(...) function in lib/vendor/Smarty/internals/core.run_insert_handler.php
    return $result;
}
コード例 #23
0
/**
 * Zikula_View function to get the site's charset.
 *
 * This function will return the Zikula version number
 *
 * available parameters:
 *  - assign      if set, the language will be assigned to this variable
 *
 * @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 version string.
 */
function smarty_function_version($params, $view)
{
    LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated, please use {%2$s} instead.', array('version', '$coredata.version_num')), E_USER_DEPRECATED);
    $assign = isset($params['assign']) ? $params['assign'] : null;
    $return = Zikula_Core::VERSION_NUM;
    if ($assign) {
        $view->assign($assign, $return);
    } else {
        return $return;
    }
}
コード例 #24
0
/**
 * Zikula_View function to obtain status message
 *
 * This function obtains the last status message posted for this session.
 * The status message exists in one of two session variables: '_ZStatusMsg' for a
 * status message, or '_ZErrorMsg' for an error message. If both a status and an
 * error message exists then the error message is returned.
 *
 * This is is a destructive function - it deletes the two session variables
 * '_ZStatusMsg' and 'erorrmsg' during its operation.
 *
 * Note that you must not cache the outputs from this function, as its results
 * change aech time it is called. The Zikula developers are looking for ways to
 * automise this.
 *
 *
 * Available parameters:
 *   - assign:   If set, the status message is assigned to the corresponding variable instead of printed out
 *   - style, class: If set, the status message is being put in a div tag with the respective attributes
 *   - tag:      You can specify if you would like a span or a div tag
 *
 * Example
 *   {getstatusmsg}
 *   {getstatusmsg style='color:red;'}
 *   {getstatusmsg class='statusmessage' tag='span'}
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the Zikula_View object.
 *
 * @todo prevent this function from being cached
 * @deprecated
 *
 * @return string|void The value of the last status message posted, or void if no status message exists.
 */
function smarty_function_getstatusmsg($params, Zikula_View $view)
{
    LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated, please use {%2$s} instead.', array('getstatusmsg', 'insert name="getstatusmsg"')), E_USER_DEPRECATED);

    $assign = isset($params['assign'])  ? $params['assign']  : null;
    $class  = isset($params['class'])   ? $params['class']   : null;
    $style  = isset($params['style'])   ? $params['style']   : null;
    $tag    = isset($params['tag'])     ? $params['tag']     : null;

    //prepare output var
    $output = '';

    // $msgStatus = LogUtil::getStatusMessages();
    // we do not use LogUtil::getStatusMessages() because we need to know if we have to
    // show a status or an error
    $session = $view->getServiceManager()->getService('session');
    $msgStatus = $session->getMessages(Zikula_Session::MESSAGE_STATUS);
    $msgtype   = ($class ? $class : 'z-statusmsg');
    $session->clearMessages(Zikula_Session::MESSAGE_STATUS);
    $msgError = $session->getMessages(Zikula_Session::MESSAGE_ERROR);
    $session->clearMessages(Zikula_Session::MESSAGE_ERROR);

    // Error message overrides status message
    if (!empty($msgError)) {
        $msgStatus = $msgError;
        $msgtype   = ($class ? $class : 'z-errormsg');
    }

    if ($assign) {
        $view->assign($assign, $msgStatus);
        return;
    }

    if (empty($msgStatus) || count($msgStatus)==0) {
        return $output;
    }

    // some parameters have been set, so we build the complete tag
    if (!$tag || $tag != 'span') {
        $tag = 'div';
    }

    // need to build a proper error message from message array
    $output = '<' . $tag . ' class="' . $msgtype . '"';
    if ($style) {
        $output .= ' style="' . $style . '"';
    }

    $output .= '>';
    $output .= implode ('<hr />', $msgStatus);
    $output .= '</' . $tag . '>';

    return $output;
}
コード例 #25
0
/**
 * Smarty function to generate a unique key to secure forms content as unique.
 *
 * Note that you must not cache the outputs from this function, as its results
 * change aech time it is called. The Zikula developers are looking for ways to
 * automise this.
 *
 *
 * Available parameters:
 *   - module:   The well-known name of a module to execute a function from (required)
 *   - assign:   If set, the results are assigned to the corresponding variable instead of printed out
 *
 * Example
 *   <input type="hidden" name="authid" value="{securityutil_generateauthkey module='MyModule'}">
 *
 * @todo         prevent this function from being cached (Smarty 2.6.0)
 * @param        array       $params      All attributes passed to this function from the template
 * @param        object      $smarty     Reference to the Smarty object
 * @return       string      the authentication key
 * @deprecated
 */
function smarty_function_securityutil_generateauthkey($params, $smarty)
{
    LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated, please use {%2$s} instead.', array('securityutil_generateauthkey', 'insert.generateauthkey')), E_USER_DEPRECATED);
    if (!isset($params['module'])) {
        $smarty->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('securityutil_generateauthkey', 'module')));
        return false;
    }
    $result = SecurityUtil::generateAuthKey($params['module']);
    if (isset($params['assign'])) {
        $smarty->assign($params['assign'], $result);
    } else {
        return $result;
    }
}
コード例 #26
0
/**
 * Zikula_View function to add the contents of a block to either the header or footer multicontent page variable
 *
 * This function adds the content of the block to either the end of the <head> portion of the page (using 'header') or to
 * a position just prior to the closing </body> tag (using 'footer').
 *
 * Available parameters:
 *   - name:     The name of the page variable to set, either 'header' or 'footer'; optional, default is 'header'
 *
 * Examples:
 *
 *  This inline stylesheet will appear in the page's <head> section just before the closing </head>:
 * <code>
 *   {pageaddvarblock name='header'}
 *   <style type="text/css">
 *       p { font-size: 1.5em; }
 *   </style>
 *   {/pageaddvarblock}
 * </code>
 *
 *  This inline script will appear in the page's <body> section just before the closing </body>:
 * <code>
 *   {pageaddvarblock name='footer'}
 *   <script language="javascript" type="text/javascript">
 *       alert ('The closing </body> tag is coming.');
 *   </style>
 *   {/pageaddvarblock}
 * </code>
 *
 * @param array       $params  All attributes passed to this function from the template.
 * @param string      $content The content of the block.
 * @param Zikula_View $view    Reference to the Zikula_View object.
 *
 * @return string
 */
function smarty_block_pageaddvarblock($params, $content, Zikula_View $view)
{
    if ($content) {
        $varname = isset($params['name']) ? $params['name'] : 'header';
        if (System::isLegacyMode() && $varname == 'rawtext') {
            LogUtil::log(__f('Warning! The page variable %1$s is deprecated. Please use %2$s instead.', array('rawtext', 'header')), E_USER_DEPRECATED);
            $varname = 'header';
        }
        if ($varname != 'header' && $varname != 'footer') {
            throw new Zikula_Exception_Fatal(__f('Invalid page variable name: \'%1$s\'.', array($varname)));
        }
        PageUtil::addVar($varname, $content);
    }
}
コード例 #27
0
/**
 * Smarty function to generate a unique key to secure forms content as unique.
 *
 * Note that you must not cache the outputs from this function, as its results
 * change aech time it is called. The Zikula developers are looking for ways to
 * automise this.
 *
 *
 * Available parameters:
 *   - module:   The well-known name of a module to execute a function from (required)
 *   - assign:   If set, the results are assigned to the corresponding variable instead of printed out
 *
 * Example
 *   <input type="hidden" name="authid" value="{secgenauthkey module="MyModule"}">
 *
 * @todo         prevent this function from being cached (Smarty 2.6.0)
 * @param        array       $params      All attributes passed to this function from the template
 * @param        object      $smarty     Reference to the Smarty object
 * @return       string      the authentication key
 * @deprecated
 */
function smarty_function_secgenauthkey($params, $smarty)
{
    LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated, please use {%2$s} instead.', array('secgenauthkey', 'insert name="csrftoken"')), E_USER_DEPRECATED);
    $assign = isset($params['assign']) ? $params['assign'] : null;
    $module = isset($params['module']) ? $params['module'] : null;
    if (!$module) {
        $module = ModUtil::getName();
    }
    $result = SecurityUtil::generateAuthKey($module);
    if ($assign) {
        $smarty->assign($assign, $result);
    } else {
        return $result;
    }
}
コード例 #28
0
/**
 * Smarty function to displaya modules online manual
 *
 * Admin
 * {adminonlinemanual}
 *
 * @see          function.admincategorymenu.php::smarty_function_admincategoreymenu()
 * @param        array       $params      All attributes passed to this function from the template
 * @param        object      $smarty     Reference to the Smarty object
 * @param        int         xhtml        if set, the link to the navtabs.css will be xhtml compliant
 * @return       string      the results of the module function
 */
function smarty_function_adminonlinemanual($params, $smarty)
{
    LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated.', array('adminonlinemanual')), E_USER_DEPRECATED);
    $lang = ZLanguage::transformFS(ZLanguage::getLanguageCode());
    $modinfo = ModUtil::getInfoFromName(ModUtil::getName());
    $modpath = $modinfo['type'] == ModUtil::TYPE_SYSTEM ? 'system' : 'modules';
    $file = DataUtil::formatForOS("{$modpath}/{$modinfo['directory']}/lang/{$lang}/manual.html");
    $man_link = '';
    if (is_readable($file)) {
        PageUtil::addVar('javascript', 'zikula.ui');
        $man_link = '<div style="margin-top: 20px; text-align:center">[ <a id="online_manual" href="' . $file . '">' . __('Online manual') . '</a> ]</div>' . "\n";
        $man_link .= '<script type="text/javascript">var online_manual = new Zikula.UI.Window($(\'online_manual\'),{resizable: true})</script>' . "\n";
    }
    return $man_link;
}
コード例 #29
0
/**
 * Zikula_View function call hooks
 *
 * This function calls a specific module function.  It returns whatever the return
 * value of the resultant function is if it succeeds.
 * Note that in contrast to the API function modcallhooks you need not to load the
 * module with ModUtil::load.
 *
 *
 * Available parameters:
 * - 'hookobject' the object the hook is called for - either 'item' or 'category'
 * - 'hookaction' the action the hook is called for - one of 'create', 'delete', 'transform', or 'display'
 * - 'hookid'     the id of the object the hook is called for (module-specific)
 * - 'implode'    Implode collapses all display hooks into a single string.
 * - 'assign'     If set, the results are assigned to the corresponding variable instead of printed out
 * - all remaining parameters are passed to the ModUtil::callHooks API via the extrainfo array
 *
 * Example
 * {modcallhooks hookobject='item' hookaction='modify' hookid=$tid $modname='ThisModule' $objectid=$tid}
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the Zikula_View object.
 *
 * @see    function.modcallhooks.php::smarty_function_modcallhooks()
 * 
 * @return string The results of the module function.
 */
function smarty_function_modcallhooks($params, $view)
{
    LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated, please use {%2$s} instead.', array('modcallhooks', 'notifydisplayhooks')), E_USER_DEPRECATED);

    $assign     = isset($params['assign'])     ? $params['assign']        : null;
    $hookid     = isset($params['hookid'])     ? $params['hookid']        : '';
    $hookaction = isset($params['hookaction']) ? $params['hookaction']    : null;
    $hookobject = isset($params['hookobject']) ? $params['hookobject']    : null;
    $implode    = isset($params['implode'])    ? (bool)$params['implode'] : true;

    // avoid sending these to ModUtil::callHooks
    unset($params['hookobject']);
    unset($params['hookaction']);
    unset($params['hookid']);
    unset($params['assign']);
    unset($params['implode']);

    if (!$hookobject) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('modcallhooks', 'hookobject')));
        return false;
    }
    if (!$hookaction) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('modcallhooks', 'hookaction')));
        return false;
    }
    if (!$hookid) {
        $hookid = '';
    }
    
    // create returnurl if not supplied (= this page)
    if (!isset($params['returnurl']) || empty($params['returnurl'])) {
        $params['returnurl'] = str_replace('&amp;', '&', 'http://' . System::getHost() . System::getCurrentUri());
    }

    // if the implode flag is true then we must always assign the result to a template variable
    // outputing the erray is no use....
    if (!$implode) {
        $assign = 'hooks';
    }

    $result = ModUtil::callHooks($hookobject, $hookaction, $hookid, $params, $implode);

    if ($assign) {
        $view->assign($assign, $result);
    } else {
        return $result;
    }
}
コード例 #30
0
/**
 * Smarty function to obtain form variable.
 *
 * This plugin obtains the variable from the input namespace. It removes any preparsing
 * done by PHP to ensure that the string is exactly as expected, without any escaped characters.
 * it also removes any HTML tags that could be considered dangerous to the Zikula system's security.
 *
 * Available parameters:
 *   - name: the name of the parameter
 *   - assign:   If set, the results are assigned to the corresponding variable instead of printed out
 *
 * @param array  $params  All attributes passed to this function from the template.
 * @param object &$smarty Reference to the Smarty object.
 *
 * @return       string      the variables content
 */
function smarty_function_varcleanfrominput($params, $smarty)
{
    LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated, please use {%2$s} instead.', array('varcleanfrominput', 'formutil_getpassedvalue')), E_USER_DEPRECATED);
    $assign = isset($params['assign']) ? $params['assign'] : null;
    $name = isset($params['name']) ? $params['name'] : null;
    if (!$name) {
        $smarty->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('varcleanfrominput', 'name')));
        return false;
    }
    $result = FormUtil::getPassedValue($name);
    if ($assign) {
        $smarty->assign($assign, $result);
    } else {
        return $result;
    }
}