Beispiel #1
0
 function Show($TYPE_SID, $HTML_BEFORE = "", $HTML_AFTER = "")
 {
     global $APPLICATION, $USER;
     $debug = null;
     if ($_SESSION["SESS_SHOW_INCLUDE_TIME_EXEC"] == "Y" && $USER->IsAdmin()) {
         $debug = new CDebugInfo();
         $debug->Start();
     }
     $arBanner = CAdvBanner::GetRandom($TYPE_SID);
     $strReturn = CAdvBanner::GetHTML($arBanner);
     if (strlen($strReturn) > 0) {
         CAdvBanner::FixShow($arBanner);
         if (($arIcons = CAdvBanner::GetEditIcons($arBanner, $TYPE_SID)) !== false) {
             $strReturn = $APPLICATION->IncludeString($strReturn, $arIcons);
         }
         $strReturn = $HTML_BEFORE . $strReturn . $HTML_AFTER;
         if ($debug) {
             $strReturn .= $debug->Output();
         }
         return $strReturn;
     }
     if ($debug) {
         echo $debug->Output();
     }
     return false;
 }
Beispiel #2
0
 /**
  * <p>Возвращает HTML представляющий из себя меню.</p>
  *
  *
  *
  *
  * @return string 
  *
  *
  * <h4>Example</h4> 
  * <pre>
  * &lt;?
  * $lm = new CMenu("left");
  * $lm-&gt;Init($APPLICATION-&gt;GetCurDir(), true);
  * $lm-&gt;template = "/bitrix/templates/demo/left.menu_template.php";
  * echo <b>$lm-&gt;GetMenuHtml</b>();
  * ?&gt;
  * </pre>
  *
  *
  *
  * <h4>See Also</h4> 
  * <ul> <li><a href="https://dev.1c-bitrix.ru/learning/course/index.php?COURSE_ID=43&amp;CHAPTER_ID=04708"
  * >Меню</a></li> <li> <a
  * href="http://dev.1c-bitrix.ru/api_help/main/reference/cmenu/getmenuhtmlex.php">CMenu::GetMenuHtmlEx</a> </li> <li> <a
  * href="http://dev.1c-bitrix.ru/api_help/main/reference/cmain/getmenuhtml.php">CMain::GetMenuHtml</a> </li> <li> <a
  * href="http://dev.1c-bitrix.ru/api_help/main/reference/cmain/getmenuhtmlex.php">CMain::GetMenuHtmlEx</a> </li> </ul></b<a
  * name="examples"></a>
  *
  *
  * @static
  * @link http://dev.1c-bitrix.ru/api_help/main/reference/cmenu/getmenuhtml.php
  * @author Bitrix
  */
 public function GetMenuHtml()
 {
     /**
      * @global CAllMain $APPLICATION
      * @noinspection PhpUnusedLocalVariableInspection
      */
     global $USER, $DB, $APPLICATION;
     // must be!
     if (!$this->RecalcMenu()) {
         return false;
     }
     // $arMENU - menu array copy
     // $arMENU_LINK - reference to menu array
     /** @noinspection PhpUnusedLocalVariableInspection */
     $arMENU_LINK = $MENU_ITEMS =& $this->arMenu;
     /** @noinspection PhpUnusedLocalVariableInspection */
     $arMENU = $this->arMenu;
     $result = "";
     $sMenuPrologTmp = "";
     $sMenuEpilog = "";
     $n = count($this->arMenu);
     for ($i = 0; $i < $n; $i++) {
         $m = $this->arMenu[$i];
         $sMenuBody = "";
         $sMenuProlog = "";
         $sMenuEpilog = "";
         $ITEM_INDEX = 0;
         extract($m, EXTR_OVERWRITE);
         // $TEXT - item text
         // $LINK - item link
         // $SELECTED - is item highlighed
         // $PERMISSION - linked page permission
         // $ADDITIONAL_LINKS - additional links for highlighting
         // $ITEM_TYPE - "D" - directory, "P" - page
         // $ITEM_INDEX - item number
         // $PARAMS - additional parameters
         include $this->MenuTemplate;
         if ($ITEM_INDEX == 0) {
             $sMenuPrologTmp = $sMenuProlog;
         }
         $result .= $sMenuBody;
     }
     $result = $sMenuPrologTmp . $result . $sMenuEpilog;
     $arIcons = array();
     $bShowButtons = false;
     $sMenuFile = $this->MenuDir . "." . $this->type . ".menu.php";
     if ($APPLICATION->GetShowIncludeAreas()) {
         $menu_perm = $APPLICATION->GetFileAccessPermission($sMenuFile);
         $templ_perm = $APPLICATION->GetFileAccessPermission($this->template);
         if ($menu_perm >= "W") {
             $arIcons[] = array("URL" => "/bitrix/admin/fileman_menu_edit.php?lang=" . LANGUAGE_ID . "&site=" . SITE_ID . "&back_url=" . urlencode($_SERVER["REQUEST_URI"]) . "&path=" . urlencode($this->MenuDir) . "&name=" . $this->type, "ICON" => "menu-edit", "TITLE" => GetMessage("MAIN_MENU_EDIT"));
         }
         if ($templ_perm >= "W" && $USER->IsAdmin()) {
             $arIcons[] = array("URL" => "/bitrix/admin/fileman_file_edit.php?lang=" . LANGUAGE_ID . "&site=" . SITE_ID . "&back_url=" . urlencode($_SERVER["REQUEST_URI"]) . "&full_src=Y&path=" . urlencode($this->template), "ICON" => "menu-template", "TITLE" => GetMessage("MAIN_MENU_TEMPLATE_EDIT"));
         }
         if (count($arIcons) > 0) {
             $result = $APPLICATION->IncludeStringBefore() . $result;
             $bShowButtons = true;
         }
     }
     if ($this->debug) {
         $result .= $this->debug->Output($sMenuFile, $sMenuFile);
     }
     if ($bShowButtons) {
         $result .= $APPLICATION->IncludeStringAfter($arIcons);
     }
     return $result;
 }
Beispiel #3
0
 function IncludeFile($rel_path, $arParams = array(), $arFunctionParams = array())
 {
     /** @global CMain $APPLICATION */
     /** @noinspection PhpUnusedLocalVariableInspection */
     global $APPLICATION, $USER, $DB, $MESS, $DOCUMENT_ROOT;
     if ($_SESSION["SESS_SHOW_INCLUDE_TIME_EXEC"] == "Y" && ($USER->CanDoOperation('edit_php') || $_SESSION["SHOW_SQL_STAT"] == "Y")) {
         $debug = new CDebugInfo();
         $debug->Start();
     } elseif ($APPLICATION->ShowIncludeStat) {
         $debug = new CDebugInfo();
         $debug->Start();
     } else {
         $debug = null;
     }
     $sType = "TEMPLATE";
     $bComponent = false;
     if (substr($rel_path, 0, 1) != "/") {
         $bComponent = true;
         $path = BX_PERSONAL_ROOT . "/templates/" . SITE_TEMPLATE_ID . "/" . $rel_path;
         if (!file_exists($_SERVER["DOCUMENT_ROOT"] . $path)) {
             $sType = "DEFAULT";
             $path = BX_PERSONAL_ROOT . "/templates/.default/" . $rel_path;
             if (!file_exists($_SERVER["DOCUMENT_ROOT"] . $path)) {
                 $path = BX_PERSONAL_ROOT . "/templates/" . SITE_TEMPLATE_ID . "/" . $rel_path;
                 $module_id = substr($rel_path, 0, strpos($rel_path, "/"));
                 if (strlen($module_id) > 0) {
                     $path = "/bitrix/modules/" . $module_id . "/install/templates/" . $rel_path;
                     $sType = "MODULE";
                     if (!file_exists($_SERVER["DOCUMENT_ROOT"] . $path)) {
                         $sType = "TEMPLATE";
                         $path = BX_PERSONAL_ROOT . "/templates/" . SITE_TEMPLATE_ID . "/" . $rel_path;
                     }
                 }
             }
         }
     } else {
         $path = $rel_path;
     }
     if ($arFunctionParams["WORKFLOW"] && !IsModuleInstalled("workflow")) {
         $arFunctionParams["WORKFLOW"] = false;
     } elseif ($sType != "TEMPLATE" && $arFunctionParams["WORKFLOW"]) {
         $arFunctionParams["WORKFLOW"] = false;
     }
     $bDrawIcons = $arFunctionParams["SHOW_BORDER"] !== false && $APPLICATION->GetShowIncludeAreas() && ($USER->CanDoFileOperation('fm_edit_existent_file', array(SITE_ID, $path)) || $arFunctionParams["WORKFLOW"] && $USER->CanDoFileOperation('fm_edit_in_workflow', array(SITE_ID, $path)));
     if ($bDrawIcons) {
         $path_url = "path=" . $path;
         $encSiteTemplateId = urlencode(SITE_TEMPLATE_ID);
         $editor = '';
         $resize = 'false';
         $iSrcLine = 0;
         $sSrcFile = '';
         if (!in_array($arFunctionParams['MODE'], array('html', 'text', 'php'))) {
             $arFunctionParams['MODE'] = $bComponent ? 'php' : 'html';
         }
         if ($sType != 'TEMPLATE') {
             switch ($arFunctionParams['MODE']) {
                 case 'html':
                     $editor = "/bitrix/admin/fileman_html_edit.php?site=" . SITE_ID . "&";
                     break;
                 case 'text':
                     $editor = "/bitrix/admin/fileman_file_edit.php?site=" . SITE_ID . "&";
                     break;
                 case 'php':
                     $editor = "/bitrix/admin/fileman_file_edit.php?full_src=Y&site=" . SITE_ID . "&";
                     break;
             }
             $editor .= "templateID=" . $encSiteTemplateId . "&";
         } else {
             switch ($arFunctionParams['MODE']) {
                 case 'html':
                     $editor = '/bitrix/admin/public_file_edit.php?bxpublic=Y&from=includefile&templateID=' . $encSiteTemplateId . '&';
                     $resize = 'false';
                     break;
                 case 'text':
                     $editor = '/bitrix/admin/public_file_edit.php?bxpublic=Y&from=includefile&noeditor=Y&';
                     $resize = 'true';
                     break;
                 case 'php':
                     $editor = '/bitrix/admin/public_file_edit_src.php?templateID=' . $encSiteTemplateId . '&';
                     $resize = 'true';
                     break;
             }
         }
         if ($arFunctionParams["TEMPLATE"]) {
             $arFunctionParams["TEMPLATE"] = "&template=" . urlencode($arFunctionParams["TEMPLATE"]);
         }
         if ($arFunctionParams["BACK_URL"]) {
             $arFunctionParams["BACK_URL"] = "&back_url=" . urlencode($arFunctionParams["BACK_URL"]);
         } else {
             $arFunctionParams["BACK_URL"] = "&back_url=" . urlencode($_SERVER["REQUEST_URI"]);
         }
         if ($arFunctionParams["LANG"]) {
             $arFunctionParams["LANG"] = "&lang=" . urlencode($arFunctionParams["LANG"]);
         } else {
             $arFunctionParams["LANG"] = "&lang=" . LANGUAGE_ID;
         }
         $arIcons = array();
         $arPanelParams = array();
         $bDefaultExists = false;
         if ($USER->CanDoOperation('edit_php') && $bComponent && function_exists("debug_backtrace")) {
             $bDefaultExists = true;
             $arPanelParams["TOOLTIP"] = array('TITLE' => GetMessage("main_incl_component1"), 'TEXT' => $rel_path);
             $aTrace = debug_backtrace();
             $sSrcFile = $aTrace[0]["file"];
             $iSrcLine = intval($aTrace[0]["line"]);
             $arIcons[] = array('URL' => 'javascript:' . $APPLICATION->GetPopupLink(array('URL' => "/bitrix/admin/component_props.php?" . "path=" . urlencode(CUtil::addslashes($rel_path)) . "&template_id=" . urlencode(CUtil::addslashes(SITE_TEMPLATE_ID)) . "&lang=" . LANGUAGE_ID . "&src_path=" . urlencode(CUtil::addslashes($sSrcFile)) . "&src_line=" . $iSrcLine . "")), 'ICON' => "parameters", 'TITLE' => GetMessage("main_incl_file_comp_param"), 'DEFAULT' => true);
         }
         if ($sType == "MODULE") {
             $arIcons[] = array('URL' => 'javascript:if(confirm(\'' . GetMessage("MAIN_INC_BLOCK_MODULE") . '\'))window.location=\'' . $editor . '&path=' . urlencode(BX_PERSONAL_ROOT . '/templates/' . SITE_TEMPLATE_ID . '/' . $rel_path) . $arFunctionParams["BACK_URL"] . $arFunctionParams["LANG"] . '&template=' . $path . '\';', 'ICON' => 'copy', 'TITLE' => str_replace("#MODE#", $arFunctionParams["MODE"], str_replace("#BLOCK_TYPE#", !is_set($arFunctionParams, "NAME") ? GetMessage("MAIN__INC_BLOCK") : $arFunctionParams["NAME"], GetMessage("main_incl_file_edit_copy"))));
         } elseif ($sType == "DEFAULT") {
             $arIcons[] = array('URL' => 'javascript:if(confirm(\'' . GetMessage("MAIN_INC_BLOCK_COMMON") . '\'))window.location=\'' . $editor . $path_url . $arFunctionParams["BACK_URL"] . $arFunctionParams["LANG"] . $arFunctionParams["TEMPLATE"] . '\';', 'ICON' => 'edit-common', 'TITLE' => str_replace("#MODE#", $arFunctionParams["MODE"], str_replace("#BLOCK_TYPE#", !is_set($arFunctionParams, "NAME") ? GetMessage("MAIN__INC_BLOCK") : $arFunctionParams["NAME"], GetMessage("MAIN_INC_BLOCK_EDIT"))));
             $arIcons[] = array('URL' => $editor . '&path=' . urlencode(BX_PERSONAL_ROOT . '/templates/' . SITE_TEMPLATE_ID . '/' . $rel_path) . $arFunctionParams["BACK_URL"] . $arFunctionParams["LANG"] . '&template=' . $path, 'ICON' => 'copy', 'TITLE' => str_replace("#MODE#", $arFunctionParams["MODE"], str_replace("#BLOCK_TYPE#", !is_set($arFunctionParams, "NAME") ? GetMessage("MAIN__INC_BLOCK") : $arFunctionParams["NAME"], GetMessage("MAIN_INC_BLOCK_COMMON_COPY"))));
         } else {
             $arPanelParams["TOOLTIP"] = array('TITLE' => GetMessage('main_incl_file'), 'TEXT' => $path);
             $arIcons[] = array('URL' => 'javascript:' . $APPLICATION->GetPopupLink(array('URL' => $editor . $path_url . $arFunctionParams["BACK_URL"] . $arFunctionParams["LANG"] . $arFunctionParams["TEMPLATE"], "PARAMS" => array('width' => 770, 'height' => 470, 'resize' => $resize))), 'ICON' => 'bx-context-toolbar-edit-icon', 'TITLE' => str_replace("#MODE#", $arFunctionParams["MODE"], str_replace("#BLOCK_TYPE#", !is_set($arFunctionParams, "NAME") ? GetMessage("MAIN__INC_BLOCK") : $arFunctionParams["NAME"], GetMessage("MAIN_INC_ED"))), 'DEFAULT' => !$bDefaultExists);
             if ($arFunctionParams["WORKFLOW"]) {
                 $arIcons[] = array('URL' => '/bitrix/admin/workflow_edit.php?' . $arFunctionParams["LANG"] . '&fname=' . urlencode($path) . $arFunctionParams["TEMPLATE"] . $arFunctionParams["BACK_URL"], 'ICON' => 'bx-context-toolbar-edit-icon', 'TITLE' => str_replace("#BLOCK_TYPE#", !is_set($arFunctionParams, "NAME") ? GetMessage("MAIN__INC_BLOCK") : $arFunctionParams["NAME"], GetMessage("MAIN_INC_ED_WF")));
             }
         }
         echo $this->IncludeStringBefore();
     }
     $res = null;
     if (is_file($_SERVER["DOCUMENT_ROOT"] . $path)) {
         if (is_array($arParams)) {
             extract($arParams, EXTR_SKIP);
         }
         $res = (include $_SERVER["DOCUMENT_ROOT"] . $path);
     }
     if ($_SESSION["SESS_SHOW_INCLUDE_TIME_EXEC"] == "Y" && ($USER->CanDoOperation('edit_php') || $_SESSION["SHOW_SQL_STAT"] == "Y")) {
         echo $debug->Output($rel_path, $path);
     } elseif (is_object($debug)) {
         $debug->Stop($rel_path, $path);
     }
     if ($bDrawIcons) {
         $comp_id = $path;
         if ($sSrcFile) {
             $comp_id .= '|' . $sSrcFile;
         }
         if ($iSrcLine) {
             $comp_id .= '|' . $iSrcLine;
         }
         $arPanelParams['COMPONENT_ID'] = md5($comp_id);
         echo $this->IncludeStringAfter($arIcons, $arPanelParams);
     }
     return $res;
 }