....................................../////.===Shadow-Here===./////................................................ > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < ------------------------------------------------------------------------------------------------------------------- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// RIFF¤ WEBPVP8 ˜ ðÑ *ôô>‘HŸK¥¤"§£±¨àð enü¹%½_F‘åè¿2ºQú³íªú`N¿­3ÿƒügµJžaÿ¯ÿ°~¼ÎùnúîÞÖô•òíôÁÉß®Sm¥Ü/ ‡ó˜f£Ùà<˜„xëJ¢Ù€SO3x<ªÔ©4¿+ç¶A`q@Ì“Úñè™ÍÿJÌ´ª-˜ÆtÊÛL]Ïq*‘Ý”ì#ŸÌÏãY]@ê`¿ /ªfkØB4·®£ó z—Üw¥Pxù–ÞLШKÇN¾AkÙTf½è'‰g gÆv›Øuh~ a˜Z— ïj*á¥t d£“uÒ ¨`K˜¹ßþ]b>˜]_ÏÔ6W—è2r4x•íÖ…"ƒÖNîä!¦å Ú}ýxGøÌ —@ ;ÆÚŠ=ɾ1ý8lªË¥ô ^yf®Œ¢u&2©nÙÇ›ñÂñŒ³ aPo['½»øFùà­+4ê“$!lövlüÞ=;N®3ð‚õ›DÉKòÞ>ÄÍ ¥ˆuߤ#ˆ$6ù™¥îЇy’ÍB¼ çxÛ;X"WL£R÷͝*ó-¶Zu}º.s¸sšXqù–DþÿvªhüïwyŸ ¯é³lÀ:KCûÄ£Ëá\…­ ~—ýóî ¼ûûÜTÓüÇy…ŽÆvc»¾×U ñ¸žþоP÷¦ó:Ò¨¨5;Ð#&#ÖúñläÿÁœ GxÉ­/ñ‡áQðìYÉtÒw޼GÔ´zàÒò ð*ëzƒ•4~H]Ø‹f ñÓÈñ`NåWçs'ÆÏW^ø¹!XžµmQ5ÃËoLœÎ: ÞËÍ¥J ù…î èo£ßPÎñ¶ž8.Œ]ʵ~5›ÙË-ù*8ÙÖß±~ ©¹rÓê‚j¶d¸{^Q'˜±Crß ÚH—#¥¥QlÀ×ëã‡DÜ«èî þ&Çæžî;ŽÏºò6ÒLÃXy&ZŒ'j‚¢Ù€IßÚù+–MGi‰*jE€‘JcÜ ÓÌ EÏÚj]o˜ Þr <¾U ûŪæÍ/šÝH¥˜b”¼ ÁñßX GP›ï2›4WŠÏà×£…íÓk†¦H·ÅíMh–*nó÷à]ÁjCº€b7<ب‹¨5車bp2:Á[UªM„QŒçiNMa#<5›áËó¸HýÊ"…×Éw¹¦ì2º–x<›»a±¸3Weü®FÝ⑱ö–î–³|LPÈ~çð~Çå‡|º kD¢µÏàÆAI %1À% ¹Ò – ”ϝS¦‰4&¶£°à Öý”û_Ò Áw°A«Å€?mÇÛgHÉ/8)á¾ÛìáöŽP í¨PŸNÙµº¦‡§Ùš"ÿ«>+ªÕ`Ê÷‡‚ß Õû˜þãÇ-PÍ.¾XV‘€ dÜ"þ4¹ ±Oú‘©t¥¦FªÄÃÄ•b‚znýu½—#cDs˜ÃiÑOˆñ×QO=*IAÊ,¶ŽZƒ;‡wøXè%EÐk:F±Ú” .Ѽ+Áu&Ç`."pÈÉw o&¿dE6‘’EqTuK@Ì¥ã™À(Êk(h‰,H}RÀIXÛš3µ1©_OqÚÒJAñ$ÊÙÜ;D3çŒ[þùœh¬Ã³™ö6ç†NY".Ú‰ï[ªŸŒ '²Ð öø_¨ÂÉ9ué¶³ÒŠõTàîMØ#û¯gN‡bÙ놚X„ö …ÉeüÌ^J ‹€.œ$Æ)βÄeæW#óüßĺŸ€ ÀzwV 9oä»f4V*uB «Ë†¹ì¯žR霓æHXa=&“I4K;¯ç‹h×·"UŠ~<•╪Vêª&ÍSÃÆÅ?ÔqÎ*mTM ˜›µwêd#[C¡©§‘D<©àb†–ÁœøvH/,í:¯( ²£|4-„Æövv„Yͼ™^Á$ˆ„¢Û[6yB.åH*V¨æ?$=˜Ñ€•ñ·­(VlŸ‘ nÀt8W÷´Bûba?q9ú¶Xƒl«ÿ\ù¶’þòUÐj/õ¢Ìµ³g$ƒÎR!¸»|Oߍë’BhîÚÑ¢ñåŒJ„®„£2Ð3•ô02Nt…!£Í]Ïc½Qÿ?ˆ<&ÃA¾Ú,JˆijÌ#5yz„‰Î|ÊŽ5QÏ:‹ÐaóVÔxW—CpeÏzÐïíçôÿÅ_[hãsÐ_/ŽTÝ?BîˆííV$<¿i>²F¬_Eß¿ †bÊŒº­ÿ®Z H“C}”¬,Mp ý/Bá£w>˜YV°aƒúh+cŠ- r/[%|üUMHäQ°X»|û/@|°¥Ð !BÔ Ç¢Ä©š+Õì D«7ìN¶ŽðÔ " ƶ’ÖçtA‰Û×}{tþz­¾GÍ›k¹OEJR$ Â׃ «ëÁ"oÉôž$oUK(Ä)Ãz³Ê-‹êN[Ò3Œñbï8P 4ƒ×q¢bo|?<ÛX¬òÄͰL–±›(™ûG?ýË©ÚÄ–ÂDØÐ_Ç¡ô ¾–ÄÏø ×e8Ë©$ÄF¹Å‹ì[©óìl:F¾f´‹‹Xì²ï®\¬ôùƒ ÿat¥óèÒùHß0äe‚;ü×h:ÆWðHž=Ã8骣"kœ'Y?³}Tûè€>?0l›e1Lòñ„aæKÆw…hÖŠùW…ÈÆÄ0ši·›[pcwËþñiêíY/~-Á5˜!¿†A›™Mÿþ(±“t@â“ö2­´TG5yé]çå僳 .·ÍïçÝ7UÚ±Ð/Nè»,_Ï ùdj7\ï Wì4›„»c¸àešg#ÒÊ⥭áØo5‘?ÌdÝô¯ ¹kzsƒ=´#ëÉK›Ø´±-¥eW?‡çßtòTã…$Ý+qÿ±ƒ÷_3Ô¥í÷:æ–ž<·Ö‡‰Å¢ š‡%Ô—utÌÈìðžgÖÀz²À—ï÷Óîäõ{K'´È÷³yaÏÁjƒô}ž§®æÊydÕÈë5¯èˆõvÕ©ã*çD„ “z„Ó‡^^xÂ3M§A´JG‚öï 3W'ˆ.OvXè¡ÊÕª?5º7†˜(˜Ç¶#çê’¶!ÌdZK§æ 0fãaN]òY³RV ™î$®K2R¨`W!1Ôó\;Ý ýB%qæK•&ÓÈe9È0êI±žeŸß -ú@žQr¦ ö4»M¼Áè¹µmw 9 EÆE_°2ó„ŸXKWÁ×Hóì^´²GѝF©óäR†¦‰ç"V»eØ<3ùd3ÿÚ¤Žú“Gi" —‘_ÙËÎ~Üö¯¥½Î»üŸEÚŽåmÞþí ;ÞólËΦMzA"Âf(´òá;Éï(/7½ûñÌ­cïÕçлþÝz¾-ÍvÑ“pH­–ðÓj$¸Äû¤‚‘ãUBË-n“2åPkS5&‹Â|+g^œ®Ì͆d!OïäîU«c;{Û!ÅŽ«ëZ9Ókóˆ]¯ƒ›né `ÇÒ+tÆš (ØKá¾—=3œ®•vuMñg²\ï Ec€ 05±d™‡×iÇ×›UúvÌ¢£Èþ¡ÕØô¶ßÎA"ß±#Ö²ˆÊŸ¦*Ä~ij|àø.-¼'»Ú¥£h ofº¦‡VsR=N½„Î v˜Z*SÌ{=jÑB‹tê…;’HžH¯8–îDù8ñ¢|Q•bÛçš–‹m³“ê¨ åÏ^m¬Žãþ©ïêO‡½6] µÆ„Ooòü ²x}N¦Ë3ïé¿»€›HA˜m%çÞ/¿í7Fø“‹léUk)É°Œµ8Q8›:ÀŠeT*šõ~ôڝG6 ¢}`ùH­–”¡k ‰P1>š†®9z11!X wKfmÁ¦xÑ,N1Q”–æB¶M…ÒÃv6SMˆhU¬ÊPŽï‘öj=·CŒ¯u¹ƒVIЃsx4’ömÛýcå¡¶7ßŠß 57^\wÒÐÆ k§h,Œý î«q^R½3]J¸ÇðN ‚çU¬ôº^Áì} ³f©Õœ§ˆã:FÄÈ‚é(€™?àýÓüè1Gô£¼éj‚OÅñ  #>×—ßtà 0G¥Åa뀐kßhc™À_ÉñÞ#±)GD" YîäË-ÿÙ̪ ¹™a¯´¢E\ÝÒö‚;™„ë]_ p8‰o¡ñ+^÷ 3‘'dT4œŽ ðVë½° :¬víÑ«£tßÚS-3¶“þ2 †üüʨòrš¹M{É_¤`Û¨0ìjœøJ‡:÷ÃáZ˜†@GP&œÑDGÏs¡þ¦þDGú‘1Yá9Ôþ¼ ûø…§÷8&–ÜÑnÄ_m®^üÆ`;ÉVÁJ£?â€-ßê}suÍ2sõA NÌúA磸‘îÿÚ»ƒìö·á¿±tÑÐ"Tÿü˜[@/äj¬€uüªìù¥Ý˜á8Ý´sõj 8@rˆð äþZÇD®ÿUÏ2ùôõrBzÆÏÞž>Ì™xœ“ wiÎ×7_… ¸ \#€MɁV¶¥üÕÿPÔ9Z‡ø§É8#H:ƒ5ÀÝå9ÍIŒ5åKÙŠ÷qÄ>1AÈøžj"µÂд/ªnÀ qªã}"iŸBå˜ÓÛŽ¦…&ݧ;G@—³b¯“•"´4í¨ôM¨åñC‹ïùÉó¯ÓsSH2Ý@ßáM‡ˆKÀªÛUeø/4\gnm¥‹ŸŒ qÄ b9ÞwÒNÏ_4Ég³ú=܆‚´ •â¥õeíþkjz>éÚyU«Íӝ݃6"8/ø{=Ô¢»G¥ äUw°W«,ô—¿ãㆅү¢³xŠUû™yŒ (øSópÐ 9\åTâ»—*oG$/×ÍT†Y¿1¤Þ¢_‡ ¼ „±ÍçèSaÓ 3ÛMÁBkxs‰’R/¡¤ˆÙçª(*õ„üXÌ´ƒ E§´¬EF"Ù”R/ÐNyÆÂ^°?™6¡œïJ·±$§?º>ÖüœcNÌù¯G ‹ñ2ЁBB„^·úìaz¨k:#¨Æ¨8LÎõލ£^§S&cŒÐU€ü(‡F±Š¼&P>8ÙÁ ‰ p5?0ÊÆƒZl¸aô š¼¡}gÿ¶zÆC²¹¬ÎÖG*HB¡O<º2#ñŒAƒ–¡B˜´É$¥›É:FÀÔx¾u?XÜÏÓvN©RS{2ʈãk9rmP¼Qq̳ è¼ÐFׄ^¡Öì fE“F4A…!ì/…¦Lƒ… … $%´¾yã@CI¬ á—3PþBÏNÿ<ý°4Ü ËÃ#ØÍ~âW«rEñw‹eùMMHß²`¬Öó½íf³:‹k˜¯÷}Z!ã¿<¥,\#öµÀ¯aÒNÆIé,Ћ–lŽ#Àæ9ÀÒS·I’½-Ïp Äz¤Š Â* ­íÄ9­< h>׍3ZkËU¹§˜ŒŠ±f­’¤º³Q ÏB?‹#µíÃ¥®@(Gs«†vI¥Mµ‹Á©e~2ú³ÁP4ìÕi‚²Ê^ö@-DþÓàlÜOÍ]n"µã:žpsŽ¢:! Aõ.ç~ÓBûH÷JCÌ]õVƒd «ú´QÙEA–¯¯Œ!.ˆˆëQ±ù œ·Ì!Õâ )ùL„ÅÀlÚè5@B…o´Æ¸XÓ&Û…O«˜”_#‡ƒ„ûÈt!¤ÁÏ›ÎÝŠ?c9 â\>lÓÁVÄÑ™£eØY]:fÝ–—ù+p{™ðè û³”g±OƒÚSù£áÁÊ„ä,ï7š²G ÕÌBk)~ÑiCµ|h#u¤¶îK¨² #²vݯGãeÖ϶ú…¾múÀ¶þÔñ‚Š9'^($¤§ò “š½{éúp÷J›ušS¹áªCÂubÃH9™D™/ZöØÁ‡¦ÝÙŸ·kð*_”.C‹{áXó€‡c¡c€§/šò/&éš÷,àéJþ‰X›fµ“C¨œ®r¬"kL‰Â_q…Z–.ÉL~O µ›zn‚¹À¦Öª7\àHµšÖ %»ÇníV[¥*Õ;ƒ#½¾HK-ÖIÊdÏEÚ#=o÷Óò³´Š: Ç?{¾+9›–‘OEáU·S€˜j"ÄaÜ ŒÛWt› á–c#a»pÔZÞdŽtWê=9éöÊ¢µ~ ë ;Öe‡Œ®:bî3±ýê¢wà¼îpêñ¹¾4 zc¾ðÖÿzdêŒÑÒŝÀ‰s6¤í³ÎÙB¿OZ”+F¤á‡3@Ñëäg©·Ž ˆèª<ù@É{&S„œÕúÀA)‰h:YÀ5^ÂÓŒ°õäU\ ùËÍû#²?Xe¬tu‰^zÒÔãë¼ÛWtEtû …‚g¶Úüâî*moGè¨7%u!]PhÏd™Ý%Îx: VÒ¦ôÊD3ÀŽKÛËãvÆî…N¯ä>Eró–ð`5 Œ%u5XkñÌ*NU%¶áœÊ:Qÿú»“úzyÏ6å-၇¾ ´ ÒÊ]y žO‘w2Äøæ…H’²f±ÎÇ.ª|¥'gîV•Ü .̘¯€šòü¤U~Ù†*¢!?ò wý,}´°ÔÞnïoKq5µb!áÓ3"vAßH¡³¡·G(ÐÎ0Îò¼MG!/ài®@—¬04*`…«é8ªøøló“ˆÊ”èù¤…ßÊoÿé'ËuÌÖ5×È¡§ˆˆfŽë9}hìâ_!!¯  B&Ëö¶‰ÀAÙNVŸ Wh›¸®XÑJì¨ú“¿÷3uj²˜¨ÍÎìë±aúŠÝå¯ð*Ó¨ôJ“yºØ)m°WýOè68†ŸÏ2—‰Ïüꪫٚ¥‹l1 ø ÏÄFjêµvÌbü¦èÝx:X±¢H=MÐß—,ˆÉÇ´(9ú¾^ÅÚ4¿m‡$âX‘å%(AlZo@½¨UOÌÕ”1ø¸jÎÀÃÃ_ µ‘Ü.œº¦Ut: Æï’!=¯uwû#,“pþÇúŒø(é@?³ü¥‘Mo §—s@Œ#)§ŒùkL}NOÆêA›¸~r½¼ÙA—HJ«eˆÖ´*¡ÓpÌŸö.m<-"³ûÈ$¬_6­åf£ïÚâj1y§ÕJ½@dÞÁr&Í\Z%D£Íñ·AZ Û³øüd/ªAi†/Й~  ‡âĮҮÏh§°b—›Û«mJžòG'[ÈYýŒ¦9psl ýÁ ®±f¦x,‰½tN ‚Xª9 ÙÖH.«Lo0×?͹m¡å†Ѽ+›2ƒF ±Ê8 7Hցϓ²Æ–m9…òŸï]Â1äN†VLâCˆU .ÿ‰Ts +ÅÎx(%¦u]6AF Š ØF鈄‘ |¢¶c±soŒ/t[a¾–û:s·`i햍ê›ËchÈ…8ßÀUÜewŒðNOƒõD%q#éû\9¤x¹&UE×G¥ Í—™$ð E6-‡¼!ýpãÔM˜ Âsìe¯ñµK¢Ç¡ùôléœ4Ö£”À Š®Ðc ^¨À}ÙËŸ§›ºê{ÊuÉC ×Sr€¤’fÉ*j!úÓ’Gsùìoîßîn%ò· àc Wp÷$¨˜)û»H ×8ŽÒ€Zj¤3ÀÙºY'Ql¦py{-6íÔCeiØp‘‡XÊîÆUߢ܂ž£Xé¼Y8þ©ëgñß}é.ÎógÒ„ÃØËø¯»™§Xýy M%@NŠ À(~áÐvu7&•,Ù˜ó€uP‡^^®=_E„jt’ 403WebShell
403Webshell
Server IP : 51.91.236.193  /  Your IP : 216.73.216.177
Web Server : Apache
System : Linux webm019.cluster128.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64
User : thillelirn ( 8290)
PHP Version : 8.0.30
Disable Function : _dyuweyrj4,_dyuweyrj4r,dl
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/t/h/i/thillelirn/www/wp-content/plugins/loco-translate/src/package/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/t/h/i/thillelirn/www/wp-content/plugins/loco-translate/src/package/Project.php
<?php
/**
 * A project is a set of translations within a Text Domain.
 * Often a text domain will have just one set, but this allows domains to be split into multiple POT files.
 */
class Loco_package_Project {
    
    /**
     * Text Domain in which project lives
     */
    private Loco_package_TextDomain $domain;
    
    /**
     * Bundle in which project lives
     */
    private Loco_package_Bundle $bundle;
    
    /**
     * Friendly project name, e.g. "Network Admin"
     */
    private string $name;
    
    /**
     * Short name used for naming files, e.g "admin"
     */
    private string $slug;

    /**
     * Configured domain path[s] not including global search paths
     */
    private Loco_fs_FileList $dpaths;

    /**
     * Additional system domain path[s] added separately from bundle config
     */
    private Loco_fs_FileList $gpaths;

    /**
     * Directory paths to exclude during target scanning
     */
    private Loco_fs_FileList $xdpaths;

    /**
     * Locations where POT, PO and MO files may be saved, including standard global paths
     */
    private ?Loco_fs_FileFinder $target = null;
    
    /**
     * Configured source path[s] not including global search paths
     */
    private Loco_fs_FileList $spaths;
    
    /**
     * File and directory paths to exclude from source file extraction
     */
    private Loco_fs_FileList $xspaths;

    /**
     * Locations where extractable source files may be found
     */
    private ?Loco_fs_FileFinder $source = null;

    /**
     * Explicitly added individual PHP source files
     */
    private Loco_fs_FileList $sfiles;

    /**
     * Paths globally excluded by bundle-level configuration
     */
    private Loco_fs_FileList $xgpaths;

    /**
     * POT template file, ideally named "<name>.pot"
     */
    private ?Loco_fs_File $pot = null;

    /**
     * Whether POT file is protected from end-user update and sync operations.
     */
    private bool $potlock = false;


    /**
     * Construct project from its domain and a descriptive name
     */
    public function __construct( Loco_package_Bundle $bundle, Loco_package_TextDomain $domain, string $name ){
        $this->setName($name);
        $this->bundle = $bundle;
        $this->domain = $domain;
        // take default slug from domain, avoiding wildcard
        $slug = $domain->getName();
        if( '*' === $slug ){
            $slug = '';
        }
        $this->slug = $slug;
        // sources
        $this->sfiles = new Loco_fs_FileList;
        $this->spaths = new Loco_fs_FileList;
        $this->xspaths = new Loco_fs_FileList;
        // targets
        $this->dpaths = new Loco_fs_FileList;
        $this->gpaths = new Loco_fs_FileList;
        $this->xdpaths = new Loco_fs_FileList;
        // global
        $this->xgpaths = new Loco_fs_FileList;
    }


    /**
     * Split project ID into domain and slug.
     * null and "" are meaningfully different. "" means deliberately empty slug, whereas null means default
     * @param string $id <domain>[.<slug>]
     * @return string[] [ <domain>, <slug> ]
     */
    public static function splitId( string $id ):array {
        $r = preg_split('/(?<!\\\\)\\./', $id, 2 );
        $domain = stripcslashes($r[0]);
        $slug = isset($r[1]) ? stripcslashes($r[1]) : $domain;
        return [ $domain, $slug ];
    }


    /**
     * Get ID identifying project uniquely within a bundle
     */
    public function getId():string {
        $slug = $this->getSlug();
        $domain = (string) $this->getDomain();
        if( $slug === $domain ){
            return $slug;
        }
        return addcslashes($domain,'.').'.'.addcslashes($slug,'.');
    }


    /**
     * @return string
     */
    public function __toString(){
        return $this->name;
    }


    /**
     * Set friendly name of project
     */
    public function setName( string $name ):self {
        $this->name = $name;
        return $this;
    }


    /**
     * Set short name of project
     */
    public function setSlug( string $slug ):self {
        $this->slug = $slug;
        return $this;
    }


    /**
     * Get friendly name of project, e.g. "Network Admin"
     */
    public function getName():string {
        return $this->name;
    }


    /**
     * Get short name of project, e.g. "admin"
     */
    public function getSlug():string {
        return $this->slug;
    }

    
    /**
     * Get text domain as stringable object
     */
    public function getDomain():Loco_package_TextDomain {
        return $this->domain;
    }

    
    /**
     * Get the  parent bundle that contains this project
     */
    public function getBundle():Loco_package_Bundle {
        return $this->bundle;
    }


    /**
     * Whether project is the default for its domain.
     */
    public function isDomainDefault():bool {
        $slug = $this->getSlug();
        $name = $this->getDomain()->getName();
        // default if slug matches text domain.
        // else special case for Core "default" domain which has empty slug
        return $slug === $name || ( 'default' === $name && '' === $slug ) || 1 === count($this->bundle);
    }


    /**
     * Add a root path where translation files may live
     * @param string|Loco_fs_File $location
     */
    public function addTargetDirectory( $location ):self {
        $this->target = null;
        $this->dpaths->add( new Loco_fs_Directory($location) );
        return $this;
    }


    /**
     * Add a global search path where translation files may live
     * @param string|Loco_fs_Directory $location
     */
    public function addSystemTargetDirectory( $location ):self {
        $this->target = null;
        $this->gpaths->add( new Loco_fs_Directory($location) );
        return $this;
    }


    /**
     * Get domain paths configured in project
     * @return Loco_fs_FileList<int,Loco_fs_Directory>
     */
    public function getConfiguredTargets():Loco_fs_FileList {
        return $this->dpaths;
    }


    /**
     * Get system paths added to project after configuration
     */
    public function getSystemTargets():Loco_fs_FileList {
        return $this->gpaths;
    }
    
    
    /**
     * Get all target directory roots including global search paths
     */
    public function getDomainTargets():Loco_fs_FileList {
        return $this->getTargetFinder()->getRootDirectories();
    }
    
    
    /**
     * Lazy create all searchable domain paths including global directories
     */
    private function getTargetFinder():Loco_fs_FileFinder {
        if( ! $this->target ){
            $target = new Loco_fs_FileFinder;
            $target->setRecursive(false)->group('pot','po','mo');
            foreach( $this->dpaths as $path ){
                // TODO search need not be recursive if it was the configured DomainPath
                // currently no way to know at this point, so recursing by default.
                $target->addRoot( (string) $path, true );
            }
            foreach( $this->gpaths as $path ){
                $target->addRoot( (string) $path, false );
            }
            $this->excludeTargets( $target );
            $this->target = $target;
        }
        return $this->target;
    }

    
    /**
     * Utility excludes current exclude paths from target finder
     */
    private function excludeTargets( Loco_fs_FileFinder $finder ):void {
        foreach( $this->xdpaths as $file ){
            if( $path = realpath( (string) $file ) ){ 
                $finder->exclude( $path );
            }
        }
        foreach( $this->xgpaths as $file ){
            if( $path = realpath( (string) $file ) ){
                $finder->exclude( $path );
            }
        }
    }


    /**
     * Check if target file or directory is excluded
     */
    private function isTargetExcluded( Loco_fs_File $file ):bool{
        return $this->xgpaths->has($file) || $this->xdpaths->has($file);
    }

    
    /**
     * Add a path for excluding in a recursive target file search
     * @param string|Loco_fs_File $path
     */
    public function excludeTargetPath( $path ):self {
        $this->target = null;
        $this->xdpaths->add( new Loco_fs_File($path) );
        return $this;
    }


    /**
     * Get all paths excluded when searching for targets
     */
    public function getConfiguredTargetsExcluded():Loco_fs_FileList {
        return $this->xdpaths;
    }


    /**
     * Get first valid domain path
     */
    private function getSafeDomainPath():Loco_fs_Directory {
        // use first configured domain path that exists
        foreach( $this->getConfiguredTargets() as $d ){
            if( $d->exists() ){
                return $d;
            }
        }
        // fallback to unconfigured, but possibly existent folders
        $base = $this->getBundle()->getDirectoryPath();
        foreach( ['languages','language','lang','l10n','i18n'] as $d ){
            $d = new Loco_fs_Directory($d);
            $d->normalize($base);
            if( $this->isTargetExcluded($d) ){
                continue;
            }
            if( $d->exists() ){
                return $d;
            }
        }
        // Give up and place in root
        return new Loco_fs_Directory($base);
    }


    /**
     * Lazy create all searchable source paths
     */
    public function getSourceFinder():Loco_fs_FileFinder {
        if( ! $this->source ){
            $source = new Loco_fs_FileFinder;
            $exts = $this->getSourceExtensions();
            $source->setRecursive(true)->filterExtensions($exts);
            /* @var $file Loco_fs_File */
            foreach( $this->spaths as $file ){
                $path = realpath( (string) $file );    
                if( $path && is_dir($path) ){
                    $source->addRoot( $path, true );
                }
            }
            $this->excludeSources( $source );
            $this->source = $source;
        }
        return $this->source;
    }


    /**
     * Get file extension filter for source code files
     */
    public function getSourceExtensions():array {
        // TODO source extensions should be moved from plugin settings to project settings
        $conf = Loco_data_Settings::get();
        $exts = $conf->php_alias;
        $exts = array_merge( $exts, $conf->jsx_alias );
        // ensure we always scan *.php and block.json files
        return array_merge( $exts, ['php','json'] );
    }


    /**
     * Utility excludes current exclude paths from passed target finder
     */
    private function excludeSources( Loco_fs_FileFinder $finder ):void {
        foreach( [$this->xspaths,$this->xgpaths] as $list ){
            foreach( $list as $file ){
                $real = realpath( (string) $file );
                if( is_string($real) && '' !== $real ){
                    $finder->exclude($real);
                }
            }
        }
    }


    /**
     * Add a root path where source files may live under for this project
     * @param string|Loco_fs_File $location
     */
    public function addSourceDirectory( $location ):self {
        $this->source = null;
        $this->spaths->add( new Loco_fs_File($location) );
        return $this;
    }


    /**
     * Add Explicit source file to project config
     * @param string|Loco_fs_File $path
     */
    public function addSourceFile( $path ):self {
        $this->source = null;
        $this->sfiles->add( new Loco_fs_File($path) );
        return $this;
    }


    /**
     * Add a file or directory as a source location
     * @param string|Loco_fs_File $path
     */
    public function addSourceLocation( $path ):self {
        $file = new Loco_fs_File( $path );
        if( $file->isDirectory() ){
            $this->addSourceDirectory( $file );
        }
        else {
            $this->addSourceFile( $file );
        }
        return $this;
    }


    /**
     * Get all source directories and files defined in project
     */
    public function getConfiguredSources():Loco_fs_FileList {
        $dynamic = $this->spaths->getArrayCopy();
        $statics = $this->sfiles->getArrayCopy();
        return new Loco_fs_FileList( array_merge( $dynamic, $statics ) );
    }


    /**
     * Test if bundle has configured source files (even if they're excluded by other rules)
     */
    public function hasSourceFiles():bool {
        return count( $this->sfiles ) || count( $this->spaths );
    }     

    
    /**
     * Add a path for excluding in source file search
     * @param string|Loco_fs_File $path
     */
    public function excludeSourcePath( $path ):self {
        $this->source = null;
        $this->xspaths->add( new Loco_fs_File($path) );
        return $this;
    }


    /**
     * Get all paths excluded when searching for sources
     */
    public function getConfiguredSourcesExcluded():Loco_fs_FileList {
        return $this->xspaths;
    }


    /**
     * Add a globally excluded location affecting sources and targets
     * @param string|Loco_fs_File $path
     */
    public function excludeLocation( $path ):self {
        $this->source = null;
        $this->target = null;
        $this->xgpaths->add( new Loco_fs_File($path) );
        return $this;
    }


    /**
     * Check whether POT file is protected from end-user update and sync operations.
     */
    public function isPotLocked():bool {
        return $this->potlock;
    }


    /**
     * Lock POT file to prevent end-user updates0
     */
    public function setPotLock( bool $locked ):self {
        $this->potlock = $locked;
        return $this;
    }


    /**
     * Get full path to template POT (file) whether it exists or nor
     */
    public function getPot():Loco_fs_File {
        if( ! $this->pot ){
            $slug = $this->getSlug();
            $name = ( $slug ?: $this->getDomain()->getName() ).'.pot';
            if( '.pot' !== $name ){
                // find actual file under configured domain paths
                $targets = $this->getConfiguredTargets()->copy();
                // always permit POT file in the bundle root (i.e. outside domain path)
                if( $this->isDomainDefault() && $this->bundle->hasDirectoryPath() ){
                    $root = $this->bundle->getDirectoryPath();
                    $targets->add( new Loco_fs_Directory($root) );
                    // look in alternative language directories if only root is configured
                    if( 1 === count($targets) ){
                        foreach( ['languages','language','lang','l10n','i18n'] as $d ) {
                            $alt = new Loco_fs_Directory($root.'/'.$d);
                            if( ! $this->isTargetExcluded($alt) ){
                                $targets->add($alt);
                            }
                        }
                     }
                }
                // pot check is for exact name and not recursive
                foreach( $targets as $dir ){
                    $file = new Loco_fs_File($name);
                    $file->normalize( $dir->getPath() );
                    if( $file->exists() && ! $this->isTargetExcluded($file) ){
                        $this->pot = $file;
                        break;
                    }
                }
            }
            // fall back to a directory that exists, but where the POT may not
            if( ! $this->pot ){
                $this->pot = new Loco_fs_File($name);
                $this->pot->normalize( (string) $this->getSafeDomainPath() );
            }
        }
        return $this->pot;
    }


    /**
     * Force the use of a known POT file. This could be a PO file if necessary
     */
    public function setPot( Loco_fs_File $pot ):self {
        $this->pot = $pot;
        return $this;
    }


    /**
     * Take a guess at most likely POT file under target locations
     */
    public function guessPot():?Loco_fs_File {
        $slug = $this->getSlug();
        if( '' === $slug ){
            $slug = (string) $this->getDomain();
            if( '' === $slug ){
                $slug = 'default';
            }
        }
        // search only inside bundle for template
        $finder = new Loco_fs_FileFinder;
        foreach( $this->dpaths as $path ){
            $finder->addRoot( (string) $path, true );
        }
        $this->excludeTargets($finder);
        $files = $finder->group('pot','po','mo')->exportGroups();
        foreach( ['pot','po'] as $ext ){
            /* @var $pot Loco_fs_File */
            foreach( $files[$ext] as $pot ){
                $name = $pot->filename();
                // use exact match on project slug if found
                if( $slug === $name ){
                    return $pot;
                }
                // support unconventional "{slug}-en_US.{ext}"
                foreach( ['-en_US'=>6, '-en'=>3 ] as $tail => $len ){
                    if( $tail === substr($name,-$len) && $slug === substr($name,0,-$len) ){
                        return $pot;
                    }
                }
            }
        }
        // Failed to find correctly named POT file,
        // but if a single POT file is found we'll use it.
        if( 1 === count($files['pot']) ){
            return $files['pot'][0];
        }
        // Either no POT files are found, or multiple are found.
        // if the project is the default in its domain, we can try aliases which may be PO
        if( $this->isDomainDefault() ){
            $options = Loco_data_Settings::get();
            if( $aliases = $options->pot_alias ){
                $found = [];
                /* @var $pot Loco_fs_File */
                foreach( $finder as $pot ){
                    $priority = array_search( $pot->basename(), $aliases, true );
                    if( false !== $priority ){
                        $found[$priority] = $pot;
                    }
                }
                if( $found ){
                    ksort( $found );
                    return current($found);
                }
            }
        }
        // failed to guess POT file
        return null;
    }


    /**
     * Get all extractable PHP source files found under all source paths
     */
    public function findSourceFiles():Loco_fs_FileList {
        $source = $this->getSourceFinder();
        // augment file list from directories unless already done so
        $list = $this->sfiles->copy();
        $crawled = $source->exportGroups();
        foreach( $crawled as $ext => $files ){
            /* @var Loco_fs_File $file */
            foreach( $files as $file ){
                $name = $file->filename();
                // skip "{name}.min.{ext}" but only if "{name}.{ext}" exists
                if( '.min' === substr($name,-4) && file_exists( $file->dirname().'/'.substr($name,0,-4).'.'.$ext ) ){
                    continue;
                }
                // .json source files like block.json theme.json etc..
                if( 'json' === $ext && 'block' !== $name && 'theme' !== $name ){
                    // arbitrarily named theme jsons, like onyx.json (twentytwentyfour)
                    if( ! $this->getBundle()->isTheme() ){
                        continue;
                    }
                    // Skip JED. We will merge these in separately as needed
                    if( preg_match('/-[0-9a-f]{32}]$/',$name ) ){
                        continue;
                    }
                    // Ok, treat as json schema file. May fail later...
                }
                $list->add($file);
            }
        }
        return $list;
    }


    /**
     * Get all translation files matching project prefix across target directories
     * @param string $ext File extension, usually "po" or "mo"
     */
    public function findLocaleFiles( string $ext ):Loco_fs_FileList {
        $finder = $this->getTargetFinder();
        $list = new Loco_fs_LocaleFileList;
        $files = $finder->exportGroups();
        $prefix = $this->getSlug(); 
        $domain = $this->domain->getName();
        $default = $this->isDomainDefault();
        $prefs = Loco_data_Preferences::get();
        /* @var $file Loco_fs_File */
        foreach( $files[$ext] as $file ){
            $file = new Loco_fs_LocaleFile( $file );
            // restrict locale by user preference
            if( $prefs && ! $prefs->has_locale( $file->getLocale() ) ){
                continue;
            }
            // add file if prefix matches and has a suffix. locale will be validated later
            if( $file->getPrefix() === $prefix && $file->getSuffix() ){
                $list->addLocalized( $file );
            }
            // else in some cases a suffix-only file like "el.po" can match
            else if( $default && $file->hasSuffixOnly() ){
                // theme files under their own directory
                if( $file->underThemeDirectory() ){
                    $list->addLocalized( $file );
                }
                // check followed links if they were originally under theme dir
                else if( ( $link = $finder->getFollowed($file) ) && $link->underThemeDirectory() ){
                    $list->addLocalized( $file );
                }
                // WordPress core "default" domain, default project
                else if( 'default' === $domain ){
                    $list->addLocalized( $file );
                }
            }
        }
        return $list;
    }


    /**
     * Find files with extension that are not localized/translation files belonging to this project
     */
    public function findNotLocaleFiles( string $ext ):Loco_fs_FileList {
        $list = new Loco_fs_LocaleFileList;
        $files = $this->getTargetFinder()->exportGroups();
        /* @var $file Loco_fs_LocaleFile */
        foreach( $files[$ext] as $file ){
            $file = new Loco_fs_LocaleFile( $file );
            // add file if it has no locale suffix and is inside the bundle
            if( $file->hasPrefixOnly() && ! $file->underGlobalDirectory() ){
                $list->add( $file );
            }
        }
        return $list;
    }


    /**
     * Initialize choice of PO file paths for a given locale
     */
    public function initLocaleFiles( Loco_Locale $locale ):Loco_fs_FileList {
        $slug = $this->getSlug();
        $domain = $this->domain->getName();
        $default = $this->isDomainDefault();
        $suffix = sprintf( '%s.po', $locale );
        $prefix = $slug ? sprintf('%s-',$slug) : '';
        $choice = new Loco_fs_FileList;
        /* @var Loco_fs_Directory $dir */
        foreach( $this->getConfiguredTargets() as $dir ){
            // theme files under their own directory normally have no file prefix
            if( $default && $dir->underThemeDirectory() ){
                $path = $dir->getPath().'/'.$suffix;
            }
            // all other paths use configured prefix, which may be empty
            else {
                $path = $dir->getPath().'/'.$prefix.$suffix;
            }
            $choice->add( new Loco_fs_LocaleFile($path) );
        }
        if( 'default' === $domain || '*' === $domain ){
            $domain = '';
        }
        /* @var Loco_fs_Directory $dir */
        foreach( $this->getSystemTargets() as $dir ){
            $path = $dir->getPath();
            // themes and plugins under global locations will be loaded by domain, regardless of prefix
            if( ( '/themes' === substr($path,-7) || '/plugins' ===  substr($path,-8) ) && '' !== $domain ){
                $path .= '/'.$domain.'-'.$suffix;
            }
            // all other paths (probably core) use the configured prefix, which may be empty
            else {
                $path .= '/'.$prefix.$suffix;
            }
            $choice->add( new Loco_fs_LocaleFile($path) );
        }

        return $choice;
    }


    /**
     * Initialize a PO file path from required location
     * @throws Loco_error_Exception
     */
    public function initLocaleFile( Loco_fs_Directory $dir, Loco_Locale $locale ):Loco_fs_LocaleFile {
        $choice = $this->initLocaleFiles($locale);
        $pattern = '!^'.preg_quote($dir->getPath(),'!').'/[^/.]+\\.po$!';
        /* @var Loco_fs_LocaleFile $file */
        foreach( $choice as $file ){
            if( preg_match($pattern,$file->getPath()) ){
                return $file;
            }
        }
        throw new Loco_error_Exception('Unexpected file location: '.$dir );
    }


    /**
     * Get newest timestamp of all translation files (includes template, but excludes source files)
     */    
    public function getLastUpdated():int {
        $t = 0;
        $file = $this->getPot();
        if( $file->exists() ){
            $t = $file->modified();
        }
        /* @var Loco_fs_File $file */
        foreach( $this->findLocaleFiles('po') as $file ){
            $t = max( $t, $file->modified() );
        }
        return $t;
    }


    /**
     * @codeCoverageIgnore
     */
    public function __debugInfo():array {
        return [
            'id' => $this->getId(),
            'domain' => (string) $this->getDomain(),
        ];
    }

}

Youez - 2016 - github.com/yon3zu
LinuXploit