Changeset 582455
- Timestamp:
- 08/06/2012 10:51:01 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
shortcode-reference/branches/20120726_include_fix/lib/ShortcodeReference.php
r318972 r582455 16 16 * @var ReflectionFunction 17 17 */ 18 private $_function_reflection; 18 private $_function_reflection; 19 20 /** 21 * @var string 22 */ 23 private $_filepath; 19 24 20 25 /** … … 69 74 $this->_known_tags = array(); 70 75 $desc = $this->_function_reflection->getDocComment(); 71 $matches = preg_split('/\n/',$desc);72 76 $parsed_desc = ''; 73 $start_pattern = '/w*\/\*\*w*/'; 74 foreach ($matches as $match) { 75 if (preg_match($start_pattern, $match,$submatch)){ 76 // skip it 77 } else if (preg_match('/w*\*\//',$match,$submatch)){ 78 $offset = strpos($match,'*/')-1; 79 $final_line.= trim(substr($match,0,-$offset)).' 77 if ($desc){ 78 $matches = preg_split('/\n/',$desc); 79 $start_pattern = '/w*\/\*\*w*/'; 80 foreach ($matches as $match) { 81 if (preg_match($start_pattern, $match,$submatch)){ 82 // skip it 83 } else if (preg_match('/w*\*\//',$match,$submatch)){ 84 $offset = strpos($match,'*/')-1; 85 $final_line.= trim(substr($match,0,-$offset)).' 80 86 '; 81 if ($final_line != ''){ 82 $parsed_desc .= $final_line; 83 } 84 } else if (preg_match('/w*\*/',$match,$submatch)){ 85 if (preg_match('/@/',$match,$submatch)){ 86 $offset = strpos($match,'@')+1; 87 $tag = trim(substr($match,$offset,strlen($match)-$offset)); 88 $this->addTagFromString($tag); 89 } else { 90 $offset = strpos($match,'*')+1; 91 $parsed_desc .= trim(substr($match,$offset,strlen($match)-$offset)).' 92 '; 87 if ($final_line != ''){ 88 $parsed_desc .= $final_line; 89 } 90 } else if (preg_match('/w*\*/',$match,$submatch)){ 91 if (preg_match('/@/',$match,$submatch)){ 92 $offset = strpos($match,'@')+1; 93 $tag = trim(substr($match,$offset,strlen($match)-$offset)); 94 $this->addTagFromString($tag); 95 } else { 96 $offset = strpos($match,'*')+1; 97 $parsed_desc .= trim(substr($match,$offset,strlen($match)-$offset)).' 98 '; 99 } 93 100 } 94 101 } … … 108 115 public function getReference(){ 109 116 $absolute_path = $this->_function_reflection->getFileName(); 117 $this->_filepath = $absolute_path; 110 118 if (strpos($absolute_path, ABSPATH)>=0){ 111 119 /** … … 126 134 127 135 /** 136 * Retrieve the absolute file path 137 * 138 * @return string 139 */ 140 public function getFilePath(){ 141 return $this->_filepath; 142 } 143 144 /** 128 145 * Get the options for the function 129 146 * … … 160 177 */ 161 178 public function getUrl(){ 179 162 180 if (!$this->_url){ 181 163 182 $is_plugin = strpos($this->getReference(),'Plugin:'); 164 183 if ($this->getReference() == 'WordPress function'){ … … 166 185 $this->_url ='http://codex.wordpress.org/index.php?title=Special:Search&search='.$this->_shortcode.'_Shortcode'; 167 186 } else if ($is_plugin !== false){ 168 169 $plugin_path = str_replace('Plugin: ','',$this->getReference()); 170 $plugin_info = get_plugin_data(WP_PLUGIN_DIR.'/'.$plugin_path.'/'.$plugin_path.'.php'); 187 $plugin_info = get_plugin_data($this->_filepath); 171 188 172 189 if (is_array($plugin_info) && key_exists('PluginURI',$plugin_info)){
Note: See TracChangeset
for help on using the changeset viewer.