Wicked_Page::previousVersion PHP Method

previousVersion() public method

Returns the previous version number for this page.
public previousVersion ( ) : string
return string A string containing the previous version or null if this is the first version.
    public function previousVersion()
    {
        global $wicked;
        $this->version();
        $history = $wicked->getHistory($this->pageName());
        if (count($history) == 0) {
            return null;
        }
        if ($this->isOld()) {
            for ($i = 0; $i < count($history); $i++) {
                if ($history[$i]['page_version'] == $this->version()) {
                    if ($i + 1 < count($history)) {
                        $i++;
                        break;
                    } else {
                        return null;
                    }
                }
            }
            if ($i == count($history)) {
                return null;
            }
        } else {
            $i = 0;
        }
        return $history[$i]['page_version'];
    }