本文整理汇总了PHP中CSite类的典型用法代码示例。如果您正苦于以下问题:PHP CSite类的具体用法?PHP CSite怎么用?PHP CSite使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CSite类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: InstallFiles
function InstallFiles()
{
CopyDirFiles($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/mobile/public/mobile/", $_SERVER["DOCUMENT_ROOT"] . "/mobile/", True, True);
CopyDirFiles($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/mobile/install/templates/", $_SERVER["DOCUMENT_ROOT"] . "/bitrix/templates/", True, True);
CopyDirFiles($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/mobile/install/components/", $_SERVER["DOCUMENT_ROOT"] . "/bitrix/components", true, true);
$default_site_id = CSite::GetDefSite();
if ($default_site_id) {
$arAppTempalate = array("SORT" => 1, "CONDITION" => "CSite::InDir('/mobile/')", "TEMPLATE" => "mobile_app");
$arFields = array("TEMPLATE" => array());
$dbTemplates = CSite::GetTemplateList($default_site_id);
$mobileAppFound = false;
while ($template = $dbTemplates->Fetch()) {
if ($template["TEMPLATE"] == "mobile_app") {
$mobileAppFound = true;
$template = $arAppTempalate;
}
$arFields["TEMPLATE"][] = array("TEMPLATE" => $template['TEMPLATE'], "SORT" => $template['SORT'], "CONDITION" => $template['CONDITION']);
}
if (!$mobileAppFound) {
$arFields["TEMPLATE"][] = $arAppTempalate;
}
$obSite = new CSite();
$arFields["LID"] = $default_site_id;
$obSite->Update($default_site_id, $arFields);
}
CUrlRewriter::ReindexFile("/mobile/webdav/index.php");
CUrlRewriter::ReindexFile("/mobile/disk/index.php");
CUrlRewriter::Add(array("CONDITION" => "#^/mobile/disk/(?<hash>[0-9]+)/download#", "RULE" => "download=1&objectId=\$1", "ID" => "bitrix:mobile.disk.file.detail", "PATH" => "/mobile/disk/index.php"));
return true;
}
示例2: InstallFiles
function InstallFiles($site_dir = "/", $default_site_id = false)
{
CopyDirFiles($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/eshopapp/install/components", $_SERVER["DOCUMENT_ROOT"] . "/bitrix/components", true, true);
CopyDirFiles($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/eshopapp/install/templates/", $_SERVER["DOCUMENT_ROOT"] . "/bitrix/templates/", true, true);
if (!$default_site_id) {
$default_site_id = CSite::GetDefSite();
}
if ($default_site_id) {
$arAppTempalate = array("SORT" => 1, "CONDITION" => "CSite::InDir('" . $site_dir . "eshop_app/')", "TEMPLATE" => "eshop_app");
$arFields = array("TEMPLATE" => array());
$dbTemplates = CSite::GetTemplateList($default_site_id);
$eshopAppFound = false;
while ($template = $dbTemplates->Fetch()) {
if ($template["TEMPLATE"] == "eshop_app") {
$eshopAppFound = true;
$template = $arAppTempalate;
}
$arFields["TEMPLATE"][] = array("TEMPLATE" => $template['TEMPLATE'], "SORT" => $template['SORT'], "CONDITION" => $template['CONDITION']);
}
if (!$eshopAppFound) {
$arFields["TEMPLATE"][] = $arAppTempalate;
}
$obSite = new CSite();
$arFields["LID"] = $default_site_id;
$obSite->Update($default_site_id, $arFields);
}
return true;
}
示例3: ShowPanel
function ShowPanel()
{
global $USER, $APPLICATION;
if (defined("ADMIN_SECTION") && ADMIN_SECTION == true) {
return;
}
if ($USER->IsAdmin()) {
if ($_REQUEST['add_new_site_sol'] == 'sol' && check_bitrix_sessid()) {
$dbrSites = CSite::GetList($by, $ord);
$arSitesID = array();
$arSitesPath = array();
$siteCnt = 0;
while ($arSite = $dbrSites->Fetch()) {
if ($arSite["ACTIVE"] == "Y") {
$siteCnt++;
}
$arSitesID[] = strtolower($arSite["ID"]);
$arSitesPath[] = strtolower($arSite["PATH"]);
}
$newSiteID = "";
while (true) {
$newSiteID = chr(rand(ord("a"), ord("z"))) . chr(rand(ord("a"), ord("z")));
if (!in_array($newSiteID, $arSitesID) && !in_array("/site" . $newSiteID . "/", $arSitesPath) && !file_exists($_SERVER['DOCUMENT_ROOT'] . "/site" . $newSiteID)) {
break;
}
}
$culture = CultureTable::getRow(array('filter' => array("=FORMAT_DATE" => FORMAT_DATE, "=FORMAT_DATETIME" => FORMAT_DATETIME, "=FORMAT_NAME" => CSite::GetDefaultNameFormat(), "=CHARSET" => SITE_CHARSET)));
if ($culture) {
$cultureId = $culture["ID"];
} else {
$addResult = CultureTable::add(array("NAME" => $newSiteID, "CODE" => $newSiteID, "FORMAT_DATE" => FORMAT_DATE, "FORMAT_DATETIME" => FORMAT_DATETIME, "FORMAT_NAME" => CSite::GetDefaultNameFormat(), "CHARSET" => SITE_CHARSET));
$cultureId = $addResult->getId();
}
$arFields = array("LID" => $newSiteID, "ACTIVE" => "Y", "SORT" => 100, "DEF" => "N", "NAME" => $newSiteID, "DIR" => "/site_" . $newSiteID . "/", "SITE_NAME" => $newSiteID, "SERVER_NAME" => $_SERVER["SERVER_NAME"], "EMAIL" => COption::GetOptionString("main", "email_from"), "LANGUAGE_ID" => LANGUAGE_ID, "DOC_ROOT" => "", "CULTURE_ID" => $cultureId);
$obSite = new CSite();
$result = $obSite->Add($arFields);
if ($result) {
LocalRedirect("/bitrix/admin/wizard_install.php?lang=" . LANGUAGE_ID . "&wizardName=bitrix:portal&wizardSiteID=" . $newSiteID . "&" . bitrix_sessid_get());
} else {
echo $obSite->LAST_ERROR;
}
}
$arMenu = array(array("ACTION" => "jsUtils.Redirect([], '" . CUtil::JSEscape(SITE_DIR) . "?add_new_site_sol=sol&" . bitrix_sessid_get() . "')", "TEXT" => "<b>" . GetMessage("SOL_BUTTON_TEST_TEXT", array("#BR#" => " ")) . "</b>", "TITLE" => GetMessage("SOL_BUTTON_TEST_TITLE")));
$arSites = array();
$dbrSites = CSite::GetList($by, $ord, array("ACTIVE" => "Y"));
while ($arSite = $dbrSites->GetNext()) {
$arSites[] = array("ACTION" => "jsUtils.Redirect([], '" . CUtil::JSEscape($arSite["DIR"]) . "');", "ICON" => $arSite["LID"] == SITE_ID ? "checked" : "", "TEXT" => $arSite["NAME"], "TITLE" => GetMessage("SOL_BUTTON_GOTOSITE") . " " . $arSite["NAME"]);
}
$arMenu[] = array("SEPARATOR" => true);
$arMenu[] = array("TEXT" => GetMessage("SOL_BUTTON_GOTOSITE"), "MENU" => $arSites);
$APPLICATION->AddPanelButton(array("HREF" => SITE_DIR . "?add_new_site_sol=sol&" . bitrix_sessid_get(), "ID" => "solutions_wizard", "ICON" => "bx-panel-install-solution-icon", "TYPE" => "BIG", "ALT" => GetMessage("SOL_BUTTON_TEST_TITLE"), "TEXT" => GetMessage("SOL_BUTTON_TEST_TEXT"), "MAIN_SORT" => 2520, "SORT" => 20, "MENU" => $arMenu, 'HINT' => array('TITLE' => str_replace('#BR#', ' ', GetMessage("SOL_BUTTON_TEST_TEXT")), 'TEXT' => GetMessage('SOL_BUTTON_TEST_TEXT_HINT')), 'HINT_MENU' => array('TITLE' => str_replace('#BR#', ' ', GetMessage("SOL_BUTTON_TEST_TEXT")), 'TEXT' => GetMessage('SOL_BUTTON_TEST_MENU_HINT'))));
}
}
示例4: Delete
/**
* Delete
* @param $ID
* @return mixed
* @throws \Exception
*/
public static function Delete($ID)
{
$obSite = new \CSite();
$dbSite = $obSite->GetList($by = "sort", $order = "desc", array('ID' => $ID));
if ($arSite = $dbSite->Fetch()) {
$res = $obSite->Delete($ID);
if ($res) {
return $ID;
} else {
throw new BimException($obSite->LAST_ERROR);
}
}
}
示例5: getDefaultSiteID
private static function getDefaultSiteID()
{
if (self::$defaultSiteID !== null) {
return self::$defaultSiteID;
}
$siteEntity = new \CSite();
$dbSites = $siteEntity->GetList($by = 'sort', $order = 'desc', array('DEFAULT' => 'Y', 'ACTIVE' => 'Y'));
$defaultSite = is_object($dbSites) ? $dbSites->Fetch() : null;
if (is_array($defaultSite)) {
return self::$defaultSiteID = $defaultSite['LID'];
}
return self::$defaultSiteID = 's1';
}
示例6: getNearestEntities
public static function getNearestEntities($entityID, $currentDate, $startDate = '', $responsibleID = 0, $intervalInDays = 7, $checkPermissions = true, $limit = 5)
{
if (!is_string($startDate) || $startDate === '') {
$startDate = $currentDate;
}
$site = new \CSite();
$dateFormat = $site->GetDateFormat('SHORT');
$curretTime = $currentDate !== '' ? MakeTimeStamp($currentDate, $dateFormat) : false;
$startTime = $startDate !== '' ? MakeTimeStamp($startDate, $dateFormat) : false;
if ($startTime === false) {
return array();
}
$dt = new \DateTime();
$dt->setTimestamp($startTime);
$dt->add(new \DateInterval("P{$intervalInDays}D"));
$endTime = $dt->getTimeStamp();
$currentSorting = self::internalPrepareSorting($curretTime);
$startSorting = self::internalPrepareSorting($startTime);
$endSorting = self::internalPrepareSorting($endTime);
$result = array();
if ($entityID === \CCrmOwnerType::Lead) {
$filter = array('>=BIRTHDAY_SORT' => $startSorting, '<=BIRTHDAY_SORT' => $endSorting, 'CHECK_PERMISSIONS' => $checkPermissions ? 'Y' : 'N');
if ($responsibleID > 0) {
$filter['=ASSIGNED_BY_ID'] = $responsibleID;
}
$dbResult = \CCrmLead::GetListEx(array(), $filter, false, array('nTopCount' => $limit), array('ID', 'BIRTHDATE', 'BIRTHDAY_SORT', 'HONORIFIC', 'NAME', 'SECOND_NAME', 'LAST_NAME'));
while ($fields = $dbResult->Fetch()) {
$fields['ENTITY_TYPE_ID'] = \CCrmOwnerType::Lead;
$fields['IMAGE_ID'] = 0;
$sorting = isset($fields['BIRTHDAY_SORT']) ? (int) $fields['BIRTHDAY_SORT'] : 512;
$fields['IS_BIRTHDAY'] = $sorting === $currentSorting;
$result[] = $fields;
}
} elseif ($entityID === \CCrmOwnerType::Contact) {
$filter = array('>=BIRTHDAY_SORT' => $startSorting, '<=BIRTHDAY_SORT' => $endSorting, 'CHECK_PERMISSIONS' => $checkPermissions ? 'Y' : 'N');
if ($responsibleID > 0) {
$filter['=ASSIGNED_BY_ID'] = $responsibleID;
}
$dbResult = \CCrmContact::GetListEx(array(), $filter, false, array('nTopCount' => $limit), array('ID', 'BIRTHDATE', 'BIRTHDAY_SORT', 'HONORIFIC', 'NAME', 'SECOND_NAME', 'LAST_NAME', 'PHOTO'));
while ($fields = $dbResult->Fetch()) {
$fields['ENTITY_TYPE_ID'] = \CCrmOwnerType::Contact;
$fields['IMAGE_ID'] = isset($fields['PHOTO']) ? (int) $fields['PHOTO'] : 0;
$sorting = isset($fields['BIRTHDAY_SORT']) ? (int) $fields['BIRTHDAY_SORT'] : 512;
$fields['IS_BIRTHDAY'] = $sorting === $currentSorting;
$result[] = $fields;
}
}
return $result;
}
示例7: getConfiguredDomains
public function getConfiguredDomains()
{
$result = array();
$converter = CBXPunycode::GetConverter();
$domainName = COption::GetOptionString("main", "server_name", "");
if ($domainName != "") {
$result[$domainName] = $domainName;
}
$by = "";
$order = "";
$siteList = CSite::GetList($by, $order, array("ACTIVE" => "Y"));
while ($site = $siteList->Fetch()) {
$domains = explode("\r\n", $site["DOMAINS"]);
foreach ($domains as $domainName) {
if ($domainName != "") {
$punyName = $converter->Encode($domainName);
if ($punyName !== false) {
$result[$punyName] = $domainName;
}
}
}
}
ksort($result);
return $result;
}
示例8: Add
public static function Add($settings)
{
global $DB, $USER;
$name = $settings['title'];
$description = $settings['description'];
$owner = $settings['owner'];
unset($settings['title']);
unset($settings['description']);
unset($settings['owner']);
$fields = array('TITLE' => $name, 'DESCRIPTION' => $description, 'OWNER_ID' => $owner, 'CREATED_DATE' => date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), time() + CTimeZone::GetOffset()), 'CREATED_BY' => $USER->GetID());
if (isset($settings['mark_default'])) {
$fields['MARK_DEFAULT'] = $settings['mark_default'];
unset($settings['mark_default']);
}
$fields['SETTINGS'] = serialize($settings);
// pre-events
foreach (GetModuleEvents("report", "OnBeforeReportAdd", true) as $arEvent) {
if (ExecuteModuleEventEx($arEvent, array(&$fields)) === false) {
return false;
}
}
// save data
$ID = $DB->Add("b_report", $fields, array("SETTINGS", "DESCRIPTION"), "report");
// clear view params
self::clearViewParams($ID);
// post-events
foreach (GetModuleEvents("report", "OnBeforeReportAdd", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array($ID, &$fields));
}
return $ID;
}
示例9: OrderBasket
/**
*
* return array() BasketList - experation - Send Order
**/
public static function OrderBasket($experation = NULL,$sort = array("ID" => "ASC"), $limit = NULL){
global $DB;
$arItems = array();
if(! $experation){
$experation = 30*24*60*60;
}
$time = date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL", SITE_ID)), time() - $experation);
$arPages = false;
if(! empty($limit)){
$arPages = array('nTopCount' => $limit);
}
$arFilter = array('>=DATE_UPDATE' => $time,
"ORDER_ID" => true,
"CAN_BUY" => "Y");
$arSelect = array("ID", "USER_ID", "PRODUCT_ID", "CAN_BUY", "DELAY", "SUBSCRIBE", "QUANTITY","DATE_UPDATE","DETAIL_PAGE_URL");
$dbBasketList = CSaleBasket::GetList(
$sort,
$arFilter,
false,
$arPages,
$arSelect
);
while($_arItems = $dbBasketList->Fetch()){
$arItems[] = $_arItems;
}
return $arItems;
}
示例10: init
function init()
{
$this->username = CSalePaySystemAction::GetParamValue("USER");
$this->pwd = CSalePaySystemAction::GetParamValue("PWD");
$this->signature = CSalePaySystemAction::GetParamValue("SIGNATURE");
$this->currency = CSalePaySystemAction::GetParamValue("CURRENCY");
$this->testMode = CSalePaySystemAction::GetParamValue("TEST") == "Y";
if ($this->testMode) {
$this->domain = "sandbox.";
}
if (strlen($_REQUEST["token"]) > 0) {
$this->token = $_REQUEST["token"];
}
if (strlen($_REQUEST["PayerID"]) > 0) {
$this->payerId = $_REQUEST["PayerID"];
}
$this->version = "98.0";
$dbSite = CSite::GetByID(SITE_ID);
$arSite = $dbSite->Fetch();
$this->serverName = $arSite["SERVER_NAME"];
if (strLen($this->serverName) <= 0) {
if (defined("SITE_SERVER_NAME") && strlen(SITE_SERVER_NAME) > 0) {
$this->serverName = SITE_SERVER_NAME;
} else {
$this->serverName = COption::GetOptionString("main", "server_name", "www.bitrixsoft.com");
}
}
$this->serverName = (CMain::IsHTTPS() ? "https" : "http") . "://" . $this->serverName;
if (strlen($this->username) <= 0 || strlen($this->username) <= 0 || strlen($this->username) <= 0) {
$GLOBALS["APPLICATION"]->ThrowException("CSalePaySystempaypal: init error", "CSalePaySystempaypal_init_error");
return false;
}
return true;
}
示例11: fetchSites
private function fetchSites()
{
if (!isset($this->sites)) {
$res = \CSite::GetList();
self::$sites = $res->arResult;
}
}
示例12: CheckFields
public static function CheckFields($ACTION, &$arFields, $ID = 0)
{
global $DB;
if ($ACTION != "ADD" && IntVal($ID) <= 0) {
$GLOBALS["APPLICATION"]->ThrowException("System error 870164", "ERROR");
return false;
}
if ((is_set($arFields, "SITE_ID") || $ACTION == "ADD") && (is_array($arFields["SITE_ID"]) && count($arFields["SITE_ID"]) <= 0 || !is_array($arFields["SITE_ID"]) && strlen($arFields["SITE_ID"]) <= 0)) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_GS_EMPTY_SITE_ID"), "EMPTY_SITE_ID");
return false;
} elseif (is_set($arFields, "SITE_ID")) {
if (!is_array($arFields["SITE_ID"])) {
$arFields["SITE_ID"] = array($arFields["SITE_ID"]);
}
foreach ($arFields["SITE_ID"] as $v) {
$dbResult = CSite::GetByID($v);
if (!$dbResult->Fetch()) {
$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $v, GetMessage("SONET_GS_ERROR_NO_SITE")), "ERROR_NO_SITE");
return false;
}
}
}
if ((is_set($arFields, "NAME") || $ACTION == "ADD") && strlen($arFields["NAME"]) <= 0) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_GS_EMPTY_NAME"), "EMPTY_NAME");
return false;
}
if (is_set($arFields, "SORT") || $ACTION == "ADD") {
$arFields["SORT"] = intVal($arFields["SORT"]) > 0 ? intVal($arFields["SORT"]) : 100;
}
return True;
}
示例13: Fetch
function Fetch()
{
static $arSite = array();
$r = parent::Fetch();
if ($r) {
$site_id = $r["SITE_ID"];
if (!isset($arSite[$site_id])) {
$rsSite = CSite::GetList($b, $o, array("ID" => $site_id));
$arSite[$site_id] = $rsSite->Fetch();
}
$r["DIR"] = $arSite[$site_id]["DIR"];
$r["SERVER_NAME"] = $arSite[$site_id]["SERVER_NAME"];
if (strlen($r["SITE_URL"]) > 0) {
$r["URL"] = $r["SITE_URL"];
}
if (substr($r["URL"], 0, 1) == "=") {
foreach (GetModuleEvents("search", "OnSearchGetURL", true) as $arEvent) {
$r["URL"] = ExecuteModuleEventEx($arEvent, array($r));
}
}
$r["URL"] = str_replace(array("#LANG#", "#SITE_DIR#", "#SERVER_NAME#"), array($r["DIR"], $r["DIR"], $r["SERVER_NAME"]), $r["URL"]);
$r["URL"] = preg_replace("'(?<!:)/+'s", "/", $r["URL"]);
unset($r["SITE_URL"]);
}
return $r;
}
示例14: GetFormatedUserName
public static function GetFormatedUserName($userId)
{
static $userCache = array();
$userId = IntVal($userId);
if($userId > 0)
{
if (!isset($userCache[$userId]) || !is_array($userCache[$userId]))
{
$dbUser = CUser::GetByID($userId);
if ($arUser = $dbUser->Fetch())
{
$userCache[$userId] = CUser::FormatName(
CSite::GetNameFormat(false),
array(
"NAME" => $arUser["NAME"],
"LAST_NAME" => $arUser["LAST_NAME"],
"SECOND_NAME" => $arUser["SECOND_NAME"],
"LOGIN" => $arUser["LOGIN"]
),
true
);
}
}
}
return $userCache[$userId];
}
示例15: DoInstall
function DoInstall()
{
global $APPLICATION, $USER, $step, $arSitesList;
if ($USER->IsAdmin()) {
$arSitesList = array();
$rsSites = CSite::GetList($by = "sort", $order = "desc", array());
while ($arSite = $rsSites->Fetch()) {
$arSitesList[$arSite['ID']] = $arSite['NAME'];
}
$step = IntVal($step);
if ($step < 2) {
$APPLICATION->IncludeAdminFile(GetMessage("CONTENT_INCLUDER_MODULE_INSTALL_TITLE") . $this->MODULE_ID, $this->sModuleInstallFullPath . "step1.php");
} elseif ($step == 2) {
RegisterModule($this->MODULE_ID);
RegisterModuleDependences("main", "OnEndBufferContent", $this->MODULE_ID, '\\Bit\\Includer\\Handlers', "OnEndBufferContentHandler");
RegisterModuleDependences("fileman", "OnIncludeHTMLEditorScript", $this->MODULE_ID, '\\Bit\\Includer\\Handlers', "OnIncludeHTMLEditorScriptHandler");
$this->InstallFiles();
$sSiteId = array_key_exists($_REQUEST['site_id'], $arSitesList) ? $_REQUEST['site_id'] : SITE_ID;
if ($_REQUEST['install_sample_iblock'] === "Y") {
$this->createSampleIblock($sSiteId);
}
if ($_REQUEST['disable_new_editor'] === "Y") {
COption::setOptionString("fileman", "use_editor_3", "");
}
COption::SetOptionString("bit.includer", "include_jquery", $_REQUEST['include_jquery_for_component'] === "Y" ? "Y" : "N");
$APPLICATION->IncludeAdminFile(GetMessage("CONTENT_INCLUDER_MODULE_INSTALL_TITLE"), $this->sModuleInstallFullPath . "step2.php");
}
}
}