function export($export_unpublished = FALSE) { $CI =& get_instance(); $CI->load->helper('array'); $return = array(); $sql['select'] = $this->_tables['pages'] . '.*'; $where = array(); if (!$export_unpublished) { $where = array('published' => 'yes'); } $pages = $this->find_all_array_assoc('location', $where, 'location asc'); foreach ($pages as $key => $val) { $parts = explode('/', $val['location']); $parent = implode('/', $parts); if (!empty($pages[$parent]) || strrpos($val['location'], '/') === FALSE) { $pages[$key]['parent_id'] = $parent; } else { // if orphaned... then put them in the _orphans folder if (empty($return['_orphans'])) { $pages['_orphans'] = array('parent_id' => null, 'location' => '_orphans'); } $pages[$key]['parent_id'] = '_orphans'; } } $pages = array_sorter($pages, 'location'); return $pages; }
function list_items($limit = null, $offset = 0, $col = 'name', $order = 'asc') { $CI =& get_instance(); $CI->load->helper('array'); $CI->load->helper('convert'); if (!isset($this->filters['group_id'])) { return array(); } $group_id = $this->filters['group_id']; // not encoded yet... then decode if (!$this->_encoded) { $this->filters['group_id'] = uri_safe_encode($group_id); // to pass the current folder $this->_encoded = TRUE; } else { $group_id = uri_safe_decode($group_id); } $asset_dir = $this->get_dir($group_id); $assets_path = $CI->asset->assets_server_path . $asset_dir . DIRECTORY_SEPARATOR; $tmpfiles = directory_to_array($assets_path, TRUE, $CI->config->item('assets_excluded_dirs', 'fuel'), FALSE); $files = get_dir_file_info($assets_path, TRUE); $cnt = count($tmpfiles); $return = array(); $asset_type_path = WEB_PATH . $CI->config->item('assets_path') . $asset_dir . '/'; //for ($i = $offset; $i < $cnt - 1; $i++) for ($i = 0; $i < $cnt; $i++) { if (!empty($tmpfiles[$i]) && !empty($files[$tmpfiles[$i]])) { $key = $tmpfiles[$i]; if (empty($this->filters['name']) || !empty($this->filters['name']) && (strpos($files[$key]['name'], $this->filters['name']) !== FALSE || strpos($key, $this->filters['name']) !== FALSE)) { $file['id'] = uri_safe_encode(assets_server_to_web_path($files[$tmpfiles[$i]]['server_path'], TRUE)); //$file['filename'] = $files[$key]['name']; $file['name'] = $key; $file['preview/kb'] = $files[$key]['size']; $file['link'] = NULL; $file['last_updated'] = english_date($files[$key]['date'], true); $return[] = $file; } } } $return = array_sorter($return, $col, $order, TRUE); // do a check for empty limit values to prevent issues found where an empty $limit value would return nothing in 5.16 $return = empty($limit) ? array_slice($return, $offset) : array_slice($return, $offset, $limit); // after sorting add the images foreach ($return as $key => $val) { if (is_image_file($return[$key]['name'])) { $return[$key]['preview/kb'] = $return[$key]['preview/kb'] . ' kb <div class="img_crop"><a href="' . $asset_type_path . $return[$key]['name'] . '" target="_blank"><img src="' . $asset_type_path . $return[$key]['name'] . '" border="0"></a></div>'; $return[$key]['link'] = '<a href="' . $asset_type_path . $return[$key]['name'] . '" target="_blank">' . $asset_dir . '/' . $return[$key]['name'] . '</a>'; } else { $return[$key]['preview/kb'] = $return[$key]['preview/kb']; $return[$key]['link'] = '<a href="' . $asset_type_path . $return[$key]['name'] . '" target="_blank">' . $asset_dir . '/' . $return[$key]['name'] . '</a>'; } } return $return; }
function tree($just_published = FALSE) { $CI =& get_instance(); $CI->load->module_model(BLOG_FOLDER, 'blog_posts_model'); $CI->load->helper('array'); $return = array(); $where = $just_published ? $where = array('published' => 'yes') : array(); $comments = $this->find_all($where, 'title asc'); foreach ($comments as $comment) { if (!isset($return[$comment->post_id])) { $return['p_' . $comment->post_id] = array('id' => 'p_' . $comment->post_id, 'label' => $comment->title, 'location' => fuel_url('blog/posts/edit/' . $comment->post_id)); } $label = !empty($comment->author_name) ? $comment->author_name : $comment->author_email; $attributes = $comment->published == 'no' ? array('class' => 'unpublished', 'title' => 'unpublished') : NULL; $return['c_' . $comment->id] = array('id' => $comment->id, 'label' => $label, 'parent_id' => 'p_' . $comment->post_id, 'location' => fuel_url('blog/posts/edit/' . $comment->post_id), 'attributes' => $attributes); } $return = array_sorter($return, 'label', 'asc'); return $return; }
function tree($just_published = false) { $CI =& get_instance(); $CI->load->helper('array'); $data = array(); $where = array(); $where['group_id'] = $this->group_id; if ($just_published) { $where['published'] = 'yes'; } $all_nav = $this->find_all_array_assoc('id', $where); $where = array(); if (!empty($parent)) { $parent = $this->find_one_array(array('location' => $parent)); $where = array('group_id' => $this->group_id, 'parent_id' => $parent['id']); } else { $where = array('group_id' => $this->group_id); } $data = $this->find_all_array($where, 'precedence desc'); $return = array(); $i = 0; foreach ($data as $key => $val) { $return[$key] = $val; if ($val['parent_id'] != 0) { if (empty($all_nav[$val['parent_id']])) { if (empty($return['_orphans'])) { $return['_orphans'] = array('label' => '_orphans', 'parent_id' => 0, 'location' => null); } $return[$key]['parent_id'] = '_orphans'; } } else { $return[$key]['parent_id'] = 0; } if ($val['published'] == 'no') { $return[$key]['attributes'] = array('class' => 'unpublished', 'title' => 'unpublished'); } $return[$key]['location'] = fuel_url('navigation/edit/' . $val['id']); } $return = array_sorter($return, 'label', 'asc'); return $return; }
function index() { $this->load->config('backup'); $this->load->helper('array'); $this->load->helper('file'); $backup_config = $this->config->item('backup'); $backup_dir = $backup_config['db_backup_path']; $backup_dir_info = get_dir_file_info($backup_dir); $vars = array(); if (!empty($backup_dir_info)) { $sorted_backup_dir_info = each(array_sorter($backup_dir_info, 'date', 'desc')); $sorted_backup_dir_info = array_sorter($backup_dir_info, 'date', 'desc'); foreach ($sorted_backup_dir_info as $path => $val) { $ext = strtolower(end(explode('.', $val['name']))); if ($ext == 'sql' || ($ext = 'zip')) { $last_backup_date = date("m/d/Y h:ia", $val['date']); $vars['last_backup_date'] = $last_backup_date; } } } $this->load->view('dashboard', $vars); }
function tree($just_published = FALSE) { $CI =& get_instance(); $CI->load->module_model(BLOG_FOLDER, 'blog_categories_model'); $CI->load->module_model(BLOG_FOLDER, 'blog_posts_to_categories_model'); $CI->load->helper('array'); $return = array(); $where = $just_published ? $where = array('published' => 'yes') : array(); $categories = $CI->blog_categories_model->find_all($where, 'id asc'); $posts_to_categories = $CI->blog_posts_to_categories_model->find_all($where, 'title asc'); if (empty($posts_to_categories)) { return array(); } foreach ($categories as $category) { $return[$category->id] = array('id' => $category->id, 'parent_id' => 0, 'label' => $category->name, 'location' => fuel_url('blog/categories/edit/' . $category->id)); } foreach ($posts_to_categories as $val) { $attributes = $val->published == 'no' ? array('class' => 'unpublished', 'title' => 'unpublished') : NULL; $return['p_' . $val->post_id] = array('label' => $val->title, 'parent_id' => $val->category_id, 'location' => fuel_url('blog/posts/edit/' . $val->post_id), 'attributes' => $attributes); } $return = array_sorter($return, 'parent_id', 'asc'); return $return; }
function tree($just_published = FALSE) { $CI =& get_instance(); $CI->load->module_model(BLOG_FOLDER, 'blog_categories_model'); $CI->load->module_model(FUEL_FOLDER, 'fuel_relationships_model'); $CI->load->helper('array'); $return = array(); $where = $just_published ? $where = array('published' => 'yes') : array(); $categories = $CI->blog_categories_model->find_all($where, 'precedence asc'); $posts_to_categories = $CI->fuel_relationships_model->find_by_candidate($this->_tables['blog_posts'], $this->_tables['blog_categories']); if (empty($posts_to_categories)) { return array(); } foreach ($categories as $category) { $return[$category->id] = array('id' => $category->id, 'parent_id' => 0, 'label' => $category->name, 'location' => fuel_url('blog/categories/edit/' . $category->id), 'precedence' => $category->precedence); } foreach ($posts_to_categories as $val) { $attributes = $val->candidate_published == 'no' ? array('class' => 'unpublished', 'title' => 'unpublished') : NULL; $return['p_' . $val->candidate_id . '_c' . $val->foreign_id] = array('label' => $val->candidate_title, 'parent_id' => $val->foreign_id, 'location' => fuel_url('blog/posts/edit/' . $val->candidate_id), 'attributes' => $attributes, 'precedence' => 100000); } $return = array_sorter($return, 'precedence', 'asc'); return $return; }
protected function _recent_pages($link, $name, $type) { $this->load->helper('array'); $session_key = $this->fuel_auth->get_session_namespace(); $user_data = $this->fuel_auth->user_data(); if (!isset($user_data['recent'])) { $user_data['recent'] = array(); } $already_included = false; foreach ($user_data['recent'] as $key => $pages) { if ($pages['link'] == $link and $pages['name'] == $name and $pages['type'] == $type) { $user_data['recent'][$key]['last_visited'] = time(); $already_included = TRUE; } } if (!$already_included) { if (strlen($name) > 100) { $name = substr($name, 0, 100) . '…'; } $val = array('name' => $name, 'link' => $link, 'last_visited' => time(), 'type' => $type); array_unshift($user_data['recent'], $val); } if (count($user_data['recent']) > $this->config->item('max_recent_pages', 'fuel')) { array_pop($user_data['recent']); } $user_data['recent'] = array_sorter($user_data['recent'], 'last_visited', 'desc', TRUE); $this->session->set_userdata($session_key, $user_data); }
{ $sorter = array(); $ret = array(); reset($array); /* Seta o ponteiro interno do array para sua primeira posição */ foreach ($array as $i => $val) { $sorter[$i] = $val[$key]; } arsort($sorter); /* Ordena um array e mantém a relação correspondente */ foreach ($sorter as $i => $val) { $ret[$i] = $array[$i]; } $array = $ret; } array_sorter($qtd_appear, "1"); $selected_users = array_slice($qtd_appear, 0, 100); /* Seleciona as 20 primeiras posicoes do array */ $category_array = array(); $qtd = 0; /* Procurar pelos nomes dos lugares que a pessoa fez check-in no facebook e encontrar categorias */ foreach ($selected_users as $key => $value) { $find_locations = mysqli_query($link, "SELECT place_name, place_latitude, place_longitude FROM FB_Friend_Places WHERE fb_friend_id = {$value['0']} GROUP BY place_name"); while ($value = mysqli_fetch_array($find_locations)) { //$category_found = find_categories($value[0],$value[1], $value[2]); // find categories function is inside foursquare-search-kmeans $check = mysqli_query($link, "SELECT category FROM FB_Locations_Categories WHERE place_name = '{$value['0']}' AND " . "place_latitude = '{$value['1']}' AND place_longitude = '{$value['2']}'"); if ($check) { $check_num_rows = mysqli_num_rows($check); } if ($check_num_rows > 0) { $values = mysqli_fetch_array($check);
/** * Adds to the recent page array * * @access public * @param string The URI path of a page * @param string The name to display * @param string The type of page * @return void */ public function add_recent_page($link, $name, $type) { $this->CI->load->helper('array'); $session_key = $this->fuel->auth->get_session_namespace(); $user_data = $this->fuel->auth->user_data(); $name = strip_tags($name); if (!isset($user_data['recent'])) { $user_data['recent'] = array(); } $already_included = FALSE; foreach ($user_data['recent'] as $key => $pages) { if ($pages['l'] == $link and $pages['n'] == $name and $pages['t'] == $type) { $user_data['recent'][$key]['ts'] = time(); $already_included = TRUE; } } if (!$already_included) { if (strlen($name) > 100) { $name = substr($name, 0, 100) . '…'; } $val = array('n' => $name, 'l' => $link, 'ts' => time(), 't' => $type); array_unshift($user_data['recent'], $val); } if (count($user_data['recent']) > $this->fuel->config('max_recent_pages')) { array_pop($user_data['recent']); } $user_data['recent'] = array_sorter($user_data['recent'], 'ts', 'desc', TRUE); $this->CI->session->set_userdata($session_key, $user_data); }