コード例 #1
0
function readDirFilesRecursive($dir, $ignorepath = false)
{
    $d = dir($dir);
    $files = array();
    while (false !== ($f = $d->read())) {
        if ($f[0] == '.') {
            continue;
        }
        $path = $dir . DIRECTORY_SEPARATOR . $f;
        if (is_dir($path)) {
            $files = array_merge($files, readDirFilesRecursive($path, $ignorepath));
        } else {
            $files[] = $ignorepath ? $f : $path;
        }
    }
    return $files;
}
コード例 #2
0
 /**
  * Display the page for managing installations
  * @see lib/Page#run()
  */
 function run()
 {
     global $USER, $CONFIG, $Templates, $SITE, $Controller;
     if (!$this->may($USER, READ)) {
         return;
     }
     $_REQUEST->setType('place', 'numeric');
     $_REQUEST->setType('parent', 'numeric');
     $_REQUEST->setType('reinstall', 'string');
     $_REQUEST->setType('new', 'string');
     if ($this->mayI(EDIT)) {
         if ($_REQUEST['reinstall']) {
             $this->reinstall($_REQUEST['reinstall']);
             Flash::create($_REQUEST['reinstall'] . ' ' . __('was reinstalled'));
         } elseif ($_REQUEST['new']) {
             $class = $_REQUEST['new'];
             if (validInclude($class) && ($class == 'MenuItem' || @is_subclass_of($class, 'MenuItem')) && $Controller->menuEditor->mayI(EDIT)) {
                 $obj = $Controller->newObj($class);
                 $obj->move($_REQUEST['place'] ? $_REQUEST['place'] : 'last', $_REQUEST['parent']);
                 Flash::queue(__('New') . ' ' . $class . ' ' . __('installed'));
                 redirect(url(array('id' => 'menuEditor')));
             }
             unset($class);
         }
     }
     $installed = $CONFIG->base->installed;
     $dir = 'plugins';
     $fullpath = ROOTDIR . DIRECTORY_SEPARATOR . $dir;
     $entries = readDirFilesRecursive($fullpath, true);
     natcasesort($entries);
     $i = 0;
     $c = array();
     foreach ($entries as $entry) {
         if (substr($entry, -4) == '.php') {
             $class = substr($entry, false, -4);
             $methods = class_exists($class) ? get_class_methods($class) : array();
             $c[] = '<span class="fixed-width">' . $class . '</span><div class="tools">' . ($this->may($USER, EDIT) && (@in_array('installable', $methods) && @in_array('install', $methods) && call_user_func(array($class, 'installable')) == $class) ? icon('small/arrow_refresh_small', __('Reinstall'), url(array('reinstall' => $class), array('id'))) : '') . (($class == 'MenuItem' || @is_subclass_of($class, 'MenuItem')) && $Controller->menuEditor->may($USER, EDIT) ? icon('small/add', __('Add new instance to menu'), url(array('new' => $class), array('id'))) : '') . '</div>';
         }
     }
     $this->setContent('header', __('Installer'));
     $this->setContent('main', listify($c));
     $Templates->admin->render();
 }