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


PHP YDForm::setDefaults方法代码示例

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


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

示例1: 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

示例2: actionDefault

 function actionDefault()
 {
     // Create the delete form
     $form = new YDForm('clearCacheForm');
     $form->addElement('checkbox', 'cache_tmb', 'Thumbnail cache');
     $form->addElement('checkbox', 'cache_web', 'Web download cache');
     $form->addElement('checkbox', 'cache_tpl', 'Template cache');
     $form->addElement('submit', '_cmdSubmit', t('cleanup'), array('class' => 'button'));
     $form->setDefaults(array('cache_web' => 1, 'cache_tmb' => 1, 'cache_tpl' => 1));
     // Validate the form
     if ($form->validate() == true) {
         // Check if we need to delete the thumbnail objects
         if ($form->getValue('cache_tmb') === 'on') {
             $this->_deleteCacheFiles('*.tmn');
         }
         // Check if we need to delete the web objects
         if ($form->getValue('cache_web') === 'on') {
             $this->_deleteCacheFiles('*.wch');
         }
         // Check if we need to delete the template objects
         if ($form->getValue('cache_tpl') === 'on') {
             $this->_deleteCacheFiles('*.tpl.php');
         }
         // Add a status message
         $this->tpl->assign('message', t('cache_cleaned_up'));
     }
     // Add the form to the template
     $this->tpl->assignForm('form', $form);
     // Display the template
     $this->display();
 }
开发者ID:BackupTheBerlios,项目名称:ydframework-svn,代码行数:31,代码来源:cache.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: actionDefault

 function actionDefault()
 {
     // Create the form
     $form = new YDForm('form1');
     $elementDate = $form->addElement('dateselect', 'dateSelect1', 'Enter data:');
     $elementDate = $form->addElement('dateselect', 'dateSelect2', 'Enter data:');
     $elementTime = $form->addElement('timeselect', 'timeSelect1', 'Enter data:');
     $elementDateTime = $form->addElement('datetimeselect', 'datetimeSelect1', 'Enter data:');
     $form->addElement('submit', 'cmd1', 'Send');
     $form->setDefaults(array('dateSelect1' => array('month' => 4, 'day' => 4, 'year' => 2002)));
     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($elementDate->getTimeStamp(), '$elementDate->getTimeStamp()');
         YDDebugUtil::dump($elementDate->getTimeStamp('%d/%m/%Y'), '$elementDate->getTimeStamp( "%d/%m/%Y" )');
         YDDebugUtil::dump(date('M-d-Y', $elementDate->getTimeStamp()), '$elementDate->gdate( getTimeStamp() )');
         YDDebugUtil::dump($elementTime->getTimeStamp(), '$elementTime->getTimeStamp()');
         YDDebugUtil::dump($elementTime->getTimeStamp('%H:%M'), '$elementTime->getTimeStamp( "%H:%M" )');
         YDDebugUtil::dump($elementDateTime->getTimeStamp(), '$elementDateTime->getTimeStamp()');
         YDDebugUtil::dump($elementDateTime->getTimeStamp('%d/%m/%Y %H:%M'), '$elementDateTime->getTimeStamp( "%H:%M" )');
     }
     $form->display();
 }
开发者ID:BackupTheBerlios,项目名称:ydframework-svn,代码行数:33,代码来源:form_dateselect.php

示例5: actionDefault

 function actionDefault()
 {
     // Create the form
     $form = new YDForm('form1');
     $form->addElement('text', 'text1', 'Enter text 1:');
     $form->addElement('text', 'text2', 'Enter text 2:');
     $form->addElement('textarea', 'textarea', 'Enter text 3:');
     $form->addElement('radio', 'radio1', 'Select a value 1:', array(), array(1 => 'one', 2 => 'two'));
     $form->addElement('radio', 'radio2', 'Select a value 2:', array(), array(1 => 'one', 2 => 'two'));
     $form->addElement('hidden', 'hidden1', '');
     $form->addElement('hidden', 'hidden2', '', array(), 'i am also hidden');
     $form->addElement('image', 'image', '', array(), 'http://www.scripting.com/images/xml.gif');
     $form->addElement('password', 'password', 'Enter your password');
     $form->addElement('bbtextarea', 'bbtextarea', 'Enter your BBCode');
     $form->addElement('checkbox', 'checkbox1', 'Check me 1');
     $form->addElement('checkbox', 'checkbox2', 'Check me 2');
     $form->addElement('select', 'select', 'Select an option:', array(), array(1 => 'one', 2 => 'two'));
     $form->addElement('dateselect', 'dateselect', 'Select a date:');
     $form->addElement('datetimeselect', 'datetimeselect', 'Select a date:');
     $form->addElement('timeselect', 'timeselect', 'Select a date:');
     $form->addElement('file', 'file', 'Select an file:');
     $form->addElement('submit', 'submit', 'Send');
     $form->addElement('button', 'button', 'Button');
     $form->addElement('reset', 'resest', 'Reset');
     $form->setDefaults(array('radio1' => 1, 'radio2' => 2, 'text1' => 'my text one', 'select' => 1, 'checkbox1' => 'on'));
     if ($form->validate()) {
         YDDebugUtil::dump($form->getDefaults(), 'Form default values');
         YDDebugUtil::dump($form->getModifiedValues(), 'Form modified values');
         YDDebugUtil::dump($form->getValues(), 'Form values');
     } else {
         $form->display();
     }
 }
开发者ID:BackupTheBerlios,项目名称:ydframework-svn,代码行数:33,代码来源:form_modified.php

示例6: 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

示例7: actionDefault

 function actionDefault()
 {
     // Create the form
     $form = new YDForm('form1');
     // Add the checkboxgroup
     $form->addElement('checkboxgroup', 'choose_multiple', 'Choose multiple default', array(), array(0 => 'choice 1', 1 => 'choice 2'));
     $form->addElement('checkboxgroup', 'choose_multiple2', 'Choose multiple HORIZONTAL', array('sep' => 'h'), array(0 => 'choice 1', 1 => 'choice 2'));
     $form->addElement('checkboxgroup', 'choose_multiple3', 'Choose multiple VERTICAL', array('sep' => 'v'), array(0 => 'choice 1', 1 => 'choice 2'));
     $form->addElement('checkboxgroup', 'choose_multiple4', 'Choose multiple LEFT', array('sep' => 'l'), array(0 => 'choice 1', 1 => 'choice 2'));
     $el =& $form->addElement('checkboxgroup', 'choose_multiple5', 'Choose multiple RIGHT', array('sep' => 'r'), array(0 => 'choice 1', 1 => 'choice 2'));
     $form->addElement('checkboxgroup', 'choose_multiple6', 'Choose multiple VERTICAL LEFT', array('sep' => 'vl'), array(0 => 'choice 1', 1 => 'choice 2'));
     $form->addElement('checkboxgroup', 'choose_multiple7', 'Choose multiple VERTICAL RIGHT', array('sep' => 'vr'), array(0 => 'choice 1', 1 => 'choice 2'));
     $form->addElement('checkboxgroup', 'choose_multiple8', 'Choose multiple HORIZONTAL LEFT', array('sep' => 'hl'), array(0 => 'choice 1', 1 => 'choice 2'));
     $form->addElement('checkboxgroup', 'choose_multiple9', 'Choose multiple HORIZONTAL RIGHT', array('sep' => 'hr'), array(0 => 'choice 1', 1 => 'choice 2'));
     $form->addElement('checkboxgroup', 'choose_multiple10', 'Custom Separator "|"', array('separator' => '&nbsp;|&nbsp;'), array(0 => 'choice 1', 1 => 'choice 2'));
     $form->addElement('checkboxgroup', 'choose_multiple11', 'Custom Separator "XXX" and LEFT', array('sep' => 'l', 'separator' => '&nbsp;&nbsp;XXX&nbsp;&nbsp;'), array(0 => 'choice 1', 1 => 'choice 2'));
     $form->addElement('checkboxgroup', 'choose_multiple12', 'Custom Separator "...", LEFT and VERTICAL', array('sep' => 'l', 'separator' => '...<br />'), array(0 => 'choice 1', 1 => 'choice 2'));
     $form->addElement('checkboxgroup', 'choose_multiple_big', 'Choose with column format', array(), array(0 => 'choice 1', 'choice 2', 'choice 3', 'choice 4', 'choice 5', 'choice 6', 'choice 7', 'choice 8'));
     $el2 =& $form->addElement('checkboxgroup', 'choose_multiple_big2', 'Choose with column format (2 columns)', array(), array(0 => 'choice 1', 'choice 2', 'choice 3', 'choice 4', 'choice 5', 'choice 6', 'choice 7', 'choice 8'));
     $el2->setColumns(2);
     $el3 =& $form->addElement('checkboxgroup', 'choose_multiple_big3', 'Choose with column format (3 columns and a default "select all")', array(), array(0 => 'choice 1', 'choice 2', 'choice 3', 'choice 4', 'choice 5', 'choice 6', 'choice 7', 'choice 8', 'choice 9'));
     $el3->setColumns(3);
     $el3->addSelectAll();
     $el4 =& $form->addElement('checkboxgroup', 'choose_multiple_big4', 'Choose with column format (3 columns and a "select all" on top)', array(), array(0 => 'choice 1', 'choice 2', 'choice 3', 'choice 4', 'choice 5', 'choice 6', 'choice 7', 'choice 8'));
     $el4->setColumns(3);
     $el4->addSelectAll(false);
     // demonstrate disable on checkboxgroup
     $form->disable('choose_multiple', 1);
     $form->disable('choose_multiple2', array(0, 1));
     $form->disable('choose_multiple3');
     // Add and example about 'select all' button
     $el->addSelectAll();
     // Add the submit button
     $form->addElement('submit', 'btnSubmit', 'submit');
     // Set the defaults
     $form->setDefaults(array('choose_multiple' => array(0 => 0, 1 => 1)));
     // Process the form
     if ($form->validate() === true) {
         YDDebugUtil::dump($form->getValues());
     }
     // Add the template
     $tpl = new YDTemplate();
     // Add the form to the template
     $tpl->assign('form', $form->toHTML());
     // Display the template
     $tpl->display();
 }
开发者ID:BackupTheBerlios,项目名称:ydframework-svn,代码行数:47,代码来源:form_checkboxgroup.php

示例8: actionDefault

 function actionDefault()
 {
     // Create the form
     $form = new YDForm('form1');
     // Add a first set of elements
     $elementDate = $form->addElement('dateselect', 'dateSelect1', 'Enter data:');
     $elementTime = $form->addElement('timeselect', 'timeSelect1', 'Enter data:');
     $elementDateTime = $form->addElement('datetimeselect', 'datetimeSelect1', 'Enter data:');
     // Add a second set of elements
     $form->addElement('dateselect', 'dateSelect2', 'Enter data:', array(), array('yearstart' => 1970, 'yearend' => '2050'));
     $form->addElement('timeselect', 'timeSelect2', 'Enter data:');
     $form->addElement('datetimeselect', 'datetimeSelect2', 'Enter data:', array(), array('yearstart' => 1970, 'yearend' => '2050'));
     $form->addElement('datetimeselect', 'datetimeSelect3', 'Enter data with seconds:', array(), array('seconds' => true));
     // Add the send button
     $form->addElement('submit', 'cmd1', 'Send');
     // Set the defaults
     $form->setDefaults(array('dateSelect1' => array('month' => 4, 'day' => 4, 'year' => 2002), 'dateSelect2' => strval(time()), 'timeSelect2' => strval(time()), 'datetimeSelect2' => time() + 3600 * 24));
     // Display the form
     $form->display();
     // Show the contents of the form
     if (YDConfig::get('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('dateSelect1'), 'dateSelect1');
         YDDebugUtil::dump($form->getValue('timeSelect1'), 'timeSelect1');
         YDDebugUtil::dump($form->getValue('datetimeSelect1'), 'datetimeSelect1');
         YDDebugUtil::dump($form->getValues(), '$form->getValues()');
         YDDebugUtil::dump($_POST, '$_POST');
         YDDebugUtil::dump($_FILES, '$_FILES');
     }
     if ($form->validate()) {
         YDDebugUtil::dump($form->getValues(), '$form->getValues()');
         YDDebugUtil::dump($elementDate->getTimeStamp(), '$elementDate->getTimeStamp()');
         YDDebugUtil::dump($elementDate->getTimeStamp('%d/%m/%Y'), '$elementDate->getTimeStamp( "%d/%m/%Y" )');
         YDDebugUtil::dump(date('M-d-Y', $elementDate->getTimeStamp()), '$elementDate->gdate( getTimeStamp() )');
         YDDebugUtil::dump($elementTime->getTimeStamp(), '$elementTime->getTimeStamp()');
         YDDebugUtil::dump($elementTime->getTimeStamp('%H:%M'), '$elementTime->getTimeStamp( "%H:%M" )');
         YDDebugUtil::dump($elementDateTime->getTimeStamp(), '$elementDateTime->getTimeStamp()');
         YDDebugUtil::dump($elementDateTime->getTimeStamp('%d/%m/%Y %H:%M'), '$elementDateTime->getTimeStamp( "%H:%M" )');
         YDDebugUtil::dump(YDStringUtil::formatDate($elementDateTime, 'datetime', 'pt'), 'YDStringUtil::formatDate');
     }
 }
开发者ID:BackupTheBerlios,项目名称:ydframework-svn,代码行数:46,代码来源:form_dateselect.php

示例9: 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

示例10: actionDefault

 function actionDefault()
 {
     // Get the list of files and file sizes
     $cache_pub_lbl = 'Public cache ' . $this->_getTotalSizeAndCountAsText(YD_WEBLOG_CACHE_PREFIX . '*.' . YD_WEBLOG_CACHE_SUFFIX);
     $cache_tmb_lbl = 'Thumbnail cache ' . $this->_getTotalSizeAndCountAsText(YD_TMP_PRE . 'N_*.*');
     $cache_web_lbl = 'Web download cache ' . $this->_getTotalSizeAndCountAsText('*.wch');
     $cache_tpl_lbl = 'Template cache ' . $this->_getTotalSizeAndCountAsText('*.tpl.php');
     // Create the delete form
     $form = new YDForm('clearCacheForm');
     $form->addElement('checkbox', 'cache_pub', $cache_pub_lbl, array('style' => 'border: none;'));
     $form->addElement('checkbox', 'cache_tmb', $cache_tmb_lbl, array('style' => 'border: none;'));
     $form->addElement('checkbox', 'cache_web', $cache_web_lbl, array('style' => 'border: none;'));
     $form->addElement('checkbox', 'cache_tpl', $cache_tpl_lbl, array('style' => 'border: none;'));
     $form->addElement('submit', '_cmdSubmit', t('cleanup'), array('class' => 'button'));
     $form->setDefaults(array('cache_pub' => 1, 'cache_web' => 1, 'cache_tmb' => 1, 'cache_tpl' => 1));
     // Validate the form
     if ($form->validate() == true) {
         // Check if we need to delete the thumbnail objects
         if ($form->getValue('cache_pub')) {
             $this->_deleteCacheFiles(YD_WEBLOG_CACHE_PREFIX . '*.' . YD_WEBLOG_CACHE_SUFFIX);
         }
         // Check if we need to delete the thumbnail objects
         if ($form->getValue('cache_tmb') == 1) {
             $this->_deleteCacheFiles(YD_TMP_PRE . 'N_*.*');
         }
         // Check if we need to delete the web objects
         if ($form->getValue('cache_web')) {
             $this->_deleteCacheFiles('*.wch');
         }
         // Check if we need to delete the template objects
         if ($form->getValue('cache_tpl')) {
             $this->_deleteCacheFiles('*.tpl.php');
         }
         // Add a status message
         $this->tpl->assign('message', t('cache_cleaned_up'));
     }
     // Add the form to the template
     $this->tpl->assignForm('form', $form);
     // Display the template
     $this->display();
 }
开发者ID:BackupTheBerlios,项目名称:ydframework-svn,代码行数:41,代码来源:cache.php

示例11: actionDefault

 function actionDefault()
 {
     // Set the title of the form
     $this->template->assign('title', 'Sample form');
     // Mark the form as not valid
     $this->template->assign('formValid', false);
     // Create the form
     $form = new YDForm('firstForm');
     // Set the defaults
     $form->setDefaults(array('name' => 'Joe User'));
     // Add the elements
     $form->addElement('text', 'name', 'Enter your name:', array('size' => 50));
     $form->addElement('bbtextarea', 'desc1', 'Enter the description:');
     $form->addElement('bbtextarea', 'desc2', 'Enter the description (no toolbar):');
     $form->addElement('bbtextarea', 'desc3', 'Enter the description:');
     $form->addElement('submit', 'cmdSubmit', 'Send');
     // Update the no toolbar element
     $element =& $form->getElement('desc2');
     $element->clearButtons();
     // Add a popup window to the third description
     $element =& $form->getElement('desc3');
     $element->addPopupWindow('form.php?do=selector&field=firstForm_desc3&tag=img', 'select image');
     $element->addPopupWindow('form.php?do=selector&field=firstForm_desc3&tag=url', 'select url');
     // Apply a filter
     $form->addFilter('name', 'trim');
     $form->addFilter('desc1', 'safe_html');
     // Add a rule
     $form->addRule('name', 'required', 'Please enter your name');
     // Process the form
     if ($form->validate()) {
         // Show the form values
         YDDebugUtil::dump($form->getValues());
         // Mark the form as valid
         $this->template->assign('formValid', true);
     }
     // Add the form to the template
     $this->template->assignForm('form', $form);
     // Output the template
     $this->template->display();
 }
开发者ID:BackupTheBerlios,项目名称:ydframework-svn,代码行数:40,代码来源:form.php

示例12: 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

示例13: actionMonProfil

 function actionMonProfil()
 {
     if ($this->user->authentificated) {
         // Create the profile form
         $form = new YDForm('profileForm');
         $form->addElement('textarea', 'profileDescription', t('user.desc'), array("cols" => 50, "rows" => 8));
         $form->addElement('password', 'profilePass', t('user.oldpwd'));
         $form->addElement('password', 'profilePassUn', t('user.newpwd'));
         $form->addElement('password', 'profilePassDeux', t('user.newpwd'));
         $form->addElement('submit', 'cmdSubmit', t('user.saveupdate'));
         // default values
         $form->setDefaults(array('profileDescription' => $this->user->description));
         $form->setDefaults(array('profilePass' => ''));
         $form->setDefaults(array('profilePassUn' => ''));
         $form->setDefaults(array('profilePassDeux' => ''));
         // Add rules
         $form->addFormRule(array(&$this, 'checkPass'));
         // Process the form
         if ($form->validate()) {
             // Update profile
             $newPass = $form->getValue('profilePassUn');
             if (strlen($newPass) > 0) {
                 // Update description and password
                 $this->user->description = $form->getValue('profileDescription');
                 $this->user->password = md5($form->getValue('profilePassUn'));
             } else {
                 // Update only description
                 $this->user->description = $form->getValue('profileDescription');
             }
             $this->user->update();
             $_SESSION['s_user'] = YDObjectUtil::serialize($this->user);
             // Mark the form as valid
             $this->actionTpl->assign('updated', true);
             $form->setDefaults(array('profilePass' => ''));
             $form->setDefaults(array('profilePassUn' => ''));
             $form->setDefaults(array('profilePassDeux' => ''));
         }
         // Assign variables to the template
         $this->actionTpl->assign('form', $form->toArray());
         $content = new page($this->actionTpl->fetch('templates/user.monprofile.tpl'), 'Mon profil');
     } else {
         $content = new page($tpl->fetch('templates/user.notAuth.tpl'), t('global.notconnected'));
     }
     // Display the action template into the master template
     $this->display($content);
 }
开发者ID:BackupTheBerlios,项目名称:ydframework-svn,代码行数:46,代码来源:user.php

示例14: 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

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