예제 #1
0
파일: file.php 프로젝트: ZerGabriel/cms-1
 /**
  * 
  * @param integer $size
  */
 public function set_max_size($size)
 {
     if (empty($size)) {
         $size = Num::bytes('1MiB');
     }
     $this->max_size = (int) $size;
 }
예제 #2
0
파일: track.php 프로젝트: anqh/anqh
 /**
  * Override __set() to handle time.
  *
  * @param   string  $key
  * @param   mixed   $value
  */
 public function __set($key, $value)
 {
     if ($key === 'size_time' && !is_numeric($value)) {
         $value = Num::seconds($value);
     }
     parent::__set($key, $value);
 }
예제 #3
0
파일: music.php 프로젝트: anqh/anqh
 /**
  * Action: browse tracks
  */
 public function action_browse()
 {
     $type = $this->request->param('music') == 'mixtapes' ? Model_Music_Track::TYPE_MIX : Model_Music_Track::TYPE_TRACK;
     $genre = $this->request->param('genre');
     // Load requested music
     $limit = 25;
     $music = Model_Music_Track::factory();
     $count = $music->count_by_type($type, $genre);
     // Build page
     $this->view = View_Page::factory($type == Model_Music_Track::TYPE_MIX ? __('Mixtapes') : __('Tracks'));
     // Set actions
     $this->_set_page_actions();
     $this->view->tab = $this->request->param('music');
     // Filters
     $this->view->add(View_Page::COLUMN_CENTER, $this->section_filters($this->request->param('music'), $genre));
     // Pagination
     $this->view->add(View_Page::COLUMN_CENTER, $pagination = $this->section_pagination($limit, $count));
     $this->view->subtitle = __($pagination->total_pages == 1 ? ':pages page' : ':pages pages', array(':pages' => Num::format($pagination->total_pages, 0)));
     // Browse
     $tracks = $music->find_by_type($type, $genre, $limit, $pagination->offset);
     $this->view->add(View_Page::COLUMN_CENTER, $this->section_browse($tracks));
     // Pagination
     $this->view->add(View_Page::COLUMN_CENTER, $pagination);
     // New
     $this->view->add(View_Page::COLUMN_RIGHT, $this->section_list($music->find_new(Model_Music_Track::TYPE_MIX, 10), __('New mixtapes')));
     $this->view->add(View_Page::COLUMN_RIGHT, $this->section_list($music->find_new(Model_Music_Track::TYPE_TRACK, 10), __('New tracks')));
 }
예제 #4
0
파일: float.php 프로젝트: shadowhand/hive
 public function verbose($value)
 {
     $value = $this->value($value);
     if ($this->decimals) {
         $value = Num::format($value, $this->decimals);
     }
     return (string) $value;
 }
예제 #5
0
파일: num.php 프로젝트: anqh/anqh
 /**
  * Get currency based on date. Used for currency chances such as Euro.
  *
  * @static
  * @param   float    $amount
  * @param   integer  $date
  * @return  string
  */
 public static function currency($amount, $date = null)
 {
     static $change;
     // Show decimals only if required
     $amount = $amount == (int) $amount ? (int) $amount : Num::format($amount, 2, true);
     // Finland switched to Euro on January 1st, 2002
     if (!$change) {
         $change = mktime(0, 0, 0, 1, 1, 2002);
     }
     $currency = !$date || $date >= $change ? '€' : 'mk';
     return $amount . $currency;
 }
예제 #6
0
파일: hovercard.php 프로젝트: anqh/anqh
    /**
     * Render view.
     *
     * @return  string
     */
    public function content()
    {
        ob_start();
        // Title
        if ($this->area->description) {
            echo $this->area->description . '<hr>';
        }
        if ($this->area->topic_count) {
            // Area has topics
            $last_topic = $this->area->last_topic();
            $last_poster = $last_topic->last_post()->author();
            ?>

		<div class="media">
			<div class="pull-left">
				<?php 
            echo HTML::avatar($last_poster ? $last_poster['avatar'] : null, $last_poster ? $last_poster['username'] : null, false);
            ?>
			</div>
			<div class="media-body">
				<small class="ago"><?php 
            echo HTML::time(Date::short_span($last_topic->last_posted, true, true), $last_topic->last_posted);
            ?>
</small>
				<?php 
            echo $last_poster ? HTML::user($last_poster) : HTML::chars($last_topic->last_poster);
            ?>
				<br>
				<?php 
            echo HTML::anchor(Route::model($last_topic, '?page=last#last'), Forum::topic($last_topic), array('title' => HTML::chars($last_topic->name)));
            ?>
<br />
			</div>
		</div>

		<small class="stats muted">
			<i class="icon-comments"></i> <?php 
            echo Num::format($this->area->topic_count, 0);
            ?>
			<i class="icon-comment"></i> <?php 
            echo Num::format($this->area->post_count, 0);
            ?>
		</small>

<?php 
        } else {
            // Empty area
            echo __('No topics yet.');
        }
        return ob_get_clean();
    }
예제 #7
0
 public function rules()
 {
     return ['amount' => function ($value) {
         if ($value <= 0) {
             return 'Еще нет средств на расход';
         }
         $amount = $this->model('Salary')->getReady();
         $amount = intval($amount);
         $value = intval($value);
         if ($amount !== $value) {
             return 'Сумма изменилась должно быть:' . \Num::format($amount);
         }
     }];
 }
예제 #8
0
파일: Uploaded.php 프로젝트: Konro1/pms
 public function validate(Jam_Validated $model, $attribute, $value)
 {
     if ($value and !$value->is_empty() and $value->source()) {
         if ($error = $value->source()->error()) {
             $model->errors()->add($attribute, 'uploaded_native', array(':message' => $error));
         } elseif (!is_file($value->file())) {
             $model->errors()->add($attribute, 'uploaded_is_file');
         }
         if ($this->only and !in_array(strtolower(pathinfo($value->filename(), PATHINFO_EXTENSION)), $this->valid_extensions())) {
             $model->errors()->add($attribute, 'uploaded_extension', array(':extension' => join(', ', $this->valid_extensions())));
         }
         if ($this->minimum_size or $this->maximum_size or $this->exact_size) {
             $size = @filesize($value->file());
             if ($this->minimum_size and $minimum_size = Num::bytes($this->minimum_size) and (int) $size < (int) $minimum_size) {
                 $model->errors()->add($attribute, 'uploaded_minimum_size', array(':minimum_size' => $this->minimum_size));
             }
             if ($this->maximum_size and $maximum_size = Num::bytes($this->maximum_size) and (int) $size > (int) $maximum_size) {
                 $model->errors()->add($attribute, 'uploaded_maximum_size', array(':maximum_size' => $this->maximum_size));
             }
             if ($this->exact_size and $exact_size = Num::bytes($this->exact_size) and (int) $size !== (int) $exact_size) {
                 $model->errors()->add($attribute, 'uploaded_exact_size', array(':exact_size' => $this->exact_size));
             }
         }
         if ($this->minimum_width or $this->minimum_height or $this->maximum_width or $this->maximum_height or $this->exact_width or $this->exact_height) {
             $dims = @getimagesize($value->file());
             if ($dims) {
                 list($width, $height) = $dims;
                 if ($this->exact_width and (int) $width !== (int) $this->exact_width) {
                     $model->errors()->add($attribute, 'uploaded_exact_width', array(':exact_width' => $this->exact_width));
                 }
                 if ($this->exact_height and (int) $height !== (int) $this->exact_height) {
                     $model->errors()->add($attribute, 'uploaded_exact_height', array(':exact_height' => $this->exact_height));
                 }
                 if ($this->minimum_width and (int) $width < (int) $this->minimum_width) {
                     $model->errors()->add($attribute, 'uploaded_minimum_width', array(':minimum_width' => $this->minimum_width));
                 }
                 if ($this->minimum_height and (int) $height < (int) $this->minimum_height) {
                     $model->errors()->add($attribute, 'uploaded_minimum_height', array(':minimum_height' => $this->minimum_height));
                 }
                 if ($this->maximum_width and (int) $width > (int) $this->maximum_width) {
                     $model->errors()->add($attribute, 'uploaded_maximum_width', array(':maximum_width' => $this->maximum_width));
                 }
                 if ($this->maximum_height and (int) $height > (int) $this->maximum_height) {
                     $model->errors()->add($attribute, 'uploaded_maximum_height', array(':maximum_height' => $this->maximum_height));
                 }
             }
         }
     }
 }
예제 #9
0
 public function rules()
 {
     return ['out' => function ($value) {
         $salary = $this->salary;
         $out = $salary['out'] + $salary['balance'];
         // должно быть всего выдано
         $_balance = $this->getData('balance', 0);
         if (!empty($value)) {
             if ($value > $out) {
                 return 'нельзя выдать больше чем должно быть ' . \Num::format($out);
             }
         }
         /*$summa = $value + $_balance;
           if($summa != $out){
               return 'Сумма Выдано + Осталось выдать НЕ Совпадает ('.\Num::format($out-$_balance).'), должно быть '.\Num::format($out);
           }*/
     }];
 }
예제 #10
0
파일: currency.php 프로젝트: raku/My-iShop
 static function pretty_format($price, $valute = NULL, $discount = NULL)
 {
     if ($valute === 'LVL' or $valute === NULL) {
         if ($discount !== NULL) {
             return Num::format($price / 100 - $price / 100 * ($discount / 100), 2) . ' ls';
         }
         return Num::format($price / 100, 2) . ' Ls';
     } elseif ($valute === 'EUR') {
         if ($discount !== NULL) {
             return '€' . Num::format(($price / 100 - $price / 100 * ($discount / 100)) / 0.7, 2);
         }
         return '€' . Num::format($price / 100 / 0.7, 2);
     } elseif ($valute === 'USD') {
         if ($discount !== NULL) {
             return Num::format(($price / 100 - $price / 100 * ($discount / 100)) / 0.57, 2);
         }
         return '$ ' . Num::format($price / 100 / 0.57, 2);
     }
 }
예제 #11
0
파일: forum.php 프로젝트: anqh/anqh
 /**
  * Get prefixed forum title.
  *
  * @static
  * @param   Model_Forum_Topic  $topic
  * @return  string
  */
 public static function topic(Model_Forum_Topic $topic)
 {
     $prefix = array();
     // Private topic
     if ($topic->recipient_count) {
         $prefix[] = $topic->recipient_count > 2 ? '<i class="fa fa-group text-muted" title="' . __(':recipients recipients', array(':recipients' => Num::format($topic->recipient_count, 0))) . '"></i>' : '<i class="fa fa-envelope text-muted" title="' . __('Personal message') . '"></i>';
     }
     // Stickyness
     if ($topic->sticky) {
         $prefix[] = '<i class="fa fa-thumb-tack text-warning" title="' . __('Pinned') . '"></i>';
     }
     // Status
     switch ($topic->status) {
         case Model_Forum_Topic::STATUS_LOCKED:
             $prefix[] = '<i class="fa fa-lock text-muted" title="' . __('Locked') . '"></i>';
             break;
         case Model_Forum_Topic::STATUS_SINK:
             $prefix[] = '<i class="fa fa-unlock text-muted" title="' . __('Sink') . '"></i>';
             break;
     }
     return implode(' ', $prefix) . ' ' . HTML::chars($topic->name);
 }
예제 #12
0
파일: rating.php 프로젝트: anqh/core
    /**
     * Render view.
     *
     * @return  string
     */
    public function render()
    {
        ob_start();
        $rating = $this->count ? $this->total / $this->count : 0;
        ?>

<span class="rating">
	<?php 
        for ($r = 1; $r <= 5; $r++) {
            ?>
	<i class="<?php 
            echo $rating >= $r - 0.5 ? 'icon-star' : 'icon-star-empty';
            ?>
 icon-white" title="<?php 
            echo $r;
            ?>
"></i>
	<?php 
        }
        ?>
	<?php 
        if ($this->score) {
            ?>
	<var title="<?php 
            echo __($this->count == 1 ? ':rates rating' : ':rates ratings', array(':rates' => $this->count));
            ?>
"><?php 
            echo Num::format($rating, 2);
            ?>
</var>
	<?php 
        }
        ?>
</span>

<?php 
        return ob_get_clean();
    }
예제 #13
0
파일: upload.php 프로젝트: ZerGabriel/cms-1
 /**
  * Загрузка файла и сохранение в папку TMPPATH
  *
  *		try
  *		{
  *			$filename = Upload::file($_FILES['file'], NULL, NULL, array('jpg', 'jpeg', 'gif', 'png'));
  *			$path = TMPPATH . $filename;
  *		}
  *		catch (Validation_Exception $e)
  *		{
  *			echo debug::vars($e->errors('validation'));
  *		}
  * 
  * При указании строки в качестве параметра $file, будет произведена 
  * попытка загрузить файл по URL
  * 
  * @param string|array $file
  * @param string $directory Путь к каталогу, куда загружать файл
  * @param string $filename Название файла (filename.ext)
  * @param array $types Разрешенные типы файлов (При указании пустой строки, разрешены все файлы) array('jpg', '...')
  * @param integer $max_size Максимальный размер загружаемого файла
  * @return string|NULL Название файла.
  * @throws Validation_Exception
  */
 public static function file($file, $directory = NULL, $filename = NULL, array $types = array('jpg', 'jpeg', 'gif', 'png'), $max_size = NULL)
 {
     if (!is_array($file)) {
         return Upload::from_url($file, $directory, $filename, $types);
     }
     if ($directory === NULL) {
         $directory = TMPPATH;
     }
     if ($filename === NULL) {
         $filename = uniqid();
     } else {
         if ($filename === TRUE) {
             $filename = $file['name'];
         }
     }
     $ext = strtolower(pathinfo($file['name'], PATHINFO_EXTENSION));
     $filename_ext = pathinfo($filename, PATHINFO_EXTENSION);
     if (empty($filename_ext)) {
         $filename .= '.' . $ext;
     }
     if ($max_size === NULL) {
         $max_size = Num::bytes('20MiB');
     }
     $validation = Validation::factory(array('file' => $file))->rules('file', array(array('Upload::valid'), array('Upload::size', array(':value', $max_size))));
     if (!empty($types)) {
         $validation->rule('file', 'Upload::type', array(':value', $types));
     }
     if (!$validation->check()) {
         throw new Validation_Exception($validation);
     }
     if (!is_dir($directory)) {
         mkdir($directory, 0777);
         chmod($directory, 0777);
     }
     Upload::save($file, $filename, $directory, 0777);
     return $filename;
 }
예제 #14
0
 /**
  * save_base64_image upload images with given path
  * 
  * @param string $image [base64 encoded image]
  * @return bool
  */
 public function save_base64_image($image)
 {
     if (!$this->loaded()) {
         return FALSE;
     }
     // Temporary save image
     $image_data = base64_decode(preg_replace('#^data:image/\\w+;base64,#i', '', $image));
     $image_tmp = tmpfile();
     $image_tmp_uri = stream_get_meta_data($image_tmp)['uri'];
     file_put_contents($image_tmp_uri, $image_data);
     $image = Image::factory($image_tmp_uri);
     if (!in_array($image->mime, explode(',', 'image/' . str_replace(",", ",image/", core::config('image.allowed_formats'))))) {
         Alert::set(Alert::ALERT, $image->mime . ' ' . sprintf(__('Is not valid format, please use one of this formats "%s"'), core::config('image.allowed_formats')));
         return FALSE;
     }
     if (filesize($image_tmp_uri) > Num::bytes(core::config('image.max_image_size') . 'M')) {
         Alert::set(Alert::ALERT, $image->mime . ' ' . sprintf(__('Is not of valid size. Size is limited to %s MB per image'), core::config('image.max_image_size')));
         return FALSE;
     }
     if (core::config('image.disallow_nudes') and $image->is_nude_image()) {
         Alert::set(Alert::ALERT, $image->mime . ' ' . __('Seems a nude picture so you cannot upload it'));
         return FALSE;
     }
     return $this->save_image_file($image_tmp_uri, $this->has_images + 1);
 }
예제 #15
0
파일: html.php 프로젝트: anqh/anqh
 /**
  * Print icon with value
  *
  * @param  integer|array  $value     :var => value
  * @param  string         $singular  title for singular value
  * @param  string         $plural    title for plural value
  * @param  string         $class     icon class
  */
 public static function icon_value($value, $singular = '', $plural = '', $class = '')
 {
     $class = $class ? 'icon ' . $class : 'icon';
     if (is_array($value)) {
         $var = key($value);
         $value = $value[$var];
     }
     if (is_numeric($value)) {
         // Format number
         $formatted = Num::format($value, 0);
         $plural = $plural ? $plural : $singular;
         $title = $singular && $plural ? ' title="' . __($value == 1 ? $singular : $plural, array($var => $formatted)) . '"' : '';
     } else {
         // Value is a string, no formatting
         $formatted = HTML::chars($singular);
         $title = '';
     }
     return '<var class="' . $class . '"' . $title . '>' . $formatted . '</var>';
 }
예제 #16
0
 /**
  * Print some render stats
  *
  * @return string
  */
 public static function render_stats()
 {
     $run = Profiler::application();
     $run = $run['current'];
     $queries = Profiler::groups();
     $queries = count($queries['database (default)']);
     return "Page rendered in " . Num::format($run['time'], 3) . " seconds using " . Num::format($run['memory'] / 1024 / 1024, 2) . "MB and " . $queries . " queries.";
 }
예제 #17
0
 /**
  * Returns array with Tickets Closed by date formatted to generate charts
  * @param  timestamp $from_date
  * @param  timestamp $to_date
  * @return array
  */
 private function tickets_closed_by_date($from_date, $to_date)
 {
     // Dates range we are filtering
     $dates = $this->dates_range($from_date, $to_date);
     $query = DB::select(DB::expr('DATE(read_date) date'))->select(DB::expr('COUNT(id_ticket) total'))->from('tickets')->where('read_date', '!=', 'NULL')->where('status', '=', Model_Ticket::STATUS_CLOSED)->where('read_date', 'between', array(Date::unix2mysql($from_date), Date::unix2mysql($to_date)));
     $query = $query->group_by(DB::expr('DATE(read_date)'))->order_by('date', 'asc')->execute();
     $result = $query->as_array('date');
     $ret = array();
     // print maxinum 30 date labels on charts
     $label_counter = 0;
     $label_breaker = count($dates) > 30 ? Num::round(count($dates) / 30) : 1;
     foreach ($dates as $k => $date) {
         $count_sum = isset($result[$date['date']]['total']) ? $result[$date['date']]['total'] : 0;
         $ret[] = array('date' => $label_counter % $label_breaker == 0 ? $date['date'] : '', '#' => $count_sum);
         $label_counter++;
     }
     return $ret;
 }
예제 #18
0
                        <span class="statcard-desc"><?php 
echo __('12 Months Ago');
?>
</span>
                        <h2 class="statcard-number">
                            <?php 
if ($six_months_ago_total !== NULL) {
    ?>
                                <?php 
    echo Num::format($twelve_months_ago_total, 0);
    ?>
                                <small class="delta-indicator <?php 
    echo Num::percent_change($twelve_months_ago_total, $twelve_six_months_ago_total) < 0 ? 'delta-negative' : 'delta-positive';
    ?>
"><?php 
    echo Num::percent_change($twelve_months_ago_total, $twelve_six_months_ago_total);
    ?>
</small>
                            <?php 
} else {
    ?>
                                --
                            <?php 
}
?>
                        </h2>
                    </div>
                </li>
            </ul>
        </div>
    </div>
예제 #19
0
    $i = 1;
    foreach ($products as $product) {
        ?>
                            <tr>
                                <td><?php 
        echo $product->title;
        ?>
</td>
                                <td><strong class="text-highlighted"><?php 
        echo $products_data[$product->id_product]['customers'];
        ?>
</strong></td>
                                <td>
                                    <strong class="text-highlighted">
                                        <?php 
        echo $num_format == 'MONEY' ? i18n::format_currency($products_data[$product->id_product]['total']) : Num::format($products_data[$product->id_product]['total'], 0);
        ?>
                                    </strong>
                                </td>
                                <td class="col-xs-2">
                                    <div class="progress">
                                        <div class="progress-bar" style="width: <?php 
        echo $current_total > 0 ? number_format($products_data[$product->id_product]['total'] / $current_total * 100, 2) : 0;
        ?>
%;">
                                        </div>
                                    </div>
                                </td>
                            </tr>
                        <?php 
    }
예제 #20
0
 /**
  * Determines if a file larger than the post_max_size has been uploaded. PHP
  * does not handle this situation gracefully on its own, so this method
  * helps to solve that problem.
  *
  * @return  boolean
  * @uses    Num::bytes
  * @uses    Arr::get
  */
 public static function post_max_size_exceeded()
 {
     // Make sure the request method is POST
     if (Request::$initial->method() !== HTTP_Request::POST) {
         return FALSE;
     }
     // Get the post_max_size in bytes
     $max_bytes = Num::bytes(ini_get('post_max_size'));
     // Error occurred if method is POST, and content length is too long
     return Arr::get($_SERVER, 'CONTENT_LENGTH') > $max_bytes;
 }
예제 #21
0
파일: num.php 프로젝트: phabos/fuel-core
 /**
  * @see     Num::mask_credit_card
  */
 public function test_mask_credit_card()
 {
     $output = Num::mask_credit_card('1234567812345678');
     $expected = '**** **** **** 5678';
     $this->assertEquals($expected, $output);
 }
예제 #22
0
 /**
  * @test
  * @dataProvider provider_round
  * @param number $input
  * @param integer $precision
  * @param integer $mode
  * @param number $expected
  */
 function test_round($input, $precision, $expected)
 {
     foreach (array(Num::ROUND_HALF_UP, Num::ROUND_HALF_DOWN, Num::ROUND_HALF_EVEN, Num::ROUND_HALF_ODD) as $i => $mode) {
         $this->assertSame($expected[$i], Num::round($input, $precision, $mode, false));
     }
 }
예제 #23
0
파일: system.php 프로젝트: samsruti/cms
 /**
  * Get PHP memory_limit
  *
  * It can be used to obtain a human-readable form
  * of a PHP memory_limit.
  *
  * [!!] Note: If ini_get('memory_limit') returns 0, -1, NULL or FALSE
  *      returns [System::MIN_MEMORY_LIMIT]
  *
  * @since   1.4.0
  *
  * @return  int|string
  *
  * @uses    Num::bytes
  * @uses    Text::bytes
  */
 public static function get_memory_limit()
 {
     $memory_limit = Num::bytes(ini_get('memory_limit'));
     return Text::bytes((int) $memory_limit <= 0 ? self::MIN_MEMORY_LIMIT : $memory_limit, 'MiB');
 }
예제 #24
0
파일: topic.php 프로젝트: anqh/forum
 /**
  * Action: index
  */
 public function action_index()
 {
     // Go to post?
     $topic_id = (int) $this->request->param('topic_id');
     if ($topic_id) {
         $post_id = (int) $this->request->param('id');
     } else {
         $topic_id = (int) $this->request->param('id');
     }
     // Load topic
     /** @var  Model_Forum_Private_Topic|Model_Forum_Topic  $topic */
     $topic = $this->private ? Model_Forum_Private_Topic::factory($topic_id) : Model_Forum_Topic::factory($topic_id);
     if (!$topic->loaded()) {
         throw new Model_Exception($topic, $topic_id);
     }
     Permission::required($topic, Model_Forum_Topic::PERMISSION_READ, self::$user);
     // Did we request single post with ajax?
     if (($this->ajax || $this->internal) && isset($post_id)) {
         $this->history = false;
         $post = $this->private ? Model_Forum_Private_Post::factory($post_id) : Model_Forum_Post::factory($post_id);
         if (!$post->loaded()) {
             throw new Model_Exception($topic, $topic_id);
         }
         // Permission is already checked by the topic, no need to check for post
         $this->response->body($this->section_post($topic, $post));
         return;
     }
     // Update counts
     if ($this->private) {
         $topic->mark_as_read(self::$user);
     }
     if (!self::$user || $topic->author_id != self::$user->id) {
         $topic->read_count++;
         $topic->save();
     }
     // Build page
     $this->view = new View_Page();
     $this->view->title_html = Forum::topic($topic);
     $this->view->subtitle = __($topic->post_count == 1 ? ':posts post' : ':posts posts', array(':posts' => Num::format($topic->post_count, 0)));
     $this->view->tab = 'topic';
     $this->page_actions['topic'] = array('link' => Route::model($topic), 'text' => '<i class="icon-comment icon-white"></i> ' . __('Topic'));
     // Public topic extras
     if (!$this->private) {
         // Quotes are supported only in public forum as we get notifications anyway in private
         if (self::$user) {
             $quotes = Model_Forum_Quote::factory()->find_by_user(self::$user);
             if (count($quotes)) {
                 foreach ($quotes as $quote) {
                     if ($topic->id == $quote->forum_topic_id) {
                         $quote->delete();
                         break;
                     }
                 }
             }
         }
         // Facebook
         if (Kohana::$config->load('site.facebook')) {
             Anqh::open_graph('title', $topic->name);
             Anqh::open_graph('url', URL::site(Route::url('forum_topic', array('id' => $topic->id, 'action' => '')), true));
         }
         Anqh::share(true);
         // Model binding
         $area = $topic->area();
         if ($area->type == Model_Forum_Area::TYPE_BIND && $topic->bind_id) {
             if ($bind = Model_Forum_Area::get_binds($area->bind)) {
                 $model = AutoModeler::factory($bind['model'], $topic->bind_id);
                 if ($model->loaded()) {
                     // Set actions
                     $this->page_actions[] = array('link' => Route::model($model), 'text' => $bind['link']);
                     // Set views
                     foreach ((array) $bind['view'] as $view) {
                         $this->view->add(View_Page::COLUMN_SIDE, View_Module::factory($view, array($bind['model'] => $model)), Widget::TOP);
                     }
                 }
             }
         }
     }
     // Public topic extras
     // Set actions
     if (Permission::has($topic, Model_Forum_Topic::PERMISSION_POST, self::$user)) {
         $this->view->actions[] = array('link' => Request::current_uri() . '#reply', 'text' => '<i class="icon-comment icon-white"></i> ' . __('Reply to topic'), 'class' => 'btn btn-primary topic-post');
     }
     if (Permission::has($topic, Model_Forum_Topic::PERMISSION_UPDATE, self::$user)) {
         $this->view->actions[] = array('link' => Route::model($topic, 'edit'), 'text' => '<i class="icon-edit icon-white"></i> ' . __('Edit topic'));
     }
     // Breadcrumbs
     $this->page_breadcrumbs[] = HTML::anchor(Route::url('forum_group'), __('Forum'));
     $this->page_breadcrumbs[] = HTML::anchor(Route::model($topic->area()), $topic->area()->name);
     // Pagination
     $this->view->add(View_Page::COLUMN_MAIN, $pagination = $this->section_pagination($topic));
     $this->view->subtitle .= ', ' . __($pagination->total_pages == 1 ? ':pages page' : ':pages pages', array(':pages' => Num::format($pagination->total_pages, 0)));
     $this->view->subtitle .= ', ' . __($topic->read_count == 1 ? ':views view' : ':views views', array(':views' => Num::format($topic->read_count, 0)));
     // Go to post?
     if (isset($post_id)) {
         $pagination->item($topic->get_post_number($post_id) + 1);
         // We need to set pagination urls manually if jumped to a post
         $pagination->base_url = Route::model($topic);
     }
     // Recipients
     if ($this->private) {
         $this->view->add(View_Page::COLUMN_MAIN, $this->section_recipients($topic));
         $this->view->add(View_Page::COLUMN_MAIN, '<hr />');
     }
     // Posts
     $this->view->add(View_Page::COLUMN_MAIN, $this->section_topic($topic, $pagination));
     // Reply
     if (Permission::has($topic, Model_Forum_Topic::PERMISSION_POST, self::$user)) {
         $section = $this->section_post_edit(View_Forum_PostEdit::REPLY, $this->private ? Model_Forum_Private_Post::factory() : Model_Forum_Post::factory());
         $section->forum_topic = $topic;
         $this->view->add(View_Page::COLUMN_MAIN, $section);
     }
     // Pagination
     $this->view->add(View_Page::COLUMN_MAIN, $pagination);
     $this->_side_views();
 }
예제 #25
0
파일: info.php 프로젝트: raku/My-iShop
	<form action="<?php 
    echo URL::site('acp/products/item/' . $product->id . '/' . Security::token());
    ?>
" method="post">
	<table>
		<tr>
			<th>Nosaukums</th>
			<td><input type="text" name="name" value="<?php 
    echo $product->name;
    ?>
" /></td>
		</tr>
		<tr>
			<th>Cena (Bez atlaides)</th>
			<td><input type="text" name="price" value="<?php 
    echo Num::format($product->price / 100, 2);
    ?>
" /></td>
		</tr>
<?php 
    if ($product->is_discount == 1) {
        ?>
		<tr>
			<th>Cena (Ar atlaidi)</th>
			<td><?php 
        echo Currency::pretty_format($product->price, $product->discount);
        ?>
</td>
		</tr>
		<tr>
			<th>Atlaide <input checked="checked" type="checkbox" name="is_discount" /></th>
예제 #26
0
 /**
  * Provides data for test_post_max_size_exceeded()
  * 
  * @return  array
  */
 public function provider_post_max_size_exceeded()
 {
     // Get the post max size
     $post_max_size = Num::bytes(ini_get('post_max_size'));
     return array(array($post_max_size + 200000, TRUE), array($post_max_size - 20, FALSE), array($post_max_size, FALSE));
 }
예제 #27
0
파일: event.php 프로젝트: anqh/events
 /**
  * Get event ticket price in event day's currency or Free!
  *
  * @return  string
  */
 public function price()
 {
     if ($this->price === 0) {
         return __('Free!');
     } elseif ($this->price > 0) {
         return Num::currency($this->price, $this->stamp_begin);
     } else {
         return null;
     }
 }
예제 #28
0
?>
" class="display-block">
                <div class="p-a">
                    <span class="statcard-desc"><?php 
echo __('Sales');
?>
</span>
                    <h2 class="statcard-number">
                        <?php 
echo i18n::format_currency($sales_total);
?>
                        <small class="delta-indicator <?php 
echo Num::percent_change($sales_total, $sales_total_past) < 0 ? 'delta-negative' : 'delta-positive';
?>
"><?php 
echo Num::percent_change($sales_total, $sales_total_past);
?>
</small> 
                        <small class="ago"><?php 
echo sprintf(__('%s days ago'), $days_ago);
?>
</small>
                    </h2>
                    <hr class="statcard-hr">
                </div>
                <div>
                    <?php 
echo Chart::line($sales, $chart_config, $chart_colors);
?>
                </div>
            </a>
예제 #29
0
파일: index.php 프로젝트: anqh/anqh
    /**
     * Render view.
     *
     * @return  string
     */
    public function content()
    {
        ob_start();
        if (count($this->topics)) {
            ?>

<table class="table table-condensed table-striped">
	<tbody>

	<?php 
            foreach ($this->topics as $topic) {
                $last_poster = $topic->last_post()->author();
                $area = $this->area ? false : $topic->area();
                ?>

	<tr>

		<td>
			<h4 class="media-heading">
			<?php 
                if ($this->area || $topic->recipient_count) {
                    ?>
				<?php 
                    echo HTML::anchor(Route::model($topic), Forum::topic($topic));
                    ?>
				<small class="transparent"><?php 
                    echo HTML::anchor(Route::model($topic, '?page=last#last'), '<i class="text-muted fa fa-level-down"></i>', array('title' => __('Last post')));
                    ?>
</small>
			<?php 
                } else {
                    ?>
				<?php 
                    echo HTML::anchor(Route::model($topic, '?page=last#last'), Forum::topic($topic));
                    ?>
				<small class="transparent"><?php 
                    echo HTML::anchor(Route::model($topic), '<i class="text-muted fa fa-level-up"></i>', array('title' => __('First post')));
                    ?>
</small>
			<?php 
                }
                ?>
			</h4>

			<?php 
                if ($area) {
                    ?>
			<small class="muted">
				<?php 
                    echo HTML::anchor(Route::model($area), HTML::chars($area->name), array('class' => 'hoverable'));
                    ?>
			</small>
			<?php 
                }
                ?>

		</td>

		<td class="text-right muted nowrap">
			<small title="<?php 
                echo __('Replies');
                ?>
"><?php 
                echo Num::format($topic->post_count - 1, 0);
                ?>
 <i class="fa fa-comment"></i></small>
		</td>

		<td>
			<?php 
                echo HTML::avatar($last_poster ? $last_poster['avatar'] : null, $last_poster ? $last_poster['username'] : null, 'small');
                ?>
			<?php 
                echo $last_poster ? HTML::user($last_poster) : HTML::chars($topic->last_poster);
                ?>
		</td>

		<td>
			<small class="muted pull-right nowrap"><?php 
                echo HTML::time(Date::short_span($topic->last_posted, true, true), $topic->last_posted);
                ?>
</small>
		</td>

	</tr>

	<?php 
            }
            ?>

	</tbody>
</table>

<?php 
        } else {
            // Empty area
            echo new View_Alert(__('Here be nothing yet.'), null, View_Alert::INFO);
        }
        return ob_get_clean();
    }
예제 #30
0
 /**
  * Validation rule to test if an uploaded file is allowed by file size.
  * File sizes are defined as: SB, where S is the size (1, 8.5, 300, etc.)
  * and B is the byte unit (K, MiB, GB, etc.). All valid byte units are
  * defined in Num::$byte_units
  *
  *     $array->rule('file', 'Upload::size', array(':value', '1M'))
  *     $array->rule('file', 'Upload::size', array(':value', '2.5KiB'))
  *
  * @param   array   $file   $_FILES item
  * @param   string  $size   maximum file size allowed
  * @return  bool
  */
 public static function size(array $file, $size)
 {
     if ($file['error'] === UPLOAD_ERR_INI_SIZE) {
         // Upload is larger than PHP allowed size (upload_max_filesize)
         return FALSE;
     }
     if ($file['error'] !== UPLOAD_ERR_OK) {
         // The upload failed, no size to check
         return TRUE;
     }
     // Convert the provided size to bytes for comparison
     $size = Num::bytes($size);
     // Test that the file is under or equal to the max size
     return $file['size'] <= $size;
 }