Example #1
0
function zdbal_FetchUntil($tagId, &$arrayTag, &$arrayTagId, $arrayOrder)
{
    $arrParam = $arrayTag[$tagId][ztagParam];
    $strId = $arrParam["id"];
    $strFileName = $arrParam["filename"];
    $strFileType = $arrParam["filetype"];
    $strShow = strtolower($arrParam["show"]);
    $strTimes = $arrParam["times"];
    $strUse = $arrParam["use"];
    $strResultType = $arrParam["resulttype"];
    $strVar = $arrParam["var"];
    $strField = $arrParam["field"];
    $errorMessage = ztagParamCheck($arrParam, "use");
    $strParam = "";
    $templateContent = $arrayTag[$tagId][ztagContent];
    $strLocalId = $strUse;
    if ($strId) {
        $strLocalId = $strId;
        $arrayTagId[$strLocalId][ztagIdValue] = $strContent;
        $arrayTagId[$strLocalId][ztagIdLength] = strlen($strContent);
        $arrayTagId[$strLocalId][ztagIdType] = idTypeFetch;
        $arrayTagId[$strLocalId][ztagIdHandle] = $arrayTagId[$strUse][ztagIdHandle];
    }
    if (!$strTimes) {
        $blnOk = 1;
    } else {
        $blnOk = $intTimes = intval($strTimes) - 1;
    }
    $blnShow = $strShow === "true" || $strShow === "1" || !strlen($strShow);
    if ($strFileName) {
        $strFileName = str_replace("\\", "/", $strFileName);
        if (substr($strFileName, 0, 1) === "/") {
            $strFileName = substr($strFileName, 1);
        }
        $strFileName = SiteRootDir . $strFileName;
        if (!($handleFile = fopen($strFileName, "w"))) {
            $errorMessage .= "\r\nCannot open file ({$strFileName})";
        }
    }
    $errorMessageTemp = "";
    $dbQuery = $arrayTagId[$strUse][ztagIdValue];
    $dbStatement = $arrayTagId[$strUse][ztagIdHandle]->executeQuery($dbQuery);
    while (($dbFetch = $dbStatement->fetch(PDO::FETCH_ASSOC)) && $blnOk) {
        if (strlen($strVar)) {
            $arrayTagId['$' . $strVar][ztagIdValue] = $dbFetch;
            $arrayTagId['$' . $strVar][ztagIdType] = idTypeFetch;
        }
        if (strlen($strField)) {
            $arrayTagId["Field_{$tagId}"][ztagIdValue] = $dbFetch;
            $arrayTagId["Field_{$tagId}"][ztagIdType] = idTypeFetch;
        }
        if ($strTimes) {
            $blnOk = $intTimes--;
        }
        $strResult = ztagRun($templateContent, 0, $arrayTagId);
        if ($handleFile && fwrite($handleFile, $arrayTag[$tagId][ztagResult]) === FALSE) {
            if (!$errorMessageTemp) {
                $errorMessage .= $errorMessageTemp = "\r\nCannot write to file ({$strFileName})";
            }
        }
        if ($blnShow) {
            $arrayTag[$tagId][ztagResult] .= $strResult;
        }
    }
    if ($handleFile) {
        fclose($handleFile);
    }
    ztagError($errorMessage, $arrayTag, $tagId);
}
Example #2
0
/**
 * Main zTag functions selector
 *
 * <code>
 * zform_execute($tagId, $tagFunction, $arrayTag, $arrayTagId, $arrayOrder);
 * </code>
 *
 * @param integer $tagId array id of current zTag of $arrayTag array
 * @param string $tagFunction name of zTag function
 * @param array $arrayTag array with all compiled zTags
 * @param array $arrayTagId array with all Ids values
 * @param array $arrayOrder array with zTag executing order
 *
 * @since 1.0
 */
function zform_zexecute($tagId, $tagFunction, &$arrayTag, &$arrayTagId, $arrayOrder)
{
    $arrParam = $arrayTag[$tagId][ztagParam];
    $strId = $arrParam["id"];
    $strTagId = $arrParam["tagid"];
    $strName = $arrParam["name"];
    $strCaption = $arrParam["caption"];
    $strValue = $arrParam["value"];
    $strValues = $arrParam["values"];
    if ($arrayTag[$tagId][ztagContentWidth]) {
        $strContent = $arrayTag[$tagId][ztagContent];
    }
    if (!$strTagId) {
        $strTagId = $strName;
    }
    $arrParam["id"] = $strTagId;
    $arrParam["for"] = $strTagId;
    if ($strCaption) {
        if (strpos(" {$strCaption}", "&")) {
            $labelAccessKey = preg_match("%&(.)%i", $strCaption);
            if (!$labelAccessKey) {
                $labelAccessKey = substr($strCaption, 1, 1);
            }
            $arrParam["accesskey"] = $labelAccessKey;
            $strCaption = preg_replace("%^(.*)&(.)(.*)\$%i", "\$1<u>\$2</u>\$3", $strCaption);
        }
    }
    $errorMessage = "";
    switch (strtolower($tagFunction)) {
        /*+
         * Input Text
         *
         * <code>
         * <zform:input type="text" name="fieldName" tagid="fieldId" value="fieldValue" />
         * </code>
         *
         * @param string type="text"
         * @param string name="fieldName"
         * @param string tagid="fieldId"
         * @param string value="fieldValue"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "input":
            $errorMessage = ztagParamCheck($arrParam, "type,name");
            $strParam = ztagParam($arrParam, "type,id,name,value,style,required,readonly,disabled,autocomplete,maxlength,size,tabindex,datebr");
            $arrayTag[$tagId][ztagResult] = "<input{$strParam} />";
            break;
            /*+
             * Input Text
             *
             * <code>
             * <zform:inputtext name="fieldName" tagid="fieldId" value="fieldValue" />
             * </code>
             *
             * @param string name="fieldName"
             * @param string tagid="fieldId"
             * @param string value="fieldValue"
             *
             * @author Ruben Zevallos Jr. <*****@*****.**>
             */
        /*+
         * Input Text
         *
         * <code>
         * <zform:inputtext name="fieldName" tagid="fieldId" value="fieldValue" />
         * </code>
         *
         * @param string name="fieldName"
         * @param string tagid="fieldId"
         * @param string value="fieldValue"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "inputtext":
            $arrParam["type"] = "text";
            $errorMessage = ztagParamCheck($arrParam, "type,name");
            $strParam = ztagParam($arrParam, "type,id,name,value,style,required,readonly,disabled,autocomplete,maxlength,size,tabindex,title,datebr");
            $arrayTag[$tagId][ztagResult] = "<input{$strParam} />";
            break;
            /*+
             * Input Hidden
             *
             * <code>
             * <zform:inputhidden name="fieldName" tagid="fieldId" value="fieldValue" />
             * </code>
             *
             * @param string name="fieldName"
             * @param string tagid="fieldId"
             * @param string value="fieldValue"
             *
             * @author Ruben Zevallos Jr. <*****@*****.**>
             */
        /*+
         * Input Hidden
         *
         * <code>
         * <zform:inputhidden name="fieldName" tagid="fieldId" value="fieldValue" />
         * </code>
         *
         * @param string name="fieldName"
         * @param string tagid="fieldId"
         * @param string value="fieldValue"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "inputhidden":
            $arrParam["type"] = "hidden";
            $errorMessage = ztagParamCheck($arrParam, "type,name");
            $strParam = ztagParam($arrParam, "type,id,name,value");
            $arrayTag[$tagId][ztagResult] = "<input{$strParam} />";
            break;
            /*+
             * Input Password
             *
             * <code>
             * <zform:inputpassword name="fieldName" tagid="fieldId" value="fieldValue" />
             * </code>
             *
             * @param string name="fieldName"
             * @param string tagid="fieldId"
             * @param string value="fieldValue"
             *
             * @author Ruben Zevallos Jr. <*****@*****.**>
             */
        /*+
         * Input Password
         *
         * <code>
         * <zform:inputpassword name="fieldName" tagid="fieldId" value="fieldValue" />
         * </code>
         *
         * @param string name="fieldName"
         * @param string tagid="fieldId"
         * @param string value="fieldValue"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "inputpassword":
            $arrParam["type"] = "password";
            $errorMessage = ztagParamCheck($arrParam, "type,name");
            $strParam = ztagParam($arrParam, "type,id,name,value,style,required,readonly");
            $arrayTag[$tagId][ztagResult] = "<input{$strParam} />";
            break;
            /*+
             * Input Checkbox
             *
             * <code>
             * <zform:inputcheckbox name="fieldName" tagid="fieldId" value="fieldValue" />
             * </code>
             *
             * @param string name="fieldName"
             * @param string tagid="fieldId"
             * @param string value="fieldValue"
             *
             * @author Ruben Zevallos Jr. <*****@*****.**>
             */
        /*+
         * Input Checkbox
         *
         * <code>
         * <zform:inputcheckbox name="fieldName" tagid="fieldId" value="fieldValue" />
         * </code>
         *
         * @param string name="fieldName"
         * @param string tagid="fieldId"
         * @param string value="fieldValue"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "inputcheckbox":
            $arrParam["type"] = "checkbox";
            $arrValues = explode(";", $strValues);
            if ($arrValues[0] == $strValue) {
                $strChecked = " checked=\"checked\"";
            }
            $errorMessage = ztagParamCheck($arrParam, "type,name,values");
            $strParam = ztagParam($arrParam, "type,id,name,value,style,required,readonly");
            $arrayTag[$tagId][ztagResult] = "<input{$strParam}{$strChecked} />";
            break;
            /*+
             * Text Area
             *
             * <code>
             * <zform:textarea name="fieldName" tagid="fieldId" value="fieldValue" />
             *
             * <zform:textarea name="fieldName" tagid="fieldId" filename="fileSave.txt" filetype="txt">
             * Text Area value
             * </zform:textarea>
             * </code>
             *
             * @param string name="fieldName"
             * @param string tagid="fieldId"
             * @param string value="fieldValue"
             *
             * @param string filename="/Alianca8/File.txt"
             * @param string filetype="txt"
             * @param string show="0"
             *
             * @author Ruben Zevallos Jr. <*****@*****.**>
             */
        /*+
         * Text Area
         *
         * <code>
         * <zform:textarea name="fieldName" tagid="fieldId" value="fieldValue" />
         *
         * <zform:textarea name="fieldName" tagid="fieldId" filename="fileSave.txt" filetype="txt">
         * Text Area value
         * </zform:textarea>
         * </code>
         *
         * @param string name="fieldName"
         * @param string tagid="fieldId"
         * @param string value="fieldValue"
         *
         * @param string filename="/Alianca8/File.txt"
         * @param string filetype="txt"
         * @param string show="0"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "textarea":
            $strFileName = $arrParam["filename"];
            $strFileType = $arrParam["filetype"];
            $strShow = strtolower($arrParam["show"]);
            if (strlen($strContent)) {
                $arrParam["value"] = $strContent;
            }
            $strValue = $arrParam["value"];
            if (strlen($strValue)) {
                $strValue = ztagVars($strValue, $arrayTagId);
                $strValue = ztagRun($strValue, 0, $arrayTagId);
            }
            $arrParam["type"] = "textarea";
            $errorMessage = ztagParamCheck($arrParam, "type,name");
            $strParam = ztagParam($arrParam, "type,id,name,style,required,readonly,disabled,cols,rows,tabindex,title");
            $arrayTag[$tagId][ztagResult] = "<textarea{$strParam} />{$strValue}</textarea>";
            $blnShow = $strShow === "true" || $strShow === "1" || !strlen($strShow);
            if ($strFileName) {
                $strFileName = str_replace("\\", "/", $strFileName);
                if (substr($strFileName, 0, 1) === "/") {
                    $strFileName = substr($strFileName, 1);
                }
                $strFileName = SiteRootDir . $strFileName;
                if (!($handleFile = fopen($strFileName, "w"))) {
                    $errorMessage .= "\r\nCannot open file ({$strFileName})";
                }
            }
            if ($handleFile && fwrite($handleFile, $strValue) === FALSE) {
                if (!$errorMessageTemp) {
                    $errorMessage .= $errorMessageTemp = "\r\nCannot write to file ({$strFileName})";
                }
            }
            if ($handleFile) {
                fclose($handleFile);
            }
            break;
            /*+
             * Select
             *
             * <code>
             * <zform:select name="textNameSelect" tagid="textIdSelect" value="tagOptionValue1,tagOptionCaption1;tagOptionValue2,tagOptionCaption2;tagOptionValue3,tagOptionCaption3" />
             * </code>
             *
             * @param string name="fieldName"
             * @param string tagid="fieldId"
             * @param string value="fieldValue"
             *
             * @author Ruben Zevallos Jr. <*****@*****.**>
             */
        /*+
         * Select
         *
         * <code>
         * <zform:select name="textNameSelect" tagid="textIdSelect" value="tagOptionValue1,tagOptionCaption1;tagOptionValue2,tagOptionCaption2;tagOptionValue3,tagOptionCaption3" />
         * </code>
         *
         * @param string name="fieldName"
         * @param string tagid="fieldId"
         * @param string value="fieldValue"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "select":
            $strOptions = $arrParam["options"];
            if ($strOptions) {
                $arrOptions = explode(";", $strOptions);
                foreach ($arrOptions as $keyOptions => $valueOptions) {
                    $strSelected = "";
                    $arrOption = explode(",", $valueOptions);
                    if ($strValue == $arrOption[0]) {
                        $strSelected = " selected=\"selected\"";
                    }
                    if (!$arrOption[1]) {
                        $arrOption[1] = $arrOption[0];
                    }
                    $strOptions .= "<option value=\"{$arrOption['0']}\"{$strSelected}>{$arrOption['1']}</option>";
                }
            }
            $errorMessage = ztagParamCheck($arrParam, "name,options");
            $strParam = ztagParam($arrParam, "type,id,name,style,required,readonly,disabled,cols,rows,tabindex,title");
            $arrayTag[$tagId][ztagResult] = "<select{$strParam} />{$strOptions}</select>";
            break;
            /*+
             * Input Submit
             *
             * <code>
             * <zform:inputsubmit name="fieldName" tagid="fieldId" value="fieldValue" />
             * </code>
             *
             * @param string name="fieldName"
             * @param string tagid="fieldId"
             * @param string value="fieldValue"
             *
             * @author Ruben Zevallos Jr. <*****@*****.**>
             */
        /*+
         * Input Submit
         *
         * <code>
         * <zform:inputsubmit name="fieldName" tagid="fieldId" value="fieldValue" />
         * </code>
         *
         * @param string name="fieldName"
         * @param string tagid="fieldId"
         * @param string value="fieldValue"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "inputsubmit":
            $arrParam["type"] = "submit";
            $errorMessage = ztagParamCheck($arrParam, "type,name,value");
            $strParam = ztagParam($arrParam, "type,id,name,value");
            $arrayTag[$tagId][ztagResult] = "<input{$strParam} />";
            break;
            /*+
             * Box
             *
             * <code>
             * <zform:box type="text" caption="caption" name="fieldName" tagid="fieldId" value="fieldValue" />
             * </code>
             *
             * @param string name="fieldName"
             * @param string tagid="fieldId"
             * @param string value="fieldValue"
             *
             * @author Ruben Zevallos Jr. <*****@*****.**>
             */
        /*+
         * Box
         *
         * <code>
         * <zform:box type="text" caption="caption" name="fieldName" tagid="fieldId" value="fieldValue" />
         * </code>
         *
         * @param string name="fieldName"
         * @param string tagid="fieldId"
         * @param string value="fieldValue"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "box":
            $errorMessage = ztagParamCheck($arrParam, "type,caption,name");
            $strLabel = ztagParam($arrParam, "accesskey,for");
            $strParam = ztagParam($arrParam, "type,id,name,value,style,required,readonly,disabled,autocomplete,maxlength,size,tabindex,title,datebr");
            $arrayTag[$tagId][ztagResult] = "<label{$strLabel}>{$strCaption}<br /><input{$strParam} /></label>";
            break;
            /*+
             * Box Text
             *
             * <code>
             * <zform:boxtext caption="caption" name="fieldName" tagid="fieldId" value="fieldValue" />
             * </code>
             *
             * @param string name="fieldName"
             * @param string tagid="fieldId"
             * @param string value="fieldValue"
             *
             * @author Ruben Zevallos Jr. <*****@*****.**>
             */
        /*+
         * Box Text
         *
         * <code>
         * <zform:boxtext caption="caption" name="fieldName" tagid="fieldId" value="fieldValue" />
         * </code>
         *
         * @param string name="fieldName"
         * @param string tagid="fieldId"
         * @param string value="fieldValue"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "boxtext":
            $arrParam["type"] = "text";
            $errorMessage = ztagParamCheck($arrParam, "type,caption,name");
            $strLabel = ztagParam($arrParam, "accesskey,for");
            $strParam = ztagParam($arrParam, "type,id,name,value,style,required,readonly,disabled,autocomplete,maxlength,size,tabindex,title,datebr");
            $arrayTag[$tagId][ztagResult] = "<label{$strLabel}>{$strCaption}<br /><input{$strParam} /></label>";
            break;
            /*+
             * Box Password
             *
             * <code>
             * <zform:boxpassword name="fieldName" tagid="fieldId" value="fieldValue" />
             * </code>
             *
             * @param string name="fieldName"
             * @param string tagid="fieldId"
             * @param string value="fieldValue"
             *
             * @author Ruben Zevallos Jr. <*****@*****.**>
             */
        /*+
         * Box Password
         *
         * <code>
         * <zform:boxpassword name="fieldName" tagid="fieldId" value="fieldValue" />
         * </code>
         *
         * @param string name="fieldName"
         * @param string tagid="fieldId"
         * @param string value="fieldValue"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "boxpassword":
            $arrParam["type"] = "password";
            $errorMessage = ztagParamCheck($arrParam, "type,caption,name");
            $strLabel = ztagParam($arrParam, "accesskey,for");
            $strParam = ztagParam($arrParam, "type,id,name,value,style,required,readonly");
            $arrayTag[$tagId][ztagResult] = "<label{$strLabel}>{$strCaption}<br /><input{$strParam} /></label>";
            break;
            /*+
             * Box Checkbox
             *
             * <code>
             * <zform:boxcheckbox caption="&CheckBox" name="checkboxNameBox" tagid="checkboxIdBox"  value="checkboxValueOn" values="checkboxValueOn;checkboxValueOff" />
             * </code>
             *
             * @param string name="fieldName"
             * @param string tagid="fieldId"
             * @param string value="fieldValue"
             *
             * @author Ruben Zevallos Jr. <*****@*****.**>
             */
        /*+
         * Box Checkbox
         *
         * <code>
         * <zform:boxcheckbox caption="&CheckBox" name="checkboxNameBox" tagid="checkboxIdBox"  value="checkboxValueOn" values="checkboxValueOn;checkboxValueOff" />
         * </code>
         *
         * @param string name="fieldName"
         * @param string tagid="fieldId"
         * @param string value="fieldValue"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "boxcheckbox":
            $arrParam["type"] = "checkbox";
            $arrValues = explode(";", $strValues);
            if ($arrValues[0] == $strValue) {
                $arrParam["checked"] = "checked";
            }
            $errorMessage = ztagParamCheck($arrParam, "type,name,value,values");
            $strParam = ztagParam($arrParam, "type,id,name,value,style,required,readonly");
            $arrayTag[$tagId][ztagResult] = "<label{$strLabel}><input{$strParam} /> {$strCaption}</label>";
            break;
            /*+
             * Box Radio
             *
             * <code>
             * <zform:boxradio caption="Processos com GTOs duplicadas" name="FL_CONTA_MEDICA_Estado" tagid="FL_DATA_Consulta" value="1" checked="$FL_GTO_DUPLICADACheck" />
             * </code>
             *
             * @param string name="fieldName"
             * @param string tagid="fieldId"
             * @param string value="fieldValue"
             *
             * @author Ruben Zevallos Jr. <*****@*****.**>
             */
        /*+
         * Box Radio
         *
         * <code>
         * <zform:boxradio caption="Processos com GTOs duplicadas" name="FL_CONTA_MEDICA_Estado" tagid="FL_DATA_Consulta" value="1" checked="$FL_GTO_DUPLICADACheck" />
         * </code>
         *
         * @param string name="fieldName"
         * @param string tagid="fieldId"
         * @param string value="fieldValue"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "boxradio":
            $arrParam["type"] = "radio";
            $arrValues = explode(";", $strValues);
            if ($arrValues[0] == $strValue) {
                $arrParam["checked"] = "checked";
            }
            $errorMessage = ztagParamCheck($arrParam, "type,name,value,values");
            $strParam = ztagParam($arrParam, "type,id,name,value,style,required,readonly");
            $arrayTag[$tagId][ztagResult] = "<label{$strLabel}><input{$strParam} /> {$strCaption}</label>";
            break;
            /*+
             * Box Text Area
             *
             * <code>
             * <zform:boxtextarea name="fieldName" tagid="fieldId" value="fieldValue" />
             * </code>
             *
             * @param string name="fieldName"
             * @param string tagid="fieldId"
             * @param string value="fieldValue"
             *
             * @author Ruben Zevallos Jr. <*****@*****.**>
             */
        /*+
         * Box Text Area
         *
         * <code>
         * <zform:boxtextarea name="fieldName" tagid="fieldId" value="fieldValue" />
         * </code>
         *
         * @param string name="fieldName"
         * @param string tagid="fieldId"
         * @param string value="fieldValue"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "boxtextarea":
            $arrParam["type"] = "textarea";
            $errorMessage = ztagParamCheck($arrParam, "type,caption,name,value");
            $strLabel = ztagParam($arrParam, "accesskey,for");
            $strParam = ztagParam($arrParam, "type,id,name,style,required,readonly,disabled,cols,rows,tabindex,title");
            $arrayTag[$tagId][ztagResult] = "<label{$strLabel}>{$strCaption}<br /><textarea{$strParam} />{$strValue}</textarea></label>";
            break;
            /*+
             * Box Select
             *
             * <code>
             * <zform:boxselect caption="&Text" name="textNameBox" tagid="textIdBox" value="textValueBox" options="tagOptionValue1,tagOptionCaption1;tagOptionValue2,tagOptionCaption2;tagOptionValue3,tagOptionCaption3" />
             * </code>
             *
             * @param string name="fieldName"
             * @param string tagid="fieldId"
             * @param string value="fieldValue"
             *
             * @author Ruben Zevallos Jr. <*****@*****.**>
             */
        /*+
         * Box Select
         *
         * <code>
         * <zform:boxselect caption="&Text" name="textNameBox" tagid="textIdBox" value="textValueBox" options="tagOptionValue1,tagOptionCaption1;tagOptionValue2,tagOptionCaption2;tagOptionValue3,tagOptionCaption3" />
         * </code>
         *
         * @param string name="fieldName"
         * @param string tagid="fieldId"
         * @param string value="fieldValue"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "boxselect":
            $strOptions = $arrParam["options"];
            if ($strOptions) {
                $arrOptions = explode(";", $strOptions);
                $strOptions = "";
                foreach ($arrOptions as $keyOptions => $valueOptions) {
                    $strSelected = "";
                    $arrOption = explode(",", $valueOptions);
                    if ($strValue == $arrOption[0]) {
                        $strSelected = " selected=\"selected\"";
                    }
                    if (!$arrOption[1]) {
                        $arrOption[1] = $arrOption[0];
                    }
                    $strOptions .= "<option value=\"{$arrOption['0']}\"{$strSelected}>{$arrOption['1']}</option>";
                }
            }
            $errorMessage = ztagParamCheck($arrParam, "name,options");
            $strLabel = ztagParam($arrParam, "accesskey,for");
            $strParam = ztagParam($arrParam, "type,id,name,style,required,readonly,disabled,cols,rows,tabindex,title");
            $arrayTag[$tagId][ztagResult] = "<label{$strLabel}>{$strCaption}<br /><select{$strParam} />{$strOptions}</select></label>";
            break;
            /*+
             * Button
             *
             * <code>
             * <zform:button name="fieldName" tagid="fieldId" value="fieldValue" />
             * </code>
             *
             * @param string name="fieldName"
             * @param string tagid="fieldId"
             * @param string value="fieldValue"
             *
             * @author Ruben Zevallos Jr. <*****@*****.**>
             */
        /*+
         * Button
         *
         * <code>
         * <zform:button name="fieldName" tagid="fieldId" value="fieldValue" />
         * </code>
         *
         * @param string name="fieldName"
         * @param string tagid="fieldId"
         * @param string value="fieldValue"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "button":
            break;
        default:
            $errorMessage .= "<br />Undefined function \"{$tagFunction}\"";
    }
    ztagError($errorMessage, $arrayTag, $tagId);
}
/**
 * Main zTag functions selector
 *
 * <code>
 * zmemcached_execute($tagId, $tagFunction, $arrayTag, $arrayTagId, $arrayOrder);
 * </code>
 *
 * @param integer $tagId array id of current zTag of $arrayTag array
 * @param string $tagFunction name of zTag function
 * @param array $arrayTag array with all compiled zTags
 * @param array $arrayTagId array with all Ids values
 * @param array $arrayOrder array with zTag executing order
 *
 * @since 1.0
 */
function zmemcached_zexecute($tagId, $tagFunction, &$arrayTag, &$arrayTagId, $arrayOrder)
{
    $arrParam = $arrayTag[$tagId][ztagParam];
    $strId = $arrParam["id"];
    $strUse = $arrParam["use"];
    $strValue = $arrParam["value"];
    $strKey = $arrParam["key"];
    if ($arrayTag[$tagId][ztagContentWidth]) {
        $strContent = $arrayTag[$tagId][ztagContent];
    }
    $errorMessage = "";
    switch (strtolower($tagFunction)) {
        /*+
         * <zmemcached:foreach use="getAll" value="value">
         *   <zhtml:b value="$key" />: <zvar:show use="$value" /><br />
         * </zmemcached:foreach>
         *
         * <zmemcached:foreach use="getAll" key="key" value="value">
         *   <zhtml:b value="$key" />: <zvar:show use="$value" /><br />
         * </zmemcached:foreach>
         *
         * Iterate over arrays executing it's content many time as it's content.
         *
         * use="getAll" Variable array
         * key="key" Variable where the array Key with saved
         * value="value" Variable where the array Value with saved
         *
         */
        case "foreach":
            $errorMessage .= ztagParamCheck($arrParam, "use,value");
            if ($arrayTagId["\$" . $strUse][ztagIdType] != idTypeFVar) {
                $errorMessage .= "<br />The handle \"{$strUse}\" is not a var one!";
            }
            $strArray = $arrayTagId["\$" . $strUse][ztagIdValue];
            $arrayTag[$tagId][ztagResult] = $strValue;
            if (strlen($strValue) && !strlen($strKey)) {
                foreach ($strArray as $value) {
                    $arrayTagId["\$" . $strValue][ztagIdValue] = $value;
                    $arrayTagId["\$" . $strValue][ztagIdType] = idTypeFVar;
                    $arrayTag[$tagId][ztagResult] .= ztagRun($strContent, 0, $arrayTagId);
                }
            } else {
                foreach ($strArray as $key => $value) {
                    $arrayTagId["\$" . $strKey][ztagIdValue] = $key;
                    $arrayTagId["\$" . $strKey][ztagIdType] = idTypeFVar;
                    $arrayTagId["\$" . $strValue][ztagIdValue] = $value;
                    $arrayTagId["\$" . $strValue][ztagIdType] = idTypeFVar;
                    $arrayTag[$tagId][ztagResult] .= ztagRun($strContent, 0, $arrayTagId);
                }
            }
            break;
        default:
            $errorMessage .= "<br />Undefined function \"{$tagFunction}\"";
    }
    /*
      debugError("tagFunction=$tagFunction"
    ."<br />tagId=$tagId"
    ."<br />strId=$strId"
    ."<br />strUse=$strUse"
    ."<br />strValue=$strValue"
    ."<br />arrayTagId[$strId][ztagIdValue]=".$arrayTagId[$strId][ztagIdValue]
    ."<br />arrayTagId[$strUse][ztagIdValue]=".$arrayTagId[$strUse][ztagIdValue]
    ."<br />arrayTag[$tagId][ztagResult]=".$arrayTag[$tagId][ztagResult]);
    */
    ztagError($errorMessage, $arrayTag, $tagId);
}
Example #4
0
function zlayout_execute($tagId, $tagFunction, &$arrayTag, &$arrayTagId, $arrayOrder)
{
    global $layoutLastCreateId;
    global $layoutColumnOrder;
    $arrParam = $arrayTag[$tagId][ztagParam];
    $strId = $arrParam["id"];
    $strUse = $arrParam["use"];
    $strName = $arrParam["name"];
    $strTransform = $arrParam["transform"];
    $errorMessage = "";
    switch (strtolower($tagFunction)) {
        /*+
         * Create
         *
         * <code>
         * <zlayout:create id="ociPrestador" headtag="th" celltag="td">
         * </code>
         *
         * @param string id="ociPrestador"
         * @param string headtag="th"
         * @param string celltag="td"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "create":
            $errorMessage .= ztagParamCheck($arrParam, "id");
            $layoutLastCreateId = $strId;
            $layoutColumnOrder[$strId] = 0;
            if ($arrayTag[$tagId][ztagContentWidth]) {
                $strContent = $arrayTag[$tagId][ztagContent];
                $arrayTagId[$strId][ztagIdValue] = $strContent;
                $arrayTagId[$strId][ztagIdLength] = strlen($strValue);
                $arrayTagId[$strId][ztagIdType] = idTypeLayout;
                if ($arrParam["headtag"]) {
                    $arrayTagId[$strId][layoutTypeDefault][layouHeadTag] = $arrParam["headtag"];
                }
                if ($arrParam["celltag"]) {
                    $arrayTagId[$strId][layoutTypeDefault][layouCellTag] = $arrParam["celltag"];
                }
                ztagRun($strContent, 0, $arrayTagId);
                echo "<pre>";
                print_r($arrayTagId);
            }
            break;
            /*+
             * Column
             *
             * <code>
             * <zlayout:column use="ociPrestador" name="NM_PESSOA" caption="Nome" headstyle="C,U" bodystyle="R" transform="sentence()" />
             * </code>
             *
             * @param string use="ociPrestador"
             * @param string name="NM_PESSOA"
             * @param string caption="Nome"
             * @param string headstyle="C,U"
             * @param string bodystyle="R"
             * @param string transform="sentence()"
             *
             * @author Ruben Zevallos Jr. <*****@*****.**>
             */
        /*+
         * Column
         *
         * <code>
         * <zlayout:column use="ociPrestador" name="NM_PESSOA" caption="Nome" headstyle="C,U" bodystyle="R" transform="sentence()" />
         * </code>
         *
         * @param string use="ociPrestador"
         * @param string name="NM_PESSOA"
         * @param string caption="Nome"
         * @param string headstyle="C,U"
         * @param string bodystyle="R"
         * @param string transform="sentence()"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "column":
            if (!$strUse) {
                $arrParam["use"] = $layoutLastCreateId;
            }
            $strUse = $arrParam["use"];
            $strCaption = $arrParam["caption"];
            $strHeadStyle = $arrParam["headstyle"];
            $strBodyStyle = $arrParam["bodystyle"];
            $errorMessage .= ztagParamCheck($arrParam, "use,name");
            if ($arrayTagId[$strUse][ztagIdType] == idTypeLayout) {
                $arrLayout = $arrayTagId[$strUse][ztagIdLayout];
                $intOrder = $layoutColumnOrder[$strUse]++;
                $arrLayout[$strName][layoutTypeOrder][$intOrder] = $strName;
                if (!$strCaption) {
                    $strCaption = $strName;
                }
                $arrLayout[$strName][layoutTypeHeader][layouCaption] = $strCaption;
                $arrLayout[$strName][layoutTypeHeader][layoutStyle] = $strHeadStyle;
                $arrLayout[$strName][layoutTypeBody][layoutStyle] = $strBodyStyle;
                $arrLayout[$strName][layoutTypeBody][layouTransform] = $strTransform;
                // unset($arrayTagId[$strId][ztagIdLayout]);
                $arrayTagId[$strUse][ztagIdLayout] = $arrLayout;
            } else {
                $errorMessage .= "<br />The id \"{$strUse}\" is not a layout type";
            }
            break;
        default:
            $errorMessage .= "<br />Undefined function \"{$tagFunction}\"";
    }
    ztagError($errorMessage, $arrayTag, $tagId);
}
Example #5
0
/**
 * Main zTag functions selector
 *
 * <code>
 * znosql_execute($tagId, $tagFunction, $arrayTag, $arrayTagId, $arrayOrder);
 * </code>
 *
 * @param integer $tagId array id of current zTag of $arrayTag array
 * @param string $tagFunction name of zTag function
 * @param array $arrayTag array with all compiled zTags
 * @param array $arrayTagId array with all Ids values
 * @param array $arrayOrder array with zTag executing order
 *
 * @since 1.0
 */
function znosql_zexecute($tagId, $tagFunction, &$arrayTag, &$arrayTagId, $arrayOrder)
{
    $arrParam = $arrayTag[$tagId][ztagParam];
    $strId = $arrParam["id"];
    $strUse = $arrParam["use"];
    $strDatabase = $arrParam["database"];
    $strCollection = $arrParam["collection"];
    $strName = $arrParam["name"];
    $strValue = $arrParam["value"];
    $strVar = $arrParam["var"];
    $strTransform = $arrParam["transform"];
    if ($arrayTag[$tagId][ztagContentWidth]) {
        $strContent = $arrayTag[$tagId][ztagContent];
    }
    $errorMessage = "";
    switch (strtolower($tagFunction)) {
        /*+
         * Open connection to a NoSQL Server
         *
         * <code>
         * <znosql:open id="mongoDB" driver="Mongo" host="username:password@mongodb.zyc.com.br:27017" database="Direito2" collection="pubPaginas" />
         * <znosql:open id="mongoDB" driver="Mongo" host="mongodb.zyc.com.br" username="******" password="******" port="27017" database="Direito2" collection="pubPaginas" />
         * </code>
         *
         * @param string id="mongoDB"
         * @param string driver="Mongo"
         * @param string host="username:password@mongodb.zyc.com.br:27017" <-- mongodb://[username:password@]host1[:port1][,host2[:port2:],...]
         * @param string username="******"
         * @param string password="******"
         * @param int port="27017"
         * @param string options="option=value;option2=value2"
         * @param string database="Direito2"
         * @param string collection="pubPaginas"
         * @param boolean persist="0|1|true|false|x"
         */
        case "open":
            $strDriver = $arrParam["driver"];
            $strHost = $arrParam["host"];
            $strUsername = $arrParam["username"];
            $strPassword = $arrParam["password"];
            $strPort = $arrParam["port"];
            $strPersist = $arrParam["persist"];
            $strOptions = $arrParam["options"];
            ztagReturnConstant($strHost);
            ztagReturnConstant($strDatabase);
            ztagReturnConstant($strUsername);
            ztagReturnConstant($strPassword);
            ztagReturnConstant($strPort);
            $errorMessage .= ztagParamCheck($arrParam, "id,driver,host");
            $strDriver = constant("nosql{$strDriver}");
            if (strlen($strUsername) && strlen($strPassword)) {
                $strHost = "{$strUsername}:{$strPassword}@{$strHost}";
            }
            if (strlen($strPort)) {
                $strHost = "{$strHost}:{$strPort}";
            }
            if (strlen($strOptions)) {
                $strHost = "{$strHost}?{$strOptions}";
            }
            if (extension_loaded('mongo')) {
                try {
                    $nosqlHandle = array();
                    if ($strPersist === "true" || $strPersist === "1" || ($strPersist = "x")) {
                        $dbHandle = new Mongo($strHost, array("persist" => "x"));
                    } else {
                        $dbHandle = new Mongo($strHost);
                    }
                    if ($strDatabase) {
                        $nosqlDB = $nosqlHandle->selectDB($strDatabase);
                    }
                } catch (MongoConnectionException $e) {
                    $errorMessage .= "<br />Cannot connect to {$strDriver} (" . $e->getMessage() . ")";
                }
                if (strlen($strCollection)) {
                    $nosqlColection = $nosqlDB->selectCollection($strCollection);
                }
            } else {
                $errorMessage .= "<br />{$strDriver} extention is not installed!";
            }
            // Set all NoSQL handler structure
            $nosqlHandle[nosqlHandleDriver] = $strDriver;
            $nosqlHandle[nosqlHandleHost] = $strHost;
            $nosqlHandle[nosqlHandleDatabaseName] = $dbDatabase;
            $nosqlHandle[nosqlHandleUser] = $strUsername;
            $nosqlHandle[nosqlHandlePassword] = $strPassword;
            $nosqlHandle[nosqlHandlePort] = $strPort;
            $nosqlHandle[nosqlHandleId] = $dbHandle;
            $nosqlHandle[nosqlHandleState] = dbHandleStateOpen;
            $arrayTagId[$strId][ztagIdHandle] = $nosqlHandle;
            $arrayTagId[$strId][ztagIdType] = idTypeNoSQL;
            $arrayTagId[$strId][ztagIdState] = idStateOpened;
            break;
            /*+
             * Close a Opened NoSQL Handle connection
             *
             * <code>
             * <znosql:close use="mongoDB">
             * </code>
             *
             * @param string use="mongoDB"
             *
             */
        /*+
         * Close a Opened NoSQL Handle connection
         *
         * <code>
         * <znosql:close use="mongoDB">
         * </code>
         *
         * @param string use="mongoDB"
         *
         */
        case "close":
            if ($arrayTagId[$strUse][ztagIdType] === idTypeNoSQL) {
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    $nosqlHandle = $arrayTagId[$strUse][ztagIdHandle];
                    $dbHandle = $nosqlHandle[nosqlHandleId];
                    $dbHandle->close();
                    $arrayTagId[$strUse][ztagIdHandle] = $dbHandle;
                    $arrayTagId[$strUse][ztagIdState] = idStateClosed;
                } else {
                    $errorMessage .= "<br />The {$strUse} NoSQL handler is not Open!";
                }
            } else {
                $errorMessage .= "<br />The {$strUse} type is not a NoSQL!";
            }
            break;
            /*+
             * Do an Insert in currente Collection
             *
             * </code>
             * <znosql:insert use="mongoDB">
             *  pagCodigo="1"
             *  , pagNome="Page \"title\""
             *  , pagResumo='Page \'resume\''
             *  , pagDescricao:"Page body"
             *  , pagPalavrasChave:{"example","NoSQL"}
             *  , pagInclusao='2010/10/10'
             *  , pagAtivo=1
             * </znosql:insert>
             *
             * <znosql:insert use="mongoDB" value="$varInsert" />
             * </code>
             *
             *  @param string use="mongoDB"
             *  @param boolean safe="true|false|1|0"
             *  @param boolean fsync="true|false|1|0"
             */
        /*+
         * Do an Insert in currente Collection
         *
         * </code>
         * <znosql:insert use="mongoDB">
         *  pagCodigo="1"
         *  , pagNome="Page \"title\""
         *  , pagResumo='Page \'resume\''
         *  , pagDescricao:"Page body"
         *  , pagPalavrasChave:{"example","NoSQL"}
         *  , pagInclusao='2010/10/10'
         *  , pagAtivo=1
         * </znosql:insert>
         *
         * <znosql:insert use="mongoDB" value="$varInsert" />
         * </code>
         *
         *  @param string use="mongoDB"
         *  @param boolean safe="true|false|1|0"
         *  @param boolean fsync="true|false|1|0"
         */
        case "insert":
            $errorMessage .= ztagParamCheck($arrParam, "use");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeNoSQL) {
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    $nosqlHandle = $arrayTagId[$strUse][ztagIdHandle];
                    if ($nosqlHandle[nosqlHandleCollection]) {
                        $dbHandle = $nosqlHandle[nosqlHandleId];
                        $strDatabase = $nosqlHandle[nosqlHandleDatabaseName];
                        $strCollection = $nosqlHandle[nosqlHandleCollectionName];
                        $dbHandleCollection = $nosqlHandle[nosqlHandleCollection];
                        // Prepare the tag content
                        if (strlen($strContent)) {
                            $contentArray = $strContent;
                        }
                        if (strlen($strValue)) {
                            $contentArray = $strValue;
                        }
                        if (strlen($contentArray)) {
                            $contentArray = ztagVars($contentArray, $arrayTagId);
                        }
                        if (strlen($contentArray)) {
                            $contentArray = ztagRun($contentArray, 0, $arrayTagId);
                        }
                        if (!strlen($strContent) && !strlen($strValue)) {
                            $errorMessage .= ztagParamCheck($arrParam, "value");
                        }
                        if (strlen($strTransform) && strlen($contentArray)) {
                            $contentArray = ztagTransform($contentArray, $strTransform);
                        }
                        $contentArray = znosql_lib_Content2Array($contentArray);
                        // @TODO Think how to manage the safe option and it's MongoCursorException
                        try {
                            $dbResult = $dbHandleCollection->insert($contentArray);
                            // echo "<br /><pre>".print_r($contentArray, 1)."</pre>";
                            if (!strlen($dbResult)) {
                                $errorMessage .= "<br />Cannot insert into collection {$strCollection} at database {$strDatabase}  <pre>" . print_r($dbResult, 1) . "</pre>";
                            }
                        } catch (MongoException $e) {
                            $errorMessage .= "<br />Cannot insert into collection {$strCollection} at database {$strDatabase} (" . $e->getMessage() . ")";
                        }
                        $arrayTagId[$strUse][ztagIdHandle] = $nosqlHandle;
                    } else {
                        $errorMessage .= "<br />The {$strUse} NoSQL handler do not have a database defined!";
                    }
                } else {
                    $errorMessage .= "<br />The {$strUse} NoSQL handler is not Open!";
                }
            } else {
                $errorMessage .= "<br />The {$strUse} type is not a NoSQL!";
            }
            break;
            /*+
             * Execute a NoSQL commands
             *
             * <code>
             * <znosql:get use="mongoDB">
             *   Commands
             * </znosql:get>
             * </code>
             *
             * @param string use="mongoDB"
             *
             */
        /*+
         * Execute a NoSQL commands
         *
         * <code>
         * <znosql:get use="mongoDB">
         *   Commands
         * </znosql:get>
         * </code>
         *
         * @param string use="mongoDB"
         *
         */
        case "getone":
            $errorMessage .= ztagParamCheck($arrParam, "use");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeNoSQL) {
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    $nosqlHandle = $arrayTagId[$strUse][ztagIdHandle];
                    if ($nosqlHandle[nosqlHandleCollection]) {
                        $strDatabase = $nosqlHandle[nosqlHandleDatabaseName];
                        $strCollection = $nosqlHandle[nosqlHandleCollectionName];
                        $dbHandleCollection = $nosqlHandle[nosqlHandleCollection];
                        // Prepare the tag content
                        if (strlen($strContent)) {
                            $contentArray = $strContent;
                        }
                        if (strlen($strValue)) {
                            $contentArray = $strValue;
                        }
                        if (strlen($contentArray)) {
                            $contentArray = ztagVars($contentArray, $arrayTagId);
                        }
                        if (!strlen($strContent) && !strlen($strValue)) {
                            $errorMessage .= ztagParamCheck($arrParam, "value");
                        }
                        if (strlen($strTransform) && strlen($contentArray)) {
                            $contentArray = ztagTransform($contentArray, $strTransform);
                        }
                        $contentArray = ltrim($contentArray, "\r\n");
                        $contentArray = rtrim($contentArray, "\r\n");
                        preg_match_all("%criteria\\s*{(?P<criteria>(?:\\}|[^}])*?)}(\\s*,\\s*fields\\s*{(?P<fields>(?:\\}|[^}])*?)})?%", $contentArray, $Matches, PREG_OFFSET_CAPTURE);
                        $arrayCriteria = znosql_lib_Content2Array($Matches["criteria"][0][0]);
                        if ($Matches["fields"][0][0]) {
                            $arrayFields = znosql_lib_Content2Array($Matches["fields"][0][0], 1);
                        }
                        // @TODO Think how to manage the safe option and it's MongoCursorException
                        try {
                            if (count($arrayFields)) {
                                $dbResult = $dbHandleCollection->findOne($arrayCriteria, $arrayFields);
                            } else {
                                $dbResult = $dbHandleCollection->findOne($arrayCriteria);
                            }
                            if (strlen($strVar) && count($dbResult)) {
                                $arrayTagId["\$" . $strVar][ztagIdValue] = $value;
                                $arrayTagId["\$" . $strVar][ztagIdType] = idTypeFVar;
                            }
                        } catch (MongoConnectionException $e) {
                            $errorMessage .= "<br />Cannot find the criteria into collection {$strCollection} at database {$strDatabase} (" . $e->getMessage() . ")";
                        }
                        $arrayTagId[$strUse][ztagIdHandle] = $nosqlHandle;
                    } else {
                        $errorMessage .= "<br />The {$strUse} NoSQL handler do not have a database defined!";
                    }
                } else {
                    $errorMessage .= "<br />The {$strUse} NoSQL handler is not Open!";
                }
            } else {
                $errorMessage .= "<br />The {$strUse} type is not a NoSQL!";
            }
            break;
            /*+
             * Execute a NoSQL commands
             *
             * <code>
             * <znosql:get use="mongoDB">
             *   Commands
             * </znosql:execute>
             * </code>
             *
             * $query - the evaluation or "where" expression
             * $orderby - sort order desired
             * $hint - hint to query optimizer
             * $explain - if true, return explain plan results instead of query results
             * $snapshot - if true, "snapshot mode"
             */
        /*+
         * Execute a NoSQL commands
         *
         * <code>
         * <znosql:get use="mongoDB">
         *   Commands
         * </znosql:execute>
         * </code>
         *
         * $query - the evaluation or "where" expression
         * $orderby - sort order desired
         * $hint - hint to query optimizer
         * $explain - if true, return explain plan results instead of query results
         * $snapshot - if true, "snapshot mode"
         */
        case "getall":
            /*$errorMessage .= ztagParamCheck($arrParam, "use");
            	    // $cursor = $this->collection->find($f);
            
            	    $k = array();
            	    $i = 0;
            
            	    while( $cursor->hasNext())
            	    {
            	        $k[$i] = $cursor->getNext();
            	      $i++;
            	    }
            
            	    // return $k;
            	     *
            	     */
            break;
            /*+
             * Do an Update in currente Collection
             *
             * <code>
             * <znosql:update use="mongoDB">
             *  criteria{pagCodigo="1"}
             *  , set{pagNome="Page \"title\" Updated"
             *  , pagResumo='Page \'resume\''
             *  , pagDescricao:"Page body"
             *  , pagPalavrasChave:{"example","NoSQL"}
             *  , pagInclusao='2010/10/10'
             *  , pagAtivo=1
             *  }
             * </znosql:update>
             *
             * <znosql:update use="mongoDB" criteria="$varCriteria" value="$varInsert" />
             * </code>
             *
             * @param string use="mongoDB"
             * @param boolean upsert="true|false|1|0"
             * @param boolean multiple="true|false|1|0"
             * @param boolean safe="true|false|1|0"
             * @param boolean fsync="true|false|1|0"
             */
        /*+
         * Do an Update in currente Collection
         *
         * <code>
         * <znosql:update use="mongoDB">
         *  criteria{pagCodigo="1"}
         *  , set{pagNome="Page \"title\" Updated"
         *  , pagResumo='Page \'resume\''
         *  , pagDescricao:"Page body"
         *  , pagPalavrasChave:{"example","NoSQL"}
         *  , pagInclusao='2010/10/10'
         *  , pagAtivo=1
         *  }
         * </znosql:update>
         *
         * <znosql:update use="mongoDB" criteria="$varCriteria" value="$varInsert" />
         * </code>
         *
         * @param string use="mongoDB"
         * @param boolean upsert="true|false|1|0"
         * @param boolean multiple="true|false|1|0"
         * @param boolean safe="true|false|1|0"
         * @param boolean fsync="true|false|1|0"
         */
        case "update":
            $errorMessage .= ztagParamCheck($arrParam, "use");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeNoSQL) {
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    $nosqlHandle = $arrayTagId[$strUse][ztagIdHandle];
                    if ($nosqlHandle[nosqlHandleCollection]) {
                        $strDatabase = $nosqlHandle[nosqlHandleDatabaseName];
                        $strCollection = $nosqlHandle[nosqlHandleCollectionName];
                        $dbHandleCollection = $nosqlHandle[nosqlHandleCollection];
                        // Prepare the tag content
                        if (strlen($strContent)) {
                            $contentArray = $strContent;
                        }
                        if (strlen($strValue)) {
                            $contentArray = $strValue;
                        }
                        if (strlen($contentArray)) {
                            $contentArray = ztagVars($contentArray, $arrayTagId);
                        }
                        if (!strlen($strContent) && !strlen($strValue)) {
                            $errorMessage .= ztagParamCheck($arrParam, "value");
                        }
                        if (strlen($strTransform) && strlen($contentArray)) {
                            $contentArray = ztagTransform($contentArray, $strTransform);
                        }
                        $contentArray = ltrim($contentArray, "\r\n");
                        $contentArray = rtrim($contentArray, "\r\n");
                        preg_match_all("%criteria\\s*{(?P<criteria>(?:\\}|[^}])*?)}\\s*,\\s*set\\s*{(?P<set>(?:\\}|[^}])*?)}%", $contentArray, $Matches, PREG_OFFSET_CAPTURE);
                        // echo "<br /><pre>".print_r($Matches, 1)."</pre>";
                        $arrayCriteria = znosql_lib_Content2Array($Matches["criteria"][0][0]);
                        $arraySet = array('$set' => znosql_lib_Content2Array($Matches["set"][0][0]));
                        // @TODO Think how to manage the safe option and it's MongoCursorException
                        try {
                            $dbResult = $dbHandleCollection->update($arrayCriteria, $arraySet);
                            // echo "<br /><pre>".print_r($contentArray, 1)."</pre>";
                            if (!$dbResult) {
                                $errorMessage .= "<br />Cannot update the criteria into collection {$strCollection} at database {$strDatabase}  <pre>" . print_r($dbResult, 1) . "</pre>";
                            }
                        } catch (InvalidArgumentException $e) {
                            $errorMessage .= "<br />Cannot update the criteria into collection {$strCollection} at database {$strDatabase} (" . $e->getMessage() . ")";
                        }
                        $arrayTagId[$strUse][ztagIdHandle] = $nosqlHandle;
                    } else {
                        $errorMessage .= "<br />The {$strUse} NoSQL handler do not have a database defined!";
                    }
                } else {
                    $errorMessage .= "<br />The {$strUse} NoSQL handler is not Open!";
                }
            } else {
                $errorMessage .= "<br />The {$strUse} type is not a NoSQL!";
            }
            break;
            /*+
             * Delete a criteria at current collection
             *
             * <code>
             * <znosql:delete use="mongoDB">
             *  pagCodigo="1"
             * </znosql:delete>
             *
             * <znosql:delete use="mongoDB" criteria="$varCriteria" />
             * </code>
             *
             * @param string use="mongoDB"
             * @param boolean justone="true|false|1|0"
             * @param boolean safe="true|false|1|0"
             * @param boolean fsync="true|false|1|0"
             */
        /*+
         * Delete a criteria at current collection
         *
         * <code>
         * <znosql:delete use="mongoDB">
         *  pagCodigo="1"
         * </znosql:delete>
         *
         * <znosql:delete use="mongoDB" criteria="$varCriteria" />
         * </code>
         *
         * @param string use="mongoDB"
         * @param boolean justone="true|false|1|0"
         * @param boolean safe="true|false|1|0"
         * @param boolean fsync="true|false|1|0"
         */
        case "delete":
            $errorMessage .= ztagParamCheck($arrParam, "use");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeNoSQL) {
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    $nosqlHandle = $arrayTagId[$strUse][ztagIdHandle];
                    if ($nosqlHandle[nosqlHandleCollection]) {
                        $strDatabase = $nosqlHandle[nosqlHandleDatabaseName];
                        $strCollection = $nosqlHandle[nosqlHandleCollectionName];
                        $dbHandleCollection = $nosqlHandle[nosqlHandleCollection];
                        // Prepare the tag content
                        if (strlen($strContent)) {
                            $contentArray = $strContent;
                        }
                        if (strlen($strValue)) {
                            $contentArray = $strValue;
                        }
                        if (strlen($contentArray)) {
                            $contentArray = ztagVars($contentArray, $arrayTagId);
                        }
                        if (!strlen($strContent) && !strlen($strValue)) {
                            $errorMessage .= ztagParamCheck($arrParam, "value");
                        }
                        if (strlen($strTransform) && strlen($contentArray)) {
                            $contentArray = ztagTransform($contentArray, $strTransform);
                        }
                        $contentArray = znosql_lib_Content2Array($contentArray);
                        // echo "<br /><pre>contentArray=".print_r($contentArray, 1)."</pre>";
                        // @TODO Think how to manage the safe option and it's MongoCursorException
                        try {
                            $dbResult = $dbHandleCollection->remove($contentArray);
                            // echo "<br /><pre>dbResult=".print_r($dbResult, 1)."</pre>";
                            if (!$dbResult) {
                                $errorMessage .= "<br />Cannot delete the criteria into collection {$strCollection} at database {$strDatabase}  <pre>" . print_r($dbResult, 1) . "</pre>";
                            }
                        } catch (InvalidArgumentException $e) {
                            $errorMessage .= "<br />Cannot delete the criteria into collection {$strCollection} at database {$strDatabase} (" . $e->getMessage() . ")";
                        }
                        $arrayTagId[$strUse][ztagIdHandle] = $nosqlHandle;
                    } else {
                        $errorMessage .= "<br />The {$strUse} NoSQL handler do not have a database defined!";
                    }
                } else {
                    $errorMessage .= "<br />The {$strUse} NoSQL handler is not Open!";
                }
            } else {
                $errorMessage .= "<br />The {$strUse} type is not a NoSQL!";
            }
            break;
            /*+
             * Execute a NoSQL commands
             *
             * <code>
             * <znosql:execute use="mongoDB">
             *   Commands
             * </znosql:execute>
             * </code>
             *
             * @param string use="mongoDB"
             *
             */
        /*+
         * Execute a NoSQL commands
         *
         * <code>
         * <znosql:execute use="mongoDB">
         *   Commands
         * </znosql:execute>
         * </code>
         *
         * @param string use="mongoDB"
         *
         */
        case "execute":
            $errorMessage .= ztagParamCheck($arrParam, "use");
            // Execute Close, but I don't know yet!
            $arrayTagId[$strUse][ztagIdState] = idStateClosed;
            // mongo->execute($cmd);
            break;
            /*+
             * Set a database for current Opened NoSQL connection
             *
             * <code>
             * <znosql:setdatabase use="mongoDB" name="Direito2" />
             * </code>
             *
             * @param string use="mongoDB"
             * @param string name="Direito2" The database name.
             */
        /*+
         * Set a database for current Opened NoSQL connection
         *
         * <code>
         * <znosql:setdatabase use="mongoDB" name="Direito2" />
         * </code>
         *
         * @param string use="mongoDB"
         * @param string name="Direito2" The database name.
         */
        case "setdatabase":
            $errorMessage .= ztagParamCheck($arrParam, "use,name");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeNoSQL) {
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    $nosqlHandle = $arrayTagId[$strUse][ztagIdHandle];
                    $dbHandle = $nosqlHandle[nosqlHandleId];
                    try {
                        $dbHandleDatabase = $dbHandle->selectDB($strName);
                        $nosqlHandle[nosqlHandleDatabaseName] = $strName;
                        $nosqlHandle[nosqlHandleDatabase] = $dbHandleDatabase;
                    } catch (InvalidArgumentException $e) {
                        $errorMessage .= "<br />Invalid database name {$strName} (" . $e->getMessage() . ")";
                    }
                    $arrayTagId[$strUse][ztagIdHandle] = $nosqlHandle;
                } else {
                    $errorMessage .= "<br />The {$strUse} NoSQL handler is not Open!";
                }
            } else {
                $errorMessage .= "<br />The {$strUse} type is not a NoSQL!";
            }
            break;
            /*+
             * List all databases
             *
             * <code>
             * <znosql:listdatabases use="mongoDB" id="mongoDBlist" var="databasesList" total="databasesTotalSize">
             *   <br /><znosql:field use="mongoDBlist" name="name" /> - <znosql:field use="mongoDBlist" name="sizeOnDisk" /> - <znosql:field use="mongoDBlist" name="empty" />
             * </znosql:listdatabases>
             * </code>
             *
             * @param string use="mongoDB" A NoSQL handle
             * @param string id="mongoDBlist" Id with array of each line
             * @param string var="databasesList" Variable with array of each line
             * @param string total="databasesTotalSize" Variable with total size
             */
        /*+
         * List all databases
         *
         * <code>
         * <znosql:listdatabases use="mongoDB" id="mongoDBlist" var="databasesList" total="databasesTotalSize">
         *   <br /><znosql:field use="mongoDBlist" name="name" /> - <znosql:field use="mongoDBlist" name="sizeOnDisk" /> - <znosql:field use="mongoDBlist" name="empty" />
         * </znosql:listdatabases>
         * </code>
         *
         * @param string use="mongoDB" A NoSQL handle
         * @param string id="mongoDBlist" Id with array of each line
         * @param string var="databasesList" Variable with array of each line
         * @param string total="databasesTotalSize" Variable with total size
         */
        case "listdatabases":
            $strTotal = $arrParam["total"];
            $errorMessage .= ztagParamCheck($arrParam, "use,id");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeNoSQL) {
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    $nosqlHandle = $arrayTagId[$strUse][ztagIdHandle];
                    $dbHandle = $nosqlHandle[nosqlHandleId];
                    $arrayDatabases = $dbHandle->listDBs();
                    $totalDbSize = $arrayDatabases['totalSize'];
                    foreach ($arrayDatabases["databases"] as $key => $value) {
                        if (strlen($strId)) {
                            $arrayTagId[$strId][ztagIdValue] = $arrayDatabases["databases"][$key];
                            $arrayTagId[$strId][ztagIdType] = idTypeValue;
                        }
                        if (strlen($strVar)) {
                            $arrayTagId["\$" . $strVar][ztagIdValue] = $arrayDatabases["databases"][$key];
                            $arrayTagId["\$" . $strVar][ztagIdType] = idTypeFVar;
                        }
                        $strResult = ztagRun($strContent, 0, $arrayTagId);
                        $arrayTag[$tagId][ztagResult] .= $strResult;
                    }
                    if (strlen($strTotal)) {
                        $arrayTagId["\$" . $strTotal][ztagIdValue] = $arrayDatabases[totalSize];
                        $arrayTagId["\$" . $strTotal][ztagIdType] = idTypeFVar;
                    }
                } else {
                    $errorMessage .= "<br />The {$strUse} NoSQL handler is not Open!";
                }
            } else {
                $errorMessage .= "<br />The {$strUse} type is not a NoSQL!";
            }
            break;
            /*+
             * Return the server Stats
             *
             * <code>
             * <znosql:getstats use="mongoDB" var="mongoStats" />
             * </code>
             *
             * @param string use="mongoDB"
             * @param string var="mongoStats"
             */
        /*+
         * Return the server Stats
         *
         * <code>
         * <znosql:getstats use="mongoDB" var="mongoStats" />
         * </code>
         *
         * @param string use="mongoDB"
         * @param string var="mongoStats"
         */
        case "getstats":
            if ($arrayTagId[$strUse][ztagIdType] === idTypeNoSQL) {
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    $nosqlHandle = $arrayTagId[$strUse][ztagIdHandle];
                    $dbHandle = $nosqlHandle[nosqlHandleId];
                    $arrayDatabases = $dbHandle->listDBs();
                    $dbHandleAdmin = $dbHandle->selectDB('admin');
                    $arrayReturn = array_merge($dbHandleAdmin->command(array('buildinfo' => 1)), $dbHandleAdmin->command(array('serverStatus' => 1)));
                    $profile = $dbHandleAdmin->command(array('profile' => -1));
                    $arrayReturn['profilingLevel'] = $profile['was'];
                    $arrayReturn['mongoDbTotalSize'] = round($totalDbSize / 1000000) . 'mb';
                    $prevError = $dbHandleAdmin->command(array('getpreverror' => 1));
                    if (!$prevError['n']) {
                        $arrayReturn['previousDbErrors'] = 'None';
                    } else {
                        $arrayReturn['previousDbErrors']['error'] = $prevError['err'];
                        $arrayReturn['previousDbErrors']['numberOfOperationsAgo'] = $prevError['nPrev'];
                    }
                    $arrayReturn['globalLock']['totalTime'] .= ' &#0181;Sec';
                    $arrayReturn['uptime'] = round($arrayReturn['uptime'] / 60) . ':' . str_pad($arrayReturn['uptime'] % 60, 2, '0', STR_PAD_LEFT) . ' minutes';
                    $arrayUnshift['mongo'] = $arrayReturn['version'] . ' (' . $arrayReturn['bits'] . '-bit)';
                    $arrayUnshift['mongoPhpDriver'] = Mongo::VERSION;
                    $arrayUnshift['phpMoAdmin'] = '1.0.8';
                    $arrayUnshift['php'] = PHP_VERSION . ' (' . (PHP_INT_MAX > 2200000000.0 ? 64 : 32) . '-bit)';
                    $arrayUnshift['gitVersion'] = $arrayReturn['gitVersion'];
                    unset($arrayReturn['ok'], $arrayReturn['version'], $arrayReturn['gitVersion'], $arrayReturn['bits']);
                    $arrayReturn = array_merge(array('version' => $arrayUnshift), $arrayReturn);
                    $iniIndex = array(-1 => 'Unlimited', 'Off', 'On');
                    $phpIni = array('allow_persistent', 'auto_reconnect', 'chunk_size', 'cmd', 'default_host', 'default_port', 'max_connections', 'max_persistent');
                    foreach ($phpIni as $ini) {
                        $key = 'php_' . $ini;
                        $arrayReturn[$key] = ini_get('mongo.' . $ini);
                        if (isset($iniIndex[$arrayReturn[$key]])) {
                            $arrayReturn[$key] = $iniIndex[$arrayReturn[$key]];
                        }
                    }
                    if (strlen($strVar)) {
                        $arrayTagId["\$" . $strVar][ztagIdValue] = $arrayReturn;
                        $arrayTagId["\$" . $strVar][ztagIdType] = idTypeFVar;
                    }
                } else {
                    $errorMessage .= "<br />The {$strUse} NoSQL handler is not Open!";
                }
            } else {
                $errorMessage .= "<br />The {$strUse} type is not a NoSQL!";
            }
            break;
            /*+
             * Repair the current Database
             *
             * <code>
             * <znosql:repairdatabase use="mongoDB" preserveclonedfiles="true" backuporiginalfiles="true" />
             * </code>
             *
             * @param boolean preserveclonedfiles="true|false|1|0"
             * @param boolean backuporiginalfiles="true|false|1|0"
             */
        /*+
         * Repair the current Database
         *
         * <code>
         * <znosql:repairdatabase use="mongoDB" preserveclonedfiles="true" backuporiginalfiles="true" />
         * </code>
         *
         * @param boolean preserveclonedfiles="true|false|1|0"
         * @param boolean backuporiginalfiles="true|false|1|0"
         */
        case "repairdatabase":
            $strPreserveClonedFiles = $arrParam["preserveclonedfiles"];
            $strBackupOriginalFiles = $arrParam["backuporiginalfiles"];
            $errorMessage .= ztagParamCheck($arrParam, "use");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeNoSQL) {
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    $nosqlHandle = $arrayTagId[$strUse][ztagIdHandle];
                    if ($nosqlHandle[nosqlHandleDatabase]) {
                        $strDatabase = $nosqlHandle[nosqlHandleDatabaseName];
                        $dbHandleDatabase = $nosqlHandle[nosqlHandleDatabase];
                        try {
                            if ($strPreserveClonedFiles === "true" || $strPreserveClonedFiles === "1") {
                                $strPreserveClonedFiles = true;
                            }
                            if ($strBackupOriginalFiles === "true" || $strBackupOriginalFiles === "1") {
                                $strBackupOriginalFiles = true;
                            }
                            if (strlen($strPreserveClonedFiles) && !strlen($strBackupOriginalFiles)) {
                                $dbResult = $dbHandleDatabase->repair($strPreserveClonedFiles);
                            } elseif (strlen($strBackupOriginalFiles)) {
                                $dbResult = $dbHandleDatabase->repair($strPreserveClonedFiles, $strBackupOriginalFiles);
                            } else {
                                $dbResult = $dbHandleDatabase->repair();
                            }
                            if ($dbResult["ok"] != 1) {
                                $errorMessage .= "<br />Cannot repair the {$strDatabase} <pre>" . print_r($dbResult, 1) . "</pre>";
                            }
                        } catch (InvalidArgumentException $e) {
                            $errorMessage .= "<br />Invalid database name {$strDatabase} (" . $e->getMessage() . ")";
                        }
                        $arrayTagId[$strUse][ztagIdHandle] = $nosqlHandle;
                    } else {
                        $errorMessage .= "<br />The {$strUse} NoSQL handler do not have a database defined!";
                    }
                } else {
                    $errorMessage .= "<br />The {$strUse} NoSQL handler is not Open!";
                }
            } else {
                $errorMessage .= "<br />The {$strUse} type is not a NoSQL!";
            }
            break;
            /*+
             * Drop current database
             *
             * <code>
             * <znosql:dropdatabase use="mongoDB" />
             * </code>
             *
             * @param string use="mongoDB"
             */
        /*+
         * Drop current database
         *
         * <code>
         * <znosql:dropdatabase use="mongoDB" />
         * </code>
         *
         * @param string use="mongoDB"
         */
        case "dropdatabase":
            $errorMessage .= ztagParamCheck($arrParam, "use");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeNoSQL) {
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    $nosqlHandle = $arrayTagId[$strUse][ztagIdHandle];
                    if ($nosqlHandle[nosqlHandleDatabase]) {
                        $strDatabase = $nosqlHandle[nosqlHandleDatabaseName];
                        $dbHandleDatabase = $nosqlHandle[nosqlHandleDatabase];
                        try {
                            $dbResult = $dbHandleDatabase->drop();
                            if ($dbResult["ok"] == 1) {
                                $nosqlHandle[nosqlHandleDatabaseName] = null;
                                $nosqlHandle[nosqlHandleDatabase] = null;
                            } else {
                                $errorMessage .= "<br />Cannot drop the database {$strDatabase} <pre>" . print_r($dbResult, 1) . "</pre>";
                            }
                        } catch (InvalidArgumentException $e) {
                            $errorMessage .= "<br />Cannot drop the database {$strDatabase} (" . $e->getMessage() . ")";
                        }
                        $arrayTagId[$strUse][ztagIdHandle] = $nosqlHandle;
                    } else {
                        $errorMessage .= "<br />The {$strUse} NoSQL handler do not have a database defined!";
                    }
                } else {
                    $errorMessage .= "<br />The {$strUse} NoSQL handler is not Open!";
                }
            } else {
                $errorMessage .= "<br />The {$strUse} type is not a NoSQL!";
            }
            break;
            /*+
             * Set a collection for current database
             *
             * <code>
             * <znosql:setcollection use="mongoDB" name="pubPaginas" />
             * </code>
             *
             * @param string use="mongoDB"
             * @param string name="pubPaginas"
             */
        /*+
         * Set a collection for current database
         *
         * <code>
         * <znosql:setcollection use="mongoDB" name="pubPaginas" />
         * </code>
         *
         * @param string use="mongoDB"
         * @param string name="pubPaginas"
         */
        case "setcollection":
            $errorMessage .= ztagParamCheck($arrParam, "use");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeNoSQL) {
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    $nosqlHandle = $arrayTagId[$strUse][ztagIdHandle];
                    if ($nosqlHandle[nosqlHandleDatabase]) {
                        $strDatabase = $nosqlHandle[nosqlHandleDatabaseName];
                        $dbHandleDatabase = $nosqlHandle[nosqlHandleDatabase];
                        try {
                            $dbHandleCollection = $dbHandleDatabase->selectCollection($strName);
                            $nosqlHandle[nosqlHandleCollectionName] = $strName;
                            $nosqlHandle[nosqlHandleCollection] = $dbHandleCollection;
                        } catch (InvalidArgumentException $e) {
                            $errorMessage .= "<br />Invalid collection name {$strName} at database {$strDatabase} (" . $e->getMessage() . ")";
                        }
                        $arrayTagId[$strUse][ztagIdHandle] = $nosqlHandle;
                    } else {
                        $errorMessage .= "<br />The {$strUse} NoSQL handler do not have a database defined!";
                    }
                } else {
                    $errorMessage .= "<br />The {$strUse} NoSQL handler is not Open!";
                }
            } else {
                $errorMessage .= "<br />The {$strUse} type is not a NoSQL!";
            }
            break;
            /*+
             * List all databases
             *
             * <code>
             * <znosql:listcollections use="mongoDB" id="mongoDBlist" var="databasesList" total="databasesTotalSize">
             *   <br /><znosql:field use="mongoDBlist" name="name" /> - <znosql:field use="mongoDBlist" name="sizeOnDisk" /> - <znosql:field use="mongoDBlist" name="empty" />
             * </znosql:listcollections>
             * </code>
             *
             * @param string use="mongoDB" A NoSQL handle
             * @param string id="mongoDBlist" Id with array of each line
             * @param string var="databasesList" Variable with array of each line
             * @param string total="databasesTotalSize" Variable with total size
             */
        /*+
         * List all databases
         *
         * <code>
         * <znosql:listcollections use="mongoDB" id="mongoDBlist" var="databasesList" total="databasesTotalSize">
         *   <br /><znosql:field use="mongoDBlist" name="name" /> - <znosql:field use="mongoDBlist" name="sizeOnDisk" /> - <znosql:field use="mongoDBlist" name="empty" />
         * </znosql:listcollections>
         * </code>
         *
         * @param string use="mongoDB" A NoSQL handle
         * @param string id="mongoDBlist" Id with array of each line
         * @param string var="databasesList" Variable with array of each line
         * @param string total="databasesTotalSize" Variable with total size
         */
        case "listcollections":
            $strTotal = $arrParam["total"];
            $errorMessage .= ztagParamCheck($arrParam, "use,id");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeNoSQL) {
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    $nosqlHandle = $arrayTagId[$strUse][ztagIdHandle];
                    $nosqlHandle = $arrayTagId[$strUse][ztagIdHandle];
                    if ($nosqlHandle[nosqlHandleDatabase]) {
                        $strDatabase = $nosqlHandle[nosqlHandleDatabaseName];
                        $dbHandleDatabase = $nosqlHandle[nosqlHandleDatabase];
                        $arrayCollections = $dbHandleDatabase->listCollections();
                        foreach ($arrayCollections as $dbHandleCollecion) {
                            if ($strId) {
                                $arrayTagId[$strId][ztagIdValue] = array("name" => $dbHandleCollecion->getName());
                                $arrayTagId[$strId][ztagIdType] = idTypeValue;
                            }
                            if ($strVar) {
                                $arrayTagId["\$" . $strVar][ztagIdValue] = array("name" => $dbHandleCollecion->getName());
                                $arrayTagId["\$" . $strVar][ztagIdType] = idTypeFVar;
                            }
                            $strResult = ztagRun($strContent, 0, $arrayTagId);
                            $arrayTag[$tagId][ztagResult] .= $strResult;
                        }
                    } else {
                        $errorMessage .= "<br />The {$strUse} NoSQL handler do not have a database defined!";
                    }
                } else {
                    $errorMessage .= "<br />The {$strUse} NoSQL handler is not Open!";
                }
            } else {
                $errorMessage .= "<br />The {$strUse} type is not a NoSQL!";
            }
            break;
            /*+
             * Drop a collection for current database
             *
             * <code>
             * <znosql:dropcollection use="mongoDB" />
             * </code>
             *
             * @param string use="mongoDB"
             */
        /*+
         * Drop a collection for current database
         *
         * <code>
         * <znosql:dropcollection use="mongoDB" />
         * </code>
         *
         * @param string use="mongoDB"
         */
        case "dropcollection":
            $errorMessage .= ztagParamCheck($arrParam, "use");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeNoSQL) {
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    $nosqlHandle = $arrayTagId[$strUse][ztagIdHandle];
                    if ($nosqlHandle[nosqlHandleCollection]) {
                        $strDatabase = $nosqlHandle[nosqlHandleDatabaseName];
                        $strCollection = $nosqlHandle[nosqlHandleCollectionName];
                        $dbHandleCollection = $nosqlHandle[nosqlHandleCollection];
                        try {
                            $dbResult = $dbHandleCollection->drop();
                            if ($dbResult["ok"] == 1) {
                                $nosqlHandle[nosqlHandleCollectionName] = null;
                                $nosqlHandle[nosqlHandleCollection] = null;
                            } else {
                                $errorMessage .= "<br />Cannot drop the collection {$strCollection} at database {$strDatabase}  <pre>" . print_r($dbResult, 1) . "</pre>";
                            }
                        } catch (InvalidArgumentException $e) {
                            $errorMessage .= "<br />Cannot drop the collection {$strCollection} at database {$strDatabase} (" . $e->getMessage() . ")";
                        }
                        $arrayTagId[$strUse][ztagIdHandle] = $nosqlHandle;
                    } else {
                        $errorMessage .= "<br />The {$strUse} NoSQL handler do not have a database defined!";
                    }
                } else {
                    $errorMessage .= "<br />The {$strUse} NoSQL handler is not Open!";
                }
            } else {
                $errorMessage .= "<br />The {$strUse} type is not a NoSQL!";
            }
            break;
            /*+
             * Create a collection for current database
             *
             * </code>
             * <znosql:createcollection use="mongoDB" name="pubPaginas" />
             * </code>
             *
             * @param string use="mongoDB"
             * @param string name="pubPaginas" The name of the collection.
             * @param boolean capped="true|false|1|0" If the collection should be a fixed size.
             * @param int  size="10000000" If the collection is fixed size, its size in bytes.
             * @param int max="1000" If the collection is fixed size, the maximum number of elements to store in the collection.
             */
        /*+
         * Create a collection for current database
         *
         * </code>
         * <znosql:createcollection use="mongoDB" name="pubPaginas" />
         * </code>
         *
         * @param string use="mongoDB"
         * @param string name="pubPaginas" The name of the collection.
         * @param boolean capped="true|false|1|0" If the collection should be a fixed size.
         * @param int  size="10000000" If the collection is fixed size, its size in bytes.
         * @param int max="1000" If the collection is fixed size, the maximum number of elements to store in the collection.
         */
        case "createcollection":
            $errorMessage .= ztagParamCheck($arrParam, "use,name");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeNoSQL) {
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    $nosqlHandle = $arrayTagId[$strUse][ztagIdHandle];
                    if ($nosqlHandle[nosqlHandleDatabase]) {
                        $strDatabase = $nosqlHandle[nosqlHandleDatabaseName];
                        $dbHandleDatabase = $nosqlHandle[nosqlHandleDatabase];
                        try {
                            $dbHandleCollection = $dbHandleDatabase->createCollection($strName);
                            $nosqlHandle[nosqlHandleCollectionName] = $strName;
                            $nosqlHandle[nosqlHandleCollection] = $dbHandleCollection;
                        } catch (InvalidArgumentException $e) {
                            $errorMessage .= "<br />Cannot create the collection {$strName} at database {$strDatabase} (" . $e->getMessage() . ")";
                        }
                        $arrayTagId[$strUse][ztagIdHandle] = $nosqlHandle;
                    } else {
                        $errorMessage .= "<br />The {$strUse} NoSQL handler do not have a database defined!";
                    }
                } else {
                    $errorMessage .= "<br />The {$strUse} NoSQL handler is not Open!";
                }
            } else {
                $errorMessage .= "<br />The {$strUse} type is not a NoSQL!";
            }
            break;
            /*+
             * Create a collection for current database
             *
             * <code>
             * <znosql:createcollection use="mongoDB" from="pubPaginas" to="pubPaginasOld"/>
             * </code>
             *
             * @param string use="mongoDB"
             * @param string from="pubPaginas"
             * @param string to="pubPaginasOld"
             */
        /*+
         * Create a collection for current database
         *
         * <code>
         * <znosql:createcollection use="mongoDB" from="pubPaginas" to="pubPaginasOld"/>
         * </code>
         *
         * @param string use="mongoDB"
         * @param string from="pubPaginas"
         * @param string to="pubPaginasOld"
         */
        case "renamecollection":
            $strFrom = $arrParam["from"];
            $strTo = $arrParam["to"];
            $errorMessage .= ztagParamCheck($arrParam, "use,name");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeNoSQL) {
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    $nosqlHandle = $arrayTagId[$strUse][ztagIdHandle];
                    $dbHandle = $nosqlHandle[nosqlHandleId];
                    if ($nosqlHandle[nosqlHandleDatabase]) {
                        $strDatabase = $nosqlHandle[nosqlHandleDatabaseName];
                        $dbResult = $dbHandle->selectDB('admin')->command(array('renameCollection' => "{$strDatabase}.{$strFrom}", 'to' => "{$strDatabase}.{$strTo}"));
                        echo "<pre>" . print_r($dbResult, 1) . "</pre>";
                    } else {
                        $errorMessage .= "<br />The {$strUse} NoSQL handler do not have a database defined!";
                    }
                } else {
                    $errorMessage .= "<br />The {$strUse} NoSQL handler is not Open!";
                }
            } else {
                $errorMessage .= "<br />The {$strUse} type is not a NoSQL!";
            }
            break;
            /*+
             * List all indexes for a Collection
             *
             * <code>
             * <znosql:listindexes use="mongoDB" collection="pubPaginas" />
             * </code>
             *
             * @param string use="mongoDB"
             * @param string collection="pubPaginas"
             */
        /*+
         * List all indexes for a Collection
         *
         * <code>
         * <znosql:listindexes use="mongoDB" collection="pubPaginas" />
         * </code>
         *
         * @param string use="mongoDB"
         * @param string collection="pubPaginas"
         */
        case "listindexes":
            return $this->mongo->selectCollection($collection)->getIndexInfo();
            break;
            /*+
             * Ensure a index of current collection
             *
             * <code>
             * <znosql:ensureindex use="mongoDB" />
             * </code>
             *
             * @param string use="mongoDB"
             */
        /*+
         * Ensure a index of current collection
         *
         * <code>
         * <znosql:ensureindex use="mongoDB" />
         * </code>
         *
         * @param string use="mongoDB"
         */
        case "ensureindex":
            $errorMessage .= ztagParamCheck($arrParam, "use");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeNoSQL) {
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    $nosqlHandle = $arrayTagId[$strUse][ztagIdHandle];
                    if ($nosqlHandle[nosqlHandleCollection]) {
                        $strDatabase = $nosqlHandle[nosqlHandleDatabaseName];
                        $strCollection = $nosqlHandle[nosqlHandleCollectionName];
                        $dbHandleCollection = $nosqlHandle[nosqlHandleCollection];
                        try {
                            $dbResult = $dbHandleCollection->ensureIndex();
                            $unique = $unique ? true : false;
                            //signature requires a bool in both Mongo v. 1.0.1 and 1.2.0
                            // mongo->selectCollection($collection)->ensureIndex($indexes, $unique);
                            if ($dbResult["ok"] == 1) {
                                $nosqlHandle[nosqlHandleCollectionName] = null;
                                $nosqlHandle[nosqlHandleCollection] = null;
                            } else {
                                $errorMessage .= "<br />Cannot drop the collection {$strCollection} at database {$strDatabase}  <pre>" . print_r($dbResult, 1) . "</pre>";
                            }
                        } catch (InvalidArgumentException $e) {
                            $errorMessage .= "<br />Cannot drop the collection {$strCollection} at database {$strDatabase} (" . $e->getMessage() . ")";
                        }
                        $arrayTagId[$strUse][ztagIdHandle] = $nosqlHandle;
                    } else {
                        $errorMessage .= "<br />The {$strUse} NoSQL handler do not have a database defined!";
                    }
                } else {
                    $errorMessage .= "<br />The {$strUse} NoSQL handler is not Open!";
                }
            } else {
                $errorMessage .= "<br />The {$strUse} type is not a NoSQL!";
            }
            break;
            /*+
             * Delete a index for a Collection
             *
             * <code>
             * <znosql:deleteindex use="mongoDB" collection="pubPaginas" index="pagNome"/>
             * </code>
             *
             * @param string use="mongoDB"
             * @param string collection="pubPaginas"
             * @param string index="pagNome"
             *
             */
        /*+
         * Delete a index for a Collection
         *
         * <code>
         * <znosql:deleteindex use="mongoDB" collection="pubPaginas" index="pagNome"/>
         * </code>
         *
         * @param string use="mongoDB"
         * @param string collection="pubPaginas"
         * @param string index="pagNome"
         *
         */
        case "deleteindex":
            // mongo->selectCollection($collection)->deleteIndex($index);
            break;
            /*+
             * Return the content of name field of current record
             *
             * </code>
             * <zdb:field use="mongoDBlist" name="name" />
             * </code>
             *
             * @param string use="mongoDBlist" - The Id Handle from current array
             * @param string name="name"
             */
        /*+
         * Return the content of name field of current record
         *
         * </code>
         * <zdb:field use="mongoDBlist" name="name" />
         * </code>
         *
         * @param string use="mongoDBlist" - The Id Handle from current array
         * @param string name="name"
         */
        case "field":
            $strVar = $arrParam["var"];
            $errorMessage .= ztagParamCheck($arrParam, "use,name");
            $fieldArray = $arrayTagId[$strUse][ztagIdValue];
            $fieldValue = $fieldArray[$strName];
            if (strlen($strTransform)) {
                $fieldValue = ztagTransform($fieldValue, $strTransform);
            }
            if (strlen($strVar)) {
                $arrayTagId["\$" . $strVar][ztagIdValue] = $fieldValue;
                $arrayTagId["\$" . $strVar][ztagIdType] = idTypeField;
            }
            $arrayTag[$tagId][ztagResult] = $fieldValue;
            break;
        default:
            $errorMessage .= "<br />Undefined function \"{$tagFunction}\"";
    }
    ztagError($errorMessage, $arrayTag, $tagId);
}
Example #6
0
/**
 * Main function to encapsulates all variables
 *
 * <code>
 * main();
 * </code>
 *
 * @global array $arrayTagSys[] Information for Tag behavior during compile, execute and mount processes
 *
 * @since 1.0
 */
function main()
{
    global $arrayTagSys;
    debugContent("o=" & parOption);
    $strFile = "/ztag/sample/helloworld.ztag";
    if (templateFile) {
        $strFile = templateFile;
    }
    /*
    echo "<pre>";
    echo $_SERVER["HTTP_USER_AGENT"];
    echo "<br />";
    $browser = get_browser(null, 1);
    print_r($browser);
    echo "</pre>";
    */
    // debugError($strFile);
    switch (parOption) {
        case 10:
            // Generates zTagManual
            // Get all phpDoc params
            // /\*{2}.*?\*/.*?(function\s+(?P<function>\w+)\s*\((?P<param>.*?)\)|define\s*\(\s*["'](?P<constant>\w+)["']\s*,\s*(?P<contantvalue>.*?)\)|\$(?P<global>\w+)\s*=\s*(?P<globalvalue>.*?)\s*);
            break;
        default:
            // @TODO incluide system information as template load data etc
            $timeTemplate = microtime();
            $templateContent = ztagTemplateLoad($strFile);
            $strResult = ztagRun($templateContent, $timeTemplate);
            if ($_GET["stats"]) {
                echo "<hr />Compiladas=" . $arrayTagSys[ztagSysCompileTags] . "<br />Executadas=" . $arrayTagSys[ztagSysExecuteTags] . "<br />Montadas=" . $arrayTagSys[ztagSysMountTags] . "<hr />Template=" . $arrayTagSys[ztagSysTemplateTime] . "<br />Compilação=" . $arrayTagSys[ztagSysCompileTime] . "<br />Execução=" . $arrayTagSys[ztagSysExecuteTime] . "<br />Montagem=" . $arrayTagSys[ztagSysMountTime] . "<br />Total=" . $arrayTagSys[ztagSysAllTime];
            }
    }
    echo $strResult;
}
Example #7
0
/**
 * Main zTag functions selector
 *
 * <code>
 * zctrl_execute($tagId, $tagFunction, $arrayTag, $arrayTagId, $arrayOrder);
 * </code>
 *
 * @param integer $tagId array id of current zTag of $arrayTag array
 * @param string $tagFunction name of zTag function
 * @param array $arrayTag array with all compiled zTags
 * @param array $arrayTagId array with all Ids values
 * @param array $arrayOrder array with zTag executing order
 *
 * @since 1.0
 */
function zctrl_zexecute($tagId, $tagFunction, &$arrayTag, &$arrayTagId, $arrayOrder)
{
    global $ztagExit;
    $arrParam = $arrayTag[$tagId][ztagParam];
    $strId = $arrParam["id"];
    $strUse = $arrParam["use"];
    $strValue = $arrParam["value"];
    $strKey = $arrParam["key"];
    $strTransform = $arrParam["transform"];
    $strMessage = $arrParam["message"];
    if ($arrayTag[$tagId][ztagContentWidth]) {
        $strContent = $arrayTag[$tagId][ztagContent];
    }
    $errorMessage = "";
    switch (strtolower($tagFunction)) {
        /*+
         * Iterate over arrays executing it's content many time as it's content.
         *
         * <code>
         * <zctrl:foreach use="getAll" value="value">
         *   <zhtml:b value="$key" />: <zvar:show use="$value" /><br />
         * </zctrl:foreach>
         *
         * <zctrl:foreach use="getAll" key="key" value="value">
         *   <zhtml:b value="$key" />: <zvar:show use="$value" /><br />
         * </zctrl:foreach>
         * </code>
         *
         * @param string use="getAll" Variable array
         * @param string key="key" Variable where the array Key with saved
         * @param string value="value" Variable where the array Value with saved
         * @param string filename="/Alianca8/File.txt"
         * @param string filetype="txt"
         * @param string show="0"
         */
        case "foreach":
            $strFileName = $arrParam["filename"];
            $strFileType = $arrParam["filetype"];
            $strShow = strtolower($arrParam["show"]);
            $errorMessage .= ztagParamCheck($arrParam, "use,value");
            if ($arrayTagId["\$" . $strUse][ztagIdType] != idTypeFVar) {
                $errorMessage .= "<br />The handle \"{$strUse}\" is not a var one!";
            }
            // $strArray = $arrayTagId["$".$strUse][ztagIdValue];
            preg_match_all('%^(?P<var>\\w+)\\[(?P<index>[^\\]]+)\\]$%', $strUse, $Matches, PREG_OFFSET_CAPTURE);
            if (count($Matches[0][0])) {
                $var = $Matches["var"][0][0];
                $index = $Matches["index"][0][0];
                $strArray = $arrayTagId["\$" . $var][ztagIdValue];
                $strArray = $strArray[$index];
            } else {
                if ($arrayTagId["\$" . $strUse][ztagIdType] != idTypeFVar) {
                    $errorMessage .= "<br />The handle \"{$strUse}\" is not a var one!";
                }
                $strArray = $arrayTagId["\$" . $strUse][ztagIdValue];
            }
            if (is_array($strArray)) {
                if (strlen($strValue) && !strlen($strKey)) {
                    foreach ($strArray as $value) {
                        $arrayTagId["\$" . $strValue][ztagIdValue] = $value;
                        $arrayTagId["\$" . $strValue][ztagIdType] = idTypeFVar;
                        $arrayTag[$tagId][ztagResult] .= ztagRun($strContent, 0, $arrayTagId);
                        if ($ztagExit) {
                            break;
                        }
                    }
                } else {
                    foreach ($strArray as $key => $value) {
                        $arrayTagId["\$" . $strKey][ztagIdValue] = $key;
                        $arrayTagId["\$" . $strKey][ztagIdType] = idTypeFVar;
                        $arrayTagId["\$" . $strValue][ztagIdValue] = $value;
                        $arrayTagId["\$" . $strValue][ztagIdType] = idTypeFVar;
                        $arrayTag[$tagId][ztagResult] .= ztagRun($strContent, 0, $arrayTagId);
                        if ($ztagExit) {
                            break;
                        }
                    }
                }
                if ($strFileName) {
                    $strFileName = str_replace("\\", "/", $strFileName);
                    if (substr($strFileName, 0, 1) === "/") {
                        $strFileName = substr($strFileName, 1);
                    }
                    $strFileName = SiteRootDir . $strFileName;
                    if (!($handleFile = fopen($strFileName, "w"))) {
                        $errorMessage .= "\r\nCannot open file ({$strFileName})";
                    } else {
                        if (fwrite($handleFile, $arrayTag[$tagId][ztagResult]) === FALSE) {
                            $errorMessage .= "\r\nCannot write to file ({$strFileName})";
                        }
                    }
                    fclose($handleFile);
                }
                if ($strShow === "false" || $strShow === "0") {
                    $arrayTag[$tagId][ztagResult] = "";
                }
            }
            break;
            /*+
             * Define a conditional execution of code fragments.
             *
             * <code>
             * <zctrl:if value="$urlAssunto0" operator="e|ne|gt|gte|lt|lte" with="0" var="ifVar" >
             * </zctrl:if>
             *
             * <zctrl:if value="$urlAssunto0" function="empty()|true()|false()|len()">
             * </zctrl:if>
             *
             * <zctrl:if value="$urlAssunto0" transform="substr(1, 3)" operator="=|<>|>|>=|<|=" with="test">
             * </zctrl:if>
             * </code>
             *
             * @param string value="value" Variable or value to be used.
             * @param string operator="e|ne|gt|gte|lt|lte" operator to be used
             * @param string with="0" second part of an boolean expression
             * @param string transform="substr(1, 3)" Tranform the value's content
             * @param string function="empty()|true()|false()|len()" Apply a function to value's content and check if result is true
             * @param string var="ifVar" Variable to save all if result
             * @param string show="1|0|true|false" False to not show the If result content
             */
        /*+
         * Define a conditional execution of code fragments.
         *
         * <code>
         * <zctrl:if value="$urlAssunto0" operator="e|ne|gt|gte|lt|lte" with="0" var="ifVar" >
         * </zctrl:if>
         *
         * <zctrl:if value="$urlAssunto0" function="empty()|true()|false()|len()">
         * </zctrl:if>
         *
         * <zctrl:if value="$urlAssunto0" transform="substr(1, 3)" operator="=|<>|>|>=|<|=" with="test">
         * </zctrl:if>
         * </code>
         *
         * @param string value="value" Variable or value to be used.
         * @param string operator="e|ne|gt|gte|lt|lte" operator to be used
         * @param string with="0" second part of an boolean expression
         * @param string transform="substr(1, 3)" Tranform the value's content
         * @param string function="empty()|true()|false()|len()" Apply a function to value's content and check if result is true
         * @param string var="ifVar" Variable to save all if result
         * @param string show="1|0|true|false" False to not show the If result content
         */
        case "if":
            $strOperator = $arrParam["operator"];
            $strWith = $arrParam["with"];
            $strFunction = $arrParam["function"];
            $strVar = $arrParam["var"];
            $strShow = $arrParam["show"];
            if (strlen($strOperator)) {
                $errorMessage .= ztagParamCheck($arrParam, "value,operator,with");
                if (strlen($strTransform)) {
                    $strValue = ztagTransform($strValue, $strTransform);
                }
                switch (strtolower($strOperator)) {
                    case "e":
                        $strOperator = "==";
                        break;
                    case "ne":
                        $strOperator = "<>";
                        break;
                    case "gt":
                        $strOperator = ">";
                        break;
                    case "gte|lt|lte":
                        $strOperator = ">=";
                        break;
                    case "lt|lte":
                        $strOperator = "<";
                        break;
                    case "lte":
                        $strOperator = "<=";
                        break;
                    default:
                        $errorMessage .= "<br />Operator \"{$strOperator}\" does not exist!";
                }
                $strEVal = "if(\$strValue {$strOperator} \$strWith) {return 1;} else {return 0;}";
                $strValue = eval($strEVal);
            } else {
                if (strlen($strFunction)) {
                    $errorMessage .= ztagParamCheck($arrParam, "value,function");
                    if (strlen($strTransform)) {
                        $strValue = ztagTransform($strValue, $strTransform);
                    }
                    if (strlen($strFunction)) {
                        $strValue = ztagTransform($strValue, $strFunction);
                    }
                } else {
                    $errorMessage .= ztagParamCheck($arrParam, "value,function");
                }
            }
            if ($strValue) {
                $getValue .= ztagRun($strContent, 0, $arrayTagId);
                if (($strShow != "false" || $strShow != "0") && strlen($getValue)) {
                    $arrayTag[$tagId][ztagResult] = $getValue;
                }
                if (strlen($strVar) && strlen($getValue)) {
                    $arrayTagId["\$" . $strVar][ztagIdValue] = $getValue;
                    $arrayTagId["\$" . $strVar][ztagIdLength] = strlen($getValue);
                    $arrayTagId["\$" . $strVar][ztagIdType] = idTypeFVar;
                }
            }
            break;
            /*+
             * Output a message and terminate the current script.
             *
             * <code>
             * <zctrl:die message="The script die here!" />
             *
             * <zctrl:die>
             *   The script die here!
             * </zctrl:die>
             * </code>
             *
             * @param string message="value" Variable or value to be printed
             */
        /*+
         * Output a message and terminate the current script.
         *
         * <code>
         * <zctrl:die message="The script die here!" />
         *
         * <zctrl:die>
         *   The script die here!
         * </zctrl:die>
         * </code>
         *
         * @param string message="value" Variable or value to be printed
         */
        case "die":
            /*+
             * Output a message and terminate the current script.
             *
             * <code>
             * <zctrl:exit message="The script exited here!" />
             *
             * <zctrl:exit>
             *   The script exit here!
             * </zctrl:exit>
             * </code>
             *
             * @param string message="value" Variable or value to be printed
             */
        /*+
         * Output a message and terminate the current script.
         *
         * <code>
         * <zctrl:exit message="The script exited here!" />
         *
         * <zctrl:exit>
         *   The script exit here!
         * </zctrl:exit>
         * </code>
         *
         * @param string message="value" Variable or value to be printed
         */
        case "exit":
            $ztagExit = 1;
            if (strlen($strContent)) {
                $strMessage = ztagVars($strContent, $arrayTagId);
            }
            if (strlen($strMessage)) {
                $arrayTag[$tagId][ztagResult] = $strMessage;
            }
            break;
            /*+
             * Output a string
             *
             * <code>
             * <zctrl:echo message="This an echo message" />
             *
             * <zctrl:echo>
             * This an echo message
             * </zctrl:echo>
             * </code>
             *
             * @param string message="value" Variable or value to be used
             */
        /*+
         * Output a string
         *
         * <code>
         * <zctrl:echo message="This an echo message" />
         *
         * <zctrl:echo>
         * This an echo message
         * </zctrl:echo>
         * </code>
         *
         * @param string message="value" Variable or value to be used
         */
        case "echo":
            /*+
             * Output a string
             *
             * <code>
             * <zctrl:print message="This a print message" />
             *
             * <zctrl:print>
             * This a print message
             * </zctrl:print>
             * </code>
             *
             * @param string message="value" Variable or value to be used
             */
        /*+
         * Output a string
         *
         * <code>
         * <zctrl:print message="This a print message" />
         *
         * <zctrl:print>
         * This a print message
         * </zctrl:print>
         * </code>
         *
         * @param string message="value" Variable or value to be used
         */
        case "print":
            if (strlen($strContent)) {
                $strMessage = ztagVars($strContent, $arrayTagId);
                $arrParam["message"] = $strMessage;
            }
            $errorMessage .= ztagParamCheck($arrParam, "message");
            if (strlen($strTransform) && strlen($strMessage)) {
                $strMessage = ztagTransform($strMessage, $strTransform);
            }
            if (strlen($strMessage)) {
                ztagError($strMessage, $arrayTag, $tagId);
            }
            break;
            /*+
             * Dumps information about a variable
             *
             * <code>
             * <zctrl:dump message="<b>arrayDump</b>=" use="arrayDump" />
             * </code>
             *
             * @param string use="arrayDump" Variable to be dumped
             * @param string message="Message" Message to complement the Dump
             */
        /*+
         * Dumps information about a variable
         *
         * <code>
         * <zctrl:dump message="<b>arrayDump</b>=" use="arrayDump" />
         * </code>
         *
         * @param string use="arrayDump" Variable to be dumped
         * @param string message="Message" Message to complement the Dump
         */
        case "dump":
            $errorMessage .= ztagParamCheck($arrParam, "use");
            // echo "<hr><pre>".print_r($strUse,1)."</pre>";
            // echo "<hr><pre>".print_r($arrayTagId["$".$strUse][ztagIdValue],1)."</pre>";
            ztagError($strMessage . var_dump($arrayTagId["\$" . $strUse][ztagIdValue]), $arrayTag, $tagId);
            break;
            /*+
             * Prints human-readable information about a variable
             *
             * <code>
             * <zctrl:printr message="<b>arrayDump</b>=" use="arrayDump" />
             * </code>
             *
             * @param string use="arrayDump" Variable to be printed
             * @param string message="Message" Message to complement the Dump
             */
        /*+
         * Prints human-readable information about a variable
         *
         * <code>
         * <zctrl:printr message="<b>arrayDump</b>=" use="arrayDump" />
         * </code>
         *
         * @param string use="arrayDump" Variable to be printed
         * @param string message="Message" Message to complement the Dump
         */
        case "printr":
            ztagError(print_r($arrayTagId, 1), $arrayTag, $tagId);
            $errorMessage .= ztagParamCheck($arrParam, "use");
            ztagError($strMessage . print_r($arrayTagId["\$" . $strUse][ztagIdValue], 1), $arrayTag, $tagId);
            break;
            /*+
             * Iterate over arrays executing it's content many time as it's content.
             *
             * <code>
             * <zctrl:while value="$urlAssunto0" operator="e|ne|gt|gte|lt|lte" with="0" var="ifVar" >
             * </zctrl:while>
             *
             * <zctrl:while value="$urlAssunto0" function="empty()|true()|false()|len()">
             * </zctrl:while>
             *
             * <zctrl:while value="$urlAssunto0" transform="substr(1, 3)" operator="=|<>|>|>=|<|=" with="test">
             * </code>
             *
             * @param string use="getAll" Variable array
             * @param string key="key" Variable where the array Key with saved
             * @param string value="value" Variable where the array Value with saved
             */
        /*+
         * Iterate over arrays executing it's content many time as it's content.
         *
         * <code>
         * <zctrl:while value="$urlAssunto0" operator="e|ne|gt|gte|lt|lte" with="0" var="ifVar" >
         * </zctrl:while>
         *
         * <zctrl:while value="$urlAssunto0" function="empty()|true()|false()|len()">
         * </zctrl:while>
         *
         * <zctrl:while value="$urlAssunto0" transform="substr(1, 3)" operator="=|<>|>|>=|<|=" with="test">
         * </code>
         *
         * @param string use="getAll" Variable array
         * @param string key="key" Variable where the array Key with saved
         * @param string value="value" Variable where the array Value with saved
         */
        case "while":
            $errorMessage .= ztagParamCheck($arrParam, "use,value");
            if ($arrayTagId["\$" . $strUse][ztagIdType] != idTypeFVar) {
                $errorMessage .= "<br />The handle \"{$strUse}\" is not a var one!";
            }
            $strArray = $arrayTagId["\$" . $strUse][ztagIdValue];
            if (is_array($strArray)) {
                if (strlen($strValue) && !strlen($strKey)) {
                    foreach ($strArray as $value) {
                        $arrayTagId["\$" . $strValue][ztagIdValue] = $value;
                        $arrayTagId["\$" . $strValue][ztagIdType] = idTypeFVar;
                        $arrayTag[$tagId][ztagResult] .= ztagRun($strContent, 0, $arrayTagId);
                        if ($ztagExit) {
                            break;
                        }
                    }
                } else {
                    foreach ($strArray as $key => $value) {
                        $arrayTagId["\$" . $strKey][ztagIdValue] = $key;
                        $arrayTagId["\$" . $strKey][ztagIdType] = idTypeFVar;
                        $arrayTagId["\$" . $strValue][ztagIdValue] = $value;
                        $arrayTagId["\$" . $strValue][ztagIdType] = idTypeFVar;
                        $arrayTag[$tagId][ztagResult] .= ztagRun($strContent, 0, $arrayTagId);
                        if ($ztagExit) {
                            break;
                        }
                    }
                }
            }
            break;
        default:
            $errorMessage .= "<br />Undefined function \"{$tagFunction}\"";
    }
    ztagError($errorMessage, $arrayTag, $tagId);
}