function display() { $image = NULL; if (sizeof($this->images)) { en('<h3 class="onpub-field-header">' . $this->heading . '</h3>'); en('<p>'); en('<small>Mouse-over an image name below for a live preview.</small>', 1, 1); en('<span id="widgetimagepreview">'); en('<select id="widgetimages" name="imageID" size="10">'); if ($this->imageID) { en('<option value="">None</option>'); } else { en('<option value="" selected="selected">None</option>'); } for ($i = 0; $i < sizeof($this->images); $i++) { if ($this->images[$i]->ID == $this->imageID) { $image = $this->images[$i]; en('<option value="' . $this->images[$i]->ID . '" selected="selected">' . strip_tags($this->images[$i]->fileName) . '</option>'); } else { en('<option value="' . $this->images[$i]->ID . '">' . strip_tags($this->images[$i]->fileName) . '</option>'); } } en('</select>'); en('</span>'); en('</p>'); en('<script type="text/javascript">var onpubThumbURLs = [];'); foreach ($this->images as $i) { en('onpubThumbURLs.push(\'' . OnpubImages::getThumbURL('src=' . urlencode($i->getFullPath()) . '&h=80&f=png') . '\');'); } en('</script>'); } }
/** * @param mixed $sections A single {@link OnpubSection} object or an array of {@link OnpubSection} objects (to insert multiple sections at a time). * @return mixed The ID(s) of the new section(s). An int will be returned if a single section was inserted. An array of ints will be returned if multiple sections were inserted. * @throws PDOException if there's a database error. */ public function insert($sections, $insertWSMaps = FALSE) { $oimages = new OnpubImages($this->pdo, FALSE); $owsmaps = new OnpubWSMaps($this->pdo, FALSE); $IDs = array(); $isArray = TRUE; $wsmaps = array(); if (!is_array($sections)) { $sections = array($sections); $isArray = FALSE; } if ($this->enableTransactions) { $status = $this->pdo->beginTransaction(); OnpubDatabase::verifyTransaction($this->pdo, $status); } $stmt = $this->pdo->prepare("INSERT INTO OnpubSections (ID, imageID, websiteID, parentID, name, url, created, modified) VALUES (:ID, :imageID, :websiteID, :parentID, :name, :url, :created, :modified)"); OnpubDatabase::verifyPrepare($this->pdo, $stmt, $this->enableTransactions); foreach ($sections as $section) { if ($section->image) { try { $imageID = $oimages->insert($section->image); $section->imageID = $imageID; } catch (PDOException $e) { if ($this->enableTransactions) { $this->pdo->rollBack(); } throw $e; } } try { $ID = $this->getID($section); } catch (PDOException $e) { if ($this->enableTransactions) { $this->pdo->rollBack(); } throw $e; } if ($ID) { $IDs[] = $ID; $section->ID = $ID; } else { $ID = $section->ID; $imageID = $section->imageID; $websiteID = $section->websiteID; $parentID = $section->parentID; $name = OnpubDatabase::utf8Decode(trim($section->name)); $url = OnpubDatabase::utf8Decode(trim($section->url)); $created = $section->getCreated()->format('Y-m-d H:i:s'); $modified = $section->getModified()->format('Y-m-d H:i:s'); $stmt->bindParam(':ID', $ID); $stmt->bindParam(':imageID', $imageID); $stmt->bindParam(':websiteID', $websiteID); $stmt->bindParam(':parentID', $parentID); $stmt->bindParam(':name', $name); $stmt->bindParam(':url', $url); $stmt->bindParam(':created', $created); $stmt->bindParam(':modified', $modified); $result = $stmt->execute(); OnpubDatabase::verifyExecute($this->pdo, $result, $this->enableTransactions, $stmt->errorInfo()); $IDs[] = $this->pdo->lastInsertId(); $section->ID = $this->pdo->lastInsertId(); } $wsmap = new OnpubWSMap(); $wsmap->websiteID = $section->websiteID; $wsmap->sectionID = $section->ID; $wsmap->setCreated($section->getCreated()); $wsmap->setModified($section->getModified()); $wsmaps[] = $wsmap; } if ($insertWSMaps) { try { $owsmaps->insert($wsmaps); } catch (PDOException $e) { if ($this->enableTransactions) { $this->pdo->rollBack(); } throw $e; } } if ($this->enableTransactions) { $status = $this->pdo->commit(); OnpubDatabase::verifyTransaction($this->pdo, $status); } if ($isArray) { return $IDs; } else { return end($IDs); } }
public function display() { if ($this->pdo) { $odatabase = new OnpubDatabase($this->pdo); $oarticles = new OnpubArticles($this->pdo); $oauthors = new OnpubAuthors($this->pdo); $oimages = new OnpubImages($this->pdo); $osections = new OnpubSections($this->pdo); $owebsites = new OnpubWebsites($this->pdo); $status = $odatabase->status(); $driver = $this->pdo->getAttribute(PDO::ATTR_DRIVER_NAME); $widget = new OnpubWidgetHeader("Dashboard", $status, $this->pdo); } else { $status = null; $widget = new OnpubWidgetHeader("Dashboard", $status, $this->pdo); } $widget->display(); en('<div class="yui3-g">'); if ($status == ONPUBAPI_SCHEMA_VERSION) { // Onpub schema is installed. $numsites = $owebsites->count(); $numarticles = $oarticles->count(); en('<div class="yui3-u-1-2">'); en('<div style="padding-right: 1em;">'); if ($numsites == 0) { en('<h3 style="margin-top: 0;">You are ready to start publishing content with Onpub.</h3>'); en('<p><b><a href="index.php?onpub=NewWebsite">Create a website</a></b> to get started.</p>'); } else { if ($numarticles) { en('<form id="onpub-form" action="index.php" method="get">'); en('<div>'); en('<input type="hidden" name="onpub" value="EditArticles">'); en('<input type="hidden" name="fullTextSearch" value="1">'); en('<p style="margin-top: 0;"><input type="text" name="keywords" style="width: 18.5em;"> <input type="submit" value="Search Articles"></p>'); //en(' For what: <select name="onpub"><option value="EditArticles">Articles</option><option value="EditSections">Sections</option><option value="EditWebsites">Websites</option></select>'); en('</div>'); en('</form>'); } $queryOptions = new OnpubQueryOptions(); $queryOptions->rowLimit = 10; $queryOptions->orderBy = "created"; $queryOptions->order = "DESC"; $articles = $oarticles->select($queryOptions); if (sizeof($articles)) { en('<table style="width: 100%;" colspan="2">'); en('<tr><th style="text-align: left; width: 75%;">Recent Articles</th><th>Created</th></tr>'); foreach ($articles as $article) { en('<tr><td><a href="index.php?onpub=EditArticle&articleID=' . $article->ID . '" title="Edit">' . $article->title . '</a></td><td>' . $article->getCreated()->format("M j, Y") . '</td></tr>'); } en('</table>'); } } en('<div class="yui3-g">'); en('<div class="yui3-u-1-2">'); en('<h3 style="margin-top: 0;">Quick Links</h3>'); en('<ul>'); en('<li><a href="index.php?onpub=NewArticle">New Article</a></li>'); en('<li><a href="index.php?onpub=NewSection">New Section</a></li>'); en('<li><a href="index.php?onpub=UploadImages">Upload Images</a></li>'); en('</ul>'); en('</div>'); en('<div class="yui3-u-1-2">'); en('<table style="float: right;">'); en('<tr><th colspan="2">Content Stats</th></tr>'); en('<tr><td><a href="index.php?onpub=EditArticles">Articles</a>:</td><td>' . $numarticles . '</td></tr>'); //en('<tr><td>Authors:</td><td>' . $oauthors->count() . '</td></tr>'); en('<tr><td><a href="index.php?onpub=EditImages">Images</a>:</td><td>' . $oimages->count() . '</td></tr>'); en('<tr><td><a href="index.php?onpub=EditSections">Sections</a>:</td><td>' . $osections->count() . '</td></tr>'); en('<tr><td><a href="index.php?onpub=EditWebsites">Websites</a>:</td><td>' . $numsites . '</td></tr>'); en('</table>'); en('</div>'); en('</div>'); en('</div>'); en('</div>'); en('<div class="yui3-u-1-2">'); } elseif ($this->pdo === NULL) { en('<div class="yui3-u-1-2">'); en('<h3><span class="onpub-error">PDOException:</span> ' . $this->pdoException->getMessage() . '</h3>'); switch ($this->pdoException->getCode()) { case 1044: // Bad database name. en('<p>Onpub is unable to connect to the specified MySQL database.</p>'); break; case 1045: // Bad credentials. en('<p>Onpub is unable to connect to the specified MySQL database using the logged-in user\'s username and/or password.</p>'); en('<p>Try logging out and log back in with the correct MySQL credentials.</p>'); break; case 2002: // Server is down en('<p>Onpub is unable to connect to the database server.</p>'); en('<p>Start the specified MySQL server and reload this page to try again.</p>'); break; case 2003: // Server is inaccessible (firewall, wrong port, etc.) en('<p>Onpub is unable to access the specified MySQL database server.</p>'); break; case 2005: // Bad host name en('<p>Onpub is unable to connect to the specified MySQL database server host.</p>'); break; } if ($this->pdoException->getMessage() == 'could not find driver') { en('<p>Either PDO_MYSQL is not installed or it is not configured correctly.</p>'); en('<p>Onpub requires the PDO and PDO_MYSQL PHP extensions in order to connect to a MySQL database server.</p>'); en('<p>You will be unable to use Onpub until PDO_MYSQL is installed.</p>'); en('<p>Please refer to the <a href="http://onpub.com/index.php?s=8&a=11" target="_blank">Onpub System Requirements</a> and the <a href="http://www.php.net/manual/en/ref.pdo-mysql.php" target="_blank">PHP Manual</a> for more information.</p>'); } en('</div>'); en('<div class="yui3-u-1-2">'); } else { // Onpub schema is not installed yet. Prompt user to install. en('<div class="yui3-u-1-2">'); en('<h2 style="margin-top: 0;">Welcome to Onpub</h2>'); if ($odatabase->current()) { en('<p>This appears to be the first time you have connected to this MySQL database with Onpub.</p>'); en('<p>Before you can publish a website with Onpub, you must add the Onpub schema to the connected database: <em>' . $_SESSION['PDO_DATABASE'] . '</em>.</p>'); en('<p>Please click the link below to continue:</p>'); en('<ul><li><b><a href="index.php?onpub=SchemaInstall">Install the Onpub MySQL database schema</a></b></li></ul>'); } else { $dbs = $odatabase->listDBs(); if (sizeof($dbs)) { en('<p>Please select the MySQL Database that you would like to work with and click Connect.</p>'); en('<form id="onpub-form" action="index.php" method="post">'); en('<div>'); en('<p>'); en('<select name="pdoDatabase">'); foreach ($dbs as $db) { en('<option value="' . $db . '">' . $db . '</option>'); } en('</select>'); en('</p>'); en('<p><input type="submit" value="Connect"></p>'); en('<input type="hidden" name="onpub" value="LoginProcess">'); en('</div>'); en('</form>'); } else { // User has no database permissions. en('<p>Your MySQL User <em>' . $_SESSION['PDO_USER'] . '</em> does not have the permissions to access any databases on this host.</p>'); en('<p><a href="http://onpub.com/index.php?s=8&a=118#setup" target="_blank">Click here for instructions</a> on how to setup a MySQL User and Database for use with Onpub.'); } } en('</div>'); en('<div class="yui3-u-1-2">'); } if ($this->pdo) { en('<table>'); en('<tr><th colspan="2">Database Connection</th></tr>'); en('<tr style="vertical-align: top;"><td>MySQL Host:</td><td>' . $this->pdo->getAttribute(PDO::ATTR_CONNECTION_STATUS) . '</td></tr>'); en('<tr style="vertical-align: top;"><td>MySQL Client:</td><td>' . $this->pdo->getAttribute(PDO::ATTR_CLIENT_VERSION) . '</td></tr>'); en('<tr style="vertical-align: top;"><td>MySQL Server:</td><td>' . $this->pdo->getAttribute(PDO::ATTR_SERVER_VERSION) . '</td></tr>'); en('<tr style="vertical-align: top;"><td>MySQL User:</td><td>' . $_SESSION['PDO_USER'] . '</td></tr>'); if ($_SESSION['PDO_DATABASE']) { en('<tr style="vertical-align: top;"><td>Connected Database:</td><td>' . $_SESSION['PDO_DATABASE'] . ' (<a href="index.php?onpub=Disconnect">Disconnect</a>)</td></tr>'); } if ($status == ONPUBAPI_SCHEMA_VERSION) { en('<tr style="vertical-align: top;"><td>Onpub Schema:</td><td>Rev. ' . ONPUBAPI_SCHEMA_VERSION . '</td></tr>'); } en('</table>'); en('<table>'); en('<tr><th colspan="2">PHP Configuration</th></tr>'); if (function_exists("gd_info")) { $gdinfo = gd_info(); en('<tr style="vertical-align: top;"><td><a href="http://php.net/manual/en/book.image.php" target="_blank">GD</a>:</td><td>Installed: ' . $gdinfo['GD Version'] . '</td></tr>'); } else { en('<tr style="vertical-align: top;"><td><a href="http://php.net/manual/en/book.image.php" target="_blank">GD</a>:</td><td><span class="onpub-error">Not installed.</span> <a href="http://php.net/manual/en/image.setup.php" target="_blank">Installing GD</a> is required.</td></tr>'); } if (get_magic_quotes_gpc()) { en('<tr style="vertical-align: top;"><td><a href="http://php.net/manual/en/info.configuration.php#ini.magic-quotes-gpc" target="_blank">Magic Quotes</a>:</td><td><span class="onpub-error">On</span>: <a href="http://php.net/manual/en/security.magicquotes.disabling.php" target="_blank">Disabling Magic Quotes</a> is required.</td></tr>'); } else { en('<tr style="vertical-align: top;"><td><a href="http://php.net/manual/en/info.configuration.php#ini.magic-quotes-gpc" target="_blank">Magic Quotes</a>:</td><td>Off</td></tr>'); } if (ini_get("allow_url_fopen")) { en('<tr style="vertical-align: top;"><td><a href="http://php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen" target="_blank">Allow URL File Open</a>:</td><td>Yes</td></tr>'); } else { en('<tr style="vertical-align: top;"><td><a href="http://php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen" target="_blank">Allow URL File Open</a>:</td><td><span class="onpub-error">No</span>: <a href="http://php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen" target="_blank">Enabling URL File Open</a> is required.</td></tr>'); } if (ini_get("file_uploads")) { en('<tr style="vertical-align: top;"><td><a href="http://php.net/ini.core#ini.file-uploads" target="_blank">Allow File Uploads</a>:</td><td>Yes</td></tr>'); } else { en('<tr style="vertical-align: top;"><td><a href="http://php.net/ini.core#ini.file-uploads" target="_blank">Allow File Uploads</a>:</td><td>No</td></tr>'); } if (ini_get("upload_max_filesize")) { en('<tr style="vertical-align: top;"><td><a href="http://php.net/ini.core#ini.upload-max-filesize" target="_blank">Upload Maximum File Size</a>:</td><td>' . ini_get("upload_max_filesize") . '</td></tr>'); } else { en('<tr style="vertical-align: top;"><td><a href="http://php.net/ini.core#ini.upload-max-filesize" target="_blank">Upload Maximum File Size</a>:</td><td>undefined</td></tr>'); } if (ini_get("date.timezone")) { en('<tr style="vertical-align: top;"><td><a href="http://php.net/ref.datetime" target="_blank">Timezone</a>:</td><td>' . ini_get("date.timezone") . '</td></tr>'); } else { en('<tr style="vertical-align: top;"><td><a href="http://php.net/ref.datetime" target="_blank">Timezone</a>:</td><td>' . ONPUBGUI_DEFAULT_TZ . '</td></tr>'); } en('</table>'); } en('</div>'); en('</div>'); $widget = new OnpubWidgetFooter(); $widget->display(); }
/** * Update an article already in the database. * * If you set the article's sectionIDs to NULL, it will be unmapped from * any sections it was previously mapped to. * * @param OnpubArticle $article The article to be updated. * @param bool $overwriteAAMaps False by default. If set to TRUE, the * article-author maps for this article will be deleted and recreated, if * applicable. * @return int 1 if the article was updated. 0 if the article does not exist in the database. */ public function update(OnpubArticle $article, $overwriteAAMaps = FALSE) { $oaamaps = new OnpubAAMaps($this->pdo, FALSE); $oauthors = new OnpubAuthors($this->pdo, FALSE); $osamaps = new OnpubSAMaps($this->pdo, FALSE); $oimages = new OnpubImages($this->pdo, FALSE); $now = new DateTime(); if ($this->enableTransactions) { $status = $this->pdo->beginTransaction(); OnpubDatabase::verifyTransaction($this->pdo, $status); } $stmt = $this->pdo->prepare("UPDATE OnpubArticles SET imageID = :imageID, title = :title, content = :content, url = :url, created = :created, modified = :modified WHERE ID = :ID"); OnpubDatabase::verifyPrepare($this->pdo, $stmt, $this->enableTransactions); if ($article->image) { try { $imageID = $oimages->insert($article->image); $article->imageID = $imageID; } catch (PDOException $e) { if ($this->enableTransactions) { $this->pdo->rollBack(); } throw $e; } } $ID = $article->ID; $imageID = $article->imageID; $title = OnpubDatabase::utf8Decode(trim($article->title)); $content = OnpubDatabase::utf8Decode(trim($article->content)); $url = OnpubDatabase::utf8Decode(trim($article->url)); $created = $article->getCreated()->format('Y-m-d H:i:s'); $modified = $now->format('Y-m-d H:i:s'); $stmt->bindParam(':ID', $ID); $stmt->bindParam(':imageID', $imageID); $stmt->bindParam(':title', $title); $stmt->bindParam(':content', $content); $stmt->bindParam(':url', $url); $stmt->bindParam(':created', $created); $stmt->bindParam(':modified', $modified); $result = $stmt->execute(); OnpubDatabase::verifyExecute($this->pdo, $result, $this->enableTransactions, $stmt->errorInfo()); if ($overwriteAAMaps) { try { $oaamaps->delete($article->ID, NULL); } catch (PDOException $e) { if ($this->enableTransactions) { $this->pdo->rollBack(); } throw $e; } } $authors = $article->authors; foreach ($authors as $author) { if ($author->ID) { try { $oauthors->update($author); } catch (PDOException $e) { if ($this->enableTransactions) { $this->pdo->rollBack(); } throw $e; } } else { try { $oauthors->insert($author); } catch (PDOException $e) { if ($this->enableTransactions) { $this->pdo->rollBack(); } throw $e; } } try { $aamap = new OnpubAAMap(); $aamap->articleID = $article->ID; $aamap->authorID = $author->ID; $oaamaps->insert($aamap); } catch (PDOException $e) { if ($this->enableTransactions) { $this->pdo->rollBack(); } throw $e; } } $sectionIDs = $article->sectionIDs; if ($sectionIDs === NULL) { try { $samaps = $osamaps->delete(NULL, $article->ID); } catch (PDOException $e) { if ($this->enableTransactions) { $this->pdo->rollBack(); } throw $e; } } elseif (sizeof($sectionIDs)) { $queryOptions = new OnpubQueryOptions(); $queryOptions->orderBy = "ID"; $queryOptions->order = "ASC"; try { $samaps = $osamaps->select($queryOptions, NULL, $article->ID); } catch (PDOException $e) { if ($this->enableTransactions) { $this->pdo->rollBack(); } throw $e; } // Unmap sections not included in $sectionIDs. foreach ($samaps as $samap) { if (!in_array($samap->sectionID, $sectionIDs)) { try { $osamaps->delete($samap->sectionID, $article->ID); } catch (PDOException $e) { if ($this->enableTransactions) { $this->pdo->rollBack(); } throw $e; } } } foreach ($sectionIDs as $sectionID) { $samap = new OnpubSAMap(); $samap->sectionID = $sectionID; $samap->articleID = $article->ID; $samap->setCreated($article->getCreated()); $samap->setModified($article->getModified()); try { $samapID = $osamaps->getID($samap); } catch (PDOException $e) { if ($this->enableTransactions) { $this->pdo->rollBack(); } throw $e; } if ($samapID) { $samap->ID = $samapID; try { $osamaps->update($samap); } catch (PDOException $e) { if ($this->enableTransactions) { $this->pdo->rollBack(); } throw $e; } } else { try { $osamaps->insert($samap); } catch (PDOException $e) { if ($this->enableTransactions) { $this->pdo->rollBack(); } throw $e; } } } } if ($this->enableTransactions) { $status = $this->pdo->commit(); OnpubDatabase::verifyTransaction($this->pdo, $status); } return $stmt->rowCount(); }
public function process() { $oimages = new OnpubImages($this->pdo); $owebsites = new OnpubWebsites($this->pdo); if ($this->overwrite !== NULL) { // An image overwrite is being requested. $image = new OnpubImage(); $image->websiteID = $this->websiteID; $image->fileName = $this->overwriteFileName; try { $this->imageID = $oimages->getID($image); } catch (PDOException $e) { throw $e; } try { $website = $owebsites->get($this->websiteID); } catch (PDOException $e) { throw $e; } if ($this->overwrite) { // Overwrite the existing image file with the temp one. if (rename(addTrailingSlash($website->imagesDirectory) . $this->overwriteFileName . ONPUBGUI_TMP_IMG_SUFFIX, addTrailingSlash($website->imagesDirectory) . $this->overwriteFileName)) { // Update the image's modified timestamp in the DB. try { $image = $oimages->get($this->imageID); } catch (PDOException $e) { throw $e; } try { $oimages->update($image); } catch (PDOException $e) { throw $e; } } } else { // Remove the temporary image file. unlink(addTrailingSlash($website->imagesDirectory) . $this->overwriteFileName . ONPUBGUI_TMP_IMG_SUFFIX); } return; } if (!ini_get("file_uploads")) { $message = "File uploads are disabled in the current PHP configuration."; throw new Exception($message, ONPUBGUI_ERROR_IMAGE_TYPE); } for ($i = 0; $i < sizeof($this->imageFiles['name']); $i++) { if ($this->imageFiles['name'][$i]) { if (!$this->isValidImage($this->imageFiles['name'][$i])) { $message = "<i>" . $this->imageFiles['name'][$i] . "</i> is an unsupported image file type."; throw new Exception($message, ONPUBGUI_ERROR_IMAGE_TYPE); } $image = new OnpubImage(); $image->websiteID = $this->websiteID; $image->fileName = $this->imageFiles['name'][$i]; try { $this->imageID = $oimages->getID($image); } catch (PDOException $e) { throw $e; } try { $website = $owebsites->get($image->websiteID); } catch (PDOException $e) { throw $e; } if ($this->imageID) { // Image exists, write the file to the images directory with a temp // name, and prompt the user to overwrite existing file. if (is_uploaded_file($this->imageFiles['tmp_name'][$i])) { if (@move_uploaded_file($this->imageFiles['tmp_name'][$i], addTrailingSlash($website->imagesDirectory) . $this->imageFiles['name'][$i] . ONPUBGUI_TMP_IMG_SUFFIX)) { throw new Exception($this->imageFiles['name'][$i], ONPUBGUI_ERROR_IMAGE_EXISTS); } else { $imagesDirectory = $website->imagesDirectory; $message = "Unable to move <i>" . $this->imageFiles['tmp_name'][$i] . "</i> to <i>" . addTrailingSlash($imagesDirectory) . $this->imageFiles['name'][$i] . ONPUBGUI_TMP_IMG_SUFFIX . "</i>."; throw new Exception($message, ONPUBGUI_ERROR_MOVE_UPLOADED_FILE); } } } else { // Image does not exsist, copy to images folder and insert in to DB. if (is_uploaded_file($this->imageFiles['tmp_name'][$i])) { if (!@move_uploaded_file($this->imageFiles['tmp_name'][$i], addTrailingSlash($website->imagesDirectory) . $this->imageFiles['name'][$i])) { $imagesDirectory = $website->imagesDirectory; $message = "Unable to move <i>" . $this->imageFiles['tmp_name'][$i] . "</i> to <i>" . addTrailingSlash($imagesDirectory) . $this->imageFiles['name'][$i] . "</i>."; throw new Exception($message, ONPUBGUI_ERROR_MOVE_UPLOADED_FILE); } try { $this->imageID = $oimages->insert($image); } catch (PDOException $e) { throw $e; } } else { $imagesDirectory = $website->imagesDirectory; $message = "<i>" . $this->imageFiles['name'][$i] . "</i> file size is larger than the current PHP configuration allows."; throw new Exception($message, ONPUBGUI_ERROR_FILE_SIZE); } } } } }
public function display() { $owebsites = new OnpubWebsites($this->pdo); $osections = new OnpubSections($this->pdo); $oimages = new OnpubImages($this->pdo); try { $queryOptions = new OnpubQueryOptions(); $queryOptions->orderBy = "name"; $queryOptions->order = "ASC"; $websites = $owebsites->select($queryOptions); $queryOptions = new OnpubQueryOptions(); $queryOptions->orderBy = "fileName"; $queryOptions->order = "ASC"; $images = $oimages->select($queryOptions); } catch (PDOException $e) { throw $e; } $widget = new OnpubWidgetHeader("New Article", 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->oarticle->title === NULL) { en('<p><span class="onpub-field-header">Title</span> <input type="text" maxlength="255" size="40" name="title" value=""> <img src="' . ONPUBGUI_IMAGE_DIRECTORY . 'exclamation.png" align="top" alt="Required field" title="Required field"></p>'); } else { en('<p><span class="onpub-field-header">Title</span> <input type="text" maxlength="255" size="40" name="title" value="' . htmlentities($this->oarticle->title) . '"></p>'); } en('</div>'); en('<div class="yui3-u-1-2">'); en('<p><span class="onpub-field-header">Author</span> <input type="text" maxlength="255" size="40" name="displayAs" value="' . htmlentities($this->oauthor->displayAs) . '"></p>'); en('</div>'); en('</div>'); en('<p><textarea rows="25" name="content" style="width: 100%;">' . htmlentities($this->oarticle->content) . '</textarea></p>'); ?> <script type="text/javascript"> if (CKEDITOR) { CKEDITOR.replace('content', { 'height': 350, 'uiColor': '#eff0f0', 'resize_dir': 'vertical', 'dataIndentationChars': ' ', 'allowedContent': true, <?php if (file_exists(ONPUBGUI_YUI_DIRECTORY)) { en("'contentsCss': [onpub_dir_yui + 'cssnormalize/cssnormalize-min.css', onpub_dir_yui + 'cssfonts/cssfonts-min.css', onpub_dir_yui + 'cssgrids/cssgrids-min.css', '" . ONPUBGUI_CKEDITOR_DIRECTORY . "contents.css', 'css/ckeditor.css']"); } else { en("'contentsCss': ['http://yui.yahooapis.com/" . ONPUBGUI_YUI_VERSION . "/build/cssnormalize/cssnormalize-min.css', 'http://yui.yahooapis.com/" . ONPUBGUI_YUI_VERSION . "/build/cssfonts/cssfonts-min.css', 'http://yui.yahooapis.com/" . ONPUBGUI_YUI_VERSION . "/build/cssgrids/cssgrids-min.css', 'ckeditor/contents.css', 'css/ckeditor.css']"); } ?> }); } </script> <?php $widget = new OnpubWidgetDateCreated($this->oarticle->getCreated()); $widget->display(); en('<div class="yui3-g">'); en('<div class="yui3-u-1-2">'); $widget = new OnpubWidgetSections(); $widget->sectionIDs = $this->oarticle->sectionIDs; $widget->websites = $websites; $widget->osections = $osections; $widget->display(); en('</div>'); en('<div class="yui3-u-1-2">'); $widget = new OnpubWidgetImages("Image", $this->oarticle->imageID, $images); $widget->display(); en('</div>'); en('</div>'); en('<input type="submit" value="Save">'); en('<input type="hidden" name="onpub" value="NewArticleProcess">'); en('</div>'); en('</form>'); $widget = new OnpubWidgetFooter(); $widget->display(); }
/** * 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(); }
public function delete() { $oimages = new OnpubImages($this->pdo); $owebsites = new OnpubWebsites($this->pdo); $this->oimage = $oimages->get($this->oimage->ID); $website = $owebsites->get($this->oimage->websiteID); try { $oimages->delete($this->oimage->ID); } catch (PDOException $e) { throw $e; } if (file_exists(addTrailingSlash($website->imagesDirectory) . $this->oimage->fileName)) { unlink(addTrailingSlash($website->imagesDirectory) . $this->oimage->fileName); } }
protected function article() { global $onpub_inc_article_info, $onpub_dir_phpthumb, $onpub_dir_manage, $onpub_dir_frontend, $onpub_inc_article_foot, $onpub_disp_friendly_urls; en('<div class="yui3-g">'); en('<div class="yui3-u-1 onpub-article" itemscope itemtype="http://schema.org/Article">'); if ($this->currentArticle) { if ($this->page == 'home') { $visibleSIDs = $this->getVisibleSIDs(); $url = ''; if ($this->currentArticle->url) { $url = $this->friendlyURLs($this->currentArticle->url, true); } elseif (sizeof($visibleSIDs)) { if ($onpub_disp_friendly_urls) { $url = $this->generateFriendlyURL(NULL, $this->currentArticle, $visibleSIDs[0]); } else { $url = 'index.php?s=' . $visibleSIDs[0] . '&a=' . $this->currentArticle->ID; } } if ($url) { en('<h1 style="margin-right: 0;" itemprop="name"><a href="' . $url . '" itemprop="url">' . $this->currentArticle->title . '</a></h1>'); } else { en('<h1 style="margin-right: 0;" itemprop="name">' . $this->currentArticle->title . '</h1>'); } } else { en('<h1 style="margin-right: 0;" itemprop="name">' . $this->currentArticle->title . '</h1>'); } en('<div class="yui3-g">'); en('<div class="yui3-u-1-2">'); en('<p class="onpub-article-info">'); $created = $this->currentArticle->getCreated(); $modified = $this->currentArticle->getModified(); if (function_exists('date_diff')) { $diff = $created->diff($modified); if (sizeof($this->currentArticle->authors)) { $author = $this->currentArticle->authors[0]; if ($diff->days > 0) { en('By <span itemprop="author">' . $author->displayAs . '</span> on <time datetime="' . $created->format('Y-m-d') . '" itemprop="datePublished">' . $created->format('M j, Y') . '</time>. Updated: <time datetime="' . $modified->format('Y-m-d') . '" itemprop="dateModified">' . $modified->format('M j, Y') . '</time>.'); } else { en('By <span itemprop="author">' . $author->displayAs . '</span> on <time datetime="' . $created->format('Y-m-d') . '" itemprop="datePublished">' . $created->format('M j, Y') . '</time>.'); } } else { if ($diff->days > 0) { en('Published: <time datetime="' . $created->format('Y-m-d') . '" itemprop="datePublished">' . $created->format('M j, Y') . '</time>. Updated: <time datetime="' . $modified->format('Y-m-d') . '" itemprop="dateModified">' . $modified->format('M j, Y') . '</time>.'); } else { en('Published: <time datetime="' . $created->format('Y-m-d') . '" itemprop="datePublished">' . $created->format('M j, Y') . '</time>.'); } } } else { if (sizeof($this->currentArticle->authors)) { $author = $this->currentArticle->authors[0]; en('By <span itemprop="author">' . $author->displayAs . '</span> on ' . $created->format('M j, Y') . '. Updated: <time datetime="' . $modified->format('Y-m-d') . '" itemprop="dateModified">' . $modified->format('M j, Y') . '</time>.'); } else { en('Published: <time datetime="' . $created->format('Y-m-d') . '" itemprop="datePublished">' . $created->format('M j, Y') . '</time>. Updated: <time datetime="' . $modified->format('Y-m-d') . '" itemprop="dateModified">' . $modified->format('M j, Y') . '</time>.'); } } en('</p>'); en('</div>'); en('<div class="yui3-u-1-2">'); if (file_exists($onpub_inc_article_info)) { include $onpub_inc_article_info; } en('</div>'); en('</div>'); if ($this->currentArticle->imageID) { $this->currentArticle->image->website = $this->website; en('<img src="' . OnpubImages::getThumbURL('src=' . urlencode($this->currentArticle->image->getFullPath()) . '&w=400&f=png', $onpub_dir_phpthumb) . '" align="right" alt="' . $this->currentArticle->image->fileName . '" title="' . $this->currentArticle->image->description . '" itemprop="thumbnailUrl">'); } en('<div itemprop="articleBody">'); en($this->friendlyURLs($this->currentArticle->content)); en('</div>'); if ($this->loginStatus) { en('<div class="yui3-g" style="margin-top: 2em">'); en('<div class="yui3-u-1">'); en('<span class="onpub-edit">'); en('<a href="' . $onpub_dir_manage . 'index.php?onpub=EditArticle&articleID=' . $this->currentArticle->ID . '" target="_onpub"><img src="' . $onpub_dir_frontend . 'images/page_edit.png" width="16" height="16" alt="Edit this Article" title="Edit this Article"></a> ' . '<a href="' . $onpub_dir_manage . 'index.php?onpub=EditArticle&articleID=' . $this->currentArticle->ID . '" target="_onpub" title="Edit this Article">EDIT</a>'); en('</span>'); en('</div>'); en('</div>'); } if (file_exists($onpub_inc_article_foot)) { include $onpub_inc_article_foot; } } else { en('<h1>Article ' . $this->requestedArticleID . ' not found... <a href="index.php">Home</a></h1>'); } en('</div>'); en('</div>'); }
/** * @param mixed $authors A single {@link OnpubAuthor} object or an array of {@link OnpubAuthor} objects (to insert multiple authors at a time). * @return mixed The ID(s) of the new author(s). An int will be returned if a single author was inserted. An array of ints will be returned if multiple authors were inserted. * @throws PDOException if there's a database error. */ public function insert($authors) { $oimages = new OnpubImages($this->pdo, FALSE); $IDs = array(); $isArray = TRUE; if (!is_array($authors)) { $authors = array($authors); $isArray = FALSE; } if ($this->enableTransactions) { $status = $this->pdo->beginTransaction(); OnpubDatabase::verifyTransaction($this->pdo, $status); } $stmt = $this->pdo->prepare("INSERT INTO OnpubAuthors (ID, imageID, givenNames, familyName, displayAs, url, created, modified) VALUES (:ID, :imageID, :givenNames, :familyName, :displayAs, :url, :created, :modified)"); OnpubDatabase::verifyPrepare($this->pdo, $stmt, $this->enableTransactions); foreach ($authors as $author) { if ($author->image) { try { $imageID = $oimages->insert($author->image); $author->imageID = $imageID; } catch (PDOException $e) { if ($this->enableTransactions) { $this->pdo->rollBack(); } throw $e; } } try { $ID = $this->getID($author); } catch (PDOException $e) { if ($this->enableTransactions) { $this->pdo->rollBack(); } throw $e; } if ($ID) { $IDs[] = $ID; $author->ID = $ID; } else { $ID = $author->ID; $imageID = $author->imageID; $givenNames = OnpubDatabase::utf8Decode(trim($author->givenNames)); $familyName = OnpubDatabase::utf8Decode(trim($author->familyName)); $displayAs = OnpubDatabase::utf8Decode(trim($author->displayAs)); $url = OnpubDatabase::utf8Decode(trim($author->url)); $created = $author->getCreated()->format('Y-m-d H:i:s'); $modified = $author->getModified()->format('Y-m-d H:i:s'); $stmt->bindParam(':ID', $ID); $stmt->bindParam(':imageID', $imageID); $stmt->bindParam(':givenNames', $givenNames); $stmt->bindParam(':familyName', $familyName); $stmt->bindParam(':displayAs', $displayAs); $stmt->bindParam(':url', $url); $stmt->bindParam(':created', $created); $stmt->bindParam(':modified', $modified); $result = $stmt->execute(); OnpubDatabase::verifyExecute($this->pdo, $result, $this->enableTransactions, $stmt->errorInfo()); $IDs[] = $this->pdo->lastInsertId(); $author->ID = $this->pdo->lastInsertId(); } } if ($this->enableTransactions) { $status = $this->pdo->commit(); OnpubDatabase::verifyTransaction($this->pdo, $status); } if ($isArray) { return $IDs; } else { return end($IDs); } }
public function display() { $oimages = new OnpubImages($this->pdo); $owebsites = new OnpubWebsites($this->pdo); $this->fullTextSearch = "NA"; $counter = 0; $currentPage = 1; if ($this->page) { $currentPage = $this->page; } if ($this->orderBy && $this->order) { if ($this->keywords) { try { $queryOptions = new OnpubQueryOptions(); $queryOptions->orderBy = $this->orderBy; $queryOptions->order = $this->order; $images = $oimages->search($this->keywords, $queryOptions); } catch (PDOException $e) { $widget = new OnpubWidgetPDOException($e); $widget->display(); return; } $totalImages = sizeof($images); } else { if ($this->sectionID) { } else { try { $queryOptions = new OnpubQueryOptions(); $queryOptions->orderBy = $this->orderBy; $queryOptions->order = $this->order; $queryOptions->setPage($currentPage, ONPUBGUI_PDO_ROW_LIMIT); $images = $oimages->select($queryOptions); } catch (PDOException $e) { $widget = new OnpubWidgetPDOException($e); $widget->display(); return; } try { $totalImages = $oimages->count(); } catch (PDOException $e) { $widget = new OnpubWidgetPDOException($e); $widget->display(); return; } } } } else { if ($this->keywords) { try { $queryOptions = new OnpubQueryOptions(); $queryOptions->orderBy = "created"; $queryOptions->order = "DESC"; $images = $oimages->search($this->keywords, $queryOptions); } catch (PDOException $e) { $widget = new OnpubWidgetPDOException($e); $widget->display(); return; } $totalImages = sizeof($images); } else { if ($this->sectionID) { } else { try { $queryOptions = new OnpubQueryOptions(); $queryOptions->orderBy = "created"; $queryOptions->order = "DESC"; $queryOptions->setPage($currentPage, ONPUBGUI_PDO_ROW_LIMIT); $images = $oimages->select($queryOptions); } catch (PDOException $e) { $widget = new OnpubWidgetPDOException($e); $widget->display(); return; } try { $totalImages = $oimages->count(); } catch (PDOException $e) { $widget = new OnpubWidgetPDOException($e); $widget->display(); return; } } } } $widget = new OnpubWidgetHeader("Images", ONPUBAPI_SCHEMA_VERSION, $this->pdo); $widget->display(); en('<form id="onpub-form" action="index.php" method="get">'); en('<div>'); en('<input type="hidden" name="onpub" value="EditImages">'); if ($totalImages) { $widget = new OnpubWidgetPaginator($totalImages, $this->orderBy, $this->order, $this->page, $this->keywords, $this->fullTextSearch, "sectionID", $this->sectionID, "EditImages"); $widget->display(); en('<table>'); en('<tr>'); //en('<td></td>'); if ($this->keywords) { $this->keywords = urlencode($this->keywords); if ($this->fullTextSearch) { switch ($this->orderBy) { case "ID": switch ($this->order) { case "ASC": en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&fullTextSearch=' . $this->fullTextSearch . '&orderBy=ID&order=DESC">ID</a></span></td>'); en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&fullTextSearch=' . $this->fullTextSearch . '&orderBy=fileName&order=ASC">File Name</a></span></td>'); en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&fullTextSearch=' . $this->fullTextSearch . '&orderBy=created&order=DESC">Created</a></span></td>'); break; case "DESC": en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&fullTextSearch=' . $this->fullTextSearch . '&orderBy=ID&order=ASC">ID</a></span></td>'); en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&fullTextSearch=' . $this->fullTextSearch . '&orderBy=fileName&order=ASC">File Name</a></span></td>'); en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&fullTextSearch=' . $this->fullTextSearch . '&orderBy=created&order=DESC">Created</a></span></td>'); break; } break; case "fileName": switch ($this->order) { case "ASC": en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&fullTextSearch=' . $this->fullTextSearch . '&orderBy=ID&order=DESC">ID</a></span></td>'); en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&fullTextSearch=' . $this->fullTextSearch . '&orderBy=fileName&order=DESC">File Name</a></span></td>'); en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&fullTextSearch=' . $this->fullTextSearch . '&orderBy=created&order=DESC">Created</a></span></td>'); break; case "DESC": en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&fullTextSearch=' . $this->fullTextSearch . '&orderBy=ID&order=DESC">ID</a></span></td>'); en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&fullTextSearch=' . $this->fullTextSearch . '&orderBy=fileName&order=ASC">File Name</a></span></td>'); en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&fullTextSearch=' . $this->fullTextSearch . '&orderBy=created&order=DESC">Created</a></span></td>'); break; } break; default: switch ($this->order) { case "ASC": en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&fullTextSearch=' . $this->fullTextSearch . '&orderBy=ID&order=DESC">ID</a></span></td>'); en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&fullTextSearch=' . $this->fullTextSearch . '&orderBy=fileName&order=ASC">File Name</a></span></td>'); en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&fullTextSearch=' . $this->fullTextSearch . '&orderBy=created&order=DESC">Created</a></span></td>'); break; case "DESC": en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&fullTextSearch=' . $this->fullTextSearch . '&orderBy=ID&order=DESC">ID</a></span></td>'); en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&fullTextSearch=' . $this->fullTextSearch . '&orderBy=fileName&order=ASC">File Name</a></span></td>'); en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&fullTextSearch=' . $this->fullTextSearch . '&orderBy=created&order=ASC">Created</a></span></td>'); break; default: en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&fullTextSearch=' . $this->fullTextSearch . '&orderBy=ID&order=DESC">ID</a></span></td>'); en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&fullTextSearch=' . $this->fullTextSearch . '&orderBy=fileName&order=ASC">File Name</a></span></td>'); en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&fullTextSearch=' . $this->fullTextSearch . '&orderBy=created&order=ASC">Created</a></span></td>'); break; } break; } } else { switch ($this->orderBy) { case "ID": switch ($this->order) { case "ASC": en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&orderBy=ID&order=DESC">ID</a></span></td>'); en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&orderBy=fileName&order=ASC">File Name</a></span></td>'); en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&orderBy=created&order=DESC">Created</a></span></td>'); break; case "DESC": en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&orderBy=ID&order=ASC">ID</a></span></td>'); en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&orderBy=fileName&order=ASC">File Name</a></span></td>'); en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&orderBy=created&order=DESC">Created</a></span></td>'); break; } break; case "fileName": switch ($this->order) { case "ASC": en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&orderBy=ID&order=DESC">ID</a></span></td>'); en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&orderBy=fileName&order=DESC">File Name</a></span></td>'); en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&orderBy=created&order=DESC">Created</a></span></td>'); break; case "DESC": en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&orderBy=ID&order=DESC">ID</a></span></td>'); en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&orderBy=fileName&order=ASC">File Name</a></span></td>'); en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&orderBy=created&order=DESC">Created</a></span></td>'); break; } break; default: switch ($this->order) { case "ASC": en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&orderBy=ID&order=DESC">ID</a></span></td>'); en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&orderBy=fileName&order=ASC">File Name</a></span></td>'); en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&orderBy=created&order=DESC">Created</a></span></td>'); break; case "DESC": en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&orderBy=ID&order=DESC">ID</a></span></td>'); en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&orderBy=fileName&order=ASC">File Name</a></span></td>'); en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&orderBy=created&order=ASC">Created</a></span></td>'); break; default: en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&orderBy=ID&order=DESC">ID</a></span></td>'); en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&orderBy=fileName&order=ASC">File Name</a></span></td>'); en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&keywords=' . $this->keywords . '&orderBy=created&order=ASC">Created</a></span></td>'); break; } break; } } $this->keywords = urldecode($this->keywords); } else { if ($this->sectionID) { switch ($this->orderBy) { case "ID": switch ($this->order) { case "ASC": en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=ID&order=DESC§ionID=' . $this->sectionID . '">ID</a></span></td>'); en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=fileName&order=ASC§ionID=' . $this->sectionID . '">File Name</a></span></td>'); en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=created&order=DESC§ionID=' . $this->sectionID . '">Created</a></span></td>'); break; case "DESC": en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=ID&order=ASC§ionID=' . $this->sectionID . '">ID</a></span></td>'); en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=fileName&order=ASC§ionID=' . $this->sectionID . '">File Name</a></span></td>'); en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=created&order=DESC§ionID=' . $this->sectionID . '">Created</a></span></td>'); break; } break; case "fileName": switch ($this->order) { case "ASC": en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=ID&order=DESC§ionID=' . $this->sectionID . '">ID</a></span></td>'); en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=fileName&order=DESC§ionID=' . $this->sectionID . '">File Name</a></span></td>'); en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=created&order=DESC§ionID=' . $this->sectionID . '">Created</a></span></td>'); break; case "DESC": en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=ID&order=DESC§ionID=' . $this->sectionID . '">ID</a></span></td>'); en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=fileName&order=ASC§ionID=' . $this->sectionID . '">File Name</a></span></td>'); en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=created&order=DESC§ionID=' . $this->sectionID . '">Created</a></span></td>'); break; } break; default: switch ($this->order) { case "ASC": en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=ID&order=DESC§ionID=' . $this->sectionID . '">ID</a></span></td>'); en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=fileName&order=ASC§ionID=' . $this->sectionID . '">File Name</a></span></td>'); en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=created&order=DESC§ionID=' . $this->sectionID . '">Created</a></span></td>'); break; case "DESC": en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=ID&order=DESC§ionID=' . $this->sectionID . '">ID</a></span></td>'); en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=fileName&order=ASC§ionID=' . $this->sectionID . '">File Name</a></span></td>'); en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=created&order=ASC§ionID=' . $this->sectionID . '">Created</a></span></td>'); break; default: en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=ID&order=DESC§ionID=' . $this->sectionID . '">ID</a></span></td>'); en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=fileName&order=ASC§ionID=' . $this->sectionID . '">File Name</a></span></td>'); en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=created&order=ASC§ionID=' . $this->sectionID . '">Created</a></span></td>'); break; } break; } } else { switch ($this->orderBy) { case "ID": switch ($this->order) { case "ASC": en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=ID&order=DESC">ID</a></span></td>'); en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=fileName&order=ASC">File Name</a></span></td>'); en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=created&order=DESC">Created</a></span></td>'); break; case "DESC": en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=ID&order=ASC">ID</a></span></td>'); en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=fileName&order=ASC">File Name</a></span></td>'); en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=created&order=DESC">Created</a></span></td>'); break; } break; case "fileName": switch ($this->order) { case "ASC": en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=ID&order=DESC">ID</a></span></td>'); en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=fileName&order=DESC">File Name</a></span></td>'); en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=created&order=DESC">Created</a></span></td>'); break; case "DESC": en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=ID&order=DESC">ID</a></span></td>'); en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=fileName&order=ASC">File Name</a></span></td>'); en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=created&order=DESC">Created</a></span></td>'); break; } break; default: switch ($this->order) { case "ASC": en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=ID&order=DESC">ID</a></span></td>'); en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=fileName&order=ASC">File Name</a></span></td>'); en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=created&order=DESC">Created</a></span></td>'); break; case "DESC": en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=ID&order=DESC">ID</a></span></td>'); en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=fileName&order=ASC">File Name</a></span></td>'); en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=created&order=ASC">Created</a></span></td>'); break; default: en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=ID&order=DESC">ID</a></span></td>'); en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=fileName&order=ASC">File Name</a></span></td>'); en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&orderBy=created&order=ASC">Created</a></span></td>'); break; } break; } } } en('<td><span class="onpub-field-header">Preview</span></td>'); en('</tr>'); if ($this->keywords || $this->sectionID) { $index = ($currentPage - 1) * ONPUBGUI_PDO_ROW_LIMIT; } else { $index = 0; } $websites = array(); for ($i = 0; $i < ONPUBGUI_PDO_ROW_LIMIT && $index < sizeof($images); $i++) { $image = $images[$index]; $websiteID = $images[$index]->websiteID; $ID = $images[$index]->ID; $fileName = $images[$index]->fileName; $created = $images[$index]->getCreated()->format("M j, Y"); if (!isset($websites[$websiteID])) { $websites[$websiteID] = $owebsites->get($websiteID); } $thumbURL = OnpubImages::getThumbURL('src=' . urlencode($image->getFullPath()) . '&w=50&f=png'); en('<tr valign="top">'); //en('<td align="right"><input type="checkbox" name="imageIDs[]" value="' . $ID . '"></td>'); switch ($this->order) { case "ASC": switch ($counter) { case 0: en('<td class="onpub-highlight1" align="right">' . $ID . '</td>'); en('<td class="onpub-highlight1" align="left"><a href="index.php?onpub=EditImage&imageID=' . $ID . '" title="Edit">' . $fileName . '</a></td>'); en('<td class="onpub-highlight1" align="left">' . $created . '</td>'); en('<td class="onpub-highlight1"><a href="index.php?onpub=EditImage&imageID=' . $ID . '" title="Edit"><img src="' . $thumbURL . '"></a></td>'); break; case 1: en('<td class="onpub-highlight2" align="right">' . $ID . '</td>'); en('<td class="onpub-highlight2" align="left"><a href="index.php?onpub=EditImage&imageID=' . $ID . '" title="Edit">' . $fileName . '</a></td>'); en('<td class="onpub-highlight2" align="left">' . $created . '</td>'); en('<td class="onpub-highlight2"><a href="index.php?onpub=EditImage&imageID=' . $ID . '" title="Edit"><img src="' . $thumbURL . '"></a></td>'); break; } break; case "DESC": switch ($counter) { case 0: en('<td class="onpub-highlight1" align="right">' . $ID . '</td>'); en('<td class="onpub-highlight1" align="left"><a href="index.php?onpub=EditImage&imageID=' . $ID . '" title="Edit">' . $fileName . '</a></td>'); en('<td class="onpub-highlight1" align="left">' . $created . '</td>'); en('<td class="onpub-highlight1"><a href="index.php?onpub=EditImage&imageID=' . $ID . '" title="Edit"><img src="' . $thumbURL . '"></a></td>'); break; case 1: en('<td class="onpub-highlight2" align="right">' . $ID . '</td>'); en('<td class="onpub-highlight2" align="left"><a href="index.php?onpub=EditImage&imageID=' . $ID . '" title="Edit">' . $fileName . '</a></td>'); en('<td class="onpub-highlight2" align="left">' . $created . '</td>'); en('<td class="onpub-highlight2"><a href="index.php?onpub=EditImage&imageID=' . $ID . '" title="Edit"><img src="' . $thumbURL . '"></a></td>'); break; } break; default: switch ($counter) { case 0: en('<td class="onpub-highlight1" align="right">' . $ID . '</td>'); en('<td class="onpub-highlight1" align="left"><a href="index.php?onpub=EditImage&imageID=' . $ID . '" title="Edit">' . $fileName . '</a></td>'); en('<td class="onpub-highlight1" align="left">' . $created . '</td>'); en('<td class="onpub-highlight1"><a href="index.php?onpub=EditImage&imageID=' . $ID . '" title="Edit"><img src="' . $thumbURL . '"></a></td>'); break; case 1: en('<td class="onpub-highlight2" align="right">' . $ID . '</td>'); en('<td class="onpub-highlight2" align="left"><a href="index.php?onpub=EditImage&imageID=' . $ID . '" title="Edit">' . $fileName . '</a></td>'); en('<td class="onpub-highlight2" align="left">' . $created . '</td>'); en('<td class="onpub-highlight2"><a href="index.php?onpub=EditImage&imageID=' . $ID . '" title="Edit"><img src="' . $thumbURL . '"></a></td>'); break; } break; } en('</tr>'); if ($counter + 1 == 2) { $counter = 0; } else { $counter++; } $index++; } en('</table>'); } else { if ($this->keywords) { en('<p>Your search did not yield any results. <a href="javascript:clearSearchField(); submitForm();">Display all images</a>.</p>'); } else { if ($this->sectionID) { } else { en('<p>There are 0 images on file. <a href="index.php?onpub=UploadImages">Upload Images</a>.</p>'); } } } if ($totalImages) { $widget = new OnpubWidgetStats($totalImages, $this->keywords, $this->sectionID, "Image", ""); $widget->display(); } en('</div>'); en('</form>'); $widget = new OnpubWidgetFooter(); $widget->display(); }
public function display() { $oarticles = new OnpubArticles($this->pdo); $owebsites = new OnpubWebsites($this->pdo); $osamaps = new OnpubSAMaps($this->pdo); $osections = new OnpubSections($this->pdo); $oimages = new OnpubImages($this->pdo); try { $queryOptions = new OnpubQueryOptions(); $queryOptions->includeAuthors = TRUE; $this->oarticle = $oarticles->get($this->oarticle->ID, $queryOptions); $queryOptions = new OnpubQueryOptions(); $queryOptions->orderBy = "fileName"; $queryOptions->order = "ASC"; $images = $oimages->select($queryOptions); $queryOptions = new OnpubQueryOptions(); $queryOptions->orderBy = "name"; $queryOptions->order = "ASC"; $websites = $owebsites->select($queryOptions); $queryOptions = new OnpubQueryOptions(); $samaps = $osamaps->select($queryOptions, NULL, $this->oarticle->ID); } catch (PDOException $e) { throw $e; } $author = $this->oarticle->authors; if (sizeof($author)) { $author = $author[0]; } else { $author = new OnpubAuthor(); } $widget = new OnpubWidgetHeader("Article " . $this->oarticle->ID . " - " . $this->oarticle->title, ONPUBAPI_SCHEMA_VERSION, $this->pdo); $widget->display(); en('<form id="onpub-form" action="index.php" method="post">'); en('<div>'); en('<p><textarea rows="25" name="content" style="width: 100%;">' . htmlentities($this->oarticle->content) . '</textarea></p>'); ?> <script type="text/javascript"> if (CKEDITOR) { CKEDITOR.replace('content', { 'height': 350, 'uiColor': '#eff0f0', 'resize_dir': 'vertical', 'dataIndentationChars': ' ', 'allowedContent': true, <?php if (file_exists(ONPUBGUI_YUI_DIRECTORY)) { en("'contentsCss': [onpub_dir_yui + 'cssnormalize/cssnormalize-min.css', onpub_dir_yui + 'cssfonts/cssfonts-min.css', onpub_dir_yui + 'cssgrids/cssgrids-min.css', '" . ONPUBGUI_CKEDITOR_DIRECTORY . "contents.css', 'css/ckeditor.css']"); } else { en("'contentsCss': ['http://yui.yahooapis.com/" . ONPUBGUI_YUI_VERSION . "/build/cssnormalize/cssnormalize-min.css', 'http://yui.yahooapis.com/" . ONPUBGUI_YUI_VERSION . "/build/cssfonts/cssfonts-min.css', 'http://yui.yahooapis.com/" . ONPUBGUI_YUI_VERSION . "/build/cssgrids/cssgrids-min.css', '" . ONPUBGUI_CKEDITOR_DIRECTORY . "contents.css', 'css/ckeditor.css']"); } ?> }); } </script> <?php en('<div class="yui3-g">'); en('<div class="yui3-u-1-2">'); en('<h3 class="onpub-field-header">Title</h3><p><input type="text" maxlength="255" size="40" name="title" value="' . htmlentities($this->oarticle->title) . '"></p>'); en('</div>'); en('<div class="yui3-u-1-2">'); en('<h3 class="onpub-field-header">Author</h3><p><input type="text" maxlength="255" size="40" name="displayAs" value="' . htmlentities($author->displayAs) . '"></p>'); en('</div>'); en('</div>'); en('<div class="yui3-g">'); en('<div class="yui3-u-1-2">'); $widget = new OnpubWidgetSections(); $widget->websites = $websites; $widget->osections = $osections; $widget->samaps = $samaps; $widget->display(); en('</div>'); en('<div class="yui3-u-1-2">'); $widget = new OnpubWidgetImages("Image", $this->oarticle->imageID, $images); $widget->display(); en('</div>'); en('</div>'); if ($this->oarticle->url) { $go = ' <a href="' . $this->oarticle->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 article 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->oarticle->url) . '">' . $go . '</p>'); en('</div>'); en('<div class="yui3-u-1-2">'); if (sizeof($samaps)) { $websitesMap = array(); foreach ($websites as $website) { $websitesMap["{$website->ID}"] = $website; } $sections = array(); $articleIDs = array(); foreach ($samaps as $samap) { $section = $osections->get($samap->sectionID); if ($section && isset($websitesMap["{$section->websiteID}"])) { $website = $websitesMap["{$section->websiteID}"]; if ($website->url) { $sections[] = $section; $articleIDs[] = $samap->articleID; } } } if (sizeof($sections)) { $urlLabel = sizeof($sections) > 1 ? 'URLs' : 'URL'; en('<h3 class="onpub-field-header">Frontend ' . $urlLabel . '</h3>'); en('<p>'); en('<small>This article is displayed by the Frontend at the ' . $urlLabel . ' listed below.</small><br>'); for ($i = 0; $i < sizeof($sections); $i++) { $section = $sections[$i]; $website = $websitesMap["{$section->websiteID}"]; $frontendURL = addTrailingSlash($website->url) . 'index.php?s=' . $section->ID . '&a=' . $articleIDs[$i]; en('• <a href="' . $frontendURL . '" target="_blank">' . $frontendURL . '</a>'); if ($i + 1 != sizeof($sections)) { en('<br>'); } } en('</p>'); } } en('</div>'); en('</div>'); $widget = new OnpubWidgetDateCreated($this->oarticle->getCreated()); $widget->display(); $modified = $this->oarticle->getModified(); en('<h3 class="onpub-field-header">Modified</h3><p>' . $modified->format('M j, Y g:i:s A') . '</p>'); en('<input type="submit" value="Save"> <input type="button" value="Delete" id="deleteArticle">'); en('<input type="hidden" name="articleID" id="articleID" value="' . $this->oarticle->ID . '">'); en('<input type="hidden" name="authorID" value="' . $author->ID . '">'); en('<input type="hidden" name="authorImageID" value="' . $author->imageID . '">'); en('<input type="hidden" name="lastDisplayAs" value="' . htmlentities($author->displayAs) . '">'); en('<input type="hidden" name="onpub" value="EditArticleProcess">'); en('</div>'); en('</form>'); $widget = new OnpubWidgetFooter(); $widget->display(); }