Ejemplo n.º 1
0
 function showLanguage()
 {
     global $survey;
     $allowed = explode("~", $survey->getAllowedLanguages(getSurveyMode()));
     if (sizeof($allowed) == 1) {
         return "";
     }
     $rgid = $this->engine->getRgid();
     $variablenames = $this->getRealVariables(explode("~", $this->engine->getDisplayed()));
     $template = $this->engine->getTemplate();
     $click = "";
     if ($template != "") {
         $group = $this->engine->getGroup($template);
         $click = $this->engine->replaceFills($group->getClickLanguageChange());
     } else {
         $vars = explode("~", $variablenames);
         $var = $this->engine->getVariableDescriptive($vars[0]);
         $click = $this->engine->replaceFills($var->getClickLanguageChange());
     }
     $click = str_replace("'", "", $click);
     $current = getSurveyLanguage();
     $langs = Language::getLanguagesArray();
     foreach ($langs as $key => $lang) {
         if (inArray($lang["value"], $allowed)) {
             $check = '';
             if ($lang["value"] == getSurveyLanguage()) {
                 //              $check = ' <span class="glyphicon glyphicon-ok"></span>';
             } else {
                 $returnStr .= '<button type="button" class="btn btn-sm btn-warning" onclick=\'document.getElementById("r").value="' . setSessionsParamString(array_merge(array(SESSION_PARAM_LASTACTION => $this->engine->getLastSurveyAction(), SESSION_PARAM_SURVEY => $survey->getSuid(), SESSION_PARAM_PRIMKEY => $this->primkey, SESSION_PARAM_RGID => $rgid, SESSION_PARAM_VARIABLES => $variablenames, SESSION_PARAM_GROUP => $template, SESSION_PARAM_MODE => getSurveyMode(), SESSION_PARAM_TEMPLATE => getSurveyTemplate(), SESSION_PARAM_VERSION => getSurveyVersion(), SESSION_PARAM_LANGUAGE => $current, SESSION_PARAM_TIMESTAMP => time(), SESSION_PARAM_SEID => $this->engine->getSeid(), SESSION_PARAM_MAINSEID => $this->engine->getMainSeid()), array(SESSION_PARAM_NEWLANGUAGE => $lang["value"]))) . '"; document.getElementById("navigation").value="' . NAVIGATION_LANGUAGE_CHANGE . '"; ' . $click . ' document.getElementById("form").submit(); \'>' . $lang["name"] . $check . '</button>';
             }
         }
     }
     return $returnStr;
 }
Ejemplo n.º 2
0
/**
 * Search for Value where $searchNum in $startArray[0 ... Value - 1] == !$searchNum in arr[Value ... count($searchNum) - 1]
 * Detail description in technical assignment
 *
 * @param int $searchNum number what we search for
 * @param array $startArray array where we searching values
 *
 * @return int
 */
function solution($searchNum, array $startArray)
{
    if (in_array($searchNum, $startArray)) {
        $arrLength = count($startArray);
        $start = 0;
        $end = $arrLength;
        $middle = (int) (($start + $end) / 2);
        $middleWatcher = 0;
        $result = inArray($startArray, $searchNum, $middle);
        while ($result['yes'] !== $result['no']) {
            if ($result['yes'] > $result['no']) {
                $end = $middle;
            } else {
                if ($result['yes'] < $result['no']) {
                    $start = $middle;
                }
            }
            $middle = (int) (($start + $end) / 2);
            //If wathcer == middle - that means that value repeating and no sense to do another loop
            if ($middle === $middleWatcher) {
                return -1;
            }
            $middleWatcher = $middle;
            $result = inArray($startArray, $searchNum, $middle);
        }
        return $middle;
    }
    return -1;
}
Ejemplo n.º 3
0
 {
     $this->variables = $variables;
     $this->realvariables = $realvariables;
     $this->language = $language;
     $returnStr = $this->singleRowTable();
     return $returnStr;
 }
 function singleRowTable()
 {
     $pt = $this->group->getParentGroup()->getTemplate();
     if ($pt != $this->group->getTemplate()) {
         $returnStr = '<div class="table-responsive">';
     }
     /* add error checks */
     $this->addErrorChecks();
     /* start table */
     $id = $this->group->getTableId();
     if (trim($id) == "") {
         $id = 'table_' . $this->group->getName() . mt_rand(0, 10000);
     }
     if ($pt != $this->group->getTemplate()) {
         $returnStr .= '<table id="' . $id . '" class="table' . $this->striped . $this->bordered . $this->hovered . $this->condensed . ' uscic-table-singlerow">';
         $returnStr .= '<thead></thead><tbody>';
         $returnStr .= "<tr class='uscic-table-row-singlerow'>";
     }
     /* build table */
     $cellwidth = "";
     //'style=" min-width: ' . round(100/(sizeof($this->variables)*2)) . '%; max-width: ' . round(100/sizeof($this->variables)) . '%; width: ' . round(100/sizeof($this->variables)) . '%;"';
     for ($i = 0; $i < sizeof($this->variables); $i++) {
         $variable = $this->variables[$i];
         if (startsWith($variable, ROUTING_IDENTIFY_SUBGROUP)) {
             //$returnStr .= "<td class='uscic-table-row-cell-singlerow' $cellwidth>" . $this->displayobject->showSubGroupQuestions($variable) . "</td>";
             $returnStr .= $this->displayobject->showSubGroupQuestions($variable, $this->group);
             $i = $this->findEndSubGroup($this->variables, $i);
             // skip until the end of the sub group, and continue display from there
         } else {
             $var = $this->engine->getVariableDescriptive($variable);
             /* only display non-inline fields */
             if ($this->engine->isInlineField($variable) == false) {
                 /* question text */
                 $returnStr .= "<td class='uscic-table-row-question-cell-singlerow' {$cellwidth}>" . $this->displayobject->showQuestionText($variable, $var, "uscic-question-table-single-row") . "</td>";
                 $cnt = $this->displaynumbers[strtoupper($variable)];
                 if (!inArray($var->getAnswerType(), array(ANSWER_TYPE_NONE, ANSWER_TYPE_SECTION))) {
                     /* answer input element */
                     $previousdata = $this->engine->getAnswer($variable);
                     $returnStr .= "<td class='uscic-table-row-cell-singlerow' {$cellwidth}>" . $this->displayobject->showAnswer($cnt, $variable, $var, $previousdata) . "</td>";
                 } else {
                     //$returnStr .= "<td></td>";
                 }
             }
Ejemplo n.º 4
0
    public function showNavBar()
    {
        $returnStr = $this->showCalculator();
        //language
        $rgid = $this->engine->getRgid();
        $variablenames = $this->engine->getDisplayed();
        // begin language
        global $survey;
        if (getSurveyLanguageAllowChange() == LANGUAGE_CHANGE_RESPONDENT_ALLOWED) {
            $allowed = explode("~", $survey->getAllowedLanguages(getSurveyMode()));
            if (sizeof($allowed) > 1) {
                $returnStr .= '<li class="dropdown">';
                $returnStr .= '   <a href="#" class="dropdown-toggle" data-toggle="dropdown">Language <b class="caret"></b></a><ul class="dropdown-menu">';
                $langs = Language::getLanguagesArray();
                //getSurveyLanguages($this->engine->survey);
                foreach ($langs as $lang) {
                    if (inArray($lang["value"], $allowed)) {
                        $check = '';
                        if ($lang["value"] == getSurveyLanguage()) {
                            $check = ' <span class="glyphicon glyphicon-ok"></span>';
                        }
                        $returnStr .= '<li><a href=# onclick=\'document.getElementById("r").value="' . setSessionsParamString(array_merge(array(SESSION_PARAM_PRIMKEY => $this->engine->primkey, SESSION_PARAM_RGID => $rgid, SESSION_PARAM_VARIABLES => $variablenames, SESSION_PARAM_LANGUAGE => getSurveyLanguage(), SESSION_PARAM_TIMESTAMP => time(), SESSION_PARAM_SEID => $this->engine->getSeid(), SESSION_PARAM_MAINSEID => $this->engine->getMainSeid()), array(SESSION_PARAM_NEWLANGUAGE => $lang["value"]))) . '"; document.getElementById("navigation").value="' . addslashes(Language::buttonUpdate()) . '"; document.getElementById("form").submit(); \'>' . $lang["name"] . $check . '</a></li>';
                    }
                }
                $returnStr .= '</ul></li>';
            }
            //end language
        }
        $user = new User($_SESSION['URID']);
        $returnStr .= '<li class="dropdown">
              <a href="#" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown">' . $user->getName() . ' <b class="caret"></b></a>
                 <ul class="dropdown-menu">
										<li class="dropdown-header">' . $this->engine->primkey . '</li>
                                                                                <li class="dropdown-header">' . $variablenames . '</li>';
        //$returnStr .= '<li><a href=# data-toggle="modal" data-target="#calculator">Calculator</a></li>';
        $returnStr .= '<li><a href="#" data-toggle="modal" data-target="#calculator"><span class="glyphicon glyphicon-th"></span> Calculator</a></li>';
        $returnStr .= '<li><a href="' . setSessionParams(array('page' => 'nurse.backfromsms', 'primkey' => $this->engine->primkey, 'suid' => $this->engine->getSuid())) . '&se=' . addslashes(USCIC_SMS) . '"><span class="glyphicon glyphicon-home"></span> ' . Language::linkBackToSMS() . '</a></li>                   
                    <li class="divider"></li>
                   <li><a href="index.php?rs=1&se=2"><span class="glyphicon glyphicon-log-out"></span> ' . Language::linkLogout() . '</a></li>
                 </ul>
             </li>
            </ul>
';
        $returnStr .= '</div><!--/.nav-collapse --> </div> </div>';
        return $returnStr;
    }
Ejemplo n.º 5
0
	public function __construct( $definedMeaningId ) {
		$dc = wdGetDataSetContext();
		$dbr = wfGetDB( DB_SLAVE );

		global
			$wgDefaultClassMids, $dataSet;

		$queryResult = $dbr->query(
			SelectLatestDistinct(
				array(
					$dataSet->classAttributes->attributeMid,
					$dataSet->classAttributes->attributeType,
					$dataSet->bootstrappedDefinedMeanings->name
				),
				array( $dataSet->classAttributes, $dataSet->bootstrappedDefinedMeanings ),
				array(
					equals( $dataSet->classAttributes->levelMid, $dataSet->bootstrappedDefinedMeanings->definedMeaningId ),
					sqlOr(
						in( $dataSet->classAttributes->classMid,
							selectLatest(
								array( $dataSet->classMemberships->classMid ),
								array( $dataSet->classMemberships ),
								array( equals( $dataSet->classMemberships->classMemberMid, $definedMeaningId ) )
							)
						),
						inArray( $dataSet->classAttributes->classMid, $wgDefaultClassMids )
					)
				)
			)
		);

		$this->classAttributes = array();
		
		while ( $row = $dbr->fetchRow( $queryResult ) ) {
			$classAttribute = new ClassAttribute();
			$classAttribute->attributeId = $row[0];
			$classAttribute->type = $row[1];
			$classAttribute->levelName = $row[2];
			
			$this->classAttributes[] = $classAttribute;
		}
	}
Ejemplo n.º 6
0
 function addQuestion(&$node, $instruction)
 {
     $rule = trim($instruction->getRule());
     $rgid = trim($instruction->getRgid());
     $excluded = array();
     $rule = excludeText($rule, $excluded);
     // check for .INLINE
     $inline = false;
     if (endsWith($rule, ROUTING_IDENTIFY_INLINE)) {
         $inline = true;
         //echo $rule;
         $pos = strrpos($rule, ROUTING_IDENTIFY_INLINE);
         //echo $pos;
         $rule = substr($rule, 0, $pos);
     }
     //echo $rule;
     // hide module dot notations
     $rule = hideModuleNotations($rule, TEXT_MODULE_DOT);
     //echo $rule;
     $rule = includeText($rule, $excluded);
     $var = $this->survey->getVariableDescriptiveByName(getBasicName($rule));
     if ($var->getVsid() != "") {
         if ($var->isHiddenRouting() == false) {
             if (trim($var->getDescription()) != "") {
                 $this->addToStatements("<div class='uscic-paperversion-question uscic-paperversion-nesting" . $this->nesting . "'><div class='uscic-paperversion-question-name'><b>" . $var->getName() . "</b> (" . $this->prepareText($var->getDescription()) . ")");
             } else {
                 $this->addToStatements("<div class='uscic-paperversion-question uscic-paperversion-nesting" . $this->nesting . "'><div class='uscic-paperversion-question-name'>" . $var->getName() . "");
             }
             $this->addToStatements('</div>');
             if (trim($var->getQuestion()) != "") {
                 $this->addToStatements("<div class='uscic-paperversion-questiontext'>" . $this->prepareText($var->getQuestion()) . "</div>", 15);
             }
             $answertype = $var->getAnswerType();
             if ($answertype == SETTING_FOLLOW_TYPE) {
                 $type = $this->survey->getType($var->getTyd());
                 $answertype = $type->getAnswerType();
             }
             if (inArray($answertype, array(ANSWER_TYPE_ENUMERATED, ANSWER_TYPE_SETOFENUMERATED, ANSWER_TYPE_DROPDOWN, ANSWER_TYPE_MULTIDROPDOWN))) {
                 $this->addToStatements("<div class='uscic-paperversion-question-categories'>" . $this->prepareText(str_replace("\r\n", "<br/>", $var->getOptionsText())) . "</div>");
             } elseif ($answertype == ANSWER_TYPE_STRING || $answertype == ANSWER_TYPE_OPEN) {
                 $this->addToStatements('STRING');
             } elseif ($answertype == ANSWER_TYPE_RANGE) {
                 $this->addToStatements('RANGE ' . $var->getMinimum() . '..' . $var->getMaximum());
             }
             $this->addToStatements("</div>", 6);
         }
     }
 }
Ejemplo n.º 7
0
    function showSearchSysadmin($searchparameters)
    {
        $returnStr = '<a id="closelink" class="close pull-right">&times;</a>';
        $returnStr .= "<script type='text/javascript'>\n                        \$ ('#closelink').click(function(event) {\n                                \$.sidr('close', 'optionssidebar');\n                                \$.get('" . setSessionParams(array("page" => "sysadmin.search.hide")) . "&updatesessionpage=2" . "',{},function(response){});\n                            });\n                        ";
        $returnStr .= "</script>";
        if (trim($searchparameters) == "") {
            $returnStr .= $this->displayWarning(Language::messageSearchNoTerm());
        } else {
            global $db, $survey;
            $query = "select * from " . Config::dbSurvey() . "_settings where suid=" . $_SESSION['SUID'] . " and CONVERT(value using utf8) COLLATE utf8_general_ci like '%" . prepareDatabaseString($searchparameters) . "%' group by objecttype,object order by objecttype, object";
            $res = $db->selectQuery($query);
            $query1 = "select * from " . Config::dbSurvey() . "_routing where suid=" . $_SESSION['SUID'] . " and CONVERT(rule using utf8) COLLATE utf8_general_ci like '%" . prepareDatabaseString($searchparameters) . "%' order by seid asc, rgid asc";
            $res1 = $db->selectQuery($query1);
            if ($res || $res1) {
                if ($db->getNumberOfRows($res) == 0 && $db->getNumberOfRows($res1) == 0) {
                    $returnStr .= $this->displayWarning(Language::labelNoSearched($searchparameters));
                } else {
                    /*
                     * 
                     */
                    $returnStr .= $this->displayCookieScripts();
                    $returnStr .= "<script type='text/javascript'>\n                        \$(document).ready(function(){\n                            \$('#search a').bind('click',function(event){\n                                  event.preventDefault();\n                                  var url=this.href + \"&" . POST_PARAM_AJAX_LOAD . "=" . AJAX_LOAD . "\";\n                                  \$.get(url,{},function(response){ \n                                     \$('#content').html(\$(response).children().first())\n                              })\t\n                           })\n                          });\n                        ";
                    $returnStr .= "</script>";
                    $_SESSION['SEARCH'] = SEARCH_OPEN_YES;
                    $_SESSION['SEARCHTERM'] = $searchparameters;
                    $returnStr .= $this->displaySuccess(Language::labelSearched($searchparameters));
                    $var_results = array();
                    $type_results = array();
                    $survey_results = array();
                    $group_results = array();
                    $section_results = array();
                    // TODO: HOW TO GROUP HERE: VARIABLE YES, SURVEY NO, SHOW NUMBER OF PLACES FOUND IN CASE OF MULTIPLE LOCATIONS? OR SHOW ALL ENTRIES?
                    if ($db->getNumberOfRows($res) > 0) {
                        while ($row = $db->getRow($res)) {
                            /* process */
                            switch ($row["objecttype"]) {
                                case OBJECT_VARIABLEDESCRIPTIVE:
                                    $variable = $survey->getVariableDescriptive($row["object"]);
                                    $tagclass = "";
                                    //'class="btn btn-default"';
                                    if (isset($_COOKIE['uscicvariablecookie'])) {
                                        $cookievalue = $_COOKIE['uscicvariablecookie'];
                                        if (inArray($variable->getSuid() . "~" . $variable->getVsid(), explode("-", $cookievalue))) {
                                            $tagclass = 'class="uscic-cookie-tag-active"';
                                        }
                                    }
                                    $var_results[$row["name"] . $row["object"] . $row["objecttype"]] = "<tr>\n                                            <td><a " . $tagclass . ' onclick="var res = updateCookie(\'uscicvariablecookie\',\'' . $variable->getSuid() . "~" . $variable->getVsid() . '\'); if (res == 1) { $(this).addClass(\'uscic-cookie-tag-active\'); } else { $(this).removeClass(\'uscic-cookie-tag-active\'); } return false;" title="' . Language::linkTagTooltip() . '" href="" role="button"><span class="glyphicon glyphicon-tag"></span></a></td>' . "<td><a class='searchlink' href='" . setSessionParams(array("page" => "sysadmin.survey.editvariable", "suid" => $_SESSION['SUID'], "vsid" => $row["object"])) . "'>" . $variable->getName() . "</a></td>                                                      \n                                                          </tr>";
                                    break;
                                case OBJECT_TYPE:
                                    $type = $survey->getType($row["object"]);
                                    $tagclass = "";
                                    //'class="btn btn-default"';
                                    if (isset($_COOKIE['uscictypeecookie'])) {
                                        $cookievalue = $_COOKIE['uscictypecookie'];
                                        if (inArray($type->getSuid() . "~" . $type->getTyd(), explode("-", $cookievalue))) {
                                            $tagclass = 'class="uscic-cookie-tag-active"';
                                        }
                                    }
                                    $type_results[] = "<tr>\n                                        <td><a " . $tagclass . ' onclick="var res = updateCookie(\'uscictypecookie\',\'' . $type->getSuid() . "~" . $type->getTyd() . '\'); if (res == 1) { $(this).addClass(\'uscic-cookie-tag-active\'); } else { $(this).removeClass(\'uscic-cookie-tag-active\'); } return false;" title="' . Language::linkTagTooltip() . '" href="" role="button"><span class="glyphicon glyphicon-tag"></span></a></td>' . "<td><a class='searchlink' href='" . setSessionParams(array("page" => "sysadmin.survey.edittype", "suid" => $_SESSION['SUID'], "tyd" => $row["object"])) . "'>" . $type->getName() . "</a></td>\n\n                                                          </tr>";
                                    break;
                                case OBJECT_SECTION:
                                    $section = $survey->getSection($row["object"]);
                                    $tagclass = "";
                                    //'class="btn btn-default"';
                                    if (isset($_COOKIE['uscicsectioncookie'])) {
                                        $cookievalue = $_COOKIE['uscicsectioncookie'];
                                        if (inArray($section->getSuid() . "~" . $section->getSeid(), explode("-", $cookievalue))) {
                                            $tagclass = 'class="uscic-cookie-tag-active"';
                                        }
                                    }
                                    $section_results[] = "<tr>\n                                        <td><a " . $tagclass . ' onclick="var res = updateCookie(\'uscicsectioncookie\',\'' . $section->getSuid() . "~" . $section->getSeid() . '\'); if (res == 1) { $(this).addClass(\'uscic-cookie-tag-active\'); } else { $(this).removeClass(\'uscic-cookie-tag-active\'); } return false;" title="' . Language::linkTagTooltip() . '" href="" role="button"><span class="glyphicon glyphicon-tag"></span></a></td>' . "<td><a class='searchlink' href='" . setSessionParams(array("page" => "sysadmin.survey.editsection", "suid" => $_SESSION['SUID'], "seid" => $row["object"])) . "'>" . $section->getName() . "</a></td>\n\n                                                          </tr>";
                                    break;
                                case OBJECT_GROUP:
                                    $group = $survey->getGroup($row["object"]);
                                    $tagclass = "";
                                    //'class="btn btn-default"';
                                    if (isset($_COOKIE['uscicgroupcookie'])) {
                                        $cookievalue = $_COOKIE['uscicgroupcookie'];
                                        if (inArray($group->getSuid() . "~" . $group->getGid(), explode("-", $cookievalue))) {
                                            $tagclass = 'class="uscic-cookie-tag-active"';
                                        }
                                    }
                                    $group_results[] = "<tr>\n                                        <td><a " . $tagclass . ' onclick="var res = updateCookie(\'uscicgroupcookie\',\'' . $group->getSuid() . "~" . $group->getGid() . '\'); if (res == 1) { $(this).addClass(\'uscic-cookie-tag-active\'); } else { $(this).removeClass(\'uscic-cookie-tag-active\'); } return false;" title="' . Language::linkTagTooltip() . '" href="" role="button"><span class="glyphicon glyphicon-tag"></span></a></td>' . "<td><a class='searchlink' href='" . setSessionParams(array("page" => "sysadmin.survey.editgroup", "suid" => $_SESSION['SUID'], "gid" => $row["object"])) . "'>" . $group->getName() . "</a></td>\n\n                                                          </tr>";
                                    break;
                                case OBJECT_SURVEY:
                                    $survey_results[] = "<tr>\n                                                            <td>" . $survey->getName() . "</td>                                                      \n                                                          </tr>";
                                    break;
                            }
                        }
                    }
                    $var_header .= '<div id="collapseVariables" class="panel-collapse collapse">
                                            <div class="panel-body">';
                    if (sizeof($var_results) > 0) {
                        $var_header .= '<table class="table table-striped table-bordered">
                                        <thead>
                                        <th></th><th align=middle>' . Language::labelSearchName() . '</th>' . '</thead>
                                        <tbody data-link="row" class="rowlink">';
                        $var_footer .= "</tbody></table></div></div>";
                    } else {
                        $var_footer .= "</div></div>";
                    }
                    $type_header .= '<div id="collapseTypes" class="panel-collapse collapse">
                                            <div class="panel-body">';
                    if (sizeof($type_results) > 0) {
                        $type_header .= '<table class="table table-striped table-bordered">
                                        <thead>
                                        <th align=middle>' . Language::labelSearchName() . '</th>' . '</thead>
                                        <tbody data-link="row" class="rowlink">';
                        $type_footer .= "</tbody></table></div></div>";
                    } else {
                        $type_footer .= "</div></div>";
                    }
                    $survey_header .= '<div id="collapseSurvey" class="panel-collapse collapse">
                                            <div class="panel-body">';
                    if (sizeof($survey_results) > 0) {
                        $survey_header .= '<table class="table table-striped table-bordered">
                                        <thead>
                                        <th align=middle>' . Language::labelSearchName() . '</th>' . '</thead>
                                        <tbody data-link="row" class="rowlink">';
                        $survey_footer .= "</tbody></table></div></div>";
                    } else {
                        $survey_footer .= "</div></div>";
                    }
                    $group_header .= '<div id="collapseGroups" class="panel-collapse collapse">
                                            <div class="panel-body">';
                    if (sizeof($group_results) > 0) {
                        $group_header .= '<table class="table table-striped table-bordered">
                                        <thead>
                                        <th align=middle>' . Language::labelSearchName() . '</th>' . '</thead>
                                        <tbody data-link="row" class="rowlink">';
                        $group_footer .= "</tbody></table></div></div>";
                    } else {
                        $group_footer .= "</div></div>";
                    }
                    $section_header .= '<div id="collapseSections" class="panel-collapse collapse">
                                            <div class="panel-body">';
                    if (sizeof($section_results) > 0) {
                        $section_header .= '<table class="table table-striped table-bordered">
                                        <thead>
                                        <th align=middle>' . Language::labelSearchName() . '</th>' . '</thead>
                                        <tbody data-link="row" class="rowlink">';
                        $section_footer .= "</tbody></table></div></div>";
                    } else {
                        $section_footer .= "</div></div>";
                    }
                    /* search in routing */
                    $routing_results = array();
                    $routing_header .= '<div id="collapseRouting" class="panel-collapse collapse">
                                            <div class="panel-body">';
                    if ($db->getNumberOfRows($res1) > 0) {
                        while ($row = $db->getRow($res1)) {
                            $section = $survey->getSection($row["seid"]);
                            $routing_results[] = "<tr>\n                                                    <td><a class='searchlink' href='" . setSessionParams(array("page" => "sysadmin.survey.section", "suid" => $_SESSION['SUID'], "seid" => $row["seid"], "routingline" => $row["rgid"])) . "'>" . $section->getName() . " at " . Language::labelSearchLine() . " " . $row["rgid"] . "</a></td>\n                                                  </tr>";
                        }
                    }
                    if (sizeof($routing_results) > 0) {
                        $routing_header .= '<table class="table table-striped table-bordered">
                                        <thead>
                                        <th align=middle>' . Language::labelSearchSection() . ' at ' . Language::labelSearchLine() . '</th> 
                                        </thead>
                                        <tbody data-link="row" class="rowlink">';
                        $routing_footer .= "</tbody></table></div></div>";
                    } else {
                        $routing_footer .= "</div></div>";
                    }
                    if (sizeof($var_results) > 0) {
                        $varstring = $var_header . implode("", $var_results) . $var_footer;
                    } else {
                        $varstring = $var_header . $this->displayWarning(Language::messageSearchNoResults()) . $var_footer;
                    }
                    if (sizeof($type_results) > 0) {
                        $typestring = $type_header . implode("", $type_results) . $type_footer;
                    } else {
                        $typestring = $type_header . $this->displayWarning(Language::messageSearchNoResults()) . $type_footer;
                    }
                    if (sizeof($group_results) > 0) {
                        $groupstring = $group_header . implode("", $group_results) . $group_footer;
                    } else {
                        $groupstring = $group_header . $this->displayWarning(Language::messageSearchNoResults()) . $group_footer;
                    }
                    if (sizeof($section_results) > 0) {
                        $sectionstring = $section_header . implode("", $section_results) . $section_footer;
                    } else {
                        $sectionstring = $section_header . $this->displayWarning(Language::messageSearchNoResults()) . $section_footer;
                    }
                    if (sizeof($survey_results) > 0) {
                        $surveystring = $survey_header . implode("", $survey_results) . $survey_footer;
                    } else {
                        $surveystring = $survey_header . $this->displayWarning(Language::messageSearchNoResults()) . $survey_footer;
                    }
                    if (sizeof($routing_results) > 0) {
                        $routingstring = $routing_header . implode("", $routing_results) . $routing_footer;
                    } else {
                        $routingstring = $routing_header . $this->displayWarning(Language::messageSearchNoResults()) . $routing_footer;
                    }
                    $returnStr .= '<div id="search">
                                    <div class="panel-group" id="accordion">
                                       <div class="panel panel-default">
                                          <div class="panel-heading">
                                            <h4 class="panel-title">
                                              <a data-toggle="collapse" data-target="#collapseVariables">
                                                ' . Language::labelSearchVariables() . '(' . sizeof($var_results) . ')
                                              </a>
                                            </h4>
                                          </div> ' . $varstring . '</div>

                                       <div class="panel panel-default">
                                          <div class="panel-heading">
                                            <h4 class="panel-title">
                                              <a data-toggle="collapse" data-target="#collapseSurvey">
                                                ' . Language::labelSearchSurvey() . '(' . sizeof($survey_results) . ')
                                              </a>
                                            </h4>
                                          </div> ' . $surveystring . '</div>
                                              
                                        <div class="panel panel-default">
                                          <div class="panel-heading">
                                            <h4 class="panel-title">
                                              <a data-toggle="collapse" data-target="#collapseRouting">
                                                ' . Language::labelSearchRouting() . '(' . sizeof($routing_results) . ')
                                              </a>
                                            </h4>
                                          </div> ' . $routingstring . '</div>  

                                      <div class="panel panel-default">
                                          <div class="panel-heading">
                                            <h4 class="panel-title">
                                              <a data-toggle="collapse" data-target="#collapseTypes">
                                                ' . Language::labelSearchTypes() . '(' . sizeof($type_results) . ')
                                              </a>
                                            </h4>
                                          </div> ' . $typestring . '</div>

                                      <div class="panel panel-default">
                                          <div class="panel-heading">
                                            <h4 class="panel-title">
                                              <a data-toggle="collapse" data-target="#collapseGroups">
                                                ' . Language::labelSearchGroups() . '(' . sizeof($group_results) . ')
                                              </a>
                                            </h4>
                                          </div> ' . $groupstring . '</div>

                                      <div class="panel panel-default">
                                          <div class="panel-heading">
                                            <h4 class="panel-title">
                                              <a data-toggle="collapse" data-target="#collapseSections">
                                                ' . Language::labelSearchSections() . '(' . sizeof($section_results) . ')
                                              </a>
                                            </h4>
                                          </div> ' . $sectionstring . '</div>';
                    /* accordion end div */
                    $returnStr .= '</div>';
                    /* end search div */
                    $returnStr .= "</div>";
                }
            } else {
                $returnStr .= $this->displayWarning(Language::messageSearchNoResults());
            }
        }
        return $returnStr;
    }
Ejemplo n.º 8
0
Archivo: cats.php Proyecto: r2git/icms1
function applet_cats()
{
    $inCore = cmsCore::getInstance();
    $inDB = cmsDatabase::getInstance();
    global $_LANG;
    $GLOBALS['cp_page_title'] = $_LANG['AD_ARTICLES'];
    cpAddPathway($_LANG['AD_ARTICLES'], 'index.php?view=tree');
    cmsCore::loadModel('content');
    $model = new cms_model_content();
    $do = cmsCore::request('do', 'str', 'add');
    $id = cmsCore::request('id', 'int', -1);
    define('IS_BILLING', $inCore->isComponentInstalled('billing'));
    if (IS_BILLING) {
        cmsCore::loadClass('billing');
    }
    if ($do == 'delete') {
        $is_with_content = cmsCore::inRequest('content');
        $model->deleteCategory($id, $is_with_content);
        cmsCore::addSessionMessage($is_with_content ? $_LANG['AD_CATEGORY_REMOVED'] : $_LANG['AD_CATEGORY_REMOVED_NOT_ARTICLE'], 'success');
        cmsCore::redirect('?view=tree');
    }
    if ($do == 'update') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        $category['id'] = cmsCore::request('id', 'int', 0);
        $category['title'] = cmsCore::request('title', 'str', $_LANG['AD_SECTION_UNTITLED']);
        $category['parent_id'] = cmsCore::request('parent_id', 'int');
        $category['description'] = cmsCore::request('description', 'html');
        $category['description'] = $inDB->escape_string($category['description']);
        $category['published'] = cmsCore::request('published', 'int', 0);
        $category['showdate'] = cmsCore::request('showdate', 'int', 0);
        $category['showcomm'] = cmsCore::request('showcomm', 'int', 0);
        $category['orderby'] = cmsCore::request('orderby', 'str');
        $category['orderto'] = cmsCore::request('orderto', 'str');
        $category['modgrp_id'] = cmsCore::request('modgrp_id', 'int', 0);
        $category['maxcols'] = cmsCore::request('maxcols', 'int', 0);
        $category['showtags'] = cmsCore::request('showtags', 'int', 0);
        $category['showrss'] = cmsCore::request('showrss', 'int', 0);
        $category['showdesc'] = cmsCore::request('showdesc', 'int', 0);
        $category['is_public'] = cmsCore::request('is_public', 'int', 0);
        $category['url'] = cmsCore::request('url', 'str');
        $category['pagetitle'] = cmsCore::request('pagetitle', 'str', '');
        $category['meta_desc'] = cmsCore::request('meta_desc', 'str');
        $category['meta_keys'] = cmsCore::request('meta_keys', 'str');
        if ($category['url']) {
            $category['url'] = cmsCore::strToURL($category['url'], $model->config['is_url_cyrillic']);
        }
        $category['tpl'] = cmsCore::request('tpl', 'str', 'com_content_view.tpl');
        $category['cost'] = cmsCore::request('cost', 'str', '');
        if (!is_numeric($category['cost'])) {
            $category['cost'] = '';
        }
        $album = array();
        $album['id'] = cmsCore::request('album_id', 'int', 0);
        $album['header'] = cmsCore::request('album_header', 'str', '');
        $album['orderby'] = cmsCore::request('album_orderby', 'str', '');
        $album['orderto'] = cmsCore::request('album_orderto', 'str', '');
        $album['maxcols'] = cmsCore::request('album_maxcols', 'int', 0);
        $album['max'] = cmsCore::request('album_max', 'int', 0);
        if ($album['id']) {
            $category['photoalbum'] = serialize($album);
        } else {
            $category['photoalbum'] = '';
        }
        // получаем старую категорию
        $old = $inDB->get_fields('cms_category', "id='{$category['id']}'", '*');
        if (!$old) {
            cmsCore::error404();
        }
        // если сменили категорию
        if ($old['parent_id'] != $category['parent_id']) {
            // перемещаем ее в дереве
            $inCore->nestedSetsInit('cms_category')->MoveNode($category['id'], $category['parent_id']);
            // обновляем сеолинки категорий
            $inDB->updateNsCategorySeoLink('cms_category', $category['id'], $model->config['is_url_cyrillic']);
            // Обновляем ссылки меню на категории
            $model->updateCatMenu();
            // обновляем сеолинки всех вложенных статей
            $model->updateArticlesSeoLink($category['id']);
            cmsCore::addSessionMessage($_LANG['AD_CATEGORY_NEW_URL'], 'info');
        }
        $inDB->update('cms_category', $category, $category['id']);
        // если пришел запрос на обновление ссылок
        // и категория не менялась - если менялась, мы выше все обновили
        if (cmsCore::inRequest('update_seolink') && $old['parent_id'] == $category['parent_id']) {
            // обновляем сеолинки категорий
            $inDB->updateNsCategorySeoLink('cms_category', $category['id'], $model->config['is_url_cyrillic']);
            // Обновляем ссылки меню на категории
            $model->updateCatMenu();
            // обновляем сеолинки всех вложенных статей
            $model->updateArticlesSeoLink($category['id']);
            cmsCore::addSessionMessage($_LANG['AD_SECTION_AND_ARTICLES_NEW_URL'], 'info');
        }
        if (!cmsCore::request('is_access', 'int', 0)) {
            $showfor = $_REQUEST['showfor'];
            cmsCore::setAccess($category['id'], $showfor, 'category');
        } else {
            cmsCore::clearAccess($category['id'], 'category');
        }
        cmsCore::addSessionMessage($_LANG['AD_CATEGORY_SAVED'], 'success');
        if (!isset($_SESSION['editlist']) || @sizeof($_SESSION['editlist']) == 0) {
            cmsCore::redirect('?view=tree&cat_id=' . $category['id']);
        } else {
            cmsCore::redirect('?view=tree');
        }
    }
    if ($do == 'submit') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        $category['title'] = cmsCore::request('title', 'str', $_LANG['AD_CATEGORY_UNTITLED']);
        $category['url'] = cmsCore::request('url', 'str');
        if ($category['url']) {
            $category['url'] = cmsCore::strToURL($category['url']);
        }
        $category['parent_id'] = cmsCore::request('parent_id', 'int');
        $category['description'] = cmsCore::request('description', 'html');
        $category['description'] = $inDB->escape_string($category['description']);
        $category['published'] = cmsCore::request('published', 'int', 0);
        $category['showdate'] = cmsCore::request('showdate', 'int', 0);
        $category['showcomm'] = cmsCore::request('showcomm', 'int', 0);
        $category['orderby'] = cmsCore::request('orderby', 'str');
        $category['orderto'] = cmsCore::request('orderto', 'str');
        $category['modgrp_id'] = cmsCore::request('modgrp_id', 'int', 0);
        $category['maxcols'] = cmsCore::request('maxcols', 'int', 0);
        $category['showtags'] = cmsCore::request('showtags', 'int', 0);
        $category['showrss'] = cmsCore::request('showrss', 'int', 0);
        $category['showdesc'] = cmsCore::request('showdesc', 'int', 0);
        $category['is_public'] = cmsCore::request('is_public', 'int', 0);
        $category['tpl'] = cmsCore::request('tpl', 'str', 'com_content_view.tpl');
        $category['pagetitle'] = cmsCore::request('pagetitle', 'str', '');
        $category['meta_desc'] = cmsCore::request('meta_desc', 'str');
        $category['meta_keys'] = cmsCore::request('meta_keys', 'str');
        $category['cost'] = cmsCore::request('cost', 'str', 0);
        if (!is_numeric($category['cost'])) {
            $category['cost'] = '';
        }
        $album = array();
        $album['id'] = cmsCore::request('album_id', 'int', 0);
        $album['header'] = cmsCore::request('album_header', 'str', '');
        $album['orderby'] = cmsCore::request('album_orderby', 'str', '');
        $album['orderto'] = cmsCore::request('album_orderto', 'str', '');
        $album['maxcols'] = cmsCore::request('album_maxcols', 'int', 0);
        $album['max'] = cmsCore::request('album_max', 'int', 0);
        if ($album['id']) {
            $category['photoalbum'] = serialize($album);
        } else {
            $category['photoalbum'] = '';
        }
        $ns = $inCore->nestedSetsInit('cms_category');
        $category['id'] = $ns->AddNode($category['parent_id']);
        $category['seolink'] = cmsCore::generateCatSeoLink($category, 'cms_category', $model->config['is_url_cyrillic']);
        if ($category['id']) {
            $inDB->update('cms_category', $category, $category['id']);
            if (!cmsCore::request('is_access', 'int', 0)) {
                $showfor = $_REQUEST['showfor'];
                cmsCore::setAccess($category['id'], $showfor, 'category');
            } else {
                cmsCore::clearAccess($category['id'], 'category');
            }
        }
        $inmenu = cmsCore::request('createmenu', 'str', '');
        if ($inmenu) {
            createMenuItem($inmenu, $category['id'], $category['title']);
        }
        cmsCore::addSessionMessage($_LANG['AD_CATEGORY_ADD'], 'success');
        cmsCore::redirect('?view=tree');
    }
    if ($do == 'add' || $do == 'edit') {
        require '../includes/jwtabs.php';
        $GLOBALS['cp_page_head'][] = jwHeader();
        $toolmenu = array();
        $toolmenu[0]['icon'] = 'save.gif';
        $toolmenu[0]['title'] = $_LANG['SAVE'];
        $toolmenu[0]['link'] = 'javascript:document.addform.submit();';
        $toolmenu[1]['icon'] = 'cancel.gif';
        $toolmenu[1]['title'] = $_LANG['CANCEL'];
        $toolmenu[1]['link'] = 'javascript:history.go(-1);';
        cpToolMenu($toolmenu);
        $menu_list = cpGetList('menu');
        if ($do == 'add') {
            echo '<h3>' . $_LANG['AD_CREATE_SECTION'] . '</h3>';
            cpAddPathway($_LANG['AD_CREATE_SECTION'], 'index.php?view=cats&do=add');
            $mod['tpl'] = 'com_content_view.tpl';
        } else {
            if (isset($_REQUEST['multiple'])) {
                if (isset($_REQUEST['item'])) {
                    $_SESSION['editlist'] = $_REQUEST['item'];
                } else {
                    echo '<p class="error">' . $_LANG['AD_NO_SELECT_OBJECTS'] . '</p>';
                    return;
                }
            }
            $ostatok = '';
            if (isset($_SESSION['editlist'])) {
                $id = array_shift($_SESSION['editlist']);
                if (sizeof($_SESSION['editlist']) == 0) {
                    unset($_SESSION['editlist']);
                } else {
                    $ostatok = '(' . $_LANG['AD_NEXT_IN'] . sizeof($_SESSION['editlist']) . ')';
                }
            } else {
                $id = (int) $_REQUEST['id'];
            }
            $sql = "SELECT * FROM cms_category WHERE id = {$id} LIMIT 1";
            $result = $inDB->query($sql);
            if ($inDB->num_rows($result)) {
                $mod = $inDB->fetch_assoc($result);
                if (@$mod['photoalbum']) {
                    $mod['photoalbum'] = unserialize($mod['photoalbum']);
                }
            }
            echo '<h3>' . $_LANG['AD_EDIT_SECTION'] . $ostatok . '</h3>';
            cpAddPathway($mod['title'], 'index.php?view=cats&do=edit&id=' . $mod['id']);
        }
        ?>

    <form id="addform" name="addform" method="post" action="index.php">
        <input type="hidden" name="csrf_token" value="<?php 
        echo cmsUser::getCsrfToken();
        ?>
" />
        <input type="hidden" name="view" value="cats" />
        <table class="proptable" width="100%" cellpadding="5" cellspacing="2">
            <tr>

                <!-- главная ячейка -->
                <td valign="top">
                    <table border="0" cellpadding="0" cellspacing="5" width="100%">
                      <tbody>
                        <tr>
                          <td>
                            <strong><?php 
        echo $_LANG['AD_TITLE_PARTITION'];
        ?>
</strong> <?php 
        printLangPanel('content_category', @$mod['id'], 'title');
        ?>
                          </td>
                          <td width="190" style="padding-left:6px">
                            <strong><?php 
        echo $_LANG['AD_TEMPLATE_PARTITION'];
        ?>
</strong>
                          </td>
                        </tr>
                        <tr>
                          <td>
                        <input name="title" type="text" id="title" style="width:100%" value="<?php 
        echo htmlspecialchars($mod['title']);
        ?>
" />
                          </td>
                          <td style="padding-left:6px">
                            <input name="tpl" type="text" style="width:98%" value="<?php 
        echo @$mod['tpl'];
        ?>
" />
                          </td>
                        </tr>
                      </tbody>
                    </table>
                    <div><strong><?php 
        echo $_LANG['AD_PARENT_PARTITION'];
        ?>
</strong></div>
                    <div>
                        <div class="parent_notice" style="color:red;margin:4px 0px;display:none"><?php 
        echo $_LANG['AD_ANOTHER_PARENT'];
        ?>
</div>
                        <select name="parent_id" size="12" id="parent_id" style="width:100%" onchange="if($('option:selected',this).data('nsleft')>='<?php 
        echo $mod['NSLeft'];
        ?>
' && $('option:selected',this).data('nsright')<='<?php 
        echo $mod['NSRight'];
        ?>
'){ $('.parent_notice').show();$('#add_mod').prop('disabled', true); } else { $('.parent_notice').hide();$('#add_mod').prop('disabled', false); }">
                            <?php 
        $rootid = $inDB->getNsRootCatId('cms_category');
        ?>
                            <option value="<?php 
        echo $rootid;
        ?>
" <?php 
        if (@$mod['parent_id'] == $rootid || !isset($mod['parent_id'])) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_SECTION'];
        ?>
</option>
                            <?php 
        if (isset($mod['parent_id'])) {
            echo $inCore->getListItemsNS('cms_category', $mod['parent_id']);
        } else {
            echo $inCore->getListItemsNS('cms_category');
        }
        ?>
                        </select>
                    </div>

                    <div><strong><?php 
        echo $_LANG['AD_SECTION_DESCRIPT'];
        ?>
</strong> <?php 
        printLangPanel('content_category', @$mod['id'], 'description');
        ?>
</div>
                    <div>
                        <?php 
        $inCore->insertEditor('description', $mod['description'], '250', '100%');
        ?>
                    </div>

                </td>

                <!-- боковая -->
                <td valign="top" width="350" style="background:#ECECEC;">

                    <?php 
        ob_start();
        ?>

                    {tab=<?php 
        echo $_LANG['AD_TAB_PUBLISH'];
        ?>
}

                    <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist">
                        <tr>
                            <td width="20"><input type="checkbox" name="published" id="published" value="1" <?php 
        if ($mod['published'] || $do == 'add') {
            echo 'checked="checked"';
        }
        ?>
/></td>
                            <td><label for="published"><strong><?php 
        echo $_LANG['AD_PUBLIC_SECTION'];
        ?>
</strong></label></td>
                        </tr>
                    </table>

					<div style=" <?php 
        if ($do == 'edit') {
            ?>
display:none;<?php 
        }
        ?>
" class="url_cat">
                        <div style="margin-top:15px">
                            <strong><?php 
        echo $_LANG['AD_SECTION_URL'];
        ?>
</strong><br/>
                            <div style="color:gray"><?php 
        echo $_LANG['AD_FROM_TITLE'];
        ?>
</div>
                        </div>
                        <div>
                            <input type="text" name="url" value="<?php 
        echo $mod['url'];
        ?>
" style="width:99%"/>
                        </div>
                    </div>

					<?php 
        if ($do == 'edit') {
            ?>
                        <table width="100%" cellpadding="0" cellspacing="0" border="0" style="margin-top:15px">
                            <tr>
                                <td width="20"><input type="checkbox" name="update_seolink" id="update_seolink" value="1" onclick="$('.url_cat').slideToggle('fast');" /></td>
                                <td><label for="update_seolink"><strong><?php 
            echo $_LANG['AD_NEW_LINK'];
            ?>
</strong></label></td>
                            </tr>
                        </table>
                        <div class="url_cat" style="display:none;"><strong style="color:#F00;"><?php 
            echo $_LANG['ATTENTION'];
            ?>
:</strong> <?php 
            echo $_LANG['AD_NO_LINKS'];
            ?>
</div>
                    <?php 
        }
        ?>

                    <div style="margin-top:20px"><strong><?php 
        echo $_LANG['AD_SORT_ARTICLES'];
        ?>
</strong></div>
                    <div>
                        <select name="orderby" id="orderby" style="width:100%">
                            <option value="pubdate" <?php 
        if (@$mod['orderby'] == 'pubdate') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_BY_CALENDAR'];
        ?>
</option>
                            <option value="title" <?php 
        if (@$mod['orderby'] == 'title') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_BY_TITLE'];
        ?>
</option>
                            <option value="ordering" <?php 
        if (@$mod['orderby'] == 'ordering') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_BY_ORDER'];
        ?>
</option>
                            <option value="hits" <?php 
        if (@$mod['orderby'] == 'hits') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_BY_VIEWS'];
        ?>
</option>
                        </select>
                        <select name="orderto" id="orderto" style="width:100%">
                            <option value="ASC" <?php 
        if (@$mod['orderto'] == 'ASC') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_BY_INCREMENT'];
        ?>
</option>
                            <option value="DESC" <?php 
        if (@$mod['orderto'] == 'DESC') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_BY_DECREMENT'];
        ?>
</option>
                        </select>
                    </div>

                    <div style="margin-top:20px"><strong><?php 
        echo $_LANG['AD_HOW_MANY_COLUMNS'];
        ?>
</strong></div>
                    <div>
                        <?php 
        if (!isset($mod['maxcols'])) {
            $mod['maxcols'] = 1;
        }
        ?>
                        <input class="uispin" name="maxcols" type="text" id="maxcols" style="width:99%" value="<?php 
        echo @$mod['maxcols'];
        ?>
" />
                    </div>

                    <div style="margin-top:20px"><strong><?php 
        echo $_LANG['AD_HOW_PUBLISH_SET'];
        ?>
</strong></div>
                    <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist">
                        <tr>
                            <td width="20"><input type="checkbox" name="showdesc" id="showdesc" value="1" <?php 
        if ($mod['showdesc'] || $do == 'add') {
            echo 'checked="checked"';
        }
        ?>
/></td>
                            <td><label for="showdesc"><?php 
        echo $_LANG['AD_PREVIEW'];
        ?>
</label></td>
                        </tr>
                        <tr>
                            <td width="20"><input type="checkbox" name="showdate" id="showdate" value="1" <?php 
        if ($mod['showdate'] || $do == 'add') {
            echo 'checked="checked"';
        }
        ?>
/></td>
                            <td><label for="showdate"><?php 
        echo $_LANG['AD_CALENDAR_VIEW'];
        ?>
</label></td>
                        </tr>
                        <tr>
                            <td width="20"><input type="checkbox" name="showcomm" id="showcomm" value="1" <?php 
        if ($mod['showcomm'] || $do == 'add') {
            echo 'checked="checked"';
        }
        ?>
/></td>
                            <td><label for="showcomm"><?php 
        echo $_LANG['AD_HOW_MANY_COMENTS'];
        ?>
</label></td>
                        </tr>
                        <tr>
                            <td width="20"><input type="checkbox" name="showtags" id="showtags" value="1" <?php 
        if ($mod['showtags'] || $do == 'add') {
            echo 'checked="checked"';
        }
        ?>
/></td>
                            <td><label for="showtags"><?php 
        echo $_LANG['AD_HOW_MANY_TAGS'];
        ?>
</label></td>
                        </tr>
                        <tr>
                            <td width="20"><input type="checkbox" name="showrss" id="showrss" value="1" <?php 
        if ($mod['showrss'] || $do == 'add') {
            echo 'checked="checked"';
        }
        ?>
/></td>
                            <td><label for="showrss"><?php 
        echo $_LANG['AD_RSS_VIEW'];
        ?>
</label></td>
                        </tr>
                    </table>

                    <?php 
        if ($do == 'add') {
            ?>
                        <div style="margin-top:25px">
                            <strong><?php 
            echo $_LANG['AD_CREATE_LINK'];
            ?>
</strong>
                        </div>
                        <div>
                            <select name="createmenu" id="createmenu" style="width:99%">
                                <option value="0" selected="selected"><?php 
            echo $_LANG['AD_DONT_CREATE'];
            ?>
</option>
                            <?php 
            foreach ($menu_list as $menu) {
                ?>
                                <option value="<?php 
                echo $menu['id'];
                ?>
">
                                    <?php 
                echo $menu['title'];
                ?>
                                </option>
                            <?php 
            }
            ?>
                            </select>
                        </div>
                    <?php 
        }
        ?>

                    {tab=<?php 
        echo $_LANG['AD_EDITORS'];
        ?>
}

                        <div style="margin-top:10px">
                            <strong><?php 
        echo $_LANG['AD_USERS_ARTICLES'];
        ?>
</strong><br/>
                            <span class="hinttext"><?php 
        echo $_LANG['AD_IF_SWITCH'];
        ?>
</span>
                        </div>
                        <div>
                            <select name="is_public" style="width:100%">
                                <option value="0" <?php 
        if (!$mod['is_public']) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['NO'];
        ?>
</option>
                                <option value="1" <?php 
        if ($mod['is_public']) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['YES'];
        ?>
</option>
                            </select>
                        </div>
                        <?php 
        if (IS_BILLING) {
            ?>
                            <div style="margin-top:15px">
                                <strong><?php 
            echo $_LANG['AD_COST_ARTICLES_ADD'];
            ?>
</strong><br/>
                                <div style="color:gray"><?php 
            echo $_LANG['AD_COST_ARTICLES_BY_DEFAULT'];
            ?>
</div>
                            </div>
                            <div>
                                <input type="text" name="cost" value="<?php 
            echo $mod['cost'];
            ?>
" style="width:50px"/><?php 
            echo $_LANG['BILLING_POINT10'];
            ?>
                            </div>
                        <?php 
        }
        ?>
                        <div style="margin-top:20px">
                            <strong><?php 
        echo $_LANG['AD_EDITORS_SECTION'];
        ?>
</strong><br/>
                            <span class="hinttext"><?php 
        echo $_LANG['AD_USERS_CAN_ADMIN'];
        ?>
</span>
                        </div>
                        <div>
                            <select name="modgrp_id" id="modgrp_id" style="width:100%">
                                <option value="0" <?php 
        if (!isset($mod['modgrp_id']) || @$mod['modgrp_id'] == 0) {
            echo 'selected';
        }
        ?>
><?php 
        echo $_LANG['AD_ONLY_ADMINS'];
        ?>
</option>
                                <?php 
        if (@$mod['modgrp_id']) {
            echo $inCore->getListItems('cms_user_groups', $mod['modgrp_id'], 'id', 'ASC', 'is_admin = 0');
        } else {
            echo $inCore->getListItems('cms_user_groups', 0, 'id', 'ASC', 'is_admin = 0');
        }
        ?>
                            </select>
                        </div>

                    {tab=<?php 
        echo $_LANG['AD_FOTO'];
        ?>
}

                        <div style="margin-top:10px">
                            <strong><?php 
        echo $_LANG['AD_PHOTOALBUM_CONNECT'];
        ?>
</strong><br/>
                            <span class="hinttext"><?php 
        echo $_LANG['AD_PHOTO_BY_ARTICLES'];
        ?>
</span>
                        </div>
                        <div>
                            <select name="album_id" id="album_id" style="width:100%" onchange="choosePhotoAlbum()">
                                <option value="0" <?php 
        if (!isset($mod['photoalbum']['id']) || !@$mod['photoalbum']['id']) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_DONT_CONNECT'];
        ?>
</option>
                                <?php 
        //FIND ROOT
        if (isset($mod['photoalbum']['id'])) {
            echo $inCore->getListItemsNS('cms_photo_albums', $mod['photoalbum']['id']);
        } else {
            echo $inCore->getListItemsNS('cms_photo_albums');
        }
        ?>
                            </select>
                        </div>
						<div id="con_photoalbum" <?php 
        if (!isset($mod['photoalbum']['id']) || !$mod['photoalbum']['id']) {
            echo 'style="display:none;"';
        }
        ?>
>
                            <div style="margin-top:20px">
                                <strong><?php 
        echo $_LANG['AD_TITLE'];
        ?>
</strong><br/>
                                <span class="hinttext"><?php 
        echo $_LANG['AD_OVER_PHOTOS'];
        ?>
</span>
                            </div>
                            <div>
                                <input name="album_header" type="text" id="album_header" style="width:99%" value="<?php 
        echo @$mod['photoalbum']['header'];
        ?>
" />
                            </div>

                            <div style="margin-top:20px">
                                <strong><?php 
        echo $_LANG['AD_PHOTOS_SORT'];
        ?>
</strong>
                            </div>
                            <div>
                                <select name="album_orderby" id="album_orderby" style="width:100%">
                                    <option value="title" <?php 
        if (@$mod['photoalbum']['orderby'] == 'title') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_BY_ALPHABET'];
        ?>
</option>
                                    <option value="pubdate" <?php 
        if (@$mod['photoalbum']['orderby'] == 'pubdate') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_BY_CALENDAR'];
        ?>
</option>
                                    <option value="rating" <?php 
        if (@$mod['photoalbum']['orderby'] == 'rating') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_BY_RATING'];
        ?>
</option>
                                    <option value="hits" <?php 
        if (@$mod['photoalbum']['orderby'] == 'hits') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_BY_VIEWS'];
        ?>
</option>
                                </select>
                                <select name="album_orderto" id="album_orderto" style="width:100%">
                                    <option value="desc" <?php 
        if (@$mod['photoalbum']['orderto'] == 'desc') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_BY_DECREMENT'];
        ?>
</option>
                                    <option value="asc" <?php 
        if (@$mod['photoalbum']['orderto'] == 'asc') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_BY_INCREMENT'];
        ?>
</option>
                                </select>
                            </div>

                            <div style="margin-top:20px">
                                <strong><?php 
        echo $_LANG['AD_HOW_MANY_COLUMNS'];
        ?>
</strong>
                            </div>
                            <div>
                                <?php 
        if (!isset($mod['photoalbum']['maxcols'])) {
            $mod['photoalbum']['maxcols'] = 2;
        }
        ?>
                                <input name="album_maxcols" type="text" id="album_maxcols" style="width:99%" value="<?php 
        echo @$mod['photoalbum']['maxcols'];
        ?>
"/>
                            </div>

                            <div style="margin-top:20px">
                                <strong><?php 
        echo $_LANG['AD_HOW_MANY_PHOTO'];
        ?>
</strong>
                            </div>
                            <div>
                                <?php 
        if (!isset($mod['photoalbum']['max'])) {
            $mod['photoalbum']['max'] = 8;
        }
        ?>
                                <input name="album_max" type="text" id="album_max" style="width:99%" value="<?php 
        echo @$mod['photoalbum']['max'];
        ?>
"/>
                            </div>
                       </div>
                        {tab=SEO}

                        <div style="margin-top:5px">
                            <strong><?php 
        echo $_LANG['AD_PAGE_TITLE'];
        ?>
</strong> <?php 
        printLangPanel('content_category', @$mod['id'], 'pagetitle');
        ?>
<br/>
                            <span class="hinttext"><?php 
        echo $_LANG['AD_IF_UNKNOWN_PAGETITLE'];
        ?>
</span>
                        </div>
                        <div>
                            <input name="pagetitle" type="text" id="pagetitle" style="width:99%" value="<?php 
        if (isset($mod['pagetitle'])) {
            echo htmlspecialchars($mod['pagetitle']);
        }
        ?>
" />
                        </div>

                        <div style="margin-top:20px">
                            <strong><?php 
        echo $_LANG['KEYWORDS'];
        ?>
</strong> <?php 
        printLangPanel('content_category', @$mod['id'], 'meta_keys');
        ?>
<br/>
                            <span class="hinttext"><?php 
        echo $_LANG['AD_FROM_COMMA'];
        ?>
</span>
                        </div>
                        <div>
                             <textarea name="meta_keys" style="width:97%" rows="4" id="meta_keys"><?php 
        echo htmlspecialchars($mod['meta_keys']);
        ?>
</textarea>
                        </div>

                        <div style="margin-top:20px">
                            <strong><?php 
        echo $_LANG['DESCRIPTION'];
        ?>
</strong>  <?php 
        printLangPanel('content_category', @$mod['id'], 'meta_desc');
        ?>
<br/>
                            <span class="hinttext"><?php 
        echo $_LANG['AD_LESS_THAN'];
        ?>
</span>
                        </div>
                        <div>
                             <textarea name="meta_desc" style="width:97%" rows="6" id="meta_desc"><?php 
        echo htmlspecialchars($mod['meta_desc']);
        ?>
</textarea>
                        </div>
                      {tab=<?php 
        echo $_LANG['AD_TAB_ACCESS'];
        ?>
}

                      <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist" style="margin-top:5px">
                          <tr>
                              <td width="20">
                                  <?php 
        $sql = "SELECT * FROM cms_user_groups";
        $result = $inDB->query($sql);
        $style = 'disabled="disabled"';
        $public = 'checked="checked"';
        if ($do == 'edit') {
            $sql2 = "SELECT * FROM cms_content_access WHERE content_id = " . $mod['id'] . " AND content_type = 'category'";
            $result2 = $inDB->query($sql2);
            $ord = array();
            if ($inDB->num_rows($result2)) {
                $public = '';
                $style = '';
                while ($r = $inDB->fetch_assoc($result2)) {
                    $ord[] = $r['group_id'];
                }
            }
        }
        ?>
                                  <input name="is_access" type="checkbox" id="is_public" onclick="checkGroupList()" value="1" <?php 
        echo $public;
        ?>
 />
                              </td>
                              <td><label for="is_public"><strong><?php 
        echo $_LANG['AD_SHARE'];
        ?>
</strong></label></td>
                          </tr>
                      </table>
                      <div style="padding:5px">
                          <span class="hinttext">
                              <?php 
        echo $_LANG['AD_IF_NOTED'];
        ?>
                          </span>
                      </div>

                      <div style="margin-top:10px;padding:5px;padding-right:0px;" id="grp">
                          <div>
                              <strong><?php 
        echo $_LANG['AD_GROUPS_VIEW'];
        ?>
</strong><br />
                              <span class="hinttext">
                                  <?php 
        echo $_LANG['AD_SELECT_MULTIPLE_CTRL'];
        ?>
                              </span>
                          </div>
                          <div>
                              <?php 
        echo '<select style="width: 99%" name="showfor[]" id="showin" size="6" multiple="multiple" ' . $style . '>';
        if ($inDB->num_rows($result)) {
            while ($item = $inDB->fetch_assoc($result)) {
                echo '<option value="' . $item['id'] . '"';
                if ($do == 'edit') {
                    if (inArray($ord, $item['id'])) {
                        echo 'selected="selected"';
                    }
                }
                echo '>';
                echo $item['title'] . '</option>';
            }
        }
        echo '</select>';
        ?>
                          </div>
                      </div>

                    {/tabs}

                    <?php 
        echo jwTabs(ob_get_clean());
        ?>

                </td>

            </tr>
        </table>
        <p>
            <input name="add_mod" type="submit" id="add_mod" <?php 
        if ($do == 'add') {
            echo 'value="' . $_LANG['AD_SAVE_SECTION'] . '"';
        } else {
            echo 'value="' . $_LANG['AD_SAVE_SECTION'] . '"';
        }
        ?>
 />
            <input name="back" type="button" id="back" value="<?php 
        echo $_LANG['CANCEL'];
        ?>
" onclick="window.history.back();"/>
            <input name="do" type="hidden" id="do" <?php 
        if ($do == 'add') {
            echo 'value="submit"';
        } else {
            echo 'value="update"';
        }
        ?>
 />
            <?php 
        if ($do == 'edit') {
            echo '<input name="id" type="hidden" value="' . $mod['id'] . '" />';
        }
        ?>
        </p>

    </form>
<script type="text/javascript">
function choosePhotoAlbum(){
	id = $('select[name=album_id]').val();
	if(id != 0){
		$('#con_photoalbum').fadeIn();
	} else {
		$('#con_photoalbum').hide();
	}
}
</script>
<?php 
    }
}
Ejemplo n.º 9
0
 function determineModeLanguage(&$de)
 {
     $user = new User($_SESSION['URID']);
     $modes = $user->getModes(loadvar('survey'));
     $mods = "";
     if (loadvar(DATA_OUTPUT_MODES) == "") {
         $mods = implode("~", $modes);
     } else {
         $ms = loadvar(DATA_OUTPUT_MODES);
         $ms1 = array();
         foreach ($ms as $m) {
             if (inArray($m, $modes)) {
                 $ms1[] = $m;
             }
         }
         $mods = implode("~", $ms1);
     }
     $de->setProperty(DATA_OUTPUT_MODES, $mods);
     $modes = explode("~", $mods);
     $langs = "";
     if (loadvar(DATA_OUTPUT_LANGUAGES) == "") {
         $langs = array();
         foreach ($modes as $m) {
             $langs = explode("~", $user->getLanguages(loadvar('survey'), $m));
         }
         $langs = implode("~", array_unique($langs));
     } else {
         $ls = loadvar(DATA_OUTPUT_LANGUAGES);
         $ls1 = array();
         foreach ($ls as $l) {
             foreach ($modes as $m) {
                 if (inArray($l, explode("~", $user->getLanguages(loadvar('survey'), $m)))) {
                     $ls1[] = $l;
                     break;
                 }
             }
         }
         $langs = implode("~", array_unique($ls1));
     }
     $de->setProperty(DATA_OUTPUT_LANGUAGES, $langs);
 }
Ejemplo n.º 10
0
function applet_menu()
{
    $inCore = cmsCore::getInstance();
    $inDB = cmsDatabase::getInstance();
    global $_LANG;
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/menu', $adminAccess)) {
        cpAccessDenied();
    }
    $GLOBALS['cp_page_title'] = $_LANG['AD_MENU'];
    cpAddPathway($_LANG['AD_MENU'], 'index.php?view=menu');
    $do = cmsCore::request('do', 'str', 'list');
    $id = cmsCore::request('id', 'int', -1);
    if ($do == 'list') {
        $toolmenu[] = array('icon' => 'new.gif', 'title' => $_LANG['AD_MENU_POINT_ADD'], 'link' => '?view=menu&do=add');
        $toolmenu[] = array('icon' => 'newmenu.gif', 'title' => $_LANG['AD_MENU_ADD'], 'link' => '?view=menu&do=addmenu');
        $toolmenu[] = array('icon' => 'edit.gif', 'title' => $_LANG['AD_EDIT_SELECTED'], 'link' => "javascript:checkSel('?view=menu&do=edit&multiple=1');");
        $toolmenu[] = array('icon' => 'delete.gif', 'title' => $_LANG['AD_DELETE_SELECTED'], 'link' => "javascript:checkSel('?view=menu&do=delete&multiple=1');");
        $toolmenu[] = array('icon' => 'show.gif', 'title' => $_LANG['AD_ALLOW_SELECTED'], 'link' => "javascript:checkSel('?view=menu&do=show&multiple=1');");
        $toolmenu[] = array('icon' => 'hide.gif', 'title' => $_LANG['AD_DISALLOW_SELECTED'], 'link' => "javascript:checkSel('?view=menu&do=hide&multiple=1');");
        $toolmenu[] = array('icon' => 'help.gif', 'title' => $_LANG['AD_HELP'], 'link' => '?view=help&topic=menu');
        cpToolMenu($toolmenu);
        $fields[] = array('title' => 'Lt', 'field' => 'NSLeft', 'width' => '30');
        $fields[] = array('title' => $_LANG['TITLE'], 'field' => 'title', 'width' => '', 'link' => '?view=menu&do=edit&id=%id%');
        $fields[] = array('title' => $_LANG['SHOW'], 'field' => 'published', 'width' => '60');
        $fields[] = array('title' => $_LANG['AD_ORDER'], 'field' => 'ordering', 'width' => '100');
        $fields[] = array('title' => $_LANG['AD_LINK'], 'field' => array('linktype', 'linkid', 'link'), 'width' => '240', 'prc' => 'cpMenutypeById');
        $fields[] = array('title' => $_LANG['AD_MENU'], 'field' => 'menu', 'width' => '70', 'filter' => '10', 'filterlist' => cpGetList('menu'), 'prc' => 'list_menu');
        $fields[] = array('title' => $_LANG['TEMPLATE'], 'field' => 'template', 'width' => '70', 'prc' => 'cpTemplateById');
        $actions[] = array('title' => $_LANG['EDIT'], 'icon' => 'edit.gif', 'link' => '?view=menu&do=edit&id=%id%');
        $actions[] = array('title' => $_LANG['DELETE'], 'icon' => 'delete.gif', 'confirm' => $_LANG['AD_MENU_POINT_CONFIRM'], 'link' => '?view=menu&do=delete&id=%id%');
        cpListTable('cms_menu', $fields, $actions, 'parent_id>0', 'NSLeft, ordering');
    } else {
        $toolmenu[] = array('icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:document.addform.submit();');
        $toolmenu[] = array('icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => 'index.php?view=menu');
        cpToolMenu($toolmenu);
    }
    if ($do == 'move_up') {
        $inDB->moveNsCategory('cms_menu', $id, 'up');
        cmsCore::redirectBack();
    }
    if ($do == 'move_down') {
        $inDB->moveNsCategory('cms_menu', $id, 'down');
        cmsCore::redirectBack();
    }
    if ($do == 'show') {
        if (!isset($_REQUEST['item'])) {
            if ($id >= 0) {
                dbShow('cms_menu', $id);
            }
            echo '1';
            exit;
        } else {
            dbShowList('cms_menu', $_REQUEST['item']);
            cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
            cmsCore::redirectBack();
        }
    }
    if ($do == 'hide') {
        if (!isset($_REQUEST['item'])) {
            if ($id >= 0) {
                dbHide('cms_menu', $id);
            }
            echo '1';
            exit;
        } else {
            dbHideList('cms_menu', cmsCore::request('item', 'array_int', array()));
            cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
            cmsCore::redirectBack();
        }
    }
    if ($do == 'delete') {
        if (!isset($_REQUEST['item'])) {
            if ($id >= 0) {
                $inDB->deleteNS('cms_menu', (int) $id);
            }
        } else {
            $items = cmsCore::request('item', 'array_int', array());
            foreach ($items as $item_id) {
                $inDB->deleteNS('cms_menu', $item_id);
            }
        }
        cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
        cmsCore::redirectBack();
    }
    if ($do == 'update') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        $id = cmsCore::request('id', 'int', 0);
        if (!$id) {
            cmsCore::redirectBack();
        }
        $title = cmsCore::request('title', 'str', '');
        $menu = cmsCore::arrayToYaml(cmsCore::request('menu', 'array_str', ''));
        $linktype = cmsCore::request('mode', 'str', '');
        $linkid = cmsCore::request($linktype, 'str', '');
        $link = $inCore->getMenuLink($linktype, $linkid);
        $target = cmsCore::request('target', 'str', '');
        $published = cmsCore::request('published', 'int', 0);
        $template = cmsCore::request('template', 'str', '');
        $iconurl = cmsCore::request('iconurl', 'str', '');
        $parent_id = cmsCore::request('parent_id', 'int', 0);
        $oldparent = cmsCore::request('oldparent', 'int', 0);
        $is_lax = cmsCore::request('is_lax', 'int', 0);
        $css_class = cmsCore::request('css_class', 'str', '');
        $is_public = cmsCore::request('is_public', 'int', '');
        if (!$is_public) {
            $access_list = cmsCore::arrayToYaml(cmsCore::request('allow_group', 'array_int'));
        }
        $ns = $inCore->nestedSetsInit('cms_menu');
        if ($oldparent != $parent_id) {
            $ns->MoveNode($id, $parent_id);
        }
        $sql = "UPDATE cms_menu\n                SET title='{$title}',\n                    css_class='{$css_class}',\n                    menu='{$menu}',\n                    link='{$link}',\n                    linktype='{$linktype}',\n                    linkid='{$linkid}',\n                    target='{$target}',\n                    published='{$published}',\n                    template='{$template}',\n                    access_list='{$access_list}',\n                    is_lax='{$is_lax}',\n                    iconurl='{$iconurl}'\n                WHERE id = '{$id}'\n                LIMIT 1";
        $inDB->query($sql);
        cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
        if (!isset($_SESSION['editlist']) || @sizeof($_SESSION['editlist']) == 0) {
            cmsCore::redirect('?view=menu');
        } else {
            cmsCore::redirect('?view=menu&do=edit');
        }
    }
    if ($do == 'submit') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        $title = cmsCore::request('title', 'str', '');
        $menu = cmsCore::arrayToYaml(cmsCore::request('menu', 'array_str', ''));
        $linktype = cmsCore::request('mode', 'str', '');
        $linkid = cmsCore::request($linktype, 'str', '');
        $link = $inCore->getMenuLink($linktype, $linkid);
        $target = cmsCore::request('target', 'str', '');
        $published = cmsCore::request('published', 'int', 0);
        $template = cmsCore::request('template', 'str', '');
        $iconurl = cmsCore::request('iconurl', 'str', '');
        $parent_id = cmsCore::request('parent_id', 'int', 0);
        $css_class = cmsCore::request('css_class', 'str', '');
        $is_public = cmsCore::request('is_public', 'int', '');
        $is_lax = cmsCore::request('is_lax', 'int', 0);
        if (!$is_public) {
            $access_list = cmsCore::arrayToYaml(cmsCore::request('allow_group', 'array_int'));
        }
        $ns = $inCore->nestedSetsInit('cms_menu');
        $myid = $ns->AddNode($parent_id);
        $sql = "UPDATE cms_menu\n\t\t\t\tSET menu='{$menu}',\n\t\t\t\t\ttitle='{$title}',\n                    css_class='{$css_class}',\n\t\t\t\t\tlink='{$link}',\n\t\t\t\t\tlinktype='{$linktype}',\n\t\t\t\t\tlinkid='{$linkid}',\n\t\t\t\t\ttarget='{$target}',\n\t\t\t\t\tpublished='{$published}',\n\t\t\t\t\ttemplate='{$template}',\n\t\t\t\t\taccess_list='{$access_list}',\n\t\t\t\t\tis_lax='{$is_lax}',\n\t\t\t\t\ticonurl='{$iconurl}'\n\t\t\t\tWHERE id = '{$myid}'";
        $inDB->query($sql);
        cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
        cmsCore::redirect('?view=menu');
    }
    if ($do == 'submitmenu') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        $sql = "SELECT ordering as max_o FROM cms_modules ORDER BY ordering DESC LIMIT 1";
        $result = $inDB->query($sql);
        $row = $inDB->fetch_assoc($result);
        $maxorder = $row['max_o'] + 1;
        $menu = cmsCore::request('menu', 'str', '');
        $title = cmsCore::request('title', 'str', '');
        $position = cmsCore::request('position', 'str', '');
        $published = cmsCore::request('published', 'int', 0);
        $css_prefix = cmsCore::request('css_prefix', 'str', '');
        $is_public = cmsCore::request('is_public', 'int', '');
        if (!$is_public) {
            $access_list = $inCore->arrayToYaml(cmsCore::request('allow_group', 'array_int'));
        }
        $cfg['menu'] = $menu;
        $cfg_str = cmsCore::arrayToYaml($cfg);
        $sql = "INSERT INTO cms_modules (position, name, title, is_external, content, ordering, showtitle, published, user, config, css_prefix, access_list)\n                VALUES ('{$position}', '{$_LANG['AD_MENU']}', '{$title}', 1, 'mod_menu', {$maxorder}, 1, {$published}, 0, '{$cfg_str}', '{$css_prefix}', '{$access_list}')";
        $inDB->query($sql);
        $newid = $inDB->get_last_id('cms_modules');
        cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
        cmsCore::redirect('?view=modules&do=edit&id=' . $newid);
    }
    if ($do == 'addmenu' || $do == 'add' || $do == 'edit') {
        $GLOBALS['cp_page_head'][] = '<script language="JavaScript" type="text/javascript" src="js/menu.js"></script>';
        echo '<script>';
        echo cmsPage::getLangJS('AD_SPECIFY_LINK_MENU');
        echo '</script>';
    }
    if ($do == 'addmenu') {
        $GLOBALS['cp_page_title'] = $_LANG['AD_MENU_ADD'];
        cpAddPathway($_LANG['AD_MENU_ADD']);
        $menu_list = cpGetList('menu');
        ?>
         <form id="addform" name="addform" action="index.php?view=menu&do=submitmenu" method="post">
             <input type="hidden" name="csrf_token" value="<?php 
        echo cmsUser::getCsrfToken();
        ?>
" />
             <table class="proptable" width="650" cellspacing="10" cellpadding="10">
                 <tr>
                     <td width="300" valign="top">
                         <strong><?php 
        echo $_LANG['AD_MODULE_MENU_TITLE'];
        ?>
</strong>
                     </td>
                     <td valign="top">
                         <input name="title" type="text" id="title2" style="width:99%" value=""/>
                     </td>
                 </tr>
                 <tr>
                     <td valign="top">
                         <strong><?php 
        echo $_LANG['AD_MENU_TO_VIEW'];
        ?>
</strong><br/>
                         <span class="hinttext"><?php 
        echo $_LANG['AD_TO_CREATE_NEW_POINT'];
        ?>
</span>
                     </td>
                     <td valign="top">
                         <select name="menu" id="menu" style="width:99%">
                             <?php 
        foreach ($menu_list as $menu) {
            ?>
                                 <option value="<?php 
            echo $menu['id'];
            ?>
">
                                     <?php 
            echo $menu['title'];
            ?>
                                 </option>
                             <?php 
        }
        ?>
                         </select>
                     </td>
                 </tr>
                 <tr>
                     <td valign="top">
                         <strong><?php 
        echo $_LANG['AD_POSITION_TO_VIEW'];
        ?>
</strong><br />
                         <span class="hinttext"><?php 
        echo $_LANG['AD_POSITION_MUST_BE'];
        ?>
</span>
                     </td>
                     <td valign="top">
                         <?php 
        $pos = cpModulePositions(cmsConfig::getConfig('template'));
        ?>
                         <select name="position" id="position" style="width:99%">
                             <?php 
        if ($pos) {
            foreach ($pos as $key => $position) {
                if (@$mod['position'] == $position) {
                    echo '<option value="' . $position . '" selected>' . $position . '</option>';
                } else {
                    echo '<option value="' . $position . '">' . $position . '</option>';
                }
            }
        }
        ?>
                         </select>
                         <input name="is_external" type="hidden" id="is_external" value="0" />
                     </td>
                 </tr>
                 <tr>
                     <td valign="top"><strong><?php 
        echo $_LANG['AD_MENU_PUBLIC'];
        ?>
</strong></td>
                     <td valign="top">
                         <label><input name="published" type="radio" value="1" checked="checked" <?php 
        if (@$mod['published']) {
            echo 'checked="checked"';
        }
        ?>
 /> <?php 
        echo $_LANG['YES'];
        ?>
</label>
                         <label><input name="published" type="radio" value="0"  <?php 
        if (@(!$mod['published'])) {
            echo 'checked="checked"';
        }
        ?>
 /> <?php 
        echo $_LANG['NO'];
        ?>
</label>
                     </td>
                 </tr>
                 <tr>
                     <td valign="top"><strong><?php 
        echo $_LANG['AD_PREFIX_CSS'];
        ?>
</strong></td>
                     <td valign="top">
                         <input name="css_prefix" type="text" id="css_prefix" value="<?php 
        echo @$mod['css_prefix'];
        ?>
" style="width:99%" />
                     </td>
                 </tr>
                 <tr>
                     <td valign="top">
                         <strong><?php 
        echo $_LANG['AD_TAB_ACCESS'];
        ?>
:</strong><br />
                         <span class="hinttext"><?php 
        echo $_LANG['AD_GROUP_ACCESS'];
        ?>
</span>
                     </td>
                     <td valign="top">
                     <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist" style="margin-top:5px">
                         <tr>
                             <td width="20">
                                 <?php 
        $groups = cmsUser::getGroups();
        $style = 'disabled="disabled"';
        $public = 'checked="checked"';
        if ($do == 'edit') {
            if ($mod['access_list']) {
                $public = '';
                $style = '';
                $access_list = $inCore->yamlToArray($mod['access_list']);
            }
        }
        ?>
                                 <input name="is_public" type="checkbox" id="is_public" onclick="checkAccesList()" value="1" <?php 
        echo $public;
        ?>
 />
                             </td>
                             <td><label for="is_public"><strong><?php 
        echo $_LANG['AD_SHARE'];
        ?>
</strong></label></td>
                         </tr>
                     </table>
                     <div style="padding:5px">
                         <span class="hinttext">
                             <?php 
        echo $_LANG['AD_VIEW_IF_CHECK'];
        ?>
                         </span>
                     </div>

                     <div style="margin-top:10px;padding:5px;padding-right:0px;" id="grp">
                         <div>
                             <strong><?php 
        echo $_LANG['AD_GROUPS_VIEW'];
        ?>
</strong><br />
                             <span class="hinttext">
                                  <?php 
        echo $_LANG['AD_SELECT_MULTIPLE_CTRL'];
        ?>
                             </span>
                         </div>
                         <div>
                             <?php 
        echo '<select style="width: 99%" name="allow_group[]" id="allow_group" size="6" multiple="multiple" ' . $style . '>';
        if ($groups) {
            foreach ($groups as $group) {
                echo '<option value="' . $group['id'] . '"';
                if ($do == 'edit') {
                    if (inArray($access_list, $group['id'])) {
                        echo 'selected="selected"';
                    }
                }
                echo '>';
                echo $group['title'] . '</option>';
            }
        }
        echo '</select>';
        ?>
                         </div>
                     </div>
                     </td>
                 </tr>
                 <tr>
                     <td colspan="2" valign="top">
                         <div style="padding:10px;margin:4px;background-color:#EBEBEB;border:solid 1px gray">
                             <?php 
        echo $_LANG['AD_NEW_MENU_NEW_MODULE'];
        ?>
                         </div>
                     </td>
                 </tr>
             </table>
             <div style="margin-top:5px">
                 <input name="save" type="submit" id="save" value="<?php 
        echo $_LANG['AD_MENU_ADD'];
        ?>
" />
                 <input name="back" type="button" id="back" value="<?php 
        echo $_LANG['CANCEL'];
        ?>
" onclick="window.location.href='index.php?view=menu';" />
             </div>
         </form>
         <?php 
    }
    if ($do == 'add' || $do == 'edit') {
        require '../includes/jwtabs.php';
        $GLOBALS['cp_page_head'][] = jwHeader();
        $menu_list = cpGetList('menu');
        if ($do == 'add') {
            cpAddPathway($_LANG['AD_MENU_POINT_ADD']);
            $mod['menu'] = array('mainmenu');
        } else {
            if (isset($_REQUEST['multiple'])) {
                if (isset($_REQUEST['item'])) {
                    $_SESSION['editlist'] = cmsCore::request('item', 'array_int', array());
                } else {
                    cmsCore::addSessionMessage($_LANG['AD_NO_SELECT_OBJECTS'], 'error');
                    cmsCore::redirectBack();
                }
            }
            $ostatok = '';
            if (isset($_SESSION['editlist'])) {
                $item_id = array_shift($_SESSION['editlist']);
                if (sizeof($_SESSION['editlist']) == 0) {
                    unset($_SESSION['editlist']);
                } else {
                    $ostatok = '(' . $_LANG['AD_NEXT_IN'] . sizeof($_SESSION['editlist']) . ')';
                }
            } else {
                $item_id = cmsCore::request('id', 'int', 0);
            }
            $mod = $inDB->get_fields('cms_menu', "id = '{$item_id}'", '*');
            if (!$mod) {
                cmsCore::error404();
            }
            $mod['menu'] = cmsCore::yamlToArray($mod['menu']);
            cpAddPathway($_LANG['AD_MENU_POINT_EDIT'] . $ostatok . ' "' . $mod['title'] . '"');
        }
        ?>
    <form id="addform" name="addform" method="post" action="index.php">
        <input type="hidden" name="csrf_token" value="<?php 
        echo cmsUser::getCsrfToken();
        ?>
" />
        <input type="hidden" name="view" value="menu" />

        <table class="proptable" width="100%" cellpadding="15" cellspacing="2">
            <tr>

                <td valign="top">

                    <div><strong><?php 
        echo $_LANG['AD_MENU_POINT_TITLE'];
        ?>
</strong> <span class="hinttext">&mdash; <?php 
        echo $_LANG['AD_VIEW_IN_SITE'];
        ?>
</span></div>
                    <div><input name="title" type="text" id="title" style="width:100%" value="<?php 
        echo htmlspecialchars($mod['title']);
        ?>
" /></div>
                    <div><strong><?php 
        echo $_LANG['AD_PARENT_POINT'];
        ?>
</strong></div>
                    <div>
                        <?php 
        $rootid = $inDB->get_field('cms_menu', 'parent_id=0', 'id');
        ?>
                        <select name="parent_id" size="10" id="parent_id" style="width:100%">
                            <option value="<?php 
        echo $rootid;
        ?>
" <?php 
        if (@$mod['parent_id'] == $rootid || !isset($mod['parent_id'])) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_MENU_ROOT'];
        ?>
</option>
                            <?php 
        if (isset($mod['parent_id'])) {
            echo $inCore->getListItemsNS('cms_menu', $mod['parent_id']);
        } else {
            echo $inCore->getListItemsNS('cms_menu');
        }
        ?>
                        </select>
                        <input type="hidden" name="oldparent" value="<?php 
        echo @$mod['parent_id'];
        ?>
" />
                    </div>

                    <div><strong><?php 
        echo $_LANG['AD_MENU_POINT_ACTION'];
        ?>
</strong></div>
                    <div>
                        <select name="mode" id="linktype" style="width:100%" onchange="showMenuTarget()">
                            <option value="link" <?php 
        if (@$mod['linktype'] == 'link' || !isset($mod['mode'])) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_OPEN_LINK'];
        ?>
</option>
                            <option value="content" <?php 
        if (@$mod['linktype'] == 'content') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_OPEN_ARTICLE'];
        ?>
</option>
                            <option value="category" <?php 
        if (@$mod['linktype'] == 'category') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_OPEN_PARTITION'];
        ?>
</option>
                            <?php 
        if ($inCore->isComponentInstalled('video')) {
            ?>
                            <option value="video_cat" <?php 
            if (@$mod['linktype'] == 'video_cat') {
                echo 'selected="selected"';
            }
            ?>
><?php 
            echo $_LANG['AD_OPEN_VIDEO_PARTITION'];
            ?>
</option>
                            <?php 
        }
        ?>
                            <option value="component" <?php 
        if (@$mod['linktype'] == 'component') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_OPEN_COMPONENT'];
        ?>
</option>
                            <option value="blog" <?php 
        if (@$mod['linktype'] == 'blog') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_OPEN_BLOG'];
        ?>
</option>
                            <option value="uccat" <?php 
        if (@$mod['linktype'] == 'uccat') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_OPEN_CATEGORY'];
        ?>
</option>
                            <option value="photoalbum" <?php 
        if (@$mod['linktype'] == 'photoalbum') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_OPEN_ALBUM'];
        ?>
</option>
                        </select>
                    </div>

                    <div id="t_link" class="menu_target" style="display:<?php 
        if ($mod['linktype'] == 'link' || $mod['linktype'] == 'ext' || !$mod['linktype']) {
            echo 'block';
        } else {
            echo 'none';
        }
        ?>
">
                        <div>
                            <strong><?php 
        echo $_LANG['AD_LINK'];
        ?>
</strong> <span class="hinttext">&mdash; <?php 
        echo $_LANG['AD_LINK_HINT'];
        ?>
 <b>http://</b></span>
                        </div>
                        <div>
                            <input name="link" type="text" id="link" size="50" style="width:100%" <?php 
        if (@$mod['linktype'] == 'link' || @$mod['linktype'] == 'ext') {
            echo 'value="' . $mod['link'] . '"';
        }
        ?>
/>
                        </div>
                    </div>

                    <div id="t_content" class="menu_target" style="display:<?php 
        if ($mod['linktype'] == 'content') {
            echo 'block';
        } else {
            echo 'none';
        }
        ?>
">
                        <div>
                            <strong><?php 
        echo $_LANG['AD_CHECK_ARTICLE'];
        ?>
</strong>
                        </div>
                        <div>
                            <select name="content" id="content" style="width:100%">
                                <?php 
        if (@$mod['linktype'] == 'content') {
            echo $inCore->getListItems('cms_content', $mod['linkid']);
        } else {
            echo $inCore->getListItems('cms_content');
        }
        ?>
                            </select>
                        </div>
                    </div>

                    <?php 
        if ($inCore->isComponentInstalled('video')) {
            ?>
                    <div id="t_video_cat" class="menu_target" style="display:<?php 
            if ($mod['linktype'] == 'video_cat') {
                echo 'block';
            } else {
                echo 'none';
            }
            ?>
">
                        <div>
                            <strong><?php 
            echo $_LANG['AD_CHECK_PARTITION'];
            ?>
</strong>
                        </div>
                        <div>
                            <select name="video_cat" id="video_cat" style="width:100%">
                                    <?php 
            if (@$mod['linktype'] == 'video_cat') {
                echo $inCore->getListItemsNS('cms_video_category', $mod['linkid']);
            } else {
                echo $inCore->getListItemsNS('cms_video_category');
            }
            ?>
                            </select>
                        </div>
                    </div>
                    <?php 
        }
        ?>

                    <div id="t_category" class="menu_target" style="display:<?php 
        if ($mod['linktype'] == 'category') {
            echo 'block';
        } else {
            echo 'none';
        }
        ?>
">
                        <div>
                            <strong><?php 
        echo $_LANG['AD_CHECK_PARTITION'];
        ?>
</strong>
                        </div>
                        <div>
                            <select name="category" id="category" style="width:100%">
                                    <?php 
        if (@$mod['linktype'] == 'category') {
            echo $inCore->getListItemsNS('cms_category', $mod['linkid']);
        } else {
            echo $inCore->getListItemsNS('cms_category');
        }
        ?>
                            </select>
                        </div>
                    </div>

                    <div id="t_component" class="menu_target" style="display:<?php 
        if ($mod['linktype'] == 'component') {
            echo 'block';
        } else {
            echo 'none';
        }
        ?>
">
                        <div>
                            <strong><?php 
        echo $_LANG['AD_CHECK_COMPONENT'];
        ?>
</strong>
                        </div>
                        <div>
                           <select name="component" id="component" style="width:100%">
                                <?php 
        if (@$mod['linktype'] == 'component') {
            echo $inCore->getListItems('cms_components', $mod['linkid'], 'title', 'asc', 'internal=0', 'link');
        } else {
            echo $inCore->getListItems('cms_components', 0, 'title', 'asc', 'internal=0', 'link');
        }
        ?>
                            </select>
                        </div>
                    </div>

                    <div id="t_blog" class="menu_target" style="display:<?php 
        if ($mod['linktype'] == 'blog') {
            echo 'block';
        } else {
            echo 'none';
        }
        ?>
">
                        <div>
                            <strong><?php 
        echo $_LANG['AD_CHECK_BLOG'];
        ?>
</strong>
                        </div>
                        <div>
                           <select name="blog" id="blog" style="width:100%">
                                <?php 
        if (@$mod['linktype'] == 'blog') {
            echo $inCore->getListItems('cms_blogs', $mod['linkid'], 'title', 'asc', "owner='user'");
        } else {
            echo $inCore->getListItems('cms_blogs', 0, 'title', 'asc', "owner='user'");
        }
        ?>
                            </select>
                        </div>
                    </div>

                    <div id="t_uccat" class="menu_target" style="display:<?php 
        if ($mod['linktype'] == 'uccat') {
            echo 'block';
        } else {
            echo 'none';
        }
        ?>
">
                        <div>
                            <strong><?php 
        echo $_LANG['AD_CHECK_CATEGORY'];
        ?>
</strong>
                        </div>
                        <div>
                           <select name="uccat" id="uccat" style="width:100%">
                                <?php 
        if (@$mod['linktype'] == 'uccat') {
            echo $inCore->getListItems('cms_uc_cats', $mod['linkid']);
        } else {
            echo $inCore->getListItems('cms_uc_cats');
        }
        ?>
                            </select>
                        </div>
                    </div>

                    <div id="t_photoalbum" class="menu_target" style="display:<?php 
        if ($mod['linktype'] == 'photoalbum') {
            echo 'block';
        } else {
            echo 'none';
        }
        ?>
">
                        <div>
                            <strong><?php 
        echo $_LANG['AD_CHECK_ALBUM'];
        ?>
</strong>
                        </div>
                        <div>
                           <select name="photoalbum" id="photoalbum" style="width:100%">
                                <?php 
        if (@$mod['linktype'] == 'photoalbum') {
            echo $inCore->getListItems('cms_photo_albums', $mod['linkid'], 'id', 'ASC', 'NSDiffer = ""');
        } else {
            echo $inCore->getListItems('cms_photo_albums', 0, 'id', 'ASC', 'NSDiffer = ""');
        }
        ?>
                            </select>
                        </div>
                    </div>

                </td>

                <td width="300" valign="top" style="background:#ECECEC;">

                    <?php 
        ob_start();
        ?>

                    {tab=<?php 
        echo $_LANG['AD_TAB_PUBLISH'];
        ?>
}

                        <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist">
                            <tr>
                                <td width="20"><input type="checkbox" name="published" id="published" value="1" <?php 
        if ($mod['published'] || $do == 'add') {
            echo 'checked="checked"';
        }
        ?>
/></td>
                                <td><label for="published"><strong><?php 
        echo $_LANG['AD_MENU_POINT_PUBLIC'];
        ?>
</strong></label></td>
                            </tr>
                        </table>

                        <div style="margin-top:15px">
                            <strong><?php 
        echo $_LANG['AD_OPEN_POINT'];
        ?>
</strong>
                        </div>
                        <div>
                            <select name="target" id="target" style="width:100%">
                                <option value="_self" <?php 
        if (@$mod['target'] == '_self') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_SELF'];
        ?>
</option>
                                <option value="_parent"><?php 
        echo $_LANG['AD_PARENT'];
        ?>
</option>
                                <option value="_blank" <?php 
        if (@$mod['target'] == '_blank') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_BLANK'];
        ?>
</option>
                                <option value="_top" <?php 
        if (@$mod['target'] == '_top') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_TOP'];
        ?>
</option>
                            </select>
                        </div>

                        <div style="margin-top:15px">
                            <strong><?php 
        echo $_LANG['TEMPLATE'];
        ?>
</strong><br/>
                            <span class="hinttext"><?php 
        echo $_LANG['AD_DESIGN_CHANGE'];
        ?>
</span>
                        </div>
                        <div>
                            <select name="template" id="template" style="width:100%">
                                <option value="0" <?php 
        if (@$mod['template'] == 0 || !$mod['template']) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_BY_DEFAULT'];
        ?>
</option>
                                <?php 
        $templates = cmsCore::getDirsList('/templates');
        foreach ($templates as $template) {
            echo '<option value="' . $template . '" ' . (@$mod['template'] == $template ? 'selected="selected"' : '') . '>' . $template . '</option>';
        }
        ?>
                            </select>
                        </div>

                        <div style="margin-top:15px">
                            <strong><?php 
        echo $_LANG['AD_ICON_PICTURE'];
        ?>
</strong><br/>
                            <span class="hinttext"><?php 
        echo $_LANG['AD_ICON_FILENAME'];
        ?>
</span>
                        </div>
                        <div>
                            <input name="iconurl" type="text" id="iconurl" size="30" value="<?php 
        echo @$mod['iconurl'];
        ?>
" style="width:100%"/>
                            <div>
                                <a id="iconlink" style="display:block;" href="javascript:showIcons()"><?php 
        echo $_LANG['AD_CHECK_ICON'];
        ?>
</a>
                                <div id="icondiv" style="display:none; padding:6px;border:solid 1px gray;background:#FFF">
                                    <div><?php 
        iconList();
        ?>
</div>
                                </div>
                            </div>
                        </div>
                        <div style="margin-top:15px">
                            <strong><?php 
        echo $_LANG['AD_CSS_CLASS'];
        ?>
</strong>
                        </div>
                        <div>
                            <input name="css_class" type="text" size="30" value="<?php 
        echo @$mod['css_class'];
        ?>
" style="width:100%"/>
                        </div>

                    {tab=<?php 
        echo $_LANG['AD_TAB_ACCESS'];
        ?>
}
                    <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist" style="margin-top:5px">
                        <tr>
                            <td width="20">
                                <?php 
        $groups = cmsUser::getGroups();
        $style = 'disabled="disabled"';
        $public = 'checked="checked"';
        if ($do == 'edit') {
            if ($mod['access_list']) {
                $public = '';
                $style = '';
                $access_list = $inCore->yamlToArray($mod['access_list']);
            }
        }
        ?>
                                <input name="is_public" type="checkbox" id="is_public" onclick="checkAccesList()" value="1" <?php 
        echo $public;
        ?>
 />
                            </td>
                            <td><label for="is_public"><strong><?php 
        echo $_LANG['AD_SHARE'];
        ?>
</strong></label></td>
                        </tr>
                    </table>
                    <div style="padding:5px">
                        <span class="hinttext">
                            <?php 
        echo $_LANG['AD_VIEW_IF_CHECK'];
        ?>
                        </span>
                    </div>

                    <div style="margin-top:10px;padding:5px;padding-right:0px;" id="grp">
                        <div>
                            <strong><?php 
        echo $_LANG['AD_GROUPS_VIEW'];
        ?>
</strong><br />
                            <span class="hinttext">
                                <?php 
        echo $_LANG['AD_SELECT_MULTIPLE_CTRL'];
        ?>
                            </span>
                        </div>
                        <div>
                            <?php 
        echo '<select style="width: 99%" name="allow_group[]" id="allow_group" size="6" multiple="multiple" ' . $style . '>';
        if ($groups) {
            foreach ($groups as $group) {
                echo '<option value="' . $group['id'] . '"';
                if ($do == 'edit' && $mod['access_list']) {
                    if (inArray($access_list, $group['id'])) {
                        echo 'selected="selected"';
                    }
                }
                echo '>';
                echo $group['title'] . '</option>';
            }
        }
        echo '</select>';
        ?>
                        </div>
                    </div>
                    <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist" style="margin-top:5px">
                        <tr>
                            <td width="20">
                                <input name="is_lax" type="checkbox" id="is_lax" value="1" <?php 
        if (@$mod['is_lax']) {
            ?>
checked="checked"<?php 
        }
        ?>
 />
                            </td>
                            <td><label for="is_lax"><strong><?php 
        echo $_LANG['AD_ONLY_CHILD_ITEM'];
        ?>
</strong></label></td>
                        </tr>
                    </table>
                    {tab=<?php 
        echo $_LANG['AD_MENU'];
        ?>
}
                    <div style="padding:5px;padding-right:0px;">
                        <div>
                            <strong><?php 
        echo $_LANG['AD_MENU_TO_VIEW'];
        ?>
</strong><br />
                            <span class="hinttext">
                                <?php 
        echo $_LANG['AD_SELECT_MULTIPLE_CTRL'];
        ?>
                            </span>
                        </div>
                        <div>
                        <select style="width: 99%" name="menu[]" size="9" multiple="multiple">
                            <?php 
        foreach ($menu_list as $menu) {
            ?>
                                <option value="<?php 
            echo $menu['id'];
            ?>
" <?php 
            if (@in_array($menu['id'], @$mod['menu'])) {
                echo 'selected="selected"';
            }
            ?>
>
                                    <?php 
            echo $menu['title'];
            ?>
                                </option>
                            <?php 
        }
        ?>
                        </select>
                        </div>
                    </div>
                    {/tabs}

                    <?php 
        echo jwTabs(ob_get_clean());
        ?>

                </td>

            </tr>
        </table>

        <p>
            <input name="add_mod" type="button" onclick="submitItem()" id="add_mod" value="<?php 
        echo $_LANG['SAVE'];
        ?>
 " />
            <input name="back" type="button" id="back" value="<?php 
        echo $_LANG['CANCEL'];
        ?>
" onclick="window.location.href='index.php?view=menu';" />
            <input name="do" type="hidden" id="do" <?php 
        if ($do == 'add') {
            echo 'value="submit"';
        } else {
            echo 'value="update"';
        }
        ?>
 />
            <?php 
        if ($do == 'edit') {
            echo '<input name="id" type="hidden" value="' . $mod['id'] . '" />';
        }
        ?>
        </p>
    </form>
    <?php 
    }
}
Ejemplo n.º 11
0
    public function showNavBar()
    {
        $returnStr = $this->showCalculator();
        //language
        $rgid = $this->engine->getRgid();
        $variablenames = $this->getRealVariables(explode("~", $this->engine->getDisplayed()));
        $variablenamesfull = $this->engine->getDisplayed();
        $template = $this->engine->getTemplate();
        $click = "";
        if ($template != "") {
            $group = $this->engine->getGroup($template);
            $click = $this->engine->replaceFills($group->getClickLanguageChange());
        } else {
            $vars = explode("~", $variablenames);
            $var = $this->engine->getVariableDescriptive($vars[0]);
            $click = $this->engine->replaceFills($var->getClickLanguageChange());
        }
        $click = str_replace("'", "", $click);
        // begin language
        global $survey;
        if (getSurveyLanguageAllowChange() == LANGUAGE_CHANGE_RESPONDENT_ALLOWED) {
            $allowed = explode("~", $survey->getAllowedLanguages(getSurveyMode()));
            if (sizeof($allowed) > 1) {
                $returnStr .= '<li class="dropdown">';
                $returnStr .= '   <a href="#" class="dropdown-toggle" data-toggle="dropdown">Language <b class="caret"></b></a><ul class="dropdown-menu">';
                $langs = Language::getLanguagesArray();
                //getSurveyLanguages($this->engine->survey);
                foreach ($langs as $lang) {
                    if (inArray($lang["value"], $allowed)) {
                        $check = '';
                        if ($lang["value"] == getSurveyLanguage()) {
                            $check = ' <span class="glyphicon glyphicon-ok"></span>';
                        }
                        $returnStr .= '<li><a href=# onclick=\'document.getElementById("r").value="' . setSessionsParamString(array_merge(array(SESSION_PARAM_SURVEY => $survey->getSuid(), SESSION_PARAM_PRIMKEY => $this->engine->getPrimaryKey(), SESSION_PARAM_RGID => $rgid, SESSION_PARAM_VARIABLES => $variablenames, SESSION_PARAM_GROUP => $template, SESSION_PARAM_MODE => getSurveyMode(), SESSION_PARAM_LANGUAGE => getSurveyLanguage(), SESSION_PARAM_TEMPLATE => getSurveyTemplate(), SESSION_PARAM_TIMESTAMP => time(), SESSION_PARAM_SEID => $this->engine->getSeid(), SESSION_PARAM_MAINSEID => $this->engine->getMainSeid()), array(SESSION_PARAM_NEWLANGUAGE => $lang["value"]))) . '"; document.getElementById("navigation").value="' . addslashes(Language::buttonUpdate()) . '"; ' . $click . ' document.getElementById("form").submit(); \'>' . $lang["name"] . $check . '</a></li>';
                    }
                }
                $returnStr .= '</ul></li>';
            }
            //end language
        }
        $user = new User($_SESSION['URID']);
        $returnStr .= '<li class="dropdown">
              <a href="#" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown">' . $user->getName() . ' <b class="caret"></b></a>
                 <ul class="dropdown-menu">
										<li class="dropdown-header">' . $this->engine->primkey . '</li>
                                                                                <li class="dropdown-header">' . $variablenamesfull . '</li>';
        //$returnStr .= '<li><a href=# data-toggle="modal" data-target="#calculator">Calculator</a></li>';
        $returnStr .= '<li><a href="#" data-toggle="modal" data-target="#calculator"><span class="glyphicon glyphicon-th"></span> ' . Language::linkCalculator() . '</a></li>';
        $windowopen = 'window.open(\'tester/' . setSessionParams(array('type' => "2", 'testpage' => 'watch', 'watchurid' => $_SESSION['URID'], 'watchsuid' => $this->engine->getSuid(), 'watchseid' => $this->engine->getSeid(), 'watchmainseid' => $this->engine->getMainSeid(), 'watchrgid' => $rgid, 'watchdisplayed' => $variablenames, 'watchlanguage' => getSurveyLanguage(), 'watchmode' => getSurveyMode(), 'watchversion' => getSurveyVersion(), 'watchprimkey' => $this->engine->getPrimarykey())) . '\', \'popupWindow\', \'width=770,height=650,scrollbars=yes,top=100,left=100\'); return false;';
        $javascript = ' onclick="' . $windowopen . '"';
        $returnStr .= '<li><a style="cursor: pointer;" ' . $javascript . '><span class="glyphicon glyphicon-zoom-in"></span> ' . Language::linkWatch() . '</a></li>';
        $windowopen = 'window.open(\'tester/' . setSessionParams(array('type' => "2", 'testpage' => 'update', 'watchurid' => $_SESSION['URID'], 'watchsuid' => $this->engine->getSuid(), 'watchseid' => $this->engine->getSeid(), 'watchmainseid' => $this->engine->getMainSeid(), 'watchrgid' => $rgid, 'watchdisplayed' => $variablenames, 'watchlanguage' => getSurveyLanguage(), 'watchmode' => getSurveyMode(), 'watchversion' => getSurveyVersion(), 'watchprimkey' => $this->engine->getPrimarykey())) . '\', \'popupWindow\', \'width=1200,height=650,scrollbars=yes,top=100,left=100\'); return false;';
        $javascript = ' onclick="' . $windowopen . '"';
        $returnStr .= '<li><a style="cursor: pointer;" ' . $javascript . '><span class="glyphicon glyphicon-zoom-in"></span> ' . Language::linkUpdate() . '</a></li>';
        $first = $this->engine->isFirstState();
        if ($first == false || $first == true && $this->engine->getForward() == true) {
            if ($this->engine->getForward() == true) {
                $stateid = $this->engine->getStateId() + 1;
            } else {
                $stateid = $this->engine->getStateId();
            }
            $windowopen = 'window.open(\'tester/' . setSessionParams(array('type' => "2", 'testpage' => 'jumpback', 'jumpurid' => $_SESSION['URID'], 'jumpsuid' => $this->engine->getSuid(), 'jumpstateid' => $stateid, 'jumpprimkey' => $this->engine->getPrimaryKey())) . '\', \'popupWindow\', \'width=770,height=300,scrollbars=yes,top=100,left=100\'); return false;';
            $javascript = ' onclick="' . $windowopen . '"';
            $returnStr .= '<li><a style="cursor: pointer;" ' . $javascript . '><span class="glyphicon glyphicon-arrow-left"></span> ' . Language::linkJumpBack() . '</a></li>';
        }
        $returnStr .= '<li><a href="' . setSessionParams(array('page' => 'interviewer.backfromsms', 'primkey' => $this->engine->primkey, 'suid' => $this->engine->getSuid())) . '&se=' . addslashes(USCIC_SMS) . '"><span class="glyphicon glyphicon-home"></span> ' . Language::linkBackToSMS() . '</a></li>                   
                    <li class="divider"></li>
                   <li><a href="index.php?rs=1&se=2"><span class="glyphicon glyphicon-log-out"></span> ' . Language::linkLogout() . '</a></li>
                 </ul>
             </li>
            </ul>
';
        $returnStr .= '</div><!--/.nav-collapse --> </div> </div>';
        return $returnStr;
    }
Ejemplo n.º 12
0
                 }
             }
             $query = "update " . $this->targettable . "_routing set rule='endgroup' where suid=" . $this->suid . " and trim(rule)='endcombine'";
             $this->db->executeQuery($query);
         }
     }
 }
 function convertTypes()
 {
     $query = "select teid as id, name as name, questiontype as answertype, answer as options from " . $this->sourcetable . "_type where syid=" . $this->syid . " order by teid";
     if ($res = $this->importdb->selectQuery($query)) {
         if ($this->importdb->getNumberOfRows($res) > 0) {
             while ($row = $this->importdb->getRow($res)) {
                 $query = "replace into " . $this->targettable . "_types (suid, tyd, name) values (";
                 $query .= prepareDatabaseString($this->suid) . ",";
                 $query .= prepareDatabaseString($row["id"]) . ",";
                 $query .= "'" . prepareDatabaseString($row["name"]) . "')";
                 $this->db->executeQuery($query);
                 /* add rest as settings */
                 $this->addSetting($row["id"], OBJECT_TYPE, SETTING_ANSWERTYPE, $this->convertAnswerType($row["answertype"], $row["settings"]));
                 $this->addSetting($row["id"], OBJECT_TYPE, SETTING_OPTIONS, $row["options"]);
                 /* add usage in variables */
                 $query = "select * from " . $this->targettable . "_settings where suid=" . $this->suid . " and name='" . SETTING_OPTIONS . "' and objecttype=" . OBJECT_VARIABLEDESCRIPTIVE . " and value='" . $row["name"] . "'";
                 //                    echo $query;
                 $res1 = $this->db->selectQuery($query);
                 if ($res1) {
                     //echo 'found some for ' . $row["tyd"] . "-----" . $query . "<br/>";
                     if ($this->db->getNumberOfRows($res1) > 0) {
                         while ($row1 = $this->db->getRow($res1)) {
                             $q = "update " . $this->targettable . "_variables set tyd=" . $row["id"] . " where suid=" . $this->suid . " and vsid=" . $row1["object"];
                             $this->db->executeQuery($q);
                             // remove options in settings for variable, so it does not override the type's options
                             $q = "delete from " . $this->targettable . "_settings where suid=" . $this->suid . " and object=" . $row1["object"] . " and name='" . SETTING_OPTIONS . "' and objecttype=" . OBJECT_VARIABLEDESCRIPTIVE;
                             $this->db->executeQuery($q);
                         }
                     }
                 }
                 /* add settings */
                 $this->convertSettings($row, OBJECT_TYPE);
                 /* convert translations */
                 $q = "select source, language, cast(translation as char) as translation from " . $this->sourcetable . "_translation where syid=" . $this->syid . " and id=" . $row["id"] . " order by source";
                 if ($r = $this->importdb->selectQuery($q)) {
                     if ($this->importdb->getNumberOfRows($r) > 0) {
                         while ($rowtrans = $this->importdb->getRow($r)) {
                             $language = $rowtrans["language"];
                             $source = $rowtrans["source"];
                             switch ($source) {
                                 case "teid":
                                     $this->addSetting($row["id"], OBJECT_TYPE, SETTING_OPTIONS, $rowtrans["translation"], $language);
                                     break;
                             }
                             if (!inArray($language, $this->languages)) {
                                 $this->languages[] = $language;
                             }
                         }
                     }
                 }
             }
             // update answer types
             $updates = array("update " . $this->targettable . "_settings set value=" . $this->convertAnswerType(3) . " where suid=" . $this->suid . " and objecttype=" . OBJECT_TYPE . " and name='" . SETTING_ANSWERTYPE . "' and value=3", "update " . $this->targettable . "_settings set value=" . $this->convertAnswerType(4) . " where suid=" . $this->suid . " and objecttype=" . OBJECT_TYPE . " and name='" . SETTING_ANSWERTYPE . "' and value=4", "update " . $this->targettable . "_settings set value=" . $this->convertAnswerType(5) . " where suid=" . $this->suid . " and objecttype=" . OBJECT_TYPE . " and name='" . SETTING_ANSWERTYPE . "' and value=5", "update " . $this->targettable . "_settings set value=" . $this->convertAnswerType(6) . " where suid=" . $this->suid . " and objecttype=" . OBJECT_TYPE . " and name='" . SETTING_ANSWERTYPE . "' and value=6");
Ejemplo n.º 13
0
					<?php 
    $groups = cmsUser::getGroups();
    $style = 'disabled="disabled"';
    $public = 'checked="checked"';
    if ($mod['access_list']) {
        $public = '';
        $style = '';
        $access_list = $inCore->yamlToArray($mod['access_list']);
    }
    echo '<select style="width: 260px" name="access_list[]" id="showin" size="6" multiple="multiple" ' . $style . '>';
    if ($groups) {
        foreach ($groups as $group) {
            if (!$group['is_admin']) {
                echo '<option value="' . $group['id'] . '"';
                if ($access_list) {
                    if (inArray($access_list, $group['id'])) {
                        echo 'selected';
                    }
                }
                echo '>';
                echo $group['title'] . '</option>';
            }
        }
    }
    echo '</select>';
    ?>
                    
                    <label><input name="is_access" type="checkbox" id="is_access" onclick="checkAccesList()" value="1" <?php 
    echo $public;
    ?>
 /> <strong>Всем группам</strong></label>
Ejemplo n.º 14
0
 function addErrorMessage($message, $rgid = "")
 {
     $arr = array();
     $r = $this->currentrgid;
     if ($rgid != "") {
         $r = $rgid;
     }
     if (isset($this->messages[$r])) {
         $arr = $this->messages[$r];
     }
     if (!inArray($message, $arr)) {
         $arr[] = $message;
     }
     $this->messages[$r] = $arr;
 }
Ejemplo n.º 15
0
             $qa = "text-justify";
             break;
         case ALIGN_CENTER:
             $qa = "text-center";
             break;
         default:
             break;
     }
     /* calculate cell width */
     $noofcolumns = sizeof($orderedoptions);
     $this->cellwidth = "width=" . round(($this->engine->replaceFills($this->group->getTableWidth()) - $this->engine->replaceFills($this->group->getQuestionColumnWidth())) / $noofcolumns) . "%";
     foreach ($orderedoptions as $option) {
         $returnStr .= "<th class='uscic-table-row-cell-header-enumerated'><div class='" . $qa . "'><span id='vsid_option" . $var->getVsid() . $option["code"] . "' uscic-target='vsid_" . $var->getVsid() . "' uscic-texttype='" . SETTING_QUESTION . "' class='" . $this->displayobject->inlineeditable . "'>" . $this->displayobject->applyFormatting($option, $this->group->getHeaderFormatting()) . "</span></div></th>";
     }
     $returnStr .= "</tr></thead>";
     return $returnStr;
 }
 function showEnumeratedOption($option, $number, $variable, $var, $first, $previousdata)
 {
     $returnStr = "";
     $varname = SESSION_PARAMS_ANSWER . $number;
     $id = $this->engine->getFill($variable, $var, SETTING_ID);
     if (trim($id) == "") {
         $id = $varname;
     }
     /* get id for inline field error checking */
     $ids = array();
     if (trim($option["label"] != "")) {
         $ids[] = $id . '_' . $option["code"];
     }
     if (inArray($var->getAnswerType(), array(ANSWER_TYPE_SETOFENUMERATED, ANSWER_TYPE_MULTIDROPDOWN))) {
         $varname .= "[]";
     }
     if ($var->getIfEmpty() != IF_EMPTY_ALLOW) {
         if (inArray($var->getAnswerType(), array(ANSWER_TYPE_SETOFENUMERATED))) {
             // custom name for set of enumerated question, since we use a hidden field/textbox to track the real answer(s); we just use this custom name for referencing in the error checking
             $this->displayobject->addErrorCheck(SESSION_PARAMS_ANSWER . $number . "_name[]", new ErrorCheck(ERROR_CHECK_REQUIRED, "true"), $this->engine->getFill($variable, $var, SETTING_EMPTY_MESSAGE));
         } else {
             $this->displayobject->addErrorCheck($varname, new ErrorCheck(ERROR_CHECK_REQUIRED, "true"), $this->engine->getFill($variable, $var, SETTING_EMPTY_MESSAGE));
         }
     }
     $inlinejavascript = $this->engine->getFill($variable, $var, SETTING_JAVASCRIPT_WITHIN_ELEMENT);
     $align = $this->group->getHeaderAlignment();
     $qa = "";
     switch ($align) {
         case ALIGN_LEFT:
             $qa = "text-left";
             break;
         case ALIGN_RIGHT:
             $qa = "text-right";
             break;
         case ALIGN_JUSTIFIED:
             $qa = "text-justify";
             break;
         case ALIGN_CENTER:
             $qa = "text-center";
             break;
         default:
             break;
     }
     switch ($var->getAnswerType()) {
         case ANSWER_TYPE_ENUMERATED:
             //enumerated
             if (trim($option["label"]) != "") {
                 $selected = '';
                 if ($option["code"] == $previousdata) {
                     $selected = ' CHECKED';
                 }
                 $returnStr .= '<td id="cell' . $id . '_' . $option["code"] . '" class="uscic-table-row-cell-enumerated" ' . $this->cellwidth . '><div class="' . $qa . '">
                                     <label for="' . $id . '_' . $option["code"] . '" class="uscic-table-enumerated-label">
                                         <div class="form-group uscic-table-row-cell-form-group">
                                             <input class="uscic-radio-table" ' . $this->displayobject->getErrorTextString($varname) . ' ' . $inlinejavascript . ' type=radio id=' . $id . '_' . $option["code"] . ' name=' . $varname . ' value=' . $option["code"] . $selected . '>
                                         </div>
                                      </label>
                                     </div>
                                     <script type="text/javascript">$( document ).ready(function() { 
                                                 $("#cell' . $id . '_' . $option["code"] . '").click(function (e) {
                                                                       $("#' . $id . '_' . $option["code"] . '").prop("checked", true);
                                                                       $("#' . $id . '_' . $option["code"] . '").change();                                                                          
                                                                       });
                                                                      });</script>
                                     </td>
                                     ';
             } else {
                 $returnStr .= '<td class="uscic-table-row-cell-enumerated"></td>';
             }
             /* done */
             break;
         case ANSWER_TYPE_SETOFENUMERATED:
             //set of enumerated
Ejemplo n.º 16
0
    public function showNavBar()
    {
        $returnStr = $this->getHeader();
        //language
        $rgid = $this->engine->getRgid();
        $variablenames = $this->getRealVariables(explode("~", $this->engine->getDisplayed()));
        $variablenamesfull = $this->engine->getDisplayed();
        $template = $this->engine->getTemplate();
        $click = "";
        if ($template != "") {
            $group = $this->engine->getGroup($template);
            $click = $this->engine->replaceFills($group->getClickLanguageChange());
        } else {
            $vars = explode("~", $variablenames);
            $var = $this->engine->getVariableDescriptive($vars[0]);
            $click = $this->engine->replaceFills($var->getClickLanguageChange());
        }
        $click = str_replace("'", "", $click);
        $clickmode = "";
        if ($template != "") {
            $group = $this->engine->getGroup($template);
            $clickmode = $this->engine->replaceFills($group->getClickModeChange());
        } else {
            $vars = explode("~", $variablenames);
            $var = $this->engine->getVariableDescriptive($vars[0]);
            $clickmode = $this->engine->replaceFills($var->getClickModeChange());
        }
        $clickmode = str_replace("'", "", $clickmode);
        // begin language
        global $survey;
        $user = new User($_SESSION['URID']);
        $allowedmodes = $user->getModes();
        $allowedlanguages = explode("~", $user->getLanguages(getSurvey(), getSurveyMode()));
        $default = $survey->getDefaultLanguage();
        $ut = "sysadmin";
        if ($user->getUserType() == USER_TRANSLATOR) {
            $ut = "translator";
            if (!inArray($default, $allowedlanguages)) {
                $allowedlanguages[] = $default;
            }
        } else {
            if ($user->GetUserType() == USER_TESTER) {
                $ut = "tester";
            }
        }
        if (getSurveyModeAllowChange() == MODE_CHANGE_RESPONDENT_ALLOWED) {
            //$allowed = explode("~", $survey->getAllowedModes());
            if (sizeof($allowedmodes) > 1) {
                $template = $this->engine->getTemplate();
                $returnStr .= '<li class="dropdown">';
                $returnStr .= '   <a href="#" class="dropdown-toggle" data-toggle="dropdown">Mode <b class="caret"></b></a>';
                $returnStr .= '<ul class="dropdown-menu" role="menu">';
                $current = getSurveyMode();
                $modes = Common::surveyModes();
                foreach ($modes as $key => $mode) {
                    if (inArray($key, $allowedmodes)) {
                        $check = '';
                        if ($key == $current) {
                            $check = ' <span class="glyphicon glyphicon-ok"></span>';
                        }
                        //$returnStr .= '<li><a href=# onclick=\'document.getElementById("r").value="' . setSessionsParamString(array_merge(array(SESSION_PARAM_LASTACTION => $this->engine->getLastSurveyAction(), SESSION_PARAM_SURVEY => $survey->getSuid(), SESSION_PARAM_PRIMKEY => $this->primkey, SESSION_PARAM_RGID => $rgid, SESSION_PARAM_VARIABLES => $variablenames, SESSION_PARAM_GROUP => $template, SESSION_PARAM_MODE => $current, SESSION_PARAM_VERSION => getSurveyVersion(), SESSION_PARAM_LANGUAGE => getSurveyLanguage(), SESSION_PARAM_TIMESTAMP => time(), SESSION_PARAM_SEID => $this->engine->getSeid(), SESSION_PARAM_MAINSEID => $this->engine->getMainSeid()), array(SESSION_PARAM_NEWMODE => $key))) . '"; document.getElementById("navigation").value="' . NAVIGATION_MODE_CHANGE . '"; $("#form").submit(); \'>' . $mode . $check . '</a></li>';
                        $returnStr .= '<li><a href=# onclick=\'document.getElementById("r").value="' . setSessionsParamString(array_merge(array(SESSION_PARAM_SURVEY => $survey->getSuid(), SESSION_PARAM_PRIMKEY => $this->engine->getPrimaryKey(), SESSION_PARAM_RGID => $rgid, SESSION_PARAM_VARIABLES => $variablenames, SESSION_PARAM_GROUP => $template, SESSION_PARAM_MODE => getSurveyMode(), SESSION_PARAM_LANGUAGE => getSurveyLanguage(), SESSION_PARAM_TEMPLATE => getSurveyTemplate(), SESSION_PARAM_TIMESTAMP => time(), SESSION_PARAM_SEID => $this->engine->getSeid(), SESSION_PARAM_MAINSEID => $this->engine->getMainSeid()), array(SESSION_PARAM_NEWMODE => $key))) . '"; document.getElementById("navigation").value="' . addslashes(Language::buttonUpdate()) . '"; ' . $clickmode . ' document.getElementById("form").submit(); \'>' . $mode . $check . '</a></li>';
                    }
                }
                $returnStr .= '</ul></li>';
            }
        }
        if (getSurveyLanguageAllowChange() == LANGUAGE_CHANGE_RESPONDENT_ALLOWED) {
            //$allowed = explode("~", $survey->getAllowedLanguages(getSurveyMode()));
            if (sizeof($allowedlanguages) > 1) {
                $returnStr .= '<li class="dropdown">';
                $returnStr .= '   <a href="#" class="dropdown-toggle" data-toggle="dropdown">Language <b class="caret"></b></a><ul class="dropdown-menu">';
                $langs = Language::getLanguagesArray();
                //getSurveyLanguages($this->engine->survey);
                foreach ($langs as $lang) {
                    if (inArray($lang["value"], $allowedlanguages)) {
                        $check = '';
                        if ($lang["value"] == getSurveyLanguage()) {
                            $check = ' <span class="glyphicon glyphicon-ok"></span>';
                        }
                        $returnStr .= '<li><a href=# onclick=\'document.getElementById("r").value="' . setSessionsParamString(array_merge(array(SESSION_PARAM_SURVEY => $survey->getSuid(), SESSION_PARAM_PRIMKEY => $this->engine->getPrimaryKey(), SESSION_PARAM_RGID => $rgid, SESSION_PARAM_VARIABLES => $variablenames, SESSION_PARAM_GROUP => $template, SESSION_PARAM_MODE => getSurveyMode(), SESSION_PARAM_LANGUAGE => getSurveyLanguage(), SESSION_PARAM_TEMPLATE => getSurveyTemplate(), SESSION_PARAM_TIMESTAMP => time(), SESSION_PARAM_SEID => $this->engine->getSeid(), SESSION_PARAM_MAINSEID => $this->engine->getMainSeid()), array(SESSION_PARAM_NEWLANGUAGE => $lang["value"]))) . '"; document.getElementById("navigation").value="' . addslashes(Language::buttonUpdate()) . '"; ' . $click . ' document.getElementById("form").submit(); \'>' . $lang["name"] . $check . '</a></li>';
                    }
                }
                $returnStr .= '</ul></li>';
            }
            //end language
        }
        $user = new User($_SESSION['URID']);
        $returnStr .= '<li class="dropdown">
              <a href="#" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown">' . $user->getName() . ' <b class="caret"></b></a>
                 <ul class="dropdown-menu">
										<li class="dropdown-header">' . $this->engine->getPrimaryKey() . '</li>
                                                                                <li class="dropdown-header">' . $variablenamesfull . '</li>';
        $windowopen = 'window.open(\'tester/' . setSessionParams(array('reporturid' => $_SESSION['URID'], 'testpage' => 'report', 'reportsuid' => $this->engine->getSuid(), 'reportseid' => $this->engine->getSeid(), 'reportmainseid' => $this->engine->getMainSeid(), 'reportrgid' => $rgid, 'reportdisplayed' => $variablenames, 'reportlanguage' => getSurveyLanguage(), 'reportmode' => getSurveyMode(), 'reportversion' => getSurveyVersion(), 'reportprimkey' => $this->engine->getPrimarykey())) . '\', \'popupWindow\', \'width=770,height=500,scrollbars=yes,top=100,left=100\'); return false;';
        $javascript = ' onclick="' . $windowopen . '"';
        $returnStr .= '<li><a style="cursor: pointer;" ' . $javascript . '><span class="glyphicon glyphicon-remove-sign"></span> ' . Language::linkReportProblem() . '</a></li>';
        $windowopen = 'window.open(\'tester/' . setSessionParams(array('testpage' => 'watch', 'watchurid' => $_SESSION['URID'], 'watchsuid' => $this->engine->getSuid(), 'watchseid' => $this->engine->getSeid(), 'watchmainseid' => $this->engine->getMainSeid(), 'watchrgid' => $rgid, 'watchdisplayed' => $variablenames, 'watchlanguage' => getSurveyLanguage(), 'watchmode' => getSurveyMode(), 'watchversion' => getSurveyVersion(), 'watchprimkey' => $this->engine->getPrimarykey())) . '\', \'popupWindow\', \'width=770,height=650,scrollbars=yes,top=100,left=100\'); return false;';
        $javascript = ' onclick="' . $windowopen . '"';
        $returnStr .= '<li><a style="cursor: pointer;" ' . $javascript . '><span class="glyphicon glyphicon-zoom-in"></span> ' . Language::linkWatch() . '</a></li>';
        $first = $this->engine->isFirstState();
        if ($first == false || $first == true && $this->engine->getForward() == true) {
            if ($this->engine->getForward() == true) {
                $stateid = $this->engine->getStateId() + 1;
            } else {
                $stateid = $this->engine->getStateId();
            }
            $windowopen = 'window.open(\'tester/' . setSessionParams(array('testpage' => 'jumpback', 'jumpurid' => $_SESSION['URID'], 'jumpsuid' => $this->engine->getSuid(), 'jumpstateid' => $stateid, 'jumpprimkey' => $this->engine->getPrimaryKey())) . '\', \'popupWindow\', \'width=770,height=300,scrollbars=yes,top=100,left=100\'); return false;';
            $javascript = ' onclick="' . $windowopen . '"';
            $returnStr .= '<li><a style="cursor: pointer;" ' . $javascript . '><span class="glyphicon glyphicon-arrow-left"></span> ' . Language::linkJumpBack() . '</a></li>';
        }
        $returnStr .= '<li><a href="' . setSessionParams(array('page' => $ut . '.tools.test', 'suid' => $this->engine->getSuid())) . '&se=' . addslashes(USCIC_SMS) . '"><span class="glyphicon glyphicon-home"></span> ' . Language::linkBackToNubis() . '</a></li>                   
                    <li class="divider"></li>
                   <li><a href="index.php?rs=1&se=2"><span class="glyphicon glyphicon-log-out"></span> ' . Language::linkLogout() . '</a></li>
                 </ul>
             </li>
            </ul>
';
        $returnStr .= '</div><!--/.nav-collapse --> </div> </div>';
        return $returnStr;
    }
Ejemplo n.º 17
0
 function showTest($content = "")
 {
     $returnStr = $this->showToolsHeader(Language::headerToolsTester());
     $returnStr .= $content;
     $surveys = new Surveys();
     $surveys = $surveys->getSurveys();
     if (sizeof($surveys) > 0) {
         $returnStr .= "<form id=refreshform method=post>";
         $returnStr .= '<input type=hidden name=page value="translator.tools.test">';
         $returnStr .= '<input type=hidden name="' . SMS_POST_SURVEY . '" id="' . SMS_POST_SURVEY . '_hidden" value="' . getSurvey() . '">';
         $returnStr .= '<input type=hidden name="' . SMS_POST_MODE . '" id="' . SMS_POST_MODE . '_hidden" value="' . getSurveyMode() . '">';
         $returnStr .= '<input type=hidden name="' . SMS_POST_LANGUAGE . '" id="' . SMS_POST_LANGUAGE . '_hidden" value="' . getSurveyLanguage() . '">';
         $returnStr .= "</form>";
         $returnStr .= "<form method=post>";
         $returnStr .= '<input type=hidden name=' . POST_PARAM_SE . ' value="' . addslashes(USCIC_SURVEY) . '">';
         $returnStr .= '<input type=hidden name=' . POST_PARAM_PRIMKEY . ' value="' . addslashes(encryptC(generateRandomPrimkey(8), Config::directLoginKey())) . '">';
         $returnStr .= '<input type=hidden name=' . POST_PARAM_NEW_PRIMKEY . ' value="1">';
         $returnStr .= '<input type=hidden name=' . POST_PARAM_SURVEY_EXECUTION_MODE . ' value="' . SURVEY_EXECUTION_MODE_TEST . '">';
         $returnStr .= '<span class="label label-default">' . Language::labelToolsTestSettings() . '</span>';
         $returnStr .= '<div class="well well-sm">';
         $returnStr .= $this->displayComboBox();
         $returnStr .= '<table>';
         $returnStr .= '<tr><td>' . Language::labelTestSurvey() . "</td><td><select onchange='document.getElementById(\"" . SMS_POST_SURVEY . "_hidden\").value=this.value; document.getElementById(\"refreshform\").submit();' name=" . POST_PARAM_SUID . " class='selectpicker show-tick'>";
         $current = new Survey(getSurvey());
         foreach ($surveys as $survey) {
             $selected = "";
             if ($survey->getSuid() == $current->getSuid()) {
                 $selected = "SELECTED";
             }
             $returnStr .= "<option {$selected} value=" . $survey->getSuid() . '>' . $survey->getName() . '</option>';
         }
         $returnStr .= "</select></td></tr>";
         $user = new User($_SESSION['URID']);
         $cm = getSurveyMode();
         $cl = getSurveyLanguage();
         $modes = $user->getModes(getSurvey());
         $langs = explode("~", $user->getLanguages(getSurvey(), getSurveyMode()));
         $default = $current->getDefaultLanguage();
         if (!inArray($default, $langs)) {
             $langs[] = $default;
         }
         $returnStr .= "<tr><td>" . Language::labelTestModeInput() . "</td><td>" . $this->displayModesAdmin(POST_PARAM_MODE, POST_PARAM_MODE, getSurveyMode(), "", implode("~", $modes), "onchange='document.getElementById(\"" . SMS_POST_MODE . "_hidden\").value=this.value; document.getElementById(\"refreshform\").submit();'") . "</td></tr>";
         $returnStr .= "<tr><td>" . Language::labelTestLanguage() . "</td><td>" . $this->displayLanguagesAdmin(POST_PARAM_LANGUAGE, POST_PARAM_LANGUAGE, getSurveyLanguage(), true, true, false, "", implode("~", $langs)) . "</td></tr>";
         $returnStr .= '</table>';
         $returnStr .= '</div>';
         $returnStr .= '<button type="submit" class="btn btn-default navbar-btn">' . Language::buttonTest() . '</button>';
         $returnStr .= "</form>";
     } else {
         $returnStr .= $this->displayInfo(Language::messageNoSurveysAvailable());
     }
     $returnStr .= '</p></div></div>';
     //container and wrap
     $returnStr .= $this->showBottomBar();
     $returnStr .= $this->showFooter(false);
     return $returnStr;
 }
Ejemplo n.º 18
0
function checkUserAccess()
{
    $user = new User($_SESSION['URID']);
    $cm = getSurveyMode();
    $cl = getSurveyLanguage();
    $modes = $user->getModes();
    $languages = explode("~", $user->getLanguages(getSurvey(), getSurveyMode()));
    if (!inArray($cm, $modes) || !inArray($cl, $languages)) {
        return false;
    }
    return true;
}
Ejemplo n.º 19
0
function applet_modules()
{
    $inCore = cmsCore::getInstance();
    $inDB = cmsDatabase::getInstance();
    global $_LANG;
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/modules', $adminAccess)) {
        cpAccessDenied();
    }
    $GLOBALS['cp_page_title'] = $_LANG['AD_MODULES'];
    cpAddPathway($_LANG['AD_MODULES'], 'index.php?view=modules');
    $GLOBALS['cp_page_head'][] = '<script language="JavaScript" type="text/javascript" src="js/modules.js"></script>';
    $do = cmsCore::request('do', 'str', 'list');
    $id = cmsCore::request('id', 'int', -1);
    $co = cmsCore::request('co', 'int', -1);
    //============================================================================//
    //============================================================================//
    if ($do == 'config') {
        $module_name = cpModuleById($id);
        $module_title = cpModuleTitleById($id);
        if (!$module_name) {
            cmsCore::redirect('index.php?view=modules&do=edit&id=' . $id);
        }
        $xml_file = PATH . '/admin/modules/' . $module_name . '/backend.xml';
        $php_file = 'modules/' . $module_name . '/backend.php';
        if (!file_exists($xml_file)) {
            if (file_exists($php_file)) {
                include $php_file;
                return;
            }
            cmsCore::halt();
        }
        $cfg = $inCore->loadModuleConfig($id);
        cmsCore::loadClass('formgen');
        $formGen = new cmsFormGen($xml_file, $cfg);
        cpAddPathway($module_title, '?view=modules&do=edit&id=' . $id);
        cpAddPathway($_LANG['AD_SETTINGS']);
        echo '<h3>' . $module_title . '</h3>';
        $toolmenu[] = array('icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:submitModuleConfig();');
        $toolmenu[] = array('icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => 'index.php?view=modules');
        $toolmenu[] = array('icon' => 'edit.gif', 'title' => $_LANG['AD_EDIT_MODULE_VIEW'], 'link' => '?view=modules&do=edit&id=' . $id);
        cpToolMenu($toolmenu);
        echo '<form action="index.php?view=modules&do=save_auto_config&id=' . $id . '" method="post" name="optform" target="_self" id="optform">';
        echo $formGen->getHTML();
        echo '</form>';
        return;
    }
    //============================================================================//
    //============================================================================//
    if ($do == 'save_auto_config') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        $module_name = cpModuleById($id);
        $is_ajax = cmsCore::inRequest('ajax');
        if ($is_ajax) {
            $title = cmsCore::request('title', 'str', '');
            $published = cmsCore::request('published', 'int', 0);
            $inDB->query("UPDATE cms_modules SET title='{$title}', published='{$published}' WHERE id={$id}");
            if (cmsCore::inRequest('content')) {
                $content = $inDB->escape_string(cmsCore::request('content', 'html'));
                $inDB->query("UPDATE cms_modules SET content='{$content}' WHERE id={$id}");
            }
            // Добавим возможность изменять css_префикс с фронта
            if (cmsCore::inRequest('css_prefix')) {
                // На шаблонах не не отдающих параметра затирать класс не будем
                $css_prefix = cmsCore::request('css_prefix', 'str', '');
                $inDB->query("UPDATE cms_modules SET css_prefix='{$css_prefix}' WHERE id='{$id}'");
            }
        }
        if (cmsCore::inRequest('title_only')) {
            cmsCore::redirectBack();
        }
        $xml_file = PATH . '/admin/modules/' . $module_name . '/backend.xml';
        if (!file_exists($xml_file)) {
            cmsCore::halt();
        }
        $cfg = array();
        $backend = simplexml_load_file($xml_file);
        foreach ($backend->params->param as $param) {
            $name = (string) $param['name'];
            $type = (string) $param['type'];
            $default = (string) $param['default'];
            switch ($param['type']) {
                case 'number':
                    $value = cmsCore::request($name, 'int', $default);
                    break;
                case 'string':
                    $value = cmsCore::request($name, 'str', $default);
                    break;
                case 'html':
                    $value = cmsCore::badTagClear(cmsCore::request($name, 'html', $default));
                    break;
                case 'flag':
                    $value = cmsCore::request($name, 'int', 0);
                    break;
                case 'list':
                    $value = is_array($_POST[$name]) ? cmsCore::request($name, 'array_str', $default) : cmsCore::request($name, 'str', $default);
                    break;
                case 'list_function':
                    $value = cmsCore::request($name, 'str', $default);
                    break;
                case 'list_db':
                    $value = is_array($_POST[$name]) ? cmsCore::request($name, 'array_str', $default) : cmsCore::request($name, 'str', $default);
                    break;
            }
            $cfg[$name] = $value;
        }
        $inCore->saveModuleConfig($id, $cfg);
        if (!$is_ajax) {
            cmsCore::addSessionMessage($_LANG['AD_CONFIG_SAVE_SUCCESS'], 'success');
        }
        cmsCore::redirectBack();
    }
    //============================================================================//
    //============================================================================//
    if ($do == 'list') {
        $toolmenu[] = array('icon' => 'new.gif', 'title' => $_LANG['AD_MODULE_ADD'], 'link' => '?view=modules&do=add');
        $toolmenu[] = array('icon' => 'install.gif', 'title' => $_LANG['AD_MODULES_SETUP'], 'link' => '?view=install&do=module');
        $toolmenu[] = array('icon' => 'edit.gif', 'title' => $_LANG['AD_EDIT_SELECTED'], 'link' => "javascript:checkSel('?view=modules&do=edit&multiple=1');");
        $toolmenu[] = array('icon' => 'delete.gif', 'title' => $_LANG['AD_DELETE_SELECTED'], 'link' => "javascript:checkSel('?view=modules&do=delete&multiple=1');");
        $toolmenu[] = array('icon' => 'show.gif', 'title' => $_LANG['AD_ALLOW_SELECTED'], 'link' => "javascript:checkSel('?view=modules&do=show&multiple=1');");
        $toolmenu[] = array('icon' => 'hide.gif', 'title' => $_LANG['AD_DISALLOW_SELECTED'], 'link' => "javascript:checkSel('?view=modules&do=hide&multiple=1');");
        $toolmenu[] = array('icon' => 'autoorder.gif', 'title' => $_LANG['AD_MODULE_ORDER'], 'link' => '?view=modules&do=autoorder');
        $toolmenu[] = array('icon' => 'reorder.gif', 'title' => $_LANG['AD_SAVE_ORDER'], 'link' => "javascript:checkSel('?view=modules&do=saveorder');");
        $toolmenu[] = array('icon' => 'help.gif', 'title' => $_LANG['AD_HELP'], 'link' => '?view=help&topic=modules');
        cpToolMenu($toolmenu);
        $fields[] = array('title' => 'id', 'field' => 'id', 'width' => '30');
        $fields[] = array('title' => $_LANG['AD_TITLE'], 'field' => array('title', 'titles'), 'width' => '', 'link' => '?view=modules&do=edit&id=%id%', 'prc' => function ($i) {
            $i['titles'] = cmsCore::yamlToArray($i['titles']);
            // переопределяем название пункта меню в зависимости от языка
            if (!empty($i['titles'][cmsConfig::getConfig('lang')])) {
                $i['title'] = $i['titles'][cmsConfig::getConfig('lang')];
            }
            return $i['title'];
        });
        $fields[] = array('title' => $_LANG['TITLE'], 'field' => 'name', 'width' => '220', 'filter' => '15');
        $fields[] = array('title' => $_LANG['AD_VERSION'], 'field' => 'version', 'width' => '55');
        $fields[] = array('title' => $_LANG['AD_AUTHOR'], 'field' => 'author', 'width' => '110');
        $fields[] = array('title' => $_LANG['SHOW'], 'field' => 'published', 'width' => '65');
        $fields[] = array('title' => $_LANG['AD_ORDER'], 'field' => 'ordering', 'width' => '75');
        $fields[] = array('title' => $_LANG['AD_POSITION'], 'field' => 'position', 'width' => '70', 'filter' => '10', 'filterlist' => cpGetList('positions'));
        $actions[] = array('title' => $_LANG['AD_CONFIG'], 'icon' => 'config.gif', 'link' => '?view=modules&do=config&id=%id%', 'condition' => 'cpModuleHasConfig');
        $actions[] = array('title' => $_LANG['EDIT'], 'icon' => 'edit.gif', 'link' => '?view=modules&do=edit&id=%id%');
        $actions[] = array('title' => $_LANG['DELETE'], 'icon' => 'delete.gif', 'confirm' => $_LANG['AD_MODULE_DELETE'], 'link' => '?view=modules&do=delete&id=%id%');
        cpListTable('cms_modules', $fields, $actions, '', 'published DESC, position, ordering ASC');
    }
    //============================================================================//
    //============================================================================//
    if ($do == 'autoorder') {
        $rs = $inDB->query("SELECT id, position FROM cms_modules ORDER BY position");
        if ($inDB->num_rows($rs)) {
            $ord = 1;
            while ($item = $inDB->fetch_assoc($rs)) {
                if (isset($latest_pos)) {
                    if ($latest_pos != $item['position']) {
                        $ord = 1;
                    }
                }
                $inDB->query("UPDATE cms_modules SET ordering = {$ord} WHERE id='{$item['id']}'");
                $ord += 1;
                $latest_pos = $item['position'];
            }
        }
        cmsCore::redirect('index.php?view=modules');
    }
    //============================================================================//
    //============================================================================//
    if ($do == 'move_up') {
        if ($id >= 0) {
            dbMoveUp('cms_modules', $id, $co);
        }
        cmsCore::redirectBack();
    }
    if ($do == 'move_down') {
        if ($id >= 0) {
            dbMoveDown('cms_modules', $id, $co);
        }
        cmsCore::redirectBack();
    }
    //============================================================================//
    //============================================================================//
    if ($do == 'saveorder') {
        if (isset($_REQUEST['ordering'])) {
            $ord = $_REQUEST['ordering'];
            $ids = $_REQUEST['ids'];
            foreach ($ord as $id => $ordering) {
                $inDB->query("UPDATE cms_modules SET ordering = '" . (int) $ordering . "' WHERE id = '" . (int) $ids[$id] . "'");
            }
            cmsCore::redirect('index.php?view=modules');
        }
    }
    //============================================================================//
    //============================================================================//
    if ($do == 'show') {
        if (!isset($_REQUEST['item'])) {
            if ($id >= 0) {
                dbShow('cms_modules', $id);
            }
            echo '1';
            exit;
        } else {
            dbShowList('cms_modules', cmsCore::request('item', 'array_int', array()));
            cmsCore::redirectBack();
        }
    }
    if ($do == 'hide') {
        if (!isset($_REQUEST['item'])) {
            if ($id >= 0) {
                dbHide('cms_modules', $id);
            }
            echo '1';
            exit;
        } else {
            dbHideList('cms_modules', cmsCore::request('item', 'array_int', array()));
            cmsCore::redirectBack();
        }
    }
    if ($do == 'delete') {
        if (!isset($_REQUEST['item'])) {
            $inCore->removeModule($id);
        } else {
            $inCore->removeModule(cmsCore::request('item', 'array_int', array()));
        }
        cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
        cmsCore::redirect('index.php?view=modules');
    }
    //============================================================================//
    //============================================================================//
    if ($do == 'update') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        $id = cmsCore::request('id', 'int', 0);
        $name = cmsCore::request('name', 'str', '');
        $title = cmsCore::request('title', 'str', '');
        $titles = cmsCore::arrayToYaml(cmsCore::request('titles', 'array_str', array()));
        $position = cmsCore::request('position', 'str', '');
        $showtitle = cmsCore::request('showtitle', 'int', 0);
        $content = $inDB->escape_string(cmsCore::request('content', 'html', ''));
        $published = cmsCore::request('published', 'int', 0);
        $css_prefix = cmsCore::request('css_prefix', 'str', '');
        $is_strict_bind = cmsCore::request('is_strict_bind', 'int', 0);
        $is_strict_bind_hidden = cmsCore::request('is_strict_bind_hidden', 'int', 0);
        $is_public = cmsCore::request('is_public', 'int', '');
        if (!$is_public) {
            $access_list = cmsCore::arrayToYaml(cmsCore::request('allow_group', 'array_int', array()));
        }
        $template = cmsCore::request('template', 'str', '');
        $cache = cmsCore::request('cache', 'int', 0);
        $cachetime = cmsCore::request('cachetime', 'int', 0);
        $cacheint = cmsCore::request('cacheint', 'str', '');
        $sql = "UPDATE cms_modules\r\n                SET name='{$name}',\r\n                    title='{$title}',\r\n                    titles='{$titles}',\r\n                    position='{$position}',\r\n                    template='{$template}',\r\n                    showtitle={$showtitle},";
        if ($content) {
            $sql .= "content='{$content}',";
        }
        $sql .= "\r\n                    published={$published},\r\n                    css_prefix='{$css_prefix}',\r\n                    access_list='{$access_list}',\r\n                    hidden_menu_ids='',\r\n                    cachetime = '{$cachetime}',\r\n                    cacheint = '{$cacheint}',\r\n                    cache = '{$cache}',\r\n                    is_strict_bind = '{$is_strict_bind}',\r\n                    is_strict_bind_hidden = '{$is_strict_bind_hidden}'\r\n                WHERE id = '{$id}'\r\n                LIMIT 1";
        $inDB->query($sql);
        $sql = "DELETE FROM cms_modules_bind WHERE module_id = {$id}";
        $inDB->query($sql);
        if (cmsCore::request('show_all', 'int', 0)) {
            $sql = "INSERT INTO cms_modules_bind (module_id, menu_id, position)\r\n                    VALUES ({$id}, 0, '{$position}')";
            $inDB->query($sql);
            $hidden_menu_ids = cmsCore::request('hidden_menu_ids', 'array_int', array());
            if ($hidden_menu_ids) {
                $hidden_menu_ids = cmsCore::arrayToYaml($hidden_menu_ids);
                $inDB->query("UPDATE cms_modules SET hidden_menu_ids='{$hidden_menu_ids}' WHERE id = '{$id}' LIMIT 1");
            }
        } else {
            $showin = cmsCore::request('showin', 'array_int', array());
            $showpos = cmsCore::request('showpos', 'array_str', array());
            if ($showin) {
                foreach ($showin as $key => $value) {
                    $sql = "INSERT INTO cms_modules_bind (module_id, menu_id, position)\r\n                            VALUES ({$id}, {$value}, '{$showpos[$value]}')";
                    $inDB->query($sql);
                }
            }
        }
        cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
        if (!isset($_SESSION['editlist']) || @sizeof($_SESSION['editlist']) == 0) {
            cmsCore::redirect('index.php?view=modules');
        } else {
            cmsCore::redirect('index.php?view=modules&do=edit');
        }
    }
    //============================================================================//
    //============================================================================//
    if ($do == 'submit') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        $sql = "SELECT ordering as max_o FROM cms_menu ORDER BY ordering DESC LIMIT 1";
        $result = $inDB->query($sql);
        $row = $inDB->fetch_assoc($result);
        $maxorder = $row['max_o'] + 1;
        $name = cmsCore::request('name', 'str', '');
        $title = cmsCore::request('title', 'str', '');
        $titles = cmsCore::arrayToYaml(cmsCore::request('titles', 'array_str', array()));
        $position = cmsCore::request('position', 'str', '');
        $showtitle = cmsCore::request('showtitle', 'int', 0);
        $content = $inDB->escape_string(cmsCore::request('content', 'html', ''));
        $published = cmsCore::request('published', 'int', 0);
        $css_prefix = cmsCore::request('css_prefix', 'str', '');
        $is_public = cmsCore::request('is_public', 'int', '');
        if (!$is_public) {
            $access_list = cmsCore::arrayToYaml(cmsCore::request('allow_group', 'array_int', array()));
        }
        $template = cmsCore::request('template', 'str', '');
        $cache = cmsCore::request('cache', 'int', 0);
        $cachetime = cmsCore::request('cachetime', 'int', 0);
        $cacheint = cmsCore::request('cacheint', 'str', '');
        $operate = cmsCore::request('operate', 'str', '');
        $is_strict_bind = cmsCore::request('is_strict_bind', 'int', 0);
        $is_strict_bind_hidden = cmsCore::request('is_strict_bind_hidden', 'int', 0);
        if ($operate == 'user') {
            //USER MODULE
            $sql = "INSERT INTO cms_modules (position, name, title, titles, is_external, content, ordering, showtitle, published, user, original, css_prefix, access_list, template, is_strict_bind, is_strict_bind_hidden)\r\n\t\t\t\t\tVALUES ('{$position}', '{$name}', '{$title}', '{$titles}', 0, '{$content}', '{$maxorder}', '{$showtitle}', '{$published}', 1, 1, '{$css_prefix}', '{$access_list}', '{$template}', '{$is_strict_bind}', '{$is_strict_bind_hidden}')";
            $inDB->query($sql);
        }
        if ($operate == 'clone') {
            //DUPLICATE MODULE
            $mod_id = cmsCore::request('clone_id', 'int', 0);
            $sql = "SELECT * FROM cms_modules WHERE id = {$mod_id} LIMIT 1";
            $result = $inDB->query($sql);
            $original = $inDB->escape_string($inDB->fetch_assoc($result));
            $is_original = cmsCore::request('del_orig', 'int', 0) ? 1 : 0;
            $sql = "INSERT INTO cms_modules (position, name, title, titles, is_external,\r\n                                             content, ordering, showtitle, published,\r\n                                             original, user, config, css_prefix, template,\r\n                                             access_list, is_strict_bind, is_strict_bind_hidden,\r\n                                             cache, cachetime, cacheint, version)\r\n\t\t\t\t\tVALUES (\r\n\t\t\t\t\t\t\t'{$position}',\r\n\t\t\t\t\t\t\t'{$original['name']}',\r\n\t\t\t\t\t\t\t'{$title}',\r\n\t\t\t\t\t\t\t'{$titles}',\r\n\t\t\t\t\t\t\t'{$original['is_external']}',\r\n\t\t\t\t\t\t\t'{$original['content']}',\r\n\t\t\t\t\t\t\t'{$maxorder}',\r\n\t\t\t\t\t\t\t'{$showtitle}',\r\n\t\t\t\t\t\t\t'{$published}',\r\n\t\t\t\t\t\t\t'{$is_original}',\r\n\t\t\t\t\t\t\t'{$original['user']}',\r\n\t\t\t\t\t\t\t'{$original['config']}',\r\n\t\t\t\t\t\t\t'{$css_prefix}',\r\n                            '{$template}',\r\n                            '{$access_list}',\r\n                            '{$is_strict_bind}',\r\n                            '{$is_strict_bind_hidden}',\r\n                            '{$cache}', '{$cachetime}', '{$cacheint}', '{$original['version']}'\r\n                            )";
            $inDB->query($sql);
            if ($is_original) {
                $sql = "DELETE FROM cms_modules WHERE id = {$mod_id}";
                $inDB->query($sql);
            }
        }
        $lastid = $inDB->get_last_id('cms_modules');
        if (cmsCore::request('show_all', 'int', 0)) {
            $sql = "INSERT INTO cms_modules_bind (module_id, menu_id, position)\r\n\t\t\t\t\tVALUES ({$lastid}, 0, '{$position}')";
            $inDB->query($sql);
            $hidden_menu_ids = cmsCore::request('hidden_menu_ids', 'array_int', array());
            if ($hidden_menu_ids) {
                $hidden_menu_ids = cmsCore::arrayToYaml($hidden_menu_ids);
                $inDB->query("UPDATE cms_modules SET hidden_menu_ids='{$hidden_menu_ids}' WHERE id = '{$lastid}' LIMIT 1");
            }
        } else {
            $showin = cmsCore::request('showin', 'array_int', array());
            $showpos = cmsCore::request('showpos', 'array_str', array());
            if ($showin) {
                foreach ($showin as $key => $value) {
                    $sql = "INSERT INTO cms_modules_bind (module_id, menu_id, position)\r\n\t\t\t\t\t\t\tVALUES ({$lastid}, {$value}, '{$showpos[$value]}')";
                    $inDB->query($sql);
                }
            }
        }
        cmsCore::addSessionMessage($_LANG['AD_MODULE_ADD_SITE'], 'success');
        cmsCore::redirect('index.php?view=modules');
    }
    //============================================================================//
    //============================================================================//
    if ($do == 'add' || $do == 'edit') {
        require '../includes/jwtabs.php';
        $GLOBALS['cp_page_head'][] = jwHeader();
        $langs = cmsCore::getDirsList('/languages');
        if ($do == 'add') {
            cpAddPathway($_LANG['AD_MODULE_ADD']);
            echo '<h3>' . $_LANG['AD_MODULE_ADD'] . '</h3>';
            $show_all = false;
        } else {
            if (isset($_REQUEST['multiple'])) {
                if (isset($_REQUEST['item'])) {
                    $_SESSION['editlist'] = cmsCore::request('item', 'array_int', array());
                } else {
                    cmsCore::addSessionMessage($_LANG['AD_NO_SELECT_OBJECTS'], 'error');
                    cmsCore::redirectBack();
                }
            }
            $ostatok = '';
            if (isset($_SESSION['editlist'])) {
                $item_id = array_shift($_SESSION['editlist']);
                if (sizeof($_SESSION['editlist']) == 0) {
                    unset($_SESSION['editlist']);
                } else {
                    $ostatok = '(' . $_LANG['AD_NEXT_IN'] . sizeof($_SESSION['editlist']) . ')';
                }
            } else {
                $item_id = cmsCore::request('id', 'int', 0);
            }
            $mod = $inDB->get_fields('cms_modules', "id = '{$item_id}'", '*');
            if (!$mod) {
                cmsCore::error404();
            }
            $mod['hidden_menu_ids'] = cmsCore::yamlToArray($mod['hidden_menu_ids']);
            $mod['titles'] = cmsCore::yamlToArray($mod['titles']);
            $sql = "SELECT id FROM cms_modules_bind WHERE module_id = {$id} AND menu_id = 0 LIMIT 1";
            $result = $inDB->query($sql);
            if ($inDB->num_rows($result)) {
                $show_all = true;
            } else {
                $show_all = false;
            }
            echo '<h3>' . $_LANG['AD_EDIT_MODULE'] . $ostatok . '</h3>';
            cpAddPathway($mod['name']);
        }
        $toolmenu[] = array('icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:document.addform.submit();');
        $toolmenu[] = array('icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => 'javascript:history.go(-1);');
        if (@$mod['is_external']) {
            $php_file = 'modules/' . $mod['content'] . '/backend.php';
            $xml_file = 'modules/' . $mod['content'] . '/backend.xml';
            if (file_exists($php_file) || file_exists($xml_file)) {
                $toolmenu[] = array('icon' => 'config.gif', 'title' => $_LANG['CONFIG_MODULE'], 'link' => '?view=modules&do=config&id=' . $mod['id']);
            }
        }
        cpToolMenu($toolmenu);
        ?>
    <form id="addform" name="addform" method="post" action="index.php">
        <input type="hidden" name="csrf_token" value="<?php 
        echo cmsUser::getCsrfToken();
        ?>
" />
        <input type="hidden" name="view" value="modules" />

        <table class="proptable" width="100%" cellpadding="15" cellspacing="2">
            <tr>

                <!-- главная ячейка -->
                <td valign="top">

                    <div><strong><?php 
        echo $_LANG['AD_MODULE_TITLE'];
        ?>
</strong> <span class="hinttext">&mdash; <?php 
        echo $_LANG['AD_VIEW_IN_SITE'];
        ?>
</span></div>
                    <div>
                        <table width="100%" cellpadding="0" cellspacing="0" border="0">
                            <tr>
                                <td><input name="title" type="text" id="title" style="width:100%" value="<?php 
        echo htmlspecialchars($mod['title']);
        ?>
" /></td>
                                <td style="width:15px;padding-left:10px;padding-right:0px;">
                                    <input type="checkbox" title="<?php 
        echo $_LANG['AD_VIEW_TITLE'];
        ?>
" name="showtitle" <?php 
        if ($mod['showtitle'] || $do == 'add') {
            echo 'checked="checked"';
        }
        ?>
 value="1">
                                </td>
                            </tr>
                        </table>
                    </div>
                    <?php 
        if (count($langs) > 1) {
            ?>
                    <div><strong><?php 
            echo $_LANG['AD_LANG_TITLES'];
            ?>
</strong> <span class="hinttext">&mdash; <?php 
            echo $_LANG['AD_LANG_TITLES_HINT'];
            ?>
</span></div>
                    <?php 
            foreach ($langs as $lang) {
                ?>

                    <div><strong><?php 
                echo $lang;
                ?>
:</strong> <input name="titles[<?php 
                echo $lang;
                ?>
]" type="text" style="width:97%" value="<?php 
                echo htmlspecialchars(@$mod['titles'][$lang]);
                ?>
" placeholder="<?php 
                echo $_LANG['AD_HINT_DEFAULT'];
                ?>
" /></div>
                    <?php 
            }
            ?>
                    <?php 
        }
        ?>
                    <table width="100%" cellpadding="0" cellspacing="0" border="0" style="margin-top:10px;">
                        <tr>
                            <td valign="top">
                                <div>
                                    <strong><?php 
        echo $_LANG['AD_MODULE_NAME'];
        ?>
</strong> <span class="hinttext">&mdash; <?php 
        echo $_LANG['AD_SHOW_ADMIN'];
        ?>
</span>
                                </div>
                                <div>
                                    <?php 
        if (!isset($mod['user']) || @$mod['user'] == 1) {
            ?>
                                        <input name="name" type="text" id="name" style="width:99%" value="<?php 
            echo htmlspecialchars($mod['name']);
            ?>
" />
                                    <?php 
        } else {
            ?>
                                        <input name="" type="text" id="name" style="width:99%" value="<?php 
            echo @$mod['name'];
            ?>
" disabled="disabled" />
                                        <input name="name" type="hidden" value="<?php 
            echo htmlspecialchars($mod['name']);
            ?>
" />
                                    <?php 
        }
        ?>
                                </div>
                            </td>
                            <td valign="top" width="160" style="padding-left:10px;">
                                <div>
                                    <strong><?php 
        echo $_LANG['AD_PREFIX_CSS'];
        ?>
</strong>
                                </div>
                                <div>
                                    <input name="css_prefix" type="text" id="css_prefix" value="<?php 
        echo @$mod['css_prefix'];
        ?>
" style="width:154px" />
                                </div>
                            </td>
                        </tr>
                    </table>

                    <div style="margin-top:8px">
                        <strong><?php 
        echo $_LANG['AD_DEFOLT_VIEW'];
        ?>
</strong> <span class="hinttext">&mdash; <?php 
        echo $_LANG['AD_POSITION_MUST_BE'];
        ?>
</span>
                    </div>
                    <div>
                        <?php 
        $pos = cpModulePositions(cmsConfig::getConfig('template'));
        ?>
                        <table width="100%" cellpadding="0" cellspacing="0" border="0" style="margin-top:5px;">
                            <tr>
                                <td valign="top">
                                    <select name="position" id="position" style="width:100%">
                                        <?php 
        if ($pos) {
            foreach ($pos as $key => $position) {
                if (@$mod['position'] == $position) {
                    echo '<option value="' . $position . '" selected>' . $position . '</option>';
                } else {
                    echo '<option value="' . $position . '">' . $position . '</option>';
                }
            }
        }
        ?>
                                    </select>
                                </td>
                                <?php 
        if (file_exists(PATH . '/templates/' . TEMPLATE . '/positions.jpg')) {
            ?>
                                <td valign="top" width="160" style="padding-left:10px;">
                                    <script>
                                    $(function() {
                                        $('#pos').dialog({modal: true, autoOpen: false, closeText: LANG_CLOSE, width: 'auto'});
                                    });
                                    </script>
                                    <a onclick="$('#pos').dialog('open');return false;" href="#" class="ajaxlink"><?php 
            echo $_LANG['AD_SEE_VISUALLY'];
            ?>
</a>
                                    <div id="pos" title="<?php 
            echo $_LANG['AD_TPL_POS'];
            ?>
"><img src="/templates/<?php 
            echo TEMPLATE;
            ?>
/positions.jpg" alt="<?php 
            echo $_LANG['AD_TPL_POS'];
            ?>
" /></div>
                                </td>
                                <?php 
        }
        ?>
                            </tr>
                        </table>
                    </div>

                    <div style="margin-top:15px">
                        <strong><?php 
        echo $_LANG['AD_MODULE_TEMPLATE'];
        ?>
</strong> <span class="hinttext">&mdash; <?php 
        echo $_LANG['AD_FOLDER_MODULES'];
        ?>
</span>
                    </div>
                    <div>
                        <?php 
        $tpls = cmsAdmin::getModuleTemplates();
        ?>
                        <select name="template" id="template" style="width:100%">
                            <?php 
        foreach ($tpls as $tpl) {
            $selected = $mod['template'] == $tpl || !$mod['template'] && $tpl == 'module.tpl' ? 'selected="selected"' : '';
            echo '<option value="' . $tpl . '" ' . $selected . '>' . $tpl . '</option>';
        }
        ?>
                        </select>
                    </div>

                    <?php 
        if ($do == 'add') {
            ?>
                    <div style="margin-top:15px">
                        <strong><?php 
            echo $_LANG['AD_MODULE_TYPE'];
            ?>
</strong>
                    </div>
                    <div>
                        <select name="operate" id="operate" onchange="checkDiv()" style="width:100%">
                            <option value="user" selected="selected"><?php 
            echo $_LANG['AD_MODULE_TYPE_NEW'];
            ?>
</option>
                            <option value="clone"><?php 
            echo $_LANG['AD_MODULE_TYPE_COPY'];
            ?>
</option>
                        </select>
                    </div>
                    <?php 
        }
        ?>

                    <?php 
        if (!isset($mod['user']) || $mod['user'] == 1 || $do == 'add') {
            ?>
                        <div id="user_div">
                            <div style="margin-top:15px">
                                <strong><?php 
            echo $_LANG['AD_MODULE_CONTENT'];
            ?>
</strong>
                            </div>
                            <div><?php 
            insertPanel();
            ?>
</div>
                            <div>
                                <?php 
            $inCore->insertEditor('content', $mod['content'], '250', '100%');
            ?>
                            </div>
                        </div>
                    <?php 
        }
        ?>

                <div id="clone_div" style="display:none;">
                        <div style="margin-top:15px">
                            <strong><?php 
        echo $_LANG['AD_MODULE_COPY'];
        ?>
</strong>
                        </div>
                        <div>
                            <select name="clone_id" id="clone_id" style="width:100%">
                                <?php 
        echo $inCore->getListItems('cms_modules');
        ?>
                            </select>
                            <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist" style="margin-top:6px">
                                <tr>
                                    <td width="20"><input type="checkbox" name="del_orig" id="del_orig" value="1" /></td>
                                    <td><label for="del_orig"><?php 
        echo $_LANG['AD_ORIGINAL_MODULE_DELETE'];
        ?>
</label></td>
                                </tr>
                            </table>
                        </div>
                </div>

                </td>

                <!-- боковая ячейка -->
                <td width="300" valign="top" style="background:#ECECEC;">

                    <?php 
        ob_start();
        ?>

                    {tab=<?php 
        echo $_LANG['AD_TAB_PUBLISH'];
        ?>
}

                    <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist">
                        <tr>
                            <td width="20"><input type="checkbox" name="published" id="published" value="1" <?php 
        if ($mod['published'] || $do == 'add') {
            echo 'checked="checked"';
        }
        ?>
/></td>
                            <td><label for="published"><strong><?php 
        echo $_LANG['AD_MODULE_PUBLIC'];
        ?>
</strong></label></td>
                        </tr>
                        <tr>
                            <td width="20"><input name="show_all" id="show_all" type="checkbox" value="1" onclick="checkGroupList()" <?php 
        if ($show_all) {
            echo 'checked';
        }
        ?>
 /></td>
                            <td><label for="show_all"><strong><?php 
        echo $_LANG['AD_VIEW_ALL_PAGES'];
        ?>
</strong></label></td>
                        </tr>
                    </table>

                    <?php 
        if ($do == 'edit') {
            $bind_sql = "SELECT * FROM cms_modules_bind WHERE module_id = " . $mod['id'];
            $bind_res = $inDB->query($bind_sql);
            $bind = array();
            $bind_pos = array();
            while ($r = $inDB->fetch_assoc($bind_res)) {
                $bind[] = $r['menu_id'];
                $bind_pos[$r['menu_id']] = $r['position'];
            }
        }
        $menu_sql = "SELECT * FROM cms_menu ORDER BY NSLeft, ordering";
        $menu_res = $inDB->query($menu_sql);
        $menu_items = array();
        if ($inDB->num_rows($menu_res)) {
            while ($item = $inDB->fetch_assoc($menu_res)) {
                if ($do == 'edit') {
                    if (in_array($item['id'], $bind)) {
                        $item['selected'] = true;
                        $item['position'] = $bind_pos[$item['id']];
                    }
                }
                $item['titles'] = cmsCore::yamlToArray($item['titles']);
                // переопределяем название пункта меню в зависимости от языка
                if (!empty($item['titles'][cmsConfig::getConfig('lang')])) {
                    $item['title'] = $item['titles'][cmsConfig::getConfig('lang')];
                }
                $item['title'] = str_replace($_LANG['AD_ROOT_PAGES'], $_LANG['AD_MAIN'], $item['title']);
                $menu_items[] = $item;
            }
        }
        ?>

                    <div id="grp">

                        <div style="margin-top:13px">
                            <strong class="show_list"><?php 
        echo $_LANG['AD_WHERE_MODULE_VIEW'];
        ?>
</strong>
                            <strong class="hide_list"><?php 
        echo $_LANG['AD_WHERE_MODULE_NOT_VIEW'];
        ?>
</strong>
                        </div>

                        <div style="height:300px;overflow: auto;border: solid 1px #999; padding:5px 10px; background: #FFF;">
                        <table cellpadding="0" cellspacing="0" border="0" width="100%" align="center">
                            <tr>
                                <td colspan="2" height="25"><strong><?php 
        echo $_LANG['AD_MENU'];
        ?>
</strong></td>
                                <td class="show_list" align="center" width="50"><strong><?php 
        echo $_LANG['AD_POSITION'];
        ?>
</strong></td>
                            </tr>
                            <?php 
        foreach ($menu_items as $i) {
            ?>
                            <tr class="show_list">
                                <td width="20" height="25">
                                    <input type="checkbox" name="showin[]" id="mid<?php 
            echo $i['id'];
            ?>
" value="<?php 
            echo $i['id'];
            ?>
" <?php 
            if ($i['selected']) {
                ?>
checked="checked"<?php 
            }
            ?>
 onclick="$('#p<?php 
            echo $i['id'];
            ?>
').toggle()"/>
                                </td>
                                <td style="padding-left:<?php 
            echo $i['NSLevel'] * 6 - 6;
            ?>
px"><label for="mid<?php 
            echo $i['id'];
            ?>
"><?php 
            echo $i['title'];
            ?>
</label></td>
                                <td align="center">
                                    <select id="p<?php 
            echo $i['id'];
            ?>
" name="showpos[<?php 
            echo $i['id'];
            ?>
]" style="<?php 
            if (!$i['selected']) {
                ?>
display:none<?php 
            }
            ?>
">
                                        <?php 
            foreach ($pos as $position) {
                ?>
                                            <option value="<?php 
                echo $position;
                ?>
" <?php 
                if ($i['position'] == $position) {
                    ?>
selected="selected"<?php 
                }
                ?>
><?php 
                echo $position;
                ?>
</option>
                                        <?php 
            }
            ?>
                                    </select>
                                </td>
                            </tr>
                            <?php 
        }
        ?>
                            <?php 
        foreach ($menu_items as $it) {
            ?>
                            <tr class="hide_list">
                                <td width="20" height="25">
                                    <input type="checkbox" name="hidden_menu_ids[]" id="hmid<?php 
            echo $it['id'];
            ?>
" value="<?php 
            echo $it['id'];
            ?>
" <?php 
            if (in_array($it['id'], $mod['hidden_menu_ids'])) {
                ?>
checked="checked"<?php 
            }
            ?>
 />
                                </td>
                                <td style="padding-left:<?php 
            echo $it['NSLevel'] * 6 - 6;
            ?>
px"><label for="hmid<?php 
            echo $it['id'];
            ?>
"><?php 
            echo $it['title'];
            ?>
</label></td>
                            </tr>
                            <?php 
        }
        ?>
                        </table>
                        </div>

                        <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist show_list">
                            <tr>
                                <td width="20"><input type="checkbox" name="is_strict_bind" id="is_strict_bind" value="1" <?php 
        if ($mod['is_strict_bind']) {
            echo 'checked="checked"';
        }
        ?>
/></td>
                                <td><label for="is_strict_bind"><strong><?php 
        echo $_LANG['AD_DONT_VIEW'];
        ?>
</strong></label></td>
                            </tr>
                        </table>
                        <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist hide_list">
                            <tr>
                                <td width="20"><input type="checkbox" name="is_strict_bind_hidden" id="is_strict_bind_hidden" value="1" <?php 
        if ($mod['is_strict_bind_hidden']) {
            echo 'checked="checked"';
        }
        ?>
/></td>
                                <td><label for="is_strict_bind_hidden"><strong><?php 
        echo $_LANG['AD_EXCEPT_NESTED'];
        ?>
</strong></label></td>
                            </tr>
                        </table>

                    </div>

					<?php 
        if ($mod['is_external'] && $do == 'edit' || $do == 'add') {
            ?>

                    {tab=<?php 
            echo $_LANG['AD_MODULE_CACHE'];
            ?>
}

                        <div style="margin-top:4px">
                            <strong><?php 
            echo $_LANG['AD_DO_MODULE_CACHE'];
            ?>
</strong>
                        </div>
                        <div>
                            <select name="cache" id="cache" style="width:100%">
                                <option value="0" <?php 
            if (@(!$mod['cache'])) {
                echo 'selected="selected"';
            }
            ?>
><?php 
            echo $_LANG['NO'];
            ?>
</option>
                                <option value="1" <?php 
            if (@$mod['cache']) {
                echo 'selected="selected"';
            }
            ?>
><?php 
            echo $_LANG['YES'];
            ?>
</option>
                            </select>
                        </div>

                        <div style="margin-top:15px">
                            <strong><?php 
            echo $_LANG['AD_MODULE_CACHE_PERIOD'];
            ?>
</strong>
                        </div>
                        <div>
                            <table width="100%" cellpadding="0" cellspacing="0" border="0" style="margin-top:5px;">
                                <tr>
                                    <td valign="top"  width="100">
                                        <input name="cachetime" type="text" id="int_1" style="width:99%" value="<?php 
            echo @(int) $mod['cachetime'];
            ?>
"/>
                                    </td>
                                    <td valign="top" style="padding-left:5px">
                                        <select name="cacheint" id="int_2" style="width:100%">
                                            <option value="MINUTE"  <?php 
            if (@mb_strstr($mod['cacheint'], 'MINUTE')) {
                echo 'selected="selected"';
            }
            ?>
><?php 
            echo cmsCore::spellCount((int) @$mod['cachetime'], $_LANG['MINUTE1'], $_LANG['MINUTE2'], $_LANG['MINUTE10'], false);
            ?>
</option>
                                            <option value="HOUR"  <?php 
            if (@mb_strstr($mod['cacheint'], 'HOUR')) {
                echo 'selected="selected"';
            }
            ?>
><?php 
            echo cmsCore::spellCount((int) @$mod['cachetime'], $_LANG['HOUR1'], $_LANG['HOUR2'], $_LANG['HOUR10'], false);
            ?>
</option>
                                            <option value="DAY" <?php 
            if (@mb_strstr($mod['cacheint'], 'DAY')) {
                echo 'selected="selected"';
            }
            ?>
><?php 
            echo cmsCore::spellCount((int) @$mod['cachetime'], $_LANG['DAY1'], $_LANG['DAY2'], $_LANG['DAY10'], false);
            ?>
</option>
                                            <option value="MONTH" <?php 
            if (@mb_strstr($mod['cacheint'], 'MONTH')) {
                echo 'selected="selected"';
            }
            ?>
><?php 
            echo cmsCore::spellCount((int) @$mod['cachetime'], $_LANG['MONTH1'], $_LANG['MONTH2'], $_LANG['MONTH10'], false);
            ?>
</option>
                                        </select>
                                    </td>
                                </tr>
                            </table>
                        </div>

                        <div style="margin-top:15px">
                            <?php 
            if ($do == 'edit') {
                if ($inCore->isCached('module', $mod['id'], $mod['cachetime'], $mod['cacheint'])) {
                    $t = 'module' . $mod['id'];
                    $cfile = PATH . '/cache/' . md5($t) . '.html';
                    if (file_exists($cfile)) {
                        $kb = round(filesize($cfile) / 1024, 2);
                        echo '<a href="index.php?view=cache&do=delcache&target=module&id=' . $mod['id'] . '">' . $_LANG['AD_MODULE_CACHE_DELETE'] . '</a> (' . $kb . $_LANG['SIZE_KB'] . ')';
                    }
                } else {
                    echo '<span style="color:gray">' . $_LANG['AD_NO_CACHE'] . '</span>';
                }
            }
            ?>
                        </div>
					<?php 
        }
        ?>

                    {tab=<?php 
        echo $_LANG['AD_TAB_ACCESS'];
        ?>
}
                    <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist" style="margin-top:5px">
                        <tr>
                            <td width="20">
                                <?php 
        $groups = cmsUser::getGroups();
        $style = 'disabled="disabled"';
        $public = 'checked="checked"';
        if ($do == 'edit') {
            if ($mod['access_list']) {
                $public = '';
                $style = '';
                $access_list = $inCore->yamlToArray($mod['access_list']);
            }
        }
        ?>
                                <input name="is_public" type="checkbox" id="is_public" onclick="checkAccesList()" value="1" <?php 
        echo $public;
        ?>
 />
                            </td>
                            <td><label for="is_public"><strong><?php 
        echo $_LANG['AD_SHARE'];
        ?>
</strong></label></td>
                        </tr>
                    </table>
                    <div style="padding:5px">
                        <span class="hinttext">
                            <?php 
        echo $_LANG['AD_IF_CHECKED'];
        ?>
                        </span>
                    </div>

                    <div style="margin-top:10px;padding:5px;padding-right:0px;">
                        <div>
                            <strong><?php 
        echo $_LANG['AD_GROUPS_VIEW'];
        ?>
</strong><br />
                            <span class="hinttext">
                                <?php 
        echo $_LANG['AD_SELECT_MULTIPLE_CTRL'];
        ?>
                            </span>
                        </div>
                        <div>
                            <?php 
        echo '<select style="width: 99%" name="allow_group[]" id="allow_group" size="6" multiple="multiple" ' . $style . '>';
        if ($groups) {
            foreach ($groups as $group) {
                echo '<option value="' . $group['id'] . '"';
                if ($do == 'edit' && $mod['access_list']) {
                    if (inArray($access_list, $group['id'])) {
                        echo 'selected="selected"';
                    }
                }
                echo '>';
                echo $group['title'] . '</option>';
            }
        }
        echo '</select>';
        ?>
                        </div>
                    </div>

                    {/tabs}

                    <?php 
        echo jwTabs(ob_get_clean());
        ?>

                </td>

            </tr>
        </table>
        <p>
            <input name="add_mod" type="submit" id="add_mod" value="<?php 
        echo $_LANG['SAVE'];
        ?>
" />
            <input name="back" type="button" id="back" value="<?php 
        echo $_LANG['CANCEL'];
        ?>
" onclick="window.history.back();" />
            <input name="do" type="hidden" id="do" <?php 
        if ($do == 'add') {
            echo 'value="submit"';
        } else {
            echo 'value="update"';
        }
        ?>
 />
            <?php 
        if ($do == 'edit') {
            echo '<input name="id" type="hidden" value="' . $mod['id'] . '" />';
        }
        ?>
        </p>
    </form>
<?php 
    }
    //============================================================================//
    //============================================================================//
}
Ejemplo n.º 20
0
 function checkArray($str, &$messages)
 {
     // http://stackoverflow.com/questions/2938137/is-there-way-to-keep-delimiter-while-using-php-explode-or-other-similar-function
     $parts = preg_split('/([\\[\\., \\]])/', $str, -1, PREG_SPLIT_DELIM_CAPTURE);
     //print_r($parts);
     //echo "<hr><hr>";
     //$sentences = array();
     //for ($i = 0, $n = count($parts) - 1; $i < $n; $i+=2) {
     //    $sentences[] = $parts[$i] . $parts[$i + 1];
     //}
     //if ($parts[$n] != '') {
     //    $sentences[] = $parts[$n];
     //}
     for ($i = 0; $i < sizeof($parts); $i++) {
         $s = $parts[$i];
         // not a delimiter
         if (!inArray($s, array("[", "]", ".", " ", ","))) {
             // see if this is a variable
             $v = $this->survey->getVariableDescriptiveByName(getBasicName($s));
             if ($v->getVsid() != "") {
                 if ($parts[$i + 1] == "[") {
                     // bracket reference
                     if ($v->isArray() == false) {
                         $messages[] = Language::messageCheckerVariableNotArray($s);
                     }
                 } else {
                     //echo $s;
                     if ($v->isArray() == true) {
                         $messages[] = Language::messageCheckerVariableArray($s);
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 21
0
 function getParadata($default = true)
 {
     /* type level setting */
     $val = $this->getSettingValue(SETTING_PARADATA, $default);
     if (!inArray($val, array("", SETTING_FOLLOW_GENERIC))) {
         return $val;
     }
     /* survey level setting */
     if ($_SESSION['PARAMETER_RETRIEVAL'] == PARAMETER_ADMIN_RETRIEVAL) {
         return SETTING_FOLLOW_GENERIC;
     }
     global $survey;
     return $survey->getParadata($default);
 }
Ejemplo n.º 22
0
 function download()
 {
     $file = pathinfo($this->downloadlocation);
     /* check */
     if (inArray($file['extension'], array(DATA_OUTPUT_FILEEXTENSION_STATA, DATA_OUTPUT_FILEEXTENSION_CSV))) {
         /* allow for time */
         set_time_limit(0);
         $lastmodified = filemtime($this->downloadlocation);
         // http://www.php.net/filemtime
         $filesize = intval(sprintf("%u", filesize($this->downloadlocation)));
         // http://stackoverflow.com/questions/5501427/php-filesize-mb-kb-conversion
         // http://www.richnetapps.com/the-right-way-to-handle-file-downloads-in-php/
         /* declare headers */
         header("Content-Description: File Transfer");
         header("Content-Type: application/force-download");
         header("Content-Type: application/download");
         header('Content-Type: application/octet-stream');
         header("Content-Length: " . $filesize);
         header("Content-Disposition: attachment; filename=" . $file['filename'] . "." . $file['extension'] . '; modification-date="' . date('r', $lastmodified) . '";');
         if ($file['extension'] == DATA_OUTPUT_FILEEXTENSION_STATA) {
             header("Content-Type: application/dta");
         } else {
             if ($file['extension'] == DATA_OUTPUT_FILEEXTENSION_CSV) {
                 header("Content-Type: application/ms-excel");
             }
         }
         /* prevent caching (http://stackoverflow.com/questions/13640109/how-to-prevent-browser-cache-for-php-site) */
         header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
         header("Cache-Control: post-check=0, pre-check=0", false);
         header("Pragma: no-cache");
         // http://stackoverflow.com/questions/15299325/x-download-options-noopen-equivalent
         header("X-Content-Type-Options: nosniff");
         // http://stackoverflow.com/questions/21723436/firefox-downloads-text-plain-instead-of-showing-it
         /* clean buffer before outputting file */
         ob_end_clean();
         // output file
         $chunksize = 1 * (1024 * 1024);
         $handle = fopen($this->downloadlocation, 'rb');
         $buffer = '';
         while (!feof($handle)) {
             print @fread($handle, $chunksize);
             //ob_flush();
             flush();
         }
         fclose($handle);
         //ob_end_clean();
         // remove temporary file
         unlink($this->downloadlocation);
         // stop
         exit;
     }
 }
Ejemplo n.º 23
0
 function getShowSectionFooter($default = true)
 {
     /* variable level setting */
     $val = $this->getSettingValue(SETTING_SHOW_SECTION_FOOTER, $default);
     if (!inArray($val, array("", SETTING_FOLLOW_GENERIC, SETTING_FOLLOW_TYPE))) {
         return $val;
     }
     /* type level setting */
     if ($val != SETTING_FOLLOW_GENERIC && $this->hasType()) {
         if ($_SESSION['PARAMETER_RETRIEVAL'] == PARAMETER_ADMIN_RETRIEVAL) {
             return SETTING_FOLLOW_TYPE;
         }
         $val = $this->type->getShowSectionFooter($default);
         if (!inArray($val, array("", SETTING_FOLLOW_GENERIC))) {
             return $val;
         }
     }
     /* survey level setting */
     if ($_SESSION['PARAMETER_RETRIEVAL'] == PARAMETER_ADMIN_RETRIEVAL) {
         return SETTING_FOLLOW_GENERIC;
     }
     global $survey;
     return $survey->getShowSectionFooter($default);
 }
Ejemplo n.º 24
0
 function processParaData($name = "")
 {
     $_SESSION['PARAMETER_RETRIEVAL'] = PARAMETER_SURVEY_RETRIEVAL;
     global $survey, $db;
     $query = "select max(pid) as pid from " . Config::dbSurveyData() . "_processed_paradata where suid=" . $survey->getSuid();
     //}
     //echo $query;
     $pid = 0;
     $res = $db->selectQuery($query);
     if ($res) {
         $row = $db->getRow($res);
         $pid = $row["pid"];
         if ($pid == "") {
             $pid = 0;
         }
     }
     $arr = array();
     $decrypt = "paradata as data_dec";
     $key = "";
     if ($survey->getDataEncryptionKey() != "") {
         $key = $survey->getDataEncryptionKey();
         $decrypt = "aes_decrypt(paradata, '" . $survey->getDataEncryptionKey() . "') as data_dec";
     }
     if ($name == "") {
         $query = "select *, {$decrypt} from " . Config::dbSurveyData() . "_paradata where pid > {$pid} and suid=" . $survey->getSuid() . ' order by primkey, pid asc';
     } else {
         $query = "select *, {$decrypt} from " . Config::dbSurveyData() . "_paradata where pid > {$pid} and suid=" . $survey->getSuid() . ' and (displayed = "' . $name . '" OR displayed like "%' . $name . '~%") order by primkey, pid asc';
     }
     //}
     //echo $query;
     $res = $db->selectQuery($query);
     $codes = array_values(Common::errorCodes());
     if ($res) {
         $oldprimkey = "";
         $arr = array();
         if ($db->getNumberOfRows($res) > 0) {
             $num = $db->getNumberOfRows($res);
             $cnt = 0;
             while ($row = $db->getRow($res)) {
                 // end of primkey, so store
                 if ($oldprimkey != "" && $row["primkey"] != $oldprimkey) {
                     // k: varname
                     // a: array of error codes with number of times
                     //print_r($arr);
                     foreach ($arr as $k => $a) {
                         foreach ($a as $error => $times) {
                             $query = "replace into " . Config::dbSurveyData() . "_processed_paradata (`pid`, `suid`, `primkey`, `rgid`, `variablename`, `answer`, `language`, `mode`, `version`, `ts`) values (";
                             if ($key != "") {
                                 $query .= $row["pid"] . "," . $row["suid"] . ",'" . $row["primkey"] . "'," . $row["rgid"] . ",'" . strtolower($k . "_" . $error) . "',aes_encrypt('" . $times . "','" . $key . "')," . $row["language"] . "," . $row["mode"] . "," . $row["version"] . ",'" . $row["ts"] . "'";
                             } else {
                                 $query .= $row["pid"] . "," . $row["suid"] . ",'" . $row["primkey"] . "'," . $row["rgid"] . ",'" . strtolower($k . "_" . $error) . "','" . $times . "'," . $row["language"] . "," . $row["mode"] . "," . $row["version"] . ",'" . $row["ts"] . "'";
                             }
                             $query .= ")";
                             $db->executeQuery($query);
                             //echo $query . "<hr>";
                         }
                     }
                     // reset
                     $arr = array();
                 }
                 $oldprimkey = $row["primkey"];
                 $line = strtoupper($row["displayed"]);
                 // if displayed == variable OR displayed contains ~varname~ or displayed starts with varname~, process; otherwise skip
                 if ($name == "" || $line == strtoupper($name) || contains($line, "~" . $name . "~") || startsWith($line, $name . "~")) {
                     $line = $row["data_dec"];
                     $line = str_replace("FO=", "FO:", $line);
                     $line = str_replace("FI=", "FI:", $line);
                     $a = explode("||", $line);
                     $displayed = explode("~", $row["displayed"]);
                     $variables = array();
                     foreach ($displayed as $d) {
                         if (startsWith($d, ROUTING_IDENTIFY_SUBGROUP) == false && startsWith($d, ROUTING_IDENTIFY_ENDSUBGROUP) == false) {
                             $variables[] = $d;
                         }
                     }
                     foreach ($a as $k) {
                         $t = explode(":", $k);
                         $code = $t[0];
                         // error code
                         if (inArray($code, $codes)) {
                             $s = explode("=", $t[1]);
                             $varname = $s[0];
                             $number = str_replace("answer", "", str_replace("_name[]", "", $varname));
                             // find varname
                             if (isset($variables[$number - 1])) {
                                 $variable = $variables[$number - 1];
                                 if (isset($arr[strtoupper($variable)])) {
                                     $vararray = $arr[strtoupper($variable)];
                                 } else {
                                     $vararray = array();
                                 }
                                 if (isset($vararray[strtoupper($code)])) {
                                     //echo $k . '------adding for: ' . $oldprimkey . '----' . $variable . "<hr>";
                                     $vararray[strtoupper($code)] = $vararray[strtoupper($code)] + 1;
                                 } else {
                                     $vararray[strtoupper($code)] = 1;
                                 }
                                 $arr[strtoupper($variable)] = $vararray;
                             }
                         } else {
                             if (inArray($code, array("FO", "FI"))) {
                                 foreach ($variables as $variable) {
                                     if (isset($arr[strtoupper($variable)])) {
                                         $vararray = $arr[strtoupper($variable)];
                                     } else {
                                         $vararray = array();
                                     }
                                     if (isset($vararray[strtoupper($code)])) {
                                         //echo $k . '------adding for: ' . $oldprimkey . '----' . $variable . "<hr>";
                                         $vararray[strtoupper($code)] = $vararray[strtoupper($code)] + 1;
                                     } else {
                                         $vararray[strtoupper($code)] = 1;
                                     }
                                     $arr[strtoupper($variable)] = $vararray;
                                 }
                             }
                         }
                     }
                 }
                 $cnt++;
                 // this was last one, so store
                 if ($cnt == $num) {
                     // k: varname
                     // a: array of error codes with number of times
                     //print_r($arr);
                     foreach ($arr as $k => $a) {
                         foreach ($a as $error => $times) {
                             $query = "replace into " . Config::dbSurveyData() . "_processed_paradata (`pid`, `suid`, `primkey`, `rgid`, `variablename`, `answer`, `language`, `mode`, `version`, `ts`) values (";
                             if ($key != "") {
                                 $query .= $row["pid"] . "," . $row["suid"] . ",'" . $row["primkey"] . "'," . $row["rgid"] . ",'" . strtolower($k . "_" . $error) . "',aes_encrypt('" . $times . "','" . $key . "')," . $row["language"] . "," . $row["mode"] . "," . $row["version"] . ",'" . $row["ts"] . "'";
                             } else {
                                 $query .= $row["pid"] . "," . $row["suid"] . ",'" . $row["primkey"] . "'," . $row["rgid"] . ",'" . strtolower($k . "_" . $error) . "','" . $times . "'," . $row["language"] . "," . $row["mode"] . "," . $row["version"] . ",'" . $row["ts"] . "'";
                             }
                             $query .= ")";
                             $db->executeQuery($query);
                             //echo $query . "<hr>";
                         }
                     }
                     // reset
                     $arr = array();
                 }
             }
         }
     }
     $_SESSION['PARAMETER_RETRIEVAL'] = PARAMETER_ADMIN_RETRIEVAL;
 }
Ejemplo n.º 25
0
权限</div>
            <div class="am-u-sm-8 am-u-md-10" style="margin-bottom:10px;">
              <div class="am-btn-group" data-am-button>
                <?php 
        if (is_array($vo[child])) {
            foreach ($vo[child] as $key => $v) {
                ?>
<label class="btnlist am-btn am-btn-primary am-btn-xs <?php 
                echo inArray($v['id'], $rules, "am-active");
                ?>
 " style="margin-bottom:5px;margin-right:5px; ">
                    <input type="checkbox" name="list[]" value="<?php 
                echo $v["id"];
                ?>
" <?php 
                echo inArray($v['id'], $rules, "checked='true' ");
                ?>
> <?php 
                echo $v["title"];
                ?>
 
                    
                  </label><?php 
            }
        }
        ?>
              </div>
            </div>
          </div><?php 
    }
}
Ejemplo n.º 26
0
 function setAnswer($primkey, $answer)
 {
     global $engine;
     // not an array
     if ($this->array == false) {
         // set of enumerated variable
         if ($this->answertype == ANSWER_TYPE_SETOFENUMERATED || $this->answertype == ANSWER_TYPE_MULTIDROPDOWN) {
             // specific set of enumerated option
             $matches = array();
             preg_match("/(_[0-9]+_\\b){1}/", $this->completevariablename, $matches);
             if (sizeof($matches) > 0) {
                 // get indicated option
                 $bracketvalue = str_replace("_", "", $matches[0]);
                 // get current values
                 global $engine;
                 $real = preg_replace("/(_[0-9]+_\\b){1}/", "", $this->completevariablename);
                 $values = explode(SEPARATOR_SETOFENUMERATED, $engine->getAnswer($real));
                 // set to empty
                 if ($answer == null) {
                     if (inArray($bracketvalue, $values)) {
                         $values[array_search($bracketvalue, $values)] = null;
                         //
                     }
                     $this->variable["answer"] = null;
                     // we don't call storeAnswer for _1_, so set the in-memory value here
                 } else {
                     if (strtoupper($answer) == ANSWER_RESPONSE) {
                         if (inArray($bracketvalue, $values)) {
                             $values[array_search($bracketvalue, $values)] = $bracketvalue;
                         } else {
                             $values[] = $bracketvalue;
                         }
                         $this->variable["answer"] = $bracketvalue;
                         // we don't call storeAnswer for _1_, so set the in-memory value here
                     }
                 }
                 sort($values);
                 // sort ascending
                 //echo "<hr>" . $real . "}}}}";
                 //print_r($values);
                 return $engine->setAnswer($real, implode(SEPARATOR_SETOFENUMERATED, $values), $this->getDirty());
             } else {
                 return $this->storeAnswer($primkey, $engine->prefixVariableName($this->completevariablename), $answer);
             }
         } else {
             return $this->storeAnswer($primkey, $engine->prefixVariableName($this->completevariablename), $answer);
         }
     } else {
         // not a specific instance (can't have set of enum indicators)
         if (endsWith($this->completevariablename, "]") == false) {
             // get current array
             $currentarray = $engine->getAnswer($this->completevariablename);
             //echo $this->completevariablename;
             // answer is not an array, then make it one
             if (!is_array($answer)) {
                 // we have something!
                 if ($answer != "") {
                     $answer = array($answer);
                 } else {
                     $answer = array();
                 }
             }
             // flatten array (http://stackoverflow.com/questions/9546181/flatten-multidimensional-array-concatenating-keys)
             $answer = flatten($answer);
             // store each individual value
             $bool = true;
             if (sizeof($answer) > 0) {
                 foreach ($answer as $key => $value) {
                     if (!$engine->setAnswer($this->completevariablename . "[" . $key . "]", $value, $this->getDirty())) {
                         $bool = false;
                     }
                 }
             }
             // reset any values no longer present
             foreach ($currentarray as $ck => $cv) {
                 if (isset($answer[$ck]) == false) {
                     if (!$engine->setAnswer($this->completevariablename . "[" . $ck . "]", null, DATA_DIRTY)) {
                         $bool = false;
                     }
                 }
             }
             // store complete array answer if value(s), don't strip any tags!
             if (sizeof($answer) > 0) {
                 $this->storeAnswer($primkey, $engine->prefixVariableName($this->completevariablename), gzcompress(serialize($answer)), false);
             } else {
                 $this->storeAnswer($primkey, $engine->prefixVariableName($this->completevariablename), "");
             }
             return true;
         } else {
             // TODO: strip the last [] --> see getBasicName in functions.php for code
             $varname = trim(substr($this->completevariablename, 0, strrpos($this->completevariablename, "[")));
             // TODO fix this to always get the correct [ after the last .
             $index = substr($this->completevariablename, strrpos($this->completevariablename, "[") + 1);
             $index = trim(substr($index, 0, strlen($index) - 1));
             //echo "<br/>" . $this->completevariablename . '---' . $index . '----' . $answer;
             // get entire answer
             $ans = $engine->getAnswer($varname);
             if ($ans == "" || is_null($ans)) {
                 $arr = array();
             } else {
                 $arr = $ans;
                 //unserialize(gzuncompress($ans));
             }
             // set of enumerated variable
             if ($this->answertype == ANSWER_TYPE_SETOFENUMERATED || $this->answertype == ANSWER_TYPE_MULTIDROPDOWN) {
                 // specific set of enumerated option: e.g. Q1_1_[1,2]
                 $matches = array();
                 preg_match("/(_[0-9]+_\\b){1}/", $varname, $matches);
                 if (sizeof($matches) > 0) {
                     // get indicated option
                     $bracketvalue = str_replace("_", "", $matches[0]);
                     // get current values
                     global $engine;
                     $real = preg_replace("/(_[0-9]+_\\b){1}/", "", $varname);
                     $values = explode(SEPARATOR_SETOFENUMERATED, $engine->getAnswer($real));
                     // set to empty
                     if ($answer == null) {
                         if (in_array($bracketvalue, $values)) {
                             $values[array_search($bracketvalue, $values)] = null;
                             //
                         }
                     } else {
                         if (strtoupper($answer) == ANSWER_RESPONSE) {
                             if (inArray($bracketvalue, $values)) {
                                 $values[array_search($bracketvalue, $values)] = $bracketvalue;
                             } else {
                                 $values[] = $bracketvalue;
                             }
                         }
                     }
                     sort($values);
                     // sort ascending
                     $answer = implode(SEPARATOR_SETOFENUMERATED, $values);
                 } else {
                     /* do nothing */
                 }
             } else {
                 /* do nothing */
             }
             // update array
             $arr[$index] = $answer;
             // flatten array
             $arr = flatten($arr);
             // flatten array
             //print_r($arr);
             // store updated array first, so the last call sets the in-memory answer properly
             //$engine->setAnswer($varname, gzcompress(serialize($arr)));
             // store complete array answer, don't strip any tags!
             $this->storeAnswer($primkey, $engine->prefixVariableName($varname), gzcompress(serialize($arr)), false);
             // array answer, then add individual entries
             if (is_array($answer)) {
                 if (sizeof($answer) > 0) {
                     $temparray[$index] = $answer;
                     $temparray = flatten($temparray);
                     // flatten array
                     //print_r($temparray);
                     foreach ($temparray as $key => $value) {
                         if (!$engine->setAnswer($varname . "[" . $key . "]", $value, $this->getDirty())) {
                             $bool = false;
                         }
                     }
                 }
             }
             //print_r($answer);
             //echo "<hr><hr><hr><br/>";
             // store the separate value under the specified name (e.g. Q1[1,1])
             // answer itself is an array
             if (is_array($answer)) {
                 //echo 'STORING: ' .                 $this->completevariablename;
                 // store array answer, don't strip any tags!
                 $this->storeAnswer($primkey, $engine->prefixVariableName($this->completevariablename), gzcompress(serialize($answer)), false);
             } else {
                 $this->storeAnswer($primkey, $engine->prefixVariableName($this->completevariablename), $answer);
             }
             //echo "<hr>in memory value for " . $this->completevariablename . " is: " . $this->variable["answer"];
             // return result
             return true;
         }
     }
 }
Ejemplo n.º 27
0
function applet_content()
{
    $inCore = cmsCore::getInstance();
    $inUser = cmsUser::getInstance();
    $inDB = cmsDatabase::getInstance();
    global $_LANG;
    //check access
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/content', $adminAccess)) {
        cpAccessDenied();
    }
    $cfg = $inCore->loadComponentConfig('content');
    cmsCore::loadModel('content');
    $model = new cms_model_content();
    $GLOBALS['cp_page_title'] = $_LANG['AD_ARTICLES'];
    cpAddPathway($_LANG['AD_ARTICLES'], 'index.php?view=tree');
    $do = cmsCore::request('do', 'str', 'add');
    $id = cmsCore::request('id', 'int', -1);
    if ($do == 'arhive_on') {
        $inDB->query("UPDATE cms_content SET is_arhive = 1 WHERE id = '{$id}'");
        cmsCore::addSessionMessage($_LANG['AD_ARTICLES_TO_ARHIVE'], 'success');
        cmsCore::redirectBack();
    }
    if ($do == 'move') {
        $item_id = cmsCore::request('id', 'int', 0);
        $cat_id = cmsCore::request('cat_id', 'int', 0);
        $dir = $_REQUEST['dir'];
        $step = 1;
        $model->moveItem($item_id, $cat_id, $dir, $step);
        echo '1';
        exit;
    }
    if ($do == 'move_to_cat') {
        $items = cmsCore::request('item', 'array_int');
        $to_cat_id = cmsCore::request('obj_id', 'int', 0);
        if ($items && $to_cat_id) {
            $last_ordering = (int) $inDB->get_field('cms_content', "category_id = '{$to_cat_id}' ORDER BY ordering DESC", 'ordering');
            foreach ($items as $item_id) {
                $article = $model->getArticle($item_id);
                if (!$article) {
                    continue;
                }
                $last_ordering++;
                $model->updateArticle($article['id'], array('category_id' => $to_cat_id, 'ordering' => $last_ordering, 'url' => $article['url'], 'title' => $inDB->escape_string($article['title']), 'id' => $article['id'], 'user_id' => $article['user_id']));
            }
            cmsCore::addSessionMessage($_LANG['AD_ARTICLES_TO'], 'success');
        }
        cmsCore::redirect('?view=tree&cat_id=' . $to_cat_id);
    }
    if ($do == 'show') {
        if (!isset($_REQUEST['item'])) {
            if ($id >= 0) {
                dbShow('cms_content', $id);
            }
            echo '1';
            exit;
        } else {
            dbShowList('cms_content', cmsCore::request('item', 'array_int'));
            cmsCore::redirectBack();
        }
    }
    if ($do == 'hide') {
        if (!isset($_REQUEST['item'])) {
            if ($id >= 0) {
                dbHide('cms_content', $id);
            }
            echo '1';
            exit;
        } else {
            dbHideList('cms_content', cmsCore::request('item', 'array_int'));
            cmsCore::redirectBack();
        }
    }
    if ($do == 'delete') {
        if (!isset($_REQUEST['item'])) {
            if ($id >= 0) {
                $model->deleteArticle($id);
                cmsCore::addSessionMessage($_LANG['AD_ARTICLE_REMOVE'], 'success');
            }
        } else {
            $model->deleteArticles(cmsCore::request('item', 'array_int'));
            cmsCore::addSessionMessage($_LANG['AD_ARTICLES_REMOVE'], 'success');
        }
        cmsCore::redirectBack();
    }
    if ($do == 'update') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        if (isset($_REQUEST['id'])) {
            $id = cmsCore::request('id', 'int', 0);
            $article['category_id'] = cmsCore::request('category_id', 'int', 1);
            $article['title'] = cmsCore::request('title', 'str');
            $article['url'] = cmsCore::request('url', 'str');
            $article['showtitle'] = cmsCore::request('showtitle', 'int', 0);
            $article['description'] = cmsCore::request('description', 'html', '');
            $article['description'] = $inDB->escape_string($article['description']);
            $article['content'] = cmsCore::request('content', 'html', '');
            $article['content'] = $inDB->escape_string($article['content']);
            $article['for_img'] = cmsCore::request('for_img', 'html', '');
            $article['for_img'] = $inDB->escape_string($article['for_img']);
            $article['published'] = cmsCore::request('published', 'int', 0);
            $article['showdate'] = cmsCore::request('showdate', 'int', 0);
            $article['showlatest'] = cmsCore::request('showlatest', 'int', 0);
            $article['show_in_new'] = cmsCore::request('show_in_new', 'int', 0);
            //new
            $article['show_in_footer'] = cmsCore::request('show_in_footer', 'int', 0);
            //new
            $article['showpath'] = cmsCore::request('showpath', 'int', 0);
            $article['comments'] = cmsCore::request('comments', 'int', 0);
            $article['canrate'] = cmsCore::request('canrate', 'int', 0);
            $article['add_text'] = cmsCore::request('add_text', 'str');
            $enddate = explode('.', cmsCore::request('enddate', 'str'));
            $article['enddate'] = $enddate[2] . '-' . $enddate[1] . '-' . $enddate[0];
            $article['is_end'] = cmsCore::request('is_end', 'int', 0);
            $article['pagetitle'] = cmsCore::request('pagetitle', 'str', '');
            $article['tags'] = cmsCore::request('tags', 'str');
            $olddate = cmsCore::request('olddate', 'str', '');
            $pubdate = cmsCore::request('pubdate', 'str', '');
            $article['user_id'] = cmsCore::request('user_id', 'int', $inUser->id);
            $article['tpl'] = cmsCore::request('tpl', 'str', 'com_content_read.tpl');
            $date = explode('.', $pubdate);
            $article['pubdate'] = $date[2] . '-' . $date[1] . '-' . $date[0] . ' ' . date('H:i');
            $autokeys = cmsCore::request('autokeys', 'int');
            switch ($autokeys) {
                case 1:
                    $article['meta_keys'] = $inCore->getKeywords($article['content']);
                    $article['meta_desc'] = $article['title'];
                    break;
                case 2:
                    $article['meta_desc'] = strip_tags($article['description']);
                    $article['meta_keys'] = $article['tags'];
                    break;
                case 3:
                    $article['meta_desc'] = cmsCore::request('meta_desc', 'str');
                    $article['meta_keys'] = cmsCore::request('meta_keys', 'str');
                    break;
            }
            $model->updateArticle($id, $article);
            if (!cmsCore::request('is_public', 'int', 0)) {
                $showfor = $_REQUEST['showfor'];
                cmsCore::setAccess($id, $showfor, 'material');
            } else {
                cmsCore::clearAccess($id, 'material');
            }
            if (isset($_SESSION['lang']) && $_SESSION['lang'] != 'ru') {
                $file = 'article' . $id . '_' . $_SESSION['lang'] . '.jpg';
            } else {
                $file = 'article' . $id . '.jpg';
            }
            //$file = 'article'.$id.'.jpg';
            if (cmsCore::request('delete_image', 'int', 0)) {
                @unlink(PATH . "/images/photos/small/{$file}");
                @unlink(PATH . "/images/photos/medium/{$file}");
            } else {
                // Загружаем класс загрузки фото
                cmsCore::loadClass('upload_photo');
                $inUploadPhoto = cmsUploadPhoto::getInstance();
                // Выставляем конфигурационные параметры
                $inUploadPhoto->upload_dir = PATH . '/images/photos/';
                $inUploadPhoto->small_size_w = $model->config['img_small_w'];
                $inUploadPhoto->medium_size_w = $model->config['img_big_w'];
                $inUploadPhoto->thumbsqr = $model->config['img_sqr'];
                $inUploadPhoto->is_watermark = $model->config['watermark'];
                $inUploadPhoto->input_name = 'picture';
                $inUploadPhoto->filename = $file;
                // Процесс загрузки фото
                $inUploadPhoto->uploadPhoto();
            }
            cmsCore::addSessionMessage($_LANG['AD_ARTICLE_SAVE'], 'success');
            if (!isset($_SESSION['editlist']) || @sizeof($_SESSION['editlist']) == 0) {
                cmsCore::redirect('?view=tree&cat_id=' . $article['category_id']);
            } else {
                cmsCore::redirect('?view=content&do=edit');
            }
        }
    }
    if ($do == 'submit') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        $article['category_id'] = cmsCore::request('category_id', 'int', 1);
        $article['title'] = cmsCore::request('title', 'str');
        $article['url'] = cmsCore::request('url', 'str');
        $article['showtitle'] = cmsCore::request('showtitle', 'int', 0);
        $article['description'] = cmsCore::request('description', 'html', '');
        $article['description'] = $inDB->escape_string($article['description']);
        $article['content'] = cmsCore::request('content', 'html', '');
        $article['content'] = $inDB->escape_string($article['content']);
        $article['for_img'] = cmsCore::request('for_img', 'html', '');
        $article['for_img'] = $inDB->escape_string($article['for_img']);
        $article['published'] = cmsCore::request('published', 'int', 0);
        $article['showdate'] = cmsCore::request('showdate', 'int', 0);
        $article['showlatest'] = cmsCore::request('showlatest', 'int', 0);
        $article['show_in_new'] = cmsCore::request('show_in_new', 'int', 0);
        //new
        $article['show_in_footer'] = cmsCore::request('show_in_footer', 'int', 0);
        //new
        $article['showpath'] = cmsCore::request('showpath', 'int', 0);
        $article['comments'] = cmsCore::request('comments', 'int', 0);
        $article['canrate'] = cmsCore::request('canrate', 'int', 0);
        $article['add_text'] = cmsCore::request('add_text', 'str');
        $enddate = explode('.', cmsCore::request('enddate', 'str'));
        $article['enddate'] = $enddate[2] . '-' . $enddate[1] . '-' . $enddate[0];
        $article['is_end'] = cmsCore::request('is_end', 'int', 0);
        $article['pagetitle'] = cmsCore::request('pagetitle', 'str', '');
        $article['tags'] = cmsCore::request('tags', 'str');
        $article['pubdate'] = $_REQUEST['pubdate'];
        $date = explode('.', $article['pubdate']);
        $article['pubdate'] = $date[2] . '-' . $date[1] . '-' . $date[0] . ' ' . date('H:i');
        $article['user_id'] = cmsCore::request('user_id', 'int', $inUser->id);
        $article['tpl'] = cmsCore::request('tpl', 'str', 'com_content_read.tpl');
        $autokeys = cmsCore::request('autokeys', 'int');
        switch ($autokeys) {
            case 1:
                $article['meta_keys'] = $inCore->getKeywords($article['content']);
                $article['meta_desc'] = $article['title'];
                break;
            case 2:
                $article['meta_desc'] = strip_tags($article['description']);
                $article['meta_keys'] = $article['tags'];
                break;
            case 3:
                $article['meta_desc'] = cmsCore::request('meta_desc', 'str');
                $article['meta_keys'] = cmsCore::request('meta_keys', 'str');
                break;
        }
        $article['id'] = $model->addArticle($article);
        if (!cmsCore::request('is_public', 'int', 0)) {
            $showfor = $_REQUEST['showfor'];
            if (sizeof($showfor) > 0 && !cmsCore::request('is_public', 'int', 0)) {
                cmsCore::setAccess($article['id'], $showfor, 'material');
            }
        }
        $inmenu = cmsCore::request('createmenu', 'str', '');
        if ($inmenu) {
            createMenuItem($inmenu, $article['id'], $article['title']);
        }
        // Загружаем класс загрузки фото
        cmsCore::loadClass('upload_photo');
        $inUploadPhoto = cmsUploadPhoto::getInstance();
        // Выставляем конфигурационные параметры
        $inUploadPhoto->upload_dir = PATH . '/images/photos/';
        $inUploadPhoto->small_size_w = $model->config['img_small_w'];
        $inUploadPhoto->medium_size_w = $model->config['img_big_w'];
        $inUploadPhoto->thumbsqr = $model->config['img_sqr'];
        $inUploadPhoto->is_watermark = $model->config['watermark'];
        $inUploadPhoto->input_name = 'picture';
        $inUploadPhoto->filename = 'article' . $article['id'] . '.jpg';
        // Процесс загрузки фото
        $inUploadPhoto->uploadPhoto();
        cmsCore::addSessionMessage($_LANG['AD_ARTICLE_ADD'], 'success');
        cmsCore::redirect('?view=tree&cat_id=' . $article['category_id']);
    }
    if ($do == 'add' || $do == 'edit') {
        require '../includes/jwtabs.php';
        $GLOBALS['cp_page_head'][] = jwHeader();
        $toolmenu = array();
        $toolmenu[0]['icon'] = 'save.gif';
        $toolmenu[0]['title'] = $_LANG['SAVE'];
        $toolmenu[0]['link'] = 'javascript:document.addform.submit();';
        $toolmenu[1]['icon'] = 'cancel.gif';
        $toolmenu[1]['title'] = $_LANG['CANCEL'];
        $toolmenu[1]['link'] = 'javascript:history.go(-1);';
        cpToolMenu($toolmenu);
        $menu_list = cpGetList('menu');
        if ($do == 'add') {
            echo '<h3>' . $_LANG['AD_CREATE_ARTICLE'] . '</h3>';
            cpAddPathway($_LANG['AD_CREATE_ARTICLE'], 'index.php?view=content&do=add');
            $mod['category_id'] = (int) $_REQUEST['to'];
            $mod['showpath'] = 1;
            $mod['tpl'] = 'com_content_read.tpl';
        } else {
            if (isset($_REQUEST['item'])) {
                $_SESSION['editlist'] = $_REQUEST['item'];
            }
            $ostatok = '';
            if (isset($_SESSION['editlist'])) {
                $id = array_shift($_SESSION['editlist']);
                if (sizeof($_SESSION['editlist']) == 0) {
                    unset($_SESSION['editlist']);
                } else {
                    $ostatok = '(' . $_LANG['AD_NEXT_IN'] . sizeof($_SESSION['editlist']) . ')';
                }
            } else {
                $id = (int) $_REQUEST['id'];
            }
            $sql = "SELECT *, (TO_DAYS(enddate) - TO_DAYS(CURDATE())) as daysleft, DATE_FORMAT(pubdate, '%d.%m.%Y') as pubdate, DATE_FORMAT(enddate, '%d.%m.%Y') as enddate\n\t\t\t\t\t FROM cms_content\n\t\t\t\t\t WHERE id = {$id} LIMIT 1";
            $result = $inDB->query($sql);
            if ($inDB->num_rows($result)) {
                $mod = $inDB->fetch_assoc($result);
            }
            echo '<h3>' . $_LANG['AD_EDIT_ARTICLE'] . $ostatok . '</h3>';
            cpAddPathway($mod['title'], 'index.php?view=content&do=edit&id=' . $mod['id']);
        }
        ?>
    <form id="addform" name="addform" method="post" action="index.php" enctype="multipart/form-data">
        <input type="hidden" name="csrf_token" value="<?php 
        echo cmsUser::getCsrfToken();
        ?>
" />
        <input type="hidden" name="view" value="content" />

        <table class="proptable" width="100%" cellpadding="5" cellspacing="2">
            <tr>

                <!-- главная ячейка -->
                <td valign="top">

                    <table width="100%" cellpadding="0" cellspacing="4" border="0">
                        <tr>
                            <td valign="top">
                                <div><strong><?php 
        echo $_LANG['AD_ARTICLE_NAME'];
        ?>
</strong></div>
                                <div>
                                    <table width="100%" cellpadding="0" cellspacing="0" border="0">
                                        <tr>
                                            <td><input name="title" type="text" id="title" style="width:100%" value="<?php 
        echo htmlspecialchars($mod['title']);
        ?>
" /></td>
                                            <td style="width:15px;padding-left:10px;padding-right:10px;">
                                                <input type="checkbox" title="<?php 
        echo $_LANG['AD_VIEW_TITLE'];
        ?>
" name="showtitle" <?php 
        if ($mod['showtitle'] || $do == 'add') {
            echo 'checked="checked"';
        }
        ?>
 value="1">
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                            </td>
                            <td width="130" valign="top">
                                <div><strong><?php 
        echo $_LANG['AD_PUBLIC_DATE'];
        ?>
</strong></div>
                                <div>
                                    <input name="pubdate" type="text" id="pubdate" style="width:100px" <?php 
        if (@(!$mod['pubdate'])) {
            echo 'value="' . date('d.m.Y') . '"';
        } else {
            echo 'value="' . $mod['pubdate'] . '"';
        }
        ?>
/>

                                    <input type="hidden" name="olddate" value="<?php 
        echo @$mod['pubdate'];
        ?>
" />
                                </div>
                            </td>
                            <td width="16" valign="bottom" style="padding-bottom:10px">
                                <input type="checkbox" name="showdate" id="showdate" title="<?php 
        echo $_LANG['AD_VIEW_DATE_AND_AUTHOR'];
        ?>
" value="1" <?php 
        if ($mod['showdate'] || $do == 'add') {
            echo 'checked="checked"';
        }
        ?>
/>
                            </td>
<!--                             <td width="160" valign="top">
                                <div><strong><?php 
        echo $_LANG['AD_ARTICLE_TEMPLATE'];
        ?>
</strong></div>
                                <div><input name="tpl" type="text" style="width:160px" value="<?php 
        echo @$mod['tpl'];
        ?>
"></div>
                            </td> -->
							  <td width="160" valign="top">
                                <div><strong>Шаблон статьи</strong></div>
								<?php 
        $inConf = cmsConfig::getInstance();
        //задаём имя директории
        $directory = PATH . "/templates/" . $inConf->template . "/components";
        $scan_dir = scandir($directory);
        if (is_dir($directory)) {
            //проверяем наличие директории
            //директория существует
            echo '<select name="tpl">';
            $scan_dir = scandir($directory);
            //сканируем (получаем массив файлов)
            array_shift($scan_dir);
            // удаляем из массива '.'
            array_shift($scan_dir);
            // удаляем из массива '..'
            for ($i = 0; $i < sizeof($scan_dir); $i++) {
                $tpl = explode("_", $scan_dir[$i]);
                if ($_GET['view'] == $tpl['1']) {
                    if ($_GET['view']) {
                        //выводим все файлы
                        if (@$mod["tpl"] == $scan_dir[$i]) {
                            echo '<option selected>' . $scan_dir[$i] . '</option>';
                        } else {
                            echo '<option>' . $scan_dir[$i] . '</option>';
                        }
                    }
                }
            }
            echo '</select>';
        } else {
            echo '<input name="tpl" type="text" style="width:160px" value="' . @$mod["tpl"] . '">';
        }
        ?>
                            </td>

                        </tr>
                    </table>

                    <div><strong><?php 
        echo $_LANG['AD_ARTICLE_NOTICE'];
        ?>
</strong></div>
                    <div><?php 
        $inCore->insertEditor('description', $mod['description'], '200', '100%');
        ?>
</div>

                    <div><strong><?php 
        echo $_LANG['AD_ARTICLE_TEXT'];
        ?>
</strong></div>
                    <?php 
        insertPanel();
        ?>
                    <div><?php 
        $inCore->insertEditor('content', $mod['content'], '400', '100%');
        ?>
</div><!--Editor text in articles-->

                    <div><strong><?php 
        echo $_LANG['AD_ARTICLE_IMG'];
        ?>
</strong></div>
                    <div><?php 
        $inCore->insertEditor('for_img', $mod['for_img'], '200', '100%');
        ?>
</div>

                    <div><strong><?php 
        echo $_LANG['AD_ARTICLE_ADD_TEXT'];
        ?>
</strong></div>
                    <div><input name="add_text" type="text" id="add_text" style="width:99%" value="<?php 
        echo htmlspecialchars($mod['add_text']);
        ?>
" /></div>


                    <div><strong><?php 
        echo $_LANG['AD_ARTICLE_TAGS'];
        ?>
</strong></div>
                    <div><input name="tags" type="text" id="tags" style="width:99%" value="<?php 
        if (isset($mod['id'])) {
            echo cmsTagLine('content', $mod['id'], false);
        }
        ?>
" /></div>

                    <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist">
                        <tr>
                            <td width="20">
                                <input type="radio" name="autokeys" id="autokeys1" <?php 
        if ($do == 'add' && $cfg['autokeys']) {
            ?>
checked="checked"<?php 
        }
        ?>
 value="1"/>
                            </td>
                            <td>
                                <label for="autokeys1"><strong><?php 
        echo $_LANG['AD_AUTO_GEN_KEY'];
        ?>
</strong></label>
                            </td>
                        </tr>
                        <tr>
                            <td width="20">
                                <input type="radio" name="autokeys" id="autokeys2" value="2"/>
                            </td>
                            <td>
                                <label for="autokeys2"><strong><?php 
        echo $_LANG['AD_TAGS_AS_KEY'];
        ?>
</strong></label>
                            </td>
                        </tr>
                        <tr>
                            <td width="20">
                                <input type="radio" name="autokeys" id="autokeys3" value="3" <?php 
        if ($do == 'edit' || !$cfg['autokeys']) {
            ?>
checked="checked"<?php 
        }
        ?>
/>
                            </td>
                            <td>
                                <label for="autokeys3"><strong><?php 
        echo $_LANG['AD_MANUAL_KEY'];
        ?>
</strong></label>
                            </td>
                        </tr>

                        <?php 
        if ($cfg['af_on'] && $do == 'add') {
            ?>
                        <tr>
                            <td width="20"><input type="checkbox" name="noforum" id="noforum" value="1" /> </td>
                            <td><label for="noforum"><strong><?php 
            echo $_LANG['AD_NO_CREATE_THEME'];
            ?>
</strong></label></td>
                        </tr>
                        <?php 
        }
        ?>
                    </table>

                </td>

                <!-- боковая ячейка -->
                <td width="300" valign="top" style="background:#ECECEC;">

                    <?php 
        ob_start();
        ?>

                    {tab=<?php 
        echo $_LANG['AD_TAB_PUBLISH'];
        ?>
}

                    <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist">
                        <tr>
                            <td width="20"><input type="checkbox" name="published" id="published" value="1" <?php 
        if ($mod['published'] || $do == 'add') {
            echo 'checked="checked"';
        }
        ?>
/></td>
                            <td><label for="published"><strong><?php 
        echo $_LANG['AD_PUBLIC_ARTICLE'];
        ?>
</strong></label></td>
                        </tr>
                    </table>

                    <div style="margin-top:7px">
                        <select name="category_id" size="10" id="category_id" style="width:99%;height:200px">
                            <option value="1" <?php 
        if (@$mod['category_id'] == 1 || !isset($mod['category_id'])) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_ROOT_CATEGORY'];
        ?>
</option>
                            <?php 
        if (isset($mod['category_id'])) {
            echo $inCore->getListItemsNS('cms_category', $mod['category_id']);
        } else {
            echo $inCore->getListItemsNS('cms_category');
        }
        ?>
                        </select>
                    </div>

                    <div style="margin-bottom:10px">
                        <select name="showpath" id="showpath" style="width:99%">
                            <option value="0" <?php 
        if (@(!$mod['showpath'])) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_PATHWAY_NAME_ONLY'];
        ?>
</option>
                            <option value="1" <?php 
        if (@$mod['showpath']) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_PATHWAY_FULL'];
        ?>
</option>
                        </select>
                    </div>

                    <div style="margin-top:15px">
                        <strong><?php 
        echo $_LANG['AD_ARTICLE_URL'];
        ?>
</strong><br/>
                        <div style="color:gray"><?php 
        echo $_LANG['AD_IF_UNKNOWN'];
        ?>
</div>
                    </div>
                    <div>
                        <table border="0" cellpadding="0" cellspacing="0" width="100%">
                            <tr>
                                <td><input type="text" name="url" value="<?php 
        echo $mod['url'];
        ?>
" style="width:100%"/></td>
                                <td width="40" align="center">.html</td>
                            </tr>
                        </table>
                    </div>

                    <div style="margin-top:10px">
                        <strong><?php 
        echo $_LANG['AD_ARTICLE_AUTHOR'];
        ?>
</strong>
                    </div>
                    <div>
                        <select name="user_id" id="user_id" style="width:99%">
                          <?php 
        if (isset($mod['user_id'])) {
            echo $inCore->getListItems('cms_users', $mod['user_id'], 'nickname', 'ASC', 'is_deleted=0 AND is_locked=0', 'id', 'nickname');
        } else {
            echo $inCore->getListItems('cms_users', $inUser->id, 'nickname', 'ASC', 'is_deleted=0 AND is_locked=0', 'id', 'nickname');
        }
        ?>
                        </select>
                    </div>

                    <div style="margin-top:12px"><strong><?php 
        echo $_LANG['AD_PHOTO'];
        ?>
</strong></div>
                    <div style="margin-bottom:10px">
                        <?php 
        if ($do == 'edit') {
            if (isset($_SESSION['lang']) && $_SESSION['lang'] != 'ru') {
                $mod_id = $mod['id'] . '_' . $_SESSION['lang'];
                $id_art = $mod['id'] . '_' . $_SESSION['lang'];
            } else {
                $mod_id = $mod['id'];
                $id_art = $id;
            }
            //if (file_exists(PATH.'/images/photos/small/article'.$mod['id'].'.jpg')){
            if (file_exists(PATH . '/images/photos/small/article' . $mod_id . '.jpg')) {
                ?>
                        <div style="margin-top:3px;margin-bottom:3px;padding:10px;border:solid 1px gray;text-align:center">
                            <?/*php<img src="/images/photos/small/article<?php 
                echo $id;
                ?>
.jpg" border="0" />*/?>
                            <img src="/images/photos/small/article<?php 
                echo $id_art;
                ?>
.jpg" border="0" />
                        </div>
                        <table cellpadding="0" cellspacing="0" border="0">
                            <tr>
                                <td width="16"><input type="checkbox" id="delete_image" name="delete_image" value="1" /></td>
                                <td><label for="delete_image"><?php 
                echo $_LANG['AD_PHOTO_REMOVE'];
                ?>
</label></td>
                            </tr>
                        </table>
                        <?php 
            }
        }
        ?>
                        <input type="file" name="picture" style="width:100%" />
                    </div>

                    <div style="margin-top:25px"><strong><?php 
        echo $_LANG['AD_PUBLIC_PARAMETRS'];
        ?>
</strong></div>
                    <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist">
                        <tr>
                            <td width="20"><input type="checkbox" name="show_in_new" id="show_in_new" value="1" <?php 
        if ($mod['show_in_new'] || $do == 'add') {
            echo 'checked="checked"';
        }
        ?>
/></td>
                            <td><label for="show_in_new"><?php 
        echo $_LANG['AD_VIEW_NEW_CATS'];
        ?>
</label></td>
                        </tr>
                        <tr>
                            <td width="20"><input type="checkbox" name="show_in_footer" id="show_in_footer" value="1" <?php 
        if ($mod['show_in_footer'] || $do == 'add') {
            echo 'checked="checked"';
        }
        ?>
/></td>
                            <td><label for="show_in_footer"><?php 
        echo $_LANG['AD_VIEW_FOOTER'];
        ?>
</label></td>
                        </tr>
                        <tr>
                            <td width="20"><input type="checkbox" name="showlatest" id="showlatest" value="1" <?php 
        if ($mod['showlatest'] || $do == 'add') {
            echo 'checked="checked"';
        }
        ?>
/></td>
                            <td><label for="showlatest"><?php 
        echo $_LANG['AD_VIEW_NEW_ARTICLES'];
        ?>
</label></td>
                        </tr>
                        <tr>
                            <td width="20"><input type="checkbox" name="comments" id="comments" value="1" <?php 
        if ($mod['comments'] || $do == 'add') {
            echo 'checked="checked"';
        }
        ?>
/></td>
                            <td><label for="comments"><?php 
        echo $_LANG['AD_ENABLE_COMMENTS'];
        ?>
</label></td>
                        </tr>
                        <tr>
                            <td width="20"><input type="checkbox" name="canrate" id="canrate" value="1" <?php 
        if ($mod['canrate']) {
            echo 'checked="checked"';
        }
        ?>
/></td>
                            <td><label for="canrate"><?php 
        echo $_LANG['AD_ENABLE_RATING'];
        ?>
</label></td>
                        </tr>
                    </table>

                    <?php 
        if ($do == 'add') {
            ?>
                        <div style="margin-top:25px">
                            <strong><?php 
            echo $_LANG['AD_CREATE_LINK'];
            ?>
</strong>
                        </div>
                        <div>
                            <select name="createmenu" id="createmenu" style="width:99%">
                                <option value="0" selected="selected"><?php 
            echo $_LANG['AD_DONT_CREATE_LINK'];
            ?>
</option>
                            <?php 
            foreach ($menu_list as $menu) {
                ?>
                                <option value="<?php 
                echo $menu['id'];
                ?>
">
                                    <?php 
                echo $menu['title'];
                ?>
                                </option>
                            <?php 
            }
            ?>
                            </select>
                        </div>
                    <?php 
        }
        ?>

                    {tab=<?php 
        echo $_LANG['AD_DATE'];
        ?>
}

                    <div style="margin-top:5px">
                        <strong><?php 
        echo $_LANG['AD_ARTICLE_TIME'];
        ?>
</strong>
                    </div>
                    <div>
                        <select name="is_end" id="is_end" style="width:99%" onchange="if($(this).val() == 1){ $('#final_time').show(); }else {$('#final_time').hide();}">
                            <option value="0" <?php 
        if (@(!$mod['is_end'])) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_UNLIMITED'];
        ?>
</option>
                            <option value="1" <?php 
        if (@$mod['is_end']) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_TO_FINAL_TIME'];
        ?>
</option>
                        </select>
                    </div>

                    <div id="final_time" <?php 
        if (@(!$mod['is_end'])) {
            echo 'style="display: none"';
        }
        ?>
>
                    <div style="margin-top:20px">
                        <strong><?php 
        echo $_LANG['AD_FINAL_TIME'];
        ?>
</strong><br/>
                        <span class="hinttext"><?php 
        echo $_LANG['AD_CALENDAR_FORMAT'];
        ?>
</span>
                    </div>
                    <div><input name="enddate" type="text" style="width:80%" <?php 
        if (@(!$mod['is_end'])) {
            echo 'value="' . date('d.m.Y') . '"';
        } else {
            echo 'value="' . $mod['enddate'] . '"';
        }
        ?>
id="enddate" /></div></div>


                    {tab=SEO}

                    <div style="margin-top:5px">
                        <strong><?php 
        echo $_LANG['AD_PAGE_TITLE'];
        ?>
</strong><br/>
                        <span class="hinttext"><?php 
        echo $_LANG['AD_IF_UNKNOWN_PAGETITLE'];
        ?>
</span>
                    </div>
                    <div>
                        <input name="pagetitle" type="text" id="pagetitle" style="width:99%" value="<?php 
        if (isset($mod['pagetitle'])) {
            echo htmlspecialchars($mod['pagetitle']);
        }
        ?>
" />
                    </div>

                    <div style="margin-top:20px">
                        <strong><?php 
        echo $_LANG['KEYWORDS'];
        ?>
</strong><br/>
                        <span class="hinttext"><?php 
        echo $_LANG['AD_FROM_COMMA'];
        ?>
</span>
                    </div>
                    <div>
                         <textarea name="meta_keys" style="width:97%" rows="4" id="meta_keys"><?php 
        echo htmlspecialchars($mod['meta_keys']);
        ?>
</textarea>
                    </div>

                    <div style="margin-top:20px">
                        <strong><?php 
        echo $_LANG['DESCRIPTION'];
        ?>
</strong><br/>
                        <span class="hinttext"><?php 
        echo $_LANG['AD_LESS_THAN'];
        ?>
</span>
                    </div>
                    <div>
                         <textarea name="meta_desc" style="width:97%" rows="6" id="meta_desc"><?php 
        echo htmlspecialchars($mod['meta_desc']);
        ?>
</textarea>
                    </div>

                    {tab=<?php 
        echo $_LANG['AD_TAB_ACCESS'];
        ?>
}

                    <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist" style="margin-top:5px">
                        <tr>
                            <td width="20">
                                <?php 
        $sql = "SELECT * FROM cms_user_groups";
        $result = $inDB->query($sql);
        $style = 'disabled="disabled"';
        $public = 'checked="checked"';
        if ($do == 'edit') {
            $sql2 = "SELECT * FROM cms_content_access WHERE content_id = " . $mod['id'] . " AND content_type = 'material'";
            $result2 = $inDB->query($sql2);
            $ord = array();
            if ($inDB->num_rows($result2)) {
                $public = '';
                $style = '';
                while ($r = $inDB->fetch_assoc($result2)) {
                    $ord[] = $r['group_id'];
                }
            }
        }
        ?>
                                <input name="is_public" type="checkbox" id="is_public" onclick="checkGroupList()" value="1" <?php 
        echo $public;
        ?>
 />
                            </td>
                            <td><label for="is_public"><strong><?php 
        echo $_LANG['AD_SHARE'];
        ?>
</strong></label></td>
                        </tr>
                    </table>
                    <div style="padding:5px">
                        <span class="hinttext">
                            <?php 
        echo $_LANG['AD_IF_NOTED'];
        ?>
                        </span>
                    </div>

                    <div style="margin-top:10px;padding:5px;padding-right:0px;" id="grp">
                        <div>
                            <strong><?php 
        echo $_LANG['AD_GROUPS_VIEW'];
        ?>
</strong><br />
                            <span class="hinttext">
                                <?php 
        echo $_LANG['AD_SELECT_MULTIPLE_CTRL'];
        ?>
                            </span>
                        </div>
                        <div>
                            <?php 
        echo '<select style="width: 99%" name="showfor[]" id="showin" size="6" multiple="multiple" ' . $style . '>';
        if ($inDB->num_rows($result)) {
            while ($item = $inDB->fetch_assoc($result)) {
                echo '<option value="' . $item['id'] . '"';
                if ($do == 'edit') {
                    if (inArray($ord, $item['id'])) {
                        echo 'selected="selected"';
                    }
                }
                echo '>';
                echo $item['title'] . '</option>';
            }
        }
        echo '</select>';
        ?>
                        </div>
                    </div>

                    {/tabs}

                    <?php 
        echo jwTabs(ob_get_clean());
        ?>

                </td>

            </tr>
        </table>

        <p>
            <input name="add_mod" type="submit" id="add_mod" <?php 
        if ($do == 'add') {
            echo 'value="' . $_LANG['AD_CREATE_CONTENT'] . '"';
        } else {
            echo 'value="' . $_LANG['AD_SAVE_CONTENT'] . '"';
        }
        ?>
 />
            <input name="back" type="button" id="back" value="<?php 
        echo $_LANG['CANCEL'];
        ?>
" onclick="window.history.back();"/>
            <input name="do" type="hidden" id="do" <?php 
        if ($do == 'add') {
            echo 'value="submit"';
        } else {
            echo 'value="update"';
        }
        ?>
 />
            <?php 
        if ($do == 'edit') {
            echo '<input name="id" type="hidden" value="' . $mod['id'] . '" />';
        }
        ?>
        </p>
    </form>
    <?php 
    }
}
Ejemplo n.º 28
0
 function getFirstSurvey($all = false)
 {
     global $db;
     $surveys = array();
     $result = $db->selectQuery('select suid from ' . Config::dbSurvey() . '_surveys order by suid asc');
     if ($result && $db->getNumberOfRows($result) > 0) {
         if ($_SESSION['SYSTEM_ENTRY'] == USCIC_SMS) {
             $user = new User($_SESSION['URID']);
             $avsurveys = $user->getSurveysAccess();
             while ($row = $db->getRow($result)) {
                 if (inArray($row["suid"], $avsurveys) || $all) {
                     return $row["suid"];
                 }
             }
         } else {
             $row = $db->getRow($result);
             return $row["suid"];
         }
     }
     return "";
 }
Ejemplo n.º 29
0
 function generateRandomDateTime($variable, $var)
 {
     $type = $var->getAnswerType();
     $eq = trim($this->engine->getFill($variable, $var, SETTING_COMPARISON_EQUAL_TO));
     if ($eq != "") {
         $values = explode("-", $eq);
         foreach ($values as $v) {
             if (inArray($type, array(ANSWER_TYPE_DATE, ANSWER_TYPE_DATETIME))) {
                 if (strtotime($v)) {
                     return strtotime($v);
                 }
             } else {
                 if (strtotime("2015-11-01 " + $v)) {
                     return $v;
                 }
             }
         }
     }
     $min = 0;
     $max = time();
     $exclude = array();
     $neq = trim($this->engine->getFill($variable, $var, SETTING_COMPARISON_NOT_EQUAL_TO));
     if ($neq != "") {
         $values = explode("-", $neq);
         foreach ($values as $v) {
             if (inArray($type, array(ANSWER_TYPE_DATE, ANSWER_TYPE_DATETIME))) {
                 if (strtotime($v)) {
                     $exclude[] = strtotime($v);
                 }
             } else {
                 if (strtotime("2015-11-01 " + $v)) {
                     $exclude[] = $this->getTimeSeconds($v);
                 }
             }
         }
     }
     $geq = trim($this->engine->getFill($variable, $var, SETTING_COMPARISON_GREATER_EQUAL_TO));
     if ($geq != "") {
         $values = explode("-", $geq);
         foreach ($values as $v) {
             if (inArray($type, array(ANSWER_TYPE_DATE, ANSWER_TYPE_DATETIME))) {
                 if (strtotime($v)) {
                     if ($min < strtotime($v)) {
                         $min = strtotime($v);
                     }
                 }
             } else {
                 if (strtotime("2015-11-01 " + $v)) {
                     if ($min < $this->getTimeSeconds($v)) {
                         $min = $this->getTimeSeconds($v);
                     }
                 }
             }
         }
     }
     //echo 'yyyyy';
     $gr = trim($this->engine->getFill($variable, $var, SETTING_COMPARISON_GREATER));
     if ($gr != "") {
         $values = explode("-", $gr);
         foreach ($values as $v) {
             if (inArray($type, array(ANSWER_TYPE_DATE, ANSWER_TYPE_DATETIME))) {
                 if (strtotime($v)) {
                     if ($min < strtotime($v) + 1) {
                         $min = strtotime($v) + 1;
                     }
                 }
             } else {
                 if (strtotime("2015-11-01 " + $v)) {
                     if ($min < $this->getTimeSeconds($v) + 1) {
                         $min = $this->getTimeSeconds($v) + 1;
                     }
                 }
             }
         }
     }
     $seq = trim($this->engine->getFill($variable, $var, SETTING_COMPARISON_SMALLER_EQUAL_TO));
     if ($seq != "") {
         $values = explode("-", $seq);
         foreach ($values as $v) {
             if (inArray($type, array(ANSWER_TYPE_DATE, ANSWER_TYPE_DATETIME))) {
                 if (strtotime($v)) {
                     if ($max > strtotime($v)) {
                         $max = strtotime($v);
                     }
                 }
             } else {
                 if (strtotime("2015-11-01 " + $v)) {
                     if ($max > $this->getTimeSeconds($v)) {
                         $max = $this->getTimeSeconds($v);
                     }
                 }
             }
         }
     }
     $sm = trim($this->engine->getFill($variable, $var, SETTING_COMPARISON_SMALLER));
     if ($sm != "") {
         $values = explode("-", $sm);
         foreach ($values as $v) {
             if (inArray($type, array(ANSWER_TYPE_DATE, ANSWER_TYPE_DATETIME))) {
                 if (strtotime($v)) {
                     if ($max > strtotime($v) - 1) {
                         $max = strtotime($v) - 1;
                     }
                 }
             } else {
                 if (strtotime("2015-11-01 " + $v)) {
                     if ($max > $this->getTimeSeconds($v)) {
                         $max = $this->getTimeSeconds($v) - 1;
                     }
                 }
             }
         }
     }
     // no acceptable answer possible
     if ($min > $max) {
         return "";
     }
     $ans = "";
     while (true) {
         $ans = mt_rand($min, $max);
         if (!inArray($ans, $exclude)) {
             break;
         }
     }
     // return generated answer
     if (inArray($type, array(ANSWER_TYPE_DATE, ANSWER_TYPE_DATETIME))) {
         return $ans;
     } else {
         return date("H:i:s", strtotime("2015-11-01") + $ans);
     }
 }
Ejemplo n.º 30
0
                            <?php 
    echo $_LANG['AD_SELECT_MULTIPLE_CTRL'];
    ?>
                        </span>
                    </div>
                    <div>
                        <?php 
    echo '<select style="width: 99%" name="showfor[]" id="showin" size="6" multiple="multiple" ' . (@$mod['is_public'] ? '' : 'disabled="disabled"') . '>';
    $sql = "SELECT * FROM cms_user_groups";
    $result = $inDB->query($sql);
    if ($inDB->num_rows($result)) {
        while ($item = $inDB->fetch_assoc($result)) {
            if ($item['alias'] != 'guest') {
                echo '<option value="' . $item['id'] . '"';
                if ($opt == 'edit_cat') {
                    if (inArray($ord, $item['id'])) {
                        echo 'selected';
                    }
                }
                echo '>';
                echo $item['title'] . '</option>';
            }
        }
    }
    echo '</select>';
    ?>
                    </div>
                </div>

                <?php 
    if (IS_BILLING) {