public static function savePassword(\Rebond\Core\User\Model $user) { Util\Log::log(Util\Error::PASSWORD_CHANGE, $user->getId(), __FILE__, __LINE__); $db = new Util\Data(); $query = 'UPDATE core_user SET password = ?, modified_date = ? WHERE id = ?'; return $db->execute($query, [$user->getPassword(), Util\Format::date(time(), 'sqlDatetime'), $user->getId()]); }
public static function save(\Rebond\Core\ModelInterface $model) { $db = new Util\Data(); if ($model->getId() === 0) { $query = 'INSERT INTO cms_gadget (page_id, component_id, `col`, filter_id, `custom_filter`, `display_order`, `status`, `created_date`, `modified_date`) VALUES (?,?,?,?,?,?,?,?,?)'; $params = [$model->getPageId(), $model->getComponentId(), $model->getCol(), $model->getFilterId(), $model->getCustomFilter(), $model->getDisplayOrder(), $model->getStatus(), $model->getCreatedDate('sqlDatetime'), Util\Format::date(time(), 'sqlDatetime')]; $id = $db->execute($query, $params); $model->setId($id); return $id; } else { $query = 'UPDATE cms_gadget SET '; $params = []; if ($model->getPageId() !== null) { $query .= 'page_id = ?, '; $params[] = $model->getPageId(); } if ($model->getComponentId() !== null) { $query .= 'component_id = ?, '; $params[] = $model->getComponentId(); } if ($model->getCol() !== null) { $query .= '`col` = ?, '; $params[] = $model->getCol(); } if ($model->getFilterId() !== null) { $query .= 'filter_id = ?, '; $params[] = $model->getFilterId(); } if ($model->getCustomFilter() !== null) { $query .= '`custom_filter` = ?, '; $params[] = $model->getCustomFilter(); } if ($model->getDisplayOrder() !== null) { $query .= '`display_order` = ?, '; $params[] = $model->getDisplayOrder(); } if ($model->getStatus() !== null) { $query .= '`status` = ?, '; $params[] = $model->getStatus(); } $query .= '`modified_date` = ?, '; $params[] = Util\Format::date(time(), 'sqlDatetime'); $query = rtrim(trim($query), ','); $query .= ' WHERE id = ?'; $params[] = $model->getId(); return $db->execute($query, $params); } }
public function text_editor() { // auth Auth::isAdminAuthorized($this->signedUser, 'admin.media.image', true, '/media'); // check $info = null; $generate = Converter::bool('generate'); $imageListPath = \Rebond\Config::getPath('admin') . 'js/tinymce/imageList.js'; // action if ($generate) { $url = \Rebond\Config::getPath('siteUrl') . \Rebond\Config::getPath('mediaFolder'); $list = '['; $options = []; $options['clearSelect'] = true; $options['select'][] = \Rebond\Core\Media\Data::getList(['id', 'title', 'path', 'upload']); $options['where'][] = 'media.status = 1'; $options['where'][] = 'media.extension IN ("png", "gif", "jpg", "jpeg")'; $options['order'][] = 'media.title'; $medium = \Rebond\Core\Media\Data::loadAll($options); foreach ($medium as $media) { $list .= '{title:"' . $media->getTitle() . '", value:"http://' . $url . $media->getPath() . $media->getUpload() . '"},' . chr(10); } if (count($medium) > 0) { $list = substr($list, 0, -2); } $list .= ']'; File::save($imageListPath, 'w', $list); $info = '<p class="bg-success">' . count($medium) . ' ' . Lang::lang('photosGenerated') . '</p>'; } // view $this->setTpl(); // main $tplMain = new Template(Template::SITE, ['admin', 'media']); $tplMain->set('info', $info); if (file_exists($imageListPath)) { $tplMain->set('date', \Rebond\Util\Format::smartDate(filemtime($imageListPath))); $tplMain->set('link', '/js/tinymce/imageList.js'); } else { $tplMain->set('date', 'n/a'); } // layout $this->tplLayout->set('column1', $tplMain->render('text-editor')); // master $this->tplMaster->set('layout', $this->tplLayout->render('layout-1-col')); return $this->tplMaster->render('tpl-default'); }
public static function save(\Rebond\Core\ModelInterface $model) { $db = new Util\Data(); if ($model->getId() === 0) { $query = 'INSERT INTO core_media (folder_id, `title`, `tags`, `upload`, `original_filename`, `path`, `extension`, `mime_type`, `file_size`, `width`, `height`, `alt`, `is_selectable`, `status`, `created_date`, `modified_date`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)'; $params = [$model->getFolderId(), $model->getTitle(), $model->getTags(), $model->getUpload(), $model->getOriginalFilename(), $model->getPath(), $model->getExtension(), $model->getMimeType(), $model->getFileSize(), $model->getWidth(), $model->getHeight(), $model->getAlt(), $model->getIsSelectable(), $model->getStatus(), $model->getCreatedDate('sqlDatetime'), Util\Format::date(time(), 'sqlDatetime')]; $id = $db->execute($query, $params); $model->setId($id); return $id; } else { $query = 'UPDATE core_media SET '; $params = []; if ($model->getFolderId() !== null) { $query .= 'folder_id = ?, '; $params[] = $model->getFolderId(); } if ($model->getTitle() !== null) { $query .= '`title` = ?, '; $params[] = $model->getTitle(); } if ($model->getTags() !== null) { $query .= '`tags` = ?, '; $params[] = $model->getTags(); } if ($model->getUpload() !== null) { $query .= '`upload` = ?, '; $params[] = $model->getUpload(); } if ($model->getOriginalFilename() !== null) { $query .= '`original_filename` = ?, '; $params[] = $model->getOriginalFilename(); } if ($model->getPath() !== null) { $query .= '`path` = ?, '; $params[] = $model->getPath(); } if ($model->getExtension() !== null) { $query .= '`extension` = ?, '; $params[] = $model->getExtension(); } if ($model->getMimeType() !== null) { $query .= '`mime_type` = ?, '; $params[] = $model->getMimeType(); } if ($model->getFileSize() !== null) { $query .= '`file_size` = ?, '; $params[] = $model->getFileSize(); } if ($model->getWidth() !== null) { $query .= '`width` = ?, '; $params[] = $model->getWidth(); } if ($model->getHeight() !== null) { $query .= '`height` = ?, '; $params[] = $model->getHeight(); } if ($model->getAlt() !== null) { $query .= '`alt` = ?, '; $params[] = $model->getAlt(); } if ($model->getIsSelectable() !== null) { $query .= '`is_selectable` = ?, '; $params[] = $model->getIsSelectable(); } if ($model->getStatus() !== null) { $query .= '`status` = ?, '; $params[] = $model->getStatus(); } $query .= '`modified_date` = ?, '; $params[] = Util\Format::date(time(), 'sqlDatetime'); $query = rtrim(trim($query), ','); $query .= ' WHERE id = ?'; $params[] = $model->getId(); return $db->execute($query, $params); } }
public static function save(\Rebond\Core\ModelInterface $model) { $db = new Util\Data(); if ($model->getId() === 0) { $query = 'INSERT INTO cms_module (`title`, `summary`, `workflow`, `has_filter`, `has_content`, `status`, `created_date`, `modified_date`) VALUES (?,?,?,?,?,?,?,?)'; $params = [$model->getTitle(), $model->getSummary(), $model->getWorkflow(), $model->getHasFilter(), $model->getHasContent(), $model->getStatus(), $model->getCreatedDate('sqlDatetime'), Util\Format::date(time(), 'sqlDatetime')]; $id = $db->execute($query, $params); $model->setId($id); return $id; } else { $query = 'UPDATE cms_module SET '; $params = []; if ($model->getTitle() !== null) { $query .= '`title` = ?, '; $params[] = $model->getTitle(); } if ($model->getSummary() !== null) { $query .= '`summary` = ?, '; $params[] = $model->getSummary(); } if ($model->getWorkflow() !== null) { $query .= '`workflow` = ?, '; $params[] = $model->getWorkflow(); } if ($model->getHasFilter() !== null) { $query .= '`has_filter` = ?, '; $params[] = $model->getHasFilter(); } if ($model->getHasContent() !== null) { $query .= '`has_content` = ?, '; $params[] = $model->getHasContent(); } if ($model->getStatus() !== null) { $query .= '`status` = ?, '; $params[] = $model->getStatus(); } $query .= '`modified_date` = ?, '; $params[] = Util\Format::date(time(), 'sqlDatetime'); $query = rtrim(trim($query), ','); $query .= ' WHERE id = ?'; $params[] = $model->getId(); return $db->execute($query, $params); } }
public function setTitle($value) { $this->title = $value; $this->setUrlfriendlytitle(Format::friendlyTitle($this->title)); }
public static function save(\Rebond\Core\ModelInterface $model) { $db = new Util\Data(); if ($model->getId() === 0) { $query = 'INSERT INTO cms_module_media (module_id, `field`, `status`, `created_date`, `modified_date`) VALUES (?,?,?,?,?)'; $params = [$model->getModuleId(), $model->getField(), $model->getStatus(), $model->getCreatedDate('sqlDatetime'), Util\Format::date(time(), 'sqlDatetime')]; $id = $db->execute($query, $params); $model->setId($id); return $id; } else { $query = 'UPDATE cms_module_media SET '; $params = []; if ($model->getModuleId() !== null) { $query .= 'module_id = ?, '; $params[] = $model->getModuleId(); } if ($model->getField() !== null) { $query .= '`field` = ?, '; $params[] = $model->getField(); } if ($model->getStatus() !== null) { $query .= '`status` = ?, '; $params[] = $model->getStatus(); } $query .= '`modified_date` = ?, '; $params[] = Util\Format::date(time(), 'sqlDatetime'); $query = rtrim(trim($query), ','); $query .= ' WHERE id = ?'; $params[] = $model->getId(); return $db->execute($query, $params); } }
public function getModifiedDate($format = null) { return Format::date($this->modifiedDate, $format); }
public function getDescription($format = null) { return Format::text($this->description, $format); }
public static function save(\Rebond\Core\ModelInterface $model) { $db = new Util\Data(); if ($model->getId() === 0) { $query = 'INSERT INTO core_site (`title`, `google_analytics`, `keywords`, `description`, `css`, `js`, `sign_in_url`, `environment`, `sql_log`, `timezone`, `is_cms`, `cache_time`, `use_device_template`, `skin`, `send_mail_on_error`, `mail_list_on_error`, `status`, `created_date`, `modified_date`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)'; $params = [$model->getTitle(), $model->getGoogleAnalytics(), $model->getKeywords(), $model->getDescription(), $model->getCss(), $model->getJs(), $model->getSignInUrl(), $model->getEnvironment(), $model->getSqlLog(), $model->getTimezone(), $model->getIsCms(), $model->getCacheTime(), $model->getUseDeviceTemplate(), $model->getSkin(), $model->getSendMailOnError(), $model->getMailListOnError(), $model->getStatus(), $model->getCreatedDate('sqlDatetime'), Util\Format::date(time(), 'sqlDatetime')]; $id = $db->execute($query, $params); $model->setId($id); return $id; } else { $query = 'UPDATE core_site SET '; $params = []; if ($model->getTitle() !== null) { $query .= '`title` = ?, '; $params[] = $model->getTitle(); } if ($model->getGoogleAnalytics() !== null) { $query .= '`google_analytics` = ?, '; $params[] = $model->getGoogleAnalytics(); } if ($model->getKeywords() !== null) { $query .= '`keywords` = ?, '; $params[] = $model->getKeywords(); } if ($model->getDescription() !== null) { $query .= '`description` = ?, '; $params[] = $model->getDescription(); } if ($model->getCss() !== null) { $query .= '`css` = ?, '; $params[] = $model->getCss(); } if ($model->getJs() !== null) { $query .= '`js` = ?, '; $params[] = $model->getJs(); } if ($model->getSignInUrl() !== null) { $query .= '`sign_in_url` = ?, '; $params[] = $model->getSignInUrl(); } if ($model->getEnvironment() !== null) { $query .= '`environment` = ?, '; $params[] = $model->getEnvironment(); } if ($model->getSqlLog() !== null) { $query .= '`sql_log` = ?, '; $params[] = $model->getSqlLog(); } if ($model->getTimezone() !== null) { $query .= '`timezone` = ?, '; $params[] = $model->getTimezone(); } if ($model->getIsCms() !== null) { $query .= '`is_cms` = ?, '; $params[] = $model->getIsCms(); } if ($model->getCacheTime() !== null) { $query .= '`cache_time` = ?, '; $params[] = $model->getCacheTime(); } if ($model->getUseDeviceTemplate() !== null) { $query .= '`use_device_template` = ?, '; $params[] = $model->getUseDeviceTemplate(); } if ($model->getSkin() !== null) { $query .= '`skin` = ?, '; $params[] = $model->getSkin(); } if ($model->getSendMailOnError() !== null) { $query .= '`send_mail_on_error` = ?, '; $params[] = $model->getSendMailOnError(); } if ($model->getMailListOnError() !== null) { $query .= '`mail_list_on_error` = ?, '; $params[] = $model->getMailListOnError(); } if ($model->getStatus() !== null) { $query .= '`status` = ?, '; $params[] = $model->getStatus(); } $query .= '`modified_date` = ?, '; $params[] = Util\Format::date(time(), 'sqlDatetime'); $query = rtrim(trim($query), ','); $query .= ' WHERE id = ?'; $params[] = $model->getId(); return $db->execute($query, $params); } }
private function addPlayers(array $players, $start, $batch) { $start *= $batch; $sqlUserMain = 'INSERT INTO core_user (id, firstname, lastname, username, email, password, avatar_id, is_admin, is_dev, status, created_date, modified_date) VALUES '; $sqlUserItem = "(%d, '%s', '%s', '%s', '%s', '%s', 0, 0, 0, 1, NOW(), NOW())"; $sqlUserRoleMain = 'INSERT INTO core_user_role (user_id, role_id) VALUES '; $sqlUserRoleItem = '(%d, 5)'; $sqlPlayerMain = 'INSERT INTO bus_player (id, max_booking, level, is_caroussel, credits) VALUES '; $sqlPlayerItem = '(%d, 1, 0, 0, 10)'; $sqlMembershipMain = 'INSERT INTO bus_player_membership (player_id, membership_id) VALUES '; $sqlMembershipItem = '(%d, 1)'; $count = 0; $sqlUser = []; $sqlUserRole = []; $sqlPlayer = []; $sqlMembership = []; foreach ($players as $id => $player) { if ($id < 1) { continue; } $start--; if ($start >= 0) { continue; } $sqlUser[] = sprintf($sqlUserItem, $id, $player[1], $player[0], Util\Format::friendlyTitle($player[1] . '_' . $player[0]), uniqid() . '@gmail.com', Util\Security::encryptPassword('test')); $sqlUserRole[] = sprintf($sqlUserRoleItem, $id); $sqlPlayer[] = sprintf($sqlPlayerItem, $id); $sqlMembership[] = sprintf($sqlMembershipItem, $id); $count++; if ($count >= $batch) { break; } } $db = new Util\Data(); $db->execute($sqlUserMain . implode(',', $sqlUser)); $db->execute($sqlUserRoleMain . implode(',', $sqlUserRole)); $db->execute($sqlPlayerMain . implode(',', $sqlPlayer)); $db->execute($sqlMembershipMain . implode(',', $sqlMembership)); return $count . ' players added. '; }
public function bin() { // auth Util\Auth::isAdminAuthorized($this->signedUser, 'admin.dev', true, '/'); // check $result = ''; $empty = Util\Converter::bool('empty'); $contentItems = []; // content items $options = []; $options['where'][] = 'module.has_content = 1'; $modules = \Rebond\Cms\Module\Data::loadAll($options); $options = []; $options['where'][] = ['content.version IN (?)', [4, 5]]; $options['order'][] = 'content.modified_date'; foreach ($modules as $module) { $appData = '\\Rebond\\App\\' . $module->getTitle() . '\\Data'; $items = $appData::loadAll($options); if (count($items) > 0) { if ($empty) { foreach ($items as $item) { $item->delete(); } } else { $contentItems[$module->getTitle()] = $items; } } } // CSS $filePath = \Rebond\Config::getPath('siteFolder') . '/css/skin/'; $skins = Util\File::getFolders($filePath); $cssFiles = []; foreach ($skins as $skin) { $cssFiles[$skin] = []; $path = $filePath . $skin . '/'; $files = Util\File::getFiles($path); foreach ($files as $file) { if (Util\File::getExtension($file) == 'css') { continue; } if ($empty) { Util\File::delete($path, $file); } else { $date = Util\Format::date(filemtime(FULL_PATH . $path . $file), 'smart'); $cssFiles[$skin][] = ['name' => $file, 'date' => $date]; } } } // Main Templates $path = 'views/' . \Rebond\Config::getPath('siteFolder') . '/'; $templates = Util\File::getFiles($path); $mainTpl = []; foreach ($templates as $tpl) { if (Util\File::getExtension($tpl) == 'tpl') { continue; } if ($empty) { Util\File::delete($path, $tpl); } else { $date = Util\Format::date(filemtime(FULL_PATH . $path . $tpl), 'smart'); $mainTpl[] = ['name' => $tpl, 'date' => $date]; } } // App Templates $appFolders = Util\File::getFolders('Rebond/App/'); $appTpl = []; foreach ($appFolders as $app) { $appTpl[$app] = []; $path = 'Rebond/App/' . $app . '/template/'; $templates = Util\File::getFiles($path); foreach ($templates as $tpl) { if (Util\File::getExtension($tpl) == 'tpl') { continue; } if ($empty) { Util\File::delete($path, $tpl); } else { $date = Util\Format::date(filemtime(FULL_PATH . $path . $tpl), 'smart'); $appTpl[$app][] = ['name' => $tpl, 'date' => $date]; } } } if ($empty) { $result = '<p class="bg-success">' . Util\Lang::lang('binEmptied') . '</p>'; } // view $this->setTpl(); // main $tplMain = new Util\Template(Util\Template::SITE, ['admin', 'dev']); $tplMain->set('contentItems', $contentItems); $tplMain->set('cssFiles', $cssFiles); $tplMain->set('mainTpl', $mainTpl); $tplMain->set('appTpl', $appTpl); $tplMain->set('result', $result); // layout $this->tplLayout->set('column1', $tplMain->render('bin')); // master $this->tplMaster->set('layout', $this->tplLayout->render('layout-1-col')); $this->tplMaster->set('jsLauncher', 'dev'); return $this->tplMaster->render('tpl-default'); }
public function tpl_edit() { // auth Util\Auth::isAdminAuthorized($this->signedUser, 'admin.designer', true, '/'); // check $file = Util\Converter::string('f'); $app = Util\Converter::string('app'); $save = Util\Converter::string('save', 'post'); if (empty($file)) { Util\Session::adminError('itemNotFound', [$file], '/designer/tpl'); } $validator = Util\Validate::validateFilename('file', $file, true); if (!$validator->isValid()) { Util\Session::setAndRedirect('adminError', $validator->getMessage(), '/designer/tpl'); } $filePath = FULL_PATH . 'views/www/'; if (!empty($app)) { $filePath = FULL_PATH . 'Rebond/App/' . $app . '/template/'; $validator = Util\Validate::validateAlphaNumeric('app', $app, true); if (!$validator->isValid()) { Util\Session::setAndRedirect('adminError', $validator->getMessage(), '/designer/tpl'); } } if (!file_exists($filePath)) { Util\Session::adminError('itemNotFound', [$filePath], '/designer/tpl'); } // action if (isset($save)) { $filePost = Util\Converter::string('file', 'post'); $tplFile = Util\Converter::string('tpl-file', 'post'); $appPost = Util\Converter::string('app', 'post'); $file = FULL_PATH . 'views/' . \Rebond\Config::getPath('siteFolder') . '/' . $filePost; if (!empty($appPost)) { $file = \Rebond\Config::getPath('rebond') . 'App/' . $appPost . '/template/' . $filePost; } if (!isset($file) || Util\File::getExtension($file) != 'tpl') { Util\Session::adminError('fileNotFoundOrValid', [$file], '/designer/css'); } if (!copy($file, Util\File::getNoExtension($file) . '-' . Util\Format::date(time(), 'string') . '.bak')) { Util\Session::adminError('itemNotCopied', [$file], '/designer/css'); } file_put_contents($file, $tplFile); Util\Session::adminSuccess('saved', '/designer/tpl'); } // view $this->setTpl(); // main $tplMain = new Util\Template(Util\Template::SITE, ['admin', 'designer']); $tplMain->set('file', $file); $tplMain->set('app', $app); $tplMain->set('filePath', $filePath); $tplMain->set('editable', Util\File::getExtension($file) == 'tpl'); // layout $this->tplLayout->set('column1', $tplMain->render('tpl-form')); // master $this->tplMaster->set('layout', $this->tplLayout->render('layout-1-col')); $this->tplMaster->set('jsLauncher', 'designerTpl'); $this->tplMaster->addCss('/css/codemirror.css'); $this->tplMaster->addJs('/js/codemirror/codemirror.js'); $this->tplMaster->addJs('/js/codemirror/htmlmixed.js'); $this->tplMaster->addJs('/js/codemirror/xml.js'); $this->tplMaster->addJs('/js/codemirror/clike.js'); $this->tplMaster->addJs('/js/codemirror/php.js'); return $this->tplMaster->render('tpl-default'); }
public static function save(\Rebond\Core\ModelInterface $model) { $db = new Util\Data(); if ($model->getId() === 0) { $query = 'INSERT INTO core_feedback (user_id, `title`, `type`, `description`, `status`, `created_date`, `modified_date`) VALUES (?,?,?,?,?,?,?)'; $params = [$model->getUserId(), $model->getTitle(), $model->getType(), $model->getDescription(), $model->getStatus(), $model->getCreatedDate('sqlDatetime'), Util\Format::date(time(), 'sqlDatetime')]; $id = $db->execute($query, $params); $model->setId($id); return $id; } else { $query = 'UPDATE core_feedback SET '; $params = []; if ($model->getUserId() !== null) { $query .= 'user_id = ?, '; $params[] = $model->getUserId(); } if ($model->getTitle() !== null) { $query .= '`title` = ?, '; $params[] = $model->getTitle(); } if ($model->getType() !== null) { $query .= '`type` = ?, '; $params[] = $model->getType(); } if ($model->getDescription() !== null) { $query .= '`description` = ?, '; $params[] = $model->getDescription(); } if ($model->getStatus() !== null) { $query .= '`status` = ?, '; $params[] = $model->getStatus(); } $query .= '`modified_date` = ?, '; $params[] = Util\Format::date(time(), 'sqlDatetime'); $query = rtrim(trim($query), ','); $query .= ' WHERE id = ?'; $params[] = $model->getId(); return $db->execute($query, $params); } }
public static function save(\Rebond\Core\ModelInterface $model) { $db = new Util\Data(); if ($model->getId() === 0) { $query = 'INSERT INTO core_log (`code`, user_id, `ip`, `request_uri`, `referer`, `message`, `trace`, `file`, `line`, `status`, `created_date`, `modified_date`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)'; $params = [$model->getCode(), $model->getUserId(), $model->getIp(), $model->getRequestUri(), $model->getReferer(), $model->getMessage(), $model->getTrace(), $model->getFile(), $model->getLine(), $model->getStatus(), $model->getCreatedDate('sqlDatetime'), Util\Format::date(time(), 'sqlDatetime')]; $id = $db->execute($query, $params); $model->setId($id); return $id; } else { $query = 'UPDATE core_log SET '; $params = []; if ($model->getCode() !== null) { $query .= '`code` = ?, '; $params[] = $model->getCode(); } if ($model->getUserId() !== null) { $query .= 'user_id = ?, '; $params[] = $model->getUserId(); } if ($model->getIp() !== null) { $query .= '`ip` = ?, '; $params[] = $model->getIp(); } if ($model->getRequestUri() !== null) { $query .= '`request_uri` = ?, '; $params[] = $model->getRequestUri(); } if ($model->getReferer() !== null) { $query .= '`referer` = ?, '; $params[] = $model->getReferer(); } if ($model->getMessage() !== null) { $query .= '`message` = ?, '; $params[] = $model->getMessage(); } if ($model->getTrace() !== null) { $query .= '`trace` = ?, '; $params[] = $model->getTrace(); } if ($model->getFile() !== null) { $query .= '`file` = ?, '; $params[] = $model->getFile(); } if ($model->getLine() !== null) { $query .= '`line` = ?, '; $params[] = $model->getLine(); } if ($model->getStatus() !== null) { $query .= '`status` = ?, '; $params[] = $model->getStatus(); } $query .= '`modified_date` = ?, '; $params[] = Util\Format::date(time(), 'sqlDatetime'); $query = rtrim(trim($query), ','); $query .= ' WHERE id = ?'; $params[] = $model->getId(); return $db->execute($query, $params); } }
public static function save(\Rebond\Core\ModelInterface $model) { $db = new Util\Data(); if ($model->getId() === 0) { $query = 'INSERT INTO cms_content (module_id, `app_id`, `content_group`, filter_id, author_id, publisher_id, `title`, `url_friendly_title`, `use_expiration`, `go_live_date`, `expiry_date`, `published_date`, `version`, `created_date`, `modified_date`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)'; $params = [$model->getModuleId(), $model->getAppId(), $model->getContentGroup(), $model->getFilterId(), $model->getAuthorId(), $model->getPublisherId(), $model->getTitle(), $model->getUrlFriendlyTitle(), $model->getUseExpiration(), $model->getGoLiveDate('sqlDatetime'), $model->getExpiryDate('sqlDatetime'), $model->getPublishedDate('sqlDatetime'), $model->getVersion(), $model->getCreatedDate('sqlDatetime'), Util\Format::date(time(), 'sqlDatetime')]; $id = $db->execute($query, $params); $model->setId($id); return $id; } else { $query = 'UPDATE cms_content SET '; $params = []; if ($model->getModuleId() !== null) { $query .= 'module_id = ?, '; $params[] = $model->getModuleId(); } if ($model->getAppId() !== null) { $query .= '`app_id` = ?, '; $params[] = $model->getAppId(); } if ($model->getContentGroup() !== null) { $query .= '`content_group` = ?, '; $params[] = $model->getContentGroup(); } if ($model->getFilterId() !== null) { $query .= 'filter_id = ?, '; $params[] = $model->getFilterId(); } if ($model->getAuthorId() !== null) { $query .= 'author_id = ?, '; $params[] = $model->getAuthorId(); } if ($model->getPublisherId() !== null) { $query .= 'publisher_id = ?, '; $params[] = $model->getPublisherId(); } if ($model->getTitle() !== null) { $query .= '`title` = ?, '; $params[] = $model->getTitle(); } if ($model->getUrlFriendlyTitle() !== null) { $query .= '`url_friendly_title` = ?, '; $params[] = $model->getUrlFriendlyTitle(); } if ($model->getUseExpiration() !== null) { $query .= '`use_expiration` = ?, '; $params[] = $model->getUseExpiration(); } if ($model->getGoLiveDate() !== null) { $query .= '`go_live_date` = ?, '; $params[] = $model->getGoLiveDate('sqlDatetime'); } if ($model->getExpiryDate() !== null) { $query .= '`expiry_date` = ?, '; $params[] = $model->getExpiryDate('sqlDatetime'); } if ($model->getPublishedDate() !== null) { $query .= '`published_date` = ?, '; $params[] = $model->getPublishedDate('sqlDatetime'); } if ($model->getVersion() !== null) { $query .= '`version` = ?, '; $params[] = $model->getVersion(); } $query .= '`modified_date` = ?, '; $params[] = Util\Format::date(time(), 'sqlDatetime'); $query = rtrim(trim($query), ','); $query .= ' WHERE id = ?'; $params[] = $model->getId(); return $db->execute($query, $params); } }
protected static function condition(Util\Data $db, $option) { switch ($option) { case 'expiration': $db->buildQuery('where', ['content.use_expiration = 0 || (content.go_live_date <= ? AND content.expiry_date >= ?)', Util\Format::date(time(), 'sqlDatetime'), Util\Format::date(time(), 'sqlDatetime')]); break; case 'published': $db->buildQuery('where', ['content.version IN (?)', [VersionType::PUBLISHED, VersionType::UPDATING]]); break; case 'pending': $db->buildQuery('where', ['content.version IN (?)', [VersionType::PENDING, VersionType::PUBLISHING]]); break; case 'preview': $db->buildQuery('where', ['content.version IN (?)', [VersionType::PENDING, VersionType::PUBLISHED, VersionType::PUBLISHING]]); break; case 'deleted': $db->buildQuery('where', ['content.version = ?', VersionType::DELETED]); break; } }
public static function save(\Rebond\Core\ModelInterface $model) { $db = new Util\Data(); if ($model->getId() === 0) { $query = 'INSERT INTO cms_page (parent_id, template_id, layout_id, `title`, `css`, `js`, `in_nav_header`, `in_nav_side`, `in_sitemap`, `in_breadcrumb`, `in_nav_footer`, `friendly_url_path`, `friendly_url`, `redirect`, `class`, `permission`, `display_order`, `status`, `created_date`, `modified_date`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)'; $params = [$model->getParentId(), $model->getTemplateId(), $model->getLayoutId(), $model->getTitle(), $model->getCss(), $model->getJs(), $model->getInNavHeader(), $model->getInNavSide(), $model->getInSitemap(), $model->getInBreadcrumb(), $model->getInNavFooter(), $model->getFriendlyUrlPath(), $model->getFriendlyUrl(), $model->getRedirect(), $model->getClass(), $model->getPermission(), $model->getDisplayOrder(), $model->getStatus(), $model->getCreatedDate('sqlDatetime'), Util\Format::date(time(), 'sqlDatetime')]; $id = $db->execute($query, $params); $model->setId($id); return $id; } else { $query = 'UPDATE cms_page SET '; $params = []; if ($model->getParentId() !== null) { $query .= 'parent_id = ?, '; $params[] = $model->getParentId(); } if ($model->getTemplateId() !== null) { $query .= 'template_id = ?, '; $params[] = $model->getTemplateId(); } if ($model->getLayoutId() !== null) { $query .= 'layout_id = ?, '; $params[] = $model->getLayoutId(); } if ($model->getTitle() !== null) { $query .= '`title` = ?, '; $params[] = $model->getTitle(); } if ($model->getCss() !== null) { $query .= '`css` = ?, '; $params[] = $model->getCss(); } if ($model->getJs() !== null) { $query .= '`js` = ?, '; $params[] = $model->getJs(); } if ($model->getInNavHeader() !== null) { $query .= '`in_nav_header` = ?, '; $params[] = $model->getInNavHeader(); } if ($model->getInNavSide() !== null) { $query .= '`in_nav_side` = ?, '; $params[] = $model->getInNavSide(); } if ($model->getInSitemap() !== null) { $query .= '`in_sitemap` = ?, '; $params[] = $model->getInSitemap(); } if ($model->getInBreadcrumb() !== null) { $query .= '`in_breadcrumb` = ?, '; $params[] = $model->getInBreadcrumb(); } if ($model->getInNavFooter() !== null) { $query .= '`in_nav_footer` = ?, '; $params[] = $model->getInNavFooter(); } if ($model->getFriendlyUrlPath() !== null) { $query .= '`friendly_url_path` = ?, '; $params[] = $model->getFriendlyUrlPath(); } if ($model->getFriendlyUrl() !== null) { $query .= '`friendly_url` = ?, '; $params[] = $model->getFriendlyUrl(); } if ($model->getRedirect() !== null) { $query .= '`redirect` = ?, '; $params[] = $model->getRedirect(); } if ($model->getClass() !== null) { $query .= '`class` = ?, '; $params[] = $model->getClass(); } if ($model->getPermission() !== null) { $query .= '`permission` = ?, '; $params[] = $model->getPermission(); } if ($model->getDisplayOrder() !== null) { $query .= '`display_order` = ?, '; $params[] = $model->getDisplayOrder(); } if ($model->getStatus() !== null) { $query .= '`status` = ?, '; $params[] = $model->getStatus(); } $query .= '`modified_date` = ?, '; $params[] = Util\Format::date(time(), 'sqlDatetime'); $query = rtrim(trim($query), ','); $query .= ' WHERE id = ?'; $params[] = $model->getId(); return $db->execute($query, $params); } }
public static function save(\Rebond\Core\ModelInterface $model) { $db = new Util\Data(); if ($model->getId() === 0) { $query = 'INSERT INTO core_user (`username`, `email`, `password`, `firstname`, `lastname`, avatar_id, `is_admin`, `is_dev`, `status`, `created_date`, `modified_date`) VALUES (?,?,?,?,?,?,?,?,?,?,?)'; $params = [$model->getUsername(), $model->getEmail(), $model->getPassword(), $model->getFirstname(), $model->getLastname(), $model->getAvatarId(), $model->getIsAdmin(), $model->getIsDev(), $model->getStatus(), $model->getCreatedDate('sqlDatetime'), Util\Format::date(time(), 'sqlDatetime')]; $id = $db->execute($query, $params); $model->setId($id); return $id; } else { $query = 'UPDATE core_user SET '; $params = []; if ($model->getUsername() !== null) { $query .= '`username` = ?, '; $params[] = $model->getUsername(); } if ($model->getEmail() !== null) { $query .= '`email` = ?, '; $params[] = $model->getEmail(); } if ($model->getPassword() !== null) { $query .= '`password` = ?, '; $params[] = $model->getPassword(); } if ($model->getFirstname() !== null) { $query .= '`firstname` = ?, '; $params[] = $model->getFirstname(); } if ($model->getLastname() !== null) { $query .= '`lastname` = ?, '; $params[] = $model->getLastname(); } if ($model->getAvatarId() !== null) { $query .= 'avatar_id = ?, '; $params[] = $model->getAvatarId(); } if ($model->getIsAdmin() !== null) { $query .= '`is_admin` = ?, '; $params[] = $model->getIsAdmin(); } if ($model->getIsDev() !== null) { $query .= '`is_dev` = ?, '; $params[] = $model->getIsDev(); } if ($model->getStatus() !== null) { $query .= '`status` = ?, '; $params[] = $model->getStatus(); } $query .= '`modified_date` = ?, '; $params[] = Util\Format::date(time(), 'sqlDatetime'); $query = rtrim(trim($query), ','); $query .= ' WHERE id = ?'; $params[] = $model->getId(); return $db->execute($query, $params); } }
public function getCreatedDate($format = null) { return Format::date($this->createdDate, $format); }