Example #1
0
 public function controllerExists($controller)
 {
     $controller = ucfirst(mb_strtolower($controller));
     // Проверяем наличие только основных контрорллеров, нам пофиг на подконтроллеры
     return in_array($controller, Router::getModuleList()) && (is_file(CORE_ROOT . 'controller' . $this->folder . $controller . '.php') || is_file(CORE_ROOT . 'controller' . $this->folder . $controller . '/' . $controller . '.php'));
 }
Example #2
0
File: Page.php Project: kizz66/meat
 public function update()
 {
     if (empty($this->Title) || empty($this->StaticPath)) {
         throw new Exception(lang('data_empty', __CLASS__));
     } else {
         if ($this->Type == 2 && !in_array($this->Link, Router::getModuleList())) {
             throw new Exception(lang('module_incorrect', __CLASS__));
         } else {
             if ($this->Type != 0 && (int) $this->ParentID < 1) {
                 throw new Exception(lang('select_parent', __CLASS__));
             }
         }
     }
     $this->_prepareContentBeforeSave();
     $db = MySQL::getInstance();
     $query = "UPDATE `page` SET\n\t\t\t`Title` = " . $db->escape($this->Title, 255) . ",\n\t\t\t`Description` = " . $db->escape($this->Description) . ",\n\t\t\t`Content` = " . $db->escape($this->Content) . ",\n\t\t\t`ParentID` = " . $db->escape((int) $this->ParentID) . ",\n\t\t\t`MetaTitle` = " . $db->escape($this->MetaTitle, 255) . ",\n\t\t\t`MetaDescription` = " . $db->escape($this->MetaDescription) . ",\n\t\t\t`MetaKeywords` = " . $db->escape($this->MetaKeywords) . ",\n\t\t\t`StaticPath` = " . $db->escape(slugify($this->StaticPath)) . ",\n\t\t\t`Link` = " . $db->escape($this->Link, 255) . ",\n\t\t\t`Active` = " . $db->escape((int) $this->Active) . ",";
     if (!empty($this->ImageDelete)) {
         $db->query("SELECT `Image` FROM `page` WHERE PageID = " . $db->escape((int) $this->PageID));
         $oldImageFile = $db->fetchField();
         if ($oldImageFile) {
             File::delete($oldImageFile);
             File::delete('thumb_' . $oldImageFile);
             $db->query("UPDATE `page` SET `Image` = NULL WHERE PageID = " . $db->escape((int) $this->PageID));
         }
     }
     if (($imageName = File::upload()) !== false) {
         if (File::copy($imageName, 'thumb_' . $imageName)) {
             File::imageCrop('thumb_' . $imageName, false, 150, 150);
         }
         File::imageCrop($imageName, false, 500, 500);
         $db->query("SELECT `Image` FROM `page` WHERE `PageID` = " . $db->escape((int) $this->PageID));
         if ($oldImageFile = $db->fetchField()) {
             File::delete($oldImageFile);
             File::delete('thumb_' . $oldImageFile);
         }
         $query .= "`Image` = " . $db->escape($imageName) . ",";
     }
     $query .= "`Modified` = " . $db->escape((int) time()) . "\n\t\t\tWHERE `PageID` = " . $db->escape((int) $this->PageID);
     $db->query($query);
     if ($this->ParentID != $this->CurrentParentID) {
         return $this->moveTo();
     }
     return true;
 }