Пример #1
0
 public function action_new()
 {
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('New field')));
     $this->template->title = __('New Custom Field for Advertisement');
     //find all, for populating form select fields
     $categories = Model_Category::get_as_array();
     $order_categories = Model_Category::get_multidimensional();
     if ($_POST) {
         if (count(Model_Field::get_all()) > 65) {
             Alert::set(Alert::ERROR, __('You have reached the maximum number of custom fields allowed.'));
             HTTP::redirect(Route::url('oc-panel', array('controller' => 'fields', 'action' => 'index')));
         }
         $name = URL::title(Core::post('name'), '_');
         if (strlen($name) >= 60) {
             $name = Text::limit_chars($name, 60, '');
         }
         $field = new Model_Field();
         try {
             $options = array('label' => Core::post('label'), 'tooltip' => Core::post('tooltip'), 'required' => Core::post('required') == 'on' ? TRUE : FALSE, 'searchable' => Core::post('searchable') == 'on' ? TRUE : FALSE, 'admin_privilege' => Core::post('admin_privilege') == 'on' ? TRUE : FALSE, 'show_listing' => Core::post('show_listing') == 'on' ? TRUE : FALSE);
             if ($field->create($name, Core::post('type'), Core::post('values'), Core::post('categories'), $options)) {
                 Core::delete_cache();
                 Alert::set(Alert::SUCCESS, sprintf(__('Field %s created'), $name));
             } else {
                 Alert::set(Alert::WARNING, sprintf(__('Field %s already exists'), $name));
             }
         } catch (Exception $e) {
             throw HTTP_Exception::factory(500, $e->getMessage());
         }
         HTTP::redirect(Route::url('oc-panel', array('controller' => 'fields', 'action' => 'index')));
     }
     $this->template->content = View::factory('oc-panel/pages/fields/new', array('categories' => $categories, 'order_categories' => $order_categories));
 }
Пример #2
0
 public function action_index()
 {
     if ($this->owner) {
         $this->template->header->title = __('Dashboard');
         $this->template->header->js = View::factory('pages/user/js/main');
         $this->active = 'dashboard-navigation-link';
         $this->sub_content = View::factory('pages/user/main')->bind('owner', $this->owner)->bind('account', $this->visited_account);
         $gravatar_view = TRUE;
     } else {
         $this->template->header->title = __(':name\'s Profile', array(':name' => Text::limit_chars($this->visited_account->user->name)));
         $this->template->header->js = View::factory('pages/user/js/profile');
         $this->template->header->js->visited_account = $this->visited_account;
         $this->template->header->js->bucket_list = json_encode($this->visited_account->user->get_buckets_array($this->user));
         $this->template->header->js->river_list = json_encode($this->visited_account->user->get_rivers_array($this->user));
         $this->sub_content = View::factory('pages/user/profile');
         $this->sub_content->account = $this->visited_account;
         $this->sub_content->anonymous = $this->anonymous;
         $gravatar_view = FALSE;
         $this->template->content->view_type = "user";
     }
     // Activity stream
     $this->sub_content->activity_stream = View::factory('template/activities')->bind('activities', $activities)->bind('fetch_url', $fetch_url)->bind('owner', $this->owner)->bind('gravatar_view', $gravatar_view);
     $fetch_url = URL::site() . $this->visited_account->account_path . '/user/action/actions';
     $activity_list = Model_User_Action::get_activity_stream($this->visited_account->user->id, $this->user->id, !$this->owner);
     $this->sub_content->has_activity = count($activity_list) > 0;
     $activities = json_encode($activity_list);
 }
Пример #3
0
 public function query($sql, $params = NULL)
 {
     $args = func_get_args();
     $display = str_replace("\n", '↵', $sql);
     $display = preg_replace("/[\\s\t]+/", " ", $display);
     $display = Text::limit_chars($display, 60);
     return $this->run_driver("query( {$display} )", __FUNCTION__, $args, TRUE);
 }
Пример #4
0
 /**
  * CRUD controller: CREATE
  */
 public function action_create()
 {
     $this->auto_render = FALSE;
     $this->template = View::factory('js');
     if (!isset($_FILES['image'])) {
         $this->template->content = json_encode('KO');
         return;
     }
     $image = $_FILES['image'];
     if (core::config('image.aws_s3_active')) {
         require_once Kohana::find_file('vendor', 'amazon-s3-php-class/S3', 'php');
         $s3 = new S3(core::config('image.aws_access_key'), core::config('image.aws_secret_key'));
     }
     if (!Upload::valid($image) or !Upload::not_empty($image) or !Upload::type($image, explode(',', core::config('image.allowed_formats'))) or !Upload::size($image, core::config('image.max_image_size') . 'M')) {
         if (Upload::not_empty($image) and !Upload::type($image, explode(',', core::config('image.allowed_formats')))) {
             $this->template->content = json_encode(array('msg' => $image['name'] . ' ' . sprintf(__('Is not valid format, please use one of this formats "%s"'), core::config('image.allowed_formats'))));
             return;
         }
         if (!Upload::size($image, core::config('image.max_image_size') . 'M')) {
             $this->template->content = json_encode(array('msg' => $image['name'] . ' ' . sprintf(__('Is not of valid size. Size is limited to %s MB per image'), core::config('image.max_image_size'))));
             return;
         }
         $this->template->content = json_encode(array('msg' => $image['name'] . ' ' . __('Image is not valid. Please try again.')));
         return;
     } elseif ($image != NULL) {
         // saving/uploading img file to dir.
         $path = 'images/cms/';
         $root = DOCROOT . $path;
         //root folder
         $image_name = URL::title(pathinfo($image['name'], PATHINFO_FILENAME));
         $image_name = Text::limit_chars(URL::title(pathinfo($image['name'], PATHINFO_FILENAME)), 200);
         $image_name = time() . '.' . $image_name;
         // if folder does not exist, try to make it
         if (!file_exists($root) and !@mkdir($root, 0775, true)) {
             // mkdir not successful ?
             $this->template->content = json_encode(array('msg' => __('Image folder is missing and cannot be created with mkdir. Please correct to be able to upload images.')));
             return;
             // exit function
         }
         // save file to root folder, file, name, dir
         if ($file = Upload::save($image, $image_name, $root)) {
             // put image to Amazon S3
             if (core::config('image.aws_s3_active')) {
                 $s3->putObject($s3->inputFile($file), core::config('image.aws_s3_bucket'), $path . $image_name, S3::ACL_PUBLIC_READ);
             }
             $this->template->content = json_encode(array('link' => Core::config('general.base_url') . $path . $image_name));
             return;
         } else {
             $this->template->content = json_encode(array('msg' => $image['name'] . ' ' . __('Image file could not been saved.')));
             return;
         }
         $this->template->content = json_encode(array('msg' => $image['name'] . ' ' . __('Image is not valid. Please try again.')));
     }
 }
Пример #5
0
 public function action_edit()
 {
     $view = View::factory('exercise/form')->bind('form', $form)->bind('questions', $questions)->bind('selected_questions', $selected_questions)->bind('exercise_questions', $exercise_questions)->bind('error_notif', $error_notif);
     $submitted = false;
     $course = ORM::factory('course', Session::instance()->get('course_id'));
     $error_notif = array();
     $exercise_id = (int) $this->request->param('id');
     $exercise = ORM::factory('exercise', $exercise_id);
     if ($this->request->method() === 'POST' && $this->request->post()) {
         $submitted = true;
         $safepost = Arr::map('Security::xss_clean', $this->request->post());
         $validator = $exercise->validator($safepost);
         if ($validator->check() && $this->validate_form($safepost)) {
             $exercise->values(array_merge($safepost, array('course_id' => $course->id, 'slug' => Text::limit_chars(Inflector::underscore($safepost['title'])), 'modified_at' => date('Y-m-d H:i:s', time()))));
             $exercise->save();
             $zip_ques = Arr::zip($safepost['selected'], $safepost['marks']);
             $exercise->delete_questions()->add_questions($zip_ques);
             if ($safepost['pub_status'] == '1') {
                 $exist = ORM::factory('feed');
                 $exist->where('type', ' = ', 'exercise');
                 $exist->where('action', ' = ', 'add');
                 $exist->where('respective_id', ' = ', $exercise->id);
                 $exist->where('course_id', ' = ', Session::instance()->get('course_id'));
                 $exists = $exist->find_all();
                 if (count($exists) == 0) {
                     $feed = new Feed_Exercise();
                     $feed->set_action('add');
                     $feed->set_course_id(Session::instance()->get('course_id'));
                     $feed->set_respective_id($exercise->id);
                     $feed->set_actor_id(Auth::instance()->get_user()->id);
                     $feed->streams(array('course_id' => (int) Session::instance()->get('course_id')));
                     $feed->save();
                 }
             }
             Session::instance()->set('success', 'Exercise edited successfully.');
             Request::current()->redirect('exercise');
             exit;
         } else {
             $this->_errors = array_merge($this->_errors, $validator->errors('exercise'));
             $error_notif = Arr::get($this->_errors, 'questions', '');
         }
     }
     $exercise_questions = $exercise->questions()->as_array('question_id', 'marks');
     $selected_questions = array_keys($exercise_questions);
     $saved_data = $exercise->as_array();
     $form = $this->form('exercise/edit/id/' . $exercise->id, $submitted, $saved_data);
     Breadcrumbs::add(array('Edit', ''));
     // set content
     $questions = Model_Question::get_questions(array('course_id' => $course->id));
     $this->content = $view;
 }
Пример #6
0
 public function write(array $messages)
 {
     foreach ($messages as $message) {
         $additional = Arr::get($message, 'additional');
         $ip = Request::$client_ip;
         $uri = Arr::get($_SERVER, 'SERVER_NAME') . Arr::get($_SERVER, 'REQUEST_URI');
         $referer = Arr::get($_SERVER, 'HTTP_REFERER');
         $agent = Arr::get($_SERVER, 'HTTP_USER_AGENT');
         $post = var_export($_POST, TRUE);
         $file = str_replace(DOCROOT, '', Arr::get($message, 'file'));
         // Write each message into the log database table
         DB::insert('logs', array('time', 'level', 'body', 'file', 'line', 'class', 'function', 'additional', 'ip', 'uri', 'referer', 'agent', 'post'))->values(array(Arr::get($message, 'time'), Arr::get($message, 'level'), Text::limit_chars(Arr::get($message, 'body'), 2048), $file, Arr::get($message, 'line'), Arr::get($message, 'class'), Arr::get($message, 'function'), empty($additional) ? NULL : Text::limit_chars(print_r($additional, TRUE), 2048), $ip, $uri, $referer, $agent, $post))->execute();
     }
 }
Пример #7
0
Файл: day.php Проект: anqh/anqh
 /**
  * Render content.
  *
  * @return  string
  */
 public function content()
 {
     // Show limited amount of data
     $info = Text::limit_chars($this->event->info, 300);
     $show_more = $info != $this->event->info;
     // Max 3 lines
     $lines = explode("\n", str_replace(array("\r\n", "\r"), "\n", $info), 3);
     $show_more = $show_more || count($lines) == 3;
     if (count($lines) > 2) {
         $lines[2] .= '…';
     }
     $info = implode("\n", $lines);
     return '<div class="djs">' . BB::factory($info)->render(null, true) . '</div>';
 }
Пример #8
0
 /**
  * generates HTML for apy buton
  * @param  Model_Order $order 
  * @return string                 
  */
 public static function button(Model_Order $order)
 {
     if (Core::config('payment.mercadopago_client_id') != '' and Core::config('payment.mercadopago_client_secret') != '' and Theme::get('premium') == 1) {
         // Include Mercadopago library
         require Kohana::find_file('vendor/mercadopago', 'mercadopago');
         // Create an instance with your MercadoPago credentials (CLIENT_ID and CLIENT_SECRET):
         $mp = new MP(core::config('payment.mercadopago_client_id'), core::config('payment.mercadopago_client_secret'));
         $preference_data = array("items" => array(array("id" => $order->id_order, "title" => $order->product->title, "currency_id" => $order->currency, "picture_url" => $order->product->get_first_image(), "description" => Text::limit_chars(Text::removebbcode($order->product->description), 30, NULL, TRUE), "category_id" => $order->product->category->name, "quantity" => 1, "unit_price" => self::money_format($order->amount))), "payer" => array("name" => Auth::instance()->get_user()->name, "email" => Auth::instance()->get_user()->email), "back_urls" => array("success" => Route::url('oc-panel', array('controller' => 'profile', 'action' => 'orders')), "failure" => Route::url('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order))), "auto_return" => "approved", "notification_url" => Route::url('default', array('controller' => 'mercadopago', 'action' => 'ipn', 'id' => $order->id_order)), "expires" => false);
         $preference = $mp->create_preference($preference_data);
         $link = $preference["response"]["init_point"];
         return View::factory('pages/mercadopago/button', array('link' => $link));
     }
     return '';
 }
Пример #9
0
 public function get_clients()
 {
     $c_db = array();
     $clients = array();
     $clients[NULL] = __('Select client');
     if (Auth::instance()->logged_in("admin")) {
         $c_db = Model::factory('Client')->order_by('id', 'desc')->find_all();
     } else {
         $c_db = Model::factory('Client')->order_by('id', 'desc')->where('user_id', '=', Auth::instance()->get_user()->id)->find_all();
     }
     foreach ($c_db as $client) {
         $clients[$client->id] = ucfirst($client->name) . " " . ucfirst($client->surname) . ". " . Text::limit_chars($client->description, 50);
     }
     return $clients;
 }
Пример #10
0
 /**
  * Просмотр вакансии
  * @throws HTTP_Exception_404
  * @return void
  */
 public function action_view()
 {
     $service = ORM::factory('service', $this->request->param('service_id'));
     if (!$service->loaded()) {
         throw new HTTP_Exception_404('Такая компания не найдена');
     }
     $vacancy = $service->vacancies->where('id', '=', $this->request->param('vacancy_id'))->find();
     if (!$vacancy->loaded()) {
         throw new HTTP_Exception_404('Такая вакансия от компании ' . $service->name . ' не найдена');
     }
     $this->template->title = 'Вакансия ' . $vacancy->title . ' &mdash; ' . $service->name;
     $this->template->bc = array_merge($this->template->bc, array('services/' . $service->id => $service->get_name(2), 'services/' . $service->id . '/vacancies' => 'Вакансии', '#' => Text::limit_chars($vacancy->title, 80)));
     $this->view = View::factory('frontend/vacancy/view')->set('vacancy', $vacancy);
     $this->template->content = $this->view;
 }
Пример #11
0
 /**
  * Display a list of incoming messages
  *
  * @uses  Assets::popup
  * @uses  Route::url
  * @uses  Route::get
  * @uses  Route::uri
  * @uses  Request::is_datatables
  * @uses  Form::checkbox
  * @uses  HTML::anchor
  * @uses  Date::formatted_time
  * @uses  HTML::icon
  * @uses  Text::limit_chars
  */
 public function action_inbox()
 {
     Assets::popup();
     $url = Route::url('user/message', array('action' => 'inbox'), TRUE);
     $redirect = Route::get('user/message')->uri(array('action' => 'inbox'));
     $form_action = Route::get('user/message')->uri(array('action' => 'bulk', 'id' => PM::INBOX));
     $destination = '?destination=' . $redirect;
     $is_datatables = Request::is_datatables();
     /** @var $messages Model_Message */
     $messages = ORM::factory('Message')->loadInbox();
     if ($is_datatables) {
         $this->_datatables = $messages->dataTables(array('id', 'subject', 'sender', 'sent'));
         foreach ($this->_datatables->result() as $message) {
             $this->_datatables->add_row(array(Form::checkbox('messages[' . $message->id . ']', $message->id, isset($_POST['messages'][$message->id])), HTML::anchor($message->user->url, $message->user->nick, array('class' => 'message-' . $message->status)), HTML::anchor($message->url, Text::limit_chars($message->subject, 20), array('class' => 'message-' . $message->status)) . ' ' . HTML::anchor($message->url, Text::limit_chars(strip_tags($message->body), 80)), Date::formatted_time($message->sent, 'M d, Y'), HTML::icon($message->delete_url . $destination, 'fa-trash-o', array('title' => __('Delete Message'), 'data-toggle' => 'popup', 'data-table' => '#user-message-inbox'))));
         }
     }
     $this->title = __('Inbox');
     $view = View::factory('message/inbox')->bind('datatables', $this->_datatables)->set('is_datatables', $is_datatables)->set('action', $form_action)->set('url', $url);
     $this->response->body($view);
 }
Пример #12
0
 public function action_ajax_light_register()
 {
     if ($this->request->is_ajax()) {
         $email = trim($this->request->post('email'));
         $role = 2;
         $invalidEmail = !filter_var($email, FILTER_VALIDATE_EMAIL);
         $emailExists = ORM::factory('User')->where('email', '=', $email)->find();
         $errors = array('invalid_email' => $invalidEmail, 'email_exists' => $emailExists->loaded());
         $textErrors = array();
         $errors_exists = false;
         foreach ($errors as $key => $error) {
             if ($error) {
                 $errors_exists = true;
             }
         }
         if ($errors['invalid_email']) {
             $textErrors[] = 'Неверный формат email адреса!';
         }
         if ($errors['email_exists']) {
             $textErrors[] = 'Данный email адрес занят!';
         }
         if (!$errors_exists) {
             $token = md5(time() . $email);
             $emailParts = explode('@', $email);
             $password = Text::limit_chars(md5(time() . 'hello world' . $email), 8, '');
             $user = ORM::factory('User');
             $user->name = Arr::get($emailParts, 0);
             $user->username = Arr::get($emailParts, 0);
             $user->email = $email;
             $user->roles = $role;
             $user->password = $password;
             $user->register_token = $token;
             $user->save();
             $message = sprintf("Спасибо за регистрацию <br/>" . "Ваш логин: %s <br/>" . "Ваш пароль: %s <br/>" . "Ваш email: %s <br/>" . "Ссылка для активации: %s", Arr::get($emailParts, 0), $password, $email, HTML::anchor(URL::base('http') . 'module_auth/token?email=' . $email . '&token=' . $token));
             Helpers_Email::send($email, 'Регистрация', $message, true);
         }
         echo json_encode(array('errors' => $textErrors, 'errors_exists' => $errors_exists));
     }
     exit;
 }
Пример #13
0
 /**
  * Pack string to array
  *
  * Gets a string divide the string based by using the symbol `$sep` creates an array,
  * where each substring - a single element of the array and serialize this array to a string
  *
  * @param   string    $string     String
  * @param   boolean   $serialize  Serialize array? [Optional]
  * @param   string    $sep        Separator [Optional]
  * @param   int|NULL  $maxlen     Max length of substring for trimming [Optional]
  *
  * @return  string
  *
  * @uses    Text::limit_chars
  */
 public static function pack_string($string, $serialize = FALSE, $sep = PHP_EOL, $maxlen = 0)
 {
     $options = explode($sep, $string);
     $result = array();
     foreach ($options as $option) {
         if ($option = trim($option)) {
             $result[] = $maxlen ? Text::limit_chars($option, $maxlen) : $option;
         }
     }
     return $serialize ? serialize($result) : $result;
 }
Пример #14
0
 /**
  * Tests Text::limit_chars()
  *
  * @test
  * @dataProvider provider_limit_chars
  */
 function test_limit_chars($expected, $str, $limit, $end_char, $preserve_words)
 {
     $this->assertSame($expected, Text::limit_chars($str, $limit, $end_char, $preserve_words));
 }
Пример #15
0
            ?>
</a></li>
                    <?php 
        }
        ?>
                <?php 
    }
    ?>
              </ul>
            </li>
            <?php 
}
?>

            <li><p class="navbar-text"><?php 
echo Text::limit_chars(Text::removebbcode($product->description), 45, NULL, TRUE);
?>
</p></li>
          </ul>

          <div class="btn-group navbar-right btn-header-group">
                <?php 
if (core::config('product.demo_resize') == TRUE) {
    ?>
                <a class="btn btn-default btn-sm mobile-btn" title="Mobile" href="#">
                    <span class="fa fa-mobile fa-2x"></span> 
                </a>
                <a class="btn btn-default btn-sm tablet-btn" title="Tablet" href="#">
                    <span class="fa fa-tablet fa-2x"></span> 
                </a>
                <a class="btn btn-default btn-sm desktop-btn" title="Desktop full width" href="#">
Пример #16
0
        if ($ad->get_first_image() !== NULL) {
            ?>
<img src="<?php 
            echo Core::imagefly($ad->get_first_image(), 100, 100);
            ?>
" style="float:left; width:100px; margin-right:10px; margin-bottom:6px;"><?php 
        }
        ?>
<a target="_blank" style="text-decoration:none; margin-bottom:15px; color:#4272db;" href="<?php 
        echo Route::url('ad', array('category' => $ad->category, 'seotitle' => $ad->seotitle));
        ?>
"><?php 
        echo htmlentities($ad->title, ENT_QUOTES);
        ?>
</a><br><br><?php 
        echo htmlentities(Text::limit_chars(Text::removenl(Text::removebbcode($ad->description)), 255, NULL, TRUE), ENT_QUOTES);
        ?>
</p></div>',
            <?php 
    } else {
        ?>
              html: '<div style="overflow: visible; cursor: default; clear: both; position: relative; background-color: rgb(255, 255, 255); border-top-right-radius: 10px; border-bottom-right-radius: 10px; border-bottom-left-radius: 10px; padding: 6px 0; width: 100%; height: auto;"><p style="margin:0;"><a target="_blank" style="text-decoration:none; margin-bottom:15px; color:#4272db;" href="<?php 
        echo Route::url('ad', array('category' => $ad->category->seoname, 'seotitle' => $ad->seotitle));
        ?>
"><?php 
        echo htmlentities($ad->title, ENT_QUOTES);
        ?>
</a></p></div>',
            <?php 
    }
    ?>
Пример #17
0
        echo $data['id'];
        ?>
[]' value="<?php 
        echo $file['value'];
        ?>
" id='fir_inp_<?php 
        echo $file['id'];
        ?>
'/>
                            <span class="glyphicon glyphicon-file"></span>&nbsp;&nbsp;

                            <span  title="<?php 
        echo $file['title'];
        ?>
"><?php 
        echo Text::limit_chars($file['title'], 35);
        ?>
</span>
                            <!--                            --><?php 
        //if($file['title']!=''):
        ?>
                            <!--                                <span title="--><?php 
        //=$file['title']
        ?>
<!--">--><?php 
        //=Text::limit_chars($file['title'], 40)
        ?>
<!--</span>-->
                            <!--                            --><?php 
        //else:
        ?>
Пример #18
0
    ?>
" width="30" height="30" style="width:30px;height:30px;" />
        </a>
        <div class="media-body">
            <h4 class="media-heading"><a href="<?php 
    echo Route::url('product-review', array('seotitle' => $review->product->seotitle, 'category' => $review->product->category->seoname));
    ?>
"><?php 
    echo Text::limit_chars(Text::bb2html($review->product->title, TRUE), 30, NULL, TRUE);
    ?>
</a><span class="label label-warning"><?php 
    echo $review->rate;
    ?>
</span></h4>
            <h5><?php 
    echo Text::limit_chars(Text::bb2html($review->description, TRUE), 30, NULL, TRUE);
    ?>
</h5>
            <hr style="margin:8px auto">
        </div>
    </div>
<?php 
}
?>
</ul>




        
Пример #19
0
            </a>
        </div>
        <div id="featured-description-<?php 
        echo $i;
        ?>
" class="featured-description">
            <h2 class="featured-title-leader">The Supply Chain of:</h2>
            <h1 class="featured-title"><a href="/view/<?php 
        print $item->id;
        ?>
"><?php 
        echo Text::limit_chars(HTML::chars(isset($item->attributes->title) ? $item->attributes->title : "An Unnamed Supply Chain"), 35);
        ?>
</a></h1>
            <? if(isset($item->attributes->description)) { ?><h3 class="featured-teaser"><?php 
        echo Text::limit_chars(HTML::chars($item->attributes->description), 70);
        ?>
</h3><? } ?>
            <h4 class="featured-info">
                 <a href="user/<?php 
        echo $item->owner->id;
        ?>
">
                    <?php 
        echo HTML::chars($item->owner->name);
        ?>
</a>,   
                <?php 
        print date("F j, Y", $item->created);
        ?>
            </h4>
Пример #20
0
<?php

/* Copyright (C) Sourcemap 2011
 * This program is free software: you can redistribute it and/or modify it under the terms
 * of the GNU Affero General Public License as published by the Free Software Foundation,
 * either version 3 of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License along with this
 * program. If not, see <http://www.gnu.org/licenses/>.*/
?>

<a href="user/<?php 
echo $user_id;
?>
"><?php 
echo ucwords(HTML::chars($username));
?>
</a> updated 
<a href="view/<?php 
echo $supplychain_id;
?>
"><?php 
echo Text::limit_chars(isset($supplychain_title) && $supplychain_title ? HTML::chars($supplychain_title) : 'An Unnamed Supply Chain', 40);
?>
</a>
Пример #21
0
            ?>
                  <li class="price"><?php 
            echo __('Price');
            ?>
: <b><?php 
            echo i18n::money_format($ad->price);
            ?>
</b></li>
              <?php 
        }
        ?>
  
          </ul>
       
          <p><?php 
        echo Text::limit_chars(Text::removebbcode($ad->description), 255, NULL, TRUE);
        ?>
</p>
          
          <a title="<?php 
        echo HTML::chars($ad->seotitle);
        ?>
" href="<?php 
        echo Route::url('ad', array('controller' => 'ad', 'category' => $ad->category->seoname, 'seotitle' => $ad->seotitle));
        ?>
"><i class="glyphicon glyphicon-share"></i><?php 
        echo __('Read more');
        ?>
</a>
          <?php 
        if ($user !== NULL && $user->id_role == Model_Role::ROLE_ADMIN) {
Пример #22
0
							<div class="panel panel-default">
								<div class="panel-heading">
									<h4><a title="<?php 
        echo HTML::chars($faq->title);
        ?>
" href="<?php 
        echo Route::url('faq', array('seotitle' => $faq->seotitle));
        ?>
"> <?php 
        echo $faq->title;
        ?>
</a></h4>
								</div>
								<div class="panel-body">
									<?php 
        echo Text::limit_chars(Text::removebbcode($faq->description), 400, NULL, TRUE);
        ?>
								</div>
								<div class="panel-footer text-right">
									<a class="btn btn-default" title="<?php 
        echo HTML::chars($faq->title);
        ?>
" href="<?php 
        echo Route::url('faq', array('seotitle' => $faq->seotitle));
        ?>
"><?php 
        echo __('Read more');
        ?>
.</a>
								</div>
							</div>	
Пример #23
0
            ?>
">
                    <?php 
        }
        ?>
                    </a>
                    <div class="caption">
                        <h4><a href="<?php 
        echo Route::url('product', array('seotitle' => $product->seotitle, 'category' => $product->category->seoname));
        ?>
"><?php 
        echo substr($product->title, 0, 30);
        ?>
</a></h4>
                        <p><?php 
        echo Text::limit_chars(Text::removebbcode($product->description), core::cookie('list/grid') == 1 ? 255 : 30, NULL, TRUE);
        ?>
</p>
                        <a class="btn btn-success" href="<?php 
        echo Route::url('product', array('seotitle' => $product->seotitle, 'category' => $product->category->seoname));
        ?>
">
                        <span class="fa fa-shopping-cart"></span>
                        <?php 
        if ($product->final_price() > 0) {
            ?>
                            <?php 
            echo __('Buy Now');
            ?>
 <?php 
            echo $product->formated_price();
Пример #24
0
    echo $row_num++ % 2 ? 'even' : 'odd';
    ?>
">
			<td class="nowrap">
				<?php 
    echo $log->tstamp;
    ?>
			</td>
			<td>
				<?php 
    echo $log->type;
    ?>
			</td>
			<td>
				<?php 
    echo Text::limit_chars($log->message, 40, ' …', TRUE);
    ?>
			</td>
			<td>
				<a href="<?php 
    echo URL::site(Request::instance()->uri()) . '/' . URL::query(array('log_id' => $log->pk()));
    ?>
">
					<?php 
    echo __('Details');
    ?>
				</a>
			</td>
		</tr>
	<?php 
}
Пример #25
0
<?php

// Displayed feeds are cached for 5 minutes
if (!Fragment::load('feed:' . $feed . ':' . $limit, Date::MINUTE * 5)) {
    // Parse the feed
    $items = Feed::parse($feed, $limit);
    // Set the "link" and "title" variable names
    isset($link) or $link = 'link';
    isset($title) or $title = 'title';
    foreach ($items as $item) {
        // Clean the title so no one can inject anything
        $clean = html::chars($item[$title]);
        // Shorten it to 50 characters, but don't cut words in half, add 2 so that if the 51st char is a space, it will grab the 52nd character, and the word its attached to, so that the strrpos below works.
        $short = Text::limit_chars($clean, 52, false, true);
        // If the string is longer than 50 chars, cut off the leftover workd from limit_chars, and append '...'
        if (strlen($short) > 50) {
            $short = substr($short, 0, strrpos($short, ' ')) . '&#8230;';
        }
        // At this point, $short is at MAX 51 characters (50 characters of the string + "..."), usually less, because its rare for the words to line up exactly with the 50th character.
        echo '<li>' . HTML::anchor($item[$link], $short, array('title' => $clean)) . '</li>';
    }
    Fragment::save();
}
Пример #26
0
            }
            ?>
                                <?php 
        }
        ?>
                            </small>
                        </td>
                        <td>
                            <small><?php 
        echo Text::limit_chars($param['size'], 12);
        ?>
</small>
                        </td>
                        <td>
                            <small><?php 
        echo Text::limit_chars($param['ordering'], 12);
        ?>
</small>
                        </td>
                    </tr>
                <?php 
    }
    ?>
            <?php 
}
?>
            <tr>
                <td colspan="12">
                    <input type="submit" value="Сохранить порядок" class="btn btn-default" name="sort_fields">
                    <input type="submit"  value="Удалить"  class="btn btn-warning pull-right" name="delete_fields">
                </td>
Пример #27
0
    <div class="title">Сортировка по услугам</div>
    <?php 
echo FORM::open('#') . FORM::hidden('city_id', $city_id, array('class' => 'city_id_search_by_car')) . FORM::hidden('car_id', $car_id, array('class' => 'car_id_search_by_car')) . FORM::hidden('district_id', $district_id, array('class' => 'district_id_search_by_car')) . FORM::hidden('metro_id', $metro_id, array('class' => 'metro_id_search_by_car')) . FORM::hidden('discount_id', $discount_id, array('class' => 'discount_id_search_by_car')) . FORM::close();
?>
    <?php 
foreach ($works as $category_name => $works) {
    ?>
        <?php 
    if (mb_strlen($category_name) > 45) {
        ?>
            <div class="category_open_short" title="<?php 
        echo $category_name;
        ?>
">
                <?php 
        echo Text::limit_chars($category_name, 45);
        ?>
            </div>
        <?php 
    } else {
        ?>
            <div class="category_open">
                <?php 
        echo $category_name;
        ?>
            </div>
        <?php 
    }
    ?>
        <div class="works_list">
             <ul>
Пример #28
0
 /**
  * It will perfome a search on the ads table
  *
  * $res = Model_Ad::search(array(
  *		'search_string' => "php, london",
  *		'telecommute' => 1,
  *		'jobtype_id' => 3,
  *		'category_id' => 2,
  *		'limit' => 50,
  *		'offset' => 0,
  *		'fields' => array('id', 'title'),
  * ));
  *
  * @param Array $args
  * @return Array
  */
 public static function search($args)
 {
     // Merge default args
     $args = array_merge(array('search_string' => '', 'telecommute' => 0, 'jobtype_id' => 0, 'jobboard_id' => 0, 'category_id' => 0, 'limit' => 50, 'offset' => 0, 'created_after' => 0, 'random_order' => false, 'fields' => array()), $args);
     // Loads application config file
     $config = Kohana::$config->load('application');
     // Create the client, tell it where the server
     // is and how long to wait for a response.
     $sphinx = new Helper_Sphinx();
     $sphinx->SetServer('localhost', 9312);
     $sphinx->SetConnectTimeout(1);
     // Use the exteneded v2 match type
     $sphinx->SetMatchMode(SPH_MATCH_BOOLEAN);
     // Set order & limit
     if ($args['search_string'] != "") {
         $sphinx->SetSortMode(SPH_SORT_EXTENDED, 'created_at DESC, highlight DESC');
     } else {
         $sphinx->SetSortMode(SPH_SORT_EXTENDED, 'created_at DESC');
     }
     $sphinx->SetLimits($args['offset'], $args['limit']);
     // Give me back the results as an array
     $sphinx->SetArrayResult(true);
     // Select only with telecommute
     if ($args['telecommute'] > 0) {
         $sphinx->SetFilter("telecommute", array(1));
     }
     // Select only with jobtype_id
     if ($args['jobtype_id'] > 0) {
         $sphinx->SetFilter("jobtype_id", array($args['jobtype_id']));
     }
     // Select only with jobboard_id
     if ($args['jobboard_id'] > 0) {
         $sphinx->SetFilter("jobboard_id", array($args['jobboard_id']));
     }
     // Select only with category_id
     if ($args['category_id'] > 0) {
         $sphinx->SetFilter("category_id", array($args['category_id']));
     }
     // Select only ads more recentent than created_after
     if ($args['created_after'] > 0) {
         $sphinx->SetFilterRange('created_at', $args['created_after'], strtotime('now'));
     }
     // Set random order
     if ($args['random_order']) {
         $sphinx->setSortMode(SPH_SORT_EXTENDED, '@random');
     }
     // Perfom the query against sphinx server
     $sphinx_results = $sphinx->Query($args['search_string'], 'ads');
     $rows = array();
     $words = array();
     // check if there's any results
     if ($sphinx_results['total'] > 0) {
         $ids = '';
         // prepare the rows ID's to be used against mysql query
         for ($i = 0; $i < count($sphinx_results['matches']); $i++) {
             $ids .= $sphinx_results['matches'][$i]['id'];
             if ($i < count($sphinx_results['matches']) - 1) {
                 $ids .= ',';
             }
         }
         // Merge the array so it can be included in the SQL query
         $fields = implode(',', $args['fields']);
         // Get the ID rows from MySQL
         $rows = DB::query(Database::SELECT, "SELECT {$fields} FROM\n\t\t\t\tads WHERE id IN({$ids}) AND active = 1 ORDER BY FIELD(id, {$ids}) ")->execute()->as_array();
         // Get all the keywords
         if (isset($sphinx_results['words'])) {
             foreach ($sphinx_results['words'] as $key => $value) {
                 $words[] = $key;
             }
         }
         // Cleans and formats data
         foreach ($rows as $key => $ad) {
             $rows[$key]['created_at'] = Helper_Datetime::format($ad['created_at'], $config['ad']['date_format']);
             $rows[$key]['is_new'] = Helper_Datetime::is_new($ad['created_at'], $config['ad']['is_new_days']);
             $rows[$key]['jobtype'] = ORM::factory('jobtype', $ad['jobtype_id'])->name;
             $rows[$key]['jobboard'] = ORM::factory('jobboard', $ad['jobboard_id'])->name;
             $rows[$key]['url'] = Helper_Utils::get_ad_url($ad['title'], $ad['id']);
             $rows[$key]['title'] = Text::limit_chars($ad['title'], 55, '...');
             if (in_array('company_logo', $args['fields'])) {
                 if (!$ad['company_logo']) {
                     $rows[$key]['company_logo'] = 'default';
                 }
                 $rows[$key]['company_logo'] = Helper_Utils::static_path('media/uploads/' . $rows[$key]['company_logo'] . '_thumb.png');
             }
             $title[] = $rows[$key]['title'];
             unset($rows[$key]['jobtype_id']);
         }
     }
     return array('rows' => $rows, 'total' => $sphinx_results['total'], 'words' => $words);
 }
Пример #29
0
  <script
    src="https://checkout.stripe.com/checkout.js" class="stripe-button"
    data-key="<?php 
echo Core::config('payment.stripe_public');
?>
"
    data-label="<?php 
echo __('Pay with Card');
?>
"
    data-name="<?php 
echo Model_Order::product_desc($order->id_product);
?>
"
    data-description="<?php 
echo Text::limit_chars(Text::removebbcode($order->description), 30, NULL, TRUE);
?>
"
    <?if (Auth::instance()->logged_in()):?>
        data-email="<?php 
echo Auth::instance()->get_user()->email;
?>
"
    <?endif?>
    data-amount="<?php 
echo StripeKO::money_format($order->amount);
?>
"
    data-currency="<?php 
echo $order->currency;
?>
Пример #30
0
				<ul class="list-group orders-list">
					<?foreach($orders as $order):?>
						<li class="list-group-item" id="tr<?php 
echo $order->pk();
?>
">
							<div class="order-item">
								<a href="#" data-toggle="modal" data-target="#viewOrderID<?php 
echo $order->id_order;
?>
" title="<?php 
echo HTML::chars($order->ad->title);
?>
">
									<?php 
echo Text::limit_chars($order->ad->title, 50, NULL, TRUE);
?>
								</a> <i class="fa fa-share-square-o"></i>
							</div>
							<div class="order-info pad_5tb">
							<span class="badge"><?php 
echo Model_Order::product_desc($order->id_product);
?>
</span>
								<?if ($order->status == Model_Order::STATUS_CREATED):?>
									<span class="badge badge-warning"> <?php 
echo i18n::format_currency($order->amount, $order->currency);
?>
 <i class="fa fa-clock-o"></i></span>
								<?else:?>
									<span class="badge badge-success"> <?php