当前位置: 首页>>代码示例>>PHP>>正文


PHP tpl::setloop方法代码示例

本文整理汇总了PHP中tpl::setloop方法的典型用法代码示例。如果您正苦于以下问题:PHP tpl::setloop方法的具体用法?PHP tpl::setloop怎么用?PHP tpl::setloop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tpl的用法示例。


在下文中一共展示了tpl::setloop方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: show

 function show()
 {
     global $app, $conf;
     //* Loading Template
     $app->uses('tpl');
     $tpl = new tpl();
     $tpl->newTemplate("dashlets/templates/modules.htm");
     $wb = array();
     $lng_file = 'lib/lang/' . $_SESSION['s']['language'] . '_dashlet_modules.lng';
     if (is_file($lng_file)) {
         include $lng_file;
     }
     $tpl->setVar($wb);
     /*
      * Show all modules, the user is allowed to use
      */
     $modules = explode(',', $_SESSION['s']['user']['modules']);
     $mod = array();
     if (is_array($modules)) {
         foreach ($modules as $mt) {
             if (is_file('../' . $mt . '/lib/module.conf.php')) {
                 if (!preg_match("/^[a-z]{2,20}\$/i", $mt)) {
                     die('module name contains unallowed chars.');
                 }
                 include_once '../' . $mt . '/lib/module.conf.php';
                 /* We don't want to show the dashboard */
                 if ($mt != 'dashboard') {
                     $module_title = $app->lng($module['title']);
                     if (function_exists('mb_strlen')) {
                         if (mb_strlen($module_title, "UTF-8") > 8) {
                             $module_title = mb_substr($module_title, 0, 7, "UTF-8") . '..';
                         }
                     } else {
                         if (strlen($module_title) > 8) {
                             $module_title = substr($module_title, 0, 7) . '..';
                         }
                     }
                     $mod[] = array('modules_title' => $module_title, 'modules_startpage' => $module['startpage'], 'modules_name' => $module['name']);
                 }
             }
         }
         $tpl->setloop('modules', $mod);
     }
     return $tpl->grab();
 }
开发者ID:shoaibali,项目名称:ispconfig3,代码行数:45,代码来源:modules.php

示例2: show

 function show()
 {
     global $app, $conf;
     //* Loading Template
     $app->uses('tpl');
     $tpl = new tpl();
     $tpl->newTemplate("dashlets/templates/mailquota.htm");
     $wb = array();
     $lng_file = 'lib/lang/' . $_SESSION['s']['language'] . '_dashlet_mailquota.lng';
     if (is_file($lng_file)) {
         include $lng_file;
     }
     $tpl->setVar($wb);
     $tmp_rec = $app->db->queryAllRecords("SELECT data from monitor_data WHERE type = 'email_quota' ORDER BY created DESC");
     $monitor_data = array();
     if (is_array($tmp_rec)) {
         foreach ($tmp_rec as $tmp_mon) {
             //$monitor_data = array_merge_recursive($monitor_data,unserialize($app->db->unquote($tmp_mon['data'])));
             $tmp_array = unserialize($app->db->unquote($tmp_mon['data']));
             if (is_array($tmp_array)) {
                 foreach ($tmp_array as $username => $data) {
                     if (!$monitor_data[$username]['used']) {
                         $monitor_data[$username]['used'] = $data['used'];
                     }
                 }
             }
         }
     }
     //print_r($monitor_data);
     if ($_SESSION["s"]["user"]["typ"] != 'admin') {
         $sql_where = " AND sys_groupid = " . intval($_SESSION['s']['user']['default_group']);
     }
     $has_mailquota = false;
     // select email accounts belonging to client
     $emails = $app->db->queryAllRecords("SELECT * FROM mail_user WHERE 1" . $sql_where);
     //print_r($emails);
     if (is_array($emails) && !empty($emails)) {
         for ($i = 0; $i < sizeof($emails); $i++) {
             $email = $emails[$i]['email'];
             $emails[$i]['used'] = isset($monitor_data[$email]['used']) ? $monitor_data[$email]['used'] : array(1 => 0);
             if (!is_numeric($emails[$i]['used'])) {
                 $emails[$i]['used'] = $emails[$i]['used'][1];
             }
             // colours
             $emails[$i]['display_colour'] = '#000000';
             if ($emails[$i]['quota'] > 0) {
                 $used_ratio = $emails[$i]['used'] / $emails[$i]['quota'];
             } else {
                 $used_ratio = 0;
             }
             if ($used_ratio >= 0.8) {
                 $emails[$i]['display_colour'] = '#fd934f';
             }
             if ($used_ratio >= 1) {
                 $emails[$i]['display_colour'] = '#cc0000';
             }
             if ($emails[$i]['quota'] == 0) {
                 $emails[$i]['quota'] = $app->lng('unlimited');
             } else {
                 $emails[$i]['quota'] = round($emails[$i]['quota'] / 1048576, 4) . ' MB';
             }
             if ($emails[$i]['used'] < 1544000) {
                 $emails[$i]['used'] = round($emails[$i]['used'] / 1024, 4) . ' KB';
             } else {
                 $emails[$i]['used'] = round($emails[$i]['used'] / 1048576, 4) . ' MB';
             }
         }
         $has_mailquota = true;
         $tpl->setloop('mailquota', $emails);
     }
     //print_r($sites);
     $tpl->setVar('has_mailquota', $has_mailquota);
     return $tpl->grab();
 }
开发者ID:istrwei,项目名称:ISPCluster,代码行数:74,代码来源:mailquota.php

示例3: show


//.........这里部分代码省略.........
     $tpl->newTemplate("dashlets/templates/quota.htm");
     $wb = array();
     $lng_file = 'lib/lang/' . $_SESSION['s']['language'] . '_dashlet_quota.lng';
     if (is_file($lng_file)) {
         include $lng_file;
     }
     $tpl->setVar($wb);
     $tmp_rec = $app->db->queryAllRecords("SELECT data from monitor_data WHERE type = 'harddisk_quota' ORDER BY created DESC");
     $monitor_data = array();
     if (is_array($tmp_rec)) {
         foreach ($tmp_rec as $tmp_mon) {
             $monitor_data = array_merge_recursive($monitor_data, unserialize($app->db->unquote($tmp_mon['data'])));
         }
     }
     //print_r($monitor_data);
     if ($_SESSION["s"]["user"]["typ"] != 'admin') {
         $sql_where = " AND sys_groupid = " . $app->functions->intval($_SESSION['s']['user']['default_group']);
     }
     $has_quota = false;
     // select websites belonging to client
     $sites = $app->db->queryAllRecords("SELECT * FROM web_domain WHERE active = 'y' AND type = 'vhost'" . $sql_where);
     //print_r($sites);
     if (is_array($sites) && !empty($sites)) {
         for ($i = 0; $i < sizeof($sites); $i++) {
             $username = $sites[$i]['system_user'];
             $sites[$i]['used'] = $monitor_data['user'][$username]['used'];
             $sites[$i]['soft'] = $monitor_data['user'][$username]['soft'];
             $sites[$i]['hard'] = $monitor_data['user'][$username]['hard'];
             $sites[$i]['files'] = $monitor_data['user'][$username]['files'];
             if (!is_numeric($sites[$i]['used'])) {
                 if ($sites[$i]['used'][0] > $sites[$i]['used'][1]) {
                     $sites[$i]['used'] = $sites[$i]['used'][0];
                 } else {
                     $sites[$i]['used'] = $sites[$i]['used'][1];
                 }
             }
             if (!is_numeric($sites[$i]['soft'])) {
                 $sites[$i]['soft'] = $sites[$i]['soft'][1];
             }
             if (!is_numeric($sites[$i]['hard'])) {
                 $sites[$i]['hard'] = $sites[$i]['hard'][1];
             }
             if (!is_numeric($sites[$i]['files'])) {
                 $sites[$i]['files'] = $sites[$i]['files'][1];
             }
             // colours
             $sites[$i]['display_colour'] = '#000000';
             if ($sites[$i]['soft'] > 0) {
                 $used_ratio = $sites[$i]['used'] / $sites[$i]['soft'];
             } else {
                 $used_ratio = 0;
             }
             if ($used_ratio >= 0.8) {
                 $sites[$i]['display_colour'] = '#fd934f';
             }
             if ($used_ratio >= 1) {
                 $sites[$i]['display_colour'] = '#cc0000';
             }
             if ($sites[$i]['used'] > 1024) {
                 $sites[$i]['used'] = round($sites[$i]['used'] / 1024, 2) . ' MB';
             } else {
                 if ($sites[$i]['used'] != '') {
                     $sites[$i]['used'] .= ' KB';
                 }
             }
             if ($sites[$i]['soft'] > 1024) {
                 $sites[$i]['soft'] = round($sites[$i]['soft'] / 1024, 2) . ' MB';
             } else {
                 $sites[$i]['soft'] .= ' KB';
             }
             if ($sites[$i]['hard'] > 1024) {
                 $sites[$i]['hard'] = round($sites[$i]['hard'] / 1024, 2) . ' MB';
             } else {
                 $sites[$i]['hard'] .= ' KB';
             }
             if ($sites[$i]['soft'] == " KB") {
                 $sites[$i]['soft'] = $app->lng('unlimited');
             }
             if ($sites[$i]['hard'] == " KB") {
                 $sites[$i]['hard'] = $app->lng('unlimited');
             }
             /*
             if(!strstr($sites[$i]['used'],'M') && !strstr($sites[$i]['used'],'K')) $sites[$i]['used'].= ' B';
             if(!strstr($sites[$i]['soft'],'M') && !strstr($sites[$i]['soft'],'K')) $sites[$i]['soft'].= ' B';
             if(!strstr($sites[$i]['hard'],'M') && !strstr($sites[$i]['hard'],'K')) $sites[$i]['hard'].= ' B';
             */
             if ($sites[$i]['soft'] == '0 B' || $sites[$i]['soft'] == '0 KB' || $sites[$i]['soft'] == '0') {
                 $sites[$i]['soft'] = $app->lng('unlimited');
             }
             if ($sites[$i]['hard'] == '0 B' || $sites[$i]['hard'] == '0 KB' || $sites[$i]['hard'] == '0') {
                 $sites[$i]['hard'] = $app->lng('unlimited');
             }
         }
         $has_quota = true;
         $tpl->setloop('quota', $sites);
     }
     //print_r($sites);
     $tpl->setVar('has_quota', $has_quota);
     return $tpl->grab();
 }
开发者ID:istrwei,项目名称:ISPCluster,代码行数:101,代码来源:quota.php


注:本文中的tpl::setloop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。