public function getFullWebPath()
 {
     return dm::getRequest()->getAbsoluteUrlRoot() . '/' . $this->getWebPath();
 }
Exemple #2
0
 public function getAbsoluteHref()
 {
     $href = $this->getHref();
     $uriPrefix = dm::getRequest()->getUriPrefix();
     if (strpos($href, $uriPrefix) !== 0) {
         $href = $uriPrefix . $href;
     }
     return $href;
 }
Exemple #3
0
 protected static function debugger($var, $level = 1, $opt = array())
 {
     $CR = "\n";
     $die = $level > 2;
     $opt = dmString::toArray($opt);
     if (!sfConfig::get('sf_debug') && !dmArray::get($opt, "force")) {
         return;
     }
     $tag = dmArray::get($opt, "tag", "pre");
     if (dmArray::get($opt, "to_string", false) && is_array($var)) {
         array_walk_recursive($var, create_function('&$val', 'if(is_object($val)) {
       if (method_exists($val, "toString")) {
         $val = get_class($val)." : ".$val->toString();
       }
       elseif (method_exists($val, "__toString")) {
         $val = get_class($val)." : ".$val->__toString();
       }
     }'));
     } elseif (is_array($var)) {
         array_walk_recursive($var, create_function('&$val', 'if(is_object($val)) {
       if (method_exists($val, "toDebug")) {
         $val = get_class($val)." : ".print_r($val->toDebug(), true);
       }
       elseif (method_exists($val, "toArray")) {
         $val = get_class($val)." : ".print_r($val->toArray(), true);
       }
     }'));
     }
     if (dmConfig::isCli()) {
         $debugString = print_r($var, true);
         $debugString = substr($debugString, 0, self::MAX_DEBUG_LENGTH);
         echo $debugString;
         if (strlen($debugString) > self::MAX_DEBUG_LENGTH) {
             echo "\n---TRUNCATED---\n";
         }
         if ($die) {
             die;
         }
     } else {
         array_walk_recursive($var, create_function('&$val', 'if(is_string($val)) { $val = htmlspecialchars($val); }'));
         if (count($var) == 1) {
             $var = dmArray::first($var);
         }
         if (dmContext::hasInstance() && ($request = dm::getRequest())) {
             if ($request->isXmlHttpRequest()) {
                 echo "\n<{$tag}>";
                 $debugString = print_r($var, true);
                 echo substr($debugString, 0, self::MAX_DEBUG_LENGTH);
                 if (strlen($debugString) > self::MAX_DEBUG_LENGTH) {
                     echo "\n---TRUNCATED---\n";
                 }
                 echo "</{$tag}>\n";
                 if ($die) {
                     die;
                 }
                 return;
             }
         }
         ob_start();
         if ($level > 1) {
             print '<br /><' . $tag . ' style="text-align: left; border: 1px solid #aaa; border-left-width: 10px; background-color: #f4F4F4; color: #000; margin: 3px; padding: 3px; font-size: 11px;">';
             $debugString = print_r($var, true);
             echo substr($debugString, 0, self::MAX_DEBUG_LENGTH);
             if (strlen($debugString) > self::MAX_DEBUG_LENGTH) {
                 echo "\n---TRUNCATED---\n";
             }
             print "</{$tag}>";
         }
         $buffer = ob_get_clean();
         if ($level == 4) {
             ob_start();
             echo '<pre>';
             debug_print_backtrace();
             echo '</pre>';
             $dieMsg = ob_get_clean();
         } else {
             $backtrace = debug_backtrace();
             $dieMsg = str_replace(sfConfig::get("sf_root_dir"), "", dmArray::get($backtrace[1], 'file')) . " l." . dmArray::get($backtrace[1], 'line');
             //      $dieMsg  = '<pre>';
             //      $dieMsg .= isset($backtrace[0]['file']) ?     '> file     : <b>'.
             //      $backtrace[1]['file'] .'</b>'. $CR : '';
             //      $dieMsg .= isset($backtrace[0]['line']) ?     '> line     : <b>'.
             //      $backtrace[1]['line'] .'</b>'. $CR : '';
             //      $dieMsg .= isset($backtrace[1]['class']) ?    '> class    : <b>'.
             //      dmArray::get(dmArray::get($backtrace, 2, array()), 'class') .'</b>'. $CR : '';
             //      $dieMsg .= isset($backtrace[1]['function']) ? '> function : <b>'.
             //      dmArray::get(dmArray::get($backtrace, 2, array()), 'function') .'</b>'. $CR : '';
             //      $dieMsg .= '</pre>';
         }
         if ($level > 1) {
             print $buffer;
             if ($die) {
                 die($dieMsg);
             } else {
                 print $dieMsg;
             }
         } else {
             sfWebDebug::getInstance()->logShortMessage($buffer . $dieMsg);
         }
     }
 }