Пример #1
0
/**
 * Smarty function to wrap Zikula_Form_View generated form controls with suitable form tags.
 *
 * @param array            $params  Parameters passed in the block tag.
 * @param string           $content Content of the block.
 * @param Zikula_Form_View $view    Reference to Zikula_Form_View object.
 *
 * @return string The rendered output.
 */
function smarty_block_form($params, $content, $view)
{
    if ($content) {
        PageUtil::AddVar('stylesheet', 'system/ThemeModule/Resources/public/css/form/style.css');
        $action = htmlspecialchars(System::getCurrentUri());
        $classString = '';
        $roleString = '';
        if (isset($params['cssClass'])) {
            $classString = "class=\"{$params['cssClass']}\" ";
        }
        if (isset($params['role'])) {
            $roleString = "role=\"{$params['role']}\" ";
        }
        $enctype = array_key_exists('enctype', $params) ? $params['enctype'] : null;
        // if enctype is not set directly, check whenever upload plugins were used;
        // if so - set proper enctype for file upload
        if (is_null($enctype)) {
            $uploadPlugins = array_filter($view->plugins, function ($plugin) {
                return $plugin instanceof Zikula_Form_Plugin_UploadInput;
            });
            if (!empty($uploadPlugins)) {
                $enctype = 'multipart/form-data';
            }
        }
        $encodingHtml = !is_null($enctype) ? " enctype=\"{$enctype}\"" : '';
        $onSubmit = isset($params['onsubmit']) ? " onSubmit=\"{$params['onsubmit']}\"" : '';
        $view->postRender();
        $formId = $view->getFormId();
        $out = "\n<form id=\"{$formId}\" {$roleString}{$classString}action=\"{$action}\" method=\"post\"{$encodingHtml}{$onSubmit}>\n    {$content}\n    <div>\n        {$view->getStateHTML()}\n        {$view->getStateDataHTML()}\n        {$view->getIncludesHTML()}\n        {$view->getCsrfTokenHtml()}\n        <input type=\"hidden\" name=\"__formid\" id=\"form__id\" value=\"{$formId}\" />\n        <input type=\"hidden\" name=\"FormEventTarget\" id=\"FormEventTarget\" value=\"\" />\n        <input type=\"hidden\" name=\"FormEventArgument\" id=\"FormEventArgument\" value=\"\" />\n        <script type=\"text/javascript\">\n        <!--\n            function FormDoPostBack(eventTarget, eventArgument)\n            {\n                var f = document.getElementById('{$formId}');\n                if (!f.onsubmit || f.onsubmit()) {\n                    f.FormEventTarget.value = eventTarget;\n                    f.FormEventArgument.value = eventArgument;\n                    f.submit();\n                }\n            }\n        // -->\n        </script>\n    </div>\n</form>\n";
        return $out;
    }
}
Пример #2
0
/**
 * Smarty function to wrap MUBoard_Form_View generated form controls with suitable form tags.
 *
 * @param array            $params  Parameters passed in the block tag.
 * @param string           $content Content of the block.
 * @param Zikula_Form_View $view    Reference to Zikula_Form_View object.
 *
 * @return string The rendered output.
 */
function smarty_block_muboardform($params, $content, $view)
{
    if ($content) {
        PageUtil::addVar('stylesheet', 'system/Theme/style/form/style.css');
        $encodingHtml = array_key_exists('enctype', $params) ? " enctype=\"{$params['enctype']}\"" : '';
        $action = htmlspecialchars(System::getCurrentUri());
        $classString = '';
        if (isset($params['cssClass'])) {
            $classString = "class=\"{$params['cssClass']}\" ";
        }
        $request = new Zikula_Request_Http();
        $id = $request->getGet()->filter('id', 0, FILTER_SANITIZE_NUMBER_INT);
        $forumid = $request->getGet()->filter('forum', 0, FILTER_SANITIZE_NUMBER_INT);
        // we check if the entrypoint is part of the url
        $stripentrypoint = ModUtil::getVar('ZConfig', 'shorturlsstripentrypoint');
        // get url name
        $tables = DBUtil::getTables();
        $modcolumn = $tables['modules_column'];
        $module = 'MUBoard';
        $where = "{$modcolumn['name']} = '" . DataUtil::formatForStore($module) . "'";
        $module = DBUtil::selectObject('modules', $where);
        $urlname = $module['url'];
        if (ModUtil::getVar('ZConfig', 'shorturls') == 0) {
            if (strpos($action, "func=display") !== false) {
                $action = 'index.php?module=' . $urlname . '&amp;type=user&amp;func=edit&amp;ot=posting&amp;answer=1';
            }
            if (strpos($action, "func=edit&ot=posting") !== false && $forumid > 0) {
                $action = 'index.php?module=' . $urlname . '&amp;type=user&amp;func=edit&amp;ot=posting&amp;forum' . $forumid;
            }
        } else {
            if (strpos($action, $urlname . "/posting/id.") !== false) {
                if ($stripentrypoint == 1) {
                    $action = $urlname . '/edit/ot/posting/answer/1';
                } elseif ($stripentrypoint == 0) {
                    $action = 'index.php/' . $urlname . '/edit/ot/posting/answer/1';
                }
            }
            if (strpos($action, "edit/ot/posting/forum/") !== false && $forumid > 0) {
                if ($stripentrypoint == 1) {
                    $action = $urlname . '/edit/ot/posting/forum/' . $forumid;
                } elseif ($stripentrypoint == 0) {
                    $action = 'index.php/' . $urlname . '/edit/ot/posting/forum/' . $forumid;
                }
            }
        }
        $view->postRender();
        $formId = $view->getFormId();
        $out = "\n        <form id=\"{$formId}\" {$classString}action=\"{$action}\" method=\"post\"{$encodingHtml}>\n        {$content}\n        <div>\n        {$view->getStateHTML()}\n        {$view->getStateDataHTML()}\n        {$view->getIncludesHTML()}\n        {$view->getCsrfTokenHtml()}\n        <input type=\"hidden\" name=\"__formid\" id=\"form__id\" value=\"{$formId}\" />\n        <input type=\"hidden\" name=\"FormEventTarget\" id=\"FormEventTarget\" value=\"\" />\n        <input type=\"hidden\" name=\"FormEventArgument\" id=\"FormEventArgument\" value=\"\" />\n        <script type=\"text/javascript\">\n        <!--\n        function FormDoPostBack(eventTarget, eventArgument)\n        {\n        var f = document.getElementById('{$formId}');\n        if (!f.onsubmit || f.onsubmit())\n        {\n        f.FormEventTarget.value = eventTarget;\n        f.FormEventArgument.value = eventArgument;\n        f.submit();\n    }\n    }\n    // -->\n    </script>\n    </div>\n    </form>\n    ";
        return $out;
    }
}
Пример #3
0
/**
 * Smarty function to wrap Zikula_Form_View generated form controls with suitable form tags.
 *
 * @param array            $params  Parameters passed in the block tag.
 * @param string           $content Content of the block.
 * @param Zikula_Form_View $view    Reference to Zikula_Form_View object.
 *
 * @return string The rendered output.
 */
function smarty_block_form($params, $content, $view)
{
    if ($content) {
        PageUtil::addVar('stylesheet', 'system/Theme/style/form/style.css');
        $encodingHtml = array_key_exists('enctype', $params) ? " enctype=\"{$params['enctype']}\"" : '';
        $action = htmlspecialchars(System::getCurrentUri());
        $classString = '';
        if (isset($params['cssClass'])) {
            $classString = "class=\"{$params['cssClass']}\" ";
        }
        $view->postRender();
        $formId = $view->getFormId();
        $out = "\n<form id=\"{$formId}\" {$classString}action=\"{$action}\" method=\"post\"{$encodingHtml}>\n    {$content}\n    <div>\n        {$view->getStateHTML()}\n        {$view->getStateDataHTML()}\n        {$view->getIncludesHTML()}\n        {$view->getCsrfTokenHtml()}\n        <input type=\"hidden\" name=\"__formid\" id=\"form__id\" value=\"{$formId}\" />\n        <input type=\"hidden\" name=\"FormEventTarget\" id=\"FormEventTarget\" value=\"\" />\n        <input type=\"hidden\" name=\"FormEventArgument\" id=\"FormEventArgument\" value=\"\" />\n        <script type=\"text/javascript\">\n        <!--\n            function FormDoPostBack(eventTarget, eventArgument)\n            {\n                var f = document.getElementById('{$formId}');\n                if (!f.onsubmit || f.onsubmit())\n                {\n                    f.FormEventTarget.value = eventTarget;\n                    f.FormEventArgument.value = eventArgument;\n                    f.submit();\n                }\n            }\n        // -->\n        </script>\n    </div>\n</form>\n";
        return $out;
    }
}