コード例 #1
0
 /**
  * Parse the template file and return it as string
  * @param array
  * @return string
  */
 public function parse($arrAttributes = null)
 {
     if ($this->formcontrol_template) {
         $this->strTemplate = $this->formcontrol_template;
         // Hide the Punycode format (see #2750)
         if ($this->rgxp == 'email' || $this->rgxp == 'friendly' || $this->rgxp == 'url') {
             $this->varValue = \Idna::decode($this->varValue);
         }
         if ($this->hideInput) {
             $strType = 'password';
         } elseif ($this->strFormat != 'xhtml') {
             // Use the HTML5 types (see #4138)
             // but not the date, time and datetime types (see #5918)
             switch ($this->rgxp) {
                 case 'digit':
                     $strType = 'number';
                     break;
                 case 'phone':
                     $strType = 'tel';
                     break;
                 case 'email':
                     $strType = 'email';
                     break;
                 case 'url':
                     $strType = 'url';
                     break;
                 default:
                     $strType = 'text';
                     break;
             }
         } else {
             $strType = 'text';
         }
         $this->type = $strType;
     }
     return parent::parse($arrAttributes);
 }
コード例 #2
0
ファイル: ModuleCloseAccount.php プロジェクト: Jobu/core
 /**
  * Generate the module
  */
 protected function compile()
 {
     $this->import('FrontendUser', 'User');
     // Initialize the password widget
     $arrField = array('name' => 'password', 'inputType' => 'text', 'label' => $GLOBALS['TL_LANG']['MSC']['password'][0], 'eval' => array('hideInput' => true, 'mandatory' => true, 'required' => true, 'tableless' => $this->tableless));
     $objWidget = new \FormTextField(\FormTextField::getAttributesFromDca($arrField, $arrField['name']));
     $objWidget->rowClass = 'row_0 row_first even';
     // Validate widget
     if (\Input::post('FORM_SUBMIT') == 'tl_close_account') {
         $objWidget->validate();
         // Validate the password
         if (!$objWidget->hasErrors()) {
             // The password has been generated with crypt()
             if (\Encryption::test($this->User->password)) {
                 $blnAuthenticated = \Encryption::verify($objWidget->value, $this->User->password);
             } else {
                 list($strPassword, $strSalt) = explode(':', $this->User->password);
                 $blnAuthenticated = $strSalt == '' ? $strPassword === sha1($objWidget->value) : $strPassword === sha1($strSalt . $objWidget->value);
             }
             if (!$blnAuthenticated) {
                 $objWidget->value = '';
                 $objWidget->addError($GLOBALS['TL_LANG']['ERR']['invalidPass']);
             }
         }
         // Close account
         if (!$objWidget->hasErrors()) {
             // HOOK: send account ID
             if (isset($GLOBALS['TL_HOOKS']['closeAccount']) && is_array($GLOBALS['TL_HOOKS']['closeAccount'])) {
                 foreach ($GLOBALS['TL_HOOKS']['closeAccount'] as $callback) {
                     $this->import($callback[0]);
                     $this->{$callback}[0]->{$callback}[1]($this->User->id, $this->reg_close, $this);
                 }
             }
             $objMember = \MemberModel::findByPk($this->User->id);
             // Remove the account
             if ($this->reg_close == 'close_delete') {
                 $objMember->delete();
                 $this->log('User account ID ' . $this->User->id . ' (' . $this->User->email . ') has been deleted', __METHOD__, TL_ACCESS);
             } else {
                 $objMember->disable = 1;
                 $objMember->tstamp = time();
                 $objMember->save();
                 $this->log('User account ID ' . $this->User->id . ' (' . $this->User->email . ') has been deactivated', __METHOD__, TL_ACCESS);
             }
             $this->User->logout();
             // Check whether there is a jumpTo page
             if (($objJumpTo = $this->objModel->getRelated('jumpTo')) !== null) {
                 $this->jumpToOrReload($objJumpTo->row());
             }
             $this->reload();
         }
     }
     $this->Template->fields = $objWidget->parse();
     $this->Template->formId = 'tl_close_account';
     $this->Template->action = \Environment::get('indexFreeRequest');
     $this->Template->slabel = specialchars($GLOBALS['TL_LANG']['MSC']['closeAccount']);
     $this->Template->rowLast = 'row_1 row_last odd';
     $this->Template->tableless = $this->tableless;
 }
コード例 #3
0
ファイル: ModuleCloseAccount.php プロジェクト: rikaix/core
 /**
  * Generate the module
  */
 protected function compile()
 {
     $this->import('FrontendUser', 'User');
     // Initialize the password widget
     $arrField = array('name' => 'password', 'inputType' => 'text', 'label' => $GLOBALS['TL_LANG']['MSC']['password'][0], 'eval' => array('hideInput' => true, 'mandatory' => true, 'required' => true, 'tableless' => $this->tableless));
     $objWidget = new \FormTextField($this->prepareForWidget($arrField, $arrField['name']));
     $objWidget->rowClass = 'row_0 row_first even';
     // Validate widget
     if (\Input::post('FORM_SUBMIT') == 'tl_close_account') {
         $objWidget->validate();
         // Validate password
         if (!$objWidget->hasErrors()) {
             list(, $strSalt) = explode(':', $this->User->password);
             if (!strlen($strSalt) || sha1($strSalt . $objWidget->value) . ':' . $strSalt != $this->User->password) {
                 $objWidget->value = '';
                 $objWidget->addError($GLOBALS['TL_LANG']['ERR']['invalidPass']);
             }
         }
         // Close account
         if (!$objWidget->hasErrors()) {
             // HOOK: send account ID
             if (isset($GLOBALS['TL_HOOKS']['closeAccount']) && is_array($GLOBALS['TL_HOOKS']['closeAccount'])) {
                 foreach ($GLOBALS['TL_HOOKS']['closeAccount'] as $callback) {
                     $this->import($callback[0]);
                     $this->{$callback}[0]->{$callback}[1]($this->User->id, $this->reg_close, $this);
                 }
             }
             $objMember = \MemberModel::findByPk($this->User->id);
             // Remove the account
             if ($this->reg_close == 'close_delete') {
                 $objMember->delete();
                 $this->log('User account ID ' . $this->User->id . ' (' . $this->User->email . ') has been deleted', 'ModuleCloseAccount compile()', TL_ACCESS);
             } else {
                 $objMember->disable = 1;
                 $objMember->save();
                 $this->log('User account ID ' . $this->User->id . ' (' . $this->User->email . ') has been deactivated', 'ModuleCloseAccount compile()', TL_ACCESS);
             }
             $this->User->logout();
             $this->jumpToOrReload($this->objModel->getRelated('jumpTo')->row());
         }
     }
     $this->Template->fields = $objWidget->parse();
     $this->Template->formId = 'tl_close_account';
     $this->Template->action = $this->getIndexFreeRequest();
     $this->Template->slabel = specialchars($GLOBALS['TL_LANG']['MSC']['closeAccount']);
     $this->Template->rowLast = 'row_1 row_last odd';
     $this->Template->tableless = $this->tableless;
 }
コード例 #4
0
    /**
     * Parse the template file and return it as string
     *
     * @param array $arrAttributes An optional attributes array
     *
     * @return string The template markup
     */
    public function parse($arrAttributes = null)
    {
        global $objPage;
        if ($this->dateIncludeCSS) {
            if (strlen($this->dateIncludeCSSTheme) > 0) {
                $GLOBALS['TL_CSS'][] = 'https://code.jquery.com/ui/' . JQUERY_UI . '/themes/' . $this->dateIncludeCSSTheme . '/jquery-ui.css';
            } else {
                $GLOBALS['TL_CSS'][] = TL_ASSETS_URL . 'assets/hofff/calendarfield/jquery.ui.datepicker/' . JQUERY_UI . '/jquery.ui.datepicker.min.css';
            }
        }
        $GLOBALS['TL_JAVASCRIPT'][] = TL_ASSETS_URL . 'assets/jquery/ui/' . JQUERY_UI . '/jquery-ui.min.js';
        $GLOBALS['TL_JAVASCRIPT'][] = TL_ASSETS_URL . 'assets/hofff/calendarfield/jquery.ui.datepicker/' . JQUERY_UI . '/jquery.ui.datepicker.min.js';
        $GLOBALS['TL_JAVASCRIPT'][] = TL_ASSETS_URL . 'assets/hofff/calendarfield/jquery.ui.datepicker/' . JQUERY_UI . '/i18n/jquery.ui.datepicker-' . $objPage->language . '.js';
        $dateFormat = $this->dateFormat ?: $GLOBALS['TL_CONFIG'][$this->rgxp . 'Format'];
        if ($this->dateParseValue && $this->varValue != '') {
            $this->varValue = \Date::parse($dateFormat, strtotime($this->varValue));
        }
        // Initialize the default config
        $arrConfig = array('showAnim' => "fadeIn", 'showOtherMonths' => true, 'selectOtherMonths' => true, 'changeMonth' => true, 'changeYear' => true);
        switch ($this->dateDirection) {
            case 'ltToday':
                $arrConfig['maxDate'] = -1;
                break;
            case 'leToday':
                $arrConfig['maxDate'] = 0;
                break;
            case 'geToday':
                $arrConfig['minDate'] = 0;
                break;
            case 'gtToday':
                $arrConfig['minDate'] = 1;
                break;
        }
        if ($this->dateImage) {
            // icon
            $strIcon = 'assets/mootools/datepicker/' . DATEPICKER . '/icon.gif';
            if (\Validator::isUuid($this->dateImageSRC)) {
                $objFile = \FilesModel::findByPk($this->dateImageSRC);
                if ($objFile !== null && is_file(TL_ROOT . '/' . $objFile->path)) {
                    $strIcon = $objFile->path;
                }
            }
            $arrSize = @getimagesize(TL_ROOT . '/' . $strIcon);
            $arrConfig['showOn'] = "both";
            $arrConfig['buttonImage'] = $strIcon;
            $arrConfig['buttonImageOnly'] = true;
            $arrConfig['buttonText'] = $GLOBALS['TL_LANG']['MSC']['calendarfield_tooltip'];
        }
        // correctly style the date format
        $arrConfig['format'] = $this->dateformat_PHP_to_jQueryUI($dateFormat);
        if (is_array($this->dateConfig)) {
            $arrConfig = array_replace($arrConfig, $this->dateConfig);
        }
        // HOOK: allow to customize the date picker
        if (isset($GLOBALS['TL_HOOKS']['formCalendarField']) && is_array($GLOBALS['TL_HOOKS']['formCalendarField'])) {
            foreach ($GLOBALS['TL_HOOKS']['formCalendarField'] as $callback) {
                $objCallback = method_exists($callback[0], 'getInstance') ? call_user_func(array($callback[0], 'getInstance')) : new $callback[0]();
                $arrConfig = $objCallback->{$callback}[1]($arrConfig, $this);
            }
        }
        $calendarfieldScript .= <<<JS
<script>
jQuery(function(\$) {
  \$("#ctrl_%s").datepicker(%s);
  \$("#ctrl_%s").datepicker( \$.datepicker.regional["%s"] );
});
</script>
JS;
        $GLOBALS['TL_BODY'][] = sprintf($calendarfieldScript, $this->strId, json_encode($arrConfig), $this->strId, $objPage->language);
        return parent::parse($arrAttributes);
    }