本文整理汇总了PHP中Tools::file_exists_cache方法的典型用法代码示例。如果您正苦于以下问题:PHP Tools::file_exists_cache方法的具体用法?PHP Tools::file_exists_cache怎么用?PHP Tools::file_exists_cache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tools
的用法示例。
在下文中一共展示了Tools::file_exists_cache方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upgrade_module_0_9
function upgrade_module_0_9($module)
{
$module_path = $module->getLocalPath();
$img_folder_path = $module->getLocalPath() . 'img';
$fixture_img_path = $module->getLocalPath() . 'img' . DIRECTORY_SEPARATOR . 'fixtures';
if (!Tools::file_exists_cache($img_folder_path)) {
mkdir($img_folder_path);
}
if (!Tools::file_exists_cache($fixture_img_path)) {
mkdir($fixture_img_path);
}
$files = scandir($module->getLocalPath());
foreach ($files as $file) {
if (strncmp($file, 'advertising', 11) == 0) {
if ($file == 'advertising.jpg') {
copy($module_path . $file, $fixture_img_path . DIRECTORY_SEPARATOR . $file);
} else {
copy($module_path . $file, $img_folder_path . DIRECTORY_SEPARATOR . $file);
}
unlink($module_path . $file);
}
}
Tools::clearCache(Context::getContext()->smarty, $module->getTemplatePath('blockadvertising.tpl'));
return true;
}
示例2: getSubCategories
public static function getSubCategories($id_lang, $active = true, $id_category = 2, $p = 0, $n = 6)
{
$sql_groups_where = '';
$sql_groups_join = '';
if (Group::isFeatureActive()) {
$sql_groups_join = 'LEFT JOIN `' . _DB_PREFIX_ . 'category_group` cg ON (cg.`id_category` = c.`id_category`)';
$groups = FrontController::getCurrentCustomerGroups();
$sql_groups_where = 'AND cg.`id_group` ' . (count($groups) ? 'IN (' . pSQL(implode(',', $groups)) . ')' : '=' . (int) Group::getCurrent()->id);
}
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT c.*, cl.id_lang, cl.name, cl.description, cl.link_rewrite, cl.meta_title, cl.meta_keywords, cl.meta_description
FROM `' . _DB_PREFIX_ . 'category` c
' . Shop::addSqlAssociation('category', 'c') . '
LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl ON (c.`id_category` = cl.`id_category`
AND `id_lang` = ' . (int) $id_lang . ' ' . Shop::addSqlRestrictionOnLang('cl') . ')
' . $sql_groups_join . '
WHERE `id_parent` = ' . (int) $id_category . '
' . ($active ? 'AND `active` = 1' : '') . '
' . $sql_groups_where . '
GROUP BY c.`id_category`
ORDER BY `level_depth` ASC, category_shop.`position` ASC
LIMIT ' . (int) $p . ', ' . (int) $n);
foreach ($result as &$row) {
$row['id_image'] = Tools::file_exists_cache(_PS_CAT_IMG_DIR_ . $row['id_category'] . '.jpg') ? (int) $row['id_category'] : Language::getIsoById($id_lang) . '-default';
$row['legend'] = 'no picture';
}
return $result;
}
示例3: setMedia
public function setMedia()
{
parent::setMedia();
$this->addCSS(_PS_MODULE_DIR_ . 'expressmailing/views/css/expressmailing.css');
$this->addJS(_PS_JS_DIR_ . 'tiny_mce/tiny_mce.js');
$this->addJqueryUI('ui.tabs');
// Try to use employee language for Tiny Editor
// --------------------------------------------
$language = new Language($this->context->employee->id_lang);
$tiny_file = _PS_MODULE_DIR_ . 'expressmailing/views/js/tinymce_' . $language->iso_code . '.js';
if (Tools::file_exists_cache($tiny_file)) {
$this->addJS($tiny_file);
} else {
$language = new Language(Configuration::get('PS_LANG_DEFAULT'));
$tiny_file = _PS_MODULE_DIR_ . 'expressmailing/views/js/tinymce_' . Configuration::get('PS_LANG_DEFAULT') . '.js';
if (Tools::file_exists_cache($tiny_file)) {
$this->addJS($tiny_file);
} else {
$this->addJS(_PS_MODULE_DIR_ . 'expressmailing/views/js/tinymce_en.js');
}
}
// And add our Tiny config
// -----------------------
$this->addJS(_PS_MODULE_DIR_ . 'expressmailing/views/js/tinymce.js');
}
示例4: setTemplate
/**
* Assign module template
*
* @param string $template
*/
public function setTemplate($template)
{
if (Tools::file_exists_cache(_PS_THEME_DIR_ . 'modules/' . $this->module->name . '/' . $template)) {
$this->template = _PS_THEME_DIR_ . 'modules/' . $this->module->name . '/' . $template;
} elseif (Tools::file_exists_cache($this->getTemplatePath() . $template)) {
$this->template = $this->getTemplatePath() . $template;
} else {
throw new PrestaShopException("Template '{$template}'' not found");
}
}
示例5: getTemplatePath
/**
* Finds and returns module front template that take the highest precedence
*
* @param string $template Template filename
* @return string|false
*/
public function getTemplatePath($template)
{
if (Tools::file_exists_cache(_PS_THEME_DIR_ . 'modules/' . $this->module->name . '/' . $template)) {
return _PS_THEME_DIR_ . 'modules/' . $this->module->name . '/' . $template;
} elseif (Tools::file_exists_cache(_PS_THEME_DIR_ . 'modules/' . $this->module->name . '/views/templates/front/' . $template)) {
return _PS_THEME_DIR_ . 'modules/' . $this->module->name . '/views/templates/front/' . $template;
} elseif (Tools::file_exists_cache(_PS_MODULE_DIR_ . $this->module->name . '/views/templates/front/' . $template)) {
return _PS_MODULE_DIR_ . $this->module->name . '/views/templates/front/' . $template;
}
return false;
}
示例6: _isTemplateOverloadedStatic
protected static function _isTemplateOverloadedStatic($module_name, $template)
{
require_once dirname(__FILE__) . '../../../../modules/designerpreview/defines.inc.php';
if (Tools::file_exists_cache(getThemeDir() . 'modules/' . $module_name . '/' . $template)) {
return true;
} elseif (Tools::file_exists_cache(_PS_MODULE_DIR_ . $module_name . '/views/templates/hook/' . $template)) {
return false;
} elseif (Tools::file_exists_cache(_PS_MODULE_DIR_ . $module_name . '/' . $template)) {
return false;
}
return null;
}
示例7: fetch
/**
* Fetch a template
*
* @param string $name template name
* @param string $source template source
* @param integer $mtime template modification timestamp (epoch)
* @return void
*/
protected function fetch($name, &$source, &$mtime)
{
foreach ($this->paths as $path) {
if (Tools::file_exists_cache($file = $path . $name)) {
if (_PS_MODE_DEV_) {
$source = implode('', ['<!-- begin ' . $file . ' -->', file_get_contents($file), '<!-- end ' . $file . ' -->']);
} else {
$source = file_get_contents($file);
}
$mtime = filemtime($file);
return;
}
}
}
示例8: create
public function create($render, $type, $width, $height, $start, $limit, $sort, $dir)
{
if (!Tools::file_exists_cache($file = dirname(__FILE__) . '/../modules/' . $render . '/' . $render . '.php')) {
die(Tools::displayError());
}
require_once $file;
$this->_render = new $render($type);
$this->_start = $start;
$this->_limit = $limit;
$this->_sort = $sort;
$this->_direction = $dir;
$this->getData();
$this->_render->setTitle($this->_title);
$this->_render->setSize($width, $height);
$this->_render->setValues($this->_values);
$this->_render->setTotalCount($this->_totalCount);
}
示例9: upgrade_module_2_5
function upgrade_module_2_5($module)
{
$module_path = $module->getLocalPath();
$img_folder_path = $module->getLocalPath() . 'img';
if (!Tools::file_exists_cache($img_folder_path)) {
mkdir($img_folder_path);
}
$files = scandir($module->getLocalPath());
foreach ($files as $file) {
if (strncmp($file, 'homepage_logo', 13) == 0) {
copy($module_path . $file, $img_folder_path . DIRECTORY_SEPARATOR . $file);
unlink($module_path . $file);
}
}
Tools::clearCache(Context::getContext()->smarty, $module->getTemplatePath('editorial.tpl'));
return true;
}
示例10: getEmailTemplateContent
protected function getEmailTemplateContent($template_name, $mail_type, $var)
{
$email_configuration = Configuration::get('PS_MAIL_TYPE');
if ($email_configuration != $mail_type && $email_configuration != Mail::TYPE_BOTH) {
return '';
}
$theme_template_path = _PS_THEME_DIR_ . 'mails' . DIRECTORY_SEPARATOR . $this->context->language->iso_code . DIRECTORY_SEPARATOR . $template_name;
$default_mail_template_path = _PS_MAIL_DIR_ . $this->context->language->iso_code . DIRECTORY_SEPARATOR . $template_name;
if (Tools::file_exists_cache($theme_template_path)) {
$default_mail_template_path = $theme_template_path;
}
if (Tools::file_exists_cache($default_mail_template_path)) {
$this->context->smarty->assign('list', $var);
return $this->context->smarty->fetch($default_mail_template_path);
}
return '';
}
示例11: deactivate_custom_modules
function deactivate_custom_modules()
{
$db = Db::getInstance();
$modulesDirOnDisk = array();
$modules = scandir(_PS_MODULE_DIR_);
foreach ($modules as $name) {
if (is_dir(_PS_MODULE_DIR_ . $name) && Tools::file_exists_cache(_PS_MODULE_DIR_ . $name . '/' . $name . '.php')) {
if (!preg_match('/^[a-zA-Z0-9_-]+$/', $name)) {
die(Tools::displayError() . ' (Module ' . $name . ')');
}
$modulesDirOnDisk[] = $name;
}
}
$module_list_xml = _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'modules_list.xml';
$nativeModules = simplexml_load_file($module_list_xml);
$nativeModules = $nativeModules->modules;
foreach ($nativeModules as $nativeModulesType) {
if (in_array($nativeModulesType['type'], array('native', 'partner'))) {
$arrNativeModules[] = '""';
foreach ($nativeModulesType->module as $module) {
$arrNativeModules[] = '"' . pSQL($module['name']) . '"';
}
}
}
$arrNonNative = $db->ExecuteS('
SELECT *
FROM `' . _DB_PREFIX_ . 'module` m
WHERE name NOT IN (' . implode(',', $arrNativeModules) . ') ');
$uninstallMe = array("undefined-modules");
if (is_array($arrNonNative)) {
foreach ($arrNonNative as $aModule) {
$uninstallMe[] = $aModule['name'];
}
}
if (!is_array($uninstallMe)) {
$uninstallMe = array($uninstallMe);
}
foreach ($uninstallMe as $k => $v) {
$uninstallMe[$k] = '"' . pSQL($v) . '"';
}
return Db::getInstance()->Execute('
UPDATE `' . _DB_PREFIX_ . 'module`
SET `active`= 0
WHERE `name` IN (' . implode(',', $uninstallMe) . ')');
}
示例12: recurseCopy
function recurseCopy($src, $dst, $del = false)
{
$dir = opendir($src);
if (!Tools::file_exists_cache($dst)) {
mkdir($dst);
}
while (false !== ($file = readdir($dir))) {
if ($file != '.' && $file != '..') {
if (is_dir($src . DIRECTORY_SEPARATOR . $file)) {
recurseCopy($src . DIRECTORY_SEPARATOR . $file, $dst . DIRECTORY_SEPARATOR . $file, $del);
} else {
copy($src . DIRECTORY_SEPARATOR . $file, $dst . DIRECTORY_SEPARATOR . $file);
if ($del && is_writable($src . DIRECTORY_SEPARATOR . $file)) {
unlink($src . DIRECTORY_SEPARATOR . $file);
}
}
}
}
closedir($dir);
if ($del && is_writable($src)) {
rmdir($src);
}
}
示例13: smartyTranslate
function smartyTranslate($params, &$smarty)
{
/*
* Warning : 2 lines have been added to the Smarty class.
* "public $currentTemplate = null;" into the class itself
* "$this->currentTemplate = substr(basename($resource_name), 0, -4);" into the "display" method
*/
global $_LANG, $_MODULES, $cookie, $_MODULE;
if (!isset($params['js'])) {
$params['js'] = 0;
}
if (!isset($params['mod'])) {
$params['mod'] = false;
}
$msg = false;
$string = str_replace('\'', '\\\'', $params['s']);
$key = $smarty->currentTemplate . '_' . md5($string);
if ($params['mod']) {
$iso = Language::getIsoById($cookie->id_lang);
if (Tools::file_exists_cache(_PS_THEME_DIR_ . 'modules/' . $params['mod'] . '/' . $iso . '.php')) {
$translationsFile = _PS_THEME_DIR_ . 'modules/' . $params['mod'] . '/' . $iso . '.php';
$modKey = '<{' . $params['mod'] . '}' . _THEME_NAME_ . '>' . $key;
} else {
$translationsFile = _PS_MODULE_DIR_ . $params['mod'] . '/' . $iso . '.php';
$modKey = '<{' . $params['mod'] . '}prestashop>' . $key;
}
if (@(include_once $translationsFile)) {
$_MODULES = array_merge($_MODULES, $_MODULE);
}
$msg = (is_array($_MODULES) and key_exists($modKey, $_MODULES)) ? $params['js'] ? addslashes($_MODULES[$modKey]) : stripslashes($_MODULES[$modKey]) : false;
}
if (!$msg) {
$msg = (is_array($_LANG) and key_exists($key, $_LANG)) ? $params['js'] ? addslashes($_LANG[$key]) : stripslashes($_LANG[$key]) : $params['s'];
}
return $params['js'] ? $msg : Tools::htmlentitiesUTF8($msg);
}
示例14: BlockWishList
$wishlist->id_shop = $context->shop->id;
$wishlist->id_shop_group = $context->shop->id_shop_group;
$wishlist->default = 1;
$mod_wishlist = new BlockWishList();
$wishlist->name = $mod_wishlist->default_wishlist_name;
$wishlist->id_customer = (int) $context->customer->id;
list($us, $s) = explode(' ', microtime());
srand($s * $us);
$wishlist->token = strtoupper(substr(sha1(uniqid(rand(), true) . _COOKIE_KEY_ . $context->customer->id), 0, 16));
$wishlist->add();
$context->cookie->id_wishlist = (int) $wishlist->id;
}
if ($add && $quantity) {
WishList::addProduct($context->cookie->id_wishlist, $context->customer->id, $id_product, $id_product_attribute, $quantity);
} else {
if ($delete) {
WishList::removeProduct($context->cookie->id_wishlist, $context->customer->id, $id_product, $id_product_attribute);
}
}
}
$context->smarty->assign('products', WishList::getProductByIdCustomer($context->cookie->id_wishlist, $context->customer->id, $context->language->id, null, true));
if (Tools::file_exists_cache(_PS_THEME_DIR_ . 'modules/blockwishlist/blockwishlist-ajax.tpl')) {
$context->smarty->display(_PS_THEME_DIR_ . 'modules/blockwishlist/blockwishlist-ajax.tpl');
} elseif (Tools::file_exists_cache(dirname(__FILE__) . '/blockwishlist-ajax.tpl')) {
$context->smarty->display(dirname(__FILE__) . '/blockwishlist-ajax.tpl');
} else {
echo $module->l('No template found', 'cart');
}
} else {
echo $module->l('You must be logged in to manage your wishlist.', 'cart');
}
示例15: _isTemplateOverloadedStatic
protected static function _isTemplateOverloadedStatic($moduleName, $template)
{
if (Tools::file_exists_cache(_PS_THEME_DIR_ . 'modules/' . $moduleName . '/' . $template)) {
return true;
} elseif (Tools::file_exists_cache(_PS_MODULE_DIR_ . $moduleName . '/' . $template)) {
return false;
}
return NULL;
}