*** freelinking.module.orig Wed Apr 20 20:52:25 2005 --- freelinking.module Sun May 1 09:07:08 2005 *************** *** 69,74 **** --- 69,75 ---- } $output .= form_select(t('Default for new nodes'), 'freelinking_nodetype', variable_get('freelinking_nodetype', 'blog'), $newnodeoptions, t('Type of node that the freelinking filter will create when clicking on a freelink without a target.')); $output .= form_select(t('Restrict free links to this node type'), 'freelinking_restriction', variable_get('freelinking_restriction','none'), $restrictoptions, t('If desired, you can restrict the freelinking title search to just nodes of this type. Note that if it is not the same as the default node type, above, new freelinked content cannot be found.')); + $output .= form_checkbox(t('Allow CamelCase linking'), 'freelinking_camelcase', 1, variable_get('freelinking_camelcase',1)==1? TRUE : FALSE, t('If desired, you can disable CamelCase linking')); // FIXME *** //$output .= form_checkbox(t('Restrict free links targets to same author'), 'freelinking_authoronly', true, variable_get('freelinking_authoronly', false), t('When this option is checked, the freelinking title search will use the author of the current node to restrict the search to other nodes by the same author. In practice, checking this box and setting the above options to "blog" turns each user\'s blog into separate wikis, that is, freelinks will not cross from one user\'s blog to another.')); *************** *** 87,104 **** case 'process': // FIXME *** ! $camelcaseregexp = '/\b([[:upper:]][[:lower:]]+){2,}\b/'; // this gets us close, but is not perfect. Example: ThisIsACamelCaseWord won't match (two caps in a row) ! preg_match_all($camelcaseregexp, $text, $ccmatches); $freelinkingregexp = '/\[\[.+]]/U'; // this finds [[links like this]], un-greedily preg_match_all($freelinkingregexp, $text, $flmatches); ! $wikiwords = array_merge($ccmatches[0], $flmatches[0]); foreach (array_unique($wikiwords) as $wikiword) { if (substr($wikiword, 0, 2) == '[[') { // if it's a freelink, the expressions are different $phrase = substr($wikiword, 2, -2); ! $pattern = '/\[\[' . $phrase . ']]/'; ! $replacement = l($phrase, 'freelinking/' . urlencode($phrase)); } ! else { // it's a CamelCase, expressions are a bit simpler $pattern = '/\b' . $wikiword . '\b/'; $replacement = l($wikiword, 'freelinking/' . urlencode($wikiword)); } --- 88,127 ---- case 'process': // FIXME *** ! $allowcamelcase = variable_get(freelinking_camelcase,1); ! if ($allowcamelcase == 1) { ! $camelcaseregexp = '/\b([[:upper:]][[:lower:]]+){2,}\b/'; // this gets us close, but is not perfect. Example: ThisIsACamelCaseWord won't match (two caps in a row) ! preg_match_all($camelcaseregexp, $text, $ccmatches); ! } $freelinkingregexp = '/\[\[.+]]/U'; // this finds [[links like this]], un-greedily preg_match_all($freelinkingregexp, $text, $flmatches); ! if ($allowcamelcase == 1) { ! $wikiwords = array_merge($ccmatches[0], $flmatches[0]); ! } ! else { ! $wikiwords = $flmatches[0]; ! } foreach (array_unique($wikiwords) as $wikiword) { if (substr($wikiword, 0, 2) == '[[') { // if it's a freelink, the expressions are different $phrase = substr($wikiword, 2, -2); ! $flink = $phrase; ! $barpos = strpos($phrase, '|'); ! if ($barpos) { ! $pattern = '/\[\[' . preg_quote($phrase,'/') . ']]/'; ! $phrase = substr($phrase,0,$barpos); ! $flink = substr($flink,$barpos+1); ! } ! else { ! $pattern = '/\[\[' . preg_quote($phrase,'/') . ']]/'; ! } ! if (substr($flink,0,7) == 'http://') { ! $replacement = '' . $phrase . ''; ! } ! else { ! $replacement = l($phrase, 'freelinking/' . urlencode($flink)); ! } } ! else if ($allowcamelcase == 1) { // it's a CamelCase, expressions are a bit simpler $pattern = '/\b' . $wikiword . '\b/'; $replacement = l($wikiword, 'freelinking/' . urlencode($wikiword)); }