Exemple #1
0
 /**
  * Assist your to debug vars. Accept n vars parameters
  * Included Debug on ARRAY an IteratorInterface Object
  *
  * @param mixed $arg1
  * @param mixed $arg2
  * @param mixed $arg3
  */
 public static function PrintValue($arg1, $arg2 = null)
 {
     if (self::$_logger == null) {
         self::$_logger = new LogWrapper('debug.output');
     }
     for ($i = 0, $numArgs = func_num_args(); $i < $numArgs; $i++) {
         $var = func_get_arg($i);
         ErrorHandler::getInstance()->addExtraInfo('DEBUG_' . Debug::$count++, $var);
         if (array_key_exists("raw", $_REQUEST)) {
             continue;
         }
         if (is_array($var)) {
             self::writeLog(null, print_r($var, true), true);
         } elseif ($var instanceof SingleRow) {
             self::writeLog('SingleRow', print_r($var->toArray(), true), true);
         } elseif ($var instanceof AnyDataset) {
             Debug::PrintValue($var->getIterator());
         } elseif ($var instanceof IteratorInterface || $var instanceof AnyIterator) {
             $it = $var;
             if (!$it->hasNext()) {
                 self::writeLog('IteratorInterface', "Não trouxe registros.", false);
             } else {
                 $result = "<style>.devdebug {border: 1px solid silver; padding: 2px;} table.devdebug {border-collapse:collapse;} th.devdebug {background-color: silver}</style>" . "<table class='devdebug'>";
                 $arr = null;
                 while ($it->hasNext()) {
                     $i++;
                     $sr = $it->moveNext();
                     if ($i > 100) {
                         break;
                     }
                     if (is_null($arr)) {
                         $arr = $sr->getFieldNames();
                         $result .= '<tr><th class="devdebug">' . implode('</b></th><th class="devdebug">', $arr) . '</th></tr>';
                     }
                     $raw = $sr->toArray();
                     $result .= '<tr>';
                     foreach ($raw as $item) {
                         $result .= '<td class="devdebug">';
                         if (is_array($item)) {
                             $result .= implode(',', $item);
                         } else {
                             $result .= $item;
                         }
                         $result .= '</td>';
                     }
                     $result .= '</tr>';
                 }
                 $result .= "</table>";
                 self::writeLog('IteratorInterface', $result, false);
             }
         } elseif ($var instanceof IteratorFilter) {
             $filter = $var->getSql("ANYTABLE", $param, "*");
             $filter = substr($filter, strpos($filter, "where") + 6);
             $result = array("XPath" => $var->getXPath(), "Filter" => $filter) + $param;
             self::writeLog(get_class($var), print_r($result, true), true);
         } elseif ($var instanceof FilenameProcessor) {
             $result = array("PathSuggested()" => $var->PathSuggested(), "PrivatePath()" => $var->PrivatePath(), "SharedPath()" => $var->SharedPath(), "Name" => $var->ToString(), "Extension()" => $var->Extension(), "FullQualifiedName()" => $var->FullQualifiedName(), "FullQualifiedNameAndPath()" => $var->FullQualifiedNameAndPath(), "getFilenameLocation()" => $var->getFilenameLocation(), "File Exists?" => file_exists($var->FullQualifiedNameAndPath()) ? "yes" : "no");
             self::writeLog(get_class($var), print_r($result, true), true);
         } elseif ($var instanceof LanguageCollection) {
             self::writeLog("", get_class($var) . ": Is Loaded? " . ($var->loadedFromFile() ? 'yes' : 'no'), false);
             $var->Debug();
         } elseif (is_object($var)) {
             if ($var instanceof DOMDocument) {
                 $var->formatOutput = true;
                 self::writeLog(get_class($var), htmlentities($var->saveXML()), true);
             } elseif ($var instanceof DOMElement || $var instanceof DOMNode) {
                 $doc = $var->ownerDocument;
                 $doc->formatOutput = true;
                 echo htmlentities($doc->saveXML($var)) . "</pre>";
                 self::writeLog(get_class($var), htmlentities('[' . $var->nodeName . "]") . "\n" . htmlentities($doc->saveXML()), true);
             } else {
                 self::writeLog(get_class($var), print_r($var, true), true);
             }
         } elseif (gettype($var) == "boolean") {
             self::writeLog("", '(boolean) ' . ($var ? "true" : "false"), true);
         } else {
             self::writeLog("", gettype($var) . ": " . $var, true);
         }
     }
 }
Exemple #2
0
 /**
  * 
  * @return array
  */
 public function Debug()
 {
     Debug::PrintValue($this->_debugInfo);
     Debug::PrintValue($this->_collection);
 }
Exemple #3
0
 protected function DebugInfo($sql, $param)
 {
     if ($this->_context->getDebugStatus()) {
         Debug::PrintValue("<hr>");
         Debug::PrintValue("Class name: " . get_class($this));
         Debug::PrintValue("SQL: " . $sql);
         if ($param != null) {
             $s = "";
             foreach ($param as $key => $value) {
                 if ($s != "") {
                     $s .= ", ";
                 }
                 $s .= "[{$key}]={$value}";
             }
             Debug::PrintValue("Params: {$s}");
         }
     }
 }
Exemple #4
0
 public function __destruct()
 {
     $this->_end = microtime(true);
     $result = $this->_end - $this->_start;
     if ($this->_context->getDebugStatus()) {
         Debug::PrintValue("Total Execution Time: " . $result . " seconds ");
     }
 }
Exemple #5
0
 public function Debug()
 {
     Debug::PrintValue($this->_config);
 }
Exemple #6
0
 protected function Opcao11()
 {
     $block = new XmlBlockCollection("Exemplo 11: DualList", BlockPosition::Center);
     //XmlnukeBreakLine br = new XmlnukeBreakLine();
     if ($this->isPostBack()) {
         Debug::PrintValue(XmlDualList::Parse($this->_context, "frmdual"));
     }
     $form = new XmlFormCollection($this->_context, $this->_url . "?op=11", "Formulário com Um Dual List");
     // Create DualList Object
     $duallist = new XmlDualList($this->_context, "frmdual", "Não Selecionado", "Selecionado");
     $duallist->setDualListSize(10, 10);
     $duallist->createDefaultButtons();
     // Define DataSet Source
     $arrayLeft = array("A" => "Letra A", "B" => "Letra B", "C" => "Letra C", "D" => "Letra D", "E" => "Letra E", "F" => "Letra F");
     $arrayRight = array("B" => "Letra B", "D" => "Letra D");
     $arrayDBLeft = new ArrayDataset($arrayLeft);
     $itLeft = $arrayDBLeft->getIterator();
     $arrayDBRight = new ArrayDataset($arrayRight);
     $itRight = $arrayDBRight->getIterator();
     $duallist->setDataSourceFieldName("key", "value");
     $duallist->setDataSource($itLeft, $itRight);
     $form->addXmlnukeObject($duallist);
     $button = new XmlInputButtons();
     $button->addSubmit("Enviar Dados");
     $form->addXmlnukeObject($button);
     $block->addXmlnukeObject($form);
     $this->_document->addXmlnukeObject($block);
 }