當前位置: 首頁>>代碼示例>>PHP>>正文


PHP IPSText::encodeForXml方法代碼示例

本文整理匯總了PHP中IPSText::encodeForXml方法的典型用法代碼示例。如果您正苦於以下問題:PHP IPSText::encodeForXml方法的具體用法?PHP IPSText::encodeForXml怎麽用?PHP IPSText::encodeForXml使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在IPSText的用法示例。


在下文中一共展示了IPSText::encodeForXml方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: rebuildMasterFromPHP


//.........這裏部分代碼省略.........
                     $updated = 0;
                     foreach ($farray as $f) {
                         //-----------------------------------------
                         // Skip javascript functions...
                         //-----------------------------------------
                         if (stristr($f, '<script')) {
                             $script_token = 1;
                             $script_jump = 0;
                         }
                         if (stristr($f, '</script>')) {
                             $script_token = 0;
                             $script_jump = 0;
                         }
                         //-----------------------------------------
                         // If, in the middle?
                         //-----------------------------------------
                         if ($script_token and $script_jump == 0) {
                             if (preg_match('#<if test=[\'\\"]#', $f)) {
                                 $script_jump = 1;
                                 $script_token = 0;
                             }
                         }
                         if ($script_token == 0 and $script_jump == 1) {
                             if (preg_match("#</if>#", $f)) {
                                 $script_jump = 0;
                                 $script_token = 1;
                             }
                         }
                         //-----------------------------------------
                         // NOT IN JS
                         //-----------------------------------------
                         if (!$script_token) {
                             if (preg_match('/^function\\s*([\\w\\_]+)\\s*\\((.*)\\)/i', $f, $matches)) {
                                 $functions[$matches[1]] = '';
                                 $config[$matches[1]] = $matches[2];
                                 $flag = $matches[1];
                                 continue;
                             }
                         } else {
                             # Make JS safe (UBE - Ugly, but effective)
                             $f = preg_replace('#if\\s+?\\(#is', "i~f~(~", $f);
                             $f = str_ireplace('else', "e~lse~", $f);
                             $f = preg_replace('#else\\s+?if#is', "e~lse~i~f", $f);
                         }
                         if ($flag) {
                             $functions[$flag] .= $f . "\n";
                             continue;
                         }
                     }
                     $final = "";
                     $flag = 0;
                     foreach ($functions as $fname => $ftext) {
                         preg_match("#//--starthtml--//(.+?)//--endhtml--//#s", $ftext, $matches);
                         $content = $this->registry->templateEngine->convertPhpToHtml($matches[1]);
                         //-----------------------------------------
                         // Unconvert JS
                         //-----------------------------------------
                         $content = str_replace("i~f~(~", "if (", $content);
                         $content = str_replace("e~lse~", "else", $content);
                         $content = str_replace("e~lse~i~f", "else if", $content);
                         /* Encode */
                         $content = IPSText::encodeForXml($content);
                         /* Build array */
                         $array = array('template_set_id' => $set_id, 'template_group' => $name, 'template_content' => $content, 'template_name' => $fname, 'template_data' => trim($config[$fname]), 'template_updated' => time(), 'template_removable' => (is_numeric($setId) and $setId) ? 1 : 0, 'template_master_key' => $set_key, 'template_added_to' => $set_id);
                         if (!$setId) {
                             $added++;
                             /* All new bits go to 'master' skin */
                             $array['template_set_id'] = 0;
                             $array['template_added_to'] = 0;
                             $array['template_master_key'] = 'root';
                             $this->DB->insert('skin_templates', $array);
                         } else {
                             /* Compare for changes? */
                             if (IPSText::contentToMd5($templates[$name][strtolower($fname)]['template_content']) != IPSText::contentToMd5($content)) {
                                 /* It's changed, so update. We create a new row as it might be inherited */
                                 $updated++;
                                 $this->DB->insert('skin_templates', $array);
                             }
                         }
                     }
                     $messages[] = sprintf($this->lang->words['tplbitimported'], $name, $added, $updated);
                     $functions = array();
                 }
             }
         }
     } catch (Exception $e) {
     }
     /* Recache */
     if (is_numeric($setId) and $setId) {
         $this->rebuildPHPTemplates($setId);
         $this->removeDeadPHPCaches($setId);
         $this->cache->putWithCacheLib('Skin_Store_' . $setId, array(), 1);
     }
     if ($set_key == 'mobile') {
         $this->rebuildMobileSkinUserAgentsFromSetDataXml();
     }
     /* Return */
     $messages[] = $this->lang->words['cpltrebuildfromcaches'];
     return $messages;
 }
開發者ID:ConnorChristie,項目名稱:GrabViews,代碼行數:101,代碼來源:skinCaching.php

示例2: importFromCacheFiles

 /**
  * Builds the language db entries from cache
  *
  * @param	boolean			return as normal
  * @return	@e void
  * @author	Josh
  */
 public function importFromCacheFiles($returnAsNormal = TRUE)
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $msg = array();
     $lang_id = 1;
     $LATESTVERSION = IPSLib::fetchVersionNumber();
     //-----------------------------------------
     // Check
     //-----------------------------------------
     if (!is_array($_POST['apps'])) {
         $this->registry->output->global_message = $this->lang->words['l_noapp'];
         $this->languagesList();
         return;
     }
     //-----------------------------------------
     // Loop through apps...
     //-----------------------------------------
     foreach (ipsRegistry::$applications as $app => $app_data) {
         if (in_array($app, $_POST['apps'])) {
             //-----------------------------------------
             // Get directory
             //-----------------------------------------
             $_dir = IPS_CACHE_PATH . 'cache/lang_cache/master_lang/';
             //-----------------------------------------
             // Go through directories
             //-----------------------------------------
             if (is_dir($_dir)) {
                 $dh = opendir($_dir);
                 while ($f = readdir($dh)) {
                     if ($f[0] == '.' || $f == 'index.html') {
                         continue;
                     }
                     if (preg_match("#^" . $app . '_\\S+?\\.php$#', $f)) {
                         //-----------------------------------------
                         // INIT
                         //-----------------------------------------
                         $updated = 0;
                         $inserted = 0;
                         $word_pack = preg_replace("#^" . $app . '_(\\S+?)\\.php$#', "\\1", $f);
                         $lang = array();
                         $db_lang = array();
                         //-----------------------------------------
                         // Delete current language bits
                         //-----------------------------------------
                         $this->DB->delete('core_sys_lang_words', "lang_id=1 AND word_app='" . $app . "' AND word_pack='" . $word_pack . "'");
                         if (IPS_IS_SHELL) {
                             $stdout = fopen('php://stdout', 'w');
                             fwrite($stdout, 'Processing: ' . $f . "\n");
                             fclose($stdout);
                         }
                         require $_dir . $f;
                         /*noLibHook*/
                         //-----------------------------------------
                         // Loop
                         //-----------------------------------------
                         foreach ($lang as $k => $v) {
                             $inserted++;
                             $insert = array('lang_id' => $lang_id, 'word_app' => $app, 'word_pack' => $word_pack, 'word_key' => $k, 'word_default' => IPSText::encodeForXml($v), 'word_default_version' => $LATESTVERSION['long'], 'word_js' => 0);
                             $this->DB->insert('core_sys_lang_words', $insert);
                         }
                         $msg[] = sprintf($this->lang->words['indev_lang_import'], $f, $inserted, $updated);
                     } else {
                         if (preg_match('/(\\.js)$/', $f) and $app == 'core') {
                             $_js_word_pack = '';
                             if ($f == 'ipb.lang.js') {
                                 $_js_word_pack = 'public_js';
                             } else {
                                 if ($f == 'acp.lang.js') {
                                     $_js_word_pack = 'admin_js';
                                 }
                             }
                             //-----------------------------------------
                             // Delete current words for this app and word pack
                             //-----------------------------------------
                             $this->DB->delete('core_sys_lang_words', "lang_id=1 AND word_app='" . $app . "' AND word_pack='" . $_js_word_pack . "'");
                             if (IPS_IS_SHELL) {
                                 $stdout = fopen('php://stdout', 'w');
                                 fwrite($stdout, 'Processing: ' . $f . "\n");
                                 fclose($stdout);
                             }
                             //-----------------------------------------
                             // Get each line
                             //-----------------------------------------
                             $js_file = file($_dir . $f);
                             //-----------------------------------------
                             // Loop through lines and import
                             //-----------------------------------------
                             foreach ($js_file as $r) {
                                 //-----------------------------------------
                                 // preg_match what we want
                                 //-----------------------------------------
//.........這裏部分代碼省略.........
開發者ID:ConnorChristie,項目名稱:GrabViews-Live,代碼行數:101,代碼來源:manage_languages.php

示例3: rebuildMasterFromPHP


//.........這裏部分代碼省略.........
                         continue;
                     }
                     $farray = explode("\n", $fdata);
                     $functions = array();
                     $added = 0;
                     $updated = 0;
                     foreach ($farray as $f) {
                         //-----------------------------------------
                         // Skip javascript functions...
                         //-----------------------------------------
                         if (stristr($f, '<script')) {
                             $script_token = 1;
                             $script_jump = 0;
                         }
                         if (stristr($f, '</script>')) {
                             $script_token = 0;
                             $script_jump = 0;
                         }
                         //-----------------------------------------
                         // If, in the middle?
                         //-----------------------------------------
                         if ($script_token and $script_jump == 0) {
                             if (preg_match("#<if test=[\\'\"]#", $f)) {
                                 $script_jump = 1;
                                 $script_token = 0;
                             }
                         }
                         if ($script_token == 0 and $script_jump == 1) {
                             if (preg_match("#</if>#", $f)) {
                                 $script_jump = 0;
                                 $script_token = 1;
                             }
                         }
                         //-----------------------------------------
                         // NOT IN JS
                         //-----------------------------------------
                         if (!$script_token) {
                             if (preg_match("/^function\\s*([\\w\\_]+)\\s*\\((.*)\\)/i", $f, $matches)) {
                                 $functions[$matches[1]] = '';
                                 $config[$matches[1]] = $matches[2];
                                 $flag = $matches[1];
                                 continue;
                             }
                         } else {
                             # Make JS safe (UBE - Ugly, but effective)
                             $f = preg_replace("#if\\s+?\\(#is", "i~f~(~", $f);
                             $f = str_ireplace("else", "e~lse~", $f);
                             $f = preg_replace("#else\\s+?if#is", "e~lse~i~f", $f);
                         }
                         if ($flag) {
                             $functions[$flag] .= $f . "\n";
                             continue;
                         }
                     }
                     $final = "";
                     $flag = 0;
                     foreach ($functions as $fname => $ftext) {
                         preg_match("#//--starthtml--//(.+?)//--endhtml--//#s", $ftext, $matches);
                         $content = $this->registry->templateEngine->convertPhpToHtml($matches[1]);
                         //-----------------------------------------
                         // Unconvert JS
                         //-----------------------------------------
                         $content = str_replace("i~f~(~", "if (", $content);
                         $content = str_replace("e~lse~", "else", $content);
                         $content = str_replace("e~lse~i~f", "else if", $content);
                         /* Encode */
                         $content = IPSText::encodeForXml($content);
                         /* Build array */
                         $array = array('template_set_id' => $setId, 'template_group' => $name, 'template_content' => $content, 'template_name' => $fname, 'template_data' => trim($config[$fname]), 'template_updated' => time(), 'template_removable' => $setId ? 1 : 0, 'template_added_to' => $setId);
                         if (!$setId or !$templates[$name][strtolower($fname)]) {
                             $added++;
                             /* All new bits go to 'master' skin */
                             $array['template_set_id'] = 0;
                             $array['template_added_to'] = 0;
                             $this->DB->insert('skin_templates', $array);
                         } else {
                             /* Compare for changes? */
                             if (IPSText::contentToMd5($templates[$name][strtolower($fname)]['template_content']) != IPSText::contentToMd5($content)) {
                                 /* It's changed, so update. We create a new row as it might be inherited */
                                 $updated++;
                                 $this->DB->insert('skin_templates', $array);
                             }
                         }
                     }
                     $messages[] = "{$name} imported (Added " . $added . "; updated " . $updated . " template bits)";
                     $functions = array();
                 }
             }
         }
     } catch (Exception $e) {
     }
     /* Recache */
     if ($setId) {
         $this->rebuildPHPTemplates($setId);
         $this->removeDeadPHPCaches($setId);
     }
     /* Return */
     $messages[] = "Completed database rebuild from PHP cache files.";
     return $messages;
 }
開發者ID:dalandis,項目名稱:Visualization-of-Cell-Phone-Locations,代碼行數:101,代碼來源:skinCaching.php


注:本文中的IPSText::encodeForXml方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。