本文整理汇总了PHP中CRM_Core_ClassLoader::singleton方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_ClassLoader::singleton方法的具体用法?PHP CRM_Core_ClassLoader::singleton怎么用?PHP CRM_Core_ClassLoader::singleton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_ClassLoader
的用法示例。
在下文中一共展示了CRM_Core_ClassLoader::singleton方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: civicrm_setup
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
* $Id$
* @param $filesDirectory
*/
function civicrm_setup($filesDirectory)
{
global $crmPath, $sqlPath, $pkgPath, $tplPath;
global $compileDir;
// Setup classloader
// This is needed to allow CiviCRM to be installed by drush.
// TODO: move to civicrm.drush.inc drush_civicrm_install()
global $crmPath;
require_once $crmPath . '/CRM/Core/ClassLoader.php';
CRM_Core_ClassLoader::singleton()->register();
$sqlPath = $crmPath . DIRECTORY_SEPARATOR . 'sql';
$tplPath = $crmPath . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'CRM' . DIRECTORY_SEPARATOR . 'common' . DIRECTORY_SEPARATOR;
if (!is_dir($filesDirectory)) {
mkdir($filesDirectory, 0777);
chmod($filesDirectory, 0777);
}
$scratchDir = $filesDirectory . DIRECTORY_SEPARATOR . 'civicrm';
if (!is_dir($scratchDir)) {
mkdir($scratchDir, 0777);
}
$compileDir = $scratchDir . DIRECTORY_SEPARATOR . 'templates_c' . DIRECTORY_SEPARATOR;
if (!is_dir($compileDir)) {
mkdir($compileDir, 0777);
}
$compileDir = addslashes($compileDir);
}
示例2: civicrm_init
function civicrm_init()
{
require_once 'CRM/Core/ClassLoader.php';
CRM_Core_ClassLoader::singleton()->register();
require_once 'PEAR.php';
$config = CRM_Core_Config::singleton();
}
示例3: civicrm_init
function civicrm_init()
{
require_once 'CRM/Core/ClassLoader.php';
CRM_Core_ClassLoader::singleton()->register();
require_once 'PEAR.php';
$config = CRM_Core_Config::singleton();
// this is the front end, so let others know
$config->userFrameworkFrontend = 1;
}
示例4: __construct
/**
* Simple name based constructor
*/
function __construct($theClass = '', $name = '')
{
if (empty($name)) {
$name = str_replace('_', ' ', get_class($this));
// also split AllTests to All Tests
$name = str_replace('AllTests', 'All Tests', $name);
}
parent::__construct($name);
// also load the class loader
require_once 'CRM/Core/ClassLoader.php';
CRM_Core_ClassLoader::singleton()->register();
}
示例5: suite
/**
* @return \EnvTests
*/
public static function suite()
{
require_once 'CRM/Core/ClassLoader.php';
CRM_Core_ClassLoader::singleton()->register();
$suite = new EnvTests();
$tests = getenv('PHPUNIT_TESTS');
foreach (explode(' ', $tests) as $test) {
if (strpos($test, '::') !== FALSE) {
list($class, $method) = explode('::', $test);
$clazz = new \ReflectionClass($class);
$suite->addTestMethod($clazz, $clazz->getMethod($method));
} else {
$suite->addTestSuite($test);
}
}
return $suite;
}
示例6: getInput
protected function getInput()
{
$value = $this->value;
$name = $this->name;
// Initiate CiviCRM
define('CIVICRM_SETTINGS_PATH', JPATH_ROOT . '/' . 'administrator/components/com_civicrm/civicrm.settings.php');
require_once CIVICRM_SETTINGS_PATH;
require_once 'CRM/Core/ClassLoader.php';
CRM_Core_ClassLoader::singleton()->register();
require_once 'CRM/Core/Config.php';
$config = CRM_Core_Config::singleton();
$ufGroups = CRM_Core_PseudoConstant::ufGroup();
$options[] = JHTML::_('select.option', '', JText::_('- Select Profile -'));
foreach ($ufGroups as $key => $values) {
$options[] = JHTML::_('select.option', $key, $values);
}
return JHTML::_('select.genericlist', $options, $name, NULL, 'value', 'text', $value);
}
示例7: getInput
protected function getInput()
{
$value = $this->value;
$name = $this->name;
// Initiate CiviCRM
define('CIVICRM_SETTINGS_PATH', JPATH_ROOT . '/' . 'administrator/components/com_civicrm/civicrm.settings.php');
require_once CIVICRM_SETTINGS_PATH;
require_once 'CRM/Core/ClassLoader.php';
CRM_Core_ClassLoader::singleton()->register();
require_once 'CRM/Core/Config.php';
$config = CRM_Core_Config::singleton();
$query = "\nSELECT value, description\nFROM civicrm_option_value\nWHERE option_group_id =24\n";
$dao = CRM_Core_DAO::executeQuery($query);
while ($dao->fetch()) {
$options[] = JHTML::_('select.option', $dao->value, $dao->description);
}
return JHTML::_('select.genericlist', $options, $name, NULL, 'value', 'text', $dao->value);
}
示例8: __construct
/**
* Constructor.
*
* Because we are overriding the parent class constructor, we
* need to show the same arguments as exist in the constructor of
* PHPUnit_Framework_TestCase, since
* PHPUnit_Framework_TestSuite::createTest() creates a
* ReflectionClass of the Test class and checks the constructor
* of that class to decide how to set up the test.
*
* @param string $name
* @param array $data
* @param string $dataName
* @param array $browser
*/
public function __construct($name = NULL, array $data = array(), $dataName = '', array $browser = array())
{
parent::__construct($name, $data, $dataName, $browser);
$this->loggedInAs = NULL;
$this->settings = new CiviSeleniumSettings();
if (property_exists($this->settings, 'serverStartupTimeOut') && $this->settings->serverStartupTimeOut) {
global $CiviSeleniumTestCase_polled;
if (!$CiviSeleniumTestCase_polled) {
$CiviSeleniumTestCase_polled = TRUE;
CRM_Utils_Network::waitForServiceStartup($this->drivers[0]->getHost(), $this->drivers[0]->getPort(), $this->settings->serverStartupTimeOut);
}
}
// autoload
require_once 'CRM/Core/ClassLoader.php';
CRM_Core_ClassLoader::singleton()->register();
// also initialize a connection to the db
// FIXME: not necessary for most tests, consider moving into functions that need this
$config = CRM_Core_Config::singleton();
}
示例9: getInput
protected function getInput()
{
$value = $this->value;
$name = $this->name;
// Initiate CiviCRM
define('CIVICRM_SETTINGS_PATH', JPATH_ROOT . '/' . 'administrator/components/com_civicrm/civicrm.settings.php');
require_once CIVICRM_SETTINGS_PATH;
require_once 'CRM/Core/ClassLoader.php';
CRM_Core_ClassLoader::singleton()->register();
require_once 'CRM/Core/Config.php';
$config = CRM_Core_Config::singleton();
// Get list of all ContribPagesPCP and assign to options array
$options = array();
$query = "SELECT cp.id, cp.title \n\t\t FROM civicrm_contribution_page cp, civicrm_pcp_block pcp \n\t\t WHERE cp.is_active = 1 \n\t\t\t\t AND pcp.is_active = 1 \n\t\t\t\t\tAND pcp.entity_id = cp.id \n\t\t\t\t AND pcp.entity_table = 'civicrm_contribution_page'\n\t\t\t\t ORDER BY cp.title;";
$dao = CRM_Core_DAO::executeQuery($query);
while ($dao->fetch()) {
$options[] = JHTML::_('select.option', $dao->id, $dao->title);
}
return JHTML::_('select.genericlist', $options, $name, NULL, 'value', 'text', $value, $name);
}
示例10: getInput
protected function getInput()
{
$value = $this->value;
$name = $this->name;
// Initiate CiviCRM
define('CIVICRM_SETTINGS_PATH', JPATH_ROOT . '/' . 'administrator/components/com_civicrm/civicrm.settings.php');
require_once CIVICRM_SETTINGS_PATH;
require_once 'CRM/Core/ClassLoader.php';
CRM_Core_ClassLoader::singleton()->register();
require_once 'CRM/Core/Config.php';
$config = CRM_Core_Config::singleton();
$options = array();
$options[] = JHTML::_('select.option', '0', JText::_('- Select Contribution Page -'));
$query = 'SELECT id,title FROM civicrm_contribution_page WHERE is_active = 1 ORDER BY title';
$dao = CRM_Core_DAO::executeQuery($query);
while ($dao->fetch()) {
$options[] = JHTML::_('select.option', $dao->id, $dao->title);
}
return JHTML::_('select.genericlist', $options, $name, NULL, 'value', 'text', $value, $name);
}
示例11: getInput
protected function getInput()
{
$value = $this->value;
$name = $this->name;
// Initiate CiviCRM
define('CIVICRM_SETTINGS_PATH', JPATH_ROOT . '/' . 'administrator/components/com_civicrm/civicrm.settings.php');
require_once CIVICRM_SETTINGS_PATH;
require_once 'CRM/Core/ClassLoader.php';
CRM_Core_ClassLoader::singleton()->register();
require_once 'CRM/Core/Config.php';
$config = CRM_Core_Config::singleton();
$params = array('version' => '3', 'is_online_registration' => 1, 'is_active' => 1, 'isCurrent' => 1, 'return.title' => 1, 'return.id' => 1, 'return.end_date' => 1, 'return.start_date' => 1);
$events = civicrm_api('event', 'get', $params);
$currentdate = date("Y-m-d H:i:s");
$options = array();
$options[] = JHTML::_('select.option', '', JText::_('- Select Event -'));
foreach ($events['values'] as $event) {
if (strtotime($event['start_date']) >= strtotime($currentdate) || strtotime($event['end_date']) >= strtotime($currentdate)) {
$options[] = JHTML::_('select.option', $event['id'], $event['event_title']);
}
}
return JHTML::_('select.genericlist', $options, $name, NULL, 'value', 'text', $value);
}
示例12: initialize
/**
* @description: initialize CiviCRM
* @return bool $success
*/
public function initialize()
{
static $initialized = FALSE;
static $failure = FALSE;
if ($failure) {
return FALSE;
}
if (!$initialized) {
// Check for php version and ensure its greater than minPhpVersion
$minPhpVersion = '5.3.3';
if (version_compare(PHP_VERSION, $minPhpVersion) < 0) {
echo '<p>' . sprintf(__('CiviCRM requires PHP Version %s or greater. You are running PHP Version %s', 'civicrm-wordpress'), $minPhpVersion, PHP_VERSION) . '<p>';
exit;
}
// check for settings
if (!file_exists(CIVICRM_SETTINGS_PATH)) {
$error = FALSE;
} else {
$error = (include_once CIVICRM_SETTINGS_PATH);
}
// autoload
require_once 'CRM/Core/ClassLoader.php';
CRM_Core_ClassLoader::singleton()->register();
// get ready for problems
$installLink = admin_url() . "options-general.php?page=civicrm-install";
$docLinkInstall = "http://wiki.civicrm.org/confluence/display/CRMDOC/WordPress+Installation+Guide";
$docLinkTrouble = "http://wiki.civicrm.org/confluence/display/CRMDOC/Installation+and+Configuration+Trouble-shooting";
$forumLink = "http://forum.civicrm.org/index.php/board,6.0.html";
// construct message
$errorMsgAdd = sprintf(__('Please review the <a href="%s">WordPress Installation Guide</a> and the <a href="%s">Trouble-shooting page</a> for assistance. If you still need help installing, you can often find solutions to your issue by searching for the error message in the <a href="%s">installation support section of the community forum</a>.', 'civicrm-wordpress'), $docLinkInstall, $docLinkTrouble, $forumLink);
// does install message get used?
$installMessage = sprintf(__('Click <a href="%s">here</a> for fresh install.', 'civicrm-wordpress'), $installLink);
if ($error == FALSE) {
header('Location: ' . admin_url() . 'options-general.php?page=civicrm-install');
return FALSE;
}
// access global defined in civicrm.settings.php
global $civicrm_root;
// this does pretty much all of the civicrm initialization
if (!file_exists($civicrm_root . 'CRM/Core/Config.php')) {
$error = FALSE;
} else {
$error = (include_once 'CRM/Core/Config.php');
}
// have we got it?
if ($error == FALSE) {
// set static flag
$failure = TRUE;
// FIX ME - why?
wp_die("<strong><p class='error'>" . sprintf(__('Oops! - The path for including CiviCRM code files is not set properly. Most likely there is an error in the <em>civicrm_root</em> setting in your CiviCRM settings file (%s).', 'civicrm-wordpress'), CIVICRM_SETTINGS_PATH) . "</p><p class='error'> » " . sprintf(__('civicrm_root is currently set to: <em>%s</em>.', 'civicrm-wordpress'), $civicrm_root) . "</p><p class='error'>" . $errorMsgAdd . "</p></strong>");
// won't reach here!
return FALSE;
}
// set static flag
$initialized = TRUE;
// initialize the system by creating a config object
$config = CRM_Core_Config::singleton();
// sync the logged in user with WP
global $current_user;
if ($current_user) {
// sync procedure sets session values for logged in users
require_once 'CRM/Core/BAO/UFMatch.php';
CRM_Core_BAO_UFMatch::synchronize($current_user, FALSE, 'WordPress', $this->get_civicrm_contact_type('Individual'));
}
}
// notify plugins
do_action('civicrm_initialized');
// success!
return TRUE;
}
示例13: civicrm_main
function civicrm_main()
{
global $civicrmUpgrade, $adminPath;
civicrm_setup();
// setup vars
$configFile = $adminPath . DIRECTORY_SEPARATOR . 'civicrm.settings.php';
// generate backend config file
$string = "\n<?php\ndefine('CIVICRM_SETTINGS_PATH', '{$configFile}');\n\$error = @include_once( '{$configFile}' );\nif ( \$error == false ) {\n echo \"Could not load the settings file at: {$configFile}\n\";\n exit( );\n}\n\n// Load class loader\nrequire_once \$civicrm_root . '/CRM/Core/ClassLoader.php';\nCRM_Core_ClassLoader::singleton()->register();\n";
$string = trim($string);
civicrm_write_file($adminPath . DIRECTORY_SEPARATOR . 'civicrm' . DIRECTORY_SEPARATOR . 'civicrm.config.php', $string);
$liveSite = substr_replace(JURI::root(), '', -1, 1);
$siteKey = md5(uniqid('', true) . $liveSite);
// generate backend settings file
$string = civicrm_config(FALSE, $siteKey);
civicrm_write_file($configFile, $string);
// generate frontend settings file
$string = civicrm_config(TRUE, $siteKey);
civicrm_write_file(JPATH_SITE . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_civicrm' . DIRECTORY_SEPARATOR . 'civicrm.settings.php', $string);
define('CIVICRM_SETTINGS_PATH', $configFile);
include_once CIVICRM_SETTINGS_PATH;
// for install case only
if (!$civicrmUpgrade) {
$sqlPath = $adminPath . DIRECTORY_SEPARATOR . 'civicrm' . DIRECTORY_SEPARATOR . 'sql';
civicrm_source($sqlPath . DIRECTORY_SEPARATOR . 'civicrm.mysql');
civicrm_source($sqlPath . DIRECTORY_SEPARATOR . 'civicrm_data.mysql');
require_once 'CRM/Core/ClassLoader.php';
CRM_Core_ClassLoader::singleton()->register();
require_once 'CRM/Core/Config.php';
$config = CRM_Core_Config::singleton();
// now also build the menu
require_once 'CRM/Core/Menu.php';
CRM_Core_Menu::store();
}
}
示例14: _bootstrap
private function _bootstrap()
{
// so the configuration works with php-cli
$_SERVER['PHP_SELF'] = "/index.php";
$_SERVER['HTTP_HOST'] = $this->_site;
$_SERVER['REMOTE_ADDR'] = "127.0.0.1";
// SCRIPT_FILENAME needed by CRM_Utils_System::cmsRootPath
$_SERVER['SCRIPT_FILENAME'] = __FILE__;
// CRM-8917 - check if script name starts with /, if not - prepend it.
if (ord($_SERVER['SCRIPT_NAME']) != 47) {
$_SERVER['SCRIPT_NAME'] = '/' . $_SERVER['SCRIPT_NAME'];
}
$civicrm_root = dirname(__DIR__);
chdir($civicrm_root);
require_once 'civicrm.config.php';
// autoload
require_once $civicrm_root . '/CRM/Core/ClassLoader.php';
CRM_Core_ClassLoader::singleton()->register();
require_once 'CRM/Core/Config.php';
$this->_config = CRM_Core_Config::singleton();
require_once 'CRM/Utils/System.php';
$class = 'CRM_Utils_System_' . $this->_config->userFramework;
$cms = new $class();
if (!CRM_Utils_System::loadBootstrap(array(), FALSE, FALSE, $civicrm_root)) {
$this->_log(ts("Failed to bootstrap CMS"));
return FALSE;
}
if (strtolower($this->_entity) == 'job') {
if (!$this->_user) {
$this->_log(ts("Jobs called from cli.php require valid user as parameter"));
return FALSE;
}
}
if (!empty($this->_user)) {
if (!$cms->loadUser($this->_user)) {
$this->_log(ts("Failed to login as %1", array('1' => $this->_user)));
return FALSE;
}
}
return TRUE;
}
示例15: _bootstrap
/**
* @return bool
*/
private function _bootstrap()
{
// so the configuration works with php-cli
$_SERVER['PHP_SELF'] = "/index.php";
$_SERVER['HTTP_HOST'] = $this->_site;
$_SERVER['REMOTE_ADDR'] = "127.0.0.1";
$_SERVER['SERVER_SOFTWARE'] = NULL;
$_SERVER['REQUEST_METHOD'] = 'GET';
// SCRIPT_FILENAME needed by CRM_Utils_System::cmsRootPath
$_SERVER['SCRIPT_FILENAME'] = __FILE__;
// CRM-8917 - check if script name starts with /, if not - prepend it.
if (ord($_SERVER['SCRIPT_NAME']) != 47) {
$_SERVER['SCRIPT_NAME'] = '/' . $_SERVER['SCRIPT_NAME'];
}
$civicrm_root = dirname(__DIR__);
chdir($civicrm_root);
require_once 'civicrm.config.php';
// autoload
if (!class_exists('CRM_Core_ClassLoader')) {
require_once $civicrm_root . '/CRM/Core/ClassLoader.php';
}
CRM_Core_ClassLoader::singleton()->register();
$this->_config = CRM_Core_Config::singleton();
// HTTP_HOST will be 'localhost' unless overwritten with the -s argument.
// Now we have a Config object, we can set it from the Base URL.
if ($_SERVER['HTTP_HOST'] == 'localhost') {
$_SERVER['HTTP_HOST'] = preg_replace('!^https?://([^/]+)/$!i', '$1', $this->_config->userFrameworkBaseURL);
}
$class = 'CRM_Utils_System_' . $this->_config->userFramework;
$cms = new $class();
if (!CRM_Utils_System::loadBootstrap(array(), FALSE, FALSE, $civicrm_root)) {
$this->_log(ts("Failed to bootstrap CMS"));
return FALSE;
}
if (strtolower($this->_entity) == 'job') {
if (!$this->_user) {
$this->_log(ts("Jobs called from cli.php require valid user as parameter"));
return FALSE;
}
}
if (!empty($this->_user)) {
if (!CRM_Utils_System::authenticateScript(TRUE, $this->_user, $this->_password, TRUE, FALSE, FALSE)) {
$this->_log(ts("Failed to login as %1. Wrong username or password.", array('1' => $this->_user)));
return FALSE;
}
if (!$cms->loadUser($this->_user)) {
$this->_log(ts("Failed to login as %1", array('1' => $this->_user)));
return FALSE;
}
}
return TRUE;
}