本文整理汇总了PHP中YDInclude函数的典型用法代码示例。如果您正苦于以下问题:PHP YDInclude函数的具体用法?PHP YDInclude怎么用?PHP YDInclude使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了YDInclude函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getObjectVisits
/**
* This function counts visits of a object
*
* @param $id Object id (content_id)
* @param $user_id (Optional) User id (0 means visitors)
* @param $period (Optional) Period for count. Valid values: 'week', 'month', year'
*
* @returns an array of labels => values
*/
function getObjectVisits($id, $user_id = 0, $period = 'week')
{
YDInclude('YDDate.php');
// compute start date
$date = new YDDate();
$labels = array();
if ($period == 'week') {
for ($i = 0; $i < 7; $i++) {
$labels[] = $date->getDayName();
$date->addDay(-1);
}
}
if ($period == 'month') {
for ($i = 0; $i < 4; $i++) {
$labels[] = $date->getMonthName();
$date->addMonth(-1);
}
}
if ($period == 'year') {
for ($i = 0; $i < 3; $i++) {
$labels[] = $date->getYear();
$date->addYear(-1);
}
}
$labels = array_reverse($labels);
$this->resetAll();
$this->user_id = intval($user_id);
}
示例2: getInstance
/**
* Using this static function, you can get an instance of a YDDatabaseDriver class.
*
* @param $driver Name of the database driver.
* @param $db Database name to use for the connection.
* @param $user (optional) User name to use for the connection.
* @param $pass (optional) Password to use for the connection.
* @param $host (optional) Host name to use for the connection.
*/
function getInstance($driver, $db, $user = '', $pass = '', $host = '')
{
// The list of known drivers
$regDrivers = array();
// Register the standard drives
$regDrivers[strtolower('mysql')] = array('class' => 'YDDatabaseDriver_mysql', 'file' => '');
$regDrivers[strtolower('oracle')] = array('class' => 'YDDatabaseDriver_oracle', 'file' => 'YDDatabaseDriver_oracle.php');
$regDrivers[strtolower('postgres')] = array('class' => 'YDDatabaseDriver_postgres', 'file' => 'YDDatabaseDriver_postgres.php');
$regDrivers[strtolower('sqlite')] = array('class' => 'YDDatabaseDriver_sqlite', 'file' => 'YDDatabaseDriver_sqlite.php');
// Check if the driver exists
if (!array_key_exists(strtolower($driver), $regDrivers)) {
trigger_error('Unsupported database type: "' . $driver . '".', YD_ERROR);
}
// Include the driver
if (!empty($regDrivers[strtolower($driver)]['file'])) {
YDInclude($regDrivers[strtolower($driver)]['file']);
}
// Check if the driver is supported
if (!call_user_func(array($regDrivers[strtolower($driver)]['class'], 'isSupported'))) {
trigger_error('Unsupported database type: "' . $driver . '". Extension is not loaded.', YD_ERROR);
}
// Make a new connection object and return it
$className = $regDrivers[strtolower($driver)]['class'];
return new $className($db, $user, $pass, $host);
}
示例3: YDGlobalTimerMarker
/**
* This function will add a marker to the global timer.
*
* @param $name The name of the marker.
*/
function YDGlobalTimerMarker($name)
{
if (!isset($GLOBALS['timer'])) {
YDInclude('YDUtil.php');
$GLOBALS['timer'] = new YDTimer();
}
$GLOBALS['timer']->addMarker($name);
}
示例4: getMailInfo
function getMailInfo()
{
// Includes
YDInclude('phpmailer/class.phpmailer.php');
$p = new PHPMailer();
$settings = array('system' => 'PHPMailer', 'version' => $p->Version);
ksort($settings);
return $settings;
}
示例5: actionRestore
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());
}
示例6: actionShowCaptcha
function actionShowCaptcha()
{
// include captcha lib
YDInclude('YDCaptcha.php');
// create captcha object
$captcha = new YDCaptcha();
// $captcha->useColour( true );
// $captcha->setNumChars( 3 );
// return image
return $captcha->Create();
}
示例7: getFormPage
/**
* This function returns the page form (form admin edition)
*
* @returns YDForm object
*/
function getFormPage()
{
YDInclude('YDForm.php');
// get template and language object
$templates = YDCMComponent::module('YDCMTemplates');
$languages = YDCMComponent::module('YDCMLanguages');
// create access options
$access = array(0 => t('public'), 1 => t('private'));
// create 'template pack' options
$template_pack = array(1 => t('use templatepack') . ' (' . $templates->template_pack() . ')', 0 => t('use custom template'));
// create form object
$form = new YDForm(YDConfig::get('YDCMPAGE_FORMPAGE'));
$form->addElement('text', 'reference', t('page_reference'), array('size' => 25, 'maxlength' => 35));
$form->addElement('text', 'title', t('page_title'), array('size' => 70, 'maxlength' => 70));
$form->addElement('textarea', 'html', t('page_html'));
$form->addElement('textarea', 'xhtml', t('page_xhtml'));
$form->addElement('select', 'access', t('page_access'), array(), $access);
$form->addElement('select', 'state', t('page_state'), array(), array(1 => t('yes'), 0 => t('no'), 2 => t('schedule')));
$form->addElement('datetimeselect', 'published_date_start', t('page_startdate'));
$form->addElement('datetimeselect', 'published_date_end', t('page_enddate'));
$form->addElement('select', 'template_pack', '', array(), $template_pack);
$form->addElement('select', 'template', t('page_template'), array(), $templates->visitors_templates());
$form->addElement('select', 'metatags', t('page_metatags'), array(), array(0 => t('no'), 1 => t('yes')));
$form->addElement('textarea', 'description', t('page_description'), array('cols' => 50, 'rows' => 5));
$form->addElement('textarea', 'keywords', t('page_keywords'), array('cols' => 50, 'rows' => 5));
$form->addElement('select', 'searcheable', t('page_search'), array(), array(0 => t('no'), 1 => t('yes')));
$form->addElement('hidden', 'content_id');
$form->addElement('hidden', 'parent_id');
$form->addElement('hidden', 'language_id');
// parent of new page is 0 by default
$form->setDefault('content_id', 0);
$form->setDefault('parent_id', 0);
$form->setDefault('language_id', $languages->adminDefault());
// add form rules
$form->addRule('reference', 'required', t('reference_required'));
$form->addRule('reference', 'alphanumeric', t('reference_alphanumeric'));
$form->addRule('reference', 'maxwords', t('reference_maxwords'), 1);
$form->addRule('reference', 'maxlength', t('reference_maxlength'), 100);
$form->addRule('title', 'required', t('title_required'));
$form->addRule('title', 'maxlength', t('title_maxlength'), 255);
$form->addRule('content_id', 'required', t('content_id_required'));
$form->addRule('content_id', 'numeric', t('content_id_numeric'));
$form->addRule('parent_id', 'required', t('parent_id_required'));
$form->addRule('parent_id', 'numeric', t('parent_id_numeric'));
$form->addRule('html', 'maxlength', t('html_maxlength'), 50000);
$form->addRule('xhtml', 'maxlength', t('xhtml_maxlength'), 50000);
$form->addRule('template_pack', 'in_array', t('template_pack_invalid'), array(0, 1));
$form->addRule('template', 'in_array', t('template_invalid'), array_keys($templates->visitors_templates()));
$form->addRule('metatags', 'in_array', t('metatags_invalid'), array(0, 1));
$form->addRule('description', 'maxlength', t('description_maxlength'), 2000);
$form->addRule('keywords', 'maxlength', t('keywords_maxlength'), 2000);
return $form;
}
示例8: getcontries
function getcontries()
{
// include Select lib
YDInclude('YDFormElement_Select.php');
// create new select element assigned to form 'myform'
$contries = new YDFormElement_Select($this->form->getName(), 'contries', '', '', array('Portugal', 'Brasil', 'Belgium'));
// assign form element code with span
$this->ajax->addResult('myspan', $contries->toHtml());
// disable previous event (myspan was assigned with a call to 'getcountries')
$this->ajax->addResult('myspan', 'return false;', 'onclick');
// return response to client browser
return $this->ajax->processResults();
}
示例9: result
function result($option)
{
// compute message
switch ($option) {
case 1:
$message = YD_FW_NAMEVERS;
break;
default:
YDInclude('YDUtil.php');
$message = YDStringUtil::formatDate(time(), '%d %B %Y %H:%M:%S');
}
// assign span 'myspanresult' of 'myform' with dynamic message
$this->ajax->addResult('myspanresult', $message);
// return response to client browser
return $this->ajax->processResults();
}
示例10: createGraph
function createGraph($name, $type)
{
YDInclude('YDGraph.php');
// generate chart
$values = array();
for ($i = 0; $i < 12; $i++) {
$values[] = rand(20, 60);
}
$labels = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
// Create a new graph
$g1 = new YDGraph(550, 250);
$g1->setLimits(0, 20);
$g1->setOffset(5);
$g1->setFormat(1, ',', '.');
$g1->addSeries($values, $type, 'Series1', SOLID, '#444444', '#4682B4');
$g1->setYAxis('#4682B4', SOLID, 5, 'example');
$g1->setLabels($labels, '#000000', 1, HORIZONTAL);
$g1->plot(dirname(__FILE__) . '/' . $name);
}
示例11: die
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');
// register fields
$this->registerField('permission_id');
$this->registerField('class');
示例12: or
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
*/
if (!defined('YD_FW_NAME')) {
die('Yellow Duck Framework is not loaded.');
}
YDInclude('YDDatabase.php');
/**
* This class defines a database driver for Oracle8i using the OCI8 interface.
*/
class YDDatabaseDriver_oracle extends YDDatabaseDriver
{
/**
* This is the class constructor for the YDDatabaseDriver_oracle class.
*
* @param $db Name of the database.
* @param $user (optional) User name to use for the connection.
* @param $pass (optional) Password to use for the connection.
* @param $host (optional) Host name to use for the connection.
* @param $host (optional) Host name to use for the connection.
* @param $options (optional) Options to pass to the driver.
*/
示例13: requestNotXmlRpc
/**
* This function will be executed if there is no post data found. This is happening when there is no XML/RPC
* request found.
*/
function requestNotXmlRpc()
{
// Get the list of methods
$methods = array();
$methodNames = $this->_server->listMethods(null);
// Loop over the methods
foreach ($methodNames as $method) {
if (isset($this->_server->signatures[$method])) {
if (sizeof($this->_server->signatures[$method]) == 1) {
$paramsIn = null;
$paramsOut = $this->_server->signatures[$method];
} else {
$paramsIn = $this->_server->signatures[$method];
$paramsOut = array_shift($paramsIn);
}
} else {
$paramsIn = null;
$paramsOut = null;
}
$methodInfo = array();
$methodInfo['signature'] = @$this->_server->signatures[$method];
$methodInfo['paramsIn'] = $paramsIn;
$methodInfo['paramsOut'] = $paramsOut;
$methodInfo['help'] = @$this->_server->help[$method];
$methods[$method] = $methodInfo;
}
// Create a new template
YDInclude('YDTemplate.php');
$template = new YDTemplate();
$template->template_dir = dirname(__FILE__);
$template->assign('methods', $methods);
$template->assign('xmlRpcUrl', $this->getCurrentUrl());
$template->assign('capabilities', $this->_server->getCapabilities(null));
$template->assign('rowcolor', '#EEEEEE');
$template->display('YDXmlRpcServer.tpl');
}
示例14: or
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.');
}
// Includes
YDInclude('YDForm.php');
/**
* This is the class that define a password form element.
*/
class YDFormElement_Password extends YDFormElement
{
/**
* This is the class constructor for the YDFormElement_Password class.
*
* @param $form The name of the form to which this element is connected.
* @param $name The name of the form element.
* @param $label (optional) The label for the form element.
* @param $attributes (optional) The attributes for the form element.
* @param $options (optional) The options for the elment.
*/
function YDFormElement_Password($form, $name, $label = '', $attributes = array(), $options = array())
示例15: valid
/**
* This function returns true if the variable is an array and each element is in opts.
*
* @param $val The value to test.
* @param $opts The array in which the value should be.
* @param $formelement (not required)
*/
function valid($val, $opts = '', $formelement = null)
{
$opts = $formelement->getOptions();
switch ($formelement->getType()) {
case 'checkboxgroup':
foreach ($val as $value => $enable) {
if (!in_array($value, $opts) || $enable != 'on') {
return false;
}
}
return true;
case 'select':
return in_array($val, $opts);
case 'country':
YDInclude('YDList.php');
return in_array($val, YDList::countries('keys'));
case 'timezone':
YDInclude('YDList.php');
return in_array($val, YDList::gmts('keys'));
default:
die('YDValidateRule "valid" is not supported in element type ' . $formelement->getType());
}
}