$src = infra_admin_cache('files_get_php', function ($isrc) { $src = infra_theme($isrc); if ($src) { return $src; } $fdata = infra_srcinfo($isrc); $folder = infra_theme($fdata['folder']); if (!infra_theme($folder)) { return false; } array_map(function ($file) use(&$result, $fdata) { if ($file[0] == '.') { return; } $file = infra_toutf($file); $fd = infra_nameinfo($file); if ($fdata['id'] && $fdata['id'] != $fd['id']) { return; } if ($fdata['name'] && $fdata['name'] != $fd['name']) { return; } if ($fdata['ext'] && $fdata['ext'] != $fd['ext']) { return; } elseif ($result) { //Расширение не указано и уже есть результат //Исключение.. расширение tpl самое авторитетное if ($fd['ext'] != 'tpl') { return; } } $result = $file; }, scandir(infra_theme($folder))); if (!$result) { return false; } return infra_theme($folder . $result); }, array($fdata['path']), isset($_GET['re']));
return $ans; }, array($id)); return infra_echo($ans); } else { if ($type == 'sitemap') { $html = infra_admin_cache('sitemap', function () { $data = array(); $all = array(); $list = infrajs_seo_list(); foreach ($list as $name) { $seo = infrajs_seo_getSeo($name); $all = array_merge($all, $seo['all']); } $data['list'] = array(); foreach ($all as $k => $v) { if (!$k) { $data['list'][] = array('link' => $k); } else { $data['list'][] = array('link' => $k, 'q' => '?'); } } $data['host'] = $_SERVER['HTTP_HOST']; $data['root'] = infra_view_getRoot(); $data['date'] = time(); $html = infra_template_parse('*seo/sitemap.tpl', $data, 'sitemap'); return $html; }); header('content-type: application/xhtml+xml'); echo $html; exit; } }
function infrajs_seo_save() { $conf = infra_config(); if (!$conf['seo']['seo']) { return; } infra_admin_cache('infrajs_seo_save', function () { $store =& infrajs_store(); $dir = 'infra/cache/seo/'; if (is_dir($dir)) { $list = infra_loadJSON('*pages/list.php?src=' . $dir . '&onlyname=1'); foreach ($list as $file) { unlink($dir . infra_tofs($file)); } $r = rmdir($dir); if (!$r) { $conf = infra_config(); if ($conf['debug']) { die('Не удалось удалить папку ' . $dir); } } } @mkdir($dir); foreach ($store['seo'] as $name => $seo) { file_put_contents($dir . infra_tofs($name) . '.json', infra_json_encode($seo)); } }); }
function _seo_all($name = false) { //Возвращает все [seo,seo] с item указанными по умолчанию и item заполненными пользователем //Те что заполенны пользователем отмечены user:true //Для каждого item расчитан link $list = infra_admin_cache('seo.inc.php', function ($name) { $list = infra_loadJSON('*pages/list.php?src=infra/cache/seo/&f=1&d=0&onlyname=2'); $seo = array(); $items_cache = array(); foreach ($list as $i) { $s = infra_loadJSON('infra/cache/seo/' . $i . '.json'); //{link:'',items:[{}]} if (!isset($s['link'])) { continue; } //link обязателен $linktpl = $s['link']; $seo[$i] = $s; if (!isset($seo[$i]['items'])) { $seo[$i]['items'] = array(); } $items_cache[$i] = array(); foreach ($seo[$i]['items'] as $item) { if ($linktpl) { $link = infra_template_parse(array($linktpl), $item['data']); } else { $link = ''; } $item['layer'] = true; $item['link'] = $link; $items_cache[$i][$link] = $item; } } $list = infra_loadJSON('*pages/list.php?src=infra/data/seo/&f=1&d=0&onlyname=2'); foreach ($list as $i) { if (!isset($seo[$i])) { continue; } //Хранятся данные seo для слоя которого сейчас нет.. и нет значит и link $linktpl = $seo[$i]['link']; $data = infra_loadJSON('infra/data/seo/' . $i . '.json'); if (!isset($data['items'])) { continue; } //items обязателен foreach ($data['items'] as $n => $item) { $link = infra_template_parse(array($linktpl), $item['data']); $item['user'] = true; $item['link'] = $link; if (isset($items_cache[$i][$link])) { foreach ($item as $k => $v) { $items_cache[$i][$link][$k] = $v; } } else { $items_cache[$i][$link] = $item; } } } $list = array(); foreach ($items_cache as $k => $v) { $r = array('json' => @$seo[$k]['json'], 'tpl' => @$seo[$k]['tpl'], 'name' => $k, 'defitems' => @$seo[$k]['defitems'], 'link' => $seo[$k]['link'], 'schema' => $seo[$k]['schema'], 'items' => array_values($v)); foreach ($r['items'] as $item) { if (isset($item['user'])) { if ($item['user']) { $r['user'] = true; break; } } } $list[] = $r; if ($k == $name) { return $r; } } if ($name) { return array('name' => $name); } return $list; }, array($name)); if ($name) { $seos = array($list); } else { $seos = $list; } return $seos; }
public static function getPos(&$pos) { $args = array($pos['producer'], $pos['article']); return infra_admin_cache('getPos', function () use($pos) { Xlsx::addFiles($pos); $files = explode(',', @$pos['Файлы']); foreach ($files as $f) { if (!$f) { continue; } $f = trim($f); $conf = infra_config(); Xlsx::addFiles($pos, $conf['catalog']['dir'] . $f); } $files = array(); foreach ($pos['files'] as $f) { if (is_string($f)) { $f = infra_theme($f); //убрали звездочку $d = infra_srcinfo(infra_toutf($f)); } else { $d = $f; $f = $d['src']; } $d['size'] = round(filesize(infra_tofs($f)) / 1000000, 2); if (!$d['size']) { $d['size'] = '0.01'; } $files[] = $d; } $pos['files'] = $files; if ($pos['texts']) { foreach ($pos['texts'] as $k => $t) { $pos['texts'][$k] = infra_loadTEXT('*files/get.php?' . $t); } } return $pos; }, $args); }