public function __construct() { $this->app_path = APP_PATH; $configManager = ConfigManager::getInstance(); if ($configManager->valueExists('global.app_path')) { $this->app_path = $configManager->getValue('global.app_path'); } }
public function getControllerUrl($params, $prefix = "") { $app_path = APP_PATH; $configManager = ConfigManager::getInstance(); if ($configManager->valueExists('global.app_path')) { $app_path = $configManager->getValue('global.app_path'); } $href = "#"; if (!MOD_REWRITE) { if (isset($params["controller"])) { $href = $app_path . "/index.php?opcion=" . $params["controller"]; if (isset($params["action"])) { $href .= "&action=" . $params["action"]; } } } else { $href = $app_path; if ($this->locale != '') { $href .= "/" . $this->locale; } if ($prefix != "") { $href .= "/" . $prefix; } else { if ($this->defaultUrlPrefix != "") { $href .= "/" . $this->defaultUrlPrefix; } } if (isset($params["controller"])) { $href .= "/" . $params["controller"]; if (isset($params["action"])) { $href .= "/" . $params["action"]; } if (isset($params["params"])) { if (is_array($params["params"])) { foreach ($params["params"] as $param) { $href .= "/" . $param; } } else { $href .= "/" . $params["params"]; } } } } return $href; }
/** * Fontion utililée dans le blog (dans le footer) */ public function wsi_addSplashImageWpFooter() { // Chargement des données en base $configBean = ConfigManager::getInstance()->get(); $siBean = SplashImageManager::getInstance()->get(1); // Si le plugin n'est pas activé dans ses options, on ne fait rien if ($configBean->isSplash_active() != 'true') { return; } // If not in First Load Mode, exit the function if ($configBean->isWsi_first_load_mode_active() == 'true') { return; } // Si la Splash Image n'est pas dans sa plage de validité, on ne fait rien if (WsiCommons::getdate_is_in_validities_dates() == "false") { return; } // If option selected, hide splash image on mobile devices if ($siBean->isWsi_hide_on_mobile_devices() == 'true') { if (is_mobile_browser()) { return; } } // If wsi_display_always option is activated, not paying attention to idle time if ($siBean->isWsi_display_always() != 'true') { // Si l'utilisateur n'a pas été inactif assez longtemps, on ne fait rien if (WsiCommons::enough_idle_to_splash($this->last_display) == false) { return; } } require "splash/content.inc.php"; }
$siBean->setWsi_picture_link_url($_POST['wsi_picture_link_url']); $siBean->setWsi_picture_link_target($_POST['wsi_picture_link_target']); $siBean->setWsi_include_url($_POST['wsi_include_url']); $siBean->setWsi_type($_POST['wsi_type']); $siBean->setWsi_opacity($_POST['wsi_opacity']); $siBean->setWsi_idle_time($_POST['wsi_idle_time']); // Dates management $siBean->setDatepicker_start($_POST['datepicker_start']); $siBean->setDatepicker_end($_POST['datepicker_end']); // Booleans management $configBean->setSplash_active(isset($_POST['splash_active'])); $configBean->setWsi_first_load_mode_active(isset($_POST['wsi_first_load_mode_active'])); $siBean->setWsi_close_on_esc_function(isset($_POST['wsi_close_on_esc_function'])); $siBean->setWsi_close_on_click_function(isset($_POST['wsi_close_on_click_function'])); $siBean->setWsi_hide_cross(isset($_POST['wsi_hide_cross'])); $siBean->setWsi_disable_shadow_border(isset($_POST['wsi_disable_shadow_border'])); $siBean->setWsi_youtube_autoplay(isset($_POST['wsi_youtube_autoplay'])); $siBean->setWsi_youtube_loop(isset($_POST['wsi_youtube_loop'])); $siBean->setWsi_fixed_splash(isset($_POST['wsi_fixed_splash'])); $siBean->setWsi_display_always(isset($_POST['wsi_display_always'])); $siBean->setWsi_hide_on_mobile_devices(isset($_POST['wsi_hide_on_mobile_devices'])); // Valeurs des onglets $siBean->setWsi_youtube($_POST['wsi_youtube']); $siBean->setWsi_yahoo($_POST['wsi_yahoo']); $siBean->setWsi_dailymotion($_POST['wsi_dailymotion']); $siBean->setWsi_metacafe($_POST['wsi_metacafe']); $siBean->setWsi_swf($_POST['wsi_swf']); // Remove slash in HTML code. $siBean->setWsi_html(stripslashes($_POST['wsi_html'])); ConfigManager::getInstance()->save($configBean); SplashImageManager::getInstance()->save($siBean);
protected function startUpDoctrine() { $configManager = ConfigManager::getInstance(); Doctrine_Manager::connection($configManager->getDbConnectionString()); Doctrine_Manager::getInstance()->setAttribute(Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_CONSERVATIVE); Doctrine::loadModels(CLASSPATH . '/models'); }
/** * Cherche une valeur de configuration * * @param string $name Le nom de la propriété à récupérer * @return ConfigContainer|null La valeur venant de la configuration */ public static function get($name) { return ConfigManager::getInstance()->__get($name); }
/** * Remise de toutes les options aux valeurs par défaut */ public function reset() { ConfigManager::getInstance()->reset(); SplashImageManager::getInstance()->reset(); }
public static function run($entrance) { spl_autoload_register(array('Application', 'autoload')); //psr-0 /** * 获取配置信息 * 同步配置包括 / 入口配置 / 模块配置 / app配置 / 默认配置 相互覆盖 * 验证 D(C()); / D(ConfigManager::getInstance($entrance)); */ ConfigManager::getInstance($entrance)->load(); //OK 配置完成 验证 /** * 计算路由信息 * 验证D(C('Router')) */ Router::getInstance()->load(); //路由信息 D(C('Router')); // if($router['method_modules']){ // $basepath = $app['APP_PATH'].'Modules/'.$app['modulelist'][$router['method_modules']].'/'; // }else{ // $basepath = $hspath; // } Bootstrap::init(); //初始化执行 /** * 对系统信息运算完毕,准备转交控制权 * 转交控制权 */ //app-> [APP_PATH] => ../App/ // [GRACE_PATH] => ../Grace/ //加载Seter spl_autoload_register(array('Application', 'autoload_controller')); //psr-0 includeIfExist(C('app')['APP_PATH'] . '/Seter/I.php'); self::DoController(); exit; exit; /** * D(C()); // // D($request->headers); // D($request->env); // D($request->cookies); // // exit; // D(C('env')); //// D($request->getMethod()); //提交的方法 //// D($request->isGet()); //提交的方法 //// D($request->isPost()); //提交的方法 //// D($request->isPut()); //提交的方法 //// D($request->isPatch()); //提交的方法 //// D($request->isDelete()); //提交的方法 //// D($request->isOptions()); //提交的方法 // // D($request->getHost()); // D($request->getHostWithPort()); // D($request->getPort()); // echo '------'; // /** // * 下面三个path模式下不准确 // * / // D($request->getScriptName()); // D($request->getRootUri()); // D($request->getPath()); // D($request->getPathInfo()); //同下 // D($request->getResourceUri()); //同上 // // D($request->getIp()); // // D($request->getRootUri()); */ /** * 调试 //验证系列配置数据 D(ConfigManager::get('modulelist')); D(ConfigManager::get('app_defaultConfig')); D(ConfigManager::get('ent')); D(ConfigManager::get('env')); D(ConfigManager::get('app')); D(C()); */ /** * 对request的验证 */ /** * 生成对象 * router * config * request * bootstrap::ini(); ->>>>>>>>>>>> 在 go 中 //================================= request ok router ok config ok bootrun ok //================================= go中 ini ok 控制权交给go Application::go -> 生成response对象 ->view/json */ /** //config //ConfigManager::Load($conf); //D(ConfigManager::get('mysql')); //D(ConfigManager::get('Rbacdb')); //D(ConfigManager::get('User')); //D(ConfigManager::get('modules')); // D(ConfigManager::get('Router')); // Router::getInstance()->load(); //$router = Router::getInstance()->getrouter(); //获得router //OK //这里准备好 // $router // $config // $_REQUEST */ //首先运行自动加载文件 exit; }
set_include_path(get_include_path() . PATH_SEPARATOR . CLASSPATH . "/controllers"); set_include_path(get_include_path() . PATH_SEPARATOR . CLASSPATH . "/helpers"); set_include_path(get_include_path() . PATH_SEPARATOR . CLASSPATH . "/managers"); set_include_path(get_include_path() . PATH_SEPARATOR . CLASSPATH . "/components"); set_include_path(get_include_path() . PATH_SEPARATOR . CLASSPATH . "/filters"); set_include_path(get_include_path() . PATH_SEPARATOR . CLASSPATH . "/dispatchers"); //For Doctrine. Uncomment if you use a DataBase. //set_include_path(get_include_path() . PATH_SEPARATOR . CLASSPATH."/models"); //Some extra useful includes - You can uncomment the ones you need or add new ones //set_include_path(get_include_path() . PATH_SEPARATOR . CLASSPATH."/components/plogger"); //Logger class //set_include_path(get_include_path() . PATH_SEPARATOR . CLASSPATH."/components/phpMailer_v2.3"); //PHP Mailer //Doctrine include. Uncomment if you use a DataBase. //require_once(DOCTRINE_FOLDER.'/Doctrine.php'); //This is used for class loading DO NOT REMOVE!! require_once 'FileSystem.php'; //Autoloaders registrations //For Doctrine. Uncomment if you use a DataBase. //spl_autoload_register(array('Doctrine', 'autoload')); spl_autoload_register(array('FileSystem', 'autoload')); //For Doctrine. Uncomment if you use a DataBase. //Doctrine configuration. This works fine for most projects but you can change it as needed to suit your needs /*$con = Doctrine_Manager::connection("{$db_conn_type}://{$db_user}:{$db_pass}@{$db_host}/{$db_name}"); Doctrine_Manager::getInstance()->setAttribute(Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_CONSERVATIVE); $con->setCharset('utf8'); $con->setAttribute(Doctrine::ATTR_USE_NATIVE_ENUM, true); Doctrine::loadModels(CLASSPATH.'/models'); */ $configManager = ConfigManager::getInstance(); $configManager->setDebugLevel(2); session_start();
/** * Fonction utilisée dans la partie Admin */ public function wp_splash_image_options() { // L'utilisateur a-t-il les droits suffisants pour afficher la page if (!current_user_can('manage_options')) { wp_die(__("You do not have sufficient permissions to access this page.", 'wp-splash-image')); } $updated = false; $reseted = false; if (isset($_POST['action'])) { switch ($_POST['action']) { case 'update': require "actions/UpdateAction.inc.php"; $updated = true; break; case 'reset': require "actions/ResetAction.inc.php"; $reseted = true; break; } } // Pour le moment on ne charge que le 1er splash screen $configBean = ConfigManager::getInstance()->get(); $siBean = SplashImageManager::getInstance()->get(1); ?> <div class="wsi-back wrap"> <!-- Logo Info --> <div id="display_info"> <a href="https://wordpress.org/plugins/wsi/" target="_blank"> <img id="info_img" class="tooltipped" data-position="bottom" data-tooltip="<?php echo __('Infos', 'wp-splash-image'); ?> " alt="<?php echo __('Infos', 'wp-splash-image'); ?> " src="<?php echo WsiCommons::getURL(); ?> /style/info.png" /> </a> </div> <!-- Logo Feedback --> <div id="display_feedback"> <a target="_blank" href="https://gitter.im/ben-barbier/WP-Splash-Image"> <img id="feedback_img" class="tooltipped" data-position="bottom" data-tooltip="<?php echo __('Chat', 'wp-splash-image'); ?> " alt="<?php echo __('Chat', 'wp-splash-image'); ?> " src="<?php echo WsiCommons::getURL(); ?> /style/chat_logo.png" /> </a> </div> <!-- Logo "Buy me a Beer" --> <div id="display_buyMeABeer"> <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=CKGNM6TBHU72C" target="_blank"> <img id="buyMeABeer_img" class="tooltipped" data-position="bottom" data-tooltip="<?php echo __('Buy me a Beer', 'wp-splash-image'); ?> " alt="<?php echo __('Buy me a Beer', 'wp-splash-image'); ?> " src="<?php echo WsiCommons::getURL(); ?> /style/beer.png" /> </a> </div> <!-- Logo Reset --> <div id="display_reset" title="<?php echo __('Reset', 'wp-splash-image'); ?> "> <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?> " style="height:32px;"> <?php wp_nonce_field('reset', 'nonce_reset_field'); ?> <input type="hidden" name="action" value="reset" /> <!-- Fix old tooltip problem --> <input type="image" id="reset_img" class="tooltipped" data-position="bottom" data-tooltip="<?php echo __('Reset original settings', 'wp-splash-image'); ?> " src="<?php echo WsiCommons::getURL(); ?> /style/reset.png" /> </form> </div> <!-- Logo GitHub --> <img id="github_img1" alt="github" src="<?php echo WsiCommons::getURL(); ?> /style/github/ForkMe_Blk.png" usemap="#github_map" /> <img id="github_img2" alt="github" src="<?php echo WsiCommons::getURL(); ?> /style/github/ForkMe_Wht.png" usemap="#github_map" /> <map name="github_map"><area shape="poly" id="github_area" coords="8,0,46,0,141,92,141,133" href="https://github.com/ben-barbier/WP-Splash-Image" target="_blank" /></map> <h2>WP Splash Image</h2> <!-- Information message --> <?php if ($updated) { WsiCommons::showMessage(__('Options Updated...', 'wp-splash-image')); } ?> <?php if (WsiCommons::has_a_new_version()) { WsiCommons::showMessage(__('A new version of "WP Splash Image" is out !', 'wp-splash-image') . " (<a href='" . WsiCommons::getUpdateURL() . "'>" . __('update automatically', 'wp-splash-image') . "</a>)"); } ?> <!-- ------ --> <!-- Forms --> <!-- ------ --> <?php require "forms/MainForm.inc.php"; ?> </div> <script type="text/javascript"> jQuery(document).ready(function ($) { // Récupération du type de splash <?php if (isset($_POST['wsi_type'])) { ?> var wsi_type = '<?php echo $_POST['wsi_type']; ?> '; <?php $wsi_type = $_POST['wsi_type']; ?> <?php } else { if ($siBean->getWsi_type() != "") { ?> var wsi_type = '<?php echo $siBean->getWsi_type(); ?> '; <?php $wsi_type = $siBean->getWsi_type(); ?> <?php } else { ?> var wsi_type = 'picture'; <?php $wsi_type = $siBean->getWsi_type(); ?> <?php } } ?> // Gestion de l'affichage de la zone "block_splash_test_active" if($("#splash_active").attr("checked")=="checked") { $("#block_splash_test_active").css("display","table-row"); } else { $("#block_splash_test_active").css("display","none"); } $("#splash_active").click(function() { if($("#splash_active").attr("checked")=="checked") {$("#block_splash_test_active").fadeIn("slow");} else{$("#block_splash_test_active").fadeOut("slow");} }); // Gestion de l'affichage des zones block_idle_time en fonction de "wsi_display_always" if($("#wsi_display_always").attr("checked")=="checked") { $("#block_idle_time").css("display","none"); }else{ $("#block_idle_time").css("display","block"); } $("#wsi_display_always").click(function() { if($("#wsi_display_always").attr("checked")=="checked") { $("#block_idle_time").fadeOut("slow"); }else{ $("#block_idle_time").fadeIn("slow"); } }); // GitHub banner effect. $('#github_area').mouseover(function() { $('#github_img2').fadeIn("400"); }); $('#github_area').mouseout(function() { $('#github_img2').fadeOut("400"); }); // Color on select input radio function color_box(boxId) { $(".box_type").velocity({ backgroundColor: "#FFFFFF" }, 200); $(boxId).velocity({ backgroundColor: "#D9FFB2" }, 500); } $("#radio_picture").click(function() { color_box("#box_picture")}); $("#radio_youtube").click(function() { color_box("#box_youtube")}); $("#radio_yahoo").click(function() { color_box("#box_yahoo")}); $("#radio_dailymotion").click(function() { color_box("#box_dailymotion")}); $("#radio_metacafe").click(function() { color_box("#box_metacafe")}); $("#radio_swf").click(function() { color_box("#box_swf")}); $("#radio_html").click(function() { color_box("#box_html")}); $("#radio_include").click(function() { color_box("#box_include")}); // Color on plugin init $("#box_<?php echo $wsi_type; ?> ").velocity({ backgroundColor: "#D9FFB2" }, 500); // Splash Color field management $("#splash_color_demo").css("background-color", "#"+$("#splash_color").val()); $("#splash_color").keyup(function() { $("#splash_color_demo").css("background-color", "#"+$("#splash_color").val()); }); // Fields filters $('#splash_color').keyfilter(/[0-9a-f]/i); $('#splash_image_height').keyfilter(/[\d\.]/); $('#splash_image_width').keyfilter(/[\d\.]/); // Live Preview $('#live_preview_button').click(function() { $.post('<?php echo WsiCommons::getURL(); ?> /wsi/back/splash/demo.php', { url_splash_image: $("#url_splash_image").val(), splash_image_width: $("#splash_image_width").val(), splash_image_height: $("#splash_image_height").val(), wsi_margin_top: $("#wsi_margin_top").val(), splash_color: $('#splash_color').val(), wsi_display_time: $("[name='wsi_display_time']").val(), wsi_fixed_splash: $("#wsi_fixed_splash:checked").is(":checked"), wsi_picture_link_url: $("#wsi_picture_link_url").val(), wsi_picture_link_target: $("#wsi_picture_link_target").val(), wsi_include_url: $("#wsi_include_url").val(), wsi_close_on_esc_function: $("#wsi_close_on_esc_function:checked").is(":checked"), wsi_close_on_click_function: $("#wsi_close_on_click_function:checked").is(":checked"), wsi_hide_cross: $("#wsi_hide_cross:checked").is(":checked"), wsi_disable_shadow_border: $("#wsi_disable_shadow_border:checked").is(":checked"), wsi_type: $("[name='wsi_type']:checked").val(), wsi_opacity: $("[name='wsi_opacity']").val(), wsi_youtube: $("#wsi_youtube").val(), wsi_youtube_autoplay: $("#wsi_youtube_autoplay:checked").is(":checked"), wsi_youtube_loop: $("#wsi_youtube_loop:checked").is(":checked"), wsi_yahoo: $("#wsi_yahoo").val(), wsi_dailymotion: $("#wsi_dailymotion").val(), wsi_metacafe: $("#wsi_metacafe").val(), wsi_swf: $("#wsi_swf").val(), wsi_html: $("#wsi_html").val() }, function(files) { $('#live_preview_div').html(files); }); }); // Materializecss $('.tooltipped').tooltip({delay: 10}); var pickadateConfig = { format:'yyyy-mm-dd', selectMonths: true, // Creates a dropdown to control month selectYears: 5, // Creates a dropdown of 5 years to control year onClose: function () { // Warning sur les dates de validités var startDate = datepickerStart.pickadate('picker').get('select', 'yyyymmdd'); var endDate = datepickerEnd.pickadate('picker').get('select', 'yyyymmdd'); var currentDate = getCurrentDate(); if (needToDisplayDateAlertMessage(startDate, endDate, currentDate)) { $("#box_datepickers_warning").velocity("fadeIn", { display: "inline" }); } else { $("#box_datepickers_warning").velocity("fadeOut"); } } }; var datepickerStart = $('#datepicker_start').pickadate(pickadateConfig); var datepickerEnd = $('#datepicker_end').pickadate(pickadateConfig); function getCurrentDate() { var today = new Date(); var dd = today.getDate(); var mm = today.getMonth() + 1; //January is 0! var yyyy = today.getFullYear(); if (dd < 10) { dd = '0' + dd } if (mm < 10) { mm = '0' + mm } return '' + yyyy + mm + dd; } function needToDisplayDateAlertMessage (startDate, endDate, currentDate) { if (startDate && startDate > currentDate) { return true; } if (endDate && endDate < currentDate) { return true; } return false; } $('select').material_select(); $('.modal-trigger').leanModal(); }); </script> <?php }
/** * Default Logger * * @param string $message * @param int $level */ private function log($message, $level = LoggingLevel::INFO) { if ($this->isLoggingEnabled) { $config = ConfigManager::getInstance()->getConfigHashmap(); // Check if logging in live if (array_key_exists('mode', $config) && $config['mode'] == 'live') { // Live should not have logging level above INFO. if ($this->loggingLevel >= LoggingLevel::INFO) { // If it is at Debug Level, throw an warning in the log. if ($this->loggingLevel == LoggingLevel::DEBUG) { error_log("[" . date('d-m-Y h:i:s') . "] " . $this->loggerName . ": ERROR\t: Not allowed to keep 'Debug' level for Live Environments. Reduced to 'INFO'\n", 3, $this->loggerFile); } // Reducing it to info level $this->loggingLevel = LoggingLevel::INFO; } } if ($level <= $this->loggingLevel) { error_log("[" . date('d-m-Y h:i:s') . "] " . $this->loggerName . ": {$message}\n", 3, $this->loggerFile); } } }
/** 独立运行 不依赖于本类的其他方法 运行处模块名,并且传递出去 * @return array * 这个在conf中第一个被调用时入口程序 //根据pathinfo_query 获取模块信息 */ public function getModule() { //计算模块 //并且返回 $config = ConfigManager::getInstance(); //未完成的 $pathinfo_query = $config->env['pathinfo_query']; $modulelist = is_array($config->modulelist) ? $config->modulelist : []; //根据这两个计算出模块信息 // D($pathinfo_query); // D($modulelist); $pathinfo_query = strtolower($pathinfo_query); $pq = explode('&', $pathinfo_query); //第一个存在等号 if (!isset(explode('=', current($pq))[1])) { $mo_ = current(explode('/', trim(array_shift($pq), '/'))); //如果存在的话,mo就是第一个/之前的值 } foreach ($pq as $key => $value) { $pq_ = explode('=', $value); $pq_[0] && $pq_[1] && ($pq__[$pq_[0]] = $pq_[1]); } $mo_ = $pq__['m'] ?: $mo_ ?: ''; //监测是否在modulelist中 if ($mo_) { $mo = in_array($mo_, $modulelist) ? $mo_ : ''; } return $mo; }