Esempio n. 1
0
 public function monitor_change($theme)
 {
     $config_file_path = vmc::get_themes_m_root_dir() . '/' . $theme . '/config.xml';
     $last_modify_time = filemtime($config_file_path);
     if (!$last_modify_time) {
         return false;
     }
     $exist_last_time = app::get('mobile')->getConf($theme . '_theme_last_config');
     $exist_last_time = $exist_last_time ? $exist_last_time : 0;
     if ($exist_last_time - $last_modify_time == 0) {
         return true;
     } else {
         app::get('mobile')->setConf($theme . '_theme_last_config', $last_modify_time);
     }
     $config_xml_content = file_get_contents($config_file_path);
     if ($config_xml_content) {
         $theme_info = vmc::singleton('mobile_utility_xml')->xml2arrayValues($config_xml_content);
     }
     if (empty($theme_info)) {
         return false;
     }
     $config = $theme_info;
     $theme_sdf = array('theme_id' => $config['theme']['id']['value'], 'theme_dir' => $theme, 'name' => $config['theme']['name']['value'], 'version' => $config['theme']['version']['value'], 'info' => $config['theme']['info']['value'], 'author' => $config['theme']['author']['value'], 'config' => array());
     $theme_sdf = vmc_('mobile', 'theme_install_config', $theme_sdf, $config);
     if (!vmc::singleton('mobile_theme_base')->update_theme($theme_sdf)) {
         return false;
     }
     return $theme_sdf;
 }
Esempio n. 2
0
 public final function display_tmpl($tmpl, $fetch = false, $is_preview = false)
 {
     vmc::singleton('mobile_theme_install')->monitor_change($this->get_theme());
     array_unshift($this->_files, $this->get_theme() . '/' . $tmpl);
     $this->_vars = $this->pagedata;
     $this->_vars['base_url'] = vmc::base_url(true);
     $this->_vars['mobile_theme_url'] = vmc::get_themes_m_host_url() . '/' . $this->get_theme();
     //title description
     $title = $this->title ? $this->title : app::get('mobile')->getConf('page_default_title');
     $keywords = $this->keywords ? $this->keywords : app::get('mobile')->getConf('page_default_keywords', $title);
     $description = $this->description ? $this->description : app::get('mobile')->getConf('page_default_description', $title);
     $this->pagedata = array_merge($this->pagedata, array('title' => htmlspecialchars($title), 'keywords' => htmlspecialchars($keywords), 'description' => htmlspecialchars($description)));
     $this->_vars = array_merge($this->_vars, array('title' => htmlspecialchars($title), 'keywords' => htmlspecialchars($keywords), 'description' => htmlspecialchars($description)));
     $tmpl_file = realpath(vmc::get_themes_m_root_dir() . '/' . $this->get_theme() . '/' . $tmpl);
     if (!$tmpl_file) {
         $tmpl_file = realpath(vmc::get_themes_m_root_dir() . '/' . $this->get_theme() . '/default.html');
         if (!$tmpl_file) {
             $unexists_path = vmc::get_themes_m_root_dir() . '/' . $this->get_theme() . '/' . $tmpl;
             setcookie('CURRENT_THEME', '', time() - 1000, '/');
             unset($_COOKIE['CURRENT_THEME']);
             setcookie('CURRENT_THEME_M', '', time() - 1000, '/');
             unset($_COOKIE['CURRENT_THEME_M']);
             setcookie('THEME_DIR', '', time() - 1000, '/');
             unset($_COOKIE['THEME_DIR']);
             setcookie('THEME_M_DIR', '', time() - 1000, '/');
             unset($_COOKIE['THEME_M_DIR']);
             trigger_error('File not exists [' . $unexists_path . ']', E_USER_ERROR);
         }
     }
     $tmpl_content = file_get_contents($tmpl_file);
     $compile_code = $this->_compiler()->compile($tmpl_content);
     if ($compile_code !== false) {
         $compile_code = $this->fix_statics_dir($compile_code);
     }
     $theme_url = vmc::get_themes_m_host_url();
     ob_start();
     eval('?>' . $compile_code);
     $content = ob_get_contents();
     ob_end_clean();
     array_shift($this->_files);
     $this->pre_display($content);
     if ($fetch === true) {
         return $content;
     } else {
         echo $content;
     }
 }