/** * set some sitewide settings */ public function settings() { if (!$this->client->can_edit($this->site_id)) { die('Please login'); } $site = ORM::factory('site', $this->site_id); if (!$site->loaded) { die('site not found'); } if ($_POST) { $homepage = explode(':', $_POST['homepage']); $site->custom_domain = $_POST['custom_domain']; $site->homepage = $homepage[0]; $site->save(); # should we publish the entire site? if (isset($_POST['publish']) and 'yes' == $_POST['publish']) { $cache_dir = DATAPATH . "{$this->site_name}/cache"; if (is_dir($cache_dir)) { Jdirectory::remove($cache_dir); } mkdir($cache_dir); } # update site_config.yml if new homepage # and force page to be enabled. if ($this->homepage != $homepage[0]) { yaml::edit_site_value($this->site_name, 'site_config', 'homepage', $_POST['homepage']); $page = ORM::factory('page', $homepage[1]); $page->enable = 'yes'; $page->save(); } die('Sitewide settings saved.'); } $pages = ORM::factory('page')->where('fk_site', $this->site_id)->orderby('page_name')->find_all(); $primary = new View('admin/settings'); $primary->pages = $pages; $primary->custom_domain = $site->custom_domain; $primary->js_rel_command = 'close-base'; die($primary); }
public function claim_login() { if (!$_POST) { die('nothing sent'); } # atttempt to log user in. if ($this->account_user->login($_POST['username'], (int) self::plusjade_site_id, $_POST['password'])) { $plusjade_user = ORM::factory('account_user')->where('fk_site', self::plusjade_site_id)->find($_POST['username']); # add edit rights for this site. $plusjade_user->add(ORM::factory('site', $this->site_id)); $plusjade_user->save(); # mark site as claimed. database it as well. yaml::edit_site_value($this->site_name, 'site_config', 'claimed', 'TRUE'); $site = ORM::factory('site', $this->site_id); $site->claimed = 'yes'; $site->save(); # setup the auth session. $this->client->force_login($plusjade_user); # FYI: this might log some newly created "account_user" out. $this->account_user->logout(); die('<div class="success">Thanks! This website has been claimed and added to your account.</div>'); } die('<div class="error">Invalid username or password</div>'); }
public function settings($page_id = NULL) { valid::id_key($page_id); $page = ORM::factory('page')->where('fk_site', $this->site_id)->find($page_id); if (!$page->loaded) { die('invalid page id'); } if ($_POST) { # Validate page_name & duplicate check $directory = empty($_POST['directory']) ? NULL : $_POST['directory']; $new_page_name = $filename = self::validate_page_name($_POST['label'], $_POST['page_name'], $directory, $_POST['page_name']); if (!empty($directory)) { $new_page_name = "{$directory}/{$filename}"; } # if this page was the homepage, update homepage value if ($this->homepage == $_POST['old_page_name']) { $site = ORM::factory('site', $this->site_id); $site->homepage = $filename; $site->save(); yaml::edit_site_value($this->site_name, 'site_config', 'homepage', $filename); $_POST['enable'] = 'yes'; # force homepage to be enabled. } $page->page_name = $new_page_name; $page->title = $_POST['title']; $page->meta = $_POST['meta']; $page->label = $_POST['label']; $page->template = $_POST['template']; $page->menu = $_POST['menu']; $page->enable = isset($_POST['enable']) ? $_POST['enable'] : 'yes'; $page->save(); # did the page name change? # update all children within this "folder" if ($_POST['old_page_name'] != $filename) { # if this page is protected update the pages_config file. yaml::edit_key($this->site_name, 'pages_config', $_POST['old_page_name'], $filename); $old_full_page = empty($_POST['directory']) ? $_POST['old_page_name'] : $_POST['directory'] . '/' . $_POST['old_page_name']; $dir_pages = self::get_folder_filenames($old_full_page, 'change'); # if this page has children, update them! foreach ($dir_pages as $page_id => $page_name) { $page = ORM::factory('page')->where('fk_site', $this->site_id)->find($page_id); if (!$page->loaded) { continue; } $page->page_name = "{$new_page_name}/{$page_name}"; $page->save(); } } # if the page was the account page, update site_config if ($this->account_page == $_POST['old_page_name']) { yaml::edit_site_value($this->site_name, 'site_config', 'account_page', $filename); } # should we publish this page? if (isset($_POST['publish']) and 'yes' == $_POST['publish']) { $cache = DATAPATH . "{$this->site_name}/cache/{$page_id}.html"; if (file_exists($cache)) { unlink($cache); } } die('Page Settings Saved'); # success } # Is this a subpage? (pop the end filename node from the directory.) $filename = $page->page_name; $directory = ''; $directory_array = explode('/', $filename); if (1 < count($directory_array)) { $filename = array_pop($directory_array); $directory = implode('/', $directory_array); } $primary = new View("page/page_settings"); $primary->page = $page; $primary->filename = $filename; $primary->dir = $directory; # get available templates from theme. if ($templates = yaml::parse($this->site_name, NULL, "themes/{$this->theme}/config")) { $primary->templates = $templates; } else { $primary->templates = array('master' => 'default layout'); } # Javascript duplicate page_name filter Validation # convert filter_array to string to use as javascript array $filter_array = self::get_folder_filenames($directory, NULL, $filename); $filter_string = implode("','", $filter_array); $primary->page_filter_js = "'{$filter_string}'"; # is page protected? $primary->is_protected = yaml::does_key_exist($this->site_name, 'pages_config', $page->page_name) ? TRUE : FALSE; die($primary); }
public static function _tool_adder($tool_id, $site_id, $sample = FALSE) { # add account_page name to site_config. # HACK, this won't work if the page name is changed. need to pass page_name. yaml::edit_site_value($site_name, 'site_config', 'account_page', 'account'); # other tools may depend on this admin user being logged in at site creation! if ($sample) { # add an admin user. $account_user = ORM::factory('account_user'); $account_user->fk_site = $site_id; $account_user->email = '*****@*****.**'; $account_user->username = '******'; $account_user->password = '******'; $account_user->save(); } }
public function logo() { $url_path = $this->assets->assets_url(); if (!empty($_POST['banner'])) { $banner = str_replace("{$url_path}/", '', $_POST['banner']); $site = ORM::factory('site', $this->site_id); $site->banner = $banner; $site->save(); if (yaml::edit_site_value($this->site_name, 'site_config', 'banner', $banner)) { die('Banner changed.'); } # success } $primary = new View("theme/logo"); $primary->img_path = $url_path; die($primary); }