本文整理汇总了PHP中file_scan_directory函数的典型用法代码示例。如果您正苦于以下问题:PHP file_scan_directory函数的具体用法?PHP file_scan_directory怎么用?PHP file_scan_directory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了file_scan_directory函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: fillRandomValues
/**
* Fill generic file field with random files.
*
* @param Form $formObject
* Form object.
* @param string $field_name
* Field name.
* @param array $options
* Options array.
*
* @return array
* An array with 3 values:
* (1) $success: Whether default values could be filled in the field.
* (2) $values: Values that were filled for the field.
* (3) $msg: Message in case there is an error. This will be empty if
* $success is TRUE.
*/
public static function fillRandomValues(Form $formObject, $field_name, $options = array())
{
$num = 1;
$file_extensions = 'txt';
$scheme = 'public';
$show_description = FALSE;
if (method_exists($formObject, 'getEntityObject')) {
// This is an entity form.
list($field, $instance, $num) = $formObject->getFieldDetails($field_name);
$file_extensions = $instance['settings']['file_extensions'];
$scheme = $field['settings']['uri_scheme'];
$show_description = $instance['settings']['description_field'];
}
$extensions = str_replace(" ", "|", $file_extensions);
$files = file_scan_directory('tests/assets', '/^.*\\.(' . $extensions . ')$/i');
$filenames = array();
foreach ($files as $file_name => $file_array) {
$filenames[] = $file_array->uri;
}
if (!sizeof($filenames)) {
return new Response(FALSE, array(), "Could not find a file to attach with any of the following extensions: " . $file_extensions);
}
$files = array();
for ($i = 0; $i < $num; $i++) {
if ($show_description) {
$files[] = array('uri' => $filenames[Utils::getRandomInt(0, sizeof($filenames) - 1)], 'description' => Utils::getRandomText(20), 'scheme' => $scheme);
} else {
$files[] = array('uri' => $filenames[Utils::getRandomInt(0, sizeof($filenames) - 1)], 'scheme' => $scheme);
}
}
$files = Utils::normalize($files);
$function = "fill" . Utils::makeTitleCase($field_name) . "Values";
return $formObject->{$function}($files);
}
开发者ID:redcrackle,项目名称:redtest-core,代码行数:51,代码来源:File.php
示例2: canUpdateDirectory
/**
* Implements Drupal\Core\Updater\UpdaterInterface::canUpdateDirectory().
*/
public static function canUpdateDirectory($directory)
{
if (file_scan_directory($directory, '/.*\\.module$/')) {
return TRUE;
}
return FALSE;
}
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:10,代码来源:Module.php
示例3: preparePackage
/**
* Reads and merges in existing files for a given package or profile.
*/
protected function preparePackage(Package $package, array $existing_packages, FeaturesBundleInterface $bundle = NULL)
{
if (isset($existing_packages[$package->getMachineName()])) {
$existing_directory = $existing_packages[$package->getMachineName()];
// Scan for all files.
$files = file_scan_directory($existing_directory, '/.*/');
foreach ($files as $file) {
// Skip files in the any existing configuration directory, as these
// will be replaced.
foreach (array_keys($this->featuresManager->getExtensionStorages()->getExtensionStorages()) as $directory) {
if (strpos($file->uri, $directory) !== FALSE) {
continue 2;
}
}
// Merge in the info file.
if ($file->name == $package->getMachineName() . '.info') {
$files = $package->getFiles();
$files['info']['string'] = $this->mergeInfoFile($package->getFiles()['info']['string'], $file->uri);
$package->setFiles($files);
} else {
// Determine if the file is within a subdirectory of the
// extension's directory.
$file_directory = dirname($file->uri);
if ($file_directory !== $existing_directory) {
$subdirectory = substr($file_directory, strlen($existing_directory) + 1);
} else {
$subdirectory = NULL;
}
$package->appendFile(['filename' => $file->filename, 'subdirectory' => $subdirectory, 'string' => file_get_contents($file->uri)]);
}
}
}
}
开发者ID:alexburrows,项目名称:cream-2.x,代码行数:36,代码来源:FeaturesGenerationArchive.php
示例4: testPiwikUninstall
/**
* Tests if the module cleans up the disk on uninstall.
*/
public function testPiwikUninstall()
{
$cache_path = 'public://piwik';
$site_id = '1';
$this->config('piwik.settings')->set('site_id', $site_id)->save();
$this->config('piwik.settings')->set('url_http', 'http://www.example.com/piwik/')->save();
$this->config('piwik.settings')->set('url_https', 'https://www.example.com/piwik/')->save();
// Enable local caching of piwik.js
$this->config('piwik.settings')->set('cache', 1)->save();
// Load front page to get the piwik.js downloaded into local cache. But
// loading the piwik.js is not possible as "url_http" is a test dummy only.
// Create a dummy file to complete the rest of the tests.
file_prepare_directory($cache_path, FILE_CREATE_DIRECTORY);
file_unmanaged_save_data($this->randomMachineName(16), $cache_path . '/piwik.js');
// Test if the directory and piwik.js exists.
$this->assertTrue(file_prepare_directory($cache_path), 'Cache directory "public://piwik" has been found.');
$this->assertTrue(file_exists($cache_path . '/piwik.js'), 'Cached piwik.js tracking file has been found.');
// Uninstall the module.
$edit = [];
$edit['uninstall[piwik]'] = TRUE;
$this->drupalPostForm('admin/modules/uninstall', $edit, t('Uninstall'));
$this->assertNoText(\Drupal::translation()->translate('Configuration deletions'), 'No configuration deletions listed on the module install confirmation page.');
$this->drupalPostForm(NULL, NULL, t('Uninstall'));
$this->assertText(t('The selected modules have been uninstalled.'), 'Modules status has been updated.');
// Test if the directory and all files have been removed.
$this->assertFalse(file_scan_directory($cache_path, '/.*/'), 'Cached JavaScript files have been removed.');
$this->assertFalse(file_prepare_directory($cache_path), 'Cache directory "public://piwik" has been removed.');
}
开发者ID:rsmccc,项目名称:drupal-bootstrap,代码行数:31,代码来源:PiwikUninstallTest.php
示例5: preparePackage
/**
* Reads and merges in existing files for a given package or profile.
*/
protected function preparePackage(array &$package, array $existing_packages, FeaturesBundleInterface $bundle = NULL) {
if (isset($existing_packages[$package['machine_name']])) {
$existing_directory = $existing_packages[$package['machine_name']];
// Scan for all files.
$files = file_scan_directory($existing_directory, '/.*/');
foreach ($files as $file) {
// Skip files in the install directory.
if (strpos($existing_directory, InstallStorage::CONFIG_INSTALL_DIRECTORY) !== FALSE) {
continue;
}
// Merge in the info file.
if ($file->name == $package['machine_name'] . '.info') {
$package['files']['info']['string'] = $this->mergeInfoFile($package['files']['info']['string'], $file->uri);
}
// Read in remaining files.
else {
// Determine if the file is within a subdirectory of the
// extension's directory.
$file_directory = dirname($file->uri);
if ($file_directory !== $existing_directory) {
$subdirectory = substr($file_directory, strlen($existing_directory) + 1);
}
else {
$subdirectory = NULL;
}
$package['files'][] = [
'filename' => $file->filename,
'subdirectory' => $subdirectory,
'string' => file_get_contents($file->uri)
];
}
}
}
}
开发者ID:jeetendrasingh,项目名称:manage_profile,代码行数:37,代码来源:FeaturesGenerationArchive.php
示例6: canUpdateDirectory
/**
* Implements Drupal\Core\Updater\UpdaterInterface::canUpdateDirectory().
*/
static function canUpdateDirectory($directory)
{
// This is a lousy test, but don't know how else to confirm it is a theme.
if (file_scan_directory($directory, '/.*\\.module$/')) {
return FALSE;
}
return TRUE;
}
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:11,代码来源:Theme.php
示例7: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
parent::setUp();
$tables = file_scan_directory($this->getDumpDirectory(), '/.php$/', array('recurse' => FALSE));
$this->loadDumps(array_keys($tables));
$this->installEntitySchema('user');
$this->installConfig(['migrate_drupal', 'system']);
}
开发者ID:komejo,项目名称:article-test,代码行数:11,代码来源:MigrateDrupalTestBase.php
示例8: systemListing
/**
* A version-independent wrapper for drupal_system_listing().
*
* Based on notes in change record at https://www.drupal.org/node/2198695.
*/
function systemListing($mask, $directory, $key = 'name', $min_depth = 1)
{
$files = array();
foreach (\Drupal::moduleHandler()->getModuleList() as $name => $module) {
$files += file_scan_directory($module->getPath(), $mask, array('key' => $key));
}
return $files;
}
开发者ID:verbruggenalex,项目名称:mediayoutubeupload,代码行数:13,代码来源:VersionHelper8.php
示例9: verifyDumpFiles
protected function verifyDumpFiles($directory)
{
$tables = file_scan_directory($directory, '/.php$/');
foreach ($tables as $table) {
$contents = rtrim(file_get_contents($table->uri));
$this->assertIdentical(substr($contents, -32), md5(substr($contents, 0, -33)), $table->uri);
}
}
开发者ID:nstielau,项目名称:drops-8,代码行数:8,代码来源:MigrateTableDumpTest.php
示例10: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state)
{
// Log execution time.
$start_time = microtime(TRUE);
// Try to load the files count from cache. This function will accept two
// arguments:
// - cache object name (cid)
// - cache bin, the (optional) cache bin (most often a database table) where
// the object is to be saved.
//
// cache_get() returns the cached object or FALSE if object does not exist.
if ($cache = \Drupal::cache()->get('cache_example_files_count')) {
/*
* Get cached data. Complex data types will be unserialized automatically.
*/
$files_count = $cache->data;
} else {
// If there was no cached data available we have to search filesystem.
// Recursively get all files from Drupal's folder.
$files_count = count(file_scan_directory('.', '/.*/'));
// Since we have recalculated, we now need to store the new data into
// cache. Complex data types will be automatically serialized before
// being saved into cache.
// Here we use the default setting and create an unexpiring cache item.
// See below for an example that creates an expiring cache item.
\Drupal::cache()->set('cache_example_files_count', $files_count, CacheBackendInterface::CACHE_PERMANENT);
}
$end_time = microtime(TRUE);
$duration = $end_time - $start_time;
// Format intro message.
$intro_message = '<p>' . t('This example will search the entire drupal folder and display a count of the files in it.') . ' ';
$intro_message .= t('This can take a while, since there are a lot of files to be searched.') . ' ';
$intro_message .= t('We will search filesystem just once and save output to the cache. We will use cached data for later requests.') . '</p>';
$intro_message .= '<p>' . t('<a href="@url">Reload this page</a> to see cache in action.', array('@url' => request_uri())) . ' ';
$intro_message .= t('You can use the button below to remove cached data.') . '</p>';
$form['file_search'] = array('#type' => 'fieldset', '#title' => t('File search caching'));
$form['file_search']['introduction'] = array('#markup' => $intro_message);
$color = empty($cache) ? 'red' : 'green';
$retrieval = empty($cache) ? t('calculated by traversing the filesystem') : t('retrieved from cache');
$form['file_search']['statistics'] = array('#type' => 'item', '#markup' => t('%count files exist in this Drupal installation; @retrieval in @time ms. <br/>(Source: <span style="color:@color;">@source</span>)', array('%count' => $files_count, '@retrieval' => $retrieval, '@time' => number_format($duration * 1000, 2), '@color' => $color, '@source' => empty($cache) ? t('actual file search') : t('cached'))));
$form['file_search']['remove_file_count'] = array('#type' => 'submit', '#submit' => array(array($this, 'expireFiles')), '#value' => t('Explicitly remove cached file count'));
$form['expiration_demo'] = array('#type' => 'fieldset', '#title' => t('Cache expiration settings'));
$form['expiration_demo']['explanation'] = array('#markup' => t('A cache item can be set as CACHE_PERMANENT, meaning that it will only be removed when explicitly cleared, or it can have an expiration time (a Unix timestamp).'));
$item = \Drupal::cache()->get('cache_example_expiring_item', TRUE);
if ($item == FALSE) {
$item_status = t('Cache item does not exist');
} else {
$item_status = $item->valid ? t('Cache item exists and is set to expire at %time', array('%time' => $item->data)) : t('Cache_item is invalid');
}
$form['expiration_demo']['current_status'] = array('#type' => 'item', '#title' => t('Current status of cache item "cache_example_expiring_item"'), '#markup' => $item_status);
$form['expiration_demo']['expiration'] = array('#type' => 'select', '#title' => t('Time before cache expiration'), '#options' => array('never_remove' => t('CACHE_PERMANENT'), -10 => t('Immediate expiration'), 10 => t('10 seconds from form submission'), 60 => t('1 minute from form submission'), 300 => t('5 minutes from form submission')), '#default_value' => -10, '#description' => t('Any cache item can be set to only expire when explicitly cleared, or to expire at a given time.'));
$form['expiration_demo']['create_cache_item'] = array('#type' => 'submit', '#value' => t('Create a cache item with this expiration'), '#submit' => array(array($this, 'createExpiringItem')));
$form['cache_clearing'] = array('#type' => 'fieldset', '#title' => t('Expire and remove options'), '#description' => t("We have APIs to expire cached items and also to just remove them. Unfortunately, they're all the same API, cache_clear_all"));
$form['cache_clearing']['cache_clear_type'] = array('#type' => 'radios', '#title' => t('Type of cache clearing to do'), '#options' => array('expire' => t('Remove items from the "cache" bin that have expired'), 'remove_all' => t('Remove all items from the "cache" bin regardless of expiration'), 'remove_tag' => t('Remove all items in the "cache" bin with the tag "cache_example" set to 1')), '#default_value' => 'expire');
// Submit button to clear cached data.
$form['cache_clearing']['clear_expired'] = array('#type' => 'submit', '#value' => t('Clear or expire cache'), '#submit' => array(array($this, 'cacheClearing')), '#access' => \Drupal::currentUser()->hasPermission('administer site configuration'));
return $form;
}
开发者ID:njcameron,项目名称:ncmd,代码行数:61,代码来源:CacheExampleForm.php
示例11: glossy_style_option
/**
* Generate list of available styles definitions
* @return $styles
* Style names that found in skin directory
*/
function glossy_style_option() {
$styles = array();
$skin_path = variable_get('glossy_skin_dir', drupal_get_path('theme', 'glossy') . '/css/skins');
if(is_dir($skin_path)) {
$styles = file_scan_directory($skin_path, '/\.css$/i');
}
asort($styles);
return $styles;
}
开发者ID:redtrayworkshop,项目名称:msdworkshop,代码行数:15,代码来源:theme-functions.php
示例12: isImageFilename
private function isImageFilename($filename, $directory)
{
$files = file_scan_directory($directory, '/.*' . $filename . '$/', array('recurse' => TRUE));
// First look for file with the exact name.
foreach ($files as $uri => $file) {
if ($file->filename == $filename && @getimagesize($uri)) {
return $uri;
}
}
// There is no file with the exact name. Return FALSE.
return FALSE;
}
开发者ID:neeravbm,项目名称:3dmart,代码行数:12,代码来源:Texture.php
示例13: __construct
public function __construct($filename, $directory = '')
{
$found = FALSE;
// Some OBJ files provide full relative pathname. Extract just the filename.
$path_info = pathinfo($filename);
$filename = $path_info['basename'];
$files = file_scan_directory($directory, '/.*' . $filename . '$/', array('recurse' => TRUE));
foreach ($files as $uri => $file) {
if ($file->filename != $filename) {
continue;
}
$found = TRUE;
$handle = fopen($uri, 'r');
$material = NULL;
$text = '';
while (($line = fgets($handle)) !== FALSE) {
$line = trim($line);
// Start of a new material.
// Store the old material first.
if (strpos($line, 'newmtl ') === 0) {
// Start a new material.
// First close the previous material.
if (!empty($text)) {
$material = new Material($text, $directory);
if ($error = $material->getError()) {
$this->error = $error;
return;
}
$this->materials[$material->name] = $material;
}
$text = $line;
} elseif (!empty($line) && strpos($line, '#') !== 0) {
$text .= PHP_EOL . $line;
}
}
// End of file. Create the material.
if (!empty($text)) {
$material = new Material($text, $directory);
if ($error = $material->getError()) {
$this->error = $error;
return;
}
$this->materials[$material->name] = $material;
}
}
if (!$found) {
$this->error = 'File ' . $filename . ' doesn\'t exist.';
return;
}
}
开发者ID:neeravbm,项目名称:3dmart,代码行数:50,代码来源:MaterialLoader.php
示例14: prepare
function prepare($caller)
{
global $settings;
foreach (file_scan_directory(__DIR__ . '/include/', '/.*\\.inc$/') as $include) {
include_once $include->uri;
}
$settings = settings($caller);
$install_file = $settings['script_path']['dirname'] . '/' . $settings['script_path']['filename'] . '.install';
$info_file = $settings['script_path']['dirname'] . '/' . $settings['script_path']['filename'] . '.info';
$includes = file_scan_directory($settings['script_path']['dirname'], '/.*\\.inc$/');
foreach ($includes as $include) {
include_once $include->uri;
}
}
开发者ID:NYULibraries,项目名称:dlts_viewer_distro,代码行数:14,代码来源:export.php
示例15: migrate
function migrate()
{
global $term_dir;
$completed = array();
$names = $_POST['edit']['migrate'];
foreach ($names as $name => $status) {
$files = file_scan_directory($term_dir, $name);
if (count($files) != 1) {
print count($files) . " files match the name: {$name}";
exit;
}
$image = array_pop($files);
$image->filename_orig = $image->filename;
if ($status == 1) {
$image->tid = migrate_term_image_get_tid($image->name);
if (!taxonomy_get_term($image->tid)) {
print "cant find the tid: {$tid}";
exit;
}
$t_i_image = db_fetch_object(db_query('SELECT path FROM {term_image} WHERE tid = %d', $image->tid));
if ($t_i_image) {
$term->has_image = true;
}
if ($term->has_image) {
taxonomy_image_delete($image->tid);
}
if (file_copy($image->filename) != 1) {
print "couldnt copy file: {$image->filename} to new location";
exit;
}
db_query("INSERT INTO {term_image} (tid, path) VALUES (%d, '%s')", $image->tid, $image->filename);
$completed[] = $image;
}
if ($_POST['edit']['delete'][$name] == 1) {
file_delete($image->filename_orig);
$deleted[] = $image;
}
}
if ($c = count($completed)) {
print "Updated {$c} terms";
} else {
print "No terms updated";
}
if ($c = count($deleted)) {
print "Deleted {$c} node_image(s)";
} else {
print "No images deleted";
}
}
开发者ID:nabuur,项目名称:nabuur-d5,代码行数:49,代码来源:update_term_images.php
示例16: perspective_form_system_theme_settings_alter
/**
* Advanced theme settings.
*/
function perspective_form_system_theme_settings_alter(&$form, $form_state)
{
$form['perspective_theme_slogan'] = array('#type' => 'textarea', '#title' => t('Theme slogan'), '#default_value' => theme_get_setting('perspective_theme_slogan', 'perspective'), '#description' => t('This is heading message on the site.'));
$form['perspective_footer_copyright'] = array('#type' => 'textarea', '#title' => t('Footer copyright message'), '#default_value' => theme_get_setting('perspective_footer_copyright', 'perspective'), '#description' => t('This is copyright message in footer region.'));
$form['perspective_footer_social_links'] = array('#type' => 'textarea', '#title' => t('Footer Social links'), '#default_value' => theme_get_setting('perspective_footer_social_links', 'perspective'), '#description' => t('This is social links in footer region.'));
$form['slider'] = array('#type' => 'fieldset', '#title' => t('Slider managment'), '#collapsible' => TRUE, '#collapsed' => FALSE);
// Image upload section ======================================================
$banners = perspective_get_banners();
$form['slider']['banner']['images'] = array('#type' => 'vertical_tabs', '#title' => t('Banner images'), '#weight' => 2, '#collapsible' => TRUE, '#collapsed' => FALSE, '#tree' => TRUE);
$i = 0;
foreach ($banners as $image_data) {
$form['slider']['banner']['images'][$i] = array('#type' => 'fieldset', '#title' => t('Image !number: !title', array('!number' => $i + 1, '!title' => $image_data['image_title'])), '#weight' => $i, '#collapsible' => TRUE, '#collapsed' => FALSE, '#tree' => TRUE, 'image' => _perspective_banner_form($image_data));
$i++;
}
$form['slider']['banner']['image_upload'] = array('#type' => 'file', '#title' => t('Upload a new image'), '#weight' => $i);
$form['#submit'][] = 'perspective_settings_submit';
$form['home'] = array('#type' => 'fieldset', '#title' => t('Homepage settings'), '#collapsible' => TRUE, '#collapsed' => FALSE);
$form['home']['perspective_homepage_type'] = array('#type' => 'select', '#title' => t('Hompage type'), '#options' => array('slider' => 'Slider', 'video' => 'Video'), '#default_value' => theme_get_setting('perspective_homepage_type', 'perspective'));
if (theme_get_setting('perspective_homepage_type', 'perspective') == 'video') {
$form['home']['video']['perspective_video_title'] = array('#type' => 'textfield', '#title' => t('Video title'), '#default_value' => theme_get_setting('perspective_video_title', 'perspective'));
$form['home']['video']['perspective_video'] = array('#type' => 'textarea', '#title' => t('Video iframe code'), '#default_value' => theme_get_setting('perspective_video', 'perspective'), '#description' => t('This is iframe of video, or you can enter image code here.'));
$form['home']['video']['perspective_video_description'] = array('#type' => 'textarea', '#title' => t('Description'), '#default_value' => theme_get_setting('perspective_video_description', 'perspective'), '#description' => t('Enter description.'));
$form['home']['video']['perspective_video_link_title'] = array('#type' => 'textfield', '#title' => t('link title'), '#default_value' => theme_get_setting('perspective_video_link_title', 'perspective'));
$form['home']['video']['perspective_video_link_url'] = array('#type' => 'textfield', '#title' => t('Link URL'), '#default_value' => theme_get_setting('perspective_video_link_url', 'perspective'), '#description' => t('This is the URL.'));
}
$blog_style_options = array('blog_meta_before' => t('[Default] big image - meta before'), 'blog_meta_after' => t('Big image - meta after'), 'blog_meta_icons_right' => t('Big image meta-icons right'), 'blog_meta_icons_left' => t('Big image meta-icons left'), 'blog_image_meta_31' => t('Image-Meta / 3:1'), 'blog_image_meta_13' => t('Meta-Image / 1:3'), 'blog_image_hidden_meta' => t('Hiden meta / Big image'), 'blog_small_image_left' => t('Small image left'), 'blog_small_image_right' => t('Small image right'), 'blog_75p_meta' => t('75% Image / Meta'), 'blog_meta_75p' => t('Meta / 75% Image'));
$form['blog_display_setting'] = array('#type' => 'select', '#title' => t('Blog style options'), '#options' => $blog_style_options, '#default_value' => theme_get_setting('blog_display_setting', 'perspective'));
$form['portfolio'] = array('#type' => 'fieldset', '#title' => t('Portfolio settings'), '#collapsible' => TRUE, '#collapsed' => FALSE);
$form['portfolio']['default_portfolio'] = array('#type' => 'select', '#title' => t('Default portfolio display'), '#options' => array('1c' => 'Portfolio - 1col', '2c' => 'Portfolio - 2cols', '3c' => 'Portfolio - 3cols', '4c' => 'portfolio - 4cols'), '#default_value' => theme_get_setting('default_portfolio', 'perspective'));
$form['portfolio']['default_nodes_portfolio'] = array('#type' => 'select', '#title' => t('Number nodes show on portfolio page'), '#options' => drupal_map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 30)), '#default_value' => theme_get_setting('default_nodes_portfolio', 'perspective'));
$form['contact'] = array('#type' => 'fieldset', '#title' => t('Contact settings'), '#collapsible' => TRUE, '#collapsed' => FALSE);
$form['contact']['contact_map'] = array('#type' => 'textarea', '#title' => 'Map embed code', '#default_value' => theme_get_setting('contact_map', 'perspective'));
$form['skin'] = array('#type' => 'fieldset', '#title' => t('Skins settings'), '#collapsible' => TRUE, '#collapsed' => FALSE);
$skins_options = array();
$dir = drupal_get_path('theme', 'perspective') . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'themes';
$files = file_scan_directory($dir, '/.*\\.css/');
if (!empty($files)) {
foreach ($files as $file) {
if (isset($file->filename)) {
$skins_options[$file->name] = $file->filename;
}
}
}
$form['skin']['default_skin'] = array('#type' => 'select', '#title' => t('Default skin'), '#options' => $skins_options, '#default_value' => theme_get_setting('default_skin', 'perspective'));
return $form;
}
开发者ID:ayurved,项目名称:ayurvedawellbeing,代码行数:49,代码来源:theme-settings.php
示例17: DrupalUnitTests
/**
* Constructor
* @param array $class_list list containing the classes of tests to be processed
* default: NULL - run all tests
*/
function DrupalUnitTests($class_list = NULL)
{
static $classes;
$this->DrupalTestSuite('Drupal Unit Tests');
/* Tricky part to avoid double inclusion */
if (!$classes) {
$files = array();
foreach (module_list() as $module) {
$module_path = drupal_get_path('module', $module);
if (file_exists($module_path . '/tests/')) {
$dir = $module_path . '/tests';
$tests = file_scan_directory($dir, '\\.test$');
$files = array_merge($files, $tests);
}
}
$files = array_keys($files);
$existing_classes = get_declared_classes();
foreach ($files as $file) {
include_once $file;
}
$classes = array_diff(get_declared_classes(), $existing_classes);
}
if (!is_null($class_list)) {
$classes = $class_list;
}
if (count($classes) == 0) {
$this->addTestCase(new BadGroupTest($test_file, 'No new test cases'));
return;
}
$groups = array();
foreach ($classes as $class) {
if (!is_subclass_of($class, 'DrupalTestCase')) {
if (!is_subclass_of($class, 'DrupalWebTestCase')) {
continue;
}
}
$this->_addClassToGroups($groups, $class);
}
foreach ($groups as $group_name => $group) {
$group_test =& new DrupalTestSuite($group_name);
foreach ($group as $key => $v) {
$group_test->addTestCase($group[$key]);
}
$this->addTestCase($group_test);
}
}
开发者ID:sdboyer,项目名称:sdboyer-test,代码行数:51,代码来源:drupal_unit_tests.php
示例18: visia_form_system_theme_settings_alter
function visia_form_system_theme_settings_alter(&$form, $form_state)
{
$form['settings'] = array('#type' => 'vertical_tabs', '#title' => t('Theme settings'), '#weight' => 2, '#collapsible' => TRUE, '#collapsed' => FALSE);
$form['settings']['general'] = array('#type' => 'fieldset', '#title' => t('General settings'), '#collapsible' => TRUE, '#collapsed' => FALSE);
$form['settings']['general']['enable_breadcrumb'] = array('#type' => 'checkbox', '#title' => t('Use breadcrumb'), '#default_value' => theme_get_setting('enable_breadcrumb'));
$form['settings']['general']['use_parallax'] = array('#type' => 'checkbox', '#title' => t('Use Parallax'), '#default_value' => theme_get_setting('use_parallax'));
$form['settings']['general']['content_column_size'] = array('#type' => 'select', '#title' => t('Content column size'), '#default_value' => theme_get_setting('content_column_size'), '#description' => t('Change size of main content column, default is 4'), '#options' => array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5));
// bg background
$dir = drupal_get_path('theme', 'visia') . DIRECTORY_SEPARATOR . 'stylesheets' . DIRECTORY_SEPARATOR . 'colors';
$files = file_scan_directory($dir, '/.*\\.css/');
$css_files = array();
if (!empty($files)) {
foreach ($files as $file) {
if (isset($file->filename)) {
$css_files[$file->filename] = $file->filename;
}
}
}
$form['settings']['general']['theme_color'] = array('#type' => 'select', '#title' => t('Default theme color'), '#default_value' => theme_get_setting('theme_color'), '#description' => t('Colors availabe in <strong>!path/stylesheets/colors</strong> , you could also create new custom css file put in that directory and system will auto detects your css file.', array('!path' => base_path() . drupal_get_path('theme', 'visia'))), '#options' => $css_files);
$form['settings']['general']['custom_theme_css'] = array('#type' => 'textarea', '#title' => t('Custom theme css'), '#default_value' => theme_get_setting('custom_theme_css'), '#description' => t('Custom your own css, eg: <strong>#page-title h2{color: #060606;}</strong>'));
}
开发者ID:antoniodltm,项目名称:iwg,代码行数:21,代码来源:theme-settings.php
示例19: getTestFiles
/**
* Gets a list of files that can be used in tests.
*
* The first time this method is called, it will call
* $this->generateFile() to generate binary and ASCII text files in the
* public:// directory. It will also copy all files in
* core/modules/simpletest/files to public://. These contain image, SQL, PHP,
* JavaScript, and HTML files.
*
* All filenames are prefixed with their type and have appropriate extensions:
* - text-*.txt
* - binary-*.txt
* - html-*.html and html-*.txt
* - image-*.png, image-*.jpg, and image-*.gif
* - javascript-*.txt and javascript-*.script
* - php-*.txt and php-*.php
* - sql-*.txt and sql-*.sql
*
* Any subsequent calls will not generate any new files, or copy the files
* over again. However, if a test class adds a new file to public:// that
* is prefixed with one of the above types, it will get returned as well, even
* on subsequent calls.
*
* @param $type
* File type, possible values: 'binary', 'html', 'image', 'javascript',
* 'php', 'sql', 'text'.
* @param $size
* (optional) File size in bytes to match. Defaults to NULL, which will not
* filter the returned list by size.
*
* @return array[]
* List of files in public:// that match the filter(s).
*/
protected function getTestFiles($type, $size = NULL)
{
if (empty($this->generatedTestFiles)) {
// Generate binary test files.
$lines = [64, 1024];
$count = 0;
foreach ($lines as $line) {
$this->generateFile('binary-' . $count++, 64, $line, 'binary');
}
// Generate ASCII text test files.
$lines = [16, 256, 1024, 2048, 20480];
$count = 0;
foreach ($lines as $line) {
$this->generateFile('text-' . $count++, 64, $line, 'text');
}
// Copy other test files from simpletest.
$original = drupal_get_path('module', 'simpletest') . '/files';
$files = file_scan_directory($original, '/(html|image|javascript|php|sql)-.*/');
foreach ($files as $file) {
file_unmanaged_copy($file->uri, PublicStream::basePath());
}
$this->generatedTestFiles = TRUE;
}
$files = [];
// Make sure type is valid.
if (in_array($type, ['binary', 'html', 'image', 'javascript', 'php', 'sql', 'text'])) {
$files = file_scan_directory('public://', '/' . $type . '\\-.*/');
// If size is set then remove any files that are not of that size.
if ($size !== NULL) {
foreach ($files as $file) {
$stats = stat($file->uri);
if ($stats['size'] != $size) {
unset($files[$file->uri]);
}
}
}
}
usort($files, [$this, 'compareFiles']);
return $files;
}
开发者ID:eigentor,项目名称:tommiblog,代码行数:73,代码来源:TestFileCreationTrait.php
示例20: testGoogleAnalyticsUninstall
/**
* Tests if the module cleans up the disk on uninstall.
*/
public function testGoogleAnalyticsUninstall()
{
$cache_path = 'public://google_analytics';
$ua_code = 'UA-123456-1';
// Show tracker in pages.
$this->config('google_analytics.settings')->set('account', $ua_code)->save();
// Enable local caching of analytics.js.
$this->config('google_analytics.settings')->set('cache', 1)->save();
// Load page to get the analytics.js downloaded into local cache.
$this->drupalGet('');
// Test if the directory and analytics.js exists.
$this->assertTrue(file_prepare_directory($cache_path), 'Cache directory "public://google_analytics" has been found.');
$this->assertTrue(file_exists($cache_path . '/analytics.js'), 'Cached analytics.js tracking file has been found.');
// Uninstall the module.
$edit = [];
$edit['uninstall[google_analytics]'] = TRUE;
$this->drupalPostForm('admin/modules/uninstall', $edit, t('Uninstall'));
$this->assertNoText(\Drupal::translation()->translate('Configuration deletions'), 'No configuration deletions listed on the module install confirmation page.');
$this->drupalPostForm(NULL, NULL, t('Uninstall'));
$this->assertText(t('The selected modules have been uninstalled.'), 'Modules status has been updated.');
// Test if the directory and all files have been removed.
$this->assertFalse(file_scan_directory($cache_path, '/.*/'), 'Cached JavaScript files have been removed.');
$this->assertFalse(file_prepare_directory($cache_path), 'Cache directory "public://google_analytics" has been removed.');
}
开发者ID:DrupalCamp-NYC,项目名称:dcnyc16,代码行数:27,代码来源:GoogleAnalyticsUninstallTest.php
注:本文中的file_scan_directory函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论