/**
 * Smarty function to display a single inline user link of a specific policy for the Legal module.
 *
 * Example
 * {legalinlinelink policytype='termsofuse'}
 *
 * Tag Parameters:
 *      policyType  The unique string identifier of the policy typw whose inline link is to be returned; required.
 *      target      The target for the generated link, such as "_blank" to open the policy in a new window; optional, default is blank (same effect as "_self").
 *      assign      The name of the template variable to which the output is assiged, if provided; optional, if not specified the output is sent to the template.
 *
 * Templates used:
 *      legal_function_legalinlinelink_notfound.tpl
 *      legal_function_legalinlinelink_legalnotice.tpl
 *      legal_function_legalinlinelink_termsofuse.tpl
 *      legal_function_legalinlinelink_privacypolicy.tpl
 *      legal_function_legalinlinelink_tradeconditions.tpl
 *      legal_function_legalinlinelink_cancellationrightpolicy.tpl
 *      legal_function_legalinlinelink_accessibilitystatement.tpl
 *
 * Template Parameters Exported:
 *      $target  The target for the generated link, such as "_blank" to open the policy in a new window; optional, default is blank (same effect as "_self").
 *      (assign) If an assign tag parameter is specified, then a template variable a name equal to the value of the assign parameter is exported, containing the rendered output; optional, default is to return the output to the template.
 *
 * @param array       $params All parameters passed to this function from the template.
 * @param Zikula_View &$view  Reference to the Zikula view object, a subclass of Smarty.
 *
 * @return string The rendered template output for the specified policy type.
 */
function smarty_function_legalinlinelink($params, Zikula_View &$view)
{
    if (!isset($params['policyType'])) {
        $template = 'plugins/legal_function_legalinlinelink_notfound.tpl';
    } else {
        $params['policyType'] = strtolower($params['policyType']);
        $template = 'plugins/legal_function_legalinlinelink_' . $params['policyType'] . '.tpl';

        if (!$view->template_exists($template)) {
            $template = 'plugins/legal_function_legalinlinelink_notfound.tpl';
        }
    }

    $templateVars = array(
        'target' => isset($params['target']) ? $params['target'] : ''
    );

    $view->assign($templateVars);

    if (isset($params['assign']) && !empty($params['assign'])) {
        $view->assign($params['assign'], $view->fetch($template));
    } else {
        return $view->fetch($template);
    }
}
 /**
  * @param array $args
  *
  * @deprecated Use "getAuthenticationMethodSelectorAction" instead.
  *
  * @return string
  *
  * @throws \InvalidArgumentException
  * @throws FatalErrorException
  */
 public function getAuthenticationMethodSelector(array $args)
 {
     // Parameter extraction and error checking
     if (!isset($args) || !is_array($args)) {
         throw new \InvalidArgumentException($this->__('An invalid \'$args\' parameter was received.'));
     }
     if (!isset($args['form_type']) || !is_string($args['form_type'])) {
         throw new \InvalidArgumentException($this->__f('An invalid form type (\'%1$s\') was received.', array(isset($args['form_type']) ? $args['form_type'] : 'NULL')));
     }
     if (!isset($args['form_action']) || !is_string($args['form_action'])) {
         throw new \InvalidArgumentException($this->__f('An invalid form action (\'%1$s\') was received.', array(isset($args['form_action']) ? $args['form_action'] : 'NULL')));
     }
     if (!isset($args['method']) || !is_string($args['method']) || !$this->supportsAuthenticationMethod($args['method'])) {
         throw new \InvalidArgumentException($this->__f('Error: An invalid method (\'%1$s\') was received.', array(isset($args['method']) ? $args['method'] : 'NULL')));
     }
     // End parameter extraction and error checking
     if ($this->authenticationMethodIsEnabled($args['method'])) {
         /** @var \Zikula\UsersModule\Helper\AuthenticationMethodHelper $authenticationMethod */
         $authenticationMethod = $this->getAuthenticationMethod($args['method']);
         $icon = $authenticationMethod->getIcon();
         $isFontAwesomeIcon = $authenticationMethod->isFontAwesomeIcon();
         $templateVars = array('authentication_method' => array('modname' => $this->name, 'method' => $args['method']), 'is_selected' => isset($args['is_selected']) && $args['is_selected'], 'form_type' => $args['form_type'], 'form_action' => $args['form_action'], 'submit_text' => $authenticationMethod->getShortDescription(), 'icon' => $icon, 'isFontAwesomeIcon' => $isFontAwesomeIcon, 'skipLoginFormFieldsPage' => $authenticationMethod->getSkipLoginFormFieldsPage() && $args['form_type'] === 'registration');
         $view = new Zikula_View($this->serviceManager, 'ZikulaUsersModule', Zikula_View::CACHE_ENABLED);
         $view->assign($templateVars);
         $templateName = "Authentication/AuthenticationMethodSelector/{$args['form_type']}/Base.tpl";
         if (!$view->template_exists($templateName)) {
             $templateName = "Authentication/AuthenticationMethodSelector/Base/Base.tpl";
             if (!$view->template_exists($templateName)) {
                 throw new FatalErrorException($this->__f('A form fields template was not found for the %1$s method using form type \'%2$s\'.', array($args['method'], $args['form_type'])));
             }
         }
         return $this->response($view->fetch($templateName));
     } else {
         return $this->response('');
     }
 }
Beispiel #3
0
 /**
  * Render template.
  *
  * @param Zikula_View $render       Renderer.
  * @param string      $objectType   Object type.
  * @param string      $type         Controller.
  * @param string      $func         Function of Controller.
  * @param string      $theme        Theme to use (themes are subfolders in /templates).
  * @param string      $tpl          Sub template name.
  * @param string      $defaultTheme Default theme (Use if $theme is null).
  *
  * @return string Rendered Template (HTML)
  */
 private function _renderTemplate(Zikula_View $render, $objectType, $type, $func, $theme = null, $tpl = null, $defaultTheme = null)
 {
     $template = $type . '_' . $func . '_' . $objectType;
     if ($tpl != null) {
         $template .= '_' . $tpl;
     }
     $template .= '.tpl';
     if (!empty($theme) && $render->template_exists(DataUtil::formatForOS($theme) . '/' . $template)) {
         $template = DataUtil::formatForOS($theme) . '/' . $template;
     } else {
         if (!empty($defaultTheme) && $render->template_exists(DataUtil::formatForOS($defaultTheme) . '/' . $template)) {
             $template = DataUtil::formatForOS($defaultTheme) . '/' . $template;
         }
     }
     return $render->fetch($template);
 }