Esempio n. 1
0
 public static function getRoutes($path)
 {
     $routes = new \Symfony\Component\Routing\RouteCollection();
     $finder = new \Symfony\Component\Finder\Finder();
     $finder->name('*.php');
     $finder->files()->in($path);
     if (!$finder->count()) {
         throw new Exception('No routes found in ' . $path);
     }
     foreach ($finder as $entry) {
         $route_path = $entry->getRelativePath();
         $basename = $entry->getBasename('.php');
         $cleaned = str_replace('/', '_', str_replace('-', '_', $route_path . $basename));
         $route = $route_path . ($basename === 'index' ? '' : '/' . $basename);
         /*
                    if (strrchr($route, '-')) {
                        $sluglen = strlen(strrchr($route, '-'));
                        $route2 = substr($route, 0, strlen($route) - $sluglen + 1) . '{slug}';
                        $basename2 = substr($basename, 0, $basename - $sluglen + 1);
                    } else {
                        $route2 = $route;
                        $basename2 = $basename;
                    }
         */
         $routes->add($cleaned, new \Symfony\Component\Routing\Route($route, ['_controller' => 'build', 'php_file' => $entry->getRealPath(), 'file_root' => $route_path . '/' . $basename, 'name' => '.+']));
         $routes->add('slash' . $cleaned, new \Symfony\Component\Routing\Route($route . '/', ['_controller' => 'build', 'php_file' => $entry->getRealPath(), 'file_root' => $route_path . '/' . $basename, 'name' => '.+']));
     }
     return $routes;
 }
 public static function exist($libraryName, $includeDirs = [])
 {
     $finder = new \Symfony\Component\Finder\Finder();
     $finder->files()->name($libraryName)->in($includeDirs);
     return 0 != $finder->count();
 }
Esempio n. 3
0
 /**
  * Run AutoMOD test.
  *
  * @param \phpbb\titania\entity\package $package
  * @param string $phpbb_path Path to phpBB files we run the test on
  * @param string $details Will hold the details of the mod
  * @param string $results Will hold the results for output
  * @param string $bbcode_results Will hold the results for storage
  * @return bool true on success, false on failure
  */
 public function run_automod_test($package, $phpbb_path, &$details, &$results, &$bbcode_results)
 {
     require $this->phpbb_root_path . 'includes/functions_transfer.' . $this->php_ext;
     require $this->phpbb_root_path . 'includes/functions_admin.' . $this->php_ext;
     require $this->ext_root_path . 'includes/library/automod/acp_mods.' . $this->php_ext;
     require $this->ext_root_path . 'includes/library/automod/editor.' . $this->php_ext;
     require $this->ext_root_path . 'includes/library/automod/mod_parser.' . $this->php_ext;
     require $this->ext_root_path . 'includes/library/automod/functions_mods.' . $this->php_ext;
     $this->user->add_lang_ext('phpbb/titania', 'automod');
     // Find the main modx file
     $modx_root = $package->find_directory(array('files' => array('required' => 'install*.xml')));
     if ($modx_root === null) {
         $this->user->add_lang_ext('phpbb/titania', 'contributions');
         $this->errors[] = $this->user->lang['COULD_NOT_FIND_ROOT'];
         return false;
     }
     $modx_root = $package->get_temp_path() . '/' . $modx_root . '/';
     $modx_file = false;
     if (file_exists($modx_root . 'install.xml')) {
         $modx_file = $modx_root . 'install.xml';
     } else {
         $finder = new \Symfony\Component\Finder\Finder();
         $finder->name('install*.xml')->depth(0)->in($modx_root);
         if ($finder->count()) {
             foreach ($finder as $file) {
                 $modx_file = $file->getPathname();
                 break;
             }
         }
     }
     if (!$modx_file) {
         $this->user->add_lang_ext('phpbb/titania', 'contributions');
         $this->errors[] = $this->user->lang['COULD_NOT_FIND_ROOT'];
         return false;
     }
     // HAX
     global $phpbb_root_path;
     $phpbb_root_path = $phpbb_path;
     // The real stuff
     $acp_mods = new \acp_mods();
     $acp_mods->mods_dir = $this->ext_config->__get('contrib_temp_path');
     $acp_mods->mod_root = $modx_root;
     $editor = new \editor_direct();
     $details = $acp_mods->mod_details($modx_file, false);
     $actions = $acp_mods->mod_actions($modx_file);
     $installed = $acp_mods->process_edits($editor, $actions, $details, false, true, false);
     // Reverse HAX
     $phpbb_root_path = $this->phpbb_root_path;
     $this->template->set_filenames(array('automod' => 'contributions/automod.html', 'automod_bbcode' => 'contributions/automod_bbcode.html'));
     $this->template->assign_var('S_AUTOMOD_SUCCESS', $installed);
     $results = $this->template->assign_display('automod');
     $bbcode_results = $this->template->assign_display('automod_bbcode');
     return $installed;
 }