1.cache.php 355 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466
  1. <?php return array (
  2. 'resourceClass' => 'modDocument',
  3. 'resource' =>
  4. array (
  5. 'id' => 1,
  6. 'type' => 'document',
  7. 'contentType' => 'text/html',
  8. 'pagetitle' => 'Australian crop management platform',
  9. 'longtitle' => 'Crop Management Platform',
  10. 'description' => 'Designed to keep all your records in one place, interfacing irrigation systems, weather data, and real-time moisture monitoring, based in Australia on local conditions.',
  11. 'alias' => 'index',
  12. 'alias_visible' => 1,
  13. 'link_attributes' => '',
  14. 'published' => 1,
  15. 'pub_date' => 0,
  16. 'unpub_date' => 0,
  17. 'parent' => 0,
  18. 'isfolder' => 1,
  19. 'introtext' => 'crop management, irrigation alerts, weather reporting, moisture monitoring, realtime dashboard, agricultural monitoring.',
  20. 'content' => 'Cloud based Soil, Plant and Water Analysis, Comprehensive Reporting based on Sustainable Agricultural Practices.',
  21. 'richtext' => 0,
  22. 'template' => 5,
  23. 'menuindex' => 6,
  24. 'searchable' => 1,
  25. 'cacheable' => 1,
  26. 'createdby' => 1,
  27. 'createdon' => 1510602201,
  28. 'editedby' => 1,
  29. 'editedon' => 1574162405,
  30. 'deleted' => 0,
  31. 'deletedon' => 0,
  32. 'deletedby' => 0,
  33. 'publishedon' => 0,
  34. 'publishedby' => 0,
  35. 'menutitle' => '',
  36. 'donthit' => 0,
  37. 'privateweb' => 0,
  38. 'privatemgr' => 0,
  39. 'content_dispo' => 0,
  40. 'hidemenu' => 0,
  41. 'class_key' => 'modDocument',
  42. 'context_key' => 'web',
  43. 'content_type' => 1,
  44. 'uri' => 'index/',
  45. 'uri_override' => 0,
  46. 'hide_children_in_tree' => 0,
  47. 'show_in_tree' => 1,
  48. 'properties' => NULL,
  49. 'Background' =>
  50. array (
  51. 0 => 'Background',
  52. 1 => '',
  53. 2 => 'default',
  54. 3 => NULL,
  55. 4 => 'image',
  56. ),
  57. 'mailChimpSubscribe' =>
  58. array (
  59. 0 => 'mailChimpSubscribe',
  60. 1 => '04e221f3bc',
  61. 2 => 'default',
  62. 3 => NULL,
  63. 4 => 'listbox',
  64. ),
  65. '_content' => '<!DOCTYPE html>
  66. <html lang="en">
  67. <head>
  68. <title>Crop Management Platform | Crop Monitor</title>
  69. <base href="[[!++site_url]]" />
  70. <meta charset="UTF-8" />
  71. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" >
  72. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  73. <meta name="keywords" content="crop management, irrigation alerts, weather reporting, moisture monitoring, realtime dashboard, agricultural monitoring." />
  74. <meta name="description" content="Designed to keep all your records in one place, interfacing irrigation systems, weather data, and real-time moisture monitoring, based in Australia on local conditions." />
  75. <link rel="icon" href="client-assets/images/favicon.ico?v=2" type="image/x-icon" >
  76. <!-- Global site tag (gtag.js) - Google Analytics -->
  77. <script type="text/javascript" async src="https://www.googletagmanager.com/gtag/js?id=UA-133963301-1"></script>
  78. <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
  79. <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
  80. <script type="text/javascript" src="https://use.fontawesome.com/1e2844bb90.js"></script>
  81. <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.1/css/all.css" integrity="sha384-gfdkjb5BdAXd+lj+gudLWI+BXq4IuLW5IT+brZEZsLFm++aCMlF1V92rMkPaX4PP" crossorigin="anonymous" />
  82. <link rel="stylesheet" type="text/css" href="/client-assets/weather-icons/css/weather-icons.min.css?version=1.16" />
  83. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/magnific-popup.css" />
  84. <!-- Custom styles for this template -->
  85. <link rel="stylesheet" href="client-assets/css/greyscale.css" >
  86. <link href="https://fonts.googleapis.com/css?family=Varela+Round" rel="stylesheet">
  87. <link href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i" rel="stylesheet">
  88. </head>
  89. <style>
  90. .nav-link {
  91. text-align: center;
  92. font-weight: bold;
  93. }
  94. </style>
  95. <body id="page-top">
  96. <!-- Navigation -->
  97. <nav class="navbar navbar-expand-lg navbar-light fixed-top py-3" id="mainNav">
  98. <div class="container">
  99. <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
  100. <span class="navbar-toggler-icon"></span>
  101. </button>
  102. <div class="collapse navbar-collapse" id="navbarResponsive">
  103. <ul class="navbar-nav mr-auto my-2 my-lg-0">
  104. <li class="nav-item active">
  105. <a class="nav-link js-scroll-trigger" href="#page-top">Home</a>
  106. </li>
  107. <li class="nav-item">
  108. <a class="nav-link js-scroll-trigger" href="#about">About</a>
  109. </li>
  110. <li class="nav-item">
  111. <a class="nav-link js-scroll-trigger" href="#services">Services</a>
  112. </li>
  113. <li class="nav-item">
  114. <a class="nav-link js-scroll-trigger" href="#pricing">Pricing</a>
  115. </li>
  116. </ul>
  117. <a class="navbar-brand js-scroll-trigger" href="#page-top">
  118. <img src="client-assets/images/crop-monitor-logo.png" height="50" class="d-inline-block align-top" alt="">
  119. </a>
  120. <ul class="navbar-nav ml-auto my-2 my-lg-0">
  121. <li class="nav-item">
  122. <a class="nav-link js-scroll-trigger" href="#signup">Newsletter</a>
  123. </li>
  124. <li class="nav-item">
  125. <a class="nav-link js-scroll-trigger" href="#blog">Blog</a>
  126. </li>
  127. <li class="nav-item">
  128. <a class="nav-link js-scroll-trigger" href="#contact">Contact Us</a>
  129. </li>
  130. <li class="nav-item">
  131. <a class="nav-link js-scroll-trigger" href="login/">Login</a>
  132. </li>
  133. </ul>
  134. </div>
  135. </div>
  136. </nav>
  137. <!-- Header -->
  138. <header class="header-image masthead">
  139. <div class="overlay"></div>
  140. <!--
  141. <div class="background">
  142. <div class="layer clouds">
  143. <div class="cloud cloud-1">
  144. <img src="client-assets/images/cloud-1.png" width="1600" height="850" alt="">
  145. </div>
  146. <div class="cloud cloud-2">
  147. <img src="client-assets/images/cloud-1.png" width="1600" height="850" alt="">
  148. </div>
  149. <div class="cloud cloud-3">
  150. <img src="client-assets/images/cloud-1.png" width="1600" height="850" alt="">
  151. </div>
  152. </div>
  153. </div>
  154. -->
  155. <!--
  156. <div class="container d-flex h-100 align-items-center">
  157. <div class="mx-auto text-center">
  158. <h1 class="mx-auto my-0 text-uppercase">Cropmonitor</h1>
  159. <img class="img-fluid" src="client-assets/images/crop-monitor-logo.png" alt="Cropmonitor">
  160. <h3 class="font-weight-bolder mx-auto mt-2 mb-5">Designed to keep all your records in one place, interfacing irrigation systems, weather data, and real-time moisture monitoring, based in Australia on local conditions.</h3>
  161. <h4 class="mx-auto mt-2 mb-5">Cloud based Soil, Plant and Water Analysis, Comprehensive Reporting based on Sustainable Agricultural Practices.</h4>
  162. <a href="#register" class="btn btn-success js-scroll-trigger text-light">Get Started</a>
  163. </div>
  164. </div>
  165. -->
  166. <div class="container h-100">
  167. <div class="row h-100 align-items-center justify-content-center text-center">
  168. <div class="col-lg-10 align-self-end">
  169. <!-- <p><img src="client-assets/images/favicon.ico" height="200" class="mx-auto" alt="Cropmonitor"></p> -->
  170. <img class="img-fluid my-5" src="client-assets/images/crop-monitor-logo.png" alt="Cropmonitor">
  171. <h1 class="text-uppercase text-white font-weight-bolder">Crop Management Platform</h1>
  172. <h2 class="text-white font-weight-bold">Designed to keep all your records in one place, interfacing irrigation systems, weather data, and real-time moisture monitoring, based in Australia on local conditions.</h2>
  173. <hr class="divider light my-4">
  174. </div>
  175. <div class="col-lg-8 align-self-baseline">
  176. <h4 class="text-white font-weight-light mb-5">Cloud based Soil, Plant and Water Analysis, Comprehensive Reporting based on Sustainable Agricultural Practices.</h4>
  177. <a class="btn btn-dark btn-xl js-scroll-trigger" href="#about">Find Out More</a>
  178. </div>
  179. <div class="container">
  180. <div class="row align-items-center">
  181. <div class="col-md">
  182. <!-- Social links -->
  183. <ul class="list-group list-group-horizontal text-center text-lg-left">
  184. <li class="list-group-item bg-transparent border-0"><a href="#"><i class="fab fa-twitter fa-2x"></i></a></li>
  185. <li class="list-group-item bg-transparent border-0"><a href="#"><i class="fab fa-facebook-f fa-2x"></i></a></li>
  186. <li class="list-group-item bg-transparent border-0"><a href="#"><i class="fab fa-instagram fa-2x"></i></a></li>
  187. </ul>
  188. </div>
  189. <div class="col-md">
  190. <!-- Address -->
  191. <div class="section_welcome__footer__address text-center text-white text-lg-right">
  192. <i class="fas fa-map-marker-alt"></i> 34 Coplestone Street, Scottsdale, Tas, 7260
  193. </div>
  194. </div>
  195. </div> <!-- / .row -->
  196. </div>
  197. </div>
  198. </div>
  199. </header>
  200. <!-- About Section -->
  201. <section id="about" class="about-section bg-success text-center">
  202. <div class="container">
  203. <div class="row">
  204. <div class="col-lg-8 mx-auto">
  205. <h1 class="text-white mb-4">Built with Bootstrap 4</h1>
  206. <h2 class="text-white mb-4">Built with Bootstrap 4</h2>
  207. <p class="text-white">Grayscale is a free Bootstrap theme created by Start Bootstrap. It can be yours right now, simply download the template on the preview page. The theme is open source, and you can use it for any purpose, personal or commercial.</p>
  208. </div>
  209. </div>
  210. </div>
  211. </section>
  212. <!-- Projects Section -->
  213. <section id="services" class="projects-section bg-light">
  214. <div class="container">
  215. [[!getResources?
  216. &parents=`1`
  217. &level=`0`
  218. &includeTVs=`1`
  219. &processTVs=`1`
  220. &includeContent=`1`
  221. &tplFirst=`projectsSectionFIRST`
  222. &tpl=`projectsSectionEVEN`
  223. &tplOdd=`projectsSectionODD`
  224. &sortby=`FIELD(modResource.id, 70,20,21,19,22,68,69 )`
  225. &sortdir=`ASC`
  226. &limit=`0`
  227. ]]
  228. </div>
  229. </section>
  230. <!-- Blogs Section -->
  231. <section id="blog" class="blog-section bg-light">
  232. <div class="container">
  233. <div vlass="row">
  234. <h2>Latest Blogs</h2>
  235. </div>
  236. <div class="row">
  237. [[!getPage@blog_paging?
  238. &elementClass=`modSnippet`
  239. &element=`getResources`
  240. &parents=`1`
  241. &tpl=`Home_blogit.blog_row_tpl`
  242. &includeTVs=`1`
  243. &processTVs=`1`
  244. &tvPrefix=``
  245. &where=`[[!TaggerGetResourcesWhere]]`
  246. &limit=`3`
  247. &sortby=`RAND()`
  248. ]]
  249. </div>
  250. </div>
  251. </section>
  252. <!-- Signup Section -->
  253. <section id="signup" class="signup-section">
  254. <div class="container">
  255. <div class="row">
  256. <div class="col-md-10 col-lg-8 mx-auto text-center">
  257. <i class="far fa-paper-plane fa-2x mb-2 text-white"></i>
  258. <h2 class="text-white mb-5">Subscribe to receive updates!</h2>
  259. [[!FormIt?
  260. &hooks=`MailChimpSubscribe`
  261. &validate=`email:email:required,name:required`
  262. &validationErrorMessage=`true`
  263. &clearFieldsOnSuccess=`1`
  264. &submitVar=`newsletter-submit`
  265. &mailchimpListId=`04e221f3bc`
  266. &mailchimpFields=`name=FNAME,email=EMAIL`
  267. &mailchimpSubscribeField=`newsletter`
  268. &mailchimpSubscribeFieldValue=`1`
  269. &successMessage=`Thankyou for subscribing`
  270. ]]
  271. <span>[[!+fi.successMessage:notempty=`<h2 class="text-white mb-5">[[!+fi.successMessage]]</h2>`]]
  272. [[!+fi.validation_error_message:notempty=`<h2 class="text-white mb-5">[[+errors]] [[!+fi.validation_error_message]]</h2>`]]</span>
  273. <form action="/#signup" method="post" class="form-inline d-flex">
  274. <input type="hidden" name="nospam" value="" />
  275. <input class="form-control flex-fill mr-0 mr-sm-2 mb-3 mb-sm-0" type="email" name="email" id="email" value="[[!+fi.email]]" placeholder="Email Address" >
  276. <input class="form-control flex-fill mr-0 mr-sm-2 mb-3 mb-sm-0" type="text" name="name" id="name" value="[[!+fi.name]]" placeholder="Full Name">
  277. <input type="submit" name="newsletter-submit" class="btn btn-success mx-auto" value="Subscribe" />
  278. </form>
  279. </div>
  280. </div>
  281. </div>
  282. </section>
  283. <!-- Contact Section -->
  284. <section id="contact" class="contact-section bg-black">
  285. <div class="container">
  286. <div class="row">
  287. <div class="col-md-4 mb-3 mb-md-0">
  288. <div class="card py-4 h-100">
  289. <div class="card-body text-center">
  290. <i class="fas fa-map-marked-alt text-primary mb-2"></i>
  291. <h4 class="text-uppercase m-0">Address</h4>
  292. <hr class="my-4">
  293. <div class="small text-black-50">34 Coplestone Street,<br> Scottsdale, Tasmania 7260</div>
  294. </div>
  295. </div>
  296. </div>
  297. <div class="col-md-4 mb-3 mb-md-0">
  298. <div class="card py-4 h-100">
  299. <div class="card-body text-center">
  300. <i class="fas fa-envelope text-primary mb-2"></i>
  301. <h4 class="text-uppercase m-0">Email</h4>
  302. <hr class="my-4">
  303. <div class="small text-black-50">
  304. <a href="#">enquiry@cropmonitor.info</a>
  305. </div>
  306. </div>
  307. </div>
  308. </div>
  309. <div class="col-md-4 mb-3 mb-md-0">
  310. <div class="card py-4 h-100">
  311. <div class="card-body text-center">
  312. <i class="fas fa-mobile-alt text-primary mb-2"></i>
  313. <h4 class="text-uppercase m-0">Phone</h4>
  314. <hr class="my-4">
  315. <div class="small text-black-50">0417 728 061</div>
  316. </div>
  317. </div>
  318. </div>
  319. </div>
  320. <div class="row">
  321. <div class="col mb-3 mt-3 mb-md-0">
  322. <div class="card py-4 h-100">
  323. <div class="card-body text-center">
  324. <i class="fas fa-mobile-alt text-primary mb-2"></i>
  325. <h4 class="text-uppercase m-0">Contact Us</h4>
  326. <hr class="my-4">
  327. [[!FormIt?
  328. &hooks=`spam,email`
  329. &submitVar=`enquiry-submit`
  330. &emailTpl=`CMenquiryEmailTpl`
  331. &emailTo=`enquiries@cropmonitor.info`
  332. &successMessage=`Thankyou for contacting us, we will be in touch soon.`
  333. &validationErrorMessage=`true`
  334. &validate=`nospam:blank,
  335. name:required,
  336. email:email:required,
  337. text:required:stripTags`
  338. ]]
  339. <span>
  340. [[!+fi.successMessage:notempty=`<div class="small text-black-50">[[!+fi.successMessage]]</div>`]]
  341. [[!+fi.validation_error_message:notempty=`<div class="small text-black-50">[[+errors]] [[!+fi.validation_error_message]]</div>`]]
  342. </span>
  343. <form action="/#contact" method="post" class="form-inline d-flex">
  344. <input type="hidden" name="nospam" value="" />
  345. <input class="form-control form-control-sm flex-fill mr-0 mr-sm-2 mb-3 mb-sm-0" type="email" name="email" id="email" value="[[!+fi.email]]" placeholder="Email Address" >
  346. <input class="form-control form-control-sm flex-fill mr-0 mr-sm-2 mb-3 mb-sm-0" type="text" name="name" id="name" value="[[!+fi.name]]" placeholder="Full Name">
  347. <textarea class="form-control form-control-sm flex-fill mr-0 mr-sm-2 mb-3 mb-sm-0" name="text" id="text" rows="1" value="[[!+fi.text]]" placeholder="Your enquiry is about...." ></textarea>
  348. <input type="submit" name="enquiry-submit" class="btn-sm btn btn-success" value="Submit" />
  349. </form>
  350. </div>
  351. </div>
  352. </div>
  353. </div>
  354. <div class="social d-flex justify-content-center">
  355. <a href="#" class="mx-2">
  356. <i class="fab fa-youtube"></i>
  357. </a>
  358. <a href="#" class="mx-2">
  359. <i class="fab fa-facebook-f"></i>
  360. </a>
  361. <a href="#" class="mx-2">
  362. <i class="fab fa-linkedin"></i>
  363. </a>
  364. </div>
  365. </div>
  366. </section>
  367. <!-- Modal -->
  368. <div class="modal fade" id="soilAnalysisExample" tabindex="-1" role="dialog" aria-labelledby="soilAnalysisExample" aria-hidden="true">
  369. <div class="modal-dialog modal-xl modal-dialog-centered" role="document">
  370. <div class="modal-content">
  371. <div class="modal-header">
  372. <h5 class="modal-title" id="soilAnalysisExample">Try out our Soil Test Analysis Report</h5>
  373. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  374. <span aria-hidden="true">&times;</span>
  375. </button>
  376. </div>
  377. <div class="modal-body">
  378. <div class="grid-form1">
  379. <span class="error">* required fields.</span>
  380. <form method="post" action="#" id="csvForm" class="needs-validation" novalidate >
  381. <div class="form-row">
  382. <div class="form-group col-12 col-md-4 mb-1">
  383. <label for="client_name" class="p-0 mb-0 col-form-label-sm">Client Name<span class="error">*</span></label>
  384. <input type="text" class="form-control form-control-sm" name="name" id="name" placeholder="Client Name" required autocomplete="on">
  385. </div>
  386. <div class="form-group col-12 col-md-4 mb-1">
  387. <label for="email" class="p-0 mb-0 col-form-label-sm">Email address<span class="error">*</span></label>
  388. <input type="email" class="form-control form-control-sm" name="email" id="email" placeholder="Email address" required autocomplete="on">
  389. </div>
  390. <div class="form-group col-12 col-md-4 mb-1">
  391. <label for="company_name" class="p-0 mb-0 col-form-label-sm">Company Name</label>
  392. <input type="text" class="form-control form-control-sm" name="company" id="company" placeholder="Company Name" autocomplete="on">
  393. </div>
  394. </div>
  395. <div class="form-row">
  396. <div class="form-group col-12 col-md-6 mb-1">
  397. <label for="site_address" class="p-0 mb-0 col-form-label-sm">Site Address</label>
  398. <input type="text" class="form-control form-control-sm" name="site_address" id="site_address" placeholder="Site Address" autocomplete="on">
  399. </div>
  400. <div class="form-group col-12 col-md-6 mb-1">
  401. <label for="state_postcode" class="p-0 mb-0 col-form-label-sm">Postal Address</label>
  402. <input type="text" class="form-control form-control-sm" name="postal_address" id="postal_address" placeholder="Postal Address" autocomplete="on">
  403. </div>
  404. </div>
  405. <hr>
  406. [[$soilAnalysisForm_bootstrap]]
  407. <button form="csvForm" type="submit" name="csvForm" class="btn btn-success">Submit</button>
  408. </form>
  409. [[!soilformSubmit]]
  410. <script type="text/javascript">
  411. // JavaScript for disabling form submission if there are invalid fields
  412. (function() {
  413. \'use strict\';
  414. window.addEventListener(\'load\', function() {
  415. // Fetch all the forms we want to apply custom Bootstrap validation styles to
  416. var forms = document.getElementsByClassName(\'needs-validation\');
  417. // Loop over them and prevent submission
  418. var validation = Array.prototype.filter.call(forms, function(form) {
  419. form.addEventListener(\'submit\', function(event) {
  420. if (form.checkValidity() === false) {
  421. event.preventDefault();
  422. event.stopPropagation();
  423. }
  424. form.classList.add(\'was-validated\');
  425. }, false);
  426. });
  427. }, false);
  428. })();
  429. </script>
  430. </div>
  431. </div>
  432. </div>
  433. </div>
  434. </div>
  435. <!-- Modal -->
  436. <div class="modal fade" id="plantAnalysisExample" tabindex="-1" role="dialog" aria-labelledby="plantAnalysisExample" aria-hidden="true">
  437. <div class="modal-dialog modal-xl modal-dialog-centered" role="document">
  438. <div class="modal-content">
  439. <div class="modal-header">
  440. <h5 class="modal-title" id="plantAnalysisExample">Try out our Plant Analysis Report</h5>
  441. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  442. <span aria-hidden="true">&times;</span>
  443. </button>
  444. </div>
  445. <div class="modal-body">
  446. <div class="grid-form1">
  447. <span class="error">* required fields.</span>
  448. <form method="post" action="#" id="PlantcsvForm" class="needs-validation" novalidate >
  449. <div class="form-row">
  450. <div class="form-group col-12 col-md-4 mb-1">
  451. <label for="client_name" class="p-0 mb-0 col-form-label-sm">Client Name<span class="error">*</span></label>
  452. <input type="text" class="form-control form-control-sm" name="name" id="name" placeholder="Client Name" required autocomplete="on">
  453. </div>
  454. <div class="form-group col-12 col-md-4 mb-1">
  455. <label for="email" class="p-0 mb-0 col-form-label-sm">Email address<span class="error">*</span></label>
  456. <input type="email" class="form-control form-control-sm" name="email" id="email" placeholder="Email address" required autocomplete="on">
  457. </div>
  458. <div class="form-group col-12 col-md-4 mb-1">
  459. <label for="company_name" class="p-0 mb-0 col-form-label-sm">Company Name</label>
  460. <input type="text" class="form-control form-control-sm" name="company" id="company" placeholder="Company Name" autocomplete="on">
  461. </div>
  462. </div>
  463. <div class="form-row">
  464. <div class="form-group col-12 col-md-6 mb-1">
  465. <label for="site_address" class="p-0 mb-0 col-form-label-sm">Site Address</label>
  466. <input type="text" class="form-control form-control-sm" name="site_address" id="site_address" placeholder="Site Address" autocomplete="on">
  467. </div>
  468. <div class="form-group col-12 col-md-6 mb-1">
  469. <label for="state_postcode" class="p-0 mb-0 col-form-label-sm">Postal Address</label>
  470. <input type="text" class="form-control form-control-sm" name="postal_address" id="postal_address" placeholder="Postal Address" autocomplete="on">
  471. </div>
  472. </div>
  473. <hr>
  474. <div class="form-row">
  475. <div class="col-md-3 form-group">
  476. <small id="analysis_type" class="form-text text-muted">Analysis Type<span class="error">*</span></small>
  477. <div><select name="analysis_type" id="analysis_type" class="form-control form-control-sm" required>
  478. <option>Select the type of Analysis...</option>
  479. <option id="ash">Dry Ash Test</option>
  480. <option id="sap">Sap Analysis</option>
  481. <option id="field">Field Test</option>
  482. </select></div>
  483. </div>
  484. <div class="col-md-3 form-group">
  485. <small id="lab_no" class="form-text text-muted">Lab No</small>
  486. <div class="input-group input-group-sm mb-3">
  487. <input type="text" class="form-control form-control-sm" name="lab_no" id="lab_no" placeholder="Lab No"></input>
  488. </div>
  489. </div>
  490. <div class="col-md-3 form-group">
  491. <small id="batch_no" class="form-text text-muted">Batch No</small>
  492. <div class="input-group input-group-sm mb-3">
  493. <input type="text" class="form-control form-control-sm" name="batch_no" id="batch_no" placeholder="Batch No"></input>
  494. </div>
  495. </div>
  496. <div class="col-md-3 form-group">
  497. <small id="date_sampled" class="form-text text-muted">Date Sampled</small>
  498. <input data-provide="datepicker" class="form-control form-control-sm" name="date_sampled" id="datepicker" placeholder="Date Sampled" data-date-format="dd/mm/yyyy" data-date-end-date="0d" ></input>
  499. <script>
  500. $(\'#datepicker\').datepicker({
  501. uiLibrary: \'bootstrap4\',
  502. calendarWeeks: \'true\',
  503. todayHighlight: \'true\'
  504. });
  505. </script>
  506. </div>
  507. <!-- Hidden Fields for Database -->
  508. <input type="hidden" class="form-control form-control-sm" name="m_user" id="m_user" placeholder="0" required>
  509. <input type="hidden" class="form-control form-control-sm" name="client_id" id="client_id" placeholder="(anonymous)" required>
  510. </div>
  511. <div class="form-row">
  512. <div class="col-md-4 form-group">
  513. <small id="lab_no" class="form-text text-muted">Sample ID<span class="error">*</span></small>
  514. <input type="text" class="form-control form-control-sm" name="sample_id" id="sample_id" placeholder="Sample Id" required></input>
  515. </div>
  516. <div class="col-md-4 form-group">
  517. <small id="lab_no" class="form-text text-muted">Site ID</small>
  518. <input type="text" class="form-control form-control-sm" name="site_id" id="site_id" placeholder="Paddock Id"></input>
  519. </div>
  520. [[!croptypeFORM]]
  521. </div>
  522. <hr>
  523. <label class="col"><b>Analysis Inputs</b></label>
  524. <div class="form-row">
  525. <div class="form-group col-md-2">
  526. <small id="nSmall" class="form-text text-muted">Nitrogen</small>
  527. <div class="input-group input-group-sm mb-3">
  528. <input type="text" class="form-control form-control-sm" name="n" id="n" placeholder="N - Nitrogen"></input>
  529. <div class="input-group-append">
  530. <input class="btn btn-append" type="button" id="nitrogen" value="ppm" onClick="conversion(this, nitrogen, n, 10000)" ></input>
  531. </div>
  532. </div>
  533. </div>
  534. <div class="form-group col-md-2">
  535. <small id="p" class="form-text text-muted">Phosphorus</small>
  536. <div class="input-group input-group-sm mb-3">
  537. <input type="text" class="form-control form-control-sm" name="p" id="p" placeholder="P - Phosphorus"></input>
  538. <div class="input-group-append">
  539. <input class="btn btn-append" type="button" id="phosphorus" value="ppm" onClick="conversion(this, phosphorus, p, 10000)" ></input>
  540. </div>
  541. </div>
  542. </div>
  543. <div class="form-group col-md-2">
  544. <small id="k" class="form-text text-muted">Postassium</small>
  545. <div class="input-group input-group-sm mb-3">
  546. <input type="text" class="form-control form-control-sm" name="k" id="k" placeholder="K - Postassium"></input>
  547. <div class="input-group-append">
  548. <input class="btn btn-append" type="button" id="postassium" value="ppm" onClick="conversion(this, postassium, k, 10000)" ></input>
  549. </div>
  550. </div>
  551. </div>
  552. <div class="form-group col-md-2">
  553. <small id="s" class="form-text text-muted">Sulphur</small>
  554. <div class="input-group input-group-sm mb-3">
  555. <input type="text" class="form-control form-control-sm" name="s" id="s" placeholder="S - Sulphur"></input>
  556. <div class="input-group-append">
  557. <input class="btn btn-append" type="button" id="sulphur" value="ppm" onClick="conversion(this, sulphur, s, 10000)" ></input>
  558. </div>
  559. </div>
  560. </div>
  561. <div class="form-group col-md-2">
  562. <small id="mg" class="form-text text-muted">Magnesium</small>
  563. <div class="input-group input-group-sm mb-3">
  564. <input type="text" class="form-control form-control-sm" name="mg" id="mg" placeholder="Mg - Magnesium"></input>
  565. <div class="input-group-append">
  566. <input class="btn btn-append" type="button" id="magnesium" value="ppm" onClick="conversion(this, magnesium, mg, 10000)" ></input>
  567. </div>
  568. </div>
  569. </div>
  570. <div class="form-group col-md-2">
  571. <small id="ca" class="form-text text-muted">Calcium</small>
  572. <div class="input-group input-group-sm mb-3">
  573. <input type="text" class="form-control form-control-sm" name="ca" id="ca" placeholder="Ca - Calcium"></input>
  574. <div class="input-group-append">
  575. <input class="btn btn-append" type="button" id="calcium" value="ppm" onClick="conversion(this, calcium, ca, 10000)" ></input>
  576. </div>
  577. </div>
  578. </div>
  579. </div>
  580. <div class="form-row">
  581. <div class="form-group col-md-2">
  582. <small id="na" class="form-text text-muted">Soduim</small>
  583. <div class="input-group input-group-sm mb-3">
  584. <input type="text" class="form-control form-control-sm" name="na" id="na" placeholder="Na - Soduim"></input>
  585. <div class="input-group-append">
  586. <input class="btn btn-append" type="button" id="soduim" value="ppm" onClick="conversion(this, soduim, na, 10000)" ></input>
  587. </div>
  588. </div>
  589. </div>
  590. <div class="form-group col-md-2">
  591. <small id="fe" class="form-text text-muted">Iron</small>
  592. <div class="input-group input-group-sm mb-3">
  593. <input type="text" class="form-control form-control-sm" name="fe" id="fe" placeholder="Fe - Iron"></input>
  594. <div class="input-group-append">
  595. <input class="btn btn-append" type="button" id="iron" value="ppm" onClick="conversion(this, iron, fe, 10000)" ></input>
  596. </div>
  597. </div>
  598. </div>
  599. <div class="form-group col-md-2">
  600. <small id="mn" class="form-text text-muted">Manganese</small>
  601. <div class="input-group input-group-sm mb-3">
  602. <input type="text" class="form-control form-control-sm" name="mn" id="mn" placeholder="Mn - Manganese"></input>
  603. <div class="input-group-append">
  604. <input class="btn btn-append" type="button" id="manganese" value="ppm" onClick="conversion(this, manganese, mn, 10000)" ></input>
  605. </div>
  606. </div>
  607. </div>
  608. <div class="form-group col-md-2">
  609. <small id="zn" class="form-text text-muted">Zinc</small>
  610. <div class="input-group input-group-sm mb-3">
  611. <input type="text" class="form-control form-control-sm" name="zn" id="zn" placeholder="Zn - Zinc"></input>
  612. <div class="input-group-append">
  613. <input class="btn btn-append" type="button" id="zinc" value="ppm" onClick="conversion(this, zinc, zn, 10000)" ></input>
  614. </div>
  615. </div>
  616. </div>
  617. <div class="form-group col-md-2">
  618. <small id="cu" class="form-text text-muted">Copper</small>
  619. <div class="input-group input-group-sm mb-3">
  620. <input type="text" class="form-control form-control-sm" name="cu" id="cu" placeholder="Cu - Copper"></input>
  621. <div class="input-group-append">
  622. <input class="btn btn-append" type="button" id="copper" value="ppm" onClick="conversion(this, copper, cu, 10000)" ></input>
  623. </div>
  624. </div>
  625. </div>
  626. <div class="form-group col-md-2">
  627. <small id="b" class="form-text text-muted">Boron</small>
  628. <div class="input-group input-group-sm mb-3">
  629. <input type="text" class="form-control form-control-sm" name="b" id="b" placeholder="B - Boron"></input>
  630. <div class="input-group-append">
  631. <input class="btn btn-append" type="button" id="boron" value="ppm" onClick="conversion(this, boron, b, 10000)" ></input>
  632. </div>
  633. </div>
  634. </div>
  635. </div>
  636. <div class="form-row">
  637. <div class="form-group col-md-2">
  638. <small id="m" class="form-text text-muted">Molybdenum</small>
  639. <div class="input-group input-group-sm mb-3">
  640. <input type="text" class="form-control form-control-sm" name="m" id="m" placeholder="M - Molybdenum"></input>
  641. <div class="input-group-append">
  642. <input class="btn btn-append" type="button" id="molybdenum" value="ppm" onClick="conversion(this, molybdenum, m, 10000)" ></input>
  643. </div>
  644. </div>
  645. </div>
  646. <div class="form-group col-md-2">
  647. <small id="co" class="form-text text-muted">Cobalt</small>
  648. <div class="input-group input-group-sm mb-3">
  649. <input type="text" class="form-control form-control-sm" name="co" id="co" placeholder="Co - Cobalt"></input>
  650. <div class="input-group-append">
  651. <input class="btn btn-append" type="button" id="cobalt" value="ppm" onClick="conversion(this, cobalt, co, 10000)" ></input>
  652. </div>
  653. </div>
  654. </div>
  655. <div class="form-group col-md-2">
  656. <small id="se" class="form-text text-muted">Selenium</small>
  657. <div class="input-group input-group-sm mb-3">
  658. <input type="text" class="form-control form-control-sm" name="se" id="se" placeholder="Se - Selenium"></input>
  659. <div class="input-group-append">
  660. <input class="btn btn-append" type="button" id="selenium" value="ppm" onClick="conversion(this, selenium, se, 10000)" ></input>
  661. </div>
  662. </div>
  663. </div>
  664. <div class="form-group col-md-2">
  665. <small id="ch" class="form-text text-muted">Chloride</small>
  666. <div class="input-group input-group-sm mb-3">
  667. <input type="text" class="form-control form-control-sm" name="ch" id="ch" placeholder="Ch - Chloride"></input>
  668. <div class="input-group-append">
  669. <input class="btn btn-append" type="button" id="chloride" value="ppm" onClick="conversion(this, chloride, cg, 10000)" ></input>
  670. </div>
  671. </div>
  672. </div>
  673. </div>
  674. <script type="text/javascript">
  675. function conversion(value, input, element, conversion) {
  676. var Nvalue = document.getElementById(element.id).value;
  677. var el = document.getElementById(input.id);
  678. if ( el.value === "%" ) {
  679. el.value = "ppm";
  680. document.getElementById(element.id).value = Nvalue*conversion;
  681. } else {
  682. el.value = "%";
  683. document.getElementById(element.id).value = Nvalue/conversion;
  684. }
  685. }
  686. </script>
  687. <button form="PlantcsvForm" type="submit" name="PlantcsvForm" class="btn btn-success">Submit</button>
  688. </form>
  689. </div>
  690. [[!plantformSubmit]]
  691. <script type="text/javascript">
  692. // JavaScript for disabling form submission if there are invalid fields
  693. (function() {
  694. \'use strict\';
  695. window.addEventListener(\'load\', function() {
  696. // Fetch all the forms we want to apply custom Bootstrap validation styles to
  697. var forms = document.getElementsByClassName(\'needs-validation\');
  698. // Loop over them and prevent submission
  699. var validation = Array.prototype.filter.call(forms, function(form) {
  700. form.addEventListener(\'submit\', function(event) {
  701. if (form.checkValidity() === false) {
  702. event.preventDefault();
  703. event.stopPropagation();
  704. }
  705. form.classList.add(\'was-validated\');
  706. }, false);
  707. });
  708. }, false);
  709. })();
  710. </script>
  711. </div>
  712. </div>
  713. </div>
  714. </div>
  715. <!-- Footer -->
  716. <footer class="bg-black small text-center text-white-50">
  717. <div class="container">
  718. <span>&copy; 2005-2019 by Crop Monitor</span>. All Rights Reserved<a href="/"></a>
  719. </div>
  720. </footer>
  721. <!-- jQuery first, then Popper.js, then Bootstrap JS -->
  722. <script type="text/javascript" src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js" integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU=" crossorigin="anonymous"></script>
  723. <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
  724. <script type="text/javascript" src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
  725. <script type="text/javascript">
  726. addEventListener("load", function() {
  727. setTimeout(hideURLbar, 0);
  728. }, false);
  729. function hideURLbar(){
  730. window.scrollTo(0,1);
  731. }
  732. </script>
  733. <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.bundle.min.js" integrity="sha384-xrRywqdh3PHs8keKZN+8zzc5TX0GRTLCcmivcbNJWm2rs5C8PRhcEn3czEjhAO9o" crossorigin="anonymous"></script>
  734. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.4.1/jquery.easing.js"></script>
  735. <script src="https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/jquery.magnific-popup.js"></script>
  736. <!-- Custom scripts for this template -->
  737. <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.4.1/jquery.easing.js"></script>
  738. <script type="text/javascript" src="client-assets/js/greyscale.js"></script>
  739. <script type="text/javascript" src="client-assets/js/creative.js"></script>
  740. </body>
  741. </html> ',
  742. '_isForward' => false,
  743. ),
  744. 'contentType' =>
  745. array (
  746. 'id' => 1,
  747. 'name' => 'HTML',
  748. 'description' => 'HTML content',
  749. 'mime_type' => 'text/html',
  750. 'file_extensions' => '.html',
  751. 'headers' => NULL,
  752. 'binary' => 0,
  753. ),
  754. 'policyCache' =>
  755. array (
  756. ),
  757. 'elementCache' =>
  758. array (
  759. '[[*longtitle]]' => 'Crop Management Platform',
  760. '[[*introtext]]' => 'crop management, irrigation alerts, weather reporting, moisture monitoring, realtime dashboard, agricultural monitoring.',
  761. '[[*description]]' => 'Designed to keep all your records in one place, interfacing irrigation systems, weather data, and real-time moisture monitoring, based in Australia on local conditions.',
  762. '[[$dash-header]]' => '<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
  763. <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
  764. <script type="text/javascript" src="https://use.fontawesome.com/1e2844bb90.js"></script>
  765. <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.1/css/all.css" integrity="sha384-gfdkjb5BdAXd+lj+gudLWI+BXq4IuLW5IT+brZEZsLFm++aCMlF1V92rMkPaX4PP" crossorigin="anonymous" />
  766. <link rel="stylesheet" type="text/css" href="/client-assets/weather-icons/css/weather-icons.min.css?version=1.16" />
  767. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/magnific-popup.css" />',
  768. '[[~4]]' => 'login/',
  769. '[[*id]]' => 1,
  770. '[[blogit.lexicon_load]]' => '',
  771. '[[~1]]' => '/',
  772. '[[$analysis_Clientdetails]]' => '<div class="form-row">
  773. <div class="form-group col-12 col-md-4 mb-1">
  774. <label for="client_name" class="p-0 mb-0 col-form-label-sm">Client Name<span class="error">*</span></label>
  775. <input type="text" class="form-control form-control-sm" name="name" id="name" placeholder="Client Name" required autocomplete="on">
  776. </div>
  777. <div class="form-group col-12 col-md-4 mb-1">
  778. <label for="email" class="p-0 mb-0 col-form-label-sm">Email address<span class="error">*</span></label>
  779. <input type="email" class="form-control form-control-sm" name="email" id="email" placeholder="Email address" required autocomplete="on">
  780. </div>
  781. <div class="form-group col-12 col-md-4 mb-1">
  782. <label for="company_name" class="p-0 mb-0 col-form-label-sm">Company Name</label>
  783. <input type="text" class="form-control form-control-sm" name="company" id="company" placeholder="Company Name" autocomplete="on">
  784. </div>
  785. </div>
  786. <div class="form-row">
  787. <div class="form-group col-12 col-md-6 mb-1">
  788. <label for="site_address" class="p-0 mb-0 col-form-label-sm">Site Address</label>
  789. <input type="text" class="form-control form-control-sm" name="site_address" id="site_address" placeholder="Site Address" autocomplete="on">
  790. </div>
  791. <div class="form-group col-12 col-md-6 mb-1">
  792. <label for="state_postcode" class="p-0 mb-0 col-form-label-sm">Postal Address</label>
  793. <input type="text" class="form-control form-control-sm" name="postal_address" id="postal_address" placeholder="Postal Address" autocomplete="on">
  794. </div>
  795. </div>',
  796. '[[$soilAnalysisTrialModal]]' => '<!-- Modal -->
  797. <div class="modal fade" id="soilAnalysisExample" tabindex="-1" role="dialog" aria-labelledby="soilAnalysisExample" aria-hidden="true">
  798. <div class="modal-dialog modal-xl modal-dialog-centered" role="document">
  799. <div class="modal-content">
  800. <div class="modal-header">
  801. <h5 class="modal-title" id="soilAnalysisExample">Try out our Soil Test Analysis Report</h5>
  802. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  803. <span aria-hidden="true">&times;</span>
  804. </button>
  805. </div>
  806. <div class="modal-body">
  807. <div class="grid-form1">
  808. <span class="error">* required fields.</span>
  809. <form method="post" action="#" id="csvForm" class="needs-validation" novalidate >
  810. <div class="form-row">
  811. <div class="form-group col-12 col-md-4 mb-1">
  812. <label for="client_name" class="p-0 mb-0 col-form-label-sm">Client Name<span class="error">*</span></label>
  813. <input type="text" class="form-control form-control-sm" name="name" id="name" placeholder="Client Name" required autocomplete="on">
  814. </div>
  815. <div class="form-group col-12 col-md-4 mb-1">
  816. <label for="email" class="p-0 mb-0 col-form-label-sm">Email address<span class="error">*</span></label>
  817. <input type="email" class="form-control form-control-sm" name="email" id="email" placeholder="Email address" required autocomplete="on">
  818. </div>
  819. <div class="form-group col-12 col-md-4 mb-1">
  820. <label for="company_name" class="p-0 mb-0 col-form-label-sm">Company Name</label>
  821. <input type="text" class="form-control form-control-sm" name="company" id="company" placeholder="Company Name" autocomplete="on">
  822. </div>
  823. </div>
  824. <div class="form-row">
  825. <div class="form-group col-12 col-md-6 mb-1">
  826. <label for="site_address" class="p-0 mb-0 col-form-label-sm">Site Address</label>
  827. <input type="text" class="form-control form-control-sm" name="site_address" id="site_address" placeholder="Site Address" autocomplete="on">
  828. </div>
  829. <div class="form-group col-12 col-md-6 mb-1">
  830. <label for="state_postcode" class="p-0 mb-0 col-form-label-sm">Postal Address</label>
  831. <input type="text" class="form-control form-control-sm" name="postal_address" id="postal_address" placeholder="Postal Address" autocomplete="on">
  832. </div>
  833. </div>
  834. <hr>
  835. [[$soilAnalysisForm_bootstrap]]
  836. <button form="csvForm" type="submit" name="csvForm" class="btn btn-success">Submit</button>
  837. </form>
  838. [[!soilformSubmit]]
  839. <script type="text/javascript">
  840. // JavaScript for disabling form submission if there are invalid fields
  841. (function() {
  842. \'use strict\';
  843. window.addEventListener(\'load\', function() {
  844. // Fetch all the forms we want to apply custom Bootstrap validation styles to
  845. var forms = document.getElementsByClassName(\'needs-validation\');
  846. // Loop over them and prevent submission
  847. var validation = Array.prototype.filter.call(forms, function(form) {
  848. form.addEventListener(\'submit\', function(event) {
  849. if (form.checkValidity() === false) {
  850. event.preventDefault();
  851. event.stopPropagation();
  852. }
  853. form.classList.add(\'was-validated\');
  854. }, false);
  855. });
  856. }, false);
  857. })();
  858. </script>
  859. </div>
  860. </div>
  861. </div>
  862. </div>
  863. </div>',
  864. '[[$plantAnalysisForm]]' => '<div class="form-row">
  865. <div class="col-md-3 form-group">
  866. <small id="analysis_type" class="form-text text-muted">Analysis Type<span class="error">*</span></small>
  867. <div><select name="analysis_type" id="analysis_type" class="form-control form-control-sm" required>
  868. <option>Select the type of Analysis...</option>
  869. <option id="ash">Dry Ash Test</option>
  870. <option id="sap">Sap Analysis</option>
  871. <option id="field">Field Test</option>
  872. </select></div>
  873. </div>
  874. <div class="col-md-3 form-group">
  875. <small id="lab_no" class="form-text text-muted">Lab No</small>
  876. <div class="input-group input-group-sm mb-3">
  877. <input type="text" class="form-control form-control-sm" name="lab_no" id="lab_no" placeholder="Lab No"></input>
  878. </div>
  879. </div>
  880. <div class="col-md-3 form-group">
  881. <small id="batch_no" class="form-text text-muted">Batch No</small>
  882. <div class="input-group input-group-sm mb-3">
  883. <input type="text" class="form-control form-control-sm" name="batch_no" id="batch_no" placeholder="Batch No"></input>
  884. </div>
  885. </div>
  886. <div class="col-md-3 form-group">
  887. <small id="date_sampled" class="form-text text-muted">Date Sampled</small>
  888. <input data-provide="datepicker" class="form-control form-control-sm" name="date_sampled" id="datepicker" placeholder="Date Sampled" data-date-format="dd/mm/yyyy" data-date-end-date="0d" ></input>
  889. <script>
  890. $(\'#datepicker\').datepicker({
  891. uiLibrary: \'bootstrap4\',
  892. calendarWeeks: \'true\',
  893. todayHighlight: \'true\'
  894. });
  895. </script>
  896. </div>
  897. <!-- Hidden Fields for Database -->
  898. <input type="hidden" class="form-control form-control-sm" name="m_user" id="m_user" placeholder="0" required>
  899. <input type="hidden" class="form-control form-control-sm" name="client_id" id="client_id" placeholder="(anonymous)" required>
  900. </div>
  901. <div class="form-row">
  902. <div class="col-md-4 form-group">
  903. <small id="lab_no" class="form-text text-muted">Sample ID<span class="error">*</span></small>
  904. <input type="text" class="form-control form-control-sm" name="sample_id" id="sample_id" placeholder="Sample Id" required></input>
  905. </div>
  906. <div class="col-md-4 form-group">
  907. <small id="lab_no" class="form-text text-muted">Site ID</small>
  908. <input type="text" class="form-control form-control-sm" name="site_id" id="site_id" placeholder="Paddock Id"></input>
  909. </div>
  910. [[!croptypeFORM]]
  911. </div>
  912. <hr>
  913. <label class="col"><b>Analysis Inputs</b></label>
  914. <div class="form-row">
  915. <div class="form-group col-md-2">
  916. <small id="nSmall" class="form-text text-muted">Nitrogen</small>
  917. <div class="input-group input-group-sm mb-3">
  918. <input type="text" class="form-control form-control-sm" name="n" id="n" placeholder="N - Nitrogen"></input>
  919. <div class="input-group-append">
  920. <input class="btn btn-append" type="button" id="nitrogen" value="ppm" onClick="conversion(this, nitrogen, n, 10000)" ></input>
  921. </div>
  922. </div>
  923. </div>
  924. <div class="form-group col-md-2">
  925. <small id="p" class="form-text text-muted">Phosphorus</small>
  926. <div class="input-group input-group-sm mb-3">
  927. <input type="text" class="form-control form-control-sm" name="p" id="p" placeholder="P - Phosphorus"></input>
  928. <div class="input-group-append">
  929. <input class="btn btn-append" type="button" id="phosphorus" value="ppm" onClick="conversion(this, phosphorus, p, 10000)" ></input>
  930. </div>
  931. </div>
  932. </div>
  933. <div class="form-group col-md-2">
  934. <small id="k" class="form-text text-muted">Postassium</small>
  935. <div class="input-group input-group-sm mb-3">
  936. <input type="text" class="form-control form-control-sm" name="k" id="k" placeholder="K - Postassium"></input>
  937. <div class="input-group-append">
  938. <input class="btn btn-append" type="button" id="postassium" value="ppm" onClick="conversion(this, postassium, k, 10000)" ></input>
  939. </div>
  940. </div>
  941. </div>
  942. <div class="form-group col-md-2">
  943. <small id="s" class="form-text text-muted">Sulphur</small>
  944. <div class="input-group input-group-sm mb-3">
  945. <input type="text" class="form-control form-control-sm" name="s" id="s" placeholder="S - Sulphur"></input>
  946. <div class="input-group-append">
  947. <input class="btn btn-append" type="button" id="sulphur" value="ppm" onClick="conversion(this, sulphur, s, 10000)" ></input>
  948. </div>
  949. </div>
  950. </div>
  951. <div class="form-group col-md-2">
  952. <small id="mg" class="form-text text-muted">Magnesium</small>
  953. <div class="input-group input-group-sm mb-3">
  954. <input type="text" class="form-control form-control-sm" name="mg" id="mg" placeholder="Mg - Magnesium"></input>
  955. <div class="input-group-append">
  956. <input class="btn btn-append" type="button" id="magnesium" value="ppm" onClick="conversion(this, magnesium, mg, 10000)" ></input>
  957. </div>
  958. </div>
  959. </div>
  960. <div class="form-group col-md-2">
  961. <small id="ca" class="form-text text-muted">Calcium</small>
  962. <div class="input-group input-group-sm mb-3">
  963. <input type="text" class="form-control form-control-sm" name="ca" id="ca" placeholder="Ca - Calcium"></input>
  964. <div class="input-group-append">
  965. <input class="btn btn-append" type="button" id="calcium" value="ppm" onClick="conversion(this, calcium, ca, 10000)" ></input>
  966. </div>
  967. </div>
  968. </div>
  969. </div>
  970. <div class="form-row">
  971. <div class="form-group col-md-2">
  972. <small id="na" class="form-text text-muted">Soduim</small>
  973. <div class="input-group input-group-sm mb-3">
  974. <input type="text" class="form-control form-control-sm" name="na" id="na" placeholder="Na - Soduim"></input>
  975. <div class="input-group-append">
  976. <input class="btn btn-append" type="button" id="soduim" value="ppm" onClick="conversion(this, soduim, na, 10000)" ></input>
  977. </div>
  978. </div>
  979. </div>
  980. <div class="form-group col-md-2">
  981. <small id="fe" class="form-text text-muted">Iron</small>
  982. <div class="input-group input-group-sm mb-3">
  983. <input type="text" class="form-control form-control-sm" name="fe" id="fe" placeholder="Fe - Iron"></input>
  984. <div class="input-group-append">
  985. <input class="btn btn-append" type="button" id="iron" value="ppm" onClick="conversion(this, iron, fe, 10000)" ></input>
  986. </div>
  987. </div>
  988. </div>
  989. <div class="form-group col-md-2">
  990. <small id="mn" class="form-text text-muted">Manganese</small>
  991. <div class="input-group input-group-sm mb-3">
  992. <input type="text" class="form-control form-control-sm" name="mn" id="mn" placeholder="Mn - Manganese"></input>
  993. <div class="input-group-append">
  994. <input class="btn btn-append" type="button" id="manganese" value="ppm" onClick="conversion(this, manganese, mn, 10000)" ></input>
  995. </div>
  996. </div>
  997. </div>
  998. <div class="form-group col-md-2">
  999. <small id="zn" class="form-text text-muted">Zinc</small>
  1000. <div class="input-group input-group-sm mb-3">
  1001. <input type="text" class="form-control form-control-sm" name="zn" id="zn" placeholder="Zn - Zinc"></input>
  1002. <div class="input-group-append">
  1003. <input class="btn btn-append" type="button" id="zinc" value="ppm" onClick="conversion(this, zinc, zn, 10000)" ></input>
  1004. </div>
  1005. </div>
  1006. </div>
  1007. <div class="form-group col-md-2">
  1008. <small id="cu" class="form-text text-muted">Copper</small>
  1009. <div class="input-group input-group-sm mb-3">
  1010. <input type="text" class="form-control form-control-sm" name="cu" id="cu" placeholder="Cu - Copper"></input>
  1011. <div class="input-group-append">
  1012. <input class="btn btn-append" type="button" id="copper" value="ppm" onClick="conversion(this, copper, cu, 10000)" ></input>
  1013. </div>
  1014. </div>
  1015. </div>
  1016. <div class="form-group col-md-2">
  1017. <small id="b" class="form-text text-muted">Boron</small>
  1018. <div class="input-group input-group-sm mb-3">
  1019. <input type="text" class="form-control form-control-sm" name="b" id="b" placeholder="B - Boron"></input>
  1020. <div class="input-group-append">
  1021. <input class="btn btn-append" type="button" id="boron" value="ppm" onClick="conversion(this, boron, b, 10000)" ></input>
  1022. </div>
  1023. </div>
  1024. </div>
  1025. </div>
  1026. <div class="form-row">
  1027. <div class="form-group col-md-2">
  1028. <small id="m" class="form-text text-muted">Molybdenum</small>
  1029. <div class="input-group input-group-sm mb-3">
  1030. <input type="text" class="form-control form-control-sm" name="m" id="m" placeholder="M - Molybdenum"></input>
  1031. <div class="input-group-append">
  1032. <input class="btn btn-append" type="button" id="molybdenum" value="ppm" onClick="conversion(this, molybdenum, m, 10000)" ></input>
  1033. </div>
  1034. </div>
  1035. </div>
  1036. <div class="form-group col-md-2">
  1037. <small id="co" class="form-text text-muted">Cobalt</small>
  1038. <div class="input-group input-group-sm mb-3">
  1039. <input type="text" class="form-control form-control-sm" name="co" id="co" placeholder="Co - Cobalt"></input>
  1040. <div class="input-group-append">
  1041. <input class="btn btn-append" type="button" id="cobalt" value="ppm" onClick="conversion(this, cobalt, co, 10000)" ></input>
  1042. </div>
  1043. </div>
  1044. </div>
  1045. <div class="form-group col-md-2">
  1046. <small id="se" class="form-text text-muted">Selenium</small>
  1047. <div class="input-group input-group-sm mb-3">
  1048. <input type="text" class="form-control form-control-sm" name="se" id="se" placeholder="Se - Selenium"></input>
  1049. <div class="input-group-append">
  1050. <input class="btn btn-append" type="button" id="selenium" value="ppm" onClick="conversion(this, selenium, se, 10000)" ></input>
  1051. </div>
  1052. </div>
  1053. </div>
  1054. <div class="form-group col-md-2">
  1055. <small id="ch" class="form-text text-muted">Chloride</small>
  1056. <div class="input-group input-group-sm mb-3">
  1057. <input type="text" class="form-control form-control-sm" name="ch" id="ch" placeholder="Ch - Chloride"></input>
  1058. <div class="input-group-append">
  1059. <input class="btn btn-append" type="button" id="chloride" value="ppm" onClick="conversion(this, chloride, cg, 10000)" ></input>
  1060. </div>
  1061. </div>
  1062. </div>
  1063. </div>
  1064. <script type="text/javascript">
  1065. function conversion(value, input, element, conversion) {
  1066. var Nvalue = document.getElementById(element.id).value;
  1067. var el = document.getElementById(input.id);
  1068. if ( el.value === "%" ) {
  1069. el.value = "ppm";
  1070. document.getElementById(element.id).value = Nvalue*conversion;
  1071. } else {
  1072. el.value = "%";
  1073. document.getElementById(element.id).value = Nvalue/conversion;
  1074. }
  1075. }
  1076. </script>',
  1077. '[[$plantAnalysisTrialModal]]' => '<!-- Modal -->
  1078. <div class="modal fade" id="plantAnalysisExample" tabindex="-1" role="dialog" aria-labelledby="plantAnalysisExample" aria-hidden="true">
  1079. <div class="modal-dialog modal-xl modal-dialog-centered" role="document">
  1080. <div class="modal-content">
  1081. <div class="modal-header">
  1082. <h5 class="modal-title" id="plantAnalysisExample">Try out our Plant Analysis Report</h5>
  1083. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  1084. <span aria-hidden="true">&times;</span>
  1085. </button>
  1086. </div>
  1087. <div class="modal-body">
  1088. <div class="grid-form1">
  1089. <span class="error">* required fields.</span>
  1090. <form method="post" action="#" id="PlantcsvForm" class="needs-validation" novalidate >
  1091. <div class="form-row">
  1092. <div class="form-group col-12 col-md-4 mb-1">
  1093. <label for="client_name" class="p-0 mb-0 col-form-label-sm">Client Name<span class="error">*</span></label>
  1094. <input type="text" class="form-control form-control-sm" name="name" id="name" placeholder="Client Name" required autocomplete="on">
  1095. </div>
  1096. <div class="form-group col-12 col-md-4 mb-1">
  1097. <label for="email" class="p-0 mb-0 col-form-label-sm">Email address<span class="error">*</span></label>
  1098. <input type="email" class="form-control form-control-sm" name="email" id="email" placeholder="Email address" required autocomplete="on">
  1099. </div>
  1100. <div class="form-group col-12 col-md-4 mb-1">
  1101. <label for="company_name" class="p-0 mb-0 col-form-label-sm">Company Name</label>
  1102. <input type="text" class="form-control form-control-sm" name="company" id="company" placeholder="Company Name" autocomplete="on">
  1103. </div>
  1104. </div>
  1105. <div class="form-row">
  1106. <div class="form-group col-12 col-md-6 mb-1">
  1107. <label for="site_address" class="p-0 mb-0 col-form-label-sm">Site Address</label>
  1108. <input type="text" class="form-control form-control-sm" name="site_address" id="site_address" placeholder="Site Address" autocomplete="on">
  1109. </div>
  1110. <div class="form-group col-12 col-md-6 mb-1">
  1111. <label for="state_postcode" class="p-0 mb-0 col-form-label-sm">Postal Address</label>
  1112. <input type="text" class="form-control form-control-sm" name="postal_address" id="postal_address" placeholder="Postal Address" autocomplete="on">
  1113. </div>
  1114. </div>
  1115. <hr>
  1116. <div class="form-row">
  1117. <div class="col-md-3 form-group">
  1118. <small id="analysis_type" class="form-text text-muted">Analysis Type<span class="error">*</span></small>
  1119. <div><select name="analysis_type" id="analysis_type" class="form-control form-control-sm" required>
  1120. <option>Select the type of Analysis...</option>
  1121. <option id="ash">Dry Ash Test</option>
  1122. <option id="sap">Sap Analysis</option>
  1123. <option id="field">Field Test</option>
  1124. </select></div>
  1125. </div>
  1126. <div class="col-md-3 form-group">
  1127. <small id="lab_no" class="form-text text-muted">Lab No</small>
  1128. <div class="input-group input-group-sm mb-3">
  1129. <input type="text" class="form-control form-control-sm" name="lab_no" id="lab_no" placeholder="Lab No"></input>
  1130. </div>
  1131. </div>
  1132. <div class="col-md-3 form-group">
  1133. <small id="batch_no" class="form-text text-muted">Batch No</small>
  1134. <div class="input-group input-group-sm mb-3">
  1135. <input type="text" class="form-control form-control-sm" name="batch_no" id="batch_no" placeholder="Batch No"></input>
  1136. </div>
  1137. </div>
  1138. <div class="col-md-3 form-group">
  1139. <small id="date_sampled" class="form-text text-muted">Date Sampled</small>
  1140. <input data-provide="datepicker" class="form-control form-control-sm" name="date_sampled" id="datepicker" placeholder="Date Sampled" data-date-format="dd/mm/yyyy" data-date-end-date="0d" ></input>
  1141. <script>
  1142. $(\'#datepicker\').datepicker({
  1143. uiLibrary: \'bootstrap4\',
  1144. calendarWeeks: \'true\',
  1145. todayHighlight: \'true\'
  1146. });
  1147. </script>
  1148. </div>
  1149. <!-- Hidden Fields for Database -->
  1150. <input type="hidden" class="form-control form-control-sm" name="m_user" id="m_user" placeholder="0" required>
  1151. <input type="hidden" class="form-control form-control-sm" name="client_id" id="client_id" placeholder="(anonymous)" required>
  1152. </div>
  1153. <div class="form-row">
  1154. <div class="col-md-4 form-group">
  1155. <small id="lab_no" class="form-text text-muted">Sample ID<span class="error">*</span></small>
  1156. <input type="text" class="form-control form-control-sm" name="sample_id" id="sample_id" placeholder="Sample Id" required></input>
  1157. </div>
  1158. <div class="col-md-4 form-group">
  1159. <small id="lab_no" class="form-text text-muted">Site ID</small>
  1160. <input type="text" class="form-control form-control-sm" name="site_id" id="site_id" placeholder="Paddock Id"></input>
  1161. </div>
  1162. [[!croptypeFORM]]
  1163. </div>
  1164. <hr>
  1165. <label class="col"><b>Analysis Inputs</b></label>
  1166. <div class="form-row">
  1167. <div class="form-group col-md-2">
  1168. <small id="nSmall" class="form-text text-muted">Nitrogen</small>
  1169. <div class="input-group input-group-sm mb-3">
  1170. <input type="text" class="form-control form-control-sm" name="n" id="n" placeholder="N - Nitrogen"></input>
  1171. <div class="input-group-append">
  1172. <input class="btn btn-append" type="button" id="nitrogen" value="ppm" onClick="conversion(this, nitrogen, n, 10000)" ></input>
  1173. </div>
  1174. </div>
  1175. </div>
  1176. <div class="form-group col-md-2">
  1177. <small id="p" class="form-text text-muted">Phosphorus</small>
  1178. <div class="input-group input-group-sm mb-3">
  1179. <input type="text" class="form-control form-control-sm" name="p" id="p" placeholder="P - Phosphorus"></input>
  1180. <div class="input-group-append">
  1181. <input class="btn btn-append" type="button" id="phosphorus" value="ppm" onClick="conversion(this, phosphorus, p, 10000)" ></input>
  1182. </div>
  1183. </div>
  1184. </div>
  1185. <div class="form-group col-md-2">
  1186. <small id="k" class="form-text text-muted">Postassium</small>
  1187. <div class="input-group input-group-sm mb-3">
  1188. <input type="text" class="form-control form-control-sm" name="k" id="k" placeholder="K - Postassium"></input>
  1189. <div class="input-group-append">
  1190. <input class="btn btn-append" type="button" id="postassium" value="ppm" onClick="conversion(this, postassium, k, 10000)" ></input>
  1191. </div>
  1192. </div>
  1193. </div>
  1194. <div class="form-group col-md-2">
  1195. <small id="s" class="form-text text-muted">Sulphur</small>
  1196. <div class="input-group input-group-sm mb-3">
  1197. <input type="text" class="form-control form-control-sm" name="s" id="s" placeholder="S - Sulphur"></input>
  1198. <div class="input-group-append">
  1199. <input class="btn btn-append" type="button" id="sulphur" value="ppm" onClick="conversion(this, sulphur, s, 10000)" ></input>
  1200. </div>
  1201. </div>
  1202. </div>
  1203. <div class="form-group col-md-2">
  1204. <small id="mg" class="form-text text-muted">Magnesium</small>
  1205. <div class="input-group input-group-sm mb-3">
  1206. <input type="text" class="form-control form-control-sm" name="mg" id="mg" placeholder="Mg - Magnesium"></input>
  1207. <div class="input-group-append">
  1208. <input class="btn btn-append" type="button" id="magnesium" value="ppm" onClick="conversion(this, magnesium, mg, 10000)" ></input>
  1209. </div>
  1210. </div>
  1211. </div>
  1212. <div class="form-group col-md-2">
  1213. <small id="ca" class="form-text text-muted">Calcium</small>
  1214. <div class="input-group input-group-sm mb-3">
  1215. <input type="text" class="form-control form-control-sm" name="ca" id="ca" placeholder="Ca - Calcium"></input>
  1216. <div class="input-group-append">
  1217. <input class="btn btn-append" type="button" id="calcium" value="ppm" onClick="conversion(this, calcium, ca, 10000)" ></input>
  1218. </div>
  1219. </div>
  1220. </div>
  1221. </div>
  1222. <div class="form-row">
  1223. <div class="form-group col-md-2">
  1224. <small id="na" class="form-text text-muted">Soduim</small>
  1225. <div class="input-group input-group-sm mb-3">
  1226. <input type="text" class="form-control form-control-sm" name="na" id="na" placeholder="Na - Soduim"></input>
  1227. <div class="input-group-append">
  1228. <input class="btn btn-append" type="button" id="soduim" value="ppm" onClick="conversion(this, soduim, na, 10000)" ></input>
  1229. </div>
  1230. </div>
  1231. </div>
  1232. <div class="form-group col-md-2">
  1233. <small id="fe" class="form-text text-muted">Iron</small>
  1234. <div class="input-group input-group-sm mb-3">
  1235. <input type="text" class="form-control form-control-sm" name="fe" id="fe" placeholder="Fe - Iron"></input>
  1236. <div class="input-group-append">
  1237. <input class="btn btn-append" type="button" id="iron" value="ppm" onClick="conversion(this, iron, fe, 10000)" ></input>
  1238. </div>
  1239. </div>
  1240. </div>
  1241. <div class="form-group col-md-2">
  1242. <small id="mn" class="form-text text-muted">Manganese</small>
  1243. <div class="input-group input-group-sm mb-3">
  1244. <input type="text" class="form-control form-control-sm" name="mn" id="mn" placeholder="Mn - Manganese"></input>
  1245. <div class="input-group-append">
  1246. <input class="btn btn-append" type="button" id="manganese" value="ppm" onClick="conversion(this, manganese, mn, 10000)" ></input>
  1247. </div>
  1248. </div>
  1249. </div>
  1250. <div class="form-group col-md-2">
  1251. <small id="zn" class="form-text text-muted">Zinc</small>
  1252. <div class="input-group input-group-sm mb-3">
  1253. <input type="text" class="form-control form-control-sm" name="zn" id="zn" placeholder="Zn - Zinc"></input>
  1254. <div class="input-group-append">
  1255. <input class="btn btn-append" type="button" id="zinc" value="ppm" onClick="conversion(this, zinc, zn, 10000)" ></input>
  1256. </div>
  1257. </div>
  1258. </div>
  1259. <div class="form-group col-md-2">
  1260. <small id="cu" class="form-text text-muted">Copper</small>
  1261. <div class="input-group input-group-sm mb-3">
  1262. <input type="text" class="form-control form-control-sm" name="cu" id="cu" placeholder="Cu - Copper"></input>
  1263. <div class="input-group-append">
  1264. <input class="btn btn-append" type="button" id="copper" value="ppm" onClick="conversion(this, copper, cu, 10000)" ></input>
  1265. </div>
  1266. </div>
  1267. </div>
  1268. <div class="form-group col-md-2">
  1269. <small id="b" class="form-text text-muted">Boron</small>
  1270. <div class="input-group input-group-sm mb-3">
  1271. <input type="text" class="form-control form-control-sm" name="b" id="b" placeholder="B - Boron"></input>
  1272. <div class="input-group-append">
  1273. <input class="btn btn-append" type="button" id="boron" value="ppm" onClick="conversion(this, boron, b, 10000)" ></input>
  1274. </div>
  1275. </div>
  1276. </div>
  1277. </div>
  1278. <div class="form-row">
  1279. <div class="form-group col-md-2">
  1280. <small id="m" class="form-text text-muted">Molybdenum</small>
  1281. <div class="input-group input-group-sm mb-3">
  1282. <input type="text" class="form-control form-control-sm" name="m" id="m" placeholder="M - Molybdenum"></input>
  1283. <div class="input-group-append">
  1284. <input class="btn btn-append" type="button" id="molybdenum" value="ppm" onClick="conversion(this, molybdenum, m, 10000)" ></input>
  1285. </div>
  1286. </div>
  1287. </div>
  1288. <div class="form-group col-md-2">
  1289. <small id="co" class="form-text text-muted">Cobalt</small>
  1290. <div class="input-group input-group-sm mb-3">
  1291. <input type="text" class="form-control form-control-sm" name="co" id="co" placeholder="Co - Cobalt"></input>
  1292. <div class="input-group-append">
  1293. <input class="btn btn-append" type="button" id="cobalt" value="ppm" onClick="conversion(this, cobalt, co, 10000)" ></input>
  1294. </div>
  1295. </div>
  1296. </div>
  1297. <div class="form-group col-md-2">
  1298. <small id="se" class="form-text text-muted">Selenium</small>
  1299. <div class="input-group input-group-sm mb-3">
  1300. <input type="text" class="form-control form-control-sm" name="se" id="se" placeholder="Se - Selenium"></input>
  1301. <div class="input-group-append">
  1302. <input class="btn btn-append" type="button" id="selenium" value="ppm" onClick="conversion(this, selenium, se, 10000)" ></input>
  1303. </div>
  1304. </div>
  1305. </div>
  1306. <div class="form-group col-md-2">
  1307. <small id="ch" class="form-text text-muted">Chloride</small>
  1308. <div class="input-group input-group-sm mb-3">
  1309. <input type="text" class="form-control form-control-sm" name="ch" id="ch" placeholder="Ch - Chloride"></input>
  1310. <div class="input-group-append">
  1311. <input class="btn btn-append" type="button" id="chloride" value="ppm" onClick="conversion(this, chloride, cg, 10000)" ></input>
  1312. </div>
  1313. </div>
  1314. </div>
  1315. </div>
  1316. <script type="text/javascript">
  1317. function conversion(value, input, element, conversion) {
  1318. var Nvalue = document.getElementById(element.id).value;
  1319. var el = document.getElementById(input.id);
  1320. if ( el.value === "%" ) {
  1321. el.value = "ppm";
  1322. document.getElementById(element.id).value = Nvalue*conversion;
  1323. } else {
  1324. el.value = "%";
  1325. document.getElementById(element.id).value = Nvalue/conversion;
  1326. }
  1327. }
  1328. </script>
  1329. <button form="PlantcsvForm" type="submit" name="PlantcsvForm" class="btn btn-success">Submit</button>
  1330. </form>
  1331. </div>
  1332. [[!plantformSubmit]]
  1333. <script type="text/javascript">
  1334. // JavaScript for disabling form submission if there are invalid fields
  1335. (function() {
  1336. \'use strict\';
  1337. window.addEventListener(\'load\', function() {
  1338. // Fetch all the forms we want to apply custom Bootstrap validation styles to
  1339. var forms = document.getElementsByClassName(\'needs-validation\');
  1340. // Loop over them and prevent submission
  1341. var validation = Array.prototype.filter.call(forms, function(form) {
  1342. form.addEventListener(\'submit\', function(event) {
  1343. if (form.checkValidity() === false) {
  1344. event.preventDefault();
  1345. event.stopPropagation();
  1346. }
  1347. form.classList.add(\'was-validated\');
  1348. }, false);
  1349. });
  1350. }, false);
  1351. })();
  1352. </script>
  1353. </div>
  1354. </div>
  1355. </div>
  1356. </div>',
  1357. '[[SimpleCopyright? &startYear=`2005`]]' => '<span>&copy; 2005-2019 by Crop Monitor</span>',
  1358. '[[$dash-footer]]' => '<!-- jQuery first, then Popper.js, then Bootstrap JS -->
  1359. <script type="text/javascript" src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js" integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU=" crossorigin="anonymous"></script>
  1360. <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
  1361. <script type="text/javascript" src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
  1362. <script type="text/javascript">
  1363. addEventListener("load", function() {
  1364. setTimeout(hideURLbar, 0);
  1365. }, false);
  1366. function hideURLbar(){
  1367. window.scrollTo(0,1);
  1368. }
  1369. </script>
  1370. <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.bundle.min.js" integrity="sha384-xrRywqdh3PHs8keKZN+8zzc5TX0GRTLCcmivcbNJWm2rs5C8PRhcEn3czEjhAO9o" crossorigin="anonymous"></script>
  1371. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.4.1/jquery.easing.js"></script>
  1372. <script src="https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/jquery.magnific-popup.js"></script>',
  1373. '[[*blogit.post_main_image:isnot=``:then=`<img class="card-img-top" src="" alt="[[+blogit.post_main_image_alt]]">`]]' => '',
  1374. '[[~70]]' => 'admb.html',
  1375. '[[%blogit.readmore]]' => 'Read more',
  1376. '[[%blogit.published_on]]' => 'Published on',
  1377. '[[~19]]' => 'home-plant-analysis.html',
  1378. '[[~69]]' => 'moisture-monitoring.html',
  1379. '[[$?cache=``&cache_expires=`0`&cache_handler=`xPDOFileCache`&cache_key=`resource`&elementClass=`modSnippet`&limit=`3`&namespace=``&offset=`0`&page=`1`&pageActiveTpl=`<li[[+activeClasses]]><a[[+activeClasses:default=` class="active"`]][[+title]] href="[[+href]]">[[+pageNo]]</a></li>`&pageFirstTpl=`<li class="control"><a[[+classes]][[+title]] href="[[+href]]">First</a></li>`&pageLastTpl=`<li class="control"><a[[+classes]][[+title]] href="[[+href]]">Last</a></li>`&pageLimit=`5`&pageNavOuterTpl=`[[+prev]][[+next]]`&pageNavScheme=``&pageNavTpl=`<li[[+classes]]><a[[+classes]][[+title]] href="[[+href]]">[[+pageNo]]</a></li>`&pageNavVar=`page.nav`&pageNextTpl=`<li class="page-item"><a class="page-link" [[+title]] href="[[+href]]">Newer</a></li>`&pagePrevTpl=`<li class="page-item"><a class="page-link" [[+title]] href="[[+href]]">Older</a></li>`&pageVarKey=`page`&totalVar=`total`&element=`getResources`&parents=`1`&tpl=`Home_blogit.blog_row_tpl`&includeTVs=`1`&processTVs=`1`&tvPrefix=``&where=`[]`&sortby=`RAND()`&total=`8`&pageOneLimit=`3`&actualLimit=`3`&toPlaceholder=``&qs=`ca2455807660326d4a471096588438b9`&pageCount=`3`&href=`/`&pageNo=`1`]]' => '<li[[+activeClasses]]><a class="active"[[+title]] href="/">1</a></li>',
  1380. '[[$?cache=``&cache_expires=`0`&cache_handler=`xPDOFileCache`&cache_key=`resource`&elementClass=`modSnippet`&limit=`3`&namespace=``&offset=`0`&page=`1`&pageActiveTpl=`<li[[+activeClasses]]><a[[+activeClasses:default=` class="active"`]][[+title]] href="[[+href]]">[[+pageNo]]</a></li>`&pageFirstTpl=`<li class="control"><a[[+classes]][[+title]] href="[[+href]]">First</a></li>`&pageLastTpl=`<li class="control"><a[[+classes]][[+title]] href="[[+href]]">Last</a></li>`&pageLimit=`5`&pageNavOuterTpl=`[[+prev]][[+next]]`&pageNavScheme=``&pageNavTpl=`<li[[+classes]]><a[[+classes]][[+title]] href="[[+href]]">[[+pageNo]]</a></li>`&pageNavVar=`page.nav`&pageNextTpl=`<li class="page-item"><a class="page-link" [[+title]] href="[[+href]]">Newer</a></li>`&pagePrevTpl=`<li class="page-item"><a class="page-link" [[+title]] href="[[+href]]">Older</a></li>`&pageVarKey=`page`&totalVar=`total`&element=`getResources`&parents=`1`&tpl=`Home_blogit.blog_row_tpl`&includeTVs=`1`&processTVs=`1`&tvPrefix=``&where=`[]`&sortby=`RAND()`&total=`8`&pageOneLimit=`3`&actualLimit=`3`&toPlaceholder=``&qs=`72dee6c760d2ea65a7eec67c219e4547`&pageCount=`3`&href=`/?page=2`&pageNo=`2`]]' => '<li[[+classes]]><a[[+classes]][[+title]] href="/?page=2">2</a></li>',
  1381. '[[$?cache=``&cache_expires=`0`&cache_handler=`xPDOFileCache`&cache_key=`resource`&elementClass=`modSnippet`&limit=`3`&namespace=``&offset=`0`&page=`1`&pageActiveTpl=`<li[[+activeClasses]]><a[[+activeClasses:default=` class="active"`]][[+title]] href="[[+href]]">[[+pageNo]]</a></li>`&pageFirstTpl=`<li class="control"><a[[+classes]][[+title]] href="[[+href]]">First</a></li>`&pageLastTpl=`<li class="control"><a[[+classes]][[+title]] href="[[+href]]">Last</a></li>`&pageLimit=`5`&pageNavOuterTpl=`[[+prev]][[+next]]`&pageNavScheme=``&pageNavTpl=`<li[[+classes]]><a[[+classes]][[+title]] href="[[+href]]">[[+pageNo]]</a></li>`&pageNavVar=`page.nav`&pageNextTpl=`<li class="page-item"><a class="page-link" [[+title]] href="[[+href]]">Newer</a></li>`&pagePrevTpl=`<li class="page-item"><a class="page-link" [[+title]] href="[[+href]]">Older</a></li>`&pageVarKey=`page`&totalVar=`total`&element=`getResources`&parents=`1`&tpl=`Home_blogit.blog_row_tpl`&includeTVs=`1`&processTVs=`1`&tvPrefix=``&where=`[]`&sortby=`RAND()`&total=`8`&pageOneLimit=`3`&actualLimit=`3`&toPlaceholder=``&qs=`9d2c8a84b5a005c1a0b8df3ecdd72b7c`&pageCount=`3`&href=`/?page=3`&pageNo=`3`]]' => '<li[[+classes]]><a[[+classes]][[+title]] href="/?page=3">3</a></li>',
  1382. '[[$?cache=``&cache_expires=`0`&cache_handler=`xPDOFileCache`&cache_key=`resource`&elementClass=`modSnippet`&limit=`3`&namespace=``&offset=`0`&page=`1`&pageActiveTpl=`<li[[+activeClasses]]><a[[+activeClasses:default=` class="active"`]][[+title]] href="[[+href]]">[[+pageNo]]</a></li>`&pageFirstTpl=`<li class="control"><a[[+classes]][[+title]] href="[[+href]]">First</a></li>`&pageLastTpl=`<li class="control"><a[[+classes]][[+title]] href="[[+href]]">Last</a></li>`&pageLimit=`5`&pageNavOuterTpl=`[[+prev]][[+next]]`&pageNavScheme=``&pageNavTpl=`<li[[+classes]]><a[[+classes]][[+title]] href="[[+href]]">[[+pageNo]]</a></li>`&pageNavVar=`page.nav`&pageNextTpl=`<li class="page-item"><a class="page-link" [[+title]] href="[[+href]]">Newer</a></li>`&pagePrevTpl=`<li class="page-item"><a class="page-link" [[+title]] href="[[+href]]">Older</a></li>`&pageVarKey=`page`&totalVar=`total`&element=`getResources`&parents=`1`&tpl=`Home_blogit.blog_row_tpl`&includeTVs=`1`&processTVs=`1`&tvPrefix=``&where=`[]`&sortby=`RAND()`&total=`8`&pageOneLimit=`3`&actualLimit=`3`&toPlaceholder=``&qs=`c9b1d0eeb1082344a6a631e7b5e227ef`&pageCount=`3`&href=`/?page=2`&pageNo=`2`]]' => '<li class="page-item"><a class="page-link" [[+title]] href="/?page=2">Newer</a></li>',
  1383. '[[$?cache=``&cache_expires=`0`&cache_handler=`xPDOFileCache`&cache_key=`resource`&elementClass=`modSnippet`&limit=`3`&namespace=``&offset=`0`&page=`1`&pageActiveTpl=`<li[[+activeClasses]]><a[[+activeClasses:default=` class="active"`]][[+title]] href="[[+href]]">[[+pageNo]]</a></li>`&pageFirstTpl=`<li class="control"><a[[+classes]][[+title]] href="[[+href]]">First</a></li>`&pageLastTpl=`<li class="control"><a[[+classes]][[+title]] href="[[+href]]">Last</a></li>`&pageLimit=`5`&pageNavOuterTpl=`[[+prev]][[+next]]`&pageNavScheme=``&pageNavTpl=`<li[[+classes]]><a[[+classes]][[+title]] href="[[+href]]">[[+pageNo]]</a></li>`&pageNavVar=`page.nav`&pageNextTpl=`<li class="page-item"><a class="page-link" [[+title]] href="[[+href]]">Newer</a></li>`&pagePrevTpl=`<li class="page-item"><a class="page-link" [[+title]] href="[[+href]]">Older</a></li>`&pageVarKey=`page`&totalVar=`total`&element=`getResources`&parents=`1`&tpl=`Home_blogit.blog_row_tpl`&includeTVs=`1`&processTVs=`1`&tvPrefix=``&where=`[]`&sortby=`RAND()`&total=`8`&pageOneLimit=`3`&actualLimit=`3`&toPlaceholder=``&qs=`622bb44ee27e6a89357809d83adc490e`&pageCount=`3`&href=`/?page=3`&pageNo=`3`]]' => '<li class="control"><a[[+classes]][[+title]] href="/?page=3">Last</a></li>',
  1384. '[[$?cache=``&cache_expires=`0`&cache_handler=`xPDOFileCache`&cache_key=`resource`&elementClass=`modSnippet`&limit=`3`&namespace=``&offset=`0`&page=`1`&pageActiveTpl=`<li[[+activeClasses]]><a[[+activeClasses:default=` class="active"`]][[+title]] href="[[+href]]">[[+pageNo]]</a></li>`&pageFirstTpl=`<li class="control"><a[[+classes]][[+title]] href="[[+href]]">First</a></li>`&pageLastTpl=`<li class="control"><a[[+classes]][[+title]] href="[[+href]]">Last</a></li>`&pageLimit=`5`&pageNavOuterTpl=`[[+prev]][[+next]]`&pageNavScheme=``&pageNavTpl=`<li[[+classes]]><a[[+classes]][[+title]] href="[[+href]]">[[+pageNo]]</a></li>`&pageNavVar=`page.nav`&pageNextTpl=`<li class="page-item"><a class="page-link" [[+title]] href="[[+href]]">Newer</a></li>`&pagePrevTpl=`<li class="page-item"><a class="page-link" [[+title]] href="[[+href]]">Older</a></li>`&pageVarKey=`page`&totalVar=`total`&element=`getResources`&parents=`1`&tpl=`Home_blogit.blog_row_tpl`&includeTVs=`1`&processTVs=`1`&tvPrefix=``&where=`[]`&sortby=`RAND()`&total=`8`&pageOneLimit=`3`&actualLimit=`3`&toPlaceholder=``&qs=`e382d710b9dba083babe1672bc745a87`&pageCount=`3`&pages=`<li[[+activeClasses]]><a class="active"[[+title]] href="/">1</a></li>
  1385. <li[[+classes]]><a[[+classes]][[+title]] href="/?page=2">2</a></li>
  1386. <li[[+classes]]><a[[+classes]][[+title]] href="/?page=3">3</a></li>`&next=`<li class="page-item"><a class="page-link" [[+title]] href="/?page=2">Newer</a></li>`&last=`<li class="control"><a[[+classes]][[+title]] href="/?page=3">Last</a></li>`]]' => '[[+prev]]<li class="page-item"><a class="page-link" [[+title]] href="/?page=2">Newer</a></li>',
  1387. ),
  1388. 'sourceCache' =>
  1389. array (
  1390. 'modChunk' =>
  1391. array (
  1392. 'dash-header' =>
  1393. array (
  1394. 'fields' =>
  1395. array (
  1396. 'id' => 13,
  1397. 'source' => 0,
  1398. 'property_preprocess' => false,
  1399. 'name' => 'dash-header',
  1400. 'description' => '',
  1401. 'editor_type' => 0,
  1402. 'category' => 0,
  1403. 'cache_type' => 0,
  1404. 'snippet' => '<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
  1405. <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
  1406. <script type="text/javascript" src="https://use.fontawesome.com/1e2844bb90.js"></script>
  1407. <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.1/css/all.css" integrity="sha384-gfdkjb5BdAXd+lj+gudLWI+BXq4IuLW5IT+brZEZsLFm++aCMlF1V92rMkPaX4PP" crossorigin="anonymous" />
  1408. <link rel="stylesheet" type="text/css" href="/client-assets/weather-icons/css/weather-icons.min.css?version=1.16" />
  1409. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/magnific-popup.css" />',
  1410. 'locked' => false,
  1411. 'properties' =>
  1412. array (
  1413. ),
  1414. 'static' => false,
  1415. 'static_file' => '',
  1416. 'content' => '<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
  1417. <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
  1418. <script type="text/javascript" src="https://use.fontawesome.com/1e2844bb90.js"></script>
  1419. <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.1/css/all.css" integrity="sha384-gfdkjb5BdAXd+lj+gudLWI+BXq4IuLW5IT+brZEZsLFm++aCMlF1V92rMkPaX4PP" crossorigin="anonymous" />
  1420. <link rel="stylesheet" type="text/css" href="/client-assets/weather-icons/css/weather-icons.min.css?version=1.16" />
  1421. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/magnific-popup.css" />',
  1422. ),
  1423. 'policies' =>
  1424. array (
  1425. 'web' =>
  1426. array (
  1427. ),
  1428. ),
  1429. 'source' =>
  1430. array (
  1431. ),
  1432. ),
  1433. 'soilAnalysisTrialModal' =>
  1434. array (
  1435. 'fields' =>
  1436. array (
  1437. 'id' => 132,
  1438. 'source' => 0,
  1439. 'property_preprocess' => false,
  1440. 'name' => 'soilAnalysisTrialModal',
  1441. 'description' => '',
  1442. 'editor_type' => 0,
  1443. 'category' => 24,
  1444. 'cache_type' => 0,
  1445. 'snippet' => '<!-- Modal -->
  1446. <div class="modal fade" id="soilAnalysisExample" tabindex="-1" role="dialog" aria-labelledby="soilAnalysisExample" aria-hidden="true">
  1447. <div class="modal-dialog modal-xl modal-dialog-centered" role="document">
  1448. <div class="modal-content">
  1449. <div class="modal-header">
  1450. <h5 class="modal-title" id="soilAnalysisExample">Try out our Soil Test Analysis Report</h5>
  1451. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  1452. <span aria-hidden="true">&times;</span>
  1453. </button>
  1454. </div>
  1455. <div class="modal-body">
  1456. <div class="grid-form1">
  1457. <span class="error">* required fields.</span>
  1458. <form method="post" action="#" id="csvForm" class="needs-validation" novalidate >
  1459. [[$analysis_Clientdetails]]
  1460. <hr>
  1461. [[$soilAnalysisForm_bootstrap]]
  1462. <button form="csvForm" type="submit" name="csvForm" class="btn btn-success">Submit</button>
  1463. </form>
  1464. [[!soilformSubmit]]
  1465. <script type="text/javascript">
  1466. // JavaScript for disabling form submission if there are invalid fields
  1467. (function() {
  1468. \'use strict\';
  1469. window.addEventListener(\'load\', function() {
  1470. // Fetch all the forms we want to apply custom Bootstrap validation styles to
  1471. var forms = document.getElementsByClassName(\'needs-validation\');
  1472. // Loop over them and prevent submission
  1473. var validation = Array.prototype.filter.call(forms, function(form) {
  1474. form.addEventListener(\'submit\', function(event) {
  1475. if (form.checkValidity() === false) {
  1476. event.preventDefault();
  1477. event.stopPropagation();
  1478. }
  1479. form.classList.add(\'was-validated\');
  1480. }, false);
  1481. });
  1482. }, false);
  1483. })();
  1484. </script>
  1485. </div>
  1486. </div>
  1487. </div>
  1488. </div>
  1489. </div>',
  1490. 'locked' => false,
  1491. 'properties' =>
  1492. array (
  1493. ),
  1494. 'static' => false,
  1495. 'static_file' => '',
  1496. 'content' => '<!-- Modal -->
  1497. <div class="modal fade" id="soilAnalysisExample" tabindex="-1" role="dialog" aria-labelledby="soilAnalysisExample" aria-hidden="true">
  1498. <div class="modal-dialog modal-xl modal-dialog-centered" role="document">
  1499. <div class="modal-content">
  1500. <div class="modal-header">
  1501. <h5 class="modal-title" id="soilAnalysisExample">Try out our Soil Test Analysis Report</h5>
  1502. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  1503. <span aria-hidden="true">&times;</span>
  1504. </button>
  1505. </div>
  1506. <div class="modal-body">
  1507. <div class="grid-form1">
  1508. <span class="error">* required fields.</span>
  1509. <form method="post" action="#" id="csvForm" class="needs-validation" novalidate >
  1510. [[$analysis_Clientdetails]]
  1511. <hr>
  1512. [[$soilAnalysisForm_bootstrap]]
  1513. <button form="csvForm" type="submit" name="csvForm" class="btn btn-success">Submit</button>
  1514. </form>
  1515. [[!soilformSubmit]]
  1516. <script type="text/javascript">
  1517. // JavaScript for disabling form submission if there are invalid fields
  1518. (function() {
  1519. \'use strict\';
  1520. window.addEventListener(\'load\', function() {
  1521. // Fetch all the forms we want to apply custom Bootstrap validation styles to
  1522. var forms = document.getElementsByClassName(\'needs-validation\');
  1523. // Loop over them and prevent submission
  1524. var validation = Array.prototype.filter.call(forms, function(form) {
  1525. form.addEventListener(\'submit\', function(event) {
  1526. if (form.checkValidity() === false) {
  1527. event.preventDefault();
  1528. event.stopPropagation();
  1529. }
  1530. form.classList.add(\'was-validated\');
  1531. }, false);
  1532. });
  1533. }, false);
  1534. })();
  1535. </script>
  1536. </div>
  1537. </div>
  1538. </div>
  1539. </div>
  1540. </div>',
  1541. ),
  1542. 'policies' =>
  1543. array (
  1544. 'web' =>
  1545. array (
  1546. ),
  1547. ),
  1548. 'source' =>
  1549. array (
  1550. ),
  1551. ),
  1552. 'analysis_Clientdetails' =>
  1553. array (
  1554. 'fields' =>
  1555. array (
  1556. 'id' => 44,
  1557. 'source' => 0,
  1558. 'property_preprocess' => false,
  1559. 'name' => 'analysis_Clientdetails',
  1560. 'description' => 'Client Data Input form for Analysis',
  1561. 'editor_type' => 0,
  1562. 'category' => 0,
  1563. 'cache_type' => 0,
  1564. 'snippet' => '<div class="form-row">
  1565. <div class="form-group col-12 col-md-4 mb-1">
  1566. <label for="client_name" class="p-0 mb-0 col-form-label-sm">Client Name<span class="error">*</span></label>
  1567. <input type="text" class="form-control form-control-sm" name="name" id="name" placeholder="Client Name" required autocomplete="on">
  1568. </div>
  1569. <div class="form-group col-12 col-md-4 mb-1">
  1570. <label for="email" class="p-0 mb-0 col-form-label-sm">Email address<span class="error">*</span></label>
  1571. <input type="email" class="form-control form-control-sm" name="email" id="email" placeholder="Email address" required autocomplete="on">
  1572. </div>
  1573. <div class="form-group col-12 col-md-4 mb-1">
  1574. <label for="company_name" class="p-0 mb-0 col-form-label-sm">Company Name</label>
  1575. <input type="text" class="form-control form-control-sm" name="company" id="company" placeholder="Company Name" autocomplete="on">
  1576. </div>
  1577. </div>
  1578. <div class="form-row">
  1579. <div class="form-group col-12 col-md-6 mb-1">
  1580. <label for="site_address" class="p-0 mb-0 col-form-label-sm">Site Address</label>
  1581. <input type="text" class="form-control form-control-sm" name="site_address" id="site_address" placeholder="Site Address" autocomplete="on">
  1582. </div>
  1583. <div class="form-group col-12 col-md-6 mb-1">
  1584. <label for="state_postcode" class="p-0 mb-0 col-form-label-sm">Postal Address</label>
  1585. <input type="text" class="form-control form-control-sm" name="postal_address" id="postal_address" placeholder="Postal Address" autocomplete="on">
  1586. </div>
  1587. </div>',
  1588. 'locked' => false,
  1589. 'properties' =>
  1590. array (
  1591. ),
  1592. 'static' => false,
  1593. 'static_file' => '',
  1594. 'content' => '<div class="form-row">
  1595. <div class="form-group col-12 col-md-4 mb-1">
  1596. <label for="client_name" class="p-0 mb-0 col-form-label-sm">Client Name<span class="error">*</span></label>
  1597. <input type="text" class="form-control form-control-sm" name="name" id="name" placeholder="Client Name" required autocomplete="on">
  1598. </div>
  1599. <div class="form-group col-12 col-md-4 mb-1">
  1600. <label for="email" class="p-0 mb-0 col-form-label-sm">Email address<span class="error">*</span></label>
  1601. <input type="email" class="form-control form-control-sm" name="email" id="email" placeholder="Email address" required autocomplete="on">
  1602. </div>
  1603. <div class="form-group col-12 col-md-4 mb-1">
  1604. <label for="company_name" class="p-0 mb-0 col-form-label-sm">Company Name</label>
  1605. <input type="text" class="form-control form-control-sm" name="company" id="company" placeholder="Company Name" autocomplete="on">
  1606. </div>
  1607. </div>
  1608. <div class="form-row">
  1609. <div class="form-group col-12 col-md-6 mb-1">
  1610. <label for="site_address" class="p-0 mb-0 col-form-label-sm">Site Address</label>
  1611. <input type="text" class="form-control form-control-sm" name="site_address" id="site_address" placeholder="Site Address" autocomplete="on">
  1612. </div>
  1613. <div class="form-group col-12 col-md-6 mb-1">
  1614. <label for="state_postcode" class="p-0 mb-0 col-form-label-sm">Postal Address</label>
  1615. <input type="text" class="form-control form-control-sm" name="postal_address" id="postal_address" placeholder="Postal Address" autocomplete="on">
  1616. </div>
  1617. </div>',
  1618. ),
  1619. 'policies' =>
  1620. array (
  1621. 'web' =>
  1622. array (
  1623. ),
  1624. ),
  1625. 'source' =>
  1626. array (
  1627. ),
  1628. ),
  1629. 'plantAnalysisTrialModal' =>
  1630. array (
  1631. 'fields' =>
  1632. array (
  1633. 'id' => 133,
  1634. 'source' => 0,
  1635. 'property_preprocess' => false,
  1636. 'name' => 'plantAnalysisTrialModal',
  1637. 'description' => '',
  1638. 'editor_type' => 0,
  1639. 'category' => 25,
  1640. 'cache_type' => 0,
  1641. 'snippet' => '<!-- Modal -->
  1642. <div class="modal fade" id="plantAnalysisExample" tabindex="-1" role="dialog" aria-labelledby="plantAnalysisExample" aria-hidden="true">
  1643. <div class="modal-dialog modal-xl modal-dialog-centered" role="document">
  1644. <div class="modal-content">
  1645. <div class="modal-header">
  1646. <h5 class="modal-title" id="plantAnalysisExample">Try out our Plant Analysis Report</h5>
  1647. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  1648. <span aria-hidden="true">&times;</span>
  1649. </button>
  1650. </div>
  1651. <div class="modal-body">
  1652. <div class="grid-form1">
  1653. <span class="error">* required fields.</span>
  1654. <form method="post" action="#" id="PlantcsvForm" class="needs-validation" novalidate >
  1655. [[$analysis_Clientdetails]]
  1656. <hr>
  1657. [[$plantAnalysisForm]]
  1658. <button form="PlantcsvForm" type="submit" name="PlantcsvForm" class="btn btn-success">Submit</button>
  1659. </form>
  1660. </div>
  1661. [[!plantformSubmit]]
  1662. <script type="text/javascript">
  1663. // JavaScript for disabling form submission if there are invalid fields
  1664. (function() {
  1665. \'use strict\';
  1666. window.addEventListener(\'load\', function() {
  1667. // Fetch all the forms we want to apply custom Bootstrap validation styles to
  1668. var forms = document.getElementsByClassName(\'needs-validation\');
  1669. // Loop over them and prevent submission
  1670. var validation = Array.prototype.filter.call(forms, function(form) {
  1671. form.addEventListener(\'submit\', function(event) {
  1672. if (form.checkValidity() === false) {
  1673. event.preventDefault();
  1674. event.stopPropagation();
  1675. }
  1676. form.classList.add(\'was-validated\');
  1677. }, false);
  1678. });
  1679. }, false);
  1680. })();
  1681. </script>
  1682. </div>
  1683. </div>
  1684. </div>
  1685. </div>',
  1686. 'locked' => false,
  1687. 'properties' =>
  1688. array (
  1689. ),
  1690. 'static' => false,
  1691. 'static_file' => '',
  1692. 'content' => '<!-- Modal -->
  1693. <div class="modal fade" id="plantAnalysisExample" tabindex="-1" role="dialog" aria-labelledby="plantAnalysisExample" aria-hidden="true">
  1694. <div class="modal-dialog modal-xl modal-dialog-centered" role="document">
  1695. <div class="modal-content">
  1696. <div class="modal-header">
  1697. <h5 class="modal-title" id="plantAnalysisExample">Try out our Plant Analysis Report</h5>
  1698. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  1699. <span aria-hidden="true">&times;</span>
  1700. </button>
  1701. </div>
  1702. <div class="modal-body">
  1703. <div class="grid-form1">
  1704. <span class="error">* required fields.</span>
  1705. <form method="post" action="#" id="PlantcsvForm" class="needs-validation" novalidate >
  1706. [[$analysis_Clientdetails]]
  1707. <hr>
  1708. [[$plantAnalysisForm]]
  1709. <button form="PlantcsvForm" type="submit" name="PlantcsvForm" class="btn btn-success">Submit</button>
  1710. </form>
  1711. </div>
  1712. [[!plantformSubmit]]
  1713. <script type="text/javascript">
  1714. // JavaScript for disabling form submission if there are invalid fields
  1715. (function() {
  1716. \'use strict\';
  1717. window.addEventListener(\'load\', function() {
  1718. // Fetch all the forms we want to apply custom Bootstrap validation styles to
  1719. var forms = document.getElementsByClassName(\'needs-validation\');
  1720. // Loop over them and prevent submission
  1721. var validation = Array.prototype.filter.call(forms, function(form) {
  1722. form.addEventListener(\'submit\', function(event) {
  1723. if (form.checkValidity() === false) {
  1724. event.preventDefault();
  1725. event.stopPropagation();
  1726. }
  1727. form.classList.add(\'was-validated\');
  1728. }, false);
  1729. });
  1730. }, false);
  1731. })();
  1732. </script>
  1733. </div>
  1734. </div>
  1735. </div>
  1736. </div>',
  1737. ),
  1738. 'policies' =>
  1739. array (
  1740. 'web' =>
  1741. array (
  1742. ),
  1743. ),
  1744. 'source' =>
  1745. array (
  1746. ),
  1747. ),
  1748. 'plantAnalysisForm' =>
  1749. array (
  1750. 'fields' =>
  1751. array (
  1752. 'id' => 45,
  1753. 'source' => 0,
  1754. 'property_preprocess' => false,
  1755. 'name' => 'plantAnalysisForm',
  1756. 'description' => 'Input form for Plant Analysis',
  1757. 'editor_type' => 0,
  1758. 'category' => 25,
  1759. 'cache_type' => 0,
  1760. 'snippet' => '<div class="form-row">
  1761. <div class="col-md-3 form-group">
  1762. <small id="analysis_type" class="form-text text-muted">Analysis Type<span class="error">*</span></small>
  1763. <div><select name="analysis_type" id="analysis_type" class="form-control form-control-sm" required>
  1764. <option>Select the type of Analysis...</option>
  1765. <option id="ash">Dry Ash Test</option>
  1766. <option id="sap">Sap Analysis</option>
  1767. <option id="field">Field Test</option>
  1768. </select></div>
  1769. </div>
  1770. <div class="col-md-3 form-group">
  1771. <small id="lab_no" class="form-text text-muted">Lab No</small>
  1772. <div class="input-group input-group-sm mb-3">
  1773. <input type="text" class="form-control form-control-sm" name="lab_no" id="lab_no" placeholder="Lab No"></input>
  1774. </div>
  1775. </div>
  1776. <div class="col-md-3 form-group">
  1777. <small id="batch_no" class="form-text text-muted">Batch No</small>
  1778. <div class="input-group input-group-sm mb-3">
  1779. <input type="text" class="form-control form-control-sm" name="batch_no" id="batch_no" placeholder="Batch No"></input>
  1780. </div>
  1781. </div>
  1782. <div class="col-md-3 form-group">
  1783. <small id="date_sampled" class="form-text text-muted">Date Sampled</small>
  1784. <input data-provide="datepicker" class="form-control form-control-sm" name="date_sampled" id="datepicker" placeholder="Date Sampled" data-date-format="dd/mm/yyyy" data-date-end-date="0d" ></input>
  1785. <script>
  1786. $(\'#datepicker\').datepicker({
  1787. uiLibrary: \'bootstrap4\',
  1788. calendarWeeks: \'true\',
  1789. todayHighlight: \'true\'
  1790. });
  1791. </script>
  1792. </div>
  1793. <!-- Hidden Fields for Database -->
  1794. <input type="hidden" class="form-control form-control-sm" name="m_user" id="m_user" placeholder="[[+modx.user.id]]" required>
  1795. <input type="hidden" class="form-control form-control-sm" name="client_id" id="client_id" placeholder="[[+modx.user.username]]" required>
  1796. </div>
  1797. <div class="form-row">
  1798. <div class="col-md-4 form-group">
  1799. <small id="lab_no" class="form-text text-muted">Sample ID<span class="error">*</span></small>
  1800. <input type="text" class="form-control form-control-sm" name="sample_id" id="sample_id" placeholder="Sample Id" required></input>
  1801. </div>
  1802. <div class="col-md-4 form-group">
  1803. <small id="lab_no" class="form-text text-muted">Site ID</small>
  1804. <input type="text" class="form-control form-control-sm" name="site_id" id="site_id" placeholder="Paddock Id"></input>
  1805. </div>
  1806. [[!croptypeFORM]]
  1807. </div>
  1808. <hr>
  1809. <label class="col"><b>Analysis Inputs</b></label>
  1810. <div class="form-row">
  1811. <div class="form-group col-md-2">
  1812. <small id="nSmall" class="form-text text-muted">Nitrogen</small>
  1813. <div class="input-group input-group-sm mb-3">
  1814. <input type="text" class="form-control form-control-sm" name="n" id="n" placeholder="N - Nitrogen"></input>
  1815. <div class="input-group-append">
  1816. <input class="btn btn-append" type="button" id="nitrogen" value="ppm" onClick="conversion(this, nitrogen, n, 10000)" ></input>
  1817. </div>
  1818. </div>
  1819. </div>
  1820. <div class="form-group col-md-2">
  1821. <small id="p" class="form-text text-muted">Phosphorus</small>
  1822. <div class="input-group input-group-sm mb-3">
  1823. <input type="text" class="form-control form-control-sm" name="p" id="p" placeholder="P - Phosphorus"></input>
  1824. <div class="input-group-append">
  1825. <input class="btn btn-append" type="button" id="phosphorus" value="ppm" onClick="conversion(this, phosphorus, p, 10000)" ></input>
  1826. </div>
  1827. </div>
  1828. </div>
  1829. <div class="form-group col-md-2">
  1830. <small id="k" class="form-text text-muted">Postassium</small>
  1831. <div class="input-group input-group-sm mb-3">
  1832. <input type="text" class="form-control form-control-sm" name="k" id="k" placeholder="K - Postassium"></input>
  1833. <div class="input-group-append">
  1834. <input class="btn btn-append" type="button" id="postassium" value="ppm" onClick="conversion(this, postassium, k, 10000)" ></input>
  1835. </div>
  1836. </div>
  1837. </div>
  1838. <div class="form-group col-md-2">
  1839. <small id="s" class="form-text text-muted">Sulphur</small>
  1840. <div class="input-group input-group-sm mb-3">
  1841. <input type="text" class="form-control form-control-sm" name="s" id="s" placeholder="S - Sulphur"></input>
  1842. <div class="input-group-append">
  1843. <input class="btn btn-append" type="button" id="sulphur" value="ppm" onClick="conversion(this, sulphur, s, 10000)" ></input>
  1844. </div>
  1845. </div>
  1846. </div>
  1847. <div class="form-group col-md-2">
  1848. <small id="mg" class="form-text text-muted">Magnesium</small>
  1849. <div class="input-group input-group-sm mb-3">
  1850. <input type="text" class="form-control form-control-sm" name="mg" id="mg" placeholder="Mg - Magnesium"></input>
  1851. <div class="input-group-append">
  1852. <input class="btn btn-append" type="button" id="magnesium" value="ppm" onClick="conversion(this, magnesium, mg, 10000)" ></input>
  1853. </div>
  1854. </div>
  1855. </div>
  1856. <div class="form-group col-md-2">
  1857. <small id="ca" class="form-text text-muted">Calcium</small>
  1858. <div class="input-group input-group-sm mb-3">
  1859. <input type="text" class="form-control form-control-sm" name="ca" id="ca" placeholder="Ca - Calcium"></input>
  1860. <div class="input-group-append">
  1861. <input class="btn btn-append" type="button" id="calcium" value="ppm" onClick="conversion(this, calcium, ca, 10000)" ></input>
  1862. </div>
  1863. </div>
  1864. </div>
  1865. </div>
  1866. <div class="form-row">
  1867. <div class="form-group col-md-2">
  1868. <small id="na" class="form-text text-muted">Soduim</small>
  1869. <div class="input-group input-group-sm mb-3">
  1870. <input type="text" class="form-control form-control-sm" name="na" id="na" placeholder="Na - Soduim"></input>
  1871. <div class="input-group-append">
  1872. <input class="btn btn-append" type="button" id="soduim" value="ppm" onClick="conversion(this, soduim, na, 10000)" ></input>
  1873. </div>
  1874. </div>
  1875. </div>
  1876. <div class="form-group col-md-2">
  1877. <small id="fe" class="form-text text-muted">Iron</small>
  1878. <div class="input-group input-group-sm mb-3">
  1879. <input type="text" class="form-control form-control-sm" name="fe" id="fe" placeholder="Fe - Iron"></input>
  1880. <div class="input-group-append">
  1881. <input class="btn btn-append" type="button" id="iron" value="ppm" onClick="conversion(this, iron, fe, 10000)" ></input>
  1882. </div>
  1883. </div>
  1884. </div>
  1885. <div class="form-group col-md-2">
  1886. <small id="mn" class="form-text text-muted">Manganese</small>
  1887. <div class="input-group input-group-sm mb-3">
  1888. <input type="text" class="form-control form-control-sm" name="mn" id="mn" placeholder="Mn - Manganese"></input>
  1889. <div class="input-group-append">
  1890. <input class="btn btn-append" type="button" id="manganese" value="ppm" onClick="conversion(this, manganese, mn, 10000)" ></input>
  1891. </div>
  1892. </div>
  1893. </div>
  1894. <div class="form-group col-md-2">
  1895. <small id="zn" class="form-text text-muted">Zinc</small>
  1896. <div class="input-group input-group-sm mb-3">
  1897. <input type="text" class="form-control form-control-sm" name="zn" id="zn" placeholder="Zn - Zinc"></input>
  1898. <div class="input-group-append">
  1899. <input class="btn btn-append" type="button" id="zinc" value="ppm" onClick="conversion(this, zinc, zn, 10000)" ></input>
  1900. </div>
  1901. </div>
  1902. </div>
  1903. <div class="form-group col-md-2">
  1904. <small id="cu" class="form-text text-muted">Copper</small>
  1905. <div class="input-group input-group-sm mb-3">
  1906. <input type="text" class="form-control form-control-sm" name="cu" id="cu" placeholder="Cu - Copper"></input>
  1907. <div class="input-group-append">
  1908. <input class="btn btn-append" type="button" id="copper" value="ppm" onClick="conversion(this, copper, cu, 10000)" ></input>
  1909. </div>
  1910. </div>
  1911. </div>
  1912. <div class="form-group col-md-2">
  1913. <small id="b" class="form-text text-muted">Boron</small>
  1914. <div class="input-group input-group-sm mb-3">
  1915. <input type="text" class="form-control form-control-sm" name="b" id="b" placeholder="B - Boron"></input>
  1916. <div class="input-group-append">
  1917. <input class="btn btn-append" type="button" id="boron" value="ppm" onClick="conversion(this, boron, b, 10000)" ></input>
  1918. </div>
  1919. </div>
  1920. </div>
  1921. </div>
  1922. <div class="form-row">
  1923. <div class="form-group col-md-2">
  1924. <small id="m" class="form-text text-muted">Molybdenum</small>
  1925. <div class="input-group input-group-sm mb-3">
  1926. <input type="text" class="form-control form-control-sm" name="m" id="m" placeholder="M - Molybdenum"></input>
  1927. <div class="input-group-append">
  1928. <input class="btn btn-append" type="button" id="molybdenum" value="ppm" onClick="conversion(this, molybdenum, m, 10000)" ></input>
  1929. </div>
  1930. </div>
  1931. </div>
  1932. <div class="form-group col-md-2">
  1933. <small id="co" class="form-text text-muted">Cobalt</small>
  1934. <div class="input-group input-group-sm mb-3">
  1935. <input type="text" class="form-control form-control-sm" name="co" id="co" placeholder="Co - Cobalt"></input>
  1936. <div class="input-group-append">
  1937. <input class="btn btn-append" type="button" id="cobalt" value="ppm" onClick="conversion(this, cobalt, co, 10000)" ></input>
  1938. </div>
  1939. </div>
  1940. </div>
  1941. <div class="form-group col-md-2">
  1942. <small id="se" class="form-text text-muted">Selenium</small>
  1943. <div class="input-group input-group-sm mb-3">
  1944. <input type="text" class="form-control form-control-sm" name="se" id="se" placeholder="Se - Selenium"></input>
  1945. <div class="input-group-append">
  1946. <input class="btn btn-append" type="button" id="selenium" value="ppm" onClick="conversion(this, selenium, se, 10000)" ></input>
  1947. </div>
  1948. </div>
  1949. </div>
  1950. <div class="form-group col-md-2">
  1951. <small id="ch" class="form-text text-muted">Chloride</small>
  1952. <div class="input-group input-group-sm mb-3">
  1953. <input type="text" class="form-control form-control-sm" name="ch" id="ch" placeholder="Ch - Chloride"></input>
  1954. <div class="input-group-append">
  1955. <input class="btn btn-append" type="button" id="chloride" value="ppm" onClick="conversion(this, chloride, cg, 10000)" ></input>
  1956. </div>
  1957. </div>
  1958. </div>
  1959. </div>
  1960. <script type="text/javascript">
  1961. function conversion(value, input, element, conversion) {
  1962. var Nvalue = document.getElementById(element.id).value;
  1963. var el = document.getElementById(input.id);
  1964. if ( el.value === "%" ) {
  1965. el.value = "ppm";
  1966. document.getElementById(element.id).value = Nvalue*conversion;
  1967. } else {
  1968. el.value = "%";
  1969. document.getElementById(element.id).value = Nvalue/conversion;
  1970. }
  1971. }
  1972. </script>',
  1973. 'locked' => false,
  1974. 'properties' =>
  1975. array (
  1976. ),
  1977. 'static' => false,
  1978. 'static_file' => '',
  1979. 'content' => '<div class="form-row">
  1980. <div class="col-md-3 form-group">
  1981. <small id="analysis_type" class="form-text text-muted">Analysis Type<span class="error">*</span></small>
  1982. <div><select name="analysis_type" id="analysis_type" class="form-control form-control-sm" required>
  1983. <option>Select the type of Analysis...</option>
  1984. <option id="ash">Dry Ash Test</option>
  1985. <option id="sap">Sap Analysis</option>
  1986. <option id="field">Field Test</option>
  1987. </select></div>
  1988. </div>
  1989. <div class="col-md-3 form-group">
  1990. <small id="lab_no" class="form-text text-muted">Lab No</small>
  1991. <div class="input-group input-group-sm mb-3">
  1992. <input type="text" class="form-control form-control-sm" name="lab_no" id="lab_no" placeholder="Lab No"></input>
  1993. </div>
  1994. </div>
  1995. <div class="col-md-3 form-group">
  1996. <small id="batch_no" class="form-text text-muted">Batch No</small>
  1997. <div class="input-group input-group-sm mb-3">
  1998. <input type="text" class="form-control form-control-sm" name="batch_no" id="batch_no" placeholder="Batch No"></input>
  1999. </div>
  2000. </div>
  2001. <div class="col-md-3 form-group">
  2002. <small id="date_sampled" class="form-text text-muted">Date Sampled</small>
  2003. <input data-provide="datepicker" class="form-control form-control-sm" name="date_sampled" id="datepicker" placeholder="Date Sampled" data-date-format="dd/mm/yyyy" data-date-end-date="0d" ></input>
  2004. <script>
  2005. $(\'#datepicker\').datepicker({
  2006. uiLibrary: \'bootstrap4\',
  2007. calendarWeeks: \'true\',
  2008. todayHighlight: \'true\'
  2009. });
  2010. </script>
  2011. </div>
  2012. <!-- Hidden Fields for Database -->
  2013. <input type="hidden" class="form-control form-control-sm" name="m_user" id="m_user" placeholder="[[+modx.user.id]]" required>
  2014. <input type="hidden" class="form-control form-control-sm" name="client_id" id="client_id" placeholder="[[+modx.user.username]]" required>
  2015. </div>
  2016. <div class="form-row">
  2017. <div class="col-md-4 form-group">
  2018. <small id="lab_no" class="form-text text-muted">Sample ID<span class="error">*</span></small>
  2019. <input type="text" class="form-control form-control-sm" name="sample_id" id="sample_id" placeholder="Sample Id" required></input>
  2020. </div>
  2021. <div class="col-md-4 form-group">
  2022. <small id="lab_no" class="form-text text-muted">Site ID</small>
  2023. <input type="text" class="form-control form-control-sm" name="site_id" id="site_id" placeholder="Paddock Id"></input>
  2024. </div>
  2025. [[!croptypeFORM]]
  2026. </div>
  2027. <hr>
  2028. <label class="col"><b>Analysis Inputs</b></label>
  2029. <div class="form-row">
  2030. <div class="form-group col-md-2">
  2031. <small id="nSmall" class="form-text text-muted">Nitrogen</small>
  2032. <div class="input-group input-group-sm mb-3">
  2033. <input type="text" class="form-control form-control-sm" name="n" id="n" placeholder="N - Nitrogen"></input>
  2034. <div class="input-group-append">
  2035. <input class="btn btn-append" type="button" id="nitrogen" value="ppm" onClick="conversion(this, nitrogen, n, 10000)" ></input>
  2036. </div>
  2037. </div>
  2038. </div>
  2039. <div class="form-group col-md-2">
  2040. <small id="p" class="form-text text-muted">Phosphorus</small>
  2041. <div class="input-group input-group-sm mb-3">
  2042. <input type="text" class="form-control form-control-sm" name="p" id="p" placeholder="P - Phosphorus"></input>
  2043. <div class="input-group-append">
  2044. <input class="btn btn-append" type="button" id="phosphorus" value="ppm" onClick="conversion(this, phosphorus, p, 10000)" ></input>
  2045. </div>
  2046. </div>
  2047. </div>
  2048. <div class="form-group col-md-2">
  2049. <small id="k" class="form-text text-muted">Postassium</small>
  2050. <div class="input-group input-group-sm mb-3">
  2051. <input type="text" class="form-control form-control-sm" name="k" id="k" placeholder="K - Postassium"></input>
  2052. <div class="input-group-append">
  2053. <input class="btn btn-append" type="button" id="postassium" value="ppm" onClick="conversion(this, postassium, k, 10000)" ></input>
  2054. </div>
  2055. </div>
  2056. </div>
  2057. <div class="form-group col-md-2">
  2058. <small id="s" class="form-text text-muted">Sulphur</small>
  2059. <div class="input-group input-group-sm mb-3">
  2060. <input type="text" class="form-control form-control-sm" name="s" id="s" placeholder="S - Sulphur"></input>
  2061. <div class="input-group-append">
  2062. <input class="btn btn-append" type="button" id="sulphur" value="ppm" onClick="conversion(this, sulphur, s, 10000)" ></input>
  2063. </div>
  2064. </div>
  2065. </div>
  2066. <div class="form-group col-md-2">
  2067. <small id="mg" class="form-text text-muted">Magnesium</small>
  2068. <div class="input-group input-group-sm mb-3">
  2069. <input type="text" class="form-control form-control-sm" name="mg" id="mg" placeholder="Mg - Magnesium"></input>
  2070. <div class="input-group-append">
  2071. <input class="btn btn-append" type="button" id="magnesium" value="ppm" onClick="conversion(this, magnesium, mg, 10000)" ></input>
  2072. </div>
  2073. </div>
  2074. </div>
  2075. <div class="form-group col-md-2">
  2076. <small id="ca" class="form-text text-muted">Calcium</small>
  2077. <div class="input-group input-group-sm mb-3">
  2078. <input type="text" class="form-control form-control-sm" name="ca" id="ca" placeholder="Ca - Calcium"></input>
  2079. <div class="input-group-append">
  2080. <input class="btn btn-append" type="button" id="calcium" value="ppm" onClick="conversion(this, calcium, ca, 10000)" ></input>
  2081. </div>
  2082. </div>
  2083. </div>
  2084. </div>
  2085. <div class="form-row">
  2086. <div class="form-group col-md-2">
  2087. <small id="na" class="form-text text-muted">Soduim</small>
  2088. <div class="input-group input-group-sm mb-3">
  2089. <input type="text" class="form-control form-control-sm" name="na" id="na" placeholder="Na - Soduim"></input>
  2090. <div class="input-group-append">
  2091. <input class="btn btn-append" type="button" id="soduim" value="ppm" onClick="conversion(this, soduim, na, 10000)" ></input>
  2092. </div>
  2093. </div>
  2094. </div>
  2095. <div class="form-group col-md-2">
  2096. <small id="fe" class="form-text text-muted">Iron</small>
  2097. <div class="input-group input-group-sm mb-3">
  2098. <input type="text" class="form-control form-control-sm" name="fe" id="fe" placeholder="Fe - Iron"></input>
  2099. <div class="input-group-append">
  2100. <input class="btn btn-append" type="button" id="iron" value="ppm" onClick="conversion(this, iron, fe, 10000)" ></input>
  2101. </div>
  2102. </div>
  2103. </div>
  2104. <div class="form-group col-md-2">
  2105. <small id="mn" class="form-text text-muted">Manganese</small>
  2106. <div class="input-group input-group-sm mb-3">
  2107. <input type="text" class="form-control form-control-sm" name="mn" id="mn" placeholder="Mn - Manganese"></input>
  2108. <div class="input-group-append">
  2109. <input class="btn btn-append" type="button" id="manganese" value="ppm" onClick="conversion(this, manganese, mn, 10000)" ></input>
  2110. </div>
  2111. </div>
  2112. </div>
  2113. <div class="form-group col-md-2">
  2114. <small id="zn" class="form-text text-muted">Zinc</small>
  2115. <div class="input-group input-group-sm mb-3">
  2116. <input type="text" class="form-control form-control-sm" name="zn" id="zn" placeholder="Zn - Zinc"></input>
  2117. <div class="input-group-append">
  2118. <input class="btn btn-append" type="button" id="zinc" value="ppm" onClick="conversion(this, zinc, zn, 10000)" ></input>
  2119. </div>
  2120. </div>
  2121. </div>
  2122. <div class="form-group col-md-2">
  2123. <small id="cu" class="form-text text-muted">Copper</small>
  2124. <div class="input-group input-group-sm mb-3">
  2125. <input type="text" class="form-control form-control-sm" name="cu" id="cu" placeholder="Cu - Copper"></input>
  2126. <div class="input-group-append">
  2127. <input class="btn btn-append" type="button" id="copper" value="ppm" onClick="conversion(this, copper, cu, 10000)" ></input>
  2128. </div>
  2129. </div>
  2130. </div>
  2131. <div class="form-group col-md-2">
  2132. <small id="b" class="form-text text-muted">Boron</small>
  2133. <div class="input-group input-group-sm mb-3">
  2134. <input type="text" class="form-control form-control-sm" name="b" id="b" placeholder="B - Boron"></input>
  2135. <div class="input-group-append">
  2136. <input class="btn btn-append" type="button" id="boron" value="ppm" onClick="conversion(this, boron, b, 10000)" ></input>
  2137. </div>
  2138. </div>
  2139. </div>
  2140. </div>
  2141. <div class="form-row">
  2142. <div class="form-group col-md-2">
  2143. <small id="m" class="form-text text-muted">Molybdenum</small>
  2144. <div class="input-group input-group-sm mb-3">
  2145. <input type="text" class="form-control form-control-sm" name="m" id="m" placeholder="M - Molybdenum"></input>
  2146. <div class="input-group-append">
  2147. <input class="btn btn-append" type="button" id="molybdenum" value="ppm" onClick="conversion(this, molybdenum, m, 10000)" ></input>
  2148. </div>
  2149. </div>
  2150. </div>
  2151. <div class="form-group col-md-2">
  2152. <small id="co" class="form-text text-muted">Cobalt</small>
  2153. <div class="input-group input-group-sm mb-3">
  2154. <input type="text" class="form-control form-control-sm" name="co" id="co" placeholder="Co - Cobalt"></input>
  2155. <div class="input-group-append">
  2156. <input class="btn btn-append" type="button" id="cobalt" value="ppm" onClick="conversion(this, cobalt, co, 10000)" ></input>
  2157. </div>
  2158. </div>
  2159. </div>
  2160. <div class="form-group col-md-2">
  2161. <small id="se" class="form-text text-muted">Selenium</small>
  2162. <div class="input-group input-group-sm mb-3">
  2163. <input type="text" class="form-control form-control-sm" name="se" id="se" placeholder="Se - Selenium"></input>
  2164. <div class="input-group-append">
  2165. <input class="btn btn-append" type="button" id="selenium" value="ppm" onClick="conversion(this, selenium, se, 10000)" ></input>
  2166. </div>
  2167. </div>
  2168. </div>
  2169. <div class="form-group col-md-2">
  2170. <small id="ch" class="form-text text-muted">Chloride</small>
  2171. <div class="input-group input-group-sm mb-3">
  2172. <input type="text" class="form-control form-control-sm" name="ch" id="ch" placeholder="Ch - Chloride"></input>
  2173. <div class="input-group-append">
  2174. <input class="btn btn-append" type="button" id="chloride" value="ppm" onClick="conversion(this, chloride, cg, 10000)" ></input>
  2175. </div>
  2176. </div>
  2177. </div>
  2178. </div>
  2179. <script type="text/javascript">
  2180. function conversion(value, input, element, conversion) {
  2181. var Nvalue = document.getElementById(element.id).value;
  2182. var el = document.getElementById(input.id);
  2183. if ( el.value === "%" ) {
  2184. el.value = "ppm";
  2185. document.getElementById(element.id).value = Nvalue*conversion;
  2186. } else {
  2187. el.value = "%";
  2188. document.getElementById(element.id).value = Nvalue/conversion;
  2189. }
  2190. }
  2191. </script>',
  2192. ),
  2193. 'policies' =>
  2194. array (
  2195. 'web' =>
  2196. array (
  2197. ),
  2198. ),
  2199. 'source' =>
  2200. array (
  2201. ),
  2202. ),
  2203. 'sc_chunk' =>
  2204. array (
  2205. 'fields' =>
  2206. array (
  2207. 'id' => 24,
  2208. 'source' => 1,
  2209. 'property_preprocess' => false,
  2210. 'name' => 'sc_chunk',
  2211. 'description' => 'This chunk styles the year output',
  2212. 'editor_type' => 0,
  2213. 'category' => 4,
  2214. 'cache_type' => 0,
  2215. 'snippet' => '<span>&copy; [[+output]] by [[++site_name]]</span>',
  2216. 'locked' => false,
  2217. 'properties' =>
  2218. array (
  2219. ),
  2220. 'static' => false,
  2221. 'static_file' => '',
  2222. 'content' => '<span>&copy; [[+output]] by [[++site_name]]</span>',
  2223. ),
  2224. 'policies' =>
  2225. array (
  2226. 'web' =>
  2227. array (
  2228. ),
  2229. ),
  2230. 'source' =>
  2231. array (
  2232. 'id' => 1,
  2233. 'name' => 'Filesystem',
  2234. 'description' => '',
  2235. 'class_key' => 'sources.modFileMediaSource',
  2236. 'properties' =>
  2237. array (
  2238. 'fred' =>
  2239. array (
  2240. 'name' => 'fred',
  2241. 'desc' => '',
  2242. 'type' => 'combo-boolean',
  2243. 'options' =>
  2244. array (
  2245. ),
  2246. 'value' => false,
  2247. 'lexicon' => NULL,
  2248. ),
  2249. 'fredReadOnly' =>
  2250. array (
  2251. 'name' => 'fredReadOnly',
  2252. 'desc' => '',
  2253. 'type' => 'combo-boolean',
  2254. 'options' =>
  2255. array (
  2256. ),
  2257. 'value' => false,
  2258. 'lexicon' => NULL,
  2259. ),
  2260. ),
  2261. 'is_stream' => true,
  2262. ),
  2263. ),
  2264. 'dash-footer' =>
  2265. array (
  2266. 'fields' =>
  2267. array (
  2268. 'id' => 15,
  2269. 'source' => 0,
  2270. 'property_preprocess' => false,
  2271. 'name' => 'dash-footer',
  2272. 'description' => '',
  2273. 'editor_type' => 0,
  2274. 'category' => 0,
  2275. 'cache_type' => 0,
  2276. 'snippet' => '<!-- jQuery first, then Popper.js, then Bootstrap JS -->
  2277. <script type="text/javascript" src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js" integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU=" crossorigin="anonymous"></script>
  2278. <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
  2279. <script type="text/javascript" src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
  2280. <script type="text/javascript">
  2281. addEventListener("load", function() {
  2282. setTimeout(hideURLbar, 0);
  2283. }, false);
  2284. function hideURLbar(){
  2285. window.scrollTo(0,1);
  2286. }
  2287. </script>
  2288. <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.bundle.min.js" integrity="sha384-xrRywqdh3PHs8keKZN+8zzc5TX0GRTLCcmivcbNJWm2rs5C8PRhcEn3czEjhAO9o" crossorigin="anonymous"></script>
  2289. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.4.1/jquery.easing.js"></script>
  2290. <script src="https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/jquery.magnific-popup.js"></script>',
  2291. 'locked' => false,
  2292. 'properties' =>
  2293. array (
  2294. ),
  2295. 'static' => false,
  2296. 'static_file' => '',
  2297. 'content' => '<!-- jQuery first, then Popper.js, then Bootstrap JS -->
  2298. <script type="text/javascript" src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js" integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU=" crossorigin="anonymous"></script>
  2299. <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
  2300. <script type="text/javascript" src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
  2301. <script type="text/javascript">
  2302. addEventListener("load", function() {
  2303. setTimeout(hideURLbar, 0);
  2304. }, false);
  2305. function hideURLbar(){
  2306. window.scrollTo(0,1);
  2307. }
  2308. </script>
  2309. <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.bundle.min.js" integrity="sha384-xrRywqdh3PHs8keKZN+8zzc5TX0GRTLCcmivcbNJWm2rs5C8PRhcEn3czEjhAO9o" crossorigin="anonymous"></script>
  2310. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.4.1/jquery.easing.js"></script>
  2311. <script src="https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/jquery.magnific-popup.js"></script>',
  2312. ),
  2313. 'policies' =>
  2314. array (
  2315. 'web' =>
  2316. array (
  2317. ),
  2318. ),
  2319. 'source' =>
  2320. array (
  2321. ),
  2322. ),
  2323. ),
  2324. 'modSnippet' =>
  2325. array (
  2326. 'blogit.lexicon_load' =>
  2327. array (
  2328. 'fields' =>
  2329. array (
  2330. 'id' => 103,
  2331. 'source' => 0,
  2332. 'property_preprocess' => false,
  2333. 'name' => 'blogit.lexicon_load',
  2334. 'description' => 'Blogit - Created by MPThemes http://mpthemes.com',
  2335. 'editor_type' => 0,
  2336. 'category' => 36,
  2337. 'cache_type' => 0,
  2338. 'snippet' => '$modx->lexicon->load(\'blogit:default\');
  2339. return \'\';',
  2340. 'locked' => false,
  2341. 'properties' =>
  2342. array (
  2343. ),
  2344. 'moduleguid' => '',
  2345. 'static' => false,
  2346. 'static_file' => '',
  2347. 'content' => '$modx->lexicon->load(\'blogit:default\');
  2348. return \'\';',
  2349. ),
  2350. 'policies' =>
  2351. array (
  2352. 'web' =>
  2353. array (
  2354. ),
  2355. ),
  2356. 'source' =>
  2357. array (
  2358. ),
  2359. ),
  2360. 'SimpleCopyright' =>
  2361. array (
  2362. 'fields' =>
  2363. array (
  2364. 'id' => 12,
  2365. 'source' => 1,
  2366. 'property_preprocess' => false,
  2367. 'name' => 'SimpleCopyright',
  2368. 'description' => 'This Snippet returns the current year and can be called with a placeholder for the start year of the website.',
  2369. 'editor_type' => 0,
  2370. 'category' => 4,
  2371. 'cache_type' => 0,
  2372. 'snippet' => '/*
  2373. * DESCRIPTION:
  2374. * This snippet returns the current year
  2375. * It is then styled with a chunk to output a copyright notice which you can adapt to fit your needs.
  2376. * You can call this snippet with a startyear for your website.
  2377. * If you use a start year it automatically changes when the year passes.
  2378. * i.e. 2012 turns into 2012-2013
  2379. *
  2380. * PARAMETERS:
  2381. * @ &startYear (string) optional. Default: Current Year
  2382. * @ &separator (string) optional. Default: \'-\'
  2383. * @ &static (bool) optional. Default: 0
  2384. * @ &tpl (string) optional. Default: \'sc_chunk\'
  2385. *
  2386. * PLACEHOLDERS:
  2387. * @ [[+output]]
  2388. *
  2389. * The usage defines \'2012\' as the \'current\' year purely for illustration purpose only.
  2390. * This is obviously wrong in 2013 or up...
  2391. *
  2392. * USAGE:
  2393. * // Outputs: "&copy; 2012 by [[+site_name]]"
  2394. * [[SimpleCopyright]]
  2395. *
  2396. * // Outputs: "&copy; 2007-2012 by [[+site_name]]"
  2397. * // After newyears eve it turns into 2012-2013 automatically
  2398. * [[SimpleCopyright? &startYear=`2007`]]
  2399. *
  2400. * // Outputs: "&copy; 2004 by [[+site_name]]".
  2401. * // Always use \'static\' in conjunction with \'startYear\'.
  2402. * // If you use \'static\' only it will ignore it\'s setting and resolve to the current year.
  2403. * [[SimpleCopyright? &startYear=`2004` &static=`1`]]
  2404. *
  2405. * You can also set the separator just for fun...
  2406. * It defaults to "-"
  2407. *
  2408. * This outputs "&copy; 2007/2012"
  2409. * [[SimpleCopyright? &startYear=`2007` &separator=`/`]]
  2410. *
  2411. */
  2412. // Get the current year
  2413. $currentYear = date(\'Y\');
  2414. // Check for a starting year, separator, static & chunk
  2415. $startYear = (string) $modx->getOption(\'startYear\', $scriptProperties);
  2416. $separator = (string) $modx->getOption(\'separator\', $scriptProperties, \'-\');
  2417. $static = (bool) $modx->getOption(\'static\', $scriptProperties, 0);
  2418. $tpl = (string) $modx->getOption(\'tpl\', $scriptProperties, \'sc_chunk\');
  2419. if($static&&!empty($startYear)){
  2420. // is static : can be the future too
  2421. $construct = $startYear;
  2422. } elseif(!empty($startYear)) {
  2423. // is semi dynamic : set with a starting year that never exceeds the future
  2424. $construct = ($startYear>=$currentYear ? $currentYear : $startYear.$separator.$currentYear);
  2425. } else {
  2426. // is dynamic : changes with each year
  2427. $construct = $currentYear;
  2428. }
  2429. // Get a chunk to style the output & check if it exists...
  2430. $chunk = $modx->getObject(\'modChunk\',array(
  2431. \'name\' => $tpl
  2432. ));
  2433. if (!$chunk){
  2434. // If no chunk is found return error & write to log
  2435. $modx->log(xPDO::LOG_LEVEL_ERROR, \'No chunk found!\');
  2436. return \'No chunk found!\';
  2437. } else {
  2438. $outputString = $modx->getChunk($tpl,array(
  2439. \'output\' => $construct
  2440. ));
  2441. }
  2442. return $outputString;',
  2443. 'locked' => false,
  2444. 'properties' =>
  2445. array (
  2446. ),
  2447. 'moduleguid' => '',
  2448. 'static' => false,
  2449. 'static_file' => '',
  2450. 'content' => '/*
  2451. * DESCRIPTION:
  2452. * This snippet returns the current year
  2453. * It is then styled with a chunk to output a copyright notice which you can adapt to fit your needs.
  2454. * You can call this snippet with a startyear for your website.
  2455. * If you use a start year it automatically changes when the year passes.
  2456. * i.e. 2012 turns into 2012-2013
  2457. *
  2458. * PARAMETERS:
  2459. * @ &startYear (string) optional. Default: Current Year
  2460. * @ &separator (string) optional. Default: \'-\'
  2461. * @ &static (bool) optional. Default: 0
  2462. * @ &tpl (string) optional. Default: \'sc_chunk\'
  2463. *
  2464. * PLACEHOLDERS:
  2465. * @ [[+output]]
  2466. *
  2467. * The usage defines \'2012\' as the \'current\' year purely for illustration purpose only.
  2468. * This is obviously wrong in 2013 or up...
  2469. *
  2470. * USAGE:
  2471. * // Outputs: "&copy; 2012 by [[+site_name]]"
  2472. * [[SimpleCopyright]]
  2473. *
  2474. * // Outputs: "&copy; 2007-2012 by [[+site_name]]"
  2475. * // After newyears eve it turns into 2012-2013 automatically
  2476. * [[SimpleCopyright? &startYear=`2007`]]
  2477. *
  2478. * // Outputs: "&copy; 2004 by [[+site_name]]".
  2479. * // Always use \'static\' in conjunction with \'startYear\'.
  2480. * // If you use \'static\' only it will ignore it\'s setting and resolve to the current year.
  2481. * [[SimpleCopyright? &startYear=`2004` &static=`1`]]
  2482. *
  2483. * You can also set the separator just for fun...
  2484. * It defaults to "-"
  2485. *
  2486. * This outputs "&copy; 2007/2012"
  2487. * [[SimpleCopyright? &startYear=`2007` &separator=`/`]]
  2488. *
  2489. */
  2490. // Get the current year
  2491. $currentYear = date(\'Y\');
  2492. // Check for a starting year, separator, static & chunk
  2493. $startYear = (string) $modx->getOption(\'startYear\', $scriptProperties);
  2494. $separator = (string) $modx->getOption(\'separator\', $scriptProperties, \'-\');
  2495. $static = (bool) $modx->getOption(\'static\', $scriptProperties, 0);
  2496. $tpl = (string) $modx->getOption(\'tpl\', $scriptProperties, \'sc_chunk\');
  2497. if($static&&!empty($startYear)){
  2498. // is static : can be the future too
  2499. $construct = $startYear;
  2500. } elseif(!empty($startYear)) {
  2501. // is semi dynamic : set with a starting year that never exceeds the future
  2502. $construct = ($startYear>=$currentYear ? $currentYear : $startYear.$separator.$currentYear);
  2503. } else {
  2504. // is dynamic : changes with each year
  2505. $construct = $currentYear;
  2506. }
  2507. // Get a chunk to style the output & check if it exists...
  2508. $chunk = $modx->getObject(\'modChunk\',array(
  2509. \'name\' => $tpl
  2510. ));
  2511. if (!$chunk){
  2512. // If no chunk is found return error & write to log
  2513. $modx->log(xPDO::LOG_LEVEL_ERROR, \'No chunk found!\');
  2514. return \'No chunk found!\';
  2515. } else {
  2516. $outputString = $modx->getChunk($tpl,array(
  2517. \'output\' => $construct
  2518. ));
  2519. }
  2520. return $outputString;',
  2521. ),
  2522. 'policies' =>
  2523. array (
  2524. 'web' =>
  2525. array (
  2526. ),
  2527. ),
  2528. 'source' =>
  2529. array (
  2530. 'id' => 1,
  2531. 'name' => 'Filesystem',
  2532. 'description' => '',
  2533. 'class_key' => 'sources.modFileMediaSource',
  2534. 'properties' =>
  2535. array (
  2536. 'fred' =>
  2537. array (
  2538. 'name' => 'fred',
  2539. 'desc' => '',
  2540. 'type' => 'combo-boolean',
  2541. 'options' =>
  2542. array (
  2543. ),
  2544. 'value' => false,
  2545. 'lexicon' => NULL,
  2546. ),
  2547. 'fredReadOnly' =>
  2548. array (
  2549. 'name' => 'fredReadOnly',
  2550. 'desc' => '',
  2551. 'type' => 'combo-boolean',
  2552. 'options' =>
  2553. array (
  2554. ),
  2555. 'value' => false,
  2556. 'lexicon' => NULL,
  2557. ),
  2558. ),
  2559. 'is_stream' => true,
  2560. ),
  2561. ),
  2562. 'getResources' =>
  2563. array (
  2564. 'fields' =>
  2565. array (
  2566. 'id' => 26,
  2567. 'source' => 0,
  2568. 'property_preprocess' => false,
  2569. 'name' => 'getResources',
  2570. 'description' => '<strong>1.6.1-pl</strong> A general purpose Resource listing and summarization snippet for MODX Revolution',
  2571. 'editor_type' => 0,
  2572. 'category' => 0,
  2573. 'cache_type' => 0,
  2574. 'snippet' => '/**
  2575. * getResources
  2576. *
  2577. * A general purpose Resource listing and summarization snippet for MODX 2.x.
  2578. *
  2579. * @author Jason Coward
  2580. * @copyright Copyright 2010-2013, Jason Coward
  2581. *
  2582. * TEMPLATES
  2583. *
  2584. * tpl - Name of a chunk serving as a resource template
  2585. * [NOTE: if not provided, properties are dumped to output for each resource]
  2586. *
  2587. * tplOdd - (Opt) Name of a chunk serving as resource template for resources with an odd idx value
  2588. * (see idx property)
  2589. * tplFirst - (Opt) Name of a chunk serving as resource template for the first resource (see first
  2590. * property)
  2591. * tplLast - (Opt) Name of a chunk serving as resource template for the last resource (see last
  2592. * property)
  2593. * tpl_{n} - (Opt) Name of a chunk serving as resource template for the nth resource
  2594. *
  2595. * tplCondition - (Opt) Defines a field of the resource to evaluate against keys defined in the
  2596. * conditionalTpls property. Must be a resource field; does not work with Template Variables.
  2597. * conditionalTpls - (Opt) A JSON object defining a map of field values and the associated tpl to
  2598. * use when the field defined by tplCondition matches the value. [NOTE: tplOdd, tplFirst, tplLast,
  2599. * and tpl_{n} will take precedence over any defined conditionalTpls]
  2600. *
  2601. * tplWrapper - (Opt) Name of a chunk serving as a wrapper template for the output
  2602. * [NOTE: Does not work with toSeparatePlaceholders]
  2603. *
  2604. * SELECTION
  2605. *
  2606. * parents - Comma-delimited list of ids serving as parents
  2607. *
  2608. * context - (Opt) Comma-delimited list of context keys to limit results by; if empty, contexts for all specified
  2609. * parents will be used (all contexts if 0 is specified) [default=]
  2610. *
  2611. * depth - (Opt) Integer value indicating depth to search for resources from each parent [default=10]
  2612. *
  2613. * tvFilters - (Opt) Delimited-list of TemplateVar values to filter resources by. Supports two
  2614. * delimiters and two value search formats. The first delimiter || represents a logical OR and the
  2615. * primary grouping mechanism. Within each group you can provide a comma-delimited list of values.
  2616. * These values can be either tied to a specific TemplateVar by name, e.g. myTV==value, or just the
  2617. * value, indicating you are searching for the value in any TemplateVar tied to the Resource. An
  2618. * example would be &tvFilters=`filter2==one,filter1==bar%||filter1==foo`
  2619. * [NOTE: filtering by values uses a LIKE query and % is considered a wildcard.]
  2620. * [NOTE: this only looks at the raw value set for specific Resource, i. e. there must be a value
  2621. * specifically set for the Resource and it is not evaluated.]
  2622. *
  2623. * tvFiltersAndDelimiter - (Opt) Custom delimiter for logical AND, default \',\', in case you want to
  2624. * match a literal comma in the tvFilters. E.g. &tvFiltersAndDelimiter=`&&`
  2625. * &tvFilters=`filter1==foo,bar&&filter2==baz` [default=,]
  2626. *
  2627. * tvFiltersOrDelimiter - (Opt) Custom delimiter for logical OR, default \'||\', in case you want to
  2628. * match a literal \'||\' in the tvFilters. E.g. &tvFiltersOrDelimiter=`|OR|`
  2629. * &tvFilters=`filter1==foo||bar|OR|filter2==baz` [default=||]
  2630. *
  2631. * where - (Opt) A JSON expression of criteria to build any additional where clauses from. An example would be
  2632. * &where=`{{"alias:LIKE":"foo%", "OR:alias:LIKE":"%bar"},{"OR:pagetitle:=":"foobar", "AND:description:=":"raboof"}}`
  2633. *
  2634. * sortby - (Opt) Field to sort by or a JSON array, e.g. {"publishedon":"ASC","createdon":"DESC"} [default=publishedon]
  2635. * sortbyTV - (opt) A Template Variable name to sort by (if supplied, this precedes the sortby value) [default=]
  2636. * sortbyTVType - (Opt) A data type to CAST a TV Value to in order to sort on it properly [default=string]
  2637. * sortbyAlias - (Opt) Query alias for sortby field [default=]
  2638. * sortbyEscaped - (Opt) Escapes the field name(s) specified in sortby [default=0]
  2639. * sortdir - (Opt) Order which to sort by [default=DESC]
  2640. * sortdirTV - (Opt) Order which to sort by a TV [default=DESC]
  2641. * limit - (Opt) Limits the number of resources returned [default=5]
  2642. * offset - (Opt) An offset of resources returned by the criteria to skip [default=0]
  2643. * dbCacheFlag - (Opt) Controls caching of db queries; 0|false = do not cache result set; 1 = cache result set
  2644. * according to cache settings, any other integer value = number of seconds to cache result set [default=0]
  2645. *
  2646. * OPTIONS
  2647. *
  2648. * includeContent - (Opt) Indicates if the content of each resource should be returned in the
  2649. * results [default=0]
  2650. * includeTVs - (Opt) Indicates if TemplateVar values should be included in the properties available
  2651. * to each resource template [default=0]
  2652. * includeTVList - (Opt) Limits the TemplateVars that are included if includeTVs is true to those specified
  2653. * by name in a comma-delimited list [default=]
  2654. * prepareTVs - (Opt) Prepares media-source dependent TemplateVar values [default=1]
  2655. * prepareTVList - (Opt) Limits the TVs that are prepared to those specified by name in a comma-delimited
  2656. * list [default=]
  2657. * processTVs - (Opt) Indicates if TemplateVar values should be rendered as they would on the
  2658. * resource being summarized [default=0]
  2659. * processTVList - (opt) Limits the TemplateVars that are processed if included to those specified
  2660. * by name in a comma-delimited list [default=]
  2661. * tvPrefix - (Opt) The prefix for TemplateVar properties [default=tv.]
  2662. * idx - (Opt) You can define the starting idx of the resources, which is an property that is
  2663. * incremented as each resource is rendered [default=1]
  2664. * first - (Opt) Define the idx which represents the first resource (see tplFirst) [default=1]
  2665. * last - (Opt) Define the idx which represents the last resource (see tplLast) [default=# of
  2666. * resources being summarized + first - 1]
  2667. * outputSeparator - (Opt) An optional string to separate each tpl instance [default="\\n"]
  2668. * wrapIfEmpty - (Opt) Indicates if the tplWrapper should be applied if the output is empty [default=0]
  2669. *
  2670. */
  2671. $output = array();
  2672. $outputSeparator = isset($outputSeparator) ? $outputSeparator : "\\n";
  2673. /* set default properties */
  2674. $tpl = !empty($tpl) ? $tpl : \'\';
  2675. $includeContent = !empty($includeContent) ? true : false;
  2676. $includeTVs = !empty($includeTVs) ? true : false;
  2677. $includeTVList = !empty($includeTVList) ? explode(\',\', $includeTVList) : array();
  2678. $processTVs = !empty($processTVs) ? true : false;
  2679. $processTVList = !empty($processTVList) ? explode(\',\', $processTVList) : array();
  2680. $prepareTVs = !empty($prepareTVs) ? true : false;
  2681. $prepareTVList = !empty($prepareTVList) ? explode(\',\', $prepareTVList) : array();
  2682. $tvPrefix = isset($tvPrefix) ? $tvPrefix : \'tv.\';
  2683. $parents = (!empty($parents) || $parents === \'0\') ? explode(\',\', $parents) : array($modx->resource->get(\'id\'));
  2684. array_walk($parents, \'trim\');
  2685. $parents = array_unique($parents);
  2686. $depth = isset($depth) ? (integer) $depth : 10;
  2687. $tvFiltersOrDelimiter = isset($tvFiltersOrDelimiter) ? $tvFiltersOrDelimiter : \'||\';
  2688. $tvFiltersAndDelimiter = isset($tvFiltersAndDelimiter) ? $tvFiltersAndDelimiter : \',\';
  2689. $tvFilters = !empty($tvFilters) ? explode($tvFiltersOrDelimiter, $tvFilters) : array();
  2690. $where = !empty($where) ? $modx->fromJSON($where) : array();
  2691. $showUnpublished = !empty($showUnpublished) ? true : false;
  2692. $showDeleted = !empty($showDeleted) ? true : false;
  2693. $sortby = isset($sortby) ? $sortby : \'publishedon\';
  2694. $sortbyTV = isset($sortbyTV) ? $sortbyTV : \'\';
  2695. $sortbyAlias = isset($sortbyAlias) ? $sortbyAlias : \'modResource\';
  2696. $sortbyEscaped = !empty($sortbyEscaped) ? true : false;
  2697. $sortdir = isset($sortdir) ? $sortdir : \'DESC\';
  2698. $sortdirTV = isset($sortdirTV) ? $sortdirTV : \'DESC\';
  2699. $limit = isset($limit) ? (integer) $limit : 5;
  2700. $offset = isset($offset) ? (integer) $offset : 0;
  2701. $totalVar = !empty($totalVar) ? $totalVar : \'total\';
  2702. $dbCacheFlag = !isset($dbCacheFlag) ? false : $dbCacheFlag;
  2703. if (is_string($dbCacheFlag) || is_numeric($dbCacheFlag)) {
  2704. if ($dbCacheFlag == \'0\') {
  2705. $dbCacheFlag = false;
  2706. } elseif ($dbCacheFlag == \'1\') {
  2707. $dbCacheFlag = true;
  2708. } else {
  2709. $dbCacheFlag = (integer) $dbCacheFlag;
  2710. }
  2711. }
  2712. /* multiple context support */
  2713. $contextArray = array();
  2714. $contextSpecified = false;
  2715. if (!empty($context)) {
  2716. $contextArray = explode(\',\',$context);
  2717. array_walk($contextArray, \'trim\');
  2718. $contexts = array();
  2719. foreach ($contextArray as $ctx) {
  2720. $contexts[] = $modx->quote($ctx);
  2721. }
  2722. $context = implode(\',\',$contexts);
  2723. $contextSpecified = true;
  2724. unset($contexts,$ctx);
  2725. } else {
  2726. $context = $modx->quote($modx->context->get(\'key\'));
  2727. }
  2728. $pcMap = array();
  2729. $pcQuery = $modx->newQuery(\'modResource\', array(\'id:IN\' => $parents), $dbCacheFlag);
  2730. $pcQuery->select(array(\'id\', \'context_key\'));
  2731. if ($pcQuery->prepare() && $pcQuery->stmt->execute()) {
  2732. foreach ($pcQuery->stmt->fetchAll(PDO::FETCH_ASSOC) as $pcRow) {
  2733. $pcMap[(integer) $pcRow[\'id\']] = $pcRow[\'context_key\'];
  2734. }
  2735. }
  2736. $children = array();
  2737. $parentArray = array();
  2738. foreach ($parents as $parent) {
  2739. $parent = (integer) $parent;
  2740. if ($parent === 0) {
  2741. $pchildren = array();
  2742. if ($contextSpecified) {
  2743. foreach ($contextArray as $pCtx) {
  2744. if (!in_array($pCtx, $contextArray)) {
  2745. continue;
  2746. }
  2747. $options = $pCtx !== $modx->context->get(\'key\') ? array(\'context\' => $pCtx) : array();
  2748. $pcchildren = $modx->getChildIds($parent, $depth, $options);
  2749. if (!empty($pcchildren)) $pchildren = array_merge($pchildren, $pcchildren);
  2750. }
  2751. } else {
  2752. $cQuery = $modx->newQuery(\'modContext\', array(\'key:!=\' => \'mgr\'));
  2753. $cQuery->select(array(\'key\'));
  2754. if ($cQuery->prepare() && $cQuery->stmt->execute()) {
  2755. foreach ($cQuery->stmt->fetchAll(PDO::FETCH_COLUMN) as $pCtx) {
  2756. $options = $pCtx !== $modx->context->get(\'key\') ? array(\'context\' => $pCtx) : array();
  2757. $pcchildren = $modx->getChildIds($parent, $depth, $options);
  2758. if (!empty($pcchildren)) $pchildren = array_merge($pchildren, $pcchildren);
  2759. }
  2760. }
  2761. }
  2762. $parentArray[] = $parent;
  2763. } else {
  2764. $pContext = array_key_exists($parent, $pcMap) ? $pcMap[$parent] : false;
  2765. if ($debug) $modx->log(modX::LOG_LEVEL_ERROR, "context for {$parent} is {$pContext}");
  2766. if ($pContext && $contextSpecified && !in_array($pContext, $contextArray, true)) {
  2767. $parent = next($parents);
  2768. continue;
  2769. }
  2770. $parentArray[] = $parent;
  2771. $options = !empty($pContext) && $pContext !== $modx->context->get(\'key\') ? array(\'context\' => $pContext) : array();
  2772. $pchildren = $modx->getChildIds($parent, $depth, $options);
  2773. }
  2774. if (!empty($pchildren)) $children = array_merge($children, $pchildren);
  2775. $parent = next($parents);
  2776. }
  2777. $parents = array_merge($parentArray, $children);
  2778. /* build query */
  2779. $criteria = array("modResource.parent IN (" . implode(\',\', $parents) . ")");
  2780. if ($contextSpecified) {
  2781. $contextResourceTbl = $modx->getTableName(\'modContextResource\');
  2782. $criteria[] = "(modResource.context_key IN ({$context}) OR EXISTS(SELECT 1 FROM {$contextResourceTbl} ctx WHERE ctx.resource = modResource.id AND ctx.context_key IN ({$context})))";
  2783. }
  2784. if (empty($showDeleted)) {
  2785. $criteria[\'deleted\'] = \'0\';
  2786. }
  2787. if (empty($showUnpublished)) {
  2788. $criteria[\'published\'] = \'1\';
  2789. }
  2790. if (empty($showHidden)) {
  2791. $criteria[\'hidemenu\'] = \'0\';
  2792. }
  2793. if (!empty($hideContainers)) {
  2794. $criteria[\'isfolder\'] = \'0\';
  2795. }
  2796. $criteria = $modx->newQuery(\'modResource\', $criteria);
  2797. if (!empty($tvFilters)) {
  2798. $tmplVarTbl = $modx->getTableName(\'modTemplateVar\');
  2799. $tmplVarResourceTbl = $modx->getTableName(\'modTemplateVarResource\');
  2800. $conditions = array();
  2801. $operators = array(
  2802. \'<=>\' => \'<=>\',
  2803. \'===\' => \'=\',
  2804. \'!==\' => \'!=\',
  2805. \'<>\' => \'<>\',
  2806. \'==\' => \'LIKE\',
  2807. \'!=\' => \'NOT LIKE\',
  2808. \'<<\' => \'<\',
  2809. \'<=\' => \'<=\',
  2810. \'=<\' => \'=<\',
  2811. \'>>\' => \'>\',
  2812. \'>=\' => \'>=\',
  2813. \'=>\' => \'=>\'
  2814. );
  2815. foreach ($tvFilters as $fGroup => $tvFilter) {
  2816. $filterGroup = array();
  2817. $filters = explode($tvFiltersAndDelimiter, $tvFilter);
  2818. $multiple = count($filters) > 0;
  2819. foreach ($filters as $filter) {
  2820. $operator = \'==\';
  2821. $sqlOperator = \'LIKE\';
  2822. foreach ($operators as $op => $opSymbol) {
  2823. if (strpos($filter, $op, 1) !== false) {
  2824. $operator = $op;
  2825. $sqlOperator = $opSymbol;
  2826. break;
  2827. }
  2828. }
  2829. $tvValueField = \'tvr.value\';
  2830. $tvDefaultField = \'tv.default_text\';
  2831. $f = explode($operator, $filter);
  2832. if (count($f) >= 2) {
  2833. if (count($f) > 2) {
  2834. $k = array_shift($f);
  2835. $b = join($operator, $f);
  2836. $f = array($k, $b);
  2837. }
  2838. $tvName = $modx->quote($f[0]);
  2839. if (is_numeric($f[1]) && !in_array($sqlOperator, array(\'LIKE\', \'NOT LIKE\'))) {
  2840. $tvValue = $f[1];
  2841. if ($f[1] == (integer)$f[1]) {
  2842. $tvValueField = "CAST({$tvValueField} AS SIGNED INTEGER)";
  2843. $tvDefaultField = "CAST({$tvDefaultField} AS SIGNED INTEGER)";
  2844. } else {
  2845. $tvValueField = "CAST({$tvValueField} AS DECIMAL)";
  2846. $tvDefaultField = "CAST({$tvDefaultField} AS DECIMAL)";
  2847. }
  2848. } else {
  2849. $tvValue = $modx->quote($f[1]);
  2850. }
  2851. if ($multiple) {
  2852. $filterGroup[] =
  2853. "(EXISTS (SELECT 1 FROM {$tmplVarResourceTbl} tvr JOIN {$tmplVarTbl} tv ON {$tvValueField} {$sqlOperator} {$tvValue} AND tv.name = {$tvName} AND tv.id = tvr.tmplvarid WHERE tvr.contentid = modResource.id) " .
  2854. "OR EXISTS (SELECT 1 FROM {$tmplVarTbl} tv WHERE tv.name = {$tvName} AND {$tvDefaultField} {$sqlOperator} {$tvValue} AND tv.id NOT IN (SELECT tmplvarid FROM {$tmplVarResourceTbl} WHERE contentid = modResource.id)) " .
  2855. ")";
  2856. } else {
  2857. $filterGroup =
  2858. "(EXISTS (SELECT 1 FROM {$tmplVarResourceTbl} tvr JOIN {$tmplVarTbl} tv ON {$tvValueField} {$sqlOperator} {$tvValue} AND tv.name = {$tvName} AND tv.id = tvr.tmplvarid WHERE tvr.contentid = modResource.id) " .
  2859. "OR EXISTS (SELECT 1 FROM {$tmplVarTbl} tv WHERE tv.name = {$tvName} AND {$tvDefaultField} {$sqlOperator} {$tvValue} AND tv.id NOT IN (SELECT tmplvarid FROM {$tmplVarResourceTbl} WHERE contentid = modResource.id)) " .
  2860. ")";
  2861. }
  2862. } elseif (count($f) == 1) {
  2863. $tvValue = $modx->quote($f[0]);
  2864. if ($multiple) {
  2865. $filterGroup[] = "EXISTS (SELECT 1 FROM {$tmplVarResourceTbl} tvr JOIN {$tmplVarTbl} tv ON {$tvValueField} {$sqlOperator} {$tvValue} AND tv.id = tvr.tmplvarid WHERE tvr.contentid = modResource.id)";
  2866. } else {
  2867. $filterGroup = "EXISTS (SELECT 1 FROM {$tmplVarResourceTbl} tvr JOIN {$tmplVarTbl} tv ON {$tvValueField} {$sqlOperator} {$tvValue} AND tv.id = tvr.tmplvarid WHERE tvr.contentid = modResource.id)";
  2868. }
  2869. }
  2870. }
  2871. $conditions[] = $filterGroup;
  2872. }
  2873. if (!empty($conditions)) {
  2874. $firstGroup = true;
  2875. foreach ($conditions as $cGroup => $c) {
  2876. if (is_array($c)) {
  2877. $first = true;
  2878. foreach ($c as $cond) {
  2879. if ($first && !$firstGroup) {
  2880. $criteria->condition($criteria->query[\'where\'][0][1], $cond, xPDOQuery::SQL_OR, null, $cGroup);
  2881. } else {
  2882. $criteria->condition($criteria->query[\'where\'][0][1], $cond, xPDOQuery::SQL_AND, null, $cGroup);
  2883. }
  2884. $first = false;
  2885. }
  2886. } else {
  2887. $criteria->condition($criteria->query[\'where\'][0][1], $c, $firstGroup ? xPDOQuery::SQL_AND : xPDOQuery::SQL_OR, null, $cGroup);
  2888. }
  2889. $firstGroup = false;
  2890. }
  2891. }
  2892. }
  2893. /* include/exclude resources, via &resources=`123,-456` prop */
  2894. if (!empty($resources)) {
  2895. $resourceConditions = array();
  2896. $resources = explode(\',\',$resources);
  2897. $include = array();
  2898. $exclude = array();
  2899. foreach ($resources as $resource) {
  2900. $resource = (int)$resource;
  2901. if ($resource == 0) continue;
  2902. if ($resource < 0) {
  2903. $exclude[] = abs($resource);
  2904. } else {
  2905. $include[] = $resource;
  2906. }
  2907. }
  2908. if (!empty($include)) {
  2909. $criteria->where(array(\'OR:modResource.id:IN\' => $include), xPDOQuery::SQL_OR);
  2910. }
  2911. if (!empty($exclude)) {
  2912. $criteria->where(array(\'modResource.id:NOT IN\' => $exclude), xPDOQuery::SQL_AND, null, 1);
  2913. }
  2914. }
  2915. if (!empty($where)) {
  2916. $criteria->where($where);
  2917. }
  2918. $total = $modx->getCount(\'modResource\', $criteria);
  2919. $modx->setPlaceholder($totalVar, $total);
  2920. $fields = array_keys($modx->getFields(\'modResource\'));
  2921. if (empty($includeContent)) {
  2922. $fields = array_diff($fields, array(\'content\'));
  2923. }
  2924. $columns = $includeContent ? $modx->getSelectColumns(\'modResource\', \'modResource\') : $modx->getSelectColumns(\'modResource\', \'modResource\', \'\', array(\'content\'), true);
  2925. $criteria->select($columns);
  2926. if (!empty($sortbyTV)) {
  2927. $criteria->leftJoin(\'modTemplateVar\', \'tvDefault\', array(
  2928. "tvDefault.name" => $sortbyTV
  2929. ));
  2930. $criteria->leftJoin(\'modTemplateVarResource\', \'tvSort\', array(
  2931. "tvSort.contentid = modResource.id",
  2932. "tvSort.tmplvarid = tvDefault.id"
  2933. ));
  2934. if (empty($sortbyTVType)) $sortbyTVType = \'string\';
  2935. if ($modx->getOption(\'dbtype\') === \'mysql\') {
  2936. switch ($sortbyTVType) {
  2937. case \'integer\':
  2938. $criteria->select("CAST(IFNULL(tvSort.value, tvDefault.default_text) AS SIGNED INTEGER) AS sortTV");
  2939. break;
  2940. case \'decimal\':
  2941. $criteria->select("CAST(IFNULL(tvSort.value, tvDefault.default_text) AS DECIMAL) AS sortTV");
  2942. break;
  2943. case \'datetime\':
  2944. $criteria->select("CAST(IFNULL(tvSort.value, tvDefault.default_text) AS DATETIME) AS sortTV");
  2945. break;
  2946. case \'string\':
  2947. default:
  2948. $criteria->select("IFNULL(tvSort.value, tvDefault.default_text) AS sortTV");
  2949. break;
  2950. }
  2951. } elseif ($modx->getOption(\'dbtype\') === \'sqlsrv\') {
  2952. switch ($sortbyTVType) {
  2953. case \'integer\':
  2954. $criteria->select("CAST(ISNULL(tvSort.value, tvDefault.default_text) AS BIGINT) AS sortTV");
  2955. break;
  2956. case \'decimal\':
  2957. $criteria->select("CAST(ISNULL(tvSort.value, tvDefault.default_text) AS DECIMAL) AS sortTV");
  2958. break;
  2959. case \'datetime\':
  2960. $criteria->select("CAST(ISNULL(tvSort.value, tvDefault.default_text) AS DATETIME) AS sortTV");
  2961. break;
  2962. case \'string\':
  2963. default:
  2964. $criteria->select("ISNULL(tvSort.value, tvDefault.default_text) AS sortTV");
  2965. break;
  2966. }
  2967. }
  2968. $criteria->sortby("sortTV", $sortdirTV);
  2969. }
  2970. if (!empty($sortby)) {
  2971. if (strpos($sortby, \'{\') === 0) {
  2972. $sorts = $modx->fromJSON($sortby);
  2973. } else {
  2974. $sorts = array($sortby => $sortdir);
  2975. }
  2976. if (is_array($sorts)) {
  2977. while (list($sort, $dir) = each($sorts)) {
  2978. if ($sortbyEscaped) $sort = $modx->escape($sort);
  2979. if (!empty($sortbyAlias)) $sort = $modx->escape($sortbyAlias) . ".{$sort}";
  2980. $criteria->sortby($sort, $dir);
  2981. }
  2982. }
  2983. }
  2984. if (!empty($limit)) $criteria->limit($limit, $offset);
  2985. if (!empty($debug)) {
  2986. $criteria->prepare();
  2987. $modx->log(modX::LOG_LEVEL_ERROR, $criteria->toSQL());
  2988. }
  2989. $collection = $modx->getCollection(\'modResource\', $criteria, $dbCacheFlag);
  2990. $idx = !empty($idx) || $idx === \'0\' ? (integer) $idx : 1;
  2991. $first = empty($first) && $first !== \'0\' ? 1 : (integer) $first;
  2992. $last = empty($last) ? (count($collection) + $idx - 1) : (integer) $last;
  2993. /* include parseTpl */
  2994. include_once $modx->getOption(\'getresources.core_path\',null,$modx->getOption(\'core_path\').\'components/getresources/\').\'include.parsetpl.php\';
  2995. $templateVars = array();
  2996. if (!empty($includeTVs) && !empty($includeTVList)) {
  2997. $templateVars = $modx->getCollection(\'modTemplateVar\', array(\'name:IN\' => $includeTVList));
  2998. }
  2999. /** @var modResource $resource */
  3000. foreach ($collection as $resourceId => $resource) {
  3001. $tvs = array();
  3002. if (!empty($includeTVs)) {
  3003. if (empty($includeTVList)) {
  3004. $templateVars = $resource->getMany(\'TemplateVars\');
  3005. }
  3006. /** @var modTemplateVar $templateVar */
  3007. foreach ($templateVars as $tvId => $templateVar) {
  3008. if (!empty($includeTVList) && !in_array($templateVar->get(\'name\'), $includeTVList)) continue;
  3009. if ($processTVs && (empty($processTVList) || in_array($templateVar->get(\'name\'), $processTVList))) {
  3010. $tvs[$tvPrefix . $templateVar->get(\'name\')] = $templateVar->renderOutput($resource->get(\'id\'));
  3011. } else {
  3012. $value = $templateVar->getValue($resource->get(\'id\'));
  3013. if ($prepareTVs && method_exists($templateVar, \'prepareOutput\') && (empty($prepareTVList) || in_array($templateVar->get(\'name\'), $prepareTVList))) {
  3014. $value = $templateVar->prepareOutput($value);
  3015. }
  3016. $tvs[$tvPrefix . $templateVar->get(\'name\')] = $value;
  3017. }
  3018. }
  3019. }
  3020. $odd = ($idx & 1);
  3021. $properties = array_merge(
  3022. $scriptProperties
  3023. ,array(
  3024. \'idx\' => $idx
  3025. ,\'first\' => $first
  3026. ,\'last\' => $last
  3027. ,\'odd\' => $odd
  3028. )
  3029. ,$includeContent ? $resource->toArray() : $resource->get($fields)
  3030. ,$tvs
  3031. );
  3032. $resourceTpl = false;
  3033. if ($idx == $first && !empty($tplFirst)) {
  3034. $resourceTpl = parseTpl($tplFirst, $properties);
  3035. }
  3036. if ($idx == $last && empty($resourceTpl) && !empty($tplLast)) {
  3037. $resourceTpl = parseTpl($tplLast, $properties);
  3038. }
  3039. $tplidx = \'tpl_\' . $idx;
  3040. if (empty($resourceTpl) && !empty($$tplidx)) {
  3041. $resourceTpl = parseTpl($$tplidx, $properties);
  3042. }
  3043. if ($idx > 1 && empty($resourceTpl)) {
  3044. $divisors = getDivisors($idx);
  3045. if (!empty($divisors)) {
  3046. foreach ($divisors as $divisor) {
  3047. $tplnth = \'tpl_n\' . $divisor;
  3048. if (!empty($$tplnth)) {
  3049. $resourceTpl = parseTpl($$tplnth, $properties);
  3050. if (!empty($resourceTpl)) {
  3051. break;
  3052. }
  3053. }
  3054. }
  3055. }
  3056. }
  3057. if ($odd && empty($resourceTpl) && !empty($tplOdd)) {
  3058. $resourceTpl = parseTpl($tplOdd, $properties);
  3059. }
  3060. if (!empty($tplCondition) && !empty($conditionalTpls) && empty($resourceTpl)) {
  3061. $conTpls = $modx->fromJSON($conditionalTpls);
  3062. $subject = $properties[$tplCondition];
  3063. $tplOperator = !empty($tplOperator) ? $tplOperator : \'=\';
  3064. $tplOperator = strtolower($tplOperator);
  3065. $tplCon = \'\';
  3066. foreach ($conTpls as $operand => $conditionalTpl) {
  3067. switch ($tplOperator) {
  3068. case \'!=\':
  3069. case \'neq\':
  3070. case \'not\':
  3071. case \'isnot\':
  3072. case \'isnt\':
  3073. case \'unequal\':
  3074. case \'notequal\':
  3075. $tplCon = (($subject != $operand) ? $conditionalTpl : $tplCon);
  3076. break;
  3077. case \'<\':
  3078. case \'lt\':
  3079. case \'less\':
  3080. case \'lessthan\':
  3081. $tplCon = (($subject < $operand) ? $conditionalTpl : $tplCon);
  3082. break;
  3083. case \'>\':
  3084. case \'gt\':
  3085. case \'greater\':
  3086. case \'greaterthan\':
  3087. $tplCon = (($subject > $operand) ? $conditionalTpl : $tplCon);
  3088. break;
  3089. case \'<=\':
  3090. case \'lte\':
  3091. case \'lessthanequals\':
  3092. case \'lessthanorequalto\':
  3093. $tplCon = (($subject <= $operand) ? $conditionalTpl : $tplCon);
  3094. break;
  3095. case \'>=\':
  3096. case \'gte\':
  3097. case \'greaterthanequals\':
  3098. case \'greaterthanequalto\':
  3099. $tplCon = (($subject >= $operand) ? $conditionalTpl : $tplCon);
  3100. break;
  3101. case \'isempty\':
  3102. case \'empty\':
  3103. $tplCon = empty($subject) ? $conditionalTpl : $tplCon;
  3104. break;
  3105. case \'!empty\':
  3106. case \'notempty\':
  3107. case \'isnotempty\':
  3108. $tplCon = !empty($subject) && $subject != \'\' ? $conditionalTpl : $tplCon;
  3109. break;
  3110. case \'isnull\':
  3111. case \'null\':
  3112. $tplCon = $subject == null || strtolower($subject) == \'null\' ? $conditionalTpl : $tplCon;
  3113. break;
  3114. case \'inarray\':
  3115. case \'in_array\':
  3116. case \'ia\':
  3117. $operand = explode(\',\', $operand);
  3118. $tplCon = in_array($subject, $operand) ? $conditionalTpl : $tplCon;
  3119. break;
  3120. case \'between\':
  3121. case \'range\':
  3122. case \'>=<\':
  3123. case \'><\':
  3124. $operand = explode(\',\', $operand);
  3125. $tplCon = ($subject >= min($operand) && $subject <= max($operand)) ? $conditionalTpl : $tplCon;
  3126. break;
  3127. case \'==\':
  3128. case \'=\':
  3129. case \'eq\':
  3130. case \'is\':
  3131. case \'equal\':
  3132. case \'equals\':
  3133. case \'equalto\':
  3134. default:
  3135. $tplCon = (($subject == $operand) ? $conditionalTpl : $tplCon);
  3136. break;
  3137. }
  3138. }
  3139. if (!empty($tplCon)) {
  3140. $resourceTpl = parseTpl($tplCon, $properties);
  3141. }
  3142. }
  3143. if (!empty($tpl) && empty($resourceTpl)) {
  3144. $resourceTpl = parseTpl($tpl, $properties);
  3145. }
  3146. if ($resourceTpl === false && !empty($debug)) {
  3147. $chunk = $modx->newObject(\'modChunk\');
  3148. $chunk->setCacheable(false);
  3149. $output[]= $chunk->process(array(), \'<pre>\' . print_r($properties, true) .\'</pre>\');
  3150. } else {
  3151. $output[]= $resourceTpl;
  3152. }
  3153. $idx++;
  3154. }
  3155. /* output */
  3156. $toSeparatePlaceholders = $modx->getOption(\'toSeparatePlaceholders\', $scriptProperties, false);
  3157. if (!empty($toSeparatePlaceholders)) {
  3158. $modx->setPlaceholders($output, $toSeparatePlaceholders);
  3159. return \'\';
  3160. }
  3161. $output = implode($outputSeparator, $output);
  3162. $tplWrapper = $modx->getOption(\'tplWrapper\', $scriptProperties, false);
  3163. $wrapIfEmpty = $modx->getOption(\'wrapIfEmpty\', $scriptProperties, false);
  3164. if (!empty($tplWrapper) && ($wrapIfEmpty || !empty($output))) {
  3165. $output = parseTpl($tplWrapper, array_merge($scriptProperties, array(\'output\' => $output)));
  3166. }
  3167. $toPlaceholder = $modx->getOption(\'toPlaceholder\', $scriptProperties, false);
  3168. if (!empty($toPlaceholder)) {
  3169. $modx->setPlaceholder($toPlaceholder, $output);
  3170. return \'\';
  3171. }
  3172. return $output;',
  3173. 'locked' => false,
  3174. 'properties' =>
  3175. array (
  3176. 'tpl' =>
  3177. array (
  3178. 'name' => 'tpl',
  3179. 'desc' => 'Name of a chunk serving as a resource template. NOTE: if not provided, properties are dumped to output for each resource.',
  3180. 'type' => 'textfield',
  3181. 'options' => '',
  3182. 'value' => '',
  3183. 'lexicon' => NULL,
  3184. 'area' => '',
  3185. 'desc_trans' => 'Name of a chunk serving as a resource template. NOTE: if not provided, properties are dumped to output for each resource.',
  3186. 'area_trans' => '',
  3187. ),
  3188. 'tplOdd' =>
  3189. array (
  3190. 'name' => 'tplOdd',
  3191. 'desc' => 'Name of a chunk serving as resource template for resources with an odd idx value (see idx property).',
  3192. 'type' => 'textfield',
  3193. 'options' => '',
  3194. 'value' => '',
  3195. 'lexicon' => NULL,
  3196. 'area' => '',
  3197. 'desc_trans' => 'Name of a chunk serving as resource template for resources with an odd idx value (see idx property).',
  3198. 'area_trans' => '',
  3199. ),
  3200. 'tplFirst' =>
  3201. array (
  3202. 'name' => 'tplFirst',
  3203. 'desc' => 'Name of a chunk serving as resource template for the first resource (see first property).',
  3204. 'type' => 'textfield',
  3205. 'options' => '',
  3206. 'value' => '',
  3207. 'lexicon' => NULL,
  3208. 'area' => '',
  3209. 'desc_trans' => 'Name of a chunk serving as resource template for the first resource (see first property).',
  3210. 'area_trans' => '',
  3211. ),
  3212. 'tplLast' =>
  3213. array (
  3214. 'name' => 'tplLast',
  3215. 'desc' => 'Name of a chunk serving as resource template for the last resource (see last property).',
  3216. 'type' => 'textfield',
  3217. 'options' => '',
  3218. 'value' => '',
  3219. 'lexicon' => NULL,
  3220. 'area' => '',
  3221. 'desc_trans' => 'Name of a chunk serving as resource template for the last resource (see last property).',
  3222. 'area_trans' => '',
  3223. ),
  3224. 'tplWrapper' =>
  3225. array (
  3226. 'name' => 'tplWrapper',
  3227. 'desc' => 'Name of a chunk serving as wrapper template for the Snippet output. This does not work with toSeparatePlaceholders.',
  3228. 'type' => 'textfield',
  3229. 'options' => '',
  3230. 'value' => '',
  3231. 'lexicon' => NULL,
  3232. 'area' => '',
  3233. 'desc_trans' => 'Name of a chunk serving as wrapper template for the Snippet output. This does not work with toSeparatePlaceholders.',
  3234. 'area_trans' => '',
  3235. ),
  3236. 'wrapIfEmpty' =>
  3237. array (
  3238. 'name' => 'wrapIfEmpty',
  3239. 'desc' => 'Indicates if empty output should be wrapped by the tplWrapper, if specified. Defaults to false.',
  3240. 'type' => 'combo-boolean',
  3241. 'options' => '',
  3242. 'value' => false,
  3243. 'lexicon' => NULL,
  3244. 'area' => '',
  3245. 'desc_trans' => 'Indicates if empty output should be wrapped by the tplWrapper, if specified. Defaults to false.',
  3246. 'area_trans' => '',
  3247. ),
  3248. 'sortby' =>
  3249. array (
  3250. 'name' => 'sortby',
  3251. 'desc' => 'A field name to sort by or JSON object of field names and sortdir for each field, e.g. {"publishedon":"ASC","createdon":"DESC"}. Defaults to publishedon.',
  3252. 'type' => 'textfield',
  3253. 'options' => '',
  3254. 'value' => 'publishedon',
  3255. 'lexicon' => NULL,
  3256. 'area' => '',
  3257. 'desc_trans' => 'A field name to sort by or JSON object of field names and sortdir for each field, e.g. {"publishedon":"ASC","createdon":"DESC"}. Defaults to publishedon.',
  3258. 'area_trans' => '',
  3259. ),
  3260. 'sortbyTV' =>
  3261. array (
  3262. 'name' => 'sortbyTV',
  3263. 'desc' => 'Name of a Template Variable to sort by. Defaults to empty string.',
  3264. 'type' => 'textfield',
  3265. 'options' => '',
  3266. 'value' => '',
  3267. 'lexicon' => NULL,
  3268. 'area' => '',
  3269. 'desc_trans' => 'Name of a Template Variable to sort by. Defaults to empty string.',
  3270. 'area_trans' => '',
  3271. ),
  3272. 'sortbyTVType' =>
  3273. array (
  3274. 'name' => 'sortbyTVType',
  3275. 'desc' => 'An optional type to indicate how to sort on the Template Variable value.',
  3276. 'type' => 'list',
  3277. 'options' =>
  3278. array (
  3279. 0 =>
  3280. array (
  3281. 'text' => 'string',
  3282. 'value' => 'string',
  3283. 'name' => 'string',
  3284. ),
  3285. 1 =>
  3286. array (
  3287. 'text' => 'integer',
  3288. 'value' => 'integer',
  3289. 'name' => 'integer',
  3290. ),
  3291. 2 =>
  3292. array (
  3293. 'text' => 'decimal',
  3294. 'value' => 'decimal',
  3295. 'name' => 'decimal',
  3296. ),
  3297. 3 =>
  3298. array (
  3299. 'text' => 'datetime',
  3300. 'value' => 'datetime',
  3301. 'name' => 'datetime',
  3302. ),
  3303. ),
  3304. 'value' => 'string',
  3305. 'lexicon' => NULL,
  3306. 'area' => '',
  3307. 'desc_trans' => 'An optional type to indicate how to sort on the Template Variable value.',
  3308. 'area_trans' => '',
  3309. ),
  3310. 'sortbyAlias' =>
  3311. array (
  3312. 'name' => 'sortbyAlias',
  3313. 'desc' => 'Query alias for sortby field. Defaults to an empty string.',
  3314. 'type' => 'textfield',
  3315. 'options' => '',
  3316. 'value' => '',
  3317. 'lexicon' => NULL,
  3318. 'area' => '',
  3319. 'desc_trans' => 'Query alias for sortby field. Defaults to an empty string.',
  3320. 'area_trans' => '',
  3321. ),
  3322. 'sortbyEscaped' =>
  3323. array (
  3324. 'name' => 'sortbyEscaped',
  3325. 'desc' => 'Determines if the field name specified in sortby should be escaped. Defaults to 0.',
  3326. 'type' => 'textfield',
  3327. 'options' => '',
  3328. 'value' => '0',
  3329. 'lexicon' => NULL,
  3330. 'area' => '',
  3331. 'desc_trans' => 'Determines if the field name specified in sortby should be escaped. Defaults to 0.',
  3332. 'area_trans' => '',
  3333. ),
  3334. 'sortdir' =>
  3335. array (
  3336. 'name' => 'sortdir',
  3337. 'desc' => 'Order which to sort by. Defaults to DESC.',
  3338. 'type' => 'list',
  3339. 'options' =>
  3340. array (
  3341. 0 =>
  3342. array (
  3343. 'text' => 'ASC',
  3344. 'value' => 'ASC',
  3345. 'name' => 'ASC',
  3346. ),
  3347. 1 =>
  3348. array (
  3349. 'text' => 'DESC',
  3350. 'value' => 'DESC',
  3351. 'name' => 'DESC',
  3352. ),
  3353. ),
  3354. 'value' => 'DESC',
  3355. 'lexicon' => NULL,
  3356. 'area' => '',
  3357. 'desc_trans' => 'Order which to sort by. Defaults to DESC.',
  3358. 'area_trans' => '',
  3359. ),
  3360. 'sortdirTV' =>
  3361. array (
  3362. 'name' => 'sortdirTV',
  3363. 'desc' => 'Order which to sort a Template Variable by. Defaults to DESC.',
  3364. 'type' => 'list',
  3365. 'options' =>
  3366. array (
  3367. 0 =>
  3368. array (
  3369. 'text' => 'ASC',
  3370. 'value' => 'ASC',
  3371. 'name' => 'ASC',
  3372. ),
  3373. 1 =>
  3374. array (
  3375. 'text' => 'DESC',
  3376. 'value' => 'DESC',
  3377. 'name' => 'DESC',
  3378. ),
  3379. ),
  3380. 'value' => 'DESC',
  3381. 'lexicon' => NULL,
  3382. 'area' => '',
  3383. 'desc_trans' => 'Order which to sort a Template Variable by. Defaults to DESC.',
  3384. 'area_trans' => '',
  3385. ),
  3386. 'limit' =>
  3387. array (
  3388. 'name' => 'limit',
  3389. 'desc' => 'Limits the number of resources returned. Defaults to 5.',
  3390. 'type' => 'textfield',
  3391. 'options' => '',
  3392. 'value' => '5',
  3393. 'lexicon' => NULL,
  3394. 'area' => '',
  3395. 'desc_trans' => 'Limits the number of resources returned. Defaults to 5.',
  3396. 'area_trans' => '',
  3397. ),
  3398. 'offset' =>
  3399. array (
  3400. 'name' => 'offset',
  3401. 'desc' => 'An offset of resources returned by the criteria to skip.',
  3402. 'type' => 'textfield',
  3403. 'options' => '',
  3404. 'value' => '0',
  3405. 'lexicon' => NULL,
  3406. 'area' => '',
  3407. 'desc_trans' => 'An offset of resources returned by the criteria to skip.',
  3408. 'area_trans' => '',
  3409. ),
  3410. 'tvFilters' =>
  3411. array (
  3412. 'name' => 'tvFilters',
  3413. 'desc' => 'Delimited-list of TemplateVar values to filter resources by. Supports two delimiters and two value search formats. THe first delimiter || represents a logical OR and the primary grouping mechanism. Within each group you can provide a comma-delimited list of values. These values can be either tied to a specific TemplateVar by name, e.g. myTV==value, or just the value, indicating you are searching for the value in any TemplateVar tied to the Resource. An example would be &tvFilters=`filter2==one,filter1==bar%||filter1==foo`. <br />NOTE: filtering by values uses a LIKE query and % is considered a wildcard. <br />ANOTHER NOTE: This only looks at the raw value set for specific Resource, i. e. there must be a value specifically set for the Resource and it is not evaluated.',
  3414. 'type' => 'textfield',
  3415. 'options' => '',
  3416. 'value' => '',
  3417. 'lexicon' => NULL,
  3418. 'area' => '',
  3419. 'desc_trans' => 'Delimited-list of TemplateVar values to filter resources by. Supports two delimiters and two value search formats. THe first delimiter || represents a logical OR and the primary grouping mechanism. Within each group you can provide a comma-delimited list of values. These values can be either tied to a specific TemplateVar by name, e.g. myTV==value, or just the value, indicating you are searching for the value in any TemplateVar tied to the Resource. An example would be &tvFilters=`filter2==one,filter1==bar%||filter1==foo`. <br />NOTE: filtering by values uses a LIKE query and % is considered a wildcard. <br />ANOTHER NOTE: This only looks at the raw value set for specific Resource, i. e. there must be a value specifically set for the Resource and it is not evaluated.',
  3420. 'area_trans' => '',
  3421. ),
  3422. 'tvFiltersAndDelimiter' =>
  3423. array (
  3424. 'name' => 'tvFiltersAndDelimiter',
  3425. 'desc' => 'The delimiter to use to separate logical AND expressions in tvFilters. Default is ,',
  3426. 'type' => 'textfield',
  3427. 'options' => '',
  3428. 'value' => ',',
  3429. 'lexicon' => NULL,
  3430. 'area' => '',
  3431. 'desc_trans' => 'The delimiter to use to separate logical AND expressions in tvFilters. Default is ,',
  3432. 'area_trans' => '',
  3433. ),
  3434. 'tvFiltersOrDelimiter' =>
  3435. array (
  3436. 'name' => 'tvFiltersOrDelimiter',
  3437. 'desc' => 'The delimiter to use to separate logical OR expressions in tvFilters. Default is ||',
  3438. 'type' => 'textfield',
  3439. 'options' => '',
  3440. 'value' => '||',
  3441. 'lexicon' => NULL,
  3442. 'area' => '',
  3443. 'desc_trans' => 'The delimiter to use to separate logical OR expressions in tvFilters. Default is ||',
  3444. 'area_trans' => '',
  3445. ),
  3446. 'depth' =>
  3447. array (
  3448. 'name' => 'depth',
  3449. 'desc' => 'Integer value indicating depth to search for resources from each parent. Defaults to 10.',
  3450. 'type' => 'textfield',
  3451. 'options' => '',
  3452. 'value' => '10',
  3453. 'lexicon' => NULL,
  3454. 'area' => '',
  3455. 'desc_trans' => 'Integer value indicating depth to search for resources from each parent. Defaults to 10.',
  3456. 'area_trans' => '',
  3457. ),
  3458. 'parents' =>
  3459. array (
  3460. 'name' => 'parents',
  3461. 'desc' => 'Optional. Comma-delimited list of ids serving as parents.',
  3462. 'type' => 'textfield',
  3463. 'options' => '',
  3464. 'value' => '',
  3465. 'lexicon' => NULL,
  3466. 'area' => '',
  3467. 'desc_trans' => 'Optional. Comma-delimited list of ids serving as parents.',
  3468. 'area_trans' => '',
  3469. ),
  3470. 'includeContent' =>
  3471. array (
  3472. 'name' => 'includeContent',
  3473. 'desc' => 'Indicates if the content of each resource should be returned in the results. Defaults to false.',
  3474. 'type' => 'combo-boolean',
  3475. 'options' => '',
  3476. 'value' => false,
  3477. 'lexicon' => NULL,
  3478. 'area' => '',
  3479. 'desc_trans' => 'Indicates if the content of each resource should be returned in the results. Defaults to false.',
  3480. 'area_trans' => '',
  3481. ),
  3482. 'includeTVs' =>
  3483. array (
  3484. 'name' => 'includeTVs',
  3485. 'desc' => 'Indicates if TemplateVar values should be included in the properties available to each resource template. Defaults to false.',
  3486. 'type' => 'combo-boolean',
  3487. 'options' => '',
  3488. 'value' => false,
  3489. 'lexicon' => NULL,
  3490. 'area' => '',
  3491. 'desc_trans' => 'Indicates if TemplateVar values should be included in the properties available to each resource template. Defaults to false.',
  3492. 'area_trans' => '',
  3493. ),
  3494. 'includeTVList' =>
  3495. array (
  3496. 'name' => 'includeTVList',
  3497. 'desc' => 'Limits included TVs to those specified as a comma-delimited list of TV names. Defaults to empty.',
  3498. 'type' => 'textfield',
  3499. 'options' => '',
  3500. 'value' => '',
  3501. 'lexicon' => NULL,
  3502. 'area' => '',
  3503. 'desc_trans' => 'Limits included TVs to those specified as a comma-delimited list of TV names. Defaults to empty.',
  3504. 'area_trans' => '',
  3505. ),
  3506. 'showHidden' =>
  3507. array (
  3508. 'name' => 'showHidden',
  3509. 'desc' => 'Indicates if Resources that are hidden from menus should be shown. Defaults to false.',
  3510. 'type' => 'combo-boolean',
  3511. 'options' => '',
  3512. 'value' => false,
  3513. 'lexicon' => NULL,
  3514. 'area' => '',
  3515. 'desc_trans' => 'Indicates if Resources that are hidden from menus should be shown. Defaults to false.',
  3516. 'area_trans' => '',
  3517. ),
  3518. 'showUnpublished' =>
  3519. array (
  3520. 'name' => 'showUnpublished',
  3521. 'desc' => 'Indicates if Resources that are unpublished should be shown. Defaults to false.',
  3522. 'type' => 'combo-boolean',
  3523. 'options' => '',
  3524. 'value' => false,
  3525. 'lexicon' => NULL,
  3526. 'area' => '',
  3527. 'desc_trans' => 'Indicates if Resources that are unpublished should be shown. Defaults to false.',
  3528. 'area_trans' => '',
  3529. ),
  3530. 'showDeleted' =>
  3531. array (
  3532. 'name' => 'showDeleted',
  3533. 'desc' => 'Indicates if Resources that are deleted should be shown. Defaults to false.',
  3534. 'type' => 'combo-boolean',
  3535. 'options' => '',
  3536. 'value' => false,
  3537. 'lexicon' => NULL,
  3538. 'area' => '',
  3539. 'desc_trans' => 'Indicates if Resources that are deleted should be shown. Defaults to false.',
  3540. 'area_trans' => '',
  3541. ),
  3542. 'resources' =>
  3543. array (
  3544. 'name' => 'resources',
  3545. 'desc' => 'A comma-separated list of resource IDs to exclude or include. IDs with a - in front mean to exclude. Ex: 123,-456 means to include Resource 123, but always exclude Resource 456.',
  3546. 'type' => 'textfield',
  3547. 'options' => '',
  3548. 'value' => '',
  3549. 'lexicon' => NULL,
  3550. 'area' => '',
  3551. 'desc_trans' => 'A comma-separated list of resource IDs to exclude or include. IDs with a - in front mean to exclude. Ex: 123,-456 means to include Resource 123, but always exclude Resource 456.',
  3552. 'area_trans' => '',
  3553. ),
  3554. 'processTVs' =>
  3555. array (
  3556. 'name' => 'processTVs',
  3557. 'desc' => 'Indicates if TemplateVar values should be rendered as they would on the resource being summarized. Defaults to false.',
  3558. 'type' => 'combo-boolean',
  3559. 'options' => '',
  3560. 'value' => false,
  3561. 'lexicon' => NULL,
  3562. 'area' => '',
  3563. 'desc_trans' => 'Indicates if TemplateVar values should be rendered as they would on the resource being summarized. Defaults to false.',
  3564. 'area_trans' => '',
  3565. ),
  3566. 'processTVList' =>
  3567. array (
  3568. 'name' => 'processTVList',
  3569. 'desc' => 'Limits processed TVs to those specified as a comma-delimited list of TV names; note only includedTVs will be available for processing if specified. Defaults to empty.',
  3570. 'type' => 'textfield',
  3571. 'options' => '',
  3572. 'value' => '',
  3573. 'lexicon' => NULL,
  3574. 'area' => '',
  3575. 'desc_trans' => 'Limits processed TVs to those specified as a comma-delimited list of TV names; note only includedTVs will be available for processing if specified. Defaults to empty.',
  3576. 'area_trans' => '',
  3577. ),
  3578. 'prepareTVs' =>
  3579. array (
  3580. 'name' => 'prepareTVs',
  3581. 'desc' => 'Indicates if TemplateVar values that are not processed fully should be prepared before being returned. Defaults to true.',
  3582. 'type' => 'combo-boolean',
  3583. 'options' => '',
  3584. 'value' => true,
  3585. 'lexicon' => NULL,
  3586. 'area' => '',
  3587. 'desc_trans' => 'Indicates if TemplateVar values that are not processed fully should be prepared before being returned. Defaults to true.',
  3588. 'area_trans' => '',
  3589. ),
  3590. 'prepareTVList' =>
  3591. array (
  3592. 'name' => 'prepareTVList',
  3593. 'desc' => 'Limits prepared TVs to those specified as a comma-delimited list of TV names; note only includedTVs will be available for preparing if specified. Defaults to empty.',
  3594. 'type' => 'textfield',
  3595. 'options' => '',
  3596. 'value' => '',
  3597. 'lexicon' => NULL,
  3598. 'area' => '',
  3599. 'desc_trans' => 'Limits prepared TVs to those specified as a comma-delimited list of TV names; note only includedTVs will be available for preparing if specified. Defaults to empty.',
  3600. 'area_trans' => '',
  3601. ),
  3602. 'tvPrefix' =>
  3603. array (
  3604. 'name' => 'tvPrefix',
  3605. 'desc' => 'The prefix for TemplateVar properties. Defaults to: tv.',
  3606. 'type' => 'textfield',
  3607. 'options' => '',
  3608. 'value' => 'tv.',
  3609. 'lexicon' => NULL,
  3610. 'area' => '',
  3611. 'desc_trans' => 'The prefix for TemplateVar properties. Defaults to: tv.',
  3612. 'area_trans' => '',
  3613. ),
  3614. 'idx' =>
  3615. array (
  3616. 'name' => 'idx',
  3617. 'desc' => 'You can define the starting idx of the resources, which is an property that is incremented as each resource is rendered.',
  3618. 'type' => 'textfield',
  3619. 'options' => '',
  3620. 'value' => '',
  3621. 'lexicon' => NULL,
  3622. 'area' => '',
  3623. 'desc_trans' => 'You can define the starting idx of the resources, which is an property that is incremented as each resource is rendered.',
  3624. 'area_trans' => '',
  3625. ),
  3626. 'first' =>
  3627. array (
  3628. 'name' => 'first',
  3629. 'desc' => 'Define the idx which represents the first resource (see tplFirst). Defaults to 1.',
  3630. 'type' => 'textfield',
  3631. 'options' => '',
  3632. 'value' => '',
  3633. 'lexicon' => NULL,
  3634. 'area' => '',
  3635. 'desc_trans' => 'Define the idx which represents the first resource (see tplFirst). Defaults to 1.',
  3636. 'area_trans' => '',
  3637. ),
  3638. 'last' =>
  3639. array (
  3640. 'name' => 'last',
  3641. 'desc' => 'Define the idx which represents the last resource (see tplLast). Defaults to the number of resources being summarized + first - 1',
  3642. 'type' => 'textfield',
  3643. 'options' => '',
  3644. 'value' => '',
  3645. 'lexicon' => NULL,
  3646. 'area' => '',
  3647. 'desc_trans' => 'Define the idx which represents the last resource (see tplLast). Defaults to the number of resources being summarized + first - 1',
  3648. 'area_trans' => '',
  3649. ),
  3650. 'toPlaceholder' =>
  3651. array (
  3652. 'name' => 'toPlaceholder',
  3653. 'desc' => 'If set, will assign the result to this placeholder instead of outputting it directly.',
  3654. 'type' => 'textfield',
  3655. 'options' => '',
  3656. 'value' => '',
  3657. 'lexicon' => NULL,
  3658. 'area' => '',
  3659. 'desc_trans' => 'If set, will assign the result to this placeholder instead of outputting it directly.',
  3660. 'area_trans' => '',
  3661. ),
  3662. 'toSeparatePlaceholders' =>
  3663. array (
  3664. 'name' => 'toSeparatePlaceholders',
  3665. 'desc' => 'If set, will assign EACH result to a separate placeholder named by this param suffixed with a sequential number (starting from 0).',
  3666. 'type' => 'textfield',
  3667. 'options' => '',
  3668. 'value' => '',
  3669. 'lexicon' => NULL,
  3670. 'area' => '',
  3671. 'desc_trans' => 'If set, will assign EACH result to a separate placeholder named by this param suffixed with a sequential number (starting from 0).',
  3672. 'area_trans' => '',
  3673. ),
  3674. 'debug' =>
  3675. array (
  3676. 'name' => 'debug',
  3677. 'desc' => 'If true, will send the SQL query to the MODX log. Defaults to false.',
  3678. 'type' => 'combo-boolean',
  3679. 'options' => '',
  3680. 'value' => false,
  3681. 'lexicon' => NULL,
  3682. 'area' => '',
  3683. 'desc_trans' => 'If true, will send the SQL query to the MODX log. Defaults to false.',
  3684. 'area_trans' => '',
  3685. ),
  3686. 'where' =>
  3687. array (
  3688. 'name' => 'where',
  3689. 'desc' => 'A JSON expression of criteria to build any additional where clauses from, e.g. &where=`{{"alias:LIKE":"foo%", "OR:alias:LIKE":"%bar"},{"OR:pagetitle:=":"foobar", "AND:description:=":"raboof"}}`',
  3690. 'type' => 'textfield',
  3691. 'options' => '',
  3692. 'value' => '',
  3693. 'lexicon' => NULL,
  3694. 'area' => '',
  3695. 'desc_trans' => 'A JSON expression of criteria to build any additional where clauses from, e.g. &where=`{{"alias:LIKE":"foo%", "OR:alias:LIKE":"%bar"},{"OR:pagetitle:=":"foobar", "AND:description:=":"raboof"}}`',
  3696. 'area_trans' => '',
  3697. ),
  3698. 'dbCacheFlag' =>
  3699. array (
  3700. 'name' => 'dbCacheFlag',
  3701. 'desc' => 'Determines how result sets are cached if cache_db is enabled in MODX. 0|false = do not cache result set; 1 = cache result set according to cache settings, any other integer value = number of seconds to cache result set',
  3702. 'type' => 'textfield',
  3703. 'options' => '',
  3704. 'value' => '0',
  3705. 'lexicon' => NULL,
  3706. 'area' => '',
  3707. 'desc_trans' => 'Determines how result sets are cached if cache_db is enabled in MODX. 0|false = do not cache result set; 1 = cache result set according to cache settings, any other integer value = number of seconds to cache result set',
  3708. 'area_trans' => '',
  3709. ),
  3710. 'context' =>
  3711. array (
  3712. 'name' => 'context',
  3713. 'desc' => 'A comma-delimited list of context keys for limiting results. Default is empty, i.e. do not limit results by context.',
  3714. 'type' => 'textfield',
  3715. 'options' => '',
  3716. 'value' => '',
  3717. 'lexicon' => NULL,
  3718. 'area' => '',
  3719. 'desc_trans' => 'A comma-delimited list of context keys for limiting results. Default is empty, i.e. do not limit results by context.',
  3720. 'area_trans' => '',
  3721. ),
  3722. 'tplCondition' =>
  3723. array (
  3724. 'name' => 'tplCondition',
  3725. 'desc' => 'A condition to compare against the conditionalTpls property to map Resources to different tpls based on custom conditional logic.',
  3726. 'type' => 'textfield',
  3727. 'options' => '',
  3728. 'value' => '',
  3729. 'lexicon' => NULL,
  3730. 'area' => '',
  3731. 'desc_trans' => 'A condition to compare against the conditionalTpls property to map Resources to different tpls based on custom conditional logic.',
  3732. 'area_trans' => '',
  3733. ),
  3734. 'tplOperator' =>
  3735. array (
  3736. 'name' => 'tplOperator',
  3737. 'desc' => 'An optional operator to use for the tplCondition when comparing against the conditionalTpls operands. Default is == (equals).',
  3738. 'type' => 'list',
  3739. 'options' =>
  3740. array (
  3741. 0 =>
  3742. array (
  3743. 'text' => 'is equal to',
  3744. 'value' => '==',
  3745. 'name' => 'is equal to',
  3746. ),
  3747. 1 =>
  3748. array (
  3749. 'text' => 'is not equal to',
  3750. 'value' => '!=',
  3751. 'name' => 'is not equal to',
  3752. ),
  3753. 2 =>
  3754. array (
  3755. 'text' => 'less than',
  3756. 'value' => '<',
  3757. 'name' => 'less than',
  3758. ),
  3759. 3 =>
  3760. array (
  3761. 'text' => 'less than or equal to',
  3762. 'value' => '<=',
  3763. 'name' => 'less than or equal to',
  3764. ),
  3765. 4 =>
  3766. array (
  3767. 'text' => 'greater than or equal to',
  3768. 'value' => '>=',
  3769. 'name' => 'greater than or equal to',
  3770. ),
  3771. 5 =>
  3772. array (
  3773. 'text' => 'is empty',
  3774. 'value' => 'empty',
  3775. 'name' => 'is empty',
  3776. ),
  3777. 6 =>
  3778. array (
  3779. 'text' => 'is not empty',
  3780. 'value' => '!empty',
  3781. 'name' => 'is not empty',
  3782. ),
  3783. 7 =>
  3784. array (
  3785. 'text' => 'is null',
  3786. 'value' => 'null',
  3787. 'name' => 'is null',
  3788. ),
  3789. 8 =>
  3790. array (
  3791. 'text' => 'is in array',
  3792. 'value' => 'inarray',
  3793. 'name' => 'is in array',
  3794. ),
  3795. 9 =>
  3796. array (
  3797. 'text' => 'is between',
  3798. 'value' => 'between',
  3799. 'name' => 'is between',
  3800. ),
  3801. ),
  3802. 'value' => '==',
  3803. 'lexicon' => NULL,
  3804. 'area' => '',
  3805. 'desc_trans' => 'An optional operator to use for the tplCondition when comparing against the conditionalTpls operands. Default is == (equals).',
  3806. 'area_trans' => '',
  3807. ),
  3808. 'conditionalTpls' =>
  3809. array (
  3810. 'name' => 'conditionalTpls',
  3811. 'desc' => 'A JSON map of conditional operands and tpls to compare against the tplCondition property using the specified tplOperator.',
  3812. 'type' => 'textfield',
  3813. 'options' => '',
  3814. 'value' => '',
  3815. 'lexicon' => NULL,
  3816. 'area' => '',
  3817. 'desc_trans' => 'A JSON map of conditional operands and tpls to compare against the tplCondition property using the specified tplOperator.',
  3818. 'area_trans' => '',
  3819. ),
  3820. ),
  3821. 'moduleguid' => '',
  3822. 'static' => false,
  3823. 'static_file' => '',
  3824. 'content' => '/**
  3825. * getResources
  3826. *
  3827. * A general purpose Resource listing and summarization snippet for MODX 2.x.
  3828. *
  3829. * @author Jason Coward
  3830. * @copyright Copyright 2010-2013, Jason Coward
  3831. *
  3832. * TEMPLATES
  3833. *
  3834. * tpl - Name of a chunk serving as a resource template
  3835. * [NOTE: if not provided, properties are dumped to output for each resource]
  3836. *
  3837. * tplOdd - (Opt) Name of a chunk serving as resource template for resources with an odd idx value
  3838. * (see idx property)
  3839. * tplFirst - (Opt) Name of a chunk serving as resource template for the first resource (see first
  3840. * property)
  3841. * tplLast - (Opt) Name of a chunk serving as resource template for the last resource (see last
  3842. * property)
  3843. * tpl_{n} - (Opt) Name of a chunk serving as resource template for the nth resource
  3844. *
  3845. * tplCondition - (Opt) Defines a field of the resource to evaluate against keys defined in the
  3846. * conditionalTpls property. Must be a resource field; does not work with Template Variables.
  3847. * conditionalTpls - (Opt) A JSON object defining a map of field values and the associated tpl to
  3848. * use when the field defined by tplCondition matches the value. [NOTE: tplOdd, tplFirst, tplLast,
  3849. * and tpl_{n} will take precedence over any defined conditionalTpls]
  3850. *
  3851. * tplWrapper - (Opt) Name of a chunk serving as a wrapper template for the output
  3852. * [NOTE: Does not work with toSeparatePlaceholders]
  3853. *
  3854. * SELECTION
  3855. *
  3856. * parents - Comma-delimited list of ids serving as parents
  3857. *
  3858. * context - (Opt) Comma-delimited list of context keys to limit results by; if empty, contexts for all specified
  3859. * parents will be used (all contexts if 0 is specified) [default=]
  3860. *
  3861. * depth - (Opt) Integer value indicating depth to search for resources from each parent [default=10]
  3862. *
  3863. * tvFilters - (Opt) Delimited-list of TemplateVar values to filter resources by. Supports two
  3864. * delimiters and two value search formats. The first delimiter || represents a logical OR and the
  3865. * primary grouping mechanism. Within each group you can provide a comma-delimited list of values.
  3866. * These values can be either tied to a specific TemplateVar by name, e.g. myTV==value, or just the
  3867. * value, indicating you are searching for the value in any TemplateVar tied to the Resource. An
  3868. * example would be &tvFilters=`filter2==one,filter1==bar%||filter1==foo`
  3869. * [NOTE: filtering by values uses a LIKE query and % is considered a wildcard.]
  3870. * [NOTE: this only looks at the raw value set for specific Resource, i. e. there must be a value
  3871. * specifically set for the Resource and it is not evaluated.]
  3872. *
  3873. * tvFiltersAndDelimiter - (Opt) Custom delimiter for logical AND, default \',\', in case you want to
  3874. * match a literal comma in the tvFilters. E.g. &tvFiltersAndDelimiter=`&&`
  3875. * &tvFilters=`filter1==foo,bar&&filter2==baz` [default=,]
  3876. *
  3877. * tvFiltersOrDelimiter - (Opt) Custom delimiter for logical OR, default \'||\', in case you want to
  3878. * match a literal \'||\' in the tvFilters. E.g. &tvFiltersOrDelimiter=`|OR|`
  3879. * &tvFilters=`filter1==foo||bar|OR|filter2==baz` [default=||]
  3880. *
  3881. * where - (Opt) A JSON expression of criteria to build any additional where clauses from. An example would be
  3882. * &where=`{{"alias:LIKE":"foo%", "OR:alias:LIKE":"%bar"},{"OR:pagetitle:=":"foobar", "AND:description:=":"raboof"}}`
  3883. *
  3884. * sortby - (Opt) Field to sort by or a JSON array, e.g. {"publishedon":"ASC","createdon":"DESC"} [default=publishedon]
  3885. * sortbyTV - (opt) A Template Variable name to sort by (if supplied, this precedes the sortby value) [default=]
  3886. * sortbyTVType - (Opt) A data type to CAST a TV Value to in order to sort on it properly [default=string]
  3887. * sortbyAlias - (Opt) Query alias for sortby field [default=]
  3888. * sortbyEscaped - (Opt) Escapes the field name(s) specified in sortby [default=0]
  3889. * sortdir - (Opt) Order which to sort by [default=DESC]
  3890. * sortdirTV - (Opt) Order which to sort by a TV [default=DESC]
  3891. * limit - (Opt) Limits the number of resources returned [default=5]
  3892. * offset - (Opt) An offset of resources returned by the criteria to skip [default=0]
  3893. * dbCacheFlag - (Opt) Controls caching of db queries; 0|false = do not cache result set; 1 = cache result set
  3894. * according to cache settings, any other integer value = number of seconds to cache result set [default=0]
  3895. *
  3896. * OPTIONS
  3897. *
  3898. * includeContent - (Opt) Indicates if the content of each resource should be returned in the
  3899. * results [default=0]
  3900. * includeTVs - (Opt) Indicates if TemplateVar values should be included in the properties available
  3901. * to each resource template [default=0]
  3902. * includeTVList - (Opt) Limits the TemplateVars that are included if includeTVs is true to those specified
  3903. * by name in a comma-delimited list [default=]
  3904. * prepareTVs - (Opt) Prepares media-source dependent TemplateVar values [default=1]
  3905. * prepareTVList - (Opt) Limits the TVs that are prepared to those specified by name in a comma-delimited
  3906. * list [default=]
  3907. * processTVs - (Opt) Indicates if TemplateVar values should be rendered as they would on the
  3908. * resource being summarized [default=0]
  3909. * processTVList - (opt) Limits the TemplateVars that are processed if included to those specified
  3910. * by name in a comma-delimited list [default=]
  3911. * tvPrefix - (Opt) The prefix for TemplateVar properties [default=tv.]
  3912. * idx - (Opt) You can define the starting idx of the resources, which is an property that is
  3913. * incremented as each resource is rendered [default=1]
  3914. * first - (Opt) Define the idx which represents the first resource (see tplFirst) [default=1]
  3915. * last - (Opt) Define the idx which represents the last resource (see tplLast) [default=# of
  3916. * resources being summarized + first - 1]
  3917. * outputSeparator - (Opt) An optional string to separate each tpl instance [default="\\n"]
  3918. * wrapIfEmpty - (Opt) Indicates if the tplWrapper should be applied if the output is empty [default=0]
  3919. *
  3920. */
  3921. $output = array();
  3922. $outputSeparator = isset($outputSeparator) ? $outputSeparator : "\\n";
  3923. /* set default properties */
  3924. $tpl = !empty($tpl) ? $tpl : \'\';
  3925. $includeContent = !empty($includeContent) ? true : false;
  3926. $includeTVs = !empty($includeTVs) ? true : false;
  3927. $includeTVList = !empty($includeTVList) ? explode(\',\', $includeTVList) : array();
  3928. $processTVs = !empty($processTVs) ? true : false;
  3929. $processTVList = !empty($processTVList) ? explode(\',\', $processTVList) : array();
  3930. $prepareTVs = !empty($prepareTVs) ? true : false;
  3931. $prepareTVList = !empty($prepareTVList) ? explode(\',\', $prepareTVList) : array();
  3932. $tvPrefix = isset($tvPrefix) ? $tvPrefix : \'tv.\';
  3933. $parents = (!empty($parents) || $parents === \'0\') ? explode(\',\', $parents) : array($modx->resource->get(\'id\'));
  3934. array_walk($parents, \'trim\');
  3935. $parents = array_unique($parents);
  3936. $depth = isset($depth) ? (integer) $depth : 10;
  3937. $tvFiltersOrDelimiter = isset($tvFiltersOrDelimiter) ? $tvFiltersOrDelimiter : \'||\';
  3938. $tvFiltersAndDelimiter = isset($tvFiltersAndDelimiter) ? $tvFiltersAndDelimiter : \',\';
  3939. $tvFilters = !empty($tvFilters) ? explode($tvFiltersOrDelimiter, $tvFilters) : array();
  3940. $where = !empty($where) ? $modx->fromJSON($where) : array();
  3941. $showUnpublished = !empty($showUnpublished) ? true : false;
  3942. $showDeleted = !empty($showDeleted) ? true : false;
  3943. $sortby = isset($sortby) ? $sortby : \'publishedon\';
  3944. $sortbyTV = isset($sortbyTV) ? $sortbyTV : \'\';
  3945. $sortbyAlias = isset($sortbyAlias) ? $sortbyAlias : \'modResource\';
  3946. $sortbyEscaped = !empty($sortbyEscaped) ? true : false;
  3947. $sortdir = isset($sortdir) ? $sortdir : \'DESC\';
  3948. $sortdirTV = isset($sortdirTV) ? $sortdirTV : \'DESC\';
  3949. $limit = isset($limit) ? (integer) $limit : 5;
  3950. $offset = isset($offset) ? (integer) $offset : 0;
  3951. $totalVar = !empty($totalVar) ? $totalVar : \'total\';
  3952. $dbCacheFlag = !isset($dbCacheFlag) ? false : $dbCacheFlag;
  3953. if (is_string($dbCacheFlag) || is_numeric($dbCacheFlag)) {
  3954. if ($dbCacheFlag == \'0\') {
  3955. $dbCacheFlag = false;
  3956. } elseif ($dbCacheFlag == \'1\') {
  3957. $dbCacheFlag = true;
  3958. } else {
  3959. $dbCacheFlag = (integer) $dbCacheFlag;
  3960. }
  3961. }
  3962. /* multiple context support */
  3963. $contextArray = array();
  3964. $contextSpecified = false;
  3965. if (!empty($context)) {
  3966. $contextArray = explode(\',\',$context);
  3967. array_walk($contextArray, \'trim\');
  3968. $contexts = array();
  3969. foreach ($contextArray as $ctx) {
  3970. $contexts[] = $modx->quote($ctx);
  3971. }
  3972. $context = implode(\',\',$contexts);
  3973. $contextSpecified = true;
  3974. unset($contexts,$ctx);
  3975. } else {
  3976. $context = $modx->quote($modx->context->get(\'key\'));
  3977. }
  3978. $pcMap = array();
  3979. $pcQuery = $modx->newQuery(\'modResource\', array(\'id:IN\' => $parents), $dbCacheFlag);
  3980. $pcQuery->select(array(\'id\', \'context_key\'));
  3981. if ($pcQuery->prepare() && $pcQuery->stmt->execute()) {
  3982. foreach ($pcQuery->stmt->fetchAll(PDO::FETCH_ASSOC) as $pcRow) {
  3983. $pcMap[(integer) $pcRow[\'id\']] = $pcRow[\'context_key\'];
  3984. }
  3985. }
  3986. $children = array();
  3987. $parentArray = array();
  3988. foreach ($parents as $parent) {
  3989. $parent = (integer) $parent;
  3990. if ($parent === 0) {
  3991. $pchildren = array();
  3992. if ($contextSpecified) {
  3993. foreach ($contextArray as $pCtx) {
  3994. if (!in_array($pCtx, $contextArray)) {
  3995. continue;
  3996. }
  3997. $options = $pCtx !== $modx->context->get(\'key\') ? array(\'context\' => $pCtx) : array();
  3998. $pcchildren = $modx->getChildIds($parent, $depth, $options);
  3999. if (!empty($pcchildren)) $pchildren = array_merge($pchildren, $pcchildren);
  4000. }
  4001. } else {
  4002. $cQuery = $modx->newQuery(\'modContext\', array(\'key:!=\' => \'mgr\'));
  4003. $cQuery->select(array(\'key\'));
  4004. if ($cQuery->prepare() && $cQuery->stmt->execute()) {
  4005. foreach ($cQuery->stmt->fetchAll(PDO::FETCH_COLUMN) as $pCtx) {
  4006. $options = $pCtx !== $modx->context->get(\'key\') ? array(\'context\' => $pCtx) : array();
  4007. $pcchildren = $modx->getChildIds($parent, $depth, $options);
  4008. if (!empty($pcchildren)) $pchildren = array_merge($pchildren, $pcchildren);
  4009. }
  4010. }
  4011. }
  4012. $parentArray[] = $parent;
  4013. } else {
  4014. $pContext = array_key_exists($parent, $pcMap) ? $pcMap[$parent] : false;
  4015. if ($debug) $modx->log(modX::LOG_LEVEL_ERROR, "context for {$parent} is {$pContext}");
  4016. if ($pContext && $contextSpecified && !in_array($pContext, $contextArray, true)) {
  4017. $parent = next($parents);
  4018. continue;
  4019. }
  4020. $parentArray[] = $parent;
  4021. $options = !empty($pContext) && $pContext !== $modx->context->get(\'key\') ? array(\'context\' => $pContext) : array();
  4022. $pchildren = $modx->getChildIds($parent, $depth, $options);
  4023. }
  4024. if (!empty($pchildren)) $children = array_merge($children, $pchildren);
  4025. $parent = next($parents);
  4026. }
  4027. $parents = array_merge($parentArray, $children);
  4028. /* build query */
  4029. $criteria = array("modResource.parent IN (" . implode(\',\', $parents) . ")");
  4030. if ($contextSpecified) {
  4031. $contextResourceTbl = $modx->getTableName(\'modContextResource\');
  4032. $criteria[] = "(modResource.context_key IN ({$context}) OR EXISTS(SELECT 1 FROM {$contextResourceTbl} ctx WHERE ctx.resource = modResource.id AND ctx.context_key IN ({$context})))";
  4033. }
  4034. if (empty($showDeleted)) {
  4035. $criteria[\'deleted\'] = \'0\';
  4036. }
  4037. if (empty($showUnpublished)) {
  4038. $criteria[\'published\'] = \'1\';
  4039. }
  4040. if (empty($showHidden)) {
  4041. $criteria[\'hidemenu\'] = \'0\';
  4042. }
  4043. if (!empty($hideContainers)) {
  4044. $criteria[\'isfolder\'] = \'0\';
  4045. }
  4046. $criteria = $modx->newQuery(\'modResource\', $criteria);
  4047. if (!empty($tvFilters)) {
  4048. $tmplVarTbl = $modx->getTableName(\'modTemplateVar\');
  4049. $tmplVarResourceTbl = $modx->getTableName(\'modTemplateVarResource\');
  4050. $conditions = array();
  4051. $operators = array(
  4052. \'<=>\' => \'<=>\',
  4053. \'===\' => \'=\',
  4054. \'!==\' => \'!=\',
  4055. \'<>\' => \'<>\',
  4056. \'==\' => \'LIKE\',
  4057. \'!=\' => \'NOT LIKE\',
  4058. \'<<\' => \'<\',
  4059. \'<=\' => \'<=\',
  4060. \'=<\' => \'=<\',
  4061. \'>>\' => \'>\',
  4062. \'>=\' => \'>=\',
  4063. \'=>\' => \'=>\'
  4064. );
  4065. foreach ($tvFilters as $fGroup => $tvFilter) {
  4066. $filterGroup = array();
  4067. $filters = explode($tvFiltersAndDelimiter, $tvFilter);
  4068. $multiple = count($filters) > 0;
  4069. foreach ($filters as $filter) {
  4070. $operator = \'==\';
  4071. $sqlOperator = \'LIKE\';
  4072. foreach ($operators as $op => $opSymbol) {
  4073. if (strpos($filter, $op, 1) !== false) {
  4074. $operator = $op;
  4075. $sqlOperator = $opSymbol;
  4076. break;
  4077. }
  4078. }
  4079. $tvValueField = \'tvr.value\';
  4080. $tvDefaultField = \'tv.default_text\';
  4081. $f = explode($operator, $filter);
  4082. if (count($f) >= 2) {
  4083. if (count($f) > 2) {
  4084. $k = array_shift($f);
  4085. $b = join($operator, $f);
  4086. $f = array($k, $b);
  4087. }
  4088. $tvName = $modx->quote($f[0]);
  4089. if (is_numeric($f[1]) && !in_array($sqlOperator, array(\'LIKE\', \'NOT LIKE\'))) {
  4090. $tvValue = $f[1];
  4091. if ($f[1] == (integer)$f[1]) {
  4092. $tvValueField = "CAST({$tvValueField} AS SIGNED INTEGER)";
  4093. $tvDefaultField = "CAST({$tvDefaultField} AS SIGNED INTEGER)";
  4094. } else {
  4095. $tvValueField = "CAST({$tvValueField} AS DECIMAL)";
  4096. $tvDefaultField = "CAST({$tvDefaultField} AS DECIMAL)";
  4097. }
  4098. } else {
  4099. $tvValue = $modx->quote($f[1]);
  4100. }
  4101. if ($multiple) {
  4102. $filterGroup[] =
  4103. "(EXISTS (SELECT 1 FROM {$tmplVarResourceTbl} tvr JOIN {$tmplVarTbl} tv ON {$tvValueField} {$sqlOperator} {$tvValue} AND tv.name = {$tvName} AND tv.id = tvr.tmplvarid WHERE tvr.contentid = modResource.id) " .
  4104. "OR EXISTS (SELECT 1 FROM {$tmplVarTbl} tv WHERE tv.name = {$tvName} AND {$tvDefaultField} {$sqlOperator} {$tvValue} AND tv.id NOT IN (SELECT tmplvarid FROM {$tmplVarResourceTbl} WHERE contentid = modResource.id)) " .
  4105. ")";
  4106. } else {
  4107. $filterGroup =
  4108. "(EXISTS (SELECT 1 FROM {$tmplVarResourceTbl} tvr JOIN {$tmplVarTbl} tv ON {$tvValueField} {$sqlOperator} {$tvValue} AND tv.name = {$tvName} AND tv.id = tvr.tmplvarid WHERE tvr.contentid = modResource.id) " .
  4109. "OR EXISTS (SELECT 1 FROM {$tmplVarTbl} tv WHERE tv.name = {$tvName} AND {$tvDefaultField} {$sqlOperator} {$tvValue} AND tv.id NOT IN (SELECT tmplvarid FROM {$tmplVarResourceTbl} WHERE contentid = modResource.id)) " .
  4110. ")";
  4111. }
  4112. } elseif (count($f) == 1) {
  4113. $tvValue = $modx->quote($f[0]);
  4114. if ($multiple) {
  4115. $filterGroup[] = "EXISTS (SELECT 1 FROM {$tmplVarResourceTbl} tvr JOIN {$tmplVarTbl} tv ON {$tvValueField} {$sqlOperator} {$tvValue} AND tv.id = tvr.tmplvarid WHERE tvr.contentid = modResource.id)";
  4116. } else {
  4117. $filterGroup = "EXISTS (SELECT 1 FROM {$tmplVarResourceTbl} tvr JOIN {$tmplVarTbl} tv ON {$tvValueField} {$sqlOperator} {$tvValue} AND tv.id = tvr.tmplvarid WHERE tvr.contentid = modResource.id)";
  4118. }
  4119. }
  4120. }
  4121. $conditions[] = $filterGroup;
  4122. }
  4123. if (!empty($conditions)) {
  4124. $firstGroup = true;
  4125. foreach ($conditions as $cGroup => $c) {
  4126. if (is_array($c)) {
  4127. $first = true;
  4128. foreach ($c as $cond) {
  4129. if ($first && !$firstGroup) {
  4130. $criteria->condition($criteria->query[\'where\'][0][1], $cond, xPDOQuery::SQL_OR, null, $cGroup);
  4131. } else {
  4132. $criteria->condition($criteria->query[\'where\'][0][1], $cond, xPDOQuery::SQL_AND, null, $cGroup);
  4133. }
  4134. $first = false;
  4135. }
  4136. } else {
  4137. $criteria->condition($criteria->query[\'where\'][0][1], $c, $firstGroup ? xPDOQuery::SQL_AND : xPDOQuery::SQL_OR, null, $cGroup);
  4138. }
  4139. $firstGroup = false;
  4140. }
  4141. }
  4142. }
  4143. /* include/exclude resources, via &resources=`123,-456` prop */
  4144. if (!empty($resources)) {
  4145. $resourceConditions = array();
  4146. $resources = explode(\',\',$resources);
  4147. $include = array();
  4148. $exclude = array();
  4149. foreach ($resources as $resource) {
  4150. $resource = (int)$resource;
  4151. if ($resource == 0) continue;
  4152. if ($resource < 0) {
  4153. $exclude[] = abs($resource);
  4154. } else {
  4155. $include[] = $resource;
  4156. }
  4157. }
  4158. if (!empty($include)) {
  4159. $criteria->where(array(\'OR:modResource.id:IN\' => $include), xPDOQuery::SQL_OR);
  4160. }
  4161. if (!empty($exclude)) {
  4162. $criteria->where(array(\'modResource.id:NOT IN\' => $exclude), xPDOQuery::SQL_AND, null, 1);
  4163. }
  4164. }
  4165. if (!empty($where)) {
  4166. $criteria->where($where);
  4167. }
  4168. $total = $modx->getCount(\'modResource\', $criteria);
  4169. $modx->setPlaceholder($totalVar, $total);
  4170. $fields = array_keys($modx->getFields(\'modResource\'));
  4171. if (empty($includeContent)) {
  4172. $fields = array_diff($fields, array(\'content\'));
  4173. }
  4174. $columns = $includeContent ? $modx->getSelectColumns(\'modResource\', \'modResource\') : $modx->getSelectColumns(\'modResource\', \'modResource\', \'\', array(\'content\'), true);
  4175. $criteria->select($columns);
  4176. if (!empty($sortbyTV)) {
  4177. $criteria->leftJoin(\'modTemplateVar\', \'tvDefault\', array(
  4178. "tvDefault.name" => $sortbyTV
  4179. ));
  4180. $criteria->leftJoin(\'modTemplateVarResource\', \'tvSort\', array(
  4181. "tvSort.contentid = modResource.id",
  4182. "tvSort.tmplvarid = tvDefault.id"
  4183. ));
  4184. if (empty($sortbyTVType)) $sortbyTVType = \'string\';
  4185. if ($modx->getOption(\'dbtype\') === \'mysql\') {
  4186. switch ($sortbyTVType) {
  4187. case \'integer\':
  4188. $criteria->select("CAST(IFNULL(tvSort.value, tvDefault.default_text) AS SIGNED INTEGER) AS sortTV");
  4189. break;
  4190. case \'decimal\':
  4191. $criteria->select("CAST(IFNULL(tvSort.value, tvDefault.default_text) AS DECIMAL) AS sortTV");
  4192. break;
  4193. case \'datetime\':
  4194. $criteria->select("CAST(IFNULL(tvSort.value, tvDefault.default_text) AS DATETIME) AS sortTV");
  4195. break;
  4196. case \'string\':
  4197. default:
  4198. $criteria->select("IFNULL(tvSort.value, tvDefault.default_text) AS sortTV");
  4199. break;
  4200. }
  4201. } elseif ($modx->getOption(\'dbtype\') === \'sqlsrv\') {
  4202. switch ($sortbyTVType) {
  4203. case \'integer\':
  4204. $criteria->select("CAST(ISNULL(tvSort.value, tvDefault.default_text) AS BIGINT) AS sortTV");
  4205. break;
  4206. case \'decimal\':
  4207. $criteria->select("CAST(ISNULL(tvSort.value, tvDefault.default_text) AS DECIMAL) AS sortTV");
  4208. break;
  4209. case \'datetime\':
  4210. $criteria->select("CAST(ISNULL(tvSort.value, tvDefault.default_text) AS DATETIME) AS sortTV");
  4211. break;
  4212. case \'string\':
  4213. default:
  4214. $criteria->select("ISNULL(tvSort.value, tvDefault.default_text) AS sortTV");
  4215. break;
  4216. }
  4217. }
  4218. $criteria->sortby("sortTV", $sortdirTV);
  4219. }
  4220. if (!empty($sortby)) {
  4221. if (strpos($sortby, \'{\') === 0) {
  4222. $sorts = $modx->fromJSON($sortby);
  4223. } else {
  4224. $sorts = array($sortby => $sortdir);
  4225. }
  4226. if (is_array($sorts)) {
  4227. while (list($sort, $dir) = each($sorts)) {
  4228. if ($sortbyEscaped) $sort = $modx->escape($sort);
  4229. if (!empty($sortbyAlias)) $sort = $modx->escape($sortbyAlias) . ".{$sort}";
  4230. $criteria->sortby($sort, $dir);
  4231. }
  4232. }
  4233. }
  4234. if (!empty($limit)) $criteria->limit($limit, $offset);
  4235. if (!empty($debug)) {
  4236. $criteria->prepare();
  4237. $modx->log(modX::LOG_LEVEL_ERROR, $criteria->toSQL());
  4238. }
  4239. $collection = $modx->getCollection(\'modResource\', $criteria, $dbCacheFlag);
  4240. $idx = !empty($idx) || $idx === \'0\' ? (integer) $idx : 1;
  4241. $first = empty($first) && $first !== \'0\' ? 1 : (integer) $first;
  4242. $last = empty($last) ? (count($collection) + $idx - 1) : (integer) $last;
  4243. /* include parseTpl */
  4244. include_once $modx->getOption(\'getresources.core_path\',null,$modx->getOption(\'core_path\').\'components/getresources/\').\'include.parsetpl.php\';
  4245. $templateVars = array();
  4246. if (!empty($includeTVs) && !empty($includeTVList)) {
  4247. $templateVars = $modx->getCollection(\'modTemplateVar\', array(\'name:IN\' => $includeTVList));
  4248. }
  4249. /** @var modResource $resource */
  4250. foreach ($collection as $resourceId => $resource) {
  4251. $tvs = array();
  4252. if (!empty($includeTVs)) {
  4253. if (empty($includeTVList)) {
  4254. $templateVars = $resource->getMany(\'TemplateVars\');
  4255. }
  4256. /** @var modTemplateVar $templateVar */
  4257. foreach ($templateVars as $tvId => $templateVar) {
  4258. if (!empty($includeTVList) && !in_array($templateVar->get(\'name\'), $includeTVList)) continue;
  4259. if ($processTVs && (empty($processTVList) || in_array($templateVar->get(\'name\'), $processTVList))) {
  4260. $tvs[$tvPrefix . $templateVar->get(\'name\')] = $templateVar->renderOutput($resource->get(\'id\'));
  4261. } else {
  4262. $value = $templateVar->getValue($resource->get(\'id\'));
  4263. if ($prepareTVs && method_exists($templateVar, \'prepareOutput\') && (empty($prepareTVList) || in_array($templateVar->get(\'name\'), $prepareTVList))) {
  4264. $value = $templateVar->prepareOutput($value);
  4265. }
  4266. $tvs[$tvPrefix . $templateVar->get(\'name\')] = $value;
  4267. }
  4268. }
  4269. }
  4270. $odd = ($idx & 1);
  4271. $properties = array_merge(
  4272. $scriptProperties
  4273. ,array(
  4274. \'idx\' => $idx
  4275. ,\'first\' => $first
  4276. ,\'last\' => $last
  4277. ,\'odd\' => $odd
  4278. )
  4279. ,$includeContent ? $resource->toArray() : $resource->get($fields)
  4280. ,$tvs
  4281. );
  4282. $resourceTpl = false;
  4283. if ($idx == $first && !empty($tplFirst)) {
  4284. $resourceTpl = parseTpl($tplFirst, $properties);
  4285. }
  4286. if ($idx == $last && empty($resourceTpl) && !empty($tplLast)) {
  4287. $resourceTpl = parseTpl($tplLast, $properties);
  4288. }
  4289. $tplidx = \'tpl_\' . $idx;
  4290. if (empty($resourceTpl) && !empty($$tplidx)) {
  4291. $resourceTpl = parseTpl($$tplidx, $properties);
  4292. }
  4293. if ($idx > 1 && empty($resourceTpl)) {
  4294. $divisors = getDivisors($idx);
  4295. if (!empty($divisors)) {
  4296. foreach ($divisors as $divisor) {
  4297. $tplnth = \'tpl_n\' . $divisor;
  4298. if (!empty($$tplnth)) {
  4299. $resourceTpl = parseTpl($$tplnth, $properties);
  4300. if (!empty($resourceTpl)) {
  4301. break;
  4302. }
  4303. }
  4304. }
  4305. }
  4306. }
  4307. if ($odd && empty($resourceTpl) && !empty($tplOdd)) {
  4308. $resourceTpl = parseTpl($tplOdd, $properties);
  4309. }
  4310. if (!empty($tplCondition) && !empty($conditionalTpls) && empty($resourceTpl)) {
  4311. $conTpls = $modx->fromJSON($conditionalTpls);
  4312. $subject = $properties[$tplCondition];
  4313. $tplOperator = !empty($tplOperator) ? $tplOperator : \'=\';
  4314. $tplOperator = strtolower($tplOperator);
  4315. $tplCon = \'\';
  4316. foreach ($conTpls as $operand => $conditionalTpl) {
  4317. switch ($tplOperator) {
  4318. case \'!=\':
  4319. case \'neq\':
  4320. case \'not\':
  4321. case \'isnot\':
  4322. case \'isnt\':
  4323. case \'unequal\':
  4324. case \'notequal\':
  4325. $tplCon = (($subject != $operand) ? $conditionalTpl : $tplCon);
  4326. break;
  4327. case \'<\':
  4328. case \'lt\':
  4329. case \'less\':
  4330. case \'lessthan\':
  4331. $tplCon = (($subject < $operand) ? $conditionalTpl : $tplCon);
  4332. break;
  4333. case \'>\':
  4334. case \'gt\':
  4335. case \'greater\':
  4336. case \'greaterthan\':
  4337. $tplCon = (($subject > $operand) ? $conditionalTpl : $tplCon);
  4338. break;
  4339. case \'<=\':
  4340. case \'lte\':
  4341. case \'lessthanequals\':
  4342. case \'lessthanorequalto\':
  4343. $tplCon = (($subject <= $operand) ? $conditionalTpl : $tplCon);
  4344. break;
  4345. case \'>=\':
  4346. case \'gte\':
  4347. case \'greaterthanequals\':
  4348. case \'greaterthanequalto\':
  4349. $tplCon = (($subject >= $operand) ? $conditionalTpl : $tplCon);
  4350. break;
  4351. case \'isempty\':
  4352. case \'empty\':
  4353. $tplCon = empty($subject) ? $conditionalTpl : $tplCon;
  4354. break;
  4355. case \'!empty\':
  4356. case \'notempty\':
  4357. case \'isnotempty\':
  4358. $tplCon = !empty($subject) && $subject != \'\' ? $conditionalTpl : $tplCon;
  4359. break;
  4360. case \'isnull\':
  4361. case \'null\':
  4362. $tplCon = $subject == null || strtolower($subject) == \'null\' ? $conditionalTpl : $tplCon;
  4363. break;
  4364. case \'inarray\':
  4365. case \'in_array\':
  4366. case \'ia\':
  4367. $operand = explode(\',\', $operand);
  4368. $tplCon = in_array($subject, $operand) ? $conditionalTpl : $tplCon;
  4369. break;
  4370. case \'between\':
  4371. case \'range\':
  4372. case \'>=<\':
  4373. case \'><\':
  4374. $operand = explode(\',\', $operand);
  4375. $tplCon = ($subject >= min($operand) && $subject <= max($operand)) ? $conditionalTpl : $tplCon;
  4376. break;
  4377. case \'==\':
  4378. case \'=\':
  4379. case \'eq\':
  4380. case \'is\':
  4381. case \'equal\':
  4382. case \'equals\':
  4383. case \'equalto\':
  4384. default:
  4385. $tplCon = (($subject == $operand) ? $conditionalTpl : $tplCon);
  4386. break;
  4387. }
  4388. }
  4389. if (!empty($tplCon)) {
  4390. $resourceTpl = parseTpl($tplCon, $properties);
  4391. }
  4392. }
  4393. if (!empty($tpl) && empty($resourceTpl)) {
  4394. $resourceTpl = parseTpl($tpl, $properties);
  4395. }
  4396. if ($resourceTpl === false && !empty($debug)) {
  4397. $chunk = $modx->newObject(\'modChunk\');
  4398. $chunk->setCacheable(false);
  4399. $output[]= $chunk->process(array(), \'<pre>\' . print_r($properties, true) .\'</pre>\');
  4400. } else {
  4401. $output[]= $resourceTpl;
  4402. }
  4403. $idx++;
  4404. }
  4405. /* output */
  4406. $toSeparatePlaceholders = $modx->getOption(\'toSeparatePlaceholders\', $scriptProperties, false);
  4407. if (!empty($toSeparatePlaceholders)) {
  4408. $modx->setPlaceholders($output, $toSeparatePlaceholders);
  4409. return \'\';
  4410. }
  4411. $output = implode($outputSeparator, $output);
  4412. $tplWrapper = $modx->getOption(\'tplWrapper\', $scriptProperties, false);
  4413. $wrapIfEmpty = $modx->getOption(\'wrapIfEmpty\', $scriptProperties, false);
  4414. if (!empty($tplWrapper) && ($wrapIfEmpty || !empty($output))) {
  4415. $output = parseTpl($tplWrapper, array_merge($scriptProperties, array(\'output\' => $output)));
  4416. }
  4417. $toPlaceholder = $modx->getOption(\'toPlaceholder\', $scriptProperties, false);
  4418. if (!empty($toPlaceholder)) {
  4419. $modx->setPlaceholder($toPlaceholder, $output);
  4420. return \'\';
  4421. }
  4422. return $output;',
  4423. ),
  4424. 'policies' =>
  4425. array (
  4426. 'web' =>
  4427. array (
  4428. ),
  4429. ),
  4430. 'source' =>
  4431. array (
  4432. ),
  4433. ),
  4434. 'TaggerGetResourcesWhere' =>
  4435. array (
  4436. 'fields' =>
  4437. array (
  4438. 'id' => 100,
  4439. 'source' => 0,
  4440. 'property_preprocess' => false,
  4441. 'name' => 'TaggerGetResourcesWhere',
  4442. 'description' => '',
  4443. 'editor_type' => 0,
  4444. 'category' => 35,
  4445. 'cache_type' => 0,
  4446. 'snippet' => '/**
  4447. * TaggerGetResourcesWhere
  4448. *
  4449. * DESCRIPTION
  4450. *
  4451. * This snippet generate SQL Query that can be used in WHERE condition in getResources snippet
  4452. *
  4453. * PROPERTIES:
  4454. *
  4455. * &tags string optional Comma separated list of Tags for which will be generated a Resource query. By default Tags from GET param will be loaded
  4456. * &groups string optional Comma separated list of Tagger Groups. Only from those groups will Tags be allowed
  4457. * &where string optional Original getResources where property. If you used where property in your current getResources call, move it here
  4458. * &likeComparison int optional If set to 1, tags will compare using LIKE
  4459. * &tagField string optional Field that will be used to compare with given tags. Default: alias
  4460. * &matchAll int optional If set to 1, resource must have all specified tags. Default: 0
  4461. * &field string optional modResource field that will be used to compare with assigned resource ID
  4462. *
  4463. * USAGE:
  4464. *
  4465. * [[!getResources? &where=`[[!TaggerGetResourcesWhere? &tags=`Books,Vehicles` &where=`{"isfolder": 0}`]]`]]
  4466. *
  4467. */
  4468. $tagger = $modx->getService(\'tagger\',\'Tagger\',$modx->getOption(\'tagger.core_path\',null,$modx->getOption(\'core_path\').\'components/tagger/\').\'model/tagger/\',$scriptProperties);
  4469. if (!($tagger instanceof Tagger)) return \'\';
  4470. $tags = $modx->getOption(\'tags\', $scriptProperties, \'\');
  4471. $where = $modx->getOption(\'where\', $scriptProperties, \'\');
  4472. $tagField = $modx->getOption(\'tagField\', $scriptProperties, \'alias\');
  4473. $likeComparison = (int) $modx->getOption(\'likeComparison\', $scriptProperties, 0);
  4474. $matchAll = (int) $modx->getOption(\'matchAll\', $scriptProperties, 0);
  4475. $field = $modx->getOption(\'field\', $scriptProperties, \'id\');
  4476. $where = $modx->fromJSON($where);
  4477. if ($where == false) {
  4478. $where = array();
  4479. }
  4480. $tagsCount = 0;
  4481. if ($tags == \'\') {
  4482. $gc = $modx->newQuery(\'TaggerGroup\');
  4483. $gc->select($modx->getSelectColumns(\'TaggerGroup\', \'\', \'\', array(\'alias\')));
  4484. $groups = $modx->getOption(\'groups\', $scriptProperties, \'\');
  4485. $groups = $tagger->explodeAndClean($groups);
  4486. if (!empty($groups)) {
  4487. $gc->where(array(
  4488. \'name:IN\' => $groups,
  4489. \'OR:alias:IN\' => $groups,
  4490. \'OR:id:IN\' => $groups,
  4491. ));
  4492. }
  4493. $gc->prepare();
  4494. $gc->stmt->execute();
  4495. $groups = $gc->stmt->fetchAll(PDO::FETCH_COLUMN, 0);
  4496. $conditions = array();
  4497. foreach ($groups as $group) {
  4498. if (isset($_GET[$group])) {
  4499. $groupTags = $tagger->explodeAndClean($_GET[$group]);
  4500. if (!empty($groupTags)) {
  4501. $like = array(\'AND:alias:IN\' => $groupTags);
  4502. if ($likeComparison == 1) {
  4503. foreach ($groupTags as $tag) {
  4504. $like[] = array(\'OR:alias:LIKE\' => \'%\' . $tag . \'%\');
  4505. }
  4506. }
  4507. $conditions[] = array(
  4508. \'OR:Group.alias:=\' => $group,
  4509. $like
  4510. );
  4511. $tagsCount += count($groupTags);
  4512. }
  4513. }
  4514. }
  4515. if (count($conditions) == 0) {
  4516. return $modx->toJSON($where);
  4517. }
  4518. $c = $modx->newQuery(\'TaggerTag\');
  4519. $c->leftJoin(\'TaggerGroup\', \'Group\');
  4520. $c->where($conditions);
  4521. } else {
  4522. $tags = $tagger->explodeAndClean($tags);
  4523. if (empty($tags)) {
  4524. return $modx->toJSON($where);
  4525. }
  4526. $tagsCount = count($tags);
  4527. $groups = $modx->getOption(\'groups\', $scriptProperties, \'\');
  4528. $groups = $tagger->explodeAndClean($groups);
  4529. $c = $modx->newQuery(\'TaggerTag\');
  4530. $c->select($modx->getSelectColumns(\'TaggerTag\', \'TaggerTag\', \'\', array(\'id\')));
  4531. $compare = array(
  4532. $tagField . \':IN\' => $tags
  4533. );
  4534. if ($likeComparison == 1) {
  4535. foreach ($tags as $tag) {
  4536. $compare[] = array(\'OR:\' . $tagField . \':LIKE\' => \'%\' . $tag . \'%\');
  4537. }
  4538. }
  4539. $c->where($compare);
  4540. if (!empty($groups)) {
  4541. $c->leftJoin(\'TaggerGroup\', \'Group\');
  4542. $c->where(array(
  4543. \'Group.id:IN\' => $groups,
  4544. \'OR:Group.name:IN\' => $groups,
  4545. \'OR:Group.alias:IN\' => $groups,
  4546. ));
  4547. }
  4548. }
  4549. $c->prepare();
  4550. $c->stmt->execute();
  4551. $tagIDs = $c->stmt->fetchAll(PDO::FETCH_COLUMN, 0);
  4552. if (count($tagIDs) == 0) {
  4553. $tagIDs[] = 0;
  4554. }
  4555. if ($matchAll == 0) {
  4556. $where[] = "EXISTS (SELECT 1 FROM {$modx->getTableName(\'TaggerTagResource\')} r WHERE r.tag IN (" . implode(\',\', $tagIDs) . ") AND r.resource = modResource." . $field . ")";
  4557. } else {
  4558. $where[] = "EXISTS (SELECT 1 as found FROM {$modx->getTableName(\'TaggerTagResource\')} r WHERE r.tag IN (" . implode(\',\', $tagIDs) . ") AND r.resource = modResource." . $field . " GROUP BY found HAVING count(found) = " . $tagsCount . ")";
  4559. }
  4560. return $modx->toJSON($where);',
  4561. 'locked' => false,
  4562. 'properties' =>
  4563. array (
  4564. 'tags' =>
  4565. array (
  4566. 'name' => 'tags',
  4567. 'desc' => 'tagger.getresourceswhere.tags_desc',
  4568. 'type' => 'textfield',
  4569. 'options' => '',
  4570. 'value' => '',
  4571. 'lexicon' => 'tagger:properties',
  4572. 'area' => '',
  4573. 'desc_trans' => 'Comma separated list of Tags for which will be generated a Resource query. By default Tags from GET param will be loaded',
  4574. 'area_trans' => '',
  4575. ),
  4576. 'groups' =>
  4577. array (
  4578. 'name' => 'groups',
  4579. 'desc' => 'tagger.getresourceswhere.groups_desc',
  4580. 'type' => 'textfield',
  4581. 'options' => '',
  4582. 'value' => '',
  4583. 'lexicon' => 'tagger:properties',
  4584. 'area' => '',
  4585. 'desc_trans' => 'Comma separated list of Tagger Groups. Only from those groups will Tags be allowed',
  4586. 'area_trans' => '',
  4587. ),
  4588. 'where' =>
  4589. array (
  4590. 'name' => 'where',
  4591. 'desc' => 'tagger.getresourceswhere.where_desc',
  4592. 'type' => 'textfield',
  4593. 'options' => '',
  4594. 'value' => '',
  4595. 'lexicon' => 'tagger:properties',
  4596. 'area' => '',
  4597. 'desc_trans' => 'Original getResources where property. If you used where property in your current getResources call, move it here',
  4598. 'area_trans' => '',
  4599. ),
  4600. 'likeComparison' =>
  4601. array (
  4602. 'name' => 'likeComparison',
  4603. 'desc' => 'tagger.getresourceswhere.likeComparison_desc',
  4604. 'type' => 'numberfield',
  4605. 'options' => '',
  4606. 'value' => '0',
  4607. 'lexicon' => 'tagger:properties',
  4608. 'area' => '',
  4609. 'desc_trans' => 'If set to 1, tags will compare using LIKE',
  4610. 'area_trans' => '',
  4611. ),
  4612. 'tagField' =>
  4613. array (
  4614. 'name' => 'tagField',
  4615. 'desc' => 'tagger.getresourceswhere.tagField_desc',
  4616. 'type' => 'textfield',
  4617. 'options' => '',
  4618. 'value' => 'alias',
  4619. 'lexicon' => 'tagger:properties',
  4620. 'area' => '',
  4621. 'desc_trans' => 'Field that will be used to compare with given tags. Default: alias',
  4622. 'area_trans' => '',
  4623. ),
  4624. 'matchAll' =>
  4625. array (
  4626. 'name' => 'matchAll',
  4627. 'desc' => 'tagger.getresourceswhere.matchAll_desc',
  4628. 'type' => 'numberfield',
  4629. 'options' => '',
  4630. 'value' => '0',
  4631. 'lexicon' => 'tagger:properties',
  4632. 'area' => '',
  4633. 'desc_trans' => 'If set to 1, resource must have all specified tags. Default: 0',
  4634. 'area_trans' => '',
  4635. ),
  4636. ),
  4637. 'moduleguid' => '',
  4638. 'static' => false,
  4639. 'static_file' => '',
  4640. 'content' => '/**
  4641. * TaggerGetResourcesWhere
  4642. *
  4643. * DESCRIPTION
  4644. *
  4645. * This snippet generate SQL Query that can be used in WHERE condition in getResources snippet
  4646. *
  4647. * PROPERTIES:
  4648. *
  4649. * &tags string optional Comma separated list of Tags for which will be generated a Resource query. By default Tags from GET param will be loaded
  4650. * &groups string optional Comma separated list of Tagger Groups. Only from those groups will Tags be allowed
  4651. * &where string optional Original getResources where property. If you used where property in your current getResources call, move it here
  4652. * &likeComparison int optional If set to 1, tags will compare using LIKE
  4653. * &tagField string optional Field that will be used to compare with given tags. Default: alias
  4654. * &matchAll int optional If set to 1, resource must have all specified tags. Default: 0
  4655. * &field string optional modResource field that will be used to compare with assigned resource ID
  4656. *
  4657. * USAGE:
  4658. *
  4659. * [[!getResources? &where=`[[!TaggerGetResourcesWhere? &tags=`Books,Vehicles` &where=`{"isfolder": 0}`]]`]]
  4660. *
  4661. */
  4662. $tagger = $modx->getService(\'tagger\',\'Tagger\',$modx->getOption(\'tagger.core_path\',null,$modx->getOption(\'core_path\').\'components/tagger/\').\'model/tagger/\',$scriptProperties);
  4663. if (!($tagger instanceof Tagger)) return \'\';
  4664. $tags = $modx->getOption(\'tags\', $scriptProperties, \'\');
  4665. $where = $modx->getOption(\'where\', $scriptProperties, \'\');
  4666. $tagField = $modx->getOption(\'tagField\', $scriptProperties, \'alias\');
  4667. $likeComparison = (int) $modx->getOption(\'likeComparison\', $scriptProperties, 0);
  4668. $matchAll = (int) $modx->getOption(\'matchAll\', $scriptProperties, 0);
  4669. $field = $modx->getOption(\'field\', $scriptProperties, \'id\');
  4670. $where = $modx->fromJSON($where);
  4671. if ($where == false) {
  4672. $where = array();
  4673. }
  4674. $tagsCount = 0;
  4675. if ($tags == \'\') {
  4676. $gc = $modx->newQuery(\'TaggerGroup\');
  4677. $gc->select($modx->getSelectColumns(\'TaggerGroup\', \'\', \'\', array(\'alias\')));
  4678. $groups = $modx->getOption(\'groups\', $scriptProperties, \'\');
  4679. $groups = $tagger->explodeAndClean($groups);
  4680. if (!empty($groups)) {
  4681. $gc->where(array(
  4682. \'name:IN\' => $groups,
  4683. \'OR:alias:IN\' => $groups,
  4684. \'OR:id:IN\' => $groups,
  4685. ));
  4686. }
  4687. $gc->prepare();
  4688. $gc->stmt->execute();
  4689. $groups = $gc->stmt->fetchAll(PDO::FETCH_COLUMN, 0);
  4690. $conditions = array();
  4691. foreach ($groups as $group) {
  4692. if (isset($_GET[$group])) {
  4693. $groupTags = $tagger->explodeAndClean($_GET[$group]);
  4694. if (!empty($groupTags)) {
  4695. $like = array(\'AND:alias:IN\' => $groupTags);
  4696. if ($likeComparison == 1) {
  4697. foreach ($groupTags as $tag) {
  4698. $like[] = array(\'OR:alias:LIKE\' => \'%\' . $tag . \'%\');
  4699. }
  4700. }
  4701. $conditions[] = array(
  4702. \'OR:Group.alias:=\' => $group,
  4703. $like
  4704. );
  4705. $tagsCount += count($groupTags);
  4706. }
  4707. }
  4708. }
  4709. if (count($conditions) == 0) {
  4710. return $modx->toJSON($where);
  4711. }
  4712. $c = $modx->newQuery(\'TaggerTag\');
  4713. $c->leftJoin(\'TaggerGroup\', \'Group\');
  4714. $c->where($conditions);
  4715. } else {
  4716. $tags = $tagger->explodeAndClean($tags);
  4717. if (empty($tags)) {
  4718. return $modx->toJSON($where);
  4719. }
  4720. $tagsCount = count($tags);
  4721. $groups = $modx->getOption(\'groups\', $scriptProperties, \'\');
  4722. $groups = $tagger->explodeAndClean($groups);
  4723. $c = $modx->newQuery(\'TaggerTag\');
  4724. $c->select($modx->getSelectColumns(\'TaggerTag\', \'TaggerTag\', \'\', array(\'id\')));
  4725. $compare = array(
  4726. $tagField . \':IN\' => $tags
  4727. );
  4728. if ($likeComparison == 1) {
  4729. foreach ($tags as $tag) {
  4730. $compare[] = array(\'OR:\' . $tagField . \':LIKE\' => \'%\' . $tag . \'%\');
  4731. }
  4732. }
  4733. $c->where($compare);
  4734. if (!empty($groups)) {
  4735. $c->leftJoin(\'TaggerGroup\', \'Group\');
  4736. $c->where(array(
  4737. \'Group.id:IN\' => $groups,
  4738. \'OR:Group.name:IN\' => $groups,
  4739. \'OR:Group.alias:IN\' => $groups,
  4740. ));
  4741. }
  4742. }
  4743. $c->prepare();
  4744. $c->stmt->execute();
  4745. $tagIDs = $c->stmt->fetchAll(PDO::FETCH_COLUMN, 0);
  4746. if (count($tagIDs) == 0) {
  4747. $tagIDs[] = 0;
  4748. }
  4749. if ($matchAll == 0) {
  4750. $where[] = "EXISTS (SELECT 1 FROM {$modx->getTableName(\'TaggerTagResource\')} r WHERE r.tag IN (" . implode(\',\', $tagIDs) . ") AND r.resource = modResource." . $field . ")";
  4751. } else {
  4752. $where[] = "EXISTS (SELECT 1 as found FROM {$modx->getTableName(\'TaggerTagResource\')} r WHERE r.tag IN (" . implode(\',\', $tagIDs) . ") AND r.resource = modResource." . $field . " GROUP BY found HAVING count(found) = " . $tagsCount . ")";
  4753. }
  4754. return $modx->toJSON($where);',
  4755. ),
  4756. 'policies' =>
  4757. array (
  4758. 'web' =>
  4759. array (
  4760. ),
  4761. ),
  4762. 'source' =>
  4763. array (
  4764. ),
  4765. ),
  4766. 'getPage' =>
  4767. array (
  4768. 'fields' =>
  4769. array (
  4770. 'id' => 109,
  4771. 'source' => 0,
  4772. 'property_preprocess' => false,
  4773. 'name' => 'getPage',
  4774. 'description' => '<b>1.2.4-pl</b> A generic wrapper snippet for returning paged results and navigation from snippets that return limitable collections.',
  4775. 'editor_type' => 0,
  4776. 'category' => 0,
  4777. 'cache_type' => 0,
  4778. 'snippet' => '/**
  4779. * @package getpage
  4780. */
  4781. $output = \'\';
  4782. $properties =& $scriptProperties;
  4783. $properties[\'page\'] = (isset($_GET[$properties[\'pageVarKey\']]) && ($page = intval($_GET[$properties[\'pageVarKey\']]))) ? $page : null;
  4784. if ($properties[\'page\'] === null) {
  4785. $properties[\'page\'] = (isset($_REQUEST[$properties[\'pageVarKey\']]) && ($page = intval($_REQUEST[$properties[\'pageVarKey\']]))) ? $page : 1;
  4786. }
  4787. $properties[\'limit\'] = (isset($_GET[\'limit\'])) ? intval($_GET[\'limit\']) : null;
  4788. if ($properties[\'limit\'] === null) {
  4789. $properties[\'limit\'] = (isset($_REQUEST[\'limit\'])) ? intval($_REQUEST[\'limit\']) : intval($limit);
  4790. }
  4791. $properties[\'offset\'] = (!empty($properties[\'limit\']) && !empty($properties[\'page\'])) ? ($properties[\'limit\'] * ($properties[\'page\'] - 1)) : 0;
  4792. $properties[\'totalVar\'] = empty($totalVar) ? "total" : $totalVar;
  4793. $properties[$properties[\'totalVar\']] = !empty($properties[$properties[\'totalVar\']]) && $total = intval($properties[$properties[\'totalVar\']]) ? $total : 0;
  4794. $properties[\'pageOneLimit\'] = (!empty($pageOneLimit) && $pageOneLimit = intval($pageOneLimit)) ? $pageOneLimit : $properties[\'limit\'];
  4795. $properties[\'actualLimit\'] = $properties[\'limit\'];
  4796. $properties[\'pageLimit\'] = isset($pageLimit) && is_numeric($pageLimit) ? intval($pageLimit) : 5;
  4797. $properties[\'element\'] = empty($element) ? \'\' : $element;
  4798. $properties[\'elementClass\'] = empty($elementClass) ? \'modChunk\' : $elementClass;
  4799. $properties[\'pageNavVar\'] = empty($pageNavVar) ? \'page.nav\' : $pageNavVar;
  4800. $properties[\'pageNavTpl\'] = !isset($pageNavTpl) ? "<li[[+classes]]><a[[+classes]][[+title]] href=\\"[[+href]]\\">[[+pageNo]]</a></li>" : $pageNavTpl;
  4801. $properties[\'pageNavOuterTpl\'] = !isset($pageNavOuterTpl) ? "[[+first]][[+prev]][[+pages]][[+next]][[+last]]" : $pageNavOuterTpl;
  4802. $properties[\'pageActiveTpl\'] = !isset($pageActiveTpl) ? "<li[[+activeClasses:default=` class=\\"active\\"`]]><a[[+activeClasses:default=` class=\\"active\\"`]][[+title]] href=\\"[[+href]]\\">[[+pageNo]]</a></li>" : $pageActiveTpl;
  4803. $properties[\'pageFirstTpl\'] = !isset($pageFirstTpl) ? "<li class=\\"control\\"><a[[+title]] href=\\"[[+href]]\\">First</a></li>" : $pageFirstTpl;
  4804. $properties[\'pageLastTpl\'] = !isset($pageLastTpl) ? "<li class=\\"control\\"><a[[+title]] href=\\"[[+href]]\\">Last</a></li>" : $pageLastTpl;
  4805. $properties[\'pagePrevTpl\'] = !isset($pagePrevTpl) ? "<li class=\\"control\\"><a[[+title]] href=\\"[[+href]]\\">&lt;&lt;</a></li>" : $pagePrevTpl;
  4806. $properties[\'pageNextTpl\'] = !isset($pageNextTpl) ? "<li class=\\"control\\"><a[[+title]] href=\\"[[+href]]\\">&gt;&gt;</a></li>" : $pageNextTpl;
  4807. $properties[\'toPlaceholder\'] = !empty($toPlaceholder) ? $toPlaceholder : \'\';
  4808. $properties[\'cache\'] = isset($cache) ? (boolean) $cache : (boolean) $modx->getOption(\'cache_resource\', null, false);
  4809. if (empty($cache_key)) $properties[xPDO::OPT_CACHE_KEY] = $modx->getOption(\'cache_resource_key\', null, \'resource\');
  4810. if (empty($cache_handler)) $properties[xPDO::OPT_CACHE_HANDLER] = $modx->getOption(\'cache_resource_handler\', null, \'xPDOFileCache\');
  4811. if (empty($cache_expires)) $properties[xPDO::OPT_CACHE_EXPIRES] = (integer) $modx->getOption(\'cache_resource_expires\', null, 0);
  4812. if ($properties[\'page\'] == 1 && $properties[\'pageOneLimit\'] !== $properties[\'actualLimit\']) {
  4813. $properties[\'limit\'] = $properties[\'pageOneLimit\'];
  4814. }
  4815. if ($properties[\'cache\']) {
  4816. $properties[\'cachePageKey\'] = $modx->resource->getCacheKey() . \'/\' . $properties[\'page\'] . \'/\' . md5(http_build_query($modx->request->getParameters()) . http_build_query($scriptProperties));
  4817. $properties[\'cacheOptions\'] = array(
  4818. xPDO::OPT_CACHE_KEY => $properties[xPDO::OPT_CACHE_KEY],
  4819. xPDO::OPT_CACHE_HANDLER => $properties[xPDO::OPT_CACHE_HANDLER],
  4820. xPDO::OPT_CACHE_EXPIRES => $properties[xPDO::OPT_CACHE_EXPIRES],
  4821. );
  4822. }
  4823. $cached = false;
  4824. if ($properties[\'cache\']) {
  4825. if ($modx->getCacheManager()) {
  4826. $cached = $modx->cacheManager->get($properties[\'cachePageKey\'], $properties[\'cacheOptions\']);
  4827. }
  4828. }
  4829. if (empty($cached) || !isset($cached[\'properties\']) || !isset($cached[\'output\'])) {
  4830. $elementObj = $modx->getObject($properties[\'elementClass\'], array(\'name\' => $properties[\'element\']));
  4831. if ($elementObj) {
  4832. $elementObj->setCacheable(false);
  4833. if (!empty($properties[\'toPlaceholder\'])) {
  4834. $elementObj->process($properties);
  4835. $output = $modx->getPlaceholder($properties[\'toPlaceholder\']);
  4836. } else {
  4837. $output = $elementObj->process($properties);
  4838. }
  4839. }
  4840. include_once $modx->getOption(\'getpage.core_path\',$properties,$modx->getOption(\'core_path\', $properties, MODX_CORE_PATH) . \'components/getpage/\').\'include.getpage.php\';
  4841. $qs = $modx->request->getParameters();
  4842. $properties[\'qs\'] =& $qs;
  4843. $totalSet = $modx->getPlaceholder($properties[\'totalVar\']);
  4844. $properties[$properties[\'totalVar\']] = (($totalSet = intval($totalSet)) ? $totalSet : $properties[$properties[\'totalVar\']]);
  4845. if (!empty($properties[$properties[\'totalVar\']]) && !empty($properties[\'actualLimit\'])) {
  4846. if ($properties[\'pageOneLimit\'] !== $properties[\'actualLimit\']) {
  4847. $adjustedTotal = $properties[$properties[\'totalVar\']] - $properties[\'pageOneLimit\'];
  4848. $properties[\'pageCount\'] = $adjustedTotal > 0 ? ceil($adjustedTotal / $properties[\'actualLimit\']) + 1 : 1;
  4849. } else {
  4850. $properties[\'pageCount\'] = ceil($properties[$properties[\'totalVar\']] / $properties[\'actualLimit\']);
  4851. }
  4852. } else {
  4853. $properties[\'pageCount\'] = 1;
  4854. }
  4855. if (empty($properties[$properties[\'totalVar\']]) || empty($properties[\'actualLimit\']) || $properties[$properties[\'totalVar\']] <= $properties[\'actualLimit\'] || ($properties[\'page\'] == 1 && $properties[$properties[\'totalVar\']] <= $properties[\'pageOneLimit\'])) {
  4856. $properties[\'page\'] = 1;
  4857. } else {
  4858. $pageNav = getpage_buildControls($modx, $properties);
  4859. $properties[$properties[\'pageNavVar\']] = $modx->newObject(\'modChunk\')->process(array_merge($properties, $pageNav), $properties[\'pageNavOuterTpl\']);
  4860. if ($properties[\'page\'] > 1) {
  4861. $qs[$properties[\'pageVarKey\']] = $properties[\'page\'];
  4862. }
  4863. }
  4864. $properties[\'firstItem\'] = $properties[\'offset\'] + 1;
  4865. $properties[\'lastItem\'] = ($properties[\'offset\'] + $properties[\'limit\']) < $totalSet ? ($properties[\'offset\'] + $properties[\'limit\']) : $totalSet;
  4866. $properties[\'pageUrl\'] = $modx->makeUrl($modx->resource->get(\'id\'), \'\', $qs);
  4867. if ($properties[\'cache\'] && $modx->getCacheManager()) {
  4868. $cached = array(\'properties\' => $properties, \'output\' => $output);
  4869. $modx->cacheManager->set($properties[\'cachePageKey\'], $cached, $properties[xPDO::OPT_CACHE_EXPIRES], $properties[\'cacheOptions\']);
  4870. }
  4871. } else {
  4872. $properties = $cached[\'properties\'];
  4873. $output = $cached[\'output\'];
  4874. }
  4875. $modx->setPlaceholders($properties, $properties[\'namespace\']);
  4876. if (!empty($properties[\'toPlaceholder\'])) {
  4877. $modx->setPlaceholder($properties[\'toPlaceholder\'], $output);
  4878. $output = \'\';
  4879. }
  4880. return $output;',
  4881. 'locked' => false,
  4882. 'properties' =>
  4883. array (
  4884. 'cache' =>
  4885. array (
  4886. 'name' => 'cache',
  4887. 'desc' => 'If true, unique page requests will be cached according to addition cache properties.',
  4888. 'type' => 'combo-boolean',
  4889. 'options' =>
  4890. array (
  4891. ),
  4892. 'value' => false,
  4893. 'lexicon' => NULL,
  4894. 'area' => '',
  4895. 'desc_trans' => 'If true, unique page requests will be cached according to addition cache properties.',
  4896. 'area_trans' => '',
  4897. ),
  4898. 'cache_expires' =>
  4899. array (
  4900. 'name' => 'cache_expires',
  4901. 'desc' => 'The number of seconds before the cached pages expire and must be regenerated; leave empty to use the cache provider option for cache_expires.',
  4902. 'type' => 'textfield',
  4903. 'options' =>
  4904. array (
  4905. ),
  4906. 'value' => false,
  4907. 'lexicon' => NULL,
  4908. 'area' => '',
  4909. 'desc_trans' => 'The number of seconds before the cached pages expire and must be regenerated; leave empty to use the cache provider option for cache_expires.',
  4910. 'area_trans' => '',
  4911. ),
  4912. 'cache_handler' =>
  4913. array (
  4914. 'name' => 'cache_handler',
  4915. 'desc' => 'The cache provider implementation to use; leave empty unless you are caching to a custom cache_key.',
  4916. 'type' => 'textfield',
  4917. 'options' =>
  4918. array (
  4919. ),
  4920. 'value' => false,
  4921. 'lexicon' => NULL,
  4922. 'area' => '',
  4923. 'desc_trans' => 'The cache provider implementation to use; leave empty unless you are caching to a custom cache_key.',
  4924. 'area_trans' => '',
  4925. ),
  4926. 'cache_key' =>
  4927. array (
  4928. 'name' => 'cache_key',
  4929. 'desc' => 'The key of the cache provider to use; leave empty to use the cache_resource_key cache partition (default is "resource").',
  4930. 'type' => 'textfield',
  4931. 'options' =>
  4932. array (
  4933. ),
  4934. 'value' => false,
  4935. 'lexicon' => NULL,
  4936. 'area' => '',
  4937. 'desc_trans' => 'The key of the cache provider to use; leave empty to use the cache_resource_key cache partition (default is "resource").',
  4938. 'area_trans' => '',
  4939. ),
  4940. 'elementClass' =>
  4941. array (
  4942. 'name' => 'elementClass',
  4943. 'desc' => 'The class of element that will be called by the getPage snippet instance.',
  4944. 'type' => 'textfield',
  4945. 'options' =>
  4946. array (
  4947. ),
  4948. 'value' => 'modSnippet',
  4949. 'lexicon' => NULL,
  4950. 'area' => '',
  4951. 'desc_trans' => 'The class of element that will be called by the getPage snippet instance.',
  4952. 'area_trans' => '',
  4953. ),
  4954. 'limit' =>
  4955. array (
  4956. 'name' => 'limit',
  4957. 'desc' => 'The result limit per page; can be overridden in the $_REQUEST.',
  4958. 'type' => 'textfield',
  4959. 'options' =>
  4960. array (
  4961. ),
  4962. 'value' => '10',
  4963. 'lexicon' => NULL,
  4964. 'area' => '',
  4965. 'desc_trans' => 'The result limit per page; can be overridden in the $_REQUEST.',
  4966. 'area_trans' => '',
  4967. ),
  4968. 'namespace' =>
  4969. array (
  4970. 'name' => 'namespace',
  4971. 'desc' => 'An execution namespace that serves as a prefix for placeholders set by a specific instance of the getPage snippet.',
  4972. 'type' => 'textfield',
  4973. 'options' =>
  4974. array (
  4975. ),
  4976. 'value' => '',
  4977. 'lexicon' => NULL,
  4978. 'area' => '',
  4979. 'desc_trans' => 'An execution namespace that serves as a prefix for placeholders set by a specific instance of the getPage snippet.',
  4980. 'area_trans' => '',
  4981. ),
  4982. 'offset' =>
  4983. array (
  4984. 'name' => 'offset',
  4985. 'desc' => 'The offset, or record position to start at within the collection for rendering results for the current page; should be calculated based on page variable set in pageVarKey.',
  4986. 'type' => 'textfield',
  4987. 'options' =>
  4988. array (
  4989. ),
  4990. 'value' => '0',
  4991. 'lexicon' => NULL,
  4992. 'area' => '',
  4993. 'desc_trans' => 'The offset, or record position to start at within the collection for rendering results for the current page; should be calculated based on page variable set in pageVarKey.',
  4994. 'area_trans' => '',
  4995. ),
  4996. 'page' =>
  4997. array (
  4998. 'name' => 'page',
  4999. 'desc' => 'The page to display; this is determined based on the value indicated by the page variable set in pageVarKey, typically in the $_REQUEST.',
  5000. 'type' => 'textfield',
  5001. 'options' =>
  5002. array (
  5003. ),
  5004. 'value' => '0',
  5005. 'lexicon' => NULL,
  5006. 'area' => '',
  5007. 'desc_trans' => 'The page to display; this is determined based on the value indicated by the page variable set in pageVarKey, typically in the $_REQUEST.',
  5008. 'area_trans' => '',
  5009. ),
  5010. 'pageActiveTpl' =>
  5011. array (
  5012. 'name' => 'pageActiveTpl',
  5013. 'desc' => 'Content representing the current page navigation control.',
  5014. 'type' => 'textfield',
  5015. 'options' =>
  5016. array (
  5017. ),
  5018. 'value' => '<li[[+activeClasses]]><a[[+activeClasses:default=` class="active"`]][[+title]] href="[[+href]]">[[+pageNo]]</a></li>',
  5019. 'lexicon' => NULL,
  5020. 'area' => '',
  5021. 'desc_trans' => 'Content representing the current page navigation control.',
  5022. 'area_trans' => '',
  5023. ),
  5024. 'pageFirstTpl' =>
  5025. array (
  5026. 'name' => 'pageFirstTpl',
  5027. 'desc' => 'Content representing the first page navigation control.',
  5028. 'type' => 'textfield',
  5029. 'options' =>
  5030. array (
  5031. ),
  5032. 'value' => '<li class="control"><a[[+classes]][[+title]] href="[[+href]]">First</a></li>',
  5033. 'lexicon' => NULL,
  5034. 'area' => '',
  5035. 'desc_trans' => 'Content representing the first page navigation control.',
  5036. 'area_trans' => '',
  5037. ),
  5038. 'pageLastTpl' =>
  5039. array (
  5040. 'name' => 'pageLastTpl',
  5041. 'desc' => 'Content representing the last page navigation control.',
  5042. 'type' => 'textfield',
  5043. 'options' =>
  5044. array (
  5045. ),
  5046. 'value' => '<li class="control"><a[[+classes]][[+title]] href="[[+href]]">Last</a></li>',
  5047. 'lexicon' => NULL,
  5048. 'area' => '',
  5049. 'desc_trans' => 'Content representing the last page navigation control.',
  5050. 'area_trans' => '',
  5051. ),
  5052. 'pageLimit' =>
  5053. array (
  5054. 'name' => 'pageLimit',
  5055. 'desc' => 'The maximum number of pages to display when rendering paging controls',
  5056. 'type' => 'textfield',
  5057. 'options' =>
  5058. array (
  5059. ),
  5060. 'value' => '5',
  5061. 'lexicon' => NULL,
  5062. 'area' => '',
  5063. 'desc_trans' => 'The maximum number of pages to display when rendering paging controls',
  5064. 'area_trans' => '',
  5065. ),
  5066. 'pageNavOuterTpl' =>
  5067. array (
  5068. 'name' => 'pageNavOuterTpl',
  5069. 'desc' => 'Content representing the layout of the page navigation controls.',
  5070. 'type' => 'textfield',
  5071. 'options' =>
  5072. array (
  5073. ),
  5074. 'value' => '[[+first]][[+prev]][[+pages]][[+next]][[+last]]',
  5075. 'lexicon' => NULL,
  5076. 'area' => '',
  5077. 'desc_trans' => 'Content representing the layout of the page navigation controls.',
  5078. 'area_trans' => '',
  5079. ),
  5080. 'pageNavScheme' =>
  5081. array (
  5082. 'name' => 'pageNavScheme',
  5083. 'desc' => 'Optionally specify a scheme for use when generating page navigation links; will use link_tag_scheme if empty or not specified (default is empty).',
  5084. 'type' => 'textfield',
  5085. 'options' =>
  5086. array (
  5087. ),
  5088. 'value' => '',
  5089. 'lexicon' => NULL,
  5090. 'area' => '',
  5091. 'desc_trans' => 'Optionally specify a scheme for use when generating page navigation links; will use link_tag_scheme if empty or not specified (default is empty).',
  5092. 'area_trans' => '',
  5093. ),
  5094. 'pageNavTpl' =>
  5095. array (
  5096. 'name' => 'pageNavTpl',
  5097. 'desc' => 'Content representing a single page navigation control.',
  5098. 'type' => 'textfield',
  5099. 'options' =>
  5100. array (
  5101. ),
  5102. 'value' => '<li[[+classes]]><a[[+classes]][[+title]] href="[[+href]]">[[+pageNo]]</a></li>',
  5103. 'lexicon' => NULL,
  5104. 'area' => '',
  5105. 'desc_trans' => 'Content representing a single page navigation control.',
  5106. 'area_trans' => '',
  5107. ),
  5108. 'pageNavVar' =>
  5109. array (
  5110. 'name' => 'pageNavVar',
  5111. 'desc' => 'The key of a placeholder to be set with the paging navigation controls.',
  5112. 'type' => 'textfield',
  5113. 'options' =>
  5114. array (
  5115. ),
  5116. 'value' => 'page.nav',
  5117. 'lexicon' => NULL,
  5118. 'area' => '',
  5119. 'desc_trans' => 'The key of a placeholder to be set with the paging navigation controls.',
  5120. 'area_trans' => '',
  5121. ),
  5122. 'pageNextTpl' =>
  5123. array (
  5124. 'name' => 'pageNextTpl',
  5125. 'desc' => 'Content representing the next page navigation control.',
  5126. 'type' => 'textfield',
  5127. 'options' =>
  5128. array (
  5129. ),
  5130. 'value' => '<li class="control"><a[[+classes]][[+title]] href="[[+href]]">&gt;&gt;</a></li>',
  5131. 'lexicon' => NULL,
  5132. 'area' => '',
  5133. 'desc_trans' => 'Content representing the next page navigation control.',
  5134. 'area_trans' => '',
  5135. ),
  5136. 'pagePrevTpl' =>
  5137. array (
  5138. 'name' => 'pagePrevTpl',
  5139. 'desc' => 'Content representing the previous page navigation control.',
  5140. 'type' => 'textfield',
  5141. 'options' =>
  5142. array (
  5143. ),
  5144. 'value' => '<li class="control"><a[[+classes]][[+title]] href="[[+href]]">&lt;&lt;</a></li>',
  5145. 'lexicon' => NULL,
  5146. 'area' => '',
  5147. 'desc_trans' => 'Content representing the previous page navigation control.',
  5148. 'area_trans' => '',
  5149. ),
  5150. 'pageVarKey' =>
  5151. array (
  5152. 'name' => 'pageVarKey',
  5153. 'desc' => 'The key of a property that indicates the current page.',
  5154. 'type' => 'textfield',
  5155. 'options' =>
  5156. array (
  5157. ),
  5158. 'value' => 'page',
  5159. 'lexicon' => NULL,
  5160. 'area' => '',
  5161. 'desc_trans' => 'The key of a property that indicates the current page.',
  5162. 'area_trans' => '',
  5163. ),
  5164. 'totalVar' =>
  5165. array (
  5166. 'name' => 'totalVar',
  5167. 'desc' => 'The key of a placeholder that must contain the total records in the limitable collection being paged.',
  5168. 'type' => 'textfield',
  5169. 'options' =>
  5170. array (
  5171. ),
  5172. 'value' => 'total',
  5173. 'lexicon' => NULL,
  5174. 'area' => '',
  5175. 'desc_trans' => 'The key of a placeholder that must contain the total records in the limitable collection being paged.',
  5176. 'area_trans' => '',
  5177. ),
  5178. ),
  5179. 'moduleguid' => '',
  5180. 'static' => false,
  5181. 'static_file' => '',
  5182. 'content' => '/**
  5183. * @package getpage
  5184. */
  5185. $output = \'\';
  5186. $properties =& $scriptProperties;
  5187. $properties[\'page\'] = (isset($_GET[$properties[\'pageVarKey\']]) && ($page = intval($_GET[$properties[\'pageVarKey\']]))) ? $page : null;
  5188. if ($properties[\'page\'] === null) {
  5189. $properties[\'page\'] = (isset($_REQUEST[$properties[\'pageVarKey\']]) && ($page = intval($_REQUEST[$properties[\'pageVarKey\']]))) ? $page : 1;
  5190. }
  5191. $properties[\'limit\'] = (isset($_GET[\'limit\'])) ? intval($_GET[\'limit\']) : null;
  5192. if ($properties[\'limit\'] === null) {
  5193. $properties[\'limit\'] = (isset($_REQUEST[\'limit\'])) ? intval($_REQUEST[\'limit\']) : intval($limit);
  5194. }
  5195. $properties[\'offset\'] = (!empty($properties[\'limit\']) && !empty($properties[\'page\'])) ? ($properties[\'limit\'] * ($properties[\'page\'] - 1)) : 0;
  5196. $properties[\'totalVar\'] = empty($totalVar) ? "total" : $totalVar;
  5197. $properties[$properties[\'totalVar\']] = !empty($properties[$properties[\'totalVar\']]) && $total = intval($properties[$properties[\'totalVar\']]) ? $total : 0;
  5198. $properties[\'pageOneLimit\'] = (!empty($pageOneLimit) && $pageOneLimit = intval($pageOneLimit)) ? $pageOneLimit : $properties[\'limit\'];
  5199. $properties[\'actualLimit\'] = $properties[\'limit\'];
  5200. $properties[\'pageLimit\'] = isset($pageLimit) && is_numeric($pageLimit) ? intval($pageLimit) : 5;
  5201. $properties[\'element\'] = empty($element) ? \'\' : $element;
  5202. $properties[\'elementClass\'] = empty($elementClass) ? \'modChunk\' : $elementClass;
  5203. $properties[\'pageNavVar\'] = empty($pageNavVar) ? \'page.nav\' : $pageNavVar;
  5204. $properties[\'pageNavTpl\'] = !isset($pageNavTpl) ? "<li[[+classes]]><a[[+classes]][[+title]] href=\\"[[+href]]\\">[[+pageNo]]</a></li>" : $pageNavTpl;
  5205. $properties[\'pageNavOuterTpl\'] = !isset($pageNavOuterTpl) ? "[[+first]][[+prev]][[+pages]][[+next]][[+last]]" : $pageNavOuterTpl;
  5206. $properties[\'pageActiveTpl\'] = !isset($pageActiveTpl) ? "<li[[+activeClasses:default=` class=\\"active\\"`]]><a[[+activeClasses:default=` class=\\"active\\"`]][[+title]] href=\\"[[+href]]\\">[[+pageNo]]</a></li>" : $pageActiveTpl;
  5207. $properties[\'pageFirstTpl\'] = !isset($pageFirstTpl) ? "<li class=\\"control\\"><a[[+title]] href=\\"[[+href]]\\">First</a></li>" : $pageFirstTpl;
  5208. $properties[\'pageLastTpl\'] = !isset($pageLastTpl) ? "<li class=\\"control\\"><a[[+title]] href=\\"[[+href]]\\">Last</a></li>" : $pageLastTpl;
  5209. $properties[\'pagePrevTpl\'] = !isset($pagePrevTpl) ? "<li class=\\"control\\"><a[[+title]] href=\\"[[+href]]\\">&lt;&lt;</a></li>" : $pagePrevTpl;
  5210. $properties[\'pageNextTpl\'] = !isset($pageNextTpl) ? "<li class=\\"control\\"><a[[+title]] href=\\"[[+href]]\\">&gt;&gt;</a></li>" : $pageNextTpl;
  5211. $properties[\'toPlaceholder\'] = !empty($toPlaceholder) ? $toPlaceholder : \'\';
  5212. $properties[\'cache\'] = isset($cache) ? (boolean) $cache : (boolean) $modx->getOption(\'cache_resource\', null, false);
  5213. if (empty($cache_key)) $properties[xPDO::OPT_CACHE_KEY] = $modx->getOption(\'cache_resource_key\', null, \'resource\');
  5214. if (empty($cache_handler)) $properties[xPDO::OPT_CACHE_HANDLER] = $modx->getOption(\'cache_resource_handler\', null, \'xPDOFileCache\');
  5215. if (empty($cache_expires)) $properties[xPDO::OPT_CACHE_EXPIRES] = (integer) $modx->getOption(\'cache_resource_expires\', null, 0);
  5216. if ($properties[\'page\'] == 1 && $properties[\'pageOneLimit\'] !== $properties[\'actualLimit\']) {
  5217. $properties[\'limit\'] = $properties[\'pageOneLimit\'];
  5218. }
  5219. if ($properties[\'cache\']) {
  5220. $properties[\'cachePageKey\'] = $modx->resource->getCacheKey() . \'/\' . $properties[\'page\'] . \'/\' . md5(http_build_query($modx->request->getParameters()) . http_build_query($scriptProperties));
  5221. $properties[\'cacheOptions\'] = array(
  5222. xPDO::OPT_CACHE_KEY => $properties[xPDO::OPT_CACHE_KEY],
  5223. xPDO::OPT_CACHE_HANDLER => $properties[xPDO::OPT_CACHE_HANDLER],
  5224. xPDO::OPT_CACHE_EXPIRES => $properties[xPDO::OPT_CACHE_EXPIRES],
  5225. );
  5226. }
  5227. $cached = false;
  5228. if ($properties[\'cache\']) {
  5229. if ($modx->getCacheManager()) {
  5230. $cached = $modx->cacheManager->get($properties[\'cachePageKey\'], $properties[\'cacheOptions\']);
  5231. }
  5232. }
  5233. if (empty($cached) || !isset($cached[\'properties\']) || !isset($cached[\'output\'])) {
  5234. $elementObj = $modx->getObject($properties[\'elementClass\'], array(\'name\' => $properties[\'element\']));
  5235. if ($elementObj) {
  5236. $elementObj->setCacheable(false);
  5237. if (!empty($properties[\'toPlaceholder\'])) {
  5238. $elementObj->process($properties);
  5239. $output = $modx->getPlaceholder($properties[\'toPlaceholder\']);
  5240. } else {
  5241. $output = $elementObj->process($properties);
  5242. }
  5243. }
  5244. include_once $modx->getOption(\'getpage.core_path\',$properties,$modx->getOption(\'core_path\', $properties, MODX_CORE_PATH) . \'components/getpage/\').\'include.getpage.php\';
  5245. $qs = $modx->request->getParameters();
  5246. $properties[\'qs\'] =& $qs;
  5247. $totalSet = $modx->getPlaceholder($properties[\'totalVar\']);
  5248. $properties[$properties[\'totalVar\']] = (($totalSet = intval($totalSet)) ? $totalSet : $properties[$properties[\'totalVar\']]);
  5249. if (!empty($properties[$properties[\'totalVar\']]) && !empty($properties[\'actualLimit\'])) {
  5250. if ($properties[\'pageOneLimit\'] !== $properties[\'actualLimit\']) {
  5251. $adjustedTotal = $properties[$properties[\'totalVar\']] - $properties[\'pageOneLimit\'];
  5252. $properties[\'pageCount\'] = $adjustedTotal > 0 ? ceil($adjustedTotal / $properties[\'actualLimit\']) + 1 : 1;
  5253. } else {
  5254. $properties[\'pageCount\'] = ceil($properties[$properties[\'totalVar\']] / $properties[\'actualLimit\']);
  5255. }
  5256. } else {
  5257. $properties[\'pageCount\'] = 1;
  5258. }
  5259. if (empty($properties[$properties[\'totalVar\']]) || empty($properties[\'actualLimit\']) || $properties[$properties[\'totalVar\']] <= $properties[\'actualLimit\'] || ($properties[\'page\'] == 1 && $properties[$properties[\'totalVar\']] <= $properties[\'pageOneLimit\'])) {
  5260. $properties[\'page\'] = 1;
  5261. } else {
  5262. $pageNav = getpage_buildControls($modx, $properties);
  5263. $properties[$properties[\'pageNavVar\']] = $modx->newObject(\'modChunk\')->process(array_merge($properties, $pageNav), $properties[\'pageNavOuterTpl\']);
  5264. if ($properties[\'page\'] > 1) {
  5265. $qs[$properties[\'pageVarKey\']] = $properties[\'page\'];
  5266. }
  5267. }
  5268. $properties[\'firstItem\'] = $properties[\'offset\'] + 1;
  5269. $properties[\'lastItem\'] = ($properties[\'offset\'] + $properties[\'limit\']) < $totalSet ? ($properties[\'offset\'] + $properties[\'limit\']) : $totalSet;
  5270. $properties[\'pageUrl\'] = $modx->makeUrl($modx->resource->get(\'id\'), \'\', $qs);
  5271. if ($properties[\'cache\'] && $modx->getCacheManager()) {
  5272. $cached = array(\'properties\' => $properties, \'output\' => $output);
  5273. $modx->cacheManager->set($properties[\'cachePageKey\'], $cached, $properties[xPDO::OPT_CACHE_EXPIRES], $properties[\'cacheOptions\']);
  5274. }
  5275. } else {
  5276. $properties = $cached[\'properties\'];
  5277. $output = $cached[\'output\'];
  5278. }
  5279. $modx->setPlaceholders($properties, $properties[\'namespace\']);
  5280. if (!empty($properties[\'toPlaceholder\'])) {
  5281. $modx->setPlaceholder($properties[\'toPlaceholder\'], $output);
  5282. $output = \'\';
  5283. }
  5284. return $output;',
  5285. ),
  5286. 'policies' =>
  5287. array (
  5288. 'web' =>
  5289. array (
  5290. ),
  5291. ),
  5292. 'source' =>
  5293. array (
  5294. ),
  5295. ),
  5296. 'phpthumbof' =>
  5297. array (
  5298. 'fields' =>
  5299. array (
  5300. 'id' => 97,
  5301. 'source' => 0,
  5302. 'property_preprocess' => false,
  5303. 'name' => 'phpthumbof',
  5304. 'description' => 'Identical to pthumb. Retained for backwards compatibility.
  5305. Documentation: https://github.com/oo12/phpThumbOf',
  5306. 'editor_type' => 0,
  5307. 'category' => 33,
  5308. 'cache_type' => 0,
  5309. 'snippet' => '/**
  5310. * pThumb
  5311. * Copyright 2013-2014 Jason Grant
  5312. *
  5313. * Please see the GitHub page for documentation or to report bugs:
  5314. * https://github.com/oo12/phpThumbOf
  5315. *
  5316. * Forked from phpThumbOf 1.4.0
  5317. * Copyright 2009-2012 by Shaun McCormick <shaun@modx.com>
  5318. *
  5319. * pThumb is free software; you can redistribute it and/or modify it
  5320. * under the terms of the GNU General Public License as published by the Free
  5321. * Software Foundation; either version 2 of the License, or (at your option) any
  5322. * later version.
  5323. *
  5324. * pThumb is distributed in the hope that it will be useful, but WITHOUT ANY
  5325. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  5326. * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  5327. *
  5328. * You should have received a copy of the GNU General Public License along with
  5329. * phpThumbOf; if not, write to the Free Software Foundation, Inc., 59 Temple
  5330. * Place, Suite 330, Boston, MA 02111-1307 USA
  5331. *
  5332. */
  5333. /**
  5334. *
  5335. * @var modX $modx
  5336. * @var array $scriptProperties
  5337. * @var string $input
  5338. * @var string|array $options
  5339. *
  5340. */
  5341. if (empty($input)) { // Exit quietly if no file name given
  5342. return;
  5343. }
  5344. $scriptProperties[\'debug\'] = isset($debug) ? $debug : false;
  5345. static $pt_settings = array();
  5346. if (empty($pt_settings)) {
  5347. if (!$modx->loadClass(\'phpThumbOf\', MODX_CORE_PATH . \'components/phpthumbof/model/\', true, true)) {
  5348. $modx->log(modX::LOG_LEVEL_ERROR, \'[pThumb] Could not load phpThumbOf class.\');
  5349. return $input;
  5350. }
  5351. }
  5352. $pThumb = new phpThumbOf($modx, $pt_settings, $scriptProperties);
  5353. $result = $pThumb->createThumbnail($input, $options);
  5354. if (!empty($toPlaceholder) || $result[\'outputDims\']) {
  5355. if ($result[\'width\'] === \'\' && $result[\'file\'] && $dims = getimagesize($result[\'file\']) ) {
  5356. $result[\'width\'] = $dims[0];
  5357. $result[\'height\'] = $dims[1];
  5358. }
  5359. if (!empty($toPlaceholder)) {
  5360. $modx->setPlaceholders(array(
  5361. $toPlaceholder => $result[\'src\'],
  5362. "$toPlaceholder.width" => $result[\'width\'],
  5363. "$toPlaceholder.height" => $result[\'height\']
  5364. ));
  5365. $output = \'\';
  5366. }
  5367. if ($result[\'outputDims\']) {
  5368. $output = "src=\\"{$result[\'src\']}\\"" . ($result[\'width\'] ? " width=\\"{$result[\'width\']}\\" height=\\"{$result[\'height\']}\\"" : \'\');
  5369. }
  5370. }
  5371. else {
  5372. $output = $result[\'src\'];
  5373. }
  5374. if ($debug && $result[\'success\']) { // if debugging is on and createThumbnail was successful, log the debug info
  5375. $pThumb->debugmsg(isset($pThumb->phpThumb->debugmessages) ? \':: Processed ::\' : ":: Loaded from cache: {$result[\'src\']}", true);
  5376. }
  5377. return $output;',
  5378. 'locked' => false,
  5379. 'properties' =>
  5380. array (
  5381. 'debug' =>
  5382. array (
  5383. 'name' => 'debug',
  5384. 'desc' => 'prop_pthumb.debug_desc',
  5385. 'type' => 'combo-boolean',
  5386. 'options' =>
  5387. array (
  5388. ),
  5389. 'value' => false,
  5390. 'lexicon' => 'phpthumbof:default',
  5391. 'area' => '',
  5392. 'desc_trans' => 'Write debug messages to the MODX error log.',
  5393. 'area_trans' => '',
  5394. ),
  5395. ),
  5396. 'moduleguid' => '',
  5397. 'static' => false,
  5398. 'static_file' => '',
  5399. 'content' => '/**
  5400. * pThumb
  5401. * Copyright 2013-2014 Jason Grant
  5402. *
  5403. * Please see the GitHub page for documentation or to report bugs:
  5404. * https://github.com/oo12/phpThumbOf
  5405. *
  5406. * Forked from phpThumbOf 1.4.0
  5407. * Copyright 2009-2012 by Shaun McCormick <shaun@modx.com>
  5408. *
  5409. * pThumb is free software; you can redistribute it and/or modify it
  5410. * under the terms of the GNU General Public License as published by the Free
  5411. * Software Foundation; either version 2 of the License, or (at your option) any
  5412. * later version.
  5413. *
  5414. * pThumb is distributed in the hope that it will be useful, but WITHOUT ANY
  5415. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  5416. * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  5417. *
  5418. * You should have received a copy of the GNU General Public License along with
  5419. * phpThumbOf; if not, write to the Free Software Foundation, Inc., 59 Temple
  5420. * Place, Suite 330, Boston, MA 02111-1307 USA
  5421. *
  5422. */
  5423. /**
  5424. *
  5425. * @var modX $modx
  5426. * @var array $scriptProperties
  5427. * @var string $input
  5428. * @var string|array $options
  5429. *
  5430. */
  5431. if (empty($input)) { // Exit quietly if no file name given
  5432. return;
  5433. }
  5434. $scriptProperties[\'debug\'] = isset($debug) ? $debug : false;
  5435. static $pt_settings = array();
  5436. if (empty($pt_settings)) {
  5437. if (!$modx->loadClass(\'phpThumbOf\', MODX_CORE_PATH . \'components/phpthumbof/model/\', true, true)) {
  5438. $modx->log(modX::LOG_LEVEL_ERROR, \'[pThumb] Could not load phpThumbOf class.\');
  5439. return $input;
  5440. }
  5441. }
  5442. $pThumb = new phpThumbOf($modx, $pt_settings, $scriptProperties);
  5443. $result = $pThumb->createThumbnail($input, $options);
  5444. if (!empty($toPlaceholder) || $result[\'outputDims\']) {
  5445. if ($result[\'width\'] === \'\' && $result[\'file\'] && $dims = getimagesize($result[\'file\']) ) {
  5446. $result[\'width\'] = $dims[0];
  5447. $result[\'height\'] = $dims[1];
  5448. }
  5449. if (!empty($toPlaceholder)) {
  5450. $modx->setPlaceholders(array(
  5451. $toPlaceholder => $result[\'src\'],
  5452. "$toPlaceholder.width" => $result[\'width\'],
  5453. "$toPlaceholder.height" => $result[\'height\']
  5454. ));
  5455. $output = \'\';
  5456. }
  5457. if ($result[\'outputDims\']) {
  5458. $output = "src=\\"{$result[\'src\']}\\"" . ($result[\'width\'] ? " width=\\"{$result[\'width\']}\\" height=\\"{$result[\'height\']}\\"" : \'\');
  5459. }
  5460. }
  5461. else {
  5462. $output = $result[\'src\'];
  5463. }
  5464. if ($debug && $result[\'success\']) { // if debugging is on and createThumbnail was successful, log the debug info
  5465. $pThumb->debugmsg(isset($pThumb->phpThumb->debugmessages) ? \':: Processed ::\' : ":: Loaded from cache: {$result[\'src\']}", true);
  5466. }
  5467. return $output;',
  5468. ),
  5469. 'policies' =>
  5470. array (
  5471. 'web' =>
  5472. array (
  5473. ),
  5474. ),
  5475. 'source' =>
  5476. array (
  5477. ),
  5478. ),
  5479. 'FormIt' =>
  5480. array (
  5481. 'fields' =>
  5482. array (
  5483. 'id' => 16,
  5484. 'source' => 0,
  5485. 'property_preprocess' => false,
  5486. 'name' => 'FormIt',
  5487. 'description' => 'A dynamic form processing snippet.',
  5488. 'editor_type' => 0,
  5489. 'category' => 8,
  5490. 'cache_type' => 0,
  5491. 'snippet' => '/**
  5492. * FormIt
  5493. *
  5494. * Copyright 2009-2012 by Shaun McCormick <shaun@modx.com>
  5495. *
  5496. * FormIt is free software; you can redistribute it and/or modify it
  5497. * under the terms of the GNU General Public License as published by the Free
  5498. * Software Foundation; either version 2 of the License, or (at your option) any
  5499. * later version.
  5500. *
  5501. * FormIt is distributed in the hope that it will be useful, but WITHOUT ANY
  5502. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  5503. * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  5504. *
  5505. * You should have received a copy of the GNU General Public License along with
  5506. * FormIt; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
  5507. * Suite 330, Boston, MA 02111-1307 USA
  5508. *
  5509. * @package formit
  5510. */
  5511. /**
  5512. * FormIt
  5513. *
  5514. * A dynamic form processing Snippet for MODx Revolution.
  5515. *
  5516. * @var modX $modx
  5517. * @var array $scriptProperties
  5518. *
  5519. * @package formit
  5520. */
  5521. $modelPath = $modx->getOption(
  5522. \'formit.core_path\',
  5523. null,
  5524. $modx->getOption(\'core_path\', null, MODX_CORE_PATH) . \'components/formit/\'
  5525. ) . \'model/formit/\';
  5526. $modx->loadClass(\'FormIt\', $modelPath, true, true);
  5527. $fi = new FormIt($modx, $scriptProperties);
  5528. $fi->initialize($modx->context->get(\'key\'));
  5529. $fi->loadRequest();
  5530. $fields = $fi->request->prepare();
  5531. return $fi->request->handle($fields);',
  5532. 'locked' => false,
  5533. 'properties' =>
  5534. array (
  5535. 'hooks' =>
  5536. array (
  5537. 'name' => 'hooks',
  5538. 'desc' => 'prop_formit.hooks_desc',
  5539. 'type' => 'textfield',
  5540. 'options' => '',
  5541. 'value' => '',
  5542. 'lexicon' => 'formit:properties',
  5543. 'area' => '',
  5544. 'desc_trans' => 'What scripts to fire, if any, after the form passes validation. This can be a comma-separated list of hooks, and if the first fails, the proceeding ones will not fire. A hook can also be a Snippet name that will execute that Snippet.',
  5545. 'area_trans' => '',
  5546. ),
  5547. 'preHooks' =>
  5548. array (
  5549. 'name' => 'preHooks',
  5550. 'desc' => 'prop_formit.prehooks_desc',
  5551. 'type' => 'textfield',
  5552. 'options' => '',
  5553. 'value' => '',
  5554. 'lexicon' => 'formit:properties',
  5555. 'area' => '',
  5556. 'desc_trans' => 'What scripts to fire, if any, once the form loads. You can pre-set form fields via $scriptProperties[`hook`]->fields[`fieldname`]. This can be a comma-separated list of hooks, and if the first fails, the proceeding ones will not fire. A hook can also be a Snippet name that will execute that Snippet.',
  5557. 'area_trans' => '',
  5558. ),
  5559. 'submitVar' =>
  5560. array (
  5561. 'name' => 'submitVar',
  5562. 'desc' => 'prop_formit.submitvar_desc',
  5563. 'type' => 'textfield',
  5564. 'options' => '',
  5565. 'value' => '',
  5566. 'lexicon' => 'formit:properties',
  5567. 'area' => '',
  5568. 'desc_trans' => 'If set, will not begin form processing if this POST variable is not passed.',
  5569. 'area_trans' => '',
  5570. ),
  5571. 'validate' =>
  5572. array (
  5573. 'name' => 'validate',
  5574. 'desc' => 'prop_formit.validate_desc',
  5575. 'type' => 'textfield',
  5576. 'options' => '',
  5577. 'value' => '',
  5578. 'lexicon' => 'formit:properties',
  5579. 'area' => '',
  5580. 'desc_trans' => 'A comma-separated list of fields to validate, with each field name as name:validator (eg: username:required,email:required). Validators can also be chained, like email:email:required. This property can be specified on multiple lines.',
  5581. 'area_trans' => '',
  5582. ),
  5583. 'errTpl' =>
  5584. array (
  5585. 'name' => 'errTpl',
  5586. 'desc' => 'prop_formit.errtpl_desc',
  5587. 'type' => 'textfield',
  5588. 'options' => '',
  5589. 'value' => '<span class="error">[[+error]]</span>',
  5590. 'lexicon' => 'formit:properties',
  5591. 'area' => '',
  5592. 'desc_trans' => 'The wrapper template for error messages.',
  5593. 'area_trans' => '',
  5594. ),
  5595. 'validationErrorMessage' =>
  5596. array (
  5597. 'name' => 'validationErrorMessage',
  5598. 'desc' => 'prop_formit.validationerrormessage_desc',
  5599. 'type' => 'textfield',
  5600. 'options' => '',
  5601. 'value' => '<p class="error">A form validation error occurred. Please check the values you have entered.</p>',
  5602. 'lexicon' => 'formit:properties',
  5603. 'area' => '',
  5604. 'desc_trans' => 'A general error message to set to a placeholder if validation fails. Can contain [[+errors]] if you want to display a list of all errors at the top.',
  5605. 'area_trans' => '',
  5606. ),
  5607. 'validationErrorBulkTpl' =>
  5608. array (
  5609. 'name' => 'validationErrorBulkTpl',
  5610. 'desc' => 'prop_formit.validationerrorbulktpl_desc',
  5611. 'type' => 'textfield',
  5612. 'options' => '',
  5613. 'value' => '<li>[[+error]]</li>',
  5614. 'lexicon' => 'formit:properties',
  5615. 'area' => '',
  5616. 'desc_trans' => 'HTML tpl that is used for each individual error in the generic validation error message value.',
  5617. 'area_trans' => '',
  5618. ),
  5619. 'trimValuesBeforeValidation' =>
  5620. array (
  5621. 'name' => 'trimValuesBeforeValidation',
  5622. 'desc' => 'prop_formit.trimvaluesdeforevalidation_desc',
  5623. 'type' => 'combo-boolean',
  5624. 'options' => '',
  5625. 'value' => true,
  5626. 'lexicon' => 'formit:properties',
  5627. 'area' => '',
  5628. 'desc_trans' => 'Whether or not to trim spaces from the beginning and end of values before attempting validation. Defaults to true.',
  5629. 'area_trans' => '',
  5630. ),
  5631. 'customValidators' =>
  5632. array (
  5633. 'name' => 'customValidators',
  5634. 'desc' => 'prop_formit.customvalidators_desc',
  5635. 'type' => 'textfield',
  5636. 'options' => '',
  5637. 'value' => '',
  5638. 'lexicon' => 'formit:properties',
  5639. 'area' => '',
  5640. 'desc_trans' => 'A comma-separated list of custom validator names (snippets) you plan to use in this form. They must be explicitly stated here, or they will not be run.',
  5641. 'area_trans' => '',
  5642. ),
  5643. 'clearFieldsOnSuccess' =>
  5644. array (
  5645. 'name' => 'clearFieldsOnSuccess',
  5646. 'desc' => 'prop_formit.clearfieldsonsuccess_desc',
  5647. 'type' => 'combo-boolean',
  5648. 'options' => '',
  5649. 'value' => true,
  5650. 'lexicon' => 'formit:properties',
  5651. 'area' => '',
  5652. 'desc_trans' => 'If true, will clear the fields on a successful form submission that does not redirect.',
  5653. 'area_trans' => '',
  5654. ),
  5655. 'successMessage' =>
  5656. array (
  5657. 'name' => 'successMessage',
  5658. 'desc' => 'prop_formit.successmessage_desc',
  5659. 'type' => 'textfield',
  5660. 'options' => '',
  5661. 'value' => '',
  5662. 'lexicon' => 'formit:properties',
  5663. 'area' => '',
  5664. 'desc_trans' => 'If set, will set this a placeholder with the name of the value of the property &successMessagePlaceholder, which defaults to `fi.successMessage`.',
  5665. 'area_trans' => '',
  5666. ),
  5667. 'successMessagePlaceholder' =>
  5668. array (
  5669. 'name' => 'successMessagePlaceholder',
  5670. 'desc' => 'prop_formit.successmessageplaceholder_desc',
  5671. 'type' => 'textfield',
  5672. 'options' => '',
  5673. 'value' => 'fi.successMessage',
  5674. 'lexicon' => 'formit:properties',
  5675. 'area' => '',
  5676. 'desc_trans' => 'The placeholder to set the success message to.',
  5677. 'area_trans' => '',
  5678. ),
  5679. 'store' =>
  5680. array (
  5681. 'name' => 'store',
  5682. 'desc' => 'prop_formit.store_desc',
  5683. 'type' => 'combo-boolean',
  5684. 'options' => '',
  5685. 'value' => false,
  5686. 'lexicon' => 'formit:properties',
  5687. 'area' => '',
  5688. 'desc_trans' => 'If true, will store the data in the cache for retrieval using the FormItRetriever snippet.',
  5689. 'area_trans' => '',
  5690. ),
  5691. 'placeholderPrefix' =>
  5692. array (
  5693. 'name' => 'placeholderPrefix',
  5694. 'desc' => 'prop_formit.placeholderprefix_desc',
  5695. 'type' => 'textfield',
  5696. 'options' => '',
  5697. 'value' => 'fi.',
  5698. 'lexicon' => 'formit:properties',
  5699. 'area' => '',
  5700. 'desc_trans' => 'The prefix to use for all placeholders set by FormIt for fields. Defaults to `fi.`',
  5701. 'area_trans' => '',
  5702. ),
  5703. 'storeTime' =>
  5704. array (
  5705. 'name' => 'storeTime',
  5706. 'desc' => 'prop_formit.storetime_desc',
  5707. 'type' => 'textfield',
  5708. 'options' => '',
  5709. 'value' => '300',
  5710. 'lexicon' => 'formit:properties',
  5711. 'area' => '',
  5712. 'desc_trans' => 'If `store` is set to true, this specifies the number of seconds to store the data from the form submission. Defaults to five minutes.',
  5713. 'area_trans' => '',
  5714. ),
  5715. 'storeLocation' =>
  5716. array (
  5717. 'name' => 'storeLocation',
  5718. 'desc' => 'prop_formit.storelocation_desc',
  5719. 'type' => 'list',
  5720. 'options' =>
  5721. array (
  5722. 0 =>
  5723. array (
  5724. 'value' => 'cache',
  5725. 'text' => 'formit.opt_cache',
  5726. 'name' => 'MODX Cache',
  5727. ),
  5728. 1 =>
  5729. array (
  5730. 'value' => 'session',
  5731. 'text' => 'formit.opt_session',
  5732. 'name' => 'Session',
  5733. ),
  5734. ),
  5735. 'value' => 'cache',
  5736. 'lexicon' => 'formit:properties',
  5737. 'area' => '',
  5738. 'desc_trans' => 'If `store` is set to true, this specifies the cache location of the data from the form submission. Defaults to MODX cache.',
  5739. 'area_trans' => '',
  5740. ),
  5741. 'allowFiles' =>
  5742. array (
  5743. 'name' => 'allowFiles',
  5744. 'desc' => 'prop_formit.allowfiles_desc',
  5745. 'type' => 'combo-boolean',
  5746. 'options' => '',
  5747. 'value' => true,
  5748. 'lexicon' => 'formit:properties',
  5749. 'area' => '',
  5750. 'desc_trans' => 'If set to 0, will prevent files from being submitted on the form.',
  5751. 'area_trans' => '',
  5752. ),
  5753. 'spamEmailFields' =>
  5754. array (
  5755. 'name' => 'spamEmailFields',
  5756. 'desc' => 'prop_formit.spamemailfields_desc',
  5757. 'type' => 'textfield',
  5758. 'options' => '',
  5759. 'value' => 'email',
  5760. 'lexicon' => 'formit:properties',
  5761. 'area' => '',
  5762. 'desc_trans' => 'If `spam` is set as a hook, a comma-separated list of fields containing emails to check spam against.',
  5763. 'area_trans' => '',
  5764. ),
  5765. 'spamCheckIp' =>
  5766. array (
  5767. 'name' => 'spamCheckIp',
  5768. 'desc' => 'prop_formit.spamcheckip_desc',
  5769. 'type' => 'combo-boolean',
  5770. 'options' => '',
  5771. 'value' => false,
  5772. 'lexicon' => 'formit:properties',
  5773. 'area' => '',
  5774. 'desc_trans' => 'If `spam` is set as a hook, and this is true, will check the IP as well.',
  5775. 'area_trans' => '',
  5776. ),
  5777. 'recaptchaJs' =>
  5778. array (
  5779. 'name' => 'recaptchaJs',
  5780. 'desc' => 'prop_formit.recaptchajs_desc',
  5781. 'type' => 'textfield',
  5782. 'options' => '',
  5783. 'value' => '{}',
  5784. 'lexicon' => 'formit:properties',
  5785. 'area' => '',
  5786. 'desc_trans' => 'If `recaptcha` is set as a hook, this can be a JSON object that will be set to the JS RecaptchaOptions variable, which configures options for reCaptcha.',
  5787. 'area_trans' => '',
  5788. ),
  5789. 'recaptchaTheme' =>
  5790. array (
  5791. 'name' => 'recaptchaTheme',
  5792. 'desc' => 'prop_formit.recaptchatheme_desc',
  5793. 'type' => 'list',
  5794. 'options' =>
  5795. array (
  5796. 0 =>
  5797. array (
  5798. 'value' => 'red',
  5799. 'text' => 'formit.opt_red',
  5800. 'name' => 'Red',
  5801. ),
  5802. 1 =>
  5803. array (
  5804. 'value' => 'white',
  5805. 'text' => 'formit.opt_white',
  5806. 'name' => 'White',
  5807. ),
  5808. 2 =>
  5809. array (
  5810. 'value' => 'clean',
  5811. 'text' => 'formit.opt_clean',
  5812. 'name' => 'Clean',
  5813. ),
  5814. 3 =>
  5815. array (
  5816. 'value' => 'blackglass',
  5817. 'text' => 'formit.opt_blackglass',
  5818. 'name' => 'Black Glass',
  5819. ),
  5820. ),
  5821. 'value' => 'clean',
  5822. 'lexicon' => 'formit:properties',
  5823. 'area' => '',
  5824. 'desc_trans' => 'If `recaptcha` is set as a hook, this will select a theme for the reCaptcha widget.',
  5825. 'area_trans' => '',
  5826. ),
  5827. 'redirectTo' =>
  5828. array (
  5829. 'name' => 'redirectTo',
  5830. 'desc' => 'prop_formit.redirectto_desc',
  5831. 'type' => 'textfield',
  5832. 'options' => '',
  5833. 'value' => '',
  5834. 'lexicon' => 'formit:properties',
  5835. 'area' => '',
  5836. 'desc_trans' => 'If `redirect` is set as a hook, this must specify the Resource ID to redirect to.',
  5837. 'area_trans' => '',
  5838. ),
  5839. 'redirectParams' =>
  5840. array (
  5841. 'name' => 'redirectParams',
  5842. 'desc' => 'prop_formit.redirectparams_desc',
  5843. 'type' => 'textfield',
  5844. 'options' => '',
  5845. 'value' => '',
  5846. 'lexicon' => 'formit:properties',
  5847. 'area' => '',
  5848. 'desc_trans' => 'A JSON array of parameters to pass to the redirect hook that will be passed when redirecting.',
  5849. 'area_trans' => '',
  5850. ),
  5851. 'emailTo' =>
  5852. array (
  5853. 'name' => 'emailTo',
  5854. 'desc' => 'prop_formit.emailto_desc',
  5855. 'type' => 'textfield',
  5856. 'options' => '',
  5857. 'value' => '',
  5858. 'lexicon' => 'formit:properties',
  5859. 'area' => '',
  5860. 'desc_trans' => 'If `email` is set as a hook, then this specifies the email(s) to send the email to. Can be a comma-separated list of email addresses.',
  5861. 'area_trans' => '',
  5862. ),
  5863. 'emailToName' =>
  5864. array (
  5865. 'name' => 'emailToName',
  5866. 'desc' => 'prop_formit.emailtoname_desc',
  5867. 'type' => 'textfield',
  5868. 'options' => '',
  5869. 'value' => '',
  5870. 'lexicon' => 'formit:properties',
  5871. 'area' => '',
  5872. 'desc_trans' => 'Optional. If `email` is set as a hook, then this must be a parallel list of comma-separated names for the email addresses specified in the `emailTo` property.',
  5873. 'area_trans' => '',
  5874. ),
  5875. 'emailFrom' =>
  5876. array (
  5877. 'name' => 'emailFrom',
  5878. 'desc' => 'prop_formit.emailfrom_desc',
  5879. 'type' => 'textfield',
  5880. 'options' => '',
  5881. 'value' => '',
  5882. 'lexicon' => 'formit:properties',
  5883. 'area' => '',
  5884. 'desc_trans' => 'Optional. If `email` is set as a hook, and this is set, will specify the From: address for the email. If not set, will first look for an `email` form field. If none is found, will default to the `emailsender` system setting.',
  5885. 'area_trans' => '',
  5886. ),
  5887. 'emailFromName' =>
  5888. array (
  5889. 'name' => 'emailFromName',
  5890. 'desc' => 'prop_formit.emailfromname_desc',
  5891. 'type' => 'textfield',
  5892. 'options' => '',
  5893. 'value' => '',
  5894. 'lexicon' => 'formit:properties',
  5895. 'area' => '',
  5896. 'desc_trans' => 'Optional. If `email` is set as a hook, and this is set, will specify the From: name for the email.',
  5897. 'area_trans' => '',
  5898. ),
  5899. 'emailReplyTo' =>
  5900. array (
  5901. 'name' => 'emailReplyTo',
  5902. 'desc' => 'prop_formit.emailreplyto_desc',
  5903. 'type' => 'textfield',
  5904. 'options' => '',
  5905. 'value' => '',
  5906. 'lexicon' => 'formit:properties',
  5907. 'area' => '',
  5908. 'desc_trans' => 'Optional. If `email` is set as a hook, and this is set, will specify the Reply-To: address for the email.',
  5909. 'area_trans' => '',
  5910. ),
  5911. 'emailReplyToName' =>
  5912. array (
  5913. 'name' => 'emailReplyToName',
  5914. 'desc' => 'prop_formit.emailreplytoname_desc',
  5915. 'type' => 'textfield',
  5916. 'options' => '',
  5917. 'value' => '',
  5918. 'lexicon' => 'formit:properties',
  5919. 'area' => '',
  5920. 'desc_trans' => 'Optional. If `email` is set as a hook, and this is set, will specify the Reply-To: name for the email.',
  5921. 'area_trans' => '',
  5922. ),
  5923. 'emailCC' =>
  5924. array (
  5925. 'name' => 'emailCC',
  5926. 'desc' => 'prop_formit.emailcc_desc',
  5927. 'type' => 'textfield',
  5928. 'options' => '',
  5929. 'value' => '',
  5930. 'lexicon' => 'formit:properties',
  5931. 'area' => '',
  5932. 'desc_trans' => 'If `email` is set as a hook, then this specifies the email(s) to send the email to as a CC. Can be a comma-separated list of email addresses.',
  5933. 'area_trans' => '',
  5934. ),
  5935. 'emailCCName' =>
  5936. array (
  5937. 'name' => 'emailCCName',
  5938. 'desc' => 'prop_formit.emailccname_desc',
  5939. 'type' => 'textfield',
  5940. 'options' => '',
  5941. 'value' => '',
  5942. 'lexicon' => 'formit:properties',
  5943. 'area' => '',
  5944. 'desc_trans' => 'Optional. If `email` is set as a hook, then this must be a parallel list of comma-separated names for the email addresses specified in the `emailCC` property.',
  5945. 'area_trans' => '',
  5946. ),
  5947. 'emailBCC' =>
  5948. array (
  5949. 'name' => 'emailBCC',
  5950. 'desc' => 'prop_formit.emailbcc_desc',
  5951. 'type' => 'textfield',
  5952. 'options' => '',
  5953. 'value' => '',
  5954. 'lexicon' => 'formit:properties',
  5955. 'area' => '',
  5956. 'desc_trans' => 'If `email` is set as a hook, then this specifies the email(s) to send the email to as a BCC. Can be a comma-separated list of email addresses.',
  5957. 'area_trans' => '',
  5958. ),
  5959. 'emailBCCName' =>
  5960. array (
  5961. 'name' => 'emailBCCName',
  5962. 'desc' => 'prop_formit.emailbccname_desc',
  5963. 'type' => 'textfield',
  5964. 'options' => '',
  5965. 'value' => '',
  5966. 'lexicon' => 'formit:properties',
  5967. 'area' => '',
  5968. 'desc_trans' => 'Optional. If `email` is set as a hook, then this must be a parallel list of comma-separated names for the email addresses specified in the `emailBCC` property.',
  5969. 'area_trans' => '',
  5970. ),
  5971. 'emailReturnPath' =>
  5972. array (
  5973. 'name' => 'emailReturnPath',
  5974. 'desc' => 'prop_formit.emailreturnpath_desc',
  5975. 'type' => 'textfield',
  5976. 'options' => '',
  5977. 'value' => '',
  5978. 'lexicon' => 'formit:properties',
  5979. 'area' => '',
  5980. 'desc_trans' => 'Optional. If `email` is set as a hook, and this is set, will specify the Return-path: address for the email. If not set, will take the value of `emailFrom` property.',
  5981. 'area_trans' => '',
  5982. ),
  5983. 'emailSubject' =>
  5984. array (
  5985. 'name' => 'emailSubject',
  5986. 'desc' => 'prop_formit.emailsubject_desc',
  5987. 'type' => 'textfield',
  5988. 'options' => '',
  5989. 'value' => '',
  5990. 'lexicon' => 'formit:properties',
  5991. 'area' => '',
  5992. 'desc_trans' => 'If `email` is set as a hook, this is required as a subject line for the email.',
  5993. 'area_trans' => '',
  5994. ),
  5995. 'emailUseFieldForSubject' =>
  5996. array (
  5997. 'name' => 'emailUseFieldForSubject',
  5998. 'desc' => 'prop_formit.emailusefieldforsubject_desc',
  5999. 'type' => 'textfield',
  6000. 'options' => '',
  6001. 'value' => '',
  6002. 'lexicon' => 'formit:properties',
  6003. 'area' => '',
  6004. 'desc_trans' => 'If the field `subject` is passed into the form, if this is true, it will use the field content for the subject line of the email.',
  6005. 'area_trans' => '',
  6006. ),
  6007. 'emailHtml' =>
  6008. array (
  6009. 'name' => 'emailHtml',
  6010. 'desc' => 'prop_formit.emailhtml_desc',
  6011. 'type' => 'combo-boolean',
  6012. 'options' => '',
  6013. 'value' => true,
  6014. 'lexicon' => 'formit:properties',
  6015. 'area' => '',
  6016. 'desc_trans' => 'Optional. If `email` is set as a hook, this toggles HTML emails or not. Defaults to true.',
  6017. 'area_trans' => '',
  6018. ),
  6019. 'emailConvertNewlines' =>
  6020. array (
  6021. 'name' => 'emailConvertNewlines',
  6022. 'desc' => 'prop_formit.emailconvertnewlines_desc',
  6023. 'type' => 'combo-boolean',
  6024. 'options' => '',
  6025. 'value' => false,
  6026. 'lexicon' => 'formit:properties',
  6027. 'area' => '',
  6028. 'desc_trans' => 'If true and emailHtml is set to 1, will convert newlines to BR tags in the email.',
  6029. 'area_trans' => '',
  6030. ),
  6031. 'emailMultiWrapper' =>
  6032. array (
  6033. 'name' => 'emailMultiWrapper',
  6034. 'desc' => 'prop_formit.emailmultiwrapper_desc',
  6035. 'type' => 'textfield',
  6036. 'options' => '',
  6037. 'value' => '[[+value]]',
  6038. 'lexicon' => 'formit:properties',
  6039. 'area' => '',
  6040. 'desc_trans' => 'Will wrap each item in a collection of fields sent via checkboxes/multi-selects. Defaults to just the value.',
  6041. 'area_trans' => '',
  6042. ),
  6043. 'emailMultiSeparator' =>
  6044. array (
  6045. 'name' => 'emailMultiSeparator',
  6046. 'desc' => 'prop_formit.emailmultiseparator_desc',
  6047. 'type' => 'textfield',
  6048. 'options' => '',
  6049. 'value' => '',
  6050. 'lexicon' => 'formit:properties',
  6051. 'area' => '',
  6052. 'desc_trans' => 'The default separator for collections of items sent through checkboxes/multi-selects. Defaults to a newline.',
  6053. 'area_trans' => '',
  6054. ),
  6055. 'fiarTpl' =>
  6056. array (
  6057. 'name' => 'fiarTpl',
  6058. 'desc' => 'prop_formit.fiartpl_desc',
  6059. 'type' => 'textfield',
  6060. 'options' => '',
  6061. 'value' => '',
  6062. 'lexicon' => 'formit:properties',
  6063. 'area' => '',
  6064. 'desc_trans' => 'prop_formit.fiartpl_desc',
  6065. 'area_trans' => '',
  6066. ),
  6067. 'fiarToField' =>
  6068. array (
  6069. 'name' => 'fiarToField',
  6070. 'desc' => 'prop_formit.fiartofield_desc',
  6071. 'type' => 'textfield',
  6072. 'options' => '',
  6073. 'value' => 'email',
  6074. 'lexicon' => 'formit:properties',
  6075. 'area' => '',
  6076. 'desc_trans' => 'prop_formit.fiartofield_desc',
  6077. 'area_trans' => '',
  6078. ),
  6079. 'fiarSubject' =>
  6080. array (
  6081. 'name' => 'fiarSubject',
  6082. 'desc' => 'prop_formit.fiarsubject_desc',
  6083. 'type' => 'textfield',
  6084. 'options' => '',
  6085. 'value' => '[[++site_name]] Auto-Responder',
  6086. 'lexicon' => 'formit:properties',
  6087. 'area' => '',
  6088. 'desc_trans' => 'prop_formit.fiarsubject_desc',
  6089. 'area_trans' => '',
  6090. ),
  6091. 'fiarFrom' =>
  6092. array (
  6093. 'name' => 'fiarFrom',
  6094. 'desc' => 'prop_formit.fiarfrom_desc',
  6095. 'type' => 'textfield',
  6096. 'options' => '',
  6097. 'value' => '',
  6098. 'lexicon' => 'formit:properties',
  6099. 'area' => '',
  6100. 'desc_trans' => 'prop_formit.fiarfrom_desc',
  6101. 'area_trans' => '',
  6102. ),
  6103. 'fiarFromName' =>
  6104. array (
  6105. 'name' => 'fiarFromName',
  6106. 'desc' => 'prop_formit.fiarfromname_desc',
  6107. 'type' => 'textfield',
  6108. 'options' => '',
  6109. 'value' => '',
  6110. 'lexicon' => 'formit:properties',
  6111. 'area' => '',
  6112. 'desc_trans' => 'prop_formit.fiarfromname_desc',
  6113. 'area_trans' => '',
  6114. ),
  6115. 'fiarReplyTo' =>
  6116. array (
  6117. 'name' => 'fiarReplyTo',
  6118. 'desc' => 'prop_formit.fiarreplyto_desc',
  6119. 'type' => 'textfield',
  6120. 'options' => '',
  6121. 'value' => '',
  6122. 'lexicon' => 'formit:properties',
  6123. 'area' => '',
  6124. 'desc_trans' => 'prop_formit.fiarreplyto_desc',
  6125. 'area_trans' => '',
  6126. ),
  6127. 'fiarReplyToName' =>
  6128. array (
  6129. 'name' => 'fiarReplyToName',
  6130. 'desc' => 'prop_formit.fiarreplytoname_desc',
  6131. 'type' => 'textfield',
  6132. 'options' => '',
  6133. 'value' => '',
  6134. 'lexicon' => 'formit:properties',
  6135. 'area' => '',
  6136. 'desc_trans' => 'prop_formit.fiarreplytoname_desc',
  6137. 'area_trans' => '',
  6138. ),
  6139. 'fiarCC' =>
  6140. array (
  6141. 'name' => 'fiarCC',
  6142. 'desc' => 'prop_formit.fiarcc_desc',
  6143. 'type' => 'textfield',
  6144. 'options' => '',
  6145. 'value' => '',
  6146. 'lexicon' => 'formit:properties',
  6147. 'area' => '',
  6148. 'desc_trans' => 'prop_formit.fiarcc_desc',
  6149. 'area_trans' => '',
  6150. ),
  6151. 'fiarCCName' =>
  6152. array (
  6153. 'name' => 'fiarCCName',
  6154. 'desc' => 'prop_fiar.fiarccname_desc',
  6155. 'type' => 'textfield',
  6156. 'options' => '',
  6157. 'value' => '',
  6158. 'lexicon' => 'formit:properties',
  6159. 'area' => '',
  6160. 'desc_trans' => 'Optional. If `FormItAutoResponder` is set as a hook, then this must be a parallel list of comma-separated names for the email addresses specified in the `emailCC` property.',
  6161. 'area_trans' => '',
  6162. ),
  6163. 'fiarBCC' =>
  6164. array (
  6165. 'name' => 'fiarBCC',
  6166. 'desc' => 'prop_formit.fiarbcc_desc',
  6167. 'type' => 'textfield',
  6168. 'options' => '',
  6169. 'value' => '',
  6170. 'lexicon' => 'formit:properties',
  6171. 'area' => '',
  6172. 'desc_trans' => 'prop_formit.fiarbcc_desc',
  6173. 'area_trans' => '',
  6174. ),
  6175. 'fiarBCCName' =>
  6176. array (
  6177. 'name' => 'fiarBCCName',
  6178. 'desc' => 'prop_formit.fiarbccname_desc',
  6179. 'type' => 'textfield',
  6180. 'options' => '',
  6181. 'value' => '',
  6182. 'lexicon' => 'formit:properties',
  6183. 'area' => '',
  6184. 'desc_trans' => 'prop_formit.fiarbccname_desc',
  6185. 'area_trans' => '',
  6186. ),
  6187. 'fiarHtml' =>
  6188. array (
  6189. 'name' => 'fiarHtml',
  6190. 'desc' => 'prop_formit.fiarhtml_desc',
  6191. 'type' => 'combo-boolean',
  6192. 'options' => '',
  6193. 'value' => true,
  6194. 'lexicon' => 'formit:properties',
  6195. 'area' => '',
  6196. 'desc_trans' => 'prop_formit.fiarhtml_desc',
  6197. 'area_trans' => '',
  6198. ),
  6199. 'mathMinRange' =>
  6200. array (
  6201. 'name' => 'mathMinRange',
  6202. 'desc' => 'prop_formit.mathminrange_desc',
  6203. 'type' => 'textfield',
  6204. 'options' => '',
  6205. 'value' => '10',
  6206. 'lexicon' => 'formit:properties',
  6207. 'area' => '',
  6208. 'desc_trans' => 'prop_formit.mathminrange_desc',
  6209. 'area_trans' => '',
  6210. ),
  6211. 'mathMaxRange' =>
  6212. array (
  6213. 'name' => 'mathMaxRange',
  6214. 'desc' => 'prop_formit.mathmaxrange_desc',
  6215. 'type' => 'textfield',
  6216. 'options' => '',
  6217. 'value' => '100',
  6218. 'lexicon' => 'formit:properties',
  6219. 'area' => '',
  6220. 'desc_trans' => 'prop_formit.mathmaxrange_desc',
  6221. 'area_trans' => '',
  6222. ),
  6223. 'mathField' =>
  6224. array (
  6225. 'name' => 'mathField',
  6226. 'desc' => 'prop_formit.mathfield_desc',
  6227. 'type' => 'textfield',
  6228. 'options' => '',
  6229. 'value' => 'math',
  6230. 'lexicon' => 'formit:properties',
  6231. 'area' => '',
  6232. 'desc_trans' => 'prop_formit.mathfield_desc',
  6233. 'area_trans' => '',
  6234. ),
  6235. 'mathOp1Field' =>
  6236. array (
  6237. 'name' => 'mathOp1Field',
  6238. 'desc' => 'prop_formit.mathop1field_desc',
  6239. 'type' => 'textfield',
  6240. 'options' => '',
  6241. 'value' => 'op1',
  6242. 'lexicon' => 'formit:properties',
  6243. 'area' => '',
  6244. 'desc_trans' => 'prop_formit.mathop1field_desc',
  6245. 'area_trans' => '',
  6246. ),
  6247. 'mathOp2Field' =>
  6248. array (
  6249. 'name' => 'mathOp2Field',
  6250. 'desc' => 'prop_formit.mathop2field_desc',
  6251. 'type' => 'textfield',
  6252. 'options' => '',
  6253. 'value' => 'op2',
  6254. 'lexicon' => 'formit:properties',
  6255. 'area' => '',
  6256. 'desc_trans' => 'prop_formit.mathop2field_desc',
  6257. 'area_trans' => '',
  6258. ),
  6259. 'mathOperatorField' =>
  6260. array (
  6261. 'name' => 'mathOperatorField',
  6262. 'desc' => 'prop_formit.mathoperatorfield_desc',
  6263. 'type' => 'textfield',
  6264. 'options' => '',
  6265. 'value' => 'operator',
  6266. 'lexicon' => 'formit:properties',
  6267. 'area' => '',
  6268. 'desc_trans' => 'prop_formit.mathoperatorfield_desc',
  6269. 'area_trans' => '',
  6270. ),
  6271. 'saveTmpFiles' =>
  6272. array (
  6273. 'name' => 'saveTmpFiles',
  6274. 'desc' => 'prop_formit.savetmpfiles_desc',
  6275. 'type' => 'combo-boolean',
  6276. 'options' => '',
  6277. 'value' => false,
  6278. 'lexicon' => 'formit:properties',
  6279. 'area' => '',
  6280. 'desc_trans' => 'If set to 1, FormIt will store submitted files in a temporary folder.',
  6281. 'area_trans' => '',
  6282. ),
  6283. 'attachFilesToEmail' =>
  6284. array (
  6285. 'name' => 'attachFilesToEmail',
  6286. 'desc' => 'prop_formit.attachfiles_desc',
  6287. 'type' => 'combo-boolean',
  6288. 'options' => '',
  6289. 'value' => true,
  6290. 'lexicon' => 'formit:properties',
  6291. 'area' => '',
  6292. 'desc_trans' => 'If true, FormIt will add all file fields as attachments in the email.',
  6293. 'area_trans' => '',
  6294. ),
  6295. 'storeAttachments' =>
  6296. array (
  6297. 'name' => 'storeAttachments',
  6298. 'desc' => 'prop_formit.store_attachments_desc',
  6299. 'type' => 'combo-boolean',
  6300. 'options' => '',
  6301. 'value' => false,
  6302. 'lexicon' => 'formit:properties',
  6303. 'area' => '',
  6304. 'desc_trans' => 'prop_formit.store_attachments_desc',
  6305. 'area_trans' => '',
  6306. ),
  6307. ),
  6308. 'moduleguid' => '',
  6309. 'static' => false,
  6310. 'static_file' => '',
  6311. 'content' => '/**
  6312. * FormIt
  6313. *
  6314. * Copyright 2009-2012 by Shaun McCormick <shaun@modx.com>
  6315. *
  6316. * FormIt is free software; you can redistribute it and/or modify it
  6317. * under the terms of the GNU General Public License as published by the Free
  6318. * Software Foundation; either version 2 of the License, or (at your option) any
  6319. * later version.
  6320. *
  6321. * FormIt is distributed in the hope that it will be useful, but WITHOUT ANY
  6322. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  6323. * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  6324. *
  6325. * You should have received a copy of the GNU General Public License along with
  6326. * FormIt; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
  6327. * Suite 330, Boston, MA 02111-1307 USA
  6328. *
  6329. * @package formit
  6330. */
  6331. /**
  6332. * FormIt
  6333. *
  6334. * A dynamic form processing Snippet for MODx Revolution.
  6335. *
  6336. * @var modX $modx
  6337. * @var array $scriptProperties
  6338. *
  6339. * @package formit
  6340. */
  6341. $modelPath = $modx->getOption(
  6342. \'formit.core_path\',
  6343. null,
  6344. $modx->getOption(\'core_path\', null, MODX_CORE_PATH) . \'components/formit/\'
  6345. ) . \'model/formit/\';
  6346. $modx->loadClass(\'FormIt\', $modelPath, true, true);
  6347. $fi = new FormIt($modx, $scriptProperties);
  6348. $fi->initialize($modx->context->get(\'key\'));
  6349. $fi->loadRequest();
  6350. $fields = $fi->request->prepare();
  6351. return $fi->request->handle($fields);',
  6352. ),
  6353. 'policies' =>
  6354. array (
  6355. 'web' =>
  6356. array (
  6357. ),
  6358. ),
  6359. 'source' =>
  6360. array (
  6361. ),
  6362. ),
  6363. 'soilformSubmit' =>
  6364. array (
  6365. 'fields' =>
  6366. array (
  6367. 'id' => 39,
  6368. 'source' => 0,
  6369. 'property_preprocess' => false,
  6370. 'name' => 'soilformSubmit',
  6371. 'description' => '',
  6372. 'editor_type' => 0,
  6373. 'category' => 24,
  6374. 'cache_type' => 0,
  6375. 'snippet' => '//error_reporting(E_ALL);
  6376. error_reporting(E_ALL ^ E_NOTICE);
  6377. ini_set(\'display_errors\', 1);
  6378. $errorLog = 1;
  6379. if(isset($_POST[\'SoilcsvForm\'])) {
  6380. if ($errorLog = "1") { error_log(print_r($_POST, true)); }
  6381. $sql = null;
  6382. $con = mysqli_connect("localhost", "root", "R3M0T31", "cropmonitor");
  6383. //set todays date
  6384. $date = date("Y-m-d H:i:s");
  6385. // ****************************************************************************
  6386. // Client Details
  6387. $client_id = (isset($_POST["client_id"])) ? $_POST["client_id"] : "";
  6388. $modx_id = (isset($_POST["m_user"])) ? $_POST["m_user"] : "";
  6389. $email = (isset($_POST["email"])) ? $_POST["email"] : "";
  6390. $client_name = (isset($_POST["name"])) ? $_POST["name"] : "";
  6391. $site_address = (isset($_POST["site_address"])) ? $_POST["site_address"] : "";
  6392. $state_postcode = (isset($_POST["state_postcode"])) ? $_POST["state_postcode"] : "";
  6393. // Analysis Details
  6394. $analysis_type = "Soil Test"; //for future types of Soil Analysis
  6395. $lab_no = (isset($_POST["lab_no"])) ? $_POST["lab_no"] : "";
  6396. $batch_no = (isset($_POST["batch_no"])) ? $_POST["batch_no"] : "";
  6397. $sample_id = (isset($_POST["sample_id"])) ? $_POST["sample_id"] : "";
  6398. $site_id = (isset($_POST["site_id"])) ? $_POST["site_id"] : "";
  6399. $crop_type = (isset($_POST["crop_type"])) ? $_POST["crop_type"] : "";
  6400. $soil_type = (isset($_POST["soil_type"])) ? $_POST["soil_type"] : "";
  6401. $date_sampled = (isset($_POST["date_sampled"])) ? $_POST["date_sampled"] : "";
  6402. $date_sampled = date("Y-m-d", strtotime($date_sampled));
  6403. // Sample Details
  6404. $texture = (isset($_POST["texture"])) ? $_POST["texture"] : "";
  6405. $gravel = (isset($_POST["gravel"])) ? $_POST["gravel"] : "";
  6406. $colour = (isset($_POST["colour"])) ? $_POST["colour"] : "";
  6407. $ocarbon = (isset($_POST["ocarbon"])) ? $_POST["ocarbon"] : "";
  6408. $omatter = (isset($_POST["omatter"])) ? $_POST["omatter"] : "";
  6409. $ph_cacl2 = (isset($_POST["ph_cacl2"])) ? $_POST["ph_cacl2"] : "";
  6410. $ph_h2o = (isset($_POST["ph_h2o"])) ? $_POST["ph_h2o"] : "";
  6411. $paramag = (isset($_POST["paramag"])) ? $_POST["paramag"] : "";
  6412. $ec = (isset($_POST["ec"])) ? $_POST["ec"] : "";
  6413. // Nutrient Details
  6414. $NO3_N = (isset($_POST["NO3_N"])) ? $_POST["NO3_N"] : "";
  6415. $NH3_N = (isset($_POST["NH3_N"])) ? $_POST["NH3_N"] : "";
  6416. $p_mehlick = (isset($_POST["p_mehlick"])) ? $_POST["p_mehlick"] : "";
  6417. $p_bray2 = (isset($_POST["p_bray2"])) ? $_POST["p_bray2"] : "";
  6418. $p_morgan = (isset($_POST["p_morgan"])) ? $_POST["p_morgan"] : "";
  6419. $k_morgan = (isset($_POST["k_morgan"])) ? $_POST["k_morgan"] : "";
  6420. $ca_morgan = (isset($_POST["ca_morgan"])) ? $_POST["ca_morgan"] : "";
  6421. $mg_morgan = (isset($_POST["mg_morgan"])) ? $_POST["mg_morgan"] : "";
  6422. $na_morgan = (isset($_POST["na_morgan"])) ? $_POST["na_morgan"] : "";
  6423. $ch_h2o = (isset($_POST["ch_h2o"])) ? $_POST["ch_h2o"] : "";
  6424. $fe = (isset($_POST["fe"])) ? $_POST["fe"] : "";
  6425. $s_morgan = (isset($_POST["s_morgan"])) ? $_POST["s_morgan"] : "";
  6426. $b_cacl2 = (isset($_POST["b_cacl2"])) ? $_POST["b_cacl2"] : "";
  6427. $mn_dtpa = (isset($_POST["mn_dtpa"])) ? $_POST["mn_dtpa"] : "";
  6428. $zn_dtpa = (isset($_POST["zn_dtpa"])) ? $_POST["zn_dtpa"] : "";
  6429. $fe_dtpa = (isset($_POST["fe_dtpa"])) ? $_POST["fe_dtpa"] : "";
  6430. $cu_dtpa = (isset($_POST["cu_dtpa"])) ? $_POST["cu_dtpa"] : "";
  6431. $al = (isset($_POST["al"])) ? $_POST["al"] : "";
  6432. $sl_cacl2 = (isset($_POST["sl_cacl2"])) ? $_POST["sl_cacl2"] : "";
  6433. $m_dtpa = (isset($_POST["m_dtpa"])) ? $_POST["m_dtpa"] : "";
  6434. $co_dtpa = (isset($_POST["co_dtpa"])) ? $_POST["co_dtpa"] : "";
  6435. $se = (isset($_POST["se"])) ? $_POST["se"] : "";
  6436. // Base Saturation Details
  6437. $tec = (isset($_POST["tec"])) ? $_POST["tec"] : "";
  6438. $cec = (isset($_POST["cec"])) ? $_POST["cec"] : "";
  6439. //Base Saturation as M.E./100g
  6440. $ca_mehlick3 = (isset($_POST["ca_mehlick3"])) ? $_POST["ca_mehlick3"] : "";
  6441. $mg_mehlick3 = (isset($_POST["mg_mehlick3"])) ? $_POST["mg_mehlick3"] : "";
  6442. $k_mehlick3 = (isset($_POST["k_mehlick3"])) ? $_POST["k_mehlick3"] : "";
  6443. $na_mehlick3 = (isset($_POST["na_mehlick3"])) ? $_POST["na_mehlick3"] : "";
  6444. $al_mehlick3 = (isset($_POST["al_mehlick3"])) ? $_POST["al_mehlick3"] : "";
  6445. //Base Saturation as PPM
  6446. if ($_POST["calcium_me3"] == "ppm") {
  6447. $ca_mehlick3 = (isset($_POST["ca_mehlick3_ppm"])) ? ($_POST["ca_mehlick3_ppm"] / 200) : "";
  6448. }
  6449. if ($_POST["magnesium_me3"] == "ppm") {
  6450. $mg_mehlick3 = (isset($_POST["mg_mehlick3_ppm"])) ? ($_POST["mg_mehlick3_ppm"] / 120) : "";
  6451. }
  6452. if ($_POST["postassium_me3"] == "ppm") {
  6453. $k_mehlick = (isset($_POST["k_mehlick3_ppm"])) ? ($_POST["k_mehlick3_ppm"] / 390) : "";
  6454. }
  6455. if ($_POST["soduim_me3"] == "ppm") {
  6456. $na_mehlick3 = (isset($_POST["na_mehlick3_ppm"])) ? ($_POST["na_mehlick3_ppm"] / 230) : "";
  6457. }
  6458. // Totals for Ratis
  6459. $c_total = (isset($_POST["c_total"])) ? $_POST["c_total"] : "";
  6460. $n_total = (isset($_POST["n_total"])) ? $_POST["n_total"] : "";
  6461. //Create Carbon Nitrogen Ratio if not specified
  6462. if ($_POST["c_nRatio"] = "") {
  6463. $c_nRatio = (isset($_POST["c_nRatio"])) ? $_POST["c_nRatio"] : "";
  6464. } else {
  6465. $c_nRatio = ( $c_total / $n_total );
  6466. }
  6467. //Create CA MG Ratio if not specified
  6468. if ($_POST["ca_mgRatio"] = "") {
  6469. $ca_mgRatio = (isset($_POST["ca_mgRatio"])) ? $_POST["ca_mgRatio"] : "";
  6470. } else {
  6471. $ca_mgRatio = ( (int)$ca_mehlick3 / (int)$mg_mehlick3 );
  6472. }
  6473. //$rand = substr(md5(microtime()),rand(0,26),5);
  6474. $rand = mt_rand(10000, 99999);
  6475. // PH lookup table (ph*10 rounded to single decimal point for easy lookup)
  6476. $phrange = array(
  6477. 30 => [75.0, 11.4],
  6478. 31 => [74.0, 11.2],
  6479. 32 => [73.0, 11.0],
  6480. 33 => [72.0, 10.8],
  6481. 34 => [71.0, 10.6],
  6482. 35 => [70.0, 10.4],
  6483. 36 => [69.0, 10.2],
  6484. 37 => [68.0, 10.0],
  6485. 38 => [67.0, 9.8],
  6486. 39 => [66.0, 9.6],
  6487. 40 => [65.0, 9.4],
  6488. 41 => [63.0, 9.2],
  6489. 42 => [61.0, 9.0],
  6490. 43 => [59.0, 8.8],
  6491. 44 => [57.0, 8.6],
  6492. 45 => [55.0, 8.4],
  6493. 46 => [53.0, 8.2],
  6494. 47 => [51.0, 8.0],
  6495. 48 => [49.0, 7.8],
  6496. 49 => [47.0, 7.6],
  6497. 50 => [45.0, 7.4],
  6498. 51 => [42.0, 7.2],
  6499. 52 => [39.0, 7.0],
  6500. 53 => [36.0, 6.8],
  6501. 54 => [33.0, 6.6],
  6502. 55 => [30.0, 6.4],
  6503. 56 => [27.0, 6.2],
  6504. 57 => [24.0, 6.0],
  6505. 58 => [21.0, 5.8],
  6506. 59 => [18.0, 5.6],
  6507. 60 => [15.0, 5.4],
  6508. 61 => [13.5, 5.3],
  6509. 62 => [12.0, 5.2],
  6510. 63 => [10.5, 5.1],
  6511. 64 => [9.0, 5.0],
  6512. 65 => [7.5, 4.9],
  6513. 66 => [6.0, 4.8],
  6514. 67 => [4.5, 4.7],
  6515. 68 => [3.0, 4.6],
  6516. 69 => [1.5, 4.5],
  6517. 70 => [0.0, 4.4],
  6518. 71 => [0.0, 4.3],
  6519. 72 => [0.0, 4.2],
  6520. 73 => [0.0, 4.1],
  6521. 74 => [0.0, 4.0],
  6522. 75 => [0.0, 3.9],
  6523. 76 => [0.0, 3.8],
  6524. 77 => [0.0, 3.7],
  6525. 78 => [0.0, 3.6],
  6526. 79 => [0.0, 3.5],
  6527. 80 => [0.0, 3.4],
  6528. 81 => [0.0, 3.3],
  6529. 82 => [0.0, 3.2],
  6530. 83 => [0.0, 3.1],
  6531. 84 => [0.0, 3.0],
  6532. 85 => [0.0, 2.9],
  6533. 86 => [0.0, 2.8],
  6534. 87 => [0.0, 2.7],
  6535. 88 => [0.0, 2.6],
  6536. 89 => [0.0, 2.5],
  6537. 90 => [0.0, 2.4],
  6538. 91 => [0.0, 2.3],
  6539. 92 => [0.0, 2.2],
  6540. 93 => [0.0, 2.1],
  6541. 94 => [0.0, 2.0],
  6542. 95 => [0.0, 1.9],
  6543. 96 => [0.0, 1.8],
  6544. 97 => [0.0, 1.7],
  6545. 98 => [0.0, 1.6],
  6546. 99 => [0.0, 1.5],
  6547. 100 => [0.0, 1.4],
  6548. );
  6549. /* ********* START ********* */
  6550. /* ********* ADD BASE SATURATION CALCULATION HERE ********* */
  6551. // Calculating hydrogen and otherbases
  6552. $ph = $ph_h2o; // $ph_h2o from above
  6553. $aluminium = $al_mehlick3;
  6554. // round the ph value to single decimal point
  6555. $ph_lookup = round($ph, 2);
  6556. if ($errorLog = "1") { error_log(print_r("ph_lookup: " . $ph_lookup . " ph: " . $ph, true )); }
  6557. // lookup Hydrogen and Other Bases
  6558. $hydrogen = $phrange[($ph_lookup * 10)][0];
  6559. $otherbases = $phrange[($ph_lookup * 10)][1];
  6560. $h_rec = round($hydrogen, 2); // recommended level added to DB
  6561. $ob_rec = round($otherbases, 2); // recommended level added to DB
  6562. if ($errorLog = "1") { error_log(print_r("Hydrogen: " . $hydrogen . " Other Bases: " . $otherbases, true)); }
  6563. if ( $aluminium < 0 ) {
  6564. $otherbases = 0;
  6565. }
  6566. $obresult = 0; // obresult == Other Bases Result
  6567. $hresult = 0; // hresult == Hydrogen Result
  6568. // IF ********************************************************************************
  6569. if ( $otherbases > 0 ) {
  6570. while ( (($obresult * 100) / $cec) <= $otherbases ) {
  6571. $obresult += 0.001;
  6572. $tempNo = $obresult;
  6573. $tempNo1 = $otherbases;
  6574. $tempNo2 = $hydrogen;
  6575. // CAUTION: storing value in Calc:E16
  6576. $hresult = ($tempNo * $tempNo2) / $tempNo1;
  6577. }
  6578. $obresult -= 0.001;
  6579. if ( $hresult != 0 ){
  6580. $hresult -= 0.001;
  6581. }
  6582. } else {
  6583. while( (($hresult * 100) / $tec) <= $hydrogen ) {
  6584. $hresultl += 0.001;
  6585. }
  6586. $hresult -= 0.001;
  6587. }
  6588. if ($errorLog = "1") { error_log(print_r("hresult: " . $hresult . " obresult: " . $obresult, true)); }
  6589. // END If ********************************************************************************
  6590. // Calculating Ca Mg K Na levels based on temp
  6591. // *** I think that the tecTemp needs to be a sum of $tec and $hresult and $obresult ***
  6592. // *** As far as I can see on the spreadsheet the TEC in CALC:B16 is "CEC + obresult + CALC:E16"
  6593. $tecTemp = $cec + $obresult + $hresult;
  6594. $tec = round($tecTemp, 2);
  6595. $cec = round($cec, 2);
  6596. if ($errorLog = "1") { error_log(print_r("tecTemp: " . $tecTemp . " cec: " . $cec . " tec: " . $tec, true)); }
  6597. // CAUTION: for $tecTemp values below 1 and above 100000 this will not work
  6598. if ( ( 1.0 < $tecTemp ) && ( $tecTemp >= 3.0 ) ) {
  6599. $cabs = $CABS = 0;
  6600. $cabsmax = $CABSMAX = 60.00;
  6601. $mgbs = $MGBS = 0;
  6602. $mgbsmax = $MGBSMAX = 20.00;
  6603. $kbs = $KBS = 5.00;
  6604. $kbsmax = $KBSMAX = 7.00;
  6605. $nabs = $NABS = 0.50;
  6606. $nabsmax = $NABSMAX = 1.50;
  6607. }
  6608. elseif ( ( 3.0 < $tecTemp ) && ( $tecTemp >= 5.0 ) ) {
  6609. $cabs = $CABS = 0;
  6610. $cabsmax = $CABSMAX = 62.00;
  6611. $mgbs = $MGBS = 0;
  6612. $mgbsmax = $MGBSMAX = 18.00;
  6613. $kbs = $KBS = 5.00;
  6614. $kbsmax = $KBSMAX = 7.00;
  6615. $nabs = $NABS = 0.50;
  6616. $nabsmax = $NABSMAX = 1.50;
  6617. }
  6618. elseif ( ( 5.0 < $tecTemp ) && ( $tecTemp >= 7.0 ) ) {
  6619. $cabs = $CABS = 0;
  6620. $cabsmax = $CABSMAX = 64.00;
  6621. $mgbs = $MGBS = 0;
  6622. $mgbsmax = $MGBSMAX = 16.00;
  6623. $kbs = $KBS = 4.00;
  6624. $kbsmax = $KBSMAX = 7.00;
  6625. $nabs = $NABS = 0.50;
  6626. $nabsmax = $NABSMAX = 1.50;
  6627. }
  6628. elseif ( ( 7.0 < $tecTemp ) && ( $tecTemp >= 9.0 ) ) {
  6629. $cabs = $CABS = 0;
  6630. $cabsmax = $CABSMAX = 65.00;
  6631. $mgbs = $MGBS = 0;
  6632. $mgbsmax = $MGBSMAX = 15.00;
  6633. $kbs = $KBS = 4.00;
  6634. $kbsmax = $KBSMAX = 7.00;
  6635. $nabs = $NABS = 0.50;
  6636. $nabsmax = $NABSMAX = 1.50;
  6637. }
  6638. elseif ( ( 9.0 < $tecTemp ) && ( $tecTemp >= 11.0 ) ) {
  6639. $cabs = $CABS = 0;
  6640. $cabsmax = $CABSMAX = 67.00;
  6641. $mgbs = $MGBS = 0;
  6642. $mgbsmax = $MGBSMAX = 13.00;
  6643. $kbs = $KBS = 4.00;
  6644. $kbsmax = $KBSMAX = 7.00;
  6645. $nabs = $NABS = 0.50;
  6646. $nabsmax = $NABSMAX = 1.50;
  6647. }
  6648. elseif ( ( 11.0 < $tecTemp ) && ( $tecTemp >= 30.0 ) ) {
  6649. $cabs = $CABS = 0;
  6650. $cabsmax = $CABSMAX = 68.00;
  6651. $mgbs = $MGBS = 0;
  6652. $mgbsmax = $MGBSMAX = 12.00;
  6653. $kbs = $KBS = 4.00;
  6654. $kbsmax = $KBSMAX = 7.00;
  6655. $nabs = $NABS = 0.50;
  6656. $nabsmax = $NABSMAX = 1.50;
  6657. }
  6658. elseif ( ( 30.0 < $tecTemp ) && ( $tecTemp >= 100000.0 ) ) {
  6659. $cabs = $CABS = 0;
  6660. $cabsmax = $CABSMAX = 70.00;
  6661. $mgbs = $MGBS = 0;
  6662. $mgbsmax = $MGBSMAX = 10.00;
  6663. $kbs = $KBS = 3.00;
  6664. $kbsmax = $KBSMAX = 6.00;
  6665. $nabs = $NABS = 0.50;
  6666. $nabsmax = $NABSMAX = 1.50;
  6667. }
  6668. // *** CALCULATED TEC % AND PPM MIN / MAX LEVELS
  6669. $cabs_min = $cabs;
  6670. $ca_ppm_min = ( $tec * $cabs_min *2 );
  6671. $cabs_max = $cabsmax;
  6672. $ca_ppm_max = ( $tec * $cabs_max * 2);
  6673. $mgbs_min = $mgbs;
  6674. $mg_ppm_min = ( $tec * $mgbs_min * 1.2 );
  6675. $mgbs_max = $mgbsmax;
  6676. $mg_ppm_max = ( $tec * $mgbs_max * 1.2 );
  6677. $kbs_min = $kbs;
  6678. $k_ppm_min = ( $tec * $kbs_min * 3.9 );
  6679. $kbs_max = $kbsmax;
  6680. $k_ppm_max = ( $tec * $kbs_max * 3.9 );
  6681. $nabs_min = $nabs;
  6682. $na_ppm_min = ( $tec * $nabs_min * 2.3 );
  6683. $nabs_max = $nabsmax;
  6684. $na_ppm_max = ( $tec * $nabs_max * 2.3 );
  6685. $albs_min = "0";
  6686. $al_ppm_min = ( $tec * $albs_min * 0.9 );
  6687. $albs_max = "0.5";
  6688. $al_ppm_max = ( $tec * $albs_max * 0.9 );
  6689. // *** CALCULATED TEC LEVELS
  6690. $cabs_tec = ( $ca_mehlick3 / $tec ) * 100;
  6691. $cabs_tec = round($cabs_tec, 2);
  6692. $mgbs_tec = ( $mg_mehlick3 / $tec ) * 100;
  6693. $mgbs_tec = round($mgbs_tec, 2);
  6694. $kbs_tec = ( $k_mehlick3 / $tec ) * 100;
  6695. $kbs_tec = round($kbs_tec, 2);
  6696. $nabs_tec = ( $na_mehlick3 / $tec ) * 100;
  6697. $nabs_tec = round($nabs_tec, 2);
  6698. $albs_tec = ( $al_mehlick3 / $tec ) * 100;
  6699. $albs_tec = round($albs_tec, 2);
  6700. // *** CALCULATED PPM FROM MEQ
  6701. $BS_ca_ppm = $ca_mehlick3 * 200;
  6702. $BS_mg_ppm = $mg_mehlick3 * 120;
  6703. $BS_k_ppm = $k_mehlick3 * 390;
  6704. $BS_na_ppm = $na_mehlick3 * 230;
  6705. $BS_al_ppm = $al_mehlick3 * 90;
  6706. /* ********* ADD BASE SATURATION CALCULATION HERE ********* */
  6707. /* ********* END ********* */
  6708. // Check connection
  6709. if (mysqli_connect_errno())
  6710. {
  6711. echo "Failed to connect to MySQL: " . mysqli_connect_error();
  6712. }
  6713. $sql = mysqli_query($con, "INSERT into `soil_records`
  6714. (
  6715. client_records_id,
  6716. modx_user_id,
  6717. date,
  6718. email,
  6719. client_name,
  6720. site_address,
  6721. state_postcode,
  6722. analysis_type,
  6723. lab_no,
  6724. batch_no,
  6725. sample_id,
  6726. site_id,
  6727. crop_type,
  6728. soil_type,
  6729. date_sampled,
  6730. tec,
  6731. cec,
  6732. texture,
  6733. gravel,
  6734. colour,
  6735. NO3_N,
  6736. NH3_N,
  6737. p_mehlick,
  6738. p_bray2,
  6739. p_morgan,
  6740. k_morgan,
  6741. ca_morgan,
  6742. mg_morgan,
  6743. na_morgan,
  6744. ch_h2o,
  6745. ocarbon,
  6746. omatter,
  6747. fe,
  6748. ec,
  6749. ph_cacl2,
  6750. ph_h2o,
  6751. paramag,
  6752. s_morgan,
  6753. b_cacl2,
  6754. mn_dtpa,
  6755. zn_dtpa,
  6756. fe_dtpa,
  6757. cu_dtpa,
  6758. al,
  6759. sl_cacl2,
  6760. m_dtpa,
  6761. co_dtpa,
  6762. se,
  6763. ca_mehlick3,
  6764. BS_ca_ppm,
  6765. mg_mehlick3,
  6766. BS_mg_ppm,
  6767. k_mehlick3,
  6768. BS_k_ppm,
  6769. na_mehlick3,
  6770. BS_na_ppm,
  6771. al_mehlick3,
  6772. BS_al_ppm,
  6773. BS_ca2,
  6774. BS_mg2,
  6775. BS_k,
  6776. BS_na,
  6777. BS_al3,
  6778. BS_ob,
  6779. BS_h,
  6780. cabs_min,
  6781. ca_ppm_min,
  6782. cabs_max,
  6783. ca_ppm_max,
  6784. mgbs_min,
  6785. mg_ppm_min,
  6786. mgbs_max,
  6787. mg_ppm_max,
  6788. kbs_min,
  6789. k_ppm_min,
  6790. kbs_max,
  6791. k_ppm_max,
  6792. nabs_min,
  6793. na_ppm_min,
  6794. nabs_max,
  6795. na_ppm_max,
  6796. albs_min,
  6797. al_ppm_min,
  6798. albs_max,
  6799. al_ppm_max,
  6800. ob_rec,
  6801. h_rec,
  6802. ca_mg_ratio,
  6803. rand
  6804. ) VALUES (
  6805. \'" . $client_id . "\',
  6806. \'" . $modx_id . "\',
  6807. \'" . $date . "\',
  6808. \'" . $email . "\',
  6809. \'" . $client_name . "\',
  6810. \'" . $site_address . "\',
  6811. \'" . $state_postcode . "\',
  6812. \'" . $analysis_type . "\',
  6813. \'" . $lab_no . "\',
  6814. \'" . $batch_no . "\',
  6815. \'" . $sample_id . "\',
  6816. \'" . $site_id . "\',
  6817. \'" . $crop_type . "\',
  6818. \'" . $soil_type . "\',
  6819. \'" . $date_sampled . "\',
  6820. \'" . $tec . "\',
  6821. \'" . $cec . "\',
  6822. IF(\'" . $texture . "\'=\'\',NULL,\'" . $texture . "\'),
  6823. IF(\'" . $gravel . "\'=\'\',NULL,\'" . $gravel . "\'),
  6824. IF(\'" . $colour . "\'=\'\',NULL,\'" . $colour . "\'),
  6825. \'" . $NO3_N . "\',
  6826. \'" . $NH3_N . "\',
  6827. \'" . $p_mehlick . "\',
  6828. \'" . $p_bray2 . "\',
  6829. \'" . $p_morgan . "\',
  6830. \'" . $k_morgan . "\',
  6831. \'" . $ca_morgan . "\',
  6832. \'" . $mg_morgan . "\',
  6833. \'" . $na_morgan . "\',
  6834. \'" . $ch_h2o . "\',
  6835. \'" . $ocarbon . "\',
  6836. \'" . $omatter . "\',
  6837. \'" . $fe . "\',
  6838. \'" . $ec . "\',
  6839. \'" . $ph_cacl2 . "\',
  6840. \'" . $ph_h2o . "\',
  6841. IF(\'" . $paramag . "\'=\'\',NULL,\'" . $paramag . "\'),
  6842. \'" . $s_morgan . "\',
  6843. \'" . $b_cacl2 . "\',
  6844. \'" . $mn_dtpa . "\',
  6845. \'" . $zn_dtpa . "\',
  6846. \'" . $fe_dtpa . "\',
  6847. \'" . $cu_dtpa . "\',
  6848. \'" . $al . "\',
  6849. \'" . $sl_cacl2 . "\',
  6850. \'" . $m_dtpa . "\',
  6851. \'" . $co_dtpa . "\',
  6852. \'" . $se . "\',
  6853. \'" . $ca_mehlick3 . "\',
  6854. \'" . $BS_ca_ppm . "\',
  6855. \'" . $mg_mehlick3 . "\',
  6856. \'" . $BS_mg_ppm . "\',
  6857. \'" . $k_mehlick3 . "\',
  6858. \'" . $BS_k_ppm . "\',
  6859. \'" . $na_mehlick3 . "\',
  6860. \'" . $BS_na_ppm . "\',
  6861. \'" . $al_mehlick3 . "\',
  6862. \'" . $BS_al_ppm . "\',
  6863. \'" . $cabs_tec . "\',
  6864. \'" . $mgbs_tec . "\',
  6865. \'" . $kbs_tec . "\',
  6866. \'" . $nabs_tec . "\',
  6867. \'" . $aluminium . "\',
  6868. \'" . $otherbases . "\',
  6869. \'" . $hydrogen . "\',
  6870. \'" . $cabs_min . "\',
  6871. \'" . $ca_ppm_min . "\',
  6872. \'" . $cabs_max . "\',
  6873. \'" . $ca_ppm_max . "\',
  6874. \'" . $mgbs_min . "\',
  6875. \'" . $mg_ppm_min . "\',
  6876. \'" . $mgbs_max . "\',
  6877. \'" . $mg_ppm_max . "\',
  6878. \'" . $kbs_min . "\',
  6879. \'" . $k_ppm_min . "\',
  6880. \'" . $kbs_max . "\',
  6881. \'" . $k_ppm_max . "\',
  6882. \'" . $nabs_min . "\',
  6883. \'" . $na_ppm_min . "\',
  6884. \'" . $nabs_max . "\',
  6885. \'" . $na_ppm_max . "\',
  6886. \'" . $albs_min . "\',
  6887. \'" . $al_ppm_min . "\',
  6888. \'" . $albs_max . "\',
  6889. \'" . $al_ppm_max . "\',
  6890. \'" . $ob_rec . "\',
  6891. \'" . $h_rec . "\',
  6892. \'" . $ca_mgRatio . "\',
  6893. \'" . $rand . "\'
  6894. )" );
  6895. $insert_id = mysqli_insert_id($con);
  6896. if ($sql === TRUE)
  6897. {
  6898. // forward to results page if successfully inserts to database [[~32]]
  6899. echo "<script>location.href = \'[[~41]]?rand=" . $rand . "&cid=" . $sample_id . "&rid=" . $insert_id . "&stid=" .$crop_type . "\';</script>";
  6900. } else {
  6901. die(mysqli_error($con)); // TODO: better error handling
  6902. //echo "User Profile incorrect";
  6903. }
  6904. }',
  6905. 'locked' => false,
  6906. 'properties' =>
  6907. array (
  6908. ),
  6909. 'moduleguid' => '',
  6910. 'static' => false,
  6911. 'static_file' => '',
  6912. 'content' => '//error_reporting(E_ALL);
  6913. error_reporting(E_ALL ^ E_NOTICE);
  6914. ini_set(\'display_errors\', 1);
  6915. $errorLog = 1;
  6916. if(isset($_POST[\'SoilcsvForm\'])) {
  6917. if ($errorLog = "1") { error_log(print_r($_POST, true)); }
  6918. $sql = null;
  6919. $con = mysqli_connect("localhost", "root", "R3M0T31", "cropmonitor");
  6920. //set todays date
  6921. $date = date("Y-m-d H:i:s");
  6922. // ****************************************************************************
  6923. // Client Details
  6924. $client_id = (isset($_POST["client_id"])) ? $_POST["client_id"] : "";
  6925. $modx_id = (isset($_POST["m_user"])) ? $_POST["m_user"] : "";
  6926. $email = (isset($_POST["email"])) ? $_POST["email"] : "";
  6927. $client_name = (isset($_POST["name"])) ? $_POST["name"] : "";
  6928. $site_address = (isset($_POST["site_address"])) ? $_POST["site_address"] : "";
  6929. $state_postcode = (isset($_POST["state_postcode"])) ? $_POST["state_postcode"] : "";
  6930. // Analysis Details
  6931. $analysis_type = "Soil Test"; //for future types of Soil Analysis
  6932. $lab_no = (isset($_POST["lab_no"])) ? $_POST["lab_no"] : "";
  6933. $batch_no = (isset($_POST["batch_no"])) ? $_POST["batch_no"] : "";
  6934. $sample_id = (isset($_POST["sample_id"])) ? $_POST["sample_id"] : "";
  6935. $site_id = (isset($_POST["site_id"])) ? $_POST["site_id"] : "";
  6936. $crop_type = (isset($_POST["crop_type"])) ? $_POST["crop_type"] : "";
  6937. $soil_type = (isset($_POST["soil_type"])) ? $_POST["soil_type"] : "";
  6938. $date_sampled = (isset($_POST["date_sampled"])) ? $_POST["date_sampled"] : "";
  6939. $date_sampled = date("Y-m-d", strtotime($date_sampled));
  6940. // Sample Details
  6941. $texture = (isset($_POST["texture"])) ? $_POST["texture"] : "";
  6942. $gravel = (isset($_POST["gravel"])) ? $_POST["gravel"] : "";
  6943. $colour = (isset($_POST["colour"])) ? $_POST["colour"] : "";
  6944. $ocarbon = (isset($_POST["ocarbon"])) ? $_POST["ocarbon"] : "";
  6945. $omatter = (isset($_POST["omatter"])) ? $_POST["omatter"] : "";
  6946. $ph_cacl2 = (isset($_POST["ph_cacl2"])) ? $_POST["ph_cacl2"] : "";
  6947. $ph_h2o = (isset($_POST["ph_h2o"])) ? $_POST["ph_h2o"] : "";
  6948. $paramag = (isset($_POST["paramag"])) ? $_POST["paramag"] : "";
  6949. $ec = (isset($_POST["ec"])) ? $_POST["ec"] : "";
  6950. // Nutrient Details
  6951. $NO3_N = (isset($_POST["NO3_N"])) ? $_POST["NO3_N"] : "";
  6952. $NH3_N = (isset($_POST["NH3_N"])) ? $_POST["NH3_N"] : "";
  6953. $p_mehlick = (isset($_POST["p_mehlick"])) ? $_POST["p_mehlick"] : "";
  6954. $p_bray2 = (isset($_POST["p_bray2"])) ? $_POST["p_bray2"] : "";
  6955. $p_morgan = (isset($_POST["p_morgan"])) ? $_POST["p_morgan"] : "";
  6956. $k_morgan = (isset($_POST["k_morgan"])) ? $_POST["k_morgan"] : "";
  6957. $ca_morgan = (isset($_POST["ca_morgan"])) ? $_POST["ca_morgan"] : "";
  6958. $mg_morgan = (isset($_POST["mg_morgan"])) ? $_POST["mg_morgan"] : "";
  6959. $na_morgan = (isset($_POST["na_morgan"])) ? $_POST["na_morgan"] : "";
  6960. $ch_h2o = (isset($_POST["ch_h2o"])) ? $_POST["ch_h2o"] : "";
  6961. $fe = (isset($_POST["fe"])) ? $_POST["fe"] : "";
  6962. $s_morgan = (isset($_POST["s_morgan"])) ? $_POST["s_morgan"] : "";
  6963. $b_cacl2 = (isset($_POST["b_cacl2"])) ? $_POST["b_cacl2"] : "";
  6964. $mn_dtpa = (isset($_POST["mn_dtpa"])) ? $_POST["mn_dtpa"] : "";
  6965. $zn_dtpa = (isset($_POST["zn_dtpa"])) ? $_POST["zn_dtpa"] : "";
  6966. $fe_dtpa = (isset($_POST["fe_dtpa"])) ? $_POST["fe_dtpa"] : "";
  6967. $cu_dtpa = (isset($_POST["cu_dtpa"])) ? $_POST["cu_dtpa"] : "";
  6968. $al = (isset($_POST["al"])) ? $_POST["al"] : "";
  6969. $sl_cacl2 = (isset($_POST["sl_cacl2"])) ? $_POST["sl_cacl2"] : "";
  6970. $m_dtpa = (isset($_POST["m_dtpa"])) ? $_POST["m_dtpa"] : "";
  6971. $co_dtpa = (isset($_POST["co_dtpa"])) ? $_POST["co_dtpa"] : "";
  6972. $se = (isset($_POST["se"])) ? $_POST["se"] : "";
  6973. // Base Saturation Details
  6974. $tec = (isset($_POST["tec"])) ? $_POST["tec"] : "";
  6975. $cec = (isset($_POST["cec"])) ? $_POST["cec"] : "";
  6976. //Base Saturation as M.E./100g
  6977. $ca_mehlick3 = (isset($_POST["ca_mehlick3"])) ? $_POST["ca_mehlick3"] : "";
  6978. $mg_mehlick3 = (isset($_POST["mg_mehlick3"])) ? $_POST["mg_mehlick3"] : "";
  6979. $k_mehlick3 = (isset($_POST["k_mehlick3"])) ? $_POST["k_mehlick3"] : "";
  6980. $na_mehlick3 = (isset($_POST["na_mehlick3"])) ? $_POST["na_mehlick3"] : "";
  6981. $al_mehlick3 = (isset($_POST["al_mehlick3"])) ? $_POST["al_mehlick3"] : "";
  6982. //Base Saturation as PPM
  6983. if ($_POST["calcium_me3"] == "ppm") {
  6984. $ca_mehlick3 = (isset($_POST["ca_mehlick3_ppm"])) ? ($_POST["ca_mehlick3_ppm"] / 200) : "";
  6985. }
  6986. if ($_POST["magnesium_me3"] == "ppm") {
  6987. $mg_mehlick3 = (isset($_POST["mg_mehlick3_ppm"])) ? ($_POST["mg_mehlick3_ppm"] / 120) : "";
  6988. }
  6989. if ($_POST["postassium_me3"] == "ppm") {
  6990. $k_mehlick = (isset($_POST["k_mehlick3_ppm"])) ? ($_POST["k_mehlick3_ppm"] / 390) : "";
  6991. }
  6992. if ($_POST["soduim_me3"] == "ppm") {
  6993. $na_mehlick3 = (isset($_POST["na_mehlick3_ppm"])) ? ($_POST["na_mehlick3_ppm"] / 230) : "";
  6994. }
  6995. // Totals for Ratis
  6996. $c_total = (isset($_POST["c_total"])) ? $_POST["c_total"] : "";
  6997. $n_total = (isset($_POST["n_total"])) ? $_POST["n_total"] : "";
  6998. //Create Carbon Nitrogen Ratio if not specified
  6999. if ($_POST["c_nRatio"] = "") {
  7000. $c_nRatio = (isset($_POST["c_nRatio"])) ? $_POST["c_nRatio"] : "";
  7001. } else {
  7002. $c_nRatio = ( $c_total / $n_total );
  7003. }
  7004. //Create CA MG Ratio if not specified
  7005. if ($_POST["ca_mgRatio"] = "") {
  7006. $ca_mgRatio = (isset($_POST["ca_mgRatio"])) ? $_POST["ca_mgRatio"] : "";
  7007. } else {
  7008. $ca_mgRatio = ( (int)$ca_mehlick3 / (int)$mg_mehlick3 );
  7009. }
  7010. //$rand = substr(md5(microtime()),rand(0,26),5);
  7011. $rand = mt_rand(10000, 99999);
  7012. // PH lookup table (ph*10 rounded to single decimal point for easy lookup)
  7013. $phrange = array(
  7014. 30 => [75.0, 11.4],
  7015. 31 => [74.0, 11.2],
  7016. 32 => [73.0, 11.0],
  7017. 33 => [72.0, 10.8],
  7018. 34 => [71.0, 10.6],
  7019. 35 => [70.0, 10.4],
  7020. 36 => [69.0, 10.2],
  7021. 37 => [68.0, 10.0],
  7022. 38 => [67.0, 9.8],
  7023. 39 => [66.0, 9.6],
  7024. 40 => [65.0, 9.4],
  7025. 41 => [63.0, 9.2],
  7026. 42 => [61.0, 9.0],
  7027. 43 => [59.0, 8.8],
  7028. 44 => [57.0, 8.6],
  7029. 45 => [55.0, 8.4],
  7030. 46 => [53.0, 8.2],
  7031. 47 => [51.0, 8.0],
  7032. 48 => [49.0, 7.8],
  7033. 49 => [47.0, 7.6],
  7034. 50 => [45.0, 7.4],
  7035. 51 => [42.0, 7.2],
  7036. 52 => [39.0, 7.0],
  7037. 53 => [36.0, 6.8],
  7038. 54 => [33.0, 6.6],
  7039. 55 => [30.0, 6.4],
  7040. 56 => [27.0, 6.2],
  7041. 57 => [24.0, 6.0],
  7042. 58 => [21.0, 5.8],
  7043. 59 => [18.0, 5.6],
  7044. 60 => [15.0, 5.4],
  7045. 61 => [13.5, 5.3],
  7046. 62 => [12.0, 5.2],
  7047. 63 => [10.5, 5.1],
  7048. 64 => [9.0, 5.0],
  7049. 65 => [7.5, 4.9],
  7050. 66 => [6.0, 4.8],
  7051. 67 => [4.5, 4.7],
  7052. 68 => [3.0, 4.6],
  7053. 69 => [1.5, 4.5],
  7054. 70 => [0.0, 4.4],
  7055. 71 => [0.0, 4.3],
  7056. 72 => [0.0, 4.2],
  7057. 73 => [0.0, 4.1],
  7058. 74 => [0.0, 4.0],
  7059. 75 => [0.0, 3.9],
  7060. 76 => [0.0, 3.8],
  7061. 77 => [0.0, 3.7],
  7062. 78 => [0.0, 3.6],
  7063. 79 => [0.0, 3.5],
  7064. 80 => [0.0, 3.4],
  7065. 81 => [0.0, 3.3],
  7066. 82 => [0.0, 3.2],
  7067. 83 => [0.0, 3.1],
  7068. 84 => [0.0, 3.0],
  7069. 85 => [0.0, 2.9],
  7070. 86 => [0.0, 2.8],
  7071. 87 => [0.0, 2.7],
  7072. 88 => [0.0, 2.6],
  7073. 89 => [0.0, 2.5],
  7074. 90 => [0.0, 2.4],
  7075. 91 => [0.0, 2.3],
  7076. 92 => [0.0, 2.2],
  7077. 93 => [0.0, 2.1],
  7078. 94 => [0.0, 2.0],
  7079. 95 => [0.0, 1.9],
  7080. 96 => [0.0, 1.8],
  7081. 97 => [0.0, 1.7],
  7082. 98 => [0.0, 1.6],
  7083. 99 => [0.0, 1.5],
  7084. 100 => [0.0, 1.4],
  7085. );
  7086. /* ********* START ********* */
  7087. /* ********* ADD BASE SATURATION CALCULATION HERE ********* */
  7088. // Calculating hydrogen and otherbases
  7089. $ph = $ph_h2o; // $ph_h2o from above
  7090. $aluminium = $al_mehlick3;
  7091. // round the ph value to single decimal point
  7092. $ph_lookup = round($ph, 2);
  7093. if ($errorLog = "1") { error_log(print_r("ph_lookup: " . $ph_lookup . " ph: " . $ph, true )); }
  7094. // lookup Hydrogen and Other Bases
  7095. $hydrogen = $phrange[($ph_lookup * 10)][0];
  7096. $otherbases = $phrange[($ph_lookup * 10)][1];
  7097. $h_rec = round($hydrogen, 2); // recommended level added to DB
  7098. $ob_rec = round($otherbases, 2); // recommended level added to DB
  7099. if ($errorLog = "1") { error_log(print_r("Hydrogen: " . $hydrogen . " Other Bases: " . $otherbases, true)); }
  7100. if ( $aluminium < 0 ) {
  7101. $otherbases = 0;
  7102. }
  7103. $obresult = 0; // obresult == Other Bases Result
  7104. $hresult = 0; // hresult == Hydrogen Result
  7105. // IF ********************************************************************************
  7106. if ( $otherbases > 0 ) {
  7107. while ( (($obresult * 100) / $cec) <= $otherbases ) {
  7108. $obresult += 0.001;
  7109. $tempNo = $obresult;
  7110. $tempNo1 = $otherbases;
  7111. $tempNo2 = $hydrogen;
  7112. // CAUTION: storing value in Calc:E16
  7113. $hresult = ($tempNo * $tempNo2) / $tempNo1;
  7114. }
  7115. $obresult -= 0.001;
  7116. if ( $hresult != 0 ){
  7117. $hresult -= 0.001;
  7118. }
  7119. } else {
  7120. while( (($hresult * 100) / $tec) <= $hydrogen ) {
  7121. $hresultl += 0.001;
  7122. }
  7123. $hresult -= 0.001;
  7124. }
  7125. if ($errorLog = "1") { error_log(print_r("hresult: " . $hresult . " obresult: " . $obresult, true)); }
  7126. // END If ********************************************************************************
  7127. // Calculating Ca Mg K Na levels based on temp
  7128. // *** I think that the tecTemp needs to be a sum of $tec and $hresult and $obresult ***
  7129. // *** As far as I can see on the spreadsheet the TEC in CALC:B16 is "CEC + obresult + CALC:E16"
  7130. $tecTemp = $cec + $obresult + $hresult;
  7131. $tec = round($tecTemp, 2);
  7132. $cec = round($cec, 2);
  7133. if ($errorLog = "1") { error_log(print_r("tecTemp: " . $tecTemp . " cec: " . $cec . " tec: " . $tec, true)); }
  7134. // CAUTION: for $tecTemp values below 1 and above 100000 this will not work
  7135. if ( ( 1.0 < $tecTemp ) && ( $tecTemp >= 3.0 ) ) {
  7136. $cabs = $CABS = 0;
  7137. $cabsmax = $CABSMAX = 60.00;
  7138. $mgbs = $MGBS = 0;
  7139. $mgbsmax = $MGBSMAX = 20.00;
  7140. $kbs = $KBS = 5.00;
  7141. $kbsmax = $KBSMAX = 7.00;
  7142. $nabs = $NABS = 0.50;
  7143. $nabsmax = $NABSMAX = 1.50;
  7144. }
  7145. elseif ( ( 3.0 < $tecTemp ) && ( $tecTemp >= 5.0 ) ) {
  7146. $cabs = $CABS = 0;
  7147. $cabsmax = $CABSMAX = 62.00;
  7148. $mgbs = $MGBS = 0;
  7149. $mgbsmax = $MGBSMAX = 18.00;
  7150. $kbs = $KBS = 5.00;
  7151. $kbsmax = $KBSMAX = 7.00;
  7152. $nabs = $NABS = 0.50;
  7153. $nabsmax = $NABSMAX = 1.50;
  7154. }
  7155. elseif ( ( 5.0 < $tecTemp ) && ( $tecTemp >= 7.0 ) ) {
  7156. $cabs = $CABS = 0;
  7157. $cabsmax = $CABSMAX = 64.00;
  7158. $mgbs = $MGBS = 0;
  7159. $mgbsmax = $MGBSMAX = 16.00;
  7160. $kbs = $KBS = 4.00;
  7161. $kbsmax = $KBSMAX = 7.00;
  7162. $nabs = $NABS = 0.50;
  7163. $nabsmax = $NABSMAX = 1.50;
  7164. }
  7165. elseif ( ( 7.0 < $tecTemp ) && ( $tecTemp >= 9.0 ) ) {
  7166. $cabs = $CABS = 0;
  7167. $cabsmax = $CABSMAX = 65.00;
  7168. $mgbs = $MGBS = 0;
  7169. $mgbsmax = $MGBSMAX = 15.00;
  7170. $kbs = $KBS = 4.00;
  7171. $kbsmax = $KBSMAX = 7.00;
  7172. $nabs = $NABS = 0.50;
  7173. $nabsmax = $NABSMAX = 1.50;
  7174. }
  7175. elseif ( ( 9.0 < $tecTemp ) && ( $tecTemp >= 11.0 ) ) {
  7176. $cabs = $CABS = 0;
  7177. $cabsmax = $CABSMAX = 67.00;
  7178. $mgbs = $MGBS = 0;
  7179. $mgbsmax = $MGBSMAX = 13.00;
  7180. $kbs = $KBS = 4.00;
  7181. $kbsmax = $KBSMAX = 7.00;
  7182. $nabs = $NABS = 0.50;
  7183. $nabsmax = $NABSMAX = 1.50;
  7184. }
  7185. elseif ( ( 11.0 < $tecTemp ) && ( $tecTemp >= 30.0 ) ) {
  7186. $cabs = $CABS = 0;
  7187. $cabsmax = $CABSMAX = 68.00;
  7188. $mgbs = $MGBS = 0;
  7189. $mgbsmax = $MGBSMAX = 12.00;
  7190. $kbs = $KBS = 4.00;
  7191. $kbsmax = $KBSMAX = 7.00;
  7192. $nabs = $NABS = 0.50;
  7193. $nabsmax = $NABSMAX = 1.50;
  7194. }
  7195. elseif ( ( 30.0 < $tecTemp ) && ( $tecTemp >= 100000.0 ) ) {
  7196. $cabs = $CABS = 0;
  7197. $cabsmax = $CABSMAX = 70.00;
  7198. $mgbs = $MGBS = 0;
  7199. $mgbsmax = $MGBSMAX = 10.00;
  7200. $kbs = $KBS = 3.00;
  7201. $kbsmax = $KBSMAX = 6.00;
  7202. $nabs = $NABS = 0.50;
  7203. $nabsmax = $NABSMAX = 1.50;
  7204. }
  7205. // *** CALCULATED TEC % AND PPM MIN / MAX LEVELS
  7206. $cabs_min = $cabs;
  7207. $ca_ppm_min = ( $tec * $cabs_min *2 );
  7208. $cabs_max = $cabsmax;
  7209. $ca_ppm_max = ( $tec * $cabs_max * 2);
  7210. $mgbs_min = $mgbs;
  7211. $mg_ppm_min = ( $tec * $mgbs_min * 1.2 );
  7212. $mgbs_max = $mgbsmax;
  7213. $mg_ppm_max = ( $tec * $mgbs_max * 1.2 );
  7214. $kbs_min = $kbs;
  7215. $k_ppm_min = ( $tec * $kbs_min * 3.9 );
  7216. $kbs_max = $kbsmax;
  7217. $k_ppm_max = ( $tec * $kbs_max * 3.9 );
  7218. $nabs_min = $nabs;
  7219. $na_ppm_min = ( $tec * $nabs_min * 2.3 );
  7220. $nabs_max = $nabsmax;
  7221. $na_ppm_max = ( $tec * $nabs_max * 2.3 );
  7222. $albs_min = "0";
  7223. $al_ppm_min = ( $tec * $albs_min * 0.9 );
  7224. $albs_max = "0.5";
  7225. $al_ppm_max = ( $tec * $albs_max * 0.9 );
  7226. // *** CALCULATED TEC LEVELS
  7227. $cabs_tec = ( $ca_mehlick3 / $tec ) * 100;
  7228. $cabs_tec = round($cabs_tec, 2);
  7229. $mgbs_tec = ( $mg_mehlick3 / $tec ) * 100;
  7230. $mgbs_tec = round($mgbs_tec, 2);
  7231. $kbs_tec = ( $k_mehlick3 / $tec ) * 100;
  7232. $kbs_tec = round($kbs_tec, 2);
  7233. $nabs_tec = ( $na_mehlick3 / $tec ) * 100;
  7234. $nabs_tec = round($nabs_tec, 2);
  7235. $albs_tec = ( $al_mehlick3 / $tec ) * 100;
  7236. $albs_tec = round($albs_tec, 2);
  7237. // *** CALCULATED PPM FROM MEQ
  7238. $BS_ca_ppm = $ca_mehlick3 * 200;
  7239. $BS_mg_ppm = $mg_mehlick3 * 120;
  7240. $BS_k_ppm = $k_mehlick3 * 390;
  7241. $BS_na_ppm = $na_mehlick3 * 230;
  7242. $BS_al_ppm = $al_mehlick3 * 90;
  7243. /* ********* ADD BASE SATURATION CALCULATION HERE ********* */
  7244. /* ********* END ********* */
  7245. // Check connection
  7246. if (mysqli_connect_errno())
  7247. {
  7248. echo "Failed to connect to MySQL: " . mysqli_connect_error();
  7249. }
  7250. $sql = mysqli_query($con, "INSERT into `soil_records`
  7251. (
  7252. client_records_id,
  7253. modx_user_id,
  7254. date,
  7255. email,
  7256. client_name,
  7257. site_address,
  7258. state_postcode,
  7259. analysis_type,
  7260. lab_no,
  7261. batch_no,
  7262. sample_id,
  7263. site_id,
  7264. crop_type,
  7265. soil_type,
  7266. date_sampled,
  7267. tec,
  7268. cec,
  7269. texture,
  7270. gravel,
  7271. colour,
  7272. NO3_N,
  7273. NH3_N,
  7274. p_mehlick,
  7275. p_bray2,
  7276. p_morgan,
  7277. k_morgan,
  7278. ca_morgan,
  7279. mg_morgan,
  7280. na_morgan,
  7281. ch_h2o,
  7282. ocarbon,
  7283. omatter,
  7284. fe,
  7285. ec,
  7286. ph_cacl2,
  7287. ph_h2o,
  7288. paramag,
  7289. s_morgan,
  7290. b_cacl2,
  7291. mn_dtpa,
  7292. zn_dtpa,
  7293. fe_dtpa,
  7294. cu_dtpa,
  7295. al,
  7296. sl_cacl2,
  7297. m_dtpa,
  7298. co_dtpa,
  7299. se,
  7300. ca_mehlick3,
  7301. BS_ca_ppm,
  7302. mg_mehlick3,
  7303. BS_mg_ppm,
  7304. k_mehlick3,
  7305. BS_k_ppm,
  7306. na_mehlick3,
  7307. BS_na_ppm,
  7308. al_mehlick3,
  7309. BS_al_ppm,
  7310. BS_ca2,
  7311. BS_mg2,
  7312. BS_k,
  7313. BS_na,
  7314. BS_al3,
  7315. BS_ob,
  7316. BS_h,
  7317. cabs_min,
  7318. ca_ppm_min,
  7319. cabs_max,
  7320. ca_ppm_max,
  7321. mgbs_min,
  7322. mg_ppm_min,
  7323. mgbs_max,
  7324. mg_ppm_max,
  7325. kbs_min,
  7326. k_ppm_min,
  7327. kbs_max,
  7328. k_ppm_max,
  7329. nabs_min,
  7330. na_ppm_min,
  7331. nabs_max,
  7332. na_ppm_max,
  7333. albs_min,
  7334. al_ppm_min,
  7335. albs_max,
  7336. al_ppm_max,
  7337. ob_rec,
  7338. h_rec,
  7339. ca_mg_ratio,
  7340. rand
  7341. ) VALUES (
  7342. \'" . $client_id . "\',
  7343. \'" . $modx_id . "\',
  7344. \'" . $date . "\',
  7345. \'" . $email . "\',
  7346. \'" . $client_name . "\',
  7347. \'" . $site_address . "\',
  7348. \'" . $state_postcode . "\',
  7349. \'" . $analysis_type . "\',
  7350. \'" . $lab_no . "\',
  7351. \'" . $batch_no . "\',
  7352. \'" . $sample_id . "\',
  7353. \'" . $site_id . "\',
  7354. \'" . $crop_type . "\',
  7355. \'" . $soil_type . "\',
  7356. \'" . $date_sampled . "\',
  7357. \'" . $tec . "\',
  7358. \'" . $cec . "\',
  7359. IF(\'" . $texture . "\'=\'\',NULL,\'" . $texture . "\'),
  7360. IF(\'" . $gravel . "\'=\'\',NULL,\'" . $gravel . "\'),
  7361. IF(\'" . $colour . "\'=\'\',NULL,\'" . $colour . "\'),
  7362. \'" . $NO3_N . "\',
  7363. \'" . $NH3_N . "\',
  7364. \'" . $p_mehlick . "\',
  7365. \'" . $p_bray2 . "\',
  7366. \'" . $p_morgan . "\',
  7367. \'" . $k_morgan . "\',
  7368. \'" . $ca_morgan . "\',
  7369. \'" . $mg_morgan . "\',
  7370. \'" . $na_morgan . "\',
  7371. \'" . $ch_h2o . "\',
  7372. \'" . $ocarbon . "\',
  7373. \'" . $omatter . "\',
  7374. \'" . $fe . "\',
  7375. \'" . $ec . "\',
  7376. \'" . $ph_cacl2 . "\',
  7377. \'" . $ph_h2o . "\',
  7378. IF(\'" . $paramag . "\'=\'\',NULL,\'" . $paramag . "\'),
  7379. \'" . $s_morgan . "\',
  7380. \'" . $b_cacl2 . "\',
  7381. \'" . $mn_dtpa . "\',
  7382. \'" . $zn_dtpa . "\',
  7383. \'" . $fe_dtpa . "\',
  7384. \'" . $cu_dtpa . "\',
  7385. \'" . $al . "\',
  7386. \'" . $sl_cacl2 . "\',
  7387. \'" . $m_dtpa . "\',
  7388. \'" . $co_dtpa . "\',
  7389. \'" . $se . "\',
  7390. \'" . $ca_mehlick3 . "\',
  7391. \'" . $BS_ca_ppm . "\',
  7392. \'" . $mg_mehlick3 . "\',
  7393. \'" . $BS_mg_ppm . "\',
  7394. \'" . $k_mehlick3 . "\',
  7395. \'" . $BS_k_ppm . "\',
  7396. \'" . $na_mehlick3 . "\',
  7397. \'" . $BS_na_ppm . "\',
  7398. \'" . $al_mehlick3 . "\',
  7399. \'" . $BS_al_ppm . "\',
  7400. \'" . $cabs_tec . "\',
  7401. \'" . $mgbs_tec . "\',
  7402. \'" . $kbs_tec . "\',
  7403. \'" . $nabs_tec . "\',
  7404. \'" . $aluminium . "\',
  7405. \'" . $otherbases . "\',
  7406. \'" . $hydrogen . "\',
  7407. \'" . $cabs_min . "\',
  7408. \'" . $ca_ppm_min . "\',
  7409. \'" . $cabs_max . "\',
  7410. \'" . $ca_ppm_max . "\',
  7411. \'" . $mgbs_min . "\',
  7412. \'" . $mg_ppm_min . "\',
  7413. \'" . $mgbs_max . "\',
  7414. \'" . $mg_ppm_max . "\',
  7415. \'" . $kbs_min . "\',
  7416. \'" . $k_ppm_min . "\',
  7417. \'" . $kbs_max . "\',
  7418. \'" . $k_ppm_max . "\',
  7419. \'" . $nabs_min . "\',
  7420. \'" . $na_ppm_min . "\',
  7421. \'" . $nabs_max . "\',
  7422. \'" . $na_ppm_max . "\',
  7423. \'" . $albs_min . "\',
  7424. \'" . $al_ppm_min . "\',
  7425. \'" . $albs_max . "\',
  7426. \'" . $al_ppm_max . "\',
  7427. \'" . $ob_rec . "\',
  7428. \'" . $h_rec . "\',
  7429. \'" . $ca_mgRatio . "\',
  7430. \'" . $rand . "\'
  7431. )" );
  7432. $insert_id = mysqli_insert_id($con);
  7433. if ($sql === TRUE)
  7434. {
  7435. // forward to results page if successfully inserts to database [[~32]]
  7436. echo "<script>location.href = \'[[~41]]?rand=" . $rand . "&cid=" . $sample_id . "&rid=" . $insert_id . "&stid=" .$crop_type . "\';</script>";
  7437. } else {
  7438. die(mysqli_error($con)); // TODO: better error handling
  7439. //echo "User Profile incorrect";
  7440. }
  7441. }',
  7442. ),
  7443. 'policies' =>
  7444. array (
  7445. 'web' =>
  7446. array (
  7447. ),
  7448. ),
  7449. 'source' =>
  7450. array (
  7451. ),
  7452. ),
  7453. 'croptypeFORM' =>
  7454. array (
  7455. 'fields' =>
  7456. array (
  7457. 'id' => 30,
  7458. 'source' => 1,
  7459. 'property_preprocess' => false,
  7460. 'name' => 'croptypeFORM',
  7461. 'description' => '',
  7462. 'editor_type' => 0,
  7463. 'category' => 0,
  7464. 'cache_type' => 0,
  7465. 'snippet' => '$con = mysqli_connect("localhost", "root", "R3M0T31", "cropmonitor");
  7466. // Check connection
  7467. if (mysqli_connect_errno())
  7468. {
  7469. echo "Failed to connect to MySQL: " . mysqli_connect_error();
  7470. }
  7471. $result = mysqli_query($con, "SELECT * FROM `plant_specifications`");
  7472. // mysqli_query returns false if something went wrong with the query
  7473. if ($result === FALSE)
  7474. {
  7475. die(mysqli_error($con)); // TODO: better error handling
  7476. }
  7477. else
  7478. {
  7479. ?>
  7480. <div class="col-md-4 form-group">
  7481. <small id="lab_no" class="form-text text-muted">Crop Type <span class="error">*</span></small>
  7482. <div><select class="form-control form-control-sm" name="crop_type" id="crop_type" required>
  7483. <option>Select the type of Crop...</option>
  7484. <?php
  7485. while ($row = mysqli_fetch_array($result))
  7486. {
  7487. echo "<option id=" . $row[\'id\'] . ">" . $row[\'plant_type\'] . "</option>";
  7488. }
  7489. ?>
  7490. </select></div>
  7491. </div>
  7492. <?php
  7493. }
  7494. mysqli_close($con);',
  7495. 'locked' => false,
  7496. 'properties' =>
  7497. array (
  7498. ),
  7499. 'moduleguid' => '',
  7500. 'static' => false,
  7501. 'static_file' => '',
  7502. 'content' => '$con = mysqli_connect("localhost", "root", "R3M0T31", "cropmonitor");
  7503. // Check connection
  7504. if (mysqli_connect_errno())
  7505. {
  7506. echo "Failed to connect to MySQL: " . mysqli_connect_error();
  7507. }
  7508. $result = mysqli_query($con, "SELECT * FROM `plant_specifications`");
  7509. // mysqli_query returns false if something went wrong with the query
  7510. if ($result === FALSE)
  7511. {
  7512. die(mysqli_error($con)); // TODO: better error handling
  7513. }
  7514. else
  7515. {
  7516. ?>
  7517. <div class="col-md-4 form-group">
  7518. <small id="lab_no" class="form-text text-muted">Crop Type <span class="error">*</span></small>
  7519. <div><select class="form-control form-control-sm" name="crop_type" id="crop_type" required>
  7520. <option>Select the type of Crop...</option>
  7521. <?php
  7522. while ($row = mysqli_fetch_array($result))
  7523. {
  7524. echo "<option id=" . $row[\'id\'] . ">" . $row[\'plant_type\'] . "</option>";
  7525. }
  7526. ?>
  7527. </select></div>
  7528. </div>
  7529. <?php
  7530. }
  7531. mysqli_close($con);',
  7532. ),
  7533. 'policies' =>
  7534. array (
  7535. 'web' =>
  7536. array (
  7537. ),
  7538. ),
  7539. 'source' =>
  7540. array (
  7541. 'id' => 1,
  7542. 'name' => 'Filesystem',
  7543. 'description' => '',
  7544. 'class_key' => 'sources.modFileMediaSource',
  7545. 'properties' =>
  7546. array (
  7547. 'fred' =>
  7548. array (
  7549. 'name' => 'fred',
  7550. 'desc' => '',
  7551. 'type' => 'combo-boolean',
  7552. 'options' =>
  7553. array (
  7554. ),
  7555. 'value' => false,
  7556. 'lexicon' => NULL,
  7557. ),
  7558. 'fredReadOnly' =>
  7559. array (
  7560. 'name' => 'fredReadOnly',
  7561. 'desc' => '',
  7562. 'type' => 'combo-boolean',
  7563. 'options' =>
  7564. array (
  7565. ),
  7566. 'value' => false,
  7567. 'lexicon' => NULL,
  7568. ),
  7569. ),
  7570. 'is_stream' => true,
  7571. ),
  7572. ),
  7573. 'plantformSubmit' =>
  7574. array (
  7575. 'fields' =>
  7576. array (
  7577. 'id' => 29,
  7578. 'source' => 0,
  7579. 'property_preprocess' => false,
  7580. 'name' => 'plantformSubmit',
  7581. 'description' => '',
  7582. 'editor_type' => 0,
  7583. 'category' => 25,
  7584. 'cache_type' => 0,
  7585. 'snippet' => 'error_reporting(E_ALL);
  7586. ini_set(\'display_errors\', 1);
  7587. if(isset($_POST[\'PlantcsvForm\'])) {
  7588. $sql = null;
  7589. $con = mysqli_connect("localhost", "root", "R3M0T31", "cropmonitor");
  7590. //set todays date
  7591. $date = date("Y-m-d H:i:s");
  7592. //Get figures
  7593. $email = (isset($_POST["email"])) ? $_POST["email"] : "";
  7594. $client_name = (isset($_POST["name"])) ? $_POST["name"] : "";
  7595. $site_address = (isset($_POST["site_address"])) ? $_POST["site_address"] : "";
  7596. $state_postcode = (isset($_POST["state_postcode"])) ? $_POST["state_postcode"] : "";
  7597. $analysis_type = (isset($_POST["analysis_type"])) ? $_POST["analysis_type"] : "";
  7598. $lab_no = (isset($_POST["lab_no"])) ? $_POST["lab_no"] : "";
  7599. $batch_no = (isset($_POST["batch_no"])) ? $_POST["batch_no"] : "";
  7600. $date_sampled = (isset($_POST["date_sampled"])) ? $_POST["date_sampled"] : "";
  7601. $sample_id = (isset($_POST["sample_id"])) ? $_POST["sample_id"] : "";
  7602. $site_id = (isset($_POST["site_id"])) ? $_POST["site_id"] : "";
  7603. $crop_type = (isset($_POST["crop_type"])) ? $_POST["crop_type"] : "";
  7604. $n = (isset($_POST["n"])) ? $_POST["n"] : "";
  7605. $p = (isset($_POST["p"])) ? $_POST["p"] : "";
  7606. $k = (isset($_POST["k"])) ? $_POST["k"] : "";
  7607. $s = (isset($_POST["s"])) ? $_POST["s"] : "";
  7608. $mg = (isset($_POST["mg"])) ? $_POST["mg"] : "";
  7609. $ca = (isset($_POST["ca"])) ? $_POST["ca"] : "";
  7610. $na = (isset($_POST["na"])) ? $_POST["na"] : "";
  7611. $fe = (isset($_POST["fe"])) ? $_POST["fe"] : "";
  7612. $mn = (isset($_POST["mn"])) ? $_POST["mn"] : "";
  7613. $zn = (isset($_POST["zn"])) ? $_POST["zn"] : "";
  7614. $cu = (isset($_POST["cu"])) ? $_POST["cu"] : "";
  7615. $b = (isset($_POST["b"])) ? $_POST["b"] : "";
  7616. $m = (isset($_POST["m"])) ? $_POST["m"] : "";
  7617. $co = (isset($_POST["co"])) ? $_POST["co"] : "";
  7618. $se = (isset($_POST["se"])) ? $_POST["se"] : "";
  7619. $ch = (isset($_POST["cl"])) ? $_POST["cl"] : "";
  7620. //$rand = substr(md5(microtime()),rand(0,26),5);
  7621. $rand = mt_rand(10000, 99999);
  7622. // Check connection
  7623. if (mysqli_connect_errno())
  7624. {
  7625. echo "Failed to connect to MySQL: " . mysqli_connect_error();
  7626. }
  7627. $sql = mysqli_query($con, "INSERT into `plant_records`
  7628. (
  7629. date,
  7630. email,
  7631. client_name,
  7632. site_address,
  7633. state_postcode,
  7634. analysis_type,
  7635. lab_no,
  7636. batch_no,
  7637. date_sampled,
  7638. sample_id,
  7639. site_id,
  7640. crop_type,
  7641. n,
  7642. p,
  7643. k,
  7644. s,
  7645. mg,
  7646. ca,
  7647. na,
  7648. fe,
  7649. mn,
  7650. zn,
  7651. cu,
  7652. b,
  7653. m,
  7654. co,
  7655. se,
  7656. cl,
  7657. rand
  7658. ) VALUES (
  7659. \'" . $date . "\',
  7660. \'" . $email . "\',
  7661. \'" . $client_name . "\',
  7662. \'" . $site_address . "\',
  7663. \'" . $state_postcode . "\',
  7664. \'" . $analysis_type . "\',
  7665. \'" . $lab_no . "\',
  7666. \'" . $batch_no . "\',
  7667. \'" . $date_sampled . "\',
  7668. \'" . $sample_id . "\',
  7669. \'" . $site_id . "\',
  7670. \'" . $crop_type . "\',
  7671. \'" . $n . "\',
  7672. \'" . $p . "\',
  7673. \'" . $k . "\',
  7674. \'" . $s . "\',
  7675. \'" . $mg . "\',
  7676. \'" . $ca . "\',
  7677. \'" . $na . "\',
  7678. \'" . $fe . "\',
  7679. \'" . $mn . "\',
  7680. \'" . $zn . "\',
  7681. \'" . $cu . "\',
  7682. \'" . $b . "\',
  7683. IF(\'" . $m . "\'=\'\',NULL,\'" . $m . "\'),
  7684. IF(\'" . $co . "\'=\'\',NULL,\'" . $co . "\'),
  7685. IF(\'" . $se . "\'=\'\',NULL,\'" . $se . "\'),
  7686. IF(\'" . $cl . "\'=\'\',NULL,\'" . $cl . "\'),
  7687. \'" . $rand . "\'
  7688. )" );
  7689. $insert_id = mysqli_insert_id($con);
  7690. if ($sql === TRUE)
  7691. {
  7692. //echo "success"; //CHECKING
  7693. // forward to results page if successfully inserts to database
  7694. echo "<script>location.href = \'[[~26]]?rand=" . $rand . "&cid=" . $sample_id . "&rid=" . $insert_id . "&stid=" .$crop_type . "\',\'_blank\';</script>";
  7695. } else {
  7696. die(mysqli_error($con)); // TODO: better error handling
  7697. //echo "User Profile incorrect";
  7698. }
  7699. }',
  7700. 'locked' => false,
  7701. 'properties' =>
  7702. array (
  7703. ),
  7704. 'moduleguid' => '',
  7705. 'static' => false,
  7706. 'static_file' => '',
  7707. 'content' => 'error_reporting(E_ALL);
  7708. ini_set(\'display_errors\', 1);
  7709. if(isset($_POST[\'PlantcsvForm\'])) {
  7710. $sql = null;
  7711. $con = mysqli_connect("localhost", "root", "R3M0T31", "cropmonitor");
  7712. //set todays date
  7713. $date = date("Y-m-d H:i:s");
  7714. //Get figures
  7715. $email = (isset($_POST["email"])) ? $_POST["email"] : "";
  7716. $client_name = (isset($_POST["name"])) ? $_POST["name"] : "";
  7717. $site_address = (isset($_POST["site_address"])) ? $_POST["site_address"] : "";
  7718. $state_postcode = (isset($_POST["state_postcode"])) ? $_POST["state_postcode"] : "";
  7719. $analysis_type = (isset($_POST["analysis_type"])) ? $_POST["analysis_type"] : "";
  7720. $lab_no = (isset($_POST["lab_no"])) ? $_POST["lab_no"] : "";
  7721. $batch_no = (isset($_POST["batch_no"])) ? $_POST["batch_no"] : "";
  7722. $date_sampled = (isset($_POST["date_sampled"])) ? $_POST["date_sampled"] : "";
  7723. $sample_id = (isset($_POST["sample_id"])) ? $_POST["sample_id"] : "";
  7724. $site_id = (isset($_POST["site_id"])) ? $_POST["site_id"] : "";
  7725. $crop_type = (isset($_POST["crop_type"])) ? $_POST["crop_type"] : "";
  7726. $n = (isset($_POST["n"])) ? $_POST["n"] : "";
  7727. $p = (isset($_POST["p"])) ? $_POST["p"] : "";
  7728. $k = (isset($_POST["k"])) ? $_POST["k"] : "";
  7729. $s = (isset($_POST["s"])) ? $_POST["s"] : "";
  7730. $mg = (isset($_POST["mg"])) ? $_POST["mg"] : "";
  7731. $ca = (isset($_POST["ca"])) ? $_POST["ca"] : "";
  7732. $na = (isset($_POST["na"])) ? $_POST["na"] : "";
  7733. $fe = (isset($_POST["fe"])) ? $_POST["fe"] : "";
  7734. $mn = (isset($_POST["mn"])) ? $_POST["mn"] : "";
  7735. $zn = (isset($_POST["zn"])) ? $_POST["zn"] : "";
  7736. $cu = (isset($_POST["cu"])) ? $_POST["cu"] : "";
  7737. $b = (isset($_POST["b"])) ? $_POST["b"] : "";
  7738. $m = (isset($_POST["m"])) ? $_POST["m"] : "";
  7739. $co = (isset($_POST["co"])) ? $_POST["co"] : "";
  7740. $se = (isset($_POST["se"])) ? $_POST["se"] : "";
  7741. $ch = (isset($_POST["cl"])) ? $_POST["cl"] : "";
  7742. //$rand = substr(md5(microtime()),rand(0,26),5);
  7743. $rand = mt_rand(10000, 99999);
  7744. // Check connection
  7745. if (mysqli_connect_errno())
  7746. {
  7747. echo "Failed to connect to MySQL: " . mysqli_connect_error();
  7748. }
  7749. $sql = mysqli_query($con, "INSERT into `plant_records`
  7750. (
  7751. date,
  7752. email,
  7753. client_name,
  7754. site_address,
  7755. state_postcode,
  7756. analysis_type,
  7757. lab_no,
  7758. batch_no,
  7759. date_sampled,
  7760. sample_id,
  7761. site_id,
  7762. crop_type,
  7763. n,
  7764. p,
  7765. k,
  7766. s,
  7767. mg,
  7768. ca,
  7769. na,
  7770. fe,
  7771. mn,
  7772. zn,
  7773. cu,
  7774. b,
  7775. m,
  7776. co,
  7777. se,
  7778. cl,
  7779. rand
  7780. ) VALUES (
  7781. \'" . $date . "\',
  7782. \'" . $email . "\',
  7783. \'" . $client_name . "\',
  7784. \'" . $site_address . "\',
  7785. \'" . $state_postcode . "\',
  7786. \'" . $analysis_type . "\',
  7787. \'" . $lab_no . "\',
  7788. \'" . $batch_no . "\',
  7789. \'" . $date_sampled . "\',
  7790. \'" . $sample_id . "\',
  7791. \'" . $site_id . "\',
  7792. \'" . $crop_type . "\',
  7793. \'" . $n . "\',
  7794. \'" . $p . "\',
  7795. \'" . $k . "\',
  7796. \'" . $s . "\',
  7797. \'" . $mg . "\',
  7798. \'" . $ca . "\',
  7799. \'" . $na . "\',
  7800. \'" . $fe . "\',
  7801. \'" . $mn . "\',
  7802. \'" . $zn . "\',
  7803. \'" . $cu . "\',
  7804. \'" . $b . "\',
  7805. IF(\'" . $m . "\'=\'\',NULL,\'" . $m . "\'),
  7806. IF(\'" . $co . "\'=\'\',NULL,\'" . $co . "\'),
  7807. IF(\'" . $se . "\'=\'\',NULL,\'" . $se . "\'),
  7808. IF(\'" . $cl . "\'=\'\',NULL,\'" . $cl . "\'),
  7809. \'" . $rand . "\'
  7810. )" );
  7811. $insert_id = mysqli_insert_id($con);
  7812. if ($sql === TRUE)
  7813. {
  7814. //echo "success"; //CHECKING
  7815. // forward to results page if successfully inserts to database
  7816. echo "<script>location.href = \'[[~26]]?rand=" . $rand . "&cid=" . $sample_id . "&rid=" . $insert_id . "&stid=" .$crop_type . "\',\'_blank\';</script>";
  7817. } else {
  7818. die(mysqli_error($con)); // TODO: better error handling
  7819. //echo "User Profile incorrect";
  7820. }
  7821. }',
  7822. ),
  7823. 'policies' =>
  7824. array (
  7825. 'web' =>
  7826. array (
  7827. ),
  7828. ),
  7829. 'source' =>
  7830. array (
  7831. ),
  7832. ),
  7833. ),
  7834. 'modTemplateVar' =>
  7835. array (
  7836. 'blogit.post_main_image' =>
  7837. array (
  7838. 'fields' =>
  7839. array (
  7840. 'id' => 5,
  7841. 'source' => 0,
  7842. 'property_preprocess' => false,
  7843. 'type' => 'image',
  7844. 'name' => 'blogit.post_main_image',
  7845. 'caption' => 'Main image',
  7846. 'description' => 'Select the main image to show with this post, leave blank for no image, a re-sized verzion will be shown on the blog post overview.',
  7847. 'editor_type' => 0,
  7848. 'category' => 36,
  7849. 'locked' => false,
  7850. 'elements' => '',
  7851. 'rank' => 1,
  7852. 'display' => 'default',
  7853. 'default_text' => '',
  7854. 'properties' =>
  7855. array (
  7856. ),
  7857. 'input_properties' =>
  7858. array (
  7859. ),
  7860. 'output_properties' =>
  7861. array (
  7862. ),
  7863. 'static' => false,
  7864. 'static_file' => '',
  7865. 'content' => '',
  7866. ),
  7867. 'policies' =>
  7868. array (
  7869. 'web' =>
  7870. array (
  7871. ),
  7872. ),
  7873. 'source' =>
  7874. array (
  7875. ),
  7876. ),
  7877. ),
  7878. ),
  7879. );