ONE WHO SEES THE PLACE OF THE MIKDASH
Gemara
(Beraisa): Ichuy (sewing back) is forbidden for the following tears...one who tore for seeing (desolate) cities of Yehudah, the Mikdash and Yerushalayim. One tears for seeing the Mikdash, and adds (to the tear) for Yerushalayim.
We learn this from "Va'Yavo'u Anashim mi'Shechem mi'Shilo umi'Shomron... u'Kru'ei Vegadim" - this connotes that their garments will be torn forever.
R. Chelbo: One who sees desolate cities of Yehudah says "Arei Kodshecha Hayu Midbar" and tears. When he sees Yerushalayim he says "Tziyon Midbar Hayasah Yerushalayim Shemamah" and tears. When he sees the Mikdash he says "Beis Kodsheinu...Hayah l'Charbah" and tears.
(Beraisa): He tears for seeing the Mikdash, and adds for Yerushalayim.
Contradiction (Beraisa): One who hears or sees, once he reaches Tzofim (from where Yerushalayim can be seen) he tears. He makes separate tears for the Mikdash and for Yerushalayim.
Answer: If he saw the Mikdash first, he adds for Yerushalayim. If he saw Yerushalayim first, he tears for it, and a separate tear for the Mikdash.
(Beraisa): For these tears it is permitted Lesholelan, Lemolelan, Leloktan, or to make (spaces between pairs of stitches, so they look) like ladders, but not Ichuy (these will be explained).
(Rav Chisda): Ichuy Alexandri is forbidden.
22b - Beraisa: For all Mesim (except for a parent) one tears a Tefach. Even if he is wearing 10 garments it suffices to tear the outermost one. He may be Sholel after seven days and be Me'acheh after 30 days. For a parent, one tears all of them, until he bares his heart. He may be Sholel after 30 days, but he may never be Me'acheh.
For all Mesim, one may tear by hand or using a Keli; he tears (from the) inside. For a parent one must tear by hand, parent one tears (from the) outside.
(Beraisa): All of these (tears for which Ichuy may never be done) are like a parent only regarding Ichuy.
Rishonim
The Rif and Rosh (3:64,65) bring these teachings.
Nimukei Yosef (DH Elu): When he sees Yerushalayim first he may not merely add to that tear for the Mikdash, lest the tear for the Mikdash not be noticeable. Therefore, he must distance three fingers from the neck opening and tear the proper Shi'ur.
Rosh (3:64): Presumably, one tears only for the first city of Yehudah that he sees. If not, why did it need to say that he tears for Yerushalayim? The Yerushalmi says that one does not tear within 30 days of the last time he saw.
Rosh (Berachos 9:1): It is unreasonable that one who sees the king every day will bless every day. Rather, all such Berachos are made only after 30 days.
Rosh (65): The Ra'avad says that Ichuy Alexandri is how we sew. It is even (flush) on top and sticks out on bottom. The Ramban calls this normal Ichuy; Ichuy Alexandri is even on top and on bottom. The Ra'avad's opinion is primary. Stitching always sticks out on bottom. Normal Ichuy is from the inside. Ichuy Alexandri is from the outside. He makes the stitches even with the threads of the garment so it is not noticeable.
Nimukei Yosef (DH v'Chulan): Lesholelan and Lemolelan are tying together threads on the two sides of the tear. Some say that it is sewing with wide stitches. Leloktan is to gather the entire rent together and stick a needle through it two or three times. The Yerushalmi says that Ichuy (that is forbidden) is when the place (of the stitching) is not noticeable.
Rashi (22b DH Me'acheh): Ichuy is sewing normally.
Rambam (Hilchos Ta'anis 5:16:): One who sees desolate cities of Yehudah says "Arei Kodshecha..." and tears. When he sees Yerushalayim he says "Tziyon Midbar Hayasah..." and tears. When he sees the Mikdash he says "Beis Kodsheinu..." and tears. One tears once he gets to Tzofim. When he reaches the Mikdash he makes another tear. If he encounters the Mikdash first when he come from the Midbar, he tears for the Mikdash and adds for Yerushalayim.
Ritva (DH Sham she'Kevar): If one comes from the east he sees the Mikdash before Yerushalayim, because it is on Har ha'Bayis, which is higher. Alternatively, he came to the Mikdash in a wagon.
Rambam (17): All these tears must be done by hand while standing. He tears all his garments, until he bares his heart. He never does Ichuy. He may be Sholelan, Molelan, Loktan, or make like ladders
Rebuttal (Ra'avad): We learned (22b) that the tear is like that for a parent only regarding Ichuy, but not regarding tearing by hand and baring the heart.
Magid Mishnah: The Rambam understands that since Ichuy is forbidden for these tears, just like a tear for a parent, they are similar in these ways also.
Question (Mishneh l'Melech): The Rambam himself does not require all of these conditions when tearing for one's Rebbi or for hearing blasphemy, even though Ichuy is forbidden!
Rambam (18): If one went to Yerushalayim, returned and went back again, he tears only if 30 days passed since the last time he saw.
Rambam (Hilchos Evel 9:10): We learn from "Va'Yavo'u Anashim..." that one tears for seeing in desolation cities of Yehudah, Yerushalayim and the Mikdash.
Ritva (ibid.): The Beraisa says that one who hears must tear. This refers to one who heard about the Churban at that time.
Rashash (DH u'Rminhi): Alternatively, it refers to a Tinuk she'Nishbah who just learned about the Churban now.
Poskim
Shulchan Aruch (OC 561:1,2 and YD 340:38): One who sees desolate cities of Yehudah says "Arei Kodshecha..." and tears.
Beis Yosef (DH ha'Ro'eh): Here the Tur wrote 'for Arei Yisrael', but in Yoreh De'ah (340) he wrote Arei Yehudah, like the Gemara. The cities listed in the verse are of Yisrael, not of Yehudah! Perhaps they did not tear until they saw ha'Mitzpah, a city of Yehudah. If the cities are inhabited but are controlled by Nochrim, it seems that one tears.
Kaf ha'Chayim (2): The Levush says that we tear only for cities of Yehudah, for they are close to Yerushalayim. The Bach says that cities of (Malchus) Yisrael are not as important.
Kaf ha'Chayim (3): Chesed l'Avraham says that we do not tear for Chevron because it was an Ir Miklat of the Leviyim, hence it is not considered an Ir of Yehudah. Others disagree.
Rema: One need not tear until he is close, like one tears for Yerushalayim when he gets to Tzofim.
Beis Yosef (DH u'Mah she'Chosav umi'Heichan): If one saw the Mikdash before reaching Tzofim he does not tear yet, for seeing from so far is not considered seeing.
Magen Avraham (3): This is unlike Tosfos (Pesachim 49a DH Im), who says that Tzofim is any place from which one can see Yerushalayim.
Mishnah Berurah (3): Several Poskim require tearing from anywhere from which one can see.
Shulchan Aruch (OC 2 and YD 38): One who sees Yerushalayim in its destruction says "Tziyon Midbar Hayasah..." When he sees the Mikdash he says "Beis Kodsheinu..." and tears.
Mishnah Berurah (4): Some say that one should not eat meat and wine the first time he sees Yerushalayim desolate.
Mishnah Berurah (6): One should bow, tear, cry, moan and mourn over the Churban. He should say the entire Tehilim 79. When tearing he blesses, without Shem and Malchus, 'Baruch Dayan ha'Emes Ki Kol Mishpatav Tzedek...'
Kaf ha'Chayim (5): The Berachah was enacted for new bad tidings, therefore we do not say it with Shem and Malchus. Afterwards, he says "Samchenu ki'Ymos Iniseinu..."
Shulchan Aruch (OC): One tears once he gets to Tzofim. When he sees the Mikdash he tears a different tear. Each tear is a Tefach.
Source (Beis Yosef DH uv'Mai): We learn from one who lost one relative after another. He tears a Tefach for each (26b).
Shulchan Aruch (OC): If he encounters the Mikdash when he comes from the Midbar, he tears for the Mikdash a Tefach. When he sees Yerushalayim he adds to the tear any amount.
Shulchan Aruch (OC 3): One who tore for a city of Yehudah does not tear for other cities of Yehudah, except for Yerushalayim. One who tore for Yerushalayim does not tear for cities of Yehudah.
Source: Magid Mishnah citing Ramban.
Mishnah Berurah (10): One who tore for a city of Yehudah adds any amount to the tear for another such city. If he tore for Yerushalayim he does not tear at all for other cities of Yehudah.
Shulchan Aruch (OC 4 and YD 39): All of these tears must be done by hand while standing. He tears all his garments, until he bares his heart. He never sews them back normally, but it is permitted Lemolelan, Lesholelan, Leloktan, or to make like ladders.
Magen Avraham (4): He tears on the left, for the heart is on the left.
Beis Yosef (YD DH v'Chosav Rabeinu): Lesholelan is to make wide stitches. Lemolelan/Leloktan is to gather the entire rent together and make two or three stitches/stick a needle through it two or three times.
Shulchan Aruch (OC 5): If one went to Yerushalayim, returned and went back again, he tears only if 30 days passed since the last time he saw.
Magen Avraham (6): Even if one did not tear for Yerushalayim, e.g. he lives there, he need not tear for seeing Arei Yehudah within 30 days. One who lived in Yerushalayim from childhood need not tear when he grows up, since he was exempt when he first saw it.
Kaf ha'Chayim (26): The Radvaz says that one who lives in Yerushalayim and did not see the Mikdash for 30 days must tear the next time he sees it. The custom is not like this.
Rema: The same applies to returning to see cities of Yehudah and the Mikdash.