function actionDefault() { // Create the form $form = new YDForm('form1'); // Add a first set of elements $form->addElement('date', 'date1', 'Date1', ''); $form->addElement('date', 'date2', 'Date2 (monthabbr = true)', array('id' => 'mydate'), array('monthabbr' => true)); $form->addElement('date', 'date3', 'Date3 (monthnumber = true)', '', array('monthnumber' => true)); $form->addElement('date', 'date4', 'Date4 (monthucfirst = true)', '', array('monthucfirst' => true)); $form->addElement('date', 'date5', 'Date5 (yearstart = 1970, yearend=2007, yeartwodigits = true)', '', array('yearstart' => 1970, 'yearend' => 2007, 'yeartwodigits' => true)); $form->addElement('date', 'time1', 'Time1', '', array('time')); $form->addElement('date', 'time2', 'Time2 (minutesoffset = 10)', '', array('time', 'minutesoffset' => 10)); $form->addElement('date', 'time3', 'Time3 (secondsoffset = 15)', '', array('time', 'secondsoffset' => 15)); $form->addElement('date', 'datetime1', 'DateTime1', '', array('datetime')); $form->addElement('date', 'date6', 'Date6 (month, year)', '', array('month', 'year')); $form->addElement('date', 'date7', 'Date7 (day, month)', '', array('day', 'month')); $form->addElement('date', 'date8', 'Date8 (day, hours, minutes)', '', array('day', 'hours', 'minutes')); $form->addElement('submit', '_cmdSubmit', 'Submit'); // Add rules $form->addRule(array('date1', 'date2', 'date3', 'date4', 'date5', 'time1', 'time2', 'time3', 'datetime1', 'date6', 'date7', 'date8'), 'date', 'must be a valid date'); if ($form->validate()) { YDDebugUtil::dump($form->getValues(), '$form->getValues()'); } // Display form $form->display(); }
function actionDefault() { // Get the data $db = YDDatabase::getInstance('mysql', 'test', 'root', '', 'localhost'); $this->setVar('processList', $db->getRecords('show processlist')); $this->setVar('status', $db->getRecords('show status')); $this->setVar('variables', $db->getRecords('show variables')); $this->setVar('version', $db->getServerVersion()); $this->setVar('sqlcount', $db->getSqlCount()); // Output the template $this->outputTemplate(); // Test string escaping YDDebugUtil::dump($db->string("Pieter's Framework"), '$db->string'); // Test timestamps YDDebugUtil::dump($db->getDate(), 'getDate()'); YDDebugUtil::dump($db->getTime(), 'getTime()'); YDDebugUtil::dump($db->getDate('__NOW__'), 'getDate( \'__NOW__\' )'); YDDebugUtil::dump($db->getTime('__NOW__'), 'getTime( \'__NOW__\' )'); YDDebugUtil::dump($db->getDate('28-FEB-1977'), 'getDate( \'28-FEB-1977\' )'); YDDebugUtil::dump($db->getTime('28-FEB-1977'), 'getTime( \'28-FEB-1977\' )'); YDDebugUtil::dump($db->sqlString($db->getDate()), 'sqlString( getDate() )'); YDDebugUtil::dump($db->sqlString($db->getTime()), 'sqlString( getTime() )'); YDDebugUtil::dump($db->sqlString($db->getDate('__NOW__')), 'sqlString( getDate( \'__NOW__\' ) )'); YDDebugUtil::dump($db->sqlString($db->getTime('__NOW__')), 'sqlString( getTime( \'__NOW__\' ) )'); // Test errors YDDebugUtil::dump($db->getRecords('xx'), 'should return error'); // Close the database connection $db->close(); }
function actionDefault() { // Get the data $db = YDDatabase::getInstance('postgres', 'template1', 'pieter', 'kermit', 'yellowduck'); // Output the server version YDDebugUtil::dump($db->getServerVersion(), 'Version:'); // Output some queries YDDebugUtil::dump($db->getRecords('select now()'), 'select now();'); // Test string escaping YDDebugUtil::dump($db->string("Pieter's Framework"), '$db->string'); // Show number of queries YDDebugUtil::dump($db->getSqlCount(), 'Number of queries'); // Test timestamps YDDebugUtil::dump($db->getDate(), 'getDate()'); YDDebugUtil::dump($db->getTime(), 'getTime()'); YDDebugUtil::dump($db->getDate('__NOW__'), 'getDate( \'__NOW__\' )'); YDDebugUtil::dump($db->getTime('__NOW__'), 'getTime( \'__NOW__\' )'); YDDebugUtil::dump($db->getDate('28-FEB-1977'), 'getDate( \'28-FEB-1977\' )'); YDDebugUtil::dump($db->getTime('28-FEB-1977'), 'getTime( \'28-FEB-1977\' )'); YDDebugUtil::dump($db->sqlString($db->getDate()), 'sqlString( getDate() )'); YDDebugUtil::dump($db->sqlString($db->getTime()), 'sqlString( getTime() )'); YDDebugUtil::dump($db->sqlString($db->getDate('__NOW__')), 'sqlString( getDate( \'__NOW__\' ) )'); YDDebugUtil::dump($db->sqlString($db->getTime('__NOW__')), 'sqlString( getTime( \'__NOW__\' ) )'); // Test limits YDDebugUtil::dump($db->_prepareSqlForLimit('SELECT * FROM TABLE', 10)); YDDebugUtil::dump($db->_prepareSqlForLimit('SELECT * FROM TABLE', 10, 25)); // Test errors YDDebugUtil::dump($db->getRecords('xx'), 'should return error'); // Close the database connection $db->close(); }
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(); }
function actionDefault() { // We want to test the different image types foreach (array('jpg', 'gif', 'png') as $imgType) { // Get the file object for the current file $img = new YDFSImage(dirname(__FILE__) . '/fsimage.' . $imgType); // Dump the object YDDebugUtil::dump($img, __FILE__); // Dump the object echo '<br>Basename: ' . $img->getBasename(); echo '<br>Extension: ' . $img->getExtension(); echo '<br>Path: ' . $img->getPath(); echo '<br>LastModified: ' . $img->getLastModified(); echo '<br>File size: ' . $img->getSize(); echo '<br>Width: ' . $img->getWidth(); echo '<br>Height: ' . $img->getHeight(); echo '<br>Image type: ' . $img->getImageType(); echo '<br>MIME type: ' . $img->getMimeType(); // Image size YDDebugUtil::dump($img->getImageSize(), 'Imagesize'); // Save a thumbnail YDDebugUtil::dump($img->saveThumbnail(150, 110, 'fsimage.thumb.jpg')); } // Get the file object for the current file $file = new YDFSFile('nofile.php'); }
function actionDefault() { // Get the data $db = YDDatabase::getInstance('sqlite', 'database2.db'); // Output the server version YDDebugUtil::dump($db->getServerVersion(), 'Version:'); // Output some queries YDDebugUtil::dump($db->getRecords('select * from escalations'), 'escalations'); YDDebugUtil::dump($db->getRecords('select * from sqlite_master'), 'sqlite_master'); // Test string escaping YDDebugUtil::dump($db->string("Pieter's Framework"), '$db->string'); // Show number of queries YDDebugUtil::dump($db->getSqlCount(), 'Number of queries'); // Test timestamps YDDebugUtil::dump($db->getDate(), 'getDate()'); YDDebugUtil::dump($db->getTime(), 'getTime()'); YDDebugUtil::dump($db->getDate('__NOW__'), 'getDate( \'__NOW__\' )'); YDDebugUtil::dump($db->getTime('__NOW__'), 'getTime( \'__NOW__\' )'); YDDebugUtil::dump($db->getDate('28-FEB-1977'), 'getDate( \'28-FEB-1977\' )'); YDDebugUtil::dump($db->getTime('28-FEB-1977'), 'getTime( \'28-FEB-1977\' )'); YDDebugUtil::dump($db->sqlString($db->getDate()), 'sqlString( getDate() )'); YDDebugUtil::dump($db->sqlString($db->getTime()), 'sqlString( getTime() )'); YDDebugUtil::dump($db->sqlString($db->getDate('__NOW__')), 'sqlString( getDate( \'__NOW__\' ) )'); YDDebugUtil::dump($db->sqlString($db->getTime('__NOW__')), 'sqlString( getTime( \'__NOW__\' ) )'); // Test errors YDDebugUtil::dump($db->getRecords('xx'), 'should return error'); // Close the database connection $db->close(); }
function actionDefault() { // Define the date format used for testing $fmt = '%A, %d %B %Y'; // Default locale is always en YDDebugUtil::dump(YDLocale::get(), 'Current locale:'); YDDebugUtil::dump(strftime($fmt), 'strftime test'); // Set the locale to English YDLocale::set('eng'); YDDebugUtil::dump(YDLocale::get(), 'Current locale:'); YDDebugUtil::dump(strftime($fmt), 'strftime test'); // Set the locale to Dutch YDLocale::set('nl'); YDDebugUtil::dump(YDLocale::get(), 'Current locale:'); YDDebugUtil::dump(strftime($fmt), 'strftime test'); YDDebugUtil::dump(date("l dS of F Y h:i:s A"), 'date function'); // Set the locale to Portugese YDLocale::set('ptg'); YDDebugUtil::dump(YDLocale::get(), 'Current locale:'); YDDebugUtil::dump(strftime($fmt), 'strftime test'); // Set the locale to Italian YDLocale::set('ita'); YDDebugUtil::dump(YDLocale::get(), 'Current locale:'); YDDebugUtil::dump(strftime($fmt), 'strftime test'); }
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(); } }
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'); }
function actionDefault() { // Get the file object for the current file $file = new YDFSFile(__FILE__); // Dump the object echo __FILE__; YDDebugUtil::dump($file); // Dump the object echo '<br>Basename: ' . $file->getBasename(); echo '<br>Extension: ' . $file->getExtension(); echo '<br>Path: ' . $file->getPath(); echo '<br>LastModified: ' . $file->getLastModified(); echo '<br>File size: ' . $file->getSize(); // Get the contents YDDebugUtil::dump($file->getContents(), '$file->getContents()'); // Get the partial contents YDDebugUtil::dump($file->getContents(2, 3), '$file->getContents( 2, 3 )'); // Create a dummy file $dir = new YDFSDirectory('.'); $file = $dir->createFile('dummy.txt', 'initial contents'); // Update the contents $file->setContents('new contents'); // Get the contents YDDebugUtil::dump($file->getContents(), '$file->getContents() after update'); // Append the contents $file->setContents(YD_CRLF . 'appended contents', true); // Get the contents YDDebugUtil::dump($file->getContents(), '$file->getContents() after append'); // Delete the file $file->delete(); // Get the file object for the current file $file = new YDFSFile('nofile.php'); }
function actionDefault() { // Get the data $db = YDDatabase::getInstance('oracle', 'CREODB_STATLER', 'prinergy_rpt', 'prinergy_rpt'); // Output the server version YDDebugUtil::dump($db->getServerVersion(), 'Version:'); // Output some queries YDDebugUtil::dump($db->getRecords('select * from RPT_Customer_V'), 'RPT_Customer_V'); // Output some queries YDDebugUtil::dump($db->getValue('select sysdate from dual'), 'sysdate'); // Test string escaping YDDebugUtil::dump($db->escape("Pieter's Framework"), '$db->escape'); // Show number of queries YDDebugUtil::dump($db->getSqlCount(), 'Number of queries'); // Test timestamps YDDebugUtil::dump($db->getDate(), 'getDate()'); YDDebugUtil::dump($db->getTime(), 'getTime()'); YDDebugUtil::dump($db->getDate('__NOW__'), 'getDate( \'__NOW__\' )'); YDDebugUtil::dump($db->getTime('__NOW__'), 'getTime( \'__NOW__\' )'); YDDebugUtil::dump($db->getDate('28-FEB-1977'), 'getDate( \'28-FEB-1977\' )'); YDDebugUtil::dump($db->getTime('28-FEB-1977'), 'getTime( \'28-FEB-1977\' )'); YDDebugUtil::dump($db->escapeSql($db->getDate()), 'escapeSql( getDate() )'); YDDebugUtil::dump($db->escapeSql($db->getTime()), 'escapeSql( getTime() )'); YDDebugUtil::dump($db->escapeSql($db->getDate('__NOW__')), 'escapeSql( getDate( \'__NOW__\' ) )'); YDDebugUtil::dump($db->escapeSql($db->getTime('__NOW__')), 'escapeSql( getTime( \'__NOW__\' ) )'); // Test limits YDDebugUtil::dump($db->_prepareSqlForLimit('SELECT * FROM TABLE', 10)); YDDebugUtil::dump($db->_prepareSqlForLimit('SELECT * FROM TABLE', 10, 25)); // Test errors YDDebugUtil::dump($db->getRecords('xx'), 'should return error'); // Close the database connection $db->close(); }
function actionDefault() { // Get the directory object for the current directory $dir = new YDFSDirectory(dirname(__FILE__)); // Dump the object YDDebugUtil::dump($dir, dirname(__FILE__)); // Dump the path properties YDDebugUtil::dump($dir->getBasename(), '$dir->getBasename()'); YDDebugUtil::dump($dir->getPath(), '$dir->getPath()'); YDDebugUtil::dump($dir->getAbsolutePath(), '$dir->getAbsolutePath()'); YDDebugUtil::dump($dir->getAbsolutePath(), '$dir->getAbsolutePath()'); YDDebugUtil::dump($dir->getSize(), '$dir->getSize()'); YDDebugUtil::dump($dir->getSize(false, true), '$dir->getSize( false, true )'); YDDebugUtil::dump($dir->getSize(true), '$dir->getSize( true )'); YDDebugUtil::dump($dir->getSize(true, true), '$dir->getSize( true, true )'); YDDebugUtil::dump($dir->getFileCount(), '$dir->getFileCount()'); YDDebugUtil::dump($dir->getDirectoryCount(), '$dir->getDirectoryCount()'); // All files in the directory YDDebugUtil::dump($dir->getContents(), '$dir->getContents()'); // PHP files in the directory YDDebugUtil::dump($dir->getContents('*.tpl'), '$dir->getContents( \'*.tpl\' )'); // PHP files in the directory YDDebugUtil::dump($dir->getContents(array('*.jpg', '*.txt')), '$dir->getContents( array( \'*.jpg\', \'*.txt\' ) )'); // Getting files recursively YDDebugUtil::dump($dir->getFilesRecursively('*.tpl'), '$dir->getFilesRecursively( \'*.tpl\' )'); // PHP files in the directory YDDebugUtil::dump($dir->getContents(array('*.jpg', '*.txt', '!bbcode.*')), '$dir->getContents( array( \'*.jpg\', \'*.txt\', \'!bbcode.*\' ) )'); // Create subdirectory YDDebugUtil::dump($dir->createDirectory('test'), '$dir->createDirectory( \'test\' ) )'); // Delete a directory tree YDDebugUtil::dump($dir->deleteDirectory('test'), '$dir->deleteDirectory( \'test\' )'); YDDebugUtil::dump($dir->deleteDirectory('xxx'), '$dir->deleteDirectory( \'xxx\' )'); }
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(); }
function actionDefault() { // Test the formatting of filesizes $filesizes = array('1152921504606846977', '1125899906842625', '1099511627777', '75715455455', '1048577', '6543', '42'); // Format the filesizes foreach ($filesizes as $filesize) { YDDebugUtil::dump(YDStringUtil::formatFileSize($filesize), 'Formatting filesize: ' . $filesize); } // Test the formatDate function YDDebugUtil::dump(YDStringUtil::formatDate(time(), 'date'), 'Formatting date - date'); YDDebugUtil::dump(YDStringUtil::formatDate(time(), 'time'), 'Formatting date - time'); YDDebugUtil::dump(YDStringUtil::formatDate(time(), 'datetime'), 'Formatting date - datetime'); YDDebugUtil::dump(YDStringUtil::formatDate(time(), '%x'), 'Formatting date - %x'); // Test the encode string function $string = 'Pieter Claerhout @ creo.com "générales obsolète"'; YDDebugUtil::dump(YDStringUtil::encodeString($string), 'Encoding: ' . $string); // Test the truncate function YDDebugUtil::dump(YDStringUtil::truncate($string), 'Truncate (default): ' . $string); YDDebugUtil::dump(YDStringUtil::truncate($string, 20), 'Truncate (20): ' . $string); YDDebugUtil::dump(YDStringUtil::truncate($string, 20, ' [more]'), 'Truncate (20/more): ' . $string); YDDebugUtil::dump(YDStringUtil::truncate($string, 20, ' [more]', true), 'Truncate (20/more/true): ' . $string); // Test the normalizing of newlines $string = "line1\nline2\rline3\r\nline4"; YDDebugUtil::dump(explode("\n", $string), 'Original string'); YDDebugUtil::dump(explode(YD_CRLF, YDStringUtil::normalizeNewlines($string)), 'normalizeNewlines'); // Test the normalizing of newlines $string = " line1 \n line2 \r line3 \r\n line4 "; YDDebugUtil::dump(YDStringUtil::removeWhiteSpace($string), 'removeWhiteSpace'); }
function actionDefault() { // Set some variables YDConfig::set('MyConfigVar1', 'value cfg1'); YDConfig::set('MyConfigVar2', 'value cfg2'); YDConfig::set('MyConfigVar3', 'value cfg3'); // Get the values YDDebugUtil::dump(YDConfig::get('MyConfigVar1'), 'get - MyConfigVar1'); YDDebugUtil::dump(YDConfig::get('MyConfigVar2'), 'get - MyConfigVar2'); YDDebugUtil::dump(YDConfig::get('MyConfigVar3'), 'get - MyConfigVar3'); // Check if the variables exist or not YDDebugUtil::dump(YDConfig::exists('MyConfigVar1'), 'exists - MyConfigVar1'); YDDebugUtil::dump(YDConfig::exists('MyConfigVar2'), 'exists - MyConfigVar2'); YDDebugUtil::dump(YDConfig::exists('MyConfigVar3'), 'exists - MyConfigVar3'); // Check an unexisting variable YDDebugUtil::dump(YDConfig::exists('xx'), 'exists - xx'); // Set some variables, not overriding existing values YDConfig::set('MyConfigVar1', 'value cfg1 changed', false); YDConfig::set('MyConfigVar2', 'value cfg2 changed', false); YDConfig::set('MyConfigVar3', 'value cfg3 changed', false); // Get the values (should be unchanged) YDDebugUtil::dump(YDConfig::get('MyConfigVar1'), 'get - MyConfigVar1 - changed1'); YDDebugUtil::dump(YDConfig::get('MyConfigVar2'), 'get - MyConfigVar2 - changed1'); YDDebugUtil::dump(YDConfig::get('MyConfigVar3'), 'get - MyConfigVar3 - changed1'); // Set some variables, overriding existing values YDConfig::set('MyConfigVar1', 'value cfg1 changed', true); YDConfig::set('MyConfigVar2', 'value cfg2 changed', true); YDConfig::set('MyConfigVar3', 'value cfg3 changed', true); // Get the values (should be changed) YDDebugUtil::dump(YDConfig::get('MyConfigVar1'), 'get - MyConfigVar1 - changed2'); YDDebugUtil::dump(YDConfig::get('MyConfigVar2'), 'get - MyConfigVar2 - changed2'); YDDebugUtil::dump(YDConfig::get('MyConfigVar3'), 'get - MyConfigVar3 - changed2'); // Dump the contents of YDConfig YDConfig::dump(); }
function before_actionEdit_callback() { $browser = new YDBrowserInfo(); $agent = YDDebugUtil::r_dump($browser->agent, 'Agent'); $additional_information = "<p>Additional Information added by the before_actionEdit_callback() callback</p>"; $this->template->assign('browserinfo', '<pre>' . $agent . '</pre>' . $additional_information); }
function actionStatus() { // Create the URL object $url = new YDUrl('http://www.yellowduck.be/index.xml'); // Dump the headers YDDebugUtil::dump($url->getStatus()); }
function actionDefault() { // Get the data $db = YDDatabase::getInstance('mysql', 'test', 'root', '', 'localhost'); $this->template->assign('processList', $db->getRecords('show processlist')); $this->template->assign('status', $db->getRecords('show status')); $this->template->assign('variables', $db->getRecords('show variables')); $this->template->assign('version', $db->getServerVersion()); $this->template->assign('sqlcount', $db->getSqlCount()); // Output the template $this->template->display(); // Test string escaping YDDebugUtil::dump($db->escape("Pieter's Framework"), '$db->escape'); YDDebugUtil::dump($db->prepareSql('SELECT * FROM comments WHERE id = :1 and author = :2', 1, "Pieter's Author"), '$db->prepareSql'); // Test timestamps YDDebugUtil::dump($db->getDate(), 'getDate()'); YDDebugUtil::dump($db->getTime(), 'getTime()'); YDDebugUtil::dump($db->getDate('__NOW__'), 'getDate( \'__NOW__\' )'); YDDebugUtil::dump($db->getTime('__NOW__'), 'getTime( \'__NOW__\' )'); YDDebugUtil::dump($db->getDate('28-FEB-1977'), 'getDate( \'28-FEB-1977\' )'); YDDebugUtil::dump($db->getTime('28-FEB-1977'), 'getTime( \'28-FEB-1977\' )'); YDDebugUtil::dump($db->escapeSql($db->getDate()), 'escapeSql( getDate() )'); YDDebugUtil::dump($db->escapeSql($db->getTime()), 'escapeSql( getTime() )'); YDDebugUtil::dump($db->escapeSql($db->getDate('__NOW__')), 'escapeSql( getDate( \'__NOW__\' ) )'); YDDebugUtil::dump($db->escapeSql($db->getTime('__NOW__')), 'escapeSql( getTime( \'__NOW__\' ) )'); // Test limits YDDebugUtil::dump($db->_prepareSqlForLimit('SELECT * FROM TABLE', 10)); YDDebugUtil::dump($db->_prepareSqlForLimit('SELECT * FROM TABLE', 10, 30)); // Test errors YDDebugUtil::dump($db->getRecords('xx'), 'should return error'); // Close the database connection $db->close(); }
function actionDefault() { // Get the data $db = YDDatabase::getInstance('sqlite', 'database2.db'); // Output the server version YDDebugUtil::dump($db->getServerVersion(), 'Version:'); // Output some queries YDDebugUtil::dump($db->getRecords('select * from escalations'), 'escalations'); YDDebugUtil::dump($db->getRecords('select * from sqlite_master'), 'sqlite_master'); YDConfig::set('YD_DB_FETCHTYPE', YD_DB_FETCH_NUM); YDDebugUtil::dump($db->getRecords('select * from sqlite_master'), 'array - sqlite_master'); YDConfig::set('YD_DB_FETCHTYPE', YD_DB_FETCH_ASSOC); // Test string escaping YDDebugUtil::dump($db->string("Pieter's Framework"), '$db->string'); // Show number of queries YDDebugUtil::dump($db->getSqlCount(), 'Number of queries'); // Test timestamps YDDebugUtil::dump($db->getDate(), 'getDate()'); YDDebugUtil::dump($db->getTime(), 'getTime()'); YDDebugUtil::dump($db->getDate('__NOW__'), 'getDate( \'__NOW__\' )'); YDDebugUtil::dump($db->getTime('__NOW__'), 'getTime( \'__NOW__\' )'); YDDebugUtil::dump($db->getDate('28-FEB-1977'), 'getDate( \'28-FEB-1977\' )'); YDDebugUtil::dump($db->getTime('28-FEB-1977'), 'getTime( \'28-FEB-1977\' )'); YDDebugUtil::dump($db->sqlString($db->getDate()), 'sqlString( getDate() )'); YDDebugUtil::dump($db->sqlString($db->getTime()), 'sqlString( getTime() )'); YDDebugUtil::dump($db->sqlString($db->getDate('__NOW__')), 'sqlString( getDate( \'__NOW__\' ) )'); YDDebugUtil::dump($db->sqlString($db->getTime('__NOW__')), 'sqlString( getTime( \'__NOW__\' ) )'); // Test limits YDDebugUtil::dump($db->_prepareSqlForLimit('SELECT * FROM TABLE', 10)); YDDebugUtil::dump($db->_prepareSqlForLimit('SELECT * FROM TABLE', 10, 25)); // Test errors YDDebugUtil::dump($db->getRecords('xx'), 'should return error'); // Close the database connection $db->close(); }
function actionDefault() { // Get the database connections $db1 = YDDatabase::getInstance('mysql', 'ydweblog', 'root', '', 'localhost'); $db2 = YDDatabase::getInstance('oracle', 'creodb_directeur', 'prinergy', 'araxi'); $db3 = YDDatabase::getInstance('postgres', 'test_db', 'postgres', 'Ster4484', 'localhost'); $db4 = YDDatabase::getInstance('sqlite', 'db_metadata.db'); // Get the metadata $db1_meta = new YDDatabaseMetaData($db1); $db2_meta = new YDDatabaseMetaData($db2); $db3_meta = new YDDatabaseMetaData($db3); $db4_meta = new YDDatabaseMetaData($db4); // Get the list of tables YDDebugUtil::dump($db1_meta->getTables(), 'mysql - getTables'); YDDebugUtil::dump($db2_meta->getTables(), 'oracle - getTables'); YDDebugUtil::dump($db3_meta->getTables(), 'postgres - getTables'); YDDebugUtil::dump($db4_meta->getTables(), 'sqlite - getTables'); // Get the list of fields for a table YDDebugUtil::dump($db1_meta->getFields('ydw_items'), 'mysql - getFields'); YDDebugUtil::dump($db2_meta->getFields('dbcs_jacket'), 'oracle - getFields'); YDDebugUtil::dump($db3_meta->getFields(), 'postgres - getFields'); YDDebugUtil::dump($db4_meta->getFields('notes'), 'sqlite - getFields'); // Get the list of indexes for a table YDDebugUtil::dump($db1_meta->getIndexes('ydw_items'), 'mysql - getIndexes'); YDDebugUtil::dump($db2_meta->getIndexes('dbcs_jacket'), 'oracle - getIndexes'); YDDebugUtil::dump($db3_meta->getIndexes(), 'postgres - getIndexes'); YDDebugUtil::dump($db4_meta->getIndexes('notes'), 'sqlite - getIndexes'); }
function actionCurrentTime() { // Create an XML/RPC client $client = new YDXmlRpcClient('http://time.xmlrpc.com/RPC2'); // currentTime.getCurrentTime $result = $client->execute('currentTime.getCurrentTime'); YDDebugUtil::dump($result, 'currentTime.getCurrentTime'); }
function actionDefault() { // get group 2 YDDebugUtil::dump($this->groups->getGroup(2), '$this->groups->getGroup( 2 );'); // get group 4 (don't exist because node is a user) YDDebugUtil::dump($this->groups->getGroup(4), '$this->groups->getGroup( 4 ); // 4 is a user'); // get group with name 'Administrators' YDDebugUtil::dump($this->groups->getGroup('Administrators'), '$this->groups->getGroup( "Administrators" );'); }
function actionDefault() { // Create the form echo '<p><b>Compare rule: equal</b></p>'; $form1 = new YDForm('form_equal'); $form1->addElement('text', 'txt1', 'Enter text 1:'); $form1->addElement('text', 'txt2', 'Enter text 2:'); $form1->addElement('text', 'txt3', 'Enter text 3:'); $form1->addElement('submit', 'cmd1', 'equal'); // Add the rules $form1->addRule('txt1', 'numeric', 'txt1 should be numeric'); $form1->addRule('txt2', 'numeric', 'txt2 should be numeric'); $form1->addRule('txt3', 'numeric', 'txt2 should be numeric'); $form1->addCompareRule(array('txt1', 'txt2', 'txt3'), 'equal', 'txt1, txt2 and txt3 should be equal'); // Validate or show the form if ($form1->validate()) { YDDebugUtil::dump($form1->getValues(), 'Form1 values'); } else { $form1->display(); } // Create the form echo '<p><b>Compare rule: asc</b></p>'; $form2 = new YDForm('form_asc'); $form2->addElement('text', 'txt1', 'Enter text 1:'); $form2->addElement('text', 'txt2', 'Enter text 2:'); $form2->addElement('text', 'txt3', 'Enter text 3:'); $form2->addElement('submit', 'cmd1', 'asc'); // Add the rules $form2->addRule('txt1', 'numeric', 'txt1 should be numeric'); $form2->addRule('txt2', 'numeric', 'txt2 should be numeric'); $form2->addRule('txt3', 'numeric', 'txt2 should be numeric'); $form2->addCompareRule(array('txt1', 'txt2', 'txt3'), 'asc', 'txt1 < txt2 < txt3'); // Validate or show the form if ($form2->validate()) { YDDebugUtil::dump($form2->getValues(), 'Form2 values'); } else { $form2->display(); } // Create the form echo '<p><b>Compare rule: desc</b></p>'; $form3 = new YDForm('form_desc'); $form3->addElement('text', 'txt1', 'Enter text 1:'); $form3->addElement('text', 'txt2', 'Enter text 2:'); $form3->addElement('text', 'txt3', 'Enter text 3:'); $form3->addElement('submit', 'cmd1', 'desc'); // Add the rules $form3->addRule('txt1', 'numeric', 'txt1 should be numeric'); $form3->addRule('txt2', 'numeric', 'txt2 should be numeric'); $form3->addRule('txt3', 'numeric', 'txt2 should be numeric'); $form3->addCompareRule(array('txt1', 'txt2', 'txt3'), 'desc', 'txt1 > txt2 > txt3'); // Validate or show the form if ($form3->validate()) { YDDebugUtil::dump($form3->getValues(), 'Form3 values'); } else { $form3->display(); } }
function actionDefault() { $browser = new YDBrowserInfo(); YDDebugUtil::dump($browser->getAgent(), 'Agent'); YDDebugUtil::dump($browser->getBrowser(), 'Browser name'); YDDebugUtil::dump($browser->getVersion(), 'Version'); YDDebugUtil::dump($browser->getPlatform(), 'Platform'); YDDebugUtil::dump($browser->getDotNetRuntimes(), 'Installed .NET runtimes'); YDDebugUtil::dump($browser->getBrowserLanguages(), 'Languages supported by the browser'); YDDebugUtil::dump($browser->getLanguage(), 'Negotiated language'); }
function actionRestore() { // Include filesystem functions YDInclude('YDFileSystem.php'); // Create file object $file = new YDFSFile($this->dump->getFilePath()); // Restore the database dump $this->dump->restore($file->getContents()); // Show the properties of the database backup YDDebugUtil::dump($file->getContents(), $this->dump->getFilePath()); }
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(); }
function actionDefault() { // get user 6 YDDebugUtil::dump($this->users->getUser(6), '$this->users->getUser( 6 );'); // get user 4 (with details translated) YDDebugUtil::dump($this->users->getUser(4, true), '$this->users->getUser( 4, true ); // details translated'); // get user 3 (don't exist because node is a group) YDDebugUtil::dump($this->users->getUser(3), '$this->users->getUser( 3 ); // 3 is a group'); // get user with username 'francisco' YDDebugUtil::dump($this->users->getUser('francisco'), '$this->users->getUser( "francisco" );'); }
function actionDefault() { // Get the debug URI if (strpos(YD_SELF_URI, 'YD_DEBUG=1') === false) { echo 'You need to run in <a href="' . YD_SELF_SCRIPT . '?YD_DEBUG=1">debugging mode</a> to see something.'; } else { echo 'If you go <a href="' . YD_SELF_SCRIPT . '">out of the debugging mode</a>, the stack trace will be hidden.'; } // Get the file object for the current file YDDebugUtil::stackTrace(); }
function actionDefault() { $browser = new YDBrowserInfo(); YDDebugUtil::dump($browser->agent, 'Agent'); YDDebugUtil::dump($browser->browser, 'Browser name'); YDDebugUtil::dump($browser->version, 'Version'); YDDebugUtil::dump($browser->platform, 'Platform'); YDDebugUtil::dump($browser->dotnet, 'Installed .NET runtimes'); YDDebugUtil::dump($browser->getBrowserLanguages(), 'Languages supported by the browser'); YDDebugUtil::dump($browser->getLanguage(), 'Negotiated language'); }
function actionDefault() { // Generate 10 GUIDs foreach (range(1, 10) as $i) { // Show the raw version $guid = YDGuidUtil::create(); YDDebugUtil::dump($guid, 'GUID ' . $i); // Create a formatted one $guid_formatted = YDGuidUtil::format($guid); YDDebugUtil::dump($guid_formatted, 'Formatted GUID ' . $i); } }