/**
  * Executes this task.
  */
 public function main()
 {
     if ($this->path === null) {
         throw new BuildException('The path attribute must be specified');
     }
     $check = new AgaviModuleFilesystemCheck();
     $check->setConfigDirectory($this->project->getProperty('module.config.directory'));
     $check->setPath($this->path->getAbsolutePath());
     if (!$check->check()) {
         throw new BuildException('The path attribute must be a valid module base directory');
     }
     /* We don't know whether the module is configured or not here, so load the
      * values we want properly. */
     $this->tryLoadAgavi();
     $this->tryBootstrapAgavi();
     require_once AgaviConfigCache::checkConfig(sprintf('%s/%s/module.xml', $this->path->getAbsolutePath(), (string) $this->project->getProperty('module.config.directory')));
     $actionPath = AgaviToolkit::expandVariables(AgaviToolkit::expandDirectives(AgaviConfig::get(sprintf('modules.%s.agavi.action.path', strtolower($this->path->getName())), '%core.module_dir%/${moduleName}/actions/${actionName}Action.class.php')), array('moduleName' => $this->path->getName()));
     $pattern = '#^' . AgaviToolkit::expandVariables(str_replace('\\$\\{actionName\\}', '${actionName}', preg_quote($actionPath, '#')), array('actionName' => '(?P<action_name>.*?)')) . '$#';
     $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->path->getAbsolutePath()));
     for (; $iterator->valid(); $iterator->next()) {
         $rdi = $iterator->getInnerIterator();
         if ($rdi->isDot() || !$rdi->isFile()) {
             continue;
         }
         $file = $rdi->getPathname();
         if (preg_match($pattern, $file, $matches)) {
             $this->log(str_replace(DIRECTORY_SEPARATOR, '.', $matches['action_name']));
         }
     }
 }
 /**
  * Executes this task.
  */
 public function main()
 {
     if ($this->property === null) {
         throw new BuildException('The property attribute must be specified');
     }
     if ($this->path === null) {
         throw new BuildException('The path attribute must be specified');
     }
     $check = new AgaviModuleFilesystemCheck();
     $check->setConfigDirectory($this->project->getProperty('module.directory.config'));
     $check->setPath($this->path->getAbsolutePath());
     if (!$check->check()) {
         throw new BuildException('The path attribute must be a valid module base directory');
     }
     $actions = array();
     $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->path->getAbsolutePath() . DIRECTORY_SEPARATOR . $this->project->getProperty('module.directory.actions')));
     for (; $iterator->valid(); $iterator->next()) {
         $rdi = $iterator->getInnerIterator();
         if ($rdi->isDot() || !$rdi->isFile()) {
             continue;
         }
         $file = $rdi->getSubpathname();
         if (preg_match('#Action\\.class\\.php$#', $file)) {
             $actions[] = str_replace(DIRECTORY_SEPARATOR, '.', substr($file, 0, -16));
         }
     }
     $list = new AgaviArraytostringTransform();
     $list->setInput($actions);
     $list->setDelimiter(' ');
     $this->project->setUserProperty($this->property, $list->transform());
 }
Beispiel #3
0
 public static function suite()
 {
     $suite = new PHPUnit_Framework_TestSuite('Test Suite');
     $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(dirname(__FILE__) . '/Test'));
     for ($it->rewind(); $it->valid(); $it->next()) {
         // Something like: Test\Application\Modules\Main\Controllers\Index.php
         $path = "Test\\" . $it->getInnerIterator()->getSubPathname();
         // Replace all of the \ with _
         $className = str_replace('\\', "_", $path);
         // Take off the extension
         $className = substr($className, 0, -4);
         require_once $path;
         $suite->addTestSuite($className);
     }
     return $suite;
 }
Beispiel #4
0
<?php

$data = array(1 => 'val1', array(2 => 'val2', array(3 => 'val3')), 4 => 'val4');
$iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($data));
foreach ($iterator as $foo) {
    $key = $iterator->key();
    echo "update {$key}\n";
    var_dump($iterator->getInnerIterator());
    $iterator->offsetSet($key, 'alter');
    var_dump($iterator->getInnerIterator());
}
$copy = $iterator->getArrayCopy();
var_dump($copy);
Beispiel #5
0
 /**
  * Returns a list of files in $dir
  *
  * @return	array	List of files (including the path)
  */
 public function get_recursive_file_list()
 {
     try {
         $iterator = new \RecursiveIteratorIterator(new \phpbb\event\recursive_event_filter_iterator(new \RecursiveDirectoryIterator($this->path, \FilesystemIterator::SKIP_DOTS), $this->path), \RecursiveIteratorIterator::LEAVES_ONLY);
     } catch (\Exception $e) {
         return array();
     }
     $files = array();
     foreach ($iterator as $file_info) {
         /** @var \RecursiveDirectoryIterator $file_info */
         $relative_path = $iterator->getInnerIterator()->getSubPathname();
         $files[] = str_replace(DIRECTORY_SEPARATOR, '/', $relative_path);
     }
     return $files;
 }
Beispiel #6
0
 /**
  * Retrieves a list of all available extensions on the filesystem
  *
  * @return array An array with extension names as keys and paths to the
  *               extension as values
  */
 public function all_available()
 {
     $available = array();
     if (!is_dir($this->phpbb_root_path . 'ext/')) {
         return $available;
     }
     $iterator = new \RecursiveIteratorIterator(new \phpbb\recursive_dot_prefix_filter_iterator(new \RecursiveDirectoryIterator($this->phpbb_root_path . 'ext/', \FilesystemIterator::NEW_CURRENT_AND_KEY | \FilesystemIterator::FOLLOW_SYMLINKS)), \RecursiveIteratorIterator::SELF_FIRST);
     $iterator->setMaxDepth(2);
     foreach ($iterator as $file_info) {
         if ($file_info->isFile() && $file_info->getFilename() == 'composer.json') {
             $ext_name = $iterator->getInnerIterator()->getSubPath();
             $composer_file = $iterator->getPath() . '/composer.json';
             // Ignore the extension if there is no composer.json.
             if (!is_readable($composer_file) || !($ext_info = file_get_contents($composer_file))) {
                 continue;
             }
             $ext_info = json_decode($ext_info, true);
             $ext_name = str_replace(DIRECTORY_SEPARATOR, '/', $ext_name);
             // Ignore the extension if directory depth is not correct or if the directory structure
             // does not match the name value specified in composer.json.
             if (substr_count($ext_name, '/') !== 1 || !isset($ext_info['name']) || $ext_name != $ext_info['name']) {
                 continue;
             }
             $available[$ext_name] = $this->phpbb_root_path . 'ext/' . $ext_name . '/';
         }
     }
     ksort($available);
     return $available;
 }
<?php

$ar = array(1, 2, array(31, 32, array(331)), 4);
$it = new RecursiveArrayIterator($ar);
$it = new RecursiveCachingIterator($it);
$it = new RecursiveIteratorIterator($it);
foreach ($it as $k => $v) {
    echo "{$k}=>{$v}\n";
    echo "hasNext: " . ($it->getInnerIterator()->hasNext() ? "yes" : "no") . "\n";
}
?>
===DONE===
Beispiel #8
0
    function main($id, $mode)
    {
        global $config, $db, $user, $template, $phpbb_log, $phpbb_container;
        global $phpbb_root_path, $phpEx, $request;
        if (!function_exists('validate_language_iso_name')) {
            include $phpbb_root_path . 'includes/functions_user.' . $phpEx;
        }
        // Check and set some common vars
        $action = isset($_POST['update_details']) ? 'update_details' : '';
        $action = isset($_POST['remove_store']) ? 'details' : $action;
        $submit = empty($action) && !isset($_POST['update']) && !isset($_POST['test_connection']) ? false : true;
        $action = empty($action) ? $request->variable('action', '') : $action;
        $form_name = 'acp_lang';
        add_form_key('acp_lang');
        $lang_id = $request->variable('id', 0);
        $selected_lang_file = $request->variable('language_file', '|common.' . $phpEx);
        list($this->language_directory, $this->language_file) = explode('|', $selected_lang_file);
        $this->language_directory = basename($this->language_directory);
        $this->language_file = basename($this->language_file);
        $user->add_lang('acp/language');
        $this->tpl_name = 'acp_language';
        $this->page_title = 'ACP_LANGUAGE_PACKS';
        switch ($action) {
            case 'update_details':
                if (!$submit || !check_form_key($form_name)) {
                    trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
                }
                if (!$lang_id) {
                    trigger_error($user->lang['NO_LANG_ID'] . adm_back_link($this->u_action), E_USER_WARNING);
                }
                $sql = 'SELECT *
					FROM ' . LANG_TABLE . "\n\t\t\t\t\tWHERE lang_id = {$lang_id}";
                $result = $db->sql_query($sql);
                $row = $db->sql_fetchrow($result);
                $db->sql_freeresult($result);
                $sql_ary = array('lang_english_name' => $request->variable('lang_english_name', $row['lang_english_name']), 'lang_local_name' => $request->variable('lang_local_name', $row['lang_local_name'], true), 'lang_author' => $request->variable('lang_author', $row['lang_author'], true));
                $db->sql_query('UPDATE ' . LANG_TABLE . '
					SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
					WHERE lang_id = ' . $lang_id);
                $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_LANGUAGE_PACK_UPDATED', false, array($sql_ary['lang_english_name']));
                trigger_error($user->lang['LANGUAGE_DETAILS_UPDATED'] . adm_back_link($this->u_action));
                break;
            case 'details':
                if (!$lang_id) {
                    trigger_error($user->lang['NO_LANG_ID'] . adm_back_link($this->u_action), E_USER_WARNING);
                }
                $this->page_title = 'LANGUAGE_PACK_DETAILS';
                $sql = 'SELECT *
					FROM ' . LANG_TABLE . '
					WHERE lang_id = ' . $lang_id;
                $result = $db->sql_query($sql);
                $lang_entries = $db->sql_fetchrow($result);
                $db->sql_freeresult($result);
                if (!$lang_entries) {
                    trigger_error($user->lang['LANGUAGE_PACK_NOT_EXIST'] . adm_back_link($this->u_action), E_USER_WARNING);
                }
                $lang_iso = $lang_entries['lang_iso'];
                $template->assign_vars(array('S_DETAILS' => true, 'U_ACTION' => $this->u_action . "&amp;action=details&amp;id={$lang_id}", 'U_BACK' => $this->u_action, 'LANG_LOCAL_NAME' => $lang_entries['lang_local_name'], 'LANG_ENGLISH_NAME' => $lang_entries['lang_english_name'], 'LANG_ISO' => $lang_iso, 'LANG_AUTHOR' => $lang_entries['lang_author'], 'L_MISSING_FILES' => $user->lang('THOSE_MISSING_LANG_FILES', $lang_entries['lang_local_name']), 'L_MISSING_VARS_EXPLAIN' => $user->lang('THOSE_MISSING_LANG_VARIABLES', $lang_entries['lang_local_name'])));
                // If current lang is different from the default lang, then highlight missing files and variables
                if ($lang_iso != $config['default_lang']) {
                    try {
                        $iterator = new \RecursiveIteratorIterator(new \phpbb\recursive_dot_prefix_filter_iterator(new \RecursiveDirectoryIterator($phpbb_root_path . 'language/' . $config['default_lang'] . '/', \FilesystemIterator::SKIP_DOTS)), \RecursiveIteratorIterator::LEAVES_ONLY);
                    } catch (\Exception $e) {
                        return array();
                    }
                    foreach ($iterator as $file_info) {
                        /** @var \RecursiveDirectoryIterator $file_info */
                        $relative_path = $iterator->getInnerIterator()->getSubPathname();
                        $relative_path = str_replace(DIRECTORY_SEPARATOR, '/', $relative_path);
                        if (file_exists($phpbb_root_path . 'language/' . $lang_iso . '/' . $relative_path)) {
                            if (substr($relative_path, 0 - strlen($phpEx)) === $phpEx) {
                                $missing_vars = $this->compare_language_files($config['default_lang'], $lang_iso, $relative_path);
                                if (!empty($missing_vars)) {
                                    $template->assign_block_vars('missing_varfile', array('FILE_NAME' => $relative_path));
                                    foreach ($missing_vars as $var) {
                                        $template->assign_block_vars('missing_varfile.variable', array('VAR_NAME' => $var));
                                    }
                                }
                            }
                        } else {
                            $template->assign_block_vars('missing_files', array('FILE_NAME' => $relative_path));
                        }
                    }
                }
                return;
                break;
            case 'delete':
                if (!$lang_id) {
                    trigger_error($user->lang['NO_LANG_ID'] . adm_back_link($this->u_action), E_USER_WARNING);
                }
                $sql = 'SELECT *
					FROM ' . LANG_TABLE . '
					WHERE lang_id = ' . $lang_id;
                $result = $db->sql_query($sql);
                $row = $db->sql_fetchrow($result);
                $db->sql_freeresult($result);
                if ($row['lang_iso'] == $config['default_lang']) {
                    trigger_error($user->lang['NO_REMOVE_DEFAULT_LANG'] . adm_back_link($this->u_action), E_USER_WARNING);
                }
                if (confirm_box(true)) {
                    $db->sql_query('DELETE FROM ' . LANG_TABLE . ' WHERE lang_id = ' . $lang_id);
                    $sql = 'UPDATE ' . USERS_TABLE . "\n\t\t\t\t\t\tSET user_lang = '" . $db->sql_escape($config['default_lang']) . "'\n\t\t\t\t\t\tWHERE user_lang = '" . $db->sql_escape($row['lang_iso']) . "'";
                    $db->sql_query($sql);
                    // We also need to remove the translated entries for custom profile fields - we want clean tables, don't we?
                    $sql = 'DELETE FROM ' . PROFILE_LANG_TABLE . ' WHERE lang_id = ' . $lang_id;
                    $db->sql_query($sql);
                    $sql = 'DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . ' WHERE lang_id = ' . $lang_id;
                    $db->sql_query($sql);
                    $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_LANGUAGE_PACK_DELETED', false, array($row['lang_english_name']));
                    trigger_error(sprintf($user->lang['LANGUAGE_PACK_DELETED'], $row['lang_english_name']) . adm_back_link($this->u_action));
                } else {
                    $s_hidden_fields = array('i' => $id, 'mode' => $mode, 'action' => $action, 'id' => $lang_id);
                    confirm_box(false, $user->lang('DELETE_LANGUAGE_CONFIRM', $row['lang_english_name']), build_hidden_fields($s_hidden_fields));
                }
                break;
            case 'install':
                $lang_iso = $request->variable('iso', '');
                $lang_iso = basename($lang_iso);
                if (!$lang_iso || !file_exists("{$phpbb_root_path}language/{$lang_iso}/iso.txt")) {
                    trigger_error($user->lang['LANGUAGE_PACK_NOT_EXIST'] . adm_back_link($this->u_action), E_USER_WARNING);
                }
                $file = file("{$phpbb_root_path}language/{$lang_iso}/iso.txt");
                $lang_pack = array('iso' => $lang_iso, 'name' => trim(htmlspecialchars($file[0])), 'local_name' => trim(htmlspecialchars($file[1], ENT_COMPAT, 'UTF-8')), 'author' => trim(htmlspecialchars($file[2], ENT_COMPAT, 'UTF-8')));
                unset($file);
                $sql = 'SELECT lang_iso
					FROM ' . LANG_TABLE . "\n\t\t\t\t\tWHERE lang_iso = '" . $db->sql_escape($lang_iso) . "'";
                $result = $db->sql_query($sql);
                $row = $db->sql_fetchrow($result);
                $db->sql_freeresult($result);
                if ($row) {
                    trigger_error($user->lang['LANGUAGE_PACK_ALREADY_INSTALLED'] . adm_back_link($this->u_action), E_USER_WARNING);
                }
                if (!$lang_pack['name'] || !$lang_pack['local_name']) {
                    trigger_error($user->lang['INVALID_LANGUAGE_PACK'] . adm_back_link($this->u_action), E_USER_WARNING);
                }
                // Add language pack
                $sql_ary = array('lang_iso' => $lang_pack['iso'], 'lang_dir' => $lang_pack['iso'], 'lang_english_name' => $lang_pack['name'], 'lang_local_name' => $lang_pack['local_name'], 'lang_author' => $lang_pack['author']);
                $db->sql_query('INSERT INTO ' . LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));
                $lang_id = $db->sql_nextid();
                // Now let's copy the default language entries for custom profile fields for this new language - makes admin's life easier.
                $sql = 'SELECT lang_id
					FROM ' . LANG_TABLE . "\n\t\t\t\t\tWHERE lang_iso = '" . $db->sql_escape($config['default_lang']) . "'";
                $result = $db->sql_query($sql);
                $default_lang_id = (int) $db->sql_fetchfield('lang_id');
                $db->sql_freeresult($result);
                // We want to notify the admin that custom profile fields need to be updated for the new language.
                $notify_cpf_update = false;
                // From the mysql documentation:
                // Prior to MySQL 4.0.14, the target table of the INSERT statement cannot appear in the FROM clause of the SELECT part of the query. This limitation is lifted in 4.0.14.
                // Due to this we stay on the safe side if we do the insertion "the manual way"
                $sql = 'SELECT field_id, lang_name, lang_explain, lang_default_value
					FROM ' . PROFILE_LANG_TABLE . '
					WHERE lang_id = ' . $default_lang_id;
                $result = $db->sql_query($sql);
                while ($row = $db->sql_fetchrow($result)) {
                    $row['lang_id'] = $lang_id;
                    $db->sql_query('INSERT INTO ' . PROFILE_LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $row));
                    $notify_cpf_update = true;
                }
                $db->sql_freeresult($result);
                $sql = 'SELECT field_id, option_id, field_type, lang_value
					FROM ' . PROFILE_FIELDS_LANG_TABLE . '
					WHERE lang_id = ' . $default_lang_id;
                $result = $db->sql_query($sql);
                while ($row = $db->sql_fetchrow($result)) {
                    $row['lang_id'] = $lang_id;
                    $db->sql_query('INSERT INTO ' . PROFILE_FIELDS_LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $row));
                    $notify_cpf_update = true;
                }
                $db->sql_freeresult($result);
                $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_LANGUAGE_PACK_INSTALLED', false, array($lang_pack['name']));
                $message = sprintf($user->lang['LANGUAGE_PACK_INSTALLED'], $lang_pack['name']);
                $message .= $notify_cpf_update ? '<br /><br />' . $user->lang['LANGUAGE_PACK_CPF_UPDATE'] : '';
                trigger_error($message . adm_back_link($this->u_action));
                break;
        }
        $sql = 'SELECT user_lang, COUNT(user_lang) AS lang_count
			FROM ' . USERS_TABLE . '
			GROUP BY user_lang';
        $result = $db->sql_query($sql);
        $lang_count = array();
        while ($row = $db->sql_fetchrow($result)) {
            $lang_count[$row['user_lang']] = $row['lang_count'];
        }
        $db->sql_freeresult($result);
        $sql = 'SELECT *
			FROM ' . LANG_TABLE . '
			ORDER BY lang_english_name';
        $result = $db->sql_query($sql);
        $installed = array();
        while ($row = $db->sql_fetchrow($result)) {
            $installed[] = $row['lang_iso'];
            $tagstyle = $row['lang_iso'] == $config['default_lang'] ? '*' : '';
            $template->assign_block_vars('lang', array('U_DETAILS' => $this->u_action . "&amp;action=details&amp;id={$row['lang_id']}", 'U_DOWNLOAD' => $this->u_action . "&amp;action=download&amp;id={$row['lang_id']}", 'U_DELETE' => $this->u_action . "&amp;action=delete&amp;id={$row['lang_id']}", 'ENGLISH_NAME' => $row['lang_english_name'], 'TAG' => $tagstyle, 'LOCAL_NAME' => $row['lang_local_name'], 'ISO' => $row['lang_iso'], 'USED_BY' => isset($lang_count[$row['lang_iso']]) ? $lang_count[$row['lang_iso']] : 0));
        }
        $db->sql_freeresult($result);
        $new_ary = $iso = array();
        /** @var \phpbb\language\language_file_helper $language_helper */
        $language_helper = $phpbb_container->get('language.helper.language_file');
        $iso = $language_helper->get_available_languages();
        foreach ($iso as $lang_array) {
            $lang_iso = $lang_array['iso'];
            if (!in_array($lang_iso, $installed)) {
                $new_ary[$lang_iso] = $lang_array;
            }
        }
        unset($installed);
        if (sizeof($new_ary)) {
            foreach ($new_ary as $iso => $lang_ary) {
                $template->assign_block_vars('notinst', array('ISO' => htmlspecialchars($lang_ary['iso']), 'LOCAL_NAME' => htmlspecialchars($lang_ary['local_name'], ENT_COMPAT, 'UTF-8'), 'NAME' => htmlspecialchars($lang_ary['name'], ENT_COMPAT, 'UTF-8'), 'U_INSTALL' => $this->u_action . '&amp;action=install&amp;iso=' . urlencode($lang_ary['iso'])));
            }
        }
        unset($new_ary);
    }
Beispiel #9
0
 /**
  * Finds all file system entries matching the configured options from
  * an array of paths
  *
  * @param array $extensions Array of extensions (name => full relative path)
  * @param bool $cache Whether the result should be cached
  * @param bool $is_dir Directories will be returned when true, only files
  *                     otherwise
  * @return array An array of paths to found items
  */
 public function find_from_paths($extensions, $cache = true, $is_dir = false)
 {
     $this->query['is_dir'] = $is_dir;
     $query = md5(serialize($this->query) . serialize($extensions));
     if (!defined('DEBUG') && $cache && isset($this->cached_queries[$query])) {
         return $this->cached_queries[$query];
     }
     $files = array();
     foreach ($extensions as $name => $path) {
         $ext_name = $name;
         if (!file_exists($path)) {
             continue;
         }
         if ($name === '/') {
             $location = $this->query['core_path'];
             $name = '';
             $suffix = $this->query['core_suffix'];
             $prefix = $this->query['core_prefix'];
             $directory = $this->query['core_directory'];
         } else {
             $location = 'ext/';
             $name .= '/';
             $suffix = $this->query['extension_suffix'];
             $prefix = $this->query['extension_prefix'];
             $directory = $this->query['extension_directory'];
         }
         // match only first directory if leading slash is given
         if ($directory === '/') {
             $directory_pattern = '^' . preg_quote(DIRECTORY_SEPARATOR, '#');
         } else {
             if ($directory && $directory[0] === '/') {
                 if (!$is_dir) {
                     $path .= substr($directory, 1);
                 }
                 $directory_pattern = '^' . preg_quote(str_replace('/', DIRECTORY_SEPARATOR, $directory) . DIRECTORY_SEPARATOR, '#');
             } else {
                 $directory_pattern = preg_quote(DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $directory) . DIRECTORY_SEPARATOR, '#');
             }
         }
         if ($is_dir) {
             $directory_pattern .= '$';
         }
         $directory_pattern = '#' . $directory_pattern . '#';
         if (is_dir($path)) {
             $iterator = new \RecursiveIteratorIterator(new \phpbb\recursive_dot_prefix_filter_iterator(new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS)), \RecursiveIteratorIterator::SELF_FIRST);
             foreach ($iterator as $file_info) {
                 $filename = $file_info->getFilename();
                 if ($file_info->isDir() == $is_dir) {
                     if ($is_dir) {
                         $relative_path = $iterator->getInnerIterator()->getSubPath() . DIRECTORY_SEPARATOR . basename($filename) . DIRECTORY_SEPARATOR;
                         if ($relative_path[0] !== DIRECTORY_SEPARATOR) {
                             $relative_path = DIRECTORY_SEPARATOR . $relative_path;
                         }
                     } else {
                         $relative_path = $iterator->getInnerIterator()->getSubPathname();
                         if ($directory && $directory[0] === '/') {
                             $relative_path = str_replace('/', DIRECTORY_SEPARATOR, $directory) . DIRECTORY_SEPARATOR . $relative_path;
                         } else {
                             $relative_path = DIRECTORY_SEPARATOR . $relative_path;
                         }
                     }
                     if ((!$suffix || substr($relative_path, -strlen($suffix)) === $suffix) && (!$prefix || substr($filename, 0, strlen($prefix)) === $prefix) && (!$directory || preg_match($directory_pattern, $relative_path))) {
                         $files[] = array('named_path' => str_replace(DIRECTORY_SEPARATOR, '/', $location . $name . substr($relative_path, 1)), 'ext_name' => $ext_name, 'path' => str_replace(array(DIRECTORY_SEPARATOR, $this->phpbb_root_path), array('/', ''), $file_info->getPath()) . '/', 'filename' => $filename);
                     }
                 }
             }
         }
     }
     if ($cache && $this->cache) {
         $this->cached_queries[$query] = $files;
         $this->cache->put($this->cache_name, $this->cached_queries);
     }
     return $files;
 }
Beispiel #10
0
 /**
  * Returns a list of files in $dir
  *
  * Works recursive with any depth
  *
  * @param	string	$dir	Directory to go through
  * @return	array	List of files (including directories)
  */
 public function get_recursive_file_list($dir)
 {
     try {
         $iterator = new \RecursiveIteratorIterator(new \src\recursive_dot_prefix_filter_iterator(new \RecursiveDirectoryIterator($dir, \FilesystemIterator::SKIP_DOTS)), \RecursiveIteratorIterator::SELF_FIRST);
     } catch (\Exception $e) {
         return array();
     }
     $files = array();
     foreach ($iterator as $file_info) {
         /** @var \RecursiveDirectoryIterator $file_info */
         if ($file_info->isDir()) {
             continue;
         }
         $relative_path = $iterator->getInnerIterator()->getSubPathname();
         if (substr($relative_path, -5) == '.html') {
             $files[] = str_replace(DIRECTORY_SEPARATOR, '/', $relative_path);
         }
     }
     return $files;
 }
$demoModpubPath = dirname(__FILE__) . '/demo/pub/modpub';
# Dev
$modpubPath = dirname(__FILE__) . '/modpub';
# Remove all files and directories from demo
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($demoModpubPath), RecursiveIteratorIterator::CHILD_FIRST);
for (; $iterator->valid(); $iterator->next()) {
    $rdi = $iterator->getInnerIterator();
    if (strpos($rdi->getSubpathname(), '.svn') !== false || $iterator->isDot()) {
        continue;
    }
    if ($rdi->isFile()) {
        unlink($rdi->getPathname());
    } else {
        rmdir($rdi->getPathname());
    }
}
# Create our ADT dir in modpub :)
mkdir($demoModpubPath . '/Adt');
# Copy and paste all needed files from dev to demo
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($modpubPath), RecursiveIteratorIterator::SELF_FIRST);
for (; $iterator->valid(); $iterator->next()) {
    $rdi = $iterator->getInnerIterator();
    if (strpos($rdi->getSubpathname(), '.svn') !== false || $iterator->isDot()) {
        continue;
    }
    if ($rdi->isDir()) {
        mkdir($demoModpubPath . '/Adt/' . $rdi->getSubPathname());
    } else {
        copy($rdi->getPathname(), $demoModpubPath . '/Adt/' . $rdi->getSubPathname());
    }
}