public static function keywords($str, $limit_chars = 255) { $clean_str = preg_replace('/[^\\p{L}\\p{M}\\p{Z}\\p{S}\\p{N}\\p{C}\\s]{1,}/', '', $str); $clean_str = trim(preg_replace('/\\s{2,}/', ' ', $clean_str)); $words = explode(' ', $clean_str); foreach ($words as $key => $word) { if (in_array($word, self::$stop_words) === TRUE || in_array(mb_strtolower($word), self::$stop_words)) { unset($words[$key]); } } // Limit to 255 characters total and preserve words $clean_str = text::limit_chars(implode(', ', $words), $limit_chars, '', TRUE); // Get rid of any trailing comma that may have been left behind from text::limit_chars $clean_str = preg_replace('/,$/', '', $clean_str); // Remove the extra spaces introduced on explode above and return the cleaned string return str_replace(' ', '', $clean_str); }
/** * Benchmark times and memory usage from the Benchmark library. * * @return void */ public function database() { $queries = Postgres_Lite::$benchmarks; $total_time = $total_rows = 0; $table = array(); $table[] = array('SQL Statement', 'Time', 'Rows'); foreach ($queries as $query) { if (mb_strlen($query['query']) < 2048) { $table[] = array(str_replace("\n", ' ', $query['query']), number_format($query['time'], 3), $query['rows']); $total_time += $query['time']; $total_rows += $query['rows']; } else { $table[] = array(str_replace("\n", ' ', text::limit_chars($query['query'], 2036, ' [TRUNCATED]')), number_format($query['time'], 3), $query['rows']); $total_time += $query['time']; $total_rows += $query['rows']; } } $this->fb(array(count($queries) . ' SQL queries took ' . number_format($total_time, 3) . ' seconds and returned ' . $total_rows . ' rows', $table), FirePHP::TABLE); }
if ($total_items == 0) { ?> <tr> <td colspan="4" class="col"> <h3><?php echo Kohana::lang('ui_main.no_results'); ?> </h3> </td> </tr> <?php } foreach ($incidents as $incident) { $incident_id = $incident->id; $incident_title = strip_tags($incident->incident_title); $incident_description = text::limit_chars(strip_tags($incident->incident_description), 150, "...", true); $incident_date = $incident->incident_date; $incident_date = date('Y-m-d', strtotime($incident->incident_date)); $incident_mode = $incident->incident_mode; // Mode of submission... WEB/SMS/EMAIL? //XXX incident_Mode will be discontinued in favour of $service_id if ($incident_mode == 1) { $submit_mode = "WEB"; // Who submitted the report? if ($incident->incident_person->id) { // Report was submitted by a visitor $submit_by = $incident->incident_person->person_first . " " . $incident->incident_person->person_last; } else { if ($incident->user_id) { $submit_by = $incident->user->name; } else {
<a href="#filter" data-filter=".Dec">Dec</a> --> </span> </p> <div class="polaroids"> <?php if ($total_items == 0) { ?> <p><?php echo Kohana::lang('ui_main.no_reports'); ?> </p> <?php } foreach ($incidents as $incident) { $incident_id = $incident->id; $incident_title = text::limit_chars($incident->incident_title, 20, '...', False); $incident_date = $incident->incident_date; $incident_date = date('l j F Y', strtotime($incident->incident_date)); $incident_month = date('M', strtotime($incident->incident_date)); $incident_location = $incident->location->location_name; $incident_lat = $incident->location->latitude; $incident_lon = $incident->location->longitude; $incident_category = $incident->incident_category; ?> <?php $isotope_js_filters = $incident_month; foreach ($incident_category as $category) { // don't show hidden categoies if ($category->category->category_visible == 0) { continue;
</div> <?php if ($reports_total == 0) { ?> <div class="post"> <h3><?php echo Kohana::lang('ui_main.no_results'); ?> </h3> </div> <?php } foreach ($incidents as $incident) { $incident_id = $incident->id; $incident_title = $incident->incident_title; $incident_description = text::limit_chars($incident->incident_description, 150, '...'); $incident_date = $incident->incident_date; $incident_date = date('g:i A', strtotime($incident->incident_date)); $incident_mode = $incident->incident_mode; // Mode of submission... WEB/SMS/EMAIL? if ($incident_mode == 1) { $submit_mode = "mail"; } elseif ($incident_mode == 2) { $submit_mode = "sms"; } elseif ($incident_mode == 3) { $submit_mode = "mail"; } elseif ($incident_mode == 4) { $submit_mode = "twitter"; } // Incident Status $incident_approved = $incident->incident_active;
<tr> <td colspan="4" class="col"> <h3><?php echo Kohana::lang('ui_main.no_results'); ?> </h3> </td> </tr> <?php } foreach ($pages as $page) { $page_id = $page->id; $page_title = $page->page_title; $page_tab = $page->page_tab; $page_description = $page->page_description; $page_description_short = strip_tags(text::limit_chars($page_description, "100", "...")); $page_active = $page->page_active; ?> <tr> <td class="col-1"> </td> <td class="col-2"> <div class="post"> <h4><?php echo $page_title; ?> </h4> <p><?php echo $page_description_short; ?> </p> </div>
// Incident Status $incident_approved = $incident->incident_active; $incident_verified = $incident->incident_verified; // Get Edit Log $edit_count = $incident_orm->verify->count(); $edit_css = $edit_count == 0 ? "post-edit-log-gray" : "post-edit-log-blue"; $edit_log = "<div class=\"" . $edit_css . "\">" . "<a href=\"javascript:showLog('edit_log_" . $incident_id . "')\">" . Kohana::lang('ui_admin.edit_log') . ":</a> (" . $edit_count . ")</div>" . "<div id=\"edit_log_" . $incident_id . "\" class=\"post-edit-log\"><ul>"; foreach ($incident_orm->verify as $verify) { $edit_log .= "<li>" . Kohana::lang('ui_admin.edited_by') . " " . $verify->user->name . " : " . $verify->verified_date . "</li>"; } $edit_log .= "</ul></div>"; // Get Any Translations $i = 1; $incident_translation = "<div class=\"post-trans-new\">" . "<a href=\"" . url::base() . 'admin/reports/translate/?iid=' . $incident_id . "\">" . strtoupper(Kohana::lang('ui_main.add_translation')) . ":</a></div>"; foreach ($incident_orm->incident_lang as $translation) { $incident_translation .= "<div class=\"post-trans\">" . Kohana::lang('ui_main.translation') . $i . ": " . "<a href=\"" . url::base() . 'admin/reports/translate/' . $translation->id . '/?iid=' . $incident_id . "\">" . text::limit_chars($translation->incident_title, 150, "...", TRUE) . "</a>" . "</div>"; } ?> <tr> <td class="col-1"> <input name="incident_id[]" id="incident" value="<?php echo $incident_id; ?> " type="checkbox" class="check-box"/> </td> <td class="col-2"> <div class="post"> <h4> <a href="<?php echo url::site() . 'admin/reports/edit/' . $incident_id; ?>
"> <?php echo $item->thumb_img(array("class" => "g-thumbnail")); ?> <p> <span class="<?php echo $item_class; ?> "></span> <?php echo html::purify(text::limit_chars($item->title, 32, "…")); ?> </p> <div> <?php echo nl2br(html::purify(text::limit_chars($item->description, 64, "…"))); ?> </div> </a> </li> <?php } ?> </ul> <?php echo $theme->paginator(); ?> <?php } else { ?>
<?php } else { ?> <?php if ($theme->tag()) { ?> <?php echo t("Photos tagged with %tag_title", array("tag_title" => $theme->tag()->name)); ?> <?php } else { /* Not an item, not a tag, no page_title specified. Help! */ ?> <?php echo html::purify(text::limit_chars(item::root()->title, 40)); ?> <?php } ?> <?php } ?> </div> <?php } ?> <div class="rNavBar"> <button class="ui-button ui-button-text-only ui-widget ui-state-default ui-corner-all" onclick="$('#g-header').slideToggle('normal', function(){$('#g-header').is(':hidden') ? $('#sidebarButton').text('Show Options') : $('#sidebarButton').text('Hide Options')});"> <span class="ui-button-text">Show Options</span> </button> </div>
<h3><?php echo Kohana::lang('ui_main.no_results'); ?> </h3> </td> </tr> <?php } foreach ($checkins as $checkin) { $checkin_id = $checkin->id; $incident_id = $checkin->incident_id; $location = $checkin->location->location_name; $latitude = $checkin->location->latitude; $longitude = $checkin->location->longitude; $description = $checkin->checkin_description; $preview = text::limit_chars(strip_tags($description), 150, "...", true); $checkin_date = date('Y-m-d h:i', strtotime($checkin->checkin_date)); $auto_checkin = $checkin->checkin_auto ? "YES" : "NO"; ?> <tr> <td class="col-1"><input name="checkin_id[]" id="checkin" value="<?php echo $checkin_id; ?> " type="checkbox" class="check-box"/></td> <td class="col-2"> <div class="post"> <p><?php echo $preview; ?> </p> <p><a href="javascript:showCheckin('checkin_preview_<?php
/** * Edit a report * @param bool|int $id The id no. of the report * @param bool|string $saved */ public function edit($id = FALSE, $saved = FALSE) { $db = new Database(); $this->template->content = new View('members/reports_edit'); $this->template->content->title = Kohana::lang('ui_admin.create_report'); // setup and initialize form field names $form = array('location_id' => '', 'form_id' => '', 'locale' => '', 'incident_title' => '', 'incident_description' => '', 'incident_date' => '', 'incident_hour' => '', 'incident_minute' => '', 'incident_ampm' => '', 'latitude' => '', 'longitude' => '', 'geometry' => array(), 'location_name' => '', 'country_id' => '', 'country_name' => '', 'incident_category' => array(), 'incident_news' => array(), 'incident_video' => array(), 'incident_photo' => array(), 'person_first' => '', 'person_last' => '', 'person_email' => '', 'custom_field' => array(), 'incident_zoom' => '', 'incident_source' => '', 'incident_information' => ''); // copy the form as errors, so the errors will be stored with keys corresponding to the form field names $errors = $form; $form_error = FALSE; $form_saved = $saved == 'saved'; // Initialize Default Values $form['locale'] = Kohana::config('locale.language'); //$form['latitude'] = Kohana::config('settings.default_lat'); //$form['longitude'] = Kohana::config('settings.default_lon'); $form['country_id'] = Kohana::config('settings.default_country'); $form['incident_date'] = date("m/d/Y", time()); $form['incident_hour'] = date('h'); $form['incident_minute'] = date('i'); $form['incident_ampm'] = date('a'); // initialize custom field array $form['custom_field'] = customforms::get_custom_form_fields($id, '', TRUE); // Locale (Language) Array $this->template->content->locale_array = Kohana::config('locale.all_languages'); // Create Categories $this->template->content->categories = Category_Model::get_categories(); // Time formatting $this->template->content->hour_array = $this->_hour_array(); $this->template->content->minute_array = $this->_minute_array(); $this->template->content->ampm_array = $this->_ampm_array(); $this->template->content->stroke_width_array = $this->_stroke_width_array(); // Get Countries $countries = array(); foreach (ORM::factory('country')->orderby('country')->find_all() as $country) { // Create a list of all categories $this_country = $country->country; if (strlen($this_country) > 35) { $this_country = substr($this_country, 0, 35) . "..."; } $countries[$country->id] = $this_country; } $this->template->content->countries = $countries; // Initialize Default Value for Hidden Field Country Name, just incase Reverse Geo coding yields no result $form['country_name'] = $countries[$form['country_id']]; //GET custom forms $forms = array(); foreach (ORM::factory('form')->where('form_active', 1)->find_all() as $custom_forms) { $forms[$custom_forms->id] = $custom_forms->form_title; } $this->template->content->forms = $forms; // Retrieve thumbnail photos (if edit); //XXX: fix _get_thumbnails $this->template->content->incident = $this->_get_thumbnails($id); // Are we creating this report from a Checkin? if (isset($_GET['cid']) and !empty($_GET['cid'])) { $checkin_id = (int) $_GET['cid']; $checkin = ORM::factory('checkin', $checkin_id); if ($checkin->loaded) { // Has a report already been created for this Checkin? if ((int) $checkin->incident_id > 0) { // Redirect to report url::redirect('members/reports/edit/' . $checkin->incident_id); } $incident_description = $checkin->checkin_description; $incident_title = text::limit_chars(strip_tags($incident_description), 100, "...", true); $form['incident_title'] = $incident_title; $form['incident_description'] = $incident_description; $form['incident_date'] = date('m/d/Y', strtotime($checkin->checkin_date)); $form['incident_hour'] = date('h', strtotime($checkin->checkin_date)); $form['incident_minute'] = date('i', strtotime($checkin->checkin_date)); $form['incident_ampm'] = date('a', strtotime($checkin->checkin_date)); // Does the sender of this message have a location? if ($checkin->location->loaded) { $form['location_id'] = $checkin->location_id; $form['latitude'] = $checkin->location->latitude; $form['longitude'] = $checkin->location->longitude; $form['location_name'] = $checkin->location->location_name; } } } // check, has the form been submitted, if so, setup validation if ($_POST) { // Instantiate Validation, use $post, so we don't overwrite $_POST fields with our own things $post = array_merge($_POST, $_FILES); if (reports::validate($post)) { // STEP 1: SAVE LOCATION $location = new Location_Model(); reports::save_location($post, $location); // STEP 2: SAVE INCIDENT $incident = new Incident_Model(); reports::save_report($post, $incident, $location->id); // STEP 2b: SAVE INCIDENT GEOMETRIES reports::save_report_geometry($post, $incident); // STEP 3: SAVE CATEGORIES reports::save_category($post, $incident); // STEP 4: SAVE MEDIA reports::save_media($post, $incident); // STEP 5: SAVE CUSTOM FORM FIELDS reports::save_custom_fields($post, $incident); // STEP 6: SAVE PERSONAL INFORMATION reports::save_personal_info($post, $incident); // If creating a report from a checkin if (isset($checkin_id) and $checkin_id != "") { $checkin = ORM::factory('checkin', $checkin_id); if ($checkin->loaded) { $checkin->incident_id = $incident->id; $checkin->save(); // Attach all the media items in this checkin to the report foreach ($checkin->media as $media) { $media->incident_id = $incident->id; $media->save(); } } } // Action::report_add / report_submit_members - Added a New Report //++ Do we need two events for this? Or will one suffice? //Event::run('ushahidi_action.report_add', $incident); Event::run('ushahidi_action.report_submit_members', $post); // SAVE AND CLOSE? if ($post->save == 1) { // Save but don't close url::redirect('members/reports/edit/' . $incident->id . '/saved'); } else { // Save and close url::redirect('members/reports/'); } } else { // repopulate the form fields $form = arr::overwrite($form, $post->as_array()); // populate the error fields, if any $errors = arr::overwrite($errors, $post->errors('report')); $form_error = TRUE; } } else { if ($id) { // Retrieve Current Incident $incident = ORM::factory('incident')->where('user_id', $this->user->id)->find($id); if ($incident->loaded == true) { // Retrieve Categories $incident_category = array(); foreach ($incident->incident_category as $category) { $incident_category[] = $category->category_id; } // Retrieve Media $incident_news = array(); $incident_video = array(); $incident_photo = array(); foreach ($incident->media as $media) { if ($media->media_type == 4) { $incident_news[] = $media->media_link; } elseif ($media->media_type == 2) { $incident_video[] = $media->media_link; } elseif ($media->media_type == 1) { $incident_photo[] = $media->media_link; } } // Get Geometries via SQL query as ORM can't handle Spatial Data $sql = "SELECT AsText(geometry) as geometry, geometry_label, \n\t\t\t\t\t\tgeometry_comment, geometry_color, geometry_strokewidth \n\t\t\t\t\t\tFROM " . Kohana::config('database.default.table_prefix') . "geometry \n\t\t\t\t\t\tWHERE incident_id=" . $id; $query = $db->query($sql); foreach ($query as $item) { $geometry = array("geometry" => $item->geometry, "label" => $item->geometry_label, "comment" => $item->geometry_comment, "color" => $item->geometry_color, "strokewidth" => $item->geometry_strokewidth); $form['geometry'][] = json_encode($geometry); } // Combine Everything $incident_arr = array('location_id' => $incident->location->id, 'form_id' => $incident->form_id, 'locale' => $incident->locale, 'incident_title' => $incident->incident_title, 'incident_description' => $incident->incident_description, 'incident_date' => date('m/d/Y', strtotime($incident->incident_date)), 'incident_hour' => date('h', strtotime($incident->incident_date)), 'incident_minute' => date('i', strtotime($incident->incident_date)), 'incident_ampm' => date('a', strtotime($incident->incident_date)), 'latitude' => $incident->location->latitude, 'longitude' => $incident->location->longitude, 'location_name' => $incident->location->location_name, 'country_id' => $incident->location->country_id, 'incident_category' => $incident_category, 'incident_news' => $incident_news, 'incident_video' => $incident_video, 'incident_photo' => $incident_photo, 'person_first' => $incident->incident_person->person_first, 'person_last' => $incident->incident_person->person_last, 'person_email' => $incident->incident_person->person_email, 'incident_source' => '', 'incident_information' => '', 'custom_field' => customforms::get_custom_form_fields($id, $incident->form_id, TRUE), 'incident_zoom' => $incident->incident_zoom); // Merge To Form Array For Display $form = arr::overwrite($form, $incident_arr); } else { // Redirect url::redirect('members/reports/'); } } } $this->template->content->id = $id; $this->template->content->form = $form; $this->template->content->errors = $errors; $this->template->content->form_error = $form_error; $this->template->content->form_saved = $form_saved; // Retrieve Custom Form Fields Structure $disp_custom_fields = customforms::get_custom_form_fields($id, $form['form_id'], FALSE); $this->template->content->disp_custom_fields = $disp_custom_fields; // Retrieve Previous & Next Records $previous = ORM::factory('incident')->where('id < ', $id)->orderby('id', 'desc')->find(); $previous_url = $previous->loaded ? url::base() . 'members/reports/edit/' . $previous->id : url::base() . 'members/reports/'; $next = ORM::factory('incident')->where('id > ', $id)->orderby('id', 'desc')->find(); $next_url = $next->loaded ? url::base() . 'members/reports/edit/' . $next->id : url::base() . 'members/reports/'; $this->template->content->previous_url = $previous_url; $this->template->content->next_url = $next_url; // Javascript Header $this->template->map_enabled = TRUE; $this->template->colorpicker_enabled = TRUE; $this->template->treeview_enabled = TRUE; $this->template->json2_enabled = TRUE; $this->template->js = new View('reports_submit_edit_js'); $this->template->js->edit_mode = FALSE; $this->template->js->default_map = Kohana::config('settings.default_map'); $this->template->js->default_zoom = Kohana::config('settings.default_zoom'); if (!$form['latitude'] or !$form['latitude']) { $this->template->js->latitude = Kohana::config('settings.default_lat'); $this->template->js->longitude = Kohana::config('settings.default_lon'); } else { $this->template->js->latitude = $form['latitude']; $this->template->js->longitude = $form['longitude']; } $this->template->js->incident_zoom = $form['incident_zoom']; $this->template->js->geometries = $form['geometry']; // Inline Javascript $this->template->content->date_picker_js = $this->_date_picker_js(); $this->template->content->color_picker_js = $this->_color_picker_js(); // Pack Javascript $myPacker = new javascriptpacker($this->template->js, 'Normal', FALSE, FALSE); $this->template->js = $myPacker->pack(); }
/** * Edit a report * @param bool|int $id The id no. of the report * @param bool|string $saved */ function edit($id = false, $saved = false) { $db = new Database(); $this->template->content = new View('members/reports_edit'); $this->template->content->title = Kohana::lang('ui_admin.create_report'); // setup and initialize form field names $form = array('location_id' => '', 'form_id' => '', 'locale' => '', 'incident_title' => '', 'incident_description' => '', 'incident_date' => '', 'incident_hour' => '', 'incident_minute' => '', 'incident_ampm' => '', 'latitude' => '', 'longitude' => '', 'geometry' => array(), 'location_name' => '', 'country_id' => '', 'incident_category' => array(), 'incident_news' => array(), 'incident_video' => array(), 'incident_photo' => array(), 'person_first' => '', 'person_last' => '', 'person_email' => '', 'custom_field' => array(), 'incident_source' => '', 'incident_information' => '', 'incident_zoom' => ''); // copy the form as errors, so the errors will be stored with keys corresponding to the form field names $errors = $form; $form_error = FALSE; if ($saved == 'saved') { $form_saved = TRUE; } else { $form_saved = FALSE; } // Initialize Default Values $form['locale'] = Kohana::config('locale.language'); //$form['latitude'] = Kohana::config('settings.default_lat'); //$form['longitude'] = Kohana::config('settings.default_lon'); $form['country_id'] = Kohana::config('settings.default_country'); $form['incident_date'] = date("m/d/Y", time()); $form['incident_hour'] = date('h'); $form['incident_minute'] = date('i'); $form['incident_ampm'] = date('a'); // initialize custom field array $form['custom_field'] = $this->_get_custom_form_fields($id, '', true); // Locale (Language) Array $this->template->content->locale_array = Kohana::config('locale.all_languages'); // Create Categories $this->template->content->categories = $this->_get_categories(); // Time formatting $this->template->content->hour_array = $this->_hour_array(); $this->template->content->minute_array = $this->_minute_array(); $this->template->content->ampm_array = $this->_ampm_array(); $this->template->content->stroke_width_array = $this->_stroke_width_array(); // Get Countries $countries = array(); foreach (ORM::factory('country')->orderby('country')->find_all() as $country) { // Create a list of all categories $this_country = $country->country; if (strlen($this_country) > 35) { $this_country = substr($this_country, 0, 35) . "..."; } $countries[$country->id] = $this_country; } $this->template->content->countries = $countries; //GET custom forms $forms = array(); foreach (ORM::factory('form')->where('form_active', 1)->find_all() as $custom_forms) { $forms[$custom_forms->id] = $custom_forms->form_title; } $this->template->content->forms = $forms; // Retrieve thumbnail photos (if edit); //XXX: fix _get_thumbnails $this->template->content->incident = $this->_get_thumbnails($id); // Are we creating this report from a Checkin? if (isset($_GET['cid']) && !empty($_GET['cid'])) { $checkin_id = (int) $_GET['cid']; $checkin = ORM::factory('checkin', $checkin_id); if ($checkin->loaded) { // Has a report already been created for this Checkin? if ((int) $checkin->incident_id > 0) { // Redirect to report url::redirect('members/reports/edit/' . $checkin->incident_id); } $incident_description = $checkin->checkin_description; $incident_title = text::limit_chars(strip_tags($incident_description), 100, "...", true); $form['incident_title'] = $incident_title; $form['incident_description'] = $incident_description; $form['incident_date'] = date('m/d/Y', strtotime($checkin->checkin_date)); $form['incident_hour'] = date('h', strtotime($checkin->checkin_date)); $form['incident_minute'] = date('i', strtotime($checkin->checkin_date)); $form['incident_ampm'] = date('a', strtotime($checkin->checkin_date)); // Does the sender of this message have a location? if ($checkin->location->loaded) { $form['location_id'] = $checkin->location_id; $form['latitude'] = $checkin->location->latitude; $form['longitude'] = $checkin->location->longitude; $form['location_name'] = $checkin->location->location_name; } } } // check, has the form been submitted, if so, setup validation if ($_POST) { // Instantiate Validation, use $post, so we don't overwrite $_POST fields with our own things $post = Validation::factory(array_merge($_POST, $_FILES)); // Add some filters $post->pre_filter('trim', TRUE); // Add some rules, the input field, followed by a list of checks, carried out in order // $post->add_rules('locale','required','alpha_dash','length[5]'); $post->add_rules('location_id', 'numeric'); $post->add_rules('message_id', 'numeric'); $post->add_rules('incident_title', 'required', 'length[3,200]'); $post->add_rules('incident_description', 'required'); $post->add_rules('incident_date', 'required', 'date_mmddyyyy'); $post->add_rules('incident_hour', 'required', 'between[1,12]'); $post->add_rules('incident_minute', 'required', 'between[0,59]'); if ($_POST['incident_ampm'] != "am" && $_POST['incident_ampm'] != "pm") { $post->add_error('incident_ampm', 'values'); } $post->add_rules('latitude', 'required', 'between[-90,90]'); // Validate for maximum and minimum latitude values $post->add_rules('longitude', 'required', 'between[-180,180]'); // Validate for maximum and minimum longitude values $post->add_rules('location_name', 'required', 'length[3,200]'); //XXX: Hack to validate for no checkboxes checked if (!isset($_POST['incident_category'])) { $post->incident_category = ""; $post->add_error('incident_category', 'required'); } else { $post->add_rules('incident_category.*', 'required', 'numeric'); } // Validate only the fields that are filled in if (!empty($_POST['incident_news'])) { foreach ($_POST['incident_news'] as $key => $url) { if (!empty($url) and !(bool) filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED)) { $post->add_error('incident_news', 'url'); } } } // Validate only the fields that are filled in if (!empty($_POST['incident_video'])) { foreach ($_POST['incident_video'] as $key => $url) { if (!empty($url) and !(bool) filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED)) { $post->add_error('incident_video', 'url'); } } } // Validate photo uploads $post->add_rules('incident_photo', 'upload::valid', 'upload::type[gif,jpg,png]', 'upload::size[2M]'); // Validate Personal Information if (!empty($_POST['person_first'])) { $post->add_rules('person_first', 'length[3,100]'); } if (!empty($_POST['person_last'])) { $post->add_rules('person_last', 'length[3,100]'); } if (!empty($_POST['person_email'])) { $post->add_rules('person_email', 'email', 'length[3,100]'); } // Validate Custom Fields if (isset($post->custom_field) && !$this->_validate_custom_form_fields($post->custom_field)) { $post->add_error('custom_field', 'values'); } $post->add_rules('incident_source', 'numeric', 'length[1,1]'); $post->add_rules('incident_information', 'numeric', 'length[1,1]'); // Test to see if things passed the rule checks if ($post->validate()) { // STEP 1: SAVE LOCATION $location = new Location_Model(); reports::save_location($post, $location); // STEP 2: SAVE INCIDENT $incident = new Incident_Model(); reports::save_report($post, $incident, $location->id); // STEP 3: SAVE CATEGORIES reports::save_category($post, $incident); // STEP 4: SAVE MEDIA reports::save_media($post, $incident); // STEP 5: SAVE CUSTOM FORM FIELDS reports::save_custom_fields($post, $incident); // STEP 6: SAVE PERSONAL INFORMATION reports::save_personal_info($post, $incident); // If creating a report from a checkin if (isset($checkin_id) and $checkin_id != "") { $checkin = ORM::factory('checkin', $checkin_id); if ($checkin->loaded) { $checkin->incident_id = $incident->id; $checkin->save(); // Attach all the media items in this checkin to the report foreach ($checkin->media as $media) { $media->incident_id = $incident->id; $media->save(); } } } // Action::report_add / report_submit_members - Added a New Report //++ Do we need two events for this? Or will one suffice? Event::run('ushahidi_action.report_add', $incident); Event::run('ushahidi_action.report_submit_members', $post); // SAVE AND CLOSE? if ($post->save == 1) { url::redirect('members/reports/edit/' . $incident->id . '/saved'); } else { url::redirect('members/reports/'); } } else { // repopulate the form fields $form = arr::overwrite($form, $post->as_array()); // populate the error fields, if any $errors = arr::overwrite($errors, $post->errors('report')); $form_error = TRUE; } } else { if ($id) { // Retrieve Current Incident $incident = ORM::factory('incident')->where('user_id', $this->user->id)->find($id); if ($incident->loaded == true) { // Retrieve Categories $incident_category = array(); foreach ($incident->incident_category as $category) { $incident_category[] = $category->category_id; } // Retrieve Media $incident_news = array(); $incident_video = array(); $incident_photo = array(); foreach ($incident->media as $media) { if ($media->media_type == 4) { $incident_news[] = $media->media_link; } elseif ($media->media_type == 2) { $incident_video[] = $media->media_link; } elseif ($media->media_type == 1) { $incident_photo[] = $media->media_link; } } // Get Geometries via SQL query as ORM can't handle Spatial Data $sql = "SELECT AsText(geometry) as geometry, geometry_label, \n\t\t\t\t\t\tgeometry_comment, geometry_color, geometry_strokewidth \n\t\t\t\t\t\tFROM " . Kohana::config('database.default.table_prefix') . "geometry \n\t\t\t\t\t\tWHERE incident_id=" . $id; $query = $db->query($sql); foreach ($query as $item) { $geometry = array("geometry" => $item->geometry, "label" => $item->geometry_label, "comment" => $item->geometry_comment, "color" => $item->geometry_color, "strokewidth" => $item->geometry_strokewidth); $form['geometry'][] = json_encode($geometry); } // Combine Everything $incident_arr = array('location_id' => $incident->location->id, 'form_id' => $incident->form_id, 'locale' => $incident->locale, 'incident_title' => $incident->incident_title, 'incident_description' => $incident->incident_description, 'incident_date' => date('m/d/Y', strtotime($incident->incident_date)), 'incident_hour' => date('h', strtotime($incident->incident_date)), 'incident_minute' => date('i', strtotime($incident->incident_date)), 'incident_ampm' => date('a', strtotime($incident->incident_date)), 'latitude' => $incident->location->latitude, 'longitude' => $incident->location->longitude, 'location_name' => $incident->location->location_name, 'country_id' => $incident->location->country_id, 'incident_category' => $incident_category, 'incident_news' => $incident_news, 'incident_video' => $incident_video, 'incident_photo' => $incident_photo, 'person_first' => $incident->incident_person->person_first, 'person_last' => $incident->incident_person->person_last, 'person_email' => $incident->incident_person->person_email, 'custom_field' => $this->_get_custom_form_fields($id, $incident->form_id, true), 'incident_source' => $incident->incident_source, 'incident_information' => $incident->incident_information, 'incident_zoom' => $incident->incident_zoom); // Merge To Form Array For Display $form = arr::overwrite($form, $incident_arr); } else { // Redirect url::redirect('members/reports/'); } } } $this->template->content->id = $id; $this->template->content->form = $form; $this->template->content->errors = $errors; $this->template->content->form_error = $form_error; $this->template->content->form_saved = $form_saved; // Retrieve Custom Form Fields Structure $disp_custom_fields = $this->_get_custom_form_fields($id, $form['form_id'], false); $this->template->content->disp_custom_fields = $disp_custom_fields; // Retrieve Previous & Next Records $previous = ORM::factory('incident')->where('id < ', $id)->orderby('id', 'desc')->find(); $previous_url = $previous->loaded ? url::base() . 'members/reports/edit/' . $previous->id : url::base() . 'members/reports/'; $next = ORM::factory('incident')->where('id > ', $id)->orderby('id', 'desc')->find(); $next_url = $next->loaded ? url::base() . 'members/reports/edit/' . $next->id : url::base() . 'members/reports/'; $this->template->content->previous_url = $previous_url; $this->template->content->next_url = $next_url; // Javascript Header $this->template->map_enabled = TRUE; $this->template->colorpicker_enabled = TRUE; $this->template->treeview_enabled = TRUE; $this->template->json2_enabled = TRUE; $this->template->js = new View('admin/reports_edit_js'); $this->template->js->default_map = Kohana::config('settings.default_map'); $this->template->js->default_zoom = Kohana::config('settings.default_zoom'); if (!$form['latitude'] || !$form['latitude']) { $this->template->js->latitude = Kohana::config('settings.default_lat'); $this->template->js->longitude = Kohana::config('settings.default_lon'); } else { $this->template->js->latitude = $form['latitude']; $this->template->js->longitude = $form['longitude']; } $this->template->js->incident_zoom = $form['incident_zoom']; $this->template->js->geometries = $form['geometry']; // Inline Javascript $this->template->content->date_picker_js = $this->_date_picker_js(); $this->template->content->color_picker_js = $this->_color_picker_js(); // Pack Javascript $myPacker = new javascriptpacker($this->template->js, 'Normal', false, false); $this->template->js = $myPacker->pack(); }
</a> </li> <?php $i++; ?> <?php } ?> <li class="g-active<?php if ($i == 0) { print " g-first"; } ?> "> <?php echo html::purify(text::limit_chars($theme->item()->title, module::get_var("gallery", "visible_title_length"))); ?> </li> </ul> <?php } ?> </div> <div id="bd"> <div id="yui-main"> <div class="yui-b"> <div id="g-content" class="yui-g"> <?php echo $theme->messages(); ?> <?php
?> <?php echo $breadcrumb->first ? "g-first" : ""; ?> "> <?php if (!$breadcrumb->last) { ?> <a href="<?php echo $breadcrumb->url; ?> "><?php } ?> <?php echo html::purify(text::limit_chars($breadcrumb->title, module::get_var("gallery", "visible_title_length"))); ?> <?php if (!$breadcrumb->last) { ?> </a><?php } ?> </li> <?php } ?> </ul> <?php } ?>
<h3>Related Mainstream News of Incident</h3> <div class="block-bg"> <div class="block-top"> <div class="block-bottom"> <ul> <li> <ul class="title"> <li class="w-01">TITLE</li> <li class="w-02">SOURCE</li> <li class="w-03">DATE</li> </ul> </li> <?php foreach ($feeds as $feed) { $feed_id = $feed->id; $feed_title = text::limit_chars($feed->item_title, 40, '...', True); $feed_link = $feed->item_link; $feed_date = date('M j Y', strtotime($feed->item_date)); $feed_source = "NEWS"; ?> <li> <ul> <li class="w-01"> <a href="<?php echo $feed_link; ?> " target="_blank"> <?php echo $feed_title; ?> </a></li>
<tr> <td colspan="4" class="col"> <h3><?php echo Kohana::lang('ui_main.no_results'); ?> </h3> </td> </tr> <?php } foreach ($pages as $page) { $page_id = $page->id; $page_title = $page->page_title; $page_tab = $page->page_tab; $page_description = htmlspecialchars_decode($page->page_description); $page_description_short = text::limit_chars(strip_tags($page_description), "100", "..."); $page_active = $page->page_active; ?> <tr> <td class="col-1"> </td> <td class="col-2"> <div class="post"> <h4><?php echo $page_title; ?> </h4> <p><?php echo $page_description_short; ?> </p> </div>
protected function attach_associated_file($field, $file, $type) { switch ($type) { case 'upload': case 'stash': $path = $file['tmp_name']; $name = $file['name']; break; case 'copy': case 'move': $path = $file; $name = $file; break; default: throw new Kohana_User_Exception('!!!', ''); } // Get original filename and extension $pathinfo = pathinfo($name) + array('extension' => NULL); // Limit filename and sanatise $filename = text::limit_chars($pathinfo['filename'], 15, ''); $filename = url::title($filename, '_'); // Sanatise extension $extension = trim(preg_replace('#[^a-z0-9]#', '', strtolower($pathinfo['extension']))); $directory = $this->associated_files_path(); // Check that the directory exists, create it if not if (!is_dir($directory)) { mkdir($directory, 0777, TRUE); } // Check it's writable if (!is_writable($directory)) { throw new Kohana_Exception('upload.not_writable', $directory); } $prefix = $directory . $this->object[$this->primary_key] . '-' . $field . '-'; $name = time() . '-' . $filename . ($extension ? ".{$extension}" : ''); switch ($type) { case 'upload': move_uploaded_file($path, $prefix . $name); break; case 'move': case 'stash': rename($path, $prefix . $name); break; case 'copy': copy($path, $prefix . $name); break; } $this->{$field} = $name; }
</div> <div class="report_col4"> <strong>LOCATION</strong> </div> <div class="report_col5"> <strong>VERIFIED?</strong> </div> </div> <?php foreach ($incidents as $incident) { $incident_id = $incident->id; $incident_title = $incident->incident_title; $incident_description = $incident->incident_description; // Trim to 150 characters without cutting words //XXX: Perhaps delcare 150 as constant $incident_description = text::limit_chars($incident_description, 150, "...", true); $incident_date = date('Y-m-d', strtotime($incident->incident_date)); $incident_location = $incident->location->location_name; $incident_verified = $incident->incident_verified; if ($incident_verified) { $incident_verified = "<span class=\"report_yes\">YES</span>"; } else { $incident_verified = "<span class=\"report_no\">NO</span>"; } echo "<div class=\"report_row1\">"; echo "\t<div class=\"report_thumb report_col1\">"; echo " \t "; if (isset($media_icons[$incident_id])) { echo $media_icons[$incident_id]; } echo " </div>";
/** * Adds hash tweets in JSON format to the database and saves the sender as a new * Reporter if they don't already exist * @param string $data - Twitter JSON results */ private function add_hash_tweets($data) { if ($this->_lock()) { return false; } $services = new Service_Model(); $service = $services->where('service_name', 'Twitter')->find(); if (!$service) { $this->_unlock(); return false; } $tweets = json_decode($data, false); if (!$tweets) { $this->_unlock(); return false; } if (isset($tweets->{'error'})) { $this->_unlock(); return false; } $tweet_results = $tweets->{'results'}; foreach ($tweet_results as $tweet) { $reporter = ORM::factory('reporter')->where('service_id', $service->id)->where('service_account', $tweet->{'from_user'})->find(); if (!$reporter->loaded) { // get default reporter level (Untrusted) $level = ORM::factory('level')->where('level_weight', 0)->find(); $reporter->service_id = $service->id; $reporter->level_id = $level->id; $reporter->service_account = $tweet->{'from_user'}; $reporter->reporter_first = null; $reporter->reporter_last = null; $reporter->reporter_email = null; $reporter->reporter_phone = null; $reporter->reporter_ip = null; $reporter->reporter_date = date('Y-m-d'); $reporter->save(); } if ($reporter->level_id > 1 && count(ORM::factory("message")->where("service_messageid = '" . $tweet->{'id_str'} . "'")->find_all()) == 0) { // Grab geo data if it exists from the tweet $tweet_lat = null; $tweet_lon = null; if ($tweet->{'geo'} != null) { $tweet_lat = $tweet->{'geo'}->coordinates[0]; $tweet_lon = $tweet->{'geo'}->coordinates[1]; } // Save Tweet as Message $message = new Message_Model(); $message->parent_id = 0; $message->incident_id = 0; $message->user_id = 0; $message->reporter_id = $reporter->id; $message->message_from = $tweet->{'from_user'}; $message->message_to = null; $message->message = $tweet->{'text'}; $message->message_type = 1; // Inbox $tweet_date = date("Y-m-d H:i:s", strtotime($tweet->{'created_at'})); $message->message_date = $tweet_date; $message->service_messageid = $tweet->{'id_str'}; $message->latitude = $tweet_lat; $message->longitude = $tweet_lon; $message->save(); // Action::message_twitter_add - Twitter Message Received! Event::run('ushahidi_action.message_twitter_add', $message); // Auto-Create A Report if Reporter is Trusted $reporter_weight = $reporter->level->level_weight; $reporter_location = $reporter->location; if ($reporter_weight > 0 and $reporter_location) { $incident_title = text::limit_chars($message->message, 50, "...", false); // Create Incident $incident = new Incident_Model(); $incident->location_id = $reporter_location->id; $incident->incident_title = $incident_title; $incident->incident_description = $message->message; $incident->incident_date = $tweet_date; $incident->incident_dateadd = date("Y-m-d H:i:s", time()); $incident->incident_active = 1; if ($reporter_weight == 2) { $incident->incident_verified = 1; } $incident->save(); // Update Message with Incident ID $message->incident_id = $incident->id; $message->save(); // Save Incident Category $trusted_categories = ORM::factory("category")->where("category_trusted", 1)->find(); if ($trusted_categories->loaded) { $incident_category = new Incident_Category_Model(); $incident_category->incident_id = $incident->id; $incident_category->category_id = $trusted_categories->id; $incident_category->save(); } } } } $this->_unlock(); return true; }
$edit_log .= "<div id=\"edit_log_".$incident_id."\" class=\"post-edit-log\"><ul>"; foreach ($incident->verify as $verify) { $edit_log .= "<li>".Kohana::lang('ui_admin.edited_by')." ".$verify->user->name." : ".$verify->verified_date."</li>"; } $edit_log .= "</ul></div>"; // Get Any Translations $i = 1; $incident_translation = "<div class=\"post-trans-new\">"; $incident_translation .= "<a href=\"" . url::base() . 'admin/reports/translate/?iid=' . $incident_id . "\">".strtoupper(Kohana::lang('ui_main.add_translation')).":</a></div>"; foreach ($incident->incident_lang as $translation) { $incident_translation .= "<div class=\"post-trans\">"; $incident_translation .= Kohana::lang('ui_main.translation'). $i . ": "; $incident_translation .= "<a href=\"" . url::base() . 'admin/reports/translate/'. $translation->id .'/?iid=' . $incident_id . "\">" . text::limit_chars($translation->incident_title, 150, "...", true) . "</a>"; $incident_translation .= "</div>"; } ?> <tr> <td class="col-1"><input name="incident_id[]" id="incident" value="<?php echo $incident_id; ?>" type="checkbox" class="check-box"/></td> <td class="col-2"> <div class="post"> <h4><a href="<?php echo url::site() . 'admin/reports/edit/' . $incident_id; ?>" class="more"><?php echo $incident_title; ?></a></h4> <p><?php echo $incident_description; ?>... <a href="<?php echo url::base() . 'admin/reports/edit/' . $incident_id; ?>" class="more"><?php echo Kohana::lang('ui_main.more');?></a></p> </div> <ul class="info"> <li class="none-separator"><?php echo Kohana::lang('ui_main.location');?>: <strong><?php echo $incident_location; ?></strong>, <strong><?php echo $countries[Kohana::config('settings.default_country')]; ?></strong></li> <li><?php echo Kohana::lang('ui_main.submitted_by');?> <strong><?php echo $submit_by; ?></strong> via <strong><?php echo $submit_mode; ?></strong></li> </ul>
?> </th> <th scope="col" class="date"><?php echo Kohana::lang('ui_main.date'); ?> </th> </tr> </thead> <tbody> <?php foreach ($gvfeeds as $feed) { $feed_id = $feed->id; $feed_title = text::limit_chars($feed->item_title, 40, '...', True); $feed_link = $feed->item_link; $feed_date = date('M j Y', strtotime($feed->item_date)); $feed_source = text::limit_chars($feed->feed->feed_name, 15, "..."); ?> <tr> <td class="title"><a href="<?php echo $feed_link; ?> " target="_blank"><?php echo $feed_title; ?> </a></td> <td class="location"><?php echo $feed_source; ?> </td> <td class="date"><?php echo $feed_date;
/** * Adds hash tweets in JSON format to the database and saves the sender as a new * Reporter if they don't already exist * @param string $data - Twitter JSON results */ private function add_hash_tweets($data) { $services = new Service_Model(); $service = $services->where('service_name', 'Twitter')->find(); if (!$service) { return; } // HACK: Make twitter IDs be strings so 32bit php doesn't choke on them - Nigel McNie $data = preg_replace('/"id":(\\d+)/', '"id":"$1"', $data); $tweets = json_decode($data, false); if (!$tweets) { return; } if (isset($tweets->{'error'})) { return; } $tweet_results = $tweets->{'results'}; foreach ($tweet_results as $tweet) { // Skip over duplicate tweets $tweet_hash = $this->tweet_hash($tweet->text); if ($this->is_tweet_registered($tweet_hash)) { continue; } $reporter = ORM::factory('reporter')->where('service_id', $service->id)->where('service_account', $tweet->{'from_user'})->find(); if (!$reporter->loaded) { // get default reporter level (Untrusted) $level = ORM::factory('level')->where('level_weight', 0)->find(); $reporter->service_id = $service->id; $reporter->level_id = $level->id; $reporter->service_userid = null; $reporter->service_account = $tweet->{'from_user'}; $reporter->reporter_first = null; $reporter->reporter_last = null; $reporter->reporter_email = null; $reporter->reporter_phone = null; $reporter->reporter_ip = null; $reporter->reporter_date = date('Y-m-d'); $reporter->save(); } if ($reporter->level_id > 1 && count(ORM::factory('message')->where('service_messageid', $tweet->{'id'})->find_all()) == 0) { // Save Tweet as Message $message = new Message_Model(); $message->parent_id = 0; $message->incident_id = 0; $message->user_id = 0; $message->reporter_id = $reporter->id; $message->message_from = $tweet->{'from_user'}; $message->message_to = null; $message->message = $tweet->{'text'}; $message->message_type = 1; // Inbox $tweet_date = date("Y-m-d H:i:s", strtotime($tweet->{'created_at'})); $message->message_date = $tweet_date; $message->service_messageid = $tweet->{'id'}; $message->save(); // Mark this tweet as received for the duplicate checker $this->register_tweet($message->id, $tweet_hash); // Action::message_twitter_add - Twitter Message Received! Event::run('ushahidi_action.message_twitter_add', $message); } // Auto-Create A Report if Reporter is Trusted $reporter_weight = $reporter->level->level_weight; $reporter_location = $reporter->location; if ($reporter_weight > 0 and $reporter_location) { $incident_title = text::limit_chars($message->message, 50, "...", false); // Create Incident $incident = new Incident_Model(); $incident->location_id = $reporter_location->id; $incident->incident_title = $incident_title; $incident->incident_description = $message->message; $incident->incident_date = $tweet_date; $incident->incident_dateadd = date("Y-m-d H:i:s", time()); $incident->incident_active = 1; if ($reporter_weight == 2) { $incident->incident_verified = 1; } $incident->save(); // Update Message with Incident ID $message->incident_id = $incident->id; $message->save(); // Save Incident Category $trusted_categories = ORM::factory("category")->where("category_trusted", 1)->find(); if ($trusted_categories->loaded) { $incident_category = new Incident_Category_Model(); $incident_category->incident_id = $incident->id; $incident_category->category_id = $trusted_categories->id; $incident_category->save(); } } } }
$edit_css = $edit_count == 0 ? "post-edit-log-red" : "post-edit-log-gray"; $edit_log = "<div class=\"" . $edit_css . "\">"; $edit_log .= "<a href=\"javascript:showLog('edit_log_" . $incident_id . "')\">" . Kohana::lang('ui_admin.edit_log') . ":</a> (" . $edit_count . ")</div>"; $edit_log .= "<div id=\"edit_log_" . $incident_id . "\" class=\"post-edit-log\"><ul>"; foreach ($incident->verify as $verify) { $edit_log .= "<li>" . Kohana::lang('ui_admin.edited_by') . " " . $verify->user->name . " : " . $verify->verified_date . "</li>"; } $edit_log .= "</ul></div>"; // Get Any Translations $i = 1; $incident_translation = "<div class=\"post-trans-new\">"; $incident_translation .= "<a href=\"" . url::base() . 'admin/reports/translate/?iid=' . $incident_id . "\">" . strtoupper(Kohana::lang('ui_main.add_translation')) . ":</a></div>"; foreach ($incident->incident_lang as $translation) { $incident_translation .= "<div class=\"post-trans\">"; $incident_translation .= Kohana::lang('ui_main.translation') . $i . ": "; $incident_translation .= "<a href=\"" . url::base() . 'admin/reports/translate/' . $translation->id . '/?iid=' . $incident_id . "\">" . text::limit_chars($translation->incident_title, 150, "...", true) . "</a>"; $incident_translation .= "</div>"; } ?> <tr> <td class="col-1"><input name="incident_id[]" id="incident" value="<?php echo $incident_id; ?> " type="checkbox" class="check-box"/></td> <td class="col-2"> <div class="post"> <h4><a href="<?php echo url::site() . 'admin/reports/edit/' . $incident_id; ?> " class="more"><?php echo $incident_title;
</th> </tr> </thead> <tbody> <?php if ($incidents->count() == 0) { ?> <tr><td colspan="3"><?php echo Kohana::lang('ui_main.no_reports'); ?> </td></tr> <?php } foreach ($incidents as $incident) { $incident_id = $incident->id; $incident_title = text::limit_chars(strip_tags($incident->incident_title), 40, '...', True); $incident_date = $incident->incident_date; $incident_date = date('M j Y', strtotime($incident->incident_date)); $incident_location = $incident->location->location_name; ?> <tr> <td><a href="<?php echo url::site() . 'reports/view/' . $incident_id; ?> "> <?php echo html::specialchars($incident_title); ?> </a></td> <td><?php echo html::specialchars($incident_location); ?>
/** * Tests the text::limit_chars() function. * @dataProvider limit_chars_provider * @group core.helpers.text.limit_chars * @test */ public function limit_chars($str, $limit, $end_char, $preserve_words, $expected_result) { $result = text::limit_chars($str, $limit, $end_char, $preserve_words); $this->assertEquals($expected_result, $result); }
<div class="big-block"> <h1>How To Help <?php echo $pagination_stats; ?> </h1> <div class="org_rowtitle"> <div class="org_col1"> <strong>Organization</strong> </div> </div> <?php foreach ($organizations as $organization) { $organization_id = $organization->id; $organization_name = $organization->organization_name; $organization_description = $organization->organization_description; // Trim to 150 characters without cutting words (Text Helper) //XXX: Perhaps delcare 150 as constant $organization_description = text::limit_chars($organization_description, 150, "...", true); echo "<div class=\"org_row1\">"; echo "\t<h3><a href=\"" . url::site() . "help/view/" . $organization_id . "\">" . $organization_name . "</a></h3>"; echo $organization_description; echo "</div>"; } ?> <?php echo $pagination; ?> </div> <!-- end block --> </div> </div>
?> "><?php echo Kohana::lang('ui_main.view_all'); ?> </a></li> <li><a href="#" class="rss-icon"><?php echo Kohana::lang('ui_main.rss'); ?> </a></li> </ul> </div> <?php foreach ($feeds as $feed) { $feed_id = $feed->id; $feed_title = $feed->item_title; $feed_description = text::limit_chars(strip_tags($feed->item_description), 150, '...', True); $feed_link = $feed->item_link; $feed_date = date('M j Y', strtotime($feed->item_date)); $feed_source = "NEWS"; ?> <div class="post"> <h4><a href="<?php echo $feed_link; ?> " target="_blank"><?php echo $feed_title; ?> </a></h4> <em class="date"><?php echo $feed_source; ?>
// Retrieve job Categories $job_category = ""; foreach ($job->job_category as $category) { $job_category .= "<a href=\"#\">" . $category->j_category->job_category_title . "</a> "; } // job Status $job_approved = $job->job_active; $job_verified = $job->job_verified; // Get Any Translations $i = 1; $job_translation = "<div class=\"post-trans-new\">"; $job_translation .= "<a href=\"" . url::base() . 'admin/jobs/translate/?iid=' . $job_id . "\">+ADD TRANSLATION:</a></div>"; foreach ($job->job_lang as $translation) { $job_translation .= "<div class=\"post-trans\">"; $job_translation .= "Translation " . $i . ": "; $job_translation .= "<a href=\"" . url::base() . 'admin/jobs/translate/' . $translation->id . '/?iid=' . $job_id . "\">" . text::limit_chars($translation->job_title, 150, "...", true) . "</a>"; $job_translation .= "</div>"; } ?> <tr> <td class="col-1"><input name="job_id[]" id="job" value="<?php echo $job_id; ?> " type="checkbox" class="check-box"/></td> <td class="col-2"> <div class="post"> <h4><a href="<?php echo url::base() . 'admin/jobs/edit/' . $job_id; ?> " class="more"><?php echo $job_title;
blocks::open("reports"); //blocks::title(Kohana::lang('ui_main.reports_listed')); ?> <?php if ($total_items == 0) { ?> <div><?php echo Kohana::lang('ui_main.no_reports'); ?> </div> <?php } $i = 0; foreach ($incidents as $incident) { $incident_id = $incident->id; $incident_title = text::limit_chars($incident->incident_title, 40, '...', True); $incident_date = $incident->incident_date; $incident_date = date('j M Y', strtotime($incident->incident_date)); $incident_location = $incident->location->location_name; $incident_category = $incident->category->current() ? $incident->category->current()->category_title : ''; $incident_video = false; if (isset($incident_videos[$incident_id][0])) { $incident_video = $incident_videos[$incident_id][0]['thumb'] ? $incident_videos[$incident_id][0]['thumb'] : $video_embed->thumb($incident_videos[$incident_id][0]['link']); } elseif (isset($incident_photos[$incident_id][0])) { $incident_video = $incident_photos[$incident_id][0]['thumb'] ? $incident_photos[$incident_id][0]['thumb'] : FALSE; } if ($incident_video) { ?> <div class="report <?php echo "col-" . $i % 5; ?>
<tr> <td colspan="4" class="col"> <h3> <?php echo Kohana::lang('ui_main.no_results'); ?> </h3> </td> </tr> <?php } foreach ($all_feedback as $feedback) { $feedback_id = $feedback->id; $feedback_title = text::limit_chars($feedback->feedback_mesg, 10, "...", true); $feedback_mesg = text::limit_chars($feedback->feedback_mesg, 150, "...", true); $feedback_dateadd = $feedback->feedback_dateadd; $feedback_dateadd = date('Y-m-d', strtotime($feedback->feedback_dateadd)); $feedback_read = $feedback->feedback_status; $person_ip = $feedback->person_ip; ?> <tr> <td class="col-1"><input name="feedback_id[]" id="feedback" value="<?php echo $feedback_id; ?> " type="checkbox" class="check-box"/></td> <td class="col-2"> <div class="post"> <h4><a href="<?php echo url::site() . 'admin/feedback/view/' . $feedback_id; ?>