コード例 #1
0
ファイル: import.php プロジェクト: Satariall/izurit
 protected function _MakeFields(&$arFields, $itemType = null)
 {
     $arRes = array();
     $upload_dir = COption::GetOptionString("main", "upload_dir", "upload");
     $arStopList = array();
     foreach ($arFields["#"] as $field => $arValue) {
         if (in_array($field, $arStopList)) {
             continue;
         }
         if (in_array($field, $this->arUnsetFields) && $itemType !== 'TMK' && $itemType !== 'QUE') {
             if (!($itemType === 'TES' && in_array($field, $this->arPreventUnsetFieldsForTest))) {
                 continue;
             }
         }
         if (in_array($field, $this->arDraftFields) && $itemType !== 'TMK') {
             if (is_set($arValue[0]["#"], "cdata-section")) {
                 $arRes[strtoupper($field)] = preg_replace("~([\"'])(cid:resources/(.+?))(\\1)~is", "\\1/" . $upload_dir . "/learning/" . $this->COURSE_ID . "/\\3\\1", $arValue[0]["#"]["cdata-section"][0]["#"]);
                 continue;
             } elseif (isset($arValue[0]["#"])) {
                 $arRes[strtoupper($field)] = preg_replace("~([\"'])(cid:resources/(.+?))(\\1)~is", "\\1/" . $upload_dir . "/learning/" . $this->COURSE_ID . "/\\3\\1", $arValue[0]["#"]);
                 continue;
             }
         }
         if (in_array($field, $this->arDate) && strlen($arValue[0]["#"]) > 0) {
             $time = date("His", $arValue[0]["#"]);
             $arRes[strtoupper($field)] = ConvertTimeStamp($arValue[0]["#"], $time == "000000" ? "SHORT" : "FULL");
             continue;
         }
         if (in_array($field, $this->arPicture) && intval($arValue[0]["#"]) > 0) {
             $file = $this->package_dir . "/dbresources/" . $arValue[0]["#"];
             if (method_exists('CFile', 'GetImageSize')) {
                 $aImage = @CFile::GetImageSize($file);
                 if ($aImage === false) {
                     continue;
                 }
                 if (function_exists("image_type_to_mime_type")) {
                     $image_type_to_mime_type = image_type_to_mime_type($aImage[2]);
                 } else {
                     $image_type_to_mime_type = CCourseImport::ImageTypeToMimeType($aImage[2]);
                 }
             } else {
                 $image_type_to_mime_type = self::ImageTypeToMimeTypeByFileName($file);
             }
             $arRes[strtoupper($field)] = array("MODULE_ID" => "learning", "name" => $arValue[0]["#"], "tmp_name" => $file, "size" => @filesize($file), "type" => $image_type_to_mime_type);
             if (isset($arFields["#"][$field . '_description'][0]['#'])) {
                 $arRes[strtoupper($field)]['description'] = $arFields["#"][$field . '_description'][0]['#'];
                 $arStopList[] = $field . '_description';
             }
             continue;
         }
         $arRes[strtoupper($field)] = $arValue[0]["#"];
     }
     unset($arFields);
     return $arRes;
 }
コード例 #2
0
ファイル: index.php プロジェクト: Satariall/izurit
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
if (!CModule::IncludeModule('learning')) {
    return;
}
__IncludeLang(GetLangFileName(dirname(__FILE__) . "/lang/", "/" . basename(__FILE__)));
$dbResult = CCourse::GetList(array(), array("CODE" => "BX-ADM001"));
$pathToService = str_replace("\\", "/", dirname(__FILE__));
if (!($arCourse = $dbResult->Fetch())) {
    $pathToCourse = $serviceRelativePath . "/" . LANGUAGE_ID . "/course/";
    $package = new CCourseImport($pathToCourse, array("s1"));
    if (strlen($package->LAST_ERROR) > 0) {
        return;
    }
    $success = $package->ImportPackage();
    if ($success) {
        $dbResult = CCourse::GetList(array(), array("CODE" => "BX-ADM001"));
        $arCourse = $dbResult->Fetch();
    }
}
if (isset($arCourse["ID"])) {
    CCourse::SetPermission($arCourse["ID"], array("2" => "R"));
}
//Public files
CopyDirFiles($pathToService . "/" . LANGUAGE_ID . "/public", $_SERVER["DOCUMENT_ROOT"] . "/communication/learning", $rewrite = false, $recursive = true);
//Left menu
DemoSiteUtil::AddMenuItem("/communication/.left.menu.php", array(GetMessage("SERVICE_LEARNING"), "/communication/learning/", array(), array(), ""));
//Template
コード例 #3
0
ファイル: learn_import.php プロジェクト: DarneoStudio/bitrix
     }
 } else {
     $strError .= GetMessage("LEARNING_DATA_FILE_NOT_FOUND");
 }
 if (strlen($strError) <= 0) {
     $oArchiver = CBXArchive::GetArchive($_SERVER["DOCUMENT_ROOT"] . $URL_DATA_FILE);
     if ($oArchiver === false) {
         $strError .= GetMessage("LEARNING_NOT_TAR_GZ") . "<br>";
     }
 }
 if (strlen($strError) <= 0 && $oArchiver !== false) {
     $tmp_dir = BX_PERSONAL_ROOT . "/tmp/learning/" . uniqid(rand());
     CheckDirPath($_SERVER["DOCUMENT_ROOT"] . $tmp_dir);
     if ($oArchiver->Unpack($_SERVER["DOCUMENT_ROOT"] . $tmp_dir)) {
         if (!isset($SCORM)) {
             $package = new CCourseImport($tmp_dir, $SITE_ID);
             if (!strlen($package->LAST_ERROR)) {
                 if (!$package->ImportPackage()) {
                     $strError .= $package->LAST_ERROR;
                 }
             } else {
                 $strError .= $package->LAST_ERROR;
             }
         } else {
             $package = new CCourseSCORM($tmp_dir, $SITE_ID);
             if (!strlen($package->LAST_ERROR)) {
                 if (!$package->ImportPackage()) {
                     $strError .= $package->LAST_ERROR;
                 }
             } else {
                 $strError .= $package->LAST_ERROR;