예제 #1
0
 public function render($sView, $aVariables = null, $asPath = null)
 {
     if (!is_null($aVariables)) {
         $vars = FlexiArrayUtil::cloneArray($aVariables);
     } else {
         //var_dump($this->aVariables);
         $vars = FlexiArrayUtil::cloneArray($this->aVariables);
     }
     $vars["#viewpath"] = $asPath;
     $vars["#css"] = $this->aHeader["css"];
     $vars["#js"] = $this->aHeader["js"];
     $vars["#template"] = $this->sTemplate;
     $sViewFile = "";
     //final file
     $sViewFile = $this->getViewFile($sView, $asPath);
     if (empty($sViewFile)) {
         FlexiLogger::error(__METHOD__, "View: " . $sView . " is missing...");
         return null;
     }
     //echo "rendering view: " . $sViewFile;
     ob_start();
     //FlexiLogger::info(__METHOD__, "found view: " . $sViewFile);
     require $sViewFile;
     $sResult = ob_get_contents();
     @ob_end_clean();
     return $sResult;
 }
예제 #2
0
파일: FlexiView.php 프로젝트: u007/FlexiPHP
 /**
  * Render array of forms via FlexiView
  * @param array $aValues fields
  * @param String $asName field name
  * @param String $asPath path to view, default to module full path
  * @return String HTML
  */
 public function renderMarkup($aValues, $asName = "", $sPath = null)
 {
     if (!is_array($aValues)) {
         throw new FlexiException("Invalid data type, must be an array: " . serialize($aValues), ERROR_DATATYPE);
     }
     $aResult = array();
     $sType = isset($aValues["#type"]) ? $aValues["#type"] : "markup";
     $bIsMarkup = $sType == "markup" ? true : false;
     $sThisName = FlexiParser::parseHTMLInputName($asName);
     //is a single element
     $adValues = FlexiArrayUtil::cloneArray($aValues);
     //    if ($asName == "agendadiv") {
     //      var_dump($aValue);
     //    }
     //echo "name: " . $asName;
     $this->renderFilterMarkup($adValues);
     //
     //    if ($asName == "agendadiv") {
     //      echo "after";
     //    }
     //var_dump($aValue);
     //$this->renderFilterForm($aValue, $asName);
     switch ($sType) {
         case "select":
         case "select.raw":
         case "textfield":
         case "textfield.raw":
         case "email":
         case "email.raw":
         case "date":
         case "date.raw":
         case "textarea":
         case "textarea.raw":
         case "button":
         case "button.raw":
         case "submit":
         case "submit.raw":
         case "form":
         case "form.raw":
         case "checkbox":
         case "checkbox.raw":
         case "checkboxes":
         case "checkboxes.raw":
         case "radio":
         case "radio.raw":
         case "radios":
         case "radios.raw":
         case "html":
             $this->renderFilterForm($adValues, $asName);
             break;
     }
     $sName = FlexiParser::parseHTMLInputName($asName);
     $aVars = array_merge($adValues, array("#name" => $sName));
     $sTheme = isset($adValues["#theme"]) ? $adValues["#theme"] : "element." . $sType;
     //echo "sorting: ";
     //print_r($adValues);
     uasort($adValues, "flexiSortByWeight");
     //		if ($bIsMarkup)
     //		{
     //			echo "is markup";
     //			$this->processMarkup($aValue, $asName, $sPath);
     //		}
     foreach ($adValues as $sName => $aValue) {
         //is a child
         if ($sName[0] != "#") {
             //echo "child: " . $sName . "\r\n<br/>";
             $aResult[] = $this->renderMarkup($aValue, $sName, $sPath);
         }
     }
     $sChildResult = implode("\r\n", $aResult);
     $aVars["#childs"] = $sChildResult;
     $sResult = $this->render($sTheme, $aVars, $sPath);
     return $sResult;
 }