コード例 #1
0
ファイル: Edit.php プロジェクト: projectesIF/Sirius
 /**
  * Handle form submission.
  *
  * @param Zikula_Form_View $view  Current Zikula_Form_View instance.
  * @param array            &$args Args.
  *
  * @return boolean
  */
 public function handleCommand(Zikula_Form_View $view, &$args)
 {
     // check for valid form
     if (!$view->isValid()) {
         return false;
     }
     // load form values
     $data = $view->getValues();
     $user = $this->_user;
     // merge attributes
     foreach ($data['attributes'] as $name => $value) {
         $user->setAttribute($name, $value);
     }
     // merge metadata
     $metadata = $user->getMetadata();
     if ($metadata == null) {
         $metadata = new ExampleDoctrine_Entity_UserMetadata($user);
         $user->setMetadata($metadata);
     }
     $metadata->merge($data['meta']);
     unset($data['attributes'], $data['meta']);
     // merge user and save everything
     $user->merge($data);
     $this->entityManager->persist($user);
     $this->entityManager->flush();
     return $view->redirect(ModUtil::url('ExampleDoctrine', 'user', 'view'));
 }
コード例 #2
0
ファイル: ModifyEditor.php プロジェクト: pheski/Scribite
 function handleCommand(Zikula_Form_View $view, &$args)
 {
     if ($args['commandName'] == 'cancel') {
         $url = ModUtil::url('Scribite', 'admin', 'main');
         return $view->redirect($url);
     } else {
         if ($args['commandName'] == 'restore') {
             $classname = 'ModulePlugin_Scribite_' . $this->editor . '_Plugin';
             if (method_exists($classname, 'getDefaults')) {
                 $defaults = $classname::getDefaults();
                 if (!empty($defaults)) {
                     ModUtil::setVars("moduleplugin.scribite." . strtolower($this->editor), $defaults);
                     LogUtil::registerStatus('Defaults succesfully restored.');
                 }
             }
             return true;
         }
     }
     // check for valid form
     if (!$view->isValid()) {
         return false;
     }
     $data = $view->getValues();
     ModUtil::setVars("moduleplugin.scribite." . strtolower($this->editor), $data);
     LogUtil::registerStatus($this->__('Done! Module configuration updated.'));
     return true;
 }
コード例 #3
0
ファイル: Config.php プロジェクト: rmaiwald/MUBoard
 /**
  * Initialize form handler.
  *
  * This method takes care of all necessary initialisation of our data and form states.
  *
  * @return boolean False in case of initialization errors, otherwise true.
  */
 public function initialize(Zikula_Form_View $view)
 {
     // permission check
     if (!SecurityUtil::checkPermission('MUBoard::', '::', ACCESS_ADMIN)) {
         return $view->registerError(LogUtil::registerPermissionError());
     }
     // retrieve module vars
     $modVars = ModUtil::getVar('MUBoard');
     // initialise list entries for the 'number images' setting
     $modVars['numberImagesItems'] = array(array('value' => '1', 'text' => '1'), array('value' => '2', 'text' => '2'), array('value' => '3', 'text' => '3'));
     // initialise list entries for the 'number files' setting
     $modVars['numberFilesItems'] = array(array('value' => '1', 'text' => '1'), array('value' => '2', 'text' => '2'), array('value' => '3', 'text' => '3'));
     // initialise list entries for the 'sorting postings' setting
     $modVars['sortingPostingsItems'] = array(array('value' => 'descending', 'text' => 'Descending'), array('value' => 'ascending', 'text' => 'Ascending'));
     // initialise list entries for the 'icon set' setting
     $modVars['iconSetItems'] = array(array('value' => '1', 'text' => '1'), array('value' => '2', 'text' => '2'), array('value' => '3', 'text' => '3'));
     // initialise list entries for the 'template' setting
     $modVars['templateItems'] = array(array('value' => 'normal', 'text' => 'Normal'), array('value' => 'jquery', 'text' => 'JQuery'));
     // assign all module vars
     $this->view->assign('config', $modVars);
     // custom initialisation aspects
     $this->initializeAdditions();
     // everything okay, no initialization errors occured
     return true;
 }
コード例 #4
0
ファイル: Reference.php プロジェクト: planetenkiller/core
 /**
  * Render event handler.
  *
  * @param Zikula_Form_View $view Reference to Form render object.
  *
  * @return string The rendered output
  */
 function render(Zikula_Form_View $view)
 {
     $imageURL = $this->imageURL == null ? 'images/icons/extrasmall/tab_right.png' : $this->imageURL;
     $menuPlugin = $view->getPluginById($this->menuId);
     $menuId = $menuPlugin->id;
     $html = "<img src=\"{$imageURL}\" alt=\"\" class=\"contextMenu\" onclick=\"Form.contextMenu.showMenu(event, '{$menuId}', '{$this->commandArgument}')\" />";
     return $html;
 }
コード例 #5
0
/**
 * Context menu reference
 *
 * This plugin creates a context menu reference.
 *
 * @param array            $params Parameters passed in the block tag.
 * @param Zikula_Form_View $view   Reference to Form render object.
 *
 * @return string The rendered output.
 */
function smarty_function_formcontextmenureference($params, $view)
{
    $output = $view->registerPlugin('Zikula_Form_Plugin_ContextMenu_Reference', $params);
    if (array_key_exists('assign', $params)) {
        $view->assign($params['assign'], $output);
    } else {
        return $output;
    }
}
コード例 #6
0
/**
 * The muboardSelectorTemplates plugin provides items for a dropdown selector.
 *
 * Available parameters:
 *   - 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  Zikula_Form_View $view    Reference to the view object.
 *
 * @return string The output of the plugin.
 */
function smarty_function_muboardGetLastPost($params, $view)
{
    $where = 'tbl.';
    ModUtil::apiFunc('MUBoard', 'selection', 'getEntities');
    if (array_key_exists('assign', $params)) {
        $view->assign($params['assign'], $result);
        return;
    }
    return $result;
}
コード例 #7
0
/**
 * The reviewsFormFrame plugin adds styling <div> elements and a validation summary.
 *
 * Available parameters:
 *   - 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 string           $content The content of the block.
 * @param Zikula_Form_View $view    Reference to the view object.
 *
 * @return string The output of the plugin.
 */
function smarty_block_reviewsFormFrame($params, $content, $view)
{
    // As with all Forms plugins, we must remember to register our plugin.
    // In this case we also register a validation summary so we don't have to
    // do that explicitively in the templates.
    // We need to concatenate the output of boths plugins.
    $result = $view->registerPlugin('\\Zikula_Form_Plugin_ValidationSummary', $params);
    $result .= $view->registerBlock('Reviews_Form_Plugin_FormFrame', $params, $content);
    return $result;
}
コード例 #8
0
ファイル: ClassSelector.php プロジェクト: robbrandt/Content
 function load(Zikula_Form_View $view, &$params)
 {
     if (!$view->isPostBack()) {
         $classes = ModUtil::apiFunc('Content', 'Admin', 'getStyleClasses');
         $empty = array(array('text' => '', 'value' => ''));
         $classes = array_merge($empty, $classes);
         $this->setItems($classes);
     }
     parent::load($view, $params);
 }
コード例 #9
0
/**
 * The reviewsObjectTypeSelector plugin provides items for a dropdown selector.
 *
 * Available parameters:
 *   - 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  Zikula_Form_View $view   Reference to the view object.
 *
 * @return string The output of the plugin.
 */
function smarty_function_reviewsObjectTypeSelector($params, $view)
{
    $dom = ZLanguage::getModuleDomain('Reviews');
    $result = array();
    $result[] = array('text' => __('Reviews', $dom), 'value' => 'review');
    if (array_key_exists('assign', $params)) {
        $view->assign($params['assign'], $result);
        return;
    }
    return $result;
}
コード例 #10
0
/**
 * The zikularoutesmoduleObjectTypeSelector plugin provides items for a dropdown selector.
 *
 * Available parameters:
 *   - 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  Zikula_Form_View $view   Reference to the view object.
 *
 * @return string The output of the plugin.
 */
function smarty_function_zikularoutesmoduleObjectTypeSelector($params, $view)
{
    $dom = \ZLanguage::getModuleDomain('ZikulaRoutesModule');
    $result = array();
    $result[] = array('text' => __('Routes', $dom), 'value' => 'route');
    if (array_key_exists('assign', $params)) {
        $view->assign($params['assign'], $result);
        return;
    }
    return $result;
}
コード例 #11
0
/**
 * The muboardSelectorTemplates plugin provides items for a dropdown selector.
 *
 * Available parameters:
 *   - 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  Zikula_Form_View $view    Reference to the view object.
 *
 * @return string The output of the plugin.
 */
function smarty_function_muboardSelectorTemplates($params, $view)
{
    $result = array();
    $result[] = array('text' => $view->__('Only item titles'), 'value' => 'itemlist_display.tpl');
    $result[] = array('text' => $view->__('With description'), 'value' => 'itemlist_display_description.tpl');
    if (array_key_exists('assign', $params)) {
        $view->assign($params['assign'], $result);
        return;
    }
    return $result;
}
コード例 #12
0
ファイル: TestConfig.php プロジェクト: projectesIF/Sirius
    public function handleCommand(Zikula_Form_View $view, &$args)
    {
        switch($args['commandName']) {
            case 'cancel':
                break;
            case 'save':
                if (!$view->isValid()) {
                    return false;
                }
                $formValues = $view->getValues();
                $toname = (string)$formValues['toname'];
                $toaddress = (string)$formValues['toaddress'];
                $subject = (string)$formValues['subject'];
                $msgtype = (string)$formValues['msgtype'];
                $textBody = (string)$formValues['mailer_textbody'];
                $htmlBody = (string)$formValues['mailer_body'];

                $html = in_array($msgtype, array('html', 'multipart')) ? true : false;
                if ($html) {
                    $msgBody = $htmlBody;
                    $altBody = $textBody;
                } else {
                    $msgBody = $textBody;
                    $altBody = '';
                }

                // set the email
                $result = ModUtil::apiFunc('Mailer', 'user', 'sendmessage', array(
                    'toname' => $toname,
                    'toaddress' => $toaddress,
                    'subject' => $subject,
                    'body' => $msgBody,
                    'altbody' => $altBody,
                    'html' => $html)
                );

                // check our result and return the correct error code
                if ($result === true) {
                    // Success
                    LogUtil::registerStatus($this->__('Done! Message sent.'));
                } elseif ($result === false) {
                    // Failiure
                    LogUtil::registerError($this->__f('Error! Could not send message. %s', ''));
                } else {
                    // Failiure with error
                    LogUtil::registerError($this->__f('Error! Could not send message. %s', $result));
                }

                break;
        }

        return $view->redirect(ModUtil::url('Mailer', 'admin', 'testconfig'));
    }
コード例 #13
0
/**
 * The muvideoObjectTypeSelector plugin provides items for a dropdown selector.
 *
 * Available parameters:
 *   - 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  Zikula_Form_View $view   Reference to the view object.
 *
 * @return string The output of the plugin.
 */
function smarty_function_muvideoObjectTypeSelector($params, $view)
{
    $dom = ZLanguage::getModuleDomain('MUVideo');
    $result = array();
    $result[] = array('text' => __('Collections', $dom), 'value' => 'collection');
    $result[] = array('text' => __('Movies', $dom), 'value' => 'movie');
    if (array_key_exists('assign', $params)) {
        $view->assign($params['assign'], $result);
        return;
    }
    return $result;
}
コード例 #14
0
/**
 * The muboardSelectorObjectTypes plugin provides items for a dropdown selector.
 *
 * Available parameters:
 *   - 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  Zikula_Form_View $view    Reference to the view object.
 *
 * @return string The output of the plugin.
 */
function smarty_function_muboardSelectorObjectTypes($params, $view)
{
    $result = array();
    $result[] = array('text' => $view->__('Categories'), 'value' => 'category');
    $result[] = array('text' => $view->__('Forums'), 'value' => 'forum');
    $result[] = array('text' => $view->__('Postings'), 'value' => 'posting');
    if (array_key_exists('assign', $params)) {
        $view->assign($params['assign'], $result);
        return;
    }
    return $result;
}
コード例 #15
0
/**
 * The muvideoTemplateSelector plugin provides items for a dropdown selector.
 *
 * Available parameters:
 *   - 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  Zikula_Form_View $view   Reference to the view object.
 *
 * @return string The output of the plugin.
 */
function smarty_function_muvideoTemplateSelector($params, $view)
{
    $dom = ZLanguage::getModuleDomain('MUVideo');
    $result = array();
    $result[] = array('text' => __('Only item titles', $dom), 'value' => 'itemlist_display.tpl');
    $result[] = array('text' => __('With description', $dom), 'value' => 'itemlist_display_description.tpl');
    $result[] = array('text' => __('Custom template', $dom), 'value' => 'custom');
    if (array_key_exists('assign', $params)) {
        $view->assign($params['assign'], $result);
        return;
    }
    return $result;
}
コード例 #16
0
ファイル: ImageButton.php プロジェクト: projectesIF/Sirius
 /**
  * Decode event handler for actions that generate a postback event.
  *
  * @param Zikula_Form_View $view Reference to Zikula_Form_View object.
  *
  * @return boolean
  */
 public function decodePostBackEvent(Zikula_Form_View $view)
 {
     $fullNameX = $this->id . '_' . $this->commandName . '_x';
     $fullNameY = $this->id . '_' . $this->commandName . '_y';
     if (isset($_POST[$fullNameX])) {
         $args = array('commandName' => $this->commandName, 'commandArgument' => $this->commandArgument, 'posX' => (int) $_POST[$fullNameX], 'posY' => (int) $_POST[$fullNameY]);
         if (!empty($this->onCommand)) {
             if ($view->raiseEvent($this->onCommand, $args) === false) {
                 return false;
             }
         }
     }
     return true;
 }
コード例 #17
0
ファイル: ModifyConfig.php プロジェクト: projectesIF/Sirius
    public function handleCommand(Zikula_Form_View $view, &$args)
    {
        switch($args['commandName']) {
            case 'cancel':
                break;
            case 'save':
                if (!$view->isValid()) {
                    return false;
                }
                $this->formValues = $view->getValues();

                // set our new module variable values
                $vars = array();
                $vars['mailertype'] = (int)$this->getFormValue('mailertype', 1);

                $vars['charset'] = (string)$this->getFormValue('charset', ZLanguage::getEncoding());

                $vars['encoding'] = (string)$this->getFormValue('encoding', '8bit');

                $vars['html'] = (bool)$this->getFormValue('html', false);

                $vars['wordwrap'] = (int)$this->getFormValue('wordwrap', 50);

                $vars['msmailheaders'] = (bool)$this->getFormValue('msmailheaders', false);

                $vars['sendmailpath'] = (string)$this->getFormValue('sendmailpath', '/usr/sbin/sendmail');

                $vars['smtpauth'] = (bool)$this->getFormValue('smtpauth', false);

                $vars['smtpserver'] = (string)$this->getFormValue('smtpserver', 'localhost');

                $vars['smtpport'] = (int)$this->getFormValue('smtpport', 25);

                $vars['smtptimeout'] = (int)$this->getFormValue('smtptimeout', 10);

                $vars['smtpusername'] = (string)$this->getFormValue('smtpusername', '');

                $vars['smtppassword'] = (string)$this->getFormValue('smtppassword', '');

                $vars['smtpsecuremethod'] = (string)$this->getFormValue('smtpsecuremethod', '');

                $this->setVars($vars);

                // the module configuration has been updated successfuly
                LogUtil::registerStatus($this->__('Done! Saved module configuration.'));
                break;
        }

        return $view->redirect(ModUtil::url('Mailer', 'admin', 'modifyconfig'));
    }
コード例 #18
0
ファイル: Config.php プロジェクト: rmaiwald/Reviews
 /**
  * Initialize form handler.
  *
  * This method takes care of all necessary initialisation of our data and form states.
  *
  * @param Zikula_Form_View $view The form view instance.
  *
  * @return boolean False in case of initialization errors, otherwise true.
  */
 public function initialize(Zikula_Form_View $view)
 {
     // permission check
     if (!SecurityUtil::checkPermission($this->name . '::', '::', ACCESS_ADMIN)) {
         return $view->registerError(LogUtil::registerPermissionError());
     }
     // retrieve module vars
     $modVars = $this->getVars();
     // assign all module vars
     $this->view->assign('config', $modVars);
     // custom initialisation aspects
     $this->initializeAdditions();
     // everything okay, no initialization errors occured
     return true;
 }
コード例 #19
0
ファイル: ModifyConfig.php プロジェクト: pheski/Scribite
 function handleCommand(Zikula_Form_View $view, &$args)
 {
     $url = ModUtil::url('Scribite', 'admin', 'main');
     if ($args['commandName'] == 'cancel') {
         return $view->redirect($url);
     }
     // check for valid form
     if (!$view->isValid()) {
         return false;
     }
     // get passed args and store to array
     $data = $view->getValues();
     $this->setVars($data);
     LogUtil::registerStatus($this->__('Done! Module configuration updated.'));
     return $view->redirect($url);
 }
コード例 #20
0
ファイル: Import.php プロジェクト: rmaiwald/MUBoard
 /**
  * Initialize form handler.
  *
  * This method takes care of all necessary initialisation of our data and form states.
  *
  * @return boolean False in case of initialization errors, otherwise true.
  */
 public function initialize(Zikula_Form_View $view)
 {
     // permission check
     if (!SecurityUtil::checkPermission('MUBoard::', '::', ACCESS_ADMIN)) {
         return $view->registerError(LogUtil::registerPermissionError());
     }
     $dom = ZLanguage::getModuleDomain('MUBoard');
     // initialise list entries for the 'number images' setting
     $vars['dizkustableItems'] = array(array('value' => '1', 'text' => __('All', $dom)), array('value' => '2', 'text' => __('Categories', $dom) . ' ' . __('and', $dom) . ' ' . __('Forums', $dom)), array('value' => '3', 'text' => __('Topics', $dom) . ' ' . __('and', $dom) . ' ' . __('Answers', $dom)), array('value' => '4', 'text' => __('Ranks', $dom) . ' ' . __('and', $dom) . ' ' . __('Users', $dom)));
     // assign all module vars
     $this->view->assign('import', $vars);
     // custom initialisation aspects
     $this->initializeAdditions();
     // everything okay, no initialization errors occured
     return true;
 }
コード例 #21
0
/**
 * Smarty function to set the initial focus for a form.
 *
 * Usage:
 * <code>
 * {formsetinitialfocus inputId='PluginId'}
 * </code>
 * The "PluginId" refers to the plugin that should have focus initially.
 *
 * @param array            $params All attributes passed to this function from the template.
 * @param Zikula_Form_View $view   Reference to Form render object.
 *
 * @return string HTML to set the initial focus for a form.
 */
function smarty_function_formsetinitialfocus($params, $view)
{
    if (!isset($params['inputId'])) {
        $view->trigger_error('initialFocus: inputId parameter required');
        return false;
    }
    $doSelect = isset($params['doSelect']) ? $params['doSelect'] : false;
    $id = $params['inputId'];
    if ($doSelect) {
        $selectHtml = 'inp.select();';
    } else {
        $selectHtml = '';
    }
    // FIXME: part of PN???
    $html = "\n<script type=\"text/javascript\">\nvar bodyElement = document.getElementsByTagName('body')[0];\nvar f = function() {\n  var inp = document.getElementById('{$id}');\n  if (inp != null)\n  {\n    inp.focus();\n    {$selectHtml}\n  }\n};\nvar oldF = window.onload;\nwindow.onload = function() { f(); if (oldF) oldF(); };\n</script>";
    return $html;
}
コード例 #22
0
ファイル: block.form.php プロジェクト: Silwereth/core
/**
 * 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;
    }
}
コード例 #23
0
ファイル: ModuleSelector.php プロジェクト: robbrandt/Content
 function load(Zikula_Form_View $view, &$params)
 {
     if (!$view->isPostBack()) {
         // Find the active modules
         $moduleList = ModUtil::apiFunc('Extensions', 'admin', 'listmodules', array('state' => ModUtil::STATE_ACTIVE));
         $modules = array();
         // Only list modules that have a User view
         foreach ($moduleList as $module) {
             if (isset($module['capabilities']['user'])) {
                 $modules[] = array('text' => $module['displayname'], 'value' => $module['name']);
             }
         }
         $empty = array(array('text' => '', 'value' => ''));
         $modules = array_merge($empty, $modules);
         $this->setItems($modules);
     }
     parent::load($view, $params);
 }
コード例 #24
0
ファイル: Plugin.php プロジェクト: Silwereth/core
 public function __construct(Zikula_ServiceManager $serviceManager, $module, $pluginName, $caching = null)
 {
     parent::__construct($serviceManager, $module, $caching);
     $this->pluginName = $pluginName;
     if ($this->modinfo['type'] == ModUtil::TYPE_CORE) {
         $path = "plugins/{$pluginName}/templates/plugins";
     } else {
         $base = ModUtil::getBaseDir($this->modinfo['name']);
         $path = "{$base}/{$this->modinfo['directory']}/plugins/{$pluginName}/templates/plugins";
     }
     $this->addPluginDir($path);
 }
コード例 #25
0
ファイル: ModifyConfig.php プロジェクト: rmaiwald/BBSmile
 function handleCommand(Zikula_Form_View $view, &$args)
 {
     if ($args['commandName'] == 'cancel') {
         $url = ModUtil::url('BBSmile', 'admin', 'main');
         return $view->redirect($url);
     }
     // Security check
     if (!SecurityUtil::checkPermission('BBSmile::', '::', ACCESS_ADMIN)) {
         return LogUtil::registerPermissionError(ModUtil::url('BBSmile', 'admin', 'main'));
     }
     // check for valid form
     if (!$view->isValid()) {
         return false;
     }
     $ok = true;
     $data = $view->getValues();
     $ossmiliepath = DataUtil::formatForOS($data['smiliepath']);
     if (!file_exists($ossmiliepath) || !is_readable($ossmiliepath)) {
         $ifield = $this->view->getPluginById('smiliepath');
         $ifield->setError(DataUtil::formatForDisplay($this->__('The path does not exists or the system cannot read it.')));
         $ok = false;
     }
     $osautosmiliepath = DataUtil::formatForOS($data['smiliepath_auto']);
     if (!file_exists($osautosmiliepath) || !is_readable($osautosmiliepath)) {
         $ifield = $this->view->getPluginById('smiliepath_auto');
         $ifield->setError(DataUtil::formatForDisplay($this->__('The path does not exists or the system cannot read it.')));
         $ok = false;
     }
     if ($ok == false) {
         return false;
     }
     $this->setVar('smiliepath', $data['smiliepath']);
     $this->setVar('smiliepath_auto', $data['smiliepath_auto']);
     $this->setVar('activate_auto', $data['activate_auto']);
     $this->setVar('remove_inactive', $data['remove_inactive']);
     LogUtil::registerStatus($this->__('BBSmile configuration updated'));
     return true;
 }
コード例 #26
0
ファイル: ModifyConfig.php プロジェクト: robbrandt/Avatar
 function handleCommand(Zikula_Form_View $view, &$args)
 {
     // Security check
     if (!SecurityUtil::checkPermission('Avatar::', '::', ACCESS_ADMIN)) {
         return LogUtil::registerPermissionError();
     }
     if ($args['commandName'] == 'submit') {
         if (!$view->IsValid()) {
             return false;
         }
         $data = $view->getValues();
         if (array_key_exists('forumdir', $data)) {
             ModUtil::setVar('Avatar', 'forumdir', $data['forumdir']);
         }
         ModUtil::setVar('Users', 'avatarpath', $data['avatarpath']);
         ModUtil::setVar('Avatar', 'allow_resize', $data['allow_resize']);
         ModUtil::setVar('Avatar', 'maxsize', $data['maxsize']);
         ModUtil::setVar('Avatar', 'maxheight', $data['maxheight']);
         ModUtil::setVar('Avatar', 'maxwidth', $data['maxwidth']);
         ModUtil::setVar('Avatar', 'allowed_extensions', $data['allowed_extensions']);
         ModUtil::setVar('Avatar', 'allow_multiple', $data['allow_multiple']);
     }
     return true;
 }
コード例 #27
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;
    }
}
コード例 #28
0
ファイル: block.form.php プロジェクト: planetenkiller/core
/**
 * 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;
    }
}
コード例 #29
0
/**
 * Image button.
 *
 * This button works like a normal {@link Zikula_Form_Plugin_Button} with the exception
 * that it displays a clickable image instead of a text button. It further
 * more returns the X and Y coordinate of the click position in the image.
 *
 * The command event arguments contains four elements:
 * - commandName: command name
 * - commandArgument: command argument
 * - posX: X position of click
 * - posY: Y position of click.
 *
 * @param array            $params Parameters passed in the block tag.
 * @param Zikula_Form_View $view   Reference to Zikula_Form_View object.
 *
 * @return string The rendered output.
 */
function smarty_function_formimagebutton($params, $view)
{
    return $view->registerPlugin('Zikula_Form_Plugin_ImageButton', $params);
}
コード例 #30
0
ファイル: DateInput.php プロジェクト: projectesIF/Sirius
 /**
  * Render event handler.
  *
  * @param Zikula_Form_View $view Reference to Zikula_Form_View object.
  *
  * @return string The rendered output
  */
 public function render(Zikula_Form_View $view)
 {
     static $firstTime = true;
     $i18n = ZI18n::getInstance();
     if (!empty($this->defaultValue) && !$view->isPostBack()) {
         $d = strtolower($this->defaultValue);
         $now = getdate();
         $date = null;
         if ($d == 'now') {
             $date = time();
         } elseif ($d == 'today') {
             $date = mktime(0, 0, 0, $now['mon'], $now['mday'], $now['year']);
         } elseif ($d == 'monthstart') {
             $date = mktime(0, 0, 0, $now['mon'], 1, $now['year']);
         } elseif ($d == 'monthend') {
             $daysInMonth = date('t');
             $date = mktime(0, 0, 0, $now['mon'], $daysInMonth, $now['year']);
         } elseif ($d == 'yearstart') {
             $date = mktime(0, 0, 0, 1, 1, $now['year']);
         } elseif ($d == 'yearend') {
             $date = mktime(0, 0, 0, 12, 31, $now['year']);
         } elseif ($d == 'custom') {
             $date = strtotime($this->initDate);
         }
         if ($date != null) {
             $this->text = DateUtil::getDatetime($date, $this->ifFormat, false);
         } else {
             $this->text = __('Unknown date');
         }
     }
     if ($view->isPostBack() && !empty($this->text)) {
         $date = strtotime($this->text);
         $this->text = DateUtil::getDatetime($date, $this->ifFormat, false);
     }
     if ($firstTime) {
         $lang = ZLanguage::transformFS(ZLanguage::getLanguageCode());
         // map of the jscalendar supported languages
         $map = array('ca' => 'ca_ES', 'cz' => 'cs_CZ', 'da' => 'da_DK', 'de' => 'de_DE', 'el' => 'el_GR', 'en-us' => 'en_US', 'es' => 'es_ES', 'fi' => 'fi_FI', 'fr' => 'fr_FR', 'he' => 'he_IL', 'hr' => 'hr_HR', 'hu' => 'hu_HU', 'it' => 'it_IT', 'ja' => 'ja_JP', 'ko' => 'ko_KR', 'lt' => 'lt_LT', 'lv' => 'lv_LV', 'nl' => 'nl_NL', 'no' => 'no_NO', 'pl' => 'pl_PL', 'pt' => 'pt_BR', 'ro' => 'ro_RO', 'ru' => 'ru_RU', 'si' => 'si_SL', 'sk' => 'sk_SK', 'sv' => 'sv_SE', 'tr' => 'tr_TR');
         if (isset($map[$lang])) {
             $lang = $map[$lang];
         }
         $headers[] = 'javascript/jscalendar/calendar.js';
         if (file_exists("javascript/jscalendar/lang/calendar-{$lang}.utf8.js")) {
             $headers[] = "javascript/jscalendar/lang/calendar-{$lang}.utf8.js";
         }
         $headers[] = 'javascript/jscalendar/calendar-setup.js';
         PageUtil::addVar('stylesheet', 'javascript/jscalendar/calendar-win2k-cold-2.css');
         PageUtil::addVar('javascript', $headers);
     }
     $firstTime = false;
     $result = '';
     if ($this->useSelectionMode) {
         $hiddenInputField = str_replace(array('type="text"', '&nbsp;*'), array('type="hidden"', ''), parent::render($view));
         $result .= '<div>' . $hiddenInputField . '<span id="' . $this->id . 'cal" style="background-color: #ff8; cursor: default" onmouseover="this.style.backgroundColor=\'#ff0\';" onmouseout="this.style.backgroundColor=\'#ff8\';">';
         if ($this->text) {
             $result .= DataUtil::formatForDisplay(DateUtil::getDatetime(DateUtil::parseUIDate($this->text, $this->ifFormat), $this->daFormat));
         } else {
             $result .= __('Select date');
         }
         $result .= '</span></div>';
         if ($this->mandatory && $this->mandatorysym) {
             $result .= '<span class="z-form-mandatory-flag">*</span>';
         }
     } else {
         $result .= '<span class="z-form-date" style="white-space: nowrap">';
         $result .= parent::render($view);
         $txt = __('Select date');
         $result .= " <img id=\"{$this->id}_img\" src=\"javascript/jscalendar/img.gif\" style=\"vertical-align: middle\" class=\"clickable\" alt=\"{$txt}\" /></span>";
     }
     // build jsCalendar script options
     $result .= "<script type=\"text/javascript\">\n            // <![CDATA[\n            Calendar.setup(\n            {\n                inputField : \"{$this->id}\",";
     if ($this->includeTime) {
         $this->initDate = str_replace('-', ',', $this->initDate);
         $result .= "\n                    ifFormat : \"" . $this->ifFormat . "\",\n                    showsTime      :    true,\n                    timeFormat     :    \"" . $i18n->locale->getTimeformat() . "\",\n                    singleClick    :    false,";
     } else {
         $result .= "\n                    ifFormat : \"" . $this->ifFormat . "\",";
     }
     if ($this->useSelectionMode) {
         $result .= "\n                    displayArea :    \"{$this->id}cal\",\n                    daFormat    :    \"{$this->daFormat}\",\n                    align       :    \"Bl\",\n                    singleClick :    true,";
     } else {
         $result .= "\n                    button : \"{$this->id}_img\",";
     }
     $result .= "\n                    firstDay: " . $i18n->locale->getFirstweekday() . "\n                }\n            );\n            // ]]>\n            </script>";
     return $result;
 }