当前位置: 首页>>代码示例>>PHP>>正文


PHP site::day_slug方法代码示例

本文整理汇总了PHP中site::day_slug方法的典型用法代码示例。如果您正苦于以下问题:PHP site::day_slug方法的具体用法?PHP site::day_slug怎么用?PHP site::day_slug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在site的用法示例。


在下文中一共展示了site::day_slug方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: check_streaks

 private function check_streaks()
 {
     $users = ORM::factory('User')->where('current_streak', '>', 0)->find_all();
     if ((bool) $users->count()) {
         foreach ($users as $user) {
             $last = $user->pages->where('type', '=', 'page')->find();
             if ($last->loaded()) {
                 $nextday = site::day_slug(strtotime('+1 day', strtotime($last->day)));
                 $today = site::day_slug($user->timestamp());
                 $tomorrow = site::day_slug(strtotime('+1 day', $user->timestamp()));
                 if ($nextday != $today && $nextday != $tomorrow) {
                     $user->current_streak = 0;
                     $user->validation_required(false)->save();
                     if ($user->doing_challenge()) {
                         $user->fail_challenge();
                     }
                 }
             } else {
                 if ($user->doing_challenge()) {
                     $start = $user->challenge->start;
                     if ($user->timestamp() - $start > 24 * 60 * 60) {
                         $user->fail_challenge();
                     }
                 }
             }
         }
     }
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:28,代码来源:Userstreaks.php

示例2: action_info

 public function action_info()
 {
     if (!user::logged()) {
         ajax::error('You must be logged in');
     }
     $user = user::get();
     $today = $user->pages->where('day', '=', site::day_slug($user->timestamp()))->find();
     $wordcount = 0;
     if ($today->loaded()) {
         $wordcount = $today->wordcount;
     }
     $doingChallenge = $user->doing_challenge();
     ajax::success('ok', array('email' => $user->email, 'bio' => $user->bio, 'website' => $user->website, 'wordcount' => $wordcount, 'options' => array('reminder' => (bool) $user->option->reminder, 'reminder_hour' => $user->option->reminder_hour, 'reminder_minute' => $user->option->reminder_minute, 'reminder_meridiem' => $user->option->reminder_meridiem, 'timezone_id' => $user->option->timezone_id, 'theme_id' => $user->option->theme_id, 'privacymode' => (bool) $user->option->privacymode, 'privacymode_minutes' => $user->option->privacymode_minutes, 'hemingwaymode' => (bool) $user->option->hemingwaymode, 'public' => (bool) $user->option->public, 'rtl' => (bool) $user->option->rtl, 'language' => $user->option->language), 'doingChallenge' => $doingChallenge, 'challengeProgress' => $doingChallenge ? $user->challenge->progress : 0));
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:14,代码来源:User.php

示例3: array

            if (!array_key_exists($year, $years)) {
                $years[$year] = array();
            }
            $month = date('F', $stamp);
            if (!array_key_exists($month, $years[$year])) {
                $years[$year][$month] = array();
            }
            $years[$year][$month][] = $p;
        }
    }
    foreach ($years as $year => $month) {
        foreach ($month as $monthname => $days) {
            echo '<optgroup label="' . $monthname . ', ' . $year . '">';
            foreach ($days as $day) {
                $dayname = date('l ', $day->created) . ' the ' . date('jS', $day->created);
                if ($day->day != site::day_slug()) {
                    //$dayname = 'Today';
                    echo '<option value="' . $day->day . '"' . ($dayname == $day->day ? ' selected="selected"' : '') . '>' . $dayname . '</option>';
                }
            }
            echo '<optgroup>';
        }
    }
    ?>
       			</select>
       		<?php 
}
?>
			
<?php 
if (!empty($user->bio)) {
开发者ID:artbypravesh,项目名称:morningpages,代码行数:31,代码来源:index.php

示例4: date

 public function date()
 {
     if (!$this->day) {
         $this->day = site::day_slug();
     }
     $today = site::day_slug();
     if ($today == $this->day) {
         return 'Today';
     }
     return $this->daystamp();
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:11,代码来源:Page.php

示例5: today_slug

 public function today_slug()
 {
     return site::day_slug($this->timestamp());
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:4,代码来源:User.php

示例6: update_stats

 public static function update_stats($page)
 {
     if (!user::logged()) {
         return;
     }
     $user = self::get();
     $yesterdayslug = site::day_slug(strtotime('-1 day', $user->timestamp()));
     $yesterday = ORM::factory('Page')->where('user_id', '=', $user->id)->where('day', '=', $yesterdayslug)->where('type', '=', 'page')->find();
     if ($yesterday->loaded()) {
         $user->current_streak += 1;
         if ($user->doing_challenge()) {
             $challenge = $user->challenge;
             $challenge->progress += 1;
             if ($challenge->progress >= 30) {
                 if ($user->option('completedchallenge') == 0) {
                     notes::success('You have completed the 30 day challenge and have been added to our ' . HTML::anchor('challenge/wall-of-fame', 'wall of fame') . '! Congratulations!');
                     $options = $user->option;
                     $options->completedchallenge = $user->timestamp();
                     $options->save();
                 } else {
                     notes::success('You have completed the 30 day challenge! Congratulations!');
                 }
                 user::award_points(100, 'Completed the 30 day challenge! (+100 points)', $user);
                 $challenge->delete();
             } else {
                 $challenge->save();
             }
         }
         if ($user->current_streak > $user->longest_streak) {
             $user->longest_streak = $user->current_streak;
         }
     } else {
         $user->current_streak = 1;
         if ($user->doing_challenge()) {
             $challenge = $user->challenge;
             $challenge->progress = 1;
             $challenge->save();
         }
     }
     $user->all_time_words += $page->wordcount;
     if ($page->wordcount > $user->most_words) {
         notes::success('You have written more today than you ever have before! Good job!');
         $user->most_words = $page->wordcount;
     }
     $user->save();
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:46,代码来源:user.php

示例7: count_total_words

 public static function count_total_words()
 {
     $numwords = DB::select(DB::expr("SUM(`wordcount`) AS count"))->from('pages')->where('day', '=', site::day_slug())->execute()->as_array();
     $numwords = arr::get($numwords[0], 'count', 0);
     return $numwords;
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:6,代码来源:site.php

示例8: find

 /**
  * Site routes
  */
 public static function find($route, $params, $request)
 {
     visitor::save_update_current();
     maintenance::delete_inactive_visitors();
     extract($params);
     if (!isset($controller)) {
         $controller = 'content';
     }
     $controller = strtolower($controller);
     $guid = $controller . '/' . $action;
     if ($action == 'index') {
         $guid = $controller;
     }
     $controllerfile = ucfirst($controller);
     $action = isset($params['action']) ? $params['action'] : 'index';
     //$action = ucfirst($action);
     $slug = isset($params['slug']) ? $params['slug'] : '';
     $slug2 = isset($params['slug2']) ? $params['slug2'] : '';
     $slug3 = isset($params['slug3']) ? $params['slug3'] : '';
     $slug4 = isset($params['slug4']) ? $params['slug4'] : '';
     $slug5 = isset($params['slug5']) ? $params['slug5'] : '';
     // Homepage
     if ($guid == 'content') {
         return array('controller' => 'Site', 'action' => 'index');
     }
     // Page alias
     if ($controller == 'test') {
         return array('controller' => 'Page', 'action' => 'test');
     }
     if ($controller == 'contact') {
         return array('controller' => 'Page', 'action' => 'contact');
     }
     if ($controller == 'challenge') {
         if ($action == 'wall-of-fame') {
             return array('controller' => 'Games', 'action' => 'walloffame');
         } elseif ($action == 'index') {
             return array('controller' => 'Games', 'action' => 'challenge');
         }
     }
     if ($controller == 'leaderboard') {
         return array('controller' => 'Games', 'action' => 'leaderboard');
     }
     if ($controller == 'write') {
         $todayslug = site::day_slug();
         if (user::logged()) {
             $todayslug = user::get()->today_slug();
         }
         if (empty($action) || $action == 'index') {
             $action = $todayslug;
         }
         $page = false;
         if (user::logged()) {
             $page = ORM::factory('Page')->where('user_id', '=', user::get()->id)->where('type', '=', 'page')->where('day', '=', $action)->find();
             if (!$page->loaded() && $action == $todayslug) {
                 $page = ORM::factory('Page')->where('user_id', '=', user::get()->id)->where('type', '=', 'autosave')->where('day', '=', $action)->find();
                 // It's today, but todays page doesn't exist yet. Create it
                 if (!$page->loaded()) {
                     $page->type = 'autosave';
                     $page->save();
                 }
             }
         }
         if (user::logged() && ($page && $page->loaded()) && $slug == 'stats') {
             return array('controller' => 'Write', 'action' => 'pagestats', 'page' => $page);
         }
         if (user::logged() && ($page && $page->loaded()) || !user::logged()) {
             return array('controller' => 'Write', 'action' => 'write', 'page' => $page, 'daystamp' => $action);
         } else {
             return array('controller' => 'Write', 'action' => 'daynotfound');
         }
     }
     if ($controller == 'read') {
         return array('controller' => 'Page', 'action' => 'read', 'id' => $action);
     }
     if ($controller == 'user') {
         if ($action != '') {
             if ($action == 'password') {
                 return array('controller' => 'User', 'action' => 'password', 'token' => $slug);
             }
             if (in_array($action, user::reservednames())) {
                 return array('controller' => 'User', 'action' => $action);
             }
             // We're either looking at a user's public profile or 404'd
             $user = ORM::factory('User')->where('slug', '=', $action)->find();
             if ($user->loaded()) {
                 if ((bool) $user->option('public') || user::logged('admin')) {
                     return array('controller' => 'Me', 'action' => 'profile', 'user' => $user);
                 } else {
                     return array('controller' => 'Me', 'action' => 'notpublic');
                 }
             } else {
                 return array('controller' => 'Errors', 'action' => '404', 'params' => $params);
             }
         } else {
             return array('controller' => 'User', 'action' => 'options');
         }
     }
//.........这里部分代码省略.........
开发者ID:artbypravesh,项目名称:morningpages,代码行数:101,代码来源:routes.php


注:本文中的site::day_slug方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。