/** * Check the status of the Onpub schema. * * @return mixed The version of the schema in the database as an int. An array * of PDOException objects will be returned if the schema is incomplete or * not installed. */ public function status() { $oaamaps = new OnpubAAMaps($this->pdo); $oarticles = new OnpubArticles($this->pdo); $oauthors = new OnpubAuthors($this->pdo); $oimages = new OnpubImages($this->pdo); $osamaps = new OnpubSAMaps($this->pdo); $osections = new OnpubSections($this->pdo); $owebsites = new OnpubWebsites($this->pdo); $owsmaps = new OnpubWSMaps($this->pdo); $queryOptions = new OnpubQueryOptions($this->pdo); $queryOptions->setPage(1, 1); $exceptions = array(); $version = 0; try { $oaamaps->select($queryOptions); } catch (PDOException $e) { $exceptions[] = $e; } try { $oarticles->select($queryOptions); } catch (PDOException $e) { $exceptions[] = $e; } try { $oauthors->select($queryOptions); } catch (PDOException $e) { $exceptions[] = $e; } try { $oimages->select($queryOptions); } catch (PDOException $e) { $exceptions[] = $e; } try { $osamaps->select($queryOptions); } catch (PDOException $e) { $exceptions[] = $e; } try { $osections->select($queryOptions); } catch (PDOException $e) { $exceptions[] = $e; } try { $owebsites->select($queryOptions); } catch (PDOException $e) { $exceptions[] = $e; } try { $owsmaps->select($queryOptions); } catch (PDOException $e) { $exceptions[] = $e; } if (sizeof($exceptions)) { return $exceptions; } $version = 1; return $version; }
public function display() { $osections = new OnpubSections($this->pdo); $owebsites = new OnpubWebsites($this->pdo); $oarticles = new OnpubArticles($this->pdo); $oimages = new OnpubImages($this->pdo); $owsmaps = new OnpubWSMaps($this->pdo); $queryOptions = new OnpubQueryOptions(); $queryOptions->includeArticles = TRUE; $queryOptions->includeContent = FALSE; try { $this->osection = $osections->get($this->osection->ID, $queryOptions); $website = $owebsites->get($this->osection->websiteID); $numOfArticles = $oarticles->count(); $queryOptions = new OnpubQueryOptions(); $queryOptions->orderBy = "fileName"; $queryOptions->order = "ASC"; $images = $oimages->select($queryOptions); $wsmap = new OnpubWSMap(); $wsmap->websiteID = $this->osection->websiteID; $wsmap->sectionID = $this->osection->ID; $this->visible = $owsmaps->getID($wsmap); $wsmaps = $owsmaps->select(NULL, NULL, $this->osection->ID); $queryOptions = new OnpubQueryOptions(); $queryOptions->orderBy = "name"; $queryOptions->order = "ASC"; if (sizeof($wsmaps)) { $websites = $owebsites->select($queryOptions); } else { $websites = array(); } } catch (PDOException $e) { throw $e; } $widget = new OnpubWidgetHeader("Section " . $this->osection->ID . " - " . $this->osection->name, ONPUBAPI_SCHEMA_VERSION, $this->pdo); $widget->display(); en('<form id="onpub-form" action="index.php" method="post">'); en('<div>'); en('<div class="yui3-g">'); en('<div class="yui3-u-1-2">'); if ($this->osection->name === NULL) { en('<h3 class="onpub-field-header">Name</h3><p><input type="text" maxlength="255" size="40" name="name" value=""> <img src="' . ONPUBGUI_IMAGE_DIRECTORY . 'exclamation.png" align="top" alt="Required field" title="Required field"></p>'); } else { en('<h3 class="onpub-field-header">Name</h3><p><input type="text" maxlength="255" size="40" name="name" value="' . htmlentities($this->osection->name) . '"></p>'); } en('</div>'); en('<div class="yui3-u-1-2">'); if ($this->visible !== NULL) { en('<h3 class="onpub-field-header">Visibility</h3>'); en('<p><input type="checkbox" id="id_visible" name="visible" value="1" checked="checked"> <label for="id_visible">De-select to hide this section from the Frontend.</label></p>'); } else { en('<h3 class="onpub-field-header">Visibility</h3>'); en('<p><input type="checkbox" id="id_visible" name="visible" value="1"> <label for="id_visible">Select to show this section on the Frontend.</label></p>'); } en('</div>'); en('</div>'); en('<div class="yui3-g">'); en('<div class="yui3-u-1-2">'); if ($this->osection->parentID) { $sectionIDs = array($this->osection->parentID); } else { $sectionIDs = array(); } $widget = new OnpubWidgetSections(); $widget->sectionIDs = $sectionIDs; $widget->websites = array($website); $widget->osections = $osections; $widget->heading = "Parent Section"; $widget->multiple = FALSE; $widget->fieldName = "parentID"; $widget->osection = $this->osection; $widget->display(); en('</div>'); en('<div class="yui3-u-1-2">'); en('<h3 class="onpub-field-header">Website</h3><p><a href="index.php?onpub=EditWebsite&websiteID=' . $website->ID . '" title="Edit">' . $website->name . '</a></p>'); en('</div>'); en('</div>'); en('<div class="yui3-g">'); en('<div class="yui3-u-1-2">'); if ($numOfArticles) { $widget = new OnpubWidgetArticles($this->pdo, $this->osection); $widget->display(); } else { en('<h3 class="onpub-field-header">Visible Articles</h3><p>'); en('There are 0 articles in the database. <a href="index.php?onpub=NewArticle">New Article</a>.</p>'); } en('</div>'); en('<div class="yui3-u-1-2">'); $widget = new OnpubWidgetImages("Image", $this->osection->imageID, $images); $widget->display(); en('</div>'); en('</div>'); if ($this->osection->url) { $go = ' <a href="' . $this->osection->url . '" target="_blank"><img src="' . ONPUBGUI_IMAGE_DIRECTORY . 'world_go.png" border="0" align="top" alt="Go" title="Go" width="16" height="16"></a>'; } else { $go = ''; } en('<div class="yui3-g">'); en('<div class="yui3-u-1-2">'); en('<h3 class="onpub-field-header">Static Link</h3><p><small>The Frontend will link this section to the path or URL entered below.<br>Leave blank to use auto-generated Frontend URLs.</small><br><input type="text" maxlength="255" size="40" name="url" value="' . htmlentities($this->osection->url) . '">' . $go . '</p>'); en('</div>'); en('<div class="yui3-u-1-2">'); if (sizeof($wsmaps)) { $websitesMap = array(); foreach ($websites as $website) { $websitesMap["{$website->ID}"] = $website; } $urlLabel = sizeof($wsmaps) > 1 ? 'URLs' : 'URL'; en('<h3 class="onpub-field-header">Frontend ' . $urlLabel . '</h3>'); en('<p>'); en('<small>This section is displayed by the Frontend at the ' . $urlLabel . ' listed below.</small><br>'); for ($i = 0; $i < sizeof($wsmaps); $i++) { $wsmap = $wsmaps[$i]; $website = $websitesMap["{$wsmap->websiteID}"]; $frontendURL = addTrailingSlash($website->url) . 'index.php?s=' . $wsmap->sectionID; en('• <a href="' . $frontendURL . '" target="_blank">' . $frontendURL . '</a>'); if ($i + 1 != sizeof($wsmaps)) { en('<br>'); } } en('</p>'); } en('</div>'); en('</div>'); en('<div class="yui3-g">'); en('<div class="yui3-u-1-2">'); en('<h3 class="onpub-field-header">Created</h3><p>' . $this->osection->getCreated()->format('M j, Y g:i:s A') . '</p>'); en('</div>'); en('<div class="yui3-u-1-2">'); en('<h3 class="onpub-field-header">Modified</h3><p>' . $this->osection->getModified()->format('M j, Y g:i:s A') . '</p>'); en('</div>'); en('</div>'); en('<input type="submit" value="Save" id="selectAll"> <input type="button" value="Delete" id="deleteSection">'); en('<input type="hidden" name="onpub" value="EditSectionProcess">'); en('<input type="hidden" name="sectionID" value="' . $this->osection->ID . '">'); en('<input type="hidden" name="websiteID" value="' . $this->osection->websiteID . '">'); en('</div>'); en('</form>'); $widget = new OnpubWidgetFooter(); $widget->display(); }