예제 #1
0
파일: util.php 프로젝트: uzura8/flockbird
 public static function get_action_uri($table, $id, $action, $api_response_format = null)
 {
     $controller_path = Site_Model::convert_table2controller_path($table);
     if ($api_response_format) {
         return sprintf('%s/api/%s/%d.%s', $controller_path, $action, $id, $api_response_format);
     }
     return sprintf('%s/%s/%d', $controller_path, $action, $id);
 }
예제 #2
0
<?php

list($name, $icon, $btn_color) = get_public_flag_label($public_flag, isset($view_icon_only) ? $view_icon_only : false, 'array', true);
if (!empty($model)) {
    $model_uri = Site_Model::convert_table2controller_path($model);
}
if (empty($option_type)) {
    $option_type = 'default';
}
?>

<?php 
if (!empty($disabled_to_update)) {
    $atter = array('class' => 'btn btn-default btn-xs public_flag ' . $btn_color);
    if (!empty($disabled_to_update['message'])) {
        $atter['data-toggle'] = 'tooltip';
        $atter['data-placement'] = 'top';
        $atter['title'] = $disabled_to_update['message'];
        $atter['onclick'] = 'return false;';
    }
    echo Html::anchor('#', $icon . $name, $atter);
    ?>


<?php 
} elseif (!empty($is_mycontents) || !empty($use_in_cache)) {
    $parent_box_attr = array('class' => 'public_flag btn-group dropdown-toggle');
    if (!empty($parent_box_additional_class)) {
        $parent_box_attr['class'] .= ' ' . $parent_box_additional_class;
    }
    $btn_attr = array('class' => 'btn dropdown-toggle btn-default btn-xs', 'type' => 'button', 'data-toggle' => 'dropdown', 'data-public_flag' => $public_flag, 'id' => !empty($model) && !empty($id) ? sprintf('public_flag_%s_%d', $model, $id) : 'public_flag_selector');
예제 #3
0
파일: api.php 프로젝트: uzura8/flockbird
 /**
  * Get liked members common api controller
  * 
  * @access  protected
  * @param   string  $parent_table  target parent table
  * @param   int     $parent_id  target parent record id
  * @param   string  $public_flag_related  related table for check brows authority
  * @param   array   $parent_member_id_relateds  related table and property array for check edit authority
  * @param   int     $limit  record count for get
  * @param   int     $limit_max  record limited count for get
  * @param   string  $parent_id_prop  parent table id property.
  * @return  Response (json|html)
  * @throws  Exception in Controller_Base::controller_common_api
  * @see  Controller_Base::controller_common_api
  */
 protected function api_get_liked_members_common($parent_table, $parent_id, $public_flag_related = null, $parent_member_id_relateds = array(), $limit = 0, $limit_max = 0, $parent_id_prop = null)
 {
     $this->api_accept_formats = array('json', 'html');
     $this->controller_common_api(function () use($parent_table, $parent_id, $public_flag_related, $parent_member_id_relateds, $limit, $limit_max, $parent_id_prop) {
         if (!conf('like.isEnabled')) {
             throw new HttpNotFoundException();
         }
         $like_model = Site_Model::get_model_name($parent_table . '_like');
         $parent_id = (int) $parent_id;
         $parent_model = Site_Model::get_model_name($parent_table);
         $parent_obj = $parent_model::check_authority($parent_id, 0, $public_flag_related);
         if (!$parent_id_prop) {
             $parent_id_prop = $parent_table . '_id';
         }
         $auther_member_ids = Util_Orm::get_related_member_ids($parent_obj, $parent_member_id_relateds);
         foreach ($auther_member_ids as $member_id) {
             $this->check_browse_authority($public_flag_related ? $parent_obj->{$public_flag_related}->public_flag : $parent_obj->public_flag, $member_id);
         }
         $default_params = array('desc' => 1, 'latest' => 1, 'limit' => $limit ?: conf('view_params_default.like.members.popover.limit'));
         list($limit, $is_latest, $is_desc, $since_id, $max_id) = $this->common_get_list_params($default_params, $limit_max ?: conf('view_params_default.like.members.popover.limit_max'));
         $params[$parent_id_prop] = $parent_id;
         list($list, $next_id) = $like_model::get_list($params, $limit, $is_latest, $is_desc, $since_id, $max_id, 'member', $this->format == 'json');
         $data = array('list' => $list, 'next_id' => $next_id);
         if ($this->format == 'html') {
             $data += array('related_member_table_name' => 'member', 'is_simple_list' => true, 'list_id' => 'liked_member_list_' . $parent_id, 'get_uri' => Site_Util::get_api_uri_get_liked_members(Site_Model::convert_table2controller_path($parent_table), $parent_id), 'no_data_message' => sprintf('%sしている%sはいません', term('form.like'), term('member.view')));
             if ($since_id) {
                 $data['since_id'] = $since_id;
             }
         }
         $this->set_response_body_api($data, $this->format == 'html' ? '_parts/member_list' : null);
     });
 }