Prints lists of versions which can be deleted

@global core_renderer $OUTPUT
@global moodle_page $PAGE
422479
private function print_delete_version() {
        global $OUTPUT, $PAGE;
        $pageid = $this->page->id;

        // versioncount is the latest version
        $versioncount = wiki_count_wiki_page_versions($pageid) - 1;
        $versions = wiki_get_wiki_page_versions($pageid, 0, $versioncount);

        // We don't want version 0 to be displayed
        // version 0 is blank page
        if (end($versions)->version == 0) {
            array_pop($versions);
        }

        $contents = array();
        $version0page = wiki_get_wiki_page_version($this->page->id, 0);
        $creator = wiki_get_user_info($version0page->userid);
        $a = new stdClass();
        $a->date = userdate($this->page->timecreated, get_string('strftimedaydatetime', 'langconfig'));
        $a->username = fullname($creator);
        echo $OUTPUT->heading(get_string('createddate', 'wiki', $a), 4);
        if ($versioncount > 0) {
            /// If there is only one version, we don't need radios nor forms
            if (count($versions) == 1) {
                $row = array_shift($versions);
                $username = wiki_get_user_info($row->userid);
                $picture = $OUTPUT->user_picture($username);
                $date = userdate($row->timecreated, get_string('strftimedate', 'langconfig'));
                $time = userdate($row->timecreated, get_string('strftimetime', 'langconfig'));
                $versionid = wiki_get_version($row->id);
                $versionlink = new moodle_url('/mod/wiki/viewversion.php', array('pageid' => $pageid, 'versionid' => $versionid->id));
                $userlink = new moodle_url('/user/view.php', array('id' => $username->id, 'course' => $this->cm->course));
                $picturelink = $picture . html_writer::link($userlink->out(false), fullname($username));
                $historydate = $OUTPUT->container($date, 'wiki_histdate');
                $contents[] = array('', html_writer::link($versionlink->out(false), $row->version), $picturelink, $time, $historydate);

                //Show current version
                $table = new html_table();
                $table->head = array('', get_string('version'), get_string('user'), get_string('modified'), '');
                $table->data = $contents;

                echo html_writer::table($table);
            } else {
                $lastdate = '';
                $rowclass = array();

                foreach ($versions as $version) {
                    $user = wiki_get_user_info($version->userid);
                    $picture = $OUTPUT->user_picture($user, array('popup' => true));
                    $date = userdate($version->timecreated, get_string('strftimedate'));
                    if ($date == $lastdate) {
                        $date = '';
                        $rowclass[] = '';
                    } else {
                        $lastdate = $date;
                        $rowclass[] = 'wiki_histnewdate';
                    }

                    $time = userdate($version->timecreated, get_string('strftimetime', 'langconfig'));
                    $versionid = wiki_get_version($version->id);
                    if ($versionid) {
                        $url = new moodle_url('/mod/wiki/viewversion.php', array('pageid' => $pageid, 'versionid' => $versionid->id));
                        $viewlink = html_writer::link($url->out(false), $version->version);
                    } else {
                        $viewlink = $version->version;
                    }

                    $userlink = new moodle_url('/user/view.php', array('id' => $version->userid, 'course' => $this->cm->course));
                    $picturelink = $picture . html_writer::link($userlink->out(false), fullname($user));
                    $historydate = $OUTPUT->container($date, 'wiki_histdate');
                    $radiofromelement = $this->choose_from_radio(array($version->version  => null), 'fromversion', 'M.mod_wiki.deleteversion()', $versioncount, true);
                    $radiotoelement = $this->choose_from_radio(array($version->version  => null), 'toversion', 'M.mod_wiki.deleteversion()', $versioncount, true);
                    $contents[] = array( $radiofromelement . $radiotoelement, $viewlink, $picturelink, $time, $historydate);
                }

                $table = new html_table();
                $table->head = array(get_string('deleteversions', 'wiki'), get_string('version'), get_string('user'), get_string('modified'), '');
                $table->data = $contents;
                $table->attributes['class'] = 'table generaltable';
                $table->rowclasses = $rowclass;

                ///Print the form
                echo html_writer::start_tag('form', array('action'=>new moodle_url('/mod/wiki/admin.php'), 'method' => 'post'));
                echo html_writer::tag('div', html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'pageid', 'value' => $pageid)));
                echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'option', 'value' => $this->view));
                echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' =>  sesskey()));
                echo html_writer::table($table);
                echo html_writer::start_tag('div');
                echo html_writer::empty_tag('input', array('type' => 'submit', 'class' => 'wiki_form-button btn btn-secondary', 'value' => get_string('deleteversions', 'wiki')));
                echo html_writer::end_tag('div');
                echo html_writer::end_tag('form');
            }
        } else {
            print_string('nohistory', 'wiki');
        }
    }
1092735
public function render_data_deletion_page(data_deletion_page $page) {
        $data = $page->export_for_template($this);
        return parent::render_from_template('tool_dataprivacy/data_deletion', $data);
    }
598001
def print_version(self):
        

        if not self._version:
            return self

        if not self._title:
            print('  %s %s' % (self._name, self._version))
            return self

        print('  %s (%s %s)' % (self._title, self._name, self._version))
        return self
629943
protected static function showVersion()
    {
        \cli\line();
        \cli\line(\cli\Colors::colorize('%y+----------------------------------------------------------------------+%N'));
        \cli\line(\cli\Colors::colorize('%y| Installer                                                            |%N'));
        \cli\line(\cli\Colors::colorize('%y| Version: ' . PROJECT_INSTALLER_VERSION . '             |%N'));
        \cli\line(\cli\Colors::colorize('%y+----------------------------------------------------------------------+%N'));
    }
96950
protected function writeVersionInfo()
    {
        if (PHP_SAPI !== 'cli') {
            return;
        }

        try {
            $client = $this->config->getChecker();
            if (!$client->isLatest()) {
                $this->output->writeln(\sprintf('New version is available (current: %s, latest: %s)', self::VERSION, $client->getLatest()));
            }
        } catch (\InvalidArgumentException $e) {
            $this->output->writeln($e->getMessage());
        }
    }
614548
public function removeOldBackups()
    {
        $versions = $this->getAvailableVersions();
        if ( $this->historyLimit < count($versions) ) {

            $lastValidIndex = count($versions)-$this->historyLimit;
            if ( $lastValidIndex<=0 ) {
                return ;
            }
            $lastValidVersion = $versions[$lastValidIndex];

            foreach ($this->backupFolders as $folder) {
                $relativeFolder = $this->getPathByFlowRoot($folder);

                $lastValidBackup = $this->getFlatBackup($folder, $lastValidVersion);
                $updatedLastValidBackup = array();
                foreach ($lastValidBackup as $sha1 => $fileItem) {
                    $this->files->createDirectoryRecursively($this->createDirectoryPath([$this->localBackupTarget, $lastValidVersion, $relativeFolder]));
                    if ( $fileItem['version']!=$lastValidVersion && file_exists($this->createFilePath([$this->localBackupTarget, $fileItem['version'], $relativeFolder, $sha1 . '.file'])) ) {
                        copy(
                            $this->createFilePath([$this->localBackupTarget, $fileItem['version'], $relativeFolder, $sha1 . '.file']),
                            $this->createFilePath([$this->localBackupTarget, $lastValidVersion, $relativeFolder, $sha1 . '.file']));

                        $fileItem['version'] = $lastValidVersion;
                        file_put_contents($this->createFilePath([$this->localBackupTarget, $lastValidVersion, $relativeFolder, $sha1 . '.meta']),
                            json_encode($fileItem));
                    }
                    $updatedLastValidBackup[$sha1] = $fileItem;
                }

            }

            $this->output->outputLine('Remove old Backups..');
            $i = 0;
            $removedVersions = array();
            foreach ($versions as $version) {
                $remove = ($i<(count($versions)-$this->historyLimit)) ? true : false;
                if ($remove) {
                    $this->files->removeDirectoryRecursively($this->createDirectoryPath([$this->localBackupTarget, $version]));
                    $this->output->outputLine(' - '.$version);
                    $removedVersions[] = $versions;
                }
                $i++;
            }
            $this->output->outputLine();

            if (count($removedVersions)>0) {
                $this->emitBackupVersionsRemoved($this->output, $removedVersions);
            }
        }
    }
1101020
public static function get_all_versions() : array {
        global $CFG;

        self::init();

        $versions = array();

        // Main version first.
        $versions['core'] = self::fetch_core_version();

        // The problem here is tha the component cache might be stable,
        // we want this to work also on frontpage without resetting the component cache.
        $usecache = false;
        if (CACHE_DISABLE_ALL or (defined('IGNORE_COMPONENT_CACHE') and IGNORE_COMPONENT_CACHE)) {
            $usecache = true;
        }

        // Now all plugins.
        $plugintypes = core_component::get_plugin_types();
        foreach ($plugintypes as $type => $typedir) {
            if ($usecache) {
                $plugs = core_component::get_plugin_list($type);
            } else {
                $plugs = self::fetch_plugins($type, $typedir);
            }
            foreach ($plugs as $plug => $fullplug) {
                $plugin = new stdClass();
                $plugin->version = null;
                $module = $plugin;
                include($fullplug.'/version.php');
                $versions[$type.'_'.$plug] = $plugin->version;
            }
        }

        return $versions;
    }
677251
protected function displayReleases()
    {
        if (!$this->command) {
            return;
        }

        $key = 0;
        $rows = [];
        $releases = $this->releasesManager->getValidationFile();

        // Append the rows
        foreach ($releases as $name => $state) {
            $icon = $state ? '✓' : '✘';
            $color = $state ? 'green' : 'red';
            $date = DateTime::createFromFormat('YmdHis', $name)->format('Y-m-d H:i:s');
            $date = sprintf('<fg=%s>%s</fg=%s>', $color, $date, $color);

            // Add color to row
            $rows[] = [$key, $name, $date, $icon];
            ++$key;
        }

        // Render table
        $this->command->comment('Here are the available releases :');
        $this->command->table(
            ['#', 'Path', 'Deployed at', 'Status'],
            $rows
        );

        return $rows;
    }
1164843
def list(latest = false)
      result = []
      @os.map do |os, versions|
        unless latest
          versions.each { |version| result << {os: os, version: version}}
        else
          result << {os: os, version: versions.last} if versions.length > 0
        end
      end
      result
    end
185245
public function changes()
    {
        // Check viewability of changes
        if (!Config::inst()->get(VersionFeed::class, 'changes_enabled')
            || !$this->owner->PublicHistory
            || $this->owner->Version == ''
        ) {
            return $this->owner->httpError(404, 'Page history not viewable');
        }

        // Cache the diffs to remove DOS possibility.
        $target = $this->owner;
        $key = implode('_', array('changes', $target->ID, $target->Version));
        $entries = $this->filterContent($key, function () use ($target) {
            return $target->getDiffList(null, Config::inst()->get(VersionFeed::class, 'changes_limit'));
        });

        // Generate the output.
        $title = _t(
            'SilverStripe\\VersionFeed\\VersionFeed.SINGLEPAGEFEEDTITLE',
            'Updates to {title} page',
            ['title' => $this->owner->Title]
        );
        $rss = new RSSFeed($entries, $this->owner->request->getURL(), $title, '', 'Title', '', null);
        $rss->setTemplate('Page_changes_rss');
        return $rss->outputToBrowser();
    }
232155
def current_command_version
      output = command('version', [], false)
      version = output[/\d+\.\d+(\.\d+)+/]
      version.split('.').collect {|i| i.to_i}
    end
315419
def list_product_versions(page_size=200, page_index=0, sort="", q=""):
    
    content = list_product_versions_raw(page_size, page_index, sort, q)
    if content:
        return utils.format_json_list(content)
391629
def print_version(ctx, value):
    """"""
    if not value:
        return
    import pkg_resources
    version = None
    try:
        version = pkg_resources.get_distribution('sandman').version
    finally:
        del pkg_resources
    click.echo(version)
    ctx.exit()
1147930
def pretty_print_instance_variables
      vars = instance_variables.sort
      vars.delete :@object_list_cache
      vars.delete :@last_http_response
      vars.delete :@network_ranges
      vars.delete :@my_distribution_point
      vars.delete :@master_distribution_point
      vars
    end
565634
public function actionList($showAllVersions = false)
    {
        foreach ($this->apis as $id => $versions) {
            foreach ($versions as $version => $api) {
                if (!$showAllVersions) {
                    $this->stdout($api->name . ' - ' . $api->title . "\n");
                    break;
                } else {
                    $this->stdout($api->id . ' - ' . $api->title . "\n");
                }
            }
        }
    }
745258
public function actionDeleteAll()
    {
        Console::output('Do you want to delete all dumps? [yes|no]');
        $answer = trim(fgets(STDIN));
        if (!strncasecmp($answer, 'y', 1)) {
            if (!empty($this->getModule()->getFileList())) {
                $fail = [];
                foreach ($this->getModule()->getFileList() as $file) {
                    if (!unlink($file)) {
                        $fail[] = $file;
                    }
                }
                if (empty($fail)) {
                    Console::output('All dumps successfully removed.');
                } else {
                    Console::output('Error deleting dumps.');
                }
            }
        }
    }
130026
public function printUsage() {
        $commandList = [];

        foreach ($this->config['commands'] as $command => $commandOptions) {
            $separator = 20 - strlen($command);

            $commandList[] = '    ' . $command . str_pad(' ', $separator) .
                '<dim>' . $commandOptions['description'] . '</dim>';
        }

        sort($commandList);

        $this->log->info(
            <<< EOF
%1\$s: %3\$s

<strong>VERSION</strong>
    %4\$s

<strong>USAGE</strong>
    \$ %1\$s [COMMAND] [OPTIONS]

<strong>COMMANDS</strong>
%2\$s

    <dim># Print usage of a command:</dim>
    \$ %1\$s help COMMAND
    <dim># or:</dim>
    \$ %1\$s COMMAND --help
    <dim># List all commands:</dim>
    \$ %1\$s list

<strong>COMMON OPTIONS</strong>
    -c <u>FILE</u>,            <dim>Include settings stored in a JSON-formatted</dim>
    --config=<u>FILE</u>       <dim>configuration file FILE; repeat option for more</dim>
                        <dim>than one FILE</dim>
    -s <u>KEY=VALUE</u>,       <dim>Add runtime setting KEY with its VALUE; separate</dim>
    --setting=<u>KEY=VALUE</u> <dim>nested keys with ".", for example "key1.key2=123";</dim>
                        <dim>repeat option for more than one KEY</dim>

    --no-colors         <dim>Do not print colored messages</dim>
    -q, --quiet         <dim>Do not output messages, only errors</dim>
    -v, --verbose       <dim>Be more verbose</dim>

    -h, --help          <dim>Print this help or information about a</dim>
                        <dim>specific command</dim>
    --version           <dim>Print version information</dim>

<strong>FIRST STEPS</strong>
    <dim># %5\$s:</dim>
    %1\$s init
    <dim># %6\$s:</dim>
    %1\$s configtest
EOF
            ,
            $this->config['composer']['extra']['name'],
            implode(PHP_EOL, $commandList),
            $this->config['composer']['description'],
            $this->config['composer']['extra']['version'],
            $this->config['commands']['init']['description'],
            $this->config['commands']['configtest']['description']
        );

        return $this;
    }