/** * @param $name * @param string $domain * @param bool|false $lang * @return string */ public static function t($name, $domain = 'messages', $lang = false) { if (!$lang) { $lang = \TAO::getCurrentLang(); } $key = "{$domain}.{$lang}"; if (!isset(self::$data[$key])) { self::$data[$key] = array(); $file = "lang/{$key}.php"; self::mergeLangData(self::$data[$key], \TAO::taoDir($file)); foreach (\TAO::bundles() as $bundle) { self::mergeLangData(self::$data[$key], $bundle->filePath($file)); } self::mergeLangData(self::$data[$key], \TAO::localDir($file)); } return isset(self::$data[$key][$name]) ? self::$data[$key][$name] : "[lang:{$domain}/{$lang}/{$name}]"; }
/** * @param $args * @param bool|false $name * @return bool|string */ public function templateForArgs($args, $name = false) { $tpl = isset($args['template']) ? $args['template'] : false; if (!$tpl || !is_file($tpl)) { $tpl = isset($args['mode']) ? $args['mode'] : false; } if (isset($args['view_name'])) { $name = $args['view_name']; } if (!$tpl || !is_file($tpl)) { if ($name) { $tpl = \TAO::localDir("views/{$name}.phtml"); } } if (!is_file($tpl)) { if ($name) { $tpl = \TAO::taoDir("views/{$name}.phtml"); } } return $tpl; }
/** * @param $id * @param bool|false $forCache * @return bool|string */ public static function run($id, $forCache = false) { $data = \CIBlock::GetByID($id)->Fetch(); if ($data) { $code = $data['CODE']; $name = $data['NAME']; $isactive = $data['ACTIVE'] == 'Y'; $sort = $data['SORT']; $description = (string) $data['DESCRIPTION']; $descriptionType = $data['DESCRIPTION_TYPE']; $className = $forCache ? \TAO::normalizeMnemocode($code) : \TAO::chunkCap($code); unset($data['ID']); unset($data['TIMESTAMP_X']); unset($data['IBLOCK_TYPE_ID']); unset($data['CODE']); unset($data['NAME']); unset($data['LANG_DIR']); unset($data['SERVER_NAME']); unset($data['LID']); unset($data['ACTIVE']); unset($data['SORT']); unset($data['DESCRIPTION']); unset($data['DESCRIPTION_TYPE']); $defs = array('RSS_ACTIVE' => 'Y', 'RSS_TTL' => '24', 'RSS_FILE_ACTIVE' => 'N', 'RSS_YANDEX_ACTIVE' => 'N', 'INDEX_ELEMENT' => 'Y', 'INDEX_SECTION' => 'N', 'WORKFLOW' => 'Y', 'VERSION' => '1', 'BIZPROC' => 'N', 'SECTION_CHOOSER' => 'L', 'RIGHTS_MODE' => 'S', 'SECTION_PROPERTY' => 'N', 'PROPERTY_INDEX' => 'N'); foreach (array_keys($data) as $k) { if (empty($data[$k])) { unset($data[$k]); } if (isset($defs[$k]) && $defs[$k] == $data[$k]) { unset($data[$k]); } } $sites = ''; $res = \CIBlock::GetSite($id); while ($row = $res->Fetch()) { $sites .= $sites != '' ? ',' : ''; $sites .= "'" . $row['SITE_ID'] . "'"; } unset($data['ELEMENTS_NAME']); unset($data['ELEMENT_NAME']); $sData = self::generateArrayExport($data, ' '); $sDescription = self::generateSimpleStringFunctionText('description', $description, ''); $sDescriptionType = self::generateSimpleStringFunctionText('descriptionType', $descriptionType, 'text'); $sIsActive = self::generateSimpleStringFunctionText('isActive', $isactive, true); $sSort = self::generateSimpleStringFunctionText('sort', $sort, '500'); $sSites = "\n\n public function sites()\n {\n return array({$sites});\n }"; $properties = array(); $result = \CIBlockProperty::GetList(array(), array('IBLOCK_ID' => $id, 'CHECK_PERMISSIONS' => 'N')); $defs = array('VERSION' => '1', 'FILTRABLE' => 'N', 'SEARCHABLE' => 'N', 'LIST_TYPE' => 'L', 'COL_COUNT' => '30', 'ROW_COUNT' => '1', 'MULTIPLE' => 'N', 'SORT' => '500', 'IS_REQUIRED' => 'N', 'WITH_DESCRIPTION' => 'N', 'MULTIPLE_CNT' => '5'); while ($row = $result->Fetch()) { $code = trim($row['CODE']); if ($code == '') { $code = 'PROP_' . $row['ID']; } $pid = $row['ID']; unset($row['ID']); unset($row['TIMESTAMP_X']); unset($row['IBLOCK_ID']); unset($row['ACTIVE']); unset($row['CODE']); foreach (array_keys($row) as $k) { if (empty($row[$k])) { unset($row[$k]); } if (isset($defs[$k]) && $defs[$k] == $row[$k]) { unset($row[$k]); } } if ($row['PROPERTY_TYPE'] == 'L') { $items = array(); $res = \CIBlockPropertyEnum::GetList(array(), array('PROPERTY_ID' => $pid, 'CHECK_PERMISSIONS' => 'N')); while ($lrow = $res->Fetch()) { $iid = $lrow['ID']; $eid = $lrow['EXTERNAL_ID']; unset($lrow['ID']); unset($lrow['EXTERNAL_ID']); unset($lrow['XML_ID']); unset($lrow['TMP_ID']); unset($lrow['PROPERTY_ID']); unset($lrow['PROPERTY_NAME']); unset($lrow['PROPERTY_CODE']); unset($lrow['PROPERTY_SORT']); if ($lrow['SORT'] == '500') { unset($lrow['SORT']); } if ($lrow['DEF'] == 'N') { unset($lrow['DEF']); } if (count($lrow) == 1 && isset($lrow['VALUE'])) { $lrow = $lrow['VALUE']; } $items[$eid] = $lrow; } $row['ITEMS'] = $items; } if (isset($row['LINK_IBLOCK_ID']) && !$forCache) { $row['LINK_IBLOCK_CODE'] = \TAO::getInfoblockCode($row['LINK_IBLOCK_ID']); unset($row['LINK_IBLOCK_ID']); } $properties[$code] = $row; } $sProperties = self::generateArrayExport($properties, ' '); $messages = \CIBlock::GetMessages($id); $sMessages = self::generateArrayExport($messages, ' '); $fields = self::trimArrayValues(\CIBlock::GetFields($id)); $defFields = self::defaultFields(); foreach (array_keys($fields) as $field) { if (isset($defFields[$field])) { $md5 = md5(serialize($fields[$field])); $def = md5(serialize($defFields[$field])); if ($md5 == $def) { //unset($fields[$field]); } else { //var_dump($fields[$field], $defFields[$field]); } } } $sFields = self::generateArrayExport($fields, ' '); $permissions = \CIBlock::GetGroupPermissions($id); $sPermissions = self::generateArrayExport($permissions, ' '); ob_start(); include \TAO::taoDir() . '/views/template-iblock.phtml'; $content = "<?php\n" . ob_get_clean(); return $content; } return false; }
/** * @param $file * @return string */ public function taoPath($file) { $file = trim($file, '/'); return \TAO::taoDir("bundles/{$this->name}/{$file}"); }
/** * @param string $mode * @return mixed */ public function viewPath($mode = 'teaser') { if (!isset($this->views[$mode])) { $path = $this->infoblock()->viewPath("{$mode}.phtml"); if (!$path) { $path = \TAO::taoDir("views/section-{$mode}.phtml"); if (!is_file($path)) { $path = \TAO::taoDir('views/section-teaser.phtml'); } } $this->views[$mode] = $path; } return $this->views[$mode]; }
/** * @param $file * @return bool|string */ public function viewPath($file) { return \TAO::filePath(array(\TAO::localDir("views/navigation"), \TAO::taoDir("views/navigation")), $file); }
/** * @param $dir * @return array */ protected function fileDirs($dir) { $dirs = array(); $sub = $this->subdir(); if ($this->bundle) { if ($sub) { $dirs[] = $this->bundle->localPath("{$dir}/forms/{$sub}"); } $dirs[] = $this->bundle->localPath("{$dir}/forms"); } if ($sub) { $dirs[] = \TAO::localDir("{$dir}/forms/{$sub}"); } $dirs[] = \TAO::localDir("{$dir}/forms"); $dirs[] = \TAO::taoDir("{$dir}/forms"); return $dirs; }
/** * @param $dir * @return array */ private function fileDirs($dir) { $dirs = array(); $sub = $this->subdir(); if ($this->bundle) { if ($sub) { $dirs[] = $this->bundle->localPath("{$dir}/shop/{$sub}"); } $dirs[] = $this->bundle->localPath("{$dir}/shop"); } if ($sub) { $dirs[] = \TAO::localDir("{$dir}/shop/{$sub}"); } $dirs[] = \TAO::localDir("{$dir}/shop"); $dirs[] = \TAO::taoDir("{$dir}/shop"); return $dirs; }
} } ?> <h2>Экспорт типа "<?php echo $name; ?> "</h2> Мнемокод: <b><?php echo $code; ?> </b>, файл: <b>local/schema/types/<?php echo $code; ?> .php</b><br> <?php $className = \TAO::chunkCap($code); ob_start(); include \TAO::taoDir() . '/views/template-type.phtml'; $content = "<?php\n" . ob_get_clean(); ?> <textarea wrap="off" style="width:90%; height: 400px; padding: 10px; border: 1px solid #888; background-color: white; font-family: monospace; font-size: 10px;"><?php echo str_replace('<', '<', $content); ?> </textarea> <?php include $_SERVER['DOCUMENT_ROOT'] . '/local/vendor/techart/bitrix.tao/include/epilog_admin.php'; ?>
/** * @param $sub * @return array */ public function dirs($sub) { $dirs = array(); if ($this->dir) { $dirs[] = "{$this->dir}/{$sub}"; } $dirs[] = \TAO::localDir($sub); $dirs[] = \TAO::taoDir($sub); return $dirs; }
/** * @param $sub * @return array */ public function dirs($sub) { $dirs = array(); $bundle = $this->bundle(); $code = $this->getMnemocodeForPaths(); if ($bundle) { $dirs[] = $bundle->localPath("{$sub}/{$code}"); $dirs[] = $bundle->taoPath("{$sub}/{$code}"); $dirs[] = $bundle->localPath($sub); $dirs[] = $bundle->taoPath($sub); } $dirs[] = \TAO::localDir("{$sub}/{$code}"); $dirs[] = \TAO::localDir($sub); $dirs[] = \TAO::taoDir($sub); return $dirs; }