本文整理汇总了PHP中CCalendar::Color方法的典型用法代码示例。如果您正苦于以下问题:PHP CCalendar::Color方法的具体用法?PHP CCalendar::Color怎么用?PHP CCalendar::Color使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCalendar
的用法示例。
在下文中一共展示了CCalendar::Color方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CheckFields
public static function CheckFields(&$arFields)
{
// Check dates
// $arFields['DT_FROM'] = CCalendar::CutZeroTime($arFields['DT_FROM']);
// $arFields['DT_TO'] = CCalendar::CutZeroTime($arFields['DT_TO']);
$fromTs = CCalendar::Timestamp($arFields['DT_FROM']);
$toTs = CCalendar::Timestamp($arFields['DT_TO']);
if (!isset($arFields['DT_FROM_TS'])) {
$arFields['DT_FROM_TS'] = $fromTs;
}
if (!isset($arFields['DT_TO_TS'])) {
$arFields['DT_TO_TS'] = $toTs;
}
$h24 = 60 * 60 * 24;
// 24 hours
// Skip time
if (isset($arFields['SKIP_TIME'])) {
$arFields['DT_SKIP_TIME'] = $arFields['SKIP_TIME'] ? 'Y' : 'N';
unset($arFields['SKIP_TIME']);
} elseif (isset($arFields['DT_SKIP_TIME']) && $arFields['DT_SKIP_TIME'] != 'Y' && $arFields['DT_SKIP_TIME'] != 'N') {
unset($arFields['DT_SKIP_TIME']);
}
// Event length in seconds
if (!isset($arFields['DT_LENGTH'])) {
//if($fromTs == $toTs && date('H:i', $fromTs) == '00:00') // One day
if ($fromTs == $toTs && date('H:i', $fromTs) == '00:00' && $arFields['DT_SKIP_TIME'] == 'Y') {
$arFields['DT_LENGTH'] = $h24;
} else {
$arFields['DT_LENGTH'] = intVal($toTs - $fromTs);
if ($arFields['DT_SKIP_TIME'] == "Y") {
// We have dates without times
$arFields['DT_LENGTH'] += $h24;
}
}
}
if (!$arFields['VERSION']) {
$arFields['VERSION'] = 1;
}
// Accessibility
$arFields['ACCESSIBILITY'] = trim(strtolower($arFields['ACCESSIBILITY']));
if (!in_array($arFields['ACCESSIBILITY'], array('busy', 'quest', 'free', 'absent'))) {
$arFields['ACCESSIBILITY'] = 'busy';
}
// Importance
$arFields['IMPORTANCE'] = trim(strtolower($arFields['IMPORTANCE']));
if (!in_array($arFields['IMPORTANCE'], array('high', 'normal', 'low'))) {
$arFields['IMPORTANCE'] = 'normal';
}
// Color
$arFields['COLOR'] = CCalendar::Color($arFields['COLOR'], false);
// Section
if (!is_array($arFields['SECTIONS']) && intVal($arFields['SECTIONS']) > 0) {
$arFields['SECTIONS'] = array(intVal($arFields['SECTIONS']));
}
// Check rrules
if (is_array($arFields['RRULE']) && isset($arFields['RRULE']['FREQ']) && in_array($arFields['RRULE']['FREQ'], array('HOURLY', 'DAILY', 'MONTHLY', 'YEARLY', 'WEEKLY'))) {
// Interval
if (isset($arFields['RRULE']['INTERVAL']) && intVal($arFields['RRULE']['INTERVAL']) > 1) {
$arFields['RRULE']['INTERVAL'] = intVal($arFields['RRULE']['INTERVAL']);
}
// Until date
if ($arFields['RRULE']['UNTIL']) {
if (!preg_match('/[^\\d]/', $arFields['RRULE']['UNTIL'])) {
$periodTs = $arFields['RRULE']['UNTIL'];
if ($periodTs > CCalendar::GetMaxTimestamp()) {
$periodTs = CCalendar::GetMaxTimestamp();
}
} else {
$periodTs = CCalendar::Timestamp($arFields['RRULE']['UNTIL']);
}
} else {
$periodTs = CCalendar::GetMaxTimestamp();
}
$arFields['RRULE']['UNTIL'] = $periodTs;
$arFields['DT_TO'] = CCalendar::Date($periodTs);
$arFields['DT_TO_TS'] = $periodTs;
if (isset($arFields['RRULE']['BYDAY'])) {
$BYDAY = array();
$days = array('SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA');
$bydays = explode(',', $arFields['RRULE']['BYDAY']);
foreach ($bydays as $day) {
$day = strtoupper($day);
if (in_array($day, $days)) {
$BYDAY[] = $day;
}
}
$arFields['RRULE']['BYDAY'] = implode(',', $BYDAY);
}
$arFields['RRULE'] = self::PackRRule($arFields['RRULE']);
} else {
$arFields['RRULE'] = '';
}
$arFields['EXRULE'] = "";
$arFields['RDATE'] = "";
$arFields['EXDATE'] = "";
// Location
if (!is_array($arFields['LOCATION'])) {
$arFields['LOCATION'] = array("NEW" => is_string($arFields['LOCATION']) ? $arFields['LOCATION'] : "");
}
// Private
//.........这里部分代码省略.........
示例2: SectionUpdate
public static function SectionUpdate($arParams = array(), $nav = null, $server = null)
{
$userId = CCalendar::GetCurUserId();
$methodName = "calendar.section.update";
if (isset($arParams['type'])) {
$type = $arParams['type'];
} else {
throw new Exception(GetMessage('CAL_REST_PARAM_EXCEPTION', array('#REST_METHOD#' => $methodName, '#PARAM_NAME#' => 'type')));
}
if (isset($arParams['ownerId'])) {
$ownerId = intval($arParams['ownerId']);
} elseif ($type == 'user') {
$ownerId = $userId;
} else {
throw new Exception(GetMessage('CAL_REST_PARAM_EXCEPTION', array('#REST_METHOD#' => $methodName, '#PARAM_NAME#' => 'ownerId')));
}
if (isset($arParams['id']) && intVal($arParams['id']) > 0) {
$id = intVal($arParams['id']);
} else {
throw new Exception(GetMessage('CAL_REST_SECT_ID_EXCEPTION'));
}
if (!CCalendar::IsPersonal($type, $ownerId, $userId) && !CCalendarSect::CanDo('calendar_edit_section', $id, $userId)) {
throw new Exception(GetMessage('CAL_REST_ACCESS_DENIED'));
}
$arFields = array('ID' => $id, 'CAL_TYPE' => $type, 'OWNER_ID' => $ownerId);
if (isset($arParams['name']) && trim($arParams['name']) != '') {
$arFields['NAME'] = trim($arParams['name']);
}
if (isset($arParams['description']) && trim($arParams['description']) != '') {
$arFields['DESCRIPTION'] = trim($arParams['description']);
}
if (isset($arParams['color'])) {
$arFields['COLOR'] = CCalendar::Color($arParams['color']);
}
if (isset($arParams['text_color'])) {
$arFields['TEXT_COLOR'] = CCalendar::Color($arParams['text_color']);
}
if (isset($arParams['access']) && is_array($arParams['access'])) {
$arFields['ACCESS'] = $arParams['access'];
}
$id = intVal(CCalendar::SaveSection(array('bAffectToDav' => false, 'arFields' => $arFields)));
if (!$id) {
throw new Exception(GetMessage('CAL_REST_SECTION_SAVE_ERROR'));
}
return $id;
}
示例3: CreateDefault
public static function CreateDefault($Params = array())
{
if ($Params['type'] == 'user' || $Params['type'] == 'group') {
$name = CCalendar::GetOwnerName($Params['type'], $Params['ownerId']);
} else {
$name = GetMessage('EC_DEF_SECT_GROUP_CAL');
}
// if ($Params['type'] == 'user')
// $name = GetMessage('EC_DEF_SECT_USER_CAL');
// else
// $name = GetMessage('EC_DEF_SECT_GROUP_CAL');
$arFields = array('CAL_TYPE' => $Params['type'], 'NAME' => $name, 'DESCRIPTION' => GetMessage('EC_DEF_SECT_DESC'), 'COLOR' => CCalendar::Color(), 'OWNER_ID' => $Params['ownerId'], 'IS_EXCHANGE' => 0, 'ACCESS' => CCalendarSect::GetDefaultAccess($Params['type'], $Params['ownerId']), 'PERM' => array('view_time' => true, 'view_title' => true, 'view_full' => true, 'add' => true, 'edit' => true, 'edit_section' => true, 'access' => true));
$arFields['ID'] = self::Edit(array('arFields' => $arFields));
if ($arFields['ID'] > 0) {
return $arFields;
}
return false;
}
示例4: CheckFields
//.........这里部分代码省略.........
$arFields['TZ_OFFSET_TO'] = CCalendar::GetTimezoneOffset($arFields['TZ_TO'], $toTs);
}
}
if (!isset($arFields['TZ_OFFSET_FROM'])) {
$arFields['TZ_OFFSET_FROM'] = 0;
}
if (!isset($arFields['TZ_OFFSET_TO'])) {
$arFields['TZ_OFFSET_TO'] = 0;
}
if (!isset($arFields['DATE_FROM_TS_UTC'])) {
$arFields['DATE_FROM_TS_UTC'] = $fromTs - $arFields['TZ_OFFSET_FROM'];
}
if (!isset($arFields['DATE_TO_TS_UTC'])) {
$arFields['DATE_TO_TS_UTC'] = $toTs - $arFields['TZ_OFFSET_TO'];
}
$h24 = 60 * 60 * 24;
// 24 hours
if ($arFields['DT_SKIP_TIME'] == 'Y') {
unset($arFields['TZ_FROM']);
unset($arFields['TZ_TO']);
unset($arFields['TZ_OFFSET_FROM']);
unset($arFields['TZ_OFFSET_TO']);
}
// Event length in seconds
if (!isset($arFields['DT_LENGTH']) || $arFields['DT_LENGTH'] == 0) {
if ($fromTs == $toTs && date('H:i', $fromTs) == '00:00' && $arFields['DT_SKIP_TIME'] == 'Y') {
$arFields['DT_LENGTH'] = $h24;
} else {
$arFields['DT_LENGTH'] = intVal($toTs - $fromTs);
if ($arFields['DT_SKIP_TIME'] == "Y") {
// We have dates without times
$arFields['DT_LENGTH'] += $h24;
}
}
}
if (!$arFields['VERSION']) {
$arFields['VERSION'] = 1;
}
// Accessibility
$arFields['ACCESSIBILITY'] = trim(strtolower($arFields['ACCESSIBILITY']));
if (!in_array($arFields['ACCESSIBILITY'], array('busy', 'quest', 'free', 'absent'))) {
$arFields['ACCESSIBILITY'] = 'busy';
}
// Importance
$arFields['IMPORTANCE'] = trim(strtolower($arFields['IMPORTANCE']));
if (!in_array($arFields['IMPORTANCE'], array('high', 'normal', 'low'))) {
$arFields['IMPORTANCE'] = 'normal';
}
// Color
$arFields['COLOR'] = CCalendar::Color($arFields['COLOR'], false);
// Section
if (!is_array($arFields['SECTIONS']) && intVal($arFields['SECTIONS']) > 0) {
$arFields['SECTIONS'] = array(intVal($arFields['SECTIONS']));
}
// Check rrules
if (is_array($arFields['RRULE']) && isset($arFields['RRULE']['FREQ']) && in_array($arFields['RRULE']['FREQ'], array('HOURLY', 'DAILY', 'MONTHLY', 'YEARLY', 'WEEKLY'))) {
// Interval
if (isset($arFields['RRULE']['INTERVAL']) && intVal($arFields['RRULE']['INTERVAL']) > 1) {
$arFields['RRULE']['INTERVAL'] = intVal($arFields['RRULE']['INTERVAL']);
}
// Until date
$periodTs = CCalendar::Timestamp($arFields['RRULE']['UNTIL'], false, false);
if (!$periodTs) {
$arFields['RRULE']['UNTIL'] = CCalendar::GetMaxDate();
$periodTs = CCalendar::Timestamp($arFields['RRULE']['UNTIL'], false, false);
}
$arFields['DATE_TO_TS_UTC'] = $periodTs;
$arFields['RRULE']['UNTIL'] = CCalendar::Date($periodTs, false);
if (isset($arFields['RRULE']['BYDAY'])) {
if (is_array($arFields['RRULE']['BYDAY'])) {
$BYDAY = $arFields['RRULE']['BYDAY'];
} else {
$BYDAY = array();
$days = array('SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA');
$bydays = explode(',', $arFields['RRULE']['BYDAY']);
foreach ($bydays as $day) {
$day = strtoupper($day);
if (in_array($day, $days)) {
$BYDAY[] = $day;
}
}
}
$arFields['RRULE']['BYDAY'] = implode(',', $BYDAY);
}
unset($arFields['RRULE']['~UNTIL']);
$arFields['RRULE'] = self::PackRRule($arFields['RRULE']);
} else {
$arFields['RRULE'] = '';
}
$arFields['EXRULE'] = "";
$arFields['RDATE'] = "";
$arFields['EXDATE'] = "";
// Location
if (!is_array($arFields['LOCATION'])) {
$arFields['LOCATION'] = array("NEW" => is_string($arFields['LOCATION']) ? $arFields['LOCATION'] : "");
}
// Private
$arFields['PRIVATE_EVENT'] = isset($arFields['PRIVATE_EVENT']) && $arFields['PRIVATE_EVENT'];
return true;
}