/**
  * Tests the text::auto_p() function.
  * @dataProvider auto_p_provider
  * @group core.helpers.text.auto_p
  * @test
  */
 public function auto_p($str, $expected_result)
 {
     $result = text::auto_p($str);
     $this->assertEquals($expected_result, $result);
 }
示例#2
0
 public function index()
 {
     $settings = kohana::config('settings');
     $site_name = $settings['site_name'];
     $alerts_email = $settings['alerts_email'] ? $settings['alerts_email'] : $settings['site_email'];
     $unsubscribe_message = Kohana::lang('alerts.unsubscribe') . url::site() . 'alerts/unsubscribe/';
     $database_settings = kohana::config('database');
     //around line 33
     $this->table_prefix = $database_settings['default']['table_prefix'];
     //around line 34
     $settings = NULL;
     $sms_from = NULL;
     $db = new Database();
     /* Find All Alerts with the following parameters
     		- incident_active = 1 -- An approved incident
     		- incident_alert_status = 1 -- Incident has been tagged for sending
     		
     		Incident Alert Statuses
     		- 0, Incident has not been tagged for sending. Ensures old incidents are not sent out as alerts
     		- 1, Incident has been tagged for sending by updating it with 'approved' or 'verified'
     		- 2, Incident has been tagged as sent. No need to resend again
     		*/
     // HT: New Code
     // Fixes an issue with one report being sent out as an alert more than ones
     // becoming spam to users
     $incident_query = "SELECT i.id, incident_title,\n\t\t\t\tincident_description, incident_verified,\n\t\t\t\tl.latitude, l.longitude FROM " . $this->table_prefix . "incident AS i INNER JOIN " . $this->table_prefix . "location AS l ON i.location_id = l.id\n\t\t\t\tWHERE i.incident_active=1 AND i.incident_alert_status = 1 ";
     /** HT: Code for alert days limitation
      * @int alert_days = 0 : All alerts
      * @int alert_days = 1 : TODAY
      * @int alert_days > 1 : alert_days - 1 days before
      */
     if ($alert_days = $settings['alert_days']) {
         $incident_query .= "AND DATE(i.incident_date) >= DATE_SUB( CURDATE(), INTERVAL " . ($alert_days - 1) . " DAY )";
     }
     // End of New Code
     $incidents = $db->query($incident_query);
     foreach ($incidents as $incident) {
         // ** Pre-Formatting Message ** //
         // Convert HTML to Text
         $incident_description = $incident->incident_description;
         $incident_url = url::site() . 'reports/view/' . $incident->id;
         $incident_description = html::clean($incident_description);
         // EMAIL MESSAGE
         $email_message = $incident_description . "\n\n" . $incident_url;
         // SMS MESSAGE
         $sms_message = $incident_description;
         // Remove line breaks
         $sms_message = str_replace("\n", " ", $sms_message);
         // Shorten to text message size
         if (Kohana::config("settings.sms_alert_url")) {
             $sms_message = text::limit_chars($sms_message, 100, "...");
             // HT: Decreased sms lenght of sms to add incident_url
             $sms_message .= " " . $incident_url;
             // HT: Added incident_url to sms
         } else {
             $sms_message = text::limit_chars($sms_message, 150, "...");
         }
         $latitude = (double) $incident->latitude;
         $longitude = (double) $incident->longitude;
         // Find all the catecories including parents
         $category_ids = $this->_find_categories($incident->id);
         // HT: New Code
         $alert_sent = ORM::factory('alert_sent')->where('incident_id', $incident->id)->select_list('id', 'alert_id');
         $alertObj = ORM::factory('alert')->where('alert_confirmed', '1');
         if (!empty($alert_sent)) {
             $alertObj->notin('id', $alert_sent);
         }
         $alertees = $alertObj->find_all();
         // End of new code
         foreach ($alertees as $alertee) {
             // HT: check same alert_receipent multi subscription does not get multiple alert
             if ($this->_multi_subscribe($alertee, $incident->id)) {
                 continue;
             }
             // Check the categories
             if (!$this->_check_categories($alertee, $category_ids)) {
                 continue;
             }
             $alert_radius = (int) $alertee->alert_radius;
             $alert_type = (int) $alertee->alert_type;
             $latitude2 = (double) $alertee->alert_lat;
             $longitude2 = (double) $alertee->alert_lon;
             $distance = (string) new Distance($latitude, $longitude, $latitude2, $longitude2);
             // If the calculated distance between the incident and the alert fits...
             if ($distance <= $alert_radius) {
                 if ($alert_type == 1) {
                     // Get SMS Numbers
                     if (Kohana::config("settings.sms_no3")) {
                         $sms_from = Kohana::config("settings.sms_no3");
                     } elseif (Kohana::config("settings.sms_no2")) {
                         $sms_from = Kohana::config("settings.sms_no2");
                     } elseif (Kohana::config("settings.sms_no1")) {
                         $sms_from = Kohana::config("settings.sms_no1");
                     } else {
                         $sms_from = "12053705050";
                     }
                     // Admin needs to set up an SMS number
                     if ($response = sms::send($alertee->alert_recipient, $sms_from, $sms_message) === true) {
                         $alert = ORM::factory('alert_sent');
                         $alert->alert_id = $alertee->id;
                         $alert->incident_id = $incident->id;
                         $alert->alert_date = date("Y-m-d H:i:s");
                         $alert->save();
                     } else {
                         // The gateway couldn't send for some reason
                         // in future we'll keep a record of this
                     }
                 } elseif ($alert_type == 2) {
                     $to = $alertee->alert_recipient;
                     $from = array();
                     $from[] = $alerts_email;
                     $from[] = $site_name;
                     $subject = "[{$site_name}] " . $incident->incident_title;
                     $message = text::auto_p($email_message . "\n\n" . $unsubscribe_message . $alertee->alert_code . "\n");
                     //if (email::send($to, $from, $subject, $message, FALSE) == 1)
                     if (email::send($to, $from, $subject, $message, TRUE) == 1) {
                         $alert = ORM::factory('alert_sent');
                         $alert->alert_id = $alertee->id;
                         $alert->incident_id = $incident->id;
                         $alert->alert_date = date("Y-m-d H:i:s");
                         $alert->save();
                     }
                 }
             }
         }
         // End For Each Loop
         // Update Incident - All Alerts Have Been Sent!
         $update_incident = ORM::factory('incident', $incident->id);
         if ($update_incident->loaded) {
             $update_incident->incident_alert_status = 2;
             $update_incident->save();
         }
     }
 }
示例#3
0
文件: BB.php 项目: anqqa/Anqh
 /**
  * Return BBCode parsed to HTML
  *
  * @return  string
  */
 public function render()
 {
     if (is_null($this->text)) {
         return '';
     }
     // Convert old system tags to BBCode
     $this->text = str_replace(array('[link', '[/link]', '[q]', '[/q]'), array('[url', '[/url]', '[quote]', '[/quote]'), $this->text);
     return text::auto_p($this->Parse($this->text));
 }
示例#4
0
 /**
  * Markdown-style paragraph converter
  * 
  * @param string
  * @return string
  */
 public static function paragraphs($text)
 {
     return str_replace('<br />', '', text::auto_p($text));
 }
示例#5
0
文件: index.php 项目: jmhobbs/q-aargh
?>
<br/>
	<label>Uniques:</label> <?php 
echo $island->visits();
?>
<br/>
	<label>Views:</label> <?php 
echo $island->views;
?>
<br/>
</fieldset>

<h2>Message From The Founder</h2>
<div class="post text-post">
	<?php 
echo text::auto_p(html::specialchars($island->introduction));
?>
</div>

<h2>Subsequent Posts</h2>
<?php 
foreach ($island->posts() as $post) {
    $view = new View('post/' . $post->type);
    $view->post = $post;
    echo $view->render();
}
if (Auth::instance()->logged_in()) {
    ?>
<h2>Leave A Post</h2>
<?php 
    echo form::open('/island/post/' . $island->code);
示例#6
0
文件: text.php 项目: jmhobbs/q-aargh
<div class="post text-post">
	<?php 
echo text::auto_p(html::specialchars($post->get_post()->content));
?>
	<div class="post-attribution">Posted By <?php 
echo html::anchor('/user/view/' . html::specialchars($post->user->username), html::specialchars($post->user->username));
?>
</div>
</div>
示例#7
0
 private function edit_profile($page_name)
 {
     if (!$this->account_user->logged_in($this->site_id)) {
         return $this->display_login($page_name);
     }
     $primary = new View('public_account/accounts/edit_profile');
     $db = new Database();
     $account_user = $this->account_user->get_user();
     $primary->account_user = $account_user;
     $primary->page_name = $page_name;
     if ($_POST) {
         if (!empty($_POST['bio'])) {
             $db->insert('account_user_meta', array('fk_site' => $this->site_id, 'account_user_id' => $account_user->id, 'key' => 'bio', 'value' => text::auto_p($_POST['bio'])));
         } else {
             foreach ($_POST as $id => $data) {
                 $db->update('account_user_meta', array('value' => $data), "id = '{$id}' AND fk_site = {$this->site_id}");
             }
         }
         $primary->status = 'Profile Saved!';
     }
     $meta = $db->query("\n      SELECT *\n      FROM account_user_meta\n      WHERE account_user_id = '{$account_user->id}'\n      AND fk_site = '{$this->site_id}'\n    ");
     $primary->meta = 0 == $meta->count() ? FALSE : $meta;
     return $primary;
 }
示例#8
0
<p><strong><?php 
echo $name;
?>
</strong> is interested in <strong><?php 
echo $work;
?>
</strong> with a budget of <strong><?php 
echo $budget;
?>
</strong>.</p>

<?php 
echo text::auto_p(text::auto_link($description));