コード例 #1
0
 public function get($options)
 {
     $url = $options['url'];
     $limit = array_key_exists('limit', $options) ? NumberHelper::makeNumeric($options['limit']) : null;
     $offset = array_key_exists('offset', $options) ? NumberHelper::makeNumeric($options['offset']) : 0;
     // Check to see if the response is cached
     $cachedResponse = craft()->fileCache->get($url);
     if ($cachedResponse) {
         return $cachedResponse;
     }
     try {
         $client = new \Guzzle\Http\Client();
         $request = $client->get($url);
         $response = $request->send();
         if (!$response->isSuccessful()) {
             return;
         }
         $items = $response->json();
         // Cache the response
         craft()->fileCache->set($url, $items);
         // Apply the limit and offset
         $items = array_slice($items, $offset, $limit);
         return $items;
     } catch (\Exception $e) {
         return;
     }
 }
コード例 #2
0
 public function __construct($View = null, $settings = array())
 {
     $settings = Set::merge(array('engine' => 'Tools.NumberLib'), $settings);
     parent::__construct($View, $settings);
     /*	
     $i18n = Configure::read('Currency');
     if (!empty($i18n['code'])) {
     	$this->code = $i18n['code'];
     }
     if (!empty($i18n['places'])) {
     	$this->places = $i18n['places'];
     }
     if (!empty($i18n['symbolRight'])) {
     	$this->symbolRight = $i18n['symbolRight'];
     }
     if (!empty($i18n['symbolLeft'])) {
     	$this->symbolLeft = $i18n['symbolLeft'];
     }
     if (isset($i18n['decimals'])) {
     	$this->decimalPoint = $i18n['decimals'];
     }
     if (isset($i18n['thousands'])) {
     	$this->thousandsPoint = $i18n['thousands'];
     }
     */
 }
コード例 #3
0
 function test_numeric()
 {
     $ret = NumberHelper::numeric(10);
     self::assertTrue(is_int($ret) and $ret == 10);
     $ret = NumberHelper::numeric(10.55, 'float');
     self::assertTrue(is_float($ret) and $ret == 10.55);
     $ret = NumberHelper::numeric('bidon');
     self::assertTrue(is_int($ret) and $ret == 0);
 }
コード例 #4
0
 /**
  * @param string $url
  * @param int    $limit
  * @param int    $offset
  * @param null   $cacheDuration
  *
  * @return array
  */
 public function getFeedItems($url, $limit = 0, $offset = 0, $cacheDuration = null)
 {
     $limit = NumberHelper::makeNumeric($limit);
     $offset = NumberHelper::makeNumeric($offset);
     $items = craft()->feeds->getFeedItems($url, $limit, $offset, $cacheDuration);
     // Prevent everyone from having to use the |raw filter when outputting the title and content
     $rawProperties = array('title', 'content', 'summary');
     foreach ($items as &$item) {
         foreach ($rawProperties as $prop) {
             $item[$prop] = TemplateHelper::getRaw($item[$prop]);
         }
     }
     return $items;
 }
コード例 #5
0
function get_trend_parameters($total_visit, $nbr_day, $yesterday_visit, $today_visit)
{
    $average = $total_visit / $nbr_day;
    if (!$yesterday_visit && $nbr_day == 1) {
        $trend = 100;
    } elseif ($today_visit > $average) {
        $trend = NumberHelper::round($today_visit * 100 / $average, 1) - 100;
    } elseif ($today_visit < $average) {
        $trend = 100 - NumberHelper::round($today_visit * 100 / $average, 1);
    } else {
        $trend = 0;
    }
    $sign = $today_visit < $average ? '-' : '+';
    return array('average' => NumberHelper::round($average, 1), 'trend' => $trend, 'sign' => $sign, 'picture' => $trend != 0 ? $sign == '+' ? 'up' : 'down' : '');
}
コード例 #6
0
 /**
  * @return array
  */
 public function getFeedItems($url, $limit = 0, $offset = 0)
 {
     $limit = NumberHelper::makeNumeric($limit);
     $offset = NumberHelper::makeNumeric($offset);
     $items = craft()->feeds->getFeedItems($url, $limit, $offset);
     // Prevent everyone from having to use the |raw filter when outputting the title and content
     $rawProperties = array('title', 'content', 'summary');
     $charset = craft()->templates->getTwig()->getCharset();
     foreach ($items as &$item) {
         foreach ($rawProperties as $prop) {
             $item[$prop] = new \Twig_Markup($item[$prop], $charset);
         }
     }
     return $items;
 }
コード例 #7
0
 public function get_menu_content()
 {
     global $LANG;
     $poll_config = PollConfig::load();
     $config_cookie_name = $poll_config->get_cookie_name();
     $polls = PollMiniMenuCache::load()->get_polls();
     //Chargement de la langue du module.
     load_module_lang('poll');
     $rand = array_rand($polls);
     $poll_mini = $polls[$rand];
     //Sondage aléatoire.
     $tpl = new FileTemplate('poll/poll_mini.tpl');
     #####################Résultats######################
     //Si le cookie existe, on redirige vers les resulats, sinon on prend en compte le vote (vérification par ip plus tard).
     $array_cookie = array();
     if (AppContext::get_request()->has_cookieparameter($config_cookie_name)) {
         $array_cookie = explode('/', AppContext::get_request()->get_cookie($config_cookie_name));
     }
     if (in_array($poll_mini['id'], $array_cookie)) {
         $tpl->put_all(array('L_VOTE' => $poll_mini['total'] > 1 ? $LANG['poll_vote_s'] : $LANG['poll_vote']));
         $tpl->assign_block_vars('result', array('QUESTION' => $poll_mini['question'], 'VOTES' => $poll_mini['total']));
         foreach ($poll_mini['votes'] as $answer => $width) {
             $tpl->assign_block_vars('result.answers', array('ANSWERS' => $answer, 'WIDTH' => NumberHelper::round($width, 0), 'PERCENT' => $width));
         }
     } else {
         #####################Questions######################
         $tpl->put_all(array('L_MINI_POLL' => $LANG['mini_poll'], 'L_VOTE' => $LANG['poll_vote'], 'L_POLL_RESULT' => $LANG['poll_result'], 'U_POLL_RESULT' => url('.php?id=' . $poll_mini['id'] . '&amp;r=1', '-' . $poll_mini['id'] . '-1.php')));
         $tpl->assign_block_vars('question', array('ID' => url('.php?id=' . $poll_mini['id'], '-' . $poll_mini['id'] . '.php'), 'QUESTION' => $poll_mini['question']));
         $z = 0;
         if ($poll_mini['type'] == '1') {
             if (is_array($poll_mini['votes'])) {
                 // FIXME should always be an array, needs to patch cache generation
                 foreach ($poll_mini['votes'] as $answer => $width) {
                     $tpl->assign_block_vars('question.radio', array('NAME' => $z, 'ANSWERS' => $answer));
                     $z++;
                 }
             }
         } elseif ($poll_mini['type'] == '0') {
             foreach ($poll_mini['votes'] as $answer => $width) {
                 $tpl->assign_block_vars('question.checkbox', array('NAME' => $z, 'ANSWERS' => $answer));
                 $z++;
             }
         }
     }
     return $tpl->render();
 }
コード例 #8
0
ファイル: MyNumberHelper.php プロジェクト: mathg/skinsound
 /**
  * Changes sign position based on language
  * @param float $number
  * @param string $currency
  * @param array $options
  * @return string
  */
 public function currency($number, $currency = 'USD', $options = array())
 {
     // Every total and price and stored in cents in DB
     $number = round(intval($number) / 100, 2);
     if (Configure::read('Config.language') == 'fr') {
         $options['wholePosition'] = 'after';
         $options['decimals'] = ',';
     }
     $options['fractionSymbol'] = '¢';
     $indicator = sprintf('<i class="currency">%s</i>', Configure::read('Config.language') == 'fr' ? 'CA' : 'C');
     $result = parent::currency($number, $currency, $options);
     if (Configure::read('Config.language') == 'fr') {
         return $result . '&nbsp;' . $indicator;
     } else {
         return $indicator . '&nbsp;' . $result;
     }
 }
コード例 #9
0
 /**
  * {@inheritdoc}
  */
 public function synchronize()
 {
     $this->polls = array();
     $result = PersistenceContext::get_querier()->select("SELECT id, question, votes, answers, type\n\t\tFROM " . PollSetup::$poll_table . "\n\t\tWHERE archive = 0 AND visible = 1 AND id IN :ids_list", array('ids_list' => PollConfig::load()->get_displayed_in_mini_module_list()));
     while ($row = $result->fetch()) {
         $row['question'] = stripslashes($row['question']);
         $row['answers'] = explode('|', $row['answers']);
         $row['votes'] = explode('|', $row['votes']);
         $number_votes = array_sum($row['votes']) ? array_sum($row['votes']) : 1;
         $array_votes = array_combine($row['answers'], $row['votes']);
         foreach ($array_votes as $answer => $nbrvote) {
             $array_votes[$answer] = NumberHelper::round($nbrvote * 100 / $number_votes, 1);
         }
         $row['votes'] = $array_votes;
         $row['total'] = $number_votes;
         $this->polls[$row['id']] = $row;
     }
     $result->dispose();
 }
コード例 #10
0
 private function build_form()
 {
     $extensions = $this->get_extensions_list();
     $form = new HTMLForm(__CLASS__);
     $fieldset = new FormFieldsetHTML('files-config', LangLoader::get_message('files_config', 'main'));
     $form->add_fieldset($fieldset);
     $auth_settings = new AuthorizationsSettings(array(new ActionAuthorization($this->lang['auth_files'], FileUploadConfig::AUTH_FILES_BIT)));
     $auth_settings->build_from_auth_array($this->file_upload_config->get_authorization_enable_interface_files());
     $auth_setter = new FormFieldAuthorizationsSetter('authorizations', $auth_settings);
     $fieldset->add_field($auth_setter);
     $fieldset->add_field(new FormFieldDecimalNumberEditor('size_limit', $this->lang['size_limit'], NumberHelper::round($this->file_upload_config->get_maximum_size_upload() / 1024, 2), array('min' => 0, 'step' => 0.05, 'description' => $this->lang['size_limit_explain'], 'required' => true)));
     $fieldset->add_field(new FormFieldCheckbox('bandwidth_protect', $this->lang['bandwidth_protect'], $this->file_upload_config->get_enable_bandwidth_protect(), array('description' => $this->lang['bandwidth_protect_explain'])));
     $fieldset->add_field(new FormFieldMultipleSelectChoice('authorized_extensions', $this->lang['auth_extensions'], $this->file_upload_config->get_authorized_extensions(), $extensions['authorized_extensions_select'], array('size' => 12)));
     $fieldset->add_field(new FormFieldTextEditor('extend_extensions', $this->lang['extend_extensions'], $extensions['extend_extensions'], array('description' => $this->lang['extend_extensions_explain'])));
     $this->submit_button = new FormButtonDefaultSubmit();
     $form->add_button($this->submit_button);
     $form->add_button(new FormButtonReset());
     $this->form = $form;
 }
コード例 #11
0
ファイル: number.php プロジェクト: nikolaskarica/bds-alliance
 /**
  * Alternative number_format() to accommodate multibyte decimals and thousands < PHP 5.4
  *
  * @param float $number
  * @param integer $places
  * @param string $decimals
  * @param string $thousands
  * @return string
  */
 protected static function _numberFormat($number, $places = 0, $decimals = '.', $thousands = ',')
 {
     if (!isset(self::$_numberFormatSupport)) {
         self::$_numberFormatSupport = version_compare(PHP_VERSION, '5.4.0', '>=');
     }
     if (self::$_numberFormatSupport) {
         return number_format($number, $places, $decimals, $thousands);
     }
     $number = number_format($number, $places, '.', '');
     $after = '';
     $foundDecimal = strpos($number, '.');
     if ($foundDecimal !== false) {
         $after = substr($number, $foundDecimal);
         $number = substr($number, 0, $foundDecimal);
     }
     while (($foundThousand = preg_replace('/(\\d+)(\\d\\d\\d)/', '\\1 \\2', $number)) != $number) {
         $number = $foundThousand;
     }
     $number .= $after;
     return strtr($number, array(' ' => $thousands, '.' => $decimals));
 }
コード例 #12
0
 public function get_search_request($args)
 {
     $weight = isset($args['weight']) && is_numeric($args['weight']) ? $args['weight'] : 1;
     $search = $args['search'];
     $idcat = !empty($args['ForumIdcat']) ? NumberHelper::numeric($args['ForumIdcat']) : -1;
     $time = (!empty($args['ForumTime']) ? NumberHelper::numeric($args['ForumTime']) : 30000) * 3600 * 24;
     $where = !empty($args['ForumWhere']) ? TextHelper::strprotect($args['ForumWhere']) : 'all';
     require_once PATH_TO_ROOT . '/forum/forum_defines.php';
     $authorized_categories = ForumService::get_authorized_categories(Category::ROOT_CATEGORY);
     if ($where == 'all') {
         // All
         return "SELECT " . $args['id_search'] . " AS `id_search`,\n\t\t\t\tMIN(msg.id) AS `id_content`,\n\t\t\t\tt.title AS `title`,\n\t\t\t\tMAX(( 2 * FT_SEARCH_RELEVANCE(t.title, '" . $search . "') + FT_SEARCH_RELEVANCE(msg.contents, '" . $search . "') ) / 3) * " . $weight . " AS `relevance`,\n\t\t\t\tCONCAT('" . PATH_TO_ROOT . "/forum/topic.php?id=', t.id, '#m', msg.id) AS `link`\n\t\t\tFROM " . PREFIX . "forum_msg msg\n\t\t\tJOIN " . PREFIX . "forum_topics t ON t.id = msg.idtopic\n\t\t\tJOIN " . PREFIX . "forum_cats c ON c.id_parent != 0 AND c.id = t.idcat\n\t\t\tWHERE ( FT_SEARCH(t.title, '" . $search . "') OR FT_SEARCH(msg.contents, '" . $search . "') ) AND msg.timestamp > '" . (time() - $time) . "'\n\t\t\t" . ($idcat > 0 ? " AND c.id = " . $idcat : '') . " AND c.id IN (" . implode(',', $authorized_categories) . ")\n\t\t\tGROUP BY t.id\n\t\t\tORDER BY relevance DESC\n\t\t\tLIMIT " . FORUM_MAX_SEARCH_RESULTS;
     }
     if ($where == 'contents') {
         // Contents
         return "SELECT " . $args['id_search'] . " AS `id_search`,\n\t\t\t\tMIN(msg.id) AS `id_content`,\n\t\t\t\tt.title AS `title`,\n\t\t\t\tMAX(FT_SEARCH_RELEVANCE(msg.contents, '" . $search . "')) * " . $weight . " AS `relevance`,\n\t\t\t\tCONCAT('" . PATH_TO_ROOT . "/forum/topic.php?id=', t.id, '#m', msg.id) AS `link`\n\t\t\tFROM " . PREFIX . "forum_msg msg\n\t\t\tJOIN " . PREFIX . "forum_topics t ON t.id = msg.idtopic\n\t\t\tJOIN " . PREFIX . "forum_cats c ON c.id_parent != 0 AND c.id = t.idcat\n\t\t\tWHERE FT_SEARCH(msg.contents, '" . $search . "') AND msg.timestamp > '" . (time() - $time) . "'\n\t\t\t" . ($idcat > 0 ? " AND c.id = " . $idcat : '') . " AND c.id IN (" . implode(',', $authorized_categories) . ")\n\t\t\tGROUP BY t.id\n\t\t\tLIMIT " . FORUM_MAX_SEARCH_RESULTS;
     } else {
         // Title only
         return "SELECT " . $args['id_search'] . " AS `id_search`,\n\t\t\t\tmsg.id AS `id_content`,\n\t\t\t\tt.title AS `title`,\n\t\t\t\tFT_SEARCH_RELEVANCE(t.title, '" . $search . "') * " . $weight . " AS `relevance`,\n\t\t\t\tCONCAT('" . PATH_TO_ROOT . "/forum/topic.php?id=', t.id, '#m', msg.id) AS `link`\n\t\t\tFROM " . PREFIX . "forum_msg msg\n\t\t\tJOIN " . PREFIX . "forum_topics t ON t.id = msg.idtopic\n\t\t\tJOIN " . PREFIX . "forum_cats c ON c.id_parent != 0 AND c.id = t.idcat\n\t\t\tWHERE FT_SEARCH(t.title, '" . $search . "') AND msg.timestamp > '" . (time() - $time) . "'\n\t\t\t" . ($idcat > 0 ? " AND c.id = " . $idcat : '') . " AND c.id IN (" . implode(',', $authorized_categories) . ")\n\t\t\tGROUP BY t.id\n\t\t\tLIMIT " . FORUM_MAX_SEARCH_RESULTS;
     }
 }
コード例 #13
0
 private function compute_nb_items_per_page()
 {
     if (isset($this->parameters['items'])) {
         $items_per_page = $this->parameters['items'];
         if (is_numeric($items_per_page)) {
             $items_per_page = NumberHelper::numeric($items_per_page);
             if (is_int($items_per_page) && $items_per_page > 0) {
                 $this->nb_items_per_page = $items_per_page;
             }
         }
     }
 }
コード例 #14
0
ファイル: admin_poll_add.php プロジェクト: AroundPBT/PHPBoost
         $start_timestamp = 0;
         $end_timestamp = 0;
     } else {
         $visible = 0;
         $start_timestamp = 0;
         $end_timestamp = 0;
     }
     $date = new Date($current_date);
     $timestamp = $date->get_timestamp();
     if ($timestamp > 0) {
         $timestamp += $hour * 3600 + $min * 60;
     } else {
         //Ajout des heures et minutes
         $timestamp = time();
     }
     $poll_type = NumberHelper::numeric($poll_type);
     $answers = '';
     $votes = '';
     for ($i = 0; $i < 20; $i++) {
         if ($request->has_postparameter('a' . $i)) {
             if (!empty(retrieve(POST, 'a' . $i, ''))) {
                 $answers .= str_replace('|', '', retrieve(POST, 'a' . $i, '')) . '|';
                 $votes .= str_replace('|', '', retrieve(POST, 'v' . $i, 0)) . '|';
             }
         }
     }
     PersistenceContext::get_querier()->insert(PREFIX . "poll", array('question' => $question, 'answers' => substr($answers, 0, strlen($answers) - 1), 'votes' => substr($votes, 0, strlen($votes) - 1), 'type' => $type, 'archive' => $archive, 'timestamp' => $timestamp, 'visible' => $visible, 'start' => $start_timestamp, 'end' => $start_timestamp, 'user_id' => AppContext::get_current_user()->get_id()));
     AppContext::get_response()->redirect('/poll/admin_poll.php');
 } else {
     AppContext::get_response()->redirect('/poll/admin_poll_add.php?error=incomplete#message_helper');
 }
コード例 #15
0
ファイル: number_helper.php プロジェクト: phpontrax/trax
function number_to_human_size($size, $precision = 1)
{
    return NumberHelper::number_to_human_size($size, $precision = 1);
}
コード例 #16
0
ファイル: Setting.php プロジェクト: koprals/coda-gosales-hsbc
 function ValidateAdd()
 {
     App::import('Helper', 'Number');
     $Number = new NumberHelper();
     $this->validate = array('title' => array('maxLength' => array('rule' => array('maxLength', 255), 'message' => "Title {$this->name} is too long, please insert less than or equals 255 character."), 'minLength' => array('rule' => array('minLength', 3), 'message' => "Title {$this->name} name is too short, please insert greater than or equals 3 character."), 'notEmpty' => array('rule' => "notEmpty", 'message' => "Please insert {$this->name} title.")), 'description' => array('notEmpty' => array('rule' => "notEmpty", 'message' => "Please insert {$this->name} description.")), 'images' => array('imagewidth' => array('rule' => array('imagewidth', 666), 'message' => 'Please upload image with minimum width is 666px'), 'size' => array('rule' => array('size', 5242880), 'message' => 'Your image size is too big, please upload less than ' . $Number->toReadableSize(5242880) . '.'), 'extension' => array('rule' => array('validateName', array('gif', 'jpeg', 'jpg', 'png')), 'message' => 'Only (*.gif,*.jpeg,*.jpg,*.png) are allowed.'), 'notEmptyImage' => array('rule' => "notEmptyImage", 'message' => 'Please upload {$this->name} images.')));
 }
コード例 #17
0
$calendar_type = !empty($date) ? 'timestamp' : 'date';
$field = !empty($field) ? trim($field) : 'calendar';
$date_lang = LangLoader::get('date-common');
$tpl = new FileTemplate('framework/util/mini_calendar_response.tpl');
$tpl->add_lang($date_lang);
//Type date.
if ($calendar_type == 'date') {
    $now = new Date();
    $year = $request->get_getint('y', $now->get_year());
    $month = $request->get_getint('m', $now->get_month());
    $day = $request->get_getint('d', $now->get_day());
    $input_date = !empty($input_date) ? trim($input_date) : $day . '/' . $month . '/' . $year;
    $selected = explode('/', $input_date);
    $selected_day = NumberHelper::numeric($selected[0]);
    $selected_month = NumberHelper::numeric($selected[1]);
    $selected_year = NumberHelper::numeric($selected[2]);
    if (!checkdate($month, $day, $year)) {
        list($year, $month, $day) = array(date('Y'), date('n'), date('j'));
    }
    $bissextile = date("L", mktime(0, 0, 0, 1, 1, $year)) == 1 ? 29 : 28;
    $array_month = array(31, $bissextile, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
    $array_l_month = array($date_lang['january'], $date_lang['february'], $date_lang['march'], $date_lang['april'], $date_lang['may'], $date_lang['june'], $date_lang['july'], $date_lang['august'], $date_lang['september'], $date_lang['october'], $date_lang['november'], $date_lang['december']);
    $month_day = $array_month[$month - 1];
    $tpl->put_all(array('FIELD' => $field, 'INPUT_FIELD' => $input_field, 'CALENDAR_NUMBER' => $calendar_number, 'MONTH' => $month, 'YEAR' => $year, 'PREVIOUS_YEAR' => $month == 1 ? $year - 1 : $year, 'PREVIOUS_MONTH' => $month == 1 ? 12 : $month - 1, 'NEXT_YEAR' => $month == 12 ? $year + 1 : $year, 'NEXT_MONTH' => $month == 12 ? 1 : $month + 1));
    //Génération des select.
    for ($i = 1; $i <= 12; $i++) {
        $selected = $month == $i ? 'selected="selected"' : '';
        $tpl->assign_block_vars('month', array('MONTH' => '<option value="' . $i . '" ' . $selected . '>' . TextHelper::htmlentities($array_l_month[$i - 1]) . '</option>'));
    }
    for ($i = 1900; $i <= 2037; $i++) {
        $selected = $year == $i ? 'selected="selected"' : '';
コード例 #18
0
 function view($id = null)
 {
     //$this->layout = 'map_only';
     //$this->Property->recursive = 1;
     $property = $this->Property->read(null, $id);
     if (empty($property)) {
         /*
         			$this->Session->setFlash('Invalid Property Id');
         			$this->redirect('index');
         */
         //	$this->cakeError('error404',array(array('url'=> $this->params['url']['url'])));
     } else {
         App::import('Helper', 'Text');
         App::import('Helper', 'Number');
         $text = new TextHelper();
         $number = new NumberHelper();
         $city = $this->City->find('first', array('conditions' => array('City.name' => array($property['Property']['City']))));
         //debug($city);
         // image setup
         // primary image
         // load agent record for extra data
         $this->MemberAgent->recursive = -1;
         $agent = $this->MemberAgent->find('first', array('conditions' => array('MemberAgent.Agent_Email_Address' => $property['Property']['Agent_Email_Address']), 'fields' => 'MemberAgent.Agent_License'));
         $property['Property']['Agent_License'] = $agent['MemberAgent']['Agent_License'];
         $co_agent = $this->MemberAgent->find('first', array('conditions' => array('MemberAgent.Agent_Email_Address' => $property['Property']['Co_Agent_Email_Address']), 'fields' => 'MemberAgent.Agent_License'));
         $property['Property']['Co_Agent_License'] = $co_agent['MemberAgent']['Agent_License'];
         /* 						debug($agent); */
         if (!empty($property['Property']['Primary_Picture_Url'])) {
             // main image exists
             $image_attributes = null;
             // first try to get image attributes from local cache
             $cached_image = WWW_ROOT . 'img_cache_fullsize/' . md5(base64_encode($property['Property']['Primary_Picture_Url']));
             if (is_file($cached_image)) {
                 $image_size = @getimagesize($cached_image);
             } else {
                 // otherwise try to get image size from remote site
                 $image_size = @getimagesize($property['Property']['Primary_Picture_Url']);
             }
             if (!empty($image_size)) {
                 $image_attributes = array('height' => $image_size[1], 'width' => $image_size[0], 'alt' => 'Primary Image', 'title' => 'Primary Image');
             } else {
                 $image_attributes = null;
             }
             $primary_image['source'] = $property['Property']['Primary_Picture_Url'];
             //$primary_image['source'] = '/listings/fullsize_image/'.base64_encode($property['Property']['Primary_Picture_Url']);
             $primary_image['attributes'] = $image_attributes;
         } else {
             // main images does not exist
             $primary_image['source'] = $html->image('/img/mls-no-image.gif');
             // the "no image" thumb
             $primary_image['attributes'] = array('height' => 90, 'width' => 125);
         }
         // find any secondary images
         //	$secondary_images = $this->_extra_images($property['Property']['Primary_Picture_Url'], $property['Property']['ML_Number_Display']);
         //	$secondary_images = $this->_extra_images($property['Property']['ML_Number_Display'], $property['Property']['Pictures_Count']);
         $secondary_images = $property['Property']['Pictures_Count'];
         // finished image setup
         $neighbors = $this->Property->find('neighbors', array('fields' => array('Property.ML_Number_Display')));
         // get most recent DB update time
         $db_updated = $this->UpdateLog->find('all', array('order' => 'modified DESC', 'limit' => 1, 'fields' => 'modified'));
         /*
         $allowed_fields = array(
         	// add all the fields we want to show here
         	'Search_Price_Display',
         	'Street_Full_Address',
         	'County',
         	'Bedrooms',
         	'Bathrooms_Display',
         	'ML_Number_Display',
         	'Acres',
         	'City',
         	'State',
         	'Street_Name',
         	'Street_Number',
         	'Street_Suffix',
         	'Zip_Code',
         	'Agent_Email_Address',
         	'Agent_Name',
         	'Bathrooms_Display',
         	'Bedrooms',
         	'County',
         	'Cross_Street',
         	'Full_Bathrooms',
         	'Half_Bathrooms',
         	'RESI_HOA_Code',
         	'RESI_HOA_Amount',
         	'RESI_HOA_Desc',
         	'Property_Agent_Email',
         	'Lot_Size_-_Sq_Ft',
         	'Lot_Size_-_Acres',
         	'Lot_Size_Source',
         	'Marketing_Remarks',
         	'Office_Broker_ID',
         	'Office_Full_Name_and_Phones',
         	'Office_Long_Name',
         	'Office_Short_Name',
         	'Office_Phone_1',
         	'Property_Subtype_1_Display',
         	'Property_Type',
         	'Search_Price_Display',
         	'Square_Footage',
         	'Status',
         	'Street_Direction',
         	'Street_Full_Address',
         	'Total_Bathrooms',
         	'RESI_Total_Rooms',
         	'Virtual_Tour_URL',
         	'Year_Built',
         	'Agent_Nickname',
         	'Lot_Size',
         	'MLS',
         	'RESI_Unit_Blk_Lot',
         	'Transaction_Type',
         	'RESI_Senior_Code',
         	'RESI_Senior_Desc',
         	'Property_Date',
         	'RESI_On_Market_Date',
         	'Agent_Phones',
         	'Agent_Phone_1',
         	'Reciprocal_Member_Name',
         	'Reciprocal_Member_Phone',
         	'Reciprocal_Office_Name',
         	'Co_Agent_Email_Address',
         	'Co_Agent_Fax_Phone',
         	'Co_Agent_Full_Name',
         	'Co_Agent_Phone_Type_1',
         	'Co_Agent_Web_Page_Address',
         	'Co_Office_Full_Name_and_Phones',
         	'RESI_2nd_Unit_on_Lot_Code',
         	'RESI_2nd_Unit_on_Lot_Desc',
         	'Property_Type',
         	'Agent_Web_Page_Address'
         );
         */
         $item = $property['Property'];
         // co-listing agent info cleanup
         if (stristr($item['Co_Agent_Full_Name'], '(ID:')) {
             $item['Co_Agent_Full_Name'] = explode('(ID:', $item['Co_Agent_Full_Name']);
             $item['Co_Agent_Full_Name'] = $item['Co_Agent_Full_Name'][0];
         }
         if (stristr($item['Co_Office_Full_Name_and_Phones'], 'Phone:')) {
             $item['Co_Office_Full_Name_and_Phones'] = explode('Phone:', $item['Co_Office_Full_Name_and_Phones']);
             $item['Co_Office_Full_Name_and_Phones'] = $item['Co_Office_Full_Name_and_Phones'][0];
         }
         $code = $item['Property_Type'];
         /* 			die($code); */
         $address_display_field = $code . '_Address_on_Internet_Desc';
         $this->set('address_display_field', $address_display_field);
         if (!isset($item[$address_display_field]) || strtolower($item[$address_display_field]) == 'full') {
             /*
             			if(strtolower($item['RESI_Address_on_Internet_Desc']) == 'full'){
             */
             $address_display = $item['Street_Number'] . ' ' . $item['Street_Name'] . ' ' . $item['Street_Suffix'];
             $this->pageTitle = $item['Street_Full_Address'];
         } else {
             /* 				$address_display = '<i>(Full Address Not Shown)</i>'; */
             $address_display = null;
             $this->pageTitle = $item['City'] . ', ' . $item['County'] . ' ' . $item['Zip_Code'];
         }
         $property_type = $item['Property_Type'];
         // find co-listing agent details
         $this->MemberAgent->recursive = -1;
         $co_agent_id = null;
         $co_agent = $this->MemberAgent->find('first', array('conditions' => array('MemberAgent.Agent_Email_Address' => $item['Co_Agent_Email_Address']), 'fields' => 'MemberAgent.Agent_MLS_ID'));
         /* 			debug($co_agent); */
         if (!empty($co_agent)) {
             $co_agent_id = $co_agent['MemberAgent']['Agent_MLS_ID'];
         }
         $this->MemberOffice->recursive = -1;
         $member_office = $this->MemberOffice->find('first', array('conditions' => array('MemberOffice.Office_MLS_ID' => $property['Property']['Office_ID'])));
         $this->set('member_office', $member_office);
         /* 			debug($member_office); */
         $this->set('co_agent_id', $co_agent_id);
         $grouping = array('Summary' => array('Status' => $item['Status'], 'MLS Number' => $item['ML_Number_Display'], 'Price' => '$' . $item['Search_Price_Display'], 'Property Type' => $item['Property_Subtype_1_Display'], 'Transaction Type' => $this->transaction_types[$item['Transaction_Type']], 'Number of Units' => @$item[$property_type . '___of_Units']), 'Property_Details' => array('Address' => $address_display, 'City' => $item['City'], 'Zip' => $item['Zip_Code'], 'County' => $item['County'], 'Bedrooms' => $item['Bedrooms'], 'Bathrooms' => $item['Bathrooms_Display'], 'Square Footage (approx.)' => $number->format($item['Square_Footage']), 'Building Sq. Ft. (approx.)' => $number->format($item['Lot_Size_Sq_Ft']), 'Lot Size - Acres (approx.)' => $item['Acres'], '2nd Unit on Lot' => @$item[$property_type . '_2nd_Unit_on_Lot_Desc'], 'HOA' => @$item[$property_type . '_HOA_Desc'], 'Senior Community' => @$item[$property_type . '_Senior_Desc'], 'Pool (Y/N)' => @$item[$property_type . '_Pool_Desc'], 'Year Built' => $item['Year_Built']), 'Contact_Information' => array('Listing Agent' => $item['Agent_Name'], 'Listing Agent Phone' => $item['Agent_Phone_1'], 'Listing Agent Email' => $item['Agent_Email_Address'], 'Agent Web Page Address' => $item['Agent_Web_Page_Address'], 'Listing Office' => $item['Office_Long_Name'], 'Listing Office Phone' => $item['Agent_Phone_1'], 'Co-Listing Agent' => $item['Co_Agent_Full_Name'], 'Co-Listing Agent Email' => $item['Co_Agent_Email_Address'], 'Co-Lisitng Agent Phone' => $item['Co_Office_Fax_Phone']));
         /*
         // GEOCODING STUFF
         
         $this->params['map'] = true;
         $address = $property['Property']['Street_Full_Address'];		
         $this->Coordinate->recursive = -1;
         $coordinate_finder =  array('conditions' => array('Coordinate.ML_Number_Display' => $property['Property']['ML_Number_Display']));
         $coordinates = $this->Coordinate->find('first', $coordinate_finder);
         if(empty($coordinates)){
         	$geo_data = $this->Geocoder->getLatLng($address, $this->google_map_API_key); 
         	$coordinate['Coordinate']['id'] = $coordinates['Coordinate']['id'];
         	$coordinate['Coordinate']['ML_Number_Display']  = $property['Property']['ML_Number_Display'];
         	$coordinate['Coordinate']['latitude'] = $geo_data['lat'];
         	$coordinate['Coordinate']['longitude'] = $geo_data['lng'];
         	$this->Coordinate->create();
         	$this->Coordinate->save($coordinate);
         	//$this->Session->setFlash('Coordinate data saved for property '.$property['Property']['ML_Number_Display']);
         	$coordinates = $this->Coordinate->find('first', $coordinate_finder);
         }
         
         	$coordinates['Coordinate']['address'] = $property['Property']['Street_Full_Address'];
         
         $this->params['coordinates'] = $coordinates; 
         // END GEOCODING STUFF
         */
         //	die(debug($grouping));
         $this->set('property', $property);
         $this->set('primary_image', $primary_image);
         $this->set('secondary_images', $secondary_images);
         $this->set('neighbors', $neighbors);
         $this->set('db_updated', $db_updated);
         // $this->set('allowed_fields', $allowed_fields);
         $this->set('grouping', $grouping);
         $this->set('city', $city);
         // $this->set('coordinates', $coordinates);
     }
 }
コード例 #19
0
ファイル: number_helper.php プロジェクト: joeymetal/v1
 function human_size($size)
 {
     return NumberHelper::number_to_human_size($size);
 }
コード例 #20
0
 public function downloadExcel()
 {
     $this->autoRender = false;
     $this->layout = '';
     $data['Linnworksapi']['order_type'] = $this->request->data['Linnworksapis']['order_type'];
     $data['Linnworksapi']['location'] = $this->request->data['Linnworksapis']['location'];
     $data['Linnworksapi']['source'] = $this->request->data['Linnworksapis']['source'];
     $data['Linnworksapi']['subsource'] = $this->request->data['Linnworksapis']['subsource'];
     $data['Linnworksapi']['datefrom'] = $this->request->data['Linnworksapis']['datefrom'];
     $data['Linnworksapi']['dateto'] = $this->request->data['Linnworksapis']['dateto'];
     $data['Linnworksapi']['orderid'] = $this->request->data['Linnworksapis']['orderid'];
     App::import('Helper', 'Soap');
     $SoapHelper = new SoapHelper(new View(null));
     $getData = $SoapHelper->getFilteredOrder($data);
     App::import('Helper', 'Number');
     $numberHelper = new NumberHelper(new View(null));
     App::import('Vendor', 'PHPExcel/IOFactory');
     App::import('Vendor', 'PHPExcel');
     $objPHPExcel = new PHPExcel();
     $objPHPExcel->setActiveSheetIndex(0);
     $objPHPExcel->getActiveSheet()->setCellValue('A1', 'OrderItemNumber');
     $objPHPExcel->getActiveSheet()->setCellValue('B1', 'Name');
     $objPHPExcel->getActiveSheet()->setCellValue('C1', 'Address');
     $objPHPExcel->getActiveSheet()->setCellValue('D1', 'Postcode');
     $objPHPExcel->getActiveSheet()->setCellValue('E1', 'Country');
     $objPHPExcel->getActiveSheet()->setCellValue('F1', 'Item Count');
     $objPHPExcel->getActiveSheet()->setCellValue('G1', 'Contents');
     $objPHPExcel->getActiveSheet()->setCellValue('H1', 'Total Packet Value');
     $objPHPExcel->getActiveSheet()->setCellValue('I1', 'Weight');
     $objPHPExcel->getActiveSheet()->setCellValue('J1', 'HS');
     $objPHPExcel->getActiveSheet()->setCellValue('K1', 'Deposit');
     $objPHPExcel->getActiveSheet()->setCellValue('L1', 'Invoice Number');
     $objPHPExcel->getActiveSheet()->setCellValue('M1', 'Bag barcode');
     $i = 2;
     foreach ($getData->GetFilteredOrdersResponse->GetFilteredOrdersResult->Orders->Order as $order) {
         $contents = array();
         $orderItems = array();
         foreach ($order->OrderItems->OrderItem as $item) {
             $contents[] = $item->Qty . ' X ' . $item->ItemTitle;
             $orderItems[] = $item->OrderItemNumber;
         }
         $content = implode(" \n", $contents);
         $orderItem = implode(" \n", $orderItems);
         $itemCount = count($order->OrderItems->OrderItem);
         $address = $order->ShippingAddress->Address1 . ',' . $order->ShippingAddress->Address2 . ',' . $order->ShippingAddress->Address3;
         $address = explode(',', $address);
         $address = implode(" \n ", $address);
         $objPHPExcel->getActiveSheet()->setCellValue('A' . $i . '', $orderItem);
         $objPHPExcel->getActiveSheet()->setCellValue('B' . $i . '', $order->ShippingAddress->Name);
         $objPHPExcel->getActiveSheet()->setCellValue('C' . $i . '', $address);
         $objPHPExcel->getActiveSheet()->setCellValue('D' . $i . '', $order->ShippingAddress->PostCode);
         $objPHPExcel->getActiveSheet()->setCellValue('E' . $i . '', $order->ShippingAddress->CountryCode);
         $objPHPExcel->getActiveSheet()->setCellValue('F' . $i . '', $itemCount);
         $totlaCost = $numberHelper->currency($order->TotalCost, 'EUR');
         $objPHPExcel->getActiveSheet()->setCellValue('G' . $i . '', $content);
         $objPHPExcel->getActiveSheet()->setCellValue('H' . $i . '', $totlaCost);
         $objPHPExcel->getActiveSheet()->setCellValue('I' . $i . '', '5');
         $objPHPExcel->getActiveSheet()->setCellValue('J' . $i . '', '5');
         $objPHPExcel->getActiveSheet()->setCellValue('K' . $i . '', '5');
         $objPHPExcel->getActiveSheet()->setCellValue('L' . $i . '', '5');
         $objPHPExcel->getActiveSheet()->setCellValue('M' . $i . '', '5');
         $i++;
     }
     if ($this->request->data['Linnworksapis']['order_type'] == 0) {
         $objPHPExcel->getActiveSheet()->setTitle('Open Order');
         $objPHPExcel->createSheet();
         $name = 'Open Order';
     }
     if ($this->request->data['Linnworksapis']['order_type'] == 1) {
         $objPHPExcel->getActiveSheet()->setTitle('Processed Order');
         $objPHPExcel->createSheet();
         $name = 'Procesed Order';
     }
     if ($this->request->data['Linnworksapis']['order_type'] == 2) {
         $objPHPExcel->getActiveSheet()->setTitle('Cancelled Order');
         $objPHPExcel->createSheet();
         $name = 'Cancelled Order';
     }
     header('Content-Encoding: UTF-8');
     header('Content-type: text/csv; charset=UTF-8');
     header('Content-Disposition: attachment;filename="' . $name . '.csv"');
     header('Cache-Control: max-age=0');
     $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'CSV');
     $objWriter->save('php://output');
 }
コード例 #21
0
ファイル: Forum.class.php プロジェクト: AroundPBT/PHPBoost
 function Add_poll($idtopic, $question, $answers, $nbr_votes, $type)
 {
     PersistenceContext::get_querier()->insert(PREFIX . "forum_poll", array('idtopic' => $idtopic, 'question' => $question, 'answers' => implode('|', $answers), 'voter_id' => 0, 'votes' => trim(str_repeat('0|', $nbr_votes)), 'type' => NumberHelper::numeric($type)));
 }
コード例 #22
0
ファイル: number.php プロジェクト: sukhjeet81/capuchn
 /**
  * Formats a number into a percentage string.
  *
  * @param float $number A floating point number
  * @param integer $precision The precision of the returned number
  * @return string Percentage string
  * @access public
  */
 function toPercentage($number, $precision = 2)
 {
     return NumberHelper::precision($number, $precision) . '%';
 }
コード例 #23
0
 /**
  * @desc Round to the next dozen
  * @param int $number Number to round
  * @param boolean $demi_dozen Round to the half dozen.
  * @return int The number rounded.
  */
 private function number_round_dozen($number, $demi_dozen = true)
 {
     $unit = $number % 10;
     $number = NumberHelper::round($number, 1) * 10;
     $decimal = $unit + $number % 10 / 10;
     $number /= 10;
     if ($demi_dozen) {
         if ($decimal < 2.5) {
             $number = $number - $decimal;
         } elseif ($decimal >= 2.5 && $decimal <= 7.5) {
             $number = $number - $decimal + 5;
         } else {
             $number = $number - $decimal + 10;
         }
     } else {
         if ($decimal < 5) {
             $number = $number - $decimal;
         } else {
             $number = $number - $decimal + 10;
         }
     }
     return NumberHelper::round($number, 0);
 }
コード例 #24
0
ファイル: admin_poll.php プロジェクト: AroundPBT/PHPBoost
    $tpl->put_all(array('IDPOLL' => $row['id'], 'QUESTIONS' => stripslashes($row['question']), 'TYPE_UNIQUE' => $row['type'] == '1' ? 'checked="checked"' : '', 'TYPE_MULTIPLE' => $row['type'] == '0' ? 'checked="checked"' : '', 'ARCHIVES_ENABLED' => $row['archive'] == '1' ? 'checked="checked"' : '', 'ARCHIVES_DISABLED' => $row['archive'] == '0' ? 'checked="checked"' : '', 'VISIBLE_WAITING' => $row['visible'] == 2 || !empty($row['end']) ? 'checked="checked"' : '', 'VISIBLE_ENABLED' => $row['visible'] == 1 && empty($row['end']) ? 'checked="checked"' : '', 'VISIBLE_UNAPROB' => $row['visible'] == 0 ? 'checked="checked"' : '', 'CALENDAR_START' => $calendar_start->display(), 'CALENDAR_END' => $calendar_end->display(), 'CALENDAR_CURRENT_DATE' => $calendar_current_date->display(), 'HOUR' => Date::to_format($row['timestamp'], 'H'), 'MIN' => Date::to_format($row['timestamp'], 'i'), 'DATE' => Date::to_format($row['timestamp'], Date::FORMAT_DAY_MONTH_YEAR), 'L_REQUIRE_QUESTION' => $LANG['require_question'], 'L_REQUIRE_ANSWER' => $LANG['require_answer'], 'L_REQUIRE_ANSWER_TYPE' => $LANG['require_answer_type'], 'L_POLL_MANAGEMENT' => $LANG['poll_management'], 'L_POLL_ADD' => $LANG['poll_add'], 'L_POLL_CONFIG' => $LANG['poll_config'], 'L_REQUIRE' => LangLoader::get_message('form.explain_required_fields', 'status-messages-common'), 'L_QUESTION' => $LANG['question'], 'L_ANSWER_TYPE' => $LANG['answer_type'], 'L_ANSWERS' => $LANG['answers'], 'L_SINGLE' => $LANG['single'], 'L_MULTIPLE' => $LANG['multiple'], 'L_YES' => LangLoader::get_message('yes', 'common'), 'L_NO' => LangLoader::get_message('no', 'common'), 'L_NUMBER_VOTE' => $LANG['number_vote'], 'L_DATE' => LangLoader::get_message('date', 'date-common'), 'L_POLL_DATE' => $LANG['poll_date'], 'L_RELEASE_DATE' => $LANG['release_date'], 'L_IMMEDIATE' => $LANG['immediate'], 'L_UNAPROB' => $LANG['unaprob'], 'L_UNTIL' => $LANG['until'], 'L_UPDATE' => $LANG['update'], 'L_RESET' => $LANG['reset'], 'L_DELETE' => LangLoader::get_message('delete', 'common')));
    //Gestion erreur.
    $get_error = retrieve(GET, 'error', '');
    if ($get_error == 'incomplete') {
        $tpl->put('message_helper', MessageHelper::display($LANG['incomplete'], MessageHelper::NOTICE));
    }
    $array_answer = explode('|', $row['answers']);
    $array_vote = explode('|', $row['votes']);
    $sum_vote = array_sum($array_vote);
    $sum_vote = $sum_vote == 0 ? 1 : $sum_vote;
    //Empêche la division par 0.
    //Liste des choix des sondages => 20 maxi
    $i = 0;
    $array_poll = array_combine($array_answer, $array_vote);
    foreach ($array_poll as $answer => $nbrvote) {
        $percent = NumberHelper::round($nbrvote * 100 / $sum_vote, 1);
        $tpl->assign_block_vars('answers', array('ID' => $i, 'ANSWER' => !empty($answer) ? $answer : ''));
        $tpl->assign_block_vars('votes', array('ID' => $i, 'VOTES' => isset($nbrvote) ? $nbrvote : '', 'PERCENT' => isset($percent) ? $percent . '%' : ''));
        $i++;
    }
    $tpl->put_all(array('MAX_ID' => $i));
    $tpl->display();
} else {
    $_NBR_ELEMENTS_PER_PAGE = 20;
    $tpl = new FileTemplate('poll/admin_poll_management.tpl');
    $nbr_poll = PersistenceContext::get_querier()->count(PREFIX . 'poll');
    //On crée une pagination si le nombre de sondages est trop important.
    $page = AppContext::get_request()->get_getint('p', 1);
    $pagination = new ModulePagination($page, $nbr_poll, $_NBR_ELEMENTS_PER_PAGE);
    $pagination->set_url(new Url('/poll/admin_poll.php?p=%d'));
    if ($pagination->current_page_is_empty() && $page > 1) {
コード例 #25
0
ファイル: stats.php プロジェクト: AroundPBT/PHPBoost
 ###################################################*/
require_once '../kernel/begin.php';
require_once '../forum/forum_begin.php';
require_once '../forum/forum_tools.php';
$Bread_crumb->add($config->get_forum_name(), 'index.php');
$Bread_crumb->add($LANG['stats'], '');
define('TITLE', $LANG['stats']);
require_once '../kernel/header.php';
$tpl = new FileTemplate('forum/forum_stats.tpl');
$total_day = NumberHelper::round((time() - GeneralConfig::load()->get_site_install_date()->get_timestamp()) / (3600 * 24), 0);
$timestamp_today = @mktime(0, 0, 1, Date::to_format(Date::DATE_NOW, 'm'), Date::to_format(Date::DATE_NOW, 'd'), Date::to_format(Date::DATE_NOW, 'y'));
$total_topics = PersistenceContext::get_querier()->count(ForumSetup::$forum_topics_table);
$total_messages = PersistenceContext::get_querier()->count(ForumSetup::$forum_message_table);
$total_day = max(1, $total_day);
$nbr_topics_day = NumberHelper::round($total_topics / $total_day, 1);
$nbr_msg_day = NumberHelper::round($total_messages / $total_day, 1);
$row = PersistenceContext::get_querier()->select_single_row_query("SELECT COUNT(*) as nbr_topics_today\nFROM " . ForumSetup::$forum_topics_table . " t\nJOIN " . ForumSetup::$forum_message_table . " m ON m.id = t.first_msg_id\nWHERE m.timestamp > :timestamp", array('timestamp' => $timestamp_today));
$nbr_topics_today = $row['nbr_topics_today'];
$nbr_msg_today = PersistenceContext::get_querier()->count(ForumSetup::$forum_message_table, 'WHERE timestamp > :timestamp', array('timestamp' => $timestamp_today));
$vars_tpl = array('FORUM_NAME' => $config->get_forum_name(), 'NBR_TOPICS' => $total_topics, 'NBR_MSG' => $total_messages, 'NBR_TOPICS_DAY' => $nbr_topics_day, 'NBR_MSG_DAY' => $nbr_msg_day, 'NBR_TOPICS_TODAY' => $nbr_topics_today, 'NBR_MSG_TODAY' => $nbr_msg_today, 'L_FORUM_INDEX' => $LANG['forum_index'], 'L_FORUM' => $LANG['forum'], 'L_STATS' => $LANG['stats'], 'L_NBR_TOPICS' => $total_topics > 1 ? $LANG['topic_s'] : $LANG['topic'], 'L_NBR_MSG' => $total_messages > 1 ? $LANG['message_s'] : $LANG['message'], 'L_NBR_TOPICS_DAY' => $LANG['nbr_topics_day'], 'L_NBR_MSG_DAY' => $LANG['nbr_msg_day'], 'L_NBR_TOPICS_TODAY' => $LANG['nbr_topics_today'], 'L_NBR_MSG_TODAY' => $LANG['nbr_msg_today'], 'L_LAST_MSG' => $LANG['forum_last_msg'], 'L_POPULAR' => $LANG['forum_popular'], 'L_ANSWERS' => $LANG['forum_nbr_answers']);
//Vérification des autorisations.
$authorized_categories = ForumService::get_authorized_categories(Category::ROOT_CATEGORY);
//Dernières réponses
$result = PersistenceContext::get_querier()->select("SELECT t.id, t.title, c.id as cid, c.auth\nFROM " . PREFIX . "forum_topics t\nLEFT JOIN " . PREFIX . "forum_cats c ON c.id = t.idcat\nWHERE c.id_parent != 0 AND c.id IN :authorized_categories\nORDER BY t.last_timestamp DESC\nLIMIT 10", array('authorized_categories' => $authorized_categories));
while ($row = $result->fetch()) {
    $tpl->assign_block_vars('last_msg', array('U_TOPIC_ID' => url('.php?id=' . $row['id'], '-' . $row['id'] . '.php'), 'TITLE' => stripslashes($row['title'])));
}
$result->dispose();
//Les plus vus
$result = PersistenceContext::get_querier()->select("SELECT t.id, t.title, c.id as cid, c.auth\nFROM " . PREFIX . "forum_topics t\nLEFT JOIN " . PREFIX . "forum_cats c ON c.id = t.idcat\nWHERE c.id_parent != 0 AND c.id IN :authorized_categories\nORDER BY t.nbr_views DESC\nLIMIT 10", array('authorized_categories' => $authorized_categories));
while ($row = $result->fetch()) {
コード例 #26
0
ファイル: admin_stats.php プロジェクト: AroundPBT/PHPBoost
                    } else {
                        $stats_array[$name] = $array_info[1];
                    }
                } else {
                    if (isset($array_info[0])) {
                        $name = ucwords($key);
                        if (array_key_exists($name, $stats_array)) {
                            $stats_array[$name] = $stats_array[$name] + $array_info[0];
                        } else {
                            $stats_array[$name] = $array_info[0];
                        }
                    }
                }
            }
        }
        if ($robots_visits_number) {
            $Stats = new ImagesStats();
            $Stats->load_data($stats_array, 'ellipse');
            foreach ($Stats->data_stats as $key => $angle_value) {
                $array_color = $Stats->array_allocated_color[$Stats->image_color_allocate_dark(false, NO_ALLOCATE_COLOR)];
                $name = ucfirst($key);
                $tpl->assign_block_vars('list', array('COLOR' => 'RGB(' . $array_color[0] . ', ' . $array_color[1] . ', ' . $array_color[2] . ')', 'VIEWS' => NumberHelper::round($angle_value * $Stats->nbr_entry / 360, 0), 'PERCENT' => NumberHelper::round($angle_value / 3.6, 1), 'L_NAME' => $name == 'Other' ? $LANG['other'] : $name));
            }
        }
        $tpl->put_all(array('C_STATS_ROBOTS' => true, 'C_ROBOTS_DATA' => $robots_visits_number, 'L_ERASE_RAPPORT' => $LANG['erase_rapport'], 'L_ERASE' => $LANG['erase'], 'L_COLORS' => $LANG['colors'], 'L_VIEW_NUMBER' => $LANG['number_r_visit'], 'L_LAST_UPDATE' => $LANG['last_update']));
    } else {
        $tpl->put_all(array('C_STATS_SITE' => true, 'START' => GeneralConfig::load()->get_site_install_date()->format(Date::FORMAT_DAY_MONTH_YEAR), 'VERSION' => Environment::get_phpboost_version(), 'BUILD' => GeneralConfig::load()->get_phpboost_major_version(), 'L_START' => $LANG['start'], 'L_KERNEL_VERSION' => $LANG['kernel_version']));
    }
    $tpl->display();
}
require_once '../admin/admin_footer.php';
コード例 #27
0
    private function build_view()
    {
        global $LANG, $Bread_crumb;
        load_module_lang('gallery');
        $g_idpics = retrieve(GET, 'id', 0);
        $g_views = retrieve(GET, 'views', false);
        $g_notes = retrieve(GET, 'notes', false);
        $g_sort = retrieve(GET, 'sort', '');
        $g_sort = !empty($g_sort) ? 'sort=' . $g_sort : '';
        //Récupération du mode d'ordonnement.
        if (preg_match('`([a-z]+)_([a-z]+)`', $g_sort, $array_match)) {
            $g_type = $array_match[1];
            $g_mode = $array_match[2];
        } else {
            list($g_type, $g_mode) = array('date', 'desc');
        }
        $comments_topic = new GalleryCommentsTopic();
        $config = GalleryConfig::load();
        $category = $this->get_category();
        $categories = GalleryService::get_categories_manager()->get_categories_cache()->get_childrens($category->get_id());
        $authorized_categories = GalleryService::get_authorized_categories($category->get_id());
        $Gallery = new Gallery();
        $nbr_pics = $this->db_querier->count(GallerySetup::$gallery_table, 'WHERE idcat=:idcat AND aprob = 1', array('idcat' => $category->get_id()));
        $total_cat = count($categories);
        //On crée une pagination si le nombre de catégories est trop important.
        $page = AppContext::get_request()->get_getint('p', 1);
        $pagination = new ModulePagination($page, $total_cat, $config->get_categories_number_per_page());
        $pagination->set_url(new Url('/gallery/gallery.php?p=%d&amp;cat=' . $category->get_id() . '&amp;id=' . $g_idpics . '&amp;' . $g_sort));
        if ($pagination->current_page_is_empty() && $page > 1) {
            $error_controller = PHPBoostErrors::unexisting_page();
            DispatchManager::redirect($error_controller);
        }
        //Colonnes des catégories.
        $nbr_column_cats = $total_cat > $config->get_columns_number() ? $config->get_columns_number() : $total_cat;
        $nbr_column_cats = !empty($nbr_column_cats) ? $nbr_column_cats : 1;
        $column_width_cats = floor(100 / $nbr_column_cats);
        //Colonnes des images.
        $nbr_column_pics = $nbr_pics > $config->get_columns_number() ? $config->get_columns_number() : $nbr_pics;
        $nbr_column_pics = !empty($nbr_column_pics) ? $nbr_column_pics : 1;
        $column_width_pics = floor(100 / $nbr_column_pics);
        $is_admin = AppContext::get_current_user()->check_level(User::ADMIN_LEVEL);
        $is_modo = GalleryAuthorizationsService::check_authorizations($category->get_id())->moderation();
        $module_data_path = $this->tpl->get_pictures_data_path();
        $rewrite_title = Url::encode_rewrite($category->get_name());
        ##### Catégorie disponibles #####
        $nbr_cat_displayed = 0;
        if ($total_cat > 0 && empty($g_idpics)) {
            $this->tpl->put('C_GALLERY_CATS', true);
            $j = 0;
            $result = $this->db_querier->select('SELECT @id_cat:= gallery_cats.id, gallery_cats.*,
			(SELECT COUNT(*) FROM ' . GallerySetup::$gallery_table . '
				WHERE idcat IN (
					@id_cat,
					(SELECT GROUP_CONCAT(id SEPARATOR \',\') FROM ' . GallerySetup::$gallery_cats_table . ' WHERE id_parent = @id_cat), 
					(SELECT GROUP_CONCAT(childs.id SEPARATOR \',\') FROM ' . GallerySetup::$gallery_cats_table . ' parents
					INNER JOIN ' . GallerySetup::$gallery_cats_table . ' childs ON parents.id = childs.id_parent
					WHERE parents.id_parent = @id_cat)
				)
				AND aprob = 1
			) AS nbr_pics
			FROM ' . GallerySetup::$gallery_cats_table . ' gallery_cats
			WHERE id_parent = :id_category
			AND id IN :authorized_categories
			ORDER BY id_parent, c_order
			LIMIT :number_items_per_page OFFSET :display_from', array('id_category' => $category->get_id(), 'authorized_categories' => $authorized_categories, 'number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from()));
            while ($row = $result->fetch()) {
                $category_image = new Url($row['image']);
                $this->tpl->assign_block_vars('sub_categories_list', array('C_CATEGORY_IMAGE' => !empty($row['image']), 'CATEGORY_NAME' => $row['name'], 'CATEGORY_IMAGE' => $category_image->rel(), 'PICTURES_NUMBER' => sprintf($LANG['nbr_pics_info'], $row['nbr_pics']), 'U_CATEGORY' => GalleryUrlBuilder::get_link_cat($row['id'], $row['name'])));
                $nbr_cat_displayed++;
            }
            $result->dispose();
        }
        $category_description = FormatingHelper::second_parse($category->get_description());
        $this->tpl->put_all(array('C_ROOT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY, 'C_CATEGORY_DESCRIPTION' => $category_description, 'C_SUB_CATEGORIES' => $nbr_cat_displayed > 0, 'C_SUBCATEGORIES_PAGINATION' => $pagination->has_several_pages(), 'SUBCATEGORIES_PAGINATION' => $pagination->display(), 'ARRAY_JS' => '', 'NBR_PICS' => 0, 'MAX_START' => 0, 'START_THUMB' => 0, 'END_THUMB' => 0, 'COLUMNS_NUMBER' => $nbr_column_pics, 'CATS_COLUMNS_WIDTH' => $column_width_cats, 'COLUMN_WIDTH_PICS' => $column_width_pics, 'CATEGORY_DESCRIPTION' => $category_description, 'U_EDIT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY ? GalleryUrlBuilder::configuration()->rel() : GalleryUrlBuilder::edit_category($category->get_id())->rel(), 'CAT_ID' => $category->get_id(), 'DISPLAY_MODE' => $config->get_pics_enlargement_mode(), 'GALLERY' => $category->get_id() != Category::ROOT_CATEGORY ? $this->lang['module_title'] . ' - ' . $category->get_name() : $this->lang['module_title'], 'HEIGHT_MAX' => $config->get_mini_max_height(), 'WIDTH_MAX' => $column_width_pics, 'MODULE_DATA_PATH' => $module_data_path, 'L_APROB' => $LANG['aprob'], 'L_UNAPROB' => $LANG['unaprob'], 'L_FILE_FORBIDDEN_CHARS' => $LANG['file_forbidden_chars'], 'L_TOTAL_IMG' => $category->get_id() != Category::ROOT_CATEGORY ? sprintf($LANG['total_img_cat'], $nbr_pics) : '', 'L_ADD_IMG' => $LANG['add_pic'], 'L_GALLERY' => $this->lang['module_title'], 'L_CATEGORIES' => $category->get_id_parent() >= 0 ? $LANG['sub_album'] : $LANG['album'], 'L_NAME' => $LANG['name'], 'L_EDIT' => LangLoader::get_message('edit', 'common'), 'L_MOVETO' => $LANG['moveto'], 'L_DELETE' => LangLoader::get_message('delete', 'common'), 'L_SUBMIT' => $LANG['submit'], 'L_ALREADY_VOTED' => $LANG['already_vote'], 'L_ORDER_BY' => LangLoader::get_message('sort_by', 'common') . (isset($LANG[$g_type]) ? ' ' . strtolower($LANG[$g_type]) : ''), 'L_DIRECTION' => $LANG['direction'], 'L_DISPLAY' => LangLoader::get_message('display', 'common'), 'U_INDEX' => url('.php'), 'U_BEST_VIEWS' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?views=1&amp;cat=' . $category->get_id(), '-' . $category->get_id() . '.php?views=1'), 'U_BEST_NOTES' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?notes=1&amp;cat=' . $category->get_id(), '-' . $category->get_id() . '.php?notes=1'), 'U_ASC' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?cat=' . $category->get_id() . '&amp;sort=' . $g_type . '_' . 'asc', '-' . $category->get_id() . '.php?sort=' . $g_type . '_' . 'asc'), 'U_DESC' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?cat=' . $category->get_id() . '&amp;sort=' . $g_type . '_' . 'desc', '-' . $category->get_id() . '.php?sort=' . $g_type . '_' . 'desc'), 'U_ORDER_BY_NAME' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?sort=name_desc&amp;cat=' . $category->get_id(), '-' . $category->get_id() . '+' . $rewrite_title . '.php?sort=name_desc'), 'U_ORDER_BY_DATE' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?sort=date_desc&amp;cat=' . $category->get_id(), '-' . $category->get_id() . '+' . $rewrite_title . '.php?sort=date_desc'), 'U_ORDER_BY_VIEWS' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?sort=views_desc&amp;cat=' . $category->get_id(), '-' . $category->get_id() . '+' . $rewrite_title . '.php?sort=views_desc'), 'U_ORDER_BY_NOTES' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?sort=notes_desc&amp;cat=' . $category->get_id(), '-' . $category->get_id() . '+' . $rewrite_title . '.php?sort=notes_desc'), 'U_ORDER_BY_COM' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?sort=com_desc&amp;cat=' . $category->get_id(), '-' . $category->get_id() . '+' . $rewrite_title . '.php?sort=com_desc'), 'L_BEST_VIEWS' => $LANG['best_views'], 'L_BEST_NOTES' => $LANG['best_notes'], 'L_ASC' => $LANG['asc'], 'L_DESC' => $LANG['desc'], 'L_DATE' => LangLoader::get_message('date', 'date-common'), 'L_VIEWS' => $LANG['views'], 'L_NOTES' => LangLoader::get_message('notes', 'common'), 'L_COM' => $LANG['com_s']));
        ##### Affichage des photos #####
        if ($nbr_pics > 0) {
            switch ($g_type) {
                case 'name':
                    $sort_type = 'g.name';
                    break;
                case 'date':
                    $sort_type = 'g.timestamp';
                    break;
                case 'views':
                    $sort_type = 'g.views';
                    break;
                case 'notes':
                    $sort_type = 'notes.average_notes';
                    break;
                case 'com':
                    $sort_type = 'com.number_comments';
                    break;
                default:
                    $sort_type = 'g.timestamp';
            }
            switch ($g_mode) {
                case 'desc':
                    $sort_mode = 'DESC';
                    break;
                case 'asc':
                    $sort_mode = 'ASC';
                    break;
                default:
                    $sort_mode = 'DESC';
            }
            $g_sql_sort = ' ORDER BY ' . $sort_type . ' ' . $sort_mode;
            if ($g_views) {
                $g_sql_sort = ' ORDER BY g.views DESC';
            } elseif ($g_notes) {
                $g_sql_sort = ' ORDER BY notes.average_notes DESC';
            }
            $this->tpl->put('C_GALLERY_PICS', true);
            //Affichage d'une photo demandée.
            if (!empty($g_idpics)) {
                $info_pics = $this->db_querier->select_single_row_query("SELECT g.*, m.display_name, m.groups, m.level, notes.average_notes, notes.number_notes, note.note\n\t\t\t\t\tFROM " . GallerySetup::$gallery_table . " g\n\t\t\t\t\tLEFT JOIN " . DB_TABLE_MEMBER . " m ON m.user_id = g.user_id\n\t\t\t\t\tLEFT JOIN " . DB_TABLE_COMMENTS_TOPIC . " com ON com.id_in_module = g.id AND com.module_id = 'gallery'\n\t\t\t\t\tLEFT JOIN " . DB_TABLE_AVERAGE_NOTES . " notes ON notes.id_in_module = g.id AND notes.module_name = 'gallery'\n\t\t\t\t\tLEFT JOIN " . DB_TABLE_NOTE . " note ON note.id_in_module = g.id AND note.module_name = 'gallery' AND note.user_id = :user_id\n\t\t\t\t\tWHERE g.idcat = :idcat AND g.id = :id AND g.aprob = 1\n\t\t\t\t\t" . $g_sql_sort, array('user_id' => AppContext::get_current_user()->get_id(), 'idcat' => $category->get_id(), 'id' => $g_idpics));
                if (!empty($info_pics['id'])) {
                    $Bread_crumb->add(stripslashes($info_pics['name']), PATH_TO_ROOT . '/gallery/gallery' . url('.php?cat=' . $info_pics['idcat'] . '&amp;id=' . $info_pics['id'], '-' . $info_pics['idcat'] . '-' . $info_pics['id'] . '.php'));
                    //Affichage miniatures.
                    $id_previous = 0;
                    $id_next = 0;
                    $nbr_pics_display_before = floor(($nbr_column_pics - 1) / 2);
                    //Nombres de photos de chaque côté de la miniature de la photo affichée.
                    $nbr_pics_display_after = $nbr_column_pics - 1 - floor($nbr_pics_display_before);
                    list($i, $reach_pics_pos, $pos_pics, $thumbnails_before, $thumbnails_after, $start_thumbnails, $end_thumbnails) = array(0, false, 0, 0, 0, $nbr_pics_display_before, $nbr_pics_display_after);
                    $array_pics = array();
                    $array_js = 'var array_pics = new Array();';
                    $result = $this->db_querier->select("SELECT g.id, g.idcat, g.path\n\t\t\t\t\tFROM " . GallerySetup::$gallery_table . " g\n\t\t\t\t\tWHERE g.idcat = :idcat AND g.aprob = 1\n\t\t\t\t\t" . $g_sql_sort, array('idcat' => $category->get_id()));
                    while ($row = $result->fetch()) {
                        //Si la miniature n'existe pas (cache vidé) on regénère la miniature à partir de l'image en taille réelle.
                        if (!file_exists(PATH_TO_ROOT . '/gallery/pics/thumbnails/' . $row['path'])) {
                            $Gallery->Resize_pics(PATH_TO_ROOT . '/gallery/pics/' . $row['path']);
                        }
                        //Redimensionnement + création miniature
                        //Affichage de la liste des miniatures sous l'image.
                        $array_pics[] = '<td class="center" style="height:' . ($config->get_mini_max_height() + 16) . 'px"><span id="thumb' . $i . '"><a href="gallery' . url('.php?cat=' . $row['idcat'] . '&amp;id=' . $row['id'] . '&amp;sort=' . $g_sort, '-' . $row['idcat'] . '-' . $row['id'] . '.php?sort=' . $g_sort) . '#pics_max' . '"><img src="pics/thumbnails/' . $row['path'] . '" alt="' . $row['path'] . '" /></a></span></td>';
                        if ($row['id'] == $g_idpics) {
                            $reach_pics_pos = true;
                            $pos_pics = $i;
                        } else {
                            if (!$reach_pics_pos) {
                                $thumbnails_before++;
                                $id_previous = $row['id'];
                            } else {
                                $thumbnails_after++;
                                if (empty($id_next)) {
                                    $id_next = $row['id'];
                                }
                            }
                        }
                        $array_js .= 'array_pics[' . $i . '] = new Array();' . "\n";
                        $array_js .= 'array_pics[' . $i . '][\'link\'] = \'' . GalleryUrlBuilder::get_link_item($row['idcat'], $row['id']) . '#pics_max' . "';\n";
                        $array_js .= 'array_pics[' . $i . '][\'path\'] = \'' . $row['path'] . "';\n";
                        $i++;
                    }
                    $result->dispose();
                    $activ_note = $config->is_notation_enabled() && AppContext::get_current_user()->check_level(User::MEMBER_LEVEL);
                    if ($activ_note) {
                        //Affichage notation.
                        $notation = new Notation();
                        $notation->set_module_name('gallery');
                        $notation->set_id_in_module($info_pics['id']);
                        $notation->set_notation_scale($config->get_notation_scale());
                        $notation->set_number_notes($info_pics['number_notes']);
                        $notation->set_average_notes($info_pics['average_notes']);
                        $notation->set_user_already_noted(!empty($info_pics['note']));
                    }
                    if ($thumbnails_before < $nbr_pics_display_before) {
                        $end_thumbnails += $nbr_pics_display_before - $thumbnails_before;
                    }
                    if ($thumbnails_after < $nbr_pics_display_after) {
                        $start_thumbnails += $nbr_pics_display_after - $thumbnails_after;
                    }
                    $html_protected_name = $info_pics['name'];
                    $comments_topic->set_id_in_module($info_pics['id']);
                    $comments_topic->set_url(new Url('/gallery/gallery.php?cat=' . $category->get_id() . '&id=' . $g_idpics . '&com=0'));
                    //Liste des catégories.
                    $search_category_children_options = new SearchCategoryChildrensOptions();
                    $search_category_children_options->add_authorizations_bits(Category::READ_AUTHORIZATIONS);
                    $search_category_children_options->add_authorizations_bits(Category::WRITE_AUTHORIZATIONS);
                    $categories_tree = GalleryService::get_categories_manager()->get_select_categories_form_field($info_pics['id'] . 'cat', '', $info_pics['idcat'], $search_category_children_options);
                    $method = new ReflectionMethod('AbstractFormFieldChoice', 'get_options');
                    $method->setAccessible(true);
                    $categories_tree_options = $method->invoke($categories_tree);
                    $cat_list = '';
                    foreach ($categories_tree_options as $option) {
                        $cat_list .= $option->display()->render();
                    }
                    $group_color = User::get_group_color($info_pics['groups'], $info_pics['level']);
                    //Affichage de l'image et de ses informations.
                    $this->tpl->put_all(array('C_GALLERY_PICS_MAX' => true, 'C_GALLERY_PICS_MODO' => $is_modo, 'C_AUTHOR_DISPLAYED' => $config->is_author_displayed(), 'C_VIEWS_COUNTER_ENABLED' => $config->is_views_counter_enabled(), 'C_TITLE_ENABLED' => $config->is_title_enabled(), 'C_COMMENTS_ENABLED' => $config->are_comments_enabled(), 'C_NOTATION_ENABLED' => $config->is_notation_enabled(), 'ID' => $info_pics['id'], 'NAME' => '<span id="fi_' . $info_pics['id'] . '">' . stripslashes($info_pics['name']) . '</span> <span id="fi' . $info_pics['id'] . '"></span>', 'POSTOR' => '<a class="small ' . UserService::get_level_class($info_pics['level']) . '"' . (!empty($group_color) ? ' style="color:' . $group_color . '"' : '') . ' href="' . UserUrlBuilder::profile($info_pics['user_id'])->rel() . '">' . $info_pics['display_name'] . '</a>', 'DATE' => Date::to_format($info_pics['timestamp'], Date::FORMAT_DAY_MONTH_YEAR), 'VIEWS' => $info_pics['views'] + 1, 'DIMENSION' => $info_pics['width'] . ' x ' . $info_pics['height'], 'SIZE' => NumberHelper::round($info_pics['weight'] / 1024, 1), 'L_COMMENTS' => CommentsService::get_number_and_lang_comments('gallery', $info_pics['id']), 'KERNEL_NOTATION' => $activ_note ? NotationService::display_active_image($notation) : '', 'COLSPAN' => $config->get_columns_number() + 2, 'CAT' => $cat_list, 'RENAME' => $html_protected_name, 'RENAME_CUT' => $html_protected_name, 'IMG_APROB' => $info_pics['aprob'] == 1 ? 'fa fa-eye-slash' : 'fa fa-eye', 'ARRAY_JS' => $array_js, 'NBR_PICS' => $i - 1, 'MAX_START' => $i - 1 - $nbr_column_pics, 'START_THUMB' => $pos_pics - $start_thumbnails > 0 ? $pos_pics - $start_thumbnails : 0, 'END_THUMB' => $pos_pics + $end_thumbnails, 'L_KB' => LangLoader::get_message('unit.kilobytes', 'common'), 'L_INFORMATIONS' => $LANG['informations'], 'L_NAME' => $LANG['name'], 'L_POSTOR' => $LANG['postor'], 'L_VIEWS' => $LANG['views'], 'L_ADD_ON' => $LANG['add_on'], 'L_DIMENSION' => $LANG['dimension'], 'L_SIZE' => $LANG['size'], 'L_NOTE' => LangLoader::get_message('note', 'common'), 'L_COM' => $LANG['com'], 'L_EDIT' => LangLoader::get_message('edit', 'common'), 'L_APROB_IMG' => $info_pics['aprob'] == 1 ? $LANG['unaprob'] : $LANG['aprob'], 'L_THUMBNAILS' => $LANG['thumbnails'], 'U_DEL' => url('gallery.php?del=' . $info_pics['id'] . '&amp;token=' . AppContext::get_session()->get_token() . '&amp;cat=' . $category->get_id()), 'U_MOVE' => url('gallery.php?id=' . $info_pics['id'] . '&amp;token=' . AppContext::get_session()->get_token() . '&amp;move=\' + this.options[this.selectedIndex].value'), 'U_PREVIOUS' => $pos_pics > 0 ? '<a href="' . GalleryUrlBuilder::get_link_item($category->get_id(), $id_previous) . '#pics_max"><i class="fa fa-arrow-left fa-2x"></i></a> <a href="' . GalleryUrlBuilder::get_link_item($category->get_id(), $id_previous) . '#pics_max">' . $LANG['previous'] . '</a>' : '', 'U_NEXT' => $pos_pics < $i - 1 ? '<a href="' . GalleryUrlBuilder::get_link_item($category->get_id(), $id_next) . '#pics_max">' . $LANG['next'] . '</a> <a href="' . GalleryUrlBuilder::get_link_item($category->get_id(), $id_next) . '#pics_max"><i class="fa fa-arrow-right fa-2x"></i></a>' : '', 'U_LEFT_THUMBNAILS' => $pos_pics - $start_thumbnails > 0 ? '<span id="display_left"><a href="javascript:display_thumbnails(\'left\')"><i class="fa fa-arrow-left fa-2x"></i></a></span>' : '<span id="display_left"></span>', 'U_RIGHT_THUMBNAILS' => $pos_pics - $start_thumbnails <= $i - 1 - $nbr_column_pics ? '<span id="display_right"><a href="javascript:display_thumbnails(\'right\')"><i class="fa fa-arrow-right fa-2x"></i></a></span>' : '<span id="display_right"></span>', 'U_COMMENTS' => GalleryUrlBuilder::get_link_item($info_pics['idcat'], $info_pics['id'], 0, $g_sort) . '#comments-list', 'U_IMG_MAX' => 'show_pics.php?id=' . $info_pics['id'] . '&amp;cat=' . $info_pics['idcat']));
                    //Affichage de la liste des miniatures sous l'image.
                    $i = 0;
                    foreach ($array_pics as $pics) {
                        if ($i >= $pos_pics - $start_thumbnails && $i <= $pos_pics + $end_thumbnails) {
                            $this->tpl->assign_block_vars('list_preview_pics', array('PICS' => $pics));
                        }
                        $i++;
                    }
                    //Commentaires
                    if (AppContext::get_request()->get_getint('com', 0) == 0 && $config->are_comments_enabled()) {
                        $this->tpl->put_all(array('COMMENTS' => CommentsService::display($comments_topic)->render()));
                    }
                }
            } else {
                $sort = retrieve(GET, 'sort', '');
                //On crée une pagination si le nombre de photos est trop important.
                $page = AppContext::get_request()->get_getint('pp', 1);
                $pagination = new ModulePagination($page, $nbr_pics, $config->get_pics_number_per_page());
                $pagination->set_url(new Url('/gallery/gallery.php?pp=%d' . (!empty($sort) ? '&amp;sort=' . $sort : '') . '&amp;cat=' . $category->get_id()));
                if ($pagination->current_page_is_empty() && $page > 1) {
                    $error_controller = PHPBoostErrors::unexisting_page();
                    DispatchManager::redirect($error_controller);
                }
                $this->tpl->put_all(array('C_GALLERY_MODO' => $is_modo, 'C_PICTURE_NAME_DISPLAYED' => $config->is_title_enabled(), 'C_AUTHOR_DISPLAYED' => $config->is_author_displayed(), 'C_VIEWS_COUNTER_ENABLED' => $config->is_views_counter_enabled(), 'C_COMMENTS_ENABLED' => $config->are_comments_enabled(), 'C_PAGINATION' => $pagination->has_several_pages(), 'PAGINATION' => $pagination->display(), 'L_EDIT' => LangLoader::get_message('edit', 'common'), 'L_VIEW' => $LANG['view'], 'L_VIEWS' => $LANG['views']));
                $is_connected = AppContext::get_current_user()->check_level(User::MEMBER_LEVEL);
                $j = 0;
                $result = $this->db_querier->select("SELECT g.id, g.idcat, g.name, g.path, g.timestamp, g.aprob, g.width, g.height, g.user_id, g.views, g.aprob, m.display_name, m.groups, m.level, notes.average_notes, notes.number_notes, note.note\n\t\t\t\tFROM " . GallerySetup::$gallery_table . " g\n\t\t\t\tLEFT JOIN " . DB_TABLE_MEMBER . " m ON m.user_id = g.user_id\n\t\t\t\tLEFT JOIN " . DB_TABLE_COMMENTS_TOPIC . " com ON com.id_in_module = g.id AND com.module_id = 'gallery'\n\t\t\t\tLEFT JOIN " . DB_TABLE_AVERAGE_NOTES . " notes ON notes.id_in_module = g.id AND notes.module_name = 'gallery'\n\t\t\t\tLEFT JOIN " . DB_TABLE_NOTE . " note ON note.id_in_module = g.id AND note.module_name = 'gallery' AND note.user_id = :user_id\n\t\t\t\tWHERE g.idcat = :idcat AND g.aprob = 1\n\t\t\t\t" . $g_sql_sort . "\n\t\t\t\tLIMIT :number_items_per_page OFFSET :display_from", array('user_id' => AppContext::get_current_user()->get_id(), 'idcat' => $category->get_id(), 'number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from()));
                while ($row = $result->fetch()) {
                    //Si la miniature n'existe pas (cache vidé) on regénère la miniature à partir de l'image en taille réelle.
                    if (!file_exists(PATH_TO_ROOT . '/gallery/pics/thumbnails/' . $row['path'])) {
                        $Gallery->Resize_pics(PATH_TO_ROOT . '/gallery/pics/' . $row['path']);
                    }
                    //Redimensionnement + création miniature
                    $onclick = '';
                    //Affichage de l'image en grand.
                    if ($config->get_pics_enlargement_mode() == GalleryConfig::FULL_SCREEN) {
                        $display_link = PATH_TO_ROOT . '/gallery/pics/' . $row['path'] . '" onmousedown="increment_view(' . $row['id'] . ');" title="' . str_replace('"', '', stripslashes($row['name']));
                    } elseif ($config->get_pics_enlargement_mode() == GalleryConfig::POPUP) {
                        $onclick = 'increment_view(' . $row['id'] . ');display_pics_popup(\'' . PATH_TO_ROOT . '/gallery/show_pics' . url('.php?id=' . $row['id'] . '&amp;cat=' . $row['idcat']) . '\', \'' . $row['width'] . '\', \'' . $row['height'] . '\');return false;';
                        $display_link = '';
                    } elseif ($config->get_pics_enlargement_mode() == GalleryConfig::RESIZE) {
                        $onclick = 'increment_view(' . $row['id'] . ');display_pics(' . $row['id'] . ', \'' . PATH_TO_ROOT . '/gallery/show_pics' . url('.php?id=' . $row['id'] . '&amp;cat=' . $row['idcat']) . '\');return false;';
                        $display_link = '';
                    } else {
                        $onclick = true;
                        $display_link = url('gallery.php?cat=' . $row['idcat'] . '&amp;id=' . $row['id'], 'gallery-' . $row['idcat'] . '-' . $row['id'] . '.php') . '#pics_max';
                    }
                    //Liste des catégories.
                    $search_category_children_options = new SearchCategoryChildrensOptions();
                    $search_category_children_options->add_authorizations_bits(Category::READ_AUTHORIZATIONS);
                    $search_category_children_options->add_authorizations_bits(Category::WRITE_AUTHORIZATIONS);
                    $categories_tree = GalleryService::get_categories_manager()->get_select_categories_form_field($row['id'] . 'cat', '', $row['idcat'], $search_category_children_options);
                    $method = new ReflectionMethod('AbstractFormFieldChoice', 'get_options');
                    $method->setAccessible(true);
                    $categories_tree_options = $method->invoke($categories_tree);
                    $cat_list = '';
                    foreach ($categories_tree_options as $option) {
                        $cat_list .= $option->display()->render();
                    }
                    $notation = new Notation();
                    $notation->set_module_name('gallery');
                    $notation->set_notation_scale($config->get_notation_scale());
                    $notation->set_id_in_module($row['id']);
                    $notation->set_number_notes($row['number_notes']);
                    $notation->set_average_notes($row['average_notes']);
                    $notation->set_user_already_noted(!empty($row['note']));
                    $group_color = User::get_group_color($row['groups'], $row['level']);
                    $comments_topic->set_id_in_module($row['id']);
                    $html_protected_name = $row['name'];
                    $this->tpl->assign_block_vars('pics_list', array('C_IMG_APROB' => $row['aprob'] == 1, 'C_OPEN_TR' => is_int($j++ / $nbr_column_pics), 'C_CLOSE_TR' => is_int($j / $nbr_column_pics), 'ID' => $row['id'], 'APROB' => $row['aprob'], 'PATH' => $row['path'], 'NAME' => stripslashes($row['name']), 'SHORT_NAME' => TextHelper::wordwrap_html(stripslashes($row['name']), 22, ' '), 'POSTOR' => $LANG['by'] . (!empty($row['display_name']) ? ' <a class="small ' . UserService::get_level_class($row['level']) . '"' . (!empty($group_color) ? ' style="color:' . $group_color . '"' : '') . ' href="' . UserUrlBuilder::profile($row['user_id'])->rel() . '">' . $row['display_name'] . '</a>' : ' ' . $LANG['guest']), 'VIEWS' => $row['views'], 'L_VIEWS' => $row['views'] > 1 ? $LANG['views'] : $LANG['view'], 'L_COMMENTS' => CommentsService::get_number_and_lang_comments('gallery', $row['id']), 'KERNEL_NOTATION' => $config->is_notation_enabled() && $is_connected ? NotationService::display_active_image($notation) : NotationService::display_static_image($notation), 'CAT' => $cat_list, 'ONCLICK' => $onclick, 'RENAME' => $html_protected_name, 'RENAME_CUT' => $html_protected_name, 'L_APROB_IMG' => $row['aprob'] == 1 ? $LANG['unaprob'] : $LANG['aprob'], 'U_PICTURE_LINK' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?cat=' . $row['idcat'] . '&amp;id=' . $row['id'], '-' . $row['idcat'] . '-' . $row['id'] . '.php'), 'U_PICTURE' => PATH_TO_ROOT . '/gallery/pics/thumbnails/' . $row['path'], 'U_DEL' => url('gallery.php?del=' . $row['id'] . '&amp;token=' . AppContext::get_session()->get_token() . '&amp;cat=' . $category->get_id()), 'U_MOVE' => url('gallery.php?id=' . $row['id'] . '&amp;token=' . AppContext::get_session()->get_token() . '&amp;move=\' + this.options[this.selectedIndex].value'), 'U_DISPLAY' => $display_link, 'U_COMMENTS' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?cat=' . $row['idcat'] . '&amp;id=' . $row['id'] . '&amp;com=0', '-' . $row['idcat'] . '-' . $row['id'] . '.php?com=0') . '#comments-list'));
                }
                $result->dispose();
                //Création des cellules du tableau si besoin est.
                while (!is_int($j / $nbr_column_pics)) {
                    $this->tpl->assign_block_vars('end_table', array('TD_END' => '<td class="td-end" style="width:' . $column_width_pics . '%">&nbsp;</td>', 'TR_END' => is_int(++$j / $nbr_column_pics) ? '</tr>' : ''));
                }
            }
        }
    }
コード例 #28
0
 private function get_raw_float($value, $varname, $default_value)
 {
     if (is_float($value)) {
         return NumberHelper::numeric($value, 'float');
     }
     if ($default_value !== null) {
         return $default_value;
     } else {
         throw new ParameterTypeMismatchException($varname, 'float', $value);
     }
 }
コード例 #29
0
ファイル: number_helper.php プロジェクト: joeymetal/v1
 public function test_for_NumberHelper()
 {
     $number = new NumberHelper();
     $this->assertEqual($number->number_to_phone(1235551234), '123-555-1234');
     $this->assertEqual($number->number_to_phone(1235551234, array('area_code' => true)), '(123) 555-1234');
     $this->assertEqual($number->number_to_phone(1235551234, array('delimiter' => ' ')), '123 555 1234');
     $this->assertEqual($number->number_to_phone(1235551234, array('area_code' => true, 'extension' => 555)), '(123) 555-1234 x 555');
     $this->assertEqual($number->number_to_currency("1234567890.50"), '$1,234,567,890.50');
     $this->assertEqual($number->number_to_currency(123456789.123456, array('precision' => 2, 'unit' => ' Skk', 'unit_position' => 'right', 'separator' => ',', 'delimiter' => ' ')), '123 456 789,12 Skk');
     $this->assertEqual($number->number_to_currency("1234567890.50"), '$1,234,567,890.50');
     $this->assertEqual($number->number_to_currency(1234567890.506), '$1,234,567,890.51');
     $this->assertEqual($number->number_to_currency(1234567890.5, array('unit' => "&pound;", 'separator' => ",", 'delimiter' => "")), '&pound;1234567890,50');
     $this->assertEqual($number->number_to_currency(1234567890.5, array('unit' => " &euro;", 'separator' => ",", 'delimiter' => ".", 'unit_position' => 'right')), '1.234.567.890,50 &euro;');
     $this->assertEqual($number->number_to_percentage(100), '100.00%');
     $this->assertEqual($number->number_to_percentage(100, array('precision' => 0)), '100%');
     $this->assertEqual($number->number_to_percentage(302.0576, array('precision' => 3)), '302.058%');
     $this->assertEqual($number->number_with_delimiter(12345678), '12,345,678');
     $this->assertEqual($number->number_with_delimiter(12345678.2), '12,345,678.2');
     $this->assertEqual($number->human_size(123), '123 Bytes');
     $this->assertEqual($number->human_size(1234), '1.2 KB');
     $this->assertEqual($number->human_size(12345), '12.1 KB');
     $this->assertEqual($number->human_size(1234567), '1.2 MB');
     $this->assertEqual($number->human_size(1234567890), '1.1 GB');
     $this->assertEqual($number->human_size_to_bytes('123 Bytes'), 123);
     $this->assertEqual($number->human_size_to_bytes('1.2 KB'), 1229);
     $this->assertEqual($number->human_size_to_bytes('12.1 KB'), 12391);
     $this->assertEqual($number->human_size_to_bytes('1.2 MB'), 1258292);
     $this->assertEqual($number->human_size_to_bytes('1.1 GB'), 1181116007);
     $this->assertEqual($number->number_with_precision(111.2345), '111.235');
     $this->assertEqual($number->zeropad(123, 6), '000123');
     $this->assertEqual($number->zeropad('0123', 6), '000123');
     $this->assertEqual($number->zeropad(12345, 2), '12345');
 }
コード例 #30
0
ファイル: FeedMenu.class.php プロジェクト: AroundPBT/PHPBoost
 /**
  * @param int $value the feed's category
  */
 public function set_cat($value)
 {
     $this->category = is_numeric($value) ? NumberHelper::numeric($value) : 0;
 }