本文整理汇总了PHP中CRM_Utils_File类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_File类的具体用法?PHP CRM_Utils_File怎么用?PHP CRM_Utils_File使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Utils_File类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
/**
* @var \Civi\Angular\Manager $angular
*/
//Use our manager instead of the one provided by core
$angular = new Civi\Angular\VolunteerManager(\CRM_Core_Resources::singleton());
$moduleNames = $this->parseModuleNames(\CRM_Utils_Request::retrieve('modules', 'String'), $angular);
switch (\CRM_Utils_Request::retrieve('format', 'String')) {
case 'json':
case '':
$this->send('application/javascript', json_encode($this->getMetadata($moduleNames, $angular)));
break;
case 'js':
$digest = $this->digestJs($angular->getResources($moduleNames, 'js', 'path'));
//Tell crmResource to use our ajax end-point
$digest = str_replace("ajax/angular-modules", "ajax/volunteer-angular-modules", $digest);
$this->send('application/javascript', $digest);
break;
case 'css':
$this->send('text/css', \CRM_Utils_File::concat($angular->getResources($moduleNames, 'css', 'path'), "\n"));
break;
default:
\CRM_Core_Error::fatal("Unrecognized format");
}
\CRM_Utils_System::civiExit();
}
开发者ID:adam-edison,项目名称:org.civicrm.volunteer,代码行数:27,代码来源:Modules.php
示例2: offlinerecurringcontributions_civicrm_install
/**
* Implements hook_civicrm_install().
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_install
*/
function offlinerecurringcontributions_civicrm_install()
{
$extensionDir = dirname(__FILE__) . DIRECTORY_SEPARATOR;
$sqlName = $extensionDir . 'sql' . DIRECTORY_SEPARATOR . 'update.sql';
CRM_Utils_File::sourceSQLFile(CIVICRM_DSN, $sqlName);
_offlinerecurringcontributions_civix_civicrm_install();
}
开发者ID:veda-consulting,项目名称:caat-4.7-recurring,代码行数:12,代码来源:offlinerecurringcontributions.php
示例3: run
function run()
{
require_once 'CRM/Utils/Request.php';
require_once 'CRM/Core/DAO.php';
$eid = CRM_Utils_Request::retrieve('eid', 'Positive', $this, true);
$fid = CRM_Utils_Request::retrieve('fid', 'Positive', $this, false);
$id = CRM_Utils_Request::retrieve('id', 'Positive', $this, true);
$quest = CRM_Utils_Request::retrieve('quest', 'String', $this);
$action = CRM_Utils_Request::retrieve('action', 'String', $this);
require_once 'CRM/Core/BAO/File.php';
list($path, $mimeType) = CRM_Core_BAO_File::path($id, $eid, null, $quest);
if (!$path) {
CRM_Core_Error::statusBounce('Could not retrieve the file');
}
$buffer = file_get_contents($path);
if (!$buffer) {
CRM_Core_Error::statusBounce('The file is either empty or you do not have permission to retrieve the file');
}
if ($action & CRM_Core_Action::DELETE) {
if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', CRM_Core_DAO::$_nullObject)) {
CRM_Core_BAO_File::delete($id, $eid, $fid);
CRM_Core_Session::setStatus(ts('The attached file has been deleted.'));
$session = CRM_Core_Session::singleton();
$toUrl = $session->popUserContext();
CRM_Utils_System::redirect($toUrl);
} else {
$wrapper = new CRM_Utils_Wrapper();
return $wrapper->run('CRM_Custom_Form_DeleteFile', ts('Domain Information Page'), null);
}
} else {
require_once 'CRM/Utils/File.php';
CRM_Utils_System::download(CRM_Utils_File::cleanFileName(basename($path)), $mimeType, $buffer);
}
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:34,代码来源:File.php
示例4: run
public function run()
{
$eid = CRM_Utils_Request::retrieve('eid', 'Positive', $this, TRUE);
$fid = CRM_Utils_Request::retrieve('fid', 'Positive', $this, FALSE);
$id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
$quest = CRM_Utils_Request::retrieve('quest', 'String', $this);
$action = CRM_Utils_Request::retrieve('action', 'String', $this);
list($path, $mimeType) = CRM_Core_BAO_File::path($id, $eid, NULL, $quest);
if (!$path) {
CRM_Core_Error::statusBounce('Could not retrieve the file');
}
$buffer = file_get_contents($path);
if (!$buffer) {
CRM_Core_Error::statusBounce('The file is either empty or you do not have permission to retrieve the file');
}
if ($action & CRM_Core_Action::DELETE) {
if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', CRM_Core_DAO::$_nullObject)) {
CRM_Core_BAO_File::deleteFileReferences($id, $eid, $fid);
CRM_Core_Session::setStatus(ts('The attached file has been deleted.'), ts('Complete'), 'success');
$session = CRM_Core_Session::singleton();
$toUrl = $session->popUserContext();
CRM_Utils_System::redirect($toUrl);
}
} else {
CRM_Utils_System::download(CRM_Utils_File::cleanFileName(basename($path)), $mimeType, $buffer);
}
}
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:27,代码来源:File.php
示例5: loadSavedSearches
/**
* Load saved search sql files into the DB.
*/
public function loadSavedSearches()
{
$dsn = CRM_Core_Config::singleton()->dsn;
foreach (glob(dirname(__FILE__) . "/SavedSearchDataSets/*.sql") as $file) {
CRM_Utils_File::sourceSQLFile($dsn, $file);
}
}
开发者ID:nganivet,项目名称:civicrm-core,代码行数:10,代码来源:GroupTest.php
示例6: civicrm_api3_speakcivi_update_stats
function civicrm_api3_speakcivi_update_stats($params)
{
$config = CRM_Core_Config::singleton();
$sql = file_get_contents(dirname(__FILE__) . '/../../sql/update.sql', true);
CRM_Utils_File::sourceSQLFile($config->dsn, $sql, NULL, true);
return civicrm_api3_create_success(array("query" => $sql), $params);
}
开发者ID:WeMoveEU,项目名称:speakcivi,代码行数:7,代码来源:Speakcivi.php
示例7: upload
public static function upload($params)
{
if (!$_FILES) {
throw new CRM_Extension_Exception('Sorry, the file you uploaded was too large or invalid. Code 1', 500);
}
if (empty($_FILES['file']['size'])) {
throw new CRM_Extension_Exception('Sorry, the file you uploaded was too large or invalid. Code 2', 500);
}
$tempFile = $_FILES['file']['tmp_name'];
$originalFilename = CRM_Simplemail_BAO_SimpleMailHelper::cleanFilename($_FILES['file']['name']);
$fileName = CRM_Utils_File::makeFileName(CRM_Simplemail_BAO_SimpleMailHelper::cleanFilename($_FILES['file']['name']));
$dirName = CRM_Simplemail_BAO_SimpleMailHelper::getUploadDirPath(static::DIRECTORY);
// Create the upload directory, if it doesn't already exist
CRM_Utils_File::createDir($dirName);
$file = $dirName . $fileName;
// Move the uploaded file to the upload directory
if (move_uploaded_file($tempFile, $file)) {
$url = CRM_Simplemail_BAO_SimpleMailHelper::getUploadUrl($fileName, static::DIRECTORY);
$databaseId = static::saveToDatabase($params['simplemail_id'], $originalFilename, $url);
$result['values'] = array(array('url' => $url, 'filename' => $originalFilename, 'databaseId' => $databaseId));
return $result;
} else {
throw new CRM_Extension_Exception('Failed to move the uploaded file', 500);
}
}
开发者ID:jaapjansma,项目名称:uk.co.compucorp.civicrm.simplemail,代码行数:25,代码来源:SimpleMailInlineAttachment.php
示例8: run
/**
* Perform an upgrade without using the web-frontend
*
* @param bool $enablePrint
*
* @throws Exception
* @return array, with keys:
* - message: string, HTML-ish blob
*/
public function run($enablePrint = TRUE)
{
// lets get around the time limit issue if possible for upgrades
if (!ini_get('safe_mode')) {
set_time_limit(0);
}
$upgrade = new CRM_Upgrade_Form();
list($currentVer, $latestVer) = $upgrade->getUpgradeVersions();
if ($error = $upgrade->checkUpgradeableVersion($currentVer, $latestVer)) {
throw new Exception($error);
}
// Disable our SQL triggers
CRM_Core_DAO::dropTriggers();
// CRM-11156
$preUpgradeMessage = NULL;
$upgrade->setPreUpgradeMessage($preUpgradeMessage, $currentVer, $latestVer);
$postUpgradeMessageFile = CRM_Utils_File::tempnam('civicrm-post-upgrade');
$queueRunner = new CRM_Queue_Runner(array('title' => ts('CiviCRM Upgrade Tasks'), 'queue' => CRM_Upgrade_Form::buildQueue($currentVer, $latestVer, $postUpgradeMessageFile)));
$queueResult = $queueRunner->runAll();
if ($queueResult !== TRUE) {
$errorMessage = CRM_Core_Error::formatTextException($queueResult['exception']);
CRM_Core_Error::debug_log_message($errorMessage);
if ($enablePrint) {
print $errorMessage;
}
throw $queueResult['exception'];
// FIXME test
}
CRM_Upgrade_Form::doFinish();
$message = file_get_contents($postUpgradeMessageFile);
return array('latestVer' => $latestVer, 'message' => $message, 'text' => CRM_Utils_String::htmlToText($message));
}
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:41,代码来源:Headless.php
示例9: processUpload
/**
* handler for upload requests
*/
static function processUpload()
{
$config = self::getConfig();
global $http_return_code;
$files = array();
if ($_SERVER["REQUEST_METHOD"] == "GET") {
$dir = scandir($config['BASE_DIR']);
foreach ($dir as $file_name) {
//issue - https://github.com/veda-consulting/uk.co.vedaconsulting.mosaico/issues/28
//Change file name to unique by adding hash so every time uploading same image it will create new image name
$file_name = CRM_Utils_File::makeFileName($file_name);
$file_path = $config['BASE_DIR'] . $file_name;
if (is_file($file_path)) {
$size = filesize($file_path);
$file = ["name" => $file_name, "url" => $config['BASE_URL'] . $file_name, "size" => $size];
if (file_exists($config['BASE_DIR'] . $config[THUMBNAILS_DIR] . $file_name)) {
$file["thumbnailUrl"] = $config['BASE_URL'] . $config[THUMBNAILS_URL] . $file_name;
}
$files[] = $file;
}
}
} else {
if (!empty($_FILES)) {
foreach ($_FILES["files"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["files"]["tmp_name"][$key];
$file_name = $_FILES["files"]["name"][$key];
//issue - https://github.com/veda-consulting/uk.co.vedaconsulting.mosaico/issues/28
//Change file name to unique by adding hash so every time uploading same image it will create new image name
$file_name = CRM_Utils_File::makeFileName($file_name);
$file_path = $config['BASE_DIR'] . $file_name;
if (move_uploaded_file($tmp_name, $file_path) === TRUE) {
$size = filesize($file_path);
$image = new Imagick($file_path);
$image->resizeImage($config[THUMBNAIL_WIDTH], $config[THUMBNAIL_HEIGHT], Imagick::FILTER_LANCZOS, 1.0, TRUE);
// $image->writeImage( $config['BASE_DIR'] . $config[ THUMBNAILS_DIR ] . $file_name );
if ($f = fopen($config['BASE_DIR'] . $config[THUMBNAILS_DIR] . $file_name, "w")) {
$image->writeImageFile($f);
}
$image->destroy();
$file = array("name" => $file_name, "url" => $config['BASE_URL'] . $file_name, "size" => $size, "thumbnailUrl" => $config['BASE_URL'] . $config[THUMBNAILS_URL] . $file_name);
$files[] = $file;
} else {
$http_return_code = 500;
return;
}
} else {
$http_return_code = 400;
return;
}
}
}
}
header("Content-Type: application/json; charset=utf-8");
header("Connection: close");
echo json_encode(array("files" => $files));
CRM_Utils_System::civiExit();
}
开发者ID:Kajakaran,项目名称:uk.co.vedaconsulting.mosaico,代码行数:61,代码来源:Utils.php
示例10: eventcalendar_civicrm_uninstall
/**
* Implementation of hook_civicrm_uninstall
*/
function eventcalendar_civicrm_uninstall()
{
$cividiscountRoot = dirname(__FILE__) . DIRECTORY_SEPARATOR;
$cividiscountSQL = $cividiscountRoot . DIRECTORY_SEPARATOR . 'uninstall.sql';
CRM_Utils_File::sourceSQLFile(CIVICRM_DSN, $cividiscountSQL);
// rebuild the menu so our path is picked up
CRM_Core_Invoke::rebuildMenuAndCaches();
//return _eventcalendar_civix_civicrm_uninstall();
}
开发者ID:teamsinger,项目名称:com.osseed.eventcalendar,代码行数:12,代码来源:eventcalendar.php
示例11: __construct
/**
* @param string $repoUrl
* URL of the remote repository.
* @param string $indexPath
* Relative path of the 'index' file within the repository.
* @param string $cacheDir
* Local path in which to cache files.
*/
public function __construct($repoUrl, $indexPath, $cacheDir)
{
$this->repoUrl = $repoUrl;
$this->cacheDir = $cacheDir;
$this->indexPath = empty($indexPath) ? self::SINGLE_FILE_PATH : $indexPath;
if ($cacheDir && !file_exists($cacheDir) && is_dir(dirname($cacheDir)) && is_writable(dirname($cacheDir))) {
CRM_Utils_File::createDir($cacheDir, FALSE);
}
}
开发者ID:kidaa30,项目名称:yes,代码行数:17,代码来源:Browser.php
示例12: findManyFiles
/**
* Find files in several directories using several filename patterns
*
* @param array $pairs each item is an array(0 => $searchBaseDir, 1 => $filePattern)
* @return array of file paths
*/
static function findManyFiles($pairs)
{
$files = array();
foreach ($pairs as $pair) {
list($dir, $pattern) = $pair;
$files = array_merge($files, CRM_Utils_File::findFiles($dir, $pattern));
}
return $files;
}
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:15,代码来源:File.php
示例13: testReportOutput
/**
* @dataProvider dataProvider
*/
public function testReportOutput($reportClass, $inputParams, $dataSet, $expectedOutputCsvFile)
{
$config = CRM_Core_Config::singleton();
CRM_Utils_File::sourceSQLFile($config->dsn, dirname(__FILE__) . "/{$dataSet}");
$reportCsvFile = $this->getReportOutputAsCsv($reportClass, $inputParams);
$reportCsvArray = $this->getArrayFromCsv($reportCsvFile);
$expectedOutputCsvArray = $this->getArrayFromCsv(dirname(__FILE__) . "/{$expectedOutputCsvFile}");
$this->assertCsvArraysEqual($expectedOutputCsvArray, $reportCsvArray);
}
开发者ID:JoeMurray,项目名称:civihr,代码行数:12,代码来源:HRAbsenceTest.php
示例14: banking_civicrm_enable
/**
* Implementation of hook_civicrm_enable
*/
function banking_civicrm_enable()
{
//add the required option groups
banking_civicrm_install_options(_banking_options());
// run the update script
$config = CRM_Core_Config::singleton();
$sql = file_get_contents(dirname(__FILE__) . '/sql/upgrade.sql', true);
CRM_Utils_File::sourceSQLFile($config->dsn, $sql, NULL, true);
return _banking_civix_civicrm_enable();
}
开发者ID:VangelisP,项目名称:org.project60.banking,代码行数:13,代码来源:banking.php
示例15: postProcess
function postProcess()
{
$config = CRM_Core_Config::singleton();
$extenDr = $config->extensionsDir;
$sDbScriptsDir = $extenDr . DIRECTORY_SEPARATOR . 'uk.co.vedaconsulting.recurdatafix' . DIRECTORY_SEPARATOR . 'sql' . DIRECTORY_SEPARATOR;
CRM_Utils_File::sourceSQLFile(CIVICRM_DSN, sprintf("%supdate.sql", $sDbScriptsDir));
//CRM_Core_Session::setStatus('Updated table civicrm_recur table with membership id', 'Success', 'info');
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/recurdatafix/create', 'reset=1'));
CRM_Utils_System::civiExit();
}
开发者ID:Kajakaran,项目名称:uk.co.vedaconsulting.recurdatafix,代码行数:10,代码来源:Update.php
示例16: putFile
/**
* @param $out
*
* @return string
*/
function putFile($out)
{
$config = CRM_Core_Config::singleton();
$fileName = $config->uploadDir . 'Financial_Transactions_' . $this->_batchIds . '_' . date('YmdHis') . '.' . $this->getFileExtension();
$this->_downloadFile[] = $config->customFileUploadDir . CRM_Utils_File::cleanFileName(basename($fileName));
$buffer = fopen($fileName, 'w');
fwrite($buffer, $out);
fclose($buffer);
return $fileName;
}
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:15,代码来源:IIF.php
示例17: initialize
private function initialize()
{
$config = CRM_Core_Config::singleton();
if (isset($config->customTemplateDir) && $config->customTemplateDir) {
$this->template_dir = array_merge(array($config->customTemplateDir), $config->templateDir);
} else {
$this->template_dir = $config->templateDir;
}
$this->compile_dir = CRM_Utils_File::addTrailingSlash(CRM_Utils_File::addTrailingSlash($config->templateCompileDir) . $this->getLocale());
CRM_Utils_File::createDir($this->compile_dir);
CRM_Utils_File::restrictAccess($this->compile_dir);
// check and ensure it is writable
// else we sometime suppress errors quietly and this results
// in blank emails etc
if (!is_writable($this->compile_dir)) {
echo "CiviCRM does not have permission to write temp files in {$this->compile_dir}, Exiting";
exit;
}
//Check for safe mode CRM-2207
if (ini_get('safe_mode')) {
$this->use_sub_dirs = FALSE;
} else {
$this->use_sub_dirs = TRUE;
}
$customPluginsDir = NULL;
if (isset($config->customPHPPathDir)) {
$customPluginsDir = $config->customPHPPathDir . DIRECTORY_SEPARATOR . 'CRM' . DIRECTORY_SEPARATOR . 'Core' . DIRECTORY_SEPARATOR . 'Smarty' . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR;
if (!file_exists($customPluginsDir)) {
$customPluginsDir = NULL;
}
}
$smartyDir = dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'packages' . DIRECTORY_SEPARATOR . 'Smarty' . DIRECTORY_SEPARATOR;
$pluginsDir = __DIR__ . DIRECTORY_SEPARATOR . 'Smarty' . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR;
if ($customPluginsDir) {
$this->plugins_dir = array($customPluginsDir, $smartyDir . 'plugins', $pluginsDir);
} else {
$this->plugins_dir = array($smartyDir . 'plugins', $pluginsDir);
}
// add the session and the config here
$session = CRM_Core_Session::singleton();
$this->assign_by_ref('config', $config);
$this->assign_by_ref('session', $session);
global $tsLocale;
$this->assign('tsLocale', $tsLocale);
// CRM-7163 hack: we don’t display langSwitch on upgrades anyway
if (!CRM_Core_Config::isUpgradeMode()) {
$this->assign('langSwitch', CRM_Core_I18n::languages(TRUE));
}
$this->register_function('crmURL', array('CRM_Utils_System', 'crmURL'));
$this->load_filter('pre', 'resetExtScope');
$this->assign('crmPermissions', new CRM_Core_Smarty_Permissions());
}
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:52,代码来源:Smarty.php
示例18: _civicrm_load_navigation
/**
* Load the navigation sql for the domain with the given name.
*
* @param string $domainName
* @param int $domainID
*/
function _civicrm_load_navigation($domainName, $domainID)
{
global $civicrm_root;
$sqlPath = $civicrm_root . DIRECTORY_SEPARATOR . 'sql';
$config = CRM_Core_Config::singleton();
$generatedFile = $config->uploadDir . DIRECTORY_SEPARATOR . str_replace(' ', '_', $domainName) . uniqid() . 'nav.mysql';
//read the entire string
$str = file_get_contents($sqlPath . DIRECTORY_SEPARATOR . 'civicrm_navigation.mysql');
$str = str_replace('SELECT @domainID := id FROM civicrm_domain where name = \'Default Domain Name\'', "SELECT @domainID := {$domainID}", $str);
file_put_contents($generatedFile, $str);
CRM_Utils_File::sourceSQLFile($config->dsn, $generatedFile, NULL, FALSE);
CRM_Core_DAO::executeQuery("UPDATE civicrm_navigation SET label = name WHERE label = ''");
}
开发者ID:seamuslee001,项目名称:org.civicrm.multisite,代码行数:19,代码来源:Create.php
示例19: testIsChildPath
/**
* Test is child path.
*/
public function testIsChildPath()
{
$testCases = array();
$testCases[] = array('/ab/cd/ef', '/ab/cd', FALSE);
$testCases[] = array('/ab/cd', '/ab/cd/ef', TRUE);
$testCases[] = array('/ab/cde', '/ab/cd/ef', FALSE);
$testCases[] = array('/ab/cde', '/ab/cd', FALSE);
$testCases[] = array('/ab/cd', 'ab/cd/ef', FALSE);
foreach ($testCases as $testCase) {
$actual = CRM_Utils_File::isChildPath($testCase[0], $testCase[1], FALSE);
$this->assertEquals($testCase[2], $actual, sprintf("parent=[%s] child=[%s] expected=[%s] actual=[%s]", $testCase[0], $testCase[1], $testCase[2], $actual));
}
}
开发者ID:nielosz,项目名称:civicrm-core,代码行数:16,代码来源:FileTest.php
示例20: _run
/**
* Scan all api directories to discover entities
*
* @param \Civi\API\Result $result
*/
public function _run(Result $result)
{
$entities = array();
foreach (explode(PATH_SEPARATOR, get_include_path()) as $path) {
$dir = \CRM_Utils_File::addTrailingSlash($path) . 'Civi/Api4';
if (is_dir($dir)) {
foreach (glob("{$dir}/*.php") as $file) {
$matches = array();
preg_match('/(\\w*).php/', $file, $matches);
$entities[$matches[1]] = $matches[1];
}
}
}
$result->exchangeArray(array_values($entities));
}
开发者ID:civicrm,项目名称:api4,代码行数:20,代码来源:Get.php
注:本文中的CRM_Utils_File类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论