当前位置: 首页>>代码示例>>PHP>>正文


PHP YDForm::addFormRule方法代码示例

本文整理汇总了PHP中YDForm::addFormRule方法的典型用法代码示例。如果您正苦于以下问题:PHP YDForm::addFormRule方法的具体用法?PHP YDForm::addFormRule怎么用?PHP YDForm::addFormRule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在YDForm的用法示例。


在下文中一共展示了YDForm::addFormRule方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionDefault

 function actionDefault()
 {
     // Create the form
     $form = new YDForm('form1', 'GET', '', '_self', array('class' => 'myform'));
     // Add elements
     $form->addElement('text', 'txt1', 'Enter text 1:');
     $form->addElement('text', 'txt2', 'Enter text 2:');
     $form->addElement('submit', 'cmdSubmit', 'submit');
     $form->addRule('txt1', 'required', 'txt1 is required');
     $form->addRule('txt1', 'maxlength', 'txt1 must be smaller than 15', 15);
     $form->addCompareRule(array('txt1', 'txt2'), 'equal', 'txt1 and txt2 must be equal');
     $form->addFormRule('formrule1');
     $form->addFormRule(array('YDValidateRule', 'formrule2'));
     $form->addFilter('txt1', 'trim');
     $form->addFilter('txt2', 'trim');
     // Convert the form to XML
     $xml = $form->render('xml');
     YDDebugUtil::dump($xml, 'Form as XML data');
     //YDDebugUtil::dump( $form );
     // Recreate a new form from the XML data
     $form2 = new YDForm('form1');
     $form2->import('xml', $xml);
     //YDDebugUtil::dump( $form2 );
     YDDebugUtil::dump(array_diff_assoc($form->toArray(), $form2->toArray()), 'toArray difference');
     YDDebugUtil::dump(array_diff_assoc($form->_attributes, $form2->_attributes), '_attributes difference');
     YDDebugUtil::dump(array_diff_assoc($form->_elements, $form2->_elements), '_elements difference');
     YDDebugUtil::dump(array_diff_assoc($form->_rules, $form2->_rules), '_rules difference');
     YDDebugUtil::dump(array_diff_assoc($form->_filters, $form2->_filters), '_filters difference');
     YDDebugUtil::dump(array_diff_assoc($form->_comparerules, $form2->_comparerules), '_comparerules difference');
     YDDebugUtil::dump(array_diff_assoc($form->_formrules, $form2->_formrules), '_formrules difference');
     YDDebugUtil::dump(array_diff_assoc($form->_regElements, $form2->_regElements), '_regElements difference');
     YDDebugUtil::dump(array_diff_assoc($form->_regRules, $form2->_regRules), '_regRules difference');
     YDDebugUtil::dump(array_diff_assoc($form->_regFilters, $form2->_regFilters), '_regFilters difference');
     YDDebugUtil::dump(array_diff_assoc($form->_regRenderers, $form2->_regRenderers), '_regRenderers difference');
 }
开发者ID:BackupTheBerlios,项目名称:ydframework-svn,代码行数:35,代码来源:form_xml2.php

示例2: actionLogin

 function actionLogin()
 {
     // Redirect to default action if already logged in
     if ($this->isAuthenticated() === true) {
         $this->forward('default');
         return;
     }
     // Create the login form
     $form = new YDForm('loginForm');
     $form->setDefaults(array('name' => 'Joe User'));
     $form->addElement('text', 'loginName', 'User name:');
     $form->addElement('password', 'loginPass', 'Password:');
     $form->addElement('submit', 'cmdSubmit', 'Login');
     // Add the rules
     $form->addFormRule(array(&$this, 'checkLogin'));
     // Process the form
     if ($form->validate()) {
         // Get username and password
         $usrName = $form->getValue('loginName');
         $usrPass = $form->getValue('loginPass');
         // Mark the session that we are logged in
         $_SESSION['usrName'] = 'pieter';
         $_SESSION['isLoggedIn'] = true;
         // Mark the form as valid
         $this->authenticationSucceeded();
         $this->forward('default');
         return;
     }
     // Add the form to the template
     $this->template->assignForm('form', $form);
     // Output the template
     $this->template->display('login');
 }
开发者ID:BackupTheBerlios,项目名称:ydframework-svn,代码行数:33,代码来源:MyLoginRequest.php

示例3: actionDefault

 function actionDefault()
 {
     // Create the form
     $form = new YDForm('form1');
     $form->registerFilter('reverse', 'strrev');
     $form->setDefaults(array('txt2' => 'First text', 'txt3' => "2\nlines", 'hid1' => 'me hidden', 'chk1' => 'x', 'chk2' => false, 'sel1' => 2));
     $text =& $form->addElement('text', 'txt1', 'Enter text 1:');
     $text->_label = 'new label for txt1';
     $form->addElement('text', 'txt2', 'Enter text 2:', array('class' => 'textInputClass', 'name' => 'x'));
     $form->addElement('textarea', 'txt3', 'Enter text 2:');
     $form->addElement('textareacounter', 'txtcounter_1', 'Textarea counter 1', array(), array('maxlength' => 10, 'before' => ' (', 'after' => ' characters remaining)'));
     $form->addElement('textareacounter', 'txtcounter_2', 'Textarea counter 2');
     $form->addElement('radio', 'rad1', 'Select a value 1:', array(), array(1 => 'een', 2 => 'twee'));
     $form->addElement('radio', 'rad2', 'Select a value 2:', array(), array(1 => 'een<br/>', 2 => 'twee'));
     $form->addElement('hidden', 'hid1', '');
     $form->addElement('hidden', 'hid2', '', array(), 'i am also hidden');
     $form->addElement('image', 'img1', '', array(), 'http://www.scripting.com/images/xml.gif');
     $form->addElement('password', 'pas1', 'Enter your password');
     $form->addElement('bbtextarea', 'bbt1', 'Enter your BBCode');
     $form->addElement('checkbox', 'chk1', 'Select me please');
     $form->addElement('checkbox', 'chk2', 'Select me please');
     $form->addElement('select', 'sel1', 'Select an option:', array(), array(1 => 'een', 2 => 'twee'));
     $form->addElement('span', 'span1', 'This is a span. The next element is an image (img).');
     $form->addElement('img', 'img2', 'http://www.scripting.com/images/xml.gif');
     $form->addElement('file', 'fil1', 'Select an file:');
     $form->addElement('submit', 'cmd1', 'Send');
     $form->addElement('reset', 'res1', 'Reset');
     $form->addFilter('__ALL__', 'upper');
     $form->addFilter('txt1', 'trim');
     $form->addFilter('txt2', 'reverse');
     $form->addRule('txt1', 'required', 'txt1 is required');
     $form->addRule('chk2', 'exact', 'chk2 is required', 1);
     $form->addFormRule(array(&$this, 'formrule'), 'txt1 is required');
     if (YDConfig::get('YD_DEBUG') == 1 || YDConfig::get('YD_DEBUG') == 2) {
         YDDebugUtil::dump($form->_regElements, 'Registered elements');
         YDDebugUtil::dump($form->_regRules, 'Registered rules');
         YDDebugUtil::dump($form->_regFilters, 'Registered filters');
         YDDebugUtil::dump($form->_filters, 'Filters');
         YDDebugUtil::dump($form->_rules, 'Rules');
         YDDebugUtil::dump($form->_formrules, 'Form Rules');
         YDDebugUtil::dump($form->getValue('txt1'), 'txt1');
         YDDebugUtil::dump($form->getValue('txt2'), 'txt2');
         YDDebugUtil::dump($_POST, '$_POST');
         YDDebugUtil::dump($_FILES, '$_FILES');
         YDDebugUtil::dump($form->toArray());
     }
     if ($form->validate()) {
         YDDebugUtil::dump($form->getModifiedValues(), 'Form modified values');
         YDDebugUtil::dump($form->getValues(), 'Form values');
     } else {
         $form->display();
     }
     // Create the form
     $form2 = new YDForm('form2');
     $form2->setDefaults(array('txt1' => 'First text'));
     $form2->addElement('text', 'txt1', 'Enter text 1:');
     $form2->addElement('text', 'txt2', 'Enter text 2:');
     $form2->addElement('submit', 'cmd1', 'Send');
     $form2->display();
 }
开发者ID:BackupTheBerlios,项目名称:ydframework-svn,代码行数:60,代码来源:form2.php

示例4: actionSearch

 function actionSearch()
 {
     // retrieve list of forums
     $forumLogic = new ForumsLogic();
     $forums = $forumLogic->retrieveAllByOrderSimple();
     $selectForums = array();
     foreach ($forums as $i => $item) {
         $selectForums["" . $item->id] = $item->name;
     }
     // Create the search form
     $form = new YDForm('searchForm');
     $form->addElement('text', 'searchKeys', t('forums.searchstring'), array("size" => 40));
     $form->addElement('select', 'searchForum', t('forums.searchforum'), array("width" => 60), $selectForums);
     $form->addElement('submit', 'cmdSubmit', t('forums.search'));
     // Add rules
     $form->addFormRule(array(&$this, 'checkSearch'));
     // Process the form
     if ($form->validate()) {
         $this->actionTpl->assign('searched', true);
         // get and show results
         $forum = $forumLogic->retrieveForumById($form->getValue('searchForum'));
         $forum->loadSubjectsMatching($form->getValue('searchKeys'));
         // number of results
         $this->actionTpl->assign('nbposts', count($forum->subjects));
         $this->actionTpl->assign('posts', $forum->subjects);
     }
     // Assign variables to the template
     $this->actionTpl->assign('form', $form->toArray());
     $content = new page($this->actionTpl->fetch('templates/forums.search.tpl'), t('forums.searching'));
     $this->display($content);
 }
开发者ID:BackupTheBerlios,项目名称:ydframework-svn,代码行数:31,代码来源:forums.php

示例5: actionDefault

 function actionDefault()
 {
     // Create the form
     $form = new YDForm('form1');
     $form->registerFilter('reverse', 'strrev');
     $form->setDefaults(array('txt2' => 'First text', 'txt3' => "2\nlines", 'hid1' => 'me hidden', 'chk1' => 'x', 'sel1' => 2));
     $text =& $form->addElement('text', 'txt1', 'Enter text 1:');
     $text->_label = 'new label for txt1';
     $form->addElement('text', 'txt2', 'Enter text 2:', array('class' => 'textInputClass', 'name' => 'x'));
     $form->addElement('textarea', 'txt3', 'Enter text 2:');
     $form->addElement('radio', 'rad1', 'Select a value 1:', array(), array(1 => 'een', 2 => 'twee'));
     $form->addElement('radio', 'rad2', 'Select a value 2:', array(), array(1 => 'een<br/>', 2 => 'twee'));
     $form->addElement('hidden', 'hid1', '');
     $form->addElement('hidden', 'hid2', '', array(), 'i am also hidden');
     $form->addElement('image', 'img1', '', array(), 'http://www.yellowduck.be/images/site_images/rss091.gif');
     $form->addElement('password', 'pas1', 'Enter your password');
     $form->addElement('bbtextarea', 'bbt1', 'Enter your BBCode');
     $form->addElement('checkbox', 'chk1', 'Select me please');
     $form->addElement('checkbox', 'chk2', 'Select me please');
     $form->addElement('select', 'sel1', 'Select an option:', array(), array(1 => 'een', 2 => 'twee'));
     $form->addElement('file', 'fil1', 'Select an file:');
     $form->addElement('submit', 'cmd1', 'Send');
     $form->addElement('reset', 'res1', 'Reset');
     $form->addFilter('__ALL__', 'upper');
     $form->addFilter('txt1', 'trim');
     $form->addFilter('txt2', 'reverse');
     $form->addRule('txt1', 'required', 'txt1 is required');
     $form->addRule('chk2', 'required', 'chk2 is required');
     $form->addFormRule(array(&$this, 'formrule'), 'txt1 is required');
     if (YD_DEBUG == 1) {
         YDDebugUtil::dump($form->_regElements, 'Registered elements');
         YDDebugUtil::dump($form->_regRules, 'Registered rules');
         YDDebugUtil::dump($form->_regFilters, 'Registered filters');
         YDDebugUtil::dump($form->_filters, 'Filters');
         YDDebugUtil::dump($form->_rules, 'Rules');
         YDDebugUtil::dump($form->_formrules, 'Form Rules');
         YDDebugUtil::dump($form->getValue('txt1'), 'txt1');
         YDDebugUtil::dump($form->getValue('txt2'), 'txt2');
         YDDebugUtil::dump($_POST, '$_POST');
         YDDebugUtil::dump($_FILES, '$_FILES');
     }
     if ($form->validate()) {
         YDDebugUtil::dump($form->getValues(), 'Form values');
     } else {
         $form->display();
     }
     // Create the form
     $form2 = new YDForm('form2');
     $form2->setDefaults(array('txt1' => 'First text'));
     $form2->addElement('text', 'txt1', 'Enter text 1:');
     $form2->addElement('text', 'txt2', 'Enter text 2:');
     $form2->addElement('submit', 'cmd1', 'Send');
     $form2->display();
 }
开发者ID:BackupTheBerlios,项目名称:ydframework-svn,代码行数:54,代码来源:form2.php

示例6: actionDefault

 function actionDefault()
 {
     // Create the form
     $form = new YDForm('myForm');
     $form->setDefaults(array('name' => 'Joe User'));
     $form->addElement('text', 'loginName', 'User name:');
     $form->addElement('password', 'loginPass', 'Password:');
     $form->addElement('submit', 'cmdSubmit', 'Login');
     // Add the form rule
     $form->addFormRule(array(&$this, 'checkLogin'));
     // Process the form
     if ($form->validate()) {
         YDDebugUtil::dump($form->getValues());
     } else {
         $form->display();
     }
 }
开发者ID:BackupTheBerlios,项目名称:ydframework-svn,代码行数:17,代码来源:form_rule.php

示例7: actionEditPost

 function actionEditPost()
 {
     if (!isset($_GET['idPost'])) {
         $this->errorRequete();
         return;
     }
     if ($this->user->authentificated) {
         $postlogic = new PostsLogic();
         $post = $postlogic->retrievePostById($_GET['idPost']);
         if ($post != null) {
             if ($this->user->rightslevel >= LEVEL_MODERATOR || $this->user->id == $post->idAuthor) {
                 // Create the add post form
                 $form = new YDForm('postEdit');
                 $form->addElement('hidden', 'idPost', $post->id);
                 $form->addElement('text', 'postTitle', t('posts.messagetitle'), array("size" => 60));
                 $form->addElement('textarea', 'postContent', t('posts.message'), array("cols" => 50, "rows" => 8));
                 $form->addElement('submit', 'cmdSubmit', t('posts.editmessage'));
                 // Add rules
                 $form->addFormRule(array(&$this, 'simpleCheckPost'));
                 // Process the form
                 if ($form->validate()) {
                     $post->title = $form->getValue('postTitle');
                     $post->content = $form->getValue('postContent');
                     $post->idEditor = $this->user->id;
                     $post->ipEditor = $this->user->ip;
                     $post->dateEdited = date('Y-m-d H:i:s', mktime());
                     $post->update();
                     // on redirige sur le post parent si il existe
                     if ($post->idPostParent != null) {
                         $postParent = $postlogic->retrievePostById($post->idPostParent);
                         $postParent->dateAnswer = date('Y-m-d H:i:s', mktime());
                         $postParent->update();
                         $this->actionTpl->assign('post', $postParent);
                     } else {
                         $this->actionTpl->assign('post', $post);
                     }
                     $this->actionTpl->assign('editMessage', true);
                     // we are editing the message
                     $content = new page($this->actionTpl->fetch('templates/posts.success.tpl'), t('posts.updsuccess'));
                     $this->display($content);
                     return;
                 }
                 $form->setDefaults(array('postTitle' => $post->title));
                 $form->setDefaults(array('postContent' => $post->content));
                 // Assign variables to the template
                 $this->actionTpl->assign('form', $form->toArray());
                 // forms
                 $this->actionTpl->assign('user', $this->user);
                 // user for rights
                 $this->actionTpl->assign('editMessage', true);
                 // we are editing the message
                 $content = new page($this->actionTpl->fetch('templates/posts.new.tpl'), t('posts.messageupdate'));
                 $this->display($content);
                 return;
             } else {
                 $this->errorRequete(t('posts.notrightupdate'));
                 return;
             }
         } else {
             $this->errorRequete(t('posts.donotexists'));
             return;
         }
     } else {
         $content = new page($this->actionTpl->fetch('templates/user.notAuth.tpl'), t('global.notconnected'));
     }
 }
开发者ID:BackupTheBerlios,项目名称:ydframework-svn,代码行数:66,代码来源:posts.php

示例8: actionLogin

 /**
  *  This action takes care of handling the login form. It can show and validate a login form and redirects to
  *  default action of the request class when the user is authenticated.
  */
 function actionLogin()
 {
     // Redirect to default action if already logged in
     if ($this->isAuthenticated() === true) {
         $this->forward('default');
         return;
     }
     // Create the login form
     $form = new YDForm('loginForm');
     $form->addElement('text', 'loginName', t('username'), array('class' => 'tfL'));
     $form->addElement('password', 'loginPass', t('password'), array('class' => 'tfL'));
     $form->addElement('checkbox', 'loginRememberMe', t('remember_me'));
     $form->addElement('submit', 'cmdSubmit', 'Login', array('class' => 'button'));
     $form->setDefault('loginRememberMe', true);
     // Add the rules
     $form->addFormRule(array(&$this, 'checkLogin'));
     // Process the form
     if ($form->validate()) {
         // Get the form values
         $values = $form->getValues();
         // Update the password
         $values['loginPass'] = md5($values['loginPass']);
         // Set the cookies
         if ($values['loginRememberMe'] === 1) {
             $this->setCookie($this->cookieNameUser, $values['loginName'], false);
             $this->setCookie($this->cookieNamePass, $values['loginPass'], false);
         } else {
             $this->setCookie($this->cookieNameUser, $values['loginName'], true);
             $this->setCookie($this->cookieNamePass, $values['loginPass'], true);
         }
         // Forward to the main manage page
         $this->redirectToAction();
     }
     // Add the form to the template
     $this->tpl->assignForm('form', $form);
     // Output the template
     $this->tpl->displayWithMaster('login');
 }
开发者ID:BackupTheBerlios,项目名称:ydframework-svn,代码行数:42,代码来源:YDSimpleCMS.php

示例9: actionSuscribe

 function actionSuscribe()
 {
     if (!$this->user->authentificated) {
         // Create the profile form
         $form = new YDForm('suscribeForm');
         $form->addElement('text', 'suscribeLogin', t('user.login'));
         $form->addElement('textarea', 'suscribeDescription', t('user.desc'));
         $form->addElement('password', 'suscribePassUn', t('user.pwd'));
         $form->addElement('password', 'suscribePassDeux', t('user.confirmpwd'));
         $form->addElement('submit', 'cmdSubmit', t('user.valid'));
         // Add rules
         $form->addFormRule(array(&$this, 'checkSuscribe'));
         // Process the form
         if ($form->validate()) {
             // Insert profile
             $this->user->id = '';
             $this->user->login = $form->getValue('suscribeLogin');
             $this->user->description = $form->getValue('suscribeDescription');
             $this->user->password = md5($form->getValue('suscribePassUn'));
             $this->user->insert();
             $this->user->auth();
             $_GET['idUser'] = $this->user->id;
             $_SESSION['s_user'] = YDObjectUtil::serialize($this->user);
             // Redirect sur les forums
             header('location: forums.php');
             return;
         }
         // Assign variables to the template
         $this->actionTpl->assign('form', $form->toArray());
         $content = new page($this->actionTpl->fetch('templates/user.suscribe.tpl'), 'Inscription');
         // Display the action template into the master template
         $this->display($content);
     } else {
         $this->actionMonProfil();
         return;
     }
 }
开发者ID:BackupTheBerlios,项目名称:ydframework-svn,代码行数:37,代码来源:user.php

示例10: actionLogin

 function actionLogin()
 {
     // Redirect to default action if already logged in
     if ($this->isAuthenticated() === true) {
         $this->forward('default');
         return;
     }
     // Create the login form
     $form = new YDForm('loginForm');
     $form->addElement('text', 'loginName', t('user.login'));
     $form->addElement('password', 'loginPass', t('user.pwd'));
     $form->addElement('submit', 'cmdSubmit', 'Login');
     $form->setDefaults(array('loginPass' => ''));
     // Add the rules
     $form->addFormRule(array(&$this, 'checkLogin'));
     // Process the form
     if ($form->validate()) {
         // Mark the form as valid
         $this->authenticationSucceeded();
         header('location: forums.php');
         return;
     }
     // Assign variables to the action template
     $this->actionTpl->assign('form', $form->toArray());
     $content = new Page($this->actionTpl->fetch('templates/user.login.tpl'), '');
     // Display the action template into the master template
     $this->display($content);
 }
开发者ID:BackupTheBerlios,项目名称:ydframework-svn,代码行数:28,代码来源:fffRequest.php

示例11: actionDefault

 function actionDefault()
 {
     // Check for the config file
     if (is_file(dirname(__FILE__) . '/include/config.php')) {
         $this->redirectToAction('error');
     }
     // Get the list of skins
     $dir = new YDFSDirectory(dirname(__FILE__) . '/' . $this->dir_skins);
     $items = $dir->getContents('!.*', '', array('YDFSDirectory'));
     $skins = array();
     foreach ($items as $item) {
         $skins[$item] = $item;
     }
     // Get the list of languages
     $dir = new YDFSDirectory(dirname(__FILE__) . '/include/languages/');
     $items = $dir->getContents('language_*.php', '', array('YDFSFile'));
     $languages = array();
     foreach ($items as $item) {
         $item = substr($item, 9, -4);
         $languages[$item] = $item;
     }
     // Create the configuration form
     $form = new YDForm('configForm');
     // Add the fields
     $form->addElement('text', 'db_host', 'Database host', array('class' => 'tfM'));
     $form->addElement('text', 'db_name', 'Database name', array('class' => 'tfM'));
     $form->addElement('text', 'db_user', 'Database user', array('class' => 'tfM'));
     $form->addElement('password', 'db_pass', 'Database password', array('class' => 'tfM'));
     $form->addElement('text', 'db_prefix', 'Database table prefix', array('class' => 'tfM'));
     $form->addElement('text', 'weblog_title', 'Weblog title', array('class' => 'tfM'));
     $form->addElement('text', 'weblog_description', 'Weblog description', array('class' => 'tfM'));
     $form->addElement('select', 'weblog_skin', 'Weblog skin', array('class' => 'tfM', 'style' => 'width: 100%'), $skins);
     $form->addElement('select', 'weblog_language', 'Weblog language', array('class' => 'tfM', 'style' => 'width: 100%'), $languages);
     $form->addElement('text', 'name', 'User name', array('class' => 'tfM'));
     $form->addElement('text', 'email', 'User email', array('class' => 'tfM'));
     $form->addElement('password', 'password', 'Password', array('class' => 'tfM'));
     $form->addElement('submit', '_cmdSubmit', 'Install', array('class' => 'button'));
     // Add the rules
     $form->addRule('db_host', 'required', 'Database host is required');
     $form->addRule('db_name', 'required', 'Database name is required');
     $form->addRule('db_user', 'required', 'Database user is required');
     $form->addRule('weblog_title', 'required', 'Weblog title is required');
     $form->addRule('name', 'required', 'User name is required');
     $form->addRule('email', 'email', 'User email is required');
     $form->addRule('password', 'required', 'Password is required');
     $form->addFormRule(array(&$this, 'checkInstallParams'));
     // Set the defaults
     $form->setDefault('db_host', 'localhost');
     $form->setDefault('db_name', 'ydweblog');
     $form->setDefault('db_user', 'root');
     $form->setDefault('db_prefix', 'ydw_');
     $form->setDefault('weblog_title', 'My Weblog');
     $form->setDefault('weblog_description', 'Description of my Weblog');
     // Process the form
     if ($form->validate() === true) {
         // Get the form values
         $values = $form->getValues();
         // Connect to the database
         $db = YDDatabase::getInstance('mysql', $values['db_name'], $values['db_user'], $values['db_pass'], $values['db_host']);
         // Create the tables
         $db->executeSql('DROP TABLE IF EXISTS ' . $values['db_prefix'] . 'categories;');
         $db->executeSql('CREATE TABLE ' . $values['db_prefix'] . 'categories ( id int(11) NOT NULL auto_increment, title varchar(255) NOT NULL default \'\', created int(11) default NULL, modified int(11) default NULL, PRIMARY KEY  (id) ) TYPE=MyISAM;');
         $db->executeSql('DROP TABLE IF EXISTS ' . $values['db_prefix'] . 'comments;');
         $db->executeSql('CREATE TABLE ' . $values['db_prefix'] . 'comments (
                   id int(11) NOT NULL auto_increment,
                   item_id int(11) NOT NULL default \'1\',
                   username varchar(255) NOT NULL default \'\',
                   useremail varchar(255) NOT NULL default \'\',
                   userwebsite varchar(255) default NULL,
                   userip varchar(20) default NULL,
                   comment longtext NOT NULL,
                   created int(11) default NULL,
                   modified int(11) default NULL,
                   PRIMARY KEY  (id),
                   KEY item_id (item_id)
                 ) TYPE=MyISAM;');
         $db->executeSql('DROP TABLE IF EXISTS ' . $values['db_prefix'] . 'items;');
         $db->executeSql('CREATE TABLE ' . $values['db_prefix'] . 'items (
                   id int(11) NOT NULL auto_increment,
                   category_id int(11) default \'1\',
                   user_id int(11) NOT NULL default \'1\',
                   title varchar(255) NOT NULL default \'\',
                   body longtext NOT NULL,
                   body_more longtext NOT NULL,
                   num_comments int(11) NOT NULL default \'0\',
                   created int(11) default NULL,
                   modified int(11) default NULL,
                   PRIMARY KEY  (id),
                   KEY category_id (category_id),
                   KEY user_id (user_id)
                 ) TYPE=MyISAM;');
         $db->executeSql('DROP TABLE IF EXISTS ' . $values['db_prefix'] . 'links;');
         $db->executeSql('CREATE TABLE ' . $values['db_prefix'] . 'links (
                   id int(11) NOT NULL auto_increment,
                   title varchar(255) NOT NULL default \'\',
                   url varchar(255) NOT NULL default \'\',
                   num_visits int(11) default \'0\',
                   created int(11) default NULL,
                   modified int(11) default NULL,
                   PRIMARY KEY  (id),
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:ydframework-svn,代码行数:101,代码来源:install.php

示例12: actionManageForums

 function actionManageForums()
 {
     // Create the addForum form
     $form = new YDForm('forumForm');
     $form->addElement('text', 'forumTitle', t('admin.newforumtitle'), array("size" => 40));
     $form->addElement('text', 'forumPoids', t('admin.forumweightorder'), array());
     $form->addElement('submit', 'cmdSubmit', t('admin.forumcreate'));
     // Add rules
     $form->addFormRule(array(&$this, 'checkNewForum'));
     $form->addRule('forumPoids', 'numeric', t('admin.forumweightinteger'));
     // Process the form
     if ($form->validate()) {
         // get and show results
         $forum = new ForumObject($form->getValue('forumTitle'), $form->getValue('forumPoids'));
         $forum->insert();
     }
     // Future defaults values
     $form->setDefaults(array('forumTitle' => ''));
     $form->setDefaults(array('forumPoids' => ''));
     // retrieve existing forums
     $forumLogic = new ForumsLogic();
     $forums = $forumLogic->retrieveAllByOrderSimple();
     // Assign variables to the template
     $this->actionTpl->assign('form', $form->toArray());
     $this->actionTpl->assign('forums', $forums);
     $content = new Page($this->actionTpl->fetch('templates/admin.forums.list.tpl'), t('admin.manageforums'), $this->menusAdmin);
     // Display the action template into the master template
     $this->display($content);
 }
开发者ID:BackupTheBerlios,项目名称:ydframework-svn,代码行数:29,代码来源:admin.php


注:本文中的YDForm::addFormRule方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。