/** * @return string */ public function getEditAreaId() { $this->uniqCounter++; $code = $this->infoblock()->getMnemocode(); $id = $this->id(); $this->editAreaId = "bx_tao_entity_{$code}_{$id}_{$this->uniqCounter}"; if (!empty($id)) { $buttons = \CIBlock::GetPanelButtons($this->infoblock()->getId(), $id, 0, array("SECTION_BUTTONS" => false, "SESSID" => false)); $editUrl = $buttons["edit"]["edit_element"]["ACTION_URL"]; $deleteUrl = $buttons["edit"]["delete_element"]["ACTION_URL"] . '&' . bitrix_sessid_get(); $messages = $this->infoblock()->messages(); $editTitle = isset($messages['ELEMENT_EDIT']) ? $messages['ELEMENT_EDIT'] : 'Редактировать'; $deleteTitle = isset($messages['ELEMENT_DELETE']) ? $messages['ELEMENT_DELETE'] : 'Удалить'; $editPopup = \TAO::app()->getPopupLink(array('URL' => $editUrl, "PARAMS" => array('width' => 780, 'height' => 500))); $btn = array('URL' => "javascript:{$editPopup}", 'TITLE' => $editTitle, 'ICON' => 'bx-context-toolbar-edit-icon'); \TAO::app()->SetEditArea($this->editAreaId, array($btn)); $btn = array('URL' => 'javascript:if(confirm(\'' . \CUtil::JSEscape("{$deleteTitle}?") . '\')) jsUtils.Redirect([], \'' . \CUtil::JSEscape($deleteUrl) . '\');', 'TITLE' => $deleteTitle, 'ICON' => 'bx-context-toolbar-delete-icon'); \TAO::app()->SetEditArea($this->editAreaId, array($btn)); } return $this->editAreaId; }
/** * @param $uri * @return bool|string */ public function routeStaticPage($uri) { if (preg_match('{^/(.+)/$}', $uri, $m)) { $file = $m[1]; $site = SITE_ID; $path = $this->staticPagePath(".{$site}/{$file}/index.phtml"); if (!$path) { $path = $this->staticPagePath(".{$site}/{$file}.phtml"); } if (!$path) { $path = $this->staticPagePath("{$file}/index.phtml"); } if (!$path) { $path = $this->staticPagePath("{$file}.phtml"); } if ($path) { ob_start(); $app = $APPLICATION = \TAO::app(); $bundle = $this; $r = (include $path); $content = ob_get_clean(); if ($content === '') { $content = ' '; } return $r === false ? false : $content; } } }
private function addCatalogSetProperties($productId, $products) { $parameters = array('TYPE' => CCatalogProductSet::TYPE_SET, 'SET_ID' => 0, 'ID' => $productId, 'ITEM_ID' => $productId, 'ITEMS' => array_map(function ($product) { /** @var Product $product */ return array('ACTIVE' => 'Y', 'ITEM_ID' => $product->id(), 'QUANTITY' => 1); }, $products)); if (!$this->sets->add($parameters)) { throw new \Exception('Cant create product set ' . \TAO::app()->getException()->GetString()); } return true; }
/** * @param array $args * @return string */ public function render($args = array()) { if (is_string($args)) { $args = array('mode' => $args); } $mode = isset($args['mode']) ? $args['mode'] : (isset($args['page_mode']) ? $args['page_mode'] : 'section-page'); $path = $this->viewPath($mode); $args['section'] = $this; if (!isset($args['page_class'])) { $icode = $this->infoblock()->getMnemocode(); $id = $this->id(); $code = trim($this['CODE']); $args['page_class'] = "infoblock-section-page infoblock-{$icode}-section-page infoblock-{$icode}-section-{$code}-page infoblock-{$icode}-section-{$id}-page section-{$id}-page section-{$code}-page"; } $APPLICATION = \TAO::app(); ob_start(); include $path; $content = ob_get_clean(); return $content; }
public function js($name, $additional = false) { if ($file = $this->file('js', $name)) { \TAO::app()->AddHeadScript($file, $additional); } }
/** * @return string */ public function getEditAreaId() { $this->uniqCounter++; $code = $this->getMnemocode(); $this->editAreaId = "bx_tao_iblockj_{$code}_{$this->uniqCounter}"; $buttons = \CIBlock::GetPanelButtons($this->getId(), 0, 0, array("SECTION_BUTTONS" => false, "SESSID" => false)); $addUrl = $buttons["edit"]["add_element"]["ACTION_URL"]; $messages = $this->messages(); $addTitle = isset($messages['ELEMENT_ADD']) ? $messages['ELEMENT_ADD'] : 'Добавить'; $addPopup = \TAO::app()->getPopupLink(array('URL' => $addUrl, "PARAMS" => array('width' => 780, 'height' => 500))); $btn = array('URL' => "javascript:{$addPopup}", 'TITLE' => $addTitle, 'ICON' => 'bx-context-toolbar-add-icon'); \TAO::app()->SetEditArea($this->editAreaId, array($btn)); return $this->editAreaId; }