• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP ls_json_encode函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中ls_json_encode函数的典型用法代码示例。如果您正苦于以下问题:PHP ls_json_encode函数的具体用法?PHP ls_json_encode怎么用?PHP ls_json_encode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ls_json_encode函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: sanitize_int

    if (isset($_REQUEST['survey_id'])) {
        $intSurveyId = sanitize_int($_REQUEST['survey_id']);
    }
    $owner_id = $_SESSION['loginID'];
    header('Content-type: application/json');
    $query = "UPDATE " . db_table_name('surveys') . " SET owner_id = {$intNewOwner} WHERE sid={$intSurveyId}";
    if (bHasGlobalPermission("USER_RIGHT_SUPERADMIN")) {
        $query .= ";";
    } else {
        $query .= " AND owner_id={$owner_id};";
    }
    $result = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
    $query = "SELECT b.users_name FROM " . db_table_name('surveys') . " as a" . " INNER JOIN  " . db_table_name('users') . " as b ON a.owner_id = b.uid   WHERE sid={$intSurveyId} AND owner_id={$intNewOwner};";
    $result = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
    $intRecordCount = $result->RecordCount();
    $aUsers = array('record_count' => $intRecordCount);
    if ($result->RecordCount() > 0) {
        while ($rows = $result->FetchRow()) {
            $aUsers['newowner'] = $rows['users_name'];
        }
    }
    $ajaxoutput = ls_json_encode($aUsers) . "\n";
} elseif ($action == "ajaxgetusers") {
    header('Content-type: application/json');
    $aSeenUsers = getuserlist();
    $aUsers = array();
    foreach ($aSeenUsers as $userline) {
        $aUsers[] = array($userline['uid'], $userline['user']);
    }
    $ajaxoutput = ls_json_encode($aUsers) . "\n";
}
开发者ID:ddrmoscow,项目名称:queXS,代码行数:31,代码来源:surveylist.php


示例2: getTokens_json


//.........这里部分代码省略.........
     $aData->records = Token::model($iSurveyId)->count($condition);
     if ($limit > $aData->records) {
         $limit = $aData->records;
     }
     if ($limit != 0) {
         $aData->total = ceil($aData->records / $limit);
     } else {
         $aData->total = 0;
     }
     Yii::app()->loadHelper("surveytranslator");
     $format = getDateFormatData(Yii::app()->session['dateformat']);
     $aSurveyInfo = Survey::model()->findByPk($iSurveyId)->getAttributes();
     //Get survey settings
     $attributes = getAttributeFieldNames($iSurveyId);
     // Now find all responses for the visible tokens
     $visibleTokens = array();
     $answeredTokens = array();
     if ($aSurveyInfo['anonymized'] == "N" && $aSurveyInfo['active'] == "Y") {
         foreach ($tokens as $token) {
             if (isset($token['token']) && $token['token']) {
                 $visibleTokens[] = $token['token'];
             }
         }
         $answers = SurveyDynamic::model($iSurveyId)->findAllByAttributes(array('token' => $visibleTokens));
         foreach ($answers as $answer) {
             $answeredTokens[$answer['token']] = $answer['token'];
         }
     }
     $bReadPermission = Permission::model()->hasSurveyPermission($iSurveyId, 'responses', 'read');
     $bCreatePermission = Permission::model()->hasSurveyPermission($iSurveyId, 'responses', 'create');
     $bTokenUpdatePermission = Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'update');
     $bTokenDeletePermission = Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'delete');
     $bGlobalPanelReadPermission = Permission::model()->hasGlobalPermission('participantpanel', 'read');
     foreach ($tokens as $token) {
         $aRowToAdd = array();
         if ((int) $token['validfrom']) {
             $token['validfrom'] = date($format['phpdate'] . ' H:i', strtotime(trim($token['validfrom'])));
         } else {
             $token['validfrom'] = '';
         }
         if ((int) $token['validuntil']) {
             $token['validuntil'] = date($format['phpdate'] . ' H:i', strtotime(trim($token['validuntil'])));
         } else {
             $token['validuntil'] = '';
         }
         $aRowToAdd['id'] = $token['tid'];
         $action = "";
         $action .= "<div class='inputbuttons'>";
         // so we can hide this when edit is clicked
         // Check is we have an answer
         if (in_array($token['token'], $answeredTokens) && $bReadPermission) {
             // @@TODO change link
             $url = $this->getController()->createUrl("admin/responses/sa/browse/surveyid/{$iSurveyId}", array('token' => $token['token']));
             $title = $clang->gT("View response details");
             $action .= CHtml::link(CHtml::image(Yii::app()->getConfig('adminimageurl') . 'token_viewanswer.png', $title, array('title' => $title)), $url, array('class' => 'imagelink'));
         } else {
             $action .= '<div style="width: 20px; height: 16px; float: left;"></div>';
         }
         // Check if the token can be taken
         if ($token['token'] != "" && ($token['completed'] == "N" || $token['completed'] == "" || $aSurveyInfo['alloweditaftercompletion'] == "Y") && $bCreatePermission) {
             $action .= viewHelper::getImageLink('do_16.png', "survey/index/sid/{$iSurveyId}/token/{$token['token']}/lang/{$token['language']}/newtest/Y", $clang->gT("Do survey"), '_blank');
         } else {
             $action .= '<div style="width: 20px; height: 16px; float: left;"></div>';
         }
         if ($bTokenDeletePermission) {
             $attribs = array('onclick' => 'if (confirm("' . $clang->gT("Are you sure you want to delete this entry?") . ' (' . $token['tid'] . ')")) {$("#displaytokens").delRowData(' . $token['tid'] . ');$.post(delUrl,{tid:' . $token['tid'] . '});}');
             $action .= viewHelper::getImageLink('token_delete.png', null, $clang->gT("Delete token entry"), null, 'imagelink btnDelete', $attribs);
         }
         if (strtolower($token['emailstatus']) == 'ok' && $token['email'] && $bTokenUpdatePermission) {
             if ($token['completed'] == 'N' && $token['usesleft'] > 0) {
                 if ($token['sent'] == 'N') {
                     $action .= viewHelper::getImageLink('token_invite.png', "admin/tokens/sa/email/surveyid/{$iSurveyId}/tokenids/" . $token['tid'], $clang->gT("Send invitation email to this person (if they have not yet been sent an invitation email)"), "_blank");
                 } else {
                     $action .= viewHelper::getImageLink('token_remind.png', "admin/tokens/sa/email/action/remind/surveyid/{$iSurveyId}/tokenids/" . $token['tid'], $clang->gT("Send reminder email to this person (if they have already received the invitation email)"), "_blank");
                 }
             } else {
                 $action .= '<div style="width: 20px; height: 16px; float: left;"></div>';
             }
         } else {
             $action .= '<div style="width: 20px; height: 16px; float: left;"></div>';
         }
         if ($bTokenUpdatePermission) {
             $action .= viewHelper::getImageLink('edit_16.png', null, $clang->gT("Edit token entry"), null, 'imagelink token_edit');
         }
         if (!empty($token['participant_id']) && $token['participant_id'] != "" && $bGlobalPanelReadPermission) {
             $action .= viewHelper::getImageLink('cpdb_16.png', null, $clang->gT("View this person in the central participants database"), null, 'imagelink cpdb', array('onclick' => "sendPost('" . $this->getController()->createUrl('admin/participants/sa/displayParticipants') . "','',['searchcondition'],['participant_id||equal||{$token['participant_id']}']);"));
         } else {
             $action .= '<div style="width: 20px; height: 16px; float: left;"></div>';
         }
         $action .= '</div>';
         $aRowToAdd['cell'] = array($token['tid'], $action, $token['firstname'], $token['lastname'], $token['email'], $token['emailstatus'], $token['token'], $token['language'], $token['sent'], $token['remindersent'], $token['remindercount'], $token['completed'], $token['usesleft'], $token['validfrom'], $token['validuntil']);
         foreach ($attributes as $attribute) {
             $aRowToAdd['cell'][] = $token[$attribute];
         }
         $aData->rows[] = $aRowToAdd;
     }
     viewHelper::disableHtmlLogging();
     header("Content-type: application/json");
     echo ls_json_encode($aData);
 }
开发者ID:josetorerobueno,项目名称:test_repo,代码行数:101,代码来源:tokens.php


示例3: htmlspecialchars

    } else {
        //$questionselecter = substr($question, 0, 35)."..";
        $questionselecter = htmlspecialchars(mb_strcut(html_entity_decode($question, ENT_QUOTES, 'UTF-8'), 0, 35, 'UTF-8')) . "...";
    }
    $quesitonNavOptions .= "<option value='{$scriptname}?sid={$surveyid}&amp;gid={$row['gid']}&amp;qid={$row['qid']}&amp;action=conditions&amp;subaction=editconditionsform'>{$row['title']}: " . $questionselecter . "</option>";
}
$quesitonNavOptions .= "</optgroup>\n";
$conditionsoutput_menubar .= "\t</div><div class='menubar-right'>\n" . "<img width=\"11\" alt=\"\" src=\"{$imageurl}/blank.gif\"/>\n" . "<font class=\"boxcaption\">" . $clang->gT("Questions") . ":</font>\n" . "<select id='questionNav' onchange=\"window.open(this.options[this.selectedIndex].value,'_self')\">{$quesitonNavOptions}</select>\n" . "<img hspace=\"0\" border=\"0\" alt=\"\" src=\"{$imageurl}/seperator.gif\"/>\n" . "<a href=\"http://docs.limesurvey.org\" target='_blank' title=\"" . $clang->gTview("LimeSurvey online manual") . "\">" . "<img src='{$imageurl}/showhelp.png' name='ShowHelp' title=''" . "alt='" . $clang->gT("LimeSurvey online manual") . "' /></a>";
$conditionsoutput_menubar .= "\t</div></div></div>\n" . "<p style='margin: 0pt; font-size: 1px; line-height: 1px; height: 1px;'> </p>" . "</td></tr>\n";
//Now display the information and forms
//BEGIN: PREPARE JAVASCRIPT TO SHOW MATCHING ANSWERS TO SELECTED QUESTION
$conditionsoutput_main_content .= "<script type='text/javascript'>\n" . "<!--\n" . "\tvar Fieldnames = new Array();\n" . "\tvar Codes = new Array();\n" . "\tvar Answers = new Array();\n" . "\tvar QFieldnames = new Array();\n" . "\tvar Qcqids = new Array();\n" . "\tvar Qtypes = new Array();\n";
$jn = 0;
if (isset($canswers)) {
    foreach ($canswers as $can) {
        $an = ls_json_encode(FlattenText($can[2]));
        $conditionsoutput_main_content .= "Fieldnames[{$jn}]='{$can['0']}';\n" . "Codes[{$jn}]='{$can['1']}';\n" . "Answers[{$jn}]={$an};\n";
        $jn++;
    }
}
$jn = 0;
if (isset($cquestions)) {
    foreach ($cquestions as $cqn) {
        $conditionsoutput_main_content .= "QFieldnames[{$jn}]='{$cqn['3']}';\n" . "Qcqids[{$jn}]='{$cqn['1']}';\n" . "Qtypes[{$jn}]='{$cqn['2']}';\n";
        $jn++;
    }
}
//  record a JS variable to let jQuery know if survey is Anonymous
if ($thissurvey['anonymized'] == 'Y') {
    $conditionsoutput_main_content .= "isAnonymousSurvey = true;";
} else {
开发者ID:ddrmoscow,项目名称:queXS,代码行数:31,代码来源:conditionshandling.php


示例4: do_multiplenumeric


//.........这里部分代码省略.........
            $slider_max = 100;
        }
        $slider_default = trim($aQuestionAttributes['slider_default']) != '' ? $aQuestionAttributes['slider_default'] : "";
        if ($slider_default == '' && $aQuestionAttributes['slider_middlestart'] == 1) {
            $slider_middlestart = intval(($slider_max + $slider_min) / 2);
        } else {
            $slider_middlestart = '';
        }
        $slider_separator = trim($aQuestionAttributes['slider_separator']) != '' ? $aQuestionAttributes['slider_separator'] : "";
        $slider_reset = $aQuestionAttributes['slider_reset'] ? 1 : 0;
    } else {
        $slider_layout = false;
    }
    $hidetip = $aQuestionAttributes['hide_tip'];
    if ($aQuestionAttributes['random_order'] == 1) {
        $ansquery = "SELECT * FROM {{questions}} WHERE parent_qid={$ia['0']}  AND language='" . $_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang'] . "' ORDER BY " . dbRandom();
    } else {
        $ansquery = "SELECT * FROM {{questions}} WHERE parent_qid={$ia['0']}  AND language='" . $_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang'] . "' ORDER BY question_order";
    }
    $ansresult = dbExecuteAssoc($ansquery);
    //Checked
    $aSubquestions = $ansresult->readAll();
    $anscount = count($aSubquestions) * 2;
    $fn = 1;
    $answer_main = '';
    if ($anscount == 0) {
        $inputnames = array();
        $answer_main .= '    <li>' . $clang->gT('Error: This question has no answers.') . "</li>\n";
    } else {
        foreach ($aSubquestions as $ansrow) {
            $myfname = $ia[1] . $ansrow['title'];
            if ($ansrow['question'] == "") {
                $ansrow['question'] = "&nbsp;";
            }
            if ($slider_layout === false || $slider_separator == '') {
                $theanswer = $ansrow['question'];
                $sliderleft = '';
                $sliderright = '';
            } else {
                $aAnswer = explode($slider_separator, $ansrow['question']);
                $theanswer = isset($aAnswer[0]) ? $aAnswer[0] : "";
                $sliderleft = isset($aAnswer[1]) ? $aAnswer[1] : "";
                $sliderright = isset($aAnswer[2]) ? $aAnswer[2] : "";
                $sliderleft = "<div class=\"slider_lefttext\">{$sliderleft}</div>";
                $sliderright = "<div class=\"slider_righttext\">{$sliderright}</div>";
            }
            // color code missing mandatory questions red
            if ($ia[6] == 'Y' && ($_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['step'] == $_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['prevstep'] || $_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['maxstep'] > $_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['step']) && $_SESSION['survey_' . Yii::app()->getConfig('surveyID')][$myfname] === '') {
                $theanswer = "<span class='errormandatory'>{$theanswer}</span>";
            }
            list($htmltbody2, $hiddenfield) = return_array_filter_strings($ia, $aQuestionAttributes, $thissurvey, $ansrow, $myfname, '', $myfname, "li", "question-item answer-item text-item numeric-item" . $extraclass);
            $answer_main .= "\t{$htmltbody2}\n";
            $answer_main .= "<label for=\"answer{$myfname}\" class=\"{$prefixclass}-label\">{$theanswer}</label>\n";
            $sSeparator = getRadixPointData($thissurvey['surveyls_numberformat']);
            $sSeparator = $sSeparator['separator'];
            $answer_main .= "{$sliderleft}<span class=\"input\">\n\t" . $prefix . "\n\t<input class=\"text {$kpclass}\" type=\"text\" size=\"" . $tiwidth . "\" name=\"" . $myfname . "\" id=\"answer" . $myfname . "\" title=\"" . $clang->gT('Only numbers may be entered in this field.') . "\" value=\"";
            if (isset($_SESSION['survey_' . Yii::app()->getConfig('surveyID')][$myfname])) {
                $dispVal = $_SESSION['survey_' . Yii::app()->getConfig('surveyID')][$myfname];
                if (strpos($dispVal, ".")) {
                    $dispVal = rtrim(rtrim($dispVal, "0"), ".");
                }
                $dispVal = str_replace('.', $sSeparator, $dispVal);
                $answer_main .= $dispVal;
            }
            $answer_main .= '" onkeyup="' . $checkconditionFunction . '(this.value, this.name, this.type);" ' . " {$maxlength} />\n\t" . $suffix . "\n</span>{$sliderright}\n\t</li>\n";
            $fn++;
            $inputnames[] = $myfname;
        }
        if (trim($aQuestionAttributes['equals_num_value']) != '' || trim($aQuestionAttributes['min_num_value']) != '' || trim($aQuestionAttributes['max_num_value']) != '') {
            $qinfo = LimeExpressionManager::GetQuestionStatus($ia[0]);
            if (trim($aQuestionAttributes['equals_num_value']) != '') {
                $answer_main .= "\t<li class='multiplenumerichelp help-item'>\n" . "<span class=\"label\">" . $clang->gT('Remaining: ') . "</span>\n" . "<span id=\"remainingvalue_{$ia[0]}\" class=\"dynamic_remaining\">{$prefix}\n" . "{" . $qinfo['sumRemainingEqn'] . "}\n" . "{$suffix}</span>\n" . "\t</li>\n";
            }
            $answer_main .= "\t<li class='multiplenumerichelp  help-item'>\n" . "<span class=\"label\">" . $clang->gT('Total: ') . "</span>\n" . "<span id=\"totalvalue_{$ia[0]}\" class=\"dynamic_sum\">{$prefix}\n" . "{" . $qinfo['sumEqn'] . "}\n" . "{$suffix}</span>\n" . "\t</li>\n";
        }
        $answer .= "<ul class=\"subquestions-list questions-list text-list {$prefixclass}-list\">\n" . $answer_main . "</ul>\n";
    }
    if ($aQuestionAttributes['slider_layout'] == 1) {
        Yii::app()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts') . "numeric-slider.js");
        Yii::app()->getClientScript()->registerCssFile(Yii::app()->getConfig('publicstyleurl') . "numeric-slider.css");
        if ($slider_default != "") {
            $slider_startvalue = $slider_default;
            $slider_displaycallout = 1;
        } elseif ($slider_middlestart != '') {
            $slider_startvalue = $slider_middlestart;
            $slider_displaycallout = 0;
        } else {
            $slider_startvalue = 'NULL';
            $slider_displaycallout = 0;
        }
        $slider_showminmax = $aQuestionAttributes['slider_showminmax'] == 1 ? 1 : 0;
        //some var for slider
        $aJsLang = array('reset' => $clang->gT('Reset'), 'tip' => $clang->gT('Please click and drag the slider handles to enter your answer.'));
        $aJsVar = array('slider_showminmax' => $slider_showminmax, 'slider_min' => $slider_min, 'slider_mintext' => $slider_mintext, 'slider_max' => $slider_max, 'slider_maxtext' => $slider_maxtext, 'slider_step' => $slider_step, 'slider_startvalue' => $slider_startvalue, 'slider_displaycallout' => $slider_displaycallout, 'slider_prefix' => $prefix, 'slider_suffix' => $suffix, 'slider_reset' => $slider_reset, 'lang' => $aJsLang);
        $answer .= "<script type='text/javascript'><!--\n" . " doNumericSlider({$ia[0]}," . ls_json_encode($aJsVar) . ");\n" . " //--></script>";
    }
    $sSeparator = getRadixPointData($thissurvey['surveyls_numberformat']);
    $sSeparator = $sSeparator['separator'];
    return array($answer, $inputnames);
}
开发者ID:josetorerobueno,项目名称:test_repo,代码行数:101,代码来源:qanda_helper.php


示例5: ajaxSets

 public function ajaxSets()
 {
     $lid = Yii::app()->getRequest()->getPost('lid');
     $answers = Yii::app()->getRequest()->getPost('answers');
     $code = Yii::app()->getRequest()->getPost('code');
     $aAssessmentValues = Yii::app()->getRequest()->getPost('assessmentvalues', array());
     //Create new label set
     $language = "";
     foreach ($answers as $lang => $answer) {
         $language .= $lang . " ";
     }
     $language = trim($language);
     if ($lid == 0) {
         $lset = new LabelSet();
         $lset->label_name = Yii::app()->getRequest()->getPost('laname');
         $lset->languages = $language;
         $lset->save();
         $lid = getLastInsertID($lset->tableName());
     } else {
         Label::model()->deleteAll('lid = :lid', array(':lid' => $lid));
     }
     $res = 'ok';
     //optimistic
     foreach ($answers as $lang => $answer) {
         foreach ($answer as $key => $ans) {
             $label = new Label();
             $label->lid = $lid;
             $label->code = $code[$key];
             $label->title = $ans;
             $label->sortorder = $key;
             $label->language = $lang;
             $label->assessment_value = isset($aAssessmentValues[$key]) ? $aAssessmentValues[$key] : 0;
             if (!$label->save()) {
                 $res = 'fail';
             }
         }
     }
     echo ls_json_encode($res);
 }
开发者ID:wrenchpilot,项目名称:LimeSurvey,代码行数:39,代码来源:labels.php


示例6: generate_statistics


//.........这里部分代码省略.........
             break;
         case 'html':
             $sOutputHTML .= "<br />\n<table class='statisticssummary' >\n" . "\t<thead><tr><th colspan='2'>" . gT("Results") . "</th></tr></thead>\n" . "\t<tr><th >" . gT("Number of records in this query:") . '</th>' . "<td>{$results}</td></tr>\n" . "\t<tr><th>" . gT("Total records in survey:") . '</th>' . "<td>{$total}</td></tr>\n";
             //only calculate percentage if $total is set
             if ($total) {
                 $percent = sprintf("%01.2f", $results / $total * 100);
                 $sOutputHTML .= "\t<tr><th align='right'>" . gT("Percentage of total:") . '</th>' . "<td>{$percent}%</td></tr>\n";
             }
             $sOutputHTML .= "</table>\n";
             break;
         default:
             break;
     }
     //put everything from $selects array into a string connected by AND
     //This string ($sql) can then be passed on to other functions so you can
     //browse these results
     if (isset($selects) && $selects) {
         $sql = implode(" AND ", $selects);
     } elseif (!empty($newsql)) {
         $sql = $newsql;
     }
     if (!isset($sql) || !$sql) {
         $sql = null;
     }
     //only continue if we have something to output
     if ($results > 0) {
         if ($outputType == 'html' && $browse === true && Permission::model()->hasSurveyPermission($surveyid, 'responses', 'read')) {
             //add a buttons to browse results
             $sOutputHTML .= CHtml::form(array("admin/responses/sa/browse/surveyid/{$surveyid}"), 'post', array('target' => '_blank')) . "\n" . "\t\t<p>" . "\t\t\t<input type='submit' value='" . gT("Browse") . "'  />\n" . "\t\t\t<input type='hidden' name='sid' value='{$surveyid}' />\n" . "\t\t\t<input type='hidden' name='sql' value=\"{$sql}\" />\n" . "\t\t\t<input type='hidden' name='subaction' value='all' />\n" . "\t\t</p>" . "\t\t</form>\n";
         }
     }
     //end if (results > 0)
     /* Show Summary results
      * The $summary array contains each fieldname that we want to display statistics for
      *
      * */
     if (isset($summary) && $summary) {
         //let's run through the survey
         $runthrough = $summary;
         //START Chop up fieldname and find matching questions
         //loop through all selected questions
         foreach ($runthrough as $rt) {
             //Step 1: Get information about this response field (SGQA) for the summary
             $outputs = $this->buildOutputList($rt, $language, $surveyid, $outputType, $sql, $sLanguageCode);
             $sOutputHTML .= $outputs['statisticsoutput'];
             //2. Collect and Display results #######################################################################
             if (isset($outputs['alist']) && $outputs['alist']) {
                 $display = $this->displayResults($outputs, $results, $rt, $outputType, $surveyid, $sql, $usegraph, $browse, $sLanguageCode);
                 $sOutputHTML .= $display['statisticsoutput'];
                 $aStatisticsData = array_merge($aStatisticsData, $display['astatdata']);
             }
             //end if -> collect and display results
             //Delete Build Outputs data
             unset($outputs);
             unset($display);
         }
         // end foreach -> loop through all questions
         //output
         if ($outputType == 'html') {
             $sOutputHTML .= "<br />&nbsp;\n";
         }
     }
     //end if -> show summary results
     switch ($outputType) {
         case 'xls':
             $this->workbook->close();
             if ($pdfOutput == 'F') {
                 return $sFileName;
             } else {
                 return;
             }
             break;
         case 'pdf':
             $this->pdf->lastPage();
             if ($pdfOutput == 'F') {
                 // This is only used by lsrc to send an E-Mail attachment, so it gives back the filename to send and delete afterwards
                 $tempfilename = $sTempDir . "/Survey_" . $surveyid . ".pdf";
                 $this->pdf->Output($tempfilename, $pdfOutput);
                 return $tempfilename;
             } else {
                 return $this->pdf->Output(gT('Survey') . '_' . $surveyid . "_" . $surveyInfo['surveyls_title'] . '.pdf', $pdfOutput);
             }
             break;
         case 'html':
             $sGoogleMapsAPIKey = trim(Yii::app()->getConfig("googleMapsAPIKey"));
             if ($sGoogleMapsAPIKey != '') {
                 $sGoogleMapsAPIKey = '&key=' . $sGoogleMapsAPIKey;
             }
             $sSSL = '';
             if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != "off") {
                 $sSSL = 's';
             }
             $sOutputHTML .= "<script type=\"text/javascript\" src=\"http{$sSSL}://maps.googleapis.com/maps/api/js?sensor=false{$sGoogleMapsAPIKey}\"></script>\n" . "<script type=\"text/javascript\">var site_url='" . Yii::app()->baseUrl . "';var temppath='" . Yii::app()->getConfig("tempurl") . "';var imgpath='" . Yii::app()->getConfig('adminimageurl') . "';var aStatData=" . ls_json_encode($aStatisticsData) . "</script>";
             return $sOutputHTML;
             break;
         default:
             return $sOutputHTML;
             break;
     }
 }
开发者ID:krsandesh,项目名称:LimeSurvey,代码行数:101,代码来源:statistics_helper.php


示例7: ajaxlabelsetpicker

 /**
  * This function prepares the data for labelset
  *
  * @access public
  * @return void
  */
 public function ajaxlabelsetpicker()
 {
     $match = (int) returnglobal('match');
     $surveyid = returnglobal('sid');
     if ($match == 1) {
         $language = GetBaseLanguageFromSurveyID($surveyid);
     } else {
         $language = null;
     }
     $resultdata = getlabelsets($language);
     echo ls_json_encode($resultdata);
 }
开发者ID:ryu1inaba,项目名称:LimeSurvey,代码行数:18,代码来源:question.php


示例8: editToken

 function editToken($iSurveyId)
 {
     // CHECK TO SEE IF A TOKEN TABLE EXISTS FOR THIS SURVEY
     $bTokenExists = tableExists('{{tokens_' . $iSurveyId . '}}');
     if (!$bTokenExists) {
         self::_newtokentable($iSurveyId);
     }
     $sOperation = Yii::app()->request->getPost('oper');
     if (trim(Yii::app()->request->getPost('validfrom')) == '') {
         $from = null;
     } else {
         $from = date('Y-m-d H:i:s', strtotime(trim($_POST['validfrom'])));
     }
     if (trim(Yii::app()->request->getPost('validuntil')) == '') {
         $until = null;
     } else {
         $until = date('Y-m-d H:i:s', strtotime(trim($_POST['validuntil'])));
     }
     // if edit it will update the row
     if ($sOperation == 'edit') {
         //            if (Yii::app()->request->getPost('language') == '')
         //            {
         //                $sLang = Yii::app()->session['adminlang'];
         //            }
         //            else
         //            {
         //                $sLang = Yii::app()->request->getPost('language');
         //            }
         Tokens_dynamic::model($iSurveyId);
         echo $from . ',' . $until;
         $aData = array('firstname' => Yii::app()->request->getPost('firstname'), 'lastname' => Yii::app()->request->getPost('lastname'), 'email' => Yii::app()->request->getPost('email'), 'emailstatus' => Yii::app()->request->getPost('emailstatus'), 'token' => Yii::app()->request->getPost('token'), 'language' => Yii::app()->request->getPost('language'), 'sent' => Yii::app()->request->getPost('sent'), 'remindersent' => Yii::app()->request->getPost('remindersent'), 'remindercount' => Yii::app()->request->getPost('remindercount'), 'completed' => Yii::app()->request->getPost('completed'), 'usesleft' => Yii::app()->request->getPost('usesleft'), 'validfrom' => $from, 'validuntil' => $until);
         $attrfieldnames = Survey::model()->findByPk($iSurveyId)->tokenAttributes;
         foreach ($attrfieldnames as $attr_name => $desc) {
             $value = Yii::app()->request->getPost($attr_name);
             if ($desc['mandatory'] == 'Y' && trim($value) == '') {
                 $this->getController()->error(sprintf($this->controller->lang->gT('%s cannot be empty'), $desc['description']));
             }
             $aData[$attr_name] = Yii::app()->request->getPost($attr_name);
         }
         $token = Tokens_dynamic::model()->find('tid=' . Yii::app()->getRequest()->getPost('id'));
         foreach ($aData as $k => $v) {
             $token->{$k} = $v;
         }
         echo $token->update();
     } elseif ($sOperation == 'add') {
         if (Yii::app()->request->getPost('language') == '') {
             $aData = array('firstname' => Yii::app()->request->getPost('firstname'), 'lastname' => Yii::app()->request->getPost('lastname'), 'email' => Yii::app()->request->getPost('email'), 'emailstatus' => Yii::app()->request->getPost('emailstatus'), 'token' => Yii::app()->request->getPost('token'), 'language' => Yii::app()->request->getPost('language'), 'sent' => Yii::app()->request->getPost('sent'), 'remindersent' => Yii::app()->request->getPost('remindersent'), 'remindercount' => Yii::app()->request->getPost('remindercount'), 'completed' => Yii::app()->request->getPost('completed'), 'usesleft' => Yii::app()->request->getPost('usesleft'), 'validfrom' => $from, 'validuntil' => $until);
         }
         $attrfieldnames = Survey::model()->findByPk($iSurveyId)->tokenAttributes;
         foreach ($attrfieldnames as $attr_name => $desc) {
             $value = Yii::app()->request->getPost($attr_name);
             if ($desc['mandatory'] == 'Y' && trim($value) == '') {
                 $this->getController()->error(sprintf($clang->gT('%s cannot be empty'), $desc['description']));
             }
             $aData[$attr_name] = Yii::app()->request->getPost($attr_name);
         }
         echo ls_json_encode(var_export($aData));
         $token = new Tokens_dynamic();
         foreach ($aData as $k => $v) {
             $token->{$k} = $v;
         }
         echo $token->save();
     } elseif ($sOperation == 'del') {
         $_POST['tid'] = Yii::app()->request->getPost('id');
         $this->delete($iSurveyId);
     }
 }
开发者ID:rawaludin,项目名称:LimeSurvey,代码行数:67,代码来源:tokens.php


示例9: array

            // unlink($randfileloc);
        }
    }
} else {
    // if everything went fine and the file was uploaded successfuly,
    // send the file related info back to the client
    if ($size > $maxfilesize) {
        $return = array("success" => false, "msg" => sprintf($clang->gT("Sorry, this file is too large. Only files up to %s KB are allowed.", 'unescaped'), $maxfilesize));
        echo ls_json_encode($return);
    } elseif ($iFileUploadTotalSpaceMB > 0 && fCalculateTotalFileUploadUsage() + $size / 1024 / 1024 > $iFileUploadTotalSpaceMB) {
        $return = array("success" => false, "msg" => $clang->gT("We are sorry but there was a system error and your file was not saved. An email has been dispatched to notify the survey administrator.", 'unescaped'));
        echo ls_json_encode($return);
    } elseif (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $randfileloc)) {
        $return = array("success" => true, "size" => $size, "name" => rawurlencode(basename($filename)), "ext" => $ext, "filename" => $randfilename, "msg" => $clang->gT("The file has been successfuly uploaded."));
        echo ls_json_encode($return);
    } else {
        // check for upload error
        if ($_FILES['uploadfile']['error'] > 2) {
            $return = array("success" => false, "msg" => $clang->gT("Sorry, there was an error uploading your file"));
            echo ls_json_encode($return);
        } else {
            if ($_FILES['uploadfile']['error'] == 1 || $_FILES['uploadfile']['error'] == 2 || $size > $maxfilesize) {
                $return = array("success" => false, "msg" => sprintf($clang->gT("Sorry, this file is too large. Only files upto %s KB are allowed."), $maxfilesize));
                echo ls_json_encode($return);
            } else {
                $return = array("success" => false, "msg" => $clang->gT("Unknown error"));
                echo ls_json_encode($return);
            }
        }
    }
}
开发者ID:ddrmoscow,项目名称:queXS,代码行数:31,代码来源:upload.php


示例10: db_table_name

        $query = 'select * from ' . db_table_name('labels') . ' where lid=' . $lid . " and language='{$language}' order by sortorder";
        $labels = $connect->GetArray($query);
        $resultdata[] = array($language => array($labels, getLanguageNameFromCode($language, false)));
    }
    echo ls_json_encode($resultdata);
}
if ($action == "ajaxlabelsetpicker") {
    $match = (int) returnglobal('match');
    $surveyid = returnglobal('sid');
    if ($match == 1) {
        $language = GetBaseLanguageFromSurveyID($surveyid);
    } else {
        $language = null;
    }
    $resultdata = getlabelsets($language);
    echo ls_json_encode($resultdata);
}
if ($action == "ajaxquestionattributes") {
    $thissurvey = getSurveyInfo($surveyid);
    $type = returnglobal('question_type');
    if (isset($qid)) {
        $attributesettings = getQuestionAttributes($qid);
    }
    $availableattributes = questionAttributes();
    if (isset($availableattributes[$type])) {
        uasort($availableattributes[$type], 'CategorySort');
        $ajaxoutput = '';
        $currentfieldset = '';
        foreach ($availableattributes[$type] as $qa) {
            if (isset($attributesettings[$qa['name']])) {
                $value = $attributesettings[$qa['name']];
开发者ID:ddrmoscow,项目名称:queXS,代码行数:31,代码来源:questionhandling.php


示例11: beforeQuestionRender

 public function beforeQuestionRender()
 {
     $oEvent = $this->getEvent();
     $sQuestionType = $this->get('questiontype', 'Survey', $oEvent->get('surveyId'), $this->get('questiontype', null, null, $this->settings['questiontype']['default']));
     $sQuestionName = $this->get('questionname', 'Survey', $oEvent->get('surveyId'), $this->get('questionname'));
     if ($sQuestionType == 'default') {
         $sQuestionType = $this->get('questiontype', null, null, $this->settings['questiontype']['default']);
     }
     if ($sQuestionType != "NA" && $oEvent->get('type') == $sQuestionType || $sQuestionName && substr($oEvent->get('code'), -strlen($sQuestionName)) === $sQuestionName) {
         $questionClass = $oEvent->get('class');
         // Danger with other plugin
         $oQuestionBrowser = Question::model()->find("sid=:sid AND qid=:qid", array(':sid' => $oEvent->get('surveyId'), ':qid' => $oEvent->get('qid')));
         $sAnswerId = "answer" . $oQuestionBrowser->sid . "X" . $oQuestionBrowser->gid . "X" . $oQuestionBrowser->qid;
         //$sScriptFile="//cdn.ckeditor.com/4.4.5/full/ckeditor.js"; // Disallow preview
         $sScriptFile = Yii::app()->baseUrl . '/plugins/htmlEditorAnswers/third_party/ckeditor/ckeditor.js';
         // Allow preview
         Yii::app()->clientScript->registerScriptFile($sScriptFile);
         // Some css correction (with asset)
         $assetUrl = Yii::app()->assetManager->publish(dirname(__FILE__) . '/assets');
         Yii::app()->clientScript->registerCssFile($assetUrl . '/htmleditoranswers.css');
         // Call the config (with asset) move it to assets ? In config, seems more clear for dev user.
         $assetUrl = Yii::app()->assetManager->publish(dirname(__FILE__) . '/config');
         $sConfigFile = $this->get('configfile', 'Survey', $oEvent->get('surveyId'), $this->get('configfile', null, null, $this->settings['configfile']['default']));
         if ($sConfigFile == 'default') {
             $sConfigFile = $this->get('configfile', null, null, $this->settings['configfile']['default']);
         }
         $sLangCode = App()->language;
         $aCkOptions = array('customConfig' => "{$assetUrl}/{$sConfigFile}.js", 'language' => $sLangCode);
         $sCssFile = $this->get('cssfile', 'Survey', $oEvent->get('surveyId'), $this->get('cssfile'));
         if ($sCssFile) {
             $aCkOptions['contentsCss'] = $sCssFile;
         }
         $sJsonTag = $this->get('tags', 'Survey', $oEvent->get('surveyId'), $this->get('tags'));
         $aTags = json_decode($sJsonTag, true);
         $aCkOptionsLang = array();
         if (!empty($aTags)) {
             $aCkOptions['format_tags'] = implode(";", array_keys($aTags));
             foreach ($aTags as $sTag => $aTag) {
                 if (!empty($aTag['description'])) {
                     $aCkOptionsLang["tag_{$sTag}"] = $aTag['description'];
                 }
                 unset($aTag['description']);
                 $aCkOptions["format_{$sTag}"] = $aTag;
             }
         } else {
             $aCkOptions['removePlugins'] = 'format';
         }
         $jsonCkOptions = ls_json_encode($aCkOptions);
         $ckeditorScript = "\$('#question{$oEvent->get('qid')} textarea').each(function(e){\n";
         $ckeditorScript .= "    var textarea = \$(this);";
         $ckeditorScript .= "    CKEDITOR.replace( this, {$jsonCkOptions} ).on( 'change', function( event ) {\n ";
         $ckeditorScript .= "        \$(textarea).val( event.editor.getData() ).trigger('keyup'); \n ";
         $ckeditorScript .= "     });";
         if (!empty($aCkOptionsLang)) {
             $ckeditorScript .= "    CKEDITOR.on( 'instanceReady', function (event ){ \n";
             foreach ($aCkOptionsLang as $label => $value) {
                 $ckeditorScript .= "          event.editor.lang.format.{$label}='{$value}';";
             }
             $ckeditorScript .= "     });\n";
         }
         $ckeditorScript .= "";
         $ckeditorScript .= " })\n";
         Yii::app()->clientScript->registerScript("ckeditorScript{$sAnswerId}", $ckeditorScript, CClientScript::POS_END);
     }
 }
开发者ID:WorldHealthOrganization,项目名称:ls-htmlEditorAnswers,代码行数:65,代码来源:htmlEditorAnswers.php


示例12: ls_json_encode

{
    "ok": <?php 
echo $success;
?>
    
    <?php 
if (isset($mapdata)) {
    echo ",\"mapdata\":" . ls_json_encode($mapdata);
}
?>
    
    <?php 
if (isset($chartdata)) {
    echo ",\"chartdata\":" . ls_json_encode($chartdata);
}
?>
}
开发者ID:mfavetti,项目名称:LimeSurvey,代码行数:17,代码来源:statistics_graph_view.php


示例13: sanitize_filename

$sFilename = sanitize_filename($_GET['filename']);
$sOriginalFileName = sanitize_filename($_GET['name']);
if (substr($sFilename, 0, 6) == 'futmp_') {
    $sFileDir = $tempdir . '/upload/';
} elseif (substr($sFilename, 0, 3) == 'fu_') {
    $sFileDir = "{$uploaddir}/surveys/{$surveyid}/files/";
} else {
    die('Invalid filename');
}
$sJSON = $_SESSION[$sFieldname];
$aFiles = json_decode(stripslashes($sJSON), true);
if (substr($sFilename, 0, 3) == 'fu_') {
    $iFileIndex = 0;
    $found = false;
    foreach ($aFiles as $aFile) {
        if ($aFile['filename'] == $sFilename) {
            $found = true;
            break;
        }
        $iFileIndex++;
    }
    if ($found == true) {
        unset($aFiles[$iFileIndex]);
    }
    $_SESSION[$sFieldname] = ls_json_encode($aFiles);
}
if (@unlink($sFileDir . $sFilename)) {
    echo sprintf($clang->gT('File %s deleted'), $sOriginalFileName);
} else {
    echo $clang->gT('Oops, There was an error deleting the file');
}
开发者ID:ddrmoscow,项目名称:queXS,代码行数:31,代码来源:delete.php


示例14: run

    function run($actionID)
    {
        $surveyid = $_SESSION['LEMsid'];
        if (isset($_SESSION['survey_' . $surveyid]['s_lang'])) {
            $sLanguage = $_SESSION['survey_' . $surveyid]['s_lang'];
        } else {
            $sLanguage = '';
        }
        $clang = SetSurveyLanguage($surveyid, $sLanguage);
        $uploaddir = Yii::app()->getConfig("uploaddir");
        $tempdir = Yii::app()->getConfig("tempdir");
        Yii::app()->loadHelper("database");
        $param = $_REQUEST;
        if (isset($param['filegetcontents'])) {
            $sFileName = $param['filegetcontents'];
            if (substr($sFileName, 0, 6) == 'futmp_') {
                $sFileDir = $tempdir . '/upload/';
            } elseif (substr($sFileName, 0, 3) == 'fu_') {
                $sFileDir = "{$uploaddir}/surveys/{$surveyid}/files/";
            }
            header('Content-Type: ' . CFileHelper::getMimeType($sFileDir . $sFileName));
            readfile($sFileDir . $sFileName);
            exit;
        } elseif (isset($param['delete'])) {
            $sFieldname = $param['fieldname'];
            $sFilename = sanitize_filename($param['filename']);
            $sOriginalFileName = sanitize_filename($param['name']);
            if (substr($sFilename, 0, 6) == 'futmp_') {
                $sFileDir = $tempdir . '/upload/';
            } elseif (substr($sFilename, 0, 3) == 'fu_') {
                $sFileDir = "{$uploaddir}/surveys/{$surveyid}/files/";
            } else {
                die('Invalid filename');
            }
            if (isset($_SESSION[$sFieldname])) {
                $sJSON = $_SESSION[$sFieldname];
                $aFiles = json_decode(stripslashes($sJSON), true);
                if (substr($sFilename, 0, 3) == 'fu_') {
                    $iFileIndex = 0;
                    $found = false;
                    foreach ($aFiles as $aFile) {
                        if ($aFile['filename'] == $sFilename) {
                            $found = true;
                            break;
                        }
                        $iFileIndex++;
                    }
                    if ($found == true) {
                        unset($aFiles[$iFileIndex]);
                    }
                    $_SESSION[$sFieldname] = ls_json_encode($aFiles);
                }
            }
            //var_dump($sFileDir.$sFilename);
            if (@unlink($sFileDir . $sFilename)) {
                echo sprintf($clang->gT('File %s deleted'), $sOriginalFileName);
            } else {
                echo $clang->gT('Oops, There was an error deleting the file');
            } 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP ls_redirect函数代码示例发布时间:2022-05-15
下一篇:
PHP ls函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap