本文整理汇总了PHP中sugar_cached函数的典型用法代码示例。如果您正苦于以下问题:PHP sugar_cached函数的具体用法?PHP sugar_cached怎么用?PHP sugar_cached使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sugar_cached函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: setUp
public function setUp()
{
//Just need base class but its abstract so we use the google implementation for this test.
$this->extAPI = new ExtAPIGoogle();
$this->fileData1 = sugar_cached('unittest');
file_put_contents($this->fileData1, "Unit test for mime type");
}
示例3: tearDown
public function tearDown()
{
$GLOBALS['db']->query("DELETE FROM contacts WHERE id= '{$this->_contact->id}'");
unset($this->_contact);
if ($this->_hasUnifiedSearchModulesConfig) {
copy(sugar_cached('modules/unified_search_modules.php.bak'), sugar_cached('modules/unified_search_modules.php'));
unlink(sugar_cached('modules/unified_search_modules.php.bak'));
} else {
unlink(sugar_cached('modules/unified_search_modules.php'));
}
if ($this->_hasUnifiedSearchModulesDisplay) {
copy('custom/modules/unified_search_modules_display.php.bak', 'custom/modules/unified_search_modules_display.php');
unlink('custom/modules/unified_search_modules_display.php.bak');
} else {
unlink('custom/modules/unified_search_modules_display.php');
}
SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
if (isset($_REQUEST['module'])) {
unset($_REQUEST['module']);
}
if (isset($_REQUEST['query_string'])) {
unset($_REQUEST['query_string']);
}
if (isset($_REQUEST['enabled_modules'])) {
unset($_REQUEST['enabled_modules']);
}
}
示例4: run
public function run()
{
if (is_file(sugar_cached('dashlets/dashlets.php'))) {
unlink(sugar_cached('dashlets/dashlets.php'));
}
require_once 'include/Dashlets/DashletCacheBuilder.php';
$dc = new DashletCacheBuilder();
$dc->buildCache();
}
示例5: setUp
public function setUp()
{
$this->testdir = sugar_cached("tests/include/utils/ziptest");
sugar_mkdir($this->testdir . '/testarchive', null, true);
sugar_touch($this->testdir . '/testarchive/testfile1.txt');
sugar_touch($this->testdir . '/testarchive/testfile2.txt');
sugar_touch($this->testdir . '/testarchive/testfile3.txt');
sugar_mkdir($this->testdir . '/testarchiveoutput', null, true);
}
示例6: extractFile
function extractFile($zip_file, $file_in_zip)
{
global $base_tmp_upgrade_dir;
if (empty($base_tmp_upgrade_dir)) {
$base_tmp_upgrade_dir = sugar_cached("upgrades/temp");
}
$my_zip_dir = mk_temp_dir($base_tmp_upgrade_dir);
unzip_file($zip_file, $file_in_zip, $my_zip_dir);
return "{$my_zip_dir}/{$file_in_zip}";
}
示例7: extractFile
public static function extractFile($zip_file, $file_in_zip)
{
global $base_tmp_upgrade_dir;
if (empty($base_tmp_upgrade_dir)) {
$base_tmp_upgrade_dir = sugar_cached("upgrades/temp");
}
$my_zip_dir = mk_temp_dir($base_tmp_upgrade_dir);
register_shutdown_function('rmdir_recursive', $my_zip_dir);
unzip_file($zip_file, $file_in_zip, $my_zip_dir);
return "{$my_zip_dir}/{$file_in_zip}";
}
示例8: setUp
public function setUp()
{
if (!class_exists('ZipArchive')) {
$this->markTestSkipped('ZipArchive class not loaded');
}
$this->testdir = sugar_cached("tests/include/utils/ziptest");
sugar_mkdir($this->testdir . '/testarchive', null, true);
sugar_touch($this->testdir . '/testarchive/testfile1.txt');
sugar_touch($this->testdir . '/testarchive/testfile2.txt');
sugar_touch($this->testdir . '/testarchive/testfile3.txt');
sugar_mkdir($this->testdir . '/testarchiveoutput', null, true);
}
示例9: create_cache_directory
function create_cache_directory($file)
{
$paths = explode('/', $file);
$dir = rtrim(sugar_cached(""), '/');
if (!file_exists($dir)) {
sugar_mkdir($dir, 0775);
}
for ($i = 0; $i < sizeof($paths) - 1; $i++) {
$dir .= '/' . $paths[$i];
if (!file_exists($dir)) {
sugar_mkdir($dir, 0775);
}
}
return $dir . '/' . $paths[sizeof($paths) - 1];
}
示例10: __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);
}
示例11: display
function display()
{
global $app_strings, $current_user, $mod_strings, $theme, $beanList, $beanFiles;
if (!is_file($cachefile = sugar_cached('Expressions/functionmap.php'))) {
$GLOBALS['updateSilent'] = true;
include 'include/Expressions/updatecache.php';
}
include $cachefile;
require_once 'include/JSON.php';
$desc = "";
if (!empty($_REQUEST['function']) && !empty($FUNCTION_MAP[$_REQUEST['function']])) {
$func_def = $FUNCTION_MAP[$_REQUEST['function']];
require_once $func_def['src'];
$class = new ReflectionClass($func_def['class']);
$doc = $class->getDocComment();
if (!empty($doc)) {
//Remove the javadoc style comment *'s
$desc = preg_replace("/((\\/\\*+)|(\\*+\\/)|(\n\\s*\\*)[^\\/])/", "", $doc);
} else {
if (isset($mod_strings['func_descriptions'][$_REQUEST['function']])) {
$desc = $mod_strings['func_descriptions'][$_REQUEST['function']];
} else {
$seed = $func_def['class'];
$count = call_user_func(array($seed, "getParamCount"));
$type = call_user_func(array($seed, "getParameterTypes"));
$desc = $_REQUEST['function'] . "(";
if ($count == -1) {
$desc .= $type . ", ...";
} else {
for ($i = 0; $i < $count; $i++) {
if ($i != 0) {
$desc .= ", ";
}
if (is_array($type)) {
$desc .= $type[$i] . ($i + 1);
} else {
$desc .= $type . ($i + 1);
}
}
}
$desc .= ")";
}
}
} else {
$desc = "function not found";
}
echo json_encode(array("func" => empty($_REQUEST['function']) ? "" : $_REQUEST['function'], "desc" => $desc));
}
示例12: testSugarCacheFile
public function testSugarCacheFile()
{
if (file_exists(sugar_cached("testevil.php"))) {
@unlink(sugar_cached("testevil.php"));
}
$obj = 'test';
try {
$obj = unserialize('O:14:"SugarCacheFile":3:{s:13:"_cacheChanged";b:1;s:14:"_cacheFileName";s:12:"testevil.php";s:11:"_localStore";b:1;}');
} catch (Exception $e) {
$obj = null;
}
$this->assertNull($obj);
unset($obj);
// call dtor if object created
$this->assertFileNotExists(sugar_cached("testevil.php"));
}
示例13: __construct
public function __construct()
{
$this->queue = new SugarJobQueue();
$this->lockfile = sugar_cached("modules/Schedulers/lastrun");
if (!empty($GLOBALS['sugar_config']['cron']['max_cron_jobs'])) {
$this->max_jobs = $GLOBALS['sugar_config']['cron']['max_cron_jobs'];
}
if (!empty($GLOBALS['sugar_config']['cron']['max_cron_runtime'])) {
$this->max_runtime = $GLOBALS['sugar_config']['cron']['max_cron_runtime'];
}
if (isset($GLOBALS['sugar_config']['cron']['min_cron_interval'])) {
$this->min_interval = $GLOBALS['sugar_config']['cron']['min_cron_interval'];
}
if (isset($GLOBALS['sugar_config']['cron']['enforce_runtime'])) {
$this->enforceHardLimit = $GLOBALS['sugar_config']['cron']['enforce_runtime'];
}
}
示例14: getJSLanguage
/**
* Retrieves the requested js language file, building it if it doesn't exist.
*/
function getJSLanguage()
{
require_once 'include/language/jsLanguage.php';
global $app_list_strings;
if (empty($_REQUEST['lang'])) {
echo "No language specified";
return;
}
$lang = clean_path($_REQUEST['lang']);
$languages = get_languages();
if (!preg_match("/^\\w\\w_\\w\\w\$/", $lang) || !isset($languages[$lang])) {
if (!preg_match("/^\\w\\w_\\w\\w\$/", $lang)) {
echo "did not match regex<br/>";
} else {
echo "{$lang} was not in list . <pre>" . print_r($languages, true) . "</pre>";
}
echo "Invalid language specified";
return;
}
if (empty($_REQUEST['module']) || $_REQUEST['module'] === 'app_strings') {
$file = sugar_cached('jsLanguage/') . $lang . '.js';
if (!sugar_is_file($file)) {
$jsLanguage = new jsLanguage();
$jsLanguage->createAppStringsCache($lang);
}
} else {
$module = clean_path($_REQUEST['module']);
$fullModuleList = array_merge($GLOBALS['moduleList'], $GLOBALS['modInvisList']);
if (!isset($app_list_strings['moduleList'][$module]) && !in_array($module, $fullModuleList)) {
echo "Invalid module specified";
return;
}
$file = sugar_cached('jsLanguage/') . $module . "/" . $lang . '.js';
if (!sugar_is_file($file)) {
jsLanguage::createModuleStringsCache($module, $lang);
}
}
//Setup cache headers
header("Content-Type: application/javascript");
header("Cache-Control: max-age=31556940, private");
header("Pragma: ");
header("Expires: " . gmdate('D, d M Y H:i:s \\G\\M\\T', time() + 31556940));
readfile($file);
}
示例15: SearchForm
/**
* loads SearchFields MetaData, sets member variables
*
* @param string $module moduleDir
* @param bean $seedBean seed bean to use
* @param string $tpl template to use, defaults to moduleDir/SearchForm.html
*
*/
function SearchForm($module, $seedBean, $tpl = null)
{
global $app_strings;
$this->module = $module;
$searchFields = SugarAutoLoader::loadSearchFields($module);
$this->searchFields = $searchFields[$module];
if (empty($tpl)) {
if (!empty($GLOBALS['layout_edit_mode'])) {
$this->tpl = sugar_cached('studio/custom/working/modules/' . $module . '/SearchForm.html');
} else {
$this->tpl = get_custom_file_if_exists('modules/' . $module . '/SearchForm.html');
}
} else {
$this->tpl = $tpl;
}
$this->bean = $seedBean;
$this->tabs = array(array('title' => $app_strings['LNK_BASIC_SEARCH'], 'link' => $module . '|basic_search', 'key' => $module . '|basic_search'), array('title' => $app_strings['LNK_ADVANCED_SEARCH'], 'link' => $module . '|advanced_search', 'key' => $module . '|advanced_search'));
if (SugarAutoLoader::fileExists('modules/' . $this->module . '/index.php')) {
$this->tabs[] = array('title' => $app_strings['LNK_SAVED_VIEWS'], 'link' => $module . '|saved_views', 'key' => $module . '|saved_views');
}
}