Explorar el Código

Merge branch 'Gallery' into BaseProject

Iñigo Valentin hace 9 años
padre
commit
27d448f92c

+ 53 - 3
app/AlbumViewController.swift

@@ -40,6 +40,7 @@ class AlbumViewController: UIViewController, UIGestureRecognizerDelegate {
 	
 	// Id received from segue.
 	var passId: Int = -1
+	var passAlbum: Int = -1
 	
 	
 	/**
@@ -61,6 +62,27 @@ class AlbumViewController: UIViewController, UIGestureRecognizerDelegate {
 		
 		// Set button action
 		barButton.addTarget(self, action: #selector(self.back), for: .touchUpInside)
+		
+		// Set this controller in the delegate
+		self.delegate = UIApplication.shared.delegate as? AppDelegate
+		self.delegate?.albumController = self
+		
+		// Get album title
+		let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
+		let appDelegate = UIApplication.shared.delegate as! AppDelegate
+		let lang : String = getLanguage()
+		context.persistentStoreCoordinator = appDelegate.persistentStoreCoordinator
+		let fetchRequest: NSFetchRequest<Album> = Album.fetchRequest()
+		fetchRequest.predicate = NSPredicate(format: "id = %i", id)
+		do {
+			let results = try context.fetch(fetchRequest)
+			let r = results[0]
+			let title: String = r.value(forKey: "title_\(lang)")! as! String
+			self.albumTitle.text = " \(title.decode().stripHtml())"
+		}
+		catch {
+			NSLog(":GALLERYCONTROLLER:ERROR: Error getting album info: \(error)")
+		}
 	}
 	
 	
@@ -102,8 +124,6 @@ class AlbumViewController: UIViewController, UIGestureRecognizerDelegate {
 			let searchResults = try context.fetch(fetchRequest)
 			var image: String
 			
-			NSLog(":GALLERYCONTROLLER:DEBUG: Total photos: \(searchResults.count)")
-			
 			for i in (0..<searchResults.count) where i % 2 == 0 {
 				
 				var r = searchResults[i]
@@ -156,7 +176,8 @@ class AlbumViewController: UIViewController, UIGestureRecognizerDelegate {
 				
 				rowcount = rowcount + 1
 			}
-		} catch {
+		}
+		catch {
 			NSLog(":GALLERYCONTROLLER:ERROR: Error with request: \(error)")
 		}
 	}
@@ -177,5 +198,34 @@ class AlbumViewController: UIViewController, UIGestureRecognizerDelegate {
 		}
 	}
 	
+	
+	/**
+	Run before performing a segue.
+	Assigns id if neccessary.
+	:param: segue The segue to perform.
+	:sender: The calling view.
+	*/
+	override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
+		NSLog(":GALLERYCONTROLLER:DEBUG: Preparing for segue '\(String(describing: segue.identifier))' with id \(self.passId)")
+		if segue.identifier == "SeguePhotoAlbum"{
+			(segue.destination as! PhotoViewController).albumId = passAlbum
+			(segue.destination as! PhotoViewController).photoId = passId
+		}
+	}
+	
+	
+	/**
+	Shows a photo.
+	:param: id The album id.
+	*/
+	func showPhoto(album: Int, photo: Int){
+		NSLog(":ALBUMCONTROLLER:DEBUG: Showing photo \(photo) of album \(album)")
+		// TODO: Set thoese variables and the prepare method
+		self.passAlbum = album
+		self.passId = photo
+		performSegue(withIdentifier: "SeguePhotoAlbum", sender: nil)
+		NSLog(":ALBUMCONTROLLER:DEBUG: PHOTO should be shown")
+	}
+	
 }
 

+ 1 - 0
app/AppDelegate.swift

@@ -27,6 +27,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
 
 	var window: UIWindow?
 	var controller: ViewController?
+	var albumController: AlbumViewController?
 
 	
 	func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

+ 27 - 9
app/Base.lproj/Main.storyboard

@@ -16,7 +16,7 @@
         <scene sceneID="e3W-6Z-Jyk">
             <objects>
                 <navigationController title="Gasteizko Margolariak" id="cgF-cq-ysf" sceneMemberID="viewController">
-                    <navigationBar key="navigationBar" contentMode="scaleToFill" misplaced="YES" id="lgI-h9-O0s">
+                    <navigationBar key="navigationBar" contentMode="scaleToFill" id="lgI-h9-O0s">
                         <rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
                         <autoresizingMask key="autoresizingMask"/>
                         <color key="backgroundColor" red="0.4079896717" green="1" blue="0.34807942549999998" alpha="1" colorSpace="calibratedRGB"/>
@@ -697,6 +697,7 @@
                         <outlet property="albumView" destination="YEF-04-q7Y" id="7tR-Lr-9nh"/>
                         <outlet property="barButton" destination="Thj-0t-rxK" id="6bX-xo-abt"/>
                         <outlet property="barTitle" destination="LLe-aQ-Sbj" id="bFR-jT-Xmq"/>
+                        <segue destination="hRA-2q-Tv9" kind="show" identifier="SeguePhotoAlbum" id="ftR-BO-YPe"/>
                     </connections>
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="GLj-OZ-Cqc" userLabel="First Responder" sceneMemberID="firstResponder"/>
@@ -1298,16 +1299,28 @@
                                                 <nil key="highlightedColor"/>
                                             </label>
                                             <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="78P-mw-WXM" userLabel="Content">
-                                                <rect key="frame" x="0.0" y="30" width="355" height="557"/>
+                                                <rect key="frame" x="0.0" y="30" width="355" height="567"/>
                                                 <subviews>
                                                     <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="jIN-Yy-3GU" userLabel="Photo">
-                                                        <rect key="frame" x="8" y="8" width="339" height="541"/>
+                                                        <rect key="frame" x="8" y="8" width="339" height="551"/>
                                                         <subviews>
                                                             <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="PhotoPlaceholder" translatesAutoresizingMaskIntoConstraints="NO" id="2wg-l8-Thi" userLabel="Image">
-                                                                <rect key="frame" x="10" y="10" width="319" height="406"/>
+                                                                <rect key="frame" x="10" y="10" width="319" height="413.5"/>
+                                                                <color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
+                                                                <userDefinedRuntimeAttributes>
+                                                                    <userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
+                                                                        <real key="value" value="2"/>
+                                                                    </userDefinedRuntimeAttribute>
+                                                                    <userDefinedRuntimeAttribute type="color" keyPath="borderColor">
+                                                                        <color key="value" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
+                                                                    </userDefinedRuntimeAttribute>
+                                                                    <userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
+                                                                        <real key="value" value="4"/>
+                                                                    </userDefinedRuntimeAttribute>
+                                                                </userDefinedRuntimeAttributes>
                                                             </imageView>
                                                             <label opaque="NO" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="254" text="Date" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Vhb-gI-4I7" userLabel="Date">
-                                                                <rect key="frame" x="10.5" y="451" width="319" height="20"/>
+                                                                <rect key="frame" x="10.5" y="461" width="319" height="20"/>
                                                                 <constraints>
                                                                     <constraint firstAttribute="height" constant="20" id="fXM-sB-Ii7"/>
                                                                 </constraints>
@@ -1316,7 +1329,7 @@
                                                                 <nil key="highlightedColor"/>
                                                             </label>
                                                             <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Jcy-kv-ggg">
-                                                                <rect key="frame" x="10" y="491" width="149.5" height="40"/>
+                                                                <rect key="frame" x="10" y="501" width="149.5" height="40"/>
                                                                 <color key="backgroundColor" red="0.070588235289999995" green="0.27058823529999998" blue="0.4039215686" alpha="1" colorSpace="calibratedRGB"/>
                                                                 <constraints>
                                                                     <constraint firstAttribute="height" constant="40" id="voU-YV-2ln"/>
@@ -1338,7 +1351,7 @@
                                                                 </userDefinedRuntimeAttributes>
                                                             </button>
                                                             <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="HOD-9J-wQK">
-                                                                <rect key="frame" x="179.5" y="491" width="149.5" height="40"/>
+                                                                <rect key="frame" x="179.5" y="501" width="149.5" height="40"/>
                                                                 <color key="backgroundColor" red="0.070588235289999995" green="0.27058823529999998" blue="0.4039215686" alpha="1" colorSpace="calibratedRGB"/>
                                                                 <constraints>
                                                                     <constraint firstAttribute="height" constant="40" id="6oc-MW-3JE"/>
@@ -1396,7 +1409,8 @@
                                         </subviews>
                                         <color key="backgroundColor" red="0.59607843140000005" green="0.7843137255" blue="1" alpha="1" colorSpace="calibratedRGB"/>
                                         <constraints>
-                                            <constraint firstAttribute="bottom" secondItem="78P-mw-WXM" secondAttribute="bottom" constant="10" id="JdO-O4-mee"/>
+                                            <constraint firstAttribute="bottom" secondItem="78P-mw-WXM" secondAttribute="bottom" id="JdO-O4-mee"/>
+                                            <constraint firstItem="esM-2C-p2i" firstAttribute="top" secondItem="bqh-wV-GNf" secondAttribute="top" id="KOQ-eg-hXm"/>
                                             <constraint firstItem="78P-mw-WXM" firstAttribute="width" secondItem="bqh-wV-GNf" secondAttribute="width" id="PpI-M2-bDk"/>
                                             <constraint firstItem="78P-mw-WXM" firstAttribute="centerX" secondItem="bqh-wV-GNf" secondAttribute="centerX" id="bEw-TV-GOh"/>
                                             <constraint firstItem="78P-mw-WXM" firstAttribute="top" secondItem="esM-2C-p2i" secondAttribute="bottom" id="muK-Pd-v3M"/>
@@ -1417,7 +1431,7 @@
                                         </userDefinedRuntimeAttributes>
                                     </view>
                                 </subviews>
-                                <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                                <color key="backgroundColor" red="0.70980392160000005" green="0.82745098039999998" blue="0.8980392157" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                 <constraints>
                                     <constraint firstItem="bqh-wV-GNf" firstAttribute="width" secondItem="dh0-OE-3US" secondAttribute="width" constant="-20" id="8a3-am-7Ch"/>
                                     <constraint firstItem="bqh-wV-GNf" firstAttribute="height" secondItem="dh0-OE-3US" secondAttribute="height" constant="-20" id="Tgd-YQ-aEQ"/>
@@ -1437,6 +1451,7 @@
                             <constraint firstItem="XUY-te-9PN" firstAttribute="top" secondItem="iD5-7d-BcL" secondAttribute="bottom" id="6xm-50-tbJ"/>
                             <constraint firstItem="dh0-OE-3US" firstAttribute="top" secondItem="XUY-te-9PN" secondAttribute="bottom" id="Cwk-RG-Bdj"/>
                             <constraint firstItem="dh0-OE-3US" firstAttribute="centerX" secondItem="zXb-Ja-8dX" secondAttribute="centerX" id="FEt-9c-pvb"/>
+                            <constraint firstItem="dh0-OE-3US" firstAttribute="width" secondItem="zXb-Ja-8dX" secondAttribute="width" id="MlH-pm-QQM"/>
                             <constraint firstItem="XUY-te-9PN" firstAttribute="centerX" secondItem="zXb-Ja-8dX" secondAttribute="centerX" id="vfQ-Yn-21i"/>
                             <constraint firstItem="UVa-jE-Gqw" firstAttribute="top" secondItem="dh0-OE-3US" secondAttribute="bottom" id="w47-kr-EXB"/>
                         </constraints>
@@ -1460,4 +1475,7 @@
         <image name="Logo" width="83" height="83"/>
         <image name="PhotoPlaceholder" width="170" height="108"/>
     </resources>
+    <inferredMetricsTieBreakers>
+        <segue reference="ftR-BO-YPe"/>
+    </inferredMetricsTieBreakers>
 </document>

+ 1 - 1
app/GalleryView.swift

@@ -73,7 +73,7 @@ class GalleryView: UIView {
 		let lang : String = getLanguage()
 		context.persistentStoreCoordinator = appDelegate.persistentStoreCoordinator
 		let fetchRequest: NSFetchRequest<Album> = Album.fetchRequest()
-		let sortDescriptor = NSSortDescriptor(key: "time", ascending: false)
+		let sortDescriptor = NSSortDescriptor(key: "id", ascending: false)
 		let sortDescriptors = [sortDescriptor]
 		fetchRequest.sortDescriptors = sortDescriptors
 		

+ 157 - 37
app/PhotoViewController.swift

@@ -25,13 +25,7 @@ import CoreData
 The view controller of the app.
 */
 class PhotoViewController: UIViewController, UIGestureRecognizerDelegate {
-	
-	
-	//@IBOutlet weak var barTitle: UILabel!
-	//@IBOutlet weak var barButton: UIButton!
-	//@IBOutlet weak var postText: UILabel!
-	//@IBOutlet weak var postTitle: UILabel!
-	//@IBOutlet weak var postImage: UIImageView!
+
 	@IBOutlet weak var barButton: UIButton!
 	@IBOutlet weak var barTitle: UILabel!
 	@IBOutlet weak var photoTitle: UILabel!
@@ -43,8 +37,10 @@ class PhotoViewController: UIViewController, UIGestureRecognizerDelegate {
 	var albumId: Int = -1
 	var photoId: Int = -1
 	var photoIds: [Int] = []
+	var photoIdx: Int = 0
 	var passPhotoId: Int = -1
 	var passAlbumId: Int = -1
+	var albumTitle: String = ""
 	var delegate: AppDelegate?
 	
 	
@@ -61,15 +57,60 @@ class PhotoViewController: UIViewController, UIGestureRecognizerDelegate {
 	Run when the app loads.
 	*/
 	override func viewDidLoad() {
-		NSLog(":PHOTOCONTROLLER:DEBUG: viewDidLoad")
+		NSLog(":PHOTO:DEBUG: viewDidLoad")
+		
+		// Populate photo array.
+		let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
+		let appDelegate = UIApplication.shared.delegate as! AppDelegate
+		let lang : String = getLanguage()
+		context.persistentStoreCoordinator = appDelegate.persistentStoreCoordinator
+		let fetchRequest: NSFetchRequest<Photo_album> = Photo_album.fetchRequest()
+		fetchRequest.predicate = NSPredicate(format: "album = %i", albumId)
+		do {
+			let searchResults = try context.fetch(fetchRequest)
+			
+			var id: Int
+			var i = 0
+			
+			for r in searchResults as [NSManagedObject] {
+				
+				id = r.value(forKey: "photo")! as! Int
+				photoIds.append(id)
+				if id == photoId{
+					photoIdx = i
+				}
+				i = i + 1
+			}
+			
+			// Get album title
+			let albumFetchRequest: NSFetchRequest<Album> = Album.fetchRequest()
+			albumFetchRequest.predicate = NSPredicate(format: "id = %i", albumId)
+			do {
+				let results = try context.fetch(albumFetchRequest)
+				let r = results[0]
+				self.albumTitle = r.value(forKey: "title_\(lang)")! as! String
+			}
+			catch {
+				NSLog(":GALLERYCONTROLLER:ERROR: Error getting album info: \(error)")
+			}
+			
+		} catch {
+			NSLog(":PHOTO:ERROR: Error getting infor from album \(albumId): \(error)")
+		}
+		
+		// Set up buttons
+		let tapRecognizerNext = UITapGestureRecognizer(target: self, action: #selector(nextPhoto(_:)))
+		btNext.isUserInteractionEnabled = true
+		btNext.addGestureRecognizer(tapRecognizerNext)
+		let tapRecognizerPrev = UITapGestureRecognizer(target: self, action: #selector(prevPhoto(_:)))
+		btPrev.isUserInteractionEnabled = true
+		btPrev.addGestureRecognizer(tapRecognizerPrev)
 		
 		super.viewDidLoad()
 		self.loadPhoto(id: photoId)
 		
-		// TODO populate photo array
-		
 		// Set button action
-		// TODO barButton.addTarget(self, action: #selector(self.back), for: .touchUpInside)
+		self.barButton.addTarget(self, action: #selector(self.back), for: .touchUpInside)
 	}
 	
 	
@@ -90,6 +131,24 @@ class PhotoViewController: UIViewController, UIGestureRecognizerDelegate {
 	}
 	
 	
+	/**
+	Opens the next photo.
+	*/
+	func nextPhoto(_ sender:UITapGestureRecognizer? = nil){
+		photoIdx = photoIdx + 1
+		loadPhoto(id: photoIds[photoIdx])
+	}
+	
+	
+	/**
+	Opens the previous photo.
+	*/
+	func prevPhoto(_ sender:UITapGestureRecognizer? = nil){
+		photoIdx = photoIdx - 1
+		loadPhoto(id: photoIds[photoIdx])
+	}
+	
+	
 	/**
 	Loads a photo in the viewer.
 	:param: id
@@ -109,40 +168,51 @@ class PhotoViewController: UIViewController, UIGestureRecognizerDelegate {
 			var sTitle: String
 			var sText: String
 			var image: String
+			var date: NSDate
 			
 			for r in searchResults as [NSManagedObject] {
 				
 				sTitle = r.value(forKey: "title_\(lang)")! as! String
-				// TODO photoTitle.text = "  \(sTitle.decode().stripHtml())"
-				// TODO date
+				if sTitle == "" || sTitle == "ul" {
+					sTitle = self.albumTitle
+				}
+				self.photoTitle.text = "  \(sTitle.decode().stripHtml())"
 				
-				// TODO set photo
+				// Enable or disable buttons
+				if photoIdx == 0{
+					self.btPrev.isEnabled = false
+					self.btPrev.alpha = 0.5
+				}
+				else{
+					self.btPrev.isEnabled = true
+					self.btPrev.alpha = 1
+				}
+				if photoIdx == photoIds.count - 1{
+					self.btNext.isEnabled = false
+					self.btNext.alpha = 0.5
+				}
+				else{
+					self.btNext.isEnabled = true
+					self.btNext.alpha = 1
+				}
 				
-				/*
-				// Get main image
+				// Get image
 				image = ""
-				let imgFetchRequest: NSFetchRequest<Post_image> = Post_image.fetchRequest()
-				let imgSortDescriptor = NSSortDescriptor(key: "idx", ascending: true)
-				let imgSortDescriptors = [imgSortDescriptor]
-				imgFetchRequest.sortDescriptors = imgSortDescriptors
-				imgFetchRequest.predicate = NSPredicate(format: "post == %i", id)
-				imgFetchRequest.fetchLimit = 1
-				//TODO get more images
+				let imgFetchRequest: NSFetchRequest<Photo> = Photo.fetchRequest()
+				imgFetchRequest.predicate = NSPredicate(format: "id == %i", id)
 				do{
 					let imgSearchResults = try context.fetch(imgFetchRequest)
-					for imgR in imgSearchResults as [NSManagedObject]{
-						image = imgR.value(forKey: "image")! as! String
-						if image == ""{
-							self.postImage.isHidden = true
-						}
-						else{
-							let path = "img/actividades/thumb/\(image)"
-							self.postImage.setImage(localPath: path, remotePath: "https://margolariak.com/\(path)")
-						}
-					}
-				} catch {
-					NSLog(":POST:ERROR: Error getting image for post \(id): \(error)")
-				}*/
+					let r: NSManagedObject = imgSearchResults[0]
+					image = r.value(forKey: "file")! as! String
+					date = r.value(forKey: "uploaded")! as! NSDate
+					let path = "img/galeria/preview/\(image)"
+					// TODO: Every time, set placeholder image
+					self.photoImage.setImage(localPath: path, remotePath: "https://margolariak.com/\(path)")
+					self.photoDate.text = formatDate(date: date, lang: lang)
+				}
+				catch {
+					NSLog(":PHOTO:ERROR: Error getting image for post \(id): \(error)")
+				}
 				
 			}
 		} catch {
@@ -150,8 +220,58 @@ class PhotoViewController: UIViewController, UIGestureRecognizerDelegate {
 		}
 	}
 	
+
 	
-	// TODO Buttons
+	/**
+	Formats a date to the desired language.
+	:param: text The date.
+	:param: lang Device language (only 'es', 'en', or 'eu').
+	*/
+	func formatDate(date: NSDate, lang: String) -> String{
+		
+		let months_es = ["0index", "enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"]
+		let months_en = ["0index", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
+		let months_eu = ["0index", "urtarrilaren", "otsailaren", "martxoaren", "abrilaren", "maiatzaren", "ekainaren", "ustailaren", "abustuaren", "irailaren", "urriaren", "azaroaren", "abenduaren"]
+		let days_es = ["0index", "Lunes", "Martes", "Miercoles", "Jueves", "Viernes", "Sábado", "Domingo"]
+		let days_en = ["0index", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
+		let days_eu = ["0index", "Astelehena", "Asteartea", "Asteazkena", "Osteguna", "Ostirala", "Larumbata", "Igandea"]
+		
+		let calendar = Calendar.current
+		let year = calendar.component(.year, from: date as Date)
+		let day = calendar.component(.day, from: date as Date)
+		let month = calendar.component(.month, from: date as Date)
+		let weekday = calendar.component(.weekday, from: date as Date)
+		var strDate = ""
+		
+		switch lang{
+		case "en":
+			
+			var dayNum = ""
+			switch day{
+			case 1:
+				dayNum = "1th"
+				break
+			case 2:
+				dayNum = "2nd"
+				break;
+			case 3:
+				dayNum = "3rd"
+				break;
+			default:
+				dayNum = "\(weekday)th"
+			}
+			
+			strDate = "\(days_en[weekday]), \(months_en[month]) \(dayNum), \(year)"
+			break
+		case "eu":
+			strDate = "\(year)ko \(days_eu[weekday]) \(months_eu[month]) \(day)an"
+			break
+		default:
+			strDate = "\(days_es[weekday]) \(day) de \(months_es[month]) de \(year)"
+		}
+		
+		return strDate
+	}
 	
 	
 	/**

+ 2 - 2
app/RowAlbum.swift

@@ -101,13 +101,13 @@ Extension of UIView to be formatted as sections.
 	func openLeftPhoto(_ sender:UITapGestureRecognizer? = nil){
 		NSLog(":ROWALBUM:DEBUG: Getting delegate and showing left photo.")
 		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
-		delegate.controller?.showPhoto(album: self.id, photo: self.photoIds[0])
+		delegate.albumController?.showPhoto(album: self.id, photo: self.photoIds[0])
 	}
 	
 	func openRightPhoto(_ sender:UITapGestureRecognizer? = nil){
 		NSLog(":ROWALBUM:DEBUG: Getting delegate and showing right photo.")
 		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
-		delegate.controller?.showPhoto(album: self.id, photo: self.photoIds[1])
+		delegate.albumController?.showPhoto(album: self.id, photo: self.photoIds[1])
 	}
 	
 	

+ 9 - 3
app/Sync.swift

@@ -1323,17 +1323,23 @@ class Sync{
 			//Get title_es
 			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
 			let title_es : String = str.subStr(start : str.indexOf(target : "\"title_es\":")! + 12, end : str.indexOf(target : ",\"")! - 2)
-			row.setValue(title_es, forKey: "title_es")
+			if (title_es != "ul"){ //From "null"
+				row.setValue(title_es, forKey: "title_es")
+			}
 			
 			//Get title_en
 			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
 			let title_en : String = str.subStr(start : str.indexOf(target : "\"title_en\":")! + 12, end : str.indexOf(target : ",\"")! - 2)
-			row.setValue(title_en, forKey: "title_en")
+			if (title_en != "ul"){ //From "null"
+				row.setValue(title_en, forKey: "title_en")
+			}
 			
 			//Get title_eu
 			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
 			let title_eu : String = str.subStr(start : str.indexOf(target : "\"title_eu\":")! + 12, end : str.indexOf(target : ",\"")! - 2)
-			row.setValue(title_eu, forKey: "title_eu")
+			if (title_eu != "ul"){ //From "null"
+				row.setValue(title_eu, forKey: "title_eu")
+			}
 			
 			//Get description_es
 			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)