public static function productAlmostOutOfStock($type) { $almost_out_of_stock = Product::with(array('brand' => function ($query) { $query->select('id', 'name'); }, 'categories' => function ($query) { $query->select('id', 'name'); }))->select('id', 'name', 'quantity', 'productcat_id', 'brand_id', 'almost_finished', 'published')->orderBy('quantity', 'asc')->get()->toArray(); //tt(count($almost_out_of_stock), true); $counter = 0; // Counter for count alert if ($type === 'list' || $type === 'all') { } if (!empty($almost_out_of_stock)) { foreach ($almost_out_of_stock as $key) { if ($key['published'] != 0 && $key['quantity'] <= $key['almost_finished']) { //We'll take record is we're requesting for listing the items if ($type === 'list' || $type === 'all') { $key['linktoproduct'] = User::permitted('role.stock manager') ? URL::route('adminShowProduct', array(slug($key['brand']['name']), slug($key['categories']['name']))) : ''; //tt($key); $data['products'][] = $key; } $counter++; } } } $data['count'] = $counter; //tt(count($data['products'])); return $data; }
function create_list_item($child) { $id = slug($child->label); if ($child->type == 'region-monde') { return "<div id='{$id}' class='{$child->type}'>"; } if ($child->type == 'pays') { return "<div id='{$id}' class='{$child->type}'><h2>{$child->label}</h2>"; } if ($child->type == 'region') { return "<div id='{$id}'><h3>{$child->label}</h3>"; } if ($child->type == 'sous-region') { return "<div id='{$id}'><h4>{$child->label}</h4>"; } if ($child->type == 'promo') { return "<div>" . create_promo_wines($child->id); } if ($child->type == 'vins-au-verre') { return "<div>" . print_vins_au_verre($child->id); } if ($child->type == 'demi-bouteilles') { return "<div>" . print_demi_bouteilles($child->id); } else { return ""; } }
function initialize_page() { $category_id = requestIdParam(); $category = Categories::FindById($category_id); $post_action = ""; if (isset($_POST['submit'])) { $post_action = $_POST['submit']; } if (isset($_POST['delete'])) { $category->delete(true); setFlash("<h3>Category Deleted</h3>"); redirect("/admin/list_categories/"); } else { if ($post_action == "Edit Category" || $post_action == "Edit and Return to List") { $category->display_name = getPostValue('display_name'); $category->name = slug(getPostValue('display_name')); $category->content = getPostValue('category_content'); $category->save(); setFlash("<h3>Category Edited</h3>"); if ($post_action == "Edit and Return to List") { redirect("admin/list_categories/"); } } } }
/** * Register an upload option * --------------------------------------------------------------------------------------- * Updated by Fawaz Tahir on 9th Sep, 2012 * ----------------------------------------------- * Introducing object parameter. This way we dont need to make separate * variables for different objects. To make sure right object is provided, we'll * check it against $Cbucket->search_types key. If it exists in variable, we'll * add it. * --------------------------------------------------------------------------------------- * * @global OBJECT $Cbucket * @param ARRAY $array * @return boolean */ function register_upload_option($array) { global $Cbucket; /** * -- for reference * an array will have * title -> required * description -> required * icon -> optional * function -> required , a php callback function to display in upload * window. */ extract($array); if (!$title || !$description || !function_exists($function) || !$function) { return false; } /* $type checking - Added by Fawaz Tahir */ if (!$Cbucket->search_types[$object]) { return false; } if (!$id) { $id = slug($title); } $upload_option = array('title' => $title, 'id' => $id, 'description' => $description, 'icon' => $icon, 'function' => $function); apply_filters($upload_option, 'register_upload_option'); $Cbucket->upload_options[$object][] = $upload_option; return $upload_option; }
function create_folder($userid, $semester_id, $subject_id) { $CI =& get_instance(); $user = $CI->common_model->query("SELECT user_type.`type`, users.user_name FROM users LEFT JOIN user_type ON users.user_type = user_type.id WHERE users.id = " . $userid . "")->row(); $folder1 = strtolower($user->type); $path = './uploads/' . $folder1; if (!file_exists($path)) { mkdir($path, 0777, true); } $folder2 = strtolower($user->user_name); $path = './uploads/' . $folder1 . '/' . $folder2; if (!file_exists($path)) { mkdir($path, 0777, true); } if (strtolower($user->type) == "student") { $semester = $CI->common_model->query("SELECT semesters.semester FROM semesters WHERE semesters.id = " . $semester_id . "")->row(); $folder3 = slug($semester->semester); $path = './uploads/' . $folder1 . '/' . $folder2 . '/' . $folder3; if (!file_exists($path)) { mkdir($path, 0777, true); } } $subjects = $CI->common_model->query("SELECT subjects.subjects FROM subjects WHERE subjects.id = " . $subject_id . "")->row(); $folder4 = slug($subjects->subjects); if (strtolower($user->type) == "student") { $path = './uploads/' . $folder1 . '/' . $folder2 . '/' . $folder3 . '/' . $folder4; } else { $path = './uploads/' . $folder1 . '/' . $folder2 . '/' . $folder4; } if (!file_exists($path)) { mkdir($path, 0777, true); } return $path; }
public function add() { if ($this->request->is('post')) { ///debug('Hiiiiiii');die; //debug($this->request->data); /*$folderName = 'profiles'; */ $slug = substr(slug($this->request->data['NoticeBoard']['title']), 0, 40); $document_path = '/files/' . $this->request->data['NoticeBoard']['url']['name']; $path = move_uploaded_file($this->data['NoticeBoard']['url']['tmp_name'], $_SERVER['DOCUMENT_ROOT'] . '/app/webroot/files/' . $this->data['NoticeBoard']['url']['name']); /*debug($_SERVER['DOCUMENT_ROOT']); debug($path);*/ /* $image_path = $this->Upload->upload_image_and_thumbnail($this->request->data,"name1",600,125,$folderName,false,$slug);*/ $this->request->data['NoticeBoard']['url'] = $document_path; //debug($image_path); //$this->request->data['NoticeBoard']['url'] = $document_path; // $this->request->data['Event']['image'] = $image_path; $this->NoticeBoard->create(); if ($this->NoticeBoard->save($this->request->data)) { $this->Session->setFlash(__('The notice board has been saved')); $this->redirect(array('action' => 'index')); } else { $this->Session->setFlash(__('The notice board could not be saved. Please, try again.')); } } }
function imgFindUploadSaveFromHTML($html, $folderName) { /* Reference: http://stackoverflow.com/questions/138313/how-to-extract-img-src-title-and-alt-from-html-using-php */ /* added on 8/28/11 to get images from any HTML content */ $html = stripslashes($html); $doc = new DOMDocument(); $doc->loadHTML($html); $xml = simplexml_import_dom($doc); // just to make xpath more simple $images = $xml->xpath('//img'); /* foreach ($images as $img) { echo $img['src'] . ' ' . $img['alt'] . ' ' . $img['title']; } */ foreach ($images as $img) { // echo $img['src'] . ' ' . $img['alt'] . ' ' . $img['title']; if (fopen($img['src'], "r") == true) { // run this check to see, if the image is on external server. For internal server, do nothing! if (strlen($img['src']) > 4) { $alt = substr(slug($img['alt']), 0, 75); $filename = $this->Upload->save_image_from_url($img['src'], 640, 125, $folderName, false, $alt); if (!empty($filename)) { $new_image_path = '/img/' . $folderName . '/big/' . $this->Upload->save_image_from_url($img['src'], 640, 125, $folderName, false, $alt); if ($new_image_path) { $html = str_replace($img['src'], $new_image_path, $html); } } } } } return $html; }
function add() { /*if (!empty($this->data)) { $this->Event->create(); if ($this->Event->save($this->data)) { $this->Session->setFlash(__('The event has been saved', true)); $this->redirect(array('action' => 'index')); } else { $this->Session->setFlash(__('The event could not be saved. Please, try again.', true)); } } $users = $this->Event->User->find('list'); $this->set(compact('users'));*/ if ($this->request->is('post')) { debug($_POST); $folderName = 'events'; $slug = substr(slug($this->request->data['Event']['title']), 0, 40); $image_path = $this->Upload->upload_image_and_thumbnail($this->request->data, "name1", 600, 125, $folderName, false, $slug); $this->request->data['Event']['image'] = $image_path; $this->Event->create(); if ($this->Event->save($this->request->data)) { $this->Session->setFlash(__('The event has been saved')); $this->redirect(array('action' => 'index')); } else { $this->Session->setFlash(__('The event could not be saved. Please, try again.')); } } $users = $this->Event->User->find('list'); $this->set(compact('users')); }
private function editOrSave($action) { $validations = array("exists" => array("Slug" => slug(POST("title", "clean")), "Year" => date("Y"), "Month" => date("m"), "Day" => date("d"), "Language" => POST("language")), "title" => "required", "content" => "required"); $this->categories = POST("categories"); $this->tags = POST("tags"); $this->URL = PATH("blog/" . date("Y")) . "/" . date("m") . "/" . date("d") . "/" . slug(POST("title", "clean")); $this->muralExist = POST("mural_exist"); $this->Files = $this->core("Files"); $this->mural = FILES("mural"); if ($this->mural["name"] !== "") { $dir = "www/lib/files/images/mural/"; $this->mural = $this->Files->uploadImage($dir, "mural", "mural"); if (is_array($this->mural)) { return $this->mural["alert"]; } } $dir = "www/lib/files/images/blog/"; $this->image = $this->Files->uploadImage($dir, "image", "resize", TRUE, TRUE, FALSE); $data = array("ID_User" => SESSION("ZanUserID"), "ID_URL" => 1, "Slug" => slug(POST("title", "clean")), "Content" => POST("content", "clean"), "Author" => SESSION("ZanUser"), "Year" => date("Y"), "Month" => date("m"), "Day" => date("d"), "Image_Small" => isset($this->image["small"]) ? $this->image["small"] : NULL, "Image_Medium" => isset($this->image["medium"]) ? $this->image["medium"] : NULL, "Pwd" => POST("pwd") ? POST("pwd", "encrypt") : NULL, "Start_Date" => now(4), "Text_Date" => now(2)); $this->Data->ignore(array("categories", "tags", "mural_exists", "mural", "pwd", "category", "language_category", "application", "mural_exist")); $this->data = $this->Data->proccess($data, $validations); if (isset($this->data["error"])) { return $this->data["error"]; } }
public function index() { $this->language->load('common/home'); $this->document->setTitle($this->language->get('heading_title')); $this->document->addScript('//code.jquery.com/ui/1.11.4/jquery-ui.min.js'); $this->data['heading_title'] = $this->language->get('heading_title'); $this->data['breadcrumbs'] = array(); $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'), 'separator' => 'fa fa-dashboard'); if (isset($this->session->data['success'])) { $this->data['success'] = $this->session->data['success']; unset($this->session->data['success']); } else { $this->data['success'] = ''; } $this->load->model('user/user'); $panels = $this->model_user_user->getDashboard($this->user->getId()); if (!$panels) { $panels = '{dashleft:"",dashcntr:"",dashright:"",dashhide:""}'; } $this->data['panels'] = $panels; $this->data['widgets'] = array(); $files = glob(DIR_APPLICATION . 'controller/dashboard/*.php'); if ($files) { foreach ($files as $file) { $extension = basename($file, '.php'); $this->load->language('dashboard/' . $extension); $this->data['widgets'][slug($extension)] = $this->load->controller('dashboard/' . $extension); } } $this->event->trigger('admin.dashboard.widget', $this->data['widgets']); $this->template = 'common/home.phtml'; $this->children = array('common/header', 'common/footer'); $this->response->setOutput($this->render()); }
/** * edit method * * @throws NotFoundException * @param string $id * @return void */ public function edit($id = null) { $this->Event->id = $id; if (!$this->Event->exists()) { throw new NotFoundException(__('Invalid event')); } if ($this->request->is('post') || $this->request->is('put')) { $slug = substr(slug($this->request->data['Event']['title']), 0, 40); $folderName = 'events'; $image_path = $this->Upload->upload_image_and_thumbnail($this->request->data, "name1", 600, 125, $folderName, false, $slug); if (strlen($image_path) > 4) { $this->request->data['Event']['image'] = $image_path; $detail = $this->Event->findById($id); $filename = $detail['Event']['image']; $this->Upload->delete_image($filename, $folderName); } if ($this->Event->save($this->request->data)) { $this->Session->setFlash(__('The event has been saved')); $this->redirect(array('action' => 'index')); } else { $this->Session->setFlash(__('The event could not be saved. Please, try again.')); } } else { $this->request->data = $this->Event->read(null, $id); } $users = $this->Event->User->find('list'); $this->set(compact('users')); }
/** * edit method * * @throws NotFoundException * @param string $id * @return void */ public function edit($id = null) { $this->Picture->id = $id; if (!$this->Picture->exists()) { throw new NotFoundException(__('Invalid picture')); } if ($this->request->is('post') || $this->request->is('put')) { $slug = substr(slug($this->request->data['Picture']['name']), 0, 40); $folderName = 'pictures'; $image_path = $this->Upload->upload_image_and_thumbnail($this->request->data, "name1", 1024, 768, $folderName, false, $slug); if (strlen($image_path) > 4) { $this->request->data['Picture']['picture'] = $image_path; $detail = $this->Picture->findById($id); $filename = $detail['Picture']['picture']; $this->Upload->delete_image($filename, $folderName); } if ($this->Picture->save($this->request->data)) { $this->Session->setFlash(__('The picture has been saved')); $this->redirect(array('action' => 'index')); } else { $this->Session->setFlash(__('The picture could not be saved. Please, try again.')); } } else { $this->request->data = $this->Picture->read(null, $id); } $albums = $this->Picture->Album->find('list'); $this->set(compact('albums')); }
function initialize_page() { $post_action = ""; if (isset($_POST['submit'])) { $post_action = $_POST['submit']; } if ($post_action == "Add Document" || $post_action == "Add and Return to List") { $name = $_POST['name']; $file_type = getFileExtension($_FILES['file']['name']); $filename = slug(getFileName($_FILES['file']['name'])); $filename_string = $filename . "." . $file_type; // Check to make sure there isn't already a file with that name $possibledoc = Documents::FindByFilename($filename_string); if (is_object($possibledoc)) { setFlash("<h3>Failure: Document filename already exists!</h3>"); redirect("admin/add_document"); } $target_path = SERVER_DOCUMENTS_ROOT . $filename_string; if (move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) { $new_doc = MyActiveRecord::Create('Documents', array('name' => $name, 'filename' => $filename_string, 'file_type' => $file_type)); $new_doc->save(); if (!chmod($target_path, 0644)) { setFlash("<h3>Warning: Document Permissions not set; this file may not display properly</h3>"); } setFlash("<h3>Document uploaded</h3>"); } else { setFlash("<h3>Failure: Document could not be uploaded</h3>"); } if ($post_action == "Add and Return to List") { redirect("admin/list_documents"); } } }
function update($conn, $dados, $id) { $update = $conn->prepare('UPDATE pages SET title=:title, body=:body, slug=:slug WHERE id=:id;'); $update->bindValue(':title', $dados['title'], PDO::PARAM_STR); $update->bindValue(':body', $dados['body'], PDO::PARAM_STR); $update->bindValue(':slug', slug($dados['title']), PDO::PARAM_STR); $update->bindValue(':id', $id, PDO::PARAM_INT); return $update->execute(); }
function initialize_page() { $page_id = requestIdParam(); $page = Pages::FindById($page_id); // get all the areas $areas = Areas::FindPublicAreas(); $post_action = ""; if (isset($_POST['submit'])) { $post_action = $_POST['submit']; } if ($post_action == "Save Page" || $post_action == "Save and Return to List") { if (isset($_POST['delete'])) { $page->delete(true); setFlash("<h3>Page deleted</h3>"); redirect("/admin/list_pages"); } else { $page->display_name = $_POST['display_name']; $oldname = $page->name; if (ALLOW_SHORT_PAGE_NAMES) { if ($_POST['name'] == "") { $page->name = slug($_POST['display_name']); } else { $page->name = slug($_POST['name']); } } else { $page->name = slug($_POST['display_name']); } $page->content = $_POST['page_content']; $page->template = $_POST['template']; $page->public = checkboxValue($_POST, 'public'); // Pages can either be directly assigned to areas, or assigned as a sub-page. // It's an either-or thing. For now, default to areas if they're selected (ie, if both selected, ignore the sub-page) // synchronize the users area selections $selected_areas = array(); if (isset($_POST['selected_areas'])) { $selected_areas = $_POST['selected_areas']; } if (count($selected_areas) > 0) { $page->parent_page_id = null; $page->updateSelectedAreas($selected_areas); } else { if ($_POST['parent_page'] != "") { $page->parent_page_id = $_POST['parent_page']; } else { $page->parent_page_id = null; } } $page->save(); $page->checkAlias($selected_areas, $oldname); setFlash("<h3>Success. Database Updated</h3>"); if ($post_action == "Save and Return to List") { redirect("admin/list_pages"); } } } }
private function editOrSave() { $validations = array("exists" => array("Slug" => slug(POST("title", "clean")), "Language" => POST("language")), "title" => "required", "content" => "required"); $data = array("ID_User" => SESSION("ZanUserID"), "Slug" => slug(POST("title", "clean")), "Content" => POST("content", "clean"), "Start_Date" => now(4), "Text_Date" => now(2)); $this->data = $this->Data->proccess($data, $validations); if (isset($this->data["error"])) { return $this->data["error"]; } return FALSE; }
public function testUnicodeTransliteration() { $ir = 'Ir Yût, the Deathsinger'; $this->assertEquals('ir-yut-the-deathsinger', slug($ir)); $alzok = 'Alzok Däl, Gornuk Däl, Zyrok Däl'; $this->assertEquals('alzok-dal-gornuk-dal-zyrok-dal', slug($alzok)); $balwur = 'Balwûr'; $this->assertEquals('balwur', slug($balwur)); $primus = 'Primus Ta\'aun'; $this->assertEquals('primus-taaun', slug($primus)); }
function bs_tab_content_func($atts, $content = null) { extract(shortcode_atts(array('title' => 'default', 'active' => false), $atts)); if ($active == true) { $active = " active"; } else { $active = ""; } $tab_content = "<div class='tab-pane" . $active . "' id='" . slug($title) . "'>" . do_shortcode($content) . "</div>"; return $tab_content; }
/** * A test of unicode * * @return void */ public function testUnicodeDuringSlugging() { $ir = 'Ir Yût, the Deathsinger'; $this->assertEquals('ir-yut-the-deathsinger', slug($ir)); $alzok = 'Alzok Däl, Gornuk Däl, Zyrok Däl'; $this->assertEquals('alzok-dal-gornuk-dal-zyrok-dal', slug($alzok)); $balwur = 'Balwûr'; $this->assertEquals('balwur', slug($balwur)); $primus = 'Primus Ta\'aun'; $this->assertEquals('primus-taaun', slug($primus)); $norusk = 'Noru\'usk, Servant of Oryx'; $this->assertEquals('noruusk-servant-of-oryx', slug($norusk)); }
public function getUniqueSlug($name, $page_id = '') { $slugname = slug($name); $q = $this->db->fetchRow("select count(*) as cnt from #__url_alias where `keyword` like '" . $this->db->escape($slugname) . "' and `query` != '" . $this->db->escape($page_id) . "'"); if ($q['cnt']) { $q = $this->db->query("select count(*) as cnt from #__url_alias where `keyword` REGEXP '^" . $this->db->escape($slugname) . "[0-9]*'"); $cnt = $q->row['cnt']; if ($cnt > 0) { $slugname .= "-" . $cnt; } } return $slugname; }
function initialize_page() { $section_id = requestIdParam(); $section = Sections::FindById($section_id); $post_action = ""; if (isset($_POST['submit'])) { $post_action = $_POST['submit']; } if ($post_action == "Edit Section" || $post_action == "Edit and Return to List") { if (isset($_POST['delete'])) { $items = $section->findItems(); $selected_sections = array('1'); foreach ($items as $item) { $item->updateSelectedSections($selected_sections); } $section->delete(true); setFlash("<h3>Section deleted</h3>"); //$main_portlink = ( DISPLAY_ITEMS_AS_LIST ) ? "admin/portfolio_list/alphabetical" : "admin/portfolio_list"; //redirect( $main_portlink ); redirect("admin/portfolio_list"); } else { if (ALLOW_SHORT_PAGE_NAMES) { if ($_POST['name'] == "") { $section->name = slug($_POST['display_name']); } else { $section->name = slug($_POST['name']); } } else { $section->name = slug($_POST['display_name']); } $section->display_name = $_POST['display_name']; $section->template = $_POST['template']; $section->content = $_POST['section_content']; $section->public = isset($_POST['public']) ? 1 : 0; $selected_areas = array(); if (isset($_POST['selected_areas'])) { $selected_areas = $_POST['selected_areas']; } else { $selected_areas = array('2'); } $section->updateSelectedAreas($selected_areas); $section->save(); setFlash("<h3>Section changes saved</h3>"); if ($post_action == "Edit and Return to List") { //$main_portlink = ( DISPLAY_ITEMS_AS_LIST ) ? "admin/portfolio_list/alphabetical" : "admin/portfolio_list"; //redirect( $main_portlink ); redirect("admin/portfolio_list"); } } } }
/** * Register a block for admin home page... * */ function register_admin_block($prop) { global $Cbucket; $blocks = $Cbucket->admin_blocks; if (!$prop['title'] || !$prop['function'] || !function_exists($prop['function'])) { return false; } $slug = slug($prop['title']); if (!$slug) { return false; } $blocks[$slug] = $prop; return $Cbucket->admin_blocks = $blocks; }
private function editOrSave() { if (!POST("title")) { return getAlert("You need to write a title"); } $this->ID = POST("ID_Application"); $this->title = POST("title", "decode", "escape"); $this->slug = slug($this->title); $this->cpanel = POST("cpanel"); $this->adding = POST("adding"); $this->defult = POST("defult"); $this->category = POST("category"); $this->comments = POST("comments"); $this->situation = POST("Situation"); }
function initialize_page() { $post_action = ""; if (isset($_POST['submit'])) { $post_action = $_POST['submit']; } if ($post_action == "Add") { $blog = MyActiveRecord::Create('Blogs'); $blog->name = $_POST['name']; $blog->slug = slug($_POST['name']); $blog->user_id = $_POST['user_id']; $blog->save(); setFlash("<h3>Blog Added</h3>"); } }
function initialize_page() { $post_action = ""; if (isset($_POST['submit'])) { $post_action = $_POST['submit']; } if ($post_action == "Add Gallery") { $gallery = MyActiveRecord::Create('Galleries'); $gallery->name = $_POST['name']; $gallery->slug = slug($_POST['name']); $gallery->save(); setFlash("<h3>Gallery Added</h3>"); redirect("/admin/edit_gallery/" . $gallery->id); } }
public function editar() { $this->form_validation->set_rules('titulo', 'TÍTULO', 'trim|required|ucfirst'); $this->form_validation->set_rules('slug', 'SLUG', 'trim'); $this->form_validation->set_rules('conteudo', 'CONTEÚDO', 'trim|required|htmlentities'); if ($this->form_validation->run() == TRUE) { $dados = elements(array('titulo', 'slug', 'conteudo'), $this->input->post()); $dados['slug'] != '' ? $dados['slug'] = slug($dados['slug']) : ($dados['slug'] = slug($dados['titulo'])); $this->paginas->do_update($dados, array('id' => $this->input->post('idpagina'))); } init_hmtmleditor(); set_tema('titulo', 'Editar página'); set_tema('conteudo', load_modulo('paginas', 'editar')); load_template(); }
public function cadastrar() { $categorias = ''; $this->form_validation->set_rules('nome', 'Nome', 'trim|required'); if ($this->form_validation->run(TRUE)) { $dados = elements(array('nome', 'slug', 'descricao'), $this->input->post()); $dados['slug'] != '' ? $dados['slug'] = slug($dados['slug']) : ($dados['slug'] = slug($dados['nome'])); $this->categorias->do_insert($dados); } //lista os modelos de categorias $query = $this->categorias->get_all()->result(); set_tema('titulo', 'Cadastrar Categoria'); set_tema('footerinc', load_js(array('data-table', 'table')), FALSE); set_tema('conteudo', load_modulo($this->view . 'gerenciar', array('categorias' => $query))); load_template(); }
public function run() { DB::beginTransaction(); $category = new Category(); $category->save(); $category->saveIcon($this->icon); foreach ($this->translations as $fields) { $fields['slug'] = slug($fields['name']); $category->translations()->create($fields); } if (!empty($this->parentId)) { $parent = Category::find($this->parentId); $parent->addChild($category); } DB::commit(); }
function search_prev($text = 'Previous', $default = '') { $per_page = Config::meta('posts_per_page'); $page = Registry::get('page_offset'); $offset = ($page - 1) * $per_page; $total = Registry::get('total_posts'); $pages = ceil($total / $per_page); $search_page = Registry::get('page'); $prev = $page - 1; $term = Registry::get('search_term'); Session::put(slug($term), $term); $url = base_url($search_page->slug . '/' . $term . '/' . $prev); if ($offset > 0) { return '<a href="' . $url . '">' . $text . '</a>'; } return $default; }
public function index() { $folder = FCPATH . $this->photos_path; $headerFolder = FCPATH . $this->photos_path . 'header/'; $thumbFolder = FCPATH . $this->photos_path . 'thumbs/'; $this->load->model('Photo'); $this->load->model('Video'); $photos = $this->Photo->get_all(); $videos = $this->Video->get_all(); foreach ($photos as $i => &$photo) { $oldFilename = $photo->filename; $fileNameParsed = explode('.', $photo->filename); $ext = array_pop($fileNameParsed); $photo->filename = implode('.', [slug(implode('.', $fileNameParsed)), $ext]); if ($oldFilename === $photo->filename) { unset($photos[$i]); continue; } if (!rename($folder . $oldFilename, $folder . $photo->filename) || !rename($headerFolder . $oldFilename, $headerFolder . $photo->filename) || !rename($thumbFolder . $oldFilename, $thumbFolder . $photo->filename)) { unset($photos[$i]); echo "File {$oldFilename} does not exists"; } } foreach ($videos as $i => &$video) { $oldThumbnail = $video->thumbnail; $fileNameParsed = explode('.', $video->thumbnail); $ext = array_pop($fileNameParsed); $video->thumbnail = implode('.', [slug(implode('.', $fileNameParsed)), $ext]); if ($oldThumbnail === $video->thumbnail) { unset($videos[$i]); continue; } if (!rename($headerFolder . $oldThumbnail, $headerFolder . $video->thumbnail) || !rename($thumbFolder . $oldThumbnail, $thumbFolder . $video->thumbnail)) { unset($photos[$i]); echo "File {$oldThumbnail} does not exists"; } } var_dump($photos); var_dump($videos); if (!empty($photos)) { $this->Photo->update_all($photos); } if (!empty($videos)) { $this->Video->update_all($videos); } }