updated date pathauto addressfield honeypot features modules
This commit is contained in:
@@ -1,298 +1,298 @@
|
||||
AT NULL Feldkirch NULL 6800 Pater Grimm Weg 20
|
||||
AU NULL Melbourne NULL
|
||||
AU NULL Sydney NULL
|
||||
AU 04 NULL NORMANBY NULL 4059 30 Normanby Terrace
|
||||
BD NULL Dhaka NULL 1205 23, Subal Das Road, Chowdhury Bazar, Lalbagh
|
||||
BD NULL Dhaka NULL 1207 R-1,H-19,Kallaynpur,Mirpur,Dhaka
|
||||
BD NULL Dhaka NULL 1207 World Bank Office Dhaka, Plot E 32, Agargaon, Sher-E-Bangla Nagar
|
||||
BD NULL Dhaka NULL 1209 House# 66B, Flat# B2 Zigatola
|
||||
BD NULL Dhaka NULL 1219 390 West Rampura Dhaka
|
||||
BD NULL Dhaka NULL 1230 Uttara
|
||||
BD 81 NULL Dhaka NULL 1000 Institute of Water and Flood Management
|
||||
BD 81 NULL Dhaka NULL 1203 84/a maniknagar
|
||||
BD 81 NULL Dhaka NULL 1205 Dhaka Bangladesh
|
||||
BD 81 NULL Dhaka NULL 1207 BetterStories Limited 17 West Panthopath
|
||||
BD 81 NULL Dhaka NULL 1216 Mirpur, Dhaka
|
||||
BD 81 NULL Dhaka NULL 1230 830, Prembagan, Dhakshin Khan
|
||||
BD 82 NULL khulna NULL 9203
|
||||
BD NULL NULL Dhaka NULL 1000 Institute of Water and Flood Management
|
||||
BD NULL NULL Dhaka NULL 1207 World Bank Office Dhaka, Plot E 32, Agargaon, Sher-E-Bangla Nagar
|
||||
BE NULL Brussels NULL
|
||||
BE NULL Watermael-Boitsfort NULL 1170 Avenue des Staphylins
|
||||
BH NULL Manama NULL 00973 Manama Bahrain Manama Bahrain
|
||||
BR NULL Porto Alegre NULL
|
||||
BR NULL Recife NULL
|
||||
BR RJ NULL Rio de Janeiro NULL
|
||||
BW NULL Francistown NULL NULL
|
||||
BW NULL NULL Francistown NULL NULL
|
||||
CA NULL Montreal NULL
|
||||
CA NULL Toronto NULL
|
||||
CA BC NULL Vancouver NULL
|
||||
CA ON NULL Kitchener NULL
|
||||
CA ON NULL wterloo NULL n2l3g1 200 University Avenue West
|
||||
CH NULL Geneva NULL 1202 15, chemin Louis-Dunant
|
||||
CH 25 NULL Zurich NULL 8098 UBS Optimus Foundation Augustinerhof 1
|
||||
DE NULL Berlin NULL
|
||||
DE 05 NULL Frankfurt am Main NULL 60386 Johanna-Tesch-Platz 7
|
||||
DK NULL Aarhus NULL
|
||||
ES NULL Bilbao NULL
|
||||
ET 44 NULL ADDIS ABABA NULL 11945 ADDIS ABABA,P.O.BOX 11945
|
||||
FI NULL Espoo NULL 02130 Mahlarinne 3B
|
||||
FI NULL Helsinki NULL 00580 Hermannin rantatie 2 A Hermannin rantatie 2 A
|
||||
FI NULL Tampere NULL 33101 Tampere Univerity of Technology
|
||||
FI 13 NULL Espoo NULL 02150 Aalto Venture Garage Betonimiehenkuja 3
|
||||
GB NULL Exeter NULL
|
||||
GB NULL London NULL
|
||||
GB NULL London NULL N4 2DP 2 Myddleton Ave
|
||||
GB NULL London NULL N7 0AH 104 St George’s Avenue
|
||||
GB NULL London NULL SE16 3UL 25 Blue Anchor Lane
|
||||
GB NULL London NULL SW18 5SP Flat 1 150 Merton road
|
||||
GB NULL London NULL W1T 4BQ 13 Fitzroy Street
|
||||
GB NULL Oxford NULL
|
||||
GB NULL Southampton NULL
|
||||
GB C3 NULL NULL cb244qg 32 market street swavesey
|
||||
GB E7 NULL London NULL SE3 7TP
|
||||
GB F3 NULL Wood Green NULL N22 5RU 6 Cedar House
|
||||
GB H1 NULL London NULL SE11 5JD 47-49 Durham Street
|
||||
GB H6 NULL London NULL SE8 4DD 8 Harton St Deptford
|
||||
GB K2 NULL Oxford NULL OX2 6QY 3 The Villas, Rutherway
|
||||
GH 05 NULL NSAWAM NULL NULL P.O.BOX 455
|
||||
GH NULL NULL Accra NULL NULL
|
||||
ID NULL Bandung NULL 40134 Jalan Sadang Hegar 1 No. 12 RT04 RW13 Sadang Serang
|
||||
ID NULL Bekasi NULL 17411 Jl.Binadharma 1 No.62. Jatiwaringin
|
||||
ID NULL Jakarta NULL
|
||||
ID NULL Jakarta NULL 12440 Jl. H. Niin 7 Lebak Bulus, Cilandak
|
||||
ID NULL Jakarta NULL 13330 Otista
|
||||
ID NULL Jakarta selatan NULL 12000 jl. rawa jati timur 6 no. 10
|
||||
ID NULL Jakarta Timur NULL Jl.Mulia No.15B Kel.Bidara Cina, Kec.Jatinegara, Jakarta Timur
|
||||
ID NULL Pematang Siantar NULL 51511 Jl. Durian I 30
|
||||
ID 04 NULL Bogor NULL 16165
|
||||
ID 04 NULL jakarta NULL otista
|
||||
ID 04 NULL Jakarta NULL 12520 Jl. Pertanian Raya III No.42 Jakarta Selatan Pasar Minggu
|
||||
ID 04 NULL Jakarta NULL 13330 Jakarta
|
||||
ID 04 NULL Jakarta NULL 13330 Jl Sensus IIC Bidaracina Jaktim
|
||||
ID 04 NULL Jakarta NULL 13330 Jl. Bonasut 2 no.22
|
||||
ID 04 NULL Jakarta NULL 13330 Otista 64c
|
||||
ID 04 NULL jakarta NULL 13330 Otista jaktim
|
||||
ID 04 NULL Jakarta Timur NULL 13330 Kebon Sayur I no. 1 RT 10/15
|
||||
ID 04 NULL Jakarta Timur NULL 13460 Jl. Pondok Kopi Blok G4/5 RT. 005/08 Jakarta Timur
|
||||
ID 04 NULL Jakarta Timur NULL 13810 Jl. Raya Pondok Gede Rt03 Rw08 no.35 , Lubang Buaya, Jakarta Timur Jl. Raya Pondok Gede Rt03 Rw08 no.35 , Lubang Buaya, Jakarta Timur
|
||||
ID 07 NULL Brebes NULL 54321 Jl Kersem Blok D14 Perum Taman Indo Kaligangsa Wetan Brebes
|
||||
ID 07 NULL Semarang NULL 50143 Puspowarno Tengah 2/2
|
||||
ID 08 NULL Lumajang NULL 67373 Desa Tumpeng Kecamatan Candipuro Lumajang
|
||||
ID 30 NULL Bandung NULL 55241 Jl Pelesiran No 55A/56
|
||||
ID 30 NULL Bekasi NULL 17510 bekasi West Java Indonesia
|
||||
ID 30 NULL Depok NULL 16245 Jalan juragan sinda 2 no 10
|
||||
ID 30 NULL Depok NULL 16424 Jalan Margonda RayaJalan Kober Gang Mawar
|
||||
ID 30 NULL Depok NULL 16424 Jl. Haji Yahya Nuih no.24, Pondok Cina
|
||||
ID 30 NULL Depok NULL 16425 Kukusan Kelurahan
|
||||
ID 30 NULL Depok NULL 16518 Jl. Salak No.1/C.88 Durenseribu Bojongsari
|
||||
ID 30 NULL Depok NULL 16952 Jl. Merak No.34 -36 Rt.004/014 Jl. Merak No. 34 -36 Rt. 004/014
|
||||
ID 36 NULL biak numfor NULL 98111 jl. s. mamberamo no 6782 biak numfor
|
||||
IL NULL Tel Aviv NULL
|
||||
IN NULL Bangalore NULL
|
||||
IN NULL India NULL
|
||||
IN NULL new delhi NULL 110003 55 lodi estate
|
||||
IN 07 NULL NEW DELHI NULL 110018 15/11 A 1ST FLOOR TILAK NAGAR
|
||||
IN 07 NULL New Delhu NULL 110075 B 54 Hilansh Apartments Plot No 1, Sector 10, Dwarka
|
||||
IN 10 NULL Gurgaon NULL D- 201 Ivy Apartments Sushant Lok 1 Gurgaon Haryana
|
||||
IN 13 NULL Trivandrum NULL 695010 TC 9/1615, SRMH Road, Sasthamangalam, Trivandrum
|
||||
IN 16 NULL Mumbai NULL 400020 Bharat Mahal, Flat#55 Marine Drive
|
||||
IN 16 NULL Mumbai NULL 400028 303,Shree Parvati Co-Op Housing Society, D.L.Vaidya Road,Dadar
|
||||
IN 16 NULL Pune NULL
|
||||
IN 16 NULL Pune NULL Infosys Campus Hinjewadi Phase 2
|
||||
IN 16 NULL Pune NULL 400705 #22 Iris Garden Gokhale Road
|
||||
IN 16 NULL PUNE NULL 411043
|
||||
IN 16 NULL Pune NULL 411051
|
||||
IN 16 NULL Pune NULL 411057 Infosys Ltd. Rajiv gandhi infostech park Hinjewadi phase 2
|
||||
IN 16 NULL Pune NULL 412108 Pune Maharatshtra
|
||||
IN 16 NULL Pune NULL 433011 502 utkarsh vihar golande state pune
|
||||
IN 19 NULL Bangalore NULL 560080 Indian Institute for Human Settlements IIHS Bangalore City Campus, Sadashivanagar,
|
||||
IN 19 NULL Bangalore NULL 560100 electronic city
|
||||
IN 19 NULL Bhalki NULL 585411 bhalki,bidar ,karnataka karnataka
|
||||
IN 24 NULL Jaipur NULL 302011 Institute of Health Management Research 1, Prabhu Dayal Marg
|
||||
IR 26 NULL Tehran NULL 1118844454 Baharestan sq. mostafa khomeini str., javahery Ave., no. 11,
|
||||
IT NULL Trento NULL
|
||||
JM 08 NULL Kingston NULL Kgn 7 MOna Campus UWI
|
||||
KE NULL Nairobi NULL
|
||||
KE 05 NULL Nairobi NULL 30300 212,kapsabet
|
||||
KH NULL NULL Phnom Penh NULL
|
||||
LR NULL Monrovia NULL 00000
|
||||
NG 11 NULL Abuja NULL 930001 17 Bechar street Wuse zone 2
|
||||
PE 15 NULL Lima NULL 18 Lima Lima
|
||||
PE 15 NULL Lima NULL Lima 18 123 Miraflores
|
||||
PE NULL NULL Lima NULL 03 Calle Granada 104
|
||||
PE NULL NULL Lima NULL 18 Lima Lima
|
||||
PH NULL Manila NULL Globe Telepark 111 Valero Street
|
||||
PH NULL Quezon Coty NULL 1109 86 Harvard Street, Cubao, Quezon City, Philippines 84 Harvard Street, Cubao, Quezon City,hilippines
|
||||
PH 20 NULL Silang NULL 4118 370 Bayungan Kaong Silang Cavite
|
||||
PH 57 NULL Kidapawan NULL 9400 Kidapawan City Kidapawan City
|
||||
PH 66 NULL zamboanga NULL 7000 29-tripplet rd san jose 29-tripplet rd san jose
|
||||
PH D9 NULL Pasig City NULL World Bank Office Manila, 20/F Taipan Place F. Ortigas Jr. Road, Ortigas Center
|
||||
PK NULL Lahore NULL 54000 17-R Model Town Lahore
|
||||
PK NULL Lahore NULL 54000 53- chamber lane road Lahore
|
||||
PK NULL Lahore NULL 54000 85 E block Model Town
|
||||
PK NULL Lahore NULL 54000 House no 227, street no 5, Imamia Colony Shahadra Lahore
|
||||
PK NULL LAHORE NULL 54000 room no.6 khalid bim waleed hall, near New Anarkali, LAHORE room no.6 khalid bim waleed hall, near New Anarkali, LAHORE
|
||||
PK NULL Lahore NULL pk097 LUMS, Lahore,
|
||||
PK NULL Sheikhupura NULL 03935 D.H.Q.Hospital Sheikhupura House number 08. Room no 109 Khalid bin waleed haal, punjab University lahore old campus.
|
||||
PK 02 NULL Quetta NULL 87000 Postal Address 87000, Kuchlak, Quetta, Balochistan. H#24 Peer Abul Khair road Quetta, Balochistan.
|
||||
PK 02 NULL Quetta NULL 87300 block no-1 falt no. 7 New Crime Branch Abbas Ali Road Cantt
|
||||
PK 02 NULL Quetta NULL 87300 Flat no. 3 Shafeen Centre Jinnah Town ,Near I.T university , Quetta
|
||||
PK 02 NULL Quetta NULL 87300 H-no. C-220 Zarghoonabad Phase-2 , Nawa Killi ,Quetta
|
||||
PK 04 NULL burewala NULL 60101 Fatima Fayyaz Hazrat Sakina hall girls hostel number 9 Punjab university Lahore Pakistan Sardar Wajid Azim Azeem abad Burewala dist Vehari Pakistan
|
||||
PK 04 NULL Faisalabad NULL 38000 P 101/1, Green Town, Millat Road, Faisalabad
|
||||
PK 04 NULL Islamabad NULL 44000 P.O Tarlai kalan chappar Islamabad
|
||||
PK 04 NULL lahore NULL
|
||||
PK 04 NULL Lahore NULL 54000
|
||||
PK 04 NULL lahore NULL 54000 Street No.63 House 36/A Al-madad Pak Colony Ravi Road, Lahore. Street No.63 House 36/A Al-madad Pak Colony Ravi Road, Lahore.
|
||||
PK 04 NULL Lahore NULL 54000 1149-1-D2 Green Town Lahore
|
||||
PK 04 NULL Lahore NULL 54000 124, street# 2, karim block Allama Iqbal Town lahore. 124, street# 2, karim block Allama Iqbal Town lahore.
|
||||
PK 04 NULL Lahore NULL 54000 150 A Qila Lachman Singh Ravi Road lahore
|
||||
PK 04 NULL Lahore NULL 54000 166/1L DHA Lahore
|
||||
PK 04 NULL Lahore NULL 54000 172 A2 Township Lahore
|
||||
PK 04 NULL Lahore NULL 54000 183,S/Block, Model Town, Lhr
|
||||
PK 04 NULL lahore NULL 54000 19- A block ,Eden Lane Villas Raiwind Road ,Lahore
|
||||
PK 04 NULL lahore NULL 54000 3-c kaliyar road opposite kids lyceum, rustam park near mor samnabad
|
||||
PK 04 NULL Lahore NULL 54000 31 Saeed Block, Canal Bank Scheme
|
||||
PK 04 NULL Lahore NULL 54000 31c DHA Lahore
|
||||
PK 04 NULL Lahore NULL 54000 387 E1 wapda town, Lahore
|
||||
PK 04 NULL Lahore NULL 54000 45-D dha eme sector multan road,lahore
|
||||
PK 04 NULL Lahore NULL 54000 5 Zafar Ali Road
|
||||
PK 04 NULL Lahore NULL 54000 54-R PGECHS
|
||||
PK 04 NULL lahore NULL 54000 566 E-1 johar town lahore 566 E-1 johar town lahore
|
||||
PK 04 NULL Lahore NULL 54000 82/1 Z Block, Phase 3 DHA
|
||||
PK 04 NULL Lahore NULL 54000 A-1 VRI Zarrar shaheed road lahore cantt A-1 VRI Zarrar shaheed road lahore cantt
|
||||
PK 04 NULL lahore NULL 54000 e5/39D street 6 zaman colony cavalry ground ext
|
||||
PK 04 NULL Lahore NULL 54000 Ho # 61, Block G3, Johar Town Lahore
|
||||
PK 04 NULL LAhore NULL 54000 House #19-A street #5 Usman nagr Ghaziabad Lahore
|
||||
PK 04 NULL lahore NULL 54000 House no 692 street no 67 sadar bazar
|
||||
PK 04 NULL Lahore NULL 54000 Khosa Law Chamber 1 Turner Road
|
||||
PK 04 NULL Lahore NULL 54000 Lahore,Pakistan Lahore,Pakistan
|
||||
PK 04 NULL Lahore NULL 54000 room no 69, khalid bin waleed hall, anarkali
|
||||
PK 04 NULL Lahore NULL 54000 Suite # 8, Al-Hafeez Suites, Gulberg II
|
||||
PK 04 NULL Lahore NULL 54085 199 Shadman 2
|
||||
PK 04 NULL Lahore NULL 54300 Mughalpura Lahore Pakistan
|
||||
PK 04 NULL Lahore NULL 54660 SD 69 falcon complex gulberg III lahore
|
||||
PK 04 NULL lahore NULL 54800 764-G4 johar town ,lahore
|
||||
PK 04 NULL Rawalpindi NULL 44000 House 522, F-Block Sattellite Town, Rawalpindi
|
||||
PK 04 NULL Rawalpindi NULL 46000 1950/c, Indusroad 2, Tariqabad, Rawalpindi Cantt
|
||||
PK 04 NULL Rawalpindi NULL 46000 House 54-E Lane 9 Sector 4, AECHS Chaklala Rawalpindi
|
||||
PK 04 NULL Rawalpindi NULL 46000 House B-1343, Sattellite town Rawalpindi
|
||||
PK 04 NULL Rawalpindi NULL 46000 House CB-299F, Street 1, Lane 4 Peshawar Road Rawalpindi
|
||||
PK 04 NULL Rawalpindi NULL 46300 House No 1518 Umer Block phase 8 BehriaTown
|
||||
PK 04 NULL sialkot NULL 51310 The National Model School, Ismaiealabad, Pacca Garah Sialkot
|
||||
PK 08 NULL Islamabad NULL CIomsats Institute of Information Technology Islamabad
|
||||
PK 08 NULL Islamabad NULL 38700 COMSATS tarlai boys hostel Islamabad. COMSATS tarlai boys hostel Islamabad (Room 30)
|
||||
PK 08 NULL Islamabad NULL 44000
|
||||
PK 08 NULL Islamabad NULL 44000 House # 256, Street # 9, Shahzad Town, Islamabad.
|
||||
PK 08 NULL Islamabad NULL 44000 Islamabad , Comsats University Islamabd ,Pakistan
|
||||
PK 08 NULL Islamabad NULL 44000 World Bank Building Sector G 5
|
||||
PK 08 NULL lahore NULL 54000 3c zafar ali road gulburg 5 3c zafar ali road gulburg 5
|
||||
PK 08 NULL lahore NULL 54000 49-a bilal park, chaburgy 49-a bilal park, chaburgy
|
||||
PK NULL NULL Lahore NULL 54000
|
||||
PK NULL NULL Lahore NULL 54000 85 E block Model Town
|
||||
SN 01 NULL NULL ouakam cité comico en face 217
|
||||
SN 01 NULL Dakar NULL
|
||||
SN 01 NULL Dakar NULL IDEV-ic Patte d'oie Builder's Villa B11
|
||||
SN 01 NULL Dakar NULL liberte 6/ dakar
|
||||
SN 01 NULL Dakar NULL ngor
|
||||
SN 01 NULL Dakar NULL 4027 ZAC Mbao Cité Fadia
|
||||
SN NULL NULL Dakar NULL IDEV-ic Patte d'oie Builder's Villa B11
|
||||
TZ NULL Dar es Salaam NULL NULL
|
||||
TZ NULL Dar es salaam NULL NULL 76021 Dar es salaam 1507 Morogoro
|
||||
TZ NULL Dar es salaam NULL NULL dar es salaam nassoro.ahmedy@yahoo.com
|
||||
TZ NULL DAR ES SALAAM NULL NULL dar es salaam UDSM
|
||||
TZ NULL Dar es salaam NULL NULL NA
|
||||
TZ NULL DAR ES SALAAM NULL NULL P O BOX 23409
|
||||
TZ NULL dar es salaam NULL NULL p. o. box 104994
|
||||
TZ NULL Dar es Salaam NULL NULL P.o. BOX 71415 Dar es Salaam
|
||||
TZ NULL Dar es Salaam NULL NULL P.O.BOx 66675 DSM
|
||||
TZ NULL Dar es salaam NULL NULL Tz Tz
|
||||
TZ NULL dsm NULL NULL
|
||||
TZ 02 NULL Bagamoyo NULL NULL PO.Box 393
|
||||
TZ 02 NULL Dar es salaam NULL NULL 22548
|
||||
TZ 03 NULL Dar-es-salaam NULL NULL Dodoma Municipal Kimara, Dar-es-salaa,
|
||||
TZ 23 NULL Dar es Salaam NULL NULL
|
||||
TZ 23 NULL dar es salaam NULL NULL 35074
|
||||
TZ 23 NULL dar es salaam NULL NULL 67389
|
||||
TZ 23 NULL Dar es Salaam NULL NULL COSTECH, Dar es Salaam, Tanzania
|
||||
TZ 23 NULL Dar es salaam NULL NULL na
|
||||
TZ 23 NULL dar es salaam NULL NULL p o box 60164
|
||||
TZ 23 NULL dar es salaam NULL NULL P. O. Box 77588
|
||||
TZ 23 NULL dar es salaam NULL NULL P.O BOX 78144
|
||||
TZ 23 NULL Dar es Salaam NULL NULL P.O.BOX 78373
|
||||
TZ 23 NULL Dar es salaam NULL NULL UDSM Dar es Salaam
|
||||
TZ 23 NULL Dar es salaam NULL NULL udsm udsm
|
||||
TZ 23 NULL Temeke NULL NULL P.O. Box 50127
|
||||
TZ NULL NULL Dar es Salaam NULL NULL
|
||||
TZ NULL NULL Dar es Salaam NULL NULL Kigoma
|
||||
TZ NULL NULL Dar es Salaam NULL NULL Mwanza
|
||||
UG NULL Kampala NULL NULL
|
||||
UG NULL Kampala NULL NULL Kampala Uganda East Africa
|
||||
US NULL London NULL SE1 8RT Capital Tower 91 Waterloo Road
|
||||
US CA NULL Los Angeles NULL
|
||||
US CA NULL Pleasanton NULL 94588 3412 Pickens Lane
|
||||
US CA NULL Sacramento NULL
|
||||
US CA NULL San Francisco NULL
|
||||
US CA NULL seattle NULL 98113 1234 1st st
|
||||
US CO NULL Denver NULL 80235 6666 West Quincy Ave
|
||||
US CT NULL Greenwich NULL 06830 140 Milbank
|
||||
US CT NULL Hartford NULL 06106 Center for Urban and Global Studies at Trinity College, 70 Vernon Street
|
||||
US DC NULL Washington NULL
|
||||
US DC NULL Washington NULL 20007 World Bank Headquarters 1818 H Street NW
|
||||
US DC NULL Washington NULL 20010
|
||||
US DC NULL Washington NULL 20036
|
||||
US DC NULL Washington NULL 20405 1889 F St NW
|
||||
US DC NULL Washington NULL 20433
|
||||
US DC NULL Washington NULL 20433 1818 H Street NW
|
||||
US DC NULL Washington NULL 20433 1818H St
|
||||
US DC NULL Washington NULL 20433 1818 H Street NW
|
||||
US DC NULL Washington DC NULL 20005 1424, K Street, NW Suite 600
|
||||
US DC NULL Washington DC NULL 20010 1818 H Street, NW
|
||||
US DC NULL Washington, DC NULL 20003 1818 H Street NW
|
||||
US DE NULL Virgin Islands|Charlotte Amalie,Cruz Bay,Christiansted NULL Morocco|Tafraout,Rabat,Tangier,Tetouan,Casablanca,Marrakesh,Fez,Oujda,Meknes,Agadir United Arab Emirates|Garhoud,Dubai,Bur Dubai,Ras al Khaymah,Abu Dhabi,Ajman,Al Fujayrah,Sharjah
|
||||
US FL NULL Falmouth NULL Falmouth Falmouth
|
||||
US FL NULL Lilongwe NULL Lilongwe Lilongwe
|
||||
US GA NULL Atlanta NULL
|
||||
US GU NULL Herndon NULL 15642 Ht USA
|
||||
US GU NULL Miami NULL Miami Miami
|
||||
US MD NULL Gaithersburg NULL 20877 554 N Frederick Avenue Suite 216
|
||||
US MD NULL Potomac NULL 20854 14 Sandalfoot Court
|
||||
US MD NULL Silver Spring NULL 20901 9202 Whitney St.
|
||||
US MI NULL Traverse City NULL 49685 PO Box 792
|
||||
US ND NULL Pirassununga NULL Pirassununga Pirassununga
|
||||
US NJ NULL Princeton NULL
|
||||
US NY NULL Brooklyn NULL 11206-1980 25 Montrose Ave. Apt 304
|
||||
US NY NULL Brooklyn NULL 11225 975 washington ave 2d
|
||||
US NY NULL Brooklyn NULL 11217 150 4TH AVE APT 9E
|
||||
US NY NULL New York NULL
|
||||
US NY NULL New York NULL 10013 148 Lafayette St. PH
|
||||
US NY NULL New York NULL 10017 UNICEF 3 UN Plaza
|
||||
US NY NULL New York NULL 10019 25 Columbus Circle Suite 52E
|
||||
US NY NULL New York NULL 10024 65 West 85th Street 3A
|
||||
US NY NULL New York NULL 10027 606 W. 116th Street #22
|
||||
US NY NULL New York NULL 10037
|
||||
US NY NULL Rochester NULL
|
||||
US NY NULL Scarsdale NULL 10583-1423 54 Walworth Avenue
|
||||
US OR NULL Portland NULL
|
||||
US PA NULL Philadelphia NULL
|
||||
US PA NULL Philadelphia NULL
|
||||
US PR NULL Colonel Hill NULL Colonel Hill Colonel Hill
|
||||
US SD NULL Banjul NULL Banjul Banjul
|
||||
US SD NULL London NULL London London
|
||||
US TX NULL Aledo NULL 76008 1588 Hunterglenn Dr
|
||||
US TX NULL Keller NULL 76248 810 Placid View Ct.
|
||||
US WA NULL Seattle NULL
|
||||
ZA NULL Cape Town NULL
|
||||
ZA NULL Cape Town NULL 7945 Alexander Road Muizenberg
|
||||
ZA NULL Pretoria NULL
|
||||
ZA 11 NULL Cape Town NULL
|
||||
ZA 11 NULL Cape Town NULL 7435 PostNet Suite #57, Private Bag X18 Milnerton
|
||||
ZA 11 NULL Cape town NULL 7508 24 Solyet Court, Lansdowne Road Claremont
|
||||
ZA 11 NULL Cape Town NULL 7701
|
||||
ZA 11 NULL Cape Town NULL 7785 10 Nyamakazi Road Luzuko Park Phillipi East
|
||||
ZA 11 NULL Cape Town NULL 7915 66 Albert Rd
|
||||
ZA 11 NULL Cape Town NULL 8001 210 Long Street
|
||||
ZM NULL Lusaka NULL
|
||||
ZM 09 NULL LUSAKA NULL 10101 P.O. BOX FW 174
|
||||
AT NULL Feldkirch NULL 6800 Pater Grimm Weg 20 NULL
|
||||
AU NULL Melbourne NULL NULL
|
||||
AU NULL Sydney NULL NULL
|
||||
AU 4 NULL NORMANBY NULL 4059 30 Normanby Terrace NULL
|
||||
BD NULL Dhaka NULL 1205 23, Subal Das Road, Chowdhury Bazar, Lalbagh NULL
|
||||
BD NULL Dhaka NULL 1207 R-1,H-19,Kallaynpur,Mirpur,Dhaka NULL
|
||||
BD NULL Dhaka NULL 1207 World Bank Office Dhaka, Plot E 32, Agargaon, Sher-E-Bangla Nagar NULL
|
||||
BD NULL Dhaka NULL 1209 House# 66B, Flat# B2 Zigatola NULL
|
||||
BD NULL Dhaka NULL 1219 390 West Rampura Dhaka NULL
|
||||
BD NULL Dhaka NULL 1230 Uttara NULL
|
||||
BD 81 NULL Dhaka NULL 1000 Institute of Water and Flood Management NULL
|
||||
BD 81 NULL Dhaka NULL 1203 84/a maniknagar NULL
|
||||
BD 81 NULL Dhaka NULL 1205 Dhaka Bangladesh NULL
|
||||
BD 81 NULL Dhaka NULL 1207 BetterStories Limited 17 West Panthopath NULL
|
||||
BD 81 NULL Dhaka NULL 1216 Mirpur, Dhaka NULL
|
||||
BD 81 NULL Dhaka NULL 1230 830, Prembagan, Dhakshin Khan NULL
|
||||
BD 82 NULL khulna NULL 9203 NULL
|
||||
BD NULL NULL Dhaka NULL 1000 Institute of Water and Flood Management NULL
|
||||
BD NULL NULL Dhaka NULL 1207 World Bank Office Dhaka, Plot E 32, Agargaon, Sher-E-Bangla Nagar NULL
|
||||
BE NULL Brussels NULL NULL
|
||||
BE NULL Watermael-Boitsfort NULL 1170 Avenue des Staphylins NULL
|
||||
BH NULL Manama NULL 973 Manama Bahrain Manama Bahrain NULL
|
||||
BR NULL Porto Alegre NULL NULL
|
||||
BR NULL Recife NULL NULL
|
||||
BR RJ NULL Rio de Janeiro NULL NULL
|
||||
BW NULL Francistown NULL NULL NULL
|
||||
BW NULL NULL Francistown NULL NULL NULL
|
||||
CA NULL Montreal NULL NULL
|
||||
CA NULL Toronto NULL NULL
|
||||
CA BC NULL Vancouver NULL NULL
|
||||
CA ON NULL Kitchener NULL NULL
|
||||
CA ON NULL wterloo NULL n2l3g1 200 University Avenue West NULL
|
||||
CH NULL Geneva NULL 1202 15, chemin Louis-Dunant NULL
|
||||
CH 25 NULL Zurich NULL 8098 UBS Optimus Foundation Augustinerhof 1 NULL
|
||||
DE NULL Berlin NULL NULL
|
||||
DE 5 NULL Frankfurt am Main NULL 60386 Johanna-Tesch-Platz 7 NULL
|
||||
DK NULL Aarhus NULL NULL
|
||||
ES NULL Bilbao NULL NULL
|
||||
ET 44 NULL ADDIS ABABA NULL 11945 ADDIS ABABA,P.O.BOX 11945 NULL
|
||||
FI NULL Espoo NULL 2130 Mahlarinne 3B NULL
|
||||
FI NULL Helsinki NULL 580 Hermannin rantatie 2 A Hermannin rantatie 2 A NULL
|
||||
FI NULL Tampere NULL 33101 Tampere University of Technology NULL
|
||||
FI 13 NULL Espoo NULL 2150 Aalto Venture Garage Betonimiehenkuja 3 NULL
|
||||
GB NULL Exeter NULL NULL
|
||||
GB NULL London NULL NULL
|
||||
GB NULL London NULL N4 2DP 2 Myddleton Ave NULL
|
||||
GB NULL London NULL N7 0AH 104 St George’s Avenue NULL
|
||||
GB NULL London NULL SE16 3UL 25 Blue Anchor Lane NULL
|
||||
GB NULL London NULL SW18 5SP Flat 1 150 Merton road NULL
|
||||
GB NULL London NULL W1T 4BQ 13 Fitzroy Street NULL
|
||||
GB NULL Oxford NULL NULL
|
||||
GB NULL Southampton NULL NULL
|
||||
GB C3 NULL NULL cb244qg 32 market street swavesey NULL
|
||||
GB E7 NULL London NULL SE3 7TP NULL
|
||||
GB F3 NULL Wood Green NULL N22 5RU 6 Cedar House NULL
|
||||
GB H1 NULL London NULL SE11 5JD 47-49 Durham Street NULL
|
||||
GB H6 NULL London NULL SE8 4DD 8 Harton St Deptford NULL
|
||||
GB K2 NULL Oxford NULL OX2 6QY 3 The Villas, Rutherway NULL
|
||||
GH 5 NULL NSAWAM NULL NULL P.O.BOX 455 NULL
|
||||
GH NULL NULL Accra NULL NULL NULL
|
||||
ID NULL Bandung NULL 40134 Jalan Sadang Hegar 1 No. 12 RT04 RW13 Sadang Serang NULL
|
||||
ID NULL Bekasi NULL 17411 Jl.Binadharma 1 No.62. Jatiwaringin NULL
|
||||
ID NULL Jakarta NULL NULL
|
||||
ID NULL Jakarta NULL 12440 Jl. H. Niin 7 Lebak Bulus, Cilandak NULL
|
||||
ID NULL Jakarta NULL 13330 Otista NULL
|
||||
ID NULL Jakarta selatan NULL 12000 jl. rawa jati timur 6 no. 10 NULL
|
||||
ID NULL Jakarta Timur NULL Jl.Mulia No.15B Kel.Bidara Cina, Kec.Jatinegara, Jakarta Timur NULL
|
||||
ID NULL Pematang Siantar NULL 51511 Jl. Durian I 30 NULL
|
||||
ID 4 NULL Bogor NULL 16165 NULL
|
||||
ID 4 NULL jakarta NULL otista NULL
|
||||
ID 4 NULL Jakarta NULL 12520 Jl. Pertanian Raya III No.42 Jakarta Selatan Pasar Minggu NULL
|
||||
ID 4 NULL Jakarta NULL 13330 Jakarta NULL
|
||||
ID 4 NULL Jakarta NULL 13330 Jl Sensus IIC Bidaracina Jaktim NULL
|
||||
ID 4 NULL Jakarta NULL 13330 Jl. Bonasut 2 no.22 NULL
|
||||
ID 4 NULL Jakarta NULL 13330 Otista 64c NULL
|
||||
ID 4 NULL jakarta NULL 13330 Otista jaktim NULL
|
||||
ID 4 NULL Jakarta Timur NULL 13330 Kebon Sayur I no. 1 RT 10/15 NULL
|
||||
ID 4 NULL Jakarta Timur NULL 13460 Jl. Pondok Kopi Blok G4/5 RT. 005/08 Jakarta Timur NULL
|
||||
ID 4 NULL Jakarta Timur NULL 13810 Jl. Raya Pondok Gede Rt03 Rw08 no.35 , Lubang Buaya, Jakarta Timur Jl. Raya Pondok Gede Rt03 Rw08 no.35 , Lubang Buaya, Jakarta Timur NULL
|
||||
ID 7 NULL Brebes NULL 54321 Jl Kersem Blok D14 Perum Taman Indo Kaligangsa Wetan Brebes NULL
|
||||
ID 7 NULL Semarang NULL 50143 Puspowarno Tengah 2/2 NULL
|
||||
ID 8 NULL Lumajang NULL 67373 Desa Tumpeng Kecamatan Candipuro Lumajang NULL
|
||||
ID 30 NULL Bandung NULL 55241 Jl Pelesiran No 55A/56 NULL
|
||||
ID 30 NULL Bekasi NULL 17510 bekasi West Java Indonesia NULL
|
||||
ID 30 NULL Depok NULL 16245 Jalan juragan sinda 2 no 10 NULL
|
||||
ID 30 NULL Depok NULL 16424 Jalan Margonda RayaJalan Kober Gang Mawar NULL
|
||||
ID 30 NULL Depok NULL 16424 Jl. Haji Yahya Nuih no.24, Pondok Cina NULL
|
||||
ID 30 NULL Depok NULL 16425 Kukusan Kelurahan NULL
|
||||
ID 30 NULL Depok NULL 16518 Jl. Salak No.1/C.88 Durenseribu Bojongsari NULL
|
||||
ID 30 NULL Depok NULL 16952 Jl. Merak No.34 -36 Rt.004/014 Jl. Merak No. 34 -36 Rt. 004/014 NULL
|
||||
ID 36 NULL biak numfor NULL 98111 jl. s. mamberamo no 6782 biak numfor NULL
|
||||
IL NULL Tel Aviv NULL NULL
|
||||
IN NULL Bangalore NULL NULL
|
||||
IN NULL India NULL NULL
|
||||
IN NULL new delhi NULL 110003 55 lodi estate NULL
|
||||
IN 7 NULL NEW DELHI NULL 110018 15/11 A 1ST FLOOR TILAK NAGAR NULL
|
||||
IN 7 NULL New Delhu NULL 110075 B 54 Hilansh Apartments Plot No 1, Sector 10, Dwarka NULL
|
||||
IN 10 NULL Gurgaon NULL D- 201 Ivy Apartments Sushant Lok 1 Gurgaon Haryana NULL
|
||||
IN 13 NULL Trivandrum NULL 695010 TC 9/1615, SRMH Road, Sasthamangalam, Trivandrum NULL
|
||||
IN 16 NULL Mumbai NULL 400020 Bharat Mahal, Flat#55 Marine Drive NULL
|
||||
IN 16 NULL Mumbai NULL 400028 303,Shree Parvati Co-Op Housing Society, D.L.Vaidya Road,Dadar NULL
|
||||
IN 16 NULL Pune NULL NULL
|
||||
IN 16 NULL Pune NULL Infosys Campus Hinjewadi Phase 2 NULL
|
||||
IN 16 NULL Pune NULL 400705 #22 Iris Garden Gokhale Road NULL
|
||||
IN 16 NULL PUNE NULL 411043 NULL
|
||||
IN 16 NULL Pune NULL 411051 NULL
|
||||
IN 16 NULL Pune NULL 411057 Infosys Ltd. Rajiv gandhi infostech park Hinjewadi phase 2 NULL
|
||||
IN 16 NULL Pune NULL 412108 Pune Maharatshtra NULL
|
||||
IN 16 NULL Pune NULL 433011 502 utkarsh vihar golande state pune NULL
|
||||
IN 19 NULL Bangalore NULL 560080 Indian Institute for Human Settlements IIHS Bangalore City Campus, Sadashivanagar, NULL
|
||||
IN 19 NULL Bangalore NULL 560100 electronic city NULL
|
||||
IN 19 NULL Bhalki NULL 585411 bhalki,bidar ,karnataka karnataka NULL
|
||||
IN 24 NULL Jaipur NULL 302011 Institute of Health Management Research 1, Prabhu Dayal Marg NULL
|
||||
IR 26 NULL Tehran NULL 1118844454 Baharestan sq. mostafa khomeini str., javahery Ave., no. 11, NULL
|
||||
IT NULL Trento NULL NULL
|
||||
JM 8 NULL Kingston NULL Kgn 7 MOna Campus UWI NULL
|
||||
KE NULL Nairobi NULL NULL
|
||||
KE 5 NULL Nairobi NULL 30300 212,kapsabet NULL
|
||||
KH NULL NULL Phnom Penh NULL NULL
|
||||
LR NULL Monrovia NULL 0 NULL
|
||||
NG 11 NULL Abuja NULL 930001 17 Bechar street Wuse zone 2 NULL
|
||||
PE 15 NULL Lima NULL 18 Lima Lima NULL
|
||||
PE 15 NULL Lima NULL Lima 18 123 Miraflores NULL
|
||||
PE NULL NULL Lima NULL 3 Calle Granada 104 NULL
|
||||
PE NULL NULL Lima NULL 18 Lima Lima NULL
|
||||
PH NULL Manila NULL Globe Telepark 111 Valero Street NULL
|
||||
PH NULL Quezon Coty NULL 1109 86 Harvard Street, Cubao, Quezon City, Philippines 84 Harvard Street, Cubao, Quezon City,hilippines NULL
|
||||
PH 20 NULL Silang NULL 4118 370 Bayungan Kaong Silang Cavite NULL
|
||||
PH 57 NULL Kidapawan NULL 9400 Kidapawan City Kidapawan City NULL
|
||||
PH 66 NULL zamboanga NULL 7000 29-tripplet rd san jose 29-tripplet rd san jose NULL
|
||||
PH D9 NULL Pasig City NULL World Bank Office Manila, 20/F Taipan Place F. Ortigas Jr. Road, Ortigas Center NULL
|
||||
PK NULL Lahore NULL 54000 17-R Model Town Lahore NULL
|
||||
PK NULL Lahore NULL 54000 53- chamber lane road Lahore NULL
|
||||
PK NULL Lahore NULL 54000 85 E block Model Town NULL
|
||||
PK NULL Lahore NULL 54000 House no 227, street no 5, Imamia Colony Shahadra Lahore NULL
|
||||
PK NULL LAHORE NULL 54000 room no.6 khalid bim waleed hall, near New Anarkali, LAHORE room no.6 khalid bim waleed hall, near New Anarkali, LAHORE NULL
|
||||
PK NULL Lahore NULL pk097 LUMS, Lahore, NULL
|
||||
PK NULL Sheikhupura NULL 3935 D.H.Q.Hospital Sheikhupura House number 08. Room no 109 Khalid bin waleed haal, punjab University lahore old campus. NULL
|
||||
PK 2 NULL Quetta NULL 87000 Postal Address 87000, Kuchlak, Quetta, Balochistan. H#24 Peer Abul Khair road Quetta, Balochistan. NULL
|
||||
PK 2 NULL Quetta NULL 87300 block no-1 falt no. 7 New Crime Branch Abbas Ali Road Cantt NULL
|
||||
PK 2 NULL Quetta NULL 87300 Flat no. 3 Shafeen Centre Jinnah Town ,Near I.T university , Quetta NULL
|
||||
PK 2 NULL Quetta NULL 87300 H-no. C-220 Zarghoonabad Phase-2 , Nawa Killi ,Quetta NULL
|
||||
PK 4 NULL burewala NULL 60101 Fatima Fayyaz Hazrat Sakina hall girls hostel number 9 Punjab university Lahore Pakistan Sardar Wajid Azim Azeem abad Burewala dist Vehari Pakistan NULL
|
||||
PK 4 NULL Faisalabad NULL 38000 P 101/1, Green Town, Millat Road, Faisalabad NULL
|
||||
PK 4 NULL Islamabad NULL 44000 P.O Tarlai kalan chappar Islamabad NULL
|
||||
PK 4 NULL lahore NULL NULL
|
||||
PK 4 NULL Lahore NULL 54000 NULL
|
||||
PK 4 NULL lahore NULL 54000 Street No.63 House 36/A Al-madad Pak Colony Ravi Road, Lahore. Street No.63 House 36/A Al-madad Pak Colony Ravi Road, Lahore. NULL
|
||||
PK 4 NULL Lahore NULL 54000 1149-1-D2 Green Town Lahore NULL
|
||||
PK 4 NULL Lahore NULL 54000 124, street# 2, karim block Allama Iqbal Town lahore. 124, street# 2, karim block Allama Iqbal Town lahore. NULL
|
||||
PK 4 NULL Lahore NULL 54000 150 A Qila Lachman Singh Ravi Road lahore NULL
|
||||
PK 4 NULL Lahore NULL 54000 166/1L DHA Lahore NULL
|
||||
PK 4 NULL Lahore NULL 54000 172 A2 Township Lahore NULL
|
||||
PK 4 NULL Lahore NULL 54000 183,S/Block, Model Town, Lhr NULL
|
||||
PK 4 NULL lahore NULL 54000 19- A block ,Eden Lane Villas Raiwind Road ,Lahore NULL
|
||||
PK 4 NULL lahore NULL 54000 3-c kaliyar road opposite kids lyceum, rustam park near mor samnabad NULL
|
||||
PK 4 NULL Lahore NULL 54000 31 Saeed Block, Canal Bank Scheme NULL
|
||||
PK 4 NULL Lahore NULL 54000 31c DHA Lahore NULL
|
||||
PK 4 NULL Lahore NULL 54000 387 E1 wapda town, Lahore NULL
|
||||
PK 4 NULL Lahore NULL 54000 45-D dha eme sector multan road,lahore NULL
|
||||
PK 4 NULL Lahore NULL 54000 5 Zafar Ali Road NULL
|
||||
PK 4 NULL Lahore NULL 54000 54-R PGECHS NULL
|
||||
PK 4 NULL lahore NULL 54000 566 E-1 johar town lahore 566 E-1 johar town lahore NULL
|
||||
PK 4 NULL Lahore NULL 54000 82/1 Z Block, Phase 3 DHA NULL
|
||||
PK 4 NULL Lahore NULL 54000 A-1 VRI Zarrar shaheed road lahore cantt A-1 VRI Zarrar shaheed road lahore cantt NULL
|
||||
PK 4 NULL lahore NULL 54000 e5/39D street 6 zaman colony cavalry ground ext NULL
|
||||
PK 4 NULL Lahore NULL 54000 Ho # 61, Block G3, Johar Town Lahore NULL
|
||||
PK 4 NULL LAhore NULL 54000 House #19-A street #5 Usman nagr Ghaziabad Lahore NULL
|
||||
PK 4 NULL lahore NULL 54000 House no 692 street no 67 sadar bazar NULL
|
||||
PK 4 NULL Lahore NULL 54000 Khosa Law Chamber 1 Turner Road NULL
|
||||
PK 4 NULL Lahore NULL 54000 Lahore,Pakistan Lahore,Pakistan NULL
|
||||
PK 4 NULL Lahore NULL 54000 room no 69, khalid bin waleed hall, anarkali NULL
|
||||
PK 4 NULL Lahore NULL 54000 Suite # 8, Al-Hafeez Suites, Gulberg II NULL
|
||||
PK 4 NULL Lahore NULL 54085 199 Shadman 2 NULL
|
||||
PK 4 NULL Lahore NULL 54300 Mughalpura Lahore Pakistan NULL
|
||||
PK 4 NULL Lahore NULL 54660 SD 69 falcon complex gulberg III lahore NULL
|
||||
PK 4 NULL lahore NULL 54800 764-G4 johar town ,lahore NULL
|
||||
PK 4 NULL Rawalpindi NULL 44000 House 522, F-Block Sattellite Town, Rawalpindi NULL
|
||||
PK 4 NULL Rawalpindi NULL 46000 1950/c, Indusroad 2, Tariqabad, Rawalpindi Cantt NULL
|
||||
PK 4 NULL Rawalpindi NULL 46000 House 54-E Lane 9 Sector 4, AECHS Chaklala Rawalpindi NULL
|
||||
PK 4 NULL Rawalpindi NULL 46000 House B-1343, Sattellite town Rawalpindi NULL
|
||||
PK 4 NULL Rawalpindi NULL 46000 House CB-299F, Street 1, Lane 4 Peshawar Road Rawalpindi NULL
|
||||
PK 4 NULL Rawalpindi NULL 46300 House No 1518 Umer Block phase 8 BehriaTown NULL
|
||||
PK 4 NULL sialkot NULL 51310 The National Model School, Ismaiealabad, Pacca Garah Sialkot NULL
|
||||
PK 8 NULL Islamabad NULL CIomsats Institute of Information Technology Islamabad NULL
|
||||
PK 8 NULL Islamabad NULL 38700 COMSATS tarlai boys hostel Islamabad. COMSATS tarlai boys hostel Islamabad (Room 30) NULL
|
||||
PK 8 NULL Islamabad NULL 44000 NULL
|
||||
PK 8 NULL Islamabad NULL 44000 House # 256, Street # 9, Shahzad Town, Islamabad. NULL
|
||||
PK 8 NULL Islamabad NULL 44000 Islamabad , Comsats University Islamabd ,Pakistan NULL
|
||||
PK 8 NULL Islamabad NULL 44000 World Bank Building Sector G 5 NULL
|
||||
PK 8 NULL lahore NULL 54000 3c zafar ali road gulburg 5 3c zafar ali road gulburg 5 NULL
|
||||
PK 8 NULL lahore NULL 54000 49-a bilal park, chaburgy 49-a bilal park, chaburgy NULL
|
||||
PK NULL NULL Lahore NULL 54000 NULL
|
||||
PK NULL NULL Lahore NULL 54000 85 E block Model Town NULL
|
||||
SN 1 NULL NULL ouakam cité comico en face 217 NULL
|
||||
SN 1 NULL Dakar NULL NULL
|
||||
SN 1 NULL Dakar NULL IDEV-ic Patte d'oie Builder's Villa B11 NULL
|
||||
SN 1 NULL Dakar NULL liberte 6/ dakar NULL
|
||||
SN 1 NULL Dakar NULL ngor NULL
|
||||
SN 1 NULL Dakar NULL 4027 ZAC Mbao Cité Fadia NULL
|
||||
SN NULL NULL Dakar NULL IDEV-ic Patte d'oie Builder's Villa B11 NULL
|
||||
TZ NULL Dar es Salaam NULL NULL NULL
|
||||
TZ NULL Dar es salaam NULL NULL 76021 Dar es salaam 1507 Morogoro NULL
|
||||
TZ NULL Dar es salaam NULL NULL dar es salaam nassoro.ahmedy@yahoo.com NULL
|
||||
TZ NULL DAR ES SALAAM NULL NULL dar es salaam UDSM NULL
|
||||
TZ NULL Dar es salaam NULL NULL NA NULL
|
||||
TZ NULL DAR ES SALAAM NULL NULL P O BOX 23409 NULL
|
||||
TZ NULL dar es salaam NULL NULL p. o. box 104994 NULL
|
||||
TZ NULL Dar es Salaam NULL NULL P.o. BOX 71415 Dar es Salaam NULL
|
||||
TZ NULL Dar es Salaam NULL NULL P.O.BOx 66675 DSM NULL
|
||||
TZ NULL Dar es salaam NULL NULL Tz Tz NULL
|
||||
TZ NULL dsm NULL NULL NULL
|
||||
TZ 2 NULL Bagamoyo NULL NULL PO.Box 393 NULL
|
||||
TZ 2 NULL Dar es salaam NULL NULL 22548 NULL
|
||||
TZ 3 NULL Dar-es-salaam NULL NULL Dodoma Municipal Kimara, Dar-es-salaa, NULL
|
||||
TZ 23 NULL Dar es Salaam NULL NULL NULL
|
||||
TZ 23 NULL dar es salaam NULL NULL 35074 NULL
|
||||
TZ 23 NULL dar es salaam NULL NULL 67389 NULL
|
||||
TZ 23 NULL Dar es Salaam NULL NULL COSTECH, Dar es Salaam, Tanzania NULL
|
||||
TZ 23 NULL Dar es salaam NULL NULL na NULL
|
||||
TZ 23 NULL dar es salaam NULL NULL p o box 60164 NULL
|
||||
TZ 23 NULL dar es salaam NULL NULL P. O. Box 77588 NULL
|
||||
TZ 23 NULL dar es salaam NULL NULL P.O BOX 78144 NULL
|
||||
TZ 23 NULL Dar es Salaam NULL NULL P.O.BOX 78373 NULL
|
||||
TZ 23 NULL Dar es salaam NULL NULL UDSM Dar es Salaam NULL
|
||||
TZ 23 NULL Dar es salaam NULL NULL udsm udsm NULL
|
||||
TZ 23 NULL Temeke NULL NULL P.O. Box 50127 NULL
|
||||
TZ NULL NULL Dar es Salaam NULL NULL NULL
|
||||
TZ NULL NULL Dar es Salaam NULL NULL Kigoma NULL
|
||||
TZ NULL NULL Dar es Salaam NULL NULL Mwanza NULL
|
||||
UG NULL Kampala NULL NULL NULL
|
||||
UG NULL Kampala NULL NULL Kampala Uganda East Africa NULL
|
||||
US NULL London NULL SE1 8RT Capital Tower 91 Waterloo Road NULL
|
||||
US CA NULL Los Angeles NULL NULL
|
||||
US CA NULL Pleasanton NULL 94588 3412 Pickens Lane NULL
|
||||
US CA NULL Sacramento NULL NULL
|
||||
US CA NULL San Francisco NULL NULL
|
||||
US CA NULL seattle NULL 98113 1234 1st st NULL
|
||||
US CO NULL Denver NULL 80235 6666 West Quincy Ave NULL
|
||||
US CT NULL Greenwich NULL 6830 140 Milbank NULL
|
||||
US CT NULL Hartford NULL 6106 Center for Urban and Global Studies at Trinity College, 70 Vernon Street NULL
|
||||
US DC NULL Washington NULL NULL
|
||||
US DC NULL Washington NULL 20007 World Bank Headquarters 1818 H Street NW NULL
|
||||
US DC NULL Washington NULL 20010 NULL
|
||||
US DC NULL Washington NULL 20036 NULL
|
||||
US DC NULL Washington NULL 20405 1889 F St NW NULL
|
||||
US DC NULL Washington NULL 20433 NULL
|
||||
US DC NULL Washington NULL 20433 1818 H Street NW NULL
|
||||
US DC NULL Washington NULL 20433 1818H St NULL
|
||||
US DC NULL Washington NULL 20433 1818 H Street NW NULL
|
||||
US DC NULL Washington DC NULL 20005 1424, K Street, NW Suite 600 NULL
|
||||
US DC NULL Washington DC NULL 20010 1818 H Street, NW NULL
|
||||
US DC NULL Washington, DC NULL 20003 1818 H Street NW NULL
|
||||
US DE NULL Virgin Islands|Charlotte Amalie,Cruz Bay,Christiansted NULL Morocco|Tafraout,Rabat,Tangier,Tetouan,Casablanca,Marrakesh,Fez,Oujda,Meknes,Agadir United Arab Emirates|Garhoud,Dubai,Bur Dubai,Ras al Khaymah,Abu Dhabi,Ajman,Al Fujayrah,Sharjah NULL
|
||||
US FL NULL Falmouth NULL Falmouth Falmouth NULL
|
||||
US FL NULL Lilongwe NULL Lilongwe Lilongwe NULL
|
||||
US GA NULL Atlanta NULL NULL
|
||||
US GU NULL Herndon NULL 15642 Ht USA NULL
|
||||
US GU NULL Miami NULL Miami Miami NULL
|
||||
US MD NULL Gaithersburg NULL 20877 554 N Frederick Avenue Suite 216 NULL
|
||||
US MD NULL Potomac NULL 20854 14 Sandalfoot Court NULL
|
||||
US MD NULL Silver Spring NULL 20901 9202 Whitney St. NULL
|
||||
US MI NULL Traverse City NULL 49685 PO Box 792 NULL
|
||||
US ND NULL Pirassununga NULL Pirassununga Pirassununga NULL
|
||||
US NJ NULL Princeton NULL NULL
|
||||
US NY NULL Brooklyn NULL 11206-1980 25 Montrose Ave. Apt 304 NULL
|
||||
US NY NULL Brooklyn NULL 11225 975 washington ave 2d NULL
|
||||
US NY NULL Brooklyn NULL 11217 150 4TH AVE APT 9E NULL
|
||||
US NY NULL New York NULL NULL
|
||||
US NY NULL New York NULL 10013 148 Lafayette St. PH NULL
|
||||
US NY NULL New York NULL 10017 UNICEF 3 UN Plaza NULL
|
||||
US NY NULL New York NULL 10019 25 Columbus Circle Suite 52E NULL
|
||||
US NY NULL New York NULL 10024 65 West 85th Street 3A NULL
|
||||
US NY NULL New York NULL 10027 606 W. 116th Street #22 NULL
|
||||
US NY NULL New York NULL 10037 NULL
|
||||
US NY NULL Rochester NULL NULL
|
||||
US NY NULL Scarsdale NULL 10583-1423 54 Walworth Avenue NULL
|
||||
US OR NULL Portland NULL NULL
|
||||
US PA NULL Philadelphia NULL NULL
|
||||
US PA NULL Philadelphia NULL NULL
|
||||
US PR NULL Colonel Hill NULL Colonel Hill Colonel Hill NULL
|
||||
US SD NULL Banjul NULL Banjul Banjul NULL
|
||||
US SD NULL London NULL London London NULL
|
||||
US TX NULL Aledo NULL 76008 1588 Hunterglenn Dr NULL
|
||||
US TX NULL Keller NULL 76248 810 Placid View Ct. NULL
|
||||
US WA NULL Seattle NULL NULL
|
||||
ZA NULL Cape Town NULL NULL
|
||||
ZA NULL Cape Town NULL 7945 Alexander Road Muizenberg NULL
|
||||
ZA NULL Pretoria NULL NULL
|
||||
ZA 11 NULL Cape Town NULL NULL
|
||||
ZA 11 NULL Cape Town NULL 7435 PostNet Suite #57, Private Bag X18 Milnerton NULL
|
||||
ZA 11 NULL Cape town NULL 7508 24 Solyet Court, Lansdowne Road Claremont NULL
|
||||
ZA 11 NULL Cape Town NULL 7701 NULL
|
||||
ZA 11 NULL Cape Town NULL 7785 10 Nyamakazi Road Luzuko Park Phillipi East NULL
|
||||
ZA 11 NULL Cape Town NULL 7915 66 Albert Rd NULL
|
||||
ZA 11 NULL Cape Town NULL 8001 210 Long Street NULL
|
||||
ZM NULL Lusaka NULL NULL
|
||||
ZM 9 NULL LUSAKA NULL 10101 P.O. BOX FW 174 NULL
|
||||
|
@@ -41,11 +41,11 @@ function addressfield_get_address_format($country_code) {
|
||||
// postal code in 'used_fields'.
|
||||
$countries_with_optional_postal_code = array(
|
||||
'AC', 'AD', 'AL', 'AZ', 'BA', 'BB', 'BD', 'BG', 'BH', 'BM', 'BN', 'BT',
|
||||
'CR', 'CY', 'CZ', 'DO', 'DZ', 'EC', 'EH', 'ET', 'FO', 'GE', 'GN', 'GT',
|
||||
'CR', 'CY', 'DO', 'DZ', 'EC', 'EH', 'ET', 'FO', 'GE', 'GN', 'GT',
|
||||
'GW', 'HR', 'HT', 'IL', 'IS', 'JO', 'KE', 'KG', 'KH', 'KW', 'LA',
|
||||
'LA', 'LB', 'LK', 'LR', 'LS', 'MA', 'MC', 'MD', 'ME', 'MG', 'MK', 'MM',
|
||||
'MT', 'MU', 'MV', 'NE', 'NP', 'OM', 'PK', 'PY', 'RO', 'RS', 'SA', 'SI',
|
||||
'SK', 'SN', 'SZ', 'TA', 'TJ', 'TM', 'TN', 'VA', 'VC', 'VG', 'XK', 'ZM',
|
||||
'SN', 'SZ', 'TA', 'TJ', 'TM', 'TN', 'VA', 'VC', 'VG', 'XK', 'ZM',
|
||||
);
|
||||
foreach ($countries_with_optional_postal_code as $code) {
|
||||
$address_formats[$code] = array(
|
||||
@@ -56,9 +56,9 @@ function addressfield_get_address_format($country_code) {
|
||||
// These formats differ from the default only by the presence of the
|
||||
// postal code in 'used_fields' and 'required_fields'.
|
||||
$countries_with_required_postal_code = array(
|
||||
'AT', 'AX', 'BE', 'BL', 'CH', 'DE', 'DK', 'FI', 'FK', 'FR', 'GF', 'GG',
|
||||
'AT', 'AX', 'BE', 'BL', 'CH', 'CZ', 'DE', 'DK', 'FI', 'FK', 'FR', 'GF', 'GG',
|
||||
'GL', 'GP', 'GR', 'GS', 'HU', 'IM', 'IO', 'JE', 'LI', 'LU', 'MF', 'MQ', 'NC',
|
||||
'NL', 'NO', 'PL', 'PM', 'PN', 'PT', 'RE', 'SE', 'SH', 'SJ', 'TC', 'WF',
|
||||
'NL', 'NO', 'PL', 'PM', 'PN', 'PT', 'RE', 'SE', 'SH', 'SJ', 'SK', 'TC', 'WF',
|
||||
'YT',
|
||||
);
|
||||
foreach ($countries_with_required_postal_code as $code) {
|
||||
@@ -114,7 +114,7 @@ function addressfield_get_address_format($country_code) {
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
);
|
||||
$address_formats['CL'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'used_fields' => array('dependent_locality', 'locality', 'administrative_area', 'postal_code'),
|
||||
'administrative_area_label' => t('State', array(), array('context' => 'Territory of a country')),
|
||||
'render_administrative_area_value' => TRUE,
|
||||
);
|
||||
@@ -124,7 +124,7 @@ function addressfield_get_address_format($country_code) {
|
||||
'dependent_locality_label' => t('District'),
|
||||
);
|
||||
$address_formats['CO'] = array(
|
||||
'used_fields' => array('locality', 'administrative_area'),
|
||||
'used_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'administrative_area_label' => t('Department', array(), array('context' => 'Territory of a country')),
|
||||
);
|
||||
$address_formats['CV'] = array(
|
||||
@@ -235,6 +235,7 @@ function addressfield_get_address_format($country_code) {
|
||||
'used_fields' => array('dependent_locality', 'locality', 'administrative_area', 'postal_code'),
|
||||
'required_fields' => array('locality', 'administrative_area', 'postal_code'),
|
||||
'dependent_locality_label' => t('District'),
|
||||
'render_administrative_area_value' => TRUE,
|
||||
);
|
||||
$address_formats['KY'] = array(
|
||||
'used_fields' => array('administrative_area', 'postal_code'),
|
||||
|
@@ -11,6 +11,29 @@
|
||||
* NULL if not found.
|
||||
*/
|
||||
function addressfield_get_administrative_areas($country_code) {
|
||||
// Maintain a static cache to avoid passing the administrative areas through
|
||||
// t() more than once per request.
|
||||
$administrative_areas = &drupal_static(__FUNCTION__, array());
|
||||
if (empty($administrative_areas)) {
|
||||
// Get the default administrative areas.
|
||||
$administrative_areas = _addressfield_get_administrative_areas_defaults();
|
||||
|
||||
// Allow other modules to alter the administrative areas.
|
||||
drupal_alter('addressfield_administrative_areas', $administrative_areas);
|
||||
}
|
||||
|
||||
return isset($administrative_areas[$country_code]) ? $administrative_areas[$country_code] : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the default administrative areas.
|
||||
*/
|
||||
function _addressfield_get_administrative_areas_defaults() {
|
||||
// To avoid needless pollution of the strings list we only pass to t()
|
||||
// those administrative areas that are in English (or a latin transcription),
|
||||
// and belong to a country that either has multiple official languages (CA)
|
||||
// or uses a non-latin script (AE, CN, JP, KR, UA, RU, etc).
|
||||
// No translation is expected in other cases.
|
||||
$administrative_areas = array();
|
||||
$administrative_areas['AE'] = array(
|
||||
'AZ' => t('Abu Dhabi'),
|
||||
@@ -22,69 +45,69 @@ function addressfield_get_administrative_areas($country_code) {
|
||||
'AJ' => t('Ajmān'),
|
||||
);
|
||||
$administrative_areas['AR'] = array(
|
||||
'B' => t('Buenos Aires'),
|
||||
'K' => t('Catamarca'),
|
||||
'H' => t('Chaco'),
|
||||
'U' => t('Chubut'),
|
||||
'C' => t('Ciudad de Buenos Aires'),
|
||||
'X' => t('Córdoba'),
|
||||
'W' => t('Corrientes'),
|
||||
'E' => t('Entre Ríos'),
|
||||
'P' => t('Formosa'),
|
||||
'Y' => t('Jujuy'),
|
||||
'L' => t('La Pampa'),
|
||||
'F' => t('La Rioja'),
|
||||
'M' => t('Mendoza'),
|
||||
'N' => t('Misiones'),
|
||||
'Q' => t('Neuquén'),
|
||||
'R' => t('Río Negro'),
|
||||
'A' => t('Salta'),
|
||||
'J' => t('San Juan'),
|
||||
'D' => t('San Luis'),
|
||||
'Z' => t('Santa Cruz'),
|
||||
'S' => t('Santa Fe'),
|
||||
'G' => t('Santiago del Estero'),
|
||||
'V' => t('Tierra del Fuego'),
|
||||
'T' => t('Tucumán'),
|
||||
'B' => 'Buenos Aires',
|
||||
'K' => 'Catamarca',
|
||||
'H' => 'Chaco',
|
||||
'U' => 'Chubut',
|
||||
'C' => 'Ciudad de Buenos Aires',
|
||||
'X' => 'Córdoba',
|
||||
'W' => 'Corrientes',
|
||||
'E' => 'Entre Ríos',
|
||||
'P' => 'Formosa',
|
||||
'Y' => 'Jujuy',
|
||||
'L' => 'La Pampa',
|
||||
'F' => 'La Rioja',
|
||||
'M' => 'Mendoza',
|
||||
'N' => 'Misiones',
|
||||
'Q' => 'Neuquén',
|
||||
'R' => 'Río Negro',
|
||||
'A' => 'Salta',
|
||||
'J' => 'San Juan',
|
||||
'D' => 'San Luis',
|
||||
'Z' => 'Santa Cruz',
|
||||
'S' => 'Santa Fe',
|
||||
'G' => 'Santiago del Estero',
|
||||
'V' => 'Tierra del Fuego',
|
||||
'T' => 'Tucumán',
|
||||
);
|
||||
$administrative_areas['AU'] = array(
|
||||
'ACT' => t('Australian Capital Territory'),
|
||||
'NSW' => t('New South Wales'),
|
||||
'NT' => t('Northern Territory'),
|
||||
'QLD' => t('Queensland'),
|
||||
'SA' => t('South Australia'),
|
||||
'TAS' => t('Tasmania'),
|
||||
'VIC' => t('Victoria'),
|
||||
'WA' => t('Western Australia'),
|
||||
'ACT' => 'Australian Capital Territory',
|
||||
'NSW' => 'New South Wales',
|
||||
'NT' => 'Northern Territory',
|
||||
'QLD' => 'Queensland',
|
||||
'SA' => 'South Australia',
|
||||
'TAS' => 'Tasmania',
|
||||
'VIC' => 'Victoria',
|
||||
'WA' => 'Western Australia',
|
||||
);
|
||||
$administrative_areas['BR'] = array(
|
||||
'AC' => t('Acre'),
|
||||
'AL' => t('Alagoas'),
|
||||
'AM' => t('Amazonas'),
|
||||
'AP' => t('Amapá'),
|
||||
'BA' => t('Bahia'),
|
||||
'CE' => t('Ceará'),
|
||||
'DF' => t('Distrito Federal'),
|
||||
'ES' => t('Espírito Santo'),
|
||||
'GO' => t('Goiás'),
|
||||
'MA' => t('Maranhão'),
|
||||
'MG' => t('Minas Gerais'),
|
||||
'MS' => t('Mato Grosso do Sul'),
|
||||
'MT' => t('Mato Grosso'),
|
||||
'PA' => t('Pará'),
|
||||
'PB' => t('Paraíba'),
|
||||
'PE' => t('Pernambuco'),
|
||||
'PI' => t('Piauí'),
|
||||
'PR' => t('Paraná'),
|
||||
'RJ' => t('Rio de Janeiro'),
|
||||
'RN' => t('Rio Grande do Norte'),
|
||||
'RO' => t('Rondônia'),
|
||||
'RR' => t('Roraima'),
|
||||
'RS' => t('Rio Grande do Sul'),
|
||||
'SC' => t('Santa Catarina'),
|
||||
'SE' => t('Sergipe'),
|
||||
'SP' => t('São Paulo'),
|
||||
'TO' => t('Tocantins'),
|
||||
'AC' => 'Acre',
|
||||
'AL' => 'Alagoas',
|
||||
'AM' => 'Amazonas',
|
||||
'AP' => 'Amapá',
|
||||
'BA' => 'Bahia',
|
||||
'CE' => 'Ceará',
|
||||
'DF' => 'Distrito Federal',
|
||||
'ES' => 'Espírito Santo',
|
||||
'GO' => 'Goiás',
|
||||
'MA' => 'Maranhão',
|
||||
'MG' => 'Minas Gerais',
|
||||
'MS' => 'Mato Grosso do Sul',
|
||||
'MT' => 'Mato Grosso',
|
||||
'PA' => 'Pará',
|
||||
'PB' => 'Paraíba',
|
||||
'PE' => 'Pernambuco',
|
||||
'PI' => 'Piauí',
|
||||
'PR' => 'Paraná',
|
||||
'RJ' => 'Rio de Janeiro',
|
||||
'RN' => 'Rio Grande do Norte',
|
||||
'RO' => 'Rondônia',
|
||||
'RR' => 'Roraima',
|
||||
'RS' => 'Rio Grande do Sul',
|
||||
'SC' => 'Santa Catarina',
|
||||
'SE' => 'Sergipe',
|
||||
'SP' => 'São Paulo',
|
||||
'TO' => 'Tocantins',
|
||||
);
|
||||
$administrative_areas['CA'] = array(
|
||||
'AB' => t('Alberta'),
|
||||
@@ -102,21 +125,21 @@ function addressfield_get_administrative_areas($country_code) {
|
||||
'YT' => t('Yukon Territory'),
|
||||
);
|
||||
$administrative_areas['CL'] = array(
|
||||
'AI' => t('Aysén del General Carlos Ibáñez del Campo'),
|
||||
'AN' => t('Antofagasta'),
|
||||
'AR' => t('Araucanía'),
|
||||
'AP' => t('Arica y Parinacota'),
|
||||
'AT' => t('Atacama'),
|
||||
'BI' => t('Biobío'),
|
||||
'CO' => t('Coquimbo'),
|
||||
'LI' => t('Libertador General Bernardo O\'Higgins'),
|
||||
'LL' => t('Los Lagos'),
|
||||
'LR' => t('Los Ríos'),
|
||||
'MA' => t('Magallanes y de la Antártica Chilena'),
|
||||
'ML' => t('Maule'),
|
||||
'RM' => t('Metropolitana de Santiago'),
|
||||
'TA' => t('Tarapacá'),
|
||||
'VS' => t('Valparaíso'),
|
||||
'AI' => 'Aysén del General Carlos Ibáñez del Campo',
|
||||
'AN' => 'Antofagasta',
|
||||
'AR' => 'Araucanía',
|
||||
'AP' => 'Arica y Parinacota',
|
||||
'AT' => 'Atacama',
|
||||
'BI' => 'Biobío',
|
||||
'CO' => 'Coquimbo',
|
||||
'LI' => 'Libertador General Bernardo O\'Higgins',
|
||||
'LL' => 'Los Lagos',
|
||||
'LR' => 'Los Ríos',
|
||||
'MA' => 'Magallanes y de la Antártica Chilena',
|
||||
'ML' => 'Maule',
|
||||
'RM' => 'Metropolitana de Santiago',
|
||||
'TA' => 'Tarapacá',
|
||||
'VS' => 'Valparaíso',
|
||||
);
|
||||
$administrative_areas['CN'] = array(
|
||||
'34' => t('Anhui Sheng'),
|
||||
@@ -155,55 +178,55 @@ function addressfield_get_administrative_areas($country_code) {
|
||||
'33' => t('Zhejiang Sheng'),
|
||||
);
|
||||
$administrative_areas['CO'] = array(
|
||||
'AMA' => t('Amazonas'),
|
||||
'ANT' => t('Antioquia'),
|
||||
'ARA' => t('Arauca'),
|
||||
'ATL' => t('Atlántico'),
|
||||
'BOL' => t('Bolívar'),
|
||||
'BOY' => t('Boyacá'),
|
||||
'CAL' => t('Caldas'),
|
||||
'CAQ' => t('Caquetá'),
|
||||
'CAS' => t('Casanare'),
|
||||
'CAU' => t('Cauca'),
|
||||
'CES' => t('Cesar'),
|
||||
'COR' => t('Córdoba'),
|
||||
'CUN' => t('Cundinamarca'),
|
||||
'CHO' => t('Chocó'),
|
||||
'GUA' => t('Guainía'),
|
||||
'GUV' => t('Guaviare'),
|
||||
'HUI' => t('Huila'),
|
||||
'LAG' => t('La Guajira'),
|
||||
'MAG' => t('Magdalena'),
|
||||
'MET' => t('Meta'),
|
||||
'NAR' => t('Nariño'),
|
||||
'NSA' => t('Norte de Santander'),
|
||||
'PUT' => t('Putumayo'),
|
||||
'QUI' => t('Quindío'),
|
||||
'RIS' => t('Risaralda'),
|
||||
'SAP' => t('San Andrés, Providencia y Santa Catalina'),
|
||||
'SAN' => t('Santander'),
|
||||
'SUC' => t('Sucre'),
|
||||
'TOL' => t('Tolima'),
|
||||
'VAC' => t('Valle del Cauca'),
|
||||
'VAU' => t('Vaupés'),
|
||||
'VID' => t('Vichada'),
|
||||
'AMA' => 'Amazonas',
|
||||
'ANT' => 'Antioquia',
|
||||
'ARA' => 'Arauca',
|
||||
'ATL' => 'Atlántico',
|
||||
'BOL' => 'Bolívar',
|
||||
'BOY' => 'Boyacá',
|
||||
'CAL' => 'Caldas',
|
||||
'CAQ' => 'Caquetá',
|
||||
'CAS' => 'Casanare',
|
||||
'CAU' => 'Cauca',
|
||||
'CES' => 'Cesar',
|
||||
'COR' => 'Córdoba',
|
||||
'CUN' => 'Cundinamarca',
|
||||
'CHO' => 'Chocó',
|
||||
'GUA' => 'Guainía',
|
||||
'GUV' => 'Guaviare',
|
||||
'HUI' => 'Huila',
|
||||
'LAG' => 'La Guajira',
|
||||
'MAG' => 'Magdalena',
|
||||
'MET' => 'Meta',
|
||||
'NAR' => 'Nariño',
|
||||
'NSA' => 'Norte de Santander',
|
||||
'PUT' => 'Putumayo',
|
||||
'QUI' => 'Quindío',
|
||||
'RIS' => 'Risaralda',
|
||||
'SAP' => 'San Andrés, Providencia y Santa Catalina',
|
||||
'SAN' => 'Santander',
|
||||
'SUC' => 'Sucre',
|
||||
'TOL' => 'Tolima',
|
||||
'VAC' => 'Valle del Cauca',
|
||||
'VAU' => 'Vaupés',
|
||||
'VID' => 'Vichada',
|
||||
);
|
||||
$administrative_areas['EE'] = array(
|
||||
'37' => t('Harjumaa'),
|
||||
'39' => t('Hiiumaa'),
|
||||
'44' => t('Ida-Virumaa'),
|
||||
'49' => t('Jõgevamaa'),
|
||||
'51' => t('Järvamaa'),
|
||||
'57' => t('Läänemaa'),
|
||||
'59' => t('Lääne-Virumaa'),
|
||||
'65' => t('Põlvamaa'),
|
||||
'67' => t('Pärnumaa'),
|
||||
'70' => t('Raplamaa'),
|
||||
'74' => t('Saaremaa'),
|
||||
'78' => t('Tartumaa'),
|
||||
'82' => t('Valgamaa'),
|
||||
'84' => t('Viljandimaa'),
|
||||
'86' => t('Võrumaa'),
|
||||
'37' => 'Harjumaa',
|
||||
'39' => 'Hiiumaa',
|
||||
'44' => 'Ida-Virumaa',
|
||||
'49' => 'Jõgevamaa',
|
||||
'51' => 'Järvamaa',
|
||||
'57' => 'Läänemaa',
|
||||
'59' => 'Lääne-Virumaa',
|
||||
'65' => 'Põlvamaa',
|
||||
'67' => 'Pärnumaa',
|
||||
'70' => 'Raplamaa',
|
||||
'74' => 'Saaremaa',
|
||||
'78' => 'Tartumaa',
|
||||
'82' => 'Valgamaa',
|
||||
'84' => 'Viljandimaa',
|
||||
'86' => 'Võrumaa',
|
||||
);
|
||||
$administrative_areas['EG'] = array(
|
||||
'ALX' => t('Alexandria'),
|
||||
@@ -235,58 +258,58 @@ function addressfield_get_administrative_areas($country_code) {
|
||||
'LX' => t('Luxor'),
|
||||
);
|
||||
$administrative_areas['ES'] = array(
|
||||
'C' => t("A Coruña"),
|
||||
'VI' => t('Alava'),
|
||||
'AB' => t('Albacete'),
|
||||
'A' => t('Alicante'),
|
||||
'AL' => t("Almería"),
|
||||
'O' => t('Asturias'),
|
||||
'AV' => t("Ávila"),
|
||||
'BA' => t('Badajoz'),
|
||||
'PM' => t('Baleares'),
|
||||
'B' => t('Barcelona'),
|
||||
'BU' => t('Burgos'),
|
||||
'CC' => t("Cáceres"),
|
||||
'CA' => t("Cádiz"),
|
||||
'S' => t('Cantabria'),
|
||||
'CS' => t("Castellón"),
|
||||
'CE' => t('Ceuta'),
|
||||
'CR' => t('Ciudad Real'),
|
||||
'CO' => t("Córdoba"),
|
||||
'CU' => t('Cuenca'),
|
||||
'GI' => t('Gerona'),
|
||||
'GR' => t('Granada'),
|
||||
'GU' => t('Guadalajara'),
|
||||
'SS' => t("Guipúzcoa"),
|
||||
'H' => t('Huelva'),
|
||||
'HU' => t('Huesca'),
|
||||
'J' => t("Jaén"),
|
||||
'LO' => t('La Rioja'),
|
||||
'GC' => t('Las Palmas'),
|
||||
'LE' => t("León"),
|
||||
'L' => t("Lérida"),
|
||||
'LU' => t('Lugo'),
|
||||
'M' => t('Madrid'),
|
||||
'MA' => t("Málaga"),
|
||||
'ML' => t('Melilla'),
|
||||
'MU' => t('Murcia'),
|
||||
'NA' => t('Navarra'),
|
||||
'OR' => t('Ourense'),
|
||||
'P' => t('Palencia'),
|
||||
'PO' => t('Pontevedra'),
|
||||
'SA' => t('Salamanca'),
|
||||
'TF' => t('Santa Cruz de Tenerife'),
|
||||
'SG' => t('Segovia'),
|
||||
'SE' => t('Sevilla'),
|
||||
'SO' => t('Soria'),
|
||||
'T' => t('Tarragona'),
|
||||
'TE' => t('Teruel'),
|
||||
'TO' => t('Toledo'),
|
||||
'V' => t('Valencia'),
|
||||
'VA' => t('Valladolid'),
|
||||
'BI' => t('Vizcaya'),
|
||||
'ZA' => t('Zamora'),
|
||||
'Z' => t('Zaragoza'),
|
||||
'C' => "A Coruña",
|
||||
'VI' => 'Alava',
|
||||
'AB' => 'Albacete',
|
||||
'A' => 'Alicante',
|
||||
'AL' => "Almería",
|
||||
'O' => 'Asturias',
|
||||
'AV' => "Ávila",
|
||||
'BA' => 'Badajoz',
|
||||
'PM' => 'Baleares',
|
||||
'B' => 'Barcelona',
|
||||
'BU' => 'Burgos',
|
||||
'CC' => "Cáceres",
|
||||
'CA' => "Cádiz",
|
||||
'S' => 'Cantabria',
|
||||
'CS' => "Castellón",
|
||||
'CE' => 'Ceuta',
|
||||
'CR' => 'Ciudad Real',
|
||||
'CO' => "Córdoba",
|
||||
'CU' => 'Cuenca',
|
||||
'GI' => 'Girona',
|
||||
'GR' => 'Granada',
|
||||
'GU' => 'Guadalajara',
|
||||
'SS' => "Guipúzcoa",
|
||||
'H' => 'Huelva',
|
||||
'HU' => 'Huesca',
|
||||
'J' => "Jaén",
|
||||
'LO' => 'La Rioja',
|
||||
'GC' => 'Las Palmas',
|
||||
'LE' => "León",
|
||||
'L' => "Lleida",
|
||||
'LU' => 'Lugo',
|
||||
'M' => 'Madrid',
|
||||
'MA' => "Málaga",
|
||||
'ML' => 'Melilla',
|
||||
'MU' => 'Murcia',
|
||||
'NA' => 'Navarra',
|
||||
'OR' => 'Ourense',
|
||||
'P' => 'Palencia',
|
||||
'PO' => 'Pontevedra',
|
||||
'SA' => 'Salamanca',
|
||||
'TF' => 'Santa Cruz de Tenerife',
|
||||
'SG' => 'Segovia',
|
||||
'SE' => 'Sevilla',
|
||||
'SO' => 'Soria',
|
||||
'T' => 'Tarragona',
|
||||
'TE' => 'Teruel',
|
||||
'TO' => 'Toledo',
|
||||
'V' => 'Valencia',
|
||||
'VA' => 'Valladolid',
|
||||
'BI' => 'Vizcaya',
|
||||
'ZA' => 'Zamora',
|
||||
'Z' => 'Zaragoza',
|
||||
);
|
||||
$administrative_areas['HK'] = array(
|
||||
// HK subdivisions have no ISO codes assigned.
|
||||
@@ -330,57 +353,57 @@ function addressfield_get_administrative_areas($country_code) {
|
||||
'SU' => t('Sumatera Utara'),
|
||||
);
|
||||
$administrative_areas['IE'] = array(
|
||||
'CW' => t('Co Carlow'),
|
||||
'CN' => t('Co Cavan'),
|
||||
'CE' => t('Co Clare'),
|
||||
'CO' => t('Co Cork'),
|
||||
'DL' => t('Co Donegal'),
|
||||
'D' => t('Co Dublin'),
|
||||
'D1' => t('Dublin 1'),
|
||||
'D2' => t('Dublin 2'),
|
||||
'D3' => t('Dublin 3'),
|
||||
'D4' => t('Dublin 4'),
|
||||
'D5' => t('Dublin 5'),
|
||||
'D6' => t('Dublin 6'),
|
||||
'D6W' => t('Dublin 6w'),
|
||||
'D7' => t('Dublin 7'),
|
||||
'D8' => t('Dublin 8'),
|
||||
'D9' => t('Dublin 9'),
|
||||
'D10' => t('Dublin 10'),
|
||||
'D11' => t('Dublin 11'),
|
||||
'D12' => t('Dublin 12'),
|
||||
'D13' => t('Dublin 13'),
|
||||
'D14' => t('Dublin 14'),
|
||||
'D15' => t('Dublin 15'),
|
||||
'D16' => t('Dublin 16'),
|
||||
'D17' => t('Dublin 17'),
|
||||
'D18' => t('Dublin 18'),
|
||||
'D19' => t('Dublin 19'),
|
||||
'D20' => t('Dublin 20'),
|
||||
'D21' => t('Dublin 21'),
|
||||
'D22' => t('Dublin 22'),
|
||||
'D23' => t('Dublin 23'),
|
||||
'D24' => t('Dublin 24'),
|
||||
'G' => t('Co Galway'),
|
||||
'KY' => t('Co Kerry'),
|
||||
'KE' => t('Co Kildare'),
|
||||
'KK' => t('Co Kilkenny'),
|
||||
'LS' => t('Co Laois'),
|
||||
'LM' => t('Co Leitrim'),
|
||||
'LK' => t('Co Limerick'),
|
||||
'LD' => t('Co Longford'),
|
||||
'LH' => t('Co Louth'),
|
||||
'MO' => t('Co Mayo'),
|
||||
'MH' => t('Co Meath'),
|
||||
'MN' => t('Co Monaghan'),
|
||||
'OY' => t('Co Offaly'),
|
||||
'RN' => t('Co Roscommon'),
|
||||
'SO' => t('Co Sligo'),
|
||||
'TA' => t('Co Tipperary'),
|
||||
'WD' => t('Co Waterford'),
|
||||
'WH' => t('Co Westmeath'),
|
||||
'WX' => t('Co Wexford'),
|
||||
'WW' => t('Co Wicklow'),
|
||||
'CW' => 'Co Carlow',
|
||||
'CN' => 'Co Cavan',
|
||||
'CE' => 'Co Clare',
|
||||
'CO' => 'Co Cork',
|
||||
'DL' => 'Co Donegal',
|
||||
'D' => 'Co Dublin',
|
||||
'D1' => 'Dublin 1',
|
||||
'D2' => 'Dublin 2',
|
||||
'D3' => 'Dublin 3',
|
||||
'D4' => 'Dublin 4',
|
||||
'D5' => 'Dublin 5',
|
||||
'D6' => 'Dublin 6',
|
||||
'D6W' => 'Dublin 6w',
|
||||
'D7' => 'Dublin 7',
|
||||
'D8' => 'Dublin 8',
|
||||
'D9' => 'Dublin 9',
|
||||
'D10' => 'Dublin 10',
|
||||
'D11' => 'Dublin 11',
|
||||
'D12' => 'Dublin 12',
|
||||
'D13' => 'Dublin 13',
|
||||
'D14' => 'Dublin 14',
|
||||
'D15' => 'Dublin 15',
|
||||
'D16' => 'Dublin 16',
|
||||
'D17' => 'Dublin 17',
|
||||
'D18' => 'Dublin 18',
|
||||
'D19' => 'Dublin 19',
|
||||
'D20' => 'Dublin 20',
|
||||
'D21' => 'Dublin 21',
|
||||
'D22' => 'Dublin 22',
|
||||
'D23' => 'Dublin 23',
|
||||
'D24' => 'Dublin 24',
|
||||
'G' => 'Co Galway',
|
||||
'KY' => 'Co Kerry',
|
||||
'KE' => 'Co Kildare',
|
||||
'KK' => 'Co Kilkenny',
|
||||
'LS' => 'Co Laois',
|
||||
'LM' => 'Co Leitrim',
|
||||
'LK' => 'Co Limerick',
|
||||
'LD' => 'Co Longford',
|
||||
'LH' => 'Co Louth',
|
||||
'MO' => 'Co Mayo',
|
||||
'MH' => 'Co Meath',
|
||||
'MN' => 'Co Monaghan',
|
||||
'OY' => 'Co Offaly',
|
||||
'RN' => 'Co Roscommon',
|
||||
'SO' => 'Co Sligo',
|
||||
'TA' => 'Co Tipperary',
|
||||
'WD' => 'Co Waterford',
|
||||
'WH' => 'Co Westmeath',
|
||||
'WX' => 'Co Wexford',
|
||||
'WW' => 'Co Wicklow',
|
||||
);
|
||||
$administrative_areas['IN'] = array(
|
||||
'AP' => t('Andhra Pradesh'),
|
||||
@@ -388,8 +411,6 @@ function addressfield_get_administrative_areas($country_code) {
|
||||
'AS' => t('Assam'),
|
||||
'BR' => t('Bihar'),
|
||||
'CT' => t('Chhattisgarh'),
|
||||
'DD' => t('Daman & Diu'),
|
||||
'DN' => t('Dadra & Nagar Haveli'),
|
||||
'GA' => t('Goa'),
|
||||
'GJ' => t('Gujarat'),
|
||||
'HP' => t('Himachal Pradesh'),
|
||||
@@ -424,116 +445,116 @@ function addressfield_get_administrative_areas($country_code) {
|
||||
'PY' => t('Puducherry'),
|
||||
);
|
||||
$administrative_areas['IT'] = array(
|
||||
'AG' => t('Agrigento'),
|
||||
'AL' => t('Alessandria'),
|
||||
'AN' => t('Ancona'),
|
||||
'AO' => t('Aosta'),
|
||||
'AP' => t('Ascoli Piceno'),
|
||||
'AQ' => t("L'Aquila"),
|
||||
'AR' => t('Arezzo'),
|
||||
'AT' => t('Asti'),
|
||||
'AV' => t('Avellino'),
|
||||
'BA' => t('Bari'),
|
||||
'BG' => t('Bergamo'),
|
||||
'BI' => t('Biella'),
|
||||
'BL' => t('Belluno'),
|
||||
'BN' => t('Benevento'),
|
||||
'BO' => t('Bologna'),
|
||||
'BR' => t('Brindisi'),
|
||||
'BS' => t('Brescia'),
|
||||
'BT' => t('Barletta-Andria-Trani'),
|
||||
'BZ' => t('Bolzano/Bozen'),
|
||||
'CA' => t('Cagliari'),
|
||||
'CB' => t('Campobasso'),
|
||||
'CE' => t('Caserta'),
|
||||
'CH' => t('Chieti'),
|
||||
'CI' => t('Carbonia-Iglesias'),
|
||||
'CL' => t('Caltanissetta'),
|
||||
'CN' => t('Cuneo'),
|
||||
'CO' => t('Como'),
|
||||
'CR' => t('Cremona'),
|
||||
'CS' => t('Cosenza'),
|
||||
'CT' => t('Catania'),
|
||||
'CZ' => t('Catanzaro'),
|
||||
'EN' => t('Enna'),
|
||||
'FC' => t('Forlì-Cesena'),
|
||||
'FE' => t('Ferrara'),
|
||||
'FG' => t('Foggia'),
|
||||
'FI' => t('Firenze'),
|
||||
'FM' => t('Fermo'),
|
||||
'FR' => t('Frosinone'),
|
||||
'GE' => t('Genova'),
|
||||
'GO' => t('Gorizia'),
|
||||
'GR' => t('Grosseto'),
|
||||
'IM' => t('Imperia'),
|
||||
'IS' => t('Isernia'),
|
||||
'KR' => t('Crotone'),
|
||||
'LC' => t('Lecco'),
|
||||
'LE' => t('Lecce'),
|
||||
'LI' => t('Livorno'),
|
||||
'LO' => t('Lodi'),
|
||||
'LT' => t('Latina'),
|
||||
'LU' => t('Lucca'),
|
||||
'MB' => t('Monza e Brianza'),
|
||||
'MC' => t('Macerata'),
|
||||
'ME' => t('Messina'),
|
||||
'MI' => t('Milano'),
|
||||
'MN' => t('Mantova'),
|
||||
'MO' => t('Modena'),
|
||||
'MS' => t('Massa-Carrara'),
|
||||
'MT' => t('Matera'),
|
||||
'NA' => t('Napoli'),
|
||||
'NO' => t('Novara'),
|
||||
'NU' => t('Nuoro'),
|
||||
'OG' => t('Ogliastra'),
|
||||
'OR' => t('Oristano'),
|
||||
'OT' => t('Olbia-Tempio'),
|
||||
'PA' => t('Palermo'),
|
||||
'PC' => t('Piacenza'),
|
||||
'PD' => t('Padova'),
|
||||
'PE' => t('Pescara'),
|
||||
'PG' => t('Perugia'),
|
||||
'PI' => t('Pisa'),
|
||||
'PN' => t('Pordenone'),
|
||||
'PO' => t('Prato'),
|
||||
'PR' => t('Parma'),
|
||||
'PT' => t('Pistoia'),
|
||||
'PU' => t('Pesaro e Urbino'),
|
||||
'PV' => t('Pavia'),
|
||||
'PZ' => t('Potenza'),
|
||||
'RA' => t('Ravenna'),
|
||||
'RC' => t('Reggio Calabria'),
|
||||
'RE' => t('Reggio Emilia'),
|
||||
'RG' => t('Ragusa'),
|
||||
'RI' => t('Rieti'),
|
||||
'RM' => t('Roma'),
|
||||
'RN' => t('Rimini'),
|
||||
'RO' => t('Rovigo'),
|
||||
'SA' => t('Salerno'),
|
||||
'SI' => t('Siena'),
|
||||
'SO' => t('Sondrio'),
|
||||
'SP' => t('La Spezia'),
|
||||
'SR' => t('Siracusa'),
|
||||
'SS' => t('Sassari'),
|
||||
'SV' => t('Savona'),
|
||||
'TA' => t('Taranto'),
|
||||
'TE' => t('Teramo'),
|
||||
'TN' => t('Trento'),
|
||||
'TO' => t('Torino'),
|
||||
'TP' => t('Trapani'),
|
||||
'TR' => t('Terni'),
|
||||
'TS' => t('Trieste'),
|
||||
'TV' => t('Treviso'),
|
||||
'UD' => t('Udine'),
|
||||
'VA' => t('Varese'),
|
||||
'VB' => t('Verbano-Cusio-Ossola'),
|
||||
'VC' => t('Vercelli'),
|
||||
'VE' => t('Venezia'),
|
||||
'VI' => t('Vicenza'),
|
||||
'VR' => t('Verona'),
|
||||
'VS' => t('Medio Campidano'),
|
||||
'VT' => t('Viterbo'),
|
||||
'VV' => t('Vibo Valentia'),
|
||||
'AG' => 'Agrigento',
|
||||
'AL' => 'Alessandria',
|
||||
'AN' => 'Ancona',
|
||||
'AO' => 'Aosta',
|
||||
'AP' => 'Ascoli Piceno',
|
||||
'AQ' => "L'Aquila",
|
||||
'AR' => 'Arezzo',
|
||||
'AT' => 'Asti',
|
||||
'AV' => 'Avellino',
|
||||
'BA' => 'Bari',
|
||||
'BG' => 'Bergamo',
|
||||
'BI' => 'Biella',
|
||||
'BL' => 'Belluno',
|
||||
'BN' => 'Benevento',
|
||||
'BO' => 'Bologna',
|
||||
'BR' => 'Brindisi',
|
||||
'BS' => 'Brescia',
|
||||
'BT' => 'Barletta-Andria-Trani',
|
||||
'BZ' => 'Bolzano/Bozen',
|
||||
'CA' => 'Cagliari',
|
||||
'CB' => 'Campobasso',
|
||||
'CE' => 'Caserta',
|
||||
'CH' => 'Chieti',
|
||||
'CI' => 'Carbonia-Iglesias',
|
||||
'CL' => 'Caltanissetta',
|
||||
'CN' => 'Cuneo',
|
||||
'CO' => 'Como',
|
||||
'CR' => 'Cremona',
|
||||
'CS' => 'Cosenza',
|
||||
'CT' => 'Catania',
|
||||
'CZ' => 'Catanzaro',
|
||||
'EN' => 'Enna',
|
||||
'FC' => 'Forlì-Cesena',
|
||||
'FE' => 'Ferrara',
|
||||
'FG' => 'Foggia',
|
||||
'FI' => 'Firenze',
|
||||
'FM' => 'Fermo',
|
||||
'FR' => 'Frosinone',
|
||||
'GE' => 'Genova',
|
||||
'GO' => 'Gorizia',
|
||||
'GR' => 'Grosseto',
|
||||
'IM' => 'Imperia',
|
||||
'IS' => 'Isernia',
|
||||
'KR' => 'Crotone',
|
||||
'LC' => 'Lecco',
|
||||
'LE' => 'Lecce',
|
||||
'LI' => 'Livorno',
|
||||
'LO' => 'Lodi',
|
||||
'LT' => 'Latina',
|
||||
'LU' => 'Lucca',
|
||||
'MB' => 'Monza e Brianza',
|
||||
'MC' => 'Macerata',
|
||||
'ME' => 'Messina',
|
||||
'MI' => 'Milano',
|
||||
'MN' => 'Mantova',
|
||||
'MO' => 'Modena',
|
||||
'MS' => 'Massa-Carrara',
|
||||
'MT' => 'Matera',
|
||||
'NA' => 'Napoli',
|
||||
'NO' => 'Novara',
|
||||
'NU' => 'Nuoro',
|
||||
'OG' => 'Ogliastra',
|
||||
'OR' => 'Oristano',
|
||||
'OT' => 'Olbia-Tempio',
|
||||
'PA' => 'Palermo',
|
||||
'PC' => 'Piacenza',
|
||||
'PD' => 'Padova',
|
||||
'PE' => 'Pescara',
|
||||
'PG' => 'Perugia',
|
||||
'PI' => 'Pisa',
|
||||
'PN' => 'Pordenone',
|
||||
'PO' => 'Prato',
|
||||
'PR' => 'Parma',
|
||||
'PT' => 'Pistoia',
|
||||
'PU' => 'Pesaro e Urbino',
|
||||
'PV' => 'Pavia',
|
||||
'PZ' => 'Potenza',
|
||||
'RA' => 'Ravenna',
|
||||
'RC' => 'Reggio Calabria',
|
||||
'RE' => 'Reggio Emilia',
|
||||
'RG' => 'Ragusa',
|
||||
'RI' => 'Rieti',
|
||||
'RM' => 'Roma',
|
||||
'RN' => 'Rimini',
|
||||
'RO' => 'Rovigo',
|
||||
'SA' => 'Salerno',
|
||||
'SI' => 'Siena',
|
||||
'SO' => 'Sondrio',
|
||||
'SP' => 'La Spezia',
|
||||
'SR' => 'Siracusa',
|
||||
'SS' => 'Sassari',
|
||||
'SV' => 'Savona',
|
||||
'TA' => 'Taranto',
|
||||
'TE' => 'Teramo',
|
||||
'TN' => 'Trento',
|
||||
'TO' => 'Torino',
|
||||
'TP' => 'Trapani',
|
||||
'TR' => 'Terni',
|
||||
'TS' => 'Trieste',
|
||||
'TV' => 'Treviso',
|
||||
'UD' => 'Udine',
|
||||
'VA' => 'Varese',
|
||||
'VB' => 'Verbano-Cusio-Ossola',
|
||||
'VC' => 'Vercelli',
|
||||
'VE' => 'Venezia',
|
||||
'VI' => 'Vicenza',
|
||||
'VR' => 'Verona',
|
||||
'VS' => 'Medio Campidano',
|
||||
'VT' => 'Viterbo',
|
||||
'VV' => 'Vibo Valentia',
|
||||
);
|
||||
$administrative_areas['JM'] = array(
|
||||
'13' => 'Clarendon',
|
||||
@@ -638,38 +659,38 @@ function addressfield_get_administrative_areas($country_code) {
|
||||
'ZHA' => t('Zhambyl region'),
|
||||
);
|
||||
$administrative_areas['MX'] = array(
|
||||
'AGU' => t('Aguascalientes'),
|
||||
'BCN' => t('Baja California'),
|
||||
'BCS' => t('Baja California Sur'),
|
||||
'CAM' => t('Campeche'),
|
||||
'COA' => t('Coahuila'),
|
||||
'COL' => t('Colima'),
|
||||
'CHP' => t('Chiapas'),
|
||||
'CHH' => t('Chihuahua'),
|
||||
'DIF' => t('Distrito Federal'),
|
||||
'DUG' => t('Durango'),
|
||||
'MEX' => t('Estado de México'),
|
||||
'GUA' => t('Guanajuato'),
|
||||
'GRO' => t('Guerrero'),
|
||||
'HID' => t('Hidalgo'),
|
||||
'JAL' => t('Jalisco'),
|
||||
'MIC' => t('Michoacán'),
|
||||
'MOR' => t('Morelos'),
|
||||
'NAY' => t('Nayarit'),
|
||||
'NLE' => t('Nuevo León'),
|
||||
'OAX' => t('Oaxaca'),
|
||||
'PUE' => t('Puebla'),
|
||||
'QUE' => t('Queretaro'),
|
||||
'ROO' => t('Quintana Roo'),
|
||||
'SLP' => t('San Luis Potosí'),
|
||||
'SIN' => t('Sinaloa'),
|
||||
'SON' => t('Sonora'),
|
||||
'TAB' => t('Tabasco'),
|
||||
'TAM' => t('Tamaulipas'),
|
||||
'TLA' => t('Tlaxcala'),
|
||||
'VER' => t('Veracruz'),
|
||||
'YUC' => t('Yucatán'),
|
||||
'ZAC' => t('Zacatecas'),
|
||||
'AGU' => 'Aguascalientes',
|
||||
'BCN' => 'Baja California',
|
||||
'BCS' => 'Baja California Sur',
|
||||
'CAM' => 'Campeche',
|
||||
'COA' => 'Coahuila',
|
||||
'COL' => 'Colima',
|
||||
'CHP' => 'Chiapas',
|
||||
'CHH' => 'Chihuahua',
|
||||
'DIF' => 'Distrito Federal',
|
||||
'DUG' => 'Durango',
|
||||
'MEX' => 'Estado de México',
|
||||
'GUA' => 'Guanajuato',
|
||||
'GRO' => 'Guerrero',
|
||||
'HID' => 'Hidalgo',
|
||||
'JAL' => 'Jalisco',
|
||||
'MIC' => 'Michoacán',
|
||||
'MOR' => 'Morelos',
|
||||
'NAY' => 'Nayarit',
|
||||
'NLE' => 'Nuevo León',
|
||||
'OAX' => 'Oaxaca',
|
||||
'PUE' => 'Puebla',
|
||||
'QUE' => 'Queretaro',
|
||||
'ROO' => 'Quintana Roo',
|
||||
'SLP' => 'San Luis Potosí',
|
||||
'SIN' => 'Sinaloa',
|
||||
'SON' => 'Sonora',
|
||||
'TAB' => 'Tabasco',
|
||||
'TAM' => 'Tamaulipas',
|
||||
'TLA' => 'Tlaxcala',
|
||||
'VER' => 'Veracruz',
|
||||
'YUC' => 'Yucatán',
|
||||
'ZAC' => 'Zacatecas',
|
||||
);
|
||||
$administrative_areas['MY'] = array(
|
||||
'01' => t('Johor'),
|
||||
@@ -690,31 +711,31 @@ function addressfield_get_administrative_areas($country_code) {
|
||||
'11' => t('Terengganu'),
|
||||
);
|
||||
$administrative_areas['PE'] = array(
|
||||
'AMA' => t('Amazonas'),
|
||||
'ANC' => t('Ancash'),
|
||||
'APU' => t('Apurimac'),
|
||||
'ARE' => t('Arequipa'),
|
||||
'AYA' => t('Ayacucho'),
|
||||
'CAJ' => t('Cajamarca'),
|
||||
'CAL' => t('Callao'),
|
||||
'CUS' => t('Cusco'),
|
||||
'HUV' => t('Huancavelica'),
|
||||
'HUC' => t('Huanuco'),
|
||||
'ICA' => t('Ica'),
|
||||
'JUN' => t('Junin'),
|
||||
'LAL' => t('La Libertad'),
|
||||
'LAM' => t('Lambayeque'),
|
||||
'LIM' => t('Lima'),
|
||||
'LOR' => t('Loreto'),
|
||||
'MDD' => t('Madre de Dios'),
|
||||
'MOQ' => t('Moquegua'),
|
||||
'PAS' => t('Pasco'),
|
||||
'PIU' => t('Piura'),
|
||||
'PUN' => t('Puno'),
|
||||
'SAM' => t('San Martin'),
|
||||
'TAC' => t('Tacna'),
|
||||
'TUM' => t('Tumbes'),
|
||||
'UCA' => t('Ucayali'),
|
||||
'AMA' => 'Amazonas',
|
||||
'ANC' => 'Ancash',
|
||||
'APU' => 'Apurimac',
|
||||
'ARE' => 'Arequipa',
|
||||
'AYA' => 'Ayacucho',
|
||||
'CAJ' => 'Cajamarca',
|
||||
'CAL' => 'Callao',
|
||||
'CUS' => 'Cusco',
|
||||
'HUV' => 'Huancavelica',
|
||||
'HUC' => 'Huanuco',
|
||||
'ICA' => 'Ica',
|
||||
'JUN' => 'Junin',
|
||||
'LAL' => 'La Libertad',
|
||||
'LAM' => 'Lambayeque',
|
||||
'LIM' => 'Lima',
|
||||
'LOR' => 'Loreto',
|
||||
'MDD' => 'Madre de Dios',
|
||||
'MOQ' => 'Moquegua',
|
||||
'PAS' => 'Pasco',
|
||||
'PIU' => 'Piura',
|
||||
'PUN' => 'Puno',
|
||||
'SAM' => 'San Martin',
|
||||
'TAC' => 'Tacna',
|
||||
'TUM' => 'Tumbes',
|
||||
'UCA' => 'Ucayali',
|
||||
);
|
||||
$administrative_areas['RU'] = array(
|
||||
'MOW' => t('Moskva'),
|
||||
@@ -918,7 +939,6 @@ function addressfield_get_administrative_areas($country_code) {
|
||||
'21' => t('Zakarpats\'ka oblast'),
|
||||
'23' => t('Zaporiz\'ka oblast'),
|
||||
'26' => t('Ivano-Frankivs\'ka oblast'),
|
||||
'30' => t('Kyiv city'),
|
||||
'30' => t('Kiev Oblast'),
|
||||
'35' => t('Kirovohrads\'ka oblast'),
|
||||
'09' => t('Luhans\'ka oblast'),
|
||||
@@ -1003,35 +1023,32 @@ function addressfield_get_administrative_areas($country_code) {
|
||||
'VI' => t('Virgin Islands'),
|
||||
);
|
||||
$administrative_areas['VE'] = array(
|
||||
'Z' => t('Amazonas'),
|
||||
'B' => t('Anzoátegui'),
|
||||
'C' => t('Apure'),
|
||||
'D' => t('Aragua'),
|
||||
'E' => t('Barinas'),
|
||||
'F' => t('Bolívar'),
|
||||
'G' => t('Carabobo'),
|
||||
'H' => t('Cojedes'),
|
||||
'Y' => t('Delta Amacuro'),
|
||||
'W' => t('Dependencias Federales'),
|
||||
'A' => t('Distrito Federal'),
|
||||
'I' => t('Falcón'),
|
||||
'J' => t('Guárico'),
|
||||
'K' => t('Lara'),
|
||||
'L' => t('Mérida'),
|
||||
'M' => t('Miranda'),
|
||||
'N' => t('Monagas'),
|
||||
'O' => t('Nueva Esparta'),
|
||||
'P' => t('Portuguesa'),
|
||||
'R' => t('Sucre'),
|
||||
'S' => t('Táchira'),
|
||||
'T' => t('Trujillo'),
|
||||
'X' => t('Vargas'),
|
||||
'U' => t('Yaracuy'),
|
||||
'V' => t('Zulia'),
|
||||
'Z' => 'Amazonas',
|
||||
'B' => 'Anzoátegui',
|
||||
'C' => 'Apure',
|
||||
'D' => 'Aragua',
|
||||
'E' => 'Barinas',
|
||||
'F' => 'Bolívar',
|
||||
'G' => 'Carabobo',
|
||||
'H' => 'Cojedes',
|
||||
'Y' => 'Delta Amacuro',
|
||||
'W' => 'Dependencias Federales',
|
||||
'A' => 'Distrito Federal',
|
||||
'I' => 'Falcón',
|
||||
'J' => 'Guárico',
|
||||
'K' => 'Lara',
|
||||
'L' => 'Mérida',
|
||||
'M' => 'Miranda',
|
||||
'N' => 'Monagas',
|
||||
'O' => 'Nueva Esparta',
|
||||
'P' => 'Portuguesa',
|
||||
'R' => 'Sucre',
|
||||
'S' => 'Táchira',
|
||||
'T' => 'Trujillo',
|
||||
'X' => 'Vargas',
|
||||
'U' => 'Yaracuy',
|
||||
'V' => 'Zulia',
|
||||
);
|
||||
|
||||
// Allow other modules to alter the administrative areas.
|
||||
drupal_alter('addressfield_administrative_areas', $administrative_areas);
|
||||
|
||||
return isset($administrative_areas[$country_code]) ? $administrative_areas[$country_code] : null;
|
||||
return $administrative_areas;
|
||||
}
|
||||
|
@@ -43,7 +43,6 @@ function _addressfield_sample_addresses() {
|
||||
$fields = array();
|
||||
if ($handle = @fopen("$filepath/addresses.txt",'r')) {
|
||||
if (is_resource($handle)) {
|
||||
$addresses = array();
|
||||
while (($buffer = fgets($handle)) !== false) {
|
||||
list($country, $administrative_area, $sub_administrative_area, $locality, $dependent_locality, $postal_code, $thoroughfare, $premise, $sub_premise) = explode("\t", $buffer);
|
||||
$fields[] = array(
|
||||
|
@@ -6,10 +6,10 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_feeds_node_processor_targets_alter().
|
||||
* Implements hook_feeds_processor_targets_alter().
|
||||
*/
|
||||
function addressfield_feeds_processor_targets_alter(&$targets, $entity_type, $bundle_name) {
|
||||
foreach (field_info_instances($entity_type, $bundle_name) as $name => $instance) {
|
||||
function addressfield_feeds_processor_targets_alter(&$targets, $entity_type, $bundle) {
|
||||
foreach (field_info_instances($entity_type, $bundle) as $name => $instance) {
|
||||
$info = field_info_field($name);
|
||||
if ($info['type'] == 'addressfield') {
|
||||
foreach ($info['columns'] as $sub_field => $schema_info) {
|
||||
@@ -34,7 +34,7 @@ function addressfield_feeds_processor_targets_alter(&$targets, $entity_type, $bu
|
||||
* An entity object, for instance a node object.
|
||||
* @param $target
|
||||
* A string identifying the target on the node.
|
||||
* @param $value
|
||||
* @param $values
|
||||
* The value to populate the target with.
|
||||
*/
|
||||
function addressfield_set_target($source, $entity, $target, $values) {
|
||||
|
@@ -6,12 +6,13 @@ package = Fields
|
||||
dependencies[] = ctools
|
||||
|
||||
files[] = addressfield.migrate.inc
|
||||
files[] = views/addressfield_views_handler_field_administrative_area.inc
|
||||
files[] = views/addressfield_views_handler_field_country.inc
|
||||
files[] = views/addressfield_views_handler_filter_country.inc
|
||||
|
||||
; Information added by Drupal.org packaging script on 2015-04-23
|
||||
version = "7.x-1.1"
|
||||
; Information added by Drupal.org packaging script on 2015-10-07
|
||||
version = "7.x-1.2"
|
||||
core = "7.x"
|
||||
project = "addressfield"
|
||||
datestamp = "1429819382"
|
||||
datestamp = "1444254070"
|
||||
|
||||
|
@@ -152,7 +152,7 @@ class MigrateAddressFieldHandler extends MigrateFieldHandler {
|
||||
|
||||
if ($value) {
|
||||
if (isset($field_info['columns'][$column_key])) {
|
||||
// Store the data in a seperate column.
|
||||
// Store the data in a separate column.
|
||||
$result[$column_key] = $value;
|
||||
}
|
||||
else {
|
||||
|
@@ -534,7 +534,9 @@ function addressfield_field_widget_form(&$form, &$form_state, $field, $instance,
|
||||
// $form_state['values'] is empty because of #limit_validation_errors, so
|
||||
// $form_state['input'] needs to be used instead.
|
||||
$parents = array_merge($element['#field_parents'], array($element['#field_name'], $langcode, $delta));
|
||||
$input_address = drupal_array_get_nested_value($form_state['input'], $parents);
|
||||
if (!empty($form_state['input'])) {
|
||||
$input_address = drupal_array_get_nested_value($form_state['input'], $parents);
|
||||
}
|
||||
if (!empty($input_address)) {
|
||||
$address = $input_address;
|
||||
}
|
||||
@@ -728,8 +730,6 @@ function addressfield_field_formatter_settings_summary($field, $instance, $view_
|
||||
$display = $instance['display'][$view_mode];
|
||||
$settings = $display['settings'];
|
||||
|
||||
$summary = '';
|
||||
|
||||
if ($settings['use_widget_handlers']) {
|
||||
return t('Use widget configuration');
|
||||
}
|
||||
|
@@ -7,9 +7,9 @@ hidden = TRUE
|
||||
dependencies[] = ctools
|
||||
dependencies[] = addressfield
|
||||
|
||||
; Information added by Drupal.org packaging script on 2015-04-23
|
||||
version = "7.x-1.1"
|
||||
; Information added by Drupal.org packaging script on 2015-10-07
|
||||
version = "7.x-1.2"
|
||||
core = "7.x"
|
||||
project = "addressfield"
|
||||
datestamp = "1429819382"
|
||||
datestamp = "1444254070"
|
||||
|
||||
|
@@ -3552,8 +3552,6 @@ function addressfield_form_ch_postal_code_validation($element, &$form_state, &$f
|
||||
if (!empty($element['#value']) && (isset($data[$element['#value']]))) {
|
||||
// Get the base #parents for this address form.
|
||||
$base_parents = array_slice($element['#parents'], 0, -1);
|
||||
$base_array_parents = array_slice($element['#array_parents'], 0, -2);
|
||||
|
||||
$city = $data[$element['#value']];
|
||||
|
||||
// Set the new values in the form.
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
$plugin = array(
|
||||
'title' => t('Make all fields optional (Not recommended)'),
|
||||
'title' => t('Make all fields optional (No validation - unsuitable for postal purposes)'),
|
||||
'format callback' => 'addressfield_format_address_optional',
|
||||
'type' => 'address',
|
||||
'weight' => 100,
|
||||
|
@@ -83,7 +83,7 @@ function addressfield_format_address_generate(&$format, $address, $context = arr
|
||||
'#tag' => 'div',
|
||||
'#attributes' => array(
|
||||
'class' => array('dependent-locality'),
|
||||
'autocomplete' => '"address-level3',
|
||||
'autocomplete' => 'address-level3',
|
||||
),
|
||||
// Most formats place this field in its own row.
|
||||
'#suffix' => $clearfix,
|
||||
@@ -97,7 +97,7 @@ function addressfield_format_address_generate(&$format, $address, $context = arr
|
||||
'#prefix' => ' ',
|
||||
'#attributes' => array(
|
||||
'class' => array('locality'),
|
||||
'autocomplete' => '"address-level2',
|
||||
'autocomplete' => 'address-level2',
|
||||
),
|
||||
);
|
||||
$format['locality_block']['administrative_area'] = array(
|
||||
|
@@ -20,7 +20,7 @@ $plugin = array(
|
||||
function addressfield_format_organisation_generate(&$format, $address) {
|
||||
$format['organisation_block'] = array(
|
||||
'#type' => 'addressfield_container',
|
||||
'#attributes' => array('class' => array('addressfield-container-inline', 'name-block')),
|
||||
'#attributes' => array('class' => array('addressfield-container-inline', 'organisation-block')),
|
||||
'#weight' => -50,
|
||||
// The addressfield is considered empty without a country, hide all fields
|
||||
// until one is selected.
|
||||
|
@@ -26,7 +26,7 @@ function addressfield_field_views_data($field) {
|
||||
// Only expose these components as Views field handlers.
|
||||
$implemented = array(
|
||||
'country' => 'addressfield_views_handler_field_country',
|
||||
'administrative_area' => 'views_handler_field',
|
||||
'administrative_area' => 'addressfield_views_handler_field_administrative_area',
|
||||
'sub_administrative_area' => 'views_handler_field',
|
||||
'dependent_locality' => 'views_handler_field',
|
||||
'locality' => 'views_handler_field',
|
||||
|
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Defines a field handler that can display the administrative area name
|
||||
* instead of the code.
|
||||
*/
|
||||
class addressfield_views_handler_field_administrative_area extends views_handler_field {
|
||||
|
||||
function query() {
|
||||
parent::query();
|
||||
|
||||
$this->country_alias = $this->query->add_field($this->table_alias, $this->definition['field_name'] . '_country');
|
||||
}
|
||||
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['display_name'] = array('default' => TRUE);
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
|
||||
$form['display_name'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display the name of administrative area instead of the code.'),
|
||||
'#default_value' => $this->options['display_name'],
|
||||
);
|
||||
}
|
||||
|
||||
function get_value($values, $field = NULL) {
|
||||
$value = parent::get_value($values, $field);
|
||||
|
||||
// If we have a value for the field, look for the administrative area name in the
|
||||
// Address Field options list array if specified.
|
||||
if (!empty($value) && !empty($this->options['display_name'])) {
|
||||
module_load_include('inc', 'addressfield', 'addressfield.administrative_areas');
|
||||
$country = $values->{$this->country_alias};
|
||||
$areas = addressfield_get_administrative_areas($country);
|
||||
|
||||
if (!empty($areas[$value])) {
|
||||
$value = $areas[$value];
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
4
sites/all/modules/contrib/fields/date/.gitignore
vendored
Normal file
4
sites/all/modules/contrib/fields/date/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
*.patch
|
||||
*.diff
|
||||
.idea/
|
||||
.idea/*
|
@@ -15,8 +15,14 @@ function date_devel_generate($entity, $field, $instance, $bundle) {
|
||||
$entity_field = array();
|
||||
if (isset($instance['widget']['settings']['year_range'])) {
|
||||
$split = explode(':', $instance['widget']['settings']['year_range']);
|
||||
$back = str_replace('-', '', $split[0]);
|
||||
$forward = str_replace('+', '', $split[1]);
|
||||
// Determine how much to go back and forward depending on whether a relative
|
||||
// number of years (with - or + sign) or an absolute year is given.
|
||||
$back = strpos($split[0], '-') === 0
|
||||
? str_replace('-', '', $split[0])
|
||||
: date_format(date_now(), 'Y') - $split[0];
|
||||
$forward = strpos($split[1], '+') === 0
|
||||
? str_replace('+', '', $split[1])
|
||||
: $split[1] - date_format(date_now(), 'Y');
|
||||
}
|
||||
else {
|
||||
$back = 2;
|
||||
@@ -61,9 +67,11 @@ function date_devel_generate($entity, $field, $instance, $bundle) {
|
||||
case 'date':
|
||||
$format = DATE_FORMAT_ISO;
|
||||
break;
|
||||
|
||||
case 'datestamp':
|
||||
$format = DATE_FORMAT_UNIX;
|
||||
break;
|
||||
|
||||
case 'datetime':
|
||||
$format = DATE_FORMAT_DATETIME;
|
||||
break;
|
||||
|
@@ -19,6 +19,7 @@ function date_field_formatter_info() {
|
||||
'multiple_from' => '',
|
||||
'multiple_to' => '',
|
||||
'fromto' => 'both',
|
||||
'show_remaining_days' => FALSE,
|
||||
),
|
||||
),
|
||||
'format_interval' => array(
|
||||
@@ -48,6 +49,7 @@ function date_field_formatter_settings_form($field, $instance, $view_mode, $form
|
||||
case 'format_interval':
|
||||
$form = date_interval_formatter_settings_form($field, $instance, $view_mode, $form, $form_state);
|
||||
break;
|
||||
|
||||
default:
|
||||
$form = date_default_formatter_settings_form($field, $instance, $view_mode, $form, $form_state);
|
||||
break;
|
||||
@@ -72,6 +74,7 @@ function date_field_formatter_settings_summary($field, $instance, $view_mode) {
|
||||
case 'format_interval':
|
||||
$summary = date_interval_formatter_settings_summary($field, $instance, $view_mode);
|
||||
break;
|
||||
|
||||
default:
|
||||
$summary = date_default_formatter_settings_summary($field, $instance, $view_mode);
|
||||
break;
|
||||
@@ -169,11 +172,16 @@ function date_field_formatter_view($entity_type, $entity, $field, $instance, $la
|
||||
$element[$delta] = array('#markup' => $item['value']);
|
||||
}
|
||||
else {
|
||||
$element[$delta] = array('#markup' => t('!start-date to !end-date', array('!start-date' => $item['value'], '!end-date' => $item['value2'])));
|
||||
$element[$delta] = array(
|
||||
'#markup' => t('!start-date to !end-date', array(
|
||||
'!start-date' => $item['value'],
|
||||
'!end-date' => $item['value2']
|
||||
)));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'format_interval':
|
||||
foreach ($items as $delta => $item) {
|
||||
if (!empty($entity->date_id) && !in_array($delta, $selected_deltas)) {
|
||||
@@ -188,6 +196,7 @@ function date_field_formatter_view($entity_type, $entity, $field, $instance, $la
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
foreach ($items as $delta => $item) {
|
||||
if (!empty($entity->date_id) && !in_array($delta, $selected_deltas)) {
|
||||
@@ -198,6 +207,7 @@ function date_field_formatter_view($entity_type, $entity, $field, $instance, $la
|
||||
$variables['item'] = $item;
|
||||
$variables['dates'] = date_formatter_process($formatter, $entity_type, $entity, $field, $instance, $langcode, $item, $display);
|
||||
$variables['attributes'] = !empty($rdf_mapping) ? rdf_rdfa_attributes($rdf_mapping, $item['value']) : array();
|
||||
$variables['show_remaining_days'] = $display['settings']['show_remaining_days'];
|
||||
$output = theme('date_display_combination', $variables);
|
||||
if (!empty($output)) {
|
||||
$element[$delta] = array('#markup' => $output);
|
||||
@@ -231,10 +241,11 @@ function date_field_is_empty($item, $field) {
|
||||
* Implements hook_field_info().
|
||||
*/
|
||||
function date_field_info() {
|
||||
$granularity = array('year', 'month', 'day', 'hour', 'minute');
|
||||
$settings = array(
|
||||
'settings' => array(
|
||||
'todate' => '',
|
||||
'granularity' => drupal_map_assoc(array('year', 'month', 'day', 'hour', 'minute')),
|
||||
'granularity' => drupal_map_assoc($granularity),
|
||||
'tz_handling' => 'site',
|
||||
'timezone_db' => 'UTC',
|
||||
),
|
||||
@@ -250,26 +261,26 @@ function date_field_info() {
|
||||
);
|
||||
return array(
|
||||
'datetime' => array(
|
||||
'label' => 'Date',
|
||||
'label' => t('Date'),
|
||||
'description' => t('Store a date in the database as a datetime field, recommended for complete dates and times that may need timezone conversion.'),
|
||||
'default_widget' => 'date_select',
|
||||
'default_formatter' => 'date_default',
|
||||
'default_token_formatter' => 'date_plain',
|
||||
) + $settings,
|
||||
) + $settings,
|
||||
'date' => array(
|
||||
'label' => 'Date (ISO format)',
|
||||
'label' => t('Date (ISO format)'),
|
||||
'description' => t('Store a date in the database as an ISO date, recommended for historical or partial dates.'),
|
||||
'default_widget' => 'date_select',
|
||||
'default_formatter' => 'date_default',
|
||||
'default_token_formatter' => 'date_plain',
|
||||
) + $settings,
|
||||
) + $settings,
|
||||
'datestamp' => array(
|
||||
'label' => 'Date (Unix timestamp)',
|
||||
'label' => t('Date (Unix timestamp)'),
|
||||
'description' => t('Store a date in the database as a timestamp, deprecated format to support legacy data.'),
|
||||
'default_widget' => 'date_select',
|
||||
'default_formatter' => 'date_default',
|
||||
'default_token_formatter' => 'date_plain',
|
||||
) + $settings,
|
||||
) + $settings,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -294,18 +305,18 @@ function date_field_widget_info() {
|
||||
|
||||
$info = array(
|
||||
'date_select' => array(
|
||||
'label' => t('Select list'),
|
||||
'label' => t('Select list'),
|
||||
'field types' => array('date', 'datestamp', 'datetime'),
|
||||
) + $settings,
|
||||
'date_text' => array(
|
||||
'label' => t('Text field'),
|
||||
'label' => t('Text field'),
|
||||
'field types' => array('date', 'datestamp', 'datetime'),
|
||||
) + $settings,
|
||||
) + $settings,
|
||||
);
|
||||
|
||||
if (module_exists('date_popup')) {
|
||||
$info['date_popup'] = array(
|
||||
'label' => t('Pop-up calendar'),
|
||||
'label' => t('Pop-up calendar'),
|
||||
'field types' => array('date', 'datestamp', 'datetime'),
|
||||
) + $settings;
|
||||
}
|
||||
|
@@ -11,10 +11,12 @@ files[] = tests/date_field.test
|
||||
files[] = tests/date_migrate.test
|
||||
files[] = tests/date_validation.test
|
||||
files[] = tests/date_timezone.test
|
||||
files[] = tests/date_views_pager.test
|
||||
files[] = tests/date_views_popup.test
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-07-29
|
||||
version = "7.x-2.8"
|
||||
; Information added by Drupal.org packaging script on 2015-09-08
|
||||
version = "7.x-2.9"
|
||||
core = "7.x"
|
||||
project = "date"
|
||||
datestamp = "1406653438"
|
||||
datestamp = "1441727353"
|
||||
|
||||
|
@@ -19,6 +19,7 @@ function date_field_schema($field) {
|
||||
'views' => TRUE,
|
||||
);
|
||||
break;
|
||||
|
||||
case 'datetime':
|
||||
$db_columns['value'] = array(
|
||||
'type' => 'datetime',
|
||||
@@ -31,6 +32,7 @@ function date_field_schema($field) {
|
||||
'views' => TRUE,
|
||||
);
|
||||
break;
|
||||
|
||||
default:
|
||||
$db_columns['value'] = array(
|
||||
'type' => 'varchar',
|
||||
@@ -66,7 +68,12 @@ function date_field_schema($field) {
|
||||
'views' => FALSE,
|
||||
);
|
||||
if (!empty($field['settings']['todate'])) {
|
||||
$db_columns['offset2'] = array('type' => 'int', 'not null' => FALSE, 'sortable' => TRUE, 'views' => FALSE);
|
||||
$db_columns['offset2'] = array(
|
||||
'type' => 'int',
|
||||
'not null' => FALSE,
|
||||
'sortable' => TRUE,
|
||||
'views' => FALSE
|
||||
);
|
||||
}
|
||||
}
|
||||
if (isset($field['settings']['repeat']) && $field['settings']['repeat'] == 1) {
|
||||
@@ -88,8 +95,9 @@ function date_update_last_removed() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get rid of the individual formatters for each format type,
|
||||
* these are now settings in the default formatter.
|
||||
* Get rid of the individual formatters for each format type.
|
||||
*
|
||||
* These are now settings in the default formatter.
|
||||
*/
|
||||
function date_update_7000() {
|
||||
$instances = field_info_instances();
|
||||
@@ -115,8 +123,9 @@ function date_update_7000() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get rid of the separate widgets for repeating dates. The code now handles
|
||||
* repeating dates correctly using the regular widgets.
|
||||
* Get rid of the separate widgets for repeating dates.
|
||||
*
|
||||
* The code now handles repeating dates correctly using the regular widgets.
|
||||
*/
|
||||
function date_update_7001() {
|
||||
$query = db_select('field_config_instance', 'fci', array('fetch' => PDO::FETCH_ASSOC));
|
||||
@@ -127,7 +136,11 @@ function date_update_7001() {
|
||||
|
||||
foreach ($results as $record) {
|
||||
$instance = unserialize($record['data']);
|
||||
if (in_array($instance['widget']['type'], array('date_popup_repeat', 'date_text_repeat', 'date_select_repeat'))) {
|
||||
if (in_array($instance['widget']['type'], array(
|
||||
'date_popup_repeat',
|
||||
'date_text_repeat',
|
||||
'date_select_repeat'
|
||||
))) {
|
||||
$instance['widget']['type'] = str_replace('_repeat', '', $instance['widget']['type']);
|
||||
db_update('field_config_instance')
|
||||
->fields(array(
|
||||
@@ -191,4 +204,3 @@ function date_update_7004() {
|
||||
field_cache_clear();
|
||||
drupal_set_message(t('Date text widgets have been updated to use an increment of 1.'));
|
||||
}
|
||||
|
||||
|
@@ -27,7 +27,7 @@ Drupal.date.EndDateHandler = function (widget) {
|
||||
this.$widget = $(widget);
|
||||
this.$start = this.$widget.find('.form-type-date-select[class$=value]');
|
||||
this.$end = this.$widget.find('.form-type-date-select[class$=value2]');
|
||||
if (this.$end.length == 0) {
|
||||
if (this.$end.length === 0) {
|
||||
return;
|
||||
}
|
||||
this.initializeSelects();
|
||||
@@ -68,7 +68,7 @@ Drupal.date.EndDateHandler.prototype.endDateIsBlank = function () {
|
||||
var id;
|
||||
for (id in this.selects) {
|
||||
if (this.selects.hasOwnProperty(id)) {
|
||||
if (this.selects[id].end.val() != '') {
|
||||
if (this.selects[id].end.val() !== '') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -40,7 +40,7 @@ class DateMigrateFieldHandler extends MigrateFieldHandler {
|
||||
* @return array
|
||||
* An array of the defined variables in this scope.
|
||||
*/
|
||||
static function arguments($timezone = 'UTC', $timezone_db = 'UTC', $rrule = NULL, $language = NULL) {
|
||||
public static function arguments($timezone = 'UTC', $timezone_db = 'UTC', $rrule = NULL, $language = NULL) {
|
||||
return get_defined_vars();
|
||||
}
|
||||
|
||||
@@ -129,6 +129,7 @@ class DateMigrateFieldHandler extends MigrateFieldHandler {
|
||||
// timestamp for 'now'.
|
||||
if (empty($from)) {
|
||||
$return[$language][$delta]['value'] = NULL;
|
||||
$return[$language][$delta]['timezone'] = NULL;
|
||||
if (!empty($field_info['settings']['todate'])) {
|
||||
$return[$language][$delta]['value2'] = NULL;
|
||||
}
|
||||
@@ -151,6 +152,7 @@ class DateMigrateFieldHandler extends MigrateFieldHandler {
|
||||
case 'datestamp':
|
||||
// Already done.
|
||||
break;
|
||||
|
||||
case 'datetime':
|
||||
// YYYY-MM-DD HH:MM:SS.
|
||||
$from = format_date($from, 'custom', 'Y-m-d H:i:s', $timezone);
|
||||
@@ -158,6 +160,7 @@ class DateMigrateFieldHandler extends MigrateFieldHandler {
|
||||
$to = format_date($to, 'custom', 'Y-m-d H:i:s', $timezone);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'date':
|
||||
// ISO date: YYYY-MM-DDTHH:MM:SS.
|
||||
$from = format_date($from, 'custom', 'Y-m-d\TH:i:s', $timezone);
|
||||
@@ -165,6 +168,7 @@ class DateMigrateFieldHandler extends MigrateFieldHandler {
|
||||
$to = format_date($to, 'custom', 'Y-m-d\TH:i:s', $timezone);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -173,12 +177,17 @@ class DateMigrateFieldHandler extends MigrateFieldHandler {
|
||||
// created.
|
||||
if (function_exists('date_repeat_build_dates') && !empty($field_info['settings']['repeat']) && $rrule) {
|
||||
include_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'date_api') . '/date_api_ical.inc';
|
||||
$item = array('value' => $from, 'value2' => $to, 'timezone' => $timezone);
|
||||
$item = array(
|
||||
'value' => $from,
|
||||
'value2' => $to,
|
||||
'timezone' => $timezone,
|
||||
);
|
||||
// Can be de-uglified when http://drupal.org/node/1159404 is committed.
|
||||
$return[$language] = date_repeat_build_dates(NULL, date_ical_parse_rrule($field_info, $rrule), $field_info, $item);
|
||||
}
|
||||
else {
|
||||
$return[$language][$delta]['value'] = $from;
|
||||
$return[$language][$delta]['timezone'] = $timezone;
|
||||
if (!empty($to)) {
|
||||
$return[$language][$delta]['value2'] = $to;
|
||||
}
|
||||
@@ -190,6 +199,9 @@ class DateMigrateFieldHandler extends MigrateFieldHandler {
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields($migration = NULL) {
|
||||
return array(
|
||||
'timezone' => t('Timezone'),
|
||||
|
@@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Defines date/time field types.
|
||||
*/
|
||||
|
||||
module_load_include('theme', 'date', 'date');
|
||||
module_load_include('inc', 'date', 'date.field');
|
||||
module_load_include('inc', 'date', 'date_elements');
|
||||
@@ -15,6 +17,7 @@ function date_get_entity_bundle($entity_type, $entity) {
|
||||
case 'field_collection_item':
|
||||
$bundle = $entity->field_name;
|
||||
break;
|
||||
|
||||
default:
|
||||
$bundle = field_extract_bundle($entity_type, $entity);
|
||||
break;
|
||||
@@ -40,13 +43,20 @@ function date_default_format($type) {
|
||||
* Wrapper function around each of the widget types for creating a date object.
|
||||
*/
|
||||
function date_input_date($field, $instance, $element, $input) {
|
||||
// Trim extra spacing off user input of text fields.
|
||||
if (isset($input['date'])) {
|
||||
$input['date'] = trim($input['date']);
|
||||
}
|
||||
|
||||
switch ($instance['widget']['type']) {
|
||||
case 'date_text':
|
||||
$function = 'date_text_input_date';
|
||||
break;
|
||||
|
||||
case 'date_popup':
|
||||
$function = 'date_popup_input_date';
|
||||
break;
|
||||
|
||||
default:
|
||||
$function = 'date_select_input_date';
|
||||
}
|
||||
@@ -66,6 +76,7 @@ function date_theme() {
|
||||
);
|
||||
$themes = array(
|
||||
'date_combo' => $base + array('render element' => 'element'),
|
||||
'date_form_element' => $base + array('render element' => 'element'),
|
||||
'date_text_parts' => $base + array('render element' => 'element'),
|
||||
'date' => $base + array('render element' => 'element'),
|
||||
'date_display_single' => $base + array(
|
||||
@@ -97,7 +108,13 @@ function date_theme() {
|
||||
'add_rdf' => NULL,
|
||||
'microdata' => NULL,
|
||||
'add_microdata' => NULL,
|
||||
)),
|
||||
),
|
||||
),
|
||||
'date_display_remaining' => $base + array(
|
||||
'variables' => array(
|
||||
'remaining_days' => NULL,
|
||||
),
|
||||
),
|
||||
'date_display_combination' => $base + array(
|
||||
'variables' => array(
|
||||
'entity_type' => NULL,
|
||||
@@ -130,7 +147,7 @@ function date_theme() {
|
||||
'attributes' => array(),
|
||||
'rdf_mapping' => NULL,
|
||||
'add_rdf' => NULL,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -209,8 +226,10 @@ function date_formatter_process($formatter, $entity_type, $entity, $field, $inst
|
||||
$settings = $display['settings'];
|
||||
$field_name = $field['field_name'];
|
||||
$format = date_formatter_format($formatter, $settings, $granularity, $langcode);
|
||||
$timezone = isset($item['timezone']) ? $item['timezone'] : '';
|
||||
$timezone = date_get_timezone($field['settings']['tz_handling'], $timezone);
|
||||
if (!isset($field['settings']['tz_handling']) || $field['settings']['tz_handling'] !== 'utc') {
|
||||
$timezone = isset($item['timezone']) ? $item['timezone'] : '';
|
||||
$timezone = date_get_timezone($field['settings']['tz_handling'], $timezone);
|
||||
}
|
||||
$timezone_db = date_get_timezone_db($field['settings']['tz_handling']);
|
||||
$db_format = date_type_format($field['type']);
|
||||
$process = date_process_values($field);
|
||||
@@ -246,10 +265,10 @@ function date_formatter_process($formatter, $entity_type, $entity, $field, $inst
|
||||
$dates[$processed]['formatted_iso'] = date_format_date($date, 'custom', 'c');
|
||||
if (is_object($date)) {
|
||||
if ($format == 'format_interval') {
|
||||
$dates[$processed]['interval'] = date_format_interval($date);
|
||||
$dates[$processed]['interval'] = date_format_interval($date);
|
||||
}
|
||||
elseif ($format == 'format_calendar_day') {
|
||||
$dates[$processed]['calendar_day'] = date_format_calendar_day($date);
|
||||
$dates[$processed]['calendar_day'] = date_format_calendar_day($date);
|
||||
}
|
||||
elseif ($format == 'U' || $format == 'r' || $format == 'c') {
|
||||
$dates[$processed]['formatted'] = date_format_date($date, 'custom', $format);
|
||||
@@ -258,10 +277,11 @@ function date_formatter_process($formatter, $entity_type, $entity, $field, $inst
|
||||
$dates[$processed]['formatted_timezone'] = '';
|
||||
}
|
||||
elseif (!empty($format)) {
|
||||
$dates[$processed]['formatted'] = date_format_date($date, 'custom', $format);
|
||||
$dates[$processed]['formatted_date'] = date_format_date($date, 'custom', date_limit_format($format, array('year', 'month', 'day')));
|
||||
$dates[$processed]['formatted_time'] = date_format_date($date, 'custom', date_limit_format($format, array('hour', 'minute', 'second')));
|
||||
$dates[$processed]['formatted_timezone'] = date_format_date($date, 'custom', date_limit_format($format, array('timezone')));
|
||||
$formats = _get_custom_date_format($date, $format);
|
||||
$dates[$processed]['formatted'] = $formats['formatted'];
|
||||
$dates[$processed]['formatted_date'] = $formats['date'];
|
||||
$dates[$processed]['formatted_time'] = $formats['time'];
|
||||
$dates[$processed]['formatted_timezone'] = $formats['zone'];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -288,6 +308,30 @@ function date_formatter_process($formatter, $entity_type, $entity, $field, $inst
|
||||
return $dates;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a custom date format.
|
||||
*/
|
||||
function _get_custom_date_format($date, $format) {
|
||||
$custom = array();
|
||||
$custom['granularities'] = array(
|
||||
'date' => array('year', 'month', 'day'),
|
||||
'time' => array('hour', 'minute', 'second'),
|
||||
'zone' => array('timezone'),
|
||||
);
|
||||
$custom['limits'] = array(
|
||||
'date' => date_limit_format($format, $custom['granularities']['date']),
|
||||
'time' => date_limit_format($format, $custom['granularities']['time']),
|
||||
'zone' => date_limit_format($format, $custom['granularities']['zone']),
|
||||
);
|
||||
|
||||
return array(
|
||||
'formatted' => date_format_date($date, 'custom', $format),
|
||||
'date' => date_format_date($date, 'custom', $custom['limits']['date']),
|
||||
'time' => date_format_date($date, 'custom', $custom['limits']['time']),
|
||||
'zone' => date_format_date($date, 'custom', $custom['limits']['zone']),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the granularity for a field.
|
||||
*
|
||||
@@ -301,14 +345,14 @@ function date_formatter_process($formatter, $entity_type, $entity, $field, $inst
|
||||
*/
|
||||
function date_granularity($field) {
|
||||
if (!is_array($field) || !is_array($field['settings']['granularity'])) {
|
||||
$field['settings']['granularity'] = drupal_map_assoc(array('year', 'month', 'day'));
|
||||
$granularity = drupal_map_assoc(array('year', 'month', 'day'));
|
||||
$field['settings']['granularity'] = $granularity;
|
||||
}
|
||||
return array_values(array_filter($field['settings']['granularity']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to create an array of the date values in a
|
||||
* field that need to be processed.
|
||||
* Helper function to create an array of the date values in a field that need to be processed.
|
||||
*/
|
||||
function date_process_values($field) {
|
||||
return $field['settings']['todate'] ? array('value', 'value2') : array('value');
|
||||
@@ -394,10 +438,10 @@ function date_formatter_format($formatter, $settings, $granularity = array(), $l
|
||||
switch ($formatter) {
|
||||
case 'format_interval':
|
||||
return 'format_interval';
|
||||
break;
|
||||
|
||||
case 'date_plain':
|
||||
return 'date_plain';
|
||||
break;
|
||||
|
||||
default:
|
||||
$format = date_format_type_format($format_type, $langcode);
|
||||
break;
|
||||
@@ -410,6 +454,7 @@ function date_formatter_format($formatter, $settings, $granularity = array(), $l
|
||||
|
||||
/**
|
||||
* Helper function to get the right format for a format type.
|
||||
*
|
||||
* Checks for locale-based format first.
|
||||
*/
|
||||
function date_format_type_format($format_type, $langcode = NULL) {
|
||||
@@ -432,27 +477,30 @@ function date_format_type_format($format_type, $langcode = NULL) {
|
||||
case 'short':
|
||||
$default = 'm/d/Y - H:i';
|
||||
break;
|
||||
|
||||
case 'long':
|
||||
$default = 'l, F j, Y - H:i';
|
||||
break;
|
||||
|
||||
// If it's not one of the core date types and isn't stored in the
|
||||
// database, we'll fall back on using the same default format as the
|
||||
// 'medium' type.
|
||||
case 'medium':
|
||||
default:
|
||||
// @todo: If a non-core module provides a date type and does not
|
||||
// variable_set() a default for it, the default assumed here may
|
||||
// not be correct (since the default format used by 'medium' may
|
||||
// not even be one of the allowed formats for the date type in
|
||||
// question). To fix this properly, we should really call
|
||||
// system_get_date_formats($format_type) and take the first
|
||||
// format from that list as the default. However, this function
|
||||
// is called often (on many different page requests), so calling
|
||||
// system_get_date_formats() from here would be a performance hit
|
||||
// since that function writes several records to the database
|
||||
// during each page request that calls it.
|
||||
// variable_set() a default for it, the default assumed here may
|
||||
// not be correct (since the default format used by 'medium' may
|
||||
// not even be one of the allowed formats for the date type in
|
||||
// question). To fix this properly, we should really call
|
||||
// system_get_date_formats($format_type) and take the first
|
||||
// format from that list as the default. However, this function
|
||||
// is called often (on many different page requests), so calling
|
||||
// system_get_date_formats() from here would be a performance hit
|
||||
// since that function writes several records to the database
|
||||
// during each page request that calls it.
|
||||
$default = 'D, m/d/Y - H:i';
|
||||
break;
|
||||
|
||||
}
|
||||
$format = variable_get('date_format_' . $format_type, $default);
|
||||
}
|
||||
@@ -506,7 +554,7 @@ function date_prepare_entity($formatter, $entity_type, $entity, $field, $instanc
|
||||
elseif ((!empty($max_count) && is_numeric($max_count) && $count >= $max_count) ||
|
||||
(!empty($value['value']) && $value['value'] < $start) ||
|
||||
(!empty($value['value2']) && $value['value2'] > $end)) {
|
||||
unset($entity->{$field_name}[$langcode][$delta]);
|
||||
unset($entity->{$field_name}[$langcode][$delta]);
|
||||
}
|
||||
else {
|
||||
$count++;
|
||||
@@ -647,7 +695,7 @@ function date_entity_metadata_field_setter(&$entity, $name, $value, $langcode, $
|
||||
}
|
||||
|
||||
/**
|
||||
* Auto creation callback for fields which contain two date values in one
|
||||
* Auto creation callback for fields which contain two date values in one.
|
||||
*/
|
||||
function date_entity_metadata_struct_create($name, $property_info) {
|
||||
return array(
|
||||
@@ -658,10 +706,10 @@ function date_entity_metadata_struct_create($name, $property_info) {
|
||||
|
||||
/**
|
||||
* Callback for setting an individual field value if a to-date may be there too.
|
||||
*
|
||||
* Based on entity_property_verbatim_set().
|
||||
*
|
||||
* The passed in unix timestamp (UTC) is converted to the right value and
|
||||
* format dependent on the field.
|
||||
* The passed in unix timestamp (UTC) is converted to the right value and format dependent on the field.
|
||||
*
|
||||
* $name is either 'value' or 'value2'.
|
||||
*/
|
||||
@@ -683,9 +731,9 @@ function date_entity_metadata_struct_setter(&$item, $name, $value, $langcode, $t
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate functionality of what is now date_all_day_field() in
|
||||
* the Date All Day module. Copy left here to avoid breaking other
|
||||
* modules that use this function.
|
||||
* Duplicate functionality of what is now date_all_day_field() in the Date All Day module.
|
||||
*
|
||||
* Copy left here to avoid breaking other modules that use this function.
|
||||
*
|
||||
* DEPRECATED!, will be removed at some time in the future.
|
||||
*/
|
||||
@@ -759,7 +807,7 @@ function date_field_widget_properties_alter(&$widget, $context) {
|
||||
$entity = $context['entity'];
|
||||
$info = entity_get_info($entity_type);
|
||||
$id = $info['entity keys']['id'];
|
||||
$widget['is_new']= FALSE;
|
||||
$widget['is_new'] = FALSE;
|
||||
if (empty($entity->$id)) {
|
||||
$widget['is_new'] = TRUE;
|
||||
}
|
||||
|
@@ -77,6 +77,7 @@ function theme_date_display_combination($variables) {
|
||||
$microdata = $variables['microdata'];
|
||||
$add_microdata = $variables['add_microdata'];
|
||||
$precision = date_granularity_precision($field['settings']['granularity']);
|
||||
$show_remaining_days = $variables['show_remaining_days'];
|
||||
|
||||
$output = '';
|
||||
|
||||
@@ -121,10 +122,12 @@ function theme_date_display_combination($variables) {
|
||||
$date1 = $dates['value']['formatted'];
|
||||
$date2 = $date1;
|
||||
break;
|
||||
|
||||
case 'value2':
|
||||
$date2 = $dates['value2']['formatted'];
|
||||
$date1 = $date2;
|
||||
break;
|
||||
|
||||
default:
|
||||
$date1 = $dates['value']['formatted'];
|
||||
$date2 = $dates['value2']['formatted'];
|
||||
@@ -151,6 +154,20 @@ function theme_date_display_combination($variables) {
|
||||
$has_time_string = FALSE;
|
||||
}
|
||||
|
||||
// Check remaining days.
|
||||
$show_remaining_days = '';
|
||||
if (!empty($variables['show_remaining_days'])) {
|
||||
$remaining_days = floor((strtotime($variables['dates']['value']['formatted_iso'])
|
||||
- strtotime('now')) / (24 * 3600));
|
||||
|
||||
// Show remaining days only for future events.
|
||||
if ($remaining_days >= 0) {
|
||||
$show_remaining_days = theme('date_display_remaining', array(
|
||||
'remaining_days' => $remaining_days,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
// No date values, display nothing.
|
||||
if (empty($date1) && empty($date2)) {
|
||||
$output .= '';
|
||||
@@ -167,6 +184,7 @@ function theme_date_display_combination($variables) {
|
||||
'microdata' => $microdata,
|
||||
'add_microdata' => $add_microdata,
|
||||
'dates' => $dates,
|
||||
'show_remaining_days' => $show_remaining_days,
|
||||
));
|
||||
}
|
||||
// Same day, different times, don't repeat the date but show both Start and
|
||||
@@ -186,6 +204,7 @@ function theme_date_display_combination($variables) {
|
||||
'microdata' => $microdata,
|
||||
'add_microdata' => $add_microdata,
|
||||
'dates' => $dates,
|
||||
'show_remaining_days' => $show_remaining_days,
|
||||
));
|
||||
$replaced = str_replace($time1, $time, $date1);
|
||||
$output .= theme('date_display_single', array(
|
||||
@@ -209,6 +228,7 @@ function theme_date_display_combination($variables) {
|
||||
'microdata' => $microdata,
|
||||
'add_microdata' => $add_microdata,
|
||||
'dates' => $dates,
|
||||
'show_remaining_days' => $show_remaining_days,
|
||||
));
|
||||
}
|
||||
|
||||
@@ -236,12 +256,12 @@ function template_preprocess_date_display_single(&$variables) {
|
||||
// Because the Entity API integration for Date has a variable data
|
||||
// structure depending on whether there is an end value, the attributes
|
||||
// could be attached to the field or to the value property.
|
||||
if(!empty($variables['microdata']['#attributes']['itemprop'])) {
|
||||
if (!empty($variables['microdata']['#attributes']['itemprop'])) {
|
||||
$variables['microdata']['value']['#attributes'] = $variables['microdata']['#attributes'];
|
||||
}
|
||||
|
||||
// Add the machine readable time using the content attribute.
|
||||
if(!empty($variables['microdata']['value']['#attributes'])) {
|
||||
if (!empty($variables['microdata']['value']['#attributes'])) {
|
||||
$variables['microdata']['value']['#attributes']['content'] = $variables['dates']['value']['formatted_iso'];
|
||||
}
|
||||
else {
|
||||
@@ -257,6 +277,7 @@ function theme_date_display_single($variables) {
|
||||
$date = $variables['date'];
|
||||
$timezone = $variables['timezone'];
|
||||
$attributes = $variables['attributes'];
|
||||
$show_remaining_days = isset($variables['show_remaining_days']) ? $variables['show_remaining_days'] : '';
|
||||
|
||||
// Wrap the result with the attributes.
|
||||
$output = '<span class="date-display-single"' . drupal_attributes($attributes) . '>' . $date . $timezone . '</span>';
|
||||
@@ -265,7 +286,8 @@ function theme_date_display_single($variables) {
|
||||
$output .= '<meta' . drupal_attributes($variables['microdata']['value']['#attributes']) . '/>';
|
||||
}
|
||||
|
||||
return $output;
|
||||
// Add remaining message and return.
|
||||
return $output . $show_remaining_days;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -314,6 +336,7 @@ function theme_date_display_range($variables) {
|
||||
$timezone = $variables['timezone'];
|
||||
$attributes_start = $variables['attributes_start'];
|
||||
$attributes_end = $variables['attributes_end'];
|
||||
$show_remaining_days = $variables['show_remaining_days'];
|
||||
|
||||
$start_date = '<span class="date-display-start"' . drupal_attributes($attributes_start) . '>' . $date1 . '</span>';
|
||||
$end_date = '<span class="date-display-end"' . drupal_attributes($attributes_end) . '>' . $date2 . $timezone . '</span>';
|
||||
@@ -326,10 +349,13 @@ function theme_date_display_range($variables) {
|
||||
}
|
||||
|
||||
// Wrap the result with the attributes.
|
||||
return t('!start-date to !end-date', array(
|
||||
$output = '<div class="date-display-range">' . t('!start-date to !end-date', array(
|
||||
'!start-date' => $start_date,
|
||||
'!end-date' => $end_date,
|
||||
));
|
||||
)) . '</div>';
|
||||
|
||||
// Add remaining message and return.
|
||||
return $output . $show_remaining_days;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -375,7 +401,7 @@ function theme_date_combo($variables) {
|
||||
'#title' => field_filter_xss(t($element['#title'])) . ' ' . ($element['#delta'] > 0 ? intval($element['#delta'] + 1) : ''),
|
||||
'#value' => '',
|
||||
'#description' => !empty($element['#fieldset_description']) ? $element['#fieldset_description'] : '',
|
||||
'#attributes' => array(),
|
||||
'#attributes' => array('class' => array('date-combo')),
|
||||
'#children' => $element['#children'],
|
||||
);
|
||||
// Add marker to required date fields.
|
||||
@@ -396,7 +422,11 @@ function theme_date_text_parts($variables) {
|
||||
$rows[] = drupal_render($element[$key]);
|
||||
}
|
||||
else {
|
||||
$rows[] = array($part, drupal_render($element[$key][0]), drupal_render($element[$key][1]));
|
||||
$rows[] = array(
|
||||
$part,
|
||||
drupal_render($element[$key][0]),
|
||||
drupal_render($element[$key][1]),
|
||||
);
|
||||
}
|
||||
}
|
||||
if ($element['year']['#type'] == 'hidden') {
|
||||
@@ -408,4 +438,49 @@ function theme_date_text_parts($variables) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a date combo as a form element.
|
||||
*/
|
||||
function theme_date_form_element($variables) {
|
||||
$element = &$variables['element'];
|
||||
|
||||
// Detect whether element is multiline.
|
||||
$count = preg_match_all('`<(?:div|span)\b[^>]* class="[^"]*\b(?:date-no-float|date-clear)\b`', $element['#children'], $matches, PREG_OFFSET_CAPTURE);
|
||||
$multiline = FALSE;
|
||||
if ($count > 1) {
|
||||
$multiline = TRUE;
|
||||
}
|
||||
elseif ($count) {
|
||||
$before = substr($element['#children'], 0, $matches[0][0][1]);
|
||||
if (preg_match('`<(?:div|span)\b[^>]* class="[^"]*\bdate-float\b`', $before)) {
|
||||
$multiline = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// Detect if there is more than one subfield.
|
||||
$count = count(explode('<label', $element['#children'])) - 1;
|
||||
if ($count == 1) {
|
||||
$element['#title_display'] = 'none';
|
||||
}
|
||||
|
||||
// Wrap children with a div and add an extra class if element is multiline.
|
||||
$element['#children'] = '<div class="date-form-element-content'. ($multiline ? ' date-form-element-content-multiline' : '') .'">'. $element['#children'] .'</div>';
|
||||
|
||||
return theme('form_element', $variables);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML for remaining message.
|
||||
*/
|
||||
function theme_date_display_remaining($variables) {
|
||||
$remaining_days = $variables['remaining_days'];
|
||||
$output = '';
|
||||
$show_remaining_text = t('The upcoming date less then 1 day.');
|
||||
if ($remaining_days) {
|
||||
$show_remaining_text = format_plural($remaining_days, 'To event remaining 1 day', 'To event remaining @count days');
|
||||
}
|
||||
|
||||
return '<div class="date-display-remaining"><span class="date-display-remaining">' . $show_remaining_text . '</span></div>';
|
||||
}
|
||||
|
||||
/** @} End of addtogroup themeable */
|
||||
|
@@ -74,6 +74,12 @@ function date_default_formatter_settings_form($field, $instance, $view_mode, $fo
|
||||
'#description' => t('Identify specific start and/or end dates in the format YYYY-MM-DDTHH:MM:SS, or leave blank for all available dates.'),
|
||||
);
|
||||
|
||||
$form['show_remaining_days'] = array(
|
||||
'#title' => t('Show remaining days'),
|
||||
'#type' => 'checkbox',
|
||||
'#default_value' => $settings['show_remaining_days'],
|
||||
'#weight' => 0,
|
||||
);
|
||||
return $form;
|
||||
}
|
||||
|
||||
@@ -127,9 +133,11 @@ function date_default_formatter_settings_summary($field, $instance, $view_mode)
|
||||
case 'date_plain':
|
||||
$format = t('Plain');
|
||||
break;
|
||||
|
||||
case 'format_interval':
|
||||
$format = t('Interval');
|
||||
break;
|
||||
|
||||
default:
|
||||
if (!empty($format_types[$settings['format_type']])) {
|
||||
$format = $format_types[$settings['format_type']];
|
||||
@@ -148,7 +156,9 @@ function date_default_formatter_settings_summary($field, $instance, $view_mode)
|
||||
'value' => t('Display Start date only'),
|
||||
'value2' => t('Display End date only'),
|
||||
);
|
||||
$summary[] = $options[$settings['fromto']];
|
||||
if (isset($options[$settings['fromto']])) {
|
||||
$summary[] = $options[$settings['fromto']];
|
||||
}
|
||||
}
|
||||
|
||||
if (array_key_exists('multiple_number', $settings) && !empty($field['cardinality'])) {
|
||||
@@ -159,6 +169,10 @@ function date_default_formatter_settings_summary($field, $instance, $view_mode)
|
||||
));
|
||||
}
|
||||
|
||||
if (array_key_exists('show_remaining_days', $settings)) {
|
||||
$summary[] = t('Show remaining days: @value', array('@value' => ($settings['show_remaining_days'] ? 'yes' : 'no')));
|
||||
}
|
||||
|
||||
return $summary;
|
||||
}
|
||||
|
||||
@@ -191,7 +205,11 @@ function _date_field_instance_settings_form($field, $instance) {
|
||||
'#type' => 'select',
|
||||
'#title' => t('Default date'),
|
||||
'#default_value' => $settings['default_value'],
|
||||
'#options' => array('blank' => t('No default value'), 'now' => t('Now'), 'strtotime' => t('Relative')),
|
||||
'#options' => array(
|
||||
'blank' => t('No default value'),
|
||||
'now' => t('Now'),
|
||||
'strtotime' => t('Relative'),
|
||||
),
|
||||
'#weight' => 1,
|
||||
'#fieldset' => 'default_values',
|
||||
);
|
||||
@@ -204,8 +222,11 @@ function _date_field_instance_settings_form($field, $instance) {
|
||||
'#default_value' => $settings['default_value_code'],
|
||||
'#states' => array(
|
||||
'visible' => array(
|
||||
':input[name="instance[settings][default_value]"]' => array('value' => 'strtotime')),
|
||||
':input[name="instance[settings][default_value]"]' => array(
|
||||
'value' => 'strtotime',
|
||||
),
|
||||
),
|
||||
),
|
||||
'#weight' => 1.1,
|
||||
'#fieldset' => 'default_values',
|
||||
);
|
||||
@@ -213,7 +234,12 @@ function _date_field_instance_settings_form($field, $instance) {
|
||||
'#type' => !empty($field['settings']['todate']) ? 'select' : 'hidden',
|
||||
'#title' => t('Default end date'),
|
||||
'#default_value' => $settings['default_value2'],
|
||||
'#options' => array('same' => t('Same as Default date'), 'blank' => t('No default value'), 'now' => t('Now'), 'strtotime' => t('Relative')),
|
||||
'#options' => array(
|
||||
'same' => t('Same as Default date'),
|
||||
'blank' => t('No default value'),
|
||||
'now' => t('Now'),
|
||||
'strtotime' => t('Relative'),
|
||||
),
|
||||
'#weight' => 2,
|
||||
'#fieldset' => 'default_values',
|
||||
);
|
||||
@@ -224,8 +250,11 @@ function _date_field_instance_settings_form($field, $instance) {
|
||||
'#default_value' => $settings['default_value_code2'],
|
||||
'#states' => array(
|
||||
'visible' => array(
|
||||
':input[name="instance[settings][default_value2]"]' => array('value' => 'strtotime')),
|
||||
':input[name="instance[settings][default_value2]"]' => array(
|
||||
'value' => 'strtotime',
|
||||
),
|
||||
),
|
||||
),
|
||||
'#weight' => 2.1,
|
||||
'#fieldset' => 'default_values',
|
||||
);
|
||||
@@ -284,6 +313,7 @@ function _date_field_widget_settings_form($field, $instance) {
|
||||
$formats = drupal_map_assoc($formats);
|
||||
}
|
||||
$now = date_example_date();
|
||||
$options['site-wide'] = t('Short date format: @date', array('@date' => date_format_date($now, 'short')));
|
||||
foreach ($formats as $f) {
|
||||
$options[$f] = date_format_date($now, 'custom', $f);
|
||||
}
|
||||
@@ -369,11 +399,18 @@ function _date_field_widget_settings_form($field, $instance) {
|
||||
'#weight' => 9,
|
||||
);
|
||||
if (in_array($widget['type'], array('date_select'))) {
|
||||
$options = array('above' => t('Above'), 'within' => t('Within'), 'none' => t('None'));
|
||||
$options = array(
|
||||
'above' => t('Above'),
|
||||
'within' => t('Within'),
|
||||
'none' => t('None'),
|
||||
);
|
||||
$description = t("The location of date part labels, like 'Year', 'Month', or 'Day' . 'Above' displays the label as titles above each date part. 'Within' inserts the label as the first option in the select list and in blank textfields. 'None' doesn't visually label any of the date parts. Theme functions like 'date_part_label_year' and 'date_part_label_month' control label text.");
|
||||
}
|
||||
else {
|
||||
$options = array('above' => t('Above'), 'none' => t('None'));
|
||||
$options = array(
|
||||
'above' => t('Above'),
|
||||
'none' => t('None'),
|
||||
);
|
||||
$description = t("The location of date part labels, like 'Year', 'Month', or 'Day' . 'Above' displays the label as titles above each date part. 'None' doesn't visually label any of the date parts. Theme functions like 'date_part_label_year' and 'date_part_label_month' control label text.");
|
||||
}
|
||||
$form['advanced']['label_position'] = array(
|
||||
@@ -403,6 +440,13 @@ function _date_field_widget_settings_form($field, $instance) {
|
||||
}
|
||||
}
|
||||
|
||||
$form['advanced']['no_fieldset'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Render as a regular field'),
|
||||
'#default_value' => !empty($settings['no_fieldset']),
|
||||
'#description' => t('Whether to render this field as a regular field instead of a fieldset. The date field elements are wrapped in a fieldset by default, and may not display well without it.'),
|
||||
);
|
||||
|
||||
$context = array(
|
||||
'field' => $field,
|
||||
'instance' => $instance,
|
||||
@@ -470,7 +514,9 @@ function _date_field_settings_form($field, $instance, $has_data) {
|
||||
'#title' => t('Date attributes to collect'),
|
||||
'#default_value' => $granularity,
|
||||
'#options' => $options,
|
||||
'#attributes' => array('class' => array('container-inline')),
|
||||
'#attributes' => array(
|
||||
'class' => array('container-inline'),
|
||||
),
|
||||
'#description' => $description,
|
||||
'year' => $checkbox_year,
|
||||
);
|
||||
@@ -528,7 +574,9 @@ function _date_field_settings_form($field, $instance, $has_data) {
|
||||
'#weight' => 11,
|
||||
'#states' => array(
|
||||
'visible' => array(
|
||||
'input[name="field[settings][cache_enabled]"]' => array('checked' => TRUE),
|
||||
'input[name="field[settings][cache_enabled]"]' => array(
|
||||
'checked' => TRUE,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -600,7 +648,7 @@ function date_timezone_handling_options() {
|
||||
'site' => t("Site's time zone"),
|
||||
'date' => t("Date's time zone"),
|
||||
'user' => t("User's time zone"),
|
||||
'utc' => 'UTC',
|
||||
'utc' => 'UTC',
|
||||
'none' => t('No time zone conversion'),
|
||||
);
|
||||
}
|
||||
|
@@ -5,9 +5,9 @@ dependencies[] = date
|
||||
package = Date/Time
|
||||
core = 7.x
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-07-29
|
||||
version = "7.x-2.8"
|
||||
; Information added by Drupal.org packaging script on 2015-09-08
|
||||
version = "7.x-2.9"
|
||||
core = "7.x"
|
||||
project = "date"
|
||||
datestamp = "1406653438"
|
||||
datestamp = "1441727353"
|
||||
|
||||
|
@@ -31,11 +31,11 @@ function date_all_day_theme() {
|
||||
'format' => NULL,
|
||||
'entity_type' => NULL,
|
||||
'entity' => NULL,
|
||||
'view' => NULL
|
||||
)
|
||||
'view' => NULL,
|
||||
),
|
||||
),
|
||||
'date_all_day_label' => array(
|
||||
'variables' => array()
|
||||
'variables' => array(),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -91,14 +91,29 @@ function date_all_day_date_formatter_dates_alter(&$dates, $context) {
|
||||
/**
|
||||
* Adjust start/end date format to account for 'all day' .
|
||||
*
|
||||
* @param array $field, the field definition for this date field.
|
||||
* @param string $which, which value to return, 'date1' or 'date2' .
|
||||
* @param object $date1, a date/time object for the 'start' date.
|
||||
* @param object $date2, a date/time object for the 'end' date.
|
||||
* @param string $format
|
||||
* @param object $entity, the node this date comes from (may be incomplete, always contains nid).
|
||||
* @param object $view, the view this node comes from, if applicable.
|
||||
* @return formatted date.
|
||||
* @params array $field
|
||||
* The field definition for this date field.
|
||||
*
|
||||
* @params string $which
|
||||
* Which value to return, 'date1' or 'date2'.
|
||||
*
|
||||
* @params object $date1
|
||||
* A date/time object for the 'start' date.
|
||||
*
|
||||
* @params object $date2
|
||||
* A date/time object for the 'end' date.
|
||||
*
|
||||
* @params string $format
|
||||
* A date/time format
|
||||
*
|
||||
* @params object $entity
|
||||
* The node this date comes from (may be incomplete, always contains nid).
|
||||
*
|
||||
* @params object $view
|
||||
* The view this node comes from, if applicable.
|
||||
*
|
||||
* @return string
|
||||
* Formatted date.
|
||||
*/
|
||||
function theme_date_all_day($vars) {
|
||||
$field = $vars['field'];
|
||||
@@ -135,23 +150,32 @@ function theme_date_all_day($vars) {
|
||||
}
|
||||
|
||||
return trim(date_format_date($$which, 'custom', $format) . $suffix);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Theme the way an 'all day' label will look.
|
||||
*/
|
||||
function theme_date_all_day_label() {
|
||||
return '(' . t('All day', array(), array('context' => 'datetime')) .')';
|
||||
return '(' . t('All day', array(), array('context' => 'datetime')) . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a Start/End date combination qualify as 'All day'.
|
||||
*
|
||||
* @param array $field, the field definition for this date field.
|
||||
* @param object $date1, a date/time object for the 'Start' date.
|
||||
* @param object $date2, a date/time object for the 'End' date.
|
||||
* @return TRUE or FALSE.
|
||||
* @param array $field
|
||||
* The field definition for this date field.
|
||||
*
|
||||
* @param array $instance
|
||||
* The field instance for this date field.
|
||||
*
|
||||
* @param object $date1
|
||||
* A date/time object for the 'Start' date.
|
||||
*
|
||||
* @param object $date2
|
||||
* A date/time object for the 'End' date.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE or FALSE.
|
||||
*/
|
||||
function date_all_day_field($field, $instance, $date1, $date2 = NULL) {
|
||||
if (empty($date1) || !is_object($date1)) {
|
||||
@@ -167,7 +191,6 @@ function date_all_day_field($field, $instance, $date1, $date2 = NULL) {
|
||||
$granularity = date_granularity_precision($field['settings']['granularity']);
|
||||
$increment = isset($instance['widget']['settings']['increment']) ? $instance['widget']['settings']['increment'] : 1;
|
||||
return date_is_all_day(date_format($date1, DATE_FORMAT_DATETIME), date_format($date2, DATE_FORMAT_DATETIME), $granularity, $increment);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -222,7 +245,8 @@ function date_all_day_date_combo_process_alter(&$element, &$form_state, $context
|
||||
function date_all_day_date_text_process_alter(&$element, &$form_state, $context) {
|
||||
$all_day_id = !empty($element['#date_all_day_id']) ? $element['#date_all_day_id'] : '';
|
||||
if ($all_day_id != '') {
|
||||
// All Day handling on text dates works only if the user leaves the time out of the input value.
|
||||
// All Day handling on text dates works only
|
||||
// if the user leaves the time out of the input value.
|
||||
// There is no element to hide or show.
|
||||
}
|
||||
}
|
||||
@@ -234,10 +258,11 @@ function date_all_day_date_text_process_alter(&$element, &$form_state, $context)
|
||||
*/
|
||||
function date_all_day_date_select_process_alter(&$element, &$form_state, $context) {
|
||||
|
||||
// Hide or show this element in reaction to the all_day status for this element.
|
||||
// Hide or show this element in reaction
|
||||
// to the all_day status for this element.
|
||||
$all_day_id = !empty($element['#date_all_day_id']) ? $element['#date_all_day_id'] : '';
|
||||
if ($all_day_id != '') {
|
||||
foreach(array('hour', 'minute', 'second', 'ampm') as $field) {
|
||||
foreach (array('hour', 'minute', 'second', 'ampm') as $field) {
|
||||
if (array_key_exists($field, $element)) {
|
||||
$element[$field]['#states'] = array(
|
||||
'visible' => array(
|
||||
@@ -255,7 +280,8 @@ function date_all_day_date_select_process_alter(&$element, &$form_state, $contex
|
||||
*/
|
||||
function date_all_day_date_popup_process_alter(&$element, &$form_state, $context) {
|
||||
|
||||
// Hide or show this element in reaction to the all_day status for this element.
|
||||
// Hide or show this element in reaction to
|
||||
// the all_day status for this element.
|
||||
$all_day_id = !empty($element['#date_all_day_id']) ? $element['#date_all_day_id'] : '';
|
||||
if ($all_day_id != '' && array_key_exists('time', $element)) {
|
||||
$element['time']['#states'] = array(
|
||||
@@ -272,7 +298,8 @@ function date_all_day_date_popup_process_alter(&$element, &$form_state, $context
|
||||
* of the date_select validation gets fired.
|
||||
*/
|
||||
function date_all_day_date_text_pre_validate_alter(&$element, &$form_state, &$input) {
|
||||
// Let Date module massage the format for all day values so they will pass validation.
|
||||
// Let Date module massage the format for all day
|
||||
// values so they will pass validation.
|
||||
// The All day flag, if used, actually exists on the parent element.
|
||||
date_all_day_value($element, $form_state);
|
||||
}
|
||||
@@ -284,7 +311,8 @@ function date_all_day_date_text_pre_validate_alter(&$element, &$form_state, &$in
|
||||
* of the date_select validation gets fired.
|
||||
*/
|
||||
function date_all_day_date_select_pre_validate_alter(&$element, &$form_state, &$input) {
|
||||
// Let Date module massage the format for all day values so they will pass validation.
|
||||
// Let Date module massage the format for all
|
||||
// day values so they will pass validation.
|
||||
// The All day flag, if used, actually exists on the parent element.
|
||||
date_all_day_value($element, $form_state);
|
||||
}
|
||||
@@ -296,13 +324,16 @@ function date_all_day_date_select_pre_validate_alter(&$element, &$form_state, &$
|
||||
* of the date_popup validation gets fired.
|
||||
*/
|
||||
function date_all_day_date_popup_pre_validate_alter(&$element, &$form_state, &$input) {
|
||||
// Let Date module massage the format for all day values so they will pass validation.
|
||||
// Let Date module massage the format for all
|
||||
// day values so they will pass validation.
|
||||
// The All day flag, if used, actually exists on the parent element.
|
||||
date_all_day_value($element, $form_state);
|
||||
}
|
||||
|
||||
/**
|
||||
* A helper function to check if the all day flag is set on the parent of an
|
||||
* A helper function date_all_day_value().
|
||||
*
|
||||
* To check if the all day flag is set on the parent of an
|
||||
* element, and adjust the date_format accordingly so the missing time will
|
||||
* not cause validation errors.
|
||||
*/
|
||||
@@ -332,7 +363,8 @@ function date_all_day_date_combo_pre_validate_alter(&$element, &$form_state, $co
|
||||
$field = $context['field'];
|
||||
|
||||
// If we have an all day flag on this date and the time is empty,
|
||||
// change the format to match the input value so we don't get validation errors.
|
||||
// change the format to match the input value
|
||||
// so we don't get validation errors.
|
||||
$element['#date_is_all_day'] = TRUE;
|
||||
$element['value']['#date_format'] = date_part_format('date', $element['value']['#date_format']);
|
||||
if (!empty($field['settings']['todate'])) {
|
||||
@@ -344,29 +376,29 @@ function date_all_day_date_combo_pre_validate_alter(&$element, &$form_state, $co
|
||||
/**
|
||||
* Implements hook_date_combo_validate_date_start_alter().
|
||||
*
|
||||
* This hook lets us alter the local date objects created by the date_combo validation
|
||||
* before they are converted back to the database timezone and stored.
|
||||
* This hook lets us alter the local date objects
|
||||
* created by the date_combo validation before they are
|
||||
* converted back to the database timezone and stored.
|
||||
*/
|
||||
function date_all_day_date_combo_validate_date_start_alter(&$date, &$form_state, $context) {
|
||||
|
||||
// If this is an 'All day' value, set the time to midnight.
|
||||
if (!empty($context['element']['#date_is_all_day'])) {
|
||||
$date->setTime(0, 0, 0);
|
||||
}
|
||||
// If this is an 'All day' value, set the time to midnight.
|
||||
if (!empty($context['element']['#date_is_all_day'])) {
|
||||
$date->setTime(0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_date_combo_validate_date_end_alter().
|
||||
*
|
||||
* This hook lets us alter the local date objects created by the date_combo validation
|
||||
* before they are converted back to the database timezone and stored.
|
||||
* This hook lets us alter the local date objects
|
||||
* created by the date_combo validation before
|
||||
* they are converted back to the database timezone and stored.
|
||||
*/
|
||||
function date_all_day_date_combo_validate_date_end_alter(&$date, &$form_state, $context) {
|
||||
|
||||
// If this is an 'All day' value, set the time to midnight.
|
||||
if (!empty($context['element']['#date_is_all_day'])) {
|
||||
$date->setTime(0, 0, 0);
|
||||
}
|
||||
// If this is an 'All day' value, set the time to midnight.
|
||||
if (!empty($context['element']['#date_is_all_day'])) {
|
||||
$date->setTime(0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -15,9 +15,11 @@
|
||||
.container-inline-date > .form-item {
|
||||
display: inline-block;
|
||||
margin-right: 0.5em; /* LTR */
|
||||
margin-bottom: 10px;
|
||||
vertical-align: top;
|
||||
}
|
||||
fieldset.date-combo .container-inline-date > .form-item {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.container-inline-date .form-item .form-item {
|
||||
float: left; /* LTR */
|
||||
}
|
||||
@@ -52,9 +54,11 @@
|
||||
|
||||
/* The exposed Views form doesn't need some of these styles */
|
||||
.container-inline-date .date-padding {
|
||||
padding: 10px;
|
||||
float: left;
|
||||
}
|
||||
fieldset.date-combo .container-inline-date .date-padding {
|
||||
padding: 10px;
|
||||
}
|
||||
.views-exposed-form .container-inline-date .date-padding {
|
||||
padding: 0;
|
||||
}
|
||||
@@ -116,7 +120,7 @@ span.date-display-end {
|
||||
}
|
||||
|
||||
/* Add space between the date and time portions of the date_select widget. */
|
||||
.form-type-date-select .form-type-select[class$=hour] {
|
||||
.form-type-date-select .form-type-select[class*=hour] {
|
||||
margin-left: .75em; /* LTR */
|
||||
}
|
||||
|
||||
@@ -173,6 +177,10 @@ div.date-calendar-day span.year {
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
.date-form-element-content-multiline {
|
||||
padding: 10px;
|
||||
border: 1px solid #CCC;
|
||||
}
|
||||
/* Admin styling */
|
||||
.form-item.form-item-instance-widget-settings-input-format-custom,
|
||||
.form-item.form-item-field-settings-enddate-required {
|
||||
|
@@ -10,112 +10,112 @@
|
||||
*/
|
||||
function _date_timezone_replacement($old) {
|
||||
$replace = array(
|
||||
'Brazil/Acre' => 'America/Rio_Branco',
|
||||
'Brazil/DeNoronha' => 'America/Noronha',
|
||||
'Brazil/East' => 'America/Recife',
|
||||
'Brazil/West' => 'America/Manaus',
|
||||
'Canada/Atlantic' => 'America/Halifax',
|
||||
'Canada/Central' => 'America/Winnipeg',
|
||||
'Canada/East-Saskatchewan' => 'America/Regina',
|
||||
'Canada/Eastern' => 'America/Toronto',
|
||||
'Canada/Mountain' => 'America/Edmonton',
|
||||
'Canada/Newfoundland' => 'America/St_Johns',
|
||||
'Canada/Pacific' => 'America/Vancouver',
|
||||
'Canada/Saskatchewan' => 'America/Regina',
|
||||
'Canada/Yukon' => 'America/Whitehorse',
|
||||
'CET' => 'Europe/Berlin',
|
||||
'Chile/Continental' => 'America/Santiago',
|
||||
'Chile/EasterIsland' => 'Pacific/Easter',
|
||||
'CST6CDT' => 'America/Chicago',
|
||||
'Cuba' => 'America/Havana',
|
||||
'EET' => 'Europe/Bucharest',
|
||||
'Egypt' => 'Africa/Cairo',
|
||||
'Eire' => 'Europe/Belfast',
|
||||
'EST' => 'America/New_York',
|
||||
'EST5EDT' => 'America/New_York',
|
||||
'GB' => 'Europe/London',
|
||||
'GB-Eire' => 'Europe/Belfast',
|
||||
'Etc/GMT' => 'UTC',
|
||||
'Etc/GMT+0' => 'UTC',
|
||||
'Etc/GMT+1' => 'UTC',
|
||||
'Etc/GMT+10' => 'UTC',
|
||||
'Etc/GMT+11' => 'UTC',
|
||||
'Etc/GMT+12' => 'UTC',
|
||||
'Etc/GMT+2' => 'UTC',
|
||||
'Etc/GMT+3' => 'UTC',
|
||||
'Etc/GMT+4' => 'UTC',
|
||||
'Etc/GMT+5' => 'UTC',
|
||||
'Etc/GMT+6' => 'UTC',
|
||||
'Etc/GMT+7' => 'UTC',
|
||||
'Etc/GMT+8' => 'UTC',
|
||||
'Etc/GMT+9' => 'UTC',
|
||||
'Etc/GMT-0' => 'UTC',
|
||||
'Etc/GMT-1' => 'UTC',
|
||||
'Etc/GMT-10' => 'UTC',
|
||||
'Etc/GMT-11' => 'UTC',
|
||||
'Etc/GMT-12' => 'UTC',
|
||||
'Etc/GMT-13' => 'UTC',
|
||||
'Etc/GMT-14' => 'UTC',
|
||||
'Etc/GMT-2' => 'UTC',
|
||||
'Etc/GMT-3' => 'UTC',
|
||||
'Etc/GMT-4' => 'UTC',
|
||||
'Etc/GMT-5' => 'UTC',
|
||||
'Etc/GMT-6' => 'UTC',
|
||||
'Etc/GMT-7' => 'UTC',
|
||||
'Etc/GMT-8' => 'UTC',
|
||||
'Etc/GMT-9' => 'UTC',
|
||||
'Etc/GMT0' => 'UTC',
|
||||
'Etc/Greenwich' => 'UTC',
|
||||
'Etc/UCT' => 'UTC',
|
||||
'Etc/Universal' => 'UTC',
|
||||
'Etc/UTC' => 'UTC',
|
||||
'Etc/Zulu' => 'UTC',
|
||||
'Factory' => 'UTC',
|
||||
'GMT' => 'UTC',
|
||||
'GMT+0' => 'UTC',
|
||||
'GMT-0' => 'UTC',
|
||||
'GMT0' => 'UTC',
|
||||
'Hongkong' => 'Asia/Hong_Kong',
|
||||
'HST' => 'Pacific/Honolulu',
|
||||
'Iceland' => 'Atlantic/Reykjavik',
|
||||
'Iran' => 'Asia/Tehran',
|
||||
'Israel' => 'Asia/Tel_Aviv',
|
||||
'Jamaica' => 'America/Jamaica',
|
||||
'Japan' => 'Asia/Tokyo',
|
||||
'Kwajalein' => 'Pacific/Kwajalein',
|
||||
'Libya' => 'Africa/Tunis',
|
||||
'MET' => 'Europe/Budapest',
|
||||
'Mexico/BajaNorte' => 'America/Tijuana',
|
||||
'Mexico/BajaSur' => 'America/Mazatlan',
|
||||
'Mexico/General' => 'America/Mexico_City',
|
||||
'MST' => 'America/Boise',
|
||||
'MST7MDT' => 'America/Boise',
|
||||
'Navajo' => 'America/Phoenix',
|
||||
'NZ' => 'Pacific/Auckland',
|
||||
'NZ-CHAT' => 'Pacific/Chatham',
|
||||
'Poland' => 'Europe/Warsaw',
|
||||
'Portugal' => 'Europe/Lisbon',
|
||||
'PRC' => 'Asia/Chongqing',
|
||||
'PST8PDT' => 'America/Los_Angeles',
|
||||
'ROC' => 'Asia/Taipei',
|
||||
'ROK' => 'Asia/Seoul',
|
||||
'Singapore' => 'Asia/Singapore',
|
||||
'Turkey' => 'Europe/Istanbul',
|
||||
'US/Alaska' => 'America/Anchorage',
|
||||
'US/Aleutian' => 'America/Adak',
|
||||
'US/Arizona' => 'America/Phoenix',
|
||||
'US/Central' => 'America/Chicago',
|
||||
'US/East-Indiana' => 'America/Indianapolis',
|
||||
'US/Eastern' => 'America/New_York',
|
||||
'US/Hawaii' => 'Pacific/Honolulu',
|
||||
'US/Indiana-Starke' => 'America/Indiana/Knox',
|
||||
'US/Michigan' => 'America/Detroit',
|
||||
'US/Mountain' => 'America/Boise',
|
||||
'US/Pacific' => 'America/Los_Angeles',
|
||||
'US/Pacific-New' => 'America/Los_Angeles',
|
||||
'US/Samoa' => 'Pacific/Samoa',
|
||||
'W-SU' => 'Europe/Moscow',
|
||||
'WET' => 'Europe/Paris',
|
||||
'Brazil/Acre' => 'America/Rio_Branco',
|
||||
'Brazil/DeNoronha' => 'America/Noronha',
|
||||
'Brazil/East' => 'America/Recife',
|
||||
'Brazil/West' => 'America/Manaus',
|
||||
'Canada/Atlantic' => 'America/Halifax',
|
||||
'Canada/Central' => 'America/Winnipeg',
|
||||
'Canada/East-Saskatchewan' => 'America/Regina',
|
||||
'Canada/Eastern' => 'America/Toronto',
|
||||
'Canada/Mountain' => 'America/Edmonton',
|
||||
'Canada/Newfoundland' => 'America/St_Johns',
|
||||
'Canada/Pacific' => 'America/Vancouver',
|
||||
'Canada/Saskatchewan' => 'America/Regina',
|
||||
'Canada/Yukon' => 'America/Whitehorse',
|
||||
'CET' => 'Europe/Berlin',
|
||||
'Chile/Continental' => 'America/Santiago',
|
||||
'Chile/EasterIsland' => 'Pacific/Easter',
|
||||
'CST6CDT' => 'America/Chicago',
|
||||
'Cuba' => 'America/Havana',
|
||||
'EET' => 'Europe/Bucharest',
|
||||
'Egypt' => 'Africa/Cairo',
|
||||
'Eire' => 'Europe/Belfast',
|
||||
'EST' => 'America/New_York',
|
||||
'EST5EDT' => 'America/New_York',
|
||||
'GB' => 'Europe/London',
|
||||
'GB-Eire' => 'Europe/Belfast',
|
||||
'Etc/GMT' => 'UTC',
|
||||
'Etc/GMT+0' => 'UTC',
|
||||
'Etc/GMT+1' => 'UTC',
|
||||
'Etc/GMT+10' => 'UTC',
|
||||
'Etc/GMT+11' => 'UTC',
|
||||
'Etc/GMT+12' => 'UTC',
|
||||
'Etc/GMT+2' => 'UTC',
|
||||
'Etc/GMT+3' => 'UTC',
|
||||
'Etc/GMT+4' => 'UTC',
|
||||
'Etc/GMT+5' => 'UTC',
|
||||
'Etc/GMT+6' => 'UTC',
|
||||
'Etc/GMT+7' => 'UTC',
|
||||
'Etc/GMT+8' => 'UTC',
|
||||
'Etc/GMT+9' => 'UTC',
|
||||
'Etc/GMT-0' => 'UTC',
|
||||
'Etc/GMT-1' => 'UTC',
|
||||
'Etc/GMT-10' => 'UTC',
|
||||
'Etc/GMT-11' => 'UTC',
|
||||
'Etc/GMT-12' => 'UTC',
|
||||
'Etc/GMT-13' => 'UTC',
|
||||
'Etc/GMT-14' => 'UTC',
|
||||
'Etc/GMT-2' => 'UTC',
|
||||
'Etc/GMT-3' => 'UTC',
|
||||
'Etc/GMT-4' => 'UTC',
|
||||
'Etc/GMT-5' => 'UTC',
|
||||
'Etc/GMT-6' => 'UTC',
|
||||
'Etc/GMT-7' => 'UTC',
|
||||
'Etc/GMT-8' => 'UTC',
|
||||
'Etc/GMT-9' => 'UTC',
|
||||
'Etc/GMT0' => 'UTC',
|
||||
'Etc/Greenwich' => 'UTC',
|
||||
'Etc/UCT' => 'UTC',
|
||||
'Etc/Universal' => 'UTC',
|
||||
'Etc/UTC' => 'UTC',
|
||||
'Etc/Zulu' => 'UTC',
|
||||
'Factory' => 'UTC',
|
||||
'GMT' => 'UTC',
|
||||
'GMT+0' => 'UTC',
|
||||
'GMT-0' => 'UTC',
|
||||
'GMT0' => 'UTC',
|
||||
'Hongkong' => 'Asia/Hong_Kong',
|
||||
'HST' => 'Pacific/Honolulu',
|
||||
'Iceland' => 'Atlantic/Reykjavik',
|
||||
'Iran' => 'Asia/Tehran',
|
||||
'Israel' => 'Asia/Tel_Aviv',
|
||||
'Jamaica' => 'America/Jamaica',
|
||||
'Japan' => 'Asia/Tokyo',
|
||||
'Kwajalein' => 'Pacific/Kwajalein',
|
||||
'Libya' => 'Africa/Tunis',
|
||||
'MET' => 'Europe/Budapest',
|
||||
'Mexico/BajaNorte' => 'America/Tijuana',
|
||||
'Mexico/BajaSur' => 'America/Mazatlan',
|
||||
'Mexico/General' => 'America/Mexico_City',
|
||||
'MST' => 'America/Boise',
|
||||
'MST7MDT' => 'America/Boise',
|
||||
'Navajo' => 'America/Phoenix',
|
||||
'NZ' => 'Pacific/Auckland',
|
||||
'NZ-CHAT' => 'Pacific/Chatham',
|
||||
'Poland' => 'Europe/Warsaw',
|
||||
'Portugal' => 'Europe/Lisbon',
|
||||
'PRC' => 'Asia/Chongqing',
|
||||
'PST8PDT' => 'America/Los_Angeles',
|
||||
'ROC' => 'Asia/Taipei',
|
||||
'ROK' => 'Asia/Seoul',
|
||||
'Singapore' => 'Asia/Singapore',
|
||||
'Turkey' => 'Europe/Istanbul',
|
||||
'US/Alaska' => 'America/Anchorage',
|
||||
'US/Aleutian' => 'America/Adak',
|
||||
'US/Arizona' => 'America/Phoenix',
|
||||
'US/Central' => 'America/Chicago',
|
||||
'US/East-Indiana' => 'America/Indianapolis',
|
||||
'US/Eastern' => 'America/New_York',
|
||||
'US/Hawaii' => 'Pacific/Honolulu',
|
||||
'US/Indiana-Starke' => 'America/Indiana/Knox',
|
||||
'US/Michigan' => 'America/Detroit',
|
||||
'US/Mountain' => 'America/Boise',
|
||||
'US/Pacific' => 'America/Los_Angeles',
|
||||
'US/Pacific-New' => 'America/Los_Angeles',
|
||||
'US/Samoa' => 'Pacific/Samoa',
|
||||
'W-SU' => 'Europe/Moscow',
|
||||
'WET' => 'Europe/Paris',
|
||||
);
|
||||
if (array_key_exists($old, $replace)) {
|
||||
return $replace[$old];
|
||||
|
@@ -9,9 +9,9 @@ stylesheets[all][] = date.css
|
||||
files[] = date_api.module
|
||||
files[] = date_api_sql.inc
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-07-29
|
||||
version = "7.x-2.8"
|
||||
; Information added by Drupal.org packaging script on 2015-09-08
|
||||
version = "7.x-2.9"
|
||||
core = "7.x"
|
||||
project = "date"
|
||||
datestamp = "1406653438"
|
||||
datestamp = "1441727353"
|
||||
|
||||
|
@@ -96,7 +96,7 @@ function date_api_uninstall() {
|
||||
'date_php_min_year',
|
||||
'date_db_tz_support',
|
||||
'date_api_use_iso8601',
|
||||
);
|
||||
);
|
||||
foreach ($variables as $variable) {
|
||||
variable_del($variable);
|
||||
}
|
||||
@@ -118,8 +118,9 @@ function date_api_update_last_removed() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Move old date format data to new date format tables, and delete the old
|
||||
* tables. Insert only values that don't already exist in the new tables, in
|
||||
* Move old date format to new date format tables,and delete the old tables.
|
||||
*
|
||||
* Insert only values that don't already exist in the new tables, in
|
||||
* case new version of those custom values have already been created.
|
||||
*/
|
||||
function date_api_update_7000() {
|
||||
|
@@ -59,16 +59,16 @@ function date_help($path, $arg) {
|
||||
}
|
||||
|
||||
if (module_exists('date_tools')) {
|
||||
$output .= '<h3>Date Tools</h3>' . t('Dates and calendars can be complicated to set up. The !date_wizard makes it easy to create a simple date content type and with a date field. ', array('!date_wizard' => l(t('Date wizard'), 'admin/config/date/tools/date_wizard')));
|
||||
$output .= '<h3>Date Tools</h3>' . t('Dates and calendars can be complicated to set up. The !date_wizard makes it easy to create a simple date content type and with a date field.', array('!date_wizard' => l(t('Date wizard'), 'admin/config/date/tools/date_wizard')));
|
||||
}
|
||||
else {
|
||||
$output .= '<h3>Date Tools</h3>' . t('Dates and calendars can be complicated to set up. If you enable the Date Tools module, it provides a Date Wizard that makes it easy to create a simple date content type with a date field. ');
|
||||
$output .= '<h3>Date Tools</h3>' . t('Dates and calendars can be complicated to set up. If you enable the Date Tools module, it provides a Date Wizard that makes it easy to create a simple date content type with a date field.');
|
||||
}
|
||||
|
||||
$output .= '<h2>More Information</h2><p>' . t('Complete documentation for the Date and Date API modules is available at <a href="@link">http://drupal.org/node/92460</a>.', array('@link' => 'http://drupal.org/node/262062')) . '</p>';
|
||||
|
||||
return $output;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ function date_api_status() {
|
||||
$value = variable_get('date_format_medium');
|
||||
if (isset($value)) {
|
||||
$now = date_now();
|
||||
$success_messages[] = $t('The medium date format type has been set to to @value. You may find it helpful to add new format types like Date, Time, Month, or Year, with appropriate formats, at <a href="@regional_date_time">Date and time</a> settings.', array('@value' => $now->format($value), '@regional_date_time' => url('admin/config/regional/date-time')));
|
||||
$success_messages[] = $t('The medium date format type has been set to @value. You may find it helpful to add new format types like Date, Time, Month, or Year, with appropriate formats, at <a href="@regional_date_time">Date and time</a> settings.', array('@value' => $now->format($value), '@regional_date_time' => url('admin/config/regional/date-time')));
|
||||
}
|
||||
else {
|
||||
$error_messages[] = $t('The Date API requires that you set up the <a href="@regional_date_time">system date formats</a> to function correctly.', array('@regional_date_time' => url('admin/config/regional/date-time')));
|
||||
@@ -143,7 +143,15 @@ function date_api_menu() {
|
||||
class DateObject extends DateTime {
|
||||
public $granularity = array();
|
||||
public $errors = array();
|
||||
protected static $allgranularity = array('year', 'month', 'day', 'hour', 'minute', 'second', 'timezone');
|
||||
protected static $allgranularity = array(
|
||||
'year',
|
||||
'month',
|
||||
'day',
|
||||
'hour',
|
||||
'minute',
|
||||
'second',
|
||||
'timezone'
|
||||
);
|
||||
private $serializedTime;
|
||||
private $serializedTimezone;
|
||||
|
||||
@@ -402,7 +410,7 @@ class DateObject extends DateTime {
|
||||
* A single date part.
|
||||
*/
|
||||
public function removeGranularity($g) {
|
||||
if ($key = array_search($g, $this->granularity)) {
|
||||
if (($key = array_search($g, $this->granularity)) !== FALSE) {
|
||||
unset($this->granularity[$key]);
|
||||
}
|
||||
}
|
||||
@@ -458,23 +466,35 @@ class DateObject extends DateTime {
|
||||
$true = $this->hasGranularity() && (!$granularity || $flexible || $this->hasGranularity($granularity));
|
||||
if (!$true && $granularity) {
|
||||
foreach ((array) $granularity as $part) {
|
||||
if (!$this->hasGranularity($part) && in_array($part, array('second', 'minute', 'hour', 'day', 'month', 'year'))) {
|
||||
if (!$this->hasGranularity($part) && in_array($part, array(
|
||||
'second',
|
||||
'minute',
|
||||
'hour',
|
||||
'day',
|
||||
'month',
|
||||
'year')
|
||||
)) {
|
||||
switch ($part) {
|
||||
case 'second':
|
||||
$this->errors[$part] = t('The second is missing.');
|
||||
break;
|
||||
|
||||
case 'minute':
|
||||
$this->errors[$part] = t('The minute is missing.');
|
||||
break;
|
||||
|
||||
case 'hour':
|
||||
$this->errors[$part] = t('The hour is missing.');
|
||||
break;
|
||||
|
||||
case 'day':
|
||||
$this->errors[$part] = t('The day is missing.');
|
||||
break;
|
||||
|
||||
case 'month':
|
||||
$this->errors[$part] = t('The month is missing.');
|
||||
break;
|
||||
|
||||
case 'year':
|
||||
$this->errors[$part] = t('The year is missing.');
|
||||
break;
|
||||
@@ -537,7 +557,14 @@ class DateObject extends DateTime {
|
||||
$temp = date_parse($time);
|
||||
// Special case for 'now'.
|
||||
if ($time == 'now') {
|
||||
$this->granularity = array('year', 'month', 'day', 'hour', 'minute', 'second');
|
||||
$this->granularity = array(
|
||||
'year',
|
||||
'month',
|
||||
'day',
|
||||
'hour',
|
||||
'minute',
|
||||
'second',
|
||||
);
|
||||
}
|
||||
else {
|
||||
// This PHP date_parse() method currently doesn't have resolution down to
|
||||
@@ -600,7 +627,14 @@ class DateObject extends DateTime {
|
||||
return FALSE;
|
||||
}
|
||||
$this->granularity = array();
|
||||
$final_date = array('hour' => 0, 'minute' => 0, 'second' => 0, 'month' => 1, 'day' => 1, 'year' => 0);
|
||||
$final_date = array(
|
||||
'hour' => 0,
|
||||
'minute' => 0,
|
||||
'second' => 0,
|
||||
'month' => 1,
|
||||
'day' => 1,
|
||||
'year' => 0,
|
||||
);
|
||||
foreach ($letters as $i => $letter) {
|
||||
$value = $values[$i];
|
||||
switch ($letter) {
|
||||
@@ -609,21 +643,25 @@ class DateObject extends DateTime {
|
||||
$final_date['day'] = intval($value);
|
||||
$this->addGranularity('day');
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
case 'm':
|
||||
$final_date['month'] = intval($value);
|
||||
$this->addGranularity('month');
|
||||
break;
|
||||
|
||||
case 'F':
|
||||
$array_month_long = array_flip(date_month_names());
|
||||
$final_date['month'] = array_key_exists($value, $array_month_long) ? $array_month_long[$value] : -1;
|
||||
$this->addGranularity('month');
|
||||
break;
|
||||
|
||||
case 'M':
|
||||
$array_month = array_flip(date_month_names_abbr());
|
||||
$final_date['month'] = array_key_exists($value, $array_month) ? $array_month[$value] : -1;
|
||||
$this->addGranularity('month');
|
||||
break;
|
||||
|
||||
case 'Y':
|
||||
$final_date['year'] = $value;
|
||||
$this->addGranularity('year');
|
||||
@@ -631,16 +669,19 @@ class DateObject extends DateTime {
|
||||
$this->errors['year'] = t('The year is invalid. Please check that entry includes four digits.');
|
||||
}
|
||||
break;
|
||||
|
||||
case 'y':
|
||||
$year = $value;
|
||||
// If no century, we add the current one ("06" => "2006").
|
||||
$final_date['year'] = str_pad($year, 4, substr(date("Y"), 0, 2), STR_PAD_LEFT);
|
||||
$this->addGranularity('year');
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
case 'A':
|
||||
$ampm = strtolower($value);
|
||||
break;
|
||||
|
||||
case 'g':
|
||||
case 'h':
|
||||
case 'G':
|
||||
@@ -648,14 +689,17 @@ class DateObject extends DateTime {
|
||||
$final_date['hour'] = intval($value);
|
||||
$this->addGranularity('hour');
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
$final_date['minute'] = intval($value);
|
||||
$this->addGranularity('minute');
|
||||
break;
|
||||
|
||||
case 's':
|
||||
$final_date['second'] = intval($value);
|
||||
$this->addGranularity('second');
|
||||
break;
|
||||
|
||||
case 'U':
|
||||
parent::__construct($value, $tz ? $tz : new DateTimeZone("UTC"));
|
||||
$this->addGranularity('year');
|
||||
@@ -665,7 +709,7 @@ class DateObject extends DateTime {
|
||||
$this->addGranularity('minute');
|
||||
$this->addGranularity('second');
|
||||
return $this;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
if (isset($ampm) && $ampm == 'pm' && $final_date['hour'] < 12) {
|
||||
@@ -758,10 +802,24 @@ class DateObject extends DateTime {
|
||||
// date or we will get date slippage, i.e. a value of 2011-00-00 will get
|
||||
// interpreted as November of 2010 by PHP.
|
||||
if ($full) {
|
||||
$arr += array('year' => 0, 'month' => 1, 'day' => 1, 'hour' => 0, 'minute' => 0, 'second' => 0);
|
||||
$arr += array(
|
||||
'year' => 0,
|
||||
'month' => 1,
|
||||
'day' => 1,
|
||||
'hour' => 0,
|
||||
'minute' => 0,
|
||||
'second' => 0,
|
||||
);
|
||||
}
|
||||
else {
|
||||
$arr += array('year' => '', 'month' => '', 'day' => '', 'hour' => '', 'minute' => '', 'second' => '');
|
||||
$arr += array(
|
||||
'year' => '',
|
||||
'month' => '',
|
||||
'day' => '',
|
||||
'hour' => '',
|
||||
'minute' => '',
|
||||
'second' => '',
|
||||
);
|
||||
}
|
||||
$datetime = '';
|
||||
if ($arr['year'] !== '') {
|
||||
@@ -839,28 +897,27 @@ class DateObject extends DateTime {
|
||||
case 'year':
|
||||
$fallback = $now->format('Y');
|
||||
return !is_int($value) || empty($value) || $value < variable_get('date_min_year', 1) || $value > variable_get('date_max_year', 4000) ? $fallback : $value;
|
||||
break;
|
||||
|
||||
case 'month':
|
||||
$fallback = $default == 'first' ? 1 : $now->format('n');
|
||||
return !is_int($value) || empty($value) || $value <= 0 || $value > 12 ? $fallback : $value;
|
||||
break;
|
||||
|
||||
case 'day':
|
||||
$fallback = $default == 'first' ? 1 : $now->format('j');
|
||||
$max_day = isset($year) && isset($month) ? date_days_in_month($year, $month) : 31;
|
||||
return !is_int($value) || empty($value) || $value <= 0 || $value > $max_day ? $fallback : $value;
|
||||
break;
|
||||
|
||||
case 'hour':
|
||||
$fallback = $default == 'first' ? 0 : $now->format('G');
|
||||
return !is_int($value) || $value < 0 || $value > 23 ? $fallback : $value;
|
||||
break;
|
||||
|
||||
case 'minute':
|
||||
$fallback = $default == 'first' ? 0 : $now->format('i');
|
||||
return !is_int($value) || $value < 0 || $value > 59 ? $fallback : $value;
|
||||
break;
|
||||
|
||||
case 'second':
|
||||
$fallback = $default == 'first' ? 0 : $now->format('s');
|
||||
return !is_int($value) || $value < 0 || $value > 59 ? $fallback : $value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -898,18 +955,23 @@ class DateObject extends DateTime {
|
||||
case 'year':
|
||||
$errors['year'] = t('The year is invalid.');
|
||||
break;
|
||||
|
||||
case 'month':
|
||||
$errors['month'] = t('The month is invalid.');
|
||||
break;
|
||||
|
||||
case 'day':
|
||||
$errors['day'] = t('The day is invalid.');
|
||||
break;
|
||||
|
||||
case 'hour':
|
||||
$errors['hour'] = t('The hour is invalid.');
|
||||
break;
|
||||
|
||||
case 'minute':
|
||||
$errors['minute'] = t('The minute is invalid.');
|
||||
break;
|
||||
|
||||
case 'second':
|
||||
$errors['second'] = t('The second is invalid.');
|
||||
break;
|
||||
@@ -929,7 +991,7 @@ class DateObject extends DateTime {
|
||||
* The stop date.
|
||||
* @param string $measure
|
||||
* (optional) A granularity date part. Defaults to 'seconds'.
|
||||
* @param boolean $absolute
|
||||
* @param bool $absolute
|
||||
* (optional) Indicate whether the absolute value of the difference should
|
||||
* be returned or if the sign should be retained. Defaults to TRUE.
|
||||
*/
|
||||
@@ -955,10 +1017,13 @@ class DateObject extends DateTime {
|
||||
// The easy cases first.
|
||||
case 'seconds':
|
||||
return $diff;
|
||||
|
||||
case 'minutes':
|
||||
return $diff / 60;
|
||||
|
||||
case 'hours':
|
||||
return $diff / 3600;
|
||||
|
||||
case 'years':
|
||||
return $year_diff;
|
||||
|
||||
@@ -1013,7 +1078,7 @@ class DateObject extends DateTime {
|
||||
$sign = ($year_diff < 0) ? -1 : 1;
|
||||
|
||||
for ($i = 1; $i <= abs($year_diff); $i++) {
|
||||
date_modify($date1, (($sign > 0) ? '+': '-').'1 year');
|
||||
date_modify($date1, (($sign > 0) ? '+' : '-') . '1 year');
|
||||
$week_diff += (date_iso_weeks_in_year($date1) * $sign);
|
||||
}
|
||||
return $week_diff;
|
||||
@@ -1060,10 +1125,13 @@ function date_type_format($type) {
|
||||
switch ($type) {
|
||||
case DATE_ISO:
|
||||
return DATE_FORMAT_ISO;
|
||||
|
||||
case DATE_UNIX:
|
||||
return DATE_FORMAT_UNIX;
|
||||
|
||||
case DATE_DATETIME:
|
||||
return DATE_FORMAT_DATETIME;
|
||||
|
||||
case DATE_ICAL:
|
||||
return DATE_FORMAT_ICAL;
|
||||
}
|
||||
@@ -1119,7 +1187,7 @@ function date_month_names($required = FALSE) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a translated array of month name abbreviations
|
||||
* Constructs a translated array of month name abbreviations.
|
||||
*
|
||||
* @param bool $required
|
||||
* (optional) If FALSE, the returned array will include a blank value.
|
||||
@@ -1211,9 +1279,11 @@ function date_week_days_abbr($required = FALSE, $refresh = TRUE, $length = 3) {
|
||||
case 1:
|
||||
$context = 'day_abbr1';
|
||||
break;
|
||||
|
||||
case 2:
|
||||
$context = 'day_abbr2';
|
||||
break;
|
||||
|
||||
default:
|
||||
$context = '';
|
||||
break;
|
||||
@@ -1248,10 +1318,10 @@ function date_week_days_ordered($weekdays) {
|
||||
/**
|
||||
* Constructs an array of years.
|
||||
*
|
||||
* @param int $min
|
||||
* The minimum year in the array.
|
||||
* @param int $max
|
||||
* The maximum year in the array.
|
||||
* @param int $start
|
||||
* The start year in the array.
|
||||
* @param int $end
|
||||
* The end year in the array.
|
||||
* @param bool $required
|
||||
* (optional) If FALSE, the returned array will include a blank value.
|
||||
* Defaults to FALSE.
|
||||
@@ -1259,16 +1329,16 @@ function date_week_days_ordered($weekdays) {
|
||||
* @return array
|
||||
* An array of years in the selected range.
|
||||
*/
|
||||
function date_years($min = 0, $max = 0, $required = FALSE) {
|
||||
function date_years($start = 0, $end = 0, $required = FALSE) {
|
||||
// Ensure $min and $max are valid values.
|
||||
if (empty($min)) {
|
||||
$min = intval(date('Y', REQUEST_TIME) - 3);
|
||||
if (empty($start)) {
|
||||
$start = intval(date('Y', REQUEST_TIME) - 3);
|
||||
}
|
||||
if (empty($max)) {
|
||||
$max = intval(date('Y', REQUEST_TIME) + 3);
|
||||
if (empty($end)) {
|
||||
$end = intval(date('Y', REQUEST_TIME) + 3);
|
||||
}
|
||||
$none = array(0 => '');
|
||||
return !$required ? $none + drupal_map_assoc(range($min, $max)) : drupal_map_assoc(range($min, $max));
|
||||
return !$required ? $none + drupal_map_assoc(range($start, $end)) : drupal_map_assoc(range($start, $end));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1474,7 +1544,14 @@ function date_granularity_names() {
|
||||
* An array of date parts.
|
||||
*/
|
||||
function date_granularity_sorted($granularity) {
|
||||
return array_intersect(array('year', 'month', 'day', 'hour', 'minute', 'second'), $granularity);
|
||||
return array_intersect(array(
|
||||
'year',
|
||||
'month',
|
||||
'day',
|
||||
'hour',
|
||||
'minute',
|
||||
'second',
|
||||
), $granularity);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1492,14 +1569,19 @@ function date_granularity_array_from_precision($precision) {
|
||||
switch ($precision) {
|
||||
case 'year':
|
||||
return array_slice($granularity_array, -6, 1);
|
||||
|
||||
case 'month':
|
||||
return array_slice($granularity_array, -6, 2);
|
||||
|
||||
case 'day':
|
||||
return array_slice($granularity_array, -6, 3);
|
||||
|
||||
case 'hour':
|
||||
return array_slice($granularity_array, -6, 4);
|
||||
|
||||
case 'minute':
|
||||
return array_slice($granularity_array, -6, 5);
|
||||
|
||||
default:
|
||||
return $granularity_array;
|
||||
}
|
||||
@@ -1533,14 +1615,19 @@ function date_granularity_format($granularity) {
|
||||
switch ($granularity) {
|
||||
case 'year':
|
||||
return substr($format, 0, 1);
|
||||
|
||||
case 'month':
|
||||
return substr($format, 0, 3);
|
||||
|
||||
case 'day':
|
||||
return substr($format, 0, 5);
|
||||
|
||||
case 'hour';
|
||||
return substr($format, 0, 7);
|
||||
|
||||
case 'minute':
|
||||
return substr($format, 0, 9);
|
||||
|
||||
default:
|
||||
return $format;
|
||||
}
|
||||
@@ -1657,40 +1744,51 @@ function date_format_date($date, $type = 'medium', $format = '', $langcode = NUL
|
||||
case 'l':
|
||||
$datestring .= t($date->format('l'), array(), array('context' => '', 'langcode' => $langcode));
|
||||
break;
|
||||
|
||||
case 'D':
|
||||
$datestring .= t($date->format('D'), array(), array('context' => '', 'langcode' => $langcode));
|
||||
break;
|
||||
|
||||
case 'F':
|
||||
$datestring .= t($date->format('F'), array(), array('context' => 'Long month name', 'langcode' => $langcode));
|
||||
break;
|
||||
|
||||
case 'M':
|
||||
$datestring .= t($date->format('M'), array(), array('langcode' => $langcode));
|
||||
break;
|
||||
|
||||
case 'A':
|
||||
case 'a':
|
||||
$datestring .= t($date->format($c), array(), array('context' => 'ampm', 'langcode' => $langcode));
|
||||
break;
|
||||
|
||||
// The timezone name translations can use t().
|
||||
case 'e':
|
||||
case 'T':
|
||||
$datestring .= t($date->format($c));
|
||||
break;
|
||||
|
||||
// Remaining date parts need no translation.
|
||||
case 'O':
|
||||
$datestring .= sprintf('%s%02d%02d', (date_offset_get($date) < 0 ? '-' : '+'), abs(date_offset_get($date) / 3600), abs(date_offset_get($date) % 3600) / 60);
|
||||
break;
|
||||
|
||||
case 'P':
|
||||
$datestring .= sprintf('%s%02d:%02d', (date_offset_get($date) < 0 ? '-' : '+'), abs(date_offset_get($date) / 3600), abs(date_offset_get($date) % 3600) / 60);
|
||||
break;
|
||||
|
||||
case 'Z':
|
||||
$datestring .= date_offset_get($date);
|
||||
break;
|
||||
|
||||
case '\\':
|
||||
$datestring .= $format[++$i];
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
$datestring .= date_format_date($date, 'custom', 'D, d M Y H:i:s O', $langcode);
|
||||
$datestring .= date_format_date($date, 'custom', 'D, d M Y H:i:s O', 'en');
|
||||
break;
|
||||
|
||||
default:
|
||||
if (strpos('BdcgGhHiIjLmnNosStTuUwWYyz', $c) !== FALSE) {
|
||||
$datestring .= $date->format($c);
|
||||
@@ -1739,8 +1837,8 @@ function date_format_interval($date, $granularity = 2, $display_ago = TRUE) {
|
||||
* (optional) Optionally force time to a specific timezone, defaults to user
|
||||
* timezone, if set, otherwise site timezone. Defaults to NULL.
|
||||
*
|
||||
* @param boolean $reset [optional]
|
||||
* Static cache reset
|
||||
* @param bool $reset
|
||||
* (optional) Static cache reset.
|
||||
*
|
||||
* @return object
|
||||
* The current time as a date object.
|
||||
@@ -1831,7 +1929,7 @@ function date_days_in_month($year, $month) {
|
||||
* @param mixed $date
|
||||
* (optional) The current date object, or a date string. Defaults to NULL.
|
||||
*
|
||||
* @return integer
|
||||
* @return int
|
||||
* The number of days in the year.
|
||||
*/
|
||||
function date_days_in_year($date = NULL) {
|
||||
@@ -1860,7 +1958,7 @@ function date_days_in_year($date = NULL) {
|
||||
* @param mixed $date
|
||||
* (optional) The current date object, or a date string. Defaults to NULL.
|
||||
*
|
||||
* @return integer
|
||||
* @return int
|
||||
* The number of ISO weeks in a year.
|
||||
*/
|
||||
function date_iso_weeks_in_year($date = NULL) {
|
||||
@@ -1952,7 +2050,7 @@ function date_week_range($week, $year) {
|
||||
|
||||
// Move forwards to the last day of the week.
|
||||
$max_date = clone($min_date);
|
||||
date_modify($max_date, '+7 days');
|
||||
date_modify($max_date, '+6 days');
|
||||
|
||||
if (date_format($min_date, 'Y') != $year) {
|
||||
$min_date = new DateObject($year . '-01-01 00:00:00');
|
||||
@@ -1986,7 +2084,7 @@ function date_iso_week_range($week, $year) {
|
||||
|
||||
// Move forwards to the last day of the week.
|
||||
$max_date = clone($min_date);
|
||||
date_modify($max_date, '+7 days');
|
||||
date_modify($max_date, '+6 days');
|
||||
return array($min_date, $max_date);
|
||||
}
|
||||
|
||||
@@ -2094,7 +2192,8 @@ function date_has_time($granularity) {
|
||||
if (!is_array($granularity)) {
|
||||
$granularity = array();
|
||||
}
|
||||
return (bool) count(array_intersect($granularity, array('hour', 'minute', 'second')));
|
||||
$options = array('hour', 'minute', 'second');
|
||||
return (bool) count(array_intersect($granularity, $options));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2110,7 +2209,8 @@ function date_has_date($granularity) {
|
||||
if (!is_array($granularity)) {
|
||||
$granularity = array();
|
||||
}
|
||||
return (bool) count(array_intersect($granularity, array('year', 'month', 'day')));
|
||||
$options = array('year', 'month', 'day');
|
||||
return (bool) count(array_intersect($granularity, $options));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2128,8 +2228,10 @@ function date_part_format($part, $format) {
|
||||
switch ($part) {
|
||||
case 'date':
|
||||
return date_limit_format($format, array('year', 'month', 'day'));
|
||||
|
||||
case 'time':
|
||||
return date_limit_format($format, array('hour', 'minute', 'second'));
|
||||
|
||||
default:
|
||||
return date_limit_format($format, array($part));
|
||||
}
|
||||
@@ -2157,7 +2259,7 @@ function date_limit_format($format, $granularity) {
|
||||
$drupal_static_fast['formats'] = &drupal_static(__FUNCTION__);
|
||||
}
|
||||
$formats = &$drupal_static_fast['formats'];
|
||||
$format_granularity_cid = $format .'|'. implode(',', $granularity);
|
||||
$format_granularity_cid = $format . '|' . implode(',', $granularity);
|
||||
if (isset($formats[$format_granularity_cid])) {
|
||||
return $formats[$format_granularity_cid];
|
||||
}
|
||||
@@ -2191,21 +2293,27 @@ function date_limit_format($format, $granularity) {
|
||||
case 'year':
|
||||
$regex[] = '([\-/\.,:]?\s?(?<!\\\\)[Yy])';
|
||||
break;
|
||||
|
||||
case 'day':
|
||||
$regex[] = '([\-/\.,:]?\s?(?<!\\\\)[l|D|d|dS|j|jS|N|w|W|z]{1,2})';
|
||||
break;
|
||||
|
||||
case 'month':
|
||||
$regex[] = '([\-/\.,:]?\s?(?<!\\\\)[FMmn])';
|
||||
break;
|
||||
|
||||
case 'hour':
|
||||
$regex[] = '([\-/\.,:]?\s?(?<!\\\\)[HhGg])';
|
||||
break;
|
||||
|
||||
case 'minute':
|
||||
$regex[] = '([\-/\.,:]?\s?(?<!\\\\)[i])';
|
||||
break;
|
||||
|
||||
case 'second':
|
||||
$regex[] = '([\-/\.,:]?\s?(?<!\\\\)[s])';
|
||||
break;
|
||||
|
||||
case 'timezone':
|
||||
$regex[] = '([\-/\.,:]?\s?(?<!\\\\)[TOZPe])';
|
||||
break;
|
||||
@@ -2278,25 +2386,30 @@ function date_format_order($format) {
|
||||
case 'j':
|
||||
$order[] = 'day';
|
||||
break;
|
||||
|
||||
case 'F':
|
||||
case 'M':
|
||||
case 'm':
|
||||
case 'n':
|
||||
$order[] = 'month';
|
||||
break;
|
||||
|
||||
case 'Y':
|
||||
case 'y':
|
||||
$order[] = 'year';
|
||||
break;
|
||||
|
||||
case 'g':
|
||||
case 'G':
|
||||
case 'h':
|
||||
case 'H':
|
||||
$order[] = 'hour';
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
$order[] = 'minute';
|
||||
break;
|
||||
|
||||
case 's':
|
||||
$order[] = 'second';
|
||||
break;
|
||||
@@ -2315,7 +2428,16 @@ function date_format_order($format) {
|
||||
* A reduced set of granularitiy elements.
|
||||
*/
|
||||
function date_nongranularity($granularity) {
|
||||
return array_diff(array('year', 'month', 'day', 'hour', 'minute', 'second', 'timezone'), (array) $granularity);
|
||||
$options = array(
|
||||
'year',
|
||||
'month',
|
||||
'day',
|
||||
'hour',
|
||||
'minute',
|
||||
'second',
|
||||
'timezone',
|
||||
);
|
||||
return array_diff($options, (array) $granularity);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2335,7 +2457,11 @@ function date_api_theme($existing, $type, $theme, $path) {
|
||||
'path' => "$path/theme",
|
||||
);
|
||||
return array(
|
||||
'date_nav_title' => $base + array('variables' => array('granularity' => NULL, 'view' => NULL, 'link' => NULL, 'format' => NULL)),
|
||||
'date_nav_title' => $base + array(
|
||||
'variables' => array(
|
||||
'granularity' => NULL, 'view' => NULL, 'link' => NULL, 'format' => NULL
|
||||
),
|
||||
),
|
||||
'date_timezone' => $base + array('render element' => 'element'),
|
||||
'date_select' => $base + array('render element' => 'element'),
|
||||
'date_text' => $base + array('render element' => 'element'),
|
||||
@@ -2355,7 +2481,11 @@ function date_api_theme($existing, $type, $theme, $path) {
|
||||
'date_part_label_time' => $base + array('variables' => array('date_part' => NULL, 'element' => NULL)),
|
||||
'date_views_filter_form' => $base + array('template' => 'date-views-filter-form', 'render element' => 'form'),
|
||||
'date_calendar_day' => $base + array('variables' => array('date' => NULL)),
|
||||
'date_time_ago' => $base + array('variables' => array('start_date' => NULL, 'end_date' => NULL, 'interval' => NULL)),
|
||||
'date_time_ago' => $base + array(
|
||||
'variables' => array(
|
||||
'start_date' => NULL, 'end_date' => NULL, 'interval' => NULL
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2375,9 +2505,11 @@ function date_get_timezone($handling, $timezone = '') {
|
||||
case 'date':
|
||||
$timezone = !empty($timezone) ? $timezone : date_default_timezone();
|
||||
break;
|
||||
|
||||
case 'utc':
|
||||
$timezone = 'UTC';
|
||||
break;
|
||||
|
||||
default:
|
||||
$timezone = date_default_timezone();
|
||||
}
|
||||
@@ -2404,6 +2536,7 @@ function date_get_timezone_db($handling, $timezone = NULL) {
|
||||
// These handling modes all convert to UTC before storing in the DB.
|
||||
$timezone = 'UTC';
|
||||
break;
|
||||
|
||||
case ('date'):
|
||||
if ($timezone == NULL) {
|
||||
// This shouldn't happen, since it's meaning is undefined. But we need
|
||||
@@ -2411,6 +2544,7 @@ function date_get_timezone_db($handling, $timezone = NULL) {
|
||||
$timezone = date_default_timezone();
|
||||
}
|
||||
break;
|
||||
|
||||
case ('none'):
|
||||
default:
|
||||
$timezone = date_default_timezone();
|
||||
@@ -2465,12 +2599,12 @@ function date_order() {
|
||||
* TRUE if the date range is valid, FALSE otherwise.
|
||||
*/
|
||||
function date_range_valid($string) {
|
||||
$matches = preg_match('@^(\-[0-9]+|[0-9]{4}):([\+|\-][0-9]+|[0-9]{4})$@', $string);
|
||||
$matches = preg_match('@^([\+\-][0-9]+|[0-9]{4}):([\+\-][0-9]+|[0-9]{4})$@', $string);
|
||||
return $matches < 1 ? FALSE : TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits a string like -3:+3 or 2001:2010 into an array of min and max years.
|
||||
* Splits a string like -3:+3 or 2001:2010 into an array of start and end years.
|
||||
*
|
||||
* Center the range around the current year, if any, but expand it far
|
||||
* enough so it will pick up the year value in the field in case
|
||||
@@ -2482,45 +2616,44 @@ function date_range_valid($string) {
|
||||
* (optional) A date object. Defaults to NULL.
|
||||
*
|
||||
* @return array
|
||||
* A numerically indexed array, containing a minimum and maximum year.
|
||||
* A numerically indexed array, containing a start and end year.
|
||||
*/
|
||||
function date_range_years($string, $date = NULL) {
|
||||
$this_year = date_format(date_now(), 'Y');
|
||||
list($min_year, $max_year) = explode(':', $string);
|
||||
list($start_year, $end_year) = explode(':', $string);
|
||||
|
||||
// Valid patterns would be -5:+5, 0:+1, 2008:2010.
|
||||
$plus_pattern = '@[\+|\-][0-9]{1,4}@';
|
||||
$plus_pattern = '@[\+\-][0-9]{1,4}@';
|
||||
$year_pattern = '@^[0-9]{4}@';
|
||||
if (!preg_match($year_pattern, $min_year, $matches)) {
|
||||
if (preg_match($plus_pattern, $min_year, $matches)) {
|
||||
$min_year = $this_year + $matches[0];
|
||||
if (!preg_match($year_pattern, $start_year, $matches)) {
|
||||
if (preg_match($plus_pattern, $start_year, $matches)) {
|
||||
$start_year = $this_year + $matches[0];
|
||||
}
|
||||
else {
|
||||
$min_year = $this_year;
|
||||
$start_year = $this_year;
|
||||
}
|
||||
}
|
||||
if (!preg_match($year_pattern, $max_year, $matches)) {
|
||||
if (preg_match($plus_pattern, $max_year, $matches)) {
|
||||
$max_year = $this_year + $matches[0];
|
||||
if (!preg_match($year_pattern, $end_year, $matches)) {
|
||||
if (preg_match($plus_pattern, $end_year, $matches)) {
|
||||
$end_year = $this_year + $matches[0];
|
||||
}
|
||||
else {
|
||||
$max_year = $this_year;
|
||||
$end_year = $this_year;
|
||||
}
|
||||
}
|
||||
// We expect the $min year to be less than the $max year.
|
||||
// Some custom values for -99:+99 might not obey that.
|
||||
if ($min_year > $max_year) {
|
||||
$temp = $max_year;
|
||||
$max_year = $min_year;
|
||||
$min_year = $temp;
|
||||
}
|
||||
// If there is a current value, stretch the range to include it.
|
||||
$value_year = is_object($date) ? $date->format('Y') : '';
|
||||
if (!empty($value_year)) {
|
||||
$min_year = min($value_year, $min_year);
|
||||
$max_year = max($value_year, $max_year);
|
||||
if ($start_year <= $end_year) {
|
||||
$start_year = min($value_year, $start_year);
|
||||
$end_year = max($value_year, $end_year);
|
||||
}
|
||||
else {
|
||||
$start_year = max($value_year, $start_year);
|
||||
$end_year = min($value_year, $end_year);
|
||||
}
|
||||
}
|
||||
return array($min_year, $max_year);
|
||||
return array($start_year, $end_year);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2680,6 +2813,7 @@ function date_is_all_day($string1, $string2, $granularity = 'second', $increment
|
||||
|| ($hour2 == 23 && in_array($min2, array($max_minutes, 59)) && in_array($sec2, array($max_seconds, 59)))
|
||||
|| ($hour1 == 0 && $hour2 == 0 && $min1 == 0 && $min2 == 0 && $sec1 == 0 && $sec2 == 0);
|
||||
break;
|
||||
|
||||
case 'minute':
|
||||
$min_match = $time1 == '00:00:00'
|
||||
|| ($hour1 == 0 && $min1 == 0);
|
||||
@@ -2687,6 +2821,7 @@ function date_is_all_day($string1, $string2, $granularity = 'second', $increment
|
||||
|| ($hour2 == 23 && in_array($min2, array($max_minutes, 59)))
|
||||
|| ($hour1 == 0 && $hour2 == 0 && $min1 == 0 && $min2 == 0);
|
||||
break;
|
||||
|
||||
case 'hour':
|
||||
$min_match = $time1 == '00:00:00'
|
||||
|| ($hour1 == 0);
|
||||
@@ -2694,6 +2829,7 @@ function date_is_all_day($string1, $string2, $granularity = 'second', $increment
|
||||
|| ($hour2 == 23)
|
||||
|| ($hour1 == 0 && $hour2 == 0);
|
||||
break;
|
||||
|
||||
default:
|
||||
$min_match = TRUE;
|
||||
$max_match = FALSE;
|
||||
@@ -2754,15 +2890,21 @@ function date_is_date($date) {
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will replace ISO values that have the pattern 9999-00-00T00:00:00
|
||||
* with a pattern like 9999-01-01T00:00:00, to match the behavior of non-ISO
|
||||
* dates and ensure that date objects created from this value contain a valid month
|
||||
* and day. Without this fix, the ISO date '2020-00-00T00:00:00' would be created as
|
||||
* Replace specific ISO values using patterns.
|
||||
*
|
||||
* Function will replace ISO values that have the pattern 9999-00-00T00:00:00
|
||||
* with a pattern like 9999-01-01T00:00:00, to match the behavior of non-ISO dates
|
||||
* and ensure that date objects created from this value contain a valid month
|
||||
* and day.
|
||||
* Without this fix, the ISO date '2020-00-00T00:00:00' would be created as
|
||||
* November 30, 2019 (the previous day in the previous month).
|
||||
*
|
||||
* @param string $iso_string
|
||||
* An ISO string that needs to be made into a complete, valid date.
|
||||
*
|
||||
* @return mixed|string
|
||||
* replaced value, or incoming value.
|
||||
*
|
||||
* @TODO Expand on this to work with all sorts of partial ISO dates.
|
||||
*/
|
||||
function date_make_iso_valid($iso_string) {
|
||||
|
@@ -116,15 +116,19 @@ function date_default_date($element) {
|
||||
case 16:
|
||||
$format = 'Y-m-d H:i';
|
||||
break;
|
||||
|
||||
case 13:
|
||||
$format = 'Y-m-d H';
|
||||
break;
|
||||
|
||||
case 10:
|
||||
$format = 'Y-m-d';
|
||||
break;
|
||||
|
||||
case 7:
|
||||
$format = 'Y-m';
|
||||
break;
|
||||
|
||||
case 4:
|
||||
$format = 'Y';
|
||||
break;
|
||||
@@ -170,7 +174,7 @@ function date_year_range_element_process($element, &$form_state, $form) {
|
||||
$element['#attached']['js'][] = drupal_get_path('module', 'date_api') . '/date_year_range.js';
|
||||
|
||||
$context = array(
|
||||
'form' => $form,
|
||||
'form' => $form,
|
||||
);
|
||||
drupal_alter('date_year_range_process', $element, $form_state, $context);
|
||||
|
||||
@@ -256,7 +260,7 @@ function date_timezone_element_process($element, &$form_state, $form) {
|
||||
}
|
||||
|
||||
$context = array(
|
||||
'form' => $form,
|
||||
'form' => $form,
|
||||
);
|
||||
drupal_alter('date_timezone_process', $element, $form_state, $context);
|
||||
|
||||
@@ -264,7 +268,7 @@ function date_timezone_element_process($element, &$form_state, $form) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validation for timezone input
|
||||
* Validation for timezone input.
|
||||
*
|
||||
* Move the timezone value from the nested field back to the original field.
|
||||
*/
|
||||
@@ -307,7 +311,6 @@ function date_text_element_value_callback($element, $input = FALSE, &$form_state
|
||||
*
|
||||
* The exact parts displayed in the field are those in #date_granularity.
|
||||
* The display of each part comes from #date_format.
|
||||
*
|
||||
*/
|
||||
function date_text_element_process($element, &$form_state, $form) {
|
||||
if (date_hidden_element($element)) {
|
||||
@@ -323,9 +326,18 @@ function date_text_element_process($element, &$form_state, $form) {
|
||||
$now = date_example_date();
|
||||
$element['date']['#title'] = t('Date');
|
||||
$element['date']['#title_display'] = 'invisible';
|
||||
$element['date']['#description'] = ' ' . t('Format: @date', array('@date' => date_format_date(date_example_date(), 'custom', $element['#date_format'])));
|
||||
$element['date']['#description'] = ' ' . t('Format: @date', array(
|
||||
'@date' => date_format_date(date_example_date(), 'custom', $element['#date_format']
|
||||
)));
|
||||
$element['date']['#ajax'] = !empty($element['#ajax']) ? $element['#ajax'] : FALSE;
|
||||
|
||||
// Make changes if instance is set to be rendered as a regular field.
|
||||
if (!empty($element['#instance']['widget']['settings']['no_fieldset']) && $element['#field']['cardinality'] == 1) {
|
||||
$element['date']['#title'] = check_plain($element['#instance']['label']);
|
||||
$element['date']['#title_display'] = $element['#title_display'];
|
||||
$element['date']['#required'] = $element['#required'];
|
||||
}
|
||||
|
||||
// Keep the system from creating an error message for the sub-element.
|
||||
// We'll set our own message on the parent element.
|
||||
// $element['date']['#required'] = $element['#required'];
|
||||
@@ -341,7 +353,7 @@ function date_text_element_process($element, &$form_state, $form) {
|
||||
}
|
||||
|
||||
$context = array(
|
||||
'form' => $form,
|
||||
'form' => $form,
|
||||
);
|
||||
drupal_alter('date_text_process', $element, $form_state, $context);
|
||||
|
||||
@@ -349,12 +361,11 @@ function date_text_element_process($element, &$form_state, $form) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validation for text input.
|
||||
* Validation for text input.
|
||||
*
|
||||
* When used as a Views widget, the validation step always gets triggered,
|
||||
* even with no form submission. Before form submission $element['#value']
|
||||
* contains a string, after submission it contains an array.
|
||||
*
|
||||
*/
|
||||
function date_text_validate($element, &$form_state) {
|
||||
if (date_hidden_element($element)) {
|
||||
@@ -367,6 +378,11 @@ function date_text_validate($element, &$form_state) {
|
||||
$input_exists = NULL;
|
||||
$input = drupal_array_get_nested_value($form_state['values'], $element['#parents'], $input_exists);
|
||||
|
||||
// Trim extra spacing off user input of text fields.
|
||||
if (isset($input['date'])) {
|
||||
$input['date'] = trim($input['date']);
|
||||
}
|
||||
|
||||
drupal_alter('date_text_pre_validate', $element, $form_state, $input);
|
||||
|
||||
$label = !empty($element['#date_title']) ? $element['#date_title'] : (!empty($element['#title']) ? $element['#title'] : '');
|
||||
@@ -421,7 +437,14 @@ function date_text_input_date($element, $input) {
|
||||
* Element value callback for date_select element.
|
||||
*/
|
||||
function date_select_element_value_callback($element, $input = FALSE, &$form_state = array()) {
|
||||
$return = array('year' => '', 'month' => '', 'day' => '', 'hour' => '', 'minute' => '', 'second' => '');
|
||||
$return = array(
|
||||
'year' => '',
|
||||
'month' => '',
|
||||
'day' => '',
|
||||
'hour' => '',
|
||||
'minute' => '',
|
||||
'second' => '',
|
||||
);
|
||||
$date = NULL;
|
||||
if ($input !== FALSE) {
|
||||
$return = $input;
|
||||
@@ -431,7 +454,14 @@ function date_select_element_value_callback($element, $input = FALSE, &$form_sta
|
||||
$date = date_default_date($element);
|
||||
}
|
||||
$granularity = date_format_order($element['#date_format']);
|
||||
$formats = array('year' => 'Y', 'month' => 'n', 'day' => 'j', 'hour' => 'H', 'minute' => 'i', 'second' => 's');
|
||||
$formats = array(
|
||||
'year' => 'Y',
|
||||
'month' => 'n',
|
||||
'day' => 'j',
|
||||
'hour' => 'H',
|
||||
'minute' => 'i',
|
||||
'second' => 's',
|
||||
);
|
||||
foreach ($granularity as $field) {
|
||||
if ($field != 'timezone') {
|
||||
$return[$field] = date_is_date($date) ? $date->format($formats[$field]) : '';
|
||||
@@ -449,7 +479,6 @@ function date_select_element_value_callback($element, $input = FALSE, &$form_sta
|
||||
*
|
||||
* The exact parts displayed in the field are those in #date_granularity.
|
||||
* The display of each part comes from ['#date_settings']['format'].
|
||||
*
|
||||
*/
|
||||
function date_select_element_process($element, &$form_state, $form) {
|
||||
if (date_hidden_element($element)) {
|
||||
@@ -473,7 +502,14 @@ function date_select_element_process($element, &$form_state, $form) {
|
||||
|
||||
// Store a hidden value for all date parts not in the current display.
|
||||
$granularity = date_format_order($element['#date_format']);
|
||||
$formats = array('year' => 'Y', 'month' => 'n', 'day' => 'j', 'hour' => 'H', 'minute' => 'i', 'second' => 's');
|
||||
$formats = array(
|
||||
'year' => 'Y',
|
||||
'month' => 'n',
|
||||
'day' => 'j',
|
||||
'hour' => 'H',
|
||||
'minute' => 'i',
|
||||
'second' => 's',
|
||||
);
|
||||
foreach (date_nongranularity($granularity) as $field) {
|
||||
if ($field != 'timezone') {
|
||||
$element[$field] = array(
|
||||
@@ -490,7 +526,7 @@ function date_select_element_process($element, &$form_state, $form) {
|
||||
}
|
||||
|
||||
$context = array(
|
||||
'form' => $form,
|
||||
'form' => $form,
|
||||
);
|
||||
drupal_alter('date_select_process', $element, $form_state, $context);
|
||||
|
||||
@@ -521,7 +557,7 @@ function date_parts_element($element, $date, $format) {
|
||||
$sub_element = array('#granularity' => $granularity);
|
||||
$order = array_flip($granularity);
|
||||
|
||||
$hours_format = strpos(strtolower($element['#date_format']), 'a') ? 'g': 'G';
|
||||
$hours_format = strpos(strtolower($element['#date_format']), 'a') ? 'g' : 'G';
|
||||
$month_function = strpos($element['#date_format'], 'F') !== FALSE ? 'date_month_names' : 'date_month_names_abbr';
|
||||
$count = 0;
|
||||
$increment = min(intval($element['#date_increment']), 1);
|
||||
@@ -539,26 +575,29 @@ function date_parts_element($element, $date, $format) {
|
||||
switch ($field) {
|
||||
case 'year':
|
||||
$range = date_range_years($element['#date_year_range'], $date);
|
||||
$min_year = $range[0];
|
||||
$max_year = $range[1];
|
||||
$start_year = $range[0];
|
||||
$end_year = $range[1];
|
||||
|
||||
$sub_element[$field]['#default_value'] = is_object($date) ? $date->format('Y') : '';
|
||||
if ($part_type == 'select') {
|
||||
$sub_element[$field]['#options'] = drupal_map_assoc(date_years($min_year, $max_year, $part_required));
|
||||
$sub_element[$field]['#options'] = drupal_map_assoc(date_years($start_year, $end_year, $part_required));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'month':
|
||||
$sub_element[$field]['#default_value'] = is_object($date) ? $date->format('n') : '';
|
||||
if ($part_type == 'select') {
|
||||
$sub_element[$field]['#options'] = $month_function($part_required);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'day':
|
||||
$sub_element[$field]['#default_value'] = is_object($date) ? $date->format('j') : '';
|
||||
if ($part_type == 'select') {
|
||||
$sub_element[$field]['#options'] = drupal_map_assoc(date_days($part_required));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'hour':
|
||||
$sub_element[$field]['#default_value'] = is_object($date) ? $date->format($hours_format) : '';
|
||||
if ($part_type == 'select') {
|
||||
@@ -566,6 +605,7 @@ function date_parts_element($element, $date, $format) {
|
||||
}
|
||||
$sub_element[$field]['#prefix'] = theme('date_part_hour_prefix', $element);
|
||||
break;
|
||||
|
||||
case 'minute':
|
||||
$sub_element[$field]['#default_value'] = is_object($date) ? $date->format('i') : '';
|
||||
if ($part_type == 'select') {
|
||||
@@ -573,6 +613,7 @@ function date_parts_element($element, $date, $format) {
|
||||
}
|
||||
$sub_element[$field]['#prefix'] = theme('date_part_minsec_prefix', $element);
|
||||
break;
|
||||
|
||||
case 'second':
|
||||
$sub_element[$field]['#default_value'] = is_object($date) ? $date->format('s') : '';
|
||||
if ($part_type == 'select') {
|
||||
|
@@ -181,6 +181,7 @@ function date_ical_parse($icaldatafolded = array()) {
|
||||
$parent[array_pop($parents)][] = array_pop($subgroups);
|
||||
}
|
||||
break;
|
||||
|
||||
// Add the timezones in with their index their TZID.
|
||||
case 'VTIMEZONE':
|
||||
$subgroup = end($subgroups);
|
||||
@@ -196,6 +197,7 @@ function date_ical_parse($icaldatafolded = array()) {
|
||||
array_pop($subgroups);
|
||||
array_pop($parents);
|
||||
break;
|
||||
|
||||
// Do some fun stuff with durations and all_day events and then append
|
||||
// to parent.
|
||||
case 'VEVENT':
|
||||
@@ -222,9 +224,9 @@ function date_ical_parse($icaldatafolded = array()) {
|
||||
// assumes the end date is inclusive.
|
||||
if (!empty($subgroup['DTEND']) && (!empty($subgroup['DTEND']['all_day']))) {
|
||||
// Make the end date one day earlier.
|
||||
$date = new DateObject ($subgroup['DTEND']['datetime'] . ' 00:00:00', $subgroup['DTEND']['tz']);
|
||||
$date = new DateObject($subgroup['DTEND']['datetime'] . ' 00:00:00', $subgroup['DTEND']['tz']);
|
||||
date_modify($date, '-1 day');
|
||||
$subgroup['DTEND']['datetime'] = date_format($date, 'Y-m-d');
|
||||
$subgroup['DTEND']['datetime'] = date_format($date, 'Y-m-d');
|
||||
}
|
||||
// If a start datetime is defined AND there is no definition for
|
||||
// the end datetime THEN make the end datetime equal the start
|
||||
@@ -239,7 +241,7 @@ function date_ical_parse($icaldatafolded = array()) {
|
||||
if (!empty($subgroup['DTSTART']['all_day'])) {
|
||||
$subgroup['all_day'] = TRUE;
|
||||
}
|
||||
// Add this element to the parent as an array under the
|
||||
// Add this element to the parent as an array under the.
|
||||
prev($subgroups);
|
||||
$parent = &$subgroups[key($subgroups)];
|
||||
|
||||
@@ -264,12 +266,13 @@ function date_ical_parse($icaldatafolded = array()) {
|
||||
$field = !empty($matches[2]) ? $matches[2] : '';
|
||||
$data = !empty($matches[3]) ? $matches[3] : '';
|
||||
$parse_result = '';
|
||||
|
||||
switch ($name) {
|
||||
// Keep blank lines out of the results.
|
||||
case '':
|
||||
break;
|
||||
|
||||
// Lots of properties have date values that must be parsed out.
|
||||
// Lots of properties have date values that must be parsed out.
|
||||
case 'CREATED':
|
||||
case 'LAST-MODIFIED':
|
||||
case 'DTSTART':
|
||||
@@ -317,9 +320,9 @@ function date_ical_parse($icaldatafolded = array()) {
|
||||
$parse_result = date_ical_parse_location($field, $data);
|
||||
break;
|
||||
|
||||
// For all other properties, just store the property and the value.
|
||||
// This can be expanded on in the future if other properties should
|
||||
// be given special treatment.
|
||||
// For all other properties, just store the property and the value.
|
||||
// This can be expanded on in the future if other properties should
|
||||
// be given special treatment.
|
||||
default:
|
||||
$parse_result = $data;
|
||||
break;
|
||||
@@ -360,7 +363,7 @@ function date_ical_parse($icaldatafolded = array()) {
|
||||
* has no timezone; the ical specs say no timezone
|
||||
* conversion should be done if no timezone info is
|
||||
* supplied
|
||||
* @todo
|
||||
* @todo
|
||||
* Another option for dates is the format PROPERTY;VALUE=PERIOD:XXXX. The
|
||||
* period may include a duration, or a date and a duration, or two dates, so
|
||||
* would have to be split into parts and run through date_ical_parse_date()
|
||||
@@ -401,6 +404,7 @@ function date_ical_parse_date($field, $data) {
|
||||
// Date.
|
||||
$datetime = date_pad($regs[1]) . '-' . date_pad($regs[2]) . '-' . date_pad($regs[3]);
|
||||
break;
|
||||
|
||||
case 'DATE-TIME':
|
||||
preg_match(DATE_REGEX_ICAL_DATETIME, $data, $regs);
|
||||
// Date.
|
||||
@@ -519,12 +523,12 @@ function date_ical_parse_duration(&$subgroup, $field = 'DURATION') {
|
||||
$data = $items['DATA'];
|
||||
preg_match('/^P(\d{1,4}[Y])?(\d{1,2}[M])?(\d{1,2}[W])?(\d{1,2}[D])?([T]{0,1})?(\d{1,2}[H])?(\d{1,2}[M])?(\d{1,2}[S])?/', $data, $duration);
|
||||
$items['year'] = isset($duration[1]) ? str_replace('Y', '', $duration[1]) : '';
|
||||
$items['month'] = isset($duration[2]) ?str_replace('M', '', $duration[2]) : '';
|
||||
$items['week'] = isset($duration[3]) ?str_replace('W', '', $duration[3]) : '';
|
||||
$items['day'] = isset($duration[4]) ?str_replace('D', '', $duration[4]) : '';
|
||||
$items['hour'] = isset($duration[6]) ?str_replace('H', '', $duration[6]) : '';
|
||||
$items['minute'] = isset($duration[7]) ?str_replace('M', '', $duration[7]) : '';
|
||||
$items['second'] = isset($duration[8]) ?str_replace('S', '', $duration[8]) : '';
|
||||
$items['month'] = isset($duration[2]) ? str_replace('M', '', $duration[2]) : '';
|
||||
$items['week'] = isset($duration[3]) ? str_replace('W', '', $duration[3]) : '';
|
||||
$items['day'] = isset($duration[4]) ? str_replace('D', '', $duration[4]) : '';
|
||||
$items['hour'] = isset($duration[6]) ? str_replace('H', '', $duration[6]) : '';
|
||||
$items['minute'] = isset($duration[7]) ? str_replace('M', '', $duration[7]) : '';
|
||||
$items['second'] = isset($duration[8]) ? str_replace('S', '', $duration[8]) : '';
|
||||
$start_date = array_key_exists('DTSTART', $subgroup) ? $subgroup['DTSTART']['datetime'] : date_format(date_now(), DATE_FORMAT_ISO);
|
||||
$timezone = array_key_exists('DTSTART', $subgroup) ? $subgroup['DTSTART']['tz'] : variable_get('date_default_timezone');
|
||||
if (empty($timezone)) {
|
||||
@@ -542,7 +546,7 @@ function date_ical_parse_duration(&$subgroup, $field = 'DURATION') {
|
||||
'datetime' => date_format($date2, DATE_FORMAT_DATETIME),
|
||||
'all_day' => isset($subgroup['DTSTART']['all_day']) ? $subgroup['DTSTART']['all_day'] : 0,
|
||||
'tz' => $timezone,
|
||||
);
|
||||
);
|
||||
$duration = date_format($date2, 'U') - date_format($date, 'U');
|
||||
$subgroup['DURATION'] = array('DATA' => $data, 'DURATION' => $duration);
|
||||
}
|
||||
@@ -631,7 +635,6 @@ function date_ical_date($ical_date, $to_tz = FALSE) {
|
||||
*
|
||||
* @return string
|
||||
* Escaped text
|
||||
*
|
||||
*/
|
||||
function date_ical_escape_text($text) {
|
||||
$text = drupal_html_to_text($text);
|
||||
@@ -693,14 +696,14 @@ function date_ical_escape_text($text) {
|
||||
* )
|
||||
*/
|
||||
function date_api_ical_build_rrule($form_values) {
|
||||
$RRULE = '';
|
||||
$rrule = '';
|
||||
if (empty($form_values) || !is_array($form_values)) {
|
||||
return $RRULE;
|
||||
return $rrule;
|
||||
}
|
||||
|
||||
// Grab the RRULE data and put them into iCal RRULE format.
|
||||
$RRULE .= 'RRULE:FREQ=' . (!array_key_exists('FREQ', $form_values) ? 'DAILY' : $form_values['FREQ']);
|
||||
$RRULE .= ';INTERVAL=' . (!array_key_exists('INTERVAL', $form_values) ? 1 : $form_values['INTERVAL']);
|
||||
$rrule .= 'RRULE:FREQ=' . (!array_key_exists('FREQ', $form_values) ? 'DAILY' : $form_values['FREQ']);
|
||||
$rrule .= ';INTERVAL=' . (!array_key_exists('INTERVAL', $form_values) ? 1 : $form_values['INTERVAL']);
|
||||
|
||||
// Unset the empty 'All' values.
|
||||
if (array_key_exists('BYDAY', $form_values) && is_array($form_values['BYDAY'])) {
|
||||
@@ -713,14 +716,14 @@ function date_api_ical_build_rrule($form_values) {
|
||||
unset($form_values['BYMONTHDAY']['']);
|
||||
}
|
||||
|
||||
if (array_key_exists('BYDAY', $form_values) && is_array($form_values['BYDAY']) && $BYDAY = implode(",", $form_values['BYDAY'])) {
|
||||
$RRULE .= ';BYDAY=' . $BYDAY;
|
||||
if (array_key_exists('BYDAY', $form_values) && is_array($form_values['BYDAY']) && $byday = implode(",", $form_values['BYDAY'])) {
|
||||
$rrule .= ';BYDAY=' . $byday;
|
||||
}
|
||||
if (array_key_exists('BYMONTH', $form_values) && is_array($form_values['BYMONTH']) && $BYMONTH = implode(",", $form_values['BYMONTH'])) {
|
||||
$RRULE .= ';BYMONTH=' . $BYMONTH;
|
||||
if (array_key_exists('BYMONTH', $form_values) && is_array($form_values['BYMONTH']) && $bymonth = implode(",", $form_values['BYMONTH'])) {
|
||||
$rrule .= ';BYMONTH=' . $bymonth;
|
||||
}
|
||||
if (array_key_exists('BYMONTHDAY', $form_values) && is_array($form_values['BYMONTHDAY']) && $BYMONTHDAY = implode(",", $form_values['BYMONTHDAY'])) {
|
||||
$RRULE .= ';BYMONTHDAY=' . $BYMONTHDAY;
|
||||
if (array_key_exists('BYMONTHDAY', $form_values) && is_array($form_values['BYMONTHDAY']) && $bymonthday = implode(",", $form_values['BYMONTHDAY'])) {
|
||||
$rrule .= ';BYMONTHDAY=' . $bymonthday;
|
||||
}
|
||||
// The UNTIL date is supposed to always be expressed in UTC.
|
||||
// The input date values may already have been converted to a date object on a
|
||||
@@ -731,8 +734,17 @@ function date_api_ical_build_rrule($form_values) {
|
||||
if (!is_object($form_values['UNTIL']['datetime'])) {
|
||||
// If this is a date without time, give it time.
|
||||
if (strlen($form_values['UNTIL']['datetime']) < 11) {
|
||||
$granularity_options = drupal_map_assoc(array(
|
||||
'year',
|
||||
'month',
|
||||
'day',
|
||||
'hour',
|
||||
'minute',
|
||||
'second',
|
||||
));
|
||||
|
||||
$form_values['UNTIL']['datetime'] .= ' 23:59:59';
|
||||
$form_values['UNTIL']['granularity'] = serialize(drupal_map_assoc(array('year', 'month', 'day', 'hour', 'minute', 'second')));
|
||||
$form_values['UNTIL']['granularity'] = serialize($granularity_options);
|
||||
$form_values['UNTIL']['all_day'] = FALSE;
|
||||
}
|
||||
$until = date_ical_date($form_values['UNTIL'], 'UTC');
|
||||
@@ -740,21 +752,21 @@ function date_api_ical_build_rrule($form_values) {
|
||||
else {
|
||||
$until = $form_values['UNTIL']['datetime'];
|
||||
}
|
||||
$RRULE .= ';UNTIL=' . date_format($until, DATE_FORMAT_ICAL) . 'Z';
|
||||
$rrule .= ';UNTIL=' . date_format($until, DATE_FORMAT_ICAL) . 'Z';
|
||||
}
|
||||
// Our form doesn't allow a value for COUNT, but it may be needed by
|
||||
// modules using the API, so add it to the rule.
|
||||
if (array_key_exists('COUNT', $form_values)) {
|
||||
$RRULE .= ';COUNT=' . $form_values['COUNT'];
|
||||
$rrule .= ';COUNT=' . $form_values['COUNT'];
|
||||
}
|
||||
|
||||
// iCal rules presume the week starts on Monday unless otherwise specified,
|
||||
// so we'll specify it.
|
||||
if (array_key_exists('WKST', $form_values)) {
|
||||
$RRULE .= ';WKST=' . $form_values['WKST'];
|
||||
$rrule .= ';WKST=' . $form_values['WKST'];
|
||||
}
|
||||
else {
|
||||
$RRULE .= ';WKST=' . date_repeat_dow2day(variable_get('date_first_day', 0));
|
||||
$rrule .= ';WKST=' . date_repeat_dow2day(variable_get('date_first_day', 0));
|
||||
}
|
||||
|
||||
// Exceptions dates go last, on their own line.
|
||||
@@ -765,7 +777,7 @@ function date_api_ical_build_rrule($form_values) {
|
||||
foreach ($form_values['EXDATE'] as $value) {
|
||||
if (!empty($value['datetime'])) {
|
||||
$date = !is_object($value['datetime']) ? date_ical_date($value, 'UTC') : $value['datetime'];
|
||||
$ex_date = !empty($date) ? date_format($date, DATE_FORMAT_ICAL) . 'Z': '';
|
||||
$ex_date = !empty($date) ? date_format($date, DATE_FORMAT_ICAL) . 'Z' : '';
|
||||
if (!empty($ex_date)) {
|
||||
$ex_dates[] = $ex_date;
|
||||
}
|
||||
@@ -773,11 +785,11 @@ function date_api_ical_build_rrule($form_values) {
|
||||
}
|
||||
if (!empty($ex_dates)) {
|
||||
sort($ex_dates);
|
||||
$RRULE .= chr(13) . chr(10) . 'EXDATE:' . implode(',', $ex_dates);
|
||||
$rrule .= chr(13) . chr(10) . 'EXDATE:' . implode(',', $ex_dates);
|
||||
}
|
||||
}
|
||||
elseif (!empty($form_values['EXDATE'])) {
|
||||
$RRULE .= chr(13) . chr(10) . 'EXDATE:' . $form_values['EXDATE'];
|
||||
$rrule .= chr(13) . chr(10) . 'EXDATE:' . $form_values['EXDATE'];
|
||||
}
|
||||
|
||||
// Exceptions dates go last, on their own line.
|
||||
@@ -785,19 +797,19 @@ function date_api_ical_build_rrule($form_values) {
|
||||
$ex_dates = array();
|
||||
foreach ($form_values['RDATE'] as $value) {
|
||||
$date = !is_object($value['datetime']) ? date_ical_date($value, 'UTC') : $value['datetime'];
|
||||
$ex_date = !empty($date) ? date_format($date, DATE_FORMAT_ICAL) . 'Z': '';
|
||||
$ex_date = !empty($date) ? date_format($date, DATE_FORMAT_ICAL) . 'Z' : '';
|
||||
if (!empty($ex_date)) {
|
||||
$ex_dates[] = $ex_date;
|
||||
}
|
||||
}
|
||||
if (!empty($ex_dates)) {
|
||||
sort($ex_dates);
|
||||
$RRULE .= chr(13) . chr(10) . 'RDATE:' . implode(',', $ex_dates);
|
||||
$rrule .= chr(13) . chr(10) . 'RDATE:' . implode(',', $ex_dates);
|
||||
}
|
||||
}
|
||||
elseif (!empty($form_values['RDATE'])) {
|
||||
$RRULE .= chr(13) . chr(10) . 'RDATE:' . $form_values['RDATE'];
|
||||
$rrule .= chr(13) . chr(10) . 'RDATE:' . $form_values['RDATE'];
|
||||
}
|
||||
|
||||
return $RRULE;
|
||||
return $rrule;
|
||||
}
|
||||
|
@@ -23,13 +23,14 @@ function date_sql_concat($array) {
|
||||
switch (Database::getConnection()->databaseType()) {
|
||||
case 'mysql':
|
||||
return "CONCAT(" . implode(",", $array) . ")";
|
||||
|
||||
case 'pgsql':
|
||||
return implode(" || ", $array);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to do cross-database NULL replacements
|
||||
* Helper function to do cross-database NULL replacements.
|
||||
*
|
||||
* @param array $array
|
||||
* An array of values to test for NULL values.
|
||||
@@ -61,6 +62,7 @@ function date_sql_pad($str, $size = 2, $pad = '0', $side = 'l') {
|
||||
switch ($side) {
|
||||
case 'r':
|
||||
return "RPAD($str, $size, '$pad')";
|
||||
|
||||
default:
|
||||
return "LPAD($str, $size, '$pad')";
|
||||
}
|
||||
@@ -69,6 +71,7 @@ function date_sql_pad($str, $size = 2, $pad = '0', $side = 'l') {
|
||||
/**
|
||||
* A class to manipulate date SQL.
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
class date_sql_handler {
|
||||
var $db_type = NULL;
|
||||
var $date_type = DATE_DATETIME;
|
||||
@@ -86,7 +89,7 @@ class date_sql_handler {
|
||||
/**
|
||||
* The object constuctor.
|
||||
*/
|
||||
function __construct($date_type = DATE_DATETIME, $local_timezone = NULL, $offset = '+00:00') {
|
||||
public function __construct($date_type = DATE_DATETIME, $local_timezone = NULL, $offset = '+00:00') {
|
||||
$this->db_type = Database::getConnection()->databaseType();
|
||||
$this->date_type = $date_type;
|
||||
$this->db_timezone = 'UTC';
|
||||
@@ -97,7 +100,7 @@ class date_sql_handler {
|
||||
/**
|
||||
* See if the db has timezone name support.
|
||||
*/
|
||||
function db_tz_support($reset = FALSE) {
|
||||
public function db_tz_support($reset = FALSE) {
|
||||
$has_support = variable_get('date_db_tz_support', -1);
|
||||
if ($has_support == -1 || $reset) {
|
||||
$has_support = FALSE;
|
||||
@@ -108,6 +111,7 @@ class date_sql_handler {
|
||||
$has_support = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'pgsql':
|
||||
$test = db_query("SELECT '2008-02-15 12:00:00 UTC' AT TIME ZONE 'US/Central'")->fetchField();
|
||||
if ($test == '2008-02-15 06:00:00') {
|
||||
@@ -136,7 +140,7 @@ class date_sql_handler {
|
||||
* set a fixed offset, not a timezone, so any value other than
|
||||
* '+00:00' should be used with caution.
|
||||
*/
|
||||
function set_db_timezone($offset = '+00:00') {
|
||||
public function set_db_timezone($offset = '+00:00') {
|
||||
static $already_set = FALSE;
|
||||
$type = Database::getConnection()->databaseType();
|
||||
if (!$already_set) {
|
||||
@@ -144,9 +148,11 @@ class date_sql_handler {
|
||||
case 'mysql':
|
||||
db_query("SET @@session.time_zone = '$offset'");
|
||||
break;
|
||||
|
||||
case 'pgsql':
|
||||
db_query("SET TIME ZONE INTERVAL '$offset' HOUR TO MINUTE");
|
||||
break;
|
||||
|
||||
case 'sqlsrv':
|
||||
// Issue #1201342, This is the wrong way to set the timezone, this
|
||||
// still needs to be fixed. In the meantime, commenting this out makes
|
||||
@@ -161,7 +167,7 @@ class date_sql_handler {
|
||||
/**
|
||||
* Return timezone offset for the date being processed.
|
||||
*/
|
||||
function get_offset($comp_date = NULL) {
|
||||
public function get_offset($comp_date = NULL) {
|
||||
if (!empty($this->db_timezone) && !empty($this->local_timezone)) {
|
||||
if ($this->db_timezone != $this->local_timezone) {
|
||||
if (empty($comp_date)) {
|
||||
@@ -199,47 +205,57 @@ class date_sql_handler {
|
||||
case DATE_UNIX:
|
||||
$field = "FROM_UNIXTIME($field)";
|
||||
break;
|
||||
|
||||
case DATE_ISO:
|
||||
$field = "STR_TO_DATE($field, '%Y-%m-%dT%T')";
|
||||
break;
|
||||
|
||||
case DATE_DATETIME:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'pgsql':
|
||||
switch ($this->date_type) {
|
||||
case DATE_UNIX:
|
||||
$field = "$field::ABSTIME";
|
||||
break;
|
||||
|
||||
case DATE_ISO:
|
||||
$field = "TO_DATE($field, 'FMYYYY-FMMM-FMDDTFMHH24:FMMI:FMSS')";
|
||||
break;
|
||||
|
||||
case DATE_DATETIME:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'sqlite':
|
||||
switch ($this->date_type) {
|
||||
case DATE_UNIX:
|
||||
$field = "datetime($field, 'unixepoch')";
|
||||
break;
|
||||
|
||||
case DATE_ISO:
|
||||
case DATE_DATETIME:
|
||||
$field = "datetime($field)";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'sqlsrv':
|
||||
switch ($this->date_type) {
|
||||
case DATE_UNIX:
|
||||
$field = "DATEADD(s, $field, '19700101 00:00:00:000')";
|
||||
break;
|
||||
|
||||
case DATE_ISO:
|
||||
case DATE_DATETIME:
|
||||
$field = "CAST($field as smalldatetime)";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
break;
|
||||
}
|
||||
// Adjust the resulting value to the right timezone/offset.
|
||||
@@ -254,10 +270,13 @@ class date_sql_handler {
|
||||
switch ($this->db_type) {
|
||||
case 'mysql':
|
||||
return "ADDTIME($field, SEC_TO_TIME($offset))";
|
||||
|
||||
case 'pgsql':
|
||||
return "($field + INTERVAL '$offset SECONDS')";;
|
||||
return "($field + INTERVAL '$offset SECONDS')";
|
||||
|
||||
case 'sqlite':
|
||||
return "datetime($field, '$offset seconds')";
|
||||
|
||||
case 'sqlsrv':
|
||||
return "DATEADD(second, $offset, $field)";
|
||||
}
|
||||
@@ -285,6 +304,7 @@ class date_sql_handler {
|
||||
switch ($direction) {
|
||||
case 'ADD':
|
||||
return "DATE_ADD($field, INTERVAL $count $granularity)";
|
||||
|
||||
case 'SUB':
|
||||
return "DATE_SUB($field, INTERVAL $count $granularity)";
|
||||
}
|
||||
@@ -294,6 +314,7 @@ class date_sql_handler {
|
||||
switch ($direction) {
|
||||
case 'ADD':
|
||||
return "($field + INTERVAL '$count $granularity')";
|
||||
|
||||
case 'SUB':
|
||||
return "($field - INTERVAL '$count $granularity')";
|
||||
}
|
||||
@@ -302,6 +323,7 @@ class date_sql_handler {
|
||||
switch ($direction) {
|
||||
case 'ADD':
|
||||
return "datetime($field, '+$count $granularity')";
|
||||
|
||||
case 'SUB':
|
||||
return "datetime($field, '-$count $granularity')";
|
||||
}
|
||||
@@ -352,6 +374,7 @@ class date_sql_handler {
|
||||
switch ($this->db_type) {
|
||||
case 'mysql':
|
||||
return "CONVERT_TZ($field, $db_zone, $localzone)";
|
||||
|
||||
case 'pgsql':
|
||||
// WITH TIME ZONE assumes the date is using the system
|
||||
// timezone, which should have been set to UTC.
|
||||
@@ -395,6 +418,7 @@ class date_sql_handler {
|
||||
);
|
||||
$format = strtr($format, $replace);
|
||||
return "DATE_FORMAT($field, '$format')";
|
||||
|
||||
case 'pgsql':
|
||||
$replace = array(
|
||||
'Y' => 'YYYY',
|
||||
@@ -421,6 +445,7 @@ class date_sql_handler {
|
||||
);
|
||||
$format = strtr($format, $replace);
|
||||
return "TO_CHAR($field, '$format')";
|
||||
|
||||
case 'sqlite':
|
||||
$replace = array(
|
||||
// 4 digit year number.
|
||||
@@ -460,6 +485,7 @@ class date_sql_handler {
|
||||
);
|
||||
$format = strtr($format, $replace);
|
||||
return "strftime('$format', $field)";
|
||||
|
||||
case 'sqlsrv':
|
||||
$replace = array(
|
||||
// 4 digit year number.
|
||||
@@ -528,18 +554,25 @@ class date_sql_handler {
|
||||
switch (strtoupper($extract_type)) {
|
||||
case 'DATE':
|
||||
return $field;
|
||||
|
||||
case 'YEAR':
|
||||
return "EXTRACT(YEAR FROM($field))";
|
||||
|
||||
case 'MONTH':
|
||||
return "EXTRACT(MONTH FROM($field))";
|
||||
|
||||
case 'DAY':
|
||||
return "EXTRACT(DAY FROM($field))";
|
||||
|
||||
case 'HOUR':
|
||||
return "EXTRACT(HOUR FROM($field))";
|
||||
|
||||
case 'MINUTE':
|
||||
return "EXTRACT(MINUTE FROM($field))";
|
||||
|
||||
case 'SECOND':
|
||||
return "EXTRACT(SECOND FROM($field))";
|
||||
|
||||
// ISO week number for date.
|
||||
case 'WEEK':
|
||||
switch ($this->db_type) {
|
||||
@@ -547,6 +580,7 @@ class date_sql_handler {
|
||||
// WEEK using arg 3 in MySQl should return the same value as
|
||||
// Postgres EXTRACT.
|
||||
return "WEEK($field, 3)";
|
||||
|
||||
case 'pgsql':
|
||||
return "EXTRACT(WEEK FROM($field))";
|
||||
}
|
||||
@@ -556,6 +590,7 @@ class date_sql_handler {
|
||||
// MySQL returns 1 for Sunday through 7 for Saturday, PHP date
|
||||
// functions and Postgres use 0 for Sunday and 6 for Saturday.
|
||||
return "INTEGER(DAYOFWEEK($field) - 1)";
|
||||
|
||||
case 'pgsql':
|
||||
return "EXTRACT(DOW FROM($field))";
|
||||
}
|
||||
@@ -563,6 +598,7 @@ class date_sql_handler {
|
||||
switch ($this->db_type) {
|
||||
case 'mysql':
|
||||
return "DAYOFYEAR($field)";
|
||||
|
||||
case 'pgsql':
|
||||
return "EXTRACT(DOY FROM($field))";
|
||||
}
|
||||
@@ -775,8 +811,7 @@ class date_sql_handler {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a complete datetime value out of an
|
||||
* incomplete array of selected values.
|
||||
* Create a complete date/time value out of an incomplete array of values.
|
||||
*
|
||||
* For example, array('year' => 2008, 'month' => 05) will fill
|
||||
* in the day, hour, minute and second with the earliest possible
|
||||
@@ -795,9 +830,11 @@ class date_sql_handler {
|
||||
case 'empty_min':
|
||||
case 'min':
|
||||
return date_format($dates[0], 'Y-m-d H:i:s');
|
||||
|
||||
case 'empty_max':
|
||||
case 'max':
|
||||
return date_format($dates[1], 'Y-m-d H:i:s');
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
@@ -840,7 +877,7 @@ class date_sql_handler {
|
||||
}
|
||||
|
||||
/**
|
||||
* A function to test the validity of various date parts
|
||||
* A function to test the validity of various date parts.
|
||||
*/
|
||||
function part_is_valid($value, $type) {
|
||||
if (!preg_match('/^[0-9]*$/', $value)) {
|
||||
@@ -856,16 +893,19 @@ class date_sql_handler {
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'month':
|
||||
if ($value < 0 || $value > 12) {
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'day':
|
||||
if ($value < 0 || $value > 31) {
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'week':
|
||||
if ($value < 0 || $value > 53) {
|
||||
return FALSE;
|
||||
@@ -890,26 +930,36 @@ class date_sql_handler {
|
||||
$formats['display'] = 'Y';
|
||||
$formats['sql'] = 'Y';
|
||||
break;
|
||||
|
||||
case 'month':
|
||||
$formats['display'] = date_limit_format($short, array('year', 'month'));
|
||||
$formats['sql'] = 'Y-m';
|
||||
break;
|
||||
|
||||
case 'day':
|
||||
$formats['display'] = date_limit_format($short, array('year', 'month', 'day'));
|
||||
$args = array('year', 'month', 'day');
|
||||
$formats['display'] = date_limit_format($short, $args);
|
||||
$formats['sql'] = 'Y-m-d';
|
||||
break;
|
||||
|
||||
case 'hour':
|
||||
$formats['display'] = date_limit_format($short, array('year', 'month', 'day', 'hour'));
|
||||
$args = array('year', 'month', 'day', 'hour');
|
||||
$formats['display'] = date_limit_format($short, $args);
|
||||
$formats['sql'] = 'Y-m-d\TH';
|
||||
break;
|
||||
|
||||
case 'minute':
|
||||
$formats['display'] = date_limit_format($short, array('year', 'month', 'day', 'hour', 'minute'));
|
||||
$args = array('year', 'month', 'day', 'hour', 'minute');
|
||||
$formats['display'] = date_limit_format($short, $args);
|
||||
$formats['sql'] = 'Y-m-d\TH:i';
|
||||
break;
|
||||
|
||||
case 'second':
|
||||
$formats['display'] = date_limit_format($short, array('year', 'month', 'day', 'hour', 'minute', 'second'));
|
||||
$args = array('year', 'month', 'day', 'hour', 'minute', 'second');
|
||||
$formats['display'] = date_limit_format($short, $args);
|
||||
$formats['sql'] = 'Y-m-d\TH:i:s';
|
||||
break;
|
||||
|
||||
case 'week':
|
||||
$formats['display'] = 'F j Y (W)';
|
||||
$formats['sql'] = 'Y-\WW';
|
||||
@@ -927,7 +977,7 @@ class date_sql_handler {
|
||||
'#type' => 'radios',
|
||||
'#default_value' => $granularity,
|
||||
'#options' => $this->date_parts(),
|
||||
);
|
||||
);
|
||||
return $form;
|
||||
}
|
||||
|
||||
@@ -1030,7 +1080,6 @@ class date_sql_handler {
|
||||
$direction = $results[1];
|
||||
$count = $results[2];
|
||||
$item = $results[3];
|
||||
|
||||
$replace = array(
|
||||
'now' => '@',
|
||||
'+' => 'P',
|
||||
@@ -1051,14 +1100,27 @@ class date_sql_handler {
|
||||
'second' => 'S',
|
||||
' ' => '',
|
||||
' ' => '',
|
||||
);
|
||||
$prefix = in_array($item, array('hours', 'hour', 'minutes', 'minute', 'seconds', 'second')) ? 'T' : '';
|
||||
return $prefix . strtr($direction, $replace) . $count . strtr($item, $replace);
|
||||
);
|
||||
$args = array('hours', 'hour', 'minutes', 'minute', 'seconds', 'second');
|
||||
if (in_array($item, $args)) {
|
||||
$prefix = 'T';
|
||||
}
|
||||
else {
|
||||
$prefix = '';
|
||||
}
|
||||
$return = $prefix;
|
||||
$return .= strtr($direction, $replace);
|
||||
$return .= $count;
|
||||
$return .= strtr($item, $replace);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the parsed values from the ISO argument to determine the
|
||||
* granularity of this period.
|
||||
* Granularity arguments handler.
|
||||
*
|
||||
* Use the parsed values from the ISO argument
|
||||
* to determine the granularity of this period.
|
||||
*/
|
||||
function arg_granularity($arg) {
|
||||
$granularity = '';
|
||||
@@ -1137,8 +1199,9 @@ class date_sql_handler {
|
||||
}
|
||||
return array($min_date, $max_date);
|
||||
}
|
||||
// Intercept invalid info and fall back to the current date.
|
||||
// Intercept invalid info and fall back to the current date.
|
||||
$now = date_now();
|
||||
return array($now, $now);
|
||||
}
|
||||
}
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
@@ -206,24 +206,31 @@ function theme_date_time_ago($variables) {
|
||||
$now = date_format(date_now(), DATE_FORMAT_UNIX);
|
||||
$start = date_format($start_date, DATE_FORMAT_UNIX);
|
||||
|
||||
// will be positive for a datetime in the past (ago), and negative for a datetime in the future (hence)
|
||||
// Will be positive for a datetime in the past (ago), and negative for a datetime in the future (hence).
|
||||
$time_diff = $now - $start;
|
||||
|
||||
// Uses the same options used by Views format_interval.
|
||||
switch ($display) {
|
||||
case 'raw time ago':
|
||||
return format_interval($time_diff, $interval);
|
||||
|
||||
case 'time ago':
|
||||
return t('%time ago', array('%time' => format_interval($time_diff, $interval)));
|
||||
|
||||
case 'raw time hence':
|
||||
return format_interval(-$time_diff, $interval);
|
||||
|
||||
case 'time hence':
|
||||
return t('%time hence', array('%time' => format_interval(-$time_diff, $interval)));
|
||||
|
||||
case 'raw time span':
|
||||
return ($time_diff < 0 ? '-' : '') . format_interval(abs($time_diff), $interval);
|
||||
|
||||
case 'inverse time span':
|
||||
return ($time_diff > 0 ? '-' : '') . format_interval(abs($time_diff), $interval);
|
||||
|
||||
case 'time span':
|
||||
return t(($time_diff < 0 ? '%time hence' : '%time ago'), array('%time' => format_interval(abs($time_diff), $interval)));
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -8,9 +8,9 @@ dependencies[] = context
|
||||
|
||||
files[] = date_context.module
|
||||
files[] = plugins/date_context_date_condition.inc
|
||||
; Information added by Drupal.org packaging script on 2014-07-29
|
||||
version = "7.x-2.8"
|
||||
; Information added by Drupal.org packaging script on 2015-09-08
|
||||
version = "7.x-2.9"
|
||||
core = "7.x"
|
||||
project = "date"
|
||||
datestamp = "1406653438"
|
||||
datestamp = "1441727353"
|
||||
|
||||
|
@@ -1,5 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Add an option to set/not set the context on forms vs views.
|
||||
*
|
||||
* @TODO
|
||||
*
|
||||
* Currently only implemented for nodes. Need to add $plugin->execute()
|
||||
@@ -8,8 +11,6 @@
|
||||
* Cache the date processing, perhaps cache the formatted, timezone-adjusted
|
||||
* date strings for each entity (would have to be cached differently for each
|
||||
* timezone, based on the tz_handling method for the date).
|
||||
*
|
||||
* Add an option to set/not set the context on forms vs views.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -22,7 +23,7 @@ function date_context_context_node_condition_alter($node, $op) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_context_plugins()
|
||||
* Implements hook_context_plugins().
|
||||
*/
|
||||
function date_context_context_plugins() {
|
||||
$plugins = array();
|
||||
@@ -38,7 +39,7 @@ function date_context_context_plugins() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_context_registry()
|
||||
* Implements hook_context_registry().
|
||||
*/
|
||||
function date_context_context_registry() {
|
||||
return array(
|
||||
@@ -51,4 +52,3 @@ function date_context_context_registry() {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -1,10 +1,20 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Context date condition plugin.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Expose term views/term forms by vocabulary as a context condition.
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
class date_context_date_condition extends context_condition_node {
|
||||
function condition_values() {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function condition_values() {
|
||||
$values = array();
|
||||
$fields = field_info_fields();
|
||||
foreach ($fields as $field_name => $field) {
|
||||
@@ -15,10 +25,13 @@ class date_context_date_condition extends context_condition_node {
|
||||
return $values;
|
||||
}
|
||||
|
||||
function options_form($context) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_form($context) {
|
||||
$defaults = $this->fetch_from_context($context, 'options');
|
||||
$options = array(
|
||||
'<' => t('Is less than'),
|
||||
'<' => t('Is less than'),
|
||||
'<=' => t('Is less than or equal to'),
|
||||
'>=' => t('Is greater than or equal to'),
|
||||
'>' => t('Is greater than'),
|
||||
@@ -27,6 +40,8 @@ class date_context_date_condition extends context_condition_node {
|
||||
'empty' => t('Is empty'),
|
||||
'not empty' => t('Is not Empty'),
|
||||
);
|
||||
$dependency_options = array('<', '<=', '>', '>=', '=', '!=');
|
||||
|
||||
$form['operation'] = array(
|
||||
'#title' => t('Operation'),
|
||||
'#type' => 'select',
|
||||
@@ -41,12 +56,15 @@ class date_context_date_condition extends context_condition_node {
|
||||
'#description' => t("The value the field should contain to meet the condition. This can either be an absolute date in ISO format (YYYY-MM-DDTHH:MM:SS) or a relative string like '12AM today'. Examples: 2011-12-31T00:00:00, now, now +1 day, 12AM today, Monday next week. <a href=\"@relative_format\">More examples of relative date formats in the PHP documentation</a>.", array('@relative_format' => 'http://www.php.net/manual/en/datetime.formats.relative.php')),
|
||||
'#default_value' => isset($defaults['value']) ? $defaults['value'] : '',
|
||||
'#process' => array('ctools_dependent_process'),
|
||||
'#dependency' => array('edit-conditions-plugins-date-context-date-condition-options-operation' => array('<', '<=', '>', '>=', '=', '!=')),
|
||||
'#dependency' => array('edit-conditions-plugins-date-context-date-condition-options-operation' => $dependency_options),
|
||||
);
|
||||
return $form;
|
||||
}
|
||||
|
||||
function execute($entity, $op) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function execute($entity, $op) {
|
||||
if (in_array($op, array('view', 'form'))) {
|
||||
foreach ($this->get_contexts() as $context) {
|
||||
$options = $this->fetch_from_context($context, 'options');
|
||||
@@ -91,32 +109,37 @@ class date_context_date_condition extends context_condition_node {
|
||||
str_replace('now', 'today', $options['value']);
|
||||
$date = date_create($options['value'], date_default_timezone_object());
|
||||
$compdate = $date->format(DATE_FORMAT_DATETIME);
|
||||
switch($options['operation']) {
|
||||
switch ($options['operation']) {
|
||||
case '=':
|
||||
if ($date2 >= $compdate && $date1 <= $compdate) {
|
||||
$this->condition_met($context, $field_name);
|
||||
}
|
||||
break;
|
||||
|
||||
case '>':
|
||||
if ($date1 > $compdate) {
|
||||
$this->condition_met($context, $field_name);
|
||||
}
|
||||
break;
|
||||
|
||||
case '>=':
|
||||
if ($date1 >= $compdate) {
|
||||
$this->condition_met($context, $field_name);
|
||||
}
|
||||
break;
|
||||
|
||||
case '<':
|
||||
if ($date2 < $compdate) {
|
||||
$this->condition_met($context, $field_name);
|
||||
}
|
||||
break;
|
||||
|
||||
case '<=':
|
||||
if ($date2 <= $compdate) {
|
||||
$this->condition_met($context, $field_name);
|
||||
}
|
||||
break;
|
||||
|
||||
case '!=':
|
||||
if ($date1 < $compdate || $date2 > $compdate) {
|
||||
$this->condition_met($context, $field_name);
|
||||
@@ -130,3 +153,4 @@ class date_context_date_condition extends context_condition_node {
|
||||
}
|
||||
}
|
||||
}
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
@@ -40,7 +40,6 @@
|
||||
*
|
||||
* - In the field's submission processing, the new date values, which are in
|
||||
* the local timezone, are converted back to their UTC values and stored.
|
||||
*
|
||||
*/
|
||||
function date_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $base) {
|
||||
|
||||
@@ -87,7 +86,7 @@ function date_field_widget_form(&$form, &$form_state, $field, $instance, $langco
|
||||
}
|
||||
|
||||
module_load_include('inc', 'date_api', 'date_api_elements');
|
||||
$timezone = date_get_timezone($field['settings']['tz_handling'], isset($items[0]['timezone']) ? $items[0]['timezone'] : date_default_timezone());
|
||||
$timezone = date_get_timezone($field['settings']['tz_handling'], isset($items[$delta]['timezone']) ? $items[$delta]['timezone'] : date_default_timezone());
|
||||
|
||||
// TODO see if there's a way to keep the timezone element from ever being
|
||||
// nested as array('timezone' => 'timezone' => value)). After struggling
|
||||
@@ -122,7 +121,13 @@ function date_field_widget_form(&$form, &$form_state, $field, $instance, $langco
|
||||
'#weight' => $instance['widget']['weight'] + 1,
|
||||
'#attributes' => array('class' => array('date-no-float')),
|
||||
'#date_label_position' => $instance['widget']['settings']['label_position'],
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
// Make changes if instance is set to be rendered as a regular field.
|
||||
if (!empty($instance['widget']['settings']['no_fieldset'])) {
|
||||
$element['#title'] = check_plain($instance['label']);
|
||||
$element['#theme_wrappers'] = ($field['cardinality'] == 1) ? array('date_form_element') : array();
|
||||
}
|
||||
|
||||
return $element;
|
||||
@@ -148,6 +153,7 @@ function date_local_date($item, $timezone, $field, $instance, $part = 'value') {
|
||||
// @TODO Figure out how to replace date_fuzzy_datetime() function.
|
||||
// Special case for ISO dates to create a valid date object for formatting.
|
||||
// Is this still needed?
|
||||
// @codingStandardsIgnoreStart
|
||||
/*
|
||||
if ($field['type'] == DATE_ISO) {
|
||||
$value = date_fuzzy_datetime($value);
|
||||
@@ -157,6 +163,7 @@ function date_local_date($item, $timezone, $field, $instance, $part = 'value') {
|
||||
$value = date_convert($value, $field['type'], DATE_DATETIME, $db_timezone);
|
||||
}
|
||||
*/
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
||||
$date = new DateObject($value, date_get_timezone_db($field['settings']['tz_handling']));
|
||||
$date->limitGranularity($field['settings']['granularity']);
|
||||
@@ -193,8 +200,7 @@ function date_default_value($field, $instance, $langcode) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for the date default value callback to set
|
||||
* either 'value' or 'value2' to its default value.
|
||||
* Helper function for the date default value callback to set either 'value' or 'value2' to its default value.
|
||||
*/
|
||||
function date_default_value_part($item, $field, $instance, $langcode, $part = 'value') {
|
||||
$timezone = date_get_timezone($field['settings']['tz_handling']);
|
||||
@@ -241,7 +247,6 @@ function date_default_value_part($item, $field, $instance, $langcode, $part = 'v
|
||||
* Process an individual date element.
|
||||
*/
|
||||
function date_combo_element_process($element, &$form_state, $form) {
|
||||
|
||||
if (date_hidden_element($element)) {
|
||||
// A hidden value for a new entity that had its end date set to blank
|
||||
// will not get processed later to populate the end date, so set it here.
|
||||
@@ -296,6 +301,7 @@ function date_combo_element_process($element, &$form_state, $form) {
|
||||
// Blank out the end date for optional end dates that match the start date,
|
||||
// except when this is a new node that has default values that should be honored.
|
||||
if (!$date_is_default && $field['settings']['todate'] != 'required'
|
||||
&& is_array($element['#default_value'])
|
||||
&& !empty($element['#default_value'][$to_field])
|
||||
&& $element['#default_value'][$to_field] == $element['#default_value'][$from_field]) {
|
||||
unset($element['#default_value'][$to_field]);
|
||||
@@ -329,9 +335,9 @@ function date_combo_element_process($element, &$form_state, $form) {
|
||||
'#date_increment' => $instance['widget']['settings']['increment'],
|
||||
'#date_year_range' => $instance['widget']['settings']['year_range'],
|
||||
'#date_label_position' => $instance['widget']['settings']['label_position'],
|
||||
);
|
||||
);
|
||||
|
||||
$description = !empty($element['#description']) ? t($element['#description']) : '';
|
||||
$description = !empty($element['#description']) ? t($element['#description']) : '';
|
||||
unset($element['#description']);
|
||||
|
||||
// Give this element the right type, using a Date API
|
||||
@@ -347,11 +353,13 @@ function date_combo_element_process($element, &$form_state, $form) {
|
||||
$element['#attached']['js'][] = drupal_get_path('module', 'date') . '/date.js';
|
||||
$element[$from_field]['#ajax'] = !empty($element['#ajax']) ? $element['#ajax'] : FALSE;
|
||||
break;
|
||||
|
||||
case 'date_popup':
|
||||
$element[$from_field]['#type'] = 'date_popup';
|
||||
$element[$from_field]['#theme_wrappers'] = array('date_popup');
|
||||
$element[$from_field]['#ajax'] = !empty($element['#ajax']) ? $element['#ajax'] : FALSE;
|
||||
break;
|
||||
|
||||
default:
|
||||
$element[$from_field]['#type'] = 'date_text';
|
||||
$element[$from_field]['#theme_wrappers'] = array('date_text');
|
||||
@@ -380,8 +388,11 @@ function date_combo_element_process($element, &$form_state, $form) {
|
||||
if ($field['settings']['todate'] == 'optional') {
|
||||
$element[$to_field]['#states'] = array(
|
||||
'visible' => array(
|
||||
'input[name="' . $show_id . '"]' => array('checked' => TRUE),
|
||||
));
|
||||
'input[name="' . $show_id . '"]' => array(
|
||||
'checked' => TRUE,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -404,16 +415,27 @@ function date_combo_element_process($element, &$form_state, $form) {
|
||||
$element[$from_field]['#date_title'] = t('@field_name', array('@field_name' => $instance['label']));
|
||||
}
|
||||
|
||||
// Make changes if instance is set to be rendered as a regular field.
|
||||
if (!empty($instance['widget']['settings']['no_fieldset'])) {
|
||||
unset($element[$from_field]['#description']);
|
||||
if (!empty($field['settings']['todate']) && isset($element['#description'])) {
|
||||
$element['#description'] .= '<span class="js-hide"> ' . t("Empty 'End date' values will use the 'Start date' values.") . '</span>';
|
||||
}
|
||||
}
|
||||
|
||||
$context = array(
|
||||
'field' => $field,
|
||||
'instance' => $instance,
|
||||
'form' => $form,
|
||||
'field' => $field,
|
||||
'instance' => $instance,
|
||||
'form' => $form,
|
||||
);
|
||||
drupal_alter('date_combo_process', $element, $form_state, $context);
|
||||
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty a date element.
|
||||
*/
|
||||
function date_element_empty($element, &$form_state) {
|
||||
$item = array();
|
||||
$item['value'] = NULL;
|
||||
@@ -428,6 +450,7 @@ function date_element_empty($element, &$form_state) {
|
||||
|
||||
/**
|
||||
* Validate and update a combo element.
|
||||
*
|
||||
* Don't try this if there were errors before reaching this point.
|
||||
*/
|
||||
function date_combo_validate($element, &$form_state) {
|
||||
@@ -444,6 +467,10 @@ function date_combo_validate($element, &$form_state) {
|
||||
$delta = $element['#delta'];
|
||||
$langcode = $element['#language'];
|
||||
|
||||
// Related issue: https://drupal.org/node/2279831.
|
||||
if (!is_array($element['#field_parents'])) {
|
||||
$element['#field_parents'] = array();
|
||||
}
|
||||
$form_values = drupal_array_get_nested_value($form_state['values'], $element['#field_parents']);
|
||||
$form_input = drupal_array_get_nested_value($form_state['input'], $element['#field_parents']);
|
||||
|
||||
|
@@ -4,9 +4,9 @@ core = 7.x
|
||||
package = Date/Time
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-07-29
|
||||
version = "7.x-2.8"
|
||||
; Information added by Drupal.org packaging script on 2015-09-08
|
||||
version = "7.x-2.9"
|
||||
core = "7.x"
|
||||
project = "date"
|
||||
datestamp = "1406653438"
|
||||
datestamp = "1441727353"
|
||||
|
||||
|
@@ -20,9 +20,9 @@ package = "Features"
|
||||
project = "date_migrate_example"
|
||||
version = "7.x-2.0"
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-07-29
|
||||
version = "7.x-2.8"
|
||||
; Information added by Drupal.org packaging script on 2015-09-08
|
||||
version = "7.x-2.9"
|
||||
core = "7.x"
|
||||
project = "date"
|
||||
datestamp = "1406653438"
|
||||
datestamp = "1441727353"
|
||||
|
||||
|
@@ -47,8 +47,8 @@ class DateExampleMigration extends XMLMigration {
|
||||
$xml_folder = drupal_get_path('module', 'date_migrate_example');
|
||||
$items_url = $xml_folder . '/date_migrate_example.xml';
|
||||
$item_xpath = '/source_data/item';
|
||||
$item_ID_xpath = 'id';
|
||||
$items_class = new MigrateItemsXML($items_url, $item_xpath, $item_ID_xpath);
|
||||
$item_id_xpath = 'id';
|
||||
$items_class = new MigrateItemsXML($items_url, $item_xpath, $item_id_xpath);
|
||||
$this->source = new MigrateSourceMultiItems($items_class, $fields);
|
||||
$this->destination = new MigrateDestinationNode('date_migrate_example');
|
||||
|
||||
@@ -78,7 +78,7 @@ class DateExampleMigration extends XMLMigration {
|
||||
$this->addFieldMapping('field_datestamp_range:to', 'datestamp_range_to');
|
||||
|
||||
// You can specify a timezone to be applied to all values going into the
|
||||
// field (Tokyo is UTC+9, no DST)
|
||||
// field (Tokyo is UTC+9, no DST).
|
||||
$this->addFieldMapping('field_datetime', 'datetime')
|
||||
->xpath('datetime');
|
||||
$this->addFieldMapping('field_datetime:timezone')
|
||||
@@ -107,25 +107,25 @@ class DateExampleMigration extends XMLMigration {
|
||||
// The date range field can have multiple values.
|
||||
$current_row->date_range_from = array();
|
||||
foreach ($current_row->xml->date_range as $range) {
|
||||
$current_row->date_range_from[] = (string)$range->from[0];
|
||||
$current_row->date_range_to[] = (string)$range->to[0];
|
||||
$current_row->date_range_from[] = (string) $range->from[0];
|
||||
$current_row->date_range_to[] = (string) $range->to[0];
|
||||
}
|
||||
|
||||
$current_row->datestamp_range_from =
|
||||
(string) $current_row->xml->datestamp_range->from[0];
|
||||
$current_row->datestamp_range_to =
|
||||
(string) $current_row->xml->datestamp_range->to[0];
|
||||
$current_row->datestamp_range_from
|
||||
= (string) $current_row->xml->datestamp_range->from[0];
|
||||
$current_row->datestamp_range_to
|
||||
= (string) $current_row->xml->datestamp_range->to[0];
|
||||
|
||||
$current_row->datetime_range_from =
|
||||
(string) $current_row->xml->datetime_range->from[0];
|
||||
$current_row->datetime_range_to =
|
||||
(string) $current_row->xml->datetime_range->to[0];
|
||||
$current_row->datetime_range_timezone =
|
||||
(string) $current_row->xml->datetime_range->timezone[0];
|
||||
$current_row->datetime_range_from
|
||||
= (string) $current_row->xml->datetime_range->from[0];
|
||||
$current_row->datetime_range_to
|
||||
= (string) $current_row->xml->datetime_range->to[0];
|
||||
$current_row->datetime_range_timezone
|
||||
= (string) $current_row->xml->datetime_range->timezone[0];
|
||||
|
||||
$current_row->date_repeat =
|
||||
(string) $current_row->xml->date_repeat->date[0];
|
||||
$current_row->date_repeat_rrule =
|
||||
(string) $current_row->xml->date_repeat->rule[0];
|
||||
$current_row->date_repeat
|
||||
= (string) $current_row->xml->date_repeat->date[0];
|
||||
$current_row->date_repeat_rrule
|
||||
= (string) $current_row->xml->date_repeat->rule[0];
|
||||
}
|
||||
}
|
||||
|
@@ -7,9 +7,9 @@ configure = admin/config/date/date_popup
|
||||
|
||||
stylesheets[all][] = themes/datepicker.1.7.css
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-07-29
|
||||
version = "7.x-2.8"
|
||||
; Information added by Drupal.org packaging script on 2015-09-08
|
||||
version = "7.x-2.9"
|
||||
core = "7.x"
|
||||
project = "date"
|
||||
datestamp = "1406653438"
|
||||
datestamp = "1441727353"
|
||||
|
||||
|
@@ -5,6 +5,7 @@
|
||||
* Install, update and uninstall functions for the Date Popup module.
|
||||
*/
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
/**
|
||||
* Implements hook_install().
|
||||
*/
|
||||
@@ -17,6 +18,7 @@ function date_popup_install() {
|
||||
function date_popup_uninstall() {
|
||||
|
||||
}
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
||||
/**
|
||||
* Implements hook_enable().
|
||||
|
@@ -1,62 +1,65 @@
|
||||
/**
|
||||
* Attaches the calendar behavior to all required fields
|
||||
*/
|
||||
(function ($) {
|
||||
Drupal.behaviors.date_popup = {
|
||||
attach: function (context) {
|
||||
for (var id in Drupal.settings.datePopup) {
|
||||
$('#'+ id).bind('focus', Drupal.settings.datePopup[id], function(e) {
|
||||
if (!$(this).hasClass('date-popup-init')) {
|
||||
var datePopup = e.data;
|
||||
// Explicitely filter the methods we accept.
|
||||
switch (datePopup.func) {
|
||||
case 'datepicker':
|
||||
$(this)
|
||||
.datepicker(datePopup.settings)
|
||||
.addClass('date-popup-init')
|
||||
$(this).click(function(){
|
||||
$(this).focus();
|
||||
});
|
||||
break;
|
||||
(function($) {
|
||||
function makeFocusHandler(e) {
|
||||
if (!$(this).hasClass('date-popup-init')) {
|
||||
var datePopup = e.data;
|
||||
// Explicitely filter the methods we accept.
|
||||
switch (datePopup.func) {
|
||||
case 'datepicker':
|
||||
$(this)
|
||||
.datepicker(datePopup.settings)
|
||||
.addClass('date-popup-init');
|
||||
$(this).click(function(){
|
||||
$(this).focus();
|
||||
});
|
||||
break;
|
||||
|
||||
case 'timeEntry':
|
||||
$(this)
|
||||
.timeEntry(datePopup.settings)
|
||||
.addClass('date-popup-init')
|
||||
$(this).click(function(){
|
||||
$(this).focus();
|
||||
});
|
||||
break;
|
||||
case 'timepicker':
|
||||
// Translate the PHP date format into the style the timepicker uses.
|
||||
datePopup.settings.timeFormat = datePopup.settings.timeFormat
|
||||
// 12-hour, leading zero,
|
||||
.replace('h', 'hh')
|
||||
// 12-hour, no leading zero.
|
||||
.replace('g', 'h')
|
||||
// 24-hour, leading zero.
|
||||
.replace('H', 'HH')
|
||||
// 24-hour, no leading zero.
|
||||
.replace('G', 'H')
|
||||
// AM/PM.
|
||||
.replace('A', 'p')
|
||||
// Minutes with leading zero.
|
||||
.replace('i', 'mm')
|
||||
// Seconds with leading zero.
|
||||
.replace('s', 'ss');
|
||||
case 'timeEntry':
|
||||
$(this)
|
||||
.timeEntry(datePopup.settings)
|
||||
.addClass('date-popup-init');
|
||||
$(this).click(function(){
|
||||
$(this).focus();
|
||||
});
|
||||
break;
|
||||
|
||||
datePopup.settings.startTime = new Date(datePopup.settings.startTime);
|
||||
$(this)
|
||||
.timepicker(datePopup.settings)
|
||||
.addClass('date-popup-init');
|
||||
$(this).click(function(){
|
||||
$(this).focus();
|
||||
});
|
||||
break;
|
||||
}
|
||||
case 'timepicker':
|
||||
// Translate the PHP date format into the style the timepicker uses.
|
||||
datePopup.settings.timeFormat = datePopup.settings.timeFormat
|
||||
// 12-hour, leading zero,
|
||||
.replace('h', 'hh')
|
||||
// 12-hour, no leading zero.
|
||||
.replace('g', 'h')
|
||||
// 24-hour, leading zero.
|
||||
.replace('H', 'HH')
|
||||
// 24-hour, no leading zero.
|
||||
.replace('G', 'H')
|
||||
// AM/PM.
|
||||
.replace('A', 'p')
|
||||
// Minutes with leading zero.
|
||||
.replace('i', 'mm')
|
||||
// Seconds with leading zero.
|
||||
.replace('s', 'ss');
|
||||
|
||||
datePopup.settings.startTime = new Date(datePopup.settings.startTime);
|
||||
$(this)
|
||||
.timepicker(datePopup.settings)
|
||||
.addClass('date-popup-init');
|
||||
$(this).click(function(){
|
||||
$(this).focus();
|
||||
});
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.behaviors.date_popup = {
|
||||
attach: function (context) {
|
||||
for (var id in Drupal.settings.datePopup) {
|
||||
$('#'+ id).bind('focus', Drupal.settings.datePopup[id], makeFocusHandler);
|
||||
}
|
||||
}
|
||||
};
|
||||
})(jQuery);
|
||||
|
@@ -16,7 +16,6 @@
|
||||
* If no time elements are included in the format string, only the date
|
||||
* textfield will be created. If no date elements are included in the format
|
||||
* string, only the time textfield, will be created.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -44,7 +43,7 @@ function date_popup_add() {
|
||||
/**
|
||||
* Get the location of the Willington Vega timepicker library.
|
||||
*
|
||||
* @return
|
||||
* @return string
|
||||
* The location of the library, or FALSE if the library isn't installed.
|
||||
*/
|
||||
function date_popup_get_wvega_path() {
|
||||
@@ -94,9 +93,11 @@ function date_popup_library() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a unique CSS id name and output a single inline JS block for
|
||||
* each startup function to call and settings array to pass it. This
|
||||
* used to create a unique CSS class for each unique combination of
|
||||
* Create a unique CSS id name and output a single inline JS block.
|
||||
*
|
||||
* For each startup function to call and settings array to pass it.
|
||||
*
|
||||
* This used to create a unique CSS class for each unique combination of
|
||||
* function and settings, but using classes requires a DOM traversal
|
||||
* and is much slower than an id lookup. The new approach returns to
|
||||
* requiring a duplicate copy of the settings/code for every element
|
||||
@@ -104,17 +105,20 @@ function date_popup_library() {
|
||||
* putting the ids for each unique function/settings combo into
|
||||
* Drupal.settings and searching for each listed id.
|
||||
*
|
||||
* @param $pfx
|
||||
* @param string $id
|
||||
* The CSS class prefix to search the DOM for.
|
||||
* TODO : unused ?
|
||||
* @param $func
|
||||
* The jQuery function to invoke on each DOM element containing the
|
||||
* returned CSS class.
|
||||
* @param $settings
|
||||
*
|
||||
* @param string $func
|
||||
* The jQuery function to invoke on each DOM element
|
||||
* containing the returned CSS class.
|
||||
*
|
||||
* @param array $settings
|
||||
* The settings array to pass to the jQuery function.
|
||||
*
|
||||
* @returns
|
||||
* The CSS id to assign to the element that should have
|
||||
* $func($settings) invoked on it.
|
||||
* The CSS id to assign to the element that should have $func($settings)
|
||||
* invoked on it.
|
||||
*/
|
||||
function date_popup_js_settings_id($id, $func, $settings) {
|
||||
static $js_added = FALSE;
|
||||
@@ -123,14 +127,15 @@ function date_popup_js_settings_id($id, $func, $settings) {
|
||||
// Make sure popup date selector grid is in correct year.
|
||||
if (!empty($settings['yearRange'])) {
|
||||
$parts = explode(':', $settings['yearRange']);
|
||||
// Set the default date to 0 or the lowest bound if the date ranges do not include the current year
|
||||
// Necessary for the datepicker to render and select dates correctly
|
||||
$defaultDate = ($parts[0] > 0 || 0 > $parts[1]) ? $parts[0] : 0;
|
||||
$settings += array('defaultDate' => (string) $defaultDate . 'y');
|
||||
// Set the default date to 0 or the lowest bound if
|
||||
// the date ranges do not include the current year.
|
||||
// Necessary for the datepicker to render and select dates correctly.
|
||||
$default_date = ($parts[0] > 0 || 0 > $parts[1]) ? $parts[0] : 0;
|
||||
$settings += array('defaultDate' => (string) $default_date . 'y');
|
||||
}
|
||||
|
||||
if (!$js_added) {
|
||||
drupal_add_js(drupal_get_path('module', 'date_popup') .'/date_popup.js');
|
||||
drupal_add_js(drupal_get_path('module', 'date_popup') . '/date_popup.js');
|
||||
$js_added = TRUE;
|
||||
}
|
||||
|
||||
@@ -140,29 +145,35 @@ function date_popup_js_settings_id($id, $func, $settings) {
|
||||
$id_count[$id] = 0;
|
||||
}
|
||||
|
||||
// It looks like we need the additional id_count for this to
|
||||
// work correctly when there are multiple values.
|
||||
// $return_id = "$id-$func-popup";
|
||||
$return_id = "$id-$func-popup-". $id_count[$id]++;
|
||||
// It looks like we need the additional id_count for this to
|
||||
// work correctly when there are multiple values.
|
||||
// $return_id = "$id-$func-popup";
|
||||
$return_id = "$id-$func-popup-" . $id_count[$id]++;
|
||||
$js_settings['datePopup'][$return_id] = array(
|
||||
'func' => $func,
|
||||
'settings' => $settings
|
||||
'settings' => $settings,
|
||||
);
|
||||
drupal_add_js($js_settings, 'setting');
|
||||
return $return_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Date popup theme handler.
|
||||
*/
|
||||
function date_popup_theme() {
|
||||
return array(
|
||||
'date_popup' => array('render element' => 'element'),
|
||||
);
|
||||
'date_popup' => array(
|
||||
'render element' => 'element',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_element_info().
|
||||
*
|
||||
* Set the #type to date_popup and fill the element #default_value with
|
||||
* a date adjusted to the proper local timezone in datetime format (YYYY-MM-DD HH:MM:SS).
|
||||
* a date adjusted to the proper local timezone in datetime format
|
||||
* (YYYY-MM-DD HH:MM:SS).
|
||||
*
|
||||
* The element will create two textfields, one for the date and one for the
|
||||
* time. The date textfield will include a jQuery popup calendar date picker,
|
||||
@@ -218,20 +229,32 @@ function date_popup_element_info() {
|
||||
return $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Date popup date granularity.
|
||||
*/
|
||||
function date_popup_date_granularity($element) {
|
||||
$granularity = date_format_order($element['#date_format']);
|
||||
return array_intersect($granularity, array('month', 'day', 'year'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Date popup time granularity.
|
||||
*/
|
||||
function date_popup_time_granularity($element) {
|
||||
$granularity = date_format_order($element['#date_format']);
|
||||
return array_intersect($granularity, array('hour', 'minute', 'second'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Date popup date format.
|
||||
*/
|
||||
function date_popup_date_format($element) {
|
||||
return (date_limit_format($element['#date_format'], date_popup_date_granularity($element)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Date popup time format.
|
||||
*/
|
||||
function date_popup_time_format($element) {
|
||||
return date_popup_format_to_popup_time(date_limit_format($element['#date_format'], date_popup_time_granularity($element)), $element['#timepicker']);
|
||||
}
|
||||
@@ -239,6 +262,7 @@ function date_popup_time_format($element) {
|
||||
/**
|
||||
* Element value callback for date_popup element.
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
function date_popup_element_value_callback($element, $input = FALSE, &$form_state) {
|
||||
$granularity = date_format_order($element['#date_format']);
|
||||
$has_time = date_has_time($granularity);
|
||||
@@ -266,9 +290,11 @@ function date_popup_element_value_callback($element, $input = FALSE, &$form_stat
|
||||
return $return;
|
||||
|
||||
}
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
||||
/**
|
||||
* Javascript popup element processing.
|
||||
*
|
||||
* Add popup attributes to $element.
|
||||
*/
|
||||
function date_popup_element_process($element, &$form_state, $form) {
|
||||
@@ -284,7 +310,9 @@ function date_popup_element_process($element, &$form_state, $form) {
|
||||
|
||||
if (!empty($element['#ajax'])) {
|
||||
$element['#ajax'] += array(
|
||||
'trigger_as' => array('name' =>$element['#name']),
|
||||
'trigger_as' => array(
|
||||
'name' => $element['#name'],
|
||||
),
|
||||
'event' => 'change',
|
||||
);
|
||||
}
|
||||
@@ -292,6 +320,18 @@ function date_popup_element_process($element, &$form_state, $form) {
|
||||
$element['date'] = date_popup_process_date_part($element);
|
||||
$element['time'] = date_popup_process_time_part($element);
|
||||
|
||||
// Make changes if instance is set to be rendered as a regular field.
|
||||
if (!empty($element['#instance']['widget']['settings']['no_fieldset']) && $element['#field']['cardinality'] == 1) {
|
||||
if (!empty($element['date']) && empty($element['time'])) {
|
||||
$element['date']['#title'] = check_plain($element['#instance']['label']);
|
||||
$element['date']['#required'] = $element['#required'];
|
||||
}
|
||||
elseif (empty($element['date']) && !empty($element['time'])) {
|
||||
$element['time']['#title'] = check_plain($element['#instance']['label']);
|
||||
$element['time']['#required'] = $element['#required'];
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($element['#element_validate'])) {
|
||||
array_push($element['#element_validate'], 'date_popup_validate');
|
||||
}
|
||||
@@ -300,7 +340,7 @@ function date_popup_element_process($element, &$form_state, $form) {
|
||||
}
|
||||
|
||||
$context = array(
|
||||
'form' => $form,
|
||||
'form' => $form,
|
||||
);
|
||||
drupal_alter('date_popup_process', $element, $form_state, $context);
|
||||
|
||||
@@ -313,13 +353,22 @@ function date_popup_element_process($element, &$form_state, $form) {
|
||||
function date_popup_process_date_part(&$element) {
|
||||
$granularity = date_format_order($element['#date_format']);
|
||||
$date_granularity = date_popup_date_granularity($element);
|
||||
if (empty($date_granularity)) return array();
|
||||
if (empty($date_granularity)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
// The datepicker can't handle zero or negative values like 0:+1
|
||||
// even though the Date API can handle them, so rework the value
|
||||
// we pass to the datepicker to use defaults it can accept (such as +0:+1)
|
||||
// date_range_string() adds the necessary +/- signs to the range string.
|
||||
$this_year = date_format(date_now(), 'Y');
|
||||
// When used as a Views exposed filter widget, $element['#value'] contains an array instead an string.
|
||||
// Fill the 'date' string in this case.
|
||||
$mock = NULL;
|
||||
$callback_values = date_popup_element_value_callback($element, FALSE, $mock);
|
||||
if (!isset($element['#value']['date']) && isset($callback_values['date'])) {
|
||||
$element['#value']['date'] = $callback_values['date'];
|
||||
}
|
||||
$date = '';
|
||||
if (!empty($element['#value']['date'])) {
|
||||
$date = new DateObject($element['#value']['date'], $element['#date_timezone'], date_popup_date_format($element));
|
||||
@@ -336,8 +385,9 @@ function date_popup_process_date_part(&$element) {
|
||||
'closeAtTop' => FALSE,
|
||||
'speed' => 'immediate',
|
||||
'firstDay' => intval(variable_get('date_first_day', 0)),
|
||||
//'buttonImage' => base_path() . drupal_get_path('module', 'date_api') ."/images/calendar.png",
|
||||
//'buttonImageOnly' => TRUE,
|
||||
// 'buttonImage' => base_path()
|
||||
// . drupal_get_path('module', 'date_api') ."/images/calendar.png",
|
||||
// 'buttonImageOnly' => TRUE,
|
||||
'dateFormat' => date_popup_format_to_popup(date_popup_date_format($element), 'datepicker'),
|
||||
'yearRange' => $year_range,
|
||||
// Custom setting, will be expanded in Drupal.behaviors.date_popup()
|
||||
@@ -347,26 +397,33 @@ function date_popup_process_date_part(&$element) {
|
||||
// Create a unique id for each set of custom settings.
|
||||
$id = date_popup_js_settings_id($element['#id'], 'datepicker', $settings);
|
||||
|
||||
// Manually build this element and set the value - this will prevent corrupting
|
||||
// the parent value
|
||||
// Manually build this element and set the value -
|
||||
// this will prevent corrupting the parent value.
|
||||
$parents = array_merge($element['#parents'], array('date'));
|
||||
$sub_element = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => theme('date_part_label_date', array('part_type' => 'date', 'element' => $element)),
|
||||
'#title_display' => $element['#date_label_position'] == 'above' ? 'before' : 'invisible',
|
||||
'#default_value' => $element['#value']['date'],
|
||||
'#default_value' => date_format_date($date, 'custom', date_popup_date_format($element)),
|
||||
'#id' => $id,
|
||||
'#input' => FALSE,
|
||||
'#size' => !empty($element['#size']) ? $element['#size'] : 20,
|
||||
'#maxlength' => !empty($element['#maxlength']) ? $element['#maxlength'] : 30,
|
||||
'#attributes' => $element['#attributes'],
|
||||
'#parents' => $parents,
|
||||
'#name' => array_shift($parents) . '['. implode('][', $parents) .']',
|
||||
'#name' => array_shift($parents) . '[' . implode('][', $parents) . ']',
|
||||
'#ajax' => !empty($element['#ajax']) ? $element['#ajax'] : FALSE,
|
||||
);
|
||||
$sub_element['#value'] = $sub_element['#default_value'];
|
||||
// TODO, figure out exactly when we want this description. In many places it is not desired.
|
||||
$sub_element['#description'] = ' '. t('E.g., @date', array('@date' => date_format_date(date_example_date(), 'custom', date_popup_date_format($element))));
|
||||
// TODO, figure out exactly when we want this description.
|
||||
// In many places it is not desired.
|
||||
$sub_element['#description'] = ' ' . t('E.g., @date', array(
|
||||
'@date' => date_format_date(
|
||||
date_example_date(),
|
||||
'custom',
|
||||
date_popup_date_format($element)
|
||||
),
|
||||
));
|
||||
|
||||
return $sub_element;
|
||||
}
|
||||
@@ -377,7 +434,17 @@ function date_popup_process_date_part(&$element) {
|
||||
function date_popup_process_time_part(&$element) {
|
||||
$granularity = date_format_order($element['#date_format']);
|
||||
$has_time = date_has_time($granularity);
|
||||
if (empty($has_time)) return array();
|
||||
if (empty($has_time)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
// When used as a Views exposed filter widget, $element['#value'] contains an array instead an string.
|
||||
// Fill the 'time' string in this case.
|
||||
$mock = NULL;
|
||||
$callback_values = date_popup_element_value_callback($element, FALSE, $mock);
|
||||
if (!isset($element['#value']['time']) && isset($callback_values['time'])) {
|
||||
$element['#value']['time'] = $callback_values['time'];
|
||||
}
|
||||
|
||||
switch ($element['#timepicker']) {
|
||||
case 'default':
|
||||
@@ -385,10 +452,14 @@ function date_popup_process_time_part(&$element) {
|
||||
$settings = array(
|
||||
'show24Hours' => strpos($element['#date_format'], 'H') !== FALSE ? TRUE : FALSE,
|
||||
'showSeconds' => (in_array('second', $granularity) ? TRUE : FALSE),
|
||||
'timeSteps' => array(1, intval($element['#date_increment']), (in_array('second', $granularity) ? $element['#date_increment'] : 0)),
|
||||
'timeSteps' => array(
|
||||
1,
|
||||
intval($element['#date_increment']),
|
||||
(in_array('second', $granularity) ? $element['#date_increment'] : 0),
|
||||
),
|
||||
'spinnerImage' => '',
|
||||
'fromTo' => isset($fromto),
|
||||
);
|
||||
);
|
||||
if (strpos($element['#date_format'], 'a') !== FALSE) {
|
||||
// Then we are using lowercase am/pm.
|
||||
$settings['ampmNames'] = array('am', 'pm');
|
||||
@@ -397,9 +468,11 @@ function date_popup_process_time_part(&$element) {
|
||||
$settings['ampmPrefix'] = ' ';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'wvega':
|
||||
$func = 'timepicker';
|
||||
$time_granularity = array_intersect($granularity, array('hour', 'minute', 'second'));
|
||||
$grans = array('hour', 'minute', 'second');
|
||||
$time_granularity = array_intersect($granularity, $grans);
|
||||
$format = date_popup_format_to_popup_time(date_limit_format($element['#date_format'], $time_granularity), 'wvega');
|
||||
// The first value in the dropdown list should be the same as the element
|
||||
// default_value, but it needs to be in JS format (i.e. milliseconds since
|
||||
@@ -414,6 +487,7 @@ function date_popup_process_time_part(&$element) {
|
||||
'scrollbar' => TRUE,
|
||||
);
|
||||
break;
|
||||
|
||||
default:
|
||||
$func = '';
|
||||
$settings = array();
|
||||
@@ -423,8 +497,8 @@ function date_popup_process_time_part(&$element) {
|
||||
// Create a unique id for each set of custom settings.
|
||||
$id = date_popup_js_settings_id($element['#id'], $func, $settings);
|
||||
|
||||
// Manually build this element and set the value - this will prevent corrupting
|
||||
// the parent value
|
||||
// Manually build this element and set the value -
|
||||
// this will prevent corrupting the parent value.
|
||||
$parents = array_merge($element['#parents'], array('time'));
|
||||
$sub_element = array(
|
||||
'#type' => 'textfield',
|
||||
@@ -436,16 +510,22 @@ function date_popup_process_time_part(&$element) {
|
||||
'#maxlength' => 10,
|
||||
'#attributes' => $element['#attributes'],
|
||||
'#parents' => $parents,
|
||||
'#name' => array_shift($parents) . '['. implode('][', $parents) .']',
|
||||
'#name' => array_shift($parents) . '[' . implode('][', $parents) . ']',
|
||||
'#ajax' => !empty($element['#ajax']) ? $element['#ajax'] : FALSE,
|
||||
);
|
||||
|
||||
$sub_element['#value'] = $sub_element['#default_value'];
|
||||
|
||||
// TODO, figure out exactly when we want this description. In many places it is not desired.
|
||||
// TODO, figure out exactly when we want this description.
|
||||
// In many places it is not desired.
|
||||
$example_date = date_now();
|
||||
date_increment_round($example_date, $element['#date_increment']);
|
||||
$sub_element['#description'] = t('E.g., @date', array('@date' => date_format_date($example_date, 'custom', date_popup_time_format($element))));
|
||||
$sub_element['#description'] = t('E.g., @date', array(
|
||||
'@date' => date_format_date(
|
||||
$example_date,
|
||||
'custom',
|
||||
date_popup_time_format($element)
|
||||
)));
|
||||
|
||||
return ($sub_element);
|
||||
}
|
||||
@@ -456,7 +536,6 @@ function date_popup_process_time_part(&$element) {
|
||||
* When used as a Views widget, the validation step always gets triggered,
|
||||
* even with no form submission. Before form submission $element['#value']
|
||||
* contains a string, after submission it contains an array.
|
||||
*
|
||||
*/
|
||||
function date_popup_validate($element, &$form_state) {
|
||||
|
||||
@@ -473,6 +552,11 @@ function date_popup_validate($element, &$form_state) {
|
||||
|
||||
$input_exists = NULL;
|
||||
$input = drupal_array_get_nested_value($form_state['values'], $element['#parents'], $input_exists);
|
||||
// If the date is a string, it is not considered valid and can cause problems
|
||||
// later on, so just exit out now.
|
||||
if (is_string($input)) {
|
||||
return;
|
||||
}
|
||||
|
||||
drupal_alter('date_popup_pre_validate', $element, $form_state, $input);
|
||||
|
||||
@@ -481,9 +565,15 @@ function date_popup_validate($element, &$form_state) {
|
||||
$time_granularity = date_popup_time_granularity($element);
|
||||
$has_time = date_has_time($granularity);
|
||||
|
||||
$label = !empty($element['#date_title']) ? $element['#date_title'] : (!empty($element['#title']) ? $element['#title'] : '');
|
||||
$label = t($label);
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
$label = '';
|
||||
if (!empty($element['#date_title'])) {
|
||||
$label = t($element['#date_title']);
|
||||
}
|
||||
elseif (!empty($element['#title'])) {
|
||||
$label = t($element['#title']);
|
||||
}
|
||||
// @codingStandardsIgnoreEnd
|
||||
$date = date_popup_input_date($element, $input);
|
||||
|
||||
// If the date has errors, display them.
|
||||
@@ -517,7 +607,7 @@ function date_popup_validate($element, &$form_state) {
|
||||
/**
|
||||
* Helper function for extracting a date value out of user input.
|
||||
*
|
||||
* @param autocomplete
|
||||
* @param bool $auto_complete
|
||||
* Should we add a time value to complete the date if there is no time?
|
||||
* Useful anytime the time value is optional.
|
||||
*/
|
||||
@@ -532,8 +622,8 @@ function date_popup_input_date($element, $input, $auto_complete = FALSE) {
|
||||
|
||||
$format = date_popup_date_format($element);
|
||||
$format .= $has_time ? ' ' . date_popup_time_format($element) : '';
|
||||
$datetime = $input['date'];
|
||||
$datetime .= $has_time ? ' ' . $input['time'] : '';
|
||||
$datetime = trim($input['date']);
|
||||
$datetime .= $has_time ? ' ' . trim($input['time']) : '';
|
||||
$date = new DateObject($datetime, $element['#date_timezone'], $format);
|
||||
if (is_object($date)) {
|
||||
$date->limitGranularity($granularity);
|
||||
@@ -552,7 +642,7 @@ function date_popup_time_formats($with_seconds = FALSE) {
|
||||
return array(
|
||||
'H:i:s',
|
||||
'h:i:sA',
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -561,8 +651,17 @@ function date_popup_time_formats($with_seconds = FALSE) {
|
||||
* TODO Remove any formats not supported by the widget, if any.
|
||||
*/
|
||||
function date_popup_formats() {
|
||||
$formats = str_replace('i', 'i:s', array_keys(system_get_date_formats('short')));
|
||||
// Load short date formats.
|
||||
$formats = system_get_date_formats('short');
|
||||
|
||||
// Load custom date formats.
|
||||
if ($formats_custom = system_get_date_formats('custom')) {
|
||||
$formats = array_merge($formats, $formats_custom);
|
||||
}
|
||||
|
||||
$formats = str_replace('i', 'i:s', array_keys($formats));
|
||||
$formats = drupal_map_assoc($formats);
|
||||
|
||||
return $formats;
|
||||
}
|
||||
|
||||
@@ -570,7 +669,8 @@ function date_popup_formats() {
|
||||
* Recreate a date format string so it has the values popup expects.
|
||||
*
|
||||
* @param string $format
|
||||
* a normal date format string, like Y-m-d
|
||||
* A normal date format string, like Y-m-d
|
||||
*
|
||||
* @return string
|
||||
* A format string in popup format, like YMD-, for the
|
||||
* earlier 'calendar' version, or m/d/Y for the later 'datepicker'
|
||||
@@ -588,15 +688,34 @@ function date_popup_format_to_popup($format) {
|
||||
* Recreate a time format string so it has the values popup expects.
|
||||
*
|
||||
* @param string $format
|
||||
* a normal time format string, like h:i (a)
|
||||
* A normal time format string, like h:i (a)
|
||||
*
|
||||
* @return string
|
||||
* a format string that the popup can accept like h:i a
|
||||
* A format string that the popup can accept like h:i a
|
||||
*/
|
||||
function date_popup_format_to_popup_time($format, $timepicker = NULL) {
|
||||
if (empty($format)) {
|
||||
$format = 'H:i';
|
||||
}
|
||||
$format = str_replace(array('/', '-', ' .', ',', 'F', 'M', 'l', 'z', 'w', 'W', 'd', 'j', 'm', 'n', 'y', 'Y'), '', $format);
|
||||
$symbols = array(
|
||||
'/',
|
||||
'-',
|
||||
' .',
|
||||
',',
|
||||
'F',
|
||||
'M',
|
||||
'l',
|
||||
'z',
|
||||
'w',
|
||||
'W',
|
||||
'd',
|
||||
'j',
|
||||
'm',
|
||||
'n',
|
||||
'y',
|
||||
'Y',
|
||||
);
|
||||
$format = str_replace($symbols, '', $format);
|
||||
$format = strtr($format, date_popup_timepicker_format_replacements($timepicker));
|
||||
return $format;
|
||||
}
|
||||
@@ -605,9 +724,10 @@ function date_popup_format_to_popup_time($format, $timepicker = NULL) {
|
||||
* Reconstruct popup format string into normal format string.
|
||||
*
|
||||
* @param string $format
|
||||
* a string in popup format, like YMD-
|
||||
* A string in popup format, like YMD-
|
||||
*
|
||||
* @return string
|
||||
* a normal date format string, like Y-m-d
|
||||
* A normal date format string, like Y-m-d
|
||||
*/
|
||||
function date_popup_popup_to_format($format) {
|
||||
$replace = array_flip(date_popup_datepicker_format_replacements());
|
||||
@@ -621,22 +741,21 @@ function date_popup_popup_to_format($format) {
|
||||
* This function returns a map of format replacements required to change any
|
||||
* input format into one that the given timepicker can support.
|
||||
*
|
||||
* @param $timepicker
|
||||
* @param string $timepicker
|
||||
* The time entry plugin being used: either 'wvega' or 'default'.
|
||||
* @return
|
||||
*
|
||||
* @return array
|
||||
* A map of replacements.
|
||||
*/
|
||||
function date_popup_timepicker_format_replacements($timepicker = 'default') {
|
||||
switch ($timepicker) {
|
||||
case 'wvega':
|
||||
return array(
|
||||
'a' => 'A', // The wvega timepicker only supports uppercase AM/PM.
|
||||
);
|
||||
// The wvega timepicker only supports uppercase AM/PM.
|
||||
return array('a' => 'A');
|
||||
|
||||
default:
|
||||
return array(
|
||||
'G' => 'H', // The default timeEntry plugin requires leading zeros.
|
||||
'g' => 'h',
|
||||
);
|
||||
// The default timeEntry plugin requires leading zeros.
|
||||
return array('G' => 'H', 'g' => 'h');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -645,16 +764,16 @@ function date_popup_timepicker_format_replacements($timepicker = 'default') {
|
||||
*/
|
||||
function date_popup_datepicker_format_replacements() {
|
||||
return array(
|
||||
'd' => 'dd',
|
||||
'j' => 'd',
|
||||
'l' => 'DD',
|
||||
'D' => 'D',
|
||||
'm' => 'mm',
|
||||
'n' => 'm',
|
||||
'F' => 'MM',
|
||||
'M' => 'M',
|
||||
'Y' => 'yy',
|
||||
'y' => 'y',
|
||||
'd' => 'dd',
|
||||
'j' => 'd',
|
||||
'l' => 'DD',
|
||||
'D' => 'D',
|
||||
'm' => 'mm',
|
||||
'n' => 'm',
|
||||
'F' => 'MM',
|
||||
'M' => 'M',
|
||||
'Y' => 'yy',
|
||||
'y' => 'y',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -667,16 +786,18 @@ function theme_date_popup($vars) {
|
||||
$element = $vars['element'];
|
||||
$attributes = !empty($element['#wrapper_attributes']) ? $element['#wrapper_attributes'] : array('class' => array());
|
||||
$attributes['class'][] = 'container-inline-date';
|
||||
// If there is no description, the floating date elements need some extra padding below them.
|
||||
// If there is no description, the floating date
|
||||
// elements need some extra padding below them.
|
||||
$wrapper_attributes = array('class' => array('date-padding'));
|
||||
if (empty($element['date']['#description'])) {
|
||||
$wrapper_attributes['class'][] = 'clearfix';
|
||||
}
|
||||
// Add an wrapper to mimic the way a single value field works, for ease in using #states.
|
||||
// Add an wrapper to mimic the way a single value field works,
|
||||
// for ease in using #states.
|
||||
if (isset($element['#children'])) {
|
||||
$element['#children'] = '<div id="' . $element['#id'] . '" ' . drupal_attributes($wrapper_attributes) .'>' . $element['#children'] . '</div>';
|
||||
$element['#children'] = '<div id="' . $element['#id'] . '" ' . drupal_attributes($wrapper_attributes) . '>' . $element['#children'] . '</div>';
|
||||
}
|
||||
return '<div ' . drupal_attributes($attributes) .'>' . theme('form_element', $element) . '</div>';
|
||||
return '<div ' . drupal_attributes($attributes) . '>' . theme('form_element', $element) . '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -707,8 +828,8 @@ function date_popup_settings() {
|
||||
'#type' => 'select',
|
||||
'#options' => array(
|
||||
'default' => t('Use default jQuery timepicker'),
|
||||
'wvega' => t('Use dropdown timepicker'),
|
||||
'none' => t('Manual time entry, no jQuery timepicker')
|
||||
'wvega' => t('Use dropdown timepicker'),
|
||||
'none' => t('Manual time entry, no jQuery timepicker'),
|
||||
),
|
||||
'#title' => t('Timepicker'),
|
||||
'#default_value' => variable_get('date_popup_timepicker', $preferred_timepicker),
|
||||
@@ -734,7 +855,7 @@ function date_popup_settings() {
|
||||
}
|
||||
EOM;
|
||||
|
||||
$form['#suffix'] = t('<p>The Date Popup calendar includes some css for IE6 that breaks css validation. Since IE 6 is now superceded by IE 7, 8, and 9, the special css for IE 6 has been removed from the regular css used by the Date Popup. If you find you need that css after all, you can add it back in your theme. Look at the way the Garland theme adds special IE-only css in in its page.tpl.php file. The css you need is:</p>') .'<blockquote><PRE>' . $css .'</PRE></blockquote>';
|
||||
$form['#suffix'] = t('<p>The Date Popup calendar includes some css for IE6 that breaks css validation. Since IE 6 is now superceded by IE 7, 8, and 9, the special css for IE 6 has been removed from the regular css used by the Date Popup. If you find you need that css after all, you can add it back in your theme. Look at the way the Garland theme adds special IE-only css in in its page.tpl.php file. The css you need is:</p>') . '<blockquote><PRE>' . $css . '</PRE></blockquote>';
|
||||
|
||||
return system_settings_form($form);
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@@ -2,5 +2,6 @@
|
||||
/**
|
||||
* @file
|
||||
* Empty file to avoid fatal error if it doesn't exist.
|
||||
*
|
||||
* Formerly the Date Repeat field code.
|
||||
*/
|
||||
*/
|
||||
|
@@ -7,9 +7,9 @@ php = 5.2
|
||||
files[] = tests/date_repeat.test
|
||||
files[] = tests/date_repeat_form.test
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-07-29
|
||||
version = "7.x-2.8"
|
||||
; Information added by Drupal.org packaging script on 2015-09-08
|
||||
version = "7.x-2.9"
|
||||
core = "7.x"
|
||||
project = "date"
|
||||
datestamp = "1406653438"
|
||||
datestamp = "1441727353"
|
||||
|
||||
|
@@ -12,21 +12,3 @@ function date_repeat_install() {
|
||||
// Make sure this module loads after date_api.
|
||||
db_query("UPDATE {system} SET weight = 1 WHERE name = 'date_repeat'");
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_uninstall().
|
||||
*/
|
||||
function date_repeat_uninstall() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_enable().
|
||||
*/
|
||||
function date_repeat_enable() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_disable().
|
||||
*/
|
||||
function date_repeat_disable() {
|
||||
}
|
||||
|
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* This module creates a form element that allows users to select
|
||||
* repeat rules for a date, and reworks the result into an iCal
|
||||
* RRULE string that can be stored in the database.
|
||||
@@ -11,8 +10,8 @@
|
||||
*
|
||||
* Other modules can use this API to add self-validating form elements
|
||||
* to their dates, and identify dates that meet the RRULE criteria.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_element_info().
|
||||
*/
|
||||
@@ -35,6 +34,9 @@ function date_repeat_element_info() {
|
||||
return $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_theme().
|
||||
*/
|
||||
function date_repeat_theme() {
|
||||
return array(
|
||||
'date_repeat_current_exceptions' => array('render element' => 'element'),
|
||||
@@ -55,6 +57,9 @@ function date_repeat_freq_options() {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for interval options.
|
||||
*/
|
||||
function date_repeat_interval_options() {
|
||||
$options = range(0, 366);
|
||||
unset($options[0]);
|
||||
@@ -92,9 +97,11 @@ function date_repeat_dow_day_options_abbr($translated = TRUE, $length = 3) {
|
||||
case 1:
|
||||
$context = 'day_abbr1';
|
||||
break;
|
||||
|
||||
case 2:
|
||||
$context = 'day_abbr2';
|
||||
break;
|
||||
|
||||
default:
|
||||
$context = '';
|
||||
break;
|
||||
@@ -105,16 +112,28 @@ function date_repeat_dow_day_options_abbr($translated = TRUE, $length = 3) {
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for weekdays translated.
|
||||
*/
|
||||
function date_repeat_dow_day_untranslated() {
|
||||
static $date_repeat_weekdays;
|
||||
if (empty($date_repeat_weekdays)) {
|
||||
$date_repeat_weekdays = array('SU' => 'Sunday', 'MO' => 'Monday', 'TU' => 'Tuesday',
|
||||
'WE' => 'Wednesday', 'TH' => 'Thursday', 'FR' => 'Friday',
|
||||
'SA' => 'Saturday');
|
||||
$date_repeat_weekdays = array(
|
||||
'SU' => 'Sunday',
|
||||
'MO' => 'Monday',
|
||||
'TU' => 'Tuesday',
|
||||
'WE' => 'Wednesday',
|
||||
'TH' => 'Thursday',
|
||||
'FR' => 'Friday',
|
||||
'SA' => 'Saturday'
|
||||
);
|
||||
}
|
||||
return $date_repeat_weekdays;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for weekdays order.
|
||||
*/
|
||||
function date_repeat_dow_day_options_ordered($weekdays) {
|
||||
$day_keys = array_keys($weekdays);
|
||||
$day_values = array_values($weekdays);
|
||||
@@ -164,8 +183,7 @@ function date_repeat_dow2day($dow) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Shift the array of iCal day names into the right order
|
||||
* for a specific week start day.
|
||||
* Shift the array of iCal day names into the right order for a specific week start day.
|
||||
*/
|
||||
function date_repeat_days_ordered($week_start_day) {
|
||||
$days = array_flip(array_keys(date_repeat_dow_day_options(FALSE)));
|
||||
@@ -212,18 +230,21 @@ function date_repeat_rrule_description($rrule, $format = 'D M d Y') {
|
||||
'!except' => '',
|
||||
'!additional' => '',
|
||||
'!week_starts_on' => '',
|
||||
);
|
||||
);
|
||||
$interval = date_repeat_interval_options();
|
||||
switch ($rrule['FREQ']) {
|
||||
case 'WEEKLY':
|
||||
$description['!interval'] = format_plural($rrule['INTERVAL'], 'every week', 'every @count weeks') . ' ';
|
||||
break;
|
||||
|
||||
case 'MONTHLY':
|
||||
$description['!interval'] = format_plural($rrule['INTERVAL'], 'every month', 'every @count months') . ' ';
|
||||
break;
|
||||
|
||||
case 'YEARLY':
|
||||
$description['!interval'] = format_plural($rrule['INTERVAL'], 'every year', 'every @count years') . ' ';
|
||||
break;
|
||||
|
||||
default:
|
||||
$description['!interval'] = format_plural($rrule['INTERVAL'], 'every day', 'every @count days') . ' ';
|
||||
break;
|
||||
@@ -240,26 +261,41 @@ function date_repeat_rrule_description($rrule, $format = 'D M d Y') {
|
||||
if (!empty($count)) {
|
||||
// See if there is a 'pretty' option for this count, i.e. +1 => First.
|
||||
$order = array_key_exists($count, $counts) ? strtolower($counts[$count]) : $count;
|
||||
$results[] = trim(t('!repeats_every_interval on the !date_order !day_of_week', array('!repeats_every_interval ' => '', '!date_order' => $order, '!day_of_week' => $days[$day])));
|
||||
$results[] = trim(t('!repeats_every_interval on the !date_order !day_of_week',
|
||||
array(
|
||||
'!repeats_every_interval ' => '',
|
||||
'!date_order' => $order,
|
||||
'!day_of_week' => $days[$day]
|
||||
)));
|
||||
}
|
||||
else {
|
||||
$results[] = trim(t('!repeats_every_interval every !day_of_week', array('!repeats_every_interval ' => '', '!day_of_week' => $days[$day])));
|
||||
$results[] = trim(t('!repeats_every_interval every !day_of_week',
|
||||
array('!repeats_every_interval ' => '', '!day_of_week' => $days[$day])));
|
||||
}
|
||||
}
|
||||
$description['!byday'] = implode(' ' . t('and') . ' ', $results);
|
||||
}
|
||||
if (!empty($rrule['BYMONTH'])) {
|
||||
if (sizeof($rrule['BYMONTH']) < 12) {
|
||||
if (count($rrule['BYMONTH']) < 12) {
|
||||
$results = array();
|
||||
$months = date_month_names();
|
||||
foreach ($rrule['BYMONTH'] as $month) {
|
||||
$results[] = $months[$month];
|
||||
}
|
||||
if (!empty($rrule['BYMONTHDAY'])) {
|
||||
$description['!bymonth'] = trim(t('!repeats_every_interval on the !month_days of !month_names', array('!repeats_every_interval ' => '', '!month_days' => implode(', ', $rrule['BYMONTHDAY']), '!month_names' => implode(', ', $results))));
|
||||
$description['!bymonth'] = trim(t('!repeats_every_interval on the !month_days of !month_names',
|
||||
array(
|
||||
'!repeats_every_interval ' => '',
|
||||
'!month_days' => implode(', ', $rrule['BYMONTHDAY']),
|
||||
'!month_names' => implode(', ', $results)
|
||||
)));
|
||||
}
|
||||
else {
|
||||
$description['!bymonth'] = trim(t('!repeats_every_interval on !month_names', array('!repeats_every_interval ' => '', '!month_names' => implode(', ', $results))));
|
||||
$description['!bymonth'] = trim(t('!repeats_every_interval on !month_names',
|
||||
array(
|
||||
'!repeats_every_interval ' => '',
|
||||
'!month_names' => implode(', ', $results)
|
||||
)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -267,12 +303,17 @@ function date_repeat_rrule_description($rrule, $format = 'D M d Y') {
|
||||
$rrule['INTERVAL'] = 1;
|
||||
}
|
||||
if (!empty($rrule['COUNT'])) {
|
||||
$description['!count'] = trim(t('!repeats_every_interval !count times', array('!repeats_every_interval ' => '', '!count' => $rrule['COUNT'])));
|
||||
$description['!count'] = trim(t('!repeats_every_interval !count times',
|
||||
array('!repeats_every_interval ' => '', '!count' => $rrule['COUNT'])));
|
||||
}
|
||||
if (!empty($rrule['UNTIL'])) {
|
||||
$until = date_ical_date($rrule['UNTIL'], 'UTC');
|
||||
date_timezone_set($until, date_default_timezone_object());
|
||||
$description['!until'] = trim(t('!repeats_every_interval until !until_date', array('!repeats_every_interval ' => '', '!until_date' => date_format_date($until, 'custom', $format))));
|
||||
$description['!until'] = trim(t('!repeats_every_interval until !until_date',
|
||||
array(
|
||||
'!repeats_every_interval ' => '',
|
||||
'!until_date' => date_format_date($until, 'custom', $format)
|
||||
)));
|
||||
}
|
||||
if ($exceptions) {
|
||||
$values = array();
|
||||
@@ -281,11 +322,16 @@ function date_repeat_rrule_description($rrule, $format = 'D M d Y') {
|
||||
date_timezone_set($except, date_default_timezone_object());
|
||||
$values[] = date_format_date($except, 'custom', $format);
|
||||
}
|
||||
$description['!except'] = trim(t('!repeats_every_interval except !except_dates', array('!repeats_every_interval ' => '', '!except_dates' => implode(', ', $values))));
|
||||
$description['!except'] = trim(t('!repeats_every_interval except !except_dates',
|
||||
array(
|
||||
'!repeats_every_interval ' => '',
|
||||
'!except_dates' => implode(', ', $values)
|
||||
)));
|
||||
}
|
||||
if (!empty($rrule['WKST'])) {
|
||||
$day_names = date_repeat_dow_day_options();
|
||||
$description['!week_starts_on'] = trim(t('!repeats_every_interval where the week start on !day_of_week', array('!repeats_every_interval ' => '', '!day_of_week' => $day_names[trim($rrule['WKST'])])));
|
||||
$description['!week_starts_on'] = trim(t('!repeats_every_interval where the week start on !day_of_week',
|
||||
array('!repeats_every_interval ' => '', '!day_of_week' => $day_names[trim($rrule['WKST'])])));
|
||||
}
|
||||
if ($additions) {
|
||||
$values = array();
|
||||
@@ -294,9 +340,15 @@ function date_repeat_rrule_description($rrule, $format = 'D M d Y') {
|
||||
date_timezone_set($add, date_default_timezone_object());
|
||||
$values[] = date_format_date($add, 'custom', $format);
|
||||
}
|
||||
$description['!additional'] = trim(t('Also includes !additional_dates.', array('!additional_dates' => implode(', ', $values))));
|
||||
$description['!additional'] = trim(t('Also includes !additional_dates.',
|
||||
array('!additional_dates' => implode(', ', $values))));
|
||||
}
|
||||
return t('Repeats !interval !bymonth !byday !count !until !except. !additional', $description);
|
||||
$output = t('Repeats !interval !bymonth !byday !count !until !except. !additional', $description);
|
||||
// Removes double whitespaces from Repeat tile.
|
||||
$output = preg_replace('/\s+/', ' ', $output);
|
||||
// Removes whitespace before full stop ".", at the end of the title.
|
||||
$output = str_replace(' .', '.', $output);
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -310,17 +362,17 @@ function date_repeat_split_rrule($rrule) {
|
||||
$additions = array();
|
||||
foreach ($parts as $part) {
|
||||
if (strstr($part, 'RRULE')) {
|
||||
$RRULE = str_replace('RRULE:', '', $part);
|
||||
$rrule = (array) date_ical_parse_rrule('RRULE:', $RRULE);
|
||||
$cleanded_part = str_replace('RRULE:', '', $part);
|
||||
$rrule = (array) date_ical_parse_rrule('RRULE:', $cleanded_part);
|
||||
}
|
||||
elseif (strstr($part, 'EXDATE')) {
|
||||
$EXDATE = str_replace('EXDATE:', '', $part);
|
||||
$exceptions = (array) date_ical_parse_exceptions('EXDATE:', $EXDATE);
|
||||
$exdate = str_replace('EXDATE:', '', $part);
|
||||
$exceptions = (array) date_ical_parse_exceptions('EXDATE:', $exdate);
|
||||
unset($exceptions['DATA']);
|
||||
}
|
||||
elseif (strstr($part, 'RDATE')) {
|
||||
$RDATE = str_replace('RDATE:', '', $part);
|
||||
$additions = (array) date_ical_parse_exceptions('RDATE:', $RDATE);
|
||||
$rdate = str_replace('RDATE:', '', $part);
|
||||
$additions = (array) date_ical_parse_exceptions('RDATE:', $rdate);
|
||||
unset($additions['DATA']);
|
||||
}
|
||||
}
|
||||
@@ -372,7 +424,7 @@ function date_repeat_form_element_radios_process($element) {
|
||||
'#title_display' => 'invisible',
|
||||
'#return_value' => $key,
|
||||
'#default_value' => isset($element['#default_value']) ?
|
||||
$element['#default_value'] : NULL,
|
||||
$element['#default_value'] : NULL,
|
||||
'#attributes' => $element['#attributes'],
|
||||
'#parents' => $element['#parents'],
|
||||
'#id' => drupal_html_id('edit-' . implode('-', $parents_for_id)),
|
||||
|
@@ -53,9 +53,11 @@ function _date_repeat_calc($rrule, $start, $end, $exceptions, $timezone, $additi
|
||||
// Create a date object for the start and end dates.
|
||||
$start_date = new DateObject($start, $timezone);
|
||||
|
||||
// Versions of PHP greater than PHP 5.3.5 require that we set an explicit time when
|
||||
// using date_modify() or the time may not match the original value. Adding this
|
||||
// modifier gives us the same results in both older and newer versions of PHP.
|
||||
// Versions of PHP greater than PHP 5.3.5 require
|
||||
// that we set an explicit time when using date_modify()
|
||||
// or the time may not match the original value.
|
||||
// Adding this modifier gives us the same results in both older
|
||||
// and newer versions of PHP.
|
||||
$modify_time = ' ' . $start_date->format('g:ia');
|
||||
|
||||
// If the rule has an UNTIL, see if that is earlier than the end date.
|
||||
@@ -91,27 +93,32 @@ function _date_repeat_calc($rrule, $start, $end, $exceptions, $timezone, $additi
|
||||
}
|
||||
|
||||
// Make sure DAILY frequency isn't used in places it won't work;
|
||||
if (!empty($rrule['BYMONTHDAY']) && !in_array($rrule['FREQ'], array('MONTHLY', 'YEARLY'))) {
|
||||
if (!empty($rrule['BYMONTHDAY']) &&
|
||||
!in_array($rrule['FREQ'], array('MONTHLY', 'YEARLY'))) {
|
||||
$rrule['FREQ'] = 'MONTHLY';
|
||||
}
|
||||
elseif (!empty($rrule['BYDAY']) && !in_array($rrule['FREQ'], array('MONTHLY', 'WEEKLY', 'YEARLY'))) {
|
||||
elseif (!empty($rrule['BYDAY'])
|
||||
&& !in_array($rrule['FREQ'], array('MONTHLY', 'WEEKLY', 'YEARLY'))) {
|
||||
$rrule['FREQ'] = 'WEEKLY';
|
||||
}
|
||||
}
|
||||
|
||||
// Find the time period to jump forward between dates.
|
||||
switch ($rrule['FREQ']) {
|
||||
case 'DAILY':
|
||||
$jump = $interval . ' days';
|
||||
break;
|
||||
case 'WEEKLY':
|
||||
$jump = $interval . ' weeks';
|
||||
break;
|
||||
case 'MONTHLY':
|
||||
$jump = $interval . ' months';
|
||||
break;
|
||||
case 'YEARLY':
|
||||
$jump = $interval . ' years';
|
||||
break;
|
||||
case 'DAILY':
|
||||
$jump = $interval . ' days';
|
||||
break;
|
||||
|
||||
case 'WEEKLY':
|
||||
$jump = $interval . ' weeks';
|
||||
break;
|
||||
|
||||
case 'MONTHLY':
|
||||
$jump = $interval . ' months';
|
||||
break;
|
||||
|
||||
case 'YEARLY':
|
||||
$jump = $interval . ' years';
|
||||
break;
|
||||
}
|
||||
$rrule = date_repeat_adjust_rrule($rrule, $start_date);
|
||||
|
||||
@@ -135,7 +142,7 @@ function _date_repeat_calc($rrule, $start, $end, $exceptions, $timezone, $additi
|
||||
$direction_days[$day] = array(
|
||||
'direction' => !empty($regs[1]) ? $regs[1] : '+',
|
||||
'direction_count' => $regs[2],
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
while (!$finished) {
|
||||
@@ -198,8 +205,9 @@ function _date_repeat_calc($rrule, $start, $end, $exceptions, $timezone, $additi
|
||||
|
||||
else {
|
||||
|
||||
// More complex searches for day names and criteria like '-1SU' or '2TU,2TH',
|
||||
// require that we interate through the whole time period checking each BYDAY.
|
||||
// More complex searches for day names and criteria
|
||||
// like '-1SU' or '2TU,2TH', require that we interate through
|
||||
// the whole time period checking each BYDAY.
|
||||
|
||||
// Create helper array to pull day names out of iCal day strings.
|
||||
$day_names = date_repeat_dow_day_options(FALSE);
|
||||
@@ -303,7 +311,8 @@ function _date_repeat_calc($rrule, $start, $end, $exceptions, $timezone, $additi
|
||||
// period, then jumping ahead to the next week, month, or year,
|
||||
// an INTERVAL at a time.
|
||||
|
||||
if (!empty($week_days) && in_array($rrule['FREQ'], array('MONTHLY', 'WEEKLY', 'YEARLY'))) {
|
||||
if (!empty($week_days) &&
|
||||
in_array($rrule['FREQ'], array('MONTHLY', 'WEEKLY', 'YEARLY'))) {
|
||||
$finished = FALSE;
|
||||
$current_day = clone($start_date);
|
||||
$format = $rrule['FREQ'] == 'YEARLY' ? 'Y' : 'n';
|
||||
@@ -322,8 +331,9 @@ function _date_repeat_calc($rrule, $start, $end, $exceptions, $timezone, $additi
|
||||
$moved = FALSE;
|
||||
foreach ($week_days as $delta => $day) {
|
||||
// Find the next occurence of each day in this week, only add it
|
||||
// if we are still in the current month or year. The date_repeat_add_dates
|
||||
// function is insufficient to test whether to include this date
|
||||
// if we are still in the current month or year.
|
||||
// The date_repeat_add_dates function is insufficient
|
||||
// to test whether to include this date
|
||||
// if we are using a rule like 'every other month', so we must
|
||||
// explicitly test it here.
|
||||
|
||||
@@ -370,10 +380,12 @@ function _date_repeat_calc($rrule, $start, $end, $exceptions, $timezone, $additi
|
||||
date_modify($current_day, '+1 ' . $week_start_day . $modify_time);
|
||||
date_modify($current_day, '-1 week' . $modify_time);
|
||||
break;
|
||||
|
||||
case 'MONTHLY':
|
||||
date_modify($current_day, '-' . (date_format($current_day, 'j') - 1) . ' days' . $modify_time);
|
||||
date_modify($current_day, '-1 month' . $modify_time);
|
||||
break;
|
||||
|
||||
case 'YEARLY':
|
||||
date_modify($current_day, '-' . date_format($current_day, 'z') . ' days' . $modify_time);
|
||||
date_modify($current_day, '-1 year' . $modify_time);
|
||||
@@ -387,7 +399,7 @@ function _date_repeat_calc($rrule, $start, $end, $exceptions, $timezone, $additi
|
||||
}
|
||||
}
|
||||
|
||||
// add additional dates
|
||||
// Add additional dates.
|
||||
foreach ($additions as $addition) {
|
||||
$date = new dateObject($addition . ' ' . $start_date->format('H:i:s'), $timezone);
|
||||
$days[] = date_format($date, DATE_FORMAT_DATETIME);
|
||||
@@ -426,8 +438,8 @@ function date_repeat_adjust_rrule($rrule, $start_date) {
|
||||
// position rules make no sense in other periods and just add complexity.
|
||||
|
||||
elseif (!empty($rrule['BYDAY']) && !in_array($rrule['FREQ'], array('MONTHLY', 'YEARLY'))) {
|
||||
foreach ($rrule['BYDAY'] as $delta => $BYDAY) {
|
||||
$rrule['BYDAY'][$delta] = substr($BYDAY, -2);
|
||||
foreach ($rrule['BYDAY'] as $delta => $by_day) {
|
||||
$rrule['BYDAY'][$delta] = substr($by_day, -2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -442,7 +454,7 @@ function date_repeat_adjust_rrule($rrule, $start_date) {
|
||||
* and that it meets other criteria in the RRULE.
|
||||
*/
|
||||
function date_repeat_add_dates(&$days, $current_day, $start_date, $end_date, $exceptions, $rrule) {
|
||||
if (isset($rrule['COUNT']) && sizeof($days) >= $rrule['COUNT']) {
|
||||
if (isset($rrule['COUNT']) && count($days) >= $rrule['COUNT']) {
|
||||
return FALSE;
|
||||
}
|
||||
$formatted = date_format($current_day, DATE_FORMAT_DATETIME);
|
||||
@@ -456,13 +468,14 @@ function date_repeat_add_dates(&$days, $current_day, $start_date, $end_date, $ex
|
||||
return FALSE;
|
||||
}
|
||||
if (!empty($rrule['BYDAY'])) {
|
||||
$BYDAYS = $rrule['BYDAY'];
|
||||
foreach ($BYDAYS as $delta => $BYDAY) {
|
||||
$BYDAYS[$delta] = substr($BYDAY, -2);
|
||||
$by_days = $rrule['BYDAY'];
|
||||
foreach ($by_days as $delta => $by_day) {
|
||||
$by_days[$delta] = substr($by_day, -2);
|
||||
}
|
||||
if (!in_array(date_repeat_dow2day(date_format($current_day, 'w')), $BYDAYS)) {
|
||||
if (!in_array(date_repeat_dow2day(date_format($current_day, 'w')), $by_days)) {
|
||||
return FALSE;
|
||||
}}
|
||||
}
|
||||
}
|
||||
if (!empty($rrule['BYYEAR']) && !in_array(date_format($current_day, 'Y'), $rrule['BYYEAR'])) {
|
||||
return FALSE;
|
||||
}
|
||||
@@ -472,17 +485,17 @@ function date_repeat_add_dates(&$days, $current_day, $start_date, $end_date, $ex
|
||||
if (!empty($rrule['BYMONTHDAY'])) {
|
||||
// Test month days, but only if there are no negative numbers.
|
||||
$test = TRUE;
|
||||
$BYMONTHDAYS = array();
|
||||
$by_month_days = array();
|
||||
foreach ($rrule['BYMONTHDAY'] as $day) {
|
||||
if ($day > 0) {
|
||||
$BYMONTHDAYS[] = $day;
|
||||
$by_month_days[] = $day;
|
||||
}
|
||||
else {
|
||||
$test = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($test && !empty($BYMONTHDAYS) && !in_array(date_format($current_day, 'j'), $BYMONTHDAYS)) {
|
||||
if ($test && !empty($by_month_days) && !in_array(date_format($current_day, 'j'), $by_month_days)) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@@ -499,7 +512,7 @@ function date_repeat_add_dates(&$days, $current_day, $start_date, $end_date, $ex
|
||||
* Stop when $current_day is greater than $end_date or $count is reached.
|
||||
*/
|
||||
function date_repeat_is_finished($current_day, $days, $count, $end_date) {
|
||||
if (($count && sizeof($days) >= $count)
|
||||
if (($count && count($days) >= $count)
|
||||
|| (!empty($end_date) && date_format($current_day, 'U') > date_format($end_date, 'U'))) {
|
||||
return TRUE;
|
||||
}
|
||||
@@ -517,7 +530,7 @@ function date_repeat_is_finished($current_day, $days, $count, $end_date) {
|
||||
* If $day is empty, will set to the number of days from the
|
||||
* beginning or end of the month.
|
||||
*/
|
||||
function date_repeat_set_month_day($date_in, $day, $count = 1, $direction = '+', $timezone = 'UTC', $modify_time) {
|
||||
function date_repeat_set_month_day($date_in, $day, $count = 1, $direction = '+', $timezone = 'UTC', $modify_time = '') {
|
||||
if (is_object($date_in)) {
|
||||
$current_month = date_format($date_in, 'n');
|
||||
|
||||
@@ -567,7 +580,7 @@ function date_repeat_set_month_day($date_in, $day, $count = 1, $direction = '+',
|
||||
* If $day is empty, will set to the number of days from the
|
||||
* beginning or end of the year.
|
||||
*/
|
||||
function date_repeat_set_year_day($date_in, $month, $day, $count = 1, $direction = '+', $timezone = 'UTC', $modify_time) {
|
||||
function date_repeat_set_year_day($date_in, $month, $day, $count = 1, $direction = '+', $timezone = 'UTC', $modify_time = '') {
|
||||
if (is_object($date_in)) {
|
||||
$current_year = date_format($date_in, 'Y');
|
||||
|
||||
@@ -620,4 +633,4 @@ function date_repeat_set_year_day($date_in, $month, $day, $count = 1, $direction
|
||||
}
|
||||
}
|
||||
return $date_in;
|
||||
}
|
||||
}
|
||||
|
@@ -30,13 +30,16 @@
|
||||
* BYSETPOS
|
||||
* Seldom used anywhere, so no reason to complicated the code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Generate the repeat setting form.
|
||||
*/
|
||||
function _date_repeat_rrule_process($element, &$form_state, $form) {
|
||||
|
||||
// If the RRULE field is not visible to the user, needs no processing or validation.
|
||||
// The Date field module is not adding this element to forms if the field is hidden,
|
||||
// If the RRULE field is not visible to the user,
|
||||
// needs no processing or validation.
|
||||
// The Date field module is not adding this element to forms
|
||||
// if the field is hidden,
|
||||
// this test is just in case some other module attempts to do so.
|
||||
|
||||
if (date_hidden_element($element)) {
|
||||
@@ -67,16 +70,16 @@ function _date_repeat_rrule_process($element, &$form_state, $form) {
|
||||
$timezone = !empty($element['#date_timezone']) ? $element['#date_timezone'] : date_default_timezone();
|
||||
$merged_values = date_repeat_merge($rrule, $element);
|
||||
|
||||
$UNTIL = '';
|
||||
$until = '';
|
||||
if (!empty($merged_values['UNTIL']['datetime'])) {
|
||||
$until_date = new DateObject($merged_values['UNTIL']['datetime'], $merged_values['UNTIL']['tz']);
|
||||
date_timezone_set($until_date, timezone_open($timezone));
|
||||
$UNTIL = date_format($until_date, DATE_FORMAT_DATETIME);
|
||||
$until = date_format($until_date, DATE_FORMAT_DATETIME);
|
||||
}
|
||||
|
||||
$COUNT = '';
|
||||
$count = '';
|
||||
if (!empty($merged_values['COUNT'])) {
|
||||
$COUNT = $merged_values['COUNT'];
|
||||
$count = $merged_values['COUNT'];
|
||||
}
|
||||
|
||||
$element['FREQ'] = array(
|
||||
@@ -137,7 +140,7 @@ function _date_repeat_rrule_process($element, &$form_state, $form) {
|
||||
);
|
||||
|
||||
list($prefix, $suffix) = explode('@interval', t('Every @interval days', array(), array('context' => 'Date repeat')));
|
||||
$DAILY_INTERVAL = array(
|
||||
$daily_interval = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Repeats', array(), array('context' => 'Date repeat')),
|
||||
'#title_display' => 'invisible',
|
||||
@@ -210,32 +213,34 @@ function _date_repeat_rrule_process($element, &$form_state, $form) {
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
|
||||
$DAILY_radios_default = 'INTERVAL';
|
||||
$daily_radios_default = 'INTERVAL';
|
||||
if (isset($rrule['FREQ']) && $rrule['FREQ'] === 'DAILY' && !empty($rrule['BYDAY'])) {
|
||||
switch (count($rrule['BYDAY'])) {
|
||||
case 2:
|
||||
$DAILY_radios_default = 'every_tu_th';
|
||||
$daily_radios_default = 'every_tu_th';
|
||||
break;
|
||||
|
||||
case 3:
|
||||
$DAILY_radios_default = 'every_mo_we_fr';
|
||||
$daily_radios_default = 'every_mo_we_fr';
|
||||
break;
|
||||
|
||||
case 5:
|
||||
$DAILY_radios_default = 'every_weekday';
|
||||
$daily_radios_default = 'every_weekday';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$DAILY_every_weekday = array(
|
||||
$daily_every_weekday = array(
|
||||
'#type' => 'item',
|
||||
'#markup' => '<div>' . t('Every weekday', array(), array('context' => 'Date repeat')) . '</div>',
|
||||
);
|
||||
|
||||
$DAILY_mo_we_fr = array(
|
||||
$daily_mo_we_fr = array(
|
||||
'#type' => 'item',
|
||||
'#markup' => '<div>' . t('Every Mon, Wed, Fri', array(), array('context' => 'Date repeat')) . '</div>',
|
||||
);
|
||||
|
||||
$DAILY_tu_th = array(
|
||||
$daily_tu_th = array(
|
||||
'#type' => 'item',
|
||||
'#markup' => '<div>' . t('Every Tue, Thu', array(), array('context' => 'Date repeat')) . '</div>',
|
||||
);
|
||||
@@ -251,17 +256,17 @@ function _date_repeat_rrule_process($element, &$form_state, $form) {
|
||||
":input[name=\"{$element['#name']}[FREQ]\"]" => array('value' => 'DAILY'),
|
||||
),
|
||||
),
|
||||
'#default_value' => $DAILY_radios_default,
|
||||
'#default_value' => $daily_radios_default,
|
||||
'#options' => array(
|
||||
'INTERVAL' => t('interval'),
|
||||
'every_weekday' => t('every weekday'),
|
||||
'every_mo_we_fr' => t('monday wednesday friday'),
|
||||
'every_tu_th' => t('tuesday thursday'),
|
||||
),
|
||||
'INTERVAL_child' => $DAILY_INTERVAL,
|
||||
'every_weekday_child' => $DAILY_every_weekday,
|
||||
'mo_we_fr_child' => $DAILY_mo_we_fr,
|
||||
'tu_th_child' => $DAILY_tu_th,
|
||||
'INTERVAL_child' => $daily_interval,
|
||||
'every_weekday_child' => $daily_every_weekday,
|
||||
'mo_we_fr_child' => $daily_mo_we_fr,
|
||||
'tu_th_child' => $daily_tu_th,
|
||||
'#div_classes' => array(
|
||||
'container-inline interval',
|
||||
'container-inline weekday',
|
||||
@@ -270,18 +275,18 @@ function _date_repeat_rrule_process($element, &$form_state, $form) {
|
||||
),
|
||||
);
|
||||
|
||||
$MONTHLY_day_month_default = 'BYMONTHDAY_BYMONTH';
|
||||
$monthly_day_month_default = 'BYMONTHDAY_BYMONTH';
|
||||
if (isset($rrule['FREQ']) && $rrule['FREQ'] === 'MONTHLY' && !empty($rrule['BYDAY'])) {
|
||||
$MONTHLY_day_month_default = 'BYDAY_BYMONTH';
|
||||
$monthly_day_month_default = 'BYDAY_BYMONTH';
|
||||
}
|
||||
|
||||
$MONTHLY_on_day_BYMONTHDAY_of_BYMONTH = array(
|
||||
$monthly_on_day_bymonthday_of_bymonth = array(
|
||||
'#type' => 'container',
|
||||
'#tree' => TRUE,
|
||||
);
|
||||
|
||||
list($bymonthday_title, $bymonthday_suffix) = explode('@bymonthday', t('On day @bymonthday of', array(), array('context' => 'Date repeat')));
|
||||
$MONTHLY_on_day_BYMONTHDAY_of_BYMONTH['BYMONTHDAY'] = array(
|
||||
$monthly_on_day_bymonthday_of_bymonth['BYMONTHDAY'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => $bymonthday_title,
|
||||
'#default_value' => !empty($rrule['BYMONTHDAY']) && $rrule['FREQ'] === 'MONTHLY' ? $rrule['BYMONTHDAY'] : '',
|
||||
@@ -292,11 +297,11 @@ function _date_repeat_rrule_process($element, &$form_state, $form) {
|
||||
'#field_suffix' => $bymonthday_suffix,
|
||||
);
|
||||
|
||||
$MONTHLY_on_day_BYMONTHDAY_of_BYMONTH['BYMONTH'] = array(
|
||||
$monthly_on_day_bymonthday_of_bymonth['BYMONTH'] = array(
|
||||
'#type' => 'checkboxes',
|
||||
'#title' => t('Bymonth', array(), array('context' => 'Date repeat')),
|
||||
'#title_display' => 'invisible',
|
||||
'#default_value' => !empty($rrule['BYMONTH']) && $rrule['FREQ'] === 'MONTHLY' && $MONTHLY_day_month_default === 'BYMONTHDAY_BYMONTH' ? $rrule['BYMONTH'] : array(),
|
||||
'#default_value' => !empty($rrule['BYMONTH']) && $rrule['FREQ'] === 'MONTHLY' && $monthly_day_month_default === 'BYMONTHDAY_BYMONTH' ? $rrule['BYMONTH'] : array(),
|
||||
'#options' => date_month_names_abbr(TRUE),
|
||||
'#attributes' => array('class' => array('container-inline')),
|
||||
'#multiple' => TRUE,
|
||||
@@ -304,45 +309,45 @@ function _date_repeat_rrule_process($element, &$form_state, $form) {
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
|
||||
$MONTHLY_on_the_BYDAY_of_BYMONTH = array(
|
||||
$monthly_on_the_byday_of_bymonth = array(
|
||||
'#type' => 'container',
|
||||
'#tree' => TRUE,
|
||||
);
|
||||
|
||||
$MONTHLY_BYDAY_COUNT = '';
|
||||
$MONTHLY_BYDAY_DAY = '';
|
||||
$monthly_byday_count = '';
|
||||
$monthly_byday_day = '';
|
||||
if (isset($rrule['BYDAY']) && !empty($rrule['BYDAY']) && $rrule['FREQ'] === 'MONTHLY') {
|
||||
$MONTHLY_BYDAY_COUNT = substr($rrule['BYDAY'][0], 0, -2);
|
||||
$MONTHLY_BYDAY_DAY = substr($rrule['BYDAY'][0], -2);;
|
||||
$monthly_byday_count = substr($rrule['BYDAY'][0], 0, -2);
|
||||
$monthly_byday_day = substr($rrule['BYDAY'][0], -2);;
|
||||
}
|
||||
|
||||
list($byday_count_title, $byday_day_title) = explode('@byday', t('On the @byday of', array(), array('context' => 'Date repeat')));
|
||||
$MONTHLY_on_the_BYDAY_of_BYMONTH['BYDAY_COUNT'] = array(
|
||||
$monthly_on_the_byday_of_bymonth['BYDAY_COUNT'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => $byday_count_title,
|
||||
'#default_value' => !empty($MONTHLY_BYDAY_COUNT) ? $MONTHLY_BYDAY_COUNT : '',
|
||||
'#default_value' => !empty($monthly_byday_count) ? $monthly_byday_count : '',
|
||||
'#options' => date_order_translated(),
|
||||
'#multiple' => FALSE,
|
||||
'#prefix' => '<div class="date-repeat-input byday-count">',
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
|
||||
$MONTHLY_on_the_BYDAY_of_BYMONTH['BYDAY_DAY'] = array(
|
||||
$monthly_on_the_byday_of_bymonth['BYDAY_DAY'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => $byday_day_title,
|
||||
'#title_display' => 'after',
|
||||
'#default_value' => !empty($MONTHLY_BYDAY_DAY) ? $MONTHLY_BYDAY_DAY : '',
|
||||
'#default_value' => !empty($monthly_byday_day) ? $monthly_byday_day : '',
|
||||
'#options' => date_repeat_dow_day_options(TRUE),
|
||||
'#multiple' => FALSE,
|
||||
'#prefix' => '<div class="date-repeat-input byday-day">',
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
|
||||
$MONTHLY_on_the_BYDAY_of_BYMONTH['BYMONTH'] = array(
|
||||
$monthly_on_the_byday_of_bymonth['BYMONTH'] = array(
|
||||
'#type' => 'checkboxes',
|
||||
'#title' => t('Bymonth', array(), array('context' => 'Date repeat')),
|
||||
'#title_display' => 'invisible',
|
||||
'#default_value' => !empty($rrule['BYMONTH']) && $rrule['FREQ'] === 'MONTHLY' && $MONTHLY_day_month_default === 'BYDAY_BYMONTH' ? $rrule['BYMONTH'] : array(),
|
||||
'#default_value' => !empty($rrule['BYMONTH']) && $rrule['FREQ'] === 'MONTHLY' && $monthly_day_month_default === 'BYDAY_BYMONTH' ? $rrule['BYMONTH'] : array(),
|
||||
'#options' => date_month_names_abbr(TRUE),
|
||||
'#attributes' => array('class' => array('container-inline')),
|
||||
'#multiple' => TRUE,
|
||||
@@ -361,31 +366,31 @@ function _date_repeat_rrule_process($element, &$form_state, $form) {
|
||||
),
|
||||
),
|
||||
'#attributes' => array('class' => array('date-repeat-radios clearfix')),
|
||||
'#default_value' => $MONTHLY_day_month_default,
|
||||
'#default_value' => $monthly_day_month_default,
|
||||
'#options' => array(
|
||||
'BYMONTHDAY_BYMONTH' => t('On day ... of ...'),
|
||||
'BYDAY_BYMONTH' => t('On the ... of ...'),
|
||||
),
|
||||
'BYMONTHDAY_BYMONTH_child' => $MONTHLY_on_day_BYMONTHDAY_of_BYMONTH,
|
||||
'BYDAY_BYMONTH_child' => $MONTHLY_on_the_BYDAY_of_BYMONTH,
|
||||
'BYMONTHDAY_BYMONTH_child' => $monthly_on_day_bymonthday_of_bymonth,
|
||||
'BYDAY_BYMONTH_child' => $monthly_on_the_byday_of_bymonth,
|
||||
'#div_classes' => array(
|
||||
'date-repeat-radios-item date-clear clearfix bymonthday-bymonth',
|
||||
'date-repeat-radios-item date-clear clearfix byday-bymonth',
|
||||
),
|
||||
);
|
||||
|
||||
$YEARLY_day_month_default = 'BYMONTHDAY_BYMONTH';
|
||||
$yearly_day_month_default = 'BYMONTHDAY_BYMONTH';
|
||||
if (isset($rrule['FREQ']) && $rrule['FREQ'] === 'YEARLY' && !empty($rrule['BYDAY'])) {
|
||||
$YEARLY_day_month_default = 'BYDAY_BYMONTH';
|
||||
$yearly_day_month_default = 'BYDAY_BYMONTH';
|
||||
}
|
||||
|
||||
$YEARLY_on_day_BYMONTHDAY_of_BYMONTH = array(
|
||||
$yearly_on_day_bymonthday_of_bymonth = array(
|
||||
'#type' => 'container',
|
||||
'#tree' => TRUE,
|
||||
);
|
||||
|
||||
list($bymonthday_title, $bymonthday_suffix) = explode('@bymonthday', t('On day @bymonthday of', array(), array('context' => 'Date repeat')));
|
||||
$YEARLY_on_day_BYMONTHDAY_of_BYMONTH['BYMONTHDAY'] = array(
|
||||
$yearly_on_day_bymonthday_of_bymonth['BYMONTHDAY'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => $bymonthday_title,
|
||||
'#default_value' => !empty($rrule['BYMONTHDAY']) && $rrule['FREQ'] === 'YEARLY' ? $rrule['BYMONTHDAY'] : '',
|
||||
@@ -396,11 +401,11 @@ function _date_repeat_rrule_process($element, &$form_state, $form) {
|
||||
'#field_suffix' => $bymonthday_suffix,
|
||||
);
|
||||
|
||||
$YEARLY_on_day_BYMONTHDAY_of_BYMONTH['BYMONTH'] = array(
|
||||
$yearly_on_day_bymonthday_of_bymonth['BYMONTH'] = array(
|
||||
'#type' => 'checkboxes',
|
||||
'#title' => t('Bymonth', array(), array('context' => 'Date repeat')),
|
||||
'#title_display' => 'invisible',
|
||||
'#default_value' => !empty($rrule['BYMONTH']) && $rrule['FREQ'] === 'YEARLY' && $YEARLY_day_month_default === 'BYMONTHDAY_BYMONTH' ? $rrule['BYMONTH'] : array(),
|
||||
'#default_value' => !empty($rrule['BYMONTH']) && $rrule['FREQ'] === 'YEARLY' && $yearly_day_month_default === 'BYMONTHDAY_BYMONTH' ? $rrule['BYMONTH'] : array(),
|
||||
'#options' => date_month_names_abbr(TRUE),
|
||||
'#attributes' => array('class' => array('container-inline')),
|
||||
'#multiple' => TRUE,
|
||||
@@ -408,45 +413,45 @@ function _date_repeat_rrule_process($element, &$form_state, $form) {
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
|
||||
$YEARLY_on_the_BYDAY_of_BYMONTH = array(
|
||||
$yearly_on_the_byday_of_bymonth = array(
|
||||
'#type' => 'container',
|
||||
'#tree' => TRUE,
|
||||
);
|
||||
|
||||
$YEARLY_BYDAY_COUNT = '';
|
||||
$YEARLY_BYDAY_DAY = '';
|
||||
$yearly_byday_count = '';
|
||||
$yearly_byday_day = '';
|
||||
if (isset($rrule['BYDAY']) && !empty($rrule['BYDAY']) && $rrule['FREQ'] === 'YEARLY') {
|
||||
$YEARLY_BYDAY_COUNT = substr($rrule['BYDAY'][0], 0, -2);
|
||||
$YEARLY_BYDAY_DAY = substr($rrule['BYDAY'][0], -2);;
|
||||
$yearly_byday_count = substr($rrule['BYDAY'][0], 0, -2);
|
||||
$yearly_byday_day = substr($rrule['BYDAY'][0], -2);;
|
||||
}
|
||||
|
||||
list($byday_count_title, $byday_day_title) = explode('@byday', t('On the @byday of', array(), array('context' => 'Date repeat')));
|
||||
$YEARLY_on_the_BYDAY_of_BYMONTH['BYDAY_COUNT'] = array(
|
||||
$yearly_on_the_byday_of_bymonth['BYDAY_COUNT'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => $byday_count_title,
|
||||
'#default_value' => !empty($YEARLY_BYDAY_COUNT) ? $YEARLY_BYDAY_COUNT : '',
|
||||
'#default_value' => !empty($yearly_byday_count) ? $yearly_byday_count : '',
|
||||
'#options' => date_order_translated(),
|
||||
'#multiple' => FALSE,
|
||||
'#prefix' => '<div class="date-repeat-input byday-count">',
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
|
||||
$YEARLY_on_the_BYDAY_of_BYMONTH['BYDAY_DAY'] = array(
|
||||
$yearly_on_the_byday_of_bymonth['BYDAY_DAY'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => $byday_day_title,
|
||||
'#title_display' => 'after',
|
||||
'#default_value' => !empty($YEARLY_BYDAY_DAY) ? $YEARLY_BYDAY_DAY : '',
|
||||
'#default_value' => !empty($yearly_byday_day) ? $yearly_byday_day : '',
|
||||
'#options' => date_repeat_dow_day_options(TRUE),
|
||||
'#multiple' => FALSE,
|
||||
'#prefix' => '<div class="date-repeat-input byday-day">',
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
|
||||
$YEARLY_on_the_BYDAY_of_BYMONTH['BYMONTH'] = array(
|
||||
$yearly_on_the_byday_of_bymonth['BYMONTH'] = array(
|
||||
'#type' => 'checkboxes',
|
||||
'#title' => t('Bymonth', array(), array('context' => 'Date repeat')),
|
||||
'#title_display' => 'invisible',
|
||||
'#default_value' => !empty($rrule['BYMONTH']) && $rrule['FREQ'] === 'YEARLY' && $YEARLY_day_month_default === 'BYDAY_BYMONTH' ? $rrule['BYMONTH'] : array(),
|
||||
'#default_value' => !empty($rrule['BYMONTH']) && $rrule['FREQ'] === 'YEARLY' && $yearly_day_month_default === 'BYDAY_BYMONTH' ? $rrule['BYMONTH'] : array(),
|
||||
'#options' => date_month_names_abbr(TRUE),
|
||||
'#attributes' => array('class' => array('container-inline')),
|
||||
'#multiple' => TRUE,
|
||||
@@ -465,13 +470,13 @@ function _date_repeat_rrule_process($element, &$form_state, $form) {
|
||||
),
|
||||
),
|
||||
'#attributes' => array('class' => array('date-repeat-radios clearfix')),
|
||||
'#default_value' => $YEARLY_day_month_default,
|
||||
'#default_value' => $yearly_day_month_default,
|
||||
'#options' => array(
|
||||
'BYMONTHDAY_BYMONTH' => t('On day ... of ...'),
|
||||
'BYDAY_BYMONTH' => t('On the ... of ...'),
|
||||
),
|
||||
'BYMONTHDAY_BYMONTH_child' => $YEARLY_on_day_BYMONTHDAY_of_BYMONTH,
|
||||
'BYDAY_BYMONTH_child' => $YEARLY_on_the_BYDAY_of_BYMONTH,
|
||||
'BYMONTHDAY_BYMONTH_child' => $yearly_on_day_bymonthday_of_bymonth,
|
||||
'BYDAY_BYMONTH_child' => $yearly_on_the_byday_of_bymonth,
|
||||
'#div_classes' => array(
|
||||
'date-repeat-radios-item date-clear clearfix bymonthday-bymonth',
|
||||
'date-repeat-radios-item date-clear clearfix byday-bymonth',
|
||||
@@ -482,7 +487,7 @@ function _date_repeat_rrule_process($element, &$form_state, $form) {
|
||||
$count_form_element = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Count', array(), array('context' => 'Date repeat')),
|
||||
'#default_value' => $COUNT,
|
||||
'#default_value' => $count,
|
||||
'#element_validate' => array('element_validate_integer_positive'),
|
||||
'#attributes' => array('placeholder' => array('#')),
|
||||
'#prefix' => $prefix,
|
||||
@@ -499,21 +504,26 @@ function _date_repeat_rrule_process($element, &$form_state, $form) {
|
||||
'#type' => $element['#date_repeat_widget'],
|
||||
'#title' => t('Until', array(), array('context' => 'Date repeat')),
|
||||
'#title_display' => 'invisible',
|
||||
'#default_value' => $UNTIL,
|
||||
'#date_format' => !empty($element['#date_format']) ? date_limit_format($element['#date_format'], array('year', 'month', 'day')) : 'Y-m-d',
|
||||
'#default_value' => $until,
|
||||
'#date_format' => !empty($element['#date_format']) ?
|
||||
date_limit_format($element['#date_format'], array('year', 'month', 'day')) : 'Y-m-d',
|
||||
'#date_timezone' => $timezone,
|
||||
'#date_text_parts' => !empty($element['#date_text_parts']) ? $element['#date_text_parts'] : array(),
|
||||
'#date_year_range' => !empty($element['#date_year_range']) ? $element['#date_year_range'] : '-3:+3',
|
||||
'#date_label_position' => !empty($element['#date_label_position']) ? $element['#date_label_position'] : 'within',
|
||||
'#date_label_position' => !empty($element['#date_label_position']) ?
|
||||
$element['#date_label_position'] : 'within',
|
||||
'#date_flexible' => 0,
|
||||
),
|
||||
'tz' => array('#type' => 'hidden', '#value' => $element['#date_timezone']),
|
||||
'all_day' => array('#type' => 'hidden', '#value' => 1),
|
||||
'granularity' => array('#type' => 'hidden', '#value' => serialize(array('year', 'month', 'day'))),
|
||||
'granularity' => array(
|
||||
'#type' => 'hidden',
|
||||
'#value' => serialize(array('year', 'month', 'day')),
|
||||
),
|
||||
);
|
||||
|
||||
$range_of_repeat_default = 'COUNT';
|
||||
if (!empty($UNTIL)) {
|
||||
if (!empty($until)) {
|
||||
$range_of_repeat_default = 'UNTIL';
|
||||
}
|
||||
$element['range_of_repeat'] = array(
|
||||
@@ -528,7 +538,7 @@ function _date_repeat_rrule_process($element, &$form_state, $form) {
|
||||
":input[name=\"{$element['#name']}[FREQ]\"]" => array('value' => 'NONE'),
|
||||
),
|
||||
),
|
||||
'#default_value' => $range_of_repeat_default,
|
||||
'#default_value' => $range_of_repeat_default,
|
||||
'#options' => array(
|
||||
'COUNT' => t('Count'),
|
||||
'UNTIL' => t('Until'),
|
||||
@@ -544,7 +554,8 @@ function _date_repeat_rrule_process($element, &$form_state, $form) {
|
||||
$parents = $element['#array_parents'];
|
||||
$instance = implode('-', $parents);
|
||||
|
||||
// Make sure this will work right either in the normal form or in an ajax callback from the 'Add more' button.
|
||||
// Make sure this will work right either in the normal
|
||||
// form or in an ajax callback from the 'Add more' button.
|
||||
if (empty($form_state['num_exceptions'][$instance])) {
|
||||
$form_state['num_exceptions'][$instance] = count($exceptions);
|
||||
}
|
||||
@@ -576,33 +587,48 @@ function _date_repeat_rrule_process($element, &$form_state, $form) {
|
||||
),
|
||||
),
|
||||
);
|
||||
for ($i = 0; $i < max($form_state['num_exceptions'][$instance], 1) ; $i++) {
|
||||
$EXCEPT = '';
|
||||
for ($i = 0; $i < max($form_state['num_exceptions'][$instance], 1); $i++) {
|
||||
$except = '';
|
||||
if (!empty($exceptions[$i]['datetime'])) {
|
||||
$ex_date = new DateObject($exceptions[$i]['datetime'], $exceptions[$i]['tz']);
|
||||
date_timezone_set($ex_date, timezone_open($timezone));
|
||||
$EXCEPT = date_format($ex_date, DATE_FORMAT_DATETIME);
|
||||
$except = date_format($ex_date, DATE_FORMAT_DATETIME);
|
||||
}
|
||||
$date_format = 'Y-m-d';
|
||||
if (!empty($element['#date_format'])) {
|
||||
$grans = array('year', 'month', 'day');
|
||||
$date_format = date_limit_format($element['#date_format'], $grans);
|
||||
}
|
||||
$element['exceptions']['EXDATE'][$i] = array(
|
||||
'#tree' => TRUE,
|
||||
'datetime' => array(
|
||||
'#name' => 'exceptions|' . $instance,
|
||||
'#type' => $element['#date_repeat_widget'],
|
||||
'#default_value' => $EXCEPT,
|
||||
'#date_timezone' => !empty($element['#date_timezone']) ? $element['#date_timezone'] : date_default_timezone(),
|
||||
'#date_format' => !empty($element['#date_format']) ? date_limit_format($element['#date_format'], array('year', 'month', 'day')) : 'Y-m-d',
|
||||
'#default_value' => $except,
|
||||
'#date_timezone' => !empty($element['#date_timezone']) ?
|
||||
$element['#date_timezone'] : date_default_timezone(),
|
||||
'#date_format' => $date_format,
|
||||
'#date_text_parts' => !empty($element['#date_text_parts']) ? $element['#date_text_parts'] : array(),
|
||||
'#date_year_range' => !empty($element['#date_year_range']) ? $element['#date_year_range'] : '-3:+3',
|
||||
'#date_label_position' => !empty($element['#date_label_position']) ? $element['#date_label_position'] : 'within',
|
||||
'#date_flexible' => 0,
|
||||
),
|
||||
'tz' => array('#type' => 'hidden', '#value' => $element['#date_timezone']),
|
||||
'all_day' => array('#type' => 'hidden', '#value' => 1),
|
||||
'granularity' => array('#type' => 'hidden', '#value' => serialize(array('year', 'month', 'day'))),
|
||||
);
|
||||
),
|
||||
'tz' => array(
|
||||
'#type' => 'hidden',
|
||||
'#value' => $element['#date_timezone'],
|
||||
),
|
||||
'all_day' => array(
|
||||
'#type' => 'hidden',
|
||||
'#value' => 1,
|
||||
),
|
||||
'granularity' => array(
|
||||
'#type' => 'hidden',
|
||||
'#value' => serialize(array('year', 'month', 'day')),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// collect additions in the same way as exceptions - implements RDATE.
|
||||
// Collect additions in the same way as exceptions - implements RDATE.
|
||||
if (empty($form_state['num_additions'][$instance])) {
|
||||
$form_state['num_additions'][$instance] = count($additions);
|
||||
}
|
||||
@@ -634,30 +660,45 @@ function _date_repeat_rrule_process($element, &$form_state, $form) {
|
||||
),
|
||||
),
|
||||
);
|
||||
for ($i = 0; $i < max($form_state['num_additions'][$instance], 1) ; $i++) {
|
||||
$RDATE = '';
|
||||
for ($i = 0; $i < max($form_state['num_additions'][$instance], 1); $i++) {
|
||||
$r_date = '';
|
||||
if (!empty($additions[$i]['datetime'])) {
|
||||
$rdate = new DateObject($additions[$i]['datetime'], $additions[$i]['tz']);
|
||||
date_timezone_set($rdate, timezone_open($timezone));
|
||||
$RDATE = date_format($rdate, DATE_FORMAT_DATETIME);
|
||||
$r_date = date_format($rdate, DATE_FORMAT_DATETIME);
|
||||
}
|
||||
$date_format = 'Y-m-d';
|
||||
if (!empty($element['#date_format'])) {
|
||||
$grans = array('year', 'month', 'day');
|
||||
$date_format = date_limit_format($element['#date_format'], $grans);
|
||||
}
|
||||
$element['additions']['RDATE'][$i] = array(
|
||||
'#tree' => TRUE,
|
||||
'datetime' => array(
|
||||
'#type' => $element['#date_repeat_widget'],
|
||||
'#name' => 'additions|' . $instance,
|
||||
'#default_value' => $RDATE,
|
||||
'#date_timezone' => !empty($element['#date_timezone']) ? $element['#date_timezone'] : date_default_timezone(),
|
||||
'#date_format' => !empty($element['#date_format']) ? date_limit_format($element['#date_format'], array('year', 'month', 'day')) : 'Y-m-d',
|
||||
'#default_value' => $r_date,
|
||||
'#date_timezone' => !empty($element['#date_timezone']) ?
|
||||
$element['#date_timezone'] : date_default_timezone(),
|
||||
'#date_format' => $date_format,
|
||||
'#date_text_parts' => !empty($element['#date_text_parts']) ? $element['#date_text_parts'] : array(),
|
||||
'#date_year_range' => !empty($element['#date_year_range']) ? $element['#date_year_range'] : '-3:+3',
|
||||
'#date_label_position' => !empty($element['#date_label_position']) ? $element['#date_label_position'] : 'within',
|
||||
'#date_flexible' => 0,
|
||||
),
|
||||
'tz' => array('#type' => 'hidden', '#value' => $element['#date_timezone']),
|
||||
'all_day' => array('#type' => 'hidden', '#value' => 1),
|
||||
'granularity' => array('#type' => 'hidden', '#value' => serialize(array('year', 'month', 'day'))),
|
||||
);
|
||||
),
|
||||
'tz' => array(
|
||||
'#type' => 'hidden',
|
||||
'#value' => $element['#date_timezone'],
|
||||
),
|
||||
'all_day' => array(
|
||||
'#type' => 'hidden',
|
||||
'#value' => 1,
|
||||
),
|
||||
'granularity' => array(
|
||||
'#type' => 'hidden',
|
||||
'#value' => serialize(array('year', 'month', 'day')),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
$element['exceptions']['exceptions_add'] = array(
|
||||
@@ -687,6 +728,9 @@ function _date_repeat_rrule_process($element, &$form_state, $form) {
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add callback to date repeat.
|
||||
*/
|
||||
function date_repeat_add_exception_callback($form, &$form_state) {
|
||||
$parents = $form_state['triggering_element']['#array_parents'];
|
||||
$button_key = array_pop($parents);
|
||||
@@ -694,6 +738,9 @@ function date_repeat_add_exception_callback($form, &$form_state) {
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add addition callback to date repeat.
|
||||
*/
|
||||
function date_repeat_add_addition_callback($form, &$form_state) {
|
||||
$parents = $form_state['triggering_element']['#array_parents'];
|
||||
$button_key = array_pop($parents);
|
||||
@@ -701,6 +748,9 @@ function date_repeat_add_addition_callback($form, &$form_state) {
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add exception to date repeat.
|
||||
*/
|
||||
function date_repeat_add_exception($form, &$form_state) {
|
||||
$parents = $form_state['triggering_element']['#array_parents'];
|
||||
$instance = implode('-', array_slice($parents, 0, count($parents) - 2));
|
||||
@@ -708,6 +758,9 @@ function date_repeat_add_exception($form, &$form_state) {
|
||||
$form_state['rebuild'] = TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add addition to date repeat.
|
||||
*/
|
||||
function date_repeat_add_addition($form, &$form_state) {
|
||||
$parents = $form_state['triggering_element']['#array_parents'];
|
||||
$instance = implode('-', array_slice($parents, 0, count($parents) - 2));
|
||||
@@ -723,8 +776,14 @@ function date_repeat_merge($form_values, $element) {
|
||||
return $form_values;
|
||||
}
|
||||
if (array_key_exists('exceptions', $form_values) || array_key_exists('additions', $form_values)) {
|
||||
if (!array_key_exists('exceptions', $form_values)) $form_values['exceptions'] = array();
|
||||
if (!array_key_exists('additions', $form_values)) $form_values['additions'] = array();
|
||||
if (!array_key_exists('exceptions', $form_values)) {
|
||||
$form_values['exceptions'] = array();
|
||||
}
|
||||
|
||||
if (!array_key_exists('additions', $form_values)) {
|
||||
$form_values['additions'] = array();
|
||||
}
|
||||
|
||||
$form_values = array_merge($form_values, (array) $form_values['exceptions'], (array) $form_values['additions']);
|
||||
unset($form_values['exceptions']);
|
||||
unset($form_values['additions']);
|
||||
@@ -738,18 +797,22 @@ function date_repeat_merge($form_values, $element) {
|
||||
case 'INTERVAL':
|
||||
$form_values['INTERVAL'] = $form_values['daily']['INTERVAL_child'];
|
||||
break;
|
||||
|
||||
case 'every_weekday':
|
||||
$form_values['BYDAY'] = array('MO', 'TU', 'WE', 'TH', 'FR');
|
||||
break;
|
||||
|
||||
case 'every_mo_we_fr':
|
||||
$form_values['BYDAY'] = array('MO', 'WE', 'FR');
|
||||
break;
|
||||
|
||||
case 'every_tu_th':
|
||||
$form_values['BYDAY'] = array('TU', 'TH');
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'WEEKLY':
|
||||
if (array_key_exists('weekly', $form_values)) {
|
||||
$form_values = array_merge($form_values, (array) $form_values['weekly']);
|
||||
@@ -758,12 +821,14 @@ function date_repeat_merge($form_values, $element) {
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'MONTHLY':
|
||||
if (array_key_exists('monthly', $form_values)) {
|
||||
switch ($form_values['monthly']['day_month']) {
|
||||
case 'BYMONTHDAY_BYMONTH':
|
||||
$form_values['monthly'] = array_merge($form_values['monthly'], (array) $form_values['monthly']['BYMONTHDAY_BYMONTH_child']);
|
||||
break;
|
||||
|
||||
case 'BYDAY_BYMONTH':
|
||||
$form_values['monthly']['BYDAY_BYMONTH_child']['BYDAY'] = $form_values['monthly']['BYDAY_BYMONTH_child']['BYDAY_COUNT'] . $form_values['monthly']['BYDAY_BYMONTH_child']['BYDAY_DAY'];
|
||||
$form_values['monthly'] = array_merge($form_values['monthly'], (array) $form_values['monthly']['BYDAY_BYMONTH_child']);
|
||||
@@ -783,12 +848,14 @@ function date_repeat_merge($form_values, $element) {
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'YEARLY':
|
||||
if (array_key_exists('yearly', $form_values)) {
|
||||
switch ($form_values['yearly']['day_month']) {
|
||||
case 'BYMONTHDAY_BYMONTH':
|
||||
$form_values['yearly'] = array_merge($form_values['yearly'], (array) $form_values['yearly']['BYMONTHDAY_BYMONTH_child']);
|
||||
break;
|
||||
|
||||
case 'BYDAY_BYMONTH':
|
||||
$form_values['yearly']['BYDAY_BYMONTH_child']['BYDAY'] = $form_values['yearly']['BYDAY_BYMONTH_child']['BYDAY_COUNT'] . $form_values['yearly']['BYDAY_BYMONTH_child']['BYDAY_DAY'];
|
||||
$form_values['yearly'] = array_merge($form_values['yearly'], (array) $form_values['yearly']['BYDAY_BYMONTH_child']);
|
||||
@@ -808,6 +875,7 @@ function date_repeat_merge($form_values, $element) {
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -823,6 +891,7 @@ function date_repeat_merge($form_values, $element) {
|
||||
case 'COUNT':
|
||||
$form_values['COUNT'] = $form_values['count_child'];
|
||||
break;
|
||||
|
||||
case 'UNTIL':
|
||||
$form_values['UNTIL'] = $form_values['until_child'];
|
||||
break;
|
||||
@@ -832,14 +901,23 @@ function date_repeat_merge($form_values, $element) {
|
||||
unset($form_values['count_child']);
|
||||
unset($form_values['until_child']);
|
||||
|
||||
if (array_key_exists('BYDAY', $form_values) && is_array($form_values['BYDAY'])) unset($form_values['BYDAY']['']);
|
||||
if (array_key_exists('BYMONTH', $form_values) && is_array($form_values['BYMONTH'])) unset($form_values['BYMONTH']['']);
|
||||
if (array_key_exists('BYMONTHDAY', $form_values) && is_array($form_values['BYMONTHDAY'])) unset($form_values['BYMONTHDAY']['']);
|
||||
if (array_key_exists('BYDAY', $form_values) && is_array($form_values['BYDAY'])) {
|
||||
unset($form_values['BYDAY']['']);
|
||||
}
|
||||
|
||||
if (array_key_exists('BYMONTH', $form_values) && is_array($form_values['BYMONTH'])) {
|
||||
unset($form_values['BYMONTH']['']);
|
||||
}
|
||||
|
||||
if (array_key_exists('BYMONTHDAY', $form_values) && is_array($form_values['BYMONTHDAY'])) {
|
||||
unset($form_values['BYMONTHDAY']['']);
|
||||
}
|
||||
|
||||
if (array_key_exists('UNTIL', $form_values) && is_array($form_values['UNTIL']['datetime'])) {
|
||||
$function = $element['#date_repeat_widget'] . '_input_date';
|
||||
$until_element = $element;
|
||||
$until_element['#date_format'] = !empty($element['#date_format']) ? date_limit_format($element['#date_format'], array('year', 'month', 'day')) : 'Y-m-d';
|
||||
$until_element['#date_format'] = !empty($element['#date_format']) ?
|
||||
date_limit_format($element['#date_format'], array('year', 'month', 'day')) : 'Y-m-d';
|
||||
$date = $function($until_element, $form_values['UNTIL']['datetime']);
|
||||
$form_values['UNTIL']['datetime'] = is_object($date) ? $date->format(DATE_FORMAT_DATETIME) : '';
|
||||
}
|
||||
@@ -849,9 +927,14 @@ function date_repeat_merge($form_values, $element) {
|
||||
if (array_key_exists('EXDATE', $form_values) && is_array($form_values['EXDATE'])) {
|
||||
$function = $element['#date_repeat_widget'] . '_input_date';
|
||||
$exdate_element = $element;
|
||||
$date_format = 'Y-m-d';
|
||||
if (!empty($element['#date_format'])) {
|
||||
$grans = array('year', 'month', 'day');
|
||||
$date_format = date_limit_format($element['#date_format'], $grans);
|
||||
}
|
||||
foreach ($form_values['EXDATE'] as $delta => $value) {
|
||||
if (is_array($value['datetime'])) {
|
||||
$exdate_element['#date_format'] = !empty($element['#date_format']) ? date_limit_format($element['#date_format'], array('year', 'month', 'day')) : 'Y-m-d';
|
||||
$exdate_element['#date_format'] = $date_format;
|
||||
$date = $function($exdate_element, $form_values['EXDATE'][$delta]['datetime']);
|
||||
$form_values['EXDATE'][$delta]['datetime'] = is_object($date) ? $date->format(DATE_FORMAT_DATETIME) : '';
|
||||
}
|
||||
@@ -864,9 +947,14 @@ function date_repeat_merge($form_values, $element) {
|
||||
if (array_key_exists('RDATE', $form_values) && is_array($form_values['RDATE'])) {
|
||||
$function = $element['#date_repeat_widget'] . '_input_date';
|
||||
$rdate_element = $element;
|
||||
$date_format = 'Y-m-d';
|
||||
if (!empty($element['#date_format'])) {
|
||||
$grans = array('year', 'month', 'day');
|
||||
$date_format = date_limit_format($element['#date_format'], $grans);
|
||||
}
|
||||
foreach ($form_values['RDATE'] as $delta => $value) {
|
||||
if (is_array($value['datetime'])) {
|
||||
$rdate_element['#date_format'] = !empty($element['#date_format']) ? date_limit_format($element['#date_format'], array('year', 'month', 'day')) : 'Y-m-d';
|
||||
$rdate_element['#date_format'] = $date_format;
|
||||
$date = $function($rdate_element, $form_values['RDATE'][$delta]['datetime']);
|
||||
$form_values['RDATE'][$delta]['datetime'] = is_object($date) ? $date->format(DATE_FORMAT_DATETIME) : '';
|
||||
}
|
||||
@@ -910,7 +998,7 @@ function date_repeat_rrule_validate($element, &$form_state) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Theme the exception list as a table so the buttons line up
|
||||
* Theme the exception list as a table so the buttons line up.
|
||||
*/
|
||||
function theme_date_repeat_current_exceptions($vars) {
|
||||
$rows = $vars['rows'];
|
||||
@@ -920,11 +1008,14 @@ function theme_date_repeat_current_exceptions($vars) {
|
||||
$rows_info[] = array(drupal_render($value['action']), drupal_render($value['display']));
|
||||
}
|
||||
}
|
||||
return theme('table', array('header' => array(t('Delete'), t('Current exceptions')), 'rows' => $rows_info));
|
||||
return theme('table', array(
|
||||
'header' => array(t('Delete'), t('Current exceptions')),
|
||||
'rows' => $rows_info)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Theme the exception list as a table so the buttons line up
|
||||
/**
|
||||
* Theme the exception list as a table so the buttons line up.
|
||||
*/
|
||||
function theme_date_repeat_current_additions($rows = array()) {
|
||||
$rows_info = array();
|
||||
@@ -933,7 +1024,10 @@ function theme_date_repeat_current_additions($rows = array()) {
|
||||
$rows_info[] = array(drupal_render($value['action']), drupal_render($value['display']));
|
||||
}
|
||||
}
|
||||
return theme('table', array('header' => array(t('Delete'), t('Current additions')), 'rows' => $rows_info));
|
||||
return theme('table', array(
|
||||
'header' => array(t('Delete'), t('Current additions')),
|
||||
'rows' => $rows_info)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -943,7 +1037,13 @@ function theme_date_repeat_rrule($vars) {
|
||||
$element = $vars['element'];
|
||||
$id = drupal_html_id('repeat-settings-fieldset');
|
||||
$parents = $element['#parents'];
|
||||
$selector = "{$parents[0]}[{$parents[1]}][{$parents[2]}][show_repeat_settings]";
|
||||
|
||||
$selector = $parents[0];
|
||||
for ($i = 1; $i < count($parents) - 1; $i++) {
|
||||
$selector .= '[' . $parents[$i] . ']';
|
||||
}
|
||||
$selector .= '[show_repeat_settings]';
|
||||
|
||||
$fieldset = array(
|
||||
'#type' => 'item',
|
||||
'#title' => t('Repeat settings'),
|
||||
@@ -960,6 +1060,9 @@ function theme_date_repeat_rrule($vars) {
|
||||
return drupal_render($fieldset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter non zero values.
|
||||
*/
|
||||
function date_repeat_filter_non_zero_value($value) {
|
||||
return $value !== 0;
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/*
|
||||
/**
|
||||
* @file
|
||||
* Handling of devel generate functionality for repeating dates.
|
||||
*/
|
||||
@@ -42,9 +42,11 @@ function date_repeat_field_date_field_insert(&$items, $context) {
|
||||
case 'date':
|
||||
$format = DATE_FORMAT_ISO;
|
||||
break;
|
||||
|
||||
case 'datestamp':
|
||||
$format = DATE_FORMAT_UNIX;
|
||||
break;
|
||||
|
||||
case 'datetime':
|
||||
$format = DATE_FORMAT_DATETIME;
|
||||
break;
|
||||
@@ -78,6 +80,7 @@ function date_repeat_field_date_field_insert(&$items, $context) {
|
||||
}
|
||||
$form_values['BYMONTHDAY'] = array($mo);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
$mo = mt_rand(1, 12);
|
||||
$options = array('YEARLY', 'MONTHLY');
|
||||
@@ -90,6 +93,7 @@ function date_repeat_field_date_field_insert(&$items, $context) {
|
||||
}
|
||||
$form_values['BYMONTH'] = array($mo);
|
||||
break;
|
||||
|
||||
default:
|
||||
$dows = array_keys(date_content_repeat_dow_options());
|
||||
$day = date_content_generate_key($dows);
|
||||
@@ -108,16 +112,18 @@ function date_repeat_field_date_field_insert(&$items, $context) {
|
||||
case 'YEARLY':
|
||||
$period = 'year';
|
||||
break;
|
||||
|
||||
case 'MONTHLY':
|
||||
$period = 'month';
|
||||
break;
|
||||
|
||||
case 'WEEKLY':
|
||||
$period = 'week';
|
||||
break;
|
||||
|
||||
default:
|
||||
$period = 'day';
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
$form_values['UNTIL'] = array();
|
||||
@@ -126,12 +132,15 @@ function date_repeat_field_date_field_insert(&$items, $context) {
|
||||
$rrule = date_api_ical_build_rrule($form_values);
|
||||
$items[0]['rrule'] = $rrule;
|
||||
|
||||
$values = date_repeat_build_dates($rrule, $form_values, $field, $item);
|
||||
$values = date_repeat_build_dates($field, $item, $rrule, $form_values);
|
||||
|
||||
$items += $values;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a random content keys.
|
||||
*/
|
||||
function date_content_generate_key($array) {
|
||||
$keys = array_keys($array);
|
||||
$min = array_shift($keys);
|
||||
@@ -155,4 +164,4 @@ function date_content_repeat_dow_options() {
|
||||
}
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
|
@@ -7,9 +7,9 @@ stylesheets[all][] = date_repeat_field.css
|
||||
package = Date/Time
|
||||
core = 7.x
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-07-29
|
||||
version = "7.x-2.8"
|
||||
; Information added by Drupal.org packaging script on 2015-09-08
|
||||
version = "7.x-2.9"
|
||||
core = "7.x"
|
||||
project = "date"
|
||||
datestamp = "1406653438"
|
||||
datestamp = "1441727353"
|
||||
|
||||
|
@@ -77,13 +77,13 @@ function date_repeat_field_menu() {
|
||||
$path = field_collection_field_get_path($field);
|
||||
$count = count(explode('/', $path));
|
||||
$items[$path . '/%field_collection_item/repeats'] = array(
|
||||
'title' => 'Repeats',
|
||||
'page callback' => 'date_repeat_field_page',
|
||||
'page arguments' => array($entity_type, $count),
|
||||
'access callback' => 'date_repeat_field_show',
|
||||
'access arguments' => array($entity_type, $count),
|
||||
'type' => MENU_LOCAL_TASK,
|
||||
'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
|
||||
'title' => 'Repeats',
|
||||
'page callback' => 'date_repeat_field_page',
|
||||
'page arguments' => array($entity_type, $count),
|
||||
'access callback' => 'date_repeat_field_show',
|
||||
'access arguments' => array($entity_type, $count),
|
||||
'type' => MENU_LOCAL_TASK,
|
||||
'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -91,13 +91,13 @@ function date_repeat_field_menu() {
|
||||
else {
|
||||
$path = $entity_type . '/%' . $entity_type;
|
||||
$items[$path . '/repeats'] = array(
|
||||
'title' => 'Repeats',
|
||||
'page callback' => 'date_repeat_field_page',
|
||||
'page arguments' => array($entity_type, 1),
|
||||
'access callback' => 'date_repeat_field_show',
|
||||
'access arguments' => array($entity_type, 1),
|
||||
'type' => MENU_LOCAL_TASK,
|
||||
'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
|
||||
'title' => 'Repeats',
|
||||
'page callback' => 'date_repeat_field_page',
|
||||
'page arguments' => array($entity_type, 1),
|
||||
'access callback' => 'date_repeat_field_show',
|
||||
'access arguments' => array($entity_type, 1),
|
||||
'type' => MENU_LOCAL_TASK,
|
||||
'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -108,10 +108,12 @@ function date_repeat_field_menu() {
|
||||
* Implements hook_permission().
|
||||
*/
|
||||
function date_repeat_field_permission() {
|
||||
return array('view date repeats' => array(
|
||||
'title' => t('View Repeating Dates'),
|
||||
'description' => t('Allow user to see a page with all the times a date repeats.'),
|
||||
));
|
||||
return array(
|
||||
'view date repeats' => array(
|
||||
'title' => t('View Repeating Dates'),
|
||||
'description' => t('Allow user to see a page with all the times a date repeats.'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -195,6 +197,9 @@ function date_repeat_field_bundles() {
|
||||
return $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check field is repeat.
|
||||
*/
|
||||
function date_is_repeat_field($field, $instance = NULL) {
|
||||
if (is_string($field)) {
|
||||
$field = field_info_field($field);
|
||||
@@ -215,7 +220,7 @@ function date_is_repeat_field($field, $instance = NULL) {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Implements hook_date_field_insert_alter().
|
||||
*/
|
||||
function date_repeat_field_date_field_insert_alter(&$items, $context) {
|
||||
@@ -239,7 +244,7 @@ function date_repeat_field_date_field_insert_alter(&$items, $context) {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Implements hook_date_field_update_alter().
|
||||
*/
|
||||
function date_repeat_field_date_field_update_alter(&$items, $context) {
|
||||
@@ -279,6 +284,13 @@ function date_repeat_field_field_widget_form_alter(&$element, &$form_state, $con
|
||||
'#suffix' => '</div>',
|
||||
'#default_value' => isset($items[$delta]['rrule']) && !empty($items[$delta]['rrule']) ? 1 : 0,
|
||||
);
|
||||
|
||||
// Make changes if instance is set to be rendered as a regular field.
|
||||
if (!empty($instance['widget']['settings']['no_fieldset'])) {
|
||||
$element['#title'] = check_plain($instance['label']);
|
||||
$element['#description'] = field_filter_xss($instance['description']);
|
||||
$element['#theme_wrappers'] = array('date_form_element');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -340,13 +352,14 @@ function date_repeat_field_widget_validate($element, &$form_state) {
|
||||
// The RRULE has already been created by this point, so go back
|
||||
// to the posted values to see if this was filled out.
|
||||
$error_field_base = implode('][', $element['#parents']);
|
||||
$error_field_until = $error_field_base . '][rrule][until_child][datetime][';
|
||||
$error_field_until = $error_field_base . '][rrule][until_child][datetime][';
|
||||
if (!empty($item['rrule']) && $rrule_values['range_of_repeat'] === 'UNTIL' && empty($rrule_values['UNTIL']['datetime'])) {
|
||||
switch ($instance['widget']['type']) {
|
||||
case 'date_text':
|
||||
case 'date_popup':
|
||||
form_set_error($error_field_until . 'date', t("Missing value in 'Range of repeat'. (UNTIL).", array(), array('context' => 'Date repeat')));
|
||||
break;
|
||||
|
||||
case 'date_select':
|
||||
form_set_error($error_field_until . 'year', t("Missing value in 'Range of repeat': Year (UNTIL)", array(), array('context' => 'Date repeat')));
|
||||
form_set_error($error_field_until . 'month', t("Missing value in 'Range of repeat': Month (UNTIL)", array(), array('context' => 'Date repeat')));
|
||||
@@ -382,8 +395,9 @@ function date_repeat_field_widget_validate($element, &$form_state) {
|
||||
// We only collect a date for UNTIL, but we need it to be inclusive,
|
||||
// so force it to a full datetime element at the last possible second of the day.
|
||||
if (!empty($rrule_values['UNTIL'])) {
|
||||
$gran = array('year', 'month', 'day', 'hour', 'minute', 'second');
|
||||
$rrule_values['UNTIL']['datetime'] .= ' 23:59:59';
|
||||
$rrule_values['UNTIL']['granularity'] = serialize(drupal_map_assoc(array('year', 'month', 'day', 'hour', 'minute', 'second')));
|
||||
$rrule_values['UNTIL']['granularity'] = serialize(drupal_map_assoc($gran));
|
||||
$rrule_values['UNTIL']['all_day'] = 0;
|
||||
}
|
||||
$value = date_repeat_build_dates($rrule, $rrule_values, $field, $item);
|
||||
@@ -418,9 +432,10 @@ function date_repeat_after_build(&$element, &$form_state) {
|
||||
* Pass in either the RRULE or the $form_values array for the RRULE,
|
||||
* whichever is missing will be created when needed.
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
function date_repeat_build_dates($rrule = NULL, $rrule_values = NULL, $field, $item) {
|
||||
|
||||
include_once(DRUPAL_ROOT . '/' . drupal_get_path('module', 'date_api') . '/date_api_ical.inc');
|
||||
// @codingStandardsIgnoreEnd
|
||||
include_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'date_api') . '/date_api_ical.inc';
|
||||
$field_name = $field['field_name'];
|
||||
|
||||
if (empty($rrule)) {
|
||||
@@ -497,8 +512,9 @@ function date_repeat_build_dates($rrule = NULL, $rrule_values = NULL, $field, $i
|
||||
'offset2' => date_offset_get($date_end),
|
||||
'timezone' => $timezone,
|
||||
'rrule' => $rrule,
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
@@ -681,9 +697,8 @@ function date_repeat_field_date_field_widget_settings_form_alter(&$form, $contex
|
||||
'#title' => t('Repeat display', array(), array('context' => 'Date repeat')),
|
||||
'#description' => t("Should the repeat options form start out expanded or collapsed? Set to 'Collapsed' to make those options less obtrusive.", array(), array('context' => 'Date repeat')),
|
||||
'#fieldset' => 'date_format',
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -28,10 +28,14 @@ function date_tools_change_type_form() {
|
||||
// Get the available date fields.
|
||||
foreach ($fields as $field_name => $field) {
|
||||
if ($field['type'] == 'date' || $field['type'] == 'datestamp' || $field['type'] == 'datetime') {
|
||||
$date_options[$labels[$field['type']]][$field_name] = t('Field @label (@field_name)', array('@label' => $field['widget']['label'], '@field_name' => $field_name, '@type' => $labels[$field['type']]));
|
||||
$date_options[$labels[$field['type']]][$field_name] = t('Field @label (@field_name)', array(
|
||||
'@label' => $field['widget']['label'],
|
||||
'@field_name' => $field_name,
|
||||
'@type' => $labels[$field['type']]
|
||||
));
|
||||
}
|
||||
}
|
||||
if (sizeof($date_options) < 1) {
|
||||
if (count($date_options) < 1) {
|
||||
drupal_set_message(t('There are no date fields in this database.'));
|
||||
return $form;
|
||||
}
|
||||
@@ -142,26 +146,31 @@ function date_tools_change_type_form_submit($form, &$form_state) {
|
||||
case 'datestamp':
|
||||
$new_columns[] = $date_handler->sql_format('U', $db_field) . ' AS ' . $info['column'];
|
||||
break;
|
||||
|
||||
case 'datetime':
|
||||
$new_columns[] = $date_handler->sql_format('Y-m-d H:i:s', $db_field) . ' AS ' . $info['column'];
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'datestamp':
|
||||
switch ($new_type) {
|
||||
case 'date':
|
||||
$new_columns[] = $date_handler->sql_format('Y-m-d/TH:i:s', $db_field) . ' AS ' . $info['column'];
|
||||
break;
|
||||
|
||||
case 'datetime':
|
||||
$new_columns[] = $date_handler->sql_format('Y-m-d H:i:s', $db_field) . ' AS ' . $info['column'];
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'datetime':
|
||||
switch ($new_type) {
|
||||
case 'date':
|
||||
$new_columns[] = $date_handler->sql_format('Y-m-d/TH:i:s', $db_field) . ' AS ' . $info['column'];
|
||||
break;
|
||||
|
||||
case 'datestamp':
|
||||
$new_columns[] = $date_handler->sql_format('U', $db_field) . ' AS ' . $info['column'];
|
||||
break;
|
||||
@@ -178,5 +187,9 @@ function date_tools_change_type_form_submit($form, &$form_state) {
|
||||
db_query($sql);
|
||||
db_query("DROP TABLE {" . $temp_table . "}");
|
||||
|
||||
drupal_set_message(t('The field @field_name has been changed from @old_type to @new_type.', array('@field_name' => $field['widget']['label'], '@old_type' => $labels[$old_type], '@new_type' => $labels[$new_type])));
|
||||
drupal_set_message(t('The field @field_name has been changed from @old_type to @new_type.', array(
|
||||
'@field_name' => $field['widget']['label'],
|
||||
'@old_type' => $labels[$old_type],
|
||||
'@new_type' => $labels[$new_type]
|
||||
)));
|
||||
}
|
||||
|
@@ -6,9 +6,9 @@ core = 7.x
|
||||
configure = admin/config/date/tools
|
||||
files[] = tests/date_tools.test
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-07-29
|
||||
version = "7.x-2.8"
|
||||
; Information added by Drupal.org packaging script on 2015-09-08
|
||||
version = "7.x-2.9"
|
||||
core = "7.x"
|
||||
project = "date"
|
||||
datestamp = "1406653438"
|
||||
datestamp = "1441727353"
|
||||
|
||||
|
@@ -31,7 +31,7 @@ function date_tools_help($section, $arg) {
|
||||
*/
|
||||
function date_tools_permission() {
|
||||
return array(
|
||||
'administer date tools' => array(
|
||||
'administer date tools' => array(
|
||||
'title' => t('Administer date tools'),
|
||||
),
|
||||
);
|
||||
@@ -68,6 +68,7 @@ function date_tools_menu() {
|
||||
'file' => 'date_tools.wizard.inc',
|
||||
);
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
/**
|
||||
$items['admin/config/date/tools/change'] = array(
|
||||
'title' => 'Change type',
|
||||
@@ -79,18 +80,18 @@ function date_tools_menu() {
|
||||
'file' => 'date_tools.change_type.inc',
|
||||
);
|
||||
*/
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Main Date Tools page
|
||||
* Main Date Tools page.
|
||||
*/
|
||||
function date_tools_page() {
|
||||
$content = '';
|
||||
|
||||
$content .= t('Dates and calendars can be complicated to set up. The !date_wizard makes it easy to create a simple date content type and related calendar. ', array('!date_wizard' => l(t('Date wizard'), 'admin/config/date/tools/date_wizard')));
|
||||
|
||||
$content .= t('Dates and calendars can be complicated to set up. The !date_wizard makes it easy to create a simple date content type and related calendar.', array('!date_wizard' => l(t('Date wizard'), 'admin/config/date/tools/date_wizard')));
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
@@ -6,6 +6,8 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_form().
|
||||
*
|
||||
* @todo.
|
||||
*/
|
||||
function date_tools_wizard_form() {
|
||||
@@ -59,7 +61,10 @@ function date_tools_wizard_form() {
|
||||
$form['field']['repeat'] = array(
|
||||
'#type' => 'select',
|
||||
'#default_value' => 0,
|
||||
'#options' => array(0 => t('No'), 1 => t('Yes')),
|
||||
'#options' => array(
|
||||
0 => t('No'),
|
||||
1 => t('Yes'),
|
||||
),
|
||||
'#title' => t('Show repeating date options'),
|
||||
'#access' => module_exists('date_repeat_field'),
|
||||
);
|
||||
@@ -72,7 +77,11 @@ function date_tools_wizard_form() {
|
||||
$form['field']['advanced']['todate'] = array(
|
||||
'#type' => 'select',
|
||||
'#default_value' => 'optional',
|
||||
'#options' => array('' => t('Never'), 'optional' => t('Optional'), 'required' => t('Required')),
|
||||
'#options' => array(
|
||||
'' => t('Never'),
|
||||
'optional' => t('Optional'),
|
||||
'required' => t('Required'),
|
||||
),
|
||||
'#title' => t('End Date'),
|
||||
'#description' => t("Display a matching second date field as a 'End date'."),
|
||||
);
|
||||
@@ -106,7 +115,10 @@ function date_tools_wizard_form() {
|
||||
$form['calendar'] = array(
|
||||
'#type' => 'select',
|
||||
'#default_value' => module_exists('calendar'),
|
||||
'#options' => array(0 => t('No'), 1 => t('Yes')),
|
||||
'#options' => array(
|
||||
0 => t('No'),
|
||||
1 => t('Yes'),
|
||||
),
|
||||
'#title' => t('Create a calendar for this date field'),
|
||||
'#access' => module_exists('calendar'),
|
||||
);
|
||||
@@ -119,13 +131,26 @@ function date_tools_wizard_form() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Form validate.
|
||||
*
|
||||
* @todo.
|
||||
*/
|
||||
function date_tools_wizard_form_validate(&$form, &$form_state) {
|
||||
$bundle = $form_state['values']['bundle'];
|
||||
$field_name = 'field_' . $form_state['values']['field_name'];
|
||||
$existing_type = db_query("SELECT type FROM {node_type} WHERE type=:bundle", array(':bundle' => $bundle))->fetchField();
|
||||
$existing_instance = db_query("SELECT field_name FROM {field_config_instance} WHERE field_name=:field_name AND bundle=:bundle AND entity_type=:entity_type", array(':field_name' => $field_name, ':bundle' => $bundle, ':entity_type' => 'node'))->fetchField();
|
||||
|
||||
$args = array(
|
||||
':field_name' => $field_name,
|
||||
':bundle' => $bundle,
|
||||
':entity_type' => 'node',
|
||||
);
|
||||
|
||||
$query = "SELECT type FROM {node_type} WHERE type=:bundle";
|
||||
$existing_type = db_query($query, array(':bundle' => $args[':bundle']))->fetchField();
|
||||
|
||||
$query = "SELECT field_name FROM {field_config_instance} WHERE field_name=:field_name AND bundle=:bundle AND entity_type=:entity_type";
|
||||
$existing_instance = db_query($query, $args)->fetchField();
|
||||
|
||||
if ($existing_type) {
|
||||
drupal_set_message(t('This content type name already exists, adding new field to existing content type.'));
|
||||
}
|
||||
@@ -147,6 +172,8 @@ function date_tools_wizard_form_validate(&$form, &$form_state) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Form submit.
|
||||
*
|
||||
* @todo.
|
||||
*/
|
||||
function date_tools_wizard_form_submit(&$form, &$form_state) {
|
||||
@@ -161,6 +188,8 @@ function date_tools_wizard_form_submit(&$form, &$form_state) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Wizard build.
|
||||
*
|
||||
* @todo.
|
||||
*/
|
||||
function date_tools_wizard_build($form_values) {
|
||||
@@ -201,7 +230,7 @@ function date_tools_wizard_build($form_values) {
|
||||
'timezone_db' => date_get_timezone_db($tz_handling),
|
||||
'repeat' => $repeat,
|
||||
'todate' => !empty($todate) ? $todate : 'optional',
|
||||
),
|
||||
),
|
||||
);
|
||||
$instance = array(
|
||||
'entity_type' => 'node',
|
||||
@@ -275,6 +304,8 @@ function date_tools_wizard_build($form_values) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Includes handler.
|
||||
*
|
||||
* @todo.
|
||||
*/
|
||||
function date_tools_wizard_include() {
|
||||
@@ -285,6 +316,8 @@ function date_tools_wizard_include() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_field_types().
|
||||
*
|
||||
* @todo.
|
||||
*/
|
||||
function date_tools_wizard_field_types() {
|
||||
@@ -296,6 +329,7 @@ function date_tools_wizard_field_types() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_widget_types().
|
||||
* @todo.
|
||||
*/
|
||||
function date_tools_wizard_widget_types() {
|
||||
@@ -309,6 +343,8 @@ function date_tools_wizard_widget_types() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Tz handler.
|
||||
*
|
||||
* @todo.
|
||||
*/
|
||||
function date_tools_wizard_tz_handling() {
|
||||
@@ -317,6 +353,8 @@ function date_tools_wizard_tz_handling() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create date tools wizard content type.
|
||||
*
|
||||
* @todo.
|
||||
*/
|
||||
function date_tools_wizard_create_content_type($name, $bundle, $description, $type_settings = array()) {
|
||||
@@ -332,8 +370,7 @@ function date_tools_wizard_create_content_type($name, $bundle, $description, $ty
|
||||
'body_label' => 'Body',
|
||||
'min_word_count' => '0',
|
||||
'help' => '',
|
||||
'node_options' =>
|
||||
array(
|
||||
'node_options' => array(
|
||||
'status' => 1,
|
||||
'promote' => 1,
|
||||
'sticky' => 0,
|
||||
@@ -374,8 +411,10 @@ function date_tools_wizard_create_content_type($name, $bundle, $description, $ty
|
||||
'weight' => -4,
|
||||
'module' => 'text',
|
||||
),
|
||||
'settings' => array('display_summary' => TRUE),
|
||||
'display' => array(
|
||||
'settings' => array(
|
||||
'display_summary' => TRUE,
|
||||
),
|
||||
'display' => array(
|
||||
'default' => array(
|
||||
'label' => 'hidden',
|
||||
'type' => 'text_default',
|
||||
|
@@ -12,9 +12,9 @@ files[] = includes/date_views_filter_handler_simple.inc
|
||||
files[] = includes/date_views.views.inc
|
||||
files[] = includes/date_views_plugin_pager.inc
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-07-29
|
||||
version = "7.x-2.8"
|
||||
; Information added by Drupal.org packaging script on 2015-09-08
|
||||
version = "7.x-2.9"
|
||||
core = "7.x"
|
||||
project = "date"
|
||||
datestamp = "1406653438"
|
||||
datestamp = "1441727353"
|
||||
|
||||
|
@@ -28,3 +28,27 @@ function date_views_uninstall() {
|
||||
variable_del('date_views_week_format_with_year');
|
||||
variable_del('date_views_week_format_without_year');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default date views variables.
|
||||
*/
|
||||
function date_views_update_7200() {
|
||||
if (!variable_get('date_views_month_format_with_year', FALSE)) {
|
||||
variable_set('date_views_month_format_with_year', 'F Y');
|
||||
}
|
||||
if (!variable_get('date_views_month_format_without_year', FALSE)) {
|
||||
variable_set('date_views_month_format_without_year', 'F');
|
||||
}
|
||||
if (!variable_get('date_views_day_format_with_year', FALSE)) {
|
||||
variable_set('date_views_day_format_with_year', 'l, F j, Y');
|
||||
}
|
||||
if (!variable_get('date_views_day_format_without_year', FALSE)) {
|
||||
variable_set('date_views_day_format_without_year', 'l, F j');
|
||||
}
|
||||
if (!variable_get('date_views_week_format_with_year', FALSE)) {
|
||||
variable_set('date_views_week_format_with_year', 'F j, Y');
|
||||
}
|
||||
if (!variable_get('date_views_week_format_without_year', FALSE)) {
|
||||
variable_set('date_views_week_format_without_year', 'F j');
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,9 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Date Views module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_menu().
|
||||
@@ -11,7 +15,7 @@ function date_views_menu() {
|
||||
'description' => 'Configure settings for date views.',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('date_views_settings'),
|
||||
'access arguments' => array('administer site configuration '),
|
||||
'access arguments' => array('administer site configuration'),
|
||||
'type' => MENU_LOCAL_TASK,
|
||||
);
|
||||
|
||||
@@ -86,13 +90,30 @@ function date_views_theme() {
|
||||
'file' => 'theme.inc',
|
||||
'path' => "$path/theme",
|
||||
);
|
||||
return array(
|
||||
'date_nav_title' => $base + array('variables' => array('granularity' => NULL, 'view' => NULL, 'link' => NULL, 'format' => NULL)),
|
||||
'date_views_filter_form' => $base + array('template' => 'date-views-filter-form', 'render element' => 'form'),
|
||||
'date_calendar_day' => $base + array('variables' => array('date' => NULL)),
|
||||
|
||||
return array(
|
||||
'date_nav_title' => $base + array(
|
||||
'variables' => array(
|
||||
'granularity' => NULL,
|
||||
'view' => NULL,
|
||||
'link' => NULL,
|
||||
'format' => NULL,
|
||||
),
|
||||
),
|
||||
'date_views_filter_form' => $base + array(
|
||||
'template' => 'date-views-filter-form',
|
||||
'render element' => 'form',
|
||||
),
|
||||
'date_calendar_day' => $base + array(
|
||||
'variables' => array(
|
||||
'date' => NULL,
|
||||
),
|
||||
),
|
||||
'date_views_pager' => $base + array(
|
||||
'variables' => array('plugin' => NULL, 'input' => NULL),
|
||||
'variables' => array(
|
||||
'plugin' => NULL,
|
||||
'input' => NULL,
|
||||
),
|
||||
// Register a pattern so that it can work like all views templates.
|
||||
'pattern' => 'date_views_pager__',
|
||||
'template' => 'date-views-pager',
|
||||
@@ -100,6 +121,9 @@ function date_views_theme() {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_views_api().
|
||||
*/
|
||||
function date_views_views_api() {
|
||||
return array(
|
||||
'api' => 3,
|
||||
@@ -119,7 +143,7 @@ function date_views_views_fetch_fields($base, $type) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Identify all potential date/timestamp fields and cache the data.
|
||||
* Identify all potential date/timestamp fields and cache the data.
|
||||
*/
|
||||
function date_views_fields($base = 'node', $reset = FALSE) {
|
||||
static $fields = array();
|
||||
@@ -141,8 +165,8 @@ function date_views_fields($base = 'node', $reset = FALSE) {
|
||||
|
||||
/**
|
||||
* Implements hook_date_views_entities().
|
||||
* Map extra Views tables to the entity that holds its date fields,
|
||||
* needed for Views tables other than the primary tables identified in entity_info().
|
||||
*
|
||||
* Map extra Views tables to the entity that holds its date fields, needed for Views tables other than the primary tables identified in entity_info().
|
||||
*/
|
||||
function date_views_date_views_extra_tables() {
|
||||
return array(
|
||||
@@ -151,14 +175,13 @@ function date_views_date_views_extra_tables() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to map entity types to the Views base table they use,
|
||||
* to make it easier to infer the entity type from a base table.
|
||||
* Helper function to map entity types to the Views base table they use, to make it easier to infer the entity type from a base table.
|
||||
*
|
||||
* Views has a new handler called views_handler_field_entity() that loads
|
||||
* entities, and you can use something like the following to get the
|
||||
* entity type from a view, but not all our base tables contain the
|
||||
* entity information we need, (i.e. revisions) so it won't work here
|
||||
* and we resort to creating information from entity_get_info().
|
||||
* Views has a new handler called views_handler_field_entity() that loads entities.
|
||||
*
|
||||
* And you can use something like the following to get the entity type from a view, but not all our base tables contain the entity information we need, (i.e. revisions).
|
||||
*
|
||||
* So it won't work here and we resort to creating information from entity_get_info().
|
||||
*
|
||||
* // A method to get the entity type for a base table.
|
||||
* $table_data = views_fetch_data($base_table);
|
||||
@@ -193,11 +216,7 @@ function date_views_base_tables() {
|
||||
/**
|
||||
* Implements hook_date_views_fields().
|
||||
*
|
||||
* All modules that create custom fields that use the
|
||||
* 'views_handler_field_date' handler can provide
|
||||
* additional information here about the type of
|
||||
* date they create so the date can be used by
|
||||
* the Date API views date argument and date filter.
|
||||
* All modules that create custom fields that use the 'views_handler_field_date' handler can provide additional information here about the type of date they create so the date can be used by the Date API views date argument and date filter.
|
||||
*/
|
||||
function date_views_date_views_fields($field) {
|
||||
$values = array(
|
||||
@@ -263,12 +282,15 @@ function date_pager_url($view, $date_type = NULL, $date_arg = NULL, $force_view_
|
||||
case 'year':
|
||||
$args[$pos] = date_pad($view->date_info->year, 4);
|
||||
break;
|
||||
|
||||
case 'week':
|
||||
$args[$pos] = date_pad($view->date_info->year, 4) . '-W' . date_pad($view->date_info->week);
|
||||
break;
|
||||
|
||||
case 'day':
|
||||
$args[$pos] = date_pad($view->date_info->year, 4) . '-' . date_pad($view->date_info->month) . '-' . date_pad($view->date_info->day);
|
||||
break;
|
||||
|
||||
default:
|
||||
$args[$pos] = date_pad($view->date_info->year, 4) . '-' . date_pad($view->date_info->month);
|
||||
break;
|
||||
@@ -298,9 +320,14 @@ function date_pager_url($view, $date_type = NULL, $date_arg = NULL, $force_view_
|
||||
// if they use exposed filters.
|
||||
return url($view->get_url($args), array(
|
||||
'query' => date_views_querystring($view),
|
||||
'absolute' => $absolute));
|
||||
'absolute' => $absolute,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Identifier of a date block.
|
||||
*/
|
||||
function date_block_identifier($view) {
|
||||
if (!empty($view->block_identifier)) {
|
||||
return $view->block_identifier;
|
||||
@@ -311,12 +338,9 @@ function date_block_identifier($view) {
|
||||
/**
|
||||
* Implements hook_field_views_data_alter().
|
||||
*
|
||||
* Create a Views field for each date column we care about
|
||||
* to supplement the generic 'entity_id' and 'revision_id'
|
||||
* fields that are automatically created.
|
||||
* Create a Views field for each date column we care about to supplement the generic 'entity_id' and 'revision_id' fields that are automatically created.
|
||||
*
|
||||
* Also use friendlier labels to distinguish the start date
|
||||
* and end date in listings (for fields that use both).
|
||||
* Also use friendlier labels to distinguish the start date and end date in listings (for fields that use both).
|
||||
*/
|
||||
function date_views_field_views_data_alter(&$result, $field, $module) {
|
||||
if ($module == 'date') {
|
||||
@@ -336,8 +360,8 @@ function date_views_field_views_data_alter(&$result, $field, $module) {
|
||||
$result[$table][$column]['field']['is date'] = TRUE;
|
||||
// Not sure yet if we still need a custom field handler in D7 now that custom formatters are available.
|
||||
// Might still need it to handle grouping of multiple value dates.
|
||||
//$result[$table][$column]['field']['handler'] = 'date_handler_field_date';
|
||||
//$result[$table][$column]['field']['add fields to query'] = TRUE;
|
||||
// $result[$table][$column]['field']['handler'] = 'date_handler_field_date';
|
||||
// $result[$table][$column]['field']['add fields to query'] = TRUE;
|
||||
}
|
||||
|
||||
// For filters, arguments, and sorts, determine if this column is for
|
||||
@@ -395,12 +419,25 @@ function date_views_field_views_data_alter(&$result, $field, $module) {
|
||||
// translatable string. This is a hack to get it to appear right
|
||||
// before 'end date' in the listing (i.e., in a non-alphabetical,
|
||||
// but more user friendly, order).
|
||||
$result[$table][$column]['title'] = t('@label - start date (!name)', array('@label' => $label, '!name' => $field['field_name']));
|
||||
$result[$table][$column]['title short'] = t('@label - start date', array('@label' => $label));
|
||||
$result[$table][$column]['title'] = t('@label - start date (!name)', array(
|
||||
'@label' => $label,
|
||||
'!name' => $field['field_name'],
|
||||
));
|
||||
$result[$table][$column]['title short'] = t('@label - start date', array(
|
||||
'@label' => $label,
|
||||
));
|
||||
break;
|
||||
|
||||
case 'value2':
|
||||
$result[$table][$column]['title'] = t('@label - end date (!name:!column)', array('@label' => $label, '!name' => $field['field_name'], '!column' => $this_column));
|
||||
$result[$table][$column]['title short'] = t('@label - end date:!column', array('@label' => $label, '!column' => $this_column));
|
||||
$result[$table][$column]['title'] = t('@label - end date (!name:!column)', array(
|
||||
'@label' => $label,
|
||||
'!name' => $field['field_name'],
|
||||
'!column' => $this_column,
|
||||
));
|
||||
$result[$table][$column]['title short'] = t('@label - end date:!column', array(
|
||||
'@label' => $label,
|
||||
'!column' => $this_column,
|
||||
));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -421,18 +458,15 @@ function date_views_form_views_ui_edit_form_alter(&$form, &$form_state, $form_id
|
||||
}
|
||||
|
||||
/**
|
||||
* The instanceof function makes this work for any handler that was derived
|
||||
* from 'views_handler_filter_date' or 'views_handler_argument_date',
|
||||
* which includes core date fields like the node updated field.
|
||||
* The instanceof function makes this work for any handler that was derived from 'views_handler_filter_date' or 'views_handler_argument_date', which includes core date fields like the node updated field.
|
||||
*
|
||||
* The test for $handler->min_date tells us that this is an argument that
|
||||
* not only is derived from the views date handler but also has been processed
|
||||
* by the Date Views filter or argument code.
|
||||
*/
|
||||
* The test for $handler->min_date tells us that this is an argument that not only is derived from the views date handler but also has been processed by the Date Views filter or argument code.
|
||||
*/
|
||||
function date_views_handler_is_date($handler, $type = 'argument') {
|
||||
switch ($type) {
|
||||
case 'filter':
|
||||
return $handler instanceof views_handler_filter_date && !empty($handler->min_date);
|
||||
|
||||
case 'argument':
|
||||
return $handler instanceof views_handler_argument_date && !empty($handler->min_date);
|
||||
}
|
||||
@@ -441,8 +475,8 @@ function date_views_handler_is_date($handler, $type = 'argument') {
|
||||
|
||||
/**
|
||||
* Validation hook for exposed filters that use the select widget.
|
||||
* This is to ensure the the user completes all parts of the date
|
||||
* not just some parts. Only needed for the select widget.
|
||||
*
|
||||
* This is to ensure the the user completes all parts of the date not just some parts. Only needed for the select widget.
|
||||
*/
|
||||
function date_views_select_validate(&$form, &$form_state) {
|
||||
// If there are no values just return.
|
||||
@@ -453,7 +487,7 @@ function date_views_select_validate(&$form, &$form_state) {
|
||||
$filled = array();
|
||||
$value = drupal_array_get_nested_value($form_state['input'], $form['#parents']);
|
||||
foreach ($granularity as $part) {
|
||||
if (!empty($value['value'][$part])) {
|
||||
if (isset($value['value']) && is_numeric($value['value'][$part])) {
|
||||
$filled[] = $part;
|
||||
}
|
||||
}
|
||||
@@ -464,18 +498,23 @@ function date_views_select_validate(&$form, &$form_state) {
|
||||
case 'year':
|
||||
form_error($form['value'][$part], t('Please choose a year.'), $form_state);
|
||||
break;
|
||||
|
||||
case 'month':
|
||||
form_error($form['value'][$part], t('Please choose a month.'), $form_state);
|
||||
break;
|
||||
|
||||
case 'day':
|
||||
form_error($form['value'][$part], t('Please choose a day.'), $form_state);
|
||||
break;
|
||||
|
||||
case 'hour':
|
||||
form_error($form['value'][$part], t('Please choose an hour.'), $form_state);
|
||||
break;
|
||||
|
||||
case 'minute':
|
||||
form_error($form['value'][$part], t('Please choose a minute.'), $form_state);
|
||||
break;
|
||||
|
||||
case 'second':
|
||||
form_error($form['value'][$part], t('Please choose a second.'), $form_state);
|
||||
break;
|
||||
@@ -487,8 +526,7 @@ function date_views_select_validate(&$form, &$form_state) {
|
||||
/**
|
||||
* Implements hook_date_formatter_view_alter().
|
||||
*
|
||||
* If we are displaying a date from a view, see if we have information about
|
||||
* which multiple value to display. If so, set the date_id in the entity.
|
||||
* If we are displaying a date from a view, see if we have information about which multiple value to display. If so, set the date_id in the entity.
|
||||
*/
|
||||
function date_views_date_formatter_pre_view_alter(&$entity, &$variables) {
|
||||
// Some views have no row index.
|
||||
@@ -501,4 +539,4 @@ function date_views_date_formatter_pre_view_alter(&$entity, &$variables) {
|
||||
$entity->date_id = 'date.' . $date_item->$date_id . '.' . $field['field_name'] . '.' . $date_item->$date_delta . '.0';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Empty file to avoid fatal error if it doesn't exist.
|
||||
* Formerly the attachment for the Date Browser.
|
||||
*/
|
||||
*/
|
||||
|
@@ -27,8 +27,9 @@
|
||||
* links by date, requires the date argument and uses the current
|
||||
* date argument default to set a starting point for the view.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_views_plugins
|
||||
* Implements hook_views_plugins().
|
||||
*/
|
||||
function date_views_views_plugins() {
|
||||
$path = drupal_get_path('module', 'date_views');
|
||||
@@ -36,7 +37,8 @@ function date_views_views_plugins() {
|
||||
module_load_include('inc', 'date_views', 'theme/theme');
|
||||
|
||||
return array(
|
||||
'module' => 'date_views', // This just tells our themes are elsewhere.
|
||||
// This just tells our themes are elsewhere.
|
||||
'module' => 'date_views',
|
||||
'display' => array(
|
||||
// Display plugin for date navigation.
|
||||
'date_nav' => array(
|
||||
@@ -83,7 +85,7 @@ function date_views_views_plugins() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_views_data()
|
||||
* Implements hook_views_data().
|
||||
*/
|
||||
function date_views_views_data() {
|
||||
$data = array();
|
||||
@@ -95,12 +97,12 @@ function date_views_views_data() {
|
||||
$data[$base_table]['date_argument'] = array(
|
||||
'group' => t('Date'),
|
||||
'title' => t('Date (!base_table)', array('!base_table' => $base_table)),
|
||||
'help' => t('Filter any Views !base_table date field by a date argument, using any common ISO date/period format (i.e. YYYY, YYYY-MM, YYYY-MM-DD, YYYY-W99, YYYY-MM-DD--P3M, P90D, etc). ', array('!base_table' => $base_table)),
|
||||
'help' => t('Filter any Views !base_table date field by a date argument, using any common ISO date/period format (i.e. YYYY, YYYY-MM, YYYY-MM-DD, YYYY-W99, YYYY-MM-DD--P3M, P90D, etc).', array('!base_table' => $base_table)),
|
||||
'argument' => array(
|
||||
'handler' => 'date_views_argument_handler',
|
||||
'empty field name' => t('Undated'),
|
||||
'is date' => TRUE,
|
||||
//'skip base' => $base_table,
|
||||
// 'skip base' => $base_table,
|
||||
),
|
||||
);
|
||||
// The flexible date filter.
|
||||
@@ -112,7 +114,7 @@ function date_views_views_data() {
|
||||
'handler' => 'date_views_filter_handler',
|
||||
'empty field name' => t('Undated'),
|
||||
'is date' => TRUE,
|
||||
//'skip base' => $base_table,
|
||||
// 'skip base' => $base_table,
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -140,8 +142,9 @@ function date_views_views_data_alter(&$data) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Central function for setting up the right timezone values
|
||||
* in the SQL date handler.
|
||||
* Central function for setting up the right timezone values.
|
||||
*
|
||||
* In the SQL date handler.
|
||||
*
|
||||
* The date handler will use this information to decide if the
|
||||
* database value needs a timezone conversion.
|
||||
@@ -152,30 +155,45 @@ function date_views_views_data_alter(&$data) {
|
||||
*/
|
||||
function date_views_set_timezone(&$date_handler, &$view, $field) {
|
||||
switch ($field['tz_handling']) {
|
||||
case 'date' :
|
||||
case 'date':
|
||||
$date_handler->db_timezone = 'UTC';
|
||||
$date_handler->local_timezone_field = $field['timezone_field'];
|
||||
$date_handler->offset_field = $field['offset_field'];
|
||||
break;
|
||||
|
||||
case 'none':
|
||||
$date_handler->db_timezone = date_default_timezone();
|
||||
$date_handler->local_timezone = date_default_timezone();
|
||||
break;
|
||||
|
||||
case 'utc':
|
||||
$date_handler->db_timezone = 'UTC';
|
||||
$date_handler->local_timezone = 'UTC';
|
||||
break;
|
||||
default :
|
||||
|
||||
default:
|
||||
$date_handler->db_timezone = 'UTC';
|
||||
$date_handler->local_timezone = date_default_timezone();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to generate a query string.
|
||||
*
|
||||
* @param object $view
|
||||
* A View object.
|
||||
*
|
||||
* @param array $extra_params
|
||||
* An extra parameters.
|
||||
*
|
||||
* @return null/string
|
||||
* Return a query or NULL.
|
||||
*/
|
||||
function date_views_querystring($view, $extra_params = array()) {
|
||||
$query_params = array_merge($_GET, $extra_params);
|
||||
// Allow NULL params to be removed from the query string.
|
||||
foreach ($extra_params AS $key => $value) {
|
||||
foreach ($extra_params as $key => $value) {
|
||||
if (!isset($value)) {
|
||||
unset($query_params[$key]);
|
||||
}
|
||||
|
@@ -3,12 +3,14 @@
|
||||
* @file
|
||||
* Date API views argument handler.
|
||||
* This argument combines multiple date arguments into a single argument
|
||||
* where all fields are controlled by the same date and can be combined with either AND or OR.
|
||||
* where all fields are controlled by the same date and can be combined
|
||||
* with either AND or OR.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Date API argument handler.
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
class date_views_argument_handler extends date_views_argument_handler_simple {
|
||||
|
||||
/**
|
||||
@@ -198,3 +200,4 @@ class date_views_argument_handler extends date_views_argument_handler_simple {
|
||||
}
|
||||
|
||||
}
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
@@ -7,11 +7,13 @@
|
||||
/**
|
||||
* Date API argument handler.
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
class date_views_argument_handler_simple extends views_handler_argument_date {
|
||||
|
||||
/**
|
||||
* Get granularity and use it to create the formula and a format
|
||||
* for the results.
|
||||
* Get granularity.
|
||||
*
|
||||
* Use it to create the formula and a format for the results.
|
||||
*/
|
||||
function init(&$view, &$options) {
|
||||
parent::init($view, $options);
|
||||
@@ -29,12 +31,14 @@ class date_views_argument_handler_simple extends views_handler_argument_date {
|
||||
$this->date_handler->local_timezone = date_get_timezone($field['settings']['tz_handling']);
|
||||
}
|
||||
$this->date_handler->granularity = $this->options['granularity'];
|
||||
// This value needs to be initialized so it exists even if the query doesn't run.
|
||||
// This value needs to be initialized so
|
||||
// it exists even if the query doesn't run.
|
||||
$this->date_handler->placeholders = array();
|
||||
|
||||
$this->format = $this->date_handler->views_formats($this->date_handler->granularity, 'display');
|
||||
$this->sql_format = $this->date_handler->views_formats($this->date_handler->granularity, 'sql');
|
||||
// $this->arg_format is the format the parent date handler will use to create a default argument.
|
||||
// $this->arg_format is the format the parent date
|
||||
// handler will use to create a default argument.
|
||||
$this->arg_format = $this->format();
|
||||
|
||||
// Identify the base table for this field.
|
||||
@@ -43,6 +47,9 @@ class date_views_argument_handler_simple extends views_handler_argument_date {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function format() {
|
||||
if (!empty($this->options['granularity'])) {
|
||||
return $this->date_handler->views_formats($this->options['granularity']);
|
||||
@@ -53,8 +60,9 @@ class date_views_argument_handler_simple extends views_handler_argument_date {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the empty argument value to the current date,
|
||||
* formatted appropriately for this argument.
|
||||
* Set the empty argument value to the current date.
|
||||
*
|
||||
* Formatted appropriately for this argument.
|
||||
*/
|
||||
function get_default_argument($raw = FALSE) {
|
||||
$is_default = FALSE;
|
||||
@@ -85,6 +93,7 @@ class date_views_argument_handler_simple extends views_handler_argument_date {
|
||||
$options = parent::option_definition();
|
||||
$options['year_range'] = array('default' => '-3:+3');
|
||||
$options['granularity'] = array('default' => 'month');
|
||||
$options['granularity_reset'] = array('default' => FALSE);
|
||||
$options['default_argument_type']['default'] = 'date';
|
||||
$options['add_delta'] = array('default' => '');
|
||||
$options['use_fromto'] = array('default' => '');
|
||||
@@ -116,7 +125,9 @@ class date_views_argument_handler_simple extends views_handler_argument_date {
|
||||
'#attributes' => array('class' => array('dependent-options')),
|
||||
'#states' => array(
|
||||
'visible' => array(
|
||||
':input[name="options[default_action]"]' => array('value' => 'summary')
|
||||
':input[name="options[default_action]"]' => array(
|
||||
'value' => 'summary',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -129,23 +140,37 @@ class date_views_argument_handler_simple extends views_handler_argument_date {
|
||||
'#attributes' => array('class' => array('dependent-options')),
|
||||
'#states' => array(
|
||||
'visible' => array(
|
||||
':input[name="options[title_format]"]' => array('value' => 'custom')
|
||||
':input[name="options[title_format]"]' => array(
|
||||
'value' => 'custom',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// Get default granularity options
|
||||
$options = $this->date_handler->date_parts();
|
||||
unset($options['second'], $options['minute']);
|
||||
$options += array('week' => t('Week', array(), array('context' => 'datetime')));
|
||||
// Add the 'week' option.
|
||||
$options += array(
|
||||
'week' => t('Week', array(), array(
|
||||
'context' => 'datetime',
|
||||
)),
|
||||
);
|
||||
|
||||
$form['granularity'] = array(
|
||||
'#title' => t('Granularity'),
|
||||
'#type' => 'radios',
|
||||
'#options' => $options,
|
||||
'#default_value' => $this->options['granularity'],
|
||||
'#multiple' => TRUE,
|
||||
'#description' => t("Select the type of date value to be used in defaults, summaries, and navigation. For example, a granularity of 'month' will set the default date to the current month, summarize by month in summary views, and link to the next and previous month when using date navigation."),
|
||||
);
|
||||
|
||||
$form['granularity_reset'] = array(
|
||||
'#title' => t('Use granularity from argument value'),
|
||||
'#type' => 'checkbox',
|
||||
'#default_value' => $this->options['granularity_reset'],
|
||||
'#description' => t("If the granularity of argument value is different from selected, use it from argument value."),
|
||||
);
|
||||
|
||||
$form['year_range'] = array(
|
||||
'#title' => t('Date year range'),
|
||||
'#type' => 'textfield',
|
||||
@@ -172,16 +197,18 @@ class date_views_argument_handler_simple extends views_handler_argument_date {
|
||||
'#default_value' => $this->options['add_delta'],
|
||||
'#options' => array('' => t('No'), 'yes' => t('Yes')),
|
||||
'#description' => t('Add an identifier to the view to show which multiple value date fields meet the filter criteria. Note: This option may introduce duplicate values into the view. Required when using multiple value fields in a Calendar or any time you want the node view of multiple value dates to display only the values that match the view filters.'),
|
||||
// Only let mere mortals tweak this setting for multi-value fields
|
||||
// Only let mere mortals tweak this setting for multi-value fields.
|
||||
'#access' => $access,
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function options_validate(&$form, &$form_state) {
|
||||
// It is very important to call the parent function here:
|
||||
parent::options_validate($form, $form_state);
|
||||
if (!preg_match('/^(?:\-[0-9]{1,4}|[0-9]{4}):(?:[\+|\-][0-9]{1,4}|[0-9]{4})$/', $form_state['values']['options']['year_range'])) {
|
||||
if (!preg_match('/^(?:\-[0-9]{1,4}|[0-9]{4}):(?:[\+\-][0-9]{1,4}|[0-9]{4})$/', $form_state['values']['options']['year_range'])) {
|
||||
form_error($form['year_range'], t('Date year range must be in the format -9:+9, 2005:2010, -9:2010, or 2005:+9'));
|
||||
}
|
||||
}
|
||||
@@ -209,14 +236,15 @@ class date_views_argument_handler_simple extends views_handler_argument_date {
|
||||
$format = !empty($this->options['title_format_custom']) && !empty($this->options['title_format_custom']) ? $this->options['title_format_custom'] : $this->date_handler->views_formats($this->options['granularity'], 'display');
|
||||
$range = $this->date_handler->arg_range($this->argument);
|
||||
return date_format_date($range[0], 'custom', $format);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide the argument to use to link from the summary to the next level;
|
||||
* this will be called once per row of a summary, and used as part of
|
||||
* Provide the argument to use to link from the summary to the next level.
|
||||
*
|
||||
* This will be called once per row of a summary, and used as part of
|
||||
* $view->get_url().
|
||||
*
|
||||
* @param $data
|
||||
* @param object $data
|
||||
* The query results for the row.
|
||||
*/
|
||||
function summary_argument($data) {
|
||||
@@ -234,10 +262,11 @@ class date_views_argument_handler_simple extends views_handler_argument_date {
|
||||
*/
|
||||
function summary_query() {
|
||||
|
||||
// @TODO The summary values are computed by the database. Unless the database has
|
||||
// built-in timezone handling it will use a fixed offset, which will not be
|
||||
// right for all dates. The only way I can see to make this work right is to
|
||||
// store the offset for each date in the database so it can be added to the base
|
||||
// @TODO The summary values are computed by the database.
|
||||
// Unless the database has built-in timezone handling it will use
|
||||
// a fixed offset, which will not be right for all dates.
|
||||
// The only way I can see to make this work right is to store the offset
|
||||
// for each date in the database so it can be added to the base
|
||||
// date value before the database formats the result. Because this is a huge
|
||||
// architectural change, it won't go in until we start a new branch.
|
||||
$this->formula = $this->date_handler->sql_format($this->sql_format, $this->date_handler->sql_field("***table***.$this->real_field"));
|
||||
@@ -245,7 +274,8 @@ class date_views_argument_handler_simple extends views_handler_argument_date {
|
||||
// Now that our table is secure, get our formula.
|
||||
$formula = $this->get_formula();
|
||||
|
||||
// Add the field, give it an alias that does NOT match the actual field name or grouping won't work right.
|
||||
// Add the field, give it an alias that does NOT match the actual
|
||||
// field name or grouping won't work right.
|
||||
$this->base_alias = $this->name_alias = $this->query->add_field(NULL, $formula, $this->field . '_summary');
|
||||
$this->query->set_count_field(NULL, $formula, $this->field);
|
||||
|
||||
@@ -254,20 +284,22 @@ class date_views_argument_handler_simple extends views_handler_argument_date {
|
||||
|
||||
/**
|
||||
* Inject a test for valid date range before the regular query.
|
||||
*
|
||||
* Override the parent query to be able to control the $group.
|
||||
*/
|
||||
function query($group_by = FALSE) {
|
||||
|
||||
// @TODO Not doing anything with $group_by yet, need to figure out what has to be done.
|
||||
// @TODO Not doing anything with $group_by yet,
|
||||
// need to figure out what has to be done.
|
||||
|
||||
if ($this->date_forbid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// See if we need to reset granularity based on an argument value.
|
||||
// Make sure we don't try to reset to some bogus value if someone has typed in an unexpected argument.
|
||||
$granularity = $this->date_handler->arg_granularity($this->argument);
|
||||
if (!empty($granularity)) {
|
||||
// Make sure we don't try to reset to some bogus value if someone has
|
||||
// typed in an unexpected argument.
|
||||
if ($this->options['granularity_reset'] && $granularity = $this->date_handler->arg_granularity($this->argument)) {
|
||||
$this->date_handler->granularity = $granularity;
|
||||
$this->format = $this->date_handler->views_formats($this->date_handler->granularity, 'display');
|
||||
$this->sql_format = $this->date_handler->views_formats($this->date_handler->granularity, 'sql');
|
||||
@@ -276,7 +308,8 @@ class date_views_argument_handler_simple extends views_handler_argument_date {
|
||||
$this->ensure_my_table();
|
||||
$group = !empty($this->options['date_group']) ? $this->options['date_group'] : 0;
|
||||
|
||||
// If requested, add the delta field to the view so we can later find the value that matched our query.
|
||||
// If requested, add the delta field to the view so
|
||||
// we can later find the value that matched our query.
|
||||
if (!empty($this->options['add_delta']) && (substr($this->real_field, -6) == '_value' || substr($this->real_field, -7) == '_value2')) {
|
||||
$this->query->add_field($this->table_alias, 'delta');
|
||||
$real_field_name = str_replace(array('_value', '_value2'), '', $this->real_field);
|
||||
@@ -291,7 +324,8 @@ class date_views_argument_handler_simple extends views_handler_argument_date {
|
||||
$view_max_placeholder = $this->placeholder();
|
||||
$this->date_handler->placeholders = array($view_min_placeholder => $view_min, $view_max_placeholder => $view_max);
|
||||
|
||||
// Are we comparing this field only or the Start/End date range to the view criteria?
|
||||
// Are we comparing this field only or the Start/End date range
|
||||
// to the view criteria?
|
||||
if (!empty($this->options['use_fromto'])) {
|
||||
|
||||
// The simple case, match the field to the view range.
|
||||
@@ -302,10 +336,14 @@ class date_views_argument_handler_simple extends views_handler_argument_date {
|
||||
}
|
||||
else {
|
||||
|
||||
// Look for the intersection of the range of the date field with the range of the view.
|
||||
// Get the Start/End values for this field. Retrieve using the original table name.
|
||||
// Swap the current table name (adjusted for relationships) into the query.
|
||||
// @TODO We may be able to use Views substitutions here, investigate that later.
|
||||
// Look for the intersection of the range
|
||||
// of the date field with the range of the view.
|
||||
// Get the Start/End values for this field.
|
||||
// Retrieve using the original table name.
|
||||
// Swap the current table name (adjusted for relationships)
|
||||
// into the query.
|
||||
// @TODO We may be able to use Views substitutions here,
|
||||
// investigate that later.
|
||||
$fields = date_views_fields($this->base_table);
|
||||
$fields = $fields['name'];
|
||||
$fromto = $fields[$this->original_table . '.' . $this->real_field]['fromto'];
|
||||
@@ -321,7 +359,10 @@ class date_views_argument_handler_simple extends views_handler_argument_date {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a callback to determine if we have moved outside the valid date range for this argument.
|
||||
* Add a callback.
|
||||
*
|
||||
* To determine if we have moved outside
|
||||
* the valid date range for this argument.
|
||||
*/
|
||||
function date_forbid() {
|
||||
if (empty($this->argument)) {
|
||||
@@ -343,3 +384,4 @@ class date_views_argument_handler_simple extends views_handler_argument_date {
|
||||
}
|
||||
|
||||
}
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
@@ -5,13 +5,11 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Identify all potential date/timestamp fields.
|
||||
* Identify all potential date/timestamp fields.
|
||||
*
|
||||
* @return
|
||||
* array with fieldname, type, and table.
|
||||
* @see
|
||||
* date_views_date_views_fields() which implements
|
||||
* the hook_date_views_fields() for the core date fields.
|
||||
* @return array
|
||||
* An array with fieldname, type, and table.
|
||||
* @see date_views_date_views_fields()
|
||||
*/
|
||||
function _date_views_fields($base = 'node') {
|
||||
|
||||
@@ -60,7 +58,7 @@ function _date_views_fields($base = 'node') {
|
||||
$handler = views_get_handler($table_name, $field_name, 'filter');
|
||||
$handler_name = $handler->definition['handler'];
|
||||
|
||||
// We don't care about anything but date handlers
|
||||
// We don't care about anything but date handlers.
|
||||
if (empty($handler->definition['is date'])) {
|
||||
continue;
|
||||
}
|
||||
@@ -72,14 +70,17 @@ function _date_views_fields($base = 'node') {
|
||||
$field = field_info_field($handler->definition['field_name']);
|
||||
$is_field = TRUE;
|
||||
switch ($field['type']) {
|
||||
case 'date':
|
||||
case 'date':
|
||||
$sql_type = DATE_ISO;
|
||||
break;
|
||||
|
||||
case 'datestamp':
|
||||
break;
|
||||
|
||||
case 'datetime':
|
||||
$sql_type = DATE_DATETIME;
|
||||
break;
|
||||
|
||||
default:
|
||||
// If this is not a date field, nothing more to do.
|
||||
continue;
|
||||
@@ -88,7 +89,8 @@ function _date_views_fields($base = 'node') {
|
||||
$revision = in_array($base, array('node_revision')) ? FIELD_LOAD_REVISION : FIELD_LOAD_CURRENT;
|
||||
$db_info = date_api_database_info($field, $revision);
|
||||
$name = $table_name . "." . $field_name;
|
||||
$granularity = !empty($field['granularity']) ? $field['granularity'] : array('year', 'month', 'day', 'hour', 'minute', 'second');
|
||||
$grans = array('year', 'month', 'day', 'hour', 'minute', 'second');
|
||||
$granularity = !empty($field['granularity']) ? $field['granularity'] : $grans;
|
||||
|
||||
$fromto = array(
|
||||
$table_name . '.' . $db_info['columns'][$table_name]['value'],
|
||||
|
@@ -3,9 +3,11 @@
|
||||
* @file
|
||||
* A flexible, configurable date filter.
|
||||
* This filter combines multiple date filters into a single filter
|
||||
* where all fields are controlled by the same date and can be combined with either AND or OR.
|
||||
* where all fields are controlled by the same date and can be combined
|
||||
* with either AND or OR.
|
||||
*/
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
class date_views_filter_handler extends date_views_filter_handler_simple {
|
||||
function init(&$view, &$options) {
|
||||
parent::init($view, $options);
|
||||
@@ -64,6 +66,9 @@ class date_views_filter_handler extends date_views_filter_handler_simple {
|
||||
if ($field['table_name'] != $this->table || !empty($this->relationship)) {
|
||||
$this->related_table_alias = $this->query->ensure_table($field['table_name'], $this->relationship);
|
||||
}
|
||||
else {
|
||||
$this->related_table_alias = null;
|
||||
}
|
||||
$table_alias = !empty($this->related_table_alias) ? $this->related_table_alias : $field['table_name'];
|
||||
$field_name = $table_alias . '.' . $field['field_name'];
|
||||
|
||||
@@ -179,3 +184,4 @@ class date_views_filter_handler extends date_views_filter_handler_simple {
|
||||
}
|
||||
}
|
||||
}
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
@@ -1,9 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* A standard Views filter for a single date field, using Date API form selectors and sql handling.
|
||||
* A standard Views filter for a single date field,
|
||||
* using Date API form selectors and sql handling.
|
||||
*/
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
class date_views_filter_handler_simple extends views_handler_filter_date {
|
||||
var $date_handler = NULL;
|
||||
var $offset = NULL;
|
||||
@@ -263,7 +265,7 @@ class date_views_filter_handler_simple extends views_handler_filter_date {
|
||||
}
|
||||
|
||||
function extra_options_validate($form, &$form_state) {
|
||||
if (!preg_match('/^(?:\-[0-9]{1,4}|[0-9]{4}):(?:[\+|\-][0-9]{1,4}|[0-9]{4})$/', $form_state['values']['options']['year_range'])) {
|
||||
if (!preg_match('/^(?:[\+\-][0-9]{1,4}|[0-9]{4}):(?:[\+\-][0-9]{1,4}|[0-9]{4})$/', $form_state['values']['options']['year_range'])) {
|
||||
form_error($form['year_range'], t('Date year range must be in the format -9:+9, 2005:2010, -9:2010, or 2005:+9'));
|
||||
}
|
||||
}
|
||||
@@ -332,7 +334,7 @@ class date_views_filter_handler_simple extends views_handler_filter_date {
|
||||
* @return
|
||||
* The form date part element for this instance.
|
||||
*/
|
||||
function date_parts_form($form_state, $prefix, $source, $which, $operator_values, $identifier, $relative_id) {
|
||||
function date_parts_form(&$form_state, $prefix, $source, $which, $operator_values, $identifier, $relative_id) {
|
||||
module_load_include('inc', 'date_api', 'date_api_elements');
|
||||
switch ($prefix) {
|
||||
case 'min':
|
||||
@@ -379,7 +381,10 @@ class date_views_filter_handler_simple extends views_handler_filter_date {
|
||||
$form[$prefix]['#dependency'] = array($source => $operator_values);
|
||||
}
|
||||
if (!isset($form_state['input'][$identifier][$prefix])) {
|
||||
$form_state['input'][$identifier][$prefix] = $this->value[$prefix];
|
||||
// Ensure these exist.
|
||||
foreach ($granularity as $key) {
|
||||
$form_state['input'][$identifier][$prefix][$key] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -530,3 +535,4 @@ class date_views_filter_handler_simple extends views_handler_filter_date {
|
||||
}
|
||||
|
||||
}
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
@@ -2,50 +2,74 @@
|
||||
/**
|
||||
* @file
|
||||
* Date pager.
|
||||
* Works with a Date argument, the argument filters the view and the pager provides back/next navigation.
|
||||
* Works with a Date argument, the argument filters
|
||||
* the view and the pager provides back/next navigation.
|
||||
*
|
||||
* USER NOTES:
|
||||
*
|
||||
* To use this, add a pager to a view, and choose the option to 'Page by date'.
|
||||
* There are several settings:
|
||||
* - The pager id: Set an id to be used as the identifier in the url for pager values, defaults to 'date'.
|
||||
* - Pager position: Choose whether to display the date pager above, below, or both above and below the content.
|
||||
* - Link format: Choose whether the pager links will be in the simple 'calendar/2011-12' format or the
|
||||
* more complex 'calendar/?date=2011-12' pager format. The second one is more likely to work correctly
|
||||
* if the pager is used in blocks and panels.
|
||||
* - The pager id: Set an id to be used as the identifier
|
||||
* in the url for pager values, defaults to 'date'.
|
||||
* - Pager position: Choose whether to display the date
|
||||
* pager above, below, or both above and below the content.
|
||||
* - Link format: Choose whether the pager links will be in t
|
||||
* he simple 'calendar/2011-12' format or the
|
||||
* more complex 'calendar/?date=2011-12' pager format.
|
||||
* The second one is more likely to work correctly
|
||||
* if the pager is used in blocks and panels.
|
||||
*
|
||||
* The pager works in combination with a Date argument and it will use the date fields and granularity
|
||||
* set in that argument to create its back/next links. If the view has no Date argument, the pager can
|
||||
* do nothing. The argument can either be a 'Date' argument that lets you select one or more date fields
|
||||
* in the argument, or the simple 'Content' argument for an individual date field. It must be an
|
||||
* The pager works in combination with a Date argument
|
||||
* and it will use the date fields and granularity
|
||||
* set in that argument to create its back/next links.
|
||||
* If the view has no Date argument, the pager can
|
||||
* do nothing. The argument can either be a 'Date' argument
|
||||
* that lets you select one or more date fields
|
||||
* in the argument, or the simple 'Content' argument for an
|
||||
* individual date field. It must be an
|
||||
* argument that uses the date argument handler.
|
||||
*
|
||||
* DEVELOPER NOTES
|
||||
*
|
||||
* The pager could technically create a query of its own rather than depending on the date argument to
|
||||
* set the query, but it has only a limited set of tools to work with because it is a plugin, not a handler:
|
||||
* it has no knowledge about relationships, it cannot use the ensure_my_table() function,
|
||||
* plugins are not even invoked in pre_query(), so can't do anything there.
|
||||
* The pager could technically create a query of its own rather
|
||||
* than depending on the date argument to
|
||||
* set the query, but it has only a limited set of tools to work
|
||||
* with because it is a plugin, not a handler:
|
||||
* it has no knowledge about relationships, it cannot use the
|
||||
* ensure_my_table() function, plugins are not even invoked in pre_query(),
|
||||
* so can't do anything there.
|
||||
*
|
||||
* My conclusion was that the date pager simply is not powerful enough to create its own queries for
|
||||
* date fields, which require very complex queries. Instead, we can combine this with a date argument and
|
||||
* let the argument create the query and let the pager just provide the back/next links. If there is no
|
||||
* My conclusion was that the date pager simply
|
||||
* is not powerful enough to create its own queries for
|
||||
* date fields, which require very complex queries.
|
||||
* Instead, we can combine this with a date argument and
|
||||
* let the argument create the query and let the pager
|
||||
* just provide the back/next links. If there is no
|
||||
* date argument, the pager will do nothing.
|
||||
*
|
||||
* There are still other problems. The pager is not even initialized until after all the handlers
|
||||
* have created their queries, so it has no chance to alter values ahead of that. And the argument
|
||||
* has no knowledge of the pager, so it can't check for pager values before the query is created.
|
||||
* There are still other problems. The pager is not even
|
||||
* initialized until after all the handlers
|
||||
* have created their queries, so it has no chance
|
||||
* to alter values ahead of that. And the argument
|
||||
* has no knowledge of the pager, so it can't check
|
||||
* for pager values before the query is created.
|
||||
*
|
||||
* The solution used here is to let the argument create the original query. The pager query
|
||||
* runs after that, so the pager checks to see if there is a pager value that needs to be used in the query.
|
||||
* The date argument has identified the placeholders it used in the query. So if a change is needed,
|
||||
* we can swap the pager value into the query created by the date argument and adjust the
|
||||
* $view->date_info values set by the argument accordingly so the theme will pick up the new information.
|
||||
* The solution used here is to let the argument create
|
||||
* the original query. The pager query
|
||||
* runs after that, so the pager checks to see
|
||||
* if there is a pager value that needs to be used in the query.
|
||||
* The date argument has identified the placeholders
|
||||
* it used in the query. So if a change is needed,
|
||||
* we can swap the pager value into the query created
|
||||
* by the date argument and adjust the
|
||||
* $view->date_info values set by the argument accordingly
|
||||
* so the theme will pick up the new information.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Example plugin to handle paging by month.
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
class date_views_plugin_pager extends views_plugin_pager {
|
||||
|
||||
/**
|
||||
@@ -79,6 +103,7 @@ class date_views_plugin_pager extends views_plugin_pager {
|
||||
$options['link_format'] = array('default' => 'pager');
|
||||
$options['date_argument'] = array('default' => 'Unknown');
|
||||
$options['granularity'] = array('default' => 'Unknown');
|
||||
$options['skip_empty_pages'] = array('default' => FALSE);
|
||||
return $options;
|
||||
}
|
||||
|
||||
@@ -110,6 +135,12 @@ class date_views_plugin_pager extends views_plugin_pager {
|
||||
'#default_value' => $this->options['link_format'],
|
||||
'#required' => TRUE,
|
||||
);
|
||||
$form['skip_empty_pages'] = array(
|
||||
'#title' => t('Skip empty pages'),
|
||||
'#type' => 'checkbox',
|
||||
'#description' => t('When selected, the pager will not display pages with no result for the given date. This causes a slight performance degradation because two additional queries need to be executed.'),
|
||||
'#default_value' => $this->options['skip_empty_pages'],
|
||||
);
|
||||
$form['date_argument']['#type'] = 'hidden';
|
||||
$form['date_argument']['#value'] = $this->options['date_argument'];
|
||||
$form['granularity']['#type'] = 'hidden';
|
||||
@@ -150,13 +181,7 @@ class date_views_plugin_pager extends views_plugin_pager {
|
||||
|
||||
// Reset values set by argument if pager requires it.
|
||||
if (!empty($value)) {
|
||||
$argument->argument = $value;
|
||||
$argument->date_range = $argument->date_handler->arg_range($value);
|
||||
$argument->min_date = $argument->date_range[0];
|
||||
$argument->max_date = $argument->date_range[1];
|
||||
// $argument->is_default works correctly for normal arguments, but does not
|
||||
// work correctly if we are swapping in a new value from the pager.
|
||||
$argument->is_default = FALSE;
|
||||
$this->set_argument_value($argument, $value);
|
||||
}
|
||||
|
||||
// The pager value might move us into a forbidden range, so test it.
|
||||
@@ -164,13 +189,102 @@ class date_views_plugin_pager extends views_plugin_pager {
|
||||
$this->view->build_info['fail'] = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
if (empty($this->view->date_info)) $this->view->date_info = new stdClass();
|
||||
// Write date_info to store information to be used
|
||||
// in the theming functions.
|
||||
if (empty($this->view->date_info)) {
|
||||
$this->view->date_info = new stdClass();
|
||||
}
|
||||
$this->view->date_info->granularity = $argument->date_handler->granularity;
|
||||
$format = $this->view->date_info->granularity == 'week' ? DATE_FORMAT_DATETIME : $argument->sql_format;
|
||||
$this->view->date_info->placeholders = isset($argument->placeholders) ? $argument->placeholders : $argument->date_handler->placeholders;
|
||||
$this->view->date_info->date_arg = $argument->argument;
|
||||
$this->view->date_info->date_arg_pos = $i;
|
||||
$this->view->date_info->limit = $argument->limit;
|
||||
$this->view->date_info->url = $this->view->get_url();
|
||||
$this->view->date_info->pager_id = $this->options['date_id'];
|
||||
$this->view->date_info->date_pager_position = $this->options['pager_position'];
|
||||
$this->view->date_info->date_pager_format = $this->options['link_format'];
|
||||
$this->view->date_info->skip_empty_pages = $this->options['skip_empty_pages'] == 1;
|
||||
// Execute two additional queries to find
|
||||
// the previous and next page with values.
|
||||
if ($this->view->date_info->skip_empty_pages) {
|
||||
$q = clone $argument->query;
|
||||
$field = $argument->table_alias . '.' . $argument->real_field;
|
||||
$fieldsql = $date_handler->sql_field($field);
|
||||
$fieldsql = $date_handler->sql_format($format, $fieldsql);
|
||||
$q->clear_fields();
|
||||
$q->orderby = array();
|
||||
$q->set_distinct(TRUE, TRUE);
|
||||
// Date limits of this argument.
|
||||
$datelimits = $argument->date_handler->arg_range($argument->limit[0] . '--' . $argument->limit[1]);
|
||||
// Find the first two dates between the minimum date
|
||||
// and the upper bound of the current value.
|
||||
$q->add_orderby(NULL, $fieldsql, 'DESC', 'date');
|
||||
$this->set_argument_placeholders($this->view->date_info->placeholders, $datelimits[0], $argument->max_date, $q, $format);
|
||||
|
||||
$compiledquery = $q->query();
|
||||
$compiledquery->range(0, 2);
|
||||
$results = $compiledquery->execute()->fetchCol(0);
|
||||
|
||||
$prevdate = array_shift($results);
|
||||
$prevdatealt = array_shift($results);
|
||||
// Find the first two dates between the lower bound
|
||||
// of the current value and the maximum date.
|
||||
$q->add_orderby(NULL, $fieldsql, 'ASC', 'date');
|
||||
$this->set_argument_placeholders($this->view->date_info->placeholders, $argument->min_date, $datelimits[1], $q, $format);
|
||||
|
||||
$compiledquery = $q->query();
|
||||
$compiledquery->range(0, 2);
|
||||
$results = $compiledquery->execute()->fetchCol(0);
|
||||
|
||||
$nextdate = array_shift($results);
|
||||
$nextdatealt = array_shift($results);
|
||||
|
||||
// Set the default value of the query to $prevfirst or $nextfirst
|
||||
// when there is no value and $prevsecond or $nextsecond is set.
|
||||
if (empty($value)) {
|
||||
// @Todo find out which of $prevdate or $nextdate is closest to the
|
||||
// default argument date value and choose that one.
|
||||
if ($prevdate && $prevdatealt) {
|
||||
$this->set_argument_value($argument, $prevdate);
|
||||
$value = $prevdate;
|
||||
$prevdate = $prevdatealt;
|
||||
// If the first next date is the same as the first previous date,
|
||||
// move to the following next date.
|
||||
if ($value == $nextdate) {
|
||||
$nextdate = $nextdatealt;
|
||||
$nextdatealt = NULL;
|
||||
}
|
||||
}
|
||||
elseif ($nextdate && $nextdatealt) {
|
||||
$this->set_argument_value($argument, $nextdate);
|
||||
$value = $nextdate;
|
||||
$nextdate = $nextdatealt;
|
||||
// If the first previous date is the same as the first next date,
|
||||
// move to the following previous date.
|
||||
if ($value == $prevdate) {
|
||||
$prevdate = $prevdatealt;
|
||||
$prevdatealt = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// $prevdate and $nextdate are the same as $value, so move to
|
||||
// the next values.
|
||||
$prevdate = $prevdatealt;
|
||||
$nextdate = $nextdatealt;
|
||||
}
|
||||
|
||||
$this->view->date_info->prev_date = $prevdate ? new DateObject($prevdate, NULL, $format) : NULL;
|
||||
$this->view->date_info->next_date = $nextdate ? new DateObject($nextdate, NULL, $format) : NULL;
|
||||
}
|
||||
else {
|
||||
$this->view->date_info->prev_date = clone($argument->min_date);
|
||||
date_modify($this->view->date_info->prev_date, '-1 ' . $argument->date_handler->granularity);
|
||||
$this->view->date_info->next_date = clone($argument->max_date);
|
||||
date_modify($this->view->date_info->next_date, '+1 ' . $argument->date_handler->granularity);
|
||||
}
|
||||
// Write the date_info properties that depend on the current value.
|
||||
$this->view->date_info->year = date_format($argument->min_date, 'Y');
|
||||
$this->view->date_info->month = date_format($argument->min_date, 'n');;
|
||||
$this->view->date_info->day = date_format($argument->min_date, 'j');
|
||||
@@ -178,11 +292,6 @@ class date_views_plugin_pager extends views_plugin_pager {
|
||||
$this->view->date_info->date_range = $argument->date_range;
|
||||
$this->view->date_info->min_date = $argument->min_date;
|
||||
$this->view->date_info->max_date = $argument->max_date;
|
||||
$this->view->date_info->limit = $argument->limit;
|
||||
$this->view->date_info->url = $this->view->get_url();
|
||||
$this->view->date_info->pager_id = $this->options['date_id'];
|
||||
$this->view->date_info->date_pager_position = $this->options['pager_position'];
|
||||
$this->view->date_info->date_pager_format = $this->options['link_format'];
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
@@ -191,20 +300,33 @@ class date_views_plugin_pager extends views_plugin_pager {
|
||||
// If there is pager input and the argument has set the placeholders,
|
||||
// swap the pager value in for the placeholder set by the argument.
|
||||
if (!empty($value) && !empty($this->view->date_info->placeholders)) {
|
||||
$placeholders = $this->view->date_info->placeholders;
|
||||
$count = count($placeholders);
|
||||
foreach ($this->view->query->where as $group => $data) {
|
||||
foreach ($data['conditions'] as $delta => $condition) {
|
||||
if (array_key_exists('value', $condition) && is_array($condition['value'])) {
|
||||
foreach ($condition['value'] as $placeholder => $placeholder_value) {
|
||||
if (array_key_exists($placeholder, $placeholders)) {
|
||||
// If we didn't get a match, this is a > $min < $max query that uses the view
|
||||
// min and max dates as placeholders.
|
||||
$date = ($count == 2) ? $this->view->date_info->min_date : $this->view->date_info->max_date;
|
||||
$next_placeholder = array_shift($placeholders);
|
||||
$this->view->query->where[$group]['conditions'][$delta]['value'][$placeholder] = $date->format($format);
|
||||
$count--;
|
||||
}
|
||||
$this->set_argument_placeholders($this->view->date_info->placeholders, $this->view->date_info->min_date, $this->view->date_info->max_date, $this->view->query, $format);
|
||||
}
|
||||
}
|
||||
|
||||
function set_argument_value($argument, $value) {
|
||||
$argument->argument = $value;
|
||||
$argument->date_range = $argument->date_handler->arg_range($value);
|
||||
$argument->min_date = $argument->date_range[0];
|
||||
$argument->max_date = $argument->date_range[1];
|
||||
// $argument->is_default works correctly for normal arguments, but does not
|
||||
// work correctly if we are swapping in a new value from the pager.
|
||||
$argument->is_default = FALSE;
|
||||
}
|
||||
|
||||
function set_argument_placeholders($placeholders, $mindate, $maxdate, $query, $format) {
|
||||
$count = count($placeholders);
|
||||
foreach ($query->where as $group => $data) {
|
||||
foreach ($data['conditions'] as $delta => $condition) {
|
||||
if (array_key_exists('value', $condition) && is_array($condition['value'])) {
|
||||
foreach ($condition['value'] as $placeholder => $placeholder_value) {
|
||||
if (array_key_exists($placeholder, $placeholders)) {
|
||||
// If we didn't get a match, this is a > $min < $max query that uses the view
|
||||
// min and max dates as placeholders.
|
||||
$date = ($count == 2) ? $mindate : $maxdate;
|
||||
$next_placeholder = array_shift($placeholders);
|
||||
$query->where[$group]['conditions'][$delta]['value'][$placeholder] = $date->format($format);
|
||||
$count--;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -230,4 +352,5 @@ class date_views_plugin_pager extends views_plugin_pager {
|
||||
$pager_theme = views_theme_functions('date_views_pager', $this->view, $this->display);
|
||||
return theme($pager_theme, array('plugin' => $this, 'input' => $input));
|
||||
}
|
||||
}
|
||||
}
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
@@ -27,8 +27,10 @@
|
||||
* be used in the l() function, including rel=nofollow.
|
||||
*/
|
||||
?>
|
||||
<?php if (!empty($pager_prefix)) print $pager_prefix; ?>
|
||||
<div class="date-nav-wrapper clearfix<?php if (!empty($extra_classes)) print $extra_classes; ?>">
|
||||
<?php if (!empty($pager_prefix)) : ?>
|
||||
<?php print $pager_prefix; ?>
|
||||
<?php endif; ?>
|
||||
<div class="date-nav-wrapper clearfix<?php if (!empty($extra_classes)): print $extra_classes; endif; ?>">
|
||||
<div class="date-nav item-list">
|
||||
<div class="date-heading">
|
||||
<h3><?php print $nav_title ?></h3>
|
||||
@@ -36,7 +38,11 @@
|
||||
<ul class="pager">
|
||||
<?php if (!empty($prev_url)) : ?>
|
||||
<li class="date-prev">
|
||||
<?php print l('«' . ($mini ? '' : ' ' . t('Prev', array(), array('context' => 'date_nav'))), $prev_url, $prev_options); ?>
|
||||
<?php
|
||||
$text = '«';
|
||||
$text .= $mini ? '' : ' ' . t('Prev', array(), array('context' => 'date_nav'));
|
||||
print l(t($text), $prev_url, $prev_options);
|
||||
?>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($next_url)) : ?>
|
||||
@@ -46,4 +52,4 @@
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -4,6 +4,7 @@
|
||||
* @file
|
||||
* Theme files for Date Pager.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Jump in and move the pager.
|
||||
*/
|
||||
@@ -15,9 +16,11 @@ function date_views_preprocess_views_view(&$vars) {
|
||||
$vars['header'] .= $vars['pager'];
|
||||
$vars['pager'] = '';
|
||||
break;
|
||||
|
||||
case 'both':
|
||||
$vars['header'] .= $vars['pager'];
|
||||
break;
|
||||
|
||||
default:
|
||||
// Already on the bottom.
|
||||
}
|
||||
@@ -66,28 +69,37 @@ function template_preprocess_date_views_pager(&$vars) {
|
||||
}
|
||||
|
||||
if (empty($date_info->hide_nav)) {
|
||||
$prev_date = clone($min_date);
|
||||
date_modify($prev_date, '-1 ' . $granularity);
|
||||
$next_date = clone($min_date);
|
||||
date_modify($next_date, '+1 ' . $granularity);
|
||||
$format = array('year' => 'Y', 'month' => 'Y-m', 'day' => 'Y-m-d');
|
||||
switch ($granularity) {
|
||||
case 'week':
|
||||
$next_week = date_week(date_format($next_date, 'Y-m-d'));
|
||||
$prev_week = date_week(date_format($prev_date, 'Y-m-d'));
|
||||
$next_arg = date_format($next_date, 'o-\W') . date_pad($next_week);
|
||||
$prev_arg = date_format($prev_date, 'o-\W') . date_pad($prev_week);
|
||||
break;
|
||||
default:
|
||||
$next_arg = date_format($next_date, $format[$granularity]);
|
||||
$prev_arg = date_format($prev_date, $format[$granularity]);
|
||||
$prev_date = $date_info->prev_date;
|
||||
$next_date = $date_info->next_date;
|
||||
|
||||
$format = array('year' => 'Y', 'month' => 'Y-m', 'day' => 'Y-m-d', 'hour' => 'Y-m-d\TH');
|
||||
if (!empty($prev_date)) {
|
||||
switch ($granularity) {
|
||||
case 'week':
|
||||
$prev_week = date_week(date_format($prev_date, 'Y-m-d'));
|
||||
$prev_arg = date_format($prev_date, 'Y-\W') . date_pad($prev_week);
|
||||
break;
|
||||
default:
|
||||
$prev_arg = date_format($prev_date, $format[$granularity]);
|
||||
}
|
||||
$prev_path = str_replace($date_info->date_arg, $prev_arg, $date_info->url);
|
||||
$prev_args[$pos] = $prev_arg;
|
||||
$vars['prev_url'] = date_pager_url($view, NULL, $prev_arg);
|
||||
}
|
||||
$next_path = str_replace($date_info->date_arg, $next_arg, $date_info->url);
|
||||
$prev_path = str_replace($date_info->date_arg, $prev_arg, $date_info->url);
|
||||
$next_args[$pos] = $next_arg;
|
||||
$prev_args[$pos] = $prev_arg;
|
||||
$vars['next_url'] = date_pager_url($view, NULL, $next_arg);
|
||||
$vars['prev_url'] = date_pager_url($view, NULL, $prev_arg);
|
||||
if (!empty($next_date)) {
|
||||
switch ($granularity) {
|
||||
case 'week':
|
||||
$next_week = date_week(date_format($next_date, 'Y-m-d'));
|
||||
$next_arg = date_format($next_date, 'Y-\W') . date_pad($next_week);
|
||||
break;
|
||||
default:
|
||||
$next_arg = date_format($next_date, $format[$granularity]);
|
||||
}
|
||||
$next_path = str_replace($date_info->date_arg, $next_arg, $date_info->url);
|
||||
$next_args[$pos] = $next_arg;
|
||||
$vars['next_url'] = date_pager_url($view, NULL, $next_arg);
|
||||
}
|
||||
|
||||
$vars['next_options'] = $vars['prev_options'] = array();
|
||||
}
|
||||
else {
|
||||
@@ -117,14 +129,17 @@ function template_preprocess_date_views_pager(&$vars) {
|
||||
$prev_title = t('Navigate to previous year');
|
||||
$next_title = t('Navigate to next year');
|
||||
break;
|
||||
|
||||
case 'month':
|
||||
$prev_title = t('Navigate to previous month');
|
||||
$next_title = t('Navigate to next month');
|
||||
break;
|
||||
|
||||
case 'week':
|
||||
$prev_title = t('Navigate to previous week');
|
||||
$next_title = t('Navigate to next week');
|
||||
break;
|
||||
|
||||
case 'day':
|
||||
$prev_title = t('Navigate to previous day');
|
||||
$next_title = t('Navigate to next day');
|
||||
@@ -157,34 +172,44 @@ function template_preprocess_date_views_pager(&$vars) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Theme the calendar title
|
||||
* Theme the calendar title.
|
||||
*/
|
||||
function theme_date_nav_title($params) {
|
||||
$title = '';
|
||||
$granularity = $params['granularity'];
|
||||
$view = $params['view'];
|
||||
$date_info = $view->date_info;
|
||||
$link = !empty($params['link']) ? $params['link'] : FALSE;
|
||||
$format = !empty($params['format']) ? $params['format'] : NULL;
|
||||
$format_with_year = variable_get('date_views_' . $granularity . 'format_with_year', 'l, F j, Y');
|
||||
$format_without_year = variable_get('date_views_' . $granularity . 'format_without_year', 'l, F j');
|
||||
$format_with_year = variable_get('date_views_' . $granularity . '_format_with_year', 'l, F j, Y');
|
||||
$format_without_year = variable_get('date_views_' . $granularity . '_format_without_year', 'l, F j');
|
||||
switch ($granularity) {
|
||||
case 'year':
|
||||
$title = $date_info->year;
|
||||
$date_arg = $date_info->year;
|
||||
break;
|
||||
|
||||
case 'month':
|
||||
$format = !empty($format) ? $format : (empty($date_info->mini) ? $format_with_year : $format_without_year);
|
||||
$title = date_format_date($date_info->min_date, 'custom', $format);
|
||||
$date_arg = $date_info->year . '-' . date_pad($date_info->month);
|
||||
break;
|
||||
|
||||
case 'day':
|
||||
$format = !empty($format) ? $format : (empty($date_info->mini) ? $format_with_year : $format_without_year);
|
||||
$title = date_format_date($date_info->min_date, 'custom', $format);
|
||||
$date_arg = $date_info->year . '-' . date_pad($date_info->month) . '-' . date_pad($date_info->day);
|
||||
$date_arg = $date_info->year;
|
||||
$date_arg .= '-';
|
||||
$date_arg .= date_pad($date_info->month);
|
||||
$date_arg .= '-';
|
||||
$date_arg .= date_pad($date_info->day);
|
||||
break;
|
||||
|
||||
case 'week':
|
||||
$format = !empty($format) ? $format : (empty($date_info->mini) ? $format_with_year : $format_without_year);
|
||||
$title = t('Week of @date', array('@date' => date_format_date($date_info->min_date, 'custom', $format)));
|
||||
$title = t('Week of @date', array(
|
||||
'@date' => date_format_date($date_info->min_date, 'custom', $format),
|
||||
));
|
||||
$date_arg = $date_info->year . '-W' . date_pad($date_info->week);
|
||||
break;
|
||||
}
|
||||
|
@@ -132,11 +132,11 @@ class DateAPITestCase extends DrupalWebTestCase {
|
||||
// Test week range with calendar weeks.
|
||||
variable_set('date_first_day', 0);
|
||||
variable_set('date_api_use_iso8601', FALSE);
|
||||
$expected = '2008-01-27 to 2008-02-03';
|
||||
$expected = '2008-01-27 to 2008-02-02';
|
||||
$result = date_week_range(5, 2008);
|
||||
$value = $result[0]->format(DATE_FORMAT_DATE) . ' to ' . $result[1]->format(DATE_FORMAT_DATE);
|
||||
$this->assertEqual($expected, $value, "Test calendar date_week_range(5, 2008): should be $expected, found $value.");
|
||||
$expected = '2009-01-25 to 2009-02-01';
|
||||
$expected = '2009-01-25 to 2009-01-31';
|
||||
$result = date_week_range(5, 2009);
|
||||
$value = $result[0]->format(DATE_FORMAT_DATE) . ' to ' . $result[1]->format(DATE_FORMAT_DATE);
|
||||
$this->assertEqual($expected, $value, "Test calendar date_week_range(5, 2009): should be $expected, found $value.");
|
||||
@@ -144,11 +144,11 @@ class DateAPITestCase extends DrupalWebTestCase {
|
||||
// And now with ISO weeks.
|
||||
variable_set('date_first_day', 1);
|
||||
variable_set('date_api_use_iso8601', TRUE);
|
||||
$expected = '2008-01-28 to 2008-02-04';
|
||||
$expected = '2008-01-28 to 2008-02-03';
|
||||
$result = date_week_range(5, 2008);
|
||||
$value = $result[0]->format(DATE_FORMAT_DATE) . ' to ' . $result[1]->format(DATE_FORMAT_DATE);
|
||||
$this->assertEqual($expected, $value, "Test ISO date_week_range(5, 2008): should be $expected, found $value.");
|
||||
$expected = '2009-01-26 to 2009-02-02';
|
||||
$expected = '2009-01-26 to 2009-02-01';
|
||||
$result = date_week_range(5, 2009);
|
||||
$value = $result[0]->format(DATE_FORMAT_DATE) . ' to ' . $result[1]->format(DATE_FORMAT_DATE);
|
||||
$this->assertEqual($expected, $value, "Test ISO date_week_range(5, 2009): should be $expected, found $value.");
|
||||
@@ -396,6 +396,28 @@ class DateAPITestCase extends DrupalWebTestCase {
|
||||
$date = new dateObject($input, $timezone, $format);
|
||||
$this->assertNotEqual(count($date->errors), 0, '23 abc 2012 should be an invalid date');
|
||||
|
||||
// Test Granularity.
|
||||
$input = '2005-06-01 10:30:45';
|
||||
$timezone = NULL;
|
||||
$format = 'Y-m-d H:i:s';
|
||||
|
||||
$date = new dateObject($input, $timezone, $format);
|
||||
$date->removeGranularity('hour');
|
||||
$date->removeGranularity('second');
|
||||
$date->removeGranularity('minute');
|
||||
|
||||
$value = $date->format($format);
|
||||
$expected = '2005-06-01';
|
||||
$this->assertEqual($expected, $value, "The date with removed granularity should be $expected, found $value.");
|
||||
|
||||
$date->addGranularity('hour');
|
||||
$date->addGranularity('second');
|
||||
$date->addGranularity('minute');
|
||||
|
||||
$value = $date->format($format);
|
||||
$expected = '2005-06-01 10:30:45';
|
||||
|
||||
$this->assertEqual($expected, $value, "The date with added granularity should be $expected, found $value.");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -52,7 +52,7 @@ abstract class DateFieldBasic extends DrupalWebTestCase {
|
||||
$repeat = !empty($repeat) ? $repeat : 0;
|
||||
$todate = !empty($todate) ? $todate : 'optional';
|
||||
$widget_type = !empty($widget_type) ? $widget_type : 'date_select';
|
||||
$tz_handling = !empty($tz_handing) ? $tz_handling : 'site';
|
||||
$tz_handling = !empty($tz_handling) ? $tz_handling : 'site';
|
||||
$granularity = !empty($granularity) ? $granularity : array('year', 'month', 'day', 'hour', 'minute');
|
||||
$year_range = !empty($year_range) ? $year_range : '2010:+1';
|
||||
$input_format = !empty($input_format) ? $input_format : date_default_format($widget_type);
|
||||
@@ -151,6 +151,123 @@ abstract class DateFieldBasic extends DrupalWebTestCase {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a date field from an array of settings values.
|
||||
*
|
||||
* All values have defaults, only need to specify values that need to be
|
||||
* different.
|
||||
*/
|
||||
protected function createMultiDateField($values = array()) {
|
||||
extract($values);
|
||||
|
||||
$field_name = !empty($field_name) ? $field_name : 'field_test';
|
||||
$entity_type = !empty($entity_type) ? $entity_type : 'node';
|
||||
$bundle = !empty($bundle) ? $bundle : 'story';
|
||||
$label = !empty($label) ? $label : 'Test';
|
||||
$field_type = !empty($field_type) ? $field_type : 'datetime';
|
||||
$repeat = !empty($repeat) ? $repeat : 0;
|
||||
$todate = !empty($todate) ? $todate : 'optional';
|
||||
$widget_type = !empty($widget_type) ? $widget_type : 'date_select';
|
||||
$this->verbose(!empty($tz_handling));
|
||||
$tz_handling = !empty($tz_handling) ? $tz_handling : 'site';
|
||||
$granularity = !empty($granularity) ? $granularity : array('year', 'month', 'day', 'hour', 'minute');
|
||||
$year_range = !empty($year_range) ? $year_range : '2010:+1';
|
||||
$input_format = !empty($input_format) ? $input_format : date_default_format($widget_type);
|
||||
$input_format_custom = !empty($input_format_custom) ? $input_format_custom : '';
|
||||
$text_parts = !empty($text_parts) ? $text_parts : array();
|
||||
$increment = !empty($increment) ? $increment : 15;
|
||||
$default_value = !empty($default_value) ? $default_value : 'now';
|
||||
$default_value2 = !empty($default_value2) ? $default_value2 : 'blank';
|
||||
$default_format = !empty($default_format) ? $default_format : 'long';
|
||||
$cache_enabled = !empty($cache_enabled);
|
||||
$cache_count = !empty($cache_count) ? $cache_count : 4;
|
||||
$cardinality = !empty($cardinality) ? $cardinality : 1;
|
||||
|
||||
$field = array(
|
||||
'field_name' => $field_name,
|
||||
'type' => $field_type,
|
||||
'cardinality' => $cardinality,
|
||||
'settings' => array(
|
||||
'granularity' => $granularity,
|
||||
'tz_handling' => $tz_handling,
|
||||
'timezone_db' => date_get_timezone_db($tz_handling),
|
||||
'repeat' => $repeat,
|
||||
'todate' => $todate,
|
||||
'cache_enabled' => $cache_enabled,
|
||||
'cache_count' => $cache_count,
|
||||
),
|
||||
);
|
||||
$instance = array(
|
||||
'entity_type' => $entity_type,
|
||||
'field_name' => $field_name,
|
||||
'label' => $label,
|
||||
'bundle' => $bundle,
|
||||
// Move the date right below the title.
|
||||
'weight' => -4,
|
||||
'widget' => array(
|
||||
'type' => $widget_type,
|
||||
// Increment for minutes and seconds, can be 1, 5, 10, 15, or 30.
|
||||
'settings' => array(
|
||||
'increment' => $increment,
|
||||
// The number of years to go back and forward in drop-down year
|
||||
// selectors.
|
||||
'year_range' => $year_range,
|
||||
'input_format' => $input_format,
|
||||
'input_format_custom' => $input_format_custom,
|
||||
'text_parts' => $text_parts,
|
||||
'label_position' => 'above',
|
||||
'repeat_collapsed' => 0,
|
||||
),
|
||||
'weight' => -4,
|
||||
),
|
||||
'settings' => array(
|
||||
'default_value' => $default_value,
|
||||
'default_value2' => $default_value2,
|
||||
),
|
||||
);
|
||||
|
||||
$instance['display'] = array(
|
||||
'default' => array(
|
||||
'label' => 'above',
|
||||
'type' => 'date_default',
|
||||
'settings' => array(
|
||||
'format_type' => $default_format,
|
||||
'show_repeat_rule' => 'show',
|
||||
'multiple_number' => '',
|
||||
'multiple_from' => '',
|
||||
'multiple_to' => '',
|
||||
'fromto' => 'both',
|
||||
),
|
||||
'module' => 'date',
|
||||
'weight' => 0 ,
|
||||
),
|
||||
'teaser' => array(
|
||||
'label' => 'above',
|
||||
'type' => 'date_default',
|
||||
'weight' => 0,
|
||||
'settings' => array(
|
||||
'format_type' => $default_format,
|
||||
'show_repeat_rule' => 'show',
|
||||
'multiple_number' => '',
|
||||
'multiple_from' => '',
|
||||
'multiple_to' => '',
|
||||
'fromto' => 'both',
|
||||
),
|
||||
'module' => 'date',
|
||||
),
|
||||
);
|
||||
|
||||
$field = field_create_field($field);
|
||||
$instance = field_create_instance($instance);
|
||||
|
||||
field_info_cache_clear(TRUE);
|
||||
field_cache_clear(TRUE);
|
||||
|
||||
// Look at how the field got configured.
|
||||
$this->drupalGet("admin/structure/types/manage/$bundle/fields/$field_name");
|
||||
$this->drupalGet("admin/structure/types/manage/$bundle/display");
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo.
|
||||
*/
|
||||
|
@@ -50,6 +50,111 @@ class DateTimezoneTestCase extends DateFieldBasic {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates timezone handling with a multi-value date field.
|
||||
*/
|
||||
public function testMultiUserTimezone() {
|
||||
// Create date fields with combinations of various types and granularity
|
||||
// using the "Date's Timezone" strategy.
|
||||
$field_type = 'datetime';
|
||||
$tz_handling = 'date';
|
||||
$max_granularity = 'minute';
|
||||
|
||||
// Create date field
|
||||
$field_name = "field_test";
|
||||
$label = 'Test';
|
||||
$options = array(
|
||||
'label' => $label,
|
||||
'widget_type' => 'date_text',
|
||||
'field_name' => $field_name,
|
||||
'field_type' => $field_type,
|
||||
'input_format' => 'custom',
|
||||
'input_format_custom' => 'm/d/Y - H:i:s T',
|
||||
'cardinality' => 3,
|
||||
'tz_handling' => $tz_handling,
|
||||
);
|
||||
$this->createMultiDateField($options);
|
||||
|
||||
// Submit a date field form with multiple values
|
||||
$this->dateMultiValueForm($field_name, $field_type, $max_granularity, $tz_handling);
|
||||
|
||||
|
||||
$this->deleteDateField($label);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the submission of a date field's widget form when using unlimited
|
||||
* cardinality
|
||||
*/
|
||||
public function dateMultiValueForm($field_name, $field_type, $max_granularity, $tz_handling) {
|
||||
variable_set('date_format_long', 'D, m/d/Y - H:i:s T');
|
||||
|
||||
$edit = array();
|
||||
$should_be = array();
|
||||
$edit['title'] = $this->randomName(8);
|
||||
$timezones = array('America/Chicago', 'America/Los_Angeles', 'America/New_York');
|
||||
|
||||
switch ($max_granularity) {
|
||||
case 'hour':
|
||||
$edit[$field_name . '[und][0][value][date]'] = '10/07/2010 - 10:30';
|
||||
$edit[$field_name . '[und][0][timezone][timezone]'] = 'America/Chicago';
|
||||
$should_be[0] = 'Thu, 10/07/2010 - 10 CDT';
|
||||
|
||||
$edit[$field_name . '[und][1][value][date]'] = '10/07/2010 - 10:30';
|
||||
$edit[$field_name . '[und][1][timezone][timezone]'] = 'America/Los_Angeles';
|
||||
$should_be[1] = 'Thu, 10/07/2010 - 10 PDT';
|
||||
|
||||
$edit[$field_name . '[und][2][value][date]'] = '10/07/2010 - 10:30';
|
||||
$edit[$field_name . '[und][2][timezone][timezone]'] = 'America/New_York';
|
||||
$should_be[2] = 'Thu, 10/07/2010 - 10 EDT';
|
||||
|
||||
break;
|
||||
case 'minute':
|
||||
$edit[$field_name . '[und][0][value][date]'] = '10/07/2010 - 10:30';
|
||||
$edit[$field_name . '[und][0][timezone][timezone]'] = 'America/Chicago';
|
||||
$should_be[0] = 'Thu, 10/07/2010 - 10:30 CDT';
|
||||
|
||||
$edit[$field_name . '[und][1][value][date]'] = '10/07/2010 - 10:30';
|
||||
$edit[$field_name . '[und][1][timezone][timezone]'] = 'America/Los_Angeles';
|
||||
$should_be[1] = 'Thu, 10/07/2010 - 10:30 PDT';
|
||||
|
||||
$edit[$field_name . '[und][2][value][date]'] = '10/07/2010 - 10:30';
|
||||
$edit[$field_name . '[und][2][timezone][timezone]'] = 'America/New_York';
|
||||
$should_be[2] = 'Thu, 10/07/2010 - 10:30 EDT';
|
||||
|
||||
break;
|
||||
case 'second':
|
||||
$edit[$field_name . '[und][0][value][date]'] = '10/07/2010 - 10:30';
|
||||
$edit[$field_name . '[und][0][timezone][timezone]'] = 'America/Chicago';
|
||||
$should_be[0] = 'Thu, 10/07/2010 - 10:30:30 CDT';
|
||||
|
||||
$edit[$field_name . '[und][1][value][date]'] = '10/07/2010 - 10:30';
|
||||
$edit[$field_name . '[und][1][timezone][timezone]'] = 'America/Los_Angeles';
|
||||
$should_be[1] = 'Thu, 10/07/2010 - 10:30:30 PDT';
|
||||
|
||||
$edit[$field_name . '[und][2][value][date]'] = '10/07/2010 - 10:30';
|
||||
$edit[$field_name . '[und][2][timezone][timezone]'] = 'America/New_York';
|
||||
$should_be[2] = 'Thu, 10/07/2010 - 10:30:30 EDT';
|
||||
break;
|
||||
}
|
||||
|
||||
$this->drupalPost('node/add/story', $edit, t('Save'));
|
||||
$this->assertText($edit['title'], "Node has been created");
|
||||
|
||||
foreach ($should_be as $assertion) {
|
||||
$this->assertText($assertion, "Found the correct date for a $field_type field using $max_granularity granularity with $tz_handling timezone handling.");
|
||||
}
|
||||
|
||||
// Goto the edit page and save the node again.
|
||||
$node = $this->drupalGetNodeByTitle($edit['title']);
|
||||
$this->drupalGet('node/' . $node->nid . '/edit');
|
||||
|
||||
// Re-assert the proper date timezones.
|
||||
foreach ($timezones as $key => $timezone) {
|
||||
$this->assertOptionSelected('edit-field-test-und-' . $key . '-timezone-timezone', $timezone, "Found the correct timezone $timezone for a $field_type field using $max_granularity granularity with $tz_handling timezone handling.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo.
|
||||
*/
|
||||
|
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Views date pager test.
|
||||
*/
|
||||
|
||||
class ViewsPagerTestCase extends DrupalWebTestCase {
|
||||
/**
|
||||
* Test info.
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Date views pager skipping test',
|
||||
'description' => "Views date pager, option to skip empty pages test",
|
||||
'group' => 'Date',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test setup actions.
|
||||
*/
|
||||
public function setUp() {
|
||||
// Load the 'date_views', 'views', 'views_ui', 'ctools' modules.
|
||||
parent::setUp('date_views', 'views', 'views_ui', 'ctools');
|
||||
// Set required permissions.
|
||||
$permissions = array('administer views', 'administer site configuration');
|
||||
// Create admin user and login.
|
||||
$admin_user = $this->drupalCreateUser($permissions);
|
||||
$this->drupalLogin($admin_user);
|
||||
|
||||
// Create a new view for test.
|
||||
$view = new view();
|
||||
$view->name = 'test_date_pager';
|
||||
$view->description = '';
|
||||
$view->tag = 'default';
|
||||
$view->base_table = 'node';
|
||||
$view->human_name = 'test_date_pager';
|
||||
$view->core = 7;
|
||||
$view->api_version = '3.0';
|
||||
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
|
||||
|
||||
/* Display: Master */
|
||||
$handler = $view->new_display('default', 'Master', 'default');
|
||||
$handler->display->display_options['title'] = 'test_date_pager';
|
||||
$handler->display->display_options['use_more_always'] = FALSE;
|
||||
$handler->display->display_options['access']['type'] = 'perm';
|
||||
$handler->display->display_options['cache']['type'] = 'none';
|
||||
$handler->display->display_options['query']['type'] = 'views_query';
|
||||
$handler->display->display_options['exposed_form']['type'] = 'basic';
|
||||
$handler->display->display_options['pager']['type'] = 'date_views_pager';
|
||||
$handler->display->display_options['pager']['options']['skip_empty_pages'] = 1;
|
||||
$handler->display->display_options['style_plugin'] = 'default';
|
||||
$handler->display->display_options['row_plugin'] = 'node';
|
||||
/* Field: Content: Title */
|
||||
$handler->display->display_options['fields']['title']['id'] = 'title';
|
||||
$handler->display->display_options['fields']['title']['table'] = 'node';
|
||||
$handler->display->display_options['fields']['title']['field'] = 'title';
|
||||
$handler->display->display_options['fields']['title']['label'] = '';
|
||||
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
|
||||
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
|
||||
/* Sort criterion: Content: Post date */
|
||||
$handler->display->display_options['sorts']['created']['id'] = 'created';
|
||||
$handler->display->display_options['sorts']['created']['table'] = 'node';
|
||||
$handler->display->display_options['sorts']['created']['field'] = 'created';
|
||||
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
|
||||
/* Contextual filter: Date: Date (node) */
|
||||
$handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
|
||||
$handler->display->display_options['arguments']['date_argument']['table'] = 'node';
|
||||
$handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
|
||||
$handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
|
||||
$handler->display->display_options['arguments']['date_argument']['default_argument_type'] = 'date';
|
||||
$handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
|
||||
$handler->display->display_options['arguments']['date_argument']['granularity'] = 'hour';
|
||||
$handler->display->display_options['arguments']['date_argument']['date_fields'] = array(
|
||||
'node.created' => 'node.created',
|
||||
);
|
||||
/* Filter criterion: Content: Published */
|
||||
$handler->display->display_options['filters']['status']['id'] = 'status';
|
||||
$handler->display->display_options['filters']['status']['table'] = 'node';
|
||||
$handler->display->display_options['filters']['status']['field'] = 'status';
|
||||
$handler->display->display_options['filters']['status']['value'] = 1;
|
||||
$handler->display->display_options['filters']['status']['group'] = 1;
|
||||
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
|
||||
|
||||
/* Display: Page */
|
||||
$handler = $view->new_display('page', 'Page', 'page_1');
|
||||
$handler->display->display_options['path'] = 'test_date_pager';
|
||||
|
||||
$view->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test pager skipping.
|
||||
*/
|
||||
public function testPagerSkipping() {
|
||||
// Go to view admin page.
|
||||
$this->drupalGet('admin/structure/views/view/display/test_date_pager/edit');
|
||||
// Go to pager options.
|
||||
$this->drupalGet('admin/structure/views/nojs/display/test_date_pager/default/pager_options');
|
||||
// Check if "Skip empty pages" text - exist.
|
||||
$this->assertText('Skip empty pages');
|
||||
// Check if field and it's value is correct.
|
||||
$this->assertFieldByName('pager_options[skip_empty_pages]', '1');
|
||||
// Go back to view admin page.
|
||||
$this->drupalGet('admin/structure/views/view/display/test_date_pager/edit');
|
||||
// Check if pager on empty page are gone.
|
||||
$this->assertNoText('« Prev', 'Previous pager does not exist');
|
||||
$this->assertNoText('Next »', 'Next pager does not exist');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the view page has no PHP warnings.
|
||||
*/
|
||||
public function testPagerWarning() {
|
||||
$this->drupalCreateNode(array('type' => 'blog'));
|
||||
// Set pager to skip empty pages.
|
||||
$edit = array(
|
||||
'pager_options[skip_empty_pages]' => FALSE,
|
||||
);
|
||||
$this->drupalPost('admin/structure/views/nojs/display/test_date_pager/default/pager_options', $edit, t('Apply'));
|
||||
// Save the view.
|
||||
$this->drupalPost('admin/structure/views/view/test_date_pager/edit', array(), t('Save'));
|
||||
|
||||
// Visit view page. This will throw error, if any PHP warnings or errors.
|
||||
$this->drupalGet('test_date_pager');
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Tests date popup in Views
|
||||
*/
|
||||
|
||||
class DateViewsPopupTestCase extends DateFieldBasic {
|
||||
/**
|
||||
* Test info.
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Date Views - Popup Test',
|
||||
'description' => 'Tests date popup in Views',
|
||||
'group' => 'Date',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test setup actions.
|
||||
*/
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
// Load the 'date_popup', 'date_views', 'views', 'views_ui', 'ctools' modules.
|
||||
$modules = array('date_popup', 'date_views', 'views', 'views_ui', 'ctools');
|
||||
$success = module_enable($modules, TRUE);
|
||||
$this->assertTrue($success, t('Enabled modules: %modules', array('%modules' => implode(', ', $modules))));
|
||||
|
||||
// Reset/rebuild all data structures after enabling the modules.
|
||||
$this->resetAll();
|
||||
|
||||
// Create a date field.
|
||||
$field_name = "field_test_date_popup";
|
||||
$label = 'Test';
|
||||
$options = array(
|
||||
'label' => 'Test',
|
||||
'widget_type' => 'date_popup',
|
||||
'field_name' => $field_name,
|
||||
'field_type' => 'datetime',
|
||||
'input_format' => 'm/d/Y - H:i',
|
||||
);
|
||||
$this->createDateField($options);
|
||||
|
||||
// Set required permissions.
|
||||
$permissions = array('administer views', 'administer site configuration');
|
||||
// Create admin user and login.
|
||||
$admin_user = $this->drupalCreateUser($permissions);
|
||||
$this->drupalLogin($admin_user);
|
||||
|
||||
// Create the view.
|
||||
$view = new view();
|
||||
$view->name = 'test_date_popup';
|
||||
$view->description = '';
|
||||
$view->tag = 'default';
|
||||
$view->base_table = 'node';
|
||||
$view->human_name = 'Test date_popup';
|
||||
$view->core = 7;
|
||||
$view->api_version = '3.0';
|
||||
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
|
||||
|
||||
/* Display: Master */
|
||||
$handler = $view->new_display('default', 'Master', 'default');
|
||||
$handler->display->display_options['title'] = 'test_date_popup_page';
|
||||
$handler->display->display_options['use_more_always'] = FALSE;
|
||||
$handler->display->display_options['access']['type'] = 'perm';
|
||||
$handler->display->display_options['cache']['type'] = 'none';
|
||||
$handler->display->display_options['query']['type'] = 'views_query';
|
||||
$handler->display->display_options['exposed_form']['type'] = 'basic';
|
||||
$handler->display->display_options['pager']['type'] = 'none';
|
||||
$handler->display->display_options['pager']['options']['offset'] = '0';
|
||||
$handler->display->display_options['style_plugin'] = 'default';
|
||||
$handler->display->display_options['row_plugin'] = 'node';
|
||||
/* Field: Content: Title */
|
||||
$handler->display->display_options['fields']['title']['id'] = 'title';
|
||||
$handler->display->display_options['fields']['title']['table'] = 'node';
|
||||
$handler->display->display_options['fields']['title']['field'] = 'title';
|
||||
$handler->display->display_options['fields']['title']['label'] = '';
|
||||
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
|
||||
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
|
||||
/* Filter criterion: Content: test_date_popup (field_test_date_popup) */
|
||||
$handler->display->display_options['filters']['field_test_date_popup_value']['id'] = 'field_test_date_popup_value';
|
||||
$handler->display->display_options['filters']['field_test_date_popup_value']['table'] = 'field_data_field_test_date_popup';
|
||||
$handler->display->display_options['filters']['field_test_date_popup_value']['field'] = 'field_test_date_popup_value';
|
||||
$handler->display->display_options['filters']['field_test_date_popup_value']['exposed'] = TRUE;
|
||||
$handler->display->display_options['filters']['field_test_date_popup_value']['expose']['operator_id'] = 'field_test_date_popup_value_op';
|
||||
$handler->display->display_options['filters']['field_test_date_popup_value']['expose']['label'] = 'test_date_popup (field_test_date_popup)';
|
||||
$handler->display->display_options['filters']['field_test_date_popup_value']['expose']['operator'] = 'field_test_date_popup_value_op';
|
||||
$handler->display->display_options['filters']['field_test_date_popup_value']['expose']['identifier'] = 'field_test_date_popup_value';
|
||||
$handler->display->display_options['filters']['field_test_date_popup_value']['form_type'] = 'date_popup';
|
||||
|
||||
/* Display: Page */
|
||||
$handler = $view->new_display('page', 'Page', 'page');
|
||||
$handler->display->display_options['path'] = 'test-date-popup';
|
||||
|
||||
$view->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test date popup.
|
||||
*/
|
||||
public function testDatePopup() {
|
||||
// Go to view page.
|
||||
$this->drupalGet('test-date-popup');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user