本文整理汇总了PHP中constant函数的典型用法代码示例。如果您正苦于以下问题:PHP constant函数的具体用法?PHP constant怎么用?PHP constant使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了constant函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
/**
* Register the application services.
*
* @return void
*/
public function register()
{
$this->app->bind('laravel-monopond-fax', function () {
$environment = config('monopond.environment');
return new MonopondSOAPClientV2(config('monopond.username'), config('monopond.password'), constant("MPENV::{$environment}"));
});
}
示例2: testInvalidDates
/**
* Tests invalid data.
*/
public function testInvalidDates()
{
$composer = new Composer();
// Invalid date/time parts
$units = array('second' => array(-1, 61, '-1', '61'), 'minute' => array(-1, 61, '-1', '61'), 'hour' => array(-1, 24, '-1', '24'), 'day' => array(0, 32, '0', '32'), 'month' => array(0, 13, '0', '13'), 'year' => array(1901, 2038, '1901', '2038'));
foreach ($units as $unit => $tests) {
foreach ($tests as $test) {
try {
$composer->{'set' . ucfirst($unit)}($test);
} catch (\Exception $e) {
$this->assertInstanceOf('\\Jyxo\\Time\\ComposerException', $e);
$this->assertSame(constant('\\Jyxo\\Time\\ComposerException::' . strtoupper($unit)), $e->getCode(), sprintf('Failed test for unit %s and value %s.', $unit, $test));
}
}
}
// Incomplete date
try {
$date = $composer->getTime();
} catch (\Exception $e) {
$this->assertInstanceOf('\\Jyxo\\Time\\ComposerException', $e);
$this->assertSame(ComposerException::NOT_COMPLETE, $e->getCode());
}
// Invalid dates
$tests = array('2002-04-31', '2003-02-29', '2004-02-30', '2005-06-31', '2006-09-31', '2007-11-31');
foreach ($tests as $test) {
try {
list($year, $month, $day) = explode('-', $test);
$composer->setDay($day)->setMonth($month)->setYear($year);
$time = $composer->getTime();
} catch (\Exception $e) {
$this->assertInstanceOf('\\Jyxo\\Time\\ComposerException', $e);
$this->assertSame(ComposerException::INVALID, $e->getCode(), sprintf('Failed test for %s.', $test));
}
}
}
示例3: dispatch
function dispatch(Lisphp_Form $name)
{
if ($name instanceof Lisphp_Symbol) {
$phpname = $name = $name->symbol;
} else {
$phpname = $name[0]->symbol;
$name = $name[1]->symbol;
}
$phpname = str_replace('-', '_', $phpname);
try {
if (preg_match('|^(?:([^/]+/)+)?<(.+?)>$|', $phpname, $matches)) {
$phpname = str_replace('/', '_', $matches[1] . $matches[2]);
$class = new Lisphp_Runtime_PHPClass($phpname);
foreach ($class->getStaticMethods() as $methodName => $method) {
$objs["{$name}/{$methodName}"] = $method;
}
$objs[$name] = $class;
return $objs;
}
if (preg_match('|^(?:([^/]+/)+)?\\+(.+?)\\+$|', $phpname, $matches)) {
$phpname = str_replace('/', '_', $matches[1] . $matches[2]);
$objs[$name] = constant($phpname);
return $objs;
}
return array($name => new Lisphp_Runtime_PHPFunction($phpname));
} catch (UnexpectedValueException $e) {
throw new InvalidArgumentException($e);
}
}
示例4: sendMemberDaytimeToAdmin
function sendMemberDaytimeToAdmin($member_id, $service_id, $daytime_id)
{
define("BodyMemberDaytimeToAdmin", "<h1>Nouvelle inscription à une tranche horaire</h1><p>Un bénévole s'est inscrit à un secteur / tranche horaire.</p><p><strong>Nom :</strong> %s <br /><strong>Secteur :</strong> %s<br /><strong>Date :</strong> %s<br /><strong>Tranche horaire :</strong> %s</p><p><a href=\"" . JURI::root() . "/administrator/index.php?option=com_estivole&view=member&layout=edit&member_id=%s\">Cliquez ici</a> pour valider l'inscription et/ou recontacter le bénévole.</p>");
define("SubjectMemberDaytimeToAdmin", "Nouvelle inscription à une tranche horaire");
$db = JFactory::getDBO();
$query = $db->getQuery(TRUE);
$this->user = JFactory::getUser();
// Get the dispatcher and load the user's plugins.
$dispatcher = JEventDispatcher::getInstance();
JPluginHelper::importPlugin('user');
$data = new JObject();
$data->id = $this->user->id;
// Trigger the data preparation event.
$dispatcher->trigger('onContentPrepareData', array('com_users.profilestivole', &$data));
$userProfilEstivole = $data;
$userName = $userProfilEstivole->profilestivole['firstname'] . ' ' . $userProfilEstivole->profilestivole['lastname'];
$query->select('*');
$query->from('#__estivole_members as b, #__estivole_services as s, #__estivole_daytimes as d');
$query->where('b.member_id = ' . (int) $member_id);
$query->where('s.service_id = ' . (int) $service_id);
$query->where('d.daytime_id = ' . (int) $daytime_id);
$db->setQuery($query);
$mailModel = $db->loadObject();
$mail = JFactory::getMailer();
$mail->setBody(sprintf(constant("BodyMemberDaytimeToAdmin"), $userName, $mailModel->service_name, date('d-m-Y', strtotime($mailModel->daytime_day)), date('H:i', strtotime($mailModel->daytime_hour_start)) . ' - ' . date('H:i', strtotime($mailModel->daytime_hour_end)), $mailModel->member_id));
$mail->setSubject(constant("SubjectMemberDaytimeToAdmin"));
$mail->isHtml();
$recipient = array('benevoles@estivale.ch', $mailModel->email_responsable);
$mail->addRecipient($recipient);
$mail->Send('estivole@estivale.ch');
}
示例5: configsAction
public function configsAction()
{
// config classes
$check_classes = array('MysqlConfig', 'MongoConfig');
// check classes
foreach ($check_classes as $class) {
if (!class_exists($class)) {
die("Error : bad config class {$define}.\n");
}
echo "Check Config class : {$class}\n";
}
echo "Check all config classes ok.\n";
// config defines
$check_defines = array('__APP_NAME', '__COMM_LIB_DIR', '__HUSH_LIB_DIR', '__MAP_INI_FILE', '__MSG_INI_FILE', '__LIB_PATH_PAGE', '__TPL_SMARTY_PATH', '__FILECACHE_DIR');
// check frontend defines
$this->_loadConfig('fe');
foreach ($check_defines as $define) {
if (!defined($define) || !constant($define)) {
die("Error : bad define constant {$define}.\n");
}
echo "Check Frontend Define : {$define} > " . constant($define) . "\n";
}
echo "Check frontend defines ok.\n";
// check backend defines
$this->_loadConfig('be');
foreach ($check_defines as $define) {
if (!defined($define) || !constant($define)) {
die("Error : bad define constant {$define}.\n");
}
echo "Check Backend Define : {$define} > " . constant($define) . "\n";
}
echo "Check backend defines ok.\n";
}
示例6: parseTypeName
/**
* @see TypeDescription::parseTypeName()
*/
function parseTypeName($typeName)
{
// Configure the parent class type description
// with the expected meta-data class.
parent::parseTypeName('lib.pkp.classes.metadata.MetadataDescription');
// Split the type name into class name and assoc type.
$typeNameParts = explode('(', $typeName);
if (!count($typeNameParts) == 2) {
return false;
}
// The meta-data schema class must be
// a fully qualified class name.
$splitMetadataSchemaClass = $this->splitClassName($typeNameParts[0]);
if ($splitMetadataSchemaClass === false) {
return false;
}
list($this->_metadataSchemaPackageName, $this->_metadataSchemaClassName) = $splitMetadataSchemaClass;
// Identify the assoc type.
$assocTypeString = trim($typeNameParts[1], ')');
if ($assocTypeString == '*') {
$this->_assocType = ASSOC_TYPE_ANY;
} else {
// Make sure that the given assoc type exists.
$assocTypeString = 'ASSOC_TYPE_' . $assocTypeString;
if (!defined($assocTypeString)) {
return false;
}
$this->_assocType = constant($assocTypeString);
}
return true;
}
示例7: getChoices
/**
* Returns the choices associated to the model.
*
* @return array An array of choices
*/
public function getChoices()
{
$choices = array();
if (false !== $this->getOption('add_empty')) {
$choices[''] = true === $this->getOption('add_empty') ? '' : $this->translate($this->getOption('add_empty'));
}
$class = constant($this->getOption('model') . '::PEER');
$criteria = null === $this->getOption('criteria') ? new Criteria() : clone $this->getOption('criteria');
if ($order = $this->getOption('order_by')) {
$method = sprintf('add%sOrderByColumn', 0 === strpos(strtoupper($order[1]), 'ASC') ? 'Ascending' : 'Descending');
$criteria->{$method}(call_user_func(array($class, 'translateFieldName'), $order[0], BasePeer::TYPE_PHPNAME, BasePeer::TYPE_COLNAME));
}
$objects = call_user_func(array($class, $this->getOption('peer_method')), $criteria, $this->getOption('connection'));
$methodKey = $this->getOption('key_method');
if (!method_exists($this->getOption('model'), $methodKey)) {
throw new RuntimeException(sprintf('Class "%s" must implement a "%s" method to be rendered in a "%s" widget', $this->getOption('model'), $methodKey, __CLASS__));
}
$methodValue = $this->getOption('method');
if (!method_exists($this->getOption('model'), $methodValue)) {
throw new RuntimeException(sprintf('Class "%s" must implement a "%s" method to be rendered in a "%s" widget', $this->getOption('model'), $methodValue, __CLASS__));
}
foreach ($objects as $object) {
$choices[$object->{$methodKey}()] = $object->{$methodValue}();
}
return $choices;
}
示例8: setOptions
protected static function setOptions($ch, $method, &$url, &$data)
{
// Set default options
foreach (static::$options as $option => $value) {
curl_setopt($ch, constant(strtoupper($option)), $value);
}
$headers = array();
foreach (static::$headers as $key => $value) {
$headers[] = $key . ': ' . $value;
}
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
if (is_array($data)) {
$data = http_build_query($data);
}
switch (strtoupper($method)) {
case 'HEAD':
curl_setopt($ch, CURLOPT_NOBODY, true);
break;
case 'GET':
curl_setopt($ch, CURLOPT_HTTPGET, true);
$url .= '?' . $data;
$data = '';
break;
case 'POST':
curl_setopt($ch, CURLOPT_POST, true);
break;
default:
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
}
curl_setopt($ch, CURLOPT_URL, $url);
if (!empty($data)) {
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
}
示例9: prepareSidebar
protected function prepareSidebar()
{
if (!JCck::on()) {
return;
}
$buttons = array();
if (JCck::getUIX() == 'compact') {
$core = array(array('val' => '2', 'pre' => '', 'key' => 'COM_CCK_'));
} else {
$core = array(array('val' => '0', 'pre' => '', 'key' => 'COM_CCK_', 'img' => 'cck-application'), array('val' => '2', 'pre' => '- ', 'key' => 'COM_CCK_', 'img' => 'cck-form'), array('val' => '3', 'pre' => '- ', 'key' => '', 'img' => 'cck-plugin'), array('val' => '4', 'pre' => '- ', 'key' => 'COM_CCK_', 'img' => 'cck-search'), array('val' => '1', 'pre' => '- ', 'key' => '', 'img' => 'cck-template'), array('val' => '5', 'pre' => '', 'key' => '', 'img' => 'cck-multisite'));
}
$components = JCckDatabase::loadObjectList('SELECT a.title, a.link, b.element' . ' FROM #__menu AS a LEFT JOIN #__extensions AS b ON b.extension_id = a.component_id' . ' WHERE a.link LIKE "index.php?option=com_cck\\_%"' . ' AND a.link NOT IN ("index.php?option=com_cck_toolbox&view=processing","index.php?option=com_cck_webservices&view=api")' . ' ORDER BY a.title ASC');
$groupedButtons = array();
$more = array('ADDON' => 16, 'PLUGIN_FIELD' => 19, 'PLUGIN_LINK' => 20, 'PLUGIN_LIVE' => 21, 'PLUGIN_RESTRICTION' => 112, 'PLUGIN_TYPOGRAPHY' => 24, 'PLUGIN_VALIDATION' => 25, 'TEMPLATE' => 27);
foreach ($core as $k => $v) {
$buttons[] = array('access' => array('core.manage', 'com_cck'), 'group' => 'COM_CCK_CORE', 'image' => $v['img'], 'link' => JRoute::_(constant('_C' . $v['val'] . '_LINK')), 'target' => '_self', 'text' => $v['pre'] . JText::_($v['key'] . constant('_C' . $v['val'] . '_TEXT') . 'S'));
}
foreach ($components as $k => $v) {
$buttons[] = array('access' => array('core.manage', $v->element), 'group' => 'COM_CCK_SEBLOD_MORE', 'image' => 'cck-addon', 'link' => JRoute::_($v->link), 'target' => '_self', 'text' => $v->title);
}
foreach ($more as $k => $v) {
$buttons[] = array('access' => array('core.manage', 'com_cck'), 'group' => 'COM_CCK_SEBLOD_COM', 'image' => 'download', 'link' => JRoute::_('http://www.seblod.com/products?seb_item_category=' . $v), 'target' => '_blank', 'text' => JText::_('COM_CCK_PANE_MORE_' . $k));
}
foreach ($buttons as $button) {
$groupedButtons[$button['group']][] = $button;
}
$this->sidebar = '<div class="sidebar-nav quick-icons">' . JHtml::_('links.linksgroups', $groupedButtons) . '</div>';
}
示例10: BackendSearchLDAP
/**
* Initializes the backend to perform the search
* Connects to the LDAP server using the values from the configuration
*
*
* @access public
* @return
* @throws StatusException
*/
public function BackendSearchLDAP()
{
if (!function_exists("ldap_connect")) {
throw new StatusException("BackendSearchLDAP(): php-ldap is not installed. Search aborted.", SYNC_SEARCHSTATUS_STORE_SERVERERROR, null, LOGLEVEL_FATAL);
}
// connect to LDAP
$this->connection = @ldap_connect(LDAP_HOST, LDAP_PORT);
@ldap_set_option($this->connection, LDAP_OPT_PROTOCOL_VERSION, 3);
// Authenticate
if (constant('ANONYMOUS_BIND') === true) {
if (!@ldap_bind($this->connection)) {
$this->connection = false;
throw new StatusException("BackendSearchLDAP(): Could not bind anonymously to server! Search aborted.", SYNC_SEARCHSTATUS_STORE_CONNECTIONFAILED, null, LOGLEVEL_ERROR);
}
} else {
if (constant('LDAP_BIND_USER') != "") {
if (!@ldap_bind($this->connection, LDAP_BIND_USER, LDAP_BIND_PASSWORD)) {
$this->connection = false;
throw new StatusException(sprintf("BackendSearchLDAP(): Could not bind to server with user '%s' and specified password! Search aborted.", LDAP_BIND_USER), SYNC_SEARCHSTATUS_STORE_ACCESSDENIED, null, LOGLEVEL_ERROR);
}
} else {
// it would be possible to use the users login and password to authenticate on the LDAP server
// the main $backend has to keep these values so they could be used here
$this->connection = false;
throw new StatusException("BackendSearchLDAP(): neither anonymous nor default bind enabled. Other options not implemented.", SYNC_SEARCHSTATUS_STORE_CONNECTIONFAILED, null, LOGLEVEL_ERROR);
}
}
}
示例11: __construct
public function __construct()
{
$this->name = 'nqgatewayneteven';
$tab_name = 'Tools';
if (constant('_PS_VERSION_') >= 1.4) {
$tab_name = 'market_place';
}
$this->tab = $tab_name;
$this->version = '2.8';
$this->author = 'NetEven';
parent::__construct();
$this->displayName = $this->l('NetEven');
$this->description = $this->l('Vendez sur toutes les marketplaces depuis votre PrestaShop');
$this->ps_versions_compliancy = array('min' => '1.4', 'max' => _PS_VERSION_);
$this->feature_url = '/script/set-neteven-categories.php?token=' . Tools::encrypt(Configuration::get('PS_SHOP_NAME'));
$this->order_url = '/script/import-order.php?token=' . Tools::encrypt(Configuration::get('PS_SHOP_NAME')) . '&active=1';
$this->product_url = '/script/update-product.php?token=' . Tools::encrypt(Configuration::get('PS_SHOP_NAME')) . '&active=1';
if (!$this->getSOAP()) {
$this->warning = $this->l('SOAP should be installed for this module');
}
if (version_compare(_PS_VERSION_, '1.5', '<')) {
require _PS_MODULE_DIR_ . $this->name . '/backward_compatibility/backward.php';
}
if (Module::isInstalled($this->name)) {
$this->unInstallHookByVersion();
$this->installHookByVersion();
$this->installCarrier();
}
}
示例12: createThumbnail
public function createThumbnail()
{
$args = array_merge($this->defaults, func_get_args()[0]);
$args = ArrayHash::from($args);
$storage = $this->media->getStorage($args->storage);
if (isset($args->namespace)) {
$storage->setNamespace($args->namespace);
}
$image = $storage->load($args->file);
$width = $args->width;
$height = $args->height;
if ($image !== NULL) {
if ($width && $width != $image->width) {
$name = $this->createThumbnailName($image, $width, $height);
$thumb = $storage->absolutePath . '/' . $name;
$src = NULL;
if (!file_exists($thumb)) {
$image = Image::fromFile($image->absolutePath);
if (empty($height)) {
$height = $width;
}
$image->resize($width, $height, constant('Nette\\Image::' . strtoupper($args->flag)));
$image->save($thumb);
}
$image = $storage->load($name);
}
$src = $storage->getBaseUrl() . '/' . $image->filename;
return $src;
}
}
示例13: load_config
public function load_config()
{
if (defined('MPESA_ORDER_ID')) {
$this->data['ORDER_ID'] = constant('MPESA_ORDER_ID');
}
if (defined('MPESA_INVOCE')) {
$this->data['INVOCE'] = constant('MPESA_INVOCE');
}
if (defined('MPESA_TOTAL')) {
$this->data['TOTAL'] = constant('MPESA_TOTAL');
}
if (defined('MPESA_PHONE_1')) {
$this->data['PHONE_1'] = constant('MPESA_PHONE_1');
}
if (defined('MPESA_PHONE_2')) {
$this->data['PHONE_2'] = constant('MPESA_PHONE_2');
}
if (defined('MPESA_EMAIL')) {
$this->data['EMAIL'] = constant('MPESA_EMAIL');
}
if (defined('MPESA_VENDOR_REF')) {
$this->data['VENDOR_REF'] = constant('MPESA_VENDOR_REF');
}
if (defined('MPESA_MPESA')) {
$this->data['MPESA'] = constant('MPESA_MPESA');
}
}
示例14: woothemes_metabox_create
/**
* woothemes_metabox_create function.
*
* @access public
* @param object $post
* @param array $callback
* @return void
*/
function woothemes_metabox_create($post, $callback)
{
global $post;
// Allow child themes/plugins to act here.
do_action('woothemes_metabox_create', $post, $callback);
$seo_post_types = array('post', 'page');
if (defined('SEOPOSTTYPES')) {
$seo_post_types_update = unserialize(constant('SEOPOSTTYPES'));
}
if (!empty($seo_post_types_update)) {
$seo_post_types = $seo_post_types_update;
}
$template_to_show = $callback['args'];
$woo_metaboxes = get_option('woo_custom_template', array());
$seo_metaboxes = get_option('woo_custom_seo_template', array());
if (empty($seo_metaboxes) && $template_to_show == 'seo') {
return;
}
// Array sanity check.
if (!is_array($woo_metaboxes)) {
$woo_metaboxes = array();
}
// Determine whether or not to display general fields.
$display_general_fields = true;
if (count($woo_metaboxes) <= 0) {
$display_general_fields = false;
}
// Determine whether or not to display SEO fields.
$display_seo_fields = true;
if (get_option('seo_woo_hide_fields') == 'true' || get_option('seo_woo_use_third_party_data') == 'true') {
$display_seo_fields = false;
}
$output = '';
// Add nonce for custom fields.
$output .= wp_nonce_field('wooframework-custom-fields', 'wooframework-custom-fields-nonce', true, false);
if ($callback['id'] == 'woothemes-settings') {
// Add tabs.
$output .= '<div class="wooframework-tabs">' . "\n";
$output .= '<ul class="tabber hide-if-no-js">' . "\n";
if ($display_general_fields) {
$output .= '<li class="wf-tab-general"><a href="#wf-tab-general">' . __('General Settings', 'woothemes') . '</a></li>' . "\n";
}
if ($display_seo_fields) {
$output .= '<li class="wf-tab-seo"><a href="#wf-tab-seo">' . __('SEO', 'woothemes') . '</a></li>' . "\n";
}
// Allow themes/plugins to add tabs to WooFramework custom fields.
$output .= apply_filters('wooframework_custom_field_tab_headings', '');
$output .= '</ul>' . "\n";
}
if ($display_general_fields) {
$output .= woothemes_metabox_create_fields($woo_metaboxes, $callback, 'general');
}
if ($display_seo_fields && array_search(get_post_type(), $seo_post_types) !== false) {
$output .= woothemes_metabox_create_fields($seo_metaboxes, $callback, 'seo');
}
// Allow themes/plugins to add tabs to WooFramework custom fields.
$output = apply_filters('wooframework_custom_field_tab_content', $output);
$output .= '</div>' . "\n";
echo $output;
}
示例15: renderConfSettings
public function renderConfSettings()
{
$settings = ['JIG_COMPILE_CHECK' => Jig::COMPILE_CHECK_EXISTS, 'CACHING_SETTING' => Caching::CACHING_TIME, 'LIBRATO_STATSSOURCENAME' => null];
$output = "";
$output .= "<table class='table-serverSettings'>";
$output .= "<thead>";
$output .= "<th>Conf setting</th>";
$output .= "<th>Value</th>";
$output .= "</thead>";
$output .= "<body>";
foreach ($settings as $setting => $expectedValue) {
$value = Config::getEnv(constant("ImagickDemo\\Config::{$setting}"));
$class = 'good';
if ($expectedValue === null) {
//Do nothing.
} else {
if ($value != $expectedValue) {
$class = 'bad';
}
}
$value = var_export($value, true);
$output .= "<tr>";
$output .= sprintf("<td class='%s'>%s</td><td class='%s'>%s</td>", $class, htmlentities($setting, ENT_DISALLOWED | ENT_HTML401 | ENT_NOQUOTES, 'UTF-8'), $class, htmlentities($value, ENT_DISALLOWED | ENT_HTML401 | ENT_NOQUOTES, 'UTF-8'));
$output .= "</tr>";
}
$output .= "</tbody></table>";
return $output;
}