Exemplo n.º 1
0
        ShowError(GetMessage('WIKI_SOCNET_INITIALIZING_FAILED'));
        return;
    }
}
if (!CWikiUtils::IsReadable()) {
    ShowError(GetMessage('WIKI_ACCESS_DENIED'));
    return;
}
if ($this->StartResultCache(false, array($USER->GetGroups(), $arNavigation, $arCache), false)) {
    $arParams['ELEMENT_NAME'] = urldecode($arParams['ELEMENT_NAME']);
    $arFilter = array('IBLOCK_ID' => $arParams['IBLOCK_ID'], 'CHECK_PERMISSIONS' => 'N', 'ACTIVE' => 'Y');
    if (empty($arParams['ELEMENT_NAME'])) {
        $arParams['ELEMENT_NAME'] = CWiki::GetDefaultPage($arParams['IBLOCK_ID']);
    }
    $arResult['ELEMENT'] = array();
    if (!empty($arParams['ELEMENT_NAME']) && ($arResult['ELEMENT'] = CWiki::GetElementByName($arParams['ELEMENT_NAME'], $arFilter)) != false) {
        $arParams['ELEMENT_ID'] = $arResult['ELEMENT']['ID'];
    }
    $CACHE_MANAGER->StartTagCache($this->GetCachePath());
    $CACHE_MANAGER->RegisterTag('wiki_' . $arParams['ELEMENT_ID']);
    $CACHE_MANAGER->EndTagCache();
    $SERVICE_NAME = '';
    if (CWikiUtils::IsCategoryPage($arParams['ELEMENT_NAME'], $SERVICE_NAME)) {
        $arParams['ELEMENT_NAME'] = strtolower(CWikiUtils::UnlocalizeCategoryName($arParams['ELEMENT_NAME']));
        $arResult['CUR_CAT']['NAME'] = $SERVICE_NAME;
        $arPagesFilter = array('IBLOCK_ID' => $arParams['IBLOCK_ID'], 'CHECK_PERMISSIONS' => 'N', 'ACTIVE' => 'Y');
        $arSort = array('XML_ID' => 'ASC');
        if ($arParams['ELEMENT_NAME'] == strtolower("category:" . GetMessage('WIKI_CATEGORY_ALL'))) {
            $arPagesFilter['INCLUDE_SUBSECTIONS'] = 'Y';
            if (CWikiSocnet::IsSocNet()) {
                $arPagesFilter['SECTION_ID'] = CWikiSocnet::$iCatId;
Exemplo n.º 2
0
            if ($arResult['WIKI_oper'] == 'add') {
                $bNotPage = false;
            }
        }
    }
} elseif ($arResult['WIKI_oper'] != 'delete') {
    $arResult['WIKI_oper'] = 'add';
}
CUtil::InitJSCore(array('window', 'ajax'));
if ((empty($arResult['ELEMENT']) || !$bNotPage) && $arResult['WIKI_oper'] != "delete" && $arResult['WIKI_oper'] != "rename" && $arResult['WIKI_oper'] != "rename_it") {
    if ($arResult['WIKI_oper'] == 'add') {
        // Check name
        if (!$bNotPage) {
            $i = 2;
            $strName = $arParams['ELEMENT_NAME'] . " ({$i})";
            while (CWiki::GetElementByName($strName, $arFilter) !== false) {
                $i++;
                $strName = $arParams['ELEMENT_NAME'] . " ({$i})";
            }
            $arParams['ELEMENT_NAME'] = $strName;
            $sPageName .= " ({$i})";
        }
        // Create a temporary item
        $sPageDecoded = CWikiUtils::htmlspecialcharsback(htmlspecialcharsbx($sPageName), false);
        $arFields = array('NAME' => CWikiUtils::htmlspecialcharsback($arParams['ELEMENT_NAME']), 'IBLOCK_ID' => $arParams['IBLOCK_ID'], 'IBLOCK_TYPE' => $arParams['IBLOCK_TYPE'], 'DETAIL_TEXT_TYPE' => $arResult['ALLOW_HTML'] == 'Y' ? 'html' : 'text', 'DETAIL_TEXT' => GetMessage('WIKI_DEFAULT_DETAIL_TEXT', array('%HEAD%' => $arResult['ALLOW_HTML'] == 'Y' ? '<h1>' . $sPageDecoded . '</h1>' : '= ' . $sPageDecoded . ' =', '%NEWLINE%' => $arResult['ALLOW_HTML'] == 'Y' ? '<br />' : "\n")), '~DETAIL_TEXT' => GetMessage('WIKI_DEFAULT_DETAIL_TEXT', array('%HEAD%' => $arResult['ALLOW_HTML'] == 'Y' ? '<h1>' . $sPageDecoded . '</h1>' : '= ' . $sPageDecoded . ' =', '%NEWLINE%' => $arResult['ALLOW_HTML'] == 'Y' ? '<br />' : "\n")), 'ACTIVE' => 'N', 'NAME_TEMPLATE' => $arParams['NAME_TEMPLATE']);
        $arParams['ELEMENT_ID'] = $CWiki->Add($arFields);
        $arResult['ELEMENT'] = $arFields;
        $arResult['ELEMENT']['ID'] = $arParams['ELEMENT_ID'];
        $sPageName = $arResult['ELEMENT']['NAME'];
        if (CWikiUtils::IsCategoryPage($sPageName, $sCatName)) {
            $sPageName = preg_replace('/^category:/i' . BX_UTF_PCRE_MODIFIER, GetMessage('CATEGORY_NAME') . ':', $sPageName);
Exemplo n.º 3
0
 $arParams['ELEMENT_NAME'] = urldecode($arParams['ELEMENT_NAME']);
 $arFilter = array('IBLOCK_ID' => $arParams['IBLOCK_ID'], 'CHECK_PERMISSIONS' => 'N', 'ACTIVE' => 'Y');
 $bNotPage = false;
 if (empty($arParams['ELEMENT_NAME'])) {
     $bNotPage = true;
     $arParams['ELEMENT_NAME'] = CWiki::GetDefaultPage($arParams['IBLOCK_ID']);
 }
 $sCatName = '';
 if (CWikiUtils::IsCategoryPage($arParams['ELEMENT_NAME'], $sCatName)) {
     $arResult['IS_CATEGORY'] = true;
     $arParams['ELEMENT_NAME'] = CWikiUtils::UnlocalizeCategoryName($arParams['ELEMENT_NAME']);
 } else {
     $arResult['IS_CATEGORY'] = false;
 }
 $arResult['ELEMENT'] = array();
 $arResult['ELEMENT'] = CWiki::GetElementByName($arParams['ELEMENT_NAME'], $arFilter, $arParams);
 if (!empty($arParams['ELEMENT_NAME']) && $arResult['ELEMENT'] != false) {
     //#REDIRECT [[target inner link]] - redirect from one page to another
     $matches = array();
     if (!$arResult['REDIRECTED_FROM'] && $arResult['REDIRECTED_FROM'] != 'no' && preg_match("/^\\#(REDIRECT|" . GetMessage('WIKI_REDIRECT') . ")\\s*\\[\\[(.+)\\]\\]/iU" . BX_UTF_PCRE_MODIFIER, $arResult['ELEMENT']['DETAIL_TEXT'], $matches)) {
         if ($matches[2]) {
             LocalRedirect(CHTTP::urlAddParams(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_POST'], array('wiki_name' => urlencode($matches[2]), 'group_id' => CWikiSocnet::$iSocNetId)), array('redirect' => urlencode($arParams['ELEMENT_NAME']))));
         }
     }
     $arParams['ELEMENT_ID'] = $arResult['ELEMENT']['ID'];
 } else {
     if ($bNotPage || empty($arParams['ELEMENT_NAME'])) {
         $arResult['ELEMENT']['NAME'] = !empty($arParams['ELEMENT_NAME']) ? $arParams['ELEMENT_NAME'] : GetMessage('WIKI_DEFAULT_PAGE_NAME');
         $arParams['ELEMENT_NAME'] = $arResult['ELEMENT']['NAME'];
         $arResult['ELEMENT']['~DETAIL_TEXT'] = GetMessage('WIKI_DEFAULT_PAGE_TEXT', array('%NAME%' => CWikiUtils::htmlspecialcharsback($arResult['ELEMENT']['NAME'], false)));
         CWiki::SetDefaultPage($arParams['IBLOCK_ID'], $arResult['ELEMENT']['NAME']);