コード例 #1
0
ファイル: Delete.php プロジェクト: alfytu/booklibrary
 /**
  * @return bool
  * @throws Exception
  */
 public function process()
 {
     $bookModel = new Book();
     if (!$bookModel->load($this->data) || !$bookModel->validate()) {
         throw new Exception('Invalid data!');
     }
     return $bookModel->delete();
 }
コード例 #2
0
ファイル: Set.php プロジェクト: alfytu/booklibrary
 /**
  * @return bool
  * @throws Exception
  */
 public function process()
 {
     $bookModel = new Book();
     if ($bookModel->load($this->data) && $bookModel->validate()) {
         $bookModel->save();
         return (array) $bookModel;
     }
     throw new Exception('Invalid data!');
 }
コード例 #3
0
		public function find ($id= null){
			if ($id!= null){
				$book= new Book();
				$book->load($id);
				return $book;
			}
			else{
				$error = new GsError(303,"Error loading book.");
				throw $error;
			}
		}
コード例 #4
0
ファイル: View.php プロジェクト: alfytu/booklibrary
 /**
  * @return array
  * @throws Exception
  */
 public function process()
 {
     $bookModel = new Book();
     if (!$bookModel->load($this->data)) {
         return $bookModel->getAllRecords();
     }
     if ($bookModel->validate()) {
         return $bookModel->getRecords();
     }
     throw new Exception('Invalid data!');
 }
コード例 #5
0
 /**
  * Export a sheet to Html table
  *
  * @param Sheet $sheet
  * @return String
  */
 public static function toHTML($sheet)
 {
     $maxCol = FormatController::maxWrittenColumn($sheet);
     $maxRow = FormatController::maxWrittenRow($sheet);
     $book = new Book();
     $book->load($sheet->getBookId());
     $cells = $sheet->cells;
     unset($output);
     $output .= '<table border=1 border-collapse="collapse">';
     for ($i = 0; $i <= $maxRow; $i++) {
         $output .= '<tr>';
         for ($j = 0; $j <= $maxCol; $j++) {
             $cell = $sheet->getCell($i, $j);
             $fsId = 0;
             if ($cell != null) {
                 $fsId = $cell->getFontStyleId();
             }
             $output .= '<td class="c' . $fsId . '">';
             if ($cell != null) {
                 //$output.= $sheet->getData($i,$j);
                 $output .= $cell->getFormula();
             }
             $output .= '</td>';
         }
         $output .= '</tr>';
     }
     $output .= '</table>';
     $style = '<style type="text/css" media="screen">';
     $style .= "table{border-collapse:collapse;}";
     $style .= "td{border:1px solid #CCC;height:18px;width:80px;position:relative;}";
     foreach ($book->getFontStyles() as $fstyle) {
         $style .= FormatController::fontStyleToCss($fstyle) . "\n";
     }
     $style .= '</style>';
     $output = '<html><head>' . $style . '</head><body>' . $output . '</body></html>';
     return $output;
 }
コード例 #6
0
/**
 * find all images on page from pageflip and replace it by <a><img></a>
 * @param string $content - content of post
 * @return string - changed content
 */
function wpimage_pageflip_filter($content)
{
    //FlippingBook
    global $pageFlip;
    // error_reporting(-1);
    if (is_object($pageFlip) && is_a($pageFlip, 'pageFlip_plugin_base')) {
        $matches = array();
        preg_match_all("/\\[\\s*book\\s*id='([0-9]*)'[\\s\\/]*\\]/", $content, $matches);
        if (empty($matches[1])) {
            return $content;
        }
        foreach ($matches[1] as $match_key => $code) {
            $book = new Book($code);
            $book->load();
            $out = '';
            foreach ($book->pages as $key => $page) {
                //                $out .= '<a href="'.$book->pages[$i]->image.'">
                //                <img src="'.$book->album->images[$i]->thumb.'" '.($i == 0?'data-wiziapp-pageflipbook-id="'.$code.'"':'').'>
                //                </a>';
                /** We dont resize images anymore!!! Only thumbnails, on demand.
                                $image = new WiziappImageHandler($page->image);
                
                                $size = wiziapp_getImageSize('full_image');
                                $url_to_full_sized_image = $image->getResizedImageUrl($page->image, $size['width'], $size['height'], 'resize');
                
                                $size = wiziapp_getImageSize('multi_image');
                                $urlToMultiSizedImage = $image->getResizedImageUrl($page->image, $size['width'], $size['height'], 'resize');
                                
                                $width = $image->getNewWidth();
                                $height = $image->getNewHeight();
                
                                $sizeHtml = " width=\"{$width}\" height=\"{$height}\" "; */
                $out .= '<a href="' . $page->image . '" class="wiziapp_gallery wiziapp_pageflip_plugin"><img src="' . $page->image . '" data-wiziapp-pageflipbook-id="' . $code . '"></a>';
            }
            $content = str_replace($matches[0][$match_key], $out, $content);
        }
    }
    return $content;
}
コード例 #7
0
ファイル: Book.class.php プロジェクト: Jtgadbois/Pedadida
		/**
		 * Saves the book into de database.
		 * If the id isn't setted, automatically assigns one
		 *
		 **/
		public function save(){
			
			
			$update = false ; 
			$hasErrors = false;

			if(!isset($this->userId))
				$this->userId = 1;    //TODO: Remove only for debugging user must be always setted (logged user)
			
			$sql = "INSERT INTO ".table('books'). " (BookId, BookName, UserId) VALUES ($this->bookId,'$this->bookName',$this->userId)";


			if (isset($this->bookId)) { // Edit book..
				//Check if the the id is correct..
				$res = mysql_query("SELECT BookId FROM ".table('books'). " where BookId=$this->bookId");
				if(!$res){
					$error = new GsError(302,"Error loading book.");
					if($error->isDebugging()){
						$error->addContentElement("BookId",$BookId);
						$err = str_replace("'", '"', mysql_error());
						$error->addContentElement("MySql Error",$err);
					}
					throw $error;					
					$hasErrors = true;
				}

				$row = mysql_fetch_object($res);
				if (!$row) {
					//ERROR: trying to save a book that does exist. Must have null value the bookid
					if(!mysql_query($sql)){
						$error = new GsError(302,"Error saving book. Book don't exists");
						if($error->isDebugging()){
							$error->addContentElement("BookId",$BookId);
							$err = str_replace("'", '"', mysql_error());
							$error->addContentElement("MySql Error",$err);
						}
						throw $error;					
					}

				}else {
				// OK: Delete.. and save it again
					$update = true;
					mysql_query("START TRANSACTION");
					$book_tmp = new Book();
					$book_tmp->load($this->bookId);
					$book_tmp->delete(true);


					if(!mysql_query($sql)){
						$error = new GsError(302,"Error saving book. Book don't exists");
						if($error->isDebugging()){
							$error->addContentElement("BookId",$BookId);
							$err = str_replace("'", '"', mysql_error());
							$error->addContentElement("MySql Error",$err);
						}
						throw $error;					
						$hasErrors = true;
					}

				}

			}else { 
				//SAVE AS...
				
				$sql = "INSERT INTO ".table('books'). " (BookName, UserId) VALUES ('$this->bookName',$this->userId)";
				$query = mysql_query($sql);
				if($query)
					$this->bookId= mysql_insert_id();
				else{
					
					$error = new GsError(302,"Error saving book.");
					if($error->isDebugging()){
						$error->addContentElement("BookId",$BookId);
						$err = str_replace("'", '"', mysql_error());
						$error->addContentElement("MySql Error",$err);
					}
					throw $error;					
					
					$hasErrors = true;
				}
			}
			
			//COMMON CODE..
			if(!$hasErrors){
				foreach ($this->sheets as $sheet) {
					$sheet->bookId = $this->bookId;
					$hasErrors = $sheet->save();
				}
			}

			if(!$hasErrors){
				foreach ($this->fontStyles as $fontStyle) {
					$fontStyle->bookId = $this->bookId;
					$hasErrors = $fontStyle->save();
				}
			}
			
			if(!$hasErrors){
				foreach ($this->layoutStyles as $layoutStyle) {
					$layoutStyle->bookId = $this->bookId;
					$hasErrors = $layoutStyle->save();
				}
			}
			
			
			if ($update) {
				//if update means that a transaction was started.. 
				//so check for errors and commit if ok
				 
				if (!$hasErrors)
					mysql_query("COMMIT");
				else 
					mysql_query("ROLLBACK") ;	
			}	
			return $hasErrors;
		}
コード例 #8
0
ファイル: BiberLog.php プロジェクト: rasstroen/metro
 private static function restoreMagazineNumber($id_book, $number)
 {
     if (!$number) {
         list($number, $id_magazine) = Database::sql2row("SELECT `n`,`id_magazine` FROM `book_magazines` WHERE `id_book`=" . $id_book);
     } else {
         $id_magazine = Database::sql2single("SELECT `id_magazine` FROM `book_magazines` WHERE `id_book`=" . $id_book);
     }
     if (!$number) {
         return;
     }
     global $current_user;
     $magazineData = Database::sql2row('SELECT * FROM `magazines` WHERE `id`=' . $id_magazine);
     $query = 'UPDATE `book_magazines` SET `n`=' . $number . '  WHERE `id_book`=' . $id_book;
     Database::query($query);
     $book = new Book($id_book);
     $book->load();
     $year = $book->data['year'];
     $title = $magazineData['title'];
     $subtitle = '№ ' . $number . ' за ' . $book->data['year'] . ' год';
     $query = 'UPDATE `book` SET `title`=' . Database::escape($title) . ' , `subtitle`=' . Database::escape($subtitle) . ' WHERE `id`=' . $id_book;
     Database::query($query);
 }