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


PHP Config::get_instance方法代码示例

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


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

示例1: enhancedcalc_remark

function enhancedcalc_remark($paper_type, $paper_id, $q_id, $settings, $db, $mode = 'unmarked')
{
    $status = array(-13 => 0, -12 => 0, -11 => 0, -10 => 0, -9 => 0, -8 => 0, -7 => 0, -6 => 0, -5 => 0, -4 => 0, -3 => 0, -2 => 0, -1 => 0, 0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0);
    $configObject = Config::get_instance();
    $enhancedcalc = new EnhancedCalc($configObject);
    $data['settings'] = $settings;
    $data['q_id'] = $q_id;
    $enhancedcalc->load($data);
    $mode_sql = $mode == 'all' ? '' : ' AND mark IS NULL';
    $result = $db->prepare("SELECT log{$paper_type}.id, user_answer FROM log{$paper_type}, log_metadata WHERE log{$paper_type}.metadataID = log_metadata.id AND q_id = ? AND paperID = ? {$mode_sql}");
    $result->bind_param('ii', $q_id, $paper_id);
    $result->execute();
    $result->store_result();
    $result->bind_result($id, $user_answer);
    while ($result->fetch()) {
        $enhancedcalc->set_useranswer($user_answer);
        $returnarray = $enhancedcalc->calculate_user_mark();
        $status[$returnarray]++;
        if ($returnarray !== Q_MARKING_UNMARKED and $returnarray !== Q_MARKING_ERROR) {
            // Save the extra data back into the log record.
            $sql = "UPDATE log{$paper_type} set mark = ?, adjmark = ?, totalpos = ?, user_answer = ? WHERE id = ? LIMIT 1";
            $storemark = $db->prepare($sql);
            $new_useranswerstring = $enhancedcalc->useranswer_to_string();
            $totalpos = $enhancedcalc->calculate_question_mark();
            $storemark->bind_param('dddsi', $enhancedcalc->qmark, $enhancedcalc->qmark, $totalpos, $new_useranswerstring, $id);
            $storemark->execute();
        }
    }
    $result->close();
    return $status;
}
开发者ID:vinod-co,项目名称:centa,代码行数:31,代码来源:enhancedcalc_helper.php

示例2: display_notice

 /**
  * This function will output a message to the user 
  *
  * @param string $title       - title to display
  * @param string $msg         - string the message
  * @param string $icon        - name of the icon image file
  * @param string $title_color - color of the tile text
  * @param bool $output_header - if true output opening HTML tags
  * @param bool $output_footer - if true output closing HTML tags
  */
 public function display_notice($title, $msg, $icon, $title_color = 'black', $output_header = true, $output_footer = true)
 {
     $configObject = Config::get_instance();
     $root = str_replace('/classes', '/', str_replace('\\', '/', dirname(__FILE__)));
     if (file_exists($root . 'config/config.inc.php')) {
         $rp = $configObject->get('cfg_root_path');
         $cs = $configObject->get('cfg_page_charset');
     } else {
         // If we have not installed there is no config.inc.php file.
         $rp = rtrim('/' . trim(str_replace($_SERVER['DOCUMENT_ROOT'], '', $root), '/'), '/');
         $cs = 'utf-8';
     }
     if ($output_header == true) {
         echo "<html>\n";
         echo "<head>\n<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n";
         echo "<meta http-equiv=\"content-type\" content=\"text/html;charset={$cs}\" />\n";
         echo "<title>{$title}</title>\n";
         echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"{$rp}/css/body.css\" />\n";
         echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"{$rp}/css/notice.css\" />\n";
         echo "</head>\n<body>\n";
     }
     echo '<div class="notice">';
     echo "<div style=\"float:left; padding-left:10px;width:60px\"><img src=\"{$rp}" . $icon . "\" width=\"48\" height=\"48\" /></div>\n";
     echo "<div><h1 style=\"color:{$title_color}\">{$title}</h1>\n";
     echo "<hr style=\"width:300px\"/>\n<p>{$msg}</p></div>";
     echo '</div>';
     if ($output_footer == true) {
         echo "\n</body>\n</html>";
     }
 }
开发者ID:vinod-co,项目名称:centa,代码行数:40,代码来源:usernotices.class.php

示例3: listtreemodules

function listtreemodules($mysqli, $moduleid, $block_id, $plk, $flat = false, $explode = false)
{
    $icons = array('formative', 'progress', 'summative', 'survey', 'osce', 'offline', 'peer_review');
    $configObject = Config::get_instance();
    $moduleidorig = $moduleid;
    $moduleid = module_utils::get_idMod($moduleid, $mysqli);
    $sql = "SELECT DISTINCT crypt_name, paper_type, paper_title, retired, idMod FROM properties, properties_modules WHERE idMod = ? and properties.property_id = properties_modules.property_id AND deleted IS NULL AND paper_type IN ('0','1','3','4') ORDER BY paper_type, paper_title";
    $results2 = $mysqli->prepare($sql);
    $results2->bind_param('i', $moduleid);
    $results2->execute();
    $results2->bind_result($crypt_name, $paper_type, $paper_title, $retired, $moduleID);
    $results2->store_result();
    if ($results2->num_rows() > 0) {
        $rt = $results2->num_rows();
        echo '<div>';
        while ($results2->fetch()) {
            if (strtolower($_SESSION['_lti_context']['resource_link_title']) == strtolower($paper_title)) {
                $checked = ' checked';
            } else {
                $checked = '';
            }
            $extra = "<input type=\"radio\" name=\"paperlinkID\" id=\"paperlinkID-{$plk}\" value=\"{$plk}\"{$checked}><label for=\"paperlinkID-{$plk}\">";
            $extra1 = "</label>";
            echo "<div style=\"padding-left:20px\">{$extra}<img src=\"../artwork/" . $icons[$paper_type] . "_16.gif\" width=\"16\" height=\"16\" alt=\"" . $paper_type . "\" />&nbsp;" . $paper_title . "{$extra1}</div>\n";
            $_SESSION['postlookup'][$plk] = array($crypt_name, $moduleid);
            $plk++;
        }
        echo '</div>';
        $block_id++;
    } else {
        // no papers
    }
    $results2->close();
    return array($block_id, $plk);
}
开发者ID:vinod-co,项目名称:centa,代码行数:35,代码来源:index.php

示例4: __construct

 protected function __construct()
 {
     $conf = Config::get_instance()->load("database")->get('db');
     $dsn = $conf['driver'] . ":dbname=" . $conf['database'] . ";host=" . $conf['host'];
     $options = array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ);
     $this->pdo = new PDO($dsn, $conf['user'], $conf['pass'], $options);
 }
开发者ID:NewPlayer2,项目名称:dcrec_website,代码行数:7,代码来源:Database.php

示例5: GetSmsUtils

 static function GetSmsUtils()
 {
     $configObject = Config::get_instance();
     $cfg_sms_api = $configObject->get('cfg_sms_api');
     if (isset($cfg_sms_api) and $cfg_sms_api != '') {
         require_once $configObject->get('cfg_web_root') . "/plugins/SMS/" . $cfg_sms_api . ".class.php";
         return new $cfg_sms_api();
     }
     return false;
 }
开发者ID:vinod-co,项目名称:centa,代码行数:10,代码来源:smsutils.class.php

示例6: toilet_break_by_id

 static function toilet_break_by_id($breakID, $db)
 {
     $configObject = Config::get_instance();
     $date_format = $configObject->get('cfg_long_date_time');
     $result = $db->prepare("SELECT DATE_FORMAT(break_taken, '" . $date_format . "') FROM toilet_breaks WHERE id = ?");
     $result->bind_param('i', $breakID);
     $result->execute();
     $result->bind_result($break_taken);
     $result->fetch();
     $result->close();
     return $break_taken;
 }
开发者ID:vinod-co,项目名称:centa,代码行数:12,代码来源:toiletbreakutils.class.php

示例7: GetCMAPI

 public static function GetCMAPI($vleapi)
 {
     $configObject = Config::get_instance();
     $classname = 'CM_' . $vleapi;
     $classfile = 'CM_' . $vleapi . '.class.php';
     try {
         include_once $configObject->get('cfg_web_root') . '/plugins/CM/' . $classfile;
         $object = new $classname();
     } catch (Exception $ex) {
         throw new ClassNotFoundException(sprintf($lang_strings['noclasserror'], $classname));
     }
     return $object;
 }
开发者ID:vinod-co,项目名称:centa,代码行数:13,代码来源:CMFactory.class.php

示例8: get_announcements

 /**
  * Return an array of the mid-exam announcements for the current paper.
  *
  * @return array         - Array of announcments keyed on Q_ID.
  */
 public function get_announcements()
 {
     $configObject = Config::get_instance();
     $announcements = array();
     $result = $this->db->prepare("SELECT q_id, q_number, screen, msg, DATE_FORMAT(created,'" . $configObject->get('cfg_long_date_time') . "') AS created FROM exam_announcements WHERE paperID = ? ORDER BY q_number");
     $result->bind_param('i', $this->paperID);
     $result->execute();
     $result->bind_result($q_id, $q_number, $screen, $msg, $created);
     while ($result->fetch()) {
         $announcements[$q_id] = array('q_number' => $q_number, 'screen' => $screen, 'msg' => $msg, 'created' => $created);
     }
     $result->close();
     return $announcements;
 }
开发者ID:vinod-co,项目名称:centa,代码行数:19,代码来源:exam_announcements.class.php

示例9: display_q

function display_q($configObject, $target_id, $db)
{
    $question_data = $db->prepare("SELECT q_type, q_id, score_method, display_method, settings, marks_correct, marks_incorrect, marks_partial, theme, scenario, leadin, correct, REPLACE(option_text,'\t','') AS option_text, q_media, q_media_width, q_media_height, o_media, o_media_width, o_media_height, notes FROM questions LEFT JOIN options ON questions.q_id = options.o_id WHERE q_id = ? ORDER BY id_num");
    $question_data->bind_param('i', $target_id);
    $question_data->execute();
    $question_data->store_result();
    $question_data->bind_result($q_type, $q_id, $score_method, $display_method, $settings, $marks_correct, $marks_incorrect, $marks_partial, $theme, $scenario, $leadin, $correct, $option_text, $q_media, $q_media_width, $q_media_height, $o_media, $o_media_width, $o_media_height, $notes);
    $num_rows = $question_data->num_rows;
    echo "<table cellpadding=\"4\" cellspacing=\"0\" border=\"0\" width=\"100%\" style=\"table-layout:fixed\">\n";
    echo "<col width=\"40\"><col>\n";
    $old_q_id = 0;
    while ($question_data->fetch()) {
        if ($old_q_id != $q_id) {
            $question['theme'] = trim($theme);
            $question['scenario'] = trim($scenario);
            $question['leadin'] = trim($leadin);
            $question['notes'] = trim($notes);
            $question['q_type'] = $q_type;
            $question['q_id'] = $q_id;
            $question['score_method'] = $score_method;
            $question['display_method'] = $display_method;
            $question['settings'] = $settings;
            $question['q_media'] = $q_media;
            $question['q_media_width'] = $q_media_width;
            $question['q_media_height'] = $q_media_height;
            $question['dismiss'] = '';
            $question['assigned_number'] = $_GET['qNo'];
        }
        $question['options'][] = array('correct' => $correct, 'option_text' => $option_text, 'o_media' => $o_media, 'o_media_width' => $o_media_width, 'o_media_height' => $o_media_height, 'marks_correct' => $marks_correct, 'marks_incorrect' => $marks_incorrect, 'marks_partial' => $marks_partial);
    }
    $question_data->close();
    $question_no = 0;
    $paper_type = 0;
    $unanswered = false;
    $question_offset = $_GET['qNo'];
    $screen_pre_submitted = 0;
    $user_answers = array();
    if ($question['q_type'] == 'enhancedcalc') {
        require_once '../plugins/questions/enhancedcalc/enhancedcalc.class.php';
        if (!isset($configObj)) {
            $configObj = Config::get_instance();
        }
        $question['object'] = new EnhancedCalc($configObj);
        $question['object']->load($question);
    }
    display_question($configObject, $question, $paper_type, 0, 1, '', $question_no, $user_answers, $unanswered);
    $question_nos[] = $old_q_id;
    echo "</table>\n";
}
开发者ID:vinod-co,项目名称:centa,代码行数:49,代码来源:map_question.php

示例10: store_data

 function store_data($sessionstoreobj)
 {
     global $string;
     $configObj = Config::get_instance();
     $cfg_web_root = $configObj->get('cfg_web_root');
     $this->savetodebug('session store of input data key is ROGO_language');
     if (isset($_REQUEST['ROGO_language'])) {
         $_SESSION['ROGO_language'] = $_REQUEST['ROGO_language'];
         $language = LangUtils::getLang($cfg_web_root);
         $lang_path = "{$cfg_web_root}lang/{$language}/" . str_replace($cfg_web_root, '', $_SERVER['SCRIPT_FILENAME']);
         if (file_exists($lang_path)) {
             require $lang_path;
         }
     }
     return $sessionstoreobj;
 }
开发者ID:vinod-co,项目名称:centa,代码行数:16,代码来源:languageselection.class.php

示例11: loadlangfile

 static function loadlangfile($file, $str = null)
 {
     if (is_null($str)) {
         global $string;
     } else {
         $string = $str;
     }
     $configObj = Config::get_instance();
     $cfg_web_root = $configObj->get('cfg_web_root');
     $language = LangUtils::getLang($cfg_web_root);
     $lang_path = "{$cfg_web_root}lang/{$language}/" . $file;
     if (file_exists($lang_path)) {
         require $lang_path;
     }
     return $string;
 }
开发者ID:vinod-co,项目名称:centa,代码行数:16,代码来源:lang.class.php

示例12: load

 static function load()
 {
     // Load the appropriate LTI integration class (if new one found load that else use this)
     $configObject = Config::get_instance();
     if (!is_null($configObject->get('lti_integration')) and $configObject->get('lti_integration') != '' and $configObject->get('lti_integration') != 'default') {
         $inc_file = $configObject->get('cfg_web_root') . 'plugins/LTI/' . $configObject->get('lti_integration') . '.class.php';
         if (file_exists($inc_file)) {
             require_once $inc_file;
         } else {
             echo "LTI Plugin not found: {$inc_file}";
             exit;
         }
         return new lti_integration_extended();
     } else {
         require_once $configObject->get('cfg_web_root') . '/plugins/LTI/' . 'default.class.php';
         return new lti_integration_extended();
     }
 }
开发者ID:vinod-co,项目名称:centa,代码行数:18,代码来源:lti_integration.class.php

示例13: sms_api

 static function sms_api($data)
 {
     global $mysqli;
     if ($data[0] != 'SMS') {
         return '';
     }
     $SMS = SmsUtils::GetSmsUtils();
     if ($SMS === false) {
         $configObject = Config::get_instance();
         $notice = UserNotices::get_instance();
         $userObject = UserObject::get_instance();
         $userid = 0;
         $username = 'PRE LOGIN';
         if (isset($userObject)) {
             $userid = $userObject->get_user_ID();
             $username = $userObject->get_username();
         }
         $error_type = 'Notice';
         $errstr = 'ROGO:SMS not correctly setup';
         $errfile = 'lti_integration.php';
         if (is_null($configObject->get('cfg_db_port'))) {
             $configObject->set('cfg_db_port', 3306);
         }
         // Query may fail if we try to insert while another statement is open.
         // Since we don't have a handle on the original statement, create another DB link
         $mysqli2 = DBUtils::get_mysqli_link($configObject->get('cfg_db_host'), $configObject->get('cfg_db_username'), $configObject->get('cfg_db_passwd'), $configObject->get('cfg_db_database'), $configObject->get('cfg_db_charset'), $notice, $configObject->get('dbclass'), $configObject->get('cfg_db_port'));
         $log_error = $mysqli2->prepare("INSERT INTO sys_errors VALUES(NULL, NOW(), ?, ?, ?, ?, ?, ?, NULL, ?, ?, ?, ?, ?, ?, ?)");
         $log_error->bind_param('issssssssisss', $userid, $username, $error_type, $errstr, $errfile, $errline, $_SERVER['PHP_SELF'], $_SERVER['QUERY_STRING'], $_SERVER['REQUEST_METHOD'], $paperID, $post_data, $variables, $backtrace);
         $log_error->execute();
         $log_error->close();
         return '';
     } else {
         $SMS->set_module($data[2]);
         return $SMS->url;
     }
 }
开发者ID:vinod-co,项目名称:centa,代码行数:36,代码来源:UoN.class.php

示例14: get_client_address

 /**
  * Get the IP address or name of the computer from the server headers
  * @return mixed client ip address
  */
 static function get_client_address()
 {
     $configObject = Config::get_instance();
     // If don't have cached version look it up
     if (!isset($_SESSION['current_ip'])) {
         if ($configObject->get('cfg_client_lookup') == 'name') {
             if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
                 $tmp_parts = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
                 $tmp_client_ipaddress = gethostbyaddr(trim($tmp_parts[0]));
             } else {
                 $tmp_client_ipaddress = gethostbyaddr($_SERVER['REMOTE_ADDR']);
             }
         } else {
             if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
                 $tmp_parts = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
                 $tmp_client_ipaddress = trim($tmp_parts[0]);
             } else {
                 $tmp_client_ipaddress = $_SERVER['REMOTE_ADDR'];
             }
         }
         $_SESSION['current_ip'] = $tmp_client_ipaddress;
     }
     return $_SESSION['current_ip'];
 }
开发者ID:vinod-co,项目名称:centa,代码行数:28,代码来源:networkutils.class.php

示例15: db_user_change

 public function db_user_change()
 {
     global $db_errors, $string;
     $configObject = Config::get_instance();
     $getback = array('cfg_db_sysadmin_user', 'cfg_db_sysadmin_passwd', 'cfg_db_admin_user', 'cfg_db_admin_passwd', 'cfg_db_staff_user', 'cfg_db_staff_passwd', 'cfg_db_student_user', 'cfg_db_student_passwd', 'cfg_db_external_user', 'cfg_db_external_passwd', 'cfg_db_inv_user', 'cfg_db_inv_passwd', 'cfg_db_database');
     $arr = $this->configObj->get($getback);
     foreach ($arr as $k => $v) {
         ${$k} = $v;
     }
     // Select the aproprate database user
     if ($this->has_role('SysAdmin')) {
         $result = $this->db->change_user($cfg_db_sysadmin_user, $cfg_db_sysadmin_passwd, $cfg_db_database);
     } elseif ($this->has_role(array('Staff', 'Admin'))) {
         // Process staff first to get higher priority than students
         $result = $this->db->change_user($cfg_db_staff_user, $cfg_db_staff_passwd, $cfg_db_database);
     } elseif ($this->has_role('Student')) {
         $result = $this->db->change_user($cfg_db_student_user, $cfg_db_student_passwd, $cfg_db_database);
     } elseif ($this->has_role('External Examiner')) {
         $result = $this->db->change_user($cfg_db_external_user, $cfg_db_external_passwd, $cfg_db_database);
     } elseif ($this->has_role('Invigilator')) {
         $result = $this->db->change_user($cfg_db_inv_user, $cfg_db_inv_passwd, $cfg_db_database);
     } else {
         $result = false;
         // new security routine
         $notice = UserNotices::get_instance();
         if (!is_array($this->roles) or isset($this->roles['']) and $this->roles[''] == 1) {
             $notice->access_denied($this->db, $string, '', true, true);
         } else {
             $notice->access_denied($this->db, $string, sprintf($string['denied_role'], implode(',', array_keys($this->roles))), true, true);
         }
     }
     if ($result == false) {
         $msg = 'This should never appear, please contact support';
         $support_email = $configObject->get('support_email');
         if ($support_email != '') {
             $msg .= " (<a href=\"{$support_email}\">{$support_email}</a>)";
         }
         $msg .= '.';
         $notice = UserNotices::get_instance();
         $notice->display_notice('Change DB user failed', $msg, '../artwork/exclamation_64.png', '#C00000', true, false);
         if ($this->db->error) {
             try {
                 throw new Exception("MySQL error " . $this->db->error . "<br /> ", $this->db->errno);
             } catch (Exception $e) {
                 echo "<p>Error No: " . $e->getCode() . " - " . $e->getMessage() . "</p>";
                 echo '<p>' . nl2br($e->getTraceAsString()) . '</p>';
                 echo "<body>\n</html>";
                 exit;
             }
         }
     }
 }
开发者ID:vinod-co,项目名称:centa,代码行数:52,代码来源:userobject.class.php


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