Beispiel #1
1
 public function results()
 {
     if (!$this->isAdmin) {
         $this->login();
     }
     $this->check();
     $this->title("Manage " . $this->application);
     $this->CSS("results", "cpanel");
     $this->CSS("pagination");
     $this->js("checkbox");
     $trash = segment(3, isLang()) === "trash" ? TRUE : FALSE;
     $total = $this->CPanel_Model->total($trash);
     $thead = $this->CPanel_Model->thead("checkbox, " . getFields($this->application) . ", Action", FALSE);
     $pagination = $this->CPanel_Model->getPagination($trash);
     $tFoot = getTFoot($trash);
     $this->vars["message"] = !$tFoot ? "Error" : NULL;
     $this->vars["pagination"] = $pagination;
     $this->vars["trash"] = $trash;
     $this->vars["search"] = getSearch();
     $this->vars["table"] = getTable(__(_("Manage " . ucfirst($this->application))), $thead, $tFoot, $total);
     $this->vars["view"] = $this->view("results", TRUE, "cpanel");
     $this->render("content", $this->vars);
 }
Beispiel #2
0
 private function limit()
 {
     if (isLang()) {
         if (segment(1) === "videos" and segment(2) > 0) {
             $start = segment(2) * _maxLimitVideos - _maxLimitVideos;
         } else {
             $start = 0;
         }
     } else {
         if (segment(0) === "videos" and segment(1) > 0) {
             $start = segment(2) * _maxLimitVideos - _maxLimitVideos;
         } else {
             $start = 0;
         }
     }
     $limit = $start . ", " . _maxLimitVideos;
     $count = $this->Videos_Model->count();
     $URL = path("videos/");
     if ($count > _maxLimitVideos) {
         $this->pagination = paginate($count, _maxLimitVideos, $start, $URL);
     } else {
         $this->pagination = NULL;
     }
     return $limit;
 }
Beispiel #3
0
 public function getCategories($action = "add", $type = "checkbox", $name = "categories")
 {
     if ($action === "add") {
         $this->Categories_Model = $this->model("Categories_Model");
         $data = $this->Categories_Model->categories();
         if ($data) {
             $HTML = $this->build($data, NULL, $type, $name);
         } else {
             return FALSE;
         }
         unset($this->HTML);
         return $HTML;
     } elseif ($action === "edit") {
         $this->Categories_Model = $this->model("Categories_Model");
         $categories = $this->Categories_Model->categories();
         $data = $this->Categories_Model->getCategoriesByRecord("3", isLang() ? segment(4) : segment(3));
         if ($data) {
             $i = 0;
             foreach ($categories as $category) {
                 foreach ($data as $category_match) {
                     if ($category["ID_Category"] === $category_match["ID_Category"]) {
                         $categories[$i]["checked"] = TRUE;
                     }
                 }
                 $i++;
             }
         }
         $data = $categories;
         if ($data) {
             $HTML = $this->build($data, NULL, $type, $name);
         } else {
             return FALSE;
         }
         unset($this->HTML);
         return $HTML;
     }
 }
Beispiel #4
0
 function whichLanguage($invert = true, $lower = false)
 {
     global $Load;
     $Load->helper("router");
     if (isLang(segment(0))) {
         if (segment(0) and !$invert) {
             return segment(0);
         } elseif (segment(0) and getLang(segment(0), true)) {
             return $lower ? strtolower(getLang(segment(0), true)) : getLang(segment(0), true);
         } elseif (!$invert) {
             return getLang(_get("webLanguage"));
         } else {
             return $lower ? strtolower(_get("webLanguage")) : _get("webLanguage");
         }
     } else {
         if (!$invert) {
             return getLang(_get("webLanguage"));
         } else {
             return $lower ? strtolower(_get("webLanguage")) : _get("webLanguage");
         }
     }
 }
Beispiel #5
0
 public function response($data, $segment = 4, $method = "GET")
 {
     if ($this->method() === $method) {
         if (isLang() and segment($segment) === "xml" or !isLang() and segment($segment - 1) === "xml") {
             header("Content-Type: text/xml");
             $this->Array2XML = $this->core("Array2XML");
             $this->Array2XML->printXML($data, "data", "contact");
         } else {
             print json_encode($data);
         }
     } else {
         return false;
     }
 }
Beispiel #6
0
 public function count($type = "posts")
 {
     if (isLang()) {
         $year = isYear(segment(1)) ? segment(1) : FALSE;
         $month = isMonth(segment(2)) ? segment(2) : FALSE;
         $day = isDay(segment(3)) ? segment(3) : FALSE;
     } else {
         $year = isYear(segment(0)) ? segment(0) : FALSE;
         $month = isMonth(segment(1)) ? segment(1) : FALSE;
         $day = isDay(segment(2)) ? segment(2) : FALSE;
     }
     if ($type === "posts") {
         if ($year and $month and $day) {
             $count = $this->Db->countBySQL("Language = '{$this->language}' AND Year = '{$year}' AND Month = '{$month}' AND Day = '{$day}' AND Situation = 'Active'", $this->table);
         } elseif ($year and $month) {
             $count = $this->Db->countBySQL("Language = '{$this->language}' AND Year = '{$year}' AND Month = '{$month}' AND Situation = 'Active'", $this->table);
         } elseif ($year) {
             $count = $this->Db->countBySQL("Language = '{$this->language}' AND Year = '{$year}' AND Situation = 'Active'", $this->table);
         } else {
             $count = $this->Db->countBySQL("Language = '{$this->language}' AND Situation = 'Active'", $this->table);
         }
     } elseif ($type === "comments") {
         $count = 0;
     } elseif ($type === "tag") {
         $data = $this->getByTag(segment(3));
         $count = count($data);
     } elseif ($type === "categories") {
         $data = $this->getByCategory(segment(3));
         $count = count($data);
     }
     return isset($count) ? $count : 0;
 }
Beispiel #7
0
function formSave($action = NULL)
{
    if ($action === "save") {
        $href = path(segment(0, isLang()) . "/cpanel/add/");
    } else {
        $href = path(segment(0, isLang()) . "/cpanel/edit/" . segment(3, isLang()));
    }
    $onclick = 'onclick="document.getElementById(\'form-add\').target=\'\'; document.getElementById(\'form-add\').action=\'' . $href . '\'"';
    $HTML = '	
		<p class="save-cancel">
			<input id="' . $action . '" name="' . $action . '" value="' . __(ucfirst($action)) . '" ' . $onclick . ' type="submit" class="btn btn-success">
			<input id="cancel" name="cancel" value="' . __("Cancel") . '" type="submit" class="btn btn-danger" />
		</p>';
    return $HTML;
}
Beispiel #8
0
function getSearch()
{
    global $Load;
    $Load->helper(array("forms", "html"));
    $application = whichApplication();
    if ($application === "users") {
        $field = "username";
        $name = __(_("Username"));
    } else {
        $field = "title";
        $name = __(_("Title"));
    }
    $fields = array(0 => array("field" => "ID", "name" => "ID", "selected" => FALSE), 1 => array("field" => $field, "name" => $name, "selected" => TRUE));
    $trash = NULL;
    if (segment(3, isLang()) === "trash") {
        $trash = "trash";
    }
    $HTML = formOpen(path($application . "/cpanel/results/{$trash}"), "form-results-search");
    $HTML .= br();
    $HTML .= bold("&nbsp" . __(_("Search")) . ":", FALSE);
    $attributes = array("p" => FALSE, "name" => "search", "class" => "span 1 required");
    $HTML .= formInput($attributes);
    $HTML .= bold(" " . __(_("Field")) . ":", FALSE);
    $i = 0;
    foreach ($fields as $field) {
        $fields[$i]["value"] = $field["field"];
        $fields[$i]["option"] = $field["name"];
        $fields[$i]["selected"] = $field["selected"];
        $i++;
    }
    $HTML .= formSelect(array("name" => "field", "class" => "span2 required"), $fields);
    $HTML .= bold(__(_("Order")) . ":", FALSE);
    $options[0]["value"] = "ASC";
    $options[0]["option"] = __(_("Ascending"));
    $options[0]["selected"] = TRUE;
    $options[1]["value"] = "DESC";
    $options[1]["option"] = __(_("Descending"));
    $options[1]["selected"] = FALSE;
    $HTML .= formSelect(array("name" => "order", "class" => "span2 required"), $options);
    $HTML .= formInput(array("name" => "seek", "type" => "submit", "class" => "btn btn-info", "value" => __(_("Seek"))));
    return $HTML;
}
Beispiel #9
0
 public function upload()
 {
     if (segment(2, isLang()) === "upload" and segment(3, isLang()) === "images") {
         $value = POST("iDirbase") ? POST("iDirbase") : 'www/lib/files/images/uploaded/';
         $value = POST("iMake") ? POST("iDir") . slug(POST("iDirname")) : $value;
         $parts = explode("/", $value);
     } elseif (segment(2, isLang()) === "upload" and segment(3, isLang()) === "documents") {
         $value = POST("dDirbase") ? POST("dDirbase") : 'www/lib/files/documents/uploaded/';
         $value = POST("dMake") ? POST("dDir") . slug(POST("dDirname")) : $value;
         $parts = explode("/", $value);
     }
     if (count($parts) > 0) {
         $part = NULL;
         for ($i = 0; $i <= count($parts) - 1; $i++) {
             $part .= slug($parts[$i]) . _sh;
         }
         $part = str_replace("//", "/", $part);
     }
     if ($part !== "") {
         $this->uploading($part);
     } else {
         $this->uploading($value);
     }
 }
Beispiel #10
0
 function path($path = false, $URL = false, $lang = true, $anchor = false)
 {
     $anchor = ($anchor and defined("_anchor")) ? SH . ANCHOR : null;
     if ($path === false) {
         return isLang() ? _get("webBase") . "/" . _get("webLang") : _get("webBase");
     } elseif ($path === true) {
         return $lang ? _get("webBase") . "/" . _get("webLang") : _get("webBase");
     }
     if ($URL === "zan") {
         return getDomain(CORE_PATH) . "/zan/" . $path;
     } elseif (isLang($path)) {
         return _get("webBase") . "/" . $path . $anchor;
     }
     if ($lang) {
         if ($lang !== true) {
             $lang = getLang($lang);
             return $URL ? _get("webURL") . "/" . $path : _get("webBase") . "/" . $lang . "/" . $path . $anchor;
         }
         return $URL ? _get("webURL") . "/" . $path : _get("webBase") . "/" . _get("webLang") . "/" . $path . $anchor;
     } else {
         return $URL ? _get("webURL") . "/" . $path : _get("webBase") . "/" . $path . $anchor;
     }
 }
Beispiel #11
0
 private function limit($type = "posts")
 {
     $start = 0;
     if ($type === "posts") {
         if (isLang()) {
             if (segment(2) === "page" and segment(3) > 0) {
                 $start = segment(3) * _maxLimit - _maxLimit;
             }
         } else {
             if (segment(1) === "page" and segment(2) > 0) {
                 $start = segment(2) * _maxLimit - _maxLimit;
             }
         }
         $limit = $start . ", " . _maxLimit;
         $count = $this->Blog_Model->count();
         $URL = path("blog/page/");
     } elseif ($type === "categories") {
         if (isLang()) {
             if (segment(2) === "category" and segment(3) !== "page" and segment(4) === "page" and segment(5) > 0) {
                 $start = segment(5) * _maxLimit - _maxLimit;
             }
         } else {
             if (segment(1) === "category" and segment(2) !== "page" and segment(3) === "page" and segment(4) > 0) {
                 $start = segment(4) * _maxLimit - _maxLimit;
             }
         }
         $limit = $start . ", " . _maxLimit;
         $URL = path("blog/category/" . segment(3) . "/page");
         $count = $this->Blog_Model->count("categories");
     } elseif ($type === "day") {
         if (isLang()) {
             if (isYear(segment(2)) and isMonth(segment(3)) and isDay(segment(4)) and segment(5) === "page" and segment(6) > 0) {
                 $start = segment(6) * _maxLimit - _maxLimit;
             }
         } else {
             if (isYear(segment(1)) and isMonth(segment(2)) and isDay(segment(3)) and segment(4) === "page" and segment(5) > 0) {
                 $start = segment(5) * _maxLimit - _maxLimit;
             }
         }
         $limit = $start . ", " . _maxLimit;
         $count = $this->Blog_Model->count("posts");
         $URL = path("blog/" . segment(2) . "/" . segment(3) . "/" . segment(4) . "/page/");
     } elseif ($type === "month") {
         if (isLang()) {
             if (isYear(segment(2)) and isMonth(segment(3)) and segment(4) === "page" and segment(5) > 0) {
                 $start = segment(5) * _maxLimit - _maxLimit;
             }
         } else {
             if (isYear(segment(1)) and isMonth(segment(2)) and segment(3) === "page" and segment(4) > 0) {
                 $start = segment(4) * _maxLimit - _maxLimit;
             }
         }
         $limit = $start . ", " . _maxLimit;
         $count = $this->Blog_Model->count("posts");
         $URL = path("blog/" . segment(2) . "/" . segment(3) . "/page/");
     } elseif ($type === "year") {
         if (isLang()) {
             if (isYear(segment(2)) and segment(3) === "page" and segment(4) > 0) {
                 $start = segment(4) * _maxLimit - _maxLimit;
             }
         } else {
             if (isYear(segment(1)) and segment(2) === "page" and segment(3) > 0) {
                 $start = segment(3) * _maxLimit - _maxLimit;
             }
         }
         $limit = $start . ", " . _maxLimit;
         $count = $this->Blog_Model->count("posts");
         $URL = path("blog/" . segment(2) . "/page/");
     } elseif ($type === "tag") {
         if (isLang()) {
             if (segment(2) === "tag" and segment(3) and segment(4) === "page" and segment(5) > 0) {
                 $start = segment(5) * _maxLimit - _maxLimit;
             }
         } else {
             if (segment(1) === "tag" and segment(2) and segment(3) === "page" and segment(4) > 0) {
                 $start = segment(4) * _maxLimit - _maxLimit;
             }
         }
         $limit = $start . ", " . _maxLimit;
         $count = $this->Blog_Model->count("tag");
         $URL = path("blog/tag/" . segment(3) . "/page/");
     }
     if ($count > _maxLimit) {
         $this->pagination = paginate($count, _maxLimit, $start, $URL);
     } else {
         $this->pagination = NULL;
     }
     return $limit;
 }
Beispiel #12
0
 public function make()
 {
     $this->action = isLang() ? _webBase . "/" . segment(0) . "/" . segment(1) . "/" . segment(2) : _webBase . "/" . segment(0) . "/" . segment(1);
     if (is_array($this->columns)) {
         $this->CSS("scaffold");
         $this->js("tiny-mce", NULL, "class");
         $HTML = formOpen($this->action, "scaffold");
         if ($this->error) {
             $HTML .= $this->error;
         } elseif ($this->success) {
             $HTML .= $this->success;
         }
         $attributes = array("type" => "hidden", "name" => "_table", "value" => base64_encode($this->table));
         $HTML .= formInput($attributes);
         unset($attributes);
     }
     $HTML .= $this->build();
     $vars["HTML"] = $HTML;
     $this->template("scaffold", $vars);
     $this->render("header", "footer");
 }
Beispiel #13
0
/**
 * whichLanguage
 *
 * Returns the default Language
 * 
 * @param boolean $invert = TRUE
 * @return string value
 */
function whichLanguage($invert = TRUE, $lower = FALSE)
{
    global $Load;
    $Load->helper("router");
    if (isLang(segment(0))) {
        if (segment(0) and !$invert) {
            return segment(0);
        } elseif (segment(0) and getLang(segment(0), TRUE)) {
            return $lower ? strtolower(getLang(segment(0), TRUE)) : getLang(segment(0), TRUE);
        } elseif (!$invert) {
            return getLang(get("webLanguage"));
        } else {
            return $lower ? strtolower(get("webLanguage")) : get("webLanguage");
        }
    } else {
        if (!$invert) {
            return getLang(get("webLanguage"));
        } else {
            return $lower ? strtolower(get("webLanguage")) : get("webLanguage");
        }
    }
}
Beispiel #14
0
 private function limit($type = "posts")
 {
     $start = 0;
     $count = $this->Blog_Model->count("posts");
     if ($type === "posts") {
         if (segment(1, isLang()) === "page" and segment(2, isLang()) > 0) {
             $start = segment(2, isLang()) * _maxLimit - _maxLimit;
         }
         $URL = path("blog/page/");
     } elseif ($type === "categories") {
         if (segment(1, isLang()) === "category" and segment(2, isLang()) !== "page" and segment(3, isLang()) === "page" and segment(4, isLang()) > 0) {
             $start = segment(4) * _maxLimit - _maxLimit;
         }
         $URL = path("blog/category/" . segment(3, isLang()) . "/page");
         $count = $this->Blog_Model->count("categories");
     } elseif ($type === "day") {
         if (isYear(segment(1, isLang())) and isMonth(segment(2, isLang())) and isDay(segment(3, isLang())) and segment(4, isLang()) === "page" and segment(5, isLang()) > 0) {
             $start = segment(5) * _maxLimit - _maxLimit;
         }
         $URL = path("blog/" . segment(2, isLang()) . "/" . segment(3, isLang()) . "/" . segment(4, isLang()) . "/page/");
     } elseif ($type === "month") {
         if (isYear(segment(1, isLang())) and isMonth(segment(2, isLang())) and segment(3, isLang()) === "page" and segment(4, isLang()) > 0) {
             $start = segment(4) * _maxLimit - _maxLimit;
         }
         $URL = path("blog/" . segment(2, isLang()) . "/" . segment(3, isLang()) . "/page/");
     } elseif ($type === "year") {
         if (isYear(segment(1, isLang())) and segment(2, isLang()) === "page" and segment(3, isLang()) > 0) {
             $start = segment(3, isLang()) * _maxLimit - _maxLimit;
         }
         $URL = path("blog/" . segment(2) . "/page/");
     } elseif ($type === "tag") {
         if (segment(1, isLang()) === "tag" and segment(2, isLang()) and segment(3, isLang()) === "page" and segment(4, isLang()) > 0) {
             $start = segment(4, isLang()) * _maxLimit - _maxLimit;
         }
         $count = $this->Blog_Model->count("tag");
         $URL = path("blog/tag/" . segment(2, isLang()) . "/page/");
     }
     $limit = $start . ", " . _maxLimit;
     $this->pagination = $count > _maxLimit ? paginate($count, _maxLimit, $start, $URL) : NULL;
     return $limit;
 }
Beispiel #15
0
function path($path = FALSE, $URL = FALSE, $lang = TRUE)
{
    if (!$path) {
        return isLang() ? get("webBase") . _sh . get("webLang") : get("webBase");
    }
    if ($URL === "zan") {
        return getDomain(_corePath) . _sh . "zan" . _sh . $path;
    } elseif (isLang($path)) {
        return get("webBase") . _sh . $path;
    }
    if ($lang) {
        return $URL ? get("webURL") . _sh . $path : get("webBase") . _sh . get("webLang") . _sh . $path;
    } else {
        return $URL ? get("webURL") . _sh . $path : get("webBase") . _sh . $path;
    }
}
Beispiel #16
0
 public function records($trash = FALSE, $order = NULL)
 {
     $Model = ucfirst(segment(0, isLang())) . "_Model";
     $this->{$Model} = $this->model($Model);
     if (isset($this->{$Model})) {
         if (POST("seek")) {
             $data = $this->{$Model}->cpanel("search", NULL, POST("field") . " " . POST("order"), POST("search"), POST("field"));
             if (!$data) {
                 showAlert("Results not found", path(whichApplication() . "/cpanel/results"));
             }
         } else {
             $start = 0;
             if ($trash) {
                 $start = (segment(4, isLang()) === "page" and segment(5, isLang()) > 0) ? segment(5, isLang()) * _maxLimit - _maxLimit : 0;
             } else {
                 $start = (segment(3, isLang()) === "page" and segment(4, isLang()) > 0) ? segment(4, isLang()) * _maxLimit - _maxLimit : 0;
             }
             $limit = $start . ", " . _maxLimit;
             if (segment(3, isLang()) === "order") {
                 $i = segment(4) ? 3 : 4;
                 $j = segment(4) ? 4 : 5;
                 if (segment($i) === "id") {
                     $field = "ID";
                 } elseif (segment($i) === "end-date") {
                     $field = "End_Date";
                 } elseif (segment($i) === "start-date") {
                     $field = "Start_Date";
                 } elseif (segment($i) === "text-date") {
                     $field = "Text_Date";
                 } else {
                     $field = ucfirst(segment($i));
                 }
                 if (segment($j) === "asc") {
                     $data = $this->{$Model}->cpanel("all", $limit, "{$field} ASC", NULL, NULL, $trash);
                 } elseif (segment($j) === "desc") {
                     $data = $this->{$Model}->cpanel("all", $limit, "{$field} DESC", NULL, NULL, $trash);
                 }
             } else {
                 $data = $this->{$Model}->cpanel("all", $limit, $order, NULL, NULL, $trash);
             }
         }
         return $data;
     }
     return FALSE;
 }
Beispiel #17
0
function path($path = FALSE, $URL = FALSE)
{
    if (!$path) {
        return isLang() ? get("webBase") . _sh . get("webLang") : get("webBase");
    }
    return $URL ? get("webURL") . _sh . $path : get("webBase") . _sh . get("webLang") . _sh . $path;
}