本文整理匯總了PHP中FileHelper::get_file_meta方法的典型用法代碼示例。如果您正苦於以下問題:PHP FileHelper::get_file_meta方法的具體用法?PHP FileHelper::get_file_meta怎麽用?PHP FileHelper::get_file_meta使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類FileHelper
的用法示例。
在下文中一共展示了FileHelper::get_file_meta方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: ElementSync
$element_sync = new ElementSync($modx, $element_sync_file);
$element_types = array('modTemplate' => $modx->getOption('elementhelper.template_path', null, 'site/elements/templates/'), 'modChunk' => $modx->getOption('elementhelper.chunk_path', null, 'site/elements/chunks/'), 'modSnippet' => $modx->getOption('elementhelper.snippet_path', null, 'site/elements/snippets/'), 'modPlugin' => $modx->getOption('elementhelper.plugin_path', null, 'site/elements/plugins/'));
$category_whitelist = array_map('trim', explode(',', $modx->getOption('elementhelper.category_whitelist', null, '')));
$element_blacklist = array_map('trim', explode(',', $modx->getOption('elementhelper.element_blacklist', null, '')));
// Loop through the element types
foreach ($element_types as $type => $type_path) {
$log_prefix = sprintf('[ElementHelper] %s: ', $type);
$file_list = FileHelper::get_directory_file_list(MODX_BASE_PATH . $type_path);
// Move onto the next element type if it has no files
if (empty($file_list)) {
$modx->log(MODX_LOG_LEVEL_INFO, $log_prefix . 'No files.');
continue;
}
// Process the files for this element type
foreach ($file_list as $file_path) {
$file = FileHelper::get_file_meta($file_path);
$element = Element::get($modx, $type, $file['name']);
// If the file is not in the sync
if (!$element_sync->has_element($type, $file['name'])) {
// If the element doesn't exist
if (!$element) {
// Create the element
$element = Element::create($modx, $type, $file['name']);
// If the element is created successfully set it's properties and then add it to the sync
if ($element) {
$properties = $element_helper->get_file_element_properties($type_path, $file_path);
if ($element->set_properties($properties)) {
$element_sync->add_element($type, $file['name'], $file['mod_time']);
}
}
} else {