public function getNeighborhood() { $images = FilterImage::all(); $filter = Filter::take(1)->get()[0]; $filters = Filter::all(); return View::make('site.neighborhood', array('images' => $images, 'text' => $filter->text, 'paragraph_title' => $filter->paragraph_title, 'filters' => $filters)); }
public function run() { DB::table('filter_images')->delete(); $success = File::cleanDirectory($this->getImagesPath()); File::put($this->getImagesPath() . '.gitignore', File::get(public_path() . '/../app/storage/cache/.gitignore')); // Create images for all filters. In this phase images for all the filter will be the same $filters = Filter::all(); foreach ($filters as $filter) { FilterImage::create(['filter_id' => $filter->id, 'image_name' => $this->copyImage(public_path() . '/backup_images/filters/gym.jpg')]); // FilterImage::create([ // 'filter_id' => $filter->id, // 'image_name' => $this->copyImage(public_path().'/backup_images/filters/hero.jpg') // ]); // // FilterImage::create([ // 'filter_id' => $filter->id, // 'image_name' => $this->copyImage(public_path().'/backup_images/filters/kitchen.jpg') // ]); // // FilterImage::create([ // 'filter_id' => $filter->id, // 'image_name' => $this->copyImage(public_path().'/backup_images/filters/living.jpg') // ]); } }
/** * Formats setting * * @uses InputFilter::filters * @uses Assets::tabledrag * @uses Config::load * @uses Message::error * @uses Filter::all */ public function action_configure() { $id = $this->request->param('id', NULL); // Get required format $format = $this->_format->get($id); $config = Config::load('inputfilter'); if (is_null($format)) { Log::error('Attempt to access non-existent format id :id', array(':id' => $id)); Message::error(__('Text Format doesn\'t exists!')); $this->request->redirect(Route::get('admin/format')->uri(), 404); } $fallback_format = (int) $config->default_format; $formats = $this->_format->get_all(); $formats[$id]['id'] = $id; $all_roles = ORM::factory('role')->find_all()->as_array('id', 'name'); $filters = Filter::all(); $enabled_filters = $formats[$id]['filters']; // Form attributes $params = array('id' => $id, 'action' => 'configure'); $this->title = __('Configure %name format', array('%name' => $format['name'])); $view = View::factory('admin/format/form')->set('roles', $all_roles)->set('filters', $filters)->set('enabled_filters', $enabled_filters)->set('format', $format)->set('params', $params); if ($this->valid_post('filter')) { unset($_POST['filter'], $_POST['_token'], $_POST['_action']); Message::info(__('Not implemented yet!')); } $this->response->body($view); Assets::tabledrag(); }
/** * Method to run all enabled filters by the format id on given string * * @param object $text The text object to be filtered. * @return string $text The filtered text */ public static function process($text) { $config = Config::load('inputfilter'); if (!array_key_exists($text->format, $config->get('formats')) or !isset($text->format)) { //make sure a valid format id exists, if not set default format id $text->format = (int) $config->get('default_format', 1); } $filters = $config->formats[$text->format]['filters']; $filter_info = Filter::all(); //sort filters by weight $filters = Arr::array_sort($filters, 'weight'); // Give filters the chance to escape HTML-like data such as code or formulas. foreach ($filters as $name => $filter) { $prepare_callback = $filter_info[$name]->prepare_callback; if ($filter['status'] and !empty($prepare_callback)) { $text->text = Filter::execute($prepare_callback, $text->text, $text->format, $filter); } } // Perform filtering foreach ($filters as $name => $filter) { $process_callback = $filter_info[$name]->process_callback; if ($filter['status'] and !empty($process_callback)) { $text->text = Filter::execute($process_callback, $text->text, $text->format, $filter); } } return $text->text; }
/** * Handle submitted settings. * * @return */ public function postIndex() { if (Input::has('api_key_id')) { $api_key_id = Setting::where('key', 'api_key_id')->firstOrFail(); $api_key_id->value = Input::get('api_key_id'); $api_key_id->save(); } if (Input::has('api_key_verification_code')) { $api_key_verification_code = Setting::where('key', 'api_key_verification_code')->firstOrFail(); $api_key_verification_code->value = Input::get('api_key_verification_code'); $api_key_verification_code->save(); } if (Input::has('api_key_character_id')) { $api_key_character_id = Setting::where('key', 'api_key_character_id')->firstOrFail(); $api_key_character_id->value = Input::get('api_key_character_id'); $api_key_character_id->save(); } if (Input::has('home_region_id')) { $home_region_id = Setting::where('key', 'home_region_id')->firstOrFail(); $home_region_id->value = Input::get('home_region_id'); $home_region_id->save(); } if (Input::has('systems')) { // Clean up the input in case the JS screwed up somewhere. $input = preg_replace('/^,|,$/', '', Input::get('systems')); $systems = Setting::where('key', 'systems')->firstOrFail(); $systems->value = $input; $systems->save(); } if (Input::has('alliances')) { // Clean up the input in case the JS screwed up somewhere. $input = preg_replace('/^,|,$/', '', Input::get('alliances')); $alliances = Setting::where('key', 'alliances')->firstOrFail(); $alliances->value = $input; $alliances->save(); // We also need to populate the alliances table with these new alliances. $response = API::eveOnline('eve/AllianceList', 'version=1'); foreach ($response->body->result->rowset->row as $row) { if (strpos($input, (string) $row['allianceID']) !== FALSE) { $alliance = Alliance::find($row['allianceID']); if (!isset($alliance->id)) { $alliance = new Alliance(); $alliance->id = $row['allianceID']; $alliance->allianceName = $row['name']; $alliance->save(); } } } } if (Input::has('shipping_cost')) { $shipping_cost = Setting::where('key', 'shipping_cost')->firstOrFail(); $shipping_cost->value = Input::get('shipping_cost'); $shipping_cost->save(); } // Process default filters. DB::table('filters')->update(array('is_default' => 0)); $filters = Filter::all(); foreach ($filters as $filter) { if (Input::has($filter->categoryName)) { $category = Filter::find($filter->categoryID); $category->is_default = 1; $category->save(); } } return Redirect::to('settings'); }
public function getDutchKillsPage($id = null) { $filters = Filter::all(); $data = array('filters' => $filters); $data['filterImages'] = FilterImage::all(); if ($id) { $filter = Filter::find($id); $data['text'] = $filter->text; $data['paragraph_title'] = $filter->paragraph_title; } else { $data['text'] = ""; $data['paragraph_title'] = ""; } return View::make('admin.dutch-kills', $data); }
public function testAll() { $pass = function () { return TRUE; }; $fail = function () { return FALSE; }; $filter = Filter::all([$pass]); $this->assertTrue($filter(NULL)); $filter = Filter::all([$pass, $fail]); $this->assertFalse($filter(NULL)); }
public function home() { // Retrieve the number of days since tracking began. $earliest_date = DB::select('SELECT killTime FROM kills ORDER BY killTime ASC LIMIT 1'); if (isset($earliest_date[0])) { $days_running = (time() - strtotime($earliest_date[0]->killTime)) / 60 / 60 / 24; } else { $days_running = 1; } // How many items to show per page. $per_page = 30; // Get the page requested. $page = Input::get('page'); if (!isset($page)) { $page = 1; } // Check whether any filters are active. $active_filters = Input::get('filter'); $active_meta_filters = Input::get('meta'); $active_blueprint_filters = Input::get('blueprint'); $whereraw = array(); $filter_url = ''; $search_term = ''; // If a search term was supplied, just use that. if (Input::get('q')) { $search_term = Input::get('q'); $whereraw[] = 'typeName LIKE "%' . $search_term . '%"'; $filter_url .= '&q=' . $search_term; } else { // If no filters are set, apply the default ones. if (!isset($active_filters)) { $active_filters = array(); $default_filters = Filter::where('is_default', 1)->get(); foreach ($default_filters as $default_filter) { array_push($active_filters, $default_filter->categoryName); } } // Check whether a filter on tech/meta level has been applied. if (count($active_meta_filters)) { // Loop through all active filters and construct the aggregate query. foreach ($active_meta_filters as $active_meta_filter) { $meta_filter_raw[] = 'metaGroupName = "' . $active_meta_filter . '"'; } // Bundle up all the filters. $whereraw[] = implode(' or ', $meta_filter_raw); // Make a URL to use in links. $filter_url .= '&meta[]=' . implode('&meta[]=', $active_meta_filters); } // Check whether there are any filters on the existence of blueprints. if (count($active_blueprint_filters)) { // Loop through all active filters and construct the aggregate query. foreach ($active_blueprint_filters as $active_blueprint_filter) { $value = $active_blueprint_filter == 'Yes' ? 1 : 0; $blueprint_filter_raw[] = 'allowManufacture = ' . $value; } // Bundle up all the filters. $whereraw[] = implode(' or ', $blueprint_filter_raw); // Make a URL to use in links. $filter_url .= '&blueprint[]=' . implode('&blueprint[]=', $active_blueprint_filters); } if (count($active_filters)) { // Loop through all active filters and construct the aggregate query. foreach ($active_filters as $active_filter) { $active_filter_raw[] = 'categoryName = "' . $active_filter . '"'; } // Bundle up all the filters. $whereraw[] = implode(' or ', $active_filter_raw); // Make a URL to use in links. $filter_url .= '&filter[]=' . implode('&filter[]=', $active_filters); } } // Query the database for the chosen items. $items = Item::selectedItems($page, $whereraw, $per_page); // Load the template to display all the items. return View::make('home')->with('items', $items)->with('days_running', $days_running)->with('page', $page)->with('filter_url', $filter_url)->with('pages', Item::getRowCount($whereraw) / $per_page)->nest('sidebar', 'filters', array('filters' => Filter::all()->sortBy('categoryName'), 'meta_filters' => array('Meta 0', 'Meta 1', 'Meta 2', 'Meta 3', 'Meta 4', 'Meta 5', 'Tech II'), 'active_filters' => $active_filters, 'active_meta_filters' => $active_meta_filters, 'active_blueprint_filters' => $active_blueprint_filters, 'search_term' => $search_term)); }