예제 #1
0
function genOptionList($parentID, $currentID, $recursion = true, $sort = "pagetitle")
{
    global $modx;
    $childrens = array();
    $childrens = $modx->getAllChildren($parentID, $sort, "ASC", "id, pagetitle, isfolder");
    $tmp = "";
    foreach ($childrens as $value) {
        if ($value['isfolder'] == 1 and $recursion) {
            $tmp .= "<optgroup label=\"" . $value['pagetitle'] . "\">";
        }
        if ($value['isfolder'] == 0 or $recursion === false) {
            $tmp .= "<option value=" . $value['id'];
            if ($value['id'] == $currentID) {
                $tmp .= " selected";
            }
            $tmp .= ">" . $value['pagetitle'] . "</option>\n";
        }
        if ($value['isfolder'] == 1 and $recursion) {
            $tmp .= genOptionList($value['id'], $currentID);
        }
        if ($value['isfolder'] == 1 and $recursion) {
            $tmp .= "</optgroup>";
        }
    }
    return $tmp;
}
예제 #2
0
            }
            if (trim($city) != "") {
                $wheres[] = "(eb.city = {$city} or eb.allcity = 1)";
            }
            if ($user != "") {
                $wheres[] = "eb.createdby = {$user}";
            }
            if ($published != "") {
                $wheres[] = "eb.published = {$published}";
            }
            if ($context != "") {
                $wheres[] = "eb.context = '{$context}'";
            }
            if ($filter != "") {
                $wheres[] = "( {$filter} )";
            }
            $where = "WHERE " . implode(" AND ", $wheres);
        }
        $result = $modx->db->query("SELECT COUNT(*), sc1.pagetitle as parentname, sc2.pagetitle as cityname, wb.username FROM {$mod_table} as eb\n\tLEFT JOIN " . $dbprefix . "site_content sc1 ON sc1.id = eb.parent\n\t\t\tLEFT JOIN " . $dbprefix . "site_content sc2 ON sc2.id = eb.city\n\t\t\tLEFT JOIN " . $dbprefix . "web_users wb ON wb.id = eb.createdby\n\t\t\t{$where}");
        $output .= $modx->db->getValue($result);
        break;
    case "searchform":
        if ($tplsearchform == "") {
            $template = file_get_contents($snippetPath . "tpl/view.searchform.tpl");
        } else {
            $template = $modx->getChunk($tplsearchform);
        }
        $pl = array("parentIds" => genOptionList($parentIds, $modx->runSnippet('toget', array('name' => "parentid"))), "cityIds" => genOptionList($cityIds, $modx->runSnippet('toget', array('name' => "cityid")), false), "search" => $modx->runSnippet('toget', array('name' => "search")), "idsearchpage" => $idsearchpage);
        $output .= $modx->parseText($template, $pl, '[+', '+]');
        break;
}
예제 #3
0
         $allcity = 0;
         $hit = 0;
         $image = "";
         $context = "";
         $save = "save";
     }
     $template = file_get_contents($basePath . "assets/modules/easy_board/tpl/add.tpl");
     $template = str_replace("[+id+]", $id, $template);
     $template = str_replace("[+pagetitle+]", $pagetitle, $template);
     $template = str_replace("[+content+]", $content, $template);
     $template = str_replace("[+createdby+]", $createdby, $template);
     $template = str_replace("[+contact+]", $contact, $template);
     $template = str_replace("[+price+]", $price, $template);
     $template = str_replace("[+hit+]", $hit, $template);
     $template = str_replace("[+parent+]", genOptionList($categoryID, $parent), $template);
     $template = str_replace("[+city+]", genOptionList($cityID, $city, false), $template);
     $template = str_replace("[+contexts+]", genOptionListContext($contexts, $context), $template);
     $template = str_replace("[+published+]", genCheckbox($published), $template);
     $template = str_replace("[+allcity+]", genCheckbox($allcity), $template);
     $template = str_replace("[+image+]", genImageForm($image, $id), $template);
     echo $template;
     echo '
 <button class="styler" href="#" onclick="postForm(\'' . $save . '\',\'' . $id . '\');return false;">Save</button>
 &nbsp;&nbsp;
 <a href="#" onclick="postForm(\'reload\',null);return false;">Cancel</a>
 ';
     break;
     //Сохранение записи в БД
 //Сохранение записи в БД
 case 'save':
     $fields = array();