/** * @param $route * @return bool */ public static function dispatchSection($route) { $infoblock = \TAO::infoblock($route['section_of']); if (!$infoblock) { return false; } $by = false; $param = false; if (isset($route['code'])) { $by = 'CODE'; $param = $route['code']; } if (isset($route['id'])) { $by = 'ID'; $param = $route['id']; } if (isset($route['id_or_code'])) { $by = false; $param = $route['id_or_code']; } if (!$param) { return false; } $section = $infoblock->getSection($param, $by); if (!$section) { return false; } $section->preparePage($route); return $section->render($route); }
<?php if ($_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest') { die('This page is for XMLHttpRequest only!'); } require_once $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_before.php'; $args = $_GET; $infoblock = false; if (isset($args['infoblock'])) { $code = htmlspecialcharsbx(trim($args['infoblock'])); if (!\TAO::getOption("infoblock.{$code}.elements.ajax")) { die('Access denied!'); } if (!empty($code)) { $infoblock = \TAO::infoblock($code); } } if (empty($infoblock)) { print "Infoblock {$code} not found!"; } else { $innerMode = 'ajax-inner'; if (isset($args['list_mode_inner'])) { $innerMode = trim($args['list_mode_inner']); } $args['list_mode'] = $innerMode; print $infoblock->render($args); }
/** * Navigation constructor. * @param bool|false $data */ public function __construct($data = false) { static $counter = 0; $counter++; if ($data === 'route') { $this->defaultTemplate = 'route'; $this->isRoute = true; return; } if (!$data) { $data = 'navigation'; } if (is_string($data)) { return $this->initRoot($data); } if (is_array($data)) { if (!isset($data['id'])) { $data['id'] = 'default' . $counter; } if (isset($data['url']) && isset($data['title'])) { $this->id = $data['id']; $this->url = $data['url']; $this->title = $data['title']; $this->parent = $data['parent']; $this->level = $this->parent->level + 1; if (isset($data['flag'])) { $this->flag = $data['flag']; unset($data['flag']); } if (isset($data['match'])) { $this->match = $data['match']; unset($data['match']); } if (isset($data['selected'])) { $this->selected = $data['selected']; unset($data['selected']); } unset($data['id']); unset($data['url']); unset($data['title']); unset($data['parent']); self::$byIds[$this->id] = $this; if (isset($data['sub'])) { $sub = $data['sub']; if (\TAO::isIterable($sub)) { $this->addArray($sub); } elseif (is_string($sub)) { if (preg_match('{^(infoblock|bundle|sections):(.+)$}', $sub, $m)) { $object = $m[1]; $code = trim($m[2]); $method = 'navigationTree'; if (preg_match('{^(.+):(.+)$}', $code, $m)) { $code = trim($m[1]); $method = trim($m[2]); } if ($object == 'sections') { $object = 'infoblock'; $method = 'navigationTreeSections'; } if ($object == 'infoblock') { $this->addArray(\TAO::infoblock($code)->{$method}($this, $data)); } elseif ($object == 'bundle') { $this->addArray(\TAO::bundle($code)->{$method}($this, $data)); } } } elseif (is_callable($sub)) { $this->addArray(call_user_func($sub, $this, $data)); } unset($data['sub']); } $this->data = $data; return; } } print 'Invalid navigation node<hr>'; var_dump($data); die; }
/** * @return mixed|null */ public function infoblock() { if (!$this->infoblock) { $this->infoblock = \TAO::infoblock($this['IBLOCK_ID']); } return $this->infoblock; }
/** * @param $code * @param array $args * @return $this */ public function addInfoblockElements($code, $args = array()) { \TAO::infoblock($code)->sitemapElements($this, $args); return $this; }
/** * */ public static function cliRebuildUrls() { foreach (\TAO::getOptions() as $k => $v) { if (preg_match('{^infoblock\\.([a-z0-9_]+)\\.route_detail}', $k, $m)) { $code = $m[1]; if ($v) { print "Rebuild elements for {$code}..."; $c = \TAO::infoblock($code)->rebuildElementsUrls(); print "{$c}\n"; } } } }