Пример #1
0
 public function __construct($page_path)
 {
     $conn = dataObject::connect();
     $sql = "select articleID,page_no,language,file_size,file_name,file_path from pages where file_path= :file_path;";
     try {
         $st = $conn->prepare($sql);
         $st->bindValue(":file_path", $page_path, PDO::PARAM_STR);
         $st->execute();
         $row = $st->fetch();
         if ($row) {
             list($this->articleID, $this->page_no, $this->language, $this->file_size, $this->file_name, $this->file_path) = $row;
         }
     } catch (PDOException $e) {
         dataObject::disconnect($conn);
         die("failed to retrieve page:" . $e->getMessage());
     }
 }
Пример #2
0
 public static function browseArticle(array $filterValues)
 {
     $title = $filterValues['title'];
     $author = $filterValues['author'];
     $year = $filterValues['year'];
     $conn = dataObject::connect();
     $sql = "select * from authors natural join author_article natural join articles";
     if ($author || $title || $year) {
         $sql .= " where";
     }
     $count = 0;
     if ($author) {
         $sql .= " authors.name like :author";
         if ($title || $year) {
             $sql .= " and";
         }
     }
     if ($title) {
         $sql .= " articles.title like :title";
         if ($year) {
             $sql .= " and";
         }
     }
     if ($year) {
         $sql .= " year= :year";
     }
     $sql .= ';';
     try {
         $st = $conn->prepare($sql);
         if ($author) {
             $st->bindValue(":author", $author, PDO::PARAM_STR);
         }
         if ($year) {
             $st->bindValue(":year", $year, PDO::PARAM_INT);
         }
         if ($title) {
             $st->bindValue(":title", $title, PDO::PARAM_STR);
         }
         $st->execute();
         return $st->fetchAll();
     } catch (PDOException $e) {
         dataObject::disconnect($conn);
         die("Query failed: " . $e->getMessage());
     }
 }
 public function submitTranslation($translated_content, $page_path)
 {
     $ourPage = new Page($page_path);
     //remove first entry from queue csv
     $queueHandle = fopen("../pages/pageQueue.csv", 'r');
     $currpage = fgetcsv($queueHandle);
     $newQueue = fopen("../pages/pageQueue2.csv", 'w');
     while ($record = fgetcsv($queueHandle)) {
         fputcsv($newQueue, $record);
     }
     fclose($queueHandle);
     fclose($newQueue);
     chmod("../pages/pageQueue.csv", 0777);
     unlink("../pages/pageQueue.csv");
     rename("../pages/pageQueue2.csv", "../pages/pageQueue.csv");
     //save new page in directory
     $pagehandle = fopen("../translatedPages/{$ourPage->getFileName()}_translated.txt", 'w');
     fwrite($pagehandle, $translated_content);
     fclose($pagehandle);
     //make entry into database
     $conn = dataObject::connect();
     $sql = "insert into pages(articleID,page_no,language,file_name,file_size,file_path) values( :articleID, :page_no," . '"hindi",' . ":file_name, :file_size, :file_path);";
     try {
         $st = $conn->prepare($sql);
         $st->bindValue(":articleID", $ourPage->getarticleID(), PDO::PARAM_INT);
         $st->bindValue(":page_no", $ourPage->getpageNo(), PDO::PARAM_INT);
         $st->bindValue(":file_name", "{$ourPage->getFileName()}_translated.txt", PDO::PARAM_STR);
         $st->bindValue(":file_size", filesize("../translatedPages/{$ourPage->getFileName()}_translated.txt"), PDO::PARAM_STR);
         $st->bindValue(":file_path", realpath("../translatedPages/{$ourPage->getFileName()}_translated.txt"), PDO::PARAM_STR);
         $st->execute();
     } catch (PDOException $e) {
         dataObject::disconnect($conn);
         die("failed to add page:" . $e->getMessage());
     }
     dataObject::disconnect($conn);
 }
Пример #4
0
 public function updatePaperDetails($title, $newTitle, $newLanguage, $newYear)
 {
     $conn = dataObject::connect();
     $sql = "update articles set title= :newtitle, year= :year, language= :language where title= :title;";
     try {
         $st = $conn->prepare($sql);
         $st->bindValue(':newtitle', $newTitle, PDO::PARAM_STR);
         $st->bindValue(':title', $title, PDO::PARAM_STR);
         $st->bindValue(':language', $newLanguage, PDO::PARAM_STR);
         $st->bindValue(':year', $newYear, PDO::PARAM_INT);
         $st->execute();
     } catch (PDOException $e) {
         dataObject::disconnect($conn);
         die("Query failed:" . $e->getMessage());
     }
 }
Пример #5
0
 public static function retrieveUnpublished()
 {
     $articleArray = array();
     $sql = "select Title,no_of_pages from articles where no_of_translations = 0 and no_of_pages > 0";
     try {
         $conn = dataObject::connect();
         $st = $conn->prepare($sql);
         $st->execute();
         $rows = $st->fetchAll();
         dataObject::disconnect($conn);
     } catch (PDOException $e) {
         dataObject::disconnect($conn);
         die("failed to retrieve articles:" . $e->getMessage());
     }
     $sql = "select count(*) as number from articles join pages on articles.articleID=pages.articleID where articles.Title= :title and pages.language= :language";
     $st = $conn->prepare($sql);
     $st->bindValue(":language", 'hindi', PDO::PARAM_STR);
     foreach ($rows as $row) {
         $st->bindValue(":title", $row['Title'], PDO::PARAM_STR);
         $st->execute();
         $num = $st->fetch();
         if ($num['number'] == $row['no_of_pages']) {
             $articleArray[] = $row['Title'];
         }
     }
     return $articleArray;
 }
Пример #6
0
 public function publishArticle($articleID)
 {
     //merge translated page content and create pdf
     $sql = 'select * from pages where articleID= :articleID and language= :language';
     $conn = dataObject::connect();
     try {
         $st = $conn->prepare($sql);
         $st->bindValue(":articleID", $articleID, PDO::PARAM_INT);
         $st->bindValue(":language", 'hindi', PDO::PARAM_STR);
         $st->execute();
         $rows = $st->fetchAll();
     } catch (PDOException $e) {
         dataObject::disconnect($conn);
         die("failed to retrieve pages:" . $e->getMessage());
     }
     $str = '';
     foreach ($rows as $row) {
         $pageObj = new Page($row['file_path']);
         $str .= $pageObj->loadContentTranslated();
     }
     //add to file
     $handle = fopen("../translations/{$articleID}_translated.txt", 'w');
     fwrite($handle, $str);
     fclose($handle);
     //Make entry into database
     $sql = "insert into translations(articleID,language,file_size,file_name,file_path) values( :articleID, :language, :filesize, :filename, :filepath);";
     try {
         $st = $conn->prepare($sql);
         $st->bindValue(":articleID", $articleID, PDO::PARAM_INT);
         $st->bindValue(":language", 'hindi', PDO::PARAM_STR);
         $st->bindValue(":filesize", filesize("../translations/{$articleID}_translated.txt"), PDO::PARAM_INT);
         $st->bindValue(":filename", "{$articleID}_translated.txt", PDO::PARAM_STR);
         $st->bindValue(":filepath", realpath("../translations/{$articleID}_translated.txt"), PDO::PARAM_STR);
         $st->execute();
     } catch (PDOException $e) {
         dataObject::disconnect($conn);
         die("failed to add translation:" . $e->getMessage());
     }
     $sql = "update articles set no_of_translations = no_of_translations+1 where articleID= :articleID";
     try {
         $st = $conn->prepare($sql);
         $st->bindValue(":articleID", $articleID, PDO::PARAM_INT);
         $st->execute();
     } catch (PDOException $e) {
         dataObject::disconnect($conn);
         die("failed to update no-of-translations:" . $e->getMessage());
     }
 }
<body style="background-image :url(iitilogo-2.png);
		background-repeat: no-repeat;
		background attachment: fixed;
		background-position: 50% 28%;
		background-size: 500px 800px
		">

<?php 
require_once 'dataObject.php';
require_once '../classes/Article.php';
require_once '../classes/Admin.php';
require_once '../classes/Page.php';
$title = $_GET['title'];
$pageno = $_GET['pageno'];
$count = $_GET['count'];
$conn = dataObject::connect();
$adminObj = new Admin();
$articleObj = new Article($title);
$sql = 'select no_of_pages from articles where Title= :title';
try {
    $st = $conn->prepare($sql);
    $st->bindValue(":title", $title, PDO::PARAM_INT);
    $st->execute();
    $row = $st->fetch();
} catch (PDOException $e) {
    dataObject::disconnect($conn);
    die("dfailed to retrieve:" . $e->getMessage());
}
$num = $row['no_of_pages'];
if (isset($_POST['finalize'])) {
    $pageno++;