Import.php 53 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357
  1. <?php
  2. namespace ZN\Importation;
  3. class __USE_STATIC_ACCESS__Import implements ImportInterface
  4. {
  5. //----------------------------------------------------------------------------------------------------
  6. //
  7. // Yazar : Ozan UYKUN <ozanbote@windowslive.com> | <ozanbote@gmail.com>
  8. // Site : www.zntr.net
  9. // Lisans : The MIT License
  10. // Telif Hakkı: Copyright (c) 2012-2016, zntr.net
  11. //
  12. //----------------------------------------------------------------------------------------------------
  13. /* Is Import Değişkeni
  14. *
  15. * Bir sınıfın daha önce dahil edilip edilmediği
  16. * bilgisini tutması için oluşturulmuştur.
  17. *
  18. */
  19. protected $isImport = [];
  20. /* Parameters Değişkeni
  21. *
  22. * Parametre bilgilerini tutması içindir.
  23. *
  24. */
  25. protected $parameters = array
  26. (
  27. 'data' => [],
  28. 'usable' => false
  29. );
  30. /* Template Değişkeni
  31. *
  32. * Template uzantısı bilgisini
  33. * bilgisini tutması için oluşturulmuştur.
  34. *
  35. */
  36. protected $templateExtension = '.template';
  37. //----------------------------------------------------------------------------------------------------
  38. // Call Method
  39. //----------------------------------------------------------------------------------------------------
  40. //
  41. // __call()
  42. //
  43. //----------------------------------------------------------------------------------------------------
  44. use \CallUndefinedMethodTrait;
  45. //----------------------------------------------------------------------------------------------------
  46. // Error Control
  47. //----------------------------------------------------------------------------------------------------
  48. //
  49. // $error
  50. // $success
  51. //
  52. // error()
  53. // success()
  54. //
  55. //----------------------------------------------------------------------------------------------------
  56. use \ErrorControlTrait;
  57. //----------------------------------------------------------------------------------------------------
  58. // Setting Methods Başlangıç
  59. //----------------------------------------------------------------------------------------------------
  60. //----------------------------------------------------------------------------------------------------
  61. // usable()
  62. //----------------------------------------------------------------------------------------------------
  63. //
  64. // @var bool $usable
  65. //
  66. //----------------------------------------------------------------------------------------------------
  67. public function usable($usable = true)
  68. {
  69. $this->parameters['usable'] = $usable;
  70. return $this;
  71. }
  72. //----------------------------------------------------------------------------------------------------
  73. // recursive()
  74. //----------------------------------------------------------------------------------------------------
  75. //
  76. // @var bool $recursive
  77. //
  78. //----------------------------------------------------------------------------------------------------
  79. public function recursive($recursive = true)
  80. {
  81. $this->parameters['recursive'] = $recursive;
  82. return $this;
  83. }
  84. //----------------------------------------------------------------------------------------------------
  85. // data()
  86. //----------------------------------------------------------------------------------------------------
  87. //
  88. // @var array $data
  89. //
  90. //----------------------------------------------------------------------------------------------------
  91. public function data($data = [])
  92. {
  93. $this->parameters['data'] = $data;
  94. return $this;
  95. }
  96. //----------------------------------------------------------------------------------------------------
  97. // headData()
  98. //----------------------------------------------------------------------------------------------------
  99. //
  100. // @var string $headData
  101. //
  102. //----------------------------------------------------------------------------------------------------
  103. public function headData($headData = true)
  104. {
  105. $this->parameters['headData'] = $headData;
  106. return $this;
  107. }
  108. //----------------------------------------------------------------------------------------------------
  109. // body()
  110. //----------------------------------------------------------------------------------------------------
  111. //
  112. // @var string $body
  113. //
  114. //----------------------------------------------------------------------------------------------------
  115. public function body($body = '')
  116. {
  117. \Config::set('Masterpage', 'bodyPage', $body);
  118. return $this;
  119. }
  120. //----------------------------------------------------------------------------------------------------
  121. // head()
  122. //----------------------------------------------------------------------------------------------------
  123. //
  124. // @var mixed $head
  125. //
  126. //----------------------------------------------------------------------------------------------------
  127. public function head($head = '')
  128. {
  129. \Config::set('Masterpage', 'headPage', $head);
  130. return $this;
  131. }
  132. //----------------------------------------------------------------------------------------------------
  133. // title()
  134. //----------------------------------------------------------------------------------------------------
  135. //
  136. // @var string $title
  137. //
  138. //----------------------------------------------------------------------------------------------------
  139. public function title($title = '')
  140. {
  141. \Config::set('Masterpage', 'title', $title);
  142. return $this;
  143. }
  144. //----------------------------------------------------------------------------------------------------
  145. // title()
  146. //----------------------------------------------------------------------------------------------------
  147. //
  148. // @var string $title
  149. //
  150. //----------------------------------------------------------------------------------------------------
  151. public function meta($meta = [])
  152. {
  153. \Config::set('Masterpage', 'meta', $meta);
  154. return $this;
  155. }
  156. //----------------------------------------------------------------------------------------------------
  157. // attributes()
  158. //----------------------------------------------------------------------------------------------------
  159. //
  160. // @var array $attributes
  161. //
  162. //----------------------------------------------------------------------------------------------------
  163. public function attributes($attributes = [])
  164. {
  165. \Config::set('Masterpage', 'attributes', $attributes);
  166. return $this;
  167. }
  168. //----------------------------------------------------------------------------------------------------
  169. // content()
  170. //----------------------------------------------------------------------------------------------------
  171. //
  172. // @var array $content
  173. //
  174. //----------------------------------------------------------------------------------------------------
  175. public function content($content = [])
  176. {
  177. \Config::set('Masterpage', 'content', $content);
  178. return $this;
  179. }
  180. //----------------------------------------------------------------------------------------------------
  181. // Setting Methods Bitiş
  182. //----------------------------------------------------------------------------------------------------
  183. //----------------------------------------------------------------------------------------------------
  184. // View Methods Başlangıç
  185. //----------------------------------------------------------------------------------------------------
  186. /******************************************************************************************
  187. * PAGE *
  188. *******************************************************************************************
  189. | Genel Kullanım: Views dosyası dahil etmek için kullanılır. |
  190. | |
  191. | Parametreler: 3 parametresi vardır. |
  192. | 1. string var @page => Dahil edilecek dosyanın yolu. |
  193. | 2. array var @data => Dahil edilecen sayfaya gönderilecek veriler. |
  194. | 3. boolean var @ob_get_contents => İçeriğin kullanımıyla ilgilidir.. |
  195. | |
  196. | Örnek Kullanım: Import::page('OrnekSayfa'); |
  197. | |
  198. ******************************************************************************************/
  199. public function page($page = '', $data = '', $obGetContents = false, $randomPageDir = PAGES_DIR)
  200. {
  201. if( stristr($page, $this->templateExtension) )
  202. {
  203. return $this->_template($page, $data, $obGetContents, $randomPageDir);
  204. }
  205. return $this->_page($page, $data, $obGetContents, $randomPageDir);
  206. }
  207. /******************************************************************************************
  208. * VIEW *
  209. *******************************************************************************************
  210. | Genel Kullanım: Views dosyası dahil etmek için kullanılır. |
  211. | |
  212. | Parametreler: 3 parametresi vardır. |
  213. | 1. string var @page => Dahil edilecek dosyanın yolu. |
  214. | 2. array var @data => Dahil edilecen sayfaya gönderilecek veriler. |
  215. | 3. boolean var @ob_get_contents => İçeriğin kullanımıyla ilgilidir.. |
  216. | |
  217. | Örnek Kullanım: Import::page('OrnekSayfa'); |
  218. | |
  219. ******************************************************************************************/
  220. public function view($page = '', $data = '', $obGetContents = false, $randomPageDir = PAGES_DIR)
  221. {
  222. return $this->page($page, $data, $obGetContents, $randomPageDir);
  223. }
  224. /******************************************************************************************
  225. * HANDLOAD *
  226. *******************************************************************************************
  227. | Genel Kullanım: Views dosyası dahil etmek için kullanılır. |
  228. | |
  229. | Parametreler: 3 parametresi vardır. |
  230. | 1. string var @page => Dahil edilecek dosyanın yolu. |
  231. | 2. array var @data => Dahil edilecen sayfaya gönderilecek veriler. |
  232. | 3. boolean var @ob_get_contents => İçeriğin kullanımıyla ilgilidir.. |
  233. | |
  234. | Örnek Kullanım: Import::page('OrnekSayfa'); |
  235. | |
  236. ******************************************************************************************/
  237. public function handload(...$args)
  238. {
  239. if( ! empty($args) ) foreach( $args as $file )
  240. {
  241. $suffix = suffix($file, '.php');
  242. $commonFile = EXTERNAL_HANDLOAD_DIR.$suffix ;
  243. $file = restorationPath(HANDLOAD_DIR.$suffix);
  244. if( is_file($file) )
  245. {
  246. require_once $file; // Yerel Dosya
  247. }
  248. elseif( is_file($commonFile) )
  249. {
  250. require_once($commonFile); // Ortak Dosya
  251. }
  252. }
  253. }
  254. /******************************************************************************************
  255. * PAGE *
  256. *******************************************************************************************
  257. | Genel Kullanım: Views dosyası dahil etmek için kullanılır. |
  258. | |
  259. | Parametreler: 3 parametresi vardır. |
  260. | 1. string var @page => Dahil edilecek dosyanın yolu. |
  261. | 2. array var @data => Dahil edilecen sayfaya gönderilecek veriler. |
  262. | 3. boolean var @ob_get_contents => İçeriğin kullanımıyla ilgilidir.. |
  263. | |
  264. | Örnek Kullanım: Import::page('OrnekSayfa'); |
  265. | |
  266. ******************************************************************************************/
  267. protected function _page($randomPageVariable = '', $randomDataVariable = '', $randomObGetContentsVariable = false, $randomPageDir = PAGES_DIR)
  268. {
  269. if( ! empty($this->parameters['usable']) )
  270. {
  271. $randomObGetContentsVariable = $this->parameters['usable'];
  272. }
  273. if( ! empty($this->parameters['data']) )
  274. {
  275. $randomDataVariable = $this->parameters['data'];
  276. }
  277. $this->parameters = [];
  278. if( ! is_string($randomPageVariable) )
  279. {
  280. return \Errors::set('Error', 'stringParameter', 'randomPageVariable');
  281. }
  282. if( ! extension($randomPageVariable) || stristr($randomPageVariable, $this->templateExtension) )
  283. {
  284. $randomPageVariable = suffix($randomPageVariable, '.php');
  285. }
  286. $randomPagePath = restorationPath($randomPageDir.$randomPageVariable);
  287. if( is_file($randomPagePath) )
  288. {
  289. if( is_array($randomDataVariable) )
  290. {
  291. extract($randomDataVariable, EXTR_OVERWRITE, 'zn');
  292. }
  293. if( $randomObGetContentsVariable === false )
  294. {
  295. require($randomPagePath);
  296. }
  297. else
  298. {
  299. ob_start();
  300. require($randomPagePath);
  301. $randomContentVariable = ob_get_contents();
  302. ob_end_clean();
  303. return $randomContentVariable ;
  304. }
  305. }
  306. else
  307. {
  308. return \Errors::set('Error', 'fileNotFound', $randomPageVariable);
  309. }
  310. }
  311. /******************************************************************************************
  312. * TEMPLATE *
  313. *******************************************************************************************
  314. | Genel Kullanım: view.template.php dosyalarını yüklemek ve ayrıştırmak için kullanılır. |
  315. | |
  316. | Parametreler: 3 parametresi vardır. |
  317. | 1. string var @page => Dahil edilecek dosyanın yolu. |
  318. | 2. array var @data => Dahil edilecen sayfaya gönderilecek veriler. |
  319. | 3. boolean var @ob_get_contents => İçeriğin kullanımıyla ilgilidir.. |
  320. | |
  321. | Örnek Kullanım: Import::page('OrnekSayfa.template'); |
  322. | |
  323. ******************************************************************************************/
  324. protected function _template($page, $data, $obGetContents, $randomPageDir = PAGES_DIR)
  325. {
  326. $return = \Template::data($this->_page($page, $data, true, $randomPageDir), $data);
  327. if( $obGetContents === true )
  328. {
  329. return $return;
  330. }
  331. echo $return;
  332. }
  333. //----------------------------------------------------------------------------------------------------
  334. // View Methods Bitiş
  335. //----------------------------------------------------------------------------------------------------
  336. //----------------------------------------------------------------------------------------------------
  337. // Template Method Başlangıç
  338. //----------------------------------------------------------------------------------------------------
  339. /******************************************************************************************
  340. * TEMPLATE *
  341. *******************************************************************************************
  342. | Genel Kullanım: .template uzantılı dosyaları yüklemek için kullanılır. |
  343. | |
  344. | Parametreler: 3 parametresi vardır. |
  345. | 1. string var @page => Dahil edilecek dosyanın yolu. |
  346. | 2. array var @data => Dahil edilecen sayfaya gönderilecek veriler. |
  347. | 3. boolean var @ob_get_contents => İçeriğin kullanımıyla ilgilidir.. |
  348. | |
  349. | Örnek Kullanım: Import::page('OrnekSayfa'); |
  350. | |
  351. ******************************************************************************************/
  352. public function template($page = '', $data = '', $obGetContents = false)
  353. {
  354. if( $return = $this->page($page, $data, $obGetContents, INTERNAL_TEMPLATES_DIR) )
  355. {
  356. return $return;
  357. }
  358. elseif( $return = $this->page($page, $data, $obGetContents, TEMPLATES_DIR) )
  359. {
  360. return $return;
  361. }
  362. elseif( $return = $this->page($page, $data, $obGetContents, EXTERNAL_TEMPLATES_DIR) )
  363. {
  364. return $return;
  365. }
  366. else
  367. {
  368. return \Errors::set('Error', 'fileNotFound', $page);
  369. }
  370. }
  371. //----------------------------------------------------------------------------------------------------
  372. // Template Method Bitiş
  373. //----------------------------------------------------------------------------------------------------
  374. //----------------------------------------------------------------------------------------------------
  375. // Master Page Method Başlangıç
  376. //----------------------------------------------------------------------------------------------------
  377. //----------------------------------------------------------------------------------------------------
  378. // Protected Set Page
  379. //----------------------------------------------------------------------------------------------------
  380. //
  381. // @param mixed $page
  382. //
  383. //----------------------------------------------------------------------------------------------------
  384. protected function _setpage($page)
  385. {
  386. if( ! empty($page) )
  387. {
  388. $eol = EOL;
  389. $return = '';
  390. // Tek bir üst sayfa kullanımı için.
  391. if( ! is_array($page) )
  392. {
  393. $return .= $this->page($page, '', true).$eol;
  394. }
  395. else
  396. {
  397. // Birden fazla üst sayfa kullanımı için.
  398. foreach( $page as $p )
  399. {
  400. $return .= $this->page($p, '', true).$eol;
  401. }
  402. }
  403. return $return;
  404. }
  405. return false;
  406. }
  407. protected function _links($masterPageSet, $head, $type)
  408. {
  409. $header = '';
  410. if( empty($masterPageSet[$type]) )
  411. {
  412. return false;
  413. }
  414. $params = $masterPageSet[$type];
  415. if( ! is_array($params) )
  416. {
  417. $params = [$params, true];
  418. }
  419. else
  420. {
  421. $params[] = true;
  422. }
  423. $header .= $this->$type(...$params);
  424. if( isset($head[$type]) )
  425. {
  426. if( is_string($head[$type]) )
  427. {
  428. $headLinks = [$head[$type], true];
  429. }
  430. else
  431. {
  432. $head[$type][] = true;
  433. $headLinks = $head[$type];
  434. }
  435. $header .= $this->$type($headLinks);
  436. }
  437. return $header;
  438. }
  439. /******************************************************************************************
  440. * MASTERPAGE *
  441. *******************************************************************************************
  442. | Genel Kullanım: Views/ dizini içinde yer alan herhangi bir sayfayı masterpage |
  443. | olarak ayarlamak için kullanılır. |
  444. | |
  445. | Parametreler: 2 parametresi vardır. |
  446. | 1. array var @data => Sayfanın body bölümüne veri göndermek için kullanılır. |
  447. | 2. array var @head => Sayfanın head bölümüne veri göndermek için kullanılır. |
  448. | |
  449. | Örnek Kullanım: Import::masterpage(); |
  450. | |
  451. | NOT: Bir sayfayı masterpage olarak ayarlamak için Config/Masterpage.php dosyası |
  452. | kullanılır. |
  453. | |
  454. ******************************************************************************************/
  455. public function masterPage($randomDataVariable = [], $head = [])
  456. {
  457. if( ! empty($this->parameters['headData']) )
  458. {
  459. $head = $this->parameters['headData'];
  460. }
  461. if( ! empty($this->parameters['data']) )
  462. {
  463. $randomDataVariable = $this->parameters['data'];
  464. }
  465. $this->parameters = [];
  466. $eol = EOL;
  467. //-----------------------------------------------------------------------------------------------------
  468. // Config/Masterpage.php dosyasından ayarlar alınıyor. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  469. //-----------------------------------------------------------------------------------------------------
  470. $masterPageSet = \Config::get('Masterpage');
  471. //-----------------------------------------------------------------------------------------------------
  472. // Başlık ve vücud sayfaları alınıyor. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  473. //-----------------------------------------------------------------------------------------------------
  474. $randomPageVariable = isset($head['bodyPage']) ? $head['bodyPage'] : $masterPageSet['bodyPage'];
  475. $headPage = isset($head['headPage']) ? $head['headPage'] : $masterPageSet['headPage'];
  476. //-----------------------------------------------------------------------------------------------------
  477. // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  478. //-----------------------------------------------------------------------------------------------------
  479. /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>HTML START<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
  480. $docType = isset($head['docType']) ? $head['docType'] : $masterPageSet["docType"];
  481. $header = \Config::get('ViewObjects', 'doctype')[$docType].$eol;
  482. $htmlAttributes = isset($head['attributes']['html']) ? $head['attributes']['html'] : $masterPageSet['attributes']['html'];
  483. $header .= '<html xmlns="http://www.w3.org/1999/xhtml"'.\Html::attributes($htmlAttributes).'>'.$eol;
  484. $headAttributes = isset($head['attributes']['head']) ? $head['attributes']['head'] : $masterPageSet['attributes']['head'];
  485. /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>HEAD START<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
  486. $header .= '<head'.\Html::attributes($headAttributes).'>'.$eol;
  487. $contentCharset = isset($head['content']['charset']) ? $head['content']['charset'] : $masterPageSet['content']['charset'];
  488. if( is_array($contentCharset) )
  489. {
  490. foreach( $contentCharset as $v )
  491. {
  492. $header .= "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=$v\">".$eol;
  493. }
  494. }
  495. else
  496. {
  497. $header .= '<meta http-equiv="Content-Type" content="text/html; charset='.$contentCharset.'">'.$eol;
  498. }
  499. $contentLanguage = isset($head['content']['language']) ? $head['content']['language'] : $masterPageSet['content']['language'];
  500. $header .= '<meta http-equiv="Content-Language" content="'.$contentLanguage .'">'.$eol;
  501. //-----------------------------------------------------------------------------------------------------
  502. // Data ve Meta verileri alınıyor. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  503. //-----------------------------------------------------------------------------------------------------
  504. $datas = $masterPageSet['data'];
  505. $metas = $masterPageSet['meta'];
  506. $title = isset($head['title']) ? $head['title'] : $masterPageSet["title"];
  507. //-----------------------------------------------------------------------------------------------------
  508. // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  509. //-----------------------------------------------------------------------------------------------------
  510. if( ! empty($title) )
  511. {
  512. $header .= '<title>'.$title.'</title>'.$eol;
  513. }
  514. //-----------------------------------------------------------------------------------------------------
  515. // Meta tagları dahil ediliyor. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  516. //-----------------------------------------------------------------------------------------------------
  517. if( isset($head['meta']) )
  518. {
  519. $metas = array_merge($metas, $head['meta']);
  520. }
  521. if( ! empty($metas) ) foreach( $metas as $name => $content )
  522. {
  523. if( isset($head['meta'][$name]) )
  524. {
  525. $content = $head['meta'][$name];
  526. }
  527. if( ! stristr($name, 'http:') && ! stristr($name, 'name:') )
  528. {
  529. $name = 'name:'.$name;
  530. }
  531. if( ! empty($content) )
  532. {
  533. $nameEx = explode(":", $name);
  534. $httpOrName = ( $nameEx[0] === 'http' ) ? 'http-equiv' : 'name';
  535. $name = ( isset($nameEx[1]) ) ? $nameEx[1] : $nameEx[0];
  536. if( ! is_array($content) )
  537. {
  538. $header .= "<meta $httpOrName=\"$name\" content=\"$content\">".$eol;
  539. }
  540. else
  541. {
  542. foreach( $content as $key => $val )
  543. {
  544. $header .= "<meta $httpOrName=\"$name\" content=\"$val\">".$eol;
  545. }
  546. }
  547. }
  548. }
  549. //-----------------------------------------------------------------------------------------------------
  550. // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  551. //-----------------------------------------------------------------------------------------------------
  552. //-----------------------------------------------------------------------------------------------------
  553. // Fontlar dahil ediliyor. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  554. //-----------------------------------------------------------------------------------------------------
  555. $header .= $this->_links($masterPageSet, $head, 'font');
  556. //-----------------------------------------------------------------------------------------------------
  557. // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  558. //-----------------------------------------------------------------------------------------------------
  559. //-----------------------------------------------------------------------------------------------------
  560. // Javascript kodları dahil ediliyor. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  561. //-----------------------------------------------------------------------------------------------------
  562. $header .= $this->_links($masterPageSet, $head, 'script');
  563. //-----------------------------------------------------------------------------------------------------
  564. // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  565. //-----------------------------------------------------------------------------------------------------
  566. //-----------------------------------------------------------------------------------------------------
  567. // Stiller dahil ediliyor. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  568. //-----------------------------------------------------------------------------------------------------
  569. $header .= $this->_links($masterPageSet, $head, 'style');
  570. //-----------------------------------------------------------------------------------------------------
  571. // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  572. //-----------------------------------------------------------------------------------------------------
  573. //-----------------------------------------------------------------------------------------------------
  574. // Browser Icon dahil ediliyor. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  575. //-----------------------------------------------------------------------------------------------------
  576. $browserIcon = isset($head['browserIcon']) ? $head['browserIcon'] : $masterPageSet["browserIcon"];
  577. if( ! empty($browserIcon) && is_file($browserIcon) )
  578. {
  579. $header .= '<link rel="shortcut icon" href="'.baseUrl($browserIcon).'" />'.$eol;
  580. }
  581. //-----------------------------------------------------------------------------------------------------
  582. // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  583. //-----------------------------------------------------------------------------------------------------
  584. //-----------------------------------------------------------------------------------------------------
  585. // Tema dahil ediliyor. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  586. //-----------------------------------------------------------------------------------------------------
  587. $theme = isset($head['theme']['name']) ? $head['theme']['name'] : $masterPageSet['theme']['name'];
  588. $themeRecursive = isset($head['theme']['recursive']) ? $head['theme']['recursive'] : $masterPageSet['theme']['recursive'];
  589. if( ! empty($theme) )
  590. {
  591. $header .= $this->theme($theme, $themeRecursive, true);
  592. }
  593. //-----------------------------------------------------------------------------------------------------
  594. // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  595. //-----------------------------------------------------------------------------------------------------
  596. //-----------------------------------------------------------------------------------------------------
  597. // Eklenti dahil ediliyor. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  598. //-----------------------------------------------------------------------------------------------------
  599. $plugin = isset($head['plugin']['name']) ? $head['plugin']['name'] : $masterPageSet['plugin']['name'];
  600. $pluginRecursive = isset($head['plugin']['recursive']) ? $head['plugin']['recursive'] : $masterPageSet['plugin']['recursive'];
  601. if( ! empty($plugin) )
  602. {
  603. $header .= $this->plugin($plugin, $pluginRecursive, true);
  604. }
  605. //-----------------------------------------------------------------------------------------------------
  606. // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  607. //-----------------------------------------------------------------------------------------------------
  608. //-----------------------------------------------------------------------------------------------------
  609. // Farklı veriler dahil ediliyor. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  610. //-----------------------------------------------------------------------------------------------------
  611. if( isset($head['data']) )
  612. {
  613. $datas = array_merge($datas, $head['data']);
  614. }
  615. if( ! empty($datas) )
  616. {
  617. if( ! is_array($datas) )
  618. {
  619. $header .= $datas.$eol;
  620. }
  621. else
  622. {
  623. foreach( $datas as $v )
  624. {
  625. $header .= $v.$eol;
  626. }
  627. }
  628. }
  629. //-----------------------------------------------------------------------------------------------------
  630. // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  631. //-----------------------------------------------------------------------------------------------------
  632. //-----------------------------------------------------------------------------------------------------
  633. // Başlık sayfası dahil ediliyor. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  634. //-----------------------------------------------------------------------------------------------------
  635. $header .= $this->_setpage($headPage);
  636. //-----------------------------------------------------------------------------------------------------
  637. // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  638. //-----------------------------------------------------------------------------------------------------
  639. $header .= '</head>'.$eol;
  640. /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>HEAD END<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
  641. /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>BODY START<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
  642. //-----------------------------------------------------------------------------------------------------
  643. // Arkaplan resmi dahil ediliyor. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  644. //-----------------------------------------------------------------------------------------------------
  645. $backgroundImage = isset($head['backgroundImage']) ? $head['backgroundImage'] : $masterPageSet["backgroundImage"];
  646. $bgImage = ( ! empty($backgroundImage) && is_file($backgroundImage) ) ? ' background="'.baseUrl($backgroundImage).'" bgproperties="fixed"' : '';
  647. //-----------------------------------------------------------------------------------------------------
  648. // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  649. //-----------------------------------------------------------------------------------------------------
  650. $bodyAttributes = isset($head['attributes']['body']) ? $head['attributes']['body'] : $masterPageSet['attributes']['body'];
  651. $header .= '<body'.\Html::attributes($bodyAttributes).$bgImage.'>'.$eol;
  652. echo $header;
  653. if( ! empty($randomPageVariable) )
  654. {
  655. $this->page($randomPageVariable, $randomDataVariable);
  656. }
  657. $randomFooterVariable = $eol.'</body>'.$eol;
  658. /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>BODY END<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
  659. $randomFooterVariable .= '</html>';
  660. /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>HTML END<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
  661. //-----------------------------------------------------------------------------------------------------
  662. // Masterpage oluşturuluyor. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  663. //-----------------------------------------------------------------------------------------------------
  664. echo $randomFooterVariable;
  665. //-----------------------------------------------------------------------------------------------------
  666. // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  667. //-----------------------------------------------------------------------------------------------------
  668. }
  669. //----------------------------------------------------------------------------------------------------
  670. // Master Page Method Bitiş
  671. //----------------------------------------------------------------------------------------------------
  672. //----------------------------------------------------------------------------------------------------
  673. // Font Method Başlangıç
  674. //----------------------------------------------------------------------------------------------------
  675. protected function _parameters($arguments, $cdn)
  676. {
  677. if( ! empty($this->parameters['usable']) )
  678. {
  679. $lastParam = $this->parameters['usable'];
  680. $this->parameters = [];
  681. }
  682. else
  683. {
  684. $argumentCount = count($arguments) - 1;
  685. $lastParam = isset($arguments[$argumentCount]) ? $arguments[$argumentCount] : false;
  686. }
  687. $arguments = array_unique($arguments);
  688. return (object)array
  689. (
  690. 'arguments' => $arguments,
  691. 'lastParam' => $lastParam,
  692. 'cdnLinks' => array_change_key_case(\Config::get('ViewObjects', 'cdn')[$cdn])
  693. );
  694. }
  695. /******************************************************************************************
  696. * FONT *
  697. *******************************************************************************************
  698. | Genel Kullanım: Harici font yüklemek için kullanılır. Yüklenmek istenen fontlar |
  699. | Resources/Fonts/ dizinine atılır. |
  700. | |
  701. | Parametreler: Tek parametresi vardır. |
  702. | 1. array/args var @fonts => Parametre olarak sıralı font dosyalarını veya dizi içinde |
  703. | eleman olarak kullanılan font dosyalarını dahil etmek için kullanılır. |
  704. | |
  705. | Örnek Kullanım: Import::font('f1', 'f2' ... 'fN'); |
  706. | Örnek Kullanım: Import::font(array('f1', 'f2' ... 'fN')); |
  707. | |
  708. ******************************************************************************************/
  709. public function font(...$fonts)
  710. {
  711. $eol = EOL;
  712. $str = "<style type='text/css'>".$eol;
  713. $args = $this->_parameters($fonts, 'fonts');
  714. $lastParam = $args->lastParam;
  715. $arguments = $args->arguments;
  716. $links = $args->cdnLinks;
  717. foreach( $arguments as $font )
  718. {
  719. if( is_array($font) )
  720. {
  721. $font = '';
  722. }
  723. $f = divide($font, "/", -1);
  724. // SVG IE VE MOZILLA DESTEKLEMIYOR
  725. $fontFile = restorationPath(FONTS_DIR.$font);
  726. $baseUrl = baseUrl($fontFile);
  727. if( ! is_file($fontFile) )
  728. {
  729. $fontFile = EXTERNAL_FONTS_DIR.$font;
  730. }
  731. if( extension($fontFile) )
  732. {
  733. if( is_file($fontFile) )
  734. {
  735. $strEx = $this->something($fontFile, '', true);
  736. break;
  737. }
  738. }
  739. if( is_file($fontFile.".svg") )
  740. {
  741. $str .= '@font-face{font-family:"'.$f.'"; src:url("'.$baseUrl.'.svg") format("truetype")}'.$eol;
  742. }
  743. if( is_file($fontFile.".woff") )
  744. {
  745. $str .= '@font-face{font-family:"'.$f.'"; src:url("'.$baseUrl.'.woff") format("truetype")}'.$eol;
  746. }
  747. // OTF IE VE CHROME DESTEKLEMIYOR
  748. if( is_file($fontFile.".otf") )
  749. {
  750. $str .= '@font-face{font-family:"'.$f.'"; src:url("'.$baseUrl.'.otf") format("truetype")}'.$eol;
  751. }
  752. // TTF IE DESTEKLEMIYOR
  753. if( is_file($fontFile.".ttf") )
  754. {
  755. $str .= '@font-face{font-family:"'.$f.'"; src:url("'.$baseUrl.'.ttf") format("truetype")}'.$eol;
  756. }
  757. // CND ENTEGRASYON
  758. $cndFont = isset($links[strtolower($font)]) ? $links[strtolower($font)] : NULL;
  759. if( ! empty($cndFont) )
  760. {
  761. $str .= '@font-face{font-family:"'.divide(removeExtension($cndFont), "/", -1).'"; src:url("'.$cndFont.'") format("truetype")}'.$eol;
  762. }
  763. // FARKLI FONTLAR
  764. $differentSet = \Config::get('ViewObjects', 'font')['differentFontExtensions'];
  765. if( ! empty($differentSet) )
  766. {
  767. foreach( $differentSet as $of )
  768. {
  769. if( is_file($fontFile.prefix($of, '.')) )
  770. {
  771. $str .= '@font-face{font-family:"'.$f.'"; src:url("'.$baseUrl.prefix($of, '.').'") format("truetype")}'.$eol;
  772. }
  773. }
  774. }
  775. // EOT IE DESTEKLIYOR
  776. if( is_file($fontFile.".eot") )
  777. {
  778. $str .= '<!--[if IE]>';
  779. $str .= '@font-face{font-family:"'.$f.'"; src:url("'.$baseUrl.'.eot") format("truetype")}';
  780. $str .= '<![endif]-->';
  781. $str .= $eol;
  782. }
  783. }
  784. $str .= '</style>'.$eol;
  785. if( isset($strEx) )
  786. {
  787. $str = $strEx;
  788. }
  789. if( ! empty($str) )
  790. {
  791. if( $lastParam === true )
  792. {
  793. return $str;
  794. }
  795. else
  796. {
  797. echo $str;
  798. }
  799. }
  800. else
  801. {
  802. return false;
  803. }
  804. }
  805. //----------------------------------------------------------------------------------------------------
  806. // Font Method Bitiş
  807. //----------------------------------------------------------------------------------------------------
  808. //----------------------------------------------------------------------------------------------------
  809. // Style Method Başlangıç
  810. //----------------------------------------------------------------------------------------------------
  811. /******************************************************************************************
  812. * STYLE *
  813. *******************************************************************************************
  814. | Genel Kullanım: Harici stil yüklemek için kullanılır. Yüklenmek istenen stiller |
  815. | Resources/Styles/ dizinine atılır. |
  816. | |
  817. | Parametreler: Tek parametresi vardır. |
  818. | 1. array/args var @styles => Parametre olarak sıralı stil dosyalarını veya dizi içinde |
  819. | eleman olarak kullanılan stil dosyalarını dahil etmek için kullanılır. |
  820. | |
  821. | Örnek Kullanım: Import::style('s1', 's2' ... 'sN'); |
  822. | Örnek Kullanım: Import::style(array('s1', 's2' ... 'sN')); |
  823. | |
  824. ******************************************************************************************/
  825. public function style(...$styles)
  826. {
  827. $str = '';
  828. $eol = EOL;
  829. $args = $this->_parameters($styles, 'styles');
  830. $lastParam = $args->lastParam;
  831. $arguments = $args->arguments;
  832. $links = $args->cdnLinks;
  833. foreach( $arguments as $style )
  834. {
  835. if( is_array($style) )
  836. {
  837. $style = '';
  838. }
  839. $styleFile = restorationPath(STYLES_DIR.suffix($style,".css"));
  840. if( ! is_file($styleFile) )
  841. {
  842. $styleFile = EXTERNAL_STYLES_DIR.suffix($style, ".css");
  843. }
  844. if( ! in_array("style_".$style, $this->isImport) )
  845. {
  846. if( is_file($styleFile) )
  847. {
  848. $str .= '<link href="'.baseUrl($styleFile).'" rel="stylesheet" type="text/css" />'.$eol;
  849. }
  850. elseif( isUrl($style) && extension($style) === 'css' )
  851. {
  852. $str .= '<link href="'.$style.'" rel="stylesheet" type="text/css" />'.$eol;
  853. }
  854. elseif( isset($links[strtolower($style)]) )
  855. {
  856. $str .= '<link href="'.$links[strtolower($style)].'" rel="stylesheet" type="text/css" />'.$eol;
  857. }
  858. $this->isImport[] = "style_".$style;
  859. }
  860. }
  861. if( ! empty($str) )
  862. {
  863. if( $lastParam === true )
  864. {
  865. return $str;
  866. }
  867. else
  868. {
  869. echo $str;
  870. }
  871. }
  872. else
  873. {
  874. return false;
  875. }
  876. }
  877. //----------------------------------------------------------------------------------------------------
  878. // Style Method Bitiş
  879. //----------------------------------------------------------------------------------------------------
  880. //----------------------------------------------------------------------------------------------------
  881. // Script Method Başlangıç
  882. //----------------------------------------------------------------------------------------------------
  883. /******************************************************************************************
  884. * SCRIPT *
  885. *******************************************************************************************
  886. | Genel Kullanım: Harici js dosyası yüklemek için kullanılır. Yüklenmek istenen stiller |
  887. | Resources/Scripts/ dizinine atılır. |
  888. | |
  889. | Parametreler: Tek parametresi vardır. |
  890. | 1. array/args var @scripts => Parametre olarak sıralı js dosyalarını veya dizi içinde |
  891. | eleman olarak kullanılan js dosyalarını dahil etmek için kullanılır. |
  892. | |
  893. | Örnek Kullanım: Import::script('s1', 's2' ... 'sN'); |
  894. | Örnek Kullanım: Import::script(script('s1', 's2' ... 'sN')); |
  895. | |
  896. ******************************************************************************************/
  897. public function script(...$scripts)
  898. {
  899. $str = '';
  900. $eol = EOL;
  901. $args = $this->_parameters($scripts, 'scripts');
  902. $lastParam = $args->lastParam;
  903. $arguments = $args->arguments;
  904. $links = $args->cdnLinks;
  905. foreach( $arguments as $script )
  906. {
  907. if( is_array($script) )
  908. {
  909. $script = '';
  910. }
  911. $scriptFile = restorationPath(SCRIPTS_DIR.suffix($script, ".js"));
  912. if( ! is_file($scriptFile) )
  913. {
  914. $scriptFile = EXTERNAL_SCRIPTS_DIR.suffix($script, ".js");
  915. }
  916. if( ! in_array("script_".$script, $this->isImport) )
  917. {
  918. if( is_file($scriptFile) )
  919. {
  920. $str .= '<script type="text/javascript" src="'.baseUrl($scriptFile).'"></script>'.$eol;
  921. }
  922. elseif( isUrl($script) && extension($script) === 'js' )
  923. {
  924. $str .= '<script type="text/javascript" src="'.$script.'"></script>'.$eol;
  925. }
  926. elseif( isset($links[strtolower($script)]) )
  927. {
  928. $str .= '<script type="text/javascript" src="'.$links[strtolower($script)].'"></script>'.$eol;
  929. }
  930. $this->isImport[] = "script_".$script;
  931. }
  932. }
  933. if( ! empty($str) )
  934. {
  935. if( $lastParam === true )
  936. {
  937. return $str;
  938. }
  939. else
  940. {
  941. echo $str;
  942. }
  943. }
  944. else
  945. {
  946. return false;
  947. }
  948. }
  949. //----------------------------------------------------------------------------------------------------
  950. // Script Method Bitiş
  951. //----------------------------------------------------------------------------------------------------
  952. //----------------------------------------------------------------------------------------------------
  953. // Something Method Başlangıç
  954. //----------------------------------------------------------------------------------------------------
  955. /******************************************************************************************
  956. * SOMETHING *
  957. *******************************************************************************************
  958. | Genel Kullanım: Herhangi bir dosya dahil etmek için kullanılır. |
  959. | |
  960. | Parametreler: 3 parametresi vardır. |
  961. | 1. string var @page => Dahil edilecek dosyanın yolu. |
  962. | 2. array var @data => Dahil edilecen sayfaya gönderilecek veriler. |
  963. | 3. boolean var @ob_get_contents => İçeriğin kullanımıyla ilgilidir.. |
  964. | |
  965. | Örnek Kullanım: Import::something('Application/Views/OrnekSayfa.php'); |
  966. | Örnek Kullanım: Import::something('Application/Resources/Styles/Stil.js'); |
  967. | |
  968. ******************************************************************************************/
  969. public function something($randomPageVariable = '', $randomDataVariable = '', $randomObGetContentsVariable = false)
  970. {
  971. if( ! empty($this->parameters['usable']) )
  972. {
  973. $randomObGetContentsVariable = $this->parameters['usable'];
  974. }
  975. if( ! empty($this->parameters['data']) )
  976. {
  977. $randomDataVariable = $this->parameters['data'];
  978. }
  979. $this->parameters = [];
  980. $eol = EOL;
  981. $randomPageVariableExtension = extension($randomPageVariable);
  982. $randomPageVariableBaseUrl = baseUrl($randomPageVariable);
  983. $return = '';
  984. if( ! is_file($randomPageVariable) )
  985. {
  986. return \Errors::set('Error', 'fileParameter', '1.(randomPageVariable)');
  987. }
  988. $randomPageVariable = restorationPath($randomPageVariable);
  989. if( $randomPageVariableExtension === 'js' )
  990. {
  991. $return = '<script type="text/javascript" src="'.$randomPageVariableBaseUrl.'"></script>'.$eol;
  992. }
  993. elseif( $randomPageVariableExtension === 'css' )
  994. {
  995. $return = '<link href="'.$randomPageVariableBaseUrl.'" rel="stylesheet" type="text/css" />'.$eol;
  996. }
  997. elseif( stristr('svg|woff|otf|ttf|'.implode('|', \Config::get('ViewObjects', 'font')['differentFontExtensions']), $randomPageVariableExtension) )
  998. {
  999. $return = '<style type="text/css">@font-face{font-family:"'.divide(removeExtension($randomPageVariable), "/", -1).'"; src:url("'.$randomPageVariableBaseUrl.'") format("truetype")}</style>'.$eol;
  1000. }
  1001. elseif( $randomPageVariableExtension === 'eot' )
  1002. {
  1003. $return = '<style type="text/css"><!--[if IE]>@font-face{font-family:"'.divide(removeExtension($randomPageVariable), "/", -1).'"; src:url("'.$randomPageVariableBaseUrl.'") format("truetype")}<![endif]--></style>'.$eol;
  1004. }
  1005. else
  1006. {
  1007. $randomPageVariable = suffix($randomPageVariable, '.php');
  1008. if( is_file($randomPageVariable) )
  1009. {
  1010. if( is_array($randomDataVariable) )
  1011. {
  1012. extract($randomDataVariable, EXTR_OVERWRITE, 'zn');
  1013. }
  1014. if( $randomObGetContentsVariable === false )
  1015. {
  1016. require($randomPageVariable);
  1017. }
  1018. else
  1019. {
  1020. ob_start();
  1021. require($randomPageVariable);
  1022. $randomContentVariable = ob_get_contents();
  1023. ob_end_clean();
  1024. return $randomContentVariable;
  1025. }
  1026. }
  1027. }
  1028. if( $randomObGetContentsVariable === false )
  1029. {
  1030. echo $return;
  1031. }
  1032. else
  1033. {
  1034. return $return;
  1035. }
  1036. }
  1037. //----------------------------------------------------------------------------------------------------
  1038. // Something Method Bitiş
  1039. //----------------------------------------------------------------------------------------------------
  1040. //----------------------------------------------------------------------------------------------------
  1041. // Package Method Başlangıç
  1042. //----------------------------------------------------------------------------------------------------
  1043. //----------------------------------------------------------------------------------------------------
  1044. // Package
  1045. //----------------------------------------------------------------------------------------------------
  1046. //
  1047. // @param string $package
  1048. // @param bool $recursive
  1049. // @param bool $getContents
  1050. //
  1051. //----------------------------------------------------------------------------------------------------
  1052. public function package($packages = "", $recursive = false, $getContents = false, $dir = '')
  1053. {
  1054. if( ! is_array($packages) )
  1055. {
  1056. return $this->_package($dir.$packages, $recursive, $getContents);
  1057. }
  1058. else
  1059. {
  1060. $return = '';
  1061. if( ! empty($packages) ) foreach( $packages as $package )
  1062. {
  1063. $return .= $this->_package($dir.$package, $recursive, true);
  1064. }
  1065. if( $getContents === false )
  1066. {
  1067. echo $return;
  1068. }
  1069. else
  1070. {
  1071. return $return;
  1072. }
  1073. }
  1074. }
  1075. //----------------------------------------------------------------------------------------------------
  1076. // Protected Package
  1077. //----------------------------------------------------------------------------------------------------
  1078. //
  1079. // @param string $package
  1080. // @param bool $recursive
  1081. // @param bool $getContents
  1082. //
  1083. //----------------------------------------------------------------------------------------------------
  1084. protected function _package($packages = "", $recursive = false, $getContents = false)
  1085. {
  1086. if( ! is_string($packages) )
  1087. {
  1088. \Errors::set('Error', 'stringParameter', 'packages');
  1089. return false;
  1090. }
  1091. if( ! empty($this->parameters['usable']) )
  1092. {
  1093. $getContents = $this->parameters['usable'];
  1094. }
  1095. if( ! empty($this->parameters['recursive']) )
  1096. {
  1097. $recursive = $this->parameters['recursive'];
  1098. }
  1099. $this->parameters = [];
  1100. $eol = EOL;
  1101. $return = '';
  1102. // Common Directory
  1103. if( ! is_dir($packages) && ! is_file($packages) )
  1104. {
  1105. $packages = str_replace(RESOURCES_DIR, EXTERNAL_RESOURCES_DIR, $packages);
  1106. }
  1107. if( is_dir($packages) )
  1108. {
  1109. $packageFiles = \Folder::allFiles(suffix($packages), $recursive);
  1110. if( ! empty($packageFiles) )
  1111. {
  1112. foreach( $packageFiles as $val )
  1113. {
  1114. $val = restorationPath($val);
  1115. if( $getContents === true )
  1116. {
  1117. $return .= $this->something($val, '', true);
  1118. }
  1119. else
  1120. {
  1121. $this->something($val);
  1122. }
  1123. }
  1124. return $return;
  1125. }
  1126. else
  1127. {
  1128. return false;
  1129. }
  1130. }
  1131. elseif( is_file($packages) )
  1132. {
  1133. // Local Directory
  1134. return $this->something($packages, '', $getContents);
  1135. }
  1136. }
  1137. //----------------------------------------------------------------------------------------------------
  1138. // Theme
  1139. //----------------------------------------------------------------------------------------------------
  1140. //
  1141. // @param string $theme
  1142. // @param bool $recursive
  1143. // @param bool $getContents
  1144. //
  1145. //----------------------------------------------------------------------------------------------------
  1146. public function theme($theme = 'Default', $recursive = false, $getContents = false)
  1147. {
  1148. return $this->package($theme, $recursive, $getContents, THEMES_DIR);
  1149. }
  1150. //----------------------------------------------------------------------------------------------------
  1151. // Plugin
  1152. //----------------------------------------------------------------------------------------------------
  1153. //
  1154. // @param string $plugin
  1155. // @param bool $recursive
  1156. // @param bool $getContents
  1157. //
  1158. //----------------------------------------------------------------------------------------------------
  1159. public function plugin($plugin = 'Default', $recursive = false, $getContents = false)
  1160. {
  1161. return $this->package($plugin, $recursive, $getContents, PLUGINS_DIR);
  1162. }
  1163. //----------------------------------------------------------------------------------------------------
  1164. // Package Method Bitiş
  1165. //----------------------------------------------------------------------------------------------------
  1166. }