本文整理汇总了PHP中create_cache_directory函数的典型用法代码示例。如果您正苦于以下问题:PHP create_cache_directory函数的具体用法?PHP create_cache_directory怎么用?PHP create_cache_directory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_cache_directory函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildCache
/**
* Builds the cache of Dashlets by scanning the system
*/
function buildCache()
{
global $beanList;
$dashletFiles = array();
$dashletFilesCustom = array();
getFiles($dashletFiles, 'modules', '/^.*\\/Dashlets\\/[^\\.]*\\.php$/');
getFiles($dashletFilesCustom, 'custom/modules', '/^.*\\/Dashlets\\/[^\\.]*\\.php$/');
$cacheDir = create_cache_directory('dashlets/');
$allDashlets = array_merge($dashletFiles, $dashletFilesCustom);
$dashletFiles = array();
foreach ($allDashlets as $num => $file) {
if (substr_count($file, '.meta') == 0) {
// ignore meta data files
$class = substr($file, strrpos($file, '/') + 1, -4);
$dashletFiles[$class] = array();
$dashletFiles[$class]['file'] = $file;
$dashletFiles[$class]['class'] = $class;
if (is_file(preg_replace('/(.*\\/.*)(\\.php)/Uis', '$1.meta$2', $file))) {
// is there an associated meta data file?
$dashletFiles[$class]['meta'] = preg_replace('/(.*\\/.*)(\\.php)/Uis', '$1.meta$2', $file);
require $dashletFiles[$class]['meta'];
if (isset($dashletMeta[$class]['module'])) {
$dashletFiles[$class]['module'] = $dashletMeta[$class]['module'];
}
}
$filesInDirectory = array();
getFiles($filesInDirectory, substr($file, 0, strrpos($file, '/')), '/^.*\\/Dashlets\\/[^\\.]*\\.icon\\.(jpg|jpeg|gif|png)$/i');
if (!empty($filesInDirectory)) {
$dashletFiles[$class]['icon'] = $filesInDirectory[0];
// take the first icon we see
}
}
}
write_array_to_file('dashletsFiles', $dashletFiles, $cacheDir . 'dashlets.php');
}
示例2: buildActionCache
static function buildActionCache($silent = true)
{
if (!is_dir(ActionFactory::$action_directory)) {
return false;
}
// First get a list of all the files in this directory.
$entries = array();
$actions = array();
$javascript = "";
foreach (SugarAutoLoader::getFilesCustom(ActionFactory::$action_directory) as $path) {
$entry = basename($path);
if (strtolower(substr($entry, -4)) != ".php" || in_array($entry, ActionFactory::$exclude_files)) {
continue;
}
require_once $path;
$className = substr($entry, 0, strlen($entry) - 4);
$actionName = call_user_func(array($className, "getActionName"));
$actions[$actionName] = array('class' => $className, 'file' => $path);
$javascript .= call_user_func(array($className, "getJavascriptClass"));
if (!$silent) {
echo "added action {$actionName} <br/>";
}
}
if (empty($actions)) {
return "";
}
create_cache_directory("Expressions/actions_cache.php");
write_array_to_file('actions', $actions, sugar_cached('Expressions/actions_cache.php'));
ActionFactory::$loaded_actions = $actions;
return $javascript;
}
示例3: UploadFile
function UploadFile($field_name)
{
// $field_name is the name of your passed file selector field in your form
// i.e., for Emails, it is "email_attachmentX" where X is 0-9
$this->field_name = $field_name;
// Bug 28408 - Add automatic creation of upload cache directory if it doesn't exist
if (!is_dir($GLOBALS['sugar_config']['upload_dir'])) {
create_cache_directory(str_replace($GLOBALS['sugar_config']['cache_dir'], '', $GLOBALS['sugar_config']['upload_dir']));
}
}
示例4: _createFileName
/**
* Returns the filename for a temporary file
*
* @param string $type string to prepend to the filename, typically to indicate the file's use
* @return string filename
*/
private static function _createFileName($type = 'misc')
{
global $sugar_config, $current_user;
if (!is_dir($sugar_config['import_dir'])) {
create_cache_directory(preg_replace('/^cache\\//', '', $sugar_config['import_dir']));
}
if (!is_writable($sugar_config['import_dir'])) {
return false;
}
return "{$sugar_config['import_dir']}{$type}_{$current_user->id}.csv";
}
示例5: createModuleStringsCache
function createModuleStringsCache($moduleDir, $lang = 'en_us')
{
$json = getJSONobj();
// cn: bug 8242 - non-US langpack chokes
$mod_strings = return_module_language($lang, $moduleDir);
$mod_strings_encoded = $json->encode($mod_strings);
$str = "SUGAR.language.setLanguage('" . $moduleDir . "', " . $mod_strings_encoded . ");";
$cacheDir = create_cache_directory('jsLanguage/' . $moduleDir . '/');
if ($fh = @fopen($cacheDir . $lang . '.js', "w")) {
fputs($fh, $str);
fclose($fh);
}
}
示例6: action_getImageMap
protected function action_getImageMap()
{
ob_start();
global $current_user;
if (!isset($_REQUEST['imageMapId'])) {
return;
}
require_once 'modules/AOR_Charts/lib/pChart/pChart.php';
$img = new pImage(100, 100);
$imageMapDir = create_cache_directory('modules/AOR_Charts/ImageMap/' . $current_user->id . '/');
$id = $current_user->id . "-" . (int) $_REQUEST['imageMapId'];
ob_clean();
$img->dumpImageMap($id, IMAGE_MAP_STORAGE_FILE, $id, $imageMapDir);
}
示例7: testcreate_cache_directory
public function testcreate_cache_directory()
{
//execute the method and test if it created file/dir exists
$cache_dir = rtrim($GLOBALS['sugar_config']['cache_dir'], '/\\');
$file = 'Test/';
if ($this->rootFs->hasChild($file) == true) {
rmdir($cache_dir . '/' . $file);
}
$actual = create_cache_directory($file);
$this->assertFileExists($actual);
if ($this->rootFs->hasChild($file) == true) {
rmdir($cache_dir . '/' . $file);
}
}
示例8: __construct
function __construct()
{
global $sugar_config;
$config = HTMLPurifier_Config::createDefault();
if (!is_dir(sugar_cached("htmlclean"))) {
create_cache_directory("htmlclean/");
}
$config->set('HTML.Doctype', 'XHTML 1.0 Transitional');
$config->set('Core.Encoding', 'UTF-8');
$hidden_tags = array('script' => true, 'style' => true, 'title' => true, 'head' => true);
$config->set('Core.HiddenElements', $hidden_tags);
$config->set('Cache.SerializerPath', sugar_cached("htmlclean"));
$config->set('URI.Base', $sugar_config['site_url']);
$config->set('CSS.Proprietary', true);
$config->set('HTML.TidyLevel', 'light');
$config->set('HTML.ForbiddenElements', array('body' => true, 'html' => true));
$config->set('AutoFormat.RemoveEmpty', false);
$config->set('Cache.SerializerPermissions', 0775);
// for style
//$config->set('Filter.ExtractStyleBlocks', true);
$config->set('Filter.ExtractStyleBlocks.TidyImpl', false);
// can't use csstidy, GPL
if (!empty($GLOBALS['sugar_config']['html_allow_objects'])) {
// for object
$config->set('HTML.SafeObject', true);
// for embed
$config->set('HTML.SafeEmbed', true);
}
$config->set('Output.FlashCompat', true);
// for iframe and xmp
$config->set('Filter.Custom', array(new HTMLPurifier_Filter_Xmp()));
// for link
$config->set('HTML.DefinitionID', 'Sugar HTML Def');
$config->set('HTML.DefinitionRev', 2);
$config->set('Cache.SerializerPath', sugar_cached('htmlclean/'));
// IDs are namespaced
$config->set('Attr.EnableID', true);
$config->set('Attr.IDPrefix', 'sugar_text_');
if ($def = $config->maybeGetRawHTMLDefinition()) {
$form = $def->addElement('link', 'Flow', 'Empty', 'Core', array('href*' => 'URI', 'rel' => 'Enum#stylesheet', 'type' => 'Enum#text/css'));
$iframe = $def->addElement('iframe', 'Flow', 'Optional: #PCDATA | Flow | Block', 'Core', array('src*' => 'URI', 'frameborder' => 'Enum#0,1', 'marginwidth' => 'Pixels', 'marginheight' => 'Pixels', 'scrolling' => 'Enum#|yes,no,auto', 'align' => 'Enum#top,middle,bottom,left,right,center', 'height' => 'Length', 'width' => 'Length'));
$iframe->excludes = array('iframe');
}
$uri = $config->getDefinition('URI');
$uri->addFilter(new SugarURIFilter(), $config);
HTMLPurifier_URISchemeRegistry::instance()->register('cid', new HTMLPurifier_URIScheme_cid());
$this->purifier = new HTMLPurifier($config);
}
示例9: createModuleStringsCache
public function createModuleStringsCache($moduleDir, $lang = 'en_us', $return = false)
{
global $mod_strings;
$json = getJSONobj();
// cn: bug 8242 - non-US langpack chokes
// Allows for modification of mod_strings by individual modules prior to
// sending down to JS
if (empty($mod_strings)) {
$mod_strings = return_module_language($lang, $moduleDir);
}
$mod_strings_encoded = $json->encode($mod_strings);
$str = "SUGAR.language.setLanguage('" . $moduleDir . "', " . $mod_strings_encoded . ");";
$cacheDir = create_cache_directory('jsLanguage/' . $moduleDir . '/');
if ($fh = @fopen($cacheDir . $lang . '.js', "w")) {
fputs($fh, $str);
fclose($fh);
}
if ($return) {
return $str;
}
}
示例10: getJSURL
/**
* Returns the URL for an image in the current theme. If not found in the current theme, will revert
* to looking in the base theme.
*
* @param string $jsFileName js file name
* @param bool $returnURL if true, returns URL with unique image mark, otherwise returns path to the file
* @return string path to js file
*/
public function getJSURL($jsFileName, $returnURL = true)
{
if (isset($this->_jsCache[$jsFileName]) && sugar_is_file(sugar_cached($this->_jsCache[$jsFileName]))) {
if ($returnURL) {
return getJSPath("cache/" . $this->_jsCache[$jsFileName]);
} else {
return sugar_cached($this->_jsCache[$jsFileName]);
}
}
$jsFileContents = '';
$fullFileName = $this->getJSPath() . '/' . $jsFileName;
$defaultFileName = $this->getDefaultJSPath() . '/' . $jsFileName;
if (isset($this->parentTheme) && SugarThemeRegistry::get($this->parentTheme) instanceof SugarTheme && ($filename = SugarThemeRegistry::get($this->parentTheme)->getJSURL($jsFileName, false)) != '' && !in_array($jsFileName, $this->ignoreParentFiles)) {
$jsFileContents .= file_get_contents($filename);
} else {
if (sugar_is_file($defaultFileName)) {
$jsFileContents .= file_get_contents($defaultFileName);
}
if (sugar_is_file('custom/' . $defaultFileName)) {
$jsFileContents .= file_get_contents('custom/' . $defaultFileName);
}
}
if (sugar_is_file($fullFileName)) {
$jsFileContents .= file_get_contents($fullFileName);
}
if (sugar_is_file('custom/' . $fullFileName)) {
$jsFileContents .= file_get_contents('custom/' . $fullFileName);
}
if (empty($jsFileContents)) {
$GLOBALS['log']->warn("Javascript File {$jsFileName} not found");
return false;
}
// create the cached file location
$jsFilePath = create_cache_directory($fullFileName);
// minify the js
if (!inDeveloperMode() && !sugar_is_file(str_replace('.js', '-min.js', $jsFilePath))) {
$jsFileContents = SugarMin::minify($jsFileContents);
$jsFilePath = str_replace('.js', '-min.js', $jsFilePath);
$fullFileName = str_replace('.js', '-min.js', $fullFileName);
}
// now write the js to cache
sugar_file_put_contents($jsFilePath, $jsFileContents);
$this->_jsCache[$jsFileName] = $fullFileName;
if ($returnURL) {
return getJSPath("cache/" . $fullFileName);
}
return sugar_cached($fullFileName);
}
示例11: saveCache
function saveCache($module, $lang, $loaded_mod_strings, $additonal_objects = array())
{
if (empty($lang)) {
$lang = $GLOBALS['sugar_config']['default_language'];
}
$file = create_cache_directory('modules/' . $module . '/language/' . $lang . '.lang.php');
write_array_to_file('mod_strings', $loaded_mod_strings, $file);
include $file;
// put the item in the sugar cache.
$key = self::getLanguageCacheKey($module, $lang);
sugar_cache_put($key, $loaded_mod_strings);
}
示例12: listFontFiles
/**
* This method fill the fontList with all the fonts available
*/
public function listFontFiles()
{
$this->fontList = array();
if (file_exists($cachedfile = sugar_cached("Sugarpdf/cachedFontList.php"))) {
require $cachedfile;
$this->fontList = $cachedFontList;
return true;
} else {
if ($this->parseFolder()) {
$cacheDir = create_cache_directory('Sugarpdf/');
write_array_to_file('cachedFontList', $this->fontList, $cacheDir . 'cachedFontList.php');
return true;
}
}
return false;
}
示例13: getControl
/**
* Returns an input control for this fieldname given
*
* @param string $module
* @param string $fieldname
* @param string $vardef
* @param string $value
* @return string html for input element for this control
*/
function getControl($module, $fieldname, $vardef = null, $value = '')
{
global $current_language, $app_strings, $dictionary, $app_list_strings;
// use the mod_strings for this module
$mod_strings = return_module_language($current_language, $module);
// set the filename for this control
$file = create_cache_directory('modules/Import/') . $module . $fieldname . '.tpl';
if (!is_file($file) || !empty($GLOBALS['sugar_config']['developerMode']) || !empty($_SESSION['developerMode'])) {
if (!isset($vardef)) {
$focus = loadBean($module);
$vardef = $focus->getFieldDefinition($fieldname);
}
// if this is the id relation field, then don't have a pop-up selector.
if ($vardef['type'] == 'relate' && $vardef['id_name'] == $vardef['name']) {
$vardef['type'] = 'varchar';
}
// create the dropdowns for the parent type fields
if ($vardef['type'] == 'parent_type') {
$vardef['type'] = 'enum';
}
// remove the special text entry field function 'getEmailAddressWidget'
if (isset($vardef['function']) && ($vardef['function'] == 'getEmailAddressWidget' || $vardef['function']['name'] == 'getEmailAddressWidget')) {
unset($vardef['function']);
}
// load SugarFieldHandler to render the field tpl file
static $sfh;
if (!isset($sfh)) {
require_once 'include/SugarFields/SugarFieldHandler.php';
$sfh = new SugarFieldHandler();
}
$displayParams = array();
$displayParams['formName'] = 'importstep3';
$contents = $sfh->displaySmarty('fields', $vardef, 'ImportView', $displayParams);
// Remove all the copyright comments
$contents = preg_replace('/\\{\\*[^\\}]*?\\*\\}/', '', $contents);
// hack to disable one of the js calls in this control
if (isset($vardef['function']) && ($vardef['function'] == 'getCurrencyDropDown' || $vardef['function']['name'] == 'getCurrencyDropDown')) {
$contents .= "{literal}<script>function CurrencyConvertAll() { return; }</script>{/literal}";
}
// Save it to the cache file
if ($fh = @sugar_fopen($file, 'w')) {
fputs($fh, $contents);
fclose($fh);
}
}
// Now render the template we received
$ss = new Sugar_Smarty();
// Create Smarty variables for the Calendar picker widget
global $timedate;
$time_format = $timedate->get_user_time_format();
$date_format = $timedate->get_cal_date_format();
$ss->assign('USER_DATEFORMAT', $timedate->get_user_date_format());
$ss->assign('TIME_FORMAT', $time_format);
$time_separator = ":";
$match = array();
if (preg_match('/\\d+([^\\d])\\d+([^\\d]*)/s', $time_format, $match)) {
$time_separator = $match[1];
}
$t23 = strpos($time_format, '23') !== false ? '%H' : '%I';
if (!isset($match[2]) || $match[2] == '') {
$ss->assign('CALENDAR_FORMAT', $date_format . ' ' . $t23 . $time_separator . "%M");
} else {
$pm = $match[2] == "pm" ? "%P" : "%p";
$ss->assign('CALENDAR_FORMAT', $date_format . ' ' . $t23 . $time_separator . "%M" . $pm);
}
// populate the fieldlist from the vardefs
$fieldlist = array();
if (!isset($focus) || !$focus instanceof SugarBean) {
$focus = loadBean($module);
}
// create the dropdowns for the parent type fields
if ($vardef['type'] == 'parent_type') {
$focus->field_defs[$vardef['name']]['options'] = $focus->field_defs[$vardef['group']]['options'];
}
$vardefFields = $focus->getFieldDefinitions();
foreach ($vardefFields as $name => $properties) {
$fieldlist[$name] = $properties;
// fill in enums
if (isset($fieldlist[$name]['options']) && is_string($fieldlist[$name]['options']) && isset($app_list_strings[$fieldlist[$name]['options']])) {
$fieldlist[$name]['options'] = $app_list_strings[$fieldlist[$name]['options']];
} elseif (isset($fieldlist[$name]['options']) && is_string($fieldlist[$name]['options']) && isset($mod_strings[$fieldlist[$name]['options']])) {
$fieldlist[$name]['options'] = $mod_strings[$fieldlist[$name]['options']];
}
// Bug 22730: make sure all enums have the ability to select blank as the default value.
if (!isset($fieldlist[$name]['options'][''])) {
$fieldlist[$name]['options'][''] = '';
}
}
// fill in function return values
if (!in_array($fieldname, array('email1', 'email2'))) {
if (!empty($fieldlist[$fieldname]['function']['returns']) && $fieldlist[$fieldname]['function']['returns'] == 'html') {
//.........这里部分代码省略.........
示例14: saveCache
/**
* Save the dictionary object to the cache
* @param string $module the name of the module
* @param string $object the name of the object
*/
static function saveCache($module, $object, $additonal_objects = array())
{
if (empty($GLOBALS['dictionary'][$object])) {
$object = BeanFactory::getObjectName($module);
}
$file = create_cache_directory('modules/' . $module . '/' . $object . 'vardefs.php');
$out = "<?php \n \$GLOBALS[\"dictionary\"][\"" . $object . "\"]=" . var_export($GLOBALS['dictionary'][$object], true) . ";";
sugar_file_put_contents_atomic($file, $out);
if (sugar_is_file($file) && is_readable($file)) {
include $file;
}
// put the item in the sugar cache.
$key = "VardefManager.{$module}.{$object}";
//Sometimes bad definitions can get in from left over extensions or file system lag(caching). We need to clean those.
$data = self::cleanVardefs($GLOBALS['dictionary'][$object]);
sugar_cache_put($key, $data);
}
示例15: buildTemplate
/**
* Builds a template
* This is a private function that should be called only from checkTemplate method
*
* @param module string module name
* @param view string view need (eg DetailView, EditView, etc)
* @param tpl string generic tpl to use
* @param ajaxSave boolean parameter indicating whether or not this is coming from an Ajax call
* @param metaDataDefs metadata definition as Array
**/
function buildTemplate($module, $view, $tpl, $ajaxSave, $metaDataDefs)
{
$this->loadSmarty();
$cacheDir = create_cache_directory($this->templateDir . $module . '/');
$file = $cacheDir . $view . '.tpl';
$string = '{* Create Date: ' . date('Y-m-d H:i:s') . "*}\n";
$this->ss->left_delimiter = '{{';
$this->ss->right_delimiter = '}}';
$this->ss->assign('module', $module);
$this->ss->assign('built_in_buttons', array('CANCEL', 'DELETE', 'DUPLICATE', 'EDIT', 'FIND_DUPLICATES', 'SAVE', 'CONNECTOR'));
$contents = $this->ss->fetch($tpl);
//Insert validation and quicksearch stuff here
if ($view == 'EditView' || strpos($view, 'QuickCreate') || $ajaxSave || $view == "ConvertLead") {
global $dictionary, $beanList, $app_strings, $mod_strings;
$mod = $beanList[$module];
if ($mod == 'aCase') {
$mod = 'Case';
}
$defs = $dictionary[$mod]['fields'];
$defs2 = array();
//Retrieve all panel field definitions with displayParams Array field set
$panelFields = array();
foreach ($metaDataDefs['panels'] as $panel) {
foreach ($panel as $row) {
foreach ($row as $entry) {
if (empty($entry)) {
continue;
}
if (is_array($entry) && isset($entry['name']) && isset($entry['displayParams']) && isset($entry['displayParams']['required']) && $entry['displayParams']['required']) {
$panelFields[$entry['name']] = $entry;
}
if (is_array($entry)) {
$defs2[$entry['name']] = $entry;
} else {
$defs2[$entry] = array('name' => $entry);
}
}
//foreach
}
//foreach
}
//foreach
foreach ($panelFields as $field => $value) {
$nameList = array();
if (!is_array($value['displayParams']['required'])) {
$nameList[] = $field;
} else {
foreach ($value['displayParams']['required'] as $groupedField) {
$nameList[] = $groupedField;
}
}
foreach ($nameList as $x) {
if (isset($defs[$x]) && isset($defs[$x]['type']) && !isset($defs[$x]['required'])) {
$defs[$x]['required'] = true;
}
}
}
//foreach
//Create a base class with field_name_map property
$sugarbean = new stdClass();
$sugarbean->field_name_map = $defs;
$sugarbean->module_dir = $module;
$javascript = new javascript();
$view = $view == 'QuickCreate' ? "QuickCreate_{$module}" : $view;
$javascript->setFormName($view);
$javascript->setSugarBean($sugarbean);
if ($view != "ConvertLead") {
$javascript->addAllFields('', null, true);
}
$validatedFields = array();
$javascript->addToValidateBinaryDependency('assigned_user_name', 'alpha', $javascript->buildStringToTranslateInSmarty('ERR_SQS_NO_MATCH_FIELD') . ': ' . $javascript->buildStringToTranslateInSmarty('LBL_ASSIGNED_TO'), 'false', '', 'assigned_user_id');
$validatedFields[] = 'assigned_user_name';
//Add remaining validation dependency for related fields
//1) a relate type as defined in vardefs
//2) set in metadata layout
//3) not have validateDepedency set to false in metadata
//4) have id_name in vardef entry
//5) not already been added to Array
foreach ($sugarbean->field_name_map as $name => $def) {
if ($def['type'] == 'relate' && isset($defs2[$name]) && (!isset($defs2[$name]['validateDependency']) || $defs2[$name]['validateDependency'] === true) && isset($def['id_name']) && !in_array($name, $validatedFields)) {
if (isset($mod_strings[$def['vname']]) || isset($app_strings[$def['vname']]) || translate($def['vname'], $sugarbean->module_dir) != $def['vname']) {
$vname = $def['vname'];
} else {
$vname = "undefined";
}
$javascript->addToValidateBinaryDependency($name, 'alpha', $javascript->buildStringToTranslateInSmarty('ERR_SQS_NO_MATCH_FIELD') . ': ' . $javascript->buildStringToTranslateInSmarty($vname), !empty($def['required']) ? 'true' : 'false', '', $def['id_name']);
$validatedFields[] = $name;
}
}
//foreach
//.........这里部分代码省略.........