Exemplo n.º 1
0
 function fetchDefinitionE(Dog_Plugin $plugin, $term)
 {
     $output = array();
     $res = GWF_HTTP::getFromUrl('http://www.urbandictionary.com/define.php?term=' . $term);
     if ($res === false) {
         return Dog::lang('err_timeout');
     }
     if (strstr($res, "isn't defined <a href")) {
         return $plugin->lang('none_yet', array($term, urlencode($term)));
     }
     preg_match('#<div class=\'meaning\'>(.+?)</div>.*?<div class=\'example\'>(.*?)</div>#s', $res, $arr);
     $definition = trim(html_entity_decode(strip_tags(preg_replace('#<\\s*?br\\s*?/?\\s*?>#', "\n", $arr[1]))));
     $definition = strtr($definition, array("\r" => ' ', "\n" => ' '));
     while (false !== strstr($definition, '  ')) {
         $definition = str_replace('  ', ' ', $definition);
     }
     if (strlen($definition) > 800) {
         $definition = substr($definition, 0, 800) . '...';
     }
     $output['definition'] = $definition;
     if (!empty($arr[2])) {
         $example = trim(html_entity_decode(strip_tags(preg_replace('#<\\s*?br\\s*?/?\\s*?>#', "\n", $arr[2]))));
         $example = strtr($example, array("\r" => ' | ', "\n" => ' | '));
         while (false !== strstr($example, ' |  | ')) {
             $example = str_replace(' |  | ', ' | ', $example);
         }
         while (false !== strstr($example, '  ')) {
             $example = str_replace('  ', ' ', $example);
         }
         if (strlen($example) > 800) {
             $example = substr($example, 0, 800) . '...';
         }
         $output['example'] = $example;
     }
     return $output;
 }
Exemplo n.º 2
0
 function dogplug_scopetxt(Dog_Plugin $plugin, $priv, $scope)
 {
     $priv = Dog::lang('priv_' . $priv);
     $scope = Dog::lang('scop_' . $scope);
     return ' ' . $plugin->lang('scope', array($scope, $priv));
 }