[ Index ]
 

Code source de vtiger CRM 5.0.2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/include/fckeditor/editor/dialog/fck_spellerpages/spellerpages/server-scripts/ -> spellchecker.cfm (source)

   1  <!--- Coldfusion MX uses java on the server to process tags. So it is save to use most java attributes. For example below
   2  I use list.lastindexOf(), lastindexOf() is a java string attribute. If you plan on using this tag with earlier versions
   3  of Coldfusion, you will have to replace the lastindexOf with a pure coldfusion function. By replacing the lastindexOf, spellchecker.cfm
   4  script should be compatible with all cf version 4.5 and up.
   5  
   6  Also if you are hosting your site at an ISP, you will have to check with them to see if the use of <CFEXECUTE> is allowed. 
   7  In most cases ISP will not allow the use of that tag for security reasons. Clients would be able to access each others files in certain cases.
   8   --->
   9  
  10  
  11  <!--- Set up variables --->
  12  <cfset tempFolder = "c:\test">
  13  <cfset tempfile = "spell_#randrange(1,1000)#">
  14  <cfset apsell_dir = "c:\aspell\bin">
  15  <!--- <cfset spellercss = "/speller/spellerStyle.css">        by FredCK --->
  16  <cfset spellercss = "../spellerStyle.css">
  17  <!--- <cfset word_win_src = "/speller/wordWindow.js">        by FredCK --->
  18  <cfset word_win_src = "../wordWindow.js">
  19  
  20  
  21  <!--- Takes care of those pesky smart quotes from MS apps, replaces them with regular quotes --->
  22  <cfset submitted_text = replacelist(form.checktext,"%u201C,%u201D","%22,%22")> 
  23  <cfset submitted_text = urlDecode(submitted_text)>
  24  
  25  
  26  
  27  
  28  <!--- need to escape special javascript characters such as ' --->
  29  <cfset unaltered_text = submitted_text>
  30  <cfset submitted_text = replace(submitted_text,"'","\'","All")>
  31  <cfset submitted_text = replace(submitted_text,"""","\""","All")>
  32  
  33  <!--- use carat on each line to escape possible aspell commands --->
  34  <cfset text = "">
  35  <cfloop list="#submitted_text#" index="idx" delimiters="#chr(10)##chr(13)#">
  36      <cfset text =text&"^"&idx&"#chr(10)##chr(13)#">
  37  </cfloop>
  38  
  39  
  40  
  41  <!--- create temp file from the submitted text, this will be passed to aspell to be check for misspelled words --->
  42  <cffile action="write" file="#tempFolder#\#tempfile#.txt" output="#text#" charset="utf-8">
  43  
  44  
  45  <!--- cfsavecontent is used to set the variable that will be returned with the results from aspell.
  46  If your using the new version of mx 6.1 you can  use the following cfexecute tag instead:
  47  <cfexecute name="C:\WINDOWS\SYSTEM32\cmd.exe" arguments="/c type c:\test\#tempfile#.txt | c:\aspell\bin\aspell -a" timeout="100" variable="results"></cfexecute> --->
  48  
  49  <cfsavecontent variable="food">
  50  <cfexecute name="C:\WINDOWS\SYSTEM32\cmd.exe" arguments="/c type #tempFolder#\#tempfile#.txt | #apsell_dir#\aspell -a" timeout="100"></cfexecute>
  51  </cfsavecontent>
  52  
  53  <!--- remove temp file --->
  54  <cffile action="delete" file="#tempFolder#\#tempfile#.txt">
  55  
  56  
  57  
  58  
  59  <cfoutput>
  60  <html>
  61  <head>
  62  <link rel="stylesheet" type="text/css" href="speller/spellerStyle.css">
  63  <script src="/speller/wordWindow.js"></script>
  64  <script language="javascript">
  65  var suggs = new Array();
  66  var words = new Array();
  67  var error;
  68  var wordtext = unescape('#urlencodedFormat(unaltered_text)#');
  69  
  70  <cfset cnt = 1>
  71  <cfset word_cnt = 0>
  72  <cfloop list="#food#" index="list" delimiters="#chr(10)##chr(13)#">
  73      <!--- removes the first line of the aspell output "@(#) International Ispell Version 3.1.20 (but really Aspell 0.50.3)" --->
  74      <cfif NOT cnt EQ 1>
  75          <cfif find("&",list) OR find("##",list)>
  76              <!--- word that misspelled --->
  77              <cfset bad_word = listGetAt(list,"2"," ")>
  78              <!--- sugestions --->
  79              <cfset wrdList = mid(list,(list.lastindexOf(':') + 2),(len(list) - (list.lastindexOf(':') + 2)))>
  80              <cfset wrdsList = "">
  81              <cfloop list=#wrdList# index="idx">
  82                  <cfset wrdsList =wrdsList&"'"&trim(replace(idx,"'","\'","All"))&"',">
  83              </cfloop>
  84              <!--- javascript --->
  85              words[#word_cnt#] = '#trim(replace(bad_word,"'","\'","All"))#';
  86              suggs[#word_cnt#] = [#trim(wrdsList)#];
  87              <cfset word_cnt = word_cnt + 1>
  88          <cfelseif find("*",list)>
  89          </cfif>            
  90      </cfif>
  91      <cfset cnt = cnt + 1>
  92  </cfloop>
  93  
  94  
  95  
  96  
  97  
  98  
  99  var wordWindowObj = new wordWindow();
 100  wordWindowObj.originalSpellings = words;
 101  wordWindowObj.suggestions = suggs;
 102  wordWindowObj.text = wordtext;
 103  
 104  
 105  function init_spell() {
 106      // check if any error occured during server-side processing
 107      if( error ) {
 108          alert( error );
 109      } else {
 110          // call the init_spell() function in the parent frameset
 111          if (parent.frames.length) {
 112              parent.init_spell( wordWindowObj );
 113          } else {
 114              alert('This page was loaded outside of a frameset. It might not display properly');
 115          }
 116      }
 117  }
 118  
 119  
 120  
 121  </script>
 122  
 123  </head>
 124  <body onLoad="init_spell();">
 125  
 126  <script>
 127  wordWindowObj.writeBody();
 128  </script>
 129  
 130  </body>
 131  </html>
 132  </cfoutput>


Généré le : Sun Feb 25 10:22:19 2007 par Balluche grâce à PHPXref 0.7