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() { // 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(); }
/** * @returns The current locale. */ function get() { // Set the default locale YDConfig::set(YD_LOCALE_KEY, 'en', false); // Return the setting return strtolower(YDConfig::get(YD_LOCALE_KEY)); }
/** * This function sets the value of a part of the format. * * @param $name The format name. * @param $part The part name: string, parts, regexes or empty. * @param $value The part value. * * @static */ function set($name, $part = 'string', $value) { $all = YDConfig::get('YD_DATE_FORMATS'); $name = strtoupper($name); if (!isset($all[$name])) { $all[$name] = array('string' => '', 'parts' => array(), 'regexes' => array(), 'empty' => ''); } $all[$name][$part] = $value; YDConfig::set('YD_DATE_FORMATS', $all); }
function YDWeblogRequest() { // Initialize the parent $this->YDRequest(); // Check if we allow caching $this->caching = true; // Delete the cache if caching is disabled if (YDConfig::get('use_cache', false) === false) { $this->clearCache(); } // Start with no userdata and check the authentication $this->user = null; // This requires authentication $this->setRequiresAuthentication(true); // Setup the weblog object $this->weblog = new YDWeblogAPI(); // Get the skin $this->skin = YDConfig::get('weblog_skin', 'default'); // Get the shortcuts to the directories $this->dir_uploads = YDConfig::get('dir_uploads', 'uploads'); $this->dir_skins = YDConfig::get('dir_skins', 'skins') . '/'; // Default to default skin if (!is_dir(dirname(__FILE__) . '/../' . $this->dir_skins . $this->skin . '/')) { YDConfig::set('weblog_skin', 'default'); $this->skin = YDConfig::get('weblog_skin', 'default'); } // Initialize the template $this->tpl = new YDTemplate(); $this->tpl->template_dir = dirname(__FILE__) . '/../' . $this->dir_skins . $this->skin . '/'; // Register the modifiers $this->tpl->register_modifier('date', 'YDTplModDate'); $this->tpl->register_modifier('link_item', 'YDTplModLinkItem'); $this->tpl->register_modifier('link_item_gallery', 'YDTplModLinkItemGallery'); $this->tpl->register_modifier('link_item_images', 'YDTplModLinkItemImages'); $this->tpl->register_modifier('link_item_comment', 'YDTplModLinkItemComment'); $this->tpl->register_modifier('link_item_respond', 'YDTplModLinkItemRespond'); $this->tpl->register_modifier('link_category', 'YDTplModLinkCategory'); $this->tpl->register_modifier('link_page', 'YDTplModLinkPage'); $this->tpl->register_modifier('link_link', 'YDTplModLinkLink'); $this->tpl->register_modifier('link_thumb', 'YDTplModLinkThumb'); $this->tpl->register_modifier('link_thumb_small', 'YDTplModLinkThumbSmall'); $this->tpl->register_modifier('text_num_comments', 'YDTplModTextNumComments'); $this->tpl->register_modifier('text_num_images', 'YDTplModTextNumImages'); }
/** * This function creates all YDF Configs */ function apply() { // if we don't have results maybe we should load them if (empty($this->_results)) { $this->load(); } // cycle all results to apply YDConfig foreach ($this->_results as $name => $value) { YDConfig::set($name, $value); } }
YDConfig::set('YD_AJAX_PREFIX', "__ydf", false); /** * This config defines the html tag to use * Default: </head> */ YDConfig::set('YD_AJAX_TAG', "</head>", false); /** * This config defines if ajax code must be placed after tag (true) or before tag (false). * Default: false. */ YDConfig::set('YD_AJAX_AFTERTAG', false, false); /** * This config defines custom debug value * Default: false */ YDConfig::set('YD_AJAX_DEBUG', false, false); /** * Include the needed libraries. */ require_once dirname(__FILE__) . '/xajax.inc.php'; /** * Class definition for the YDAjax addon. */ class YDAjax extends xajax { /** * This is the class constructor for the YDAjax class. * * @param $template Template object. * @param $form Form object. */
$form = new YDForm('ydcmforumpost'); $form->addElement('textarea', 'content', 'Content'); $form->addElement('button', 'cmdLogin', 'Submit'); // if we are replying to someone, let's get the content if (is_numeric($quote_id)) { // get replying post $posts = new YDCMForum_posts(); $post = $posts->getElement($quote_id); // apply default to content textarea $form->setDefault('content', $post['post_content']); } return $form; } } // last user login date. YDConfig::set('YD_FORUM_LASTLOGINDATE', YDStringUtil::formatDate(time(), 'datetimesql'), false); class YDCMForum_topics extends YDDatabaseObject { function YDCMForum_topics() { // init DB object $this->YDDatabaseObject(); // register database as default $this->registerDatabase(); // register table for this component $this->registerTable('YDCMForum_topics'); // register fields $this->registerKey('topic_id', true); $this->registerField('topic_forum_id'); $this->registerField('topic_title'); $this->registerField('topic_user_id');
You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ // Check if the framework is loaded if (!defined('YD_FW_NAME')) { die('Yellow Duck Framework is not loaded.'); } // Includes include_once YD_DIR_HOME_CLS . '/YDUtil.php'; // YDFSImage cropping specific constants define('YD_FS_CROP_UNCHANGED', 1); define('YD_FS_CROP_ENLARGED', 2); define('YD_FS_CROP_BORDERED', 3); // Config when cropping smaller images YDConfig::set('YD_FS_CROP', YD_FS_CROP_ENLARGED, false); // The mime types mapping $GLOBALS['YD_FS_MIME_MAPPING'] = array('ez' => 'application/andrew-inset', 'hqx' => 'application/mac-binhex40', 'cpt' => 'application/mac-compactpro', 'mathml' => 'application/mathml+xml', 'doc' => 'application/msword', 'oda' => 'application/oda', 'ogg' => 'application/ogg', 'pdf' => 'application/pdf', 'rdf' => 'application/rdf+xml', 'gram' => 'application/srgs', 'grxml' => 'application/srgs+xml', 'mif' => 'application/vnd.mif', 'xul' => 'application/vnd.mozilla.xul+xml', 'xls' => 'application/vnd.ms-excel', 'ppt' => 'application/vnd.ms-powerpoint', 'wbxml' => 'application/vnd.wap.wbxml', 'wmlc' => 'application/vnd.wap.wmlc', 'wmlsc' => 'application/vnd.wap.wmlscriptc', 'vxml' => 'application/voicexml+xml', 'bcpio' => 'application/x-bcpio', 'vcd' => 'application/x-cdlink', 'pgn' => 'application/x-chess-pgn', 'cpio' => 'application/x-cpio', 'csh' => 'application/x-csh', 'dvi' => 'application/x-dvi', 'spl' => 'application/x-futuresplash', 'gtar' => 'application/x-gtar', 'hdf' => 'application/x-hdf', 'js' => 'application/x-javascript', 'latex' => 'application/x-latex', 'sh' => 'application/x-sh', 'shar' => 'application/x-shar', 'swf' => 'application/x-shockwave-flash', 'sit' => 'application/x-stuffit', 'sv4cpio' => 'application/x-sv4cpio', 'sv4crc' => 'application/x-sv4crc', 'tar' => 'application/x-tar', 'tcl' => 'application/x-tcl', 'tex' => 'application/x-tex', 'man' => 'application/x-troff-man', 'me' => 'application/x-troff-me', 'ms' => 'application/x-troff-ms', 'ustar' => 'application/x-ustar', 'src' => 'application/x-wais-source', 'xslt' => 'application/xslt+xml', 'dtd' => 'application/xml-dtd', 'zip' => 'application/zip', 'm3u' => 'audio/x-mpegurl', 'rpm' => 'audio/x-pn-realaudio-plugin', 'ra' => 'audio/x-realaudio', 'wav' => 'audio/x-wav', 'pdb' => 'chemical/x-pdb', 'xyz' => 'chemical/x-xyz', 'bmp' => 'image/bmp', 'cgm' => 'image/cgm', 'gif' => 'image/gif', 'ief' => 'image/ief', 'png' => 'image/png', 'jpg' => 'image/jpeg', 'svg' => 'image/svg+xml', 'wbmp' => 'image/vnd.wap.wbmp', 'ras' => 'image/x-cmu-raster', 'ico' => 'image/x-icon', 'pnm' => 'image/x-portable-anymap', 'pbm' => 'image/x-portable-bitmap', 'pgm' => 'image/x-portable-graymap', 'ppm' => 'image/x-portable-pixmap', 'rgb' => 'image/x-rgb', 'xbm' => 'image/x-xbitmap', 'xpm' => 'image/x-xpixmap', 'xwd' => 'image/x-xwindowdump', 'css' => 'text/css', 'rtx' => 'text/richtext', 'rtf' => 'text/rtf', 'tsv' => 'text/tab-separated-values', 'wml' => 'text/vnd.wap.wml', 'wmls' => 'text/vnd.wap.wmlscript', 'etx' => 'text/x-setext', 'avi' => 'video/x-msvideo', 'movie' => 'video/x-sgi-movie', 'ice' => 'x-conference/x-cooltalk', 'php' => 'text/plain'); /** * This class houses all different path related functions. */ class YDPath extends YDBase { /** * Provides a platform-specific character used to separate directory levels in a path string that reflects a * hierarchical file system organization. * * @returns String containing the directory separator * * @static */
License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ // Check if the framework is loaded if (!defined('YD_FW_NAME')) { die('Yellow Duck Framework is not loaded.'); } // set components path YDConfig::set('YD_DBOBJECT_PATH', YD_DIR_HOME_ADD . '/YDCMComponent', false); // include YDF libs YDInclude('YDDatabaseObject.php'); YDInclude('YDResult.php'); // add translations directory for generic translations YDLocale::addDirectory(dirname(__FILE__) . '/languages/'); class YDCMPermission extends YDDatabaseObject { function YDCMPermission() { // init component as non default $this->YDDatabaseObject(); // register database as default $this->registerDatabase(); // register table for this component $this->registerTable('YDCMPermission');
<?php // Standard include include_once dirname(__FILE__) . '/../include/YDWeblog_init.php'; // We don't limit the execution time set_time_limit(0); // Includes YDInclude('YDRequest.php'); YDInclude('YDFileSystem.php'); YDInclude('YDUrl.php'); // Config setting YDConfig::set('updateDbUrl', 'http://ydframework.berlios.de/weblog_updater.php'); YDConfig::set('currentBranch', '/YDFramework2.0/trunk/'); YDConfig::set('chkoutUrl', 'http://svn.berlios.de/viewcvs/*checkout*/ydframework'); // Logger class class YDUpdateLog { // Flush a message to the browser function flushMsg($msg, $fatal) { echo $msg . '<br/>' . YD_CRLF; @ob_flush(); @flush(); if ($fatal) { die; } } // Log an info message function info($msg, $fatal = false) { YDUpdateLog::flushMsg('<font color="#009900">[ INFO ] ' . $msg . '</font>', $fatal);
// Check if the framework is loaded if (!defined('YD_FW_NAME')) { die('Yellow Duck Framework is not loaded.'); } // Includes include_once YD_DIR_HOME_CLS . '/YDForm.php'; /** * This config defines the start tag to show before render an element * Default: '<p>' */ YDConfig::set('YD_RENDER_HTML_PRETAG', "<p>", false); /** * This config defines the end tag to show after render an element * Default: '<p>' */ YDConfig::set('YD_RENDER_HTML_POSTAG', "</p>", false); /** * This is the class that is able to render a form object to HTML. * * @ingroup YDForm */ class YDFormRenderer_html extends YDFormRenderer { /** * This is the class constructor for the YDFormRenderer_html class. * * @param $form The form that needs to be rendered. */ function YDFormRenderer_html($form) { // Initialize the parent
die('Yellow Duck Framework is not loaded.'); } // Includes include_once YD_DIR_HOME_CLS . '/YDFileSystem.php'; // The different log levels @define('YD_LOG_DEBUG', 4); @define('YD_LOG_INFO', 3); @define('YD_LOG_WARNING', 2); @define('YD_LOG_ERROR', 1); // Configure the default for this class YDConfig::set('YD_LOG_LEVEL', YD_LOG_INFO, false); YDConfig::set('YD_LOG_FILE', YDPath::join(YD_DIR_TEMP, 'YDFramework2_log.xml'), false); YDConfig::set('YD_LOG_FORMAT', 'XML', false); YDConfig::set('YD_LOG_TEXTFORMAT', "%date% | %level% | %uri% | %basefile%:%line% | %function% | %message%", false); YDConfig::set('YD_LOG_WRAPLINES', false, false); YDConfig::set('YD_LOG_MAX_LINESIZE', 100, false); /** * This class defines the logging static functions. * * @ingroup YDFramework */ class YDLog extends YDBase { /** * This adds a debug message to the logfile. * * @param $text The message to add to the logfile. * * @static */ function debug($text)
*/ /** * @addtogroup YDFramework Core */ // Check if the framework is loaded if (!defined('YD_FW_NAME')) { die('Yellow Duck Framework is not loaded.'); } // Includes include_once YD_DIR_HOME_CLS . '/YDEncryption.php'; // Constants YDConfig::set('YD_PERSISTENT_STORE_NAME', strtoupper(str_replace(' ', '_', YD_FW_NAME)) . '_PERSISTENT_STORE', false); YDConfig::set('YD_PERSISTENT_DEFAULT_LIFETIME', 0, false); YDConfig::set('YD_PERSISTENT_DEFAULT_PASSWORD', null, false); YDConfig::set('YD_PERSISTENT_SCOPE', '/', false); YDConfig::set('YD_ALLOW_OVERRIDE_QS', false, false); /** * This class is able to save and load persistent data. This data stay active between different requests and allows * you to share data between different requests and different sessions. * * @todo * The default scope of the persistent variable should be the current script in stead of the root of the site. * The problem is that if you use the variable for e.g. storing sorting data, and use different ones over * different pages, they clash with each other. * * @ingroup YDFramework */ class YDPersistent extends YDBase { /** * This function initializes the persistent object store.
YDConfig::set('YD_DATABASEOBJECT_PATH', YD_SELF_DIR, false); /** * YDDatabaseObjects file extension. * Default: YD_SCR_EXT */ YDConfig::set('YD_DATABASEOBJECT_EXT', YD_SCR_EXT, false); /** * This constant defines if a DELETE query with no conditions can be executed. * Default: false. */ YDConfig::set('YD_DATABASEOBJECT_DELETE', false, false); /** * This constant defines if a UPDATE query with no conditions can be executed. * Default: false. */ YDConfig::set('YD_DATABASEOBJECT_UPDATE', false, false); YDInclude('YDDatabase.php'); YDInclude('YDSqlQuery.php'); /** * This class defines a YDDatabaseObject object. */ class YDDatabaseObject extends YDBase { var $__db = null; var $__table = null; var $__sql = null; var $__last = array(); var $__fields = array(); var $__keys = array(); var $__relations = array(); var $__protected = array();
<?php // initialize the Yellow Duck Framework include_once dirname(__FILE__) . '/../../YDFramework2/YDF2_init.php'; YDInclude('YDDatabase.php'); YDInclude('YDUrl.php'); // BASIC CONFIGURATION: set YDDatabase instance connection YDDatabase::registerInstance('default', 'mysql', 'xpto', 'root', '', 'localhost'); // BASIC CONFIGURATION: set portal language. Currently you can use 'en' and 'pt'. YDLocale::set('en'); // set admin template path YDConfig::set('YDCMTEMPLATES_ADMIN_PATH', dirname(__FILE__) . '/backend/templates'); YDConfig::set('YDCMTEMPLATES_ADMIN_URL', YDUrl::makeLinkAbsolute('./templates'));
<?php // Standard include include_once dirname(__FILE__) . '/../YDFramework2/YDF2_init.php'; // Configure the template class YDConfig::set('YD_TEMPLATE_ENGINE', 'php'); // Includes YDInclude('YDRequest.php'); YDInclude('YDUtil.php'); YDInclude('YDTemplate.php'); // Class definition class template_php extends YDRequest { // Class constructor function template_php() { // Initialize the parent $this->YDRequest(); // Create the template object $this->tpl = new YDTemplate(); // Assign some stuff $browser = new YDBrowserInfo(); $this->tpl->assign('browser', $browser); } // Default action - short open tags function actionDefault() { // Display the template $this->tpl->display('template_php.tpl'); } // Complete PHP tags
function actionSelectorImages() { // Set the action for the upload form $this->form->setDefault('action', $this->getActionName()); // Define the default pagesize YDConfig::set('YD_DB_DEFAULTPAGESIZE', 15); // Get the list of images $images = $this->getImages(); // Get the pagesize and current page from the URL $page = @$_GET['page']; // Create the YDRecordSet object $images = new YDRecordSet($images, $page, YDConfig::get('YD_DB_DEFAULTPAGESIZE', 20)); $images->set = YDArrayUtil::convertToTable($images->set, 5, true); // Assign it to the template $this->tpl->assign('uploads_dir', $this->dir_rel); $this->tpl->assign('images', $images); // Assign the quick upload form to the template $this->tpl->assignForm('form', $this->form); // Output the template $this->display('images_selector.tpl'); }
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Based on: PanaChart - PHP Chart Generator - October 2003 Yellow Duck Framework addon by Francisco Azevedo Copyright (C) 2003 Eugen Fernea - eugenf@panacode.com Panacode Software - info@panacode.com http://www.panacode.com/ */ // Check if the framework is loaded if (!defined('YD_FW_NAME')) { die('Yellow Duck Framework is not loaded.'); } // Define the default image type for the resulting graphs YDConfig::set('YD_GRAPH_TYPE', IMG_PNG, false); // Define the constants we are going to use define('HORIZONTAL', 0); define('VERTICAL', 1); // Define the different graph types define('SOLID', 0); define('DASHED', 1); define('DOTTED', 2); define('MEDIUM_SOLID', 3); define('MEDIUM_DASHED', 4); define('MEDIUM_DOTTED', 5); define('LARGE_SOLID', 6); define('LARGE_DASHED', 7); define('LARGE_DOTTED', 8); /** * This class implements an addon module that is able to draw graphs using the GD library.
/* Yellow Duck Framework version 2.1 (c) Copyright 2002-2007 Pieter Claerhout This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** * @addtogroup YDFramework Core */ // Check if the framework is loaded if (!defined('YD_FW_NAME')) { die('Yellow Duck Framework is not loaded.'); } // Auto execute config value. Default: true. YDConfig::set('YD_AUTO_EXECUTE', true, false); // Check if we need to auto execute if (YDConfig::get('YD_AUTO_EXECUTE', true) == true) { $clsInst = new YDExecutor(YD_SELF_FILE); @session_start(); $clsInst->execute(); }
<?php // Standard include include_once dirname(__FILE__) . '/../YDFramework2/YDF2_init.php'; // Includes YDInclude('YDLog.php'); YDInclude('YDRequest.php'); YDInclude('YDFileSystem.php'); // Include all log messages YDConfig::set('YD_LOG_LEVEL', 4); YDConfig::set('YD_LOG_WRAPLINES', true); // Plain function function PlainFunction() { YDLog::info('Message from PlainFunction'); } // Class definition class logging extends YDRequest { // Class constructor function logging() { $this->YDRequest(); } // Default action function actionDefault() { echo 'Log level: '; switch (YDConfig::get('YD_LOG_LEVEL')) { case YD_LOG_DEBUG: echo 'YD_LOG_DEBUG';
<?php // Standard include include_once dirname(__FILE__) . '/../YDFramework2/YDF2_init.php'; // Includes YDInclude('YDUrl.php'); YDInclude('YDRequest.php'); YDInclude('YDTemplate.php'); YDInclude('YDFeedCreator.php'); // Some defines we need to override YDConfig::set('YD_HTTP_CACHE_USEHEAD', 0); // Class definition class pbase extends YDRequest { // Class constructor function pbase() { // Initialize the parent $this->YDRequest(); // Initialize the template $this->template = new YDTemplate(); // Set the home url $this->homeUrl = 'http://www.pbase.com/beachshop/'; $this->template->assign('homeUrl', $this->homeUrl); // Title for the image gallery $this->template->assign('galTitle', 'Beachshop Pictures'); // Start with no galleries and no selected gallery $this->galleries = array(); $this->gallery = null; // Download the gallery index $pIndex = '/HREF="http:\\/\\/www.pbase.com\\/beachshop\\/(.*?)" class="thumbnail".*? src="http:\\/\\/.*?.image.pbase.com\\/.*?\\/.*?\\/small\\/([0-9]+).*?alt="(.*?)">/ism';
<?php // Standard include include_once dirname(__FILE__) . '/../YDFramework2/YDF2_init.php'; // Includes YDInclude('YDRequest.php'); YDInclude('YDDatabase.php'); YDInclude('YDTemplate.php'); // Define the default pagesize YDConfig::set('YD_DB_DEFAULTPAGESIZE', 15); // Class definition class database_paging extends YDRequest { // Class constructor function database_paging() { $this->YDRequest(); $this->template = new YDTemplate(); } // Default action function actionDefault() { // Get the pagesize and current page from the query string $page = @$_GET['page']; $size = @$_GET['size']; // Get the database connection $db = YDDatabase::getInstance('mysql', 'test', 'root', '', 'localhost'); // Get the records $recordset = $db->getRecordsAsSet('show status', $page, $size); // Alter the URL $url =& $recordset->getUrl();
YDConfig::set('YD_LOCALE', 'en', false); // Fix the PHP variables affected by magic_quotes_gpc (which is evil if you ask me ;-) if (!defined('YD_FIXED_MAGIC_QUOTES')) { if (get_magic_quotes_gpc() == 1) { $_GET = @YDRemoveMagicQuotes($_GET); $_POST = @YDRemoveMagicQuotes($_POST); $_COOKIE = @YDRemoveMagicQuotes($_COOKIE); $_REQUEST = @YDRemoveMagicQuotes($_REQUEST); } define('YD_FIXED_MAGIC_QUOTES', true); } // Check if we have the right PHP version if (version_compare(phpversion(), '4.2.0') == -1) { trigger_error('PHP version 4.2.0 or greater is required.', YD_ERROR); } // Set the debugging level switch (@$_GET['YD_DEBUG']) { case 2: YDConfig::set('YD_DEBUG', 2, false); break; case 1: YDConfig::set('YD_DEBUG', 1, false); break; default: YDConfig::set('YD_DEBUG', 0, false); break; } // Include the base classes include_once YD_DIR_HOME . '/YDClasses/YDUtil.php'; // Start the global timer $timer = new YDTimer();
if (!defined('YD_FW_NAME')) { die('Yellow Duck Framework is not loaded.'); } // Includes include_once YD_DIR_HOME_CLS . '/YDUtil.php'; // Constants define('YD_DB_FETCH_ASSOC', 1); define('YD_DB_FETCH_NUM', 2); define('YD_BROWSEBAR_FULL', 3); define('YD_BROWSEBAR_SHORT', 4); // Configure the default for this class YDConfig::set('YD_DB_FETCHTYPE', YD_DB_FETCH_ASSOC, false); YDConfig::set('YD_DB_DEFAULTPAGESIZE', 20, false); YDConfig::set('YD_DB_TABLEPREFIX', '', false); YDConfig::set('YD_DB_ALLOW_PERSISTENT_SORT', false, false); YDConfig::set('YD_DB_RS_CYCLENAVIGATION', false, false); /** * This class implements a (paged) recordset. It contains a lot of extra information about the recordset which is * not available if you return the database results as an array. This object is really handy if you want to work * with paged recordsets. * * Here's the extra information that is available: * * - page: current page number * - pagesize: total size of each page * - pagePrevious: the number of the previous page * - pageNext: the number of the next page * - offset: the first record we started reading from * - totalPages: the total number of pages * - totalRows: the total number of rows in the unpaged recordset * - totalRowsOnPages: the total number of rows on the current page
<?php // Include the Yellow Duck Framework include_once dirname(__FILE__) . '/../../../YDFramework2/YDF2_init.php'; // Include the classes you need on all pages YDInclude('YDRequest.php'); YDInclude('YDTemplate.php'); YDInclude('YDUtil.php'); YDInclude('YDFileSystem.php'); // Define the constants we want to override for the Framework YDConfig::set('YD_DEBUG', 1); // Here, we define our custom request class class MyAppRequest extends YDRequest { // Class constructor function MyAppRequest() { // Initialize the parent request $this->YDRequest(); // Make the template object available for all requests $this->tpl = new YDTemplate(); // Instantiate a timer as well $this->timer = new YDTimer(); } }
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ // Check if the framework is loaded if (!defined('YD_FW_NAME')) { die('Yellow Duck Framework is not loaded.'); } // Includes YDInclude('HttpClient.class.php'); // Configure the default for this class YDConfig::set('YD_HTTP_USES_GZIP', 1, false); YDConfig::set('YD_HTTP_CACHE_TIMEOUT', 3600, false); YDConfig::set('YD_HTTP_CACHE_USEHEAD', 1, false); /** * This is the YDHttpClient class. It extends the HttpClient class and adds support for specifying the content * type. * * @todo * Redirects to different sites are not supported, and make retrieving of images from pbase fail. This might * result in the fact that we need to move to a different HTTP library. Another option is to rewrite the ] * library completely. */ class YDHttpClient extends HttpClient { /** * This is the class constructor for the YDHttpClient class. * * @param $host The host name to connect to.
function actionExample($id = false) { YDConfig::set('YD_DEBUG', 0); // Get node ID if ($id == false) { $id = $_GET['id']; } // compute root link echo '<p><b>Path:</b> <a href="' . YD_SELF_SCRIPT . '?do=example&id=1">ROOT</a> » '; foreach ($this->tree->getPath($id) as $path_item) { echo '<a href="' . YD_SELF_SCRIPT . '?do=example&id=' . $path_item['id'] . '">' . $path_item['title'] . '</a> » '; } // compute node name $node = $this->tree->getNode($id); echo '<a href="' . YD_SELF_SCRIPT . '?do=example&id=' . $node['id'] . '">' . $node['title'] . '</a>'; echo '</p>'; // Show the children in a table echo '<table><tr><td><b>Children:</b></td><td>actions</td></tr>'; $children = $this->tree->getChildren($id); foreach ($children as $child) { echo '<tr><td>'; // show child action echo '<a href="' . YD_SELF_SCRIPT . '?do=example&id=' . $child['id'] . '">' . $child['title'] . '</a> '; echo '</td><td>'; // delete action element and nodes echo '<a href="' . YD_SELF_SCRIPT . '?do=delete&nodeandchildren=1&id=' . $child['id'] . '">Delete ' . $child['title'] . ' and subnodes</a> | '; // delete action nodes only echo '<a href="' . YD_SELF_SCRIPT . '?do=delete&id=' . $child['id'] . '">Delete nodes of ' . $child['title'] . ' </a> | '; // move up if ($child['position'] != 1) { echo '<a href="' . YD_SELF_SCRIPT . '?do=move&id=' . $child['id'] . '&position=' . ($child['position'] - 1) . '">Move up</a> | '; } // move down if ($child['position'] != count($children)) { echo '<a href="' . YD_SELF_SCRIPT . '?do=move&id=' . $child['id'] . '&position=' . ($child['position'] + 1) . '">Move down</a>'; } echo '</td></tr>'; } // add node action echo '<tr><td></td><td>'; echo '<a href="' . YD_SELF_SCRIPT . '?do=add&id=' . $node['id'] . '">Add new node to (' . $node['title'] . ') at bottom</a> | '; echo '<a href="' . YD_SELF_SCRIPT . '?do=add&position=1&id=' . $node['id'] . '">Add new node to (' . $node['title'] . ') at top</a>'; echo '</td></tr>'; echo '</table>'; }
/** * This function execute the SQL statement passed and adds it's * results to the object. * * @param $sql The SQL statement. * @param $slices (optional) The slices of the query. * * @returns The number of records found. */ function findSql($sql, $slices = array()) { YDDebugUtil::debug(YDStringUtil::removeWhiteSpace($sql)); $fetch = YDConfig::get('YD_DB_FETCHTYPE'); YDConfig::set('YD_DB_FETCHTYPE', YD_DB_FETCH_NUM); $results = $this->_db->getRecords($sql); YDConfig::set('YD_DB_FETCHTYPE', $fetch); if (!sizeof($slices)) { $slices = array(0 => ''); } reset($slices); $var = current($slices); while ($var !== false) { $curr_pos = key($slices); $next = next($slices); $next_pos = $next ? key($slices) : false; if (!$var) { $obj =& $this; } else { $obj =& $this->{$var}; } $obj->resetResults(); $obj->_count = $results ? sizeof($results) : 0; $select = $obj->_query->select; foreach ($results as $result) { if (!$next_pos) { $next_pos = sizeof($result); } $length = $next_pos - $curr_pos; $res = array_slice($result, $curr_pos, $length); $new_res = array(); for ($i = 0; $i < sizeof($res); $i++) { $new_res[$select[$i]['alias']] = $res[$i]; } $obj->_results[] = $new_res; } $obj->resetQuery(); if ($obj->_count >= 1) { $obj->setValues($obj->_results[0]); } $var = current($slices); } return $this->_count; }
<?php // Initialize the Yellow Duck Framework require_once dirname(__FILE__) . '/../../YDFramework2/YDF2_init.php'; YDConfig::set('YD_DATABASEOBJECT_PATH', YD_SELF_DIR . YD_DIRDELIM . 'includes'); YDInclude('User.php'); echo "<h1>Loading and finding all relations</h1>"; echo "<p>There is way of loading all relations and making a single query to all relations.</p>"; echo "<p>You can use the findAllRelations method or findRelation( 'relation', 'relation', ... ) to<br>"; echo "join only a few relations in a single query.</p>"; echo "<p>Let's do that with my user.</p>"; $user = new User(); $user->loadAllRelations(); $user->id = 1; $user->findAllRelations(); while ($user->fetchRelation()) { YDDebugUtil::dump($user->getRelationValues()); } echo "<p>With getRelationValues I've returned all values in a single array, but we still are<br>"; echo "able to access the individual relation objects.</p>"; echo "<p>Let's do that with Pieter's user.</p>"; $user->resetRelation(); $user->id = 2; $user->findAllRelations(); while ($user->fetchRelation()) { YDDebugUtil::dump($user->getRelationValues()); } echo "<p>That's it! Enjoy! =)</p>"; echo "<p><a href=\"index.php?YD_DEBUG=" . YDConfig::get('YD_DEBUG') . "\">Click here to return</a></p>"; echo "<p></p><p> </p>";