QuadBracesããŒãµãŒã«é¢ããæåã®å ¬éããã»ãŒ2幎ãçµéããŸãããããã¯ãæšæºåãå¿ èŠãªæãåçŽãªãããžã§ã¯ãåãã®MODX Evolutionã®ä»£æ¿ã§ãã ããã¯ãéåžžã®åºçç©ãããŒããã©ãªãªãååºãµã€ããã»ãŒéçãªããŒãžãªã©ã§æ§æããã1ããŒãžã«ããããšãã§ããŸãã ãã以æ¥ãç§ã¯èªåã®éçºãæŽæ°ããã³ãã¥ããã£ã«æ°ä»ãããã«ã3çªç®ã®ããŒãžã§ã³ã«ã¯ããŒã«ããŸããã QuadBracesããŒãµãŒã®çŸåšã®ããŒãžã§ã³ã«ã¯éåžžã«å€ãã®å€æŽãå«ãŸããŠããããã詳现ãªãã¥ãŒããªã¢ã«ãå ¬éããå¿ èŠããããŸãã ã ãã...
ã¿ã°
ã¿ã°ãã³ãã©ããå§ããŸãããã QuadBraces 3ã§ã¯ãã¿ã°ãã³ãã©ãŒã¯åå¥ã®ã¯ã©ã¹ã«é 眮ãããŸãã ããã§ãéçºè ã¯ããŒãµãŒèªäœã®ã³ãŒããå€æŽããã«ãã¿ã°ã¿ã€ããèªç±ã«å®çŸ©ã§ããŸãã ãããè¡ãã«ã¯ãQuadBracesTagPrototypeã¯ã©ã¹ã®åå«ãäœæããŸãããã®ã¯ã©ã¹ã§ã¯ã以äžã決å®ããå¿ èŠããããŸãã
- $ _name-ã¿ã°èå¥åå
- $ _start-åæã¿ã°ã·ãŒã±ã³ã¹
- $ _rstartã¯ãMODX Revolutionæ§æã¢ãŒãã®åæã¿ã°ã·ãŒã±ã³ã¹ã§ãã è§æ¬åŒ§ãªãã
- $ _finish-æçµã¿ã°ã·ãŒã±ã³ã¹
- $ _order-ãªãã·ã§ã³ã åŠçé åº
- function mainïŒarray $ mã$ key = ``ïŒ -ã¿ã°åŠçã®çµæãè¿ãé¢æ°ã $ m-PCREéåžžããŒã¿ãããŒïŒæãéèŠïŒ-èŠã€ãã£ãã¿ã°ã®ããŒã
äŸãšããŠå®æ°ã¿ã°ãã³ãã©ã䜿çšããïŒ
class QuadBracesTagConstant extends QuadBracesTagPrototype { protected $_name = 'constant'; protected $_start = '\{\*'; protected $_rstart = '\/'; protected $_finish = '\*\}'; protected $_order = 5; public function main(array $m,$key='') { $v = ''; if (empty($key) || !defined($key)) { $this->_error = 'not found'; } else { $v = constant($key); } return $v; } }
ããã確ãã«-ãã¹ãŠããšãŠãã·ã³ãã«ã§ãã ç§ã¯ãæãªããã®ããã°ã©ããŒãšããŠãé¡åŸ®é¡ãµã€ãºã®ãã¡ã€ã«ãä¿åããå¿ èŠæ§ã«ã²ã©ãæã£ãŠããŸãã ãããã圌ããèšãããã«ãããã¯å人çãªåé¡ã§ãã
åã®åºçç©ãèªãã§ããªã人ã®ããã«ã QuadBracesã¿ã°ã®æ§æã¯ããã¹ãŠã®ã¿ã°ã¿ã€ãã§åãã§ãã
- æåã®æåã·ãŒã±ã³ã¹ã ããšãã°ãã{{ãã
- ãšã³ãã£ãã£ã®èå¥åã ã©ãã³æåãæ°åãããã°ããããã·ã¥ãããã³/ãŸãã¯ãããã§æ§æããå¿ èŠããããŸãã ããšãã°ããmy-chunkãã 泚æããŠãã ããïŒ èå¥åã®ãããã¯ããã¹ãã¬ãã«ã®ã»ãã¬ãŒã¿ãŒã®åœ¹å²ãæãããŸãã ã€ãŸããããšãã°ãå€æ°ãmy.varãã¯å®éã«ã¯ããã«é 眮ãããŸã-$ parser-> data ['my'] ['var']ã ãã£ã³ã¯ãã¹ããããããã³ãã¬ãŒãã«ã€ããŠ-以äžã
- å€æ°ã®æ¡åŒµãã³ãã©ãŒïŒãªãã·ã§ã³ïŒã ããããããïŒsome_identifierããŸãã¯ãïŒsome_identifier = `some_data_ããšãã圢åŒã®æ§é ãè¡šããŸãïŒã³ãã³ãšèå¥åã®éã«ã¹ããŒã¹ãå ¥ããªãã§ãã ããïŒã ãã³ãã©ãŒæ¡åŒµæ©èœã¯ãã¿ã°åŠçã®æçµçµæã§æ©èœããŸãã ã€ãŸããããšãã°ãé»è©±çªå·ãå«ãå€æ°ãåãåãã人éãèªã¿ãããããã«ãã©ãŒãããããŸããã
- MODXæ§æãšã®äºææ§ã®ããã«ãçå笊ãåŸã«ç¶ãå ŽåããããŸãã
- ç¹å®ã®æ°ã®åŒæ°ïŒãªãã·ã§ã³ïŒã ååŒæ°ã¯ã "ïŒsome_name =` some_value` "ãšãã圢åŒã®æ§é ã§ãã ã¯ããå€æ°ã«ãåŒæ°ãèšå®ã§ããŸãã ã¯ããåäœããŸãã ã»ãšãã©ã®å Žåãæž¡ãããåŒæ°ã¯ããŒã«ã«ãã¬ãŒã¹ãã«ããŒã§äœ¿çšãããŸãã
- æåã®æçµã·ãŒã±ã³ã¹ã ããšãã°ãã}}ãã
ããããæ¢ã«ç解ããŠããããã«ãããŒãµãŒã®3çªç®ã®ããŒãžã§ã³ã«ã¯ãMODX Revolutionæ§æã¢ãŒãããããŸãã ãã®ã¢ãŒãã§ã¯ãã¿ã°ã¯2ã€ã®éãè§æ¬åŒ§ã§å§ãŸãããã®åŸã«ã¿ã°ã®ã¿ã€ãã決å®ããç¹å®ã®æåãç¶ããŸãã ã¿ã°ã¯åžžã«2ã€ã®éãè§æ¬åŒ§ã§éããããŸãã
ç¹å®ã®ãã£ã³ã¯ã®ã¿ã°ã®äŸïŒ
{{news-item? &title=` ` &date=`15-09-17` &url=`/news/150917.html`}}
ãã£ã³ã¯ã次ã®å ŽåïŒ
<article> <h3>[+title+]</h3> <span class="date">[+date+]</span> <a href="[+url+]"> </a> </article>
ãããŠãæåŸã«ããã£ã³ã¯ã®å Žæã§ãããã衚瀺ãããŸãïŒ
<article> <h3> </h3> <span class="date">15-09-17</span> <a href="/news/150917.html"> </a> </article>
ããšãšããã°ã Uyutnenkyã®ãšãã£ã¿ãŒã®ããœãŒã¹ã³ãŒããã¡ãã¥ãŒããHTMLã¢ã€ãã ãé£ã¹ãŸãããïŒ
ããã«äœ¿çšã§ããQuadBracesã¯ã次ã®ã¿ã€ãã®ã¿ã°ããµããŒãããŠããŸãïŒ2ã€ã®ã¢ãŒãã®éå§ã·ãŒã±ã³ã¹ãšçµäºã·ãŒã±ã³ã¹ã瀺ãããŠããŸãïŒã
- [+ +]ãŸãã¯[[+]] - ããŒã«ã«å€æ° ã ã»ãšãã©ã®å Žåãã«ãŒãã§å€æ°ã¹ããããã«äœ¿çšãããŸãã ã¹ãããããé€ãä»»æã®èŠçŽ ã®åŒæ°ãèšå®ãããšãèŠçŽ ã®ããŒã«ã«ãã¬ãŒã¹ãã«ããŒã¯åŒæ°ã®å€ã«çœ®ãæããããŸãã
- {{}}ãŸãã¯[[$]] - ãã£ã³ã¯ ã HTMLã®æç 1ã€ã®ãã¡ã€ã«ã«ã¯1ã€ã®ãã£ã³ã¯ãå«ãŸããŸãã ãã³ãã¬ãŒãã®äž»ãªèŠçŽ ã®1ã€ã
- {[]}ãŸãã¯[[-]] - 1è¡ã®ã©ã€ãã©ãªãã£ã³ã¯ ã HTMLã®æç 1ã€ã®ãã¡ã€ã«ã«ã¯è€æ°ã®ãã£ã³ã¯ãå«ãŸããŸãã åè¡ã«ã¯1ã€ã®ãã£ã³ã¯ããããŸãã
- {ïŒïŒ}ãŸãã¯[[=]] - è€æ°è¡ã©ã€ãã©ãªãã£ã³ã¯ ã HTMLã®æç 1ã€ã®ãã¡ã€ã«ã«ã¯è€æ°ã®ãã£ã³ã¯ãå«ãŸããŸãã ãã£ã³ã¯ã¯æ¬¡ã®æ§é ã§åºåãããŸãïŒ "<ïŒ-tagsïŒsplit->"
- {* *}ãŸãã¯[[/]] - PHPå®æ° ã ãããã¯ãã·ã¹ãã ã§å®çŸ©ãããPHPå®æ°ïŒãŠãŒã¶ãŒã«ãããã®ãå«ãïŒã衚瀺ããŸãã
- [ïŒïŒ]ãŸãã¯[[++]] - èšå® ã SETTINGSé åã®å€æ°ã éåžžãããŒãµãŒã䜿çšããŠCMSå€æ°ãåºåããããã«äœ¿çšãããŸãã
- [* *]ãŸãã¯[[*]] - å€æ° ããŒãµãŒå€æ°ã ãã³ãã¬ãŒãã®äž»ãªèŠçŽ ã®1ã€ã
- [^ ^]ãŸãã¯[[^]] - ããŒã¿ã®ãããã° ã ããŒãµãŒã®ãããã°ããŒã¿ã
- [%%]ãŸãã¯[[ïŒ ]] - èšèªå€æ° ã èªåœèšèªå€æ°ã èšèªã·ã¹ãã ããªã³ã«ãªããšãçŸåšã®èšèªã«å¿ããŠçœ®ãæããããŸãã
- [ïŒ ïŒ]ãŸãã¯[[ïŒ ]] - ã¹ãããã ã åºæ¬çã«ãPHPã³ãŒãã®ãã£ã³ã¯ã
- [[]]ãŸãã¯[[]] - ãã£ãã·ã¥ãã©ã°ä»ãã®ã¹ãããã ã ãã£ãã·ã¥ãã©ã°ãèšå®ãããŠããå Žåã®ã¿ãäžèšãšåãã§ãã 倧ãŸãã«èšã£ãŠãå€ãtrueã®$ cachedåŒæ°ã¯ãããŒãµãŒã®å®è¡é¢æ°ã«æž¡ãããŸãã
- [ãã]ãŸãã¯[[ã]] - ãªãœãŒã¹èå¥åããã®ãªã³ã¯ ã é 眮ãããå éšçªå·ããªãœãŒã¹ãžã®ãªã³ã¯ã«å€ããŸãã 以äžã®ãªãœãŒã¹ã«ã€ããŠã
- [::]ãŸãã¯[[ïŒ]] - ã«ã¹ã¿ã å€æ°ãã³ãã©ãŒ ã ãããã«ã€ããŠã¯å¥ã«ã
ããŒãµãŒã®çŸåšã®ããŒãžã§ã³ã§ã¯ãããããããŒãµãŒãªããžã§ã¯ãã®ã»ãããçªãåºãããšãå¯èœã§ãã ãªãœãŒã¹ã åºæ¬çã«ãããã¯MODXã®ãªãœãŒã¹ãšã»ãŒåãã§ãã 倧ãŸãã«èšããšãããŒã¿ããŒã¹ã¯æçµãããžã§ã¯ãã®ããŒã¿ããŒã¹ã«æ ŒçŽãããããã«ã¯ããã°æçš¿ã®ãããšã³ããªãæ ŒçŽãããŸãã äž»ãªããšã¯ãURLãäœæããã«ã¯ãåãšã³ããªã«æ°å€IDã芪IDããŸãã¯NULLãšãšã€ãªã¢ã¹ãå«ãŸããŠããå¿ èŠãããããšãèŠããŠããããšã§ãã ããŒãµãŒãªããžã§ã¯ãã®ãªãœãŒã¹ããããã£ãèšå®ãããšãããŒãµãŒãªããžã§ã¯ãã®idxããããã£ãèšå®ãããŸãã ãªãœãŒã¹ããªãŒã®ãã©ã³ãã®ã€ã³ããã¯ã¹ãè¡šããŸãã ããã«ããããªãœãŒã¹ã®æéã»ããã®æ§é ãæäœã§ããŸãã å®éãããããã¹ãŠã®
ã«ã¹ã¿ã å€æ°ãã³ãã©ãŒã¯ãããŒãµãŒå€æ°ãã©ã³ãã ã«åŠçããäžçš®ã®ãã€ã¯ãããŒãµãŒã§ãã ããšãã°ãããŒãµãŒå€æ°ïŒãããã¡ãã¥ãŒãªã©ïŒã«ã次ã®åœ¢åŒã®URLãå«ãé åãå«ãŸããŠããå ŽåïŒ
array( array('url' => '/','title' => ''), array('url' => '/about.html','title' => ' '), array( 'url' => '/news/','title' => '','children' => array( array('url' => '/news/10-09-17.html','title' => ' '), array('url' => '/news/15-09-17.html','title' => ' ') ) ), array('url' => '/contacts.html','title' => ''), );
ããããã¡ãã¥ãŒãäœæã§ããŸãã ãããè¡ãã«ã¯ãæ§é ãé©åãªå Žæã«é 眮ããã ãã§ãã
[:menu@top-menu:]
ãã®ä»£ããã«ãç®æ¡æžããªã¹ãã䜿çšããŠã¡ãã¥ãŒã衚瀺ãããŸãã Wayfinderã®æé«ã®äŒçµ±ã§ã¯ãããã°ããã°ã
äžè¬çã«ãã«ã¹ã¿ã ãã³ãã©ãŒã«ã€ããŠã¯ãå¥ã®èšäºãæžãå¿ èŠããããšæããŸãã
ãããšã¯å¥ã«ããã³ãã¬ãŒãã®1ã€ã®éèŠãªæ©èœãã€ãŸãã¡ã¿ãã£ãŒã«ãã«ã€ããŠã ã»ãŒæåã®ããŒãžã§ã³ããããã³ãã¬ãŒãã³ãŒãã«ã¡ã¿ãã£ãŒã«ããèšå®ããæ©äŒããããŸãã ãããã¯åºæ¬çã«ããã®æ§é ã䜿çšããŠãã³ãã¬ãŒãèªäœã§å®çŸ©ãããå€æ°ã§ãã
<!-- FIELD:_? [] -->
åŒæ°ã¯ããŒãµãŒã¿ã°ãšã»ãŒåãã§ãã ãã£ãŒã«ãã§æå®ãããŠããåŒæ°ã«é¢ä¿ãªããæçµãã£ãŒã«ãã«ã¯3ã€ã®å±æ§ãå«ãŸããŸãã
- ããã©ã«ãïŒããã¹ãïŒ-ããã©ã«ãå€
- ã¿ã€ãïŒæŽæ°ïŒ-ã¿ã€ã
- ãã£ãã·ã§ã³ïŒæååïŒ-ã¿ã€ãã«
ãã¹ãŠã®ã¡ã¿ãã£ãŒã«ãã¯ãããŒãµãŒã®fieldsããããã£ãä»ããŠã¢ã¯ã»ã¹ã§ããŸãã
åæ§ã«éèŠãªæ©èœã¯ãã¡ã¿å€ã§ãã somevarå€æ°ãããŒãµãŒã§å®çŸ©ãããŠãããšæ³åããŠãã ããã ã€ã³ã¹ããŒã«ããããã³ãã¬ãŒãã®ã¡ã¿å€ã¯ãå€æ°ã®çŸåšã®å€ããªãŒããŒã©ã€ãã§ããŸãã ã¡ã¿å€ã¯èšèšã«ãã£ãŠæ±ºå®ãããŸãã
<!-- DATA:_ ` ` -->
ãã³ãã¬ãŒããã€ã³ã¹ããŒã«ãããšãäž¡æ¹ãšããã³ãã¬ãŒãã®æçµã³ãŒãããåé€ãããŸãã
ã¯ã©ã¹API
ã¯ã©ã¹ããããã£ïŒæãéèŠïŒ
ïŒ- ææè ïŒãªããžã§ã¯ãïŒ-ææè ãªããžã§ã¯ãïŒèªã¿åãå°çšãåæåäžã«ã€ã³ã¹ããŒã«ïŒ;
- ãã¹ ïŒé åïŒ-ãã³ãã¬ãŒããã¹ã é åã«èšå®ã§ãããã¹ãã³ã³ãã§ãªã¹ããããŠããè¡ã«ããããšãã§ããŸãã
- fields ïŒé åïŒ-ãã³ãã¬ãŒããã£ãŒã«ãïŒèªã¿åãå°çšïŒ;
- ããŒã¿ ïŒé åïŒ-ããŒãµãŒå€æ°ã
- èšå® ïŒé åïŒ-ãèšå®ã;
- debug ïŒarrayïŒ-ãããã°ããŒã¿ã
- language ïŒstringïŒ-çŸåšã®èšèªã äžè¬ã«åãå ¥ããããŠããæšæºã«åŸã£ã眲åã
- loadLanguage ïŒãã©ã°ïŒ-èšèªã®èªåããŒãïŒããã©ã«ãã¯falseïŒ;
- dictionary ïŒarrayïŒ-çŸåšã®èŸæžã çã®ããã¹ããè¡ã«åå²ããŠèšå®ã§ããŸãã
- maxLevel ïŒæŽæ°ïŒ-æ倧ãã¹ãã¬ãã«ïŒããã©ã«ãã§ã¯32ïŒã
- ã¬ãã« ïŒæŽæ°ïŒ-çŸåšã®ã¬ãã«ã
- notice ïŒé åïŒ-éç¥ã®ã¬ãã«ã "strict"-ãã¹ãŠã®èŠçŽ ã "common"ïŒããã©ã«ãïŒ-ãã£ã³ã¯ãšã¹ããããã®æå³ãç解ããŠããŸãã
- ãã³ãã¬ãŒã ïŒããã¹ãïŒ-ãã³ãã¬ãŒã; ã€ã³ã¹ããŒã«æã«ãååãæå®ããå 容ãè¿ããŸãã
- templateName ïŒæååïŒ-çŸåšã®ãã³ãã¬ãŒãã®ååïŒèªã¿åãå°çšïŒ;
- autoTemplate ïŒãã©ã°ïŒ-ã€ã³ã¹ããŒã«ãããã³ã³ãã³ãããã®ãã³ãã¬ãŒãã®èªåæœåºããã³ã€ã³ã¹ããŒã«ã®ãã©ã°ã 倧ãŸãã«èšã£ãŠããã³ãã¬ãŒãã¡ã¿ããŒã«ãæå¹ã«ããŠã³ã³ãã³ããããŒãµãŒã«ãã£ãŒããããšãããŒãµãŒã¯èªåçã«ãã³ãã¬ãŒããèšå®ããŸãïŒããã©ã«ãã§ã¯falseïŒã
- ã³ã³ãã³ã ïŒããã¹ãïŒ-ã³ã³ãã³ãã äžè¬çã«ãæ¬è³ªçã«ãã³ã³ãã³ãããšåŒã°ããå€æ°ã
- ãªãœãŒã¹ ïŒé åïŒ-ãªãœãŒã¹ã®é åã
- idx ïŒé åïŒ-ãªãœãŒã¹ããªãŒã®ãã©ã³ãã®ã€ã³ããã¯ã¹ïŒèªã¿åãå°çšïŒã
- SEOStrict ïŒãã©ã°ïŒ-SEOStrictæšæºãžã®æºæ ïŒããã©ã«ãã§ã¯falseïŒã
- MODXRevoMode ïŒãã©ã°ïŒ -MODX Revolutionæ§æã¢ãŒããžã®åãæ¿ãïŒããã©ã«ãã§ã¯falseïŒã
æ¹æ³
ïŒ- registerTagïŒQuadBracesTagPrototype $ oïŒ -ã¿ã°ç»é²; åæåãããã¿ã°ãå ¥åãšããŠåãå ¥ããŸãã ç»é²æžã¿ã®ã¿ã°ãè¿ããŸãã
- parseStartïŒ$ mïŒ -åŠçã®éå§ã å ¥åã¯preg_match_callbacké¢æ°ããããŒã¿ãåãåããŸãã èŠçŽ ã®ããŒãè¿ããŸãã
- parseFinishïŒ$ mã$ tã$ kã$ vïŒ -åŠçã®çµäºã å ¥åã¯ãã¬ã®ã¥ã©ãŒã·ãŒãºã³ãã¿ã°ã¿ã€ããã¿ã°ããŒãçŸåšã®åŠçå€ããããŒã¿ãåãåããŸãã åŠççµæãè¿ããŸãã
- èšå®ïŒ$ããŒã$å€= nullïŒ -èšå®ã®èªã¿åã/æžã蟌ã¿ã nullã®å Žåãèªã¿åãã
- å€æ°ïŒ$ããŒã$å€= nullïŒ -å€æ°ã®èªã¿åã/æžã蟌ã¿ã nullã®å Žåãèªã¿åãã
- searchïŒ$ typeã$ nameïŒ -èŠçŽ ãã¡ã€ã«ãæ€çŽ¢ããŸã; ããŒã«ã©ã€ãºãèæ ®ããŸãã èŠã€ãã£ããã¡ã€ã«ã®ååãè¿ããŸãã
- setTemplateïŒ$ vïŒ -ãã³ãã¬ãŒããååã§èšå®ããŸãã ãã³ãã¬ãŒãã€ã³ã¹ããŒã«ã®ã³ãŒã«ããã¯ã䜿çšããå Žåã«éåžžã«å¿ èŠãªæ¹æ³ã
- getChunkïŒ$ããŒã$ã¿ã€ã= 'ãã£ã³ã¯'ïŒ - ãã£ã³ã¯ã®å 容ãååŸããŸãã èŠã€ãã£ããã£ã³ã¯ã®å 容ãŸãã¯falseãè¿ããŸãã
- executeïŒ$ nameã$ args = arrayïŒïŒã$ input = ''ã$ cached = falseïŒ -ã¹ãããããŸãã¯æ¡åŒµæ©èœãå®è¡ããŸã; ã¹ããããã®ååãåŒæ°ãå ¥åããã¹ãããã£ãã·ã¥ãã©ã°ãåãå ¥ããŸãã åŠçã®çµæãè¿ããŸãã
- parseïŒ$ t = ``ã$ d = nullã$ e = ''ã$ k = ''ïŒ -ã¡ã€ã³ã®ããŒãµãŒã¡ãœãããåŠçäžã§ã; ãã³ãã¬ãŒãå šäœãåŠçããããã«åŒæ°ãèšå®ããå¿ èŠã¯ãããŸããã åŒæ°ã¯ãå éšã®ããŒãºãŸãã¯åå¥ã®åŠçïŒQuadBracesã³ãŒãã®äžéšïŒã«å¿ èŠã§ãã å ¥ååŒæ°-å ¥åã³ãŒããå€æ°ã®ããŒã¿ãèŠçŽ ãèŠçŽ ããŒã åºåã§-åŠçãããããŒã¿ã
- sanitizeïŒ$ t = ''ïŒ -QuadBracesããã®å ¥åã³ãŒãã®ãµãã¿ã€ãºã
- æ¡åŒµæ©èœïŒ$ vã$ eïŒ -æ¡åŒµæ©èœã®å®è¡; å ¥åæ-çŸåšã®ã³ãŒããšæ¡åŒµåä»ãã®è¡ã
- registerEventïŒ$ nã$ fïŒ -ã€ãã³ãç»é²; å ¥åæ-ã€ãã³ããšé¢æ°ã®ååã
- registerMethodïŒ$ nã$ fïŒ -APIã¡ãœãããç»é²ããŸãã å ¥åæ-ã¡ãœãããšé¢æ°ã®ååã
- invokeïŒïŒ -ã€ãã³ãåŒã³åºãã æåã®åŒæ°ã¯ã€ãã³ãã®ååã§ãæ®ãã¯åŒã³åºãåŒæ°ã§ãã
ã©ããèŠãŸããïŒ
QuadBracesããŒãµãŒã®æãéèŠãªããããã£ã®1ã€ã¯ãpathsããããã£ã§ãã ããŒãµãŒããã£ã³ã¯ãã¹ãããããæ¡åŒµæ©èœããã³ãã¬ãŒããæ¢ãå Žæã決å®ããŸãã èšèªã·ã¹ãã ã¯å°ãé¢ããŠåäœããŸãã èŠçŽ ãæ€çŽ¢ããããã»ã¹ã§ã¯ãããŒãµãŒã¯ç»é²ããããã¹ãŠã®ãã¹ãé çªã«æ€çŽ¢ããŸãã æ¯åãæ€çŽ¢æ©èœã¯ãèŠçŽ ã®ã¿ã€ãã«å¿ããŠãéžæãããã¹ã«ãã©ã«ããŒãè¿œå ããŸãã ãã£ã³ã¯-ãã£ã³ã¯ããã³ãã¬ãŒã-ãã³ãã¬ãŒããã¹ãããã-ã¹ããããã ãããŠããã§ã«å¿ èŠãªèŠçŽ ãæ±ããããŠããŸãã ãã£ã³ã¯ãã¹ãããããããã³ãã³ãã¬ãŒãã®ããŒã®ãããããå®éã«ã¯ãã£ã¬ã¯ããªã»ãã¬ãŒã¿ãŒã眮ãæããããšãæãåºãããŠãã ããã
äŸïŒ
$parser->paths = 'D:/projects/mysite/content,D:/repo/templates/default'; $fn = $parser->search('snippet','basis.snipcon');
å®éããã®å Žåã®ããŒãµãŒã¯æ¬¡ã®ãã¡ã€ã«ã®ååšã確èªããŸãã
D:/projects/mysite/content/snippets/basis/snipcon.php
D:/repo/templates/default/snippets/basis/snipcon.php
æåŸã«èŠã€ãã£ããã¡ã€ã«ãè¿ãããŸãã èšèªã·ã¹ãã ããªã³ã«ãªã£ãŠããå Žåãèšèªçœ²åä»ãã®ãã¹ãå®éã«æ€çŽ¢ã«è¿œå ãããŸãã ã€ã³ã¹ããŒã«ãããŠããèšèªããã·ã¢èªãã€ãŸãã眲åããruãã§ãããšããŸãã ãããã£ãŠããã¡ã€ã«ã®ãªã¹ãã¯æ¬¡ã®ãšããã§ãã
D:/projects/mysite/content/snippets/basis/snipcon.php
D:/projects/mysite/content/snippets/basis/ru/snipcon.php
D:/repo/templates/default/snippets/basis/snipcon.php
D:/repo/templates/default/snippets/basis/ru/snipcon.php
ä»ã®ãã¹ãŠã¯ãããããã£ãšã¡ãœãããéããŠååŸãããŸãã
èšèªäœç³»
ãŸããèšèªã·ã¹ãã ãæ瀺çã«å«ããå¿ èŠãããããšãããã«äºçŽããŸãã ããã¯ãQuadBracesLangã¯ã©ã¹ãæ¥ç¶ããããšã«ããè¡ãããŸãã ããã¯ãã¡ã€ã³ã¯ã©ã¹ãå«ããåã®æãåçŽãªã³ãŒãã§å®è¡ãããŸãã
define("QUADBRACES_LOCALIZED",true);
loadLanguageãã©ã°ãæå¹ã«ããããšããå§ãããŸãã ãã®åŸãèŸæžãèªåçã«ããŒããããŸãã ååãšããŠãããã©ã«ãã§ã¯ãããŒãµãŒã®ãã¹ãèšå®ãããšãèšèªã·ã¹ãã ã®ãã¹ãèšå®ãããŸãã å®éãèšèªã·ã¹ãã ã¯ãèŠçŽ æ€çŽ¢ãšã³ãžã³ãšåãåçã§ãã¡ã€ã«ãæ€çŽ¢ããŸãã èšèªã·ã¹ãã ãã©ã«ãã®ã¿ãlangã§ãã
äŸïŒ
$parser->paths = 'D:/projects/mysite/content,D:/repo/templates/default'; $parser->language = 'ru';
ãã©ã«ããŒãã¹ãã£ã³ãããŸãïŒ
D:/projects/mysite/content/lang/ru/
D:/repo/templates/default/lang/ru/
ãããã§ã¯ãæ¡åŒµåãlngããæã€ãã¹ãŠã®ãã¡ã€ã«ãæ€çŽ¢ãããŸãã åãã¡ã€ã«ã¯1è¡ãã€èªã¿åãããŸãã åè¡ã«ã¯ãèšèªããŒãã¿ã€ãã«ã説æããã¬ãŒã¹ãã«ããŒã®4ã€ã®èŠçŽ ããããŸãã èšèªããŒã¯ãèšèªã¿ã°ã§äœ¿çšããããã®ã§ãã ãã£ãã·ã§ã³-ããã©ã«ãã®èšèªã¿ã°ã眮ãæããŸãã 説æ-éåžžãããŒã«ããããŸãã¯ãã£ãŒã«ãã®èª¬æã«äœ¿çšãããŸãã ãã¬ãŒã¹ãã«ããŒ-ã»ãšãã©ã®å Žåãå ¥åèŠçŽ ã®å¯Ÿå¿ããå±æ§ã«äœ¿çšãããŸãã
ã€ãã³ã
ããŒãµãŒãªããžã§ã¯ãã¯ã€ãã³ãããµããŒãããŸãã äžã§æžããããã«ããã³ãã©ãŒã¯registerEventã¡ãœããã«ãã£ãŠèšå®ãããŸãã
ãµããŒããããã€ãã³ãïŒã©ãã§ã$ pã¯ããŒãµãŒãªããžã§ã¯ãã§ãïŒïŒ
- initïŒ$ pïŒ -ã³ã³ã¹ãã©ã¯ã¿ãŒã®å®äºã
- beforeChangeDataïŒ$ vã$ pïŒ -ãããã®å€æ°ãå€æŽããåã $ v-èšå®å¯èœãªå€æ°ã
- changeDataïŒ$ vã$ pïŒ -å€æ°ã®ããŒã¿ãå€æŽããŸãã $ v-èšå®å¯èœãªå€æ°ã
- beforeChangeSettingsïŒ$ vã$ pïŒ -èšå®ããŒã¿ãå€æŽããåã $ v-ã€ã³ã¹ããŒã«å¯èœãªèšå®ã
- changeSettingsïŒ$ vã$ pïŒ -èšå®ããŒã¿ãå€æŽããŸãã $ v-ã€ã³ã¹ããŒã«å¯èœãªèšå®ã
- beforeLoadDictionaryïŒ$ vã$ pïŒ -èŸæžãããŒãããåã $ vã¯èŸæžã§ãã
- loadDictionaryïŒ$ vã$ pïŒ -èŸæžãããŠã³ããŒãããŸãã $ vã¯èŸæžã§ãã
- methodNotFoundïŒ$ nã$ pïŒ -ã¡ãœãããèŠã€ãããŸããã $ n-ã¡ãœããã®ååã
- beforeSetLanguageïŒ$ vã$ pïŒ -èšèªãã€ã³ã¹ããŒã«ããåã $ v-èšèª;
- setLanguageïŒ$ vã$ pïŒ -èšèªãã€ã³ã¹ããŒã«ãããšãã $ v-èšèª;
- setContentïŒ$ vã$ pïŒ -ã³ã³ãã³ããã€ã³ã¹ããŒã«ãããšãã $ v-ã³ã³ãã³ãã
- setResourcesïŒ$ vã$ pïŒ -ãªãœãŒã¹ãã€ã³ã¹ããŒã«ãããšãã $ v-ãªãœãŒã¹ããŒã¿ã
- invalidHandlerïŒ$ nã$ aã$ pïŒ -ã€ãã³ããã³ãã©ãŒããªãå Žåã $ n-ãã³ãã©ãŒã®ååã$ a-æž¡ãããåŒæ°ã
- setResourcesïŒ$ vã$ pïŒ -ãªãœãŒã¹ãã€ã³ã¹ããŒã«ãããšãã $ v-ãªãœãŒã¹ããŒã¿ã
- defaultTemplateïŒ$ pïŒ -ããã©ã«ãã®ãã³ãã¬ãŒãïŒç©ºã®ãã³ãã¬ãŒãã®ã€ã³ã¹ããŒã«ãè©Šã¿ãŸãïŒ;
- loadTemplateïŒ$ vã$ pïŒ -ãã³ãã¬ãŒããã€ã³ã¹ããŒã«ãããšã; $ v-ãã³ãã¬ãŒãã®ååã
- templateMotFoundïŒ$ vã$ pïŒ -ãã³ãã¬ãŒãããªãå Žåã $ v-ãã³ãã¬ãŒãã®ååã
- templateFieldsïŒ$ vã$ pïŒ -ãã³ãã¬ãŒããã£ãŒã«ãã®ååŸã $ v-ãã³ãã¬ãŒããã£ãŒã«ãã
- templateDataïŒ$ vã$ pïŒ -ãã³ãã¬ãŒãããŒã¿ãååŸããŸãã $ v-ãã³ãã¬ãŒãããŒã¿ã
- beforeLocalParseïŒ$ vã$ dã$ pïŒ -ããŒã«ã«åŠçã®åã $ v-åŠçãããã³ãŒãã$ d-ããŒã¿ã
- beforeParseïŒ$ vã$ pïŒ -åŠçå; $ v-åŠçãããã³ãŒãã
- localParseïŒ$ vã$ pïŒ -ããŒã«ã«ãã³ãã¬ãŒãã®åŠçåŸïŒãµãã¿ã€ãºåïŒ; $ v-åŠçãããã³ãŒãã
- parseïŒ$ vã$ pïŒ -ãã³ãã¬ãŒãã®åŠçåŸïŒãµãã¿ã€ãºåïŒ; $ v-åŠçãããã³ãŒãã
ç§ã¯åçœããŸãããç¥ããªããã¡ã«PHPã®1ã€ã®æ©èœã«ã¶ã€ãããŸããã ããšãã°ãtemplateNotFoundã€ãã³ããã³ãã©ãŒã«é¢æ°ãå²ãåœãŠããã®äžã«ãã³ãã¬ãŒãããããã£ãèšå®ããããšããŠããäœãèµ·ãããŸããã ããã¯ãPHPãªããžã§ã¯ãã®ããããã£ã®ã¢ã¯ã»ãµãŒãåŒã³åºããšãã®ååž°å¶éã«ãããã®ã§ãã ã€ãŸããåãããããã£ã®ã¢ã¯ã»ãµãŒãšã¢ã¯ã»ãµãŒãä»ããŠããããã£ãèšå®ããããšã¯ã§ããŸããã ãŸããã ãå®å šã«ããšããèšèããã ãããã£ãŠãtemplateNotFoundã€ãã³ããã³ãã©ãŒã§404çªç®ãäœæããå Žåã¯ããã®å éšã§
ãã³ãã©ãŒæ¡åŒµ
ãã¹ãŠã®ã¿ã°ã¯æçµå€ãã³ãã©ãŒããµããŒãããŸãã ããšãã°ãå€æ°ãååŸããŸãããã空ã§ãã notemptyãã³ãã©ãŒã䜿çšãããšããã®ã±ãŒã¹ã®åºåããã¹ããèšå®ã§ããŸãã äžéšã®æ¡åŒµæ©èœã«ã¯ãè¿œå ã®ãæ¡åŒµæ©èœãããããŸãã ããšãã°ãåºç€ãšãªãããžãã¯ã«ã¯ãthenãããã³ãelseããšããæ¡åŒµåããããŸãã
ãµããŒãããããã³ãã©ãŒ
- isãeq-çåŒïŒæ¯èŒãããå€ãããããïŒ
- isnotãneq-äžçåŒïŒå€ã®æ¯èŒããã以å€ã®å ŽåïŒ
- lt-ããå°ããïŒæ¯èŒå€ãããããïŒ
- lte-ããå°ããããŸãã¯çããïŒå€ã®æ¯èŒããã以å€ã®å ŽåïŒ
- gt-ãã倧ããïŒæ¯èŒå€ãããããïŒ
- gte-以äžïŒæ¯èŒãããå€ããã以å€ã®å ŽåïŒ
- å¶æ° -ããªãã£ã®ç¬Šå·ïŒå€ã®æ¯èŒããã以å€ã®å ŽåïŒ
- å¥æ° - å¥æ°èšå·ïŒæ¯èŒããå€ããã以å€ïŒ
- empty-空ã®å€ã®ãµã€ã³ïŒå€ "then"ããã®ä»ïŒ
- notempty-空ã§ãªãå€ã®ãµã€ã³ïŒå€ "then"ããã®ä»ïŒ
- nullãisnull-å€ãNULLãã©ããïŒå€ "then"ããã®ä»ïŒ
- notnull-å€ãNULLã§ã¯ãªããã©ããïŒæ¬¡ã«ãããã§ãªãå ŽåïŒ
- isarray-å€ãé åãã©ããïŒå€ "then"ããã®ä»ïŒ
- for-æŽæ°å埩åïŒå埩åæ°ãéå§ãã¹ããªãã¿ãŒïŒ
- foreach-ã€ã³ããã¯ã¹ã€ãã¬ãŒã¿ïŒã€ã³ããã¯ã¹ã®ã³ã³ãåºåããªã¹ããã¹ããªãã¿ãŒïŒ
- js-link-å€ãã¹ã¯ãªãããžã®ãªã³ã¯ã«å€æããŸã
- css-link-å€ãã¹ã¿ã€ã«ã·ãŒããžã®ãªã³ã¯ã«å€æããŸã
- import-å€ãã¹ã¿ã€ã«ã·ãŒããžã®ãªã³ã¯ã«å€æããŸãïŒCSSã®@importïŒ
- ãªã³ã¯ -å€ããªã³ã¯ïŒã¿ã€ãã«ïŒã«å€æããŸã
- link-external-å€ãå€éšãªã³ã¯ïŒããããŒïŒã«å€æããŸã
- links-å€ã®ãã¹ãŠã®URLããªã³ã¯ïŒãªã³ã¯å±æ§ïŒã«å€æããŸã
- ulãol-è€æ°è¡ã®å€ããªã¹ãã«å€æããŸãïŒãªã¹ãã¢ã€ãã ãã³ãã¬ãŒãïŒ
ul / olæ¡åŒµã«ã¯ã2ã€ã®å éšãã¬ãŒã¹ãã«ããŒããããŸãã[+ã¯ã©ã¹+]-èŠçŽ ã¯ã©ã¹ïŒæåãæåŸïŒã[+ã¢ã€ãã +]-å®éã®æååã æ¡åŒµã®å ŽåãçŸåšã®å埩çªå·ãå«ãå éšãã¬ãŒã¹ãã«ããŒ[+ã€ãã¬ãŒã¿ãŒ+]ã䜿çšå¯èœã§ãã foreachæ¡åŒµã®å éšãã¬ãŒã¹ãã«ããŒãå©çšå¯èœã§ãïŒ[+ iterator.index +]-çŸåšã®å埩ã®äœçœ®çªå·ã[+ iterator +]-çŸåšã®ã€ã³ããã¯ã¹ã
ã¯ãŒã¯ã·ã§ãã
å®éãããŒãµãŒã¯ã©ã¹ã®æäœã¯éåžžã«ç°¡åã§ãã åºæ¬çãªäŸïŒ
<?php require 'quadbraces/parser.php'; $parser = new QuadBracesParser('//__'); $parser->template = 'my-template'; echo $parser->parse(); ?>
ãã®äžã§ãããŒãµãŒã¯ã©ã¹ãæ¥ç¶ãããã³ãã¬ãŒãããŒã¿ãžã®ãã¹ã§ãªããžã§ã¯ããåæåãããã³ãã¬ãŒããšparsimãèšå®ããŸãã ãã¡ãããåŠçããåã«ããèšå®ããããŒãµãŒå€æ°ã«æž¡ãããšãã§ããŸãã ãããŠãããŒãµãŒã¯ã©ã¹ããªã³ã«ããåã«ãäžèšã®ããã«èšèªã·ã¹ãã ããªã³ã«ããŸãã ããå®çšçãªäŸïŒ
<?php define("QUADBRACES_LOCALIZED",true); require 'quadbraces/parser.php'; $parser = new QuadBracesParser('D:/projects/foo/content/template'); $parser->language = 'ru'; $parser->data = array( 'pagetitle' => ' ', 'date' => '20-09-17', 'image' => 'content/images/flies.jpg' ); $parser->template = 'news.single'; echo $parser->parse(); ?>
ãã³ãã¬ãŒãã¯ã次ã®ãã¡ã€ã«ã§æ€çŽ¢ãããŸãã
D:/projects/foo/content/template/templates/news/single.html
D:/projects/foo/content/template/templates/news/ru/single.html
ç·å 責äºé
ãã¥ãŒããªã¢ã«ãããã¥ã¡ã³ããæžãããšãã§ããªãããšããizeã³ããŸãïŒ ã³ãã¥ããã£ãæ¬åœã«èå³ãæã£ãŠãããªããæãèå³æ·±ãç¹ã¯ãã®åŸã®åºçç©ã§æããã«ãããã§ãããã 質åãã-åãã§ãçãããŸãã ééãã«æ°ã¥ãããã ããã§githubã«åé¡ãæžããŠãã ãã ã