Пример #1
0
 /**
  * Get note list by member
  * 
  * @access  public
  * @param   int  $member_id
  * @return  Response (html)
  * @throws  Exception in Controller_Base::controller_common_api
  * @see  Controller_Base::controller_common_api
  */
 public function get_member($member_id = null)
 {
     $this->api_accept_formats = 'html';
     $this->controller_common_api(function () use($member_id) {
         $member_id = (int) $member_id;
         list($is_mypage, $member) = $member_id ? $this->check_auth_and_is_mypage($member_id, true) : array(null, false);
         list($limit, $page) = $this->common_get_pager_list_params();
         $is_draft = $is_mypage ? \Util_string::cast_bool_int(\Input::get('is_draft', 0)) : 0;
         $data = Site_Model::get_list($limit, $page, \Auth::check() ? $this->u->id : 0, $member, $is_mypage, $is_draft);
         $this->set_response_body_api($data, '_parts/list');
     });
 }
Пример #2
0
 /**
  * Note member
  * 
  * @access  public
  * @params  integer
  * @return  Response
  */
 public function action_member($member_id = null)
 {
     $member_id = (int) $member_id;
     list($is_mypage, $member) = $this->check_auth_and_is_mypage($member_id);
     $is_draft = $is_mypage ? \Util_string::cast_bool_int(\Input::get('is_draft', 0)) : 0;
     list($limit, $page) = $this->common_get_pager_list_params();
     $data = Site_Model::get_list($limit, $page, \Auth::check() ? $this->u->id : 0, $member, $is_mypage, $is_draft);
     $this->set_title_and_breadcrumbs(sprintf('%sの%s', $is_mypage ? '自分' : $member->name . 'さん', term('note', 'site.list')), null, $member);
     $this->template->subtitle = $is_mypage ? \View::forge('_parts/member_subtitle') : '';
     $this->template->content = \View::forge('member', $data);
     $this->template->post_footer = \View::forge('_parts/list_footer');
 }
Пример #3
0
 public static function set_relations_cache4member_id_from_to($member_id_from, $member_id_to)
 {
     $sorted_key = Util_string::combine_nums(array($member_id_from, $member_id_to), true);
     $key = Util_string::combine_nums(array($member_id_from, $member_id_to));
     self::$relations_friend[$sorted_key] = 0;
     self::$relations_friend_pre[$key] = 0;
     self::$relations_follow[$key] = 0;
     self::$relations_access_block[$key] = 0;
     if (!($relation = self::get4member_id_from_to($member_id_from, $member_id_to))) {
         return;
     }
     self::$relations_friend[$sorted_key] = $relation->is_friend;
     self::$relations_friend_pre[$key] = $relation->is_friend_pre;
     self::$relations_follow[$key] = $relation->is_follow;
     self::$relations_access_block[$key] = $relation->is_access_block;
     return;
 }
Пример #4
0
 public static function get_slug()
 {
     $main = date('ymd');
     $suffix = '';
     $slug = $main . $suffix;
     $max = \Config::get('news.max_articles_per_day');
     $i = 0;
     while (Model_News::check_exists4slug($slug)) {
         if ($i > $max) {
             throw \FuelException('Posted news exceeded the limit on par day.');
         }
         $suffix = \Util_string::get_next_alpha_str($suffix);
         $slug = $main . $suffix;
         $i++;
     }
     return $slug;
 }
Пример #5
0
    if (!is_array($callbacks)) {
        $callbacks = (array) $callbacks;
    }
    foreach ($callbacks as $callback) {
        if (is_callable($callback)) {
            $body = call_user_func($callback, $body);
        }
    }
}
$is_truncated = false;
if (!$options['is_detail']) {
    if ($options['line']) {
        list($body, $is_truncated4line) = Util_string::truncate4line($body, $options['line'], '', $options['is_rtrim'], $options['encoding']);
    }
    if ($options['width']) {
        list($body, $is_truncated4count) = Util_string::truncate($body, $options['width'], '', true);
    }
    $is_truncated = $is_truncated4line || $is_truncated4count;
}
if ($is_truncated && $options['trimmarker']) {
    if (!Str::ends_with($body, "\n")) {
        $body .= ' ';
    }
    $body .= $options['trimmarker'];
}
?>
<div><?php 
echo $body;
?>
</div>
<?php 
Пример #6
0
 public static function truncate4line($body, $line, $trimmarker = '...', $is_rtrim = true, $encoding = null)
 {
     $encoding or $encoding = \Fuel::$encoding;
     $is_truncated = false;
     if (!$line) {
         return array($body, $is_truncated);
     }
     if (!($pos = Util_string::mb_strpos_n($body, "\n", $line, $encoding))) {
         return array($body, $is_truncated);
     }
     $is_truncated = $pos < mb_strlen($body, $encoding);
     $body = mb_substr($body, 0, $pos, $encoding);
     if ($is_truncated) {
         if ($is_rtrim) {
             $body = rtrim($body);
         }
         if ($trimmarker) {
             if (!Str::ends_with($body, "\n")) {
                 $body .= ' ';
             }
             $body .= $trimmarker;
         }
     }
     return array($body, $is_truncated);
 }
Пример #7
0
 protected function truncate($body)
 {
     $is_truncated4line = false;
     $is_truncated4count = false;
     if ($this->options['is_truncate']) {
         if ($this->options['truncate_line']) {
             list($body, $is_truncated4line) = Util_string::truncate4line($body, $this->options['truncate_line'], $this->options['trimmarker'], $this->options['is_rtrim'], $this->options['encoding']);
         }
         if ($this->options['truncate_width']) {
             list($body, $is_truncated4count) = Util_string::truncate($body, $this->options['truncate_width'], $this->options['trimmarker'], true);
         }
         $this->is_truncated = $is_truncated4line || $is_truncated4count;
     }
     return $body;
 }
Пример #8
0
 public static function get_redirect_uri($default_uri = '')
 {
     $redirect_uri = Input::post('destination');
     if (!$redirect_uri || !Util_string::check_uri_for_redilrect($redirect_uri)) {
         $redirect_uri = $default_uri;
     }
     return $redirect_uri;
 }
Пример #9
0
 private function change_publish_status($id, $target_status)
 {
     $target_status = \Util_string::cast_bool_int($target_status);
     \Util_security::check_method('POST');
     \Util_security::check_csrf();
     $news = \News\Model_News::check_authority($id);
     $msg_status = $target_status ? term('form.publish') : term('form.unpublish') . 'に';
     $redirect_uri = \Site_Util::get_redirect_uri('admin/news/' . $id);
     if ($news->is_published == $target_status) {
         \Session::set_flash('error', sprintf('既に%sされています。', $msg_status));
         \Response::redirect($redirect_uri);
     }
     try {
         \DB::start_transaction();
         $news->is_published = $target_status;
         if ($news->is_published && !isset_datatime($news->published_at)) {
             $news->published_at = date('Y-m-d H:i:s');
         }
         $news->save();
         //// timeline 投稿
         //if (is_enabled('timeline')) \Timeline\Site_Model::save_timeline($this->u->id, $note->public_flag, 'note', $note->id);
         \DB::commit_transaction();
         \Session::set_flash('message', sprintf('%sを%sしました。', term('news.view'), $msg_status));
     } catch (\FuelException $e) {
         if (\DB::in_transaction()) {
             \DB::rollback_transaction();
         }
         \Session::set_flash('error', $e->getMessage());
     }
     \Response::redirect($redirect_uri);
 }
Пример #10
0
 public function login_succeeded($destination = null)
 {
     Session::set_flash('message', 'ログインしました');
     $redirect_uri = urldecode($destination);
     if ($redirect_uri && Util_string::check_uri_for_redilrect($redirect_uri)) {
         Response::redirect($redirect_uri);
     }
     Response::redirect($this->after_auth_uri);
 }
Пример #11
0
 public static function make_filename($extention, $prefix = '', $original_filename = '', $with_extension = true, $delimitter = '')
 {
     $filename = Util_string::get_random($original_filename, $extention);
     if ($prefix) {
         $prefix .= $delimitter;
     }
     if ($with_extension) {
         $filename .= '.' . $extention;
     }
     return $prefix . $filename;
 }
Пример #12
0
 protected function save_profile_image($provider, $image_url, $member_obj)
 {
     $image_url = $this->get_profile_image_url($provider, $image_url);
     $save_file_path_tmp = sprintf('%stmp/%s_%s_%s', APPPATH, $member_obj->id, Util_string::get_unique_id(), time());
     Site_Upload::save_image_from_url($image_url, $save_file_path_tmp, conf('upload.types.img.types.m.max_size', null, 0));
     \DB::start_transaction();
     Site_Member::save_profile_image($member_obj, $save_file_path_tmp, false);
     \DB::commit_transaction();
 }