Exemplo n.º 1
0
 /**
  * Handles GET requests for the import page.
  */
 public function get_import()
 {
     // First check for plugins that provide troublseome features
     $features_present = Plugins::provided();
     $troublemakers = array();
     $bad_features = array('ping', 'pingback', 'spamcheck');
     $unwanted_features = array_intersect_key($features_present, array_flip($bad_features));
     array_walk($unwanted_features, function ($item, $key) use(&$troublemakers) {
         foreach ($item as $current) {
             if (!in_array($current, $troublemakers)) {
                 $troublemakers[] = $current;
             }
         }
     });
     if (count($troublemakers)) {
         $troublemakers = implode(', ', $troublemakers);
         $msg = _t('Plugins that conflict with importing are active. To prevent undesirable consequences, please de-activate the following plugins until the import is finished: ') . '<br>';
         $msg .= $troublemakers;
         $this->theme->conflicting_plugins = $msg;
         Session::error($msg);
     }
     // Now get on with creating the page
     $importer = isset($_POST['importer']) ? $_POST['importer'] : '';
     $stage = isset($_POST['stage']) ? $_POST['stage'] : '1';
     $step = isset($_POST['step']) ? $_POST['step'] : '1';
     //		$this->theme->enctype = Plugins::filter( 'import_form_enctype', 'application/x-www-form-urlencoded', $importer, $stage, $step );
     // filter to get registered importers
     $importers = Plugins::filter('import_names', array());
     // filter to get the output of the current importer, if one is running
     if ($importer == '') {
         $output = $this->get_form($importers, $importer);
     } else {
         $output = Plugins::filter('import_stage', '', $importer, $stage, $step);
     }
     $this->theme->importer = $importer;
     $this->theme->stage = $stage;
     $this->theme->step = $step;
     $this->theme->importers = $importers;
     $this->theme->output = $output;
     $this->display('import');
 }
Exemplo n.º 2
0
 /**
  * Ensure that a theme meets requirements for activation/preview
  * @static
  * @param string $theme_dir the directory of the theme
  * @return bool True if the theme meets all requirements
  */
 public static function validate_theme($theme_dir)
 {
     $all_themes = Themes::get_all_data();
     // @todo Make this a closure in php 5.3
     $theme_names = Utils::array_map_field($all_themes, 'name');
     $theme_data = $all_themes[$theme_dir];
     $ok = true;
     if (isset($theme_data['info']->parent) && !in_array((string) $theme_data['info']->parent, $theme_names)) {
         Session::error(_t('This theme requires the parent theme named "%s" to be present prior to activation.', array($theme_data['info']->parent)));
         $ok = false;
     }
     if (isset($theme_data['info']->requires)) {
         $provided = Plugins::provided();
         foreach ($theme_data['info']->requires->feature as $requirement) {
             if (!isset($provided[(string) $requirement])) {
                 Session::error(_t('This theme requires the feature "<a href="%2$s">%1$s</a>" to be present prior to activation.', array((string) $requirement, $requirement['url'])));
                 $ok = false;
             }
         }
     }
     return $ok;
 }