コード例 #1
0
ファイル: DaySet.php プロジェクト: devhelp/calendar
 /**
  * Checks if given day exists in the set
  * @param Day $day
  * @return boolean
  */
 public function has(Day $day)
 {
     if (isset($this->days[$day->getMonth()][$day->getDay()])) {
         return true;
     }
     return false;
 }
コード例 #2
0
ファイル: Day.php プロジェクト: tijsverkoyen/uitdatabank
 /**
  * Convert the raw XML into an object
  *
  * @param \SimpleXMLElement $xml
  * @return Phone
  */
 public static function createFromXML(\SimpleXMLElement $xml)
 {
     $day = new Day();
     $attributes = $xml->attributes();
     if (isset($attributes['opentype'])) {
         $day->setOpenType((string) $attributes['opentype']);
     }
     return $day;
 }
コード例 #3
0
 /**
  * Removes a day from the list of days, if added before
  * @param Day $day
  */
 function RemoveDay(Day $day)
 {
     $result = array();
     foreach ($this->days as $currentDay) {
         if ($currentDay->DayOfWeek != $day->DayOfWeek()) {
             $result[] = $currentDay;
         }
     }
     $this->days = $result;
 }
コード例 #4
0
ファイル: DayRange.php プロジェクト: devhelp/calendar
 /**
  * Orders days from earlier to later
  * @param Day $firstDay
  * @param Day $secondDay
  * @return array of Day objects sorted by date (ascending)
  */
 protected static function order(Day $firstDay, Day $secondDay)
 {
     if ($secondDay->isEarlierThan($firstDay)) {
         $earlierDay = $secondDay;
         $laterDay = $firstDay;
     } else {
         $earlierDay = $firstDay;
         $laterDay = $secondDay;
     }
     return array($earlierDay, $laterDay);
 }
コード例 #5
0
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Day::create([]);
     }
 }
コード例 #6
0
 public function loadModel($id)
 {
     if (($model = Day::model()->findByPk($id)) === null) {
         throw new CHttpException(404, 'Страница не найдена');
     }
     return $model;
 }
コード例 #7
0
ファイル: SetsTest.php プロジェクト: websublime/enum
 public function testSetsScheduleWeekend()
 {
     // Instead of starting out with an empty collection, EnumSet comes with a couple of convenient initialization methods
     // The of() static method will create a new collection and initialize it with the given enums
     $weekend = Websublime\Enum\EnumSet::of(Day::SATURDAY(), Day::SUNDAY());
     // Since we already have the weekend definition above, we can complement it, ending up with a collection of week days
     // This effectively generates a collection with all enums NOT present in the given set
     $weekdays = Websublime\Enum\EnumSet::complement($weekend);
     // An alternative way of generating the collection of week days is through a range using the range() static method
     $weekdays = Websublime\Enum\EnumSet::range(Day::MONDAY(), Day::FRIDAY());
     $weekdays = Websublime\Enum\EnumSet::range(Day::FRIDAY(), Day::MONDAY());
     // The order is insignificant
     // Lastly, it's possibly to fetch all enums by using the all() static method
     $all = Websublime\Enum\EnumSet::all('Day');
     // EnumSet too, supports binary flag/mask support
     $weekdays->getBinary();
     // Results in 31 (0x0000001F in hex or 00000000 00000000 00000000 00011111 in binary)
     // And alternatively, constructing an EnumSet using a binary mask
     $weekend = Websublime\Enum\EnumSet::byBinary('Day', 96);
     $this->assertInstanceOf('Websublime\\Enum\\EnumSet', $weekend);
     $this->assertInstanceOf('Websublime\\Enum\\EnumSet', $weekdays);
     $this->assertInstanceOf('Websublime\\Enum\\EnumSet', $all);
     // Iterating over a set
     foreach ($weekdays as $enum) {
         print 'Verbose testSetsScheduleWeekend: ' . $enum . PHP_EOL;
     }
 }
コード例 #8
0
ファイル: DayTest.php プロジェクト: jarnstedt/timetable
 /**
  * Test different day formats
  */
 public function testDayFormatting()
 {
     $mon = Day::monday()->format('l');
     $tue = Day::tuesday()->format('l');
     $fri = Day::friday()->format('l');
     $this->assertEquals('Monday', $mon);
     $this->assertEquals('Tuesday', $tue);
     $this->assertEquals('Friday', $fri);
 }
コード例 #9
0
 public function actionDarsJadvali()
 {
     $keys = array_keys($_GET);
     $group_id = (int) $keys[0];
     $days = Day::model()->findAll();
     $weeks = Day::forMegalka();
     $toq = $weeks[0];
     $juft = $weeks[1];
     $dgsts = [];
     foreach ($days as $day) {
         $dgsts[$day->id] = Dgst::model()->findAllByAttributes(['group_id' => $group_id, 'day_id' => $day->id]);
     }
     $this->renderPartial('_dars_jadvali', ['days' => $days, 'dgsts' => $dgsts, 'toq' => $toq, 'juft' => $juft]);
 }
コード例 #10
0
 public function build()
 {
     foreach ($this->xmlConfig->days->day as $configDay) {
         $day = new Day();
         $day->setDate(new \DateTime($configDay->date));
         $day->setTitle($configDay->title);
         $day->setDescription($configDay->description);
         $day->setLink($configDay->link);
         $this->calendar->addDay($day);
     }
 }
コード例 #11
0
 public function actionShow($alias)
 {
     if (Yii::app()->user->isAuthenticated() === false) {
         $this->controller->redirect(Yii::app()->user->loginUrl);
     }
     if (($user = Yii::app()->user->getProfile()) === null) {
         Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::ERROR_MESSAGE, Yii::t('UserModule.user', 'User not found.'));
         Yii::app()->user->logout();
         $this->controller->redirect((array) '/user/account/login');
     }
     $course = Course::model()->published()->find('t.alias = :alias', array(':alias' => $alias));
     if (!$course) {
         throw new CHttpException(404);
     }
     // ToDO
     // Пакет
     $package = Package::model()->findByPK(1);
     // День
     $dayId = Yii::app()->getRequest()->getParam('day', null);
     if ($dayId) {
         $day = Day::model()->published()->package($package->id)->findByPK((int) $dayId);
     } else {
         $day = Day::model()->published()->package($package->id)->find(array('order' => 't.number ASC'));
     }
     if (!$day) {
         throw new CHttpException(404);
     }
     // Страница
     $pageId = Yii::app()->getRequest()->getParam('page', null);
     if ($pageId) {
         $page = Page::model()->published()->day($day->id)->findByPK((int) $pageId);
     } else {
         $page = Page::model()->published()->day($day->id)->find(array('order' => 't.number ASC'));
     }
     if (!$page) {
         throw new CHttpException(404);
     }
     // Вывод в шаблон
     $this->render('show', array('course' => $course, 'package' => $package, 'day' => $day, 'page' => $page));
 }
コード例 #12
0
ファイル: Poi.php プロジェクト: BenCavens/bpost
 /**
  * Create a POI based on an XML-object
  *
  * @param  \SimpleXMLElement $xml
  * @return Poi
  */
 public static function createFromXML(\SimpleXMLElement $xml)
 {
     $poi = new Poi();
     if (isset($xml->Id) && $xml->Id != '') {
         $poi->setId((string) $xml->Id);
     }
     if (isset($xml->ID) && $xml->ID != '') {
         $poi->setId((string) $xml->ID);
     }
     if (isset($xml->Type) && $xml->Type != '') {
         $poi->setType((string) $xml->Type);
     }
     if (isset($xml->Name) && $xml->Name != '') {
         $poi->setOffice((string) $xml->Name);
     }
     if (isset($xml->OFFICE) && $xml->OFFICE != '') {
         $poi->setOffice((string) $xml->OFFICE);
     }
     if (isset($xml->Street) && $xml->Street != '') {
         $poi->setStreet((string) $xml->Street);
     }
     if (isset($xml->STREET) && $xml->STREET != '') {
         $poi->setStreet((string) $xml->STREET);
     }
     if (isset($xml->Number) && $xml->Number != '') {
         $poi->setNr((string) $xml->Number);
     }
     if (isset($xml->NR) && $xml->NR != '') {
         $poi->setNr((string) $xml->NR);
     }
     if (isset($xml->Zip) && $xml->Zip != '') {
         $poi->setZip((string) $xml->Zip);
     }
     if (isset($xml->ZIP) && $xml->ZIP != '') {
         $poi->setZip((string) $xml->ZIP);
     }
     if (isset($xml->City) && $xml->City != '') {
         $poi->setCity((string) $xml->City);
     }
     if (isset($xml->CITY) && $xml->CITY != '') {
         $poi->setCity((string) $xml->CITY);
     }
     if (isset($xml->X) && $xml->X != '') {
         $poi->setX((int) $xml->X);
     }
     if (isset($xml->Y) && $xml->Y != '') {
         $poi->setY((int) $xml->Y);
     }
     if (isset($xml->Longitude) && $xml->Longitude != '') {
         $poi->setLongitude((double) $xml->Longitude);
     }
     if (isset($xml->Latitude) && $xml->Latitude != '') {
         $poi->setLatitude((double) $xml->Latitude);
     }
     if (isset($xml->Services->Service)) {
         foreach ($xml->Services->Service as $service) {
             $poi->addService(Service::createFromXML($service));
         }
     }
     if (isset($xml->Hours->Monday)) {
         $poi->addHour(1, Day::createFromXML($xml->Hours->Monday));
     }
     if (isset($xml->Hours->Tuesday)) {
         $poi->addHour(2, Day::createFromXML($xml->Hours->Tuesday));
     }
     if (isset($xml->Hours->Wednesday)) {
         $poi->addHour(3, Day::createFromXML($xml->Hours->Wednesday));
     }
     if (isset($xml->Hours->Thursday)) {
         $poi->addHour(4, Day::createFromXML($xml->Hours->Thursday));
     }
     if (isset($xml->Hours->Friday)) {
         $poi->addHour(5, Day::createFromXML($xml->Hours->Friday));
     }
     if (isset($xml->Hours->Saturday)) {
         $poi->addHour(6, Day::createFromXML($xml->Hours->Saturday));
     }
     if (isset($xml->Hours->Sunday)) {
         $poi->addHour(7, Day::createFromXML($xml->Hours->Sunday));
     }
     if (isset($xml->ClosedFrom) && $xml->ClosedFrom != '') {
         $poi->setClosedFrom((string) $xml->ClosedFrom);
     }
     if (isset($xml->ClosedTo) && $xml->ClosedTo != '') {
         $poi->setClosedTo((string) $xml->ClosedTo);
     }
     if (isset($xml->NOTE) && $xml->NOTE != '') {
         $poi->setNote((string) $xml->NOTE);
     }
     return $poi;
 }
コード例 #13
0
 /**
  * 計算
  *
  * @return \Month
  */
 public function calc()
 {
     $day = 1;
     // 先月用
     $lastMonthLastDay = $this->lastMonthLastDay() - $this->firstDayWeekCode;
     // 来月開始日用
     $nextMonthDay = 1;
     $weekCnt = $this->haveWeeksCount();
     for ($i = 1; $i <= $weekCnt; $i++) {
         $week = new Week();
         for ($j = 0; $j < 7; $j++) {
             // 先月
             if ($i === 1 && $j < $this->firstDayWeekCode) {
                 $week->setDays(Day::forge($this->lastMonthFullDate($lastMonthLastDay + $j + 1), Day::LAST_MONTH)->calc());
                 continue;
             }
             // 当月
             if ($day <= $this->lastDay) {
                 $week->setDays(Day::forge($this->fullDate($day++))->calc());
                 continue;
             }
             // 来月
             $week->setDays(Day::forge($this->nextMonthFullDate($nextMonthDay++), Day::NEXT_MONTH)->calc());
         }
         $this->weeks[$i] = $week;
     }
     return $this;
 }
コード例 #14
0
ファイル: Day.php プロジェクト: devhelp/calendar
 /**
  * Returns Day that is after given offset (calculated for given year)
  * @param string $offset
  * @param integer $year
  * @return Day
  */
 public function modify($offset, $year)
 {
     $dt = $this->toDateTime($year);
     $dt->modify($offset);
     return Day::fromDateTime($dt);
 }
コード例 #15
0
ファイル: Week.php プロジェクト: alfechner/weekly-schedule
 public function addDay(Day $day)
 {
     $this->days[$day->getNumberInWeek()] = $day;
 }
コード例 #16
0
 public function storeMeeting()
 {
     $advisor = Auth::user();
     $day = Day::find(Input::get('day_id'));
     // If form validation passes:
     $meeting = new Meeting();
     $meeting->title = Input::get('title');
     if (Input::get('notes')) {
         $meeting->notes = Input::get('notes');
     }
     $meeting->save();
     $meeting->days()->save($day);
     $advisor->meetings()->save($meeting);
     return Redirect::attempt('advisor.dashboard');
 }
コード例 #17
0
ファイル: Day.php プロジェクト: kuzmina-mariya/happy-end
 public function duplicate($modify = array())
 {
     $clone = new Day();
     $clone->attributes = $this->attributes;
     $clone->id = null;
     foreach ($modify as $key => $value) {
         $clone->{$key} = $value;
     }
     if ($clone->save()) {
         // Сохраняем страницы
         $result = true;
         foreach ($this->pages as $page) {
             $result = $page->duplicate(array('day_id' => $clone->id));
         }
         return $result;
     }
     return false;
 }
コード例 #18
0
 public function getDayName()
 {
     include_once 'Day.php';
     $day = new Day();
     return $day->getWeekDayName($this->_day);
 }
コード例 #19
0
ファイル: Day.php プロジェクト: DostonAkhmedov/Dars_jadvali
 public static function days()
 {
     $model = Day::model()->findAll();
     return CHtml::listData($model, 'id', 'name');
 }
コード例 #20
0
ファイル: admin.php プロジェクト: DostonAkhmedov/Dars_jadvali
<?php

/* @var $this DgstController */
/* @var $model Dgst */
$this->breadcrumbs = array('Dgsts' => array('index'), 'Manage');
$this->menu = array(array('label' => 'List Dgst', 'url' => array('index')), array('label' => 'Create Dgst', 'url' => array('create')));
Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\t\$('.search-form').toggle();\n\treturn false;\n});\n\$('.search-form form').submit(function(){\n\t\$('#dgst-grid').yiiGridView('update', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n");
?>

<h1>Manage Dgsts</h1>

<p>
You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b>
or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.
</p>

<?php 
echo CHtml::link('Advanced Search', '#', array('class' => 'search-button'));
?>
<div class="search-form" style="display:none">
<?php 
$this->renderPartial('_search', array('model' => $model));
?>
</div><!-- search-form -->

<?php 
$this->widget('zii.widgets.grid.CGridView', array('id' => 'dgst-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array('id' => ['name' => 'id', 'htmlOptions' => ['width' => 30]], 'day_id' => ['name' => 'day_id', 'value' => '$data->day->name', 'filter' => Day::days()], 'group_id' => ['name' => 'group_id', 'value' => '$data->group->name', 'filter' => Group::groups()], 'subject_id' => ['name' => 'subject_id', 'value' => '$data->subject->name', 'filter' => Subject::subjects()], 'teacher_id' => ['name' => 'teacher_id', 'value' => '$data->teacher->fio', 'filter' => Teacher::teachers()], 'para' => ['name' => 'para', 'filter' => Dgst::para()], 'megalka' => ['name' => 'megalka', 'filter' => Dgst::megalka()], 'teacher2_id' => ['name' => 'teacher2_id', 'value' => '$data->teacher->fio', 'filter' => Teacher::teachers()], array('class' => 'CButtonColumn'))));
コード例 #21
0
 public function actionShow($courseAlias, $typeAlias)
 {
     // Авторизован ли пользователь
     if (Yii::app()->user->isAuthenticated() === false) {
         $this->redirect(Yii::app()->user->loginUrl);
     }
     if (($user = Yii::app()->user->getProfile()) === null) {
         Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::ERROR_MESSAGE, Yii::t('UserModule.user', 'User not found.'));
         Yii::app()->user->logout();
         $this->redirect((array) '/user/account/login');
     }
     // Вид курса
     $courseType = CourseType::model()->published()->with('course')->find('course.alias = :courseAlias AND t.alias = :typeAlias', array(':courseAlias' => $courseAlias, ':typeAlias' => $typeAlias));
     if (!$courseType) {
         throw new CHttpException(404);
     }
     if (Yii::app()->user->isSuperUser()) {
         // Админ может просматривать любой тип курса
         if ($_GET['adminPackageId'] != '') {
             $adminPackageId = (int) Yii::app()->getRequest()->getParam('adminPackageId');
             if ($adminPackageId > 0) {
                 Yii::app()->user->setState('adminPackageId', $adminPackageId);
             } else {
                 Yii::app()->user->setState('adminPackageId', null);
             }
         }
         // Админ может просматривать курс с данными  другого пользователя
         if ($_GET['adminUserId'] != '') {
             $adminUserId = (int) Yii::app()->getRequest()->getParam('adminUserId');
             if ($adminUserId > 0) {
                 Yii::app()->user->setState('adminUserId', $adminUserId);
             } else {
                 Yii::app()->user->setState('adminUserId', null);
             }
         }
         // Подмена данных пользователя для администратора
         if (Yii::app()->user->getState('adminUserId') !== null) {
             $viewedUser = User::model()->findByPK((int) Yii::app()->user->getState('adminUserId'));
             if ($viewedUser) {
                 $user->code = $viewedUser->code;
                 $user->profile->setAttributes(array('name' => $viewedUser->profile->name, 'gender' => $viewedUser->profile->gender, 'birth_date' => $viewedUser->profile->birth_date, 'birth_time' => $viewedUser->profile->birth_time, 'city_id' => $viewedUser->profile->city_id));
                 $user->profile->city = $viewedUser->profile->city;
             }
         }
     }
     // Пакет
     if (Yii::app()->user->isSuperUser() && Yii::app()->user->getState('adminPackageId') !== null) {
         // Админ может просмотреть любой пакет
         $packageId = (int) Yii::app()->user->getState('adminPackageId');
         $this->package = Package::model()->published()->findByPK($packageId);
     } else {
         // Остальным подбираем пакет в зависимости от указанных данных
         $this->package = Package::model()->published()->find('t.type_id = :type_id AND t.gender = :gender AND t.notime = :notime', array(':type_id' => $courseType->id, ':gender' => $user->profile->gender, ':notime' => $user->profile->birth_time === null));
     }
     if (!$this->package) {
         throw new CHttpException(404);
     }
     // День
     $dayNumber = (int) Yii::app()->getRequest()->getParam('day', 1);
     $this->day = $day = Day::model()->published()->package($this->package->id)->findByNumber($dayNumber);
     if (!$day) {
         throw new CHttpException(404);
     }
     // Страница
     $pageNumber = (int) Yii::app()->getRequest()->getParam('page', 1);
     $page = Page::model()->published()->day($day->id)->with(array('blocks' => array('scopes' => 'published', 'order' => 'blocks.sort ASC')))->findByNumber($pageNumber);
     if (!$page) {
         throw new CHttpException(404);
     }
     // Определяем, имеет ли пользователь доступ к выбранной странице курса
     $this->_checkPermissions($user, $courseType, $dayNumber, $pageNumber);
     // Запоминаем последнюю прочитанную страницу для пользователя
     LastReadPage::model()->fixLastPage($user, $courseType, $page);
     // Определяем предыдущую и следующую страницы
     $prevPage = $page->getPrevPage();
     $nextPage = $page->getNextPage();
     // Выделяем интересную мысль, если она указана
     $quoteText = '';
     $highlightId = Yii::app()->getRequest()->getParam('highlight', null);
     if (!empty($highlightId)) {
         $quote = Quote::model()->findByPk($highlightId);
         $quoteText = $quote ? $quote->content : '';
     }
     // Вывод в шаблон
     $this->render('show', array('package' => $this->package, 'day' => $day, 'page' => $page, 'nextPage' => $nextPage, 'prevPage' => $prevPage, 'quoteText' => $quoteText));
 }
コード例 #22
0
ファイル: DayReference.php プロジェクト: devhelp/calendar
 /**
  * Returns referenced day from the calendar
  * @param Calendar $calendar calendar in which day has to be looked
  * @param integer $year year for which the day has to be calculated
  * @return null|Day
  */
 public function getReferencedDay(Calendar $calendar, $year = null)
 {
     $day = $calendar->getDay($this->getEvent(), $year);
     if (!$day) {
         return null;
     }
     if ($this->getOffsetValue() === 0) {
         $referencedDay = $day;
     } else {
         $dt = $day->toDateTime($year);
         $dt->modify($this->getOffsetString());
         $referencedDay = Day::fromDateTime($dt);
     }
     return $referencedDay;
 }
コード例 #23
0
ファイル: schedule.php プロジェクト: mhender24/WebScheduler
 public static function update()
 {
     for ($i = 0; $i < count($_POST['day_id_arr']); $i++) {
         Day::update($i);
     }
 }
コード例 #24
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Day the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Day::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
コード例 #25
0
	<div class="row">
		<?php 
echo $form->label($model, 'id');
?>
		<?php 
echo $form->textField($model, 'id');
?>
	</div>

	<div class="row">
		<?php 
echo $form->label($model, 'day_id');
?>
		<?php 
echo $form->dropDownList($model, 'day_id', Day::days());
?>
	</div>

	<div class="row">
		<?php 
echo $form->label($model, 'group_id');
?>
		<?php 
echo $form->dropDownList($model, 'group_id', Group::groups());
?>
	</div>

	<div class="row">
		<?php 
echo $form->label($model, 'subject_id');
コード例 #26
0
 public function addDay(Day $day)
 {
     $dayNumber = $day->getDate()->format('d');
     $this->days[$dayNumber] = $day;
 }
コード例 #27
0
ファイル: cal_day.php プロジェクト: nanoprime/sureinvoice
if (!isset($_GET['m'])) {
    $_GET['m'] = date('m');
}
if (!isset($_GET['d'])) {
    $_GET['d'] = date('d');
}
if (!isset($_GET['h'])) {
    $_GET['h'] = date('H');
}
if ($loggedin_user->hasRight('admin') && isset($_REQUEST['user_id'])) {
    $user_id = $_REQUEST['user_id'];
} else {
    $user_id = $loggedin_user->id;
}
// Create a new day
$day = new Day($_GET['y'], $_GET['m'], $_GET['d']);
// Get the task data
$task = new SI_Task();
$tasks = $task->getCalendarTasks($user_id, $day->getTimestamp(), $day->getTimestamp() + 24 * 60 * 60, 'hour');
if ($tasks === FALSE) {
    $error_msg .= "Could not retrieve Tasks!\n";
    debug_message($task->getLastError());
}
// Get the activity data
$ta = new SI_TaskActivity();
$activities = $ta->getCalendarActivities($user_id, $day->getTimestamp(), $day->getTimestamp() + 24 * 60 * 60, 'hour');
if ($activities === FALSE) {
    $error_msg .= "Could not retrieve activities!\n";
    debug_message($ta->getLastError());
}
// Make sure the current date is selected
コード例 #28
0
ファイル: Day.php プロジェクト: milanvodicka/SmartFriday
function assertHour(Day $day)
{
    if ($day->getHour() > 23) {
        throw new Exception('Whaaat?');
    }
}