Exemplo n.º 1
0
 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);
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
 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&amp;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('&bull; <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();
 }
Exemplo n.º 3
0
 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);
     }
 }
Exemplo n.º 4
0
 public function display()
 {
     $osections = new OnpubSections($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;
                 $sections = $osections->search($this->keywords, $queryOptions);
             } catch (PDOException $e) {
                 $widget = new OnpubWidgetPDOException($e);
                 $widget->display();
                 return;
             }
             $totalSections = sizeof($sections);
         } else {
             if ($this->websiteID) {
                 try {
                     $queryOptions = new OnpubQueryOptions();
                     $queryOptions->orderBy = $this->orderBy;
                     $queryOptions->order = $this->order;
                     $sections = $osections->select($queryOptions, $this->websiteID);
                 } catch (PDOException $e) {
                     $widget = new OnpubWidgetPDOException($e);
                     $widget->display();
                     return;
                 }
                 $totalSections = sizeof($sections);
             } else {
                 try {
                     $queryOptions = new OnpubQueryOptions();
                     $queryOptions->orderBy = $this->orderBy;
                     $queryOptions->order = $this->order;
                     $queryOptions->setPage($currentPage, ONPUBGUI_PDO_ROW_LIMIT);
                     $sections = $osections->select($queryOptions);
                 } catch (PDOException $e) {
                     $widget = new OnpubWidgetPDOException($e);
                     $widget->display();
                     return;
                 }
                 try {
                     $totalSections = $osections->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";
                 $sections = $osections->search($this->keywords, $queryOptions);
             } catch (PDOException $e) {
                 $widget = new OnpubWidgetPDOException($e);
                 $widget->display();
                 return;
             }
             $totalSections = sizeof($sections);
         } else {
             if ($this->websiteID) {
                 try {
                     $queryOptions = new OnpubQueryOptions();
                     $queryOptions->orderBy = "created";
                     $queryOptions->order = "DESC";
                     $sections = $osections->select($queryOptions, $this->websiteID);
                 } catch (PDOException $e) {
                     $widget = new OnpubWidgetPDOException($e);
                     $widget->display();
                     return;
                 }
                 $totalSections = sizeof($sections);
             } else {
                 try {
                     $queryOptions = new OnpubQueryOptions();
                     $queryOptions->orderBy = "created";
                     $queryOptions->order = "DESC";
                     $queryOptions->setPage($currentPage, ONPUBGUI_PDO_ROW_LIMIT);
                     $sections = $osections->select($queryOptions);
                 } catch (PDOException $e) {
                     $widget = new OnpubWidgetPDOException($e);
                     $widget->display();
                     return;
                 }
                 try {
                     $totalSections = $osections->count();
                 } catch (PDOException $e) {
                     $widget = new OnpubWidgetPDOException($e);
                     $widget->display();
                     return;
                 }
             }
         }
     }
     $widget = new OnpubWidgetHeader("Sections", ONPUBAPI_SCHEMA_VERSION, $this->pdo);
     $widget->display();
     en('<form id="onpub-form" action="index.php" method="get">');
     en('<div>');
     if ($totalSections) {
         if (!$this->keywords) {
             $widget = new OnpubWidgetSelectWebsite($this->pdo, $this->websiteID);
             $widget->display();
         }
         $widget = new OnpubWidgetPaginator($totalSections, $this->orderBy, $this->order, $this->page, $this->keywords, $this->fullTextSearch, "websiteID", $this->websiteID, "EditSections");
         $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=EditSections&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=ID&amp;order=DESC">ID</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=name&amp;order=ASC">Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header">Website</span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=created&amp;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=EditSections&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=ID&amp;order=ASC">ID</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=name&amp;order=ASC">Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header">Website</span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=created&amp;order=DESC">Created</a></span></td>');
                                 break;
                         }
                         break;
                     case "name":
                         switch ($this->order) {
                             case "ASC":
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=ID&amp;order=DESC">ID</a></span></td>');
                                 en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=name&amp;order=DESC">Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header">Website</span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=created&amp;order=DESC">Created</a></span></td>');
                                 break;
                             case "DESC":
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=ID&amp;order=DESC">ID</a></span></td>');
                                 en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=name&amp;order=ASC">Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header">Website</span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=created&amp;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=EditSections&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=ID&amp;order=DESC">ID</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=name&amp;order=ASC">Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header">Website</span></td>');
                                 en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=created&amp;order=DESC">Created</a></span></td>');
                                 break;
                             case "DESC":
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=ID&amp;order=DESC">ID</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=name&amp;order=ASC">Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header">Website</span></td>');
                                 en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=created&amp;order=ASC">Created</a></span></td>');
                                 break;
                             default:
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=ID&amp;order=DESC">ID</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=name&amp;order=ASC">Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header">Website</span></td>');
                                 en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=created&amp;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=EditSections&amp;keywords=' . $this->keywords . '&amp;orderBy=ID&amp;order=DESC">ID</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;keywords=' . $this->keywords . '&amp;orderBy=name&amp;order=ASC">Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header">Website</span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;keywords=' . $this->keywords . '&amp;orderBy=created&amp;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=EditSections&amp;keywords=' . $this->keywords . '&amp;orderBy=ID&amp;order=ASC">ID</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;keywords=' . $this->keywords . '&amp;orderBy=name&amp;order=ASC">Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header">Website</span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;keywords=' . $this->keywords . '&amp;orderBy=created&amp;order=DESC">Created</a></span></td>');
                                 break;
                         }
                         break;
                     case "name":
                         switch ($this->order) {
                             case "ASC":
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;keywords=' . $this->keywords . '&amp;orderBy=ID&amp;order=DESC">ID</a></span></td>');
                                 en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;keywords=' . $this->keywords . '&amp;orderBy=name&amp;order=DESC">Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header">Website</span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;keywords=' . $this->keywords . '&amp;orderBy=created&amp;order=DESC">Created</a></span></td>');
                                 break;
                             case "DESC":
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;keywords=' . $this->keywords . '&amp;orderBy=ID&amp;order=DESC">ID</a></span></td>');
                                 en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;keywords=' . $this->keywords . '&amp;orderBy=name&amp;order=ASC">Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header">Website</span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;keywords=' . $this->keywords . '&amp;orderBy=created&amp;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=EditSections&amp;keywords=' . $this->keywords . '&amp;orderBy=ID&amp;order=DESC">ID</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;keywords=' . $this->keywords . '&amp;orderBy=name&amp;order=ASC">Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header">Website</span></td>');
                                 en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;keywords=' . $this->keywords . '&amp;orderBy=created&amp;order=DESC">Created</a></span></td>');
                                 break;
                             case "DESC":
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;keywords=' . $this->keywords . '&amp;orderBy=ID&amp;order=DESC">ID</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;keywords=' . $this->keywords . '&amp;orderBy=name&amp;order=ASC">Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header">Website</span></td>');
                                 en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;keywords=' . $this->keywords . '&amp;orderBy=created&amp;order=ASC">Created</a></span></td>');
                                 break;
                             default:
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;keywords=' . $this->keywords . '&amp;orderBy=ID&amp;order=DESC">ID</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;keywords=' . $this->keywords . '&amp;orderBy=name&amp;order=ASC">Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header">Website</span></td>');
                                 en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;keywords=' . $this->keywords . '&amp;orderBy=created&amp;order=ASC">Created</a></span></td>');
                                 break;
                         }
                         break;
                 }
             }
             $this->keywords = urldecode($this->keywords);
         } else {
             if ($this->websiteID) {
                 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=EditSections&amp;orderBy=ID&amp;order=DESC&websiteID=' . $this->websiteID . '">ID</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;orderBy=name&amp;order=ASC&websiteID=' . $this->websiteID . '">Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header">Website</span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;orderBy=created&amp;order=DESC&websiteID=' . $this->websiteID . '">Created</a></span></td>');
                                 break;
                             case "DESC":
                                 en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;orderBy=ID&amp;order=ASC&websiteID=' . $this->websiteID . '">ID</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;orderBy=name&amp;order=ASC&websiteID=' . $this->websiteID . '">Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header">Website</span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;orderBy=created&amp;order=DESC&websiteID=' . $this->websiteID . '">Created</a></span></td>');
                                 break;
                         }
                         break;
                     case "name":
                         switch ($this->order) {
                             case "ASC":
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;orderBy=ID&amp;order=DESC&websiteID=' . $this->websiteID . '">ID</a></span></td>');
                                 en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;orderBy=name&amp;order=DESC&websiteID=' . $this->websiteID . '">Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header">Website</span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;orderBy=created&amp;order=DESC&websiteID=' . $this->websiteID . '">Created</a></span></td>');
                                 break;
                             case "DESC":
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;orderBy=ID&amp;order=DESC&websiteID=' . $this->websiteID . '">ID</a></span></td>');
                                 en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;orderBy=name&amp;order=ASC&websiteID=' . $this->websiteID . '">Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header">Website</span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;orderBy=created&amp;order=DESC&websiteID=' . $this->websiteID . '">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=EditSections&amp;orderBy=ID&amp;order=DESC&websiteID=' . $this->websiteID . '">ID</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;orderBy=name&amp;order=ASC&websiteID=' . $this->websiteID . '">Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header">Website</span></td>');
                                 en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;orderBy=created&amp;order=DESC&websiteID=' . $this->websiteID . '">Created</a></span></td>');
                                 break;
                             case "DESC":
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;orderBy=ID&amp;order=DESC&websiteID=' . $this->websiteID . '">ID</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;orderBy=name&amp;order=ASC&websiteID=' . $this->websiteID . '">Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header">Website</span></td>');
                                 en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;orderBy=created&amp;order=ASC&websiteID=' . $this->websiteID . '">Created</a></span></td>');
                                 break;
                             default:
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;orderBy=ID&amp;order=DESC&websiteID=' . $this->websiteID . '">ID</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;orderBy=name&amp;order=ASC&websiteID=' . $this->websiteID . '">Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header">Website</span></td>');
                                 en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;orderBy=created&amp;order=ASC&websiteID=' . $this->websiteID . '">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=EditSections&amp;orderBy=ID&amp;order=DESC">ID</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;orderBy=name&amp;order=ASC">Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header">Website</span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;orderBy=created&amp;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=EditSections&amp;orderBy=ID&amp;order=ASC">ID</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;orderBy=name&amp;order=ASC">Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header">Website</span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;orderBy=created&amp;order=DESC">Created</a></span></td>');
                                 break;
                         }
                         break;
                     case "name":
                         switch ($this->order) {
                             case "ASC":
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;orderBy=ID&amp;order=DESC">ID</a></span></td>');
                                 en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;orderBy=name&amp;order=DESC">Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header">Website</span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;orderBy=created&amp;order=DESC">Created</a></span></td>');
                                 break;
                             case "DESC":
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;orderBy=ID&amp;order=DESC">ID</a></span></td>');
                                 en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;orderBy=name&amp;order=ASC">Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header">Website</span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;orderBy=created&amp;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=EditSections&amp;orderBy=ID&amp;order=DESC">ID</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;orderBy=name&amp;order=ASC">Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header">Website</span></td>');
                                 en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;orderBy=created&amp;order=DESC">Created</a></span></td>');
                                 break;
                             case "DESC":
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;orderBy=ID&amp;order=DESC">ID</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;orderBy=name&amp;order=ASC">Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header">Website</span></td>');
                                 en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;orderBy=created&amp;order=ASC">Created</a></span></td>');
                                 break;
                             default:
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;orderBy=ID&amp;order=DESC">ID</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;orderBy=name&amp;order=ASC">Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header">Website</span></td>');
                                 en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditSections&amp;orderBy=created&amp;order=ASC">Created</a></span></td>');
                                 break;
                         }
                         break;
                 }
             }
         }
         en('</tr>');
         if ($this->keywords || $this->websiteID) {
             $index = ($currentPage - 1) * ONPUBGUI_PDO_ROW_LIMIT;
         } else {
             $index = 0;
         }
         for ($i = 0; $i < ONPUBGUI_PDO_ROW_LIMIT && $index < sizeof($sections); $i++) {
             $section = $sections[$index];
             $this->ID = $sections[$index]->ID;
             $name = $sections[$index]->name;
             $created = $sections[$index]->getCreated()->format("M j, Y");
             $website = $owebsites->get($sections[$index]->websiteID);
             $websiteName = $website->name;
             if ($section->parentID) {
                 $names = array();
                 $names[] = $name;
                 $name = "";
                 while ($section->parentID) {
                     $section = $section->parent;
                     $names[] = $section->name;
                 }
                 $names = array_reverse($names);
                 for ($j = 0; $j < sizeof($names); $j++) {
                     if ($j == 0) {
                         $name .= $names[$j];
                     } else {
                         $name .= ' &ndash; ' . $names[$j];
                     }
                 }
             }
             en('<tr valign="top">');
             //en('<td align="right"><input type="checkbox" name="sectionIDs[]" value="' . $this->ID . '"></td>');
             switch ($this->order) {
                 case "ASC":
                     switch ($counter) {
                         case 0:
                             en('<td class="onpub-highlight1" align="right">' . $this->ID . '</td>');
                             en('<td class="onpub-highlight1" align="left"><a href="index.php?onpub=EditSection&amp;sectionID=' . $this->ID . '" title="Edit">' . $name . '</a></td>');
                             en('<td class="onpub-highlight1" align="left">' . $websiteName . '</td>');
                             en('<td class="onpub-highlight1" align="left">' . $created . '</td>');
                             break;
                         case 1:
                             en('<td class="onpub-highlight2" align="right">' . $this->ID . '</td>');
                             en('<td class="onpub-highlight2" align="left"><a href="index.php?onpub=EditSection&amp;sectionID=' . $this->ID . '" title="Edit">' . $name . '</a></td>');
                             en('<td class="onpub-highlight2" align="left">' . $websiteName . '</td>');
                             en('<td class="onpub-highlight2" align="left">' . $created . '</td>');
                             break;
                     }
                     break;
                 case "DESC":
                     switch ($counter) {
                         case 0:
                             en('<td class="onpub-highlight1" align="right">' . $this->ID . '</td>');
                             en('<td class="onpub-highlight1" align="left"><a href="index.php?onpub=EditSection&amp;sectionID=' . $this->ID . '" title="Edit">' . $name . '</a></td>');
                             en('<td class="onpub-highlight1" align="left">' . $websiteName . '</td>');
                             en('<td class="onpub-highlight1" align="left">' . $created . '</td>');
                             break;
                         case 1:
                             en('<td class="onpub-highlight2" align="right">' . $this->ID . '</td>');
                             en('<td class="onpub-highlight2" align="left"><a href="index.php?onpub=EditSection&amp;sectionID=' . $this->ID . '" title="Edit">' . $name . '</a></td>');
                             en('<td class="onpub-highlight2" align="left">' . $websiteName . '</td>');
                             en('<td class="onpub-highlight2" align="left">' . $created . '</td>');
                             break;
                     }
                     break;
                 default:
                     switch ($counter) {
                         case 0:
                             en('<td class="onpub-highlight1" align="right">' . $this->ID . '</td>');
                             en('<td class="onpub-highlight1" align="left"><a href="index.php?onpub=EditSection&amp;sectionID=' . $this->ID . '" title="Edit">' . $name . '</a></td>');
                             en('<td class="onpub-highlight1" align="left">' . $websiteName . '</td>');
                             en('<td class="onpub-highlight1" align="left">' . $created . '</td>');
                             break;
                         case 1:
                             en('<td class="onpub-highlight2" align="right">' . $this->ID . '</td>');
                             en('<td class="onpub-highlight2" align="left"><a href="index.php?onpub=EditSection&amp;sectionID=' . $this->ID . '" title="Edit">' . $name . '</a></td>');
                             en('<td class="onpub-highlight2" align="left">' . $websiteName . '</td>');
                             en('<td class="onpub-highlight2" align="left">' . $created . '</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 sections</a>.</p>');
         } else {
             if ($this->websiteID) {
                 $widget = new OnpubWidgetSelectWebsite($this->pdo, $this->websiteID);
                 $widget->display();
                 br(2);
                 en('<p>There are 0 sections in the selected website. <a href="index.php?onpub=EditSections&amp;websiteID=">Display all sections</a>.</p>');
             } else {
                 en('<p>There are 0 sections in the database. <a href="index.php?onpub=NewSection">New Section</a>.</p>');
             }
         }
     }
     if ($totalSections) {
         $widget = new OnpubWidgetStats($totalSections, $this->keywords, $this->websiteID, "Section", "Website");
         $widget->display();
     }
     en('<input type="hidden" name="onpub" value="EditSections">');
     en('</div>');
     en('</form>');
     $widget = new OnpubWidgetFooter();
     $widget->display();
 }
Exemplo n.º 5
0
 protected function init()
 {
     global $onpub_db_host, $onpub_db_name, $onpub_db_user, $onpub_db_pass, $onpub_disp_website;
     if (!ini_get("date.timezone")) {
         date_default_timezone_set('America/New_York');
     }
     $this->page = 'home';
     $this->requestedSectionID = null;
     $this->currentSection = null;
     $this->requestedArticleID = null;
     $this->currentArticle = null;
     $this->schemaInstalled = false;
     if (class_exists('PDO')) {
         $this->pdoInstalled = true;
         try {
             $onpub_pdo = new PDO('mysql:host=' . $onpub_db_host . ';dbname=' . $onpub_db_name, $onpub_db_user, $onpub_db_pass, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES latin1 COLLATE latin1_general_ci'));
             $this->lastPDOException = null;
         } catch (PDOException $e) {
             // Connection error. PDO_MYSQL driver isn't installed or DB credentials are incorrect.
             $onpub_pdo = null;
             $this->lastPDOException = $e;
         }
     } else {
         // PDO is not install at all.
         $this->pdoInstalled = false;
         $onpub_pdo = null;
         $this->lastPDOException = null;
     }
     if ($onpub_pdo) {
         $onpub_websites = new OnpubWebsites($onpub_pdo);
         $this->sections = new OnpubSections($onpub_pdo);
         $this->articles = new OnpubArticles($onpub_pdo);
         $this->samaps = new OnpubSAMaps($onpub_pdo);
         $qo = new OnpubQueryOptions();
         $qo->includeSections = true;
         try {
             $this->website = $onpub_websites->get($onpub_disp_website, $qo);
             $this->schemaInstalled = true;
             $this->lastPDOException = null;
         } catch (PDOException $e) {
             $this->website = null;
             if ($e->getCode() == 1146) {
                 // Schema has not yet been installed.
                 $this->schemaInstalled = false;
                 $this->lastPDOException = null;
             } else {
                 // There was some other DB error.
                 $this->schemaInstalled = true;
                 $this->lastPDOException = $e;
             }
         }
     } else {
         $this->website = null;
         $this->schemaInstalled = false;
     }
     if ($this->schemaInstalled) {
         // Check for legacy GET query params..
         if (isset($_GET['sectionID']) && !isset($_GET['articleID'])) {
             if (!ctype_digit($_GET['sectionID'])) {
                 en('<span style="color: red;">sectionID must be an integer.</span>');
                 exit;
             }
             $this->page = 'section';
             $this->requestedSectionID = $_GET['sectionID'];
             $this->currentSection = $this->sections->get($this->requestedSectionID);
             $this->parentSection = null;
             if ($this->currentSection && $this->currentSection->parentID) {
                 $this->parentSection = $this->sections->get($this->currentSection->parentID);
             }
         } elseif (!isset($_GET['sectionID']) && isset($_GET['articleID'])) {
             if (!ctype_digit($_GET['articleID'])) {
                 en('<span style="color: red;">articleID must be an integer.</span>');
                 exit;
             }
             $this->page = 'article';
             $this->requestedArticleID = $_GET['articleID'];
             $qo = new OnpubQueryOptions();
             $qo->includeAuthors = true;
             $this->currentArticle = $this->articles->get($this->requestedArticleID, $qo);
         } elseif (isset($_GET['sectionID']) && isset($_GET['articleID'])) {
             if (!ctype_digit($_GET['sectionID'])) {
                 en('<span style="color: red;">sectionID must be an integer.</span>');
                 exit;
             }
             if (!ctype_digit($_GET['articleID'])) {
                 en('<span style="color: red;">articleID must be an integer.</span>');
                 exit;
             }
             $this->page = 'section-article';
             $this->requestedSectionID = $_GET['sectionID'];
             $this->requestedArticleID = $_GET['articleID'];
             $this->currentSection = $this->sections->get($this->requestedSectionID);
             $this->parentSection = null;
             if ($this->currentSection && $this->currentSection->parentID) {
                 $this->parentSection = $this->sections->get($this->currentSection->parentID);
             }
             $qo = new OnpubQueryOptions();
             $qo->includeAuthors = true;
             $this->currentArticle = $this->articles->get($this->requestedArticleID, $qo);
         } elseif (isset($_GET['rss'])) {
             $this->page = 'rss';
         }
         // Check for new short/optimized GET query params..
         if (isset($_GET['s']) && !isset($_GET['a'])) {
             if (!ctype_digit($_GET['s'])) {
                 en('<span style="color: red;">s must be an integer.</span>');
                 exit;
             }
             $this->page = 'section';
             $this->requestedSectionID = $_GET['s'];
             $this->currentSection = $this->sections->get($this->requestedSectionID);
             $this->parentSection = null;
             if ($this->currentSection && $this->currentSection->parentID) {
                 $this->parentSection = $this->sections->get($this->currentSection->parentID);
             }
         } elseif (!isset($_GET['s']) && isset($_GET['a'])) {
             if (!ctype_digit($_GET['a'])) {
                 en('<span style="color: red;">a must be an integer.</span>');
                 exit;
             }
             $this->page = 'article';
             $this->requestedArticleID = $_GET['a'];
             $qo = new OnpubQueryOptions();
             $qo->includeAuthors = true;
             $this->currentArticle = $this->articles->get($_GET['a'], $qo);
         } elseif (isset($_GET['s']) && isset($_GET['a'])) {
             if (!ctype_digit($_GET['s'])) {
                 en('<span style="color: red;">s must be an integer.</span>');
                 exit;
             }
             if (!ctype_digit($_GET['a'])) {
                 en('<span style="color: red;">a must be an integer.</span>');
                 exit;
             }
             $this->page = 'section-article';
             $this->requestedSectionID = $_GET['s'];
             $this->requestedArticleID = $_GET['a'];
             $this->currentSection = $this->sections->get($this->requestedSectionID);
             $this->parentSection = null;
             if ($this->currentSection && $this->currentSection->parentID) {
                 $this->parentSection = $this->sections->get($this->currentSection->parentID);
             }
             $qo = new OnpubQueryOptions();
             $qo->includeAuthors = true;
             $this->currentArticle = $this->articles->get($this->requestedArticleID, $qo);
         } elseif (isset($_GET['rss'])) {
             $this->page = 'rss';
         }
     }
 }
Exemplo n.º 6
0
 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&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=ID&amp;order=DESC">ID</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=fileName&amp;order=ASC">File Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=created&amp;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&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=ID&amp;order=ASC">ID</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=fileName&amp;order=ASC">File Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=created&amp;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&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=ID&amp;order=DESC">ID</a></span></td>');
                                 en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=fileName&amp;order=DESC">File Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=created&amp;order=DESC">Created</a></span></td>');
                                 break;
                             case "DESC":
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=ID&amp;order=DESC">ID</a></span></td>');
                                 en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=fileName&amp;order=ASC">File Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=created&amp;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&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=ID&amp;order=DESC">ID</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=fileName&amp;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&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=created&amp;order=DESC">Created</a></span></td>');
                                 break;
                             case "DESC":
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=ID&amp;order=DESC">ID</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=fileName&amp;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&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=created&amp;order=ASC">Created</a></span></td>');
                                 break;
                             default:
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=ID&amp;order=DESC">ID</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=fileName&amp;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&amp;keywords=' . $this->keywords . '&amp;fullTextSearch=' . $this->fullTextSearch . '&amp;orderBy=created&amp;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&amp;keywords=' . $this->keywords . '&amp;orderBy=ID&amp;order=DESC">ID</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;keywords=' . $this->keywords . '&amp;orderBy=fileName&amp;order=ASC">File Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;keywords=' . $this->keywords . '&amp;orderBy=created&amp;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&amp;keywords=' . $this->keywords . '&amp;orderBy=ID&amp;order=ASC">ID</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;keywords=' . $this->keywords . '&amp;orderBy=fileName&amp;order=ASC">File Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;keywords=' . $this->keywords . '&amp;orderBy=created&amp;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&amp;keywords=' . $this->keywords . '&amp;orderBy=ID&amp;order=DESC">ID</a></span></td>');
                                 en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;keywords=' . $this->keywords . '&amp;orderBy=fileName&amp;order=DESC">File Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;keywords=' . $this->keywords . '&amp;orderBy=created&amp;order=DESC">Created</a></span></td>');
                                 break;
                             case "DESC":
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;keywords=' . $this->keywords . '&amp;orderBy=ID&amp;order=DESC">ID</a></span></td>');
                                 en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;keywords=' . $this->keywords . '&amp;orderBy=fileName&amp;order=ASC">File Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;keywords=' . $this->keywords . '&amp;orderBy=created&amp;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&amp;keywords=' . $this->keywords . '&amp;orderBy=ID&amp;order=DESC">ID</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;keywords=' . $this->keywords . '&amp;orderBy=fileName&amp;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&amp;keywords=' . $this->keywords . '&amp;orderBy=created&amp;order=DESC">Created</a></span></td>');
                                 break;
                             case "DESC":
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;keywords=' . $this->keywords . '&amp;orderBy=ID&amp;order=DESC">ID</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;keywords=' . $this->keywords . '&amp;orderBy=fileName&amp;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&amp;keywords=' . $this->keywords . '&amp;orderBy=created&amp;order=ASC">Created</a></span></td>');
                                 break;
                             default:
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;keywords=' . $this->keywords . '&amp;orderBy=ID&amp;order=DESC">ID</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;keywords=' . $this->keywords . '&amp;orderBy=fileName&amp;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&amp;keywords=' . $this->keywords . '&amp;orderBy=created&amp;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&amp;orderBy=ID&amp;order=DESC&sectionID=' . $this->sectionID . '">ID</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;orderBy=fileName&amp;order=ASC&sectionID=' . $this->sectionID . '">File Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;orderBy=created&amp;order=DESC&sectionID=' . $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&amp;orderBy=ID&amp;order=ASC&sectionID=' . $this->sectionID . '">ID</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;orderBy=fileName&amp;order=ASC&sectionID=' . $this->sectionID . '">File Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;orderBy=created&amp;order=DESC&sectionID=' . $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&amp;orderBy=ID&amp;order=DESC&sectionID=' . $this->sectionID . '">ID</a></span></td>');
                                 en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;orderBy=fileName&amp;order=DESC&sectionID=' . $this->sectionID . '">File Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;orderBy=created&amp;order=DESC&sectionID=' . $this->sectionID . '">Created</a></span></td>');
                                 break;
                             case "DESC":
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;orderBy=ID&amp;order=DESC&sectionID=' . $this->sectionID . '">ID</a></span></td>');
                                 en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;orderBy=fileName&amp;order=ASC&sectionID=' . $this->sectionID . '">File Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;orderBy=created&amp;order=DESC&sectionID=' . $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&amp;orderBy=ID&amp;order=DESC&sectionID=' . $this->sectionID . '">ID</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;orderBy=fileName&amp;order=ASC&sectionID=' . $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&amp;orderBy=created&amp;order=DESC&sectionID=' . $this->sectionID . '">Created</a></span></td>');
                                 break;
                             case "DESC":
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;orderBy=ID&amp;order=DESC&sectionID=' . $this->sectionID . '">ID</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;orderBy=fileName&amp;order=ASC&sectionID=' . $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&amp;orderBy=created&amp;order=ASC&sectionID=' . $this->sectionID . '">Created</a></span></td>');
                                 break;
                             default:
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;orderBy=ID&amp;order=DESC&sectionID=' . $this->sectionID . '">ID</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;orderBy=fileName&amp;order=ASC&sectionID=' . $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&amp;orderBy=created&amp;order=ASC&sectionID=' . $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&amp;orderBy=ID&amp;order=DESC">ID</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;orderBy=fileName&amp;order=ASC">File Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;orderBy=created&amp;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&amp;orderBy=ID&amp;order=ASC">ID</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;orderBy=fileName&amp;order=ASC">File Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;orderBy=created&amp;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&amp;orderBy=ID&amp;order=DESC">ID</a></span></td>');
                                 en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;orderBy=fileName&amp;order=DESC">File Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;orderBy=created&amp;order=DESC">Created</a></span></td>');
                                 break;
                             case "DESC":
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;orderBy=ID&amp;order=DESC">ID</a></span></td>');
                                 en('<td align="left" class="onpub-highlight2"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;orderBy=fileName&amp;order=ASC">File Name</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;orderBy=created&amp;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&amp;orderBy=ID&amp;order=DESC">ID</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;orderBy=fileName&amp;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&amp;orderBy=created&amp;order=DESC">Created</a></span></td>');
                                 break;
                             case "DESC":
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;orderBy=ID&amp;order=DESC">ID</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;orderBy=fileName&amp;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&amp;orderBy=created&amp;order=ASC">Created</a></span></td>');
                                 break;
                             default:
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;orderBy=ID&amp;order=DESC">ID</a></span></td>');
                                 en('<td align="left"><span class="onpub-field-header"><a href="index.php?onpub=EditImages&amp;orderBy=fileName&amp;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&amp;orderBy=created&amp;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&amp;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&amp;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&amp;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&amp;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&amp;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&amp;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&amp;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&amp;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&amp;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&amp;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&amp;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&amp;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();
 }