コード例 #1
0
 public function editAction()
 {
     $form = new Blog_Form();
     $mdlBlog = new Blog_Blog();
     if ($this->_request->isPost() && $form->isValid($_POST) && $this->_request->getParam('isInsert') != true) {
         $values = $form->getValues();
         $blog = $mdlBlog->updateBlog($values['id'], $values['name']);
         $blog = $blog->page;
         //the update blog function returns the results of open
     } else {
         $id = $this->_request->getParam('id');
         $blog = $mdlBlog->find($id)->current();
         $form->populate($blog->toArray());
     }
     $form->setAction($this->baseUrl . '/mod_blog/blog/edit');
     $submit = $form->getElement('submit');
     $submit->setLabel($this->view->getTranslation('Update Blog'));
     $this->view->form = $form;
     $this->view->blog = $blog;
     $mdlPost = new Blog_Post();
     $this->view->posts = $mdlPost->getPosts($blog->id);
     $postForm = new Post_Form();
     $postFormValues['blog_id'] = $blog->id;
     $postForm->populate($postFormValues);
     $postForm->setAction($this->baseUrl . '/mod_blog/post/create');
     $submit = $postForm->getElement('submit');
     $submit->setLabel($this->view->getTranslation('Add New Post'));
     $this->view->postForm = $postForm;
     $this->view->breadcrumbs[$blog->name] = $this->baseUrl . '/mod_blog/blog/edit/id/' . $blog->id;
     $this->view->toolbarLinks['Delete'] = $this->baseUrl . '/mod_blog/blog/delete/id/' . $blog->id;
 }
コード例 #2
0
 public function deleteAction()
 {
     $mdlPost = new Blog_Post();
     $id = $this->_request->getParam('id');
     $post = $mdlPost->openPost($id);
     $mdlPost->deletePageById($id);
     $this->_request->setParam('id', $post->blogId);
     $this->_forward('edit', 'blog');
 }
コード例 #3
0
ファイル: blog.php プロジェクト: csiber/blog-site
 public function post($subject = '')
 {
     $this->load->helper('form');
     $this->load->library('form_validation');
     $blog = new Blog_Post();
     $blog->load_where(array('subject' => str_replace("%20", " ", $subject)));
     $this->load->view('blog/details', array('blog' => $blog, 'subject' => $subject));
     $this->load->view('footer');
 }
コード例 #4
0
 public function blogAction()
 {
     if ($this->moduleData->blog > 0) {
         $mdlBlog = new Blog_Blog();
         $mdlPost = new Blog_Post();
         $page = Digitalus_Builder::getPage();
         $params = $page->getParams();
         if (isset($params['openPost']) && $params['openPost'] > 0) {
             $openPost = $mdlPost->openPost($params['openPost']);
             $this->view->openPost = $openPost;
             $this->view->blog = $mdlBlog->find($openPost->blogId)->current();
         } else {
             $this->view->blog = $mdlBlog->find($this->moduleData->blog)->current();
             $this->view->posts = $mdlPost->getPosts($this->moduleData->blog);
         }
     }
 }
コード例 #5
0
ファイル: blog_view.php プロジェクト: CodeWingX/sassculture
include "headers.php";
include "nav.php";
?>
<div class='post_list jumbo_custom container-fluid'>
	<div class="jumbotron pacifico white vSpacePx">
		<h1>Browse through a wonderful gallery of posts.</h1>
		<h2>
			"A reader lives a thousand lives."- George R.R. Martin
		</h2>
	</div>
</div>
<div class='container pacifico'>
<hr class='featurette-divider'>
<h1>List of blog posts</h1>
<ol>
<?php 
$posts = new Blog_Post();
$titles = $posts->readBlogTitles();
while ($row = $titles->fetch_assoc()) {
    echo "<li>" . $row['title'] . "</li>";
}
?>
</ol>	
</div>

<div class="container vSpace">
<a class='btn btn-info btn-block white anchor' href="new_blog.php">Write a new blog?</a>
</div>

<?php 
include "footers.php";
コード例 #6
0
ファイル: admin.php プロジェクト: csiber/blog-site
 public function delete($table, $id)
 {
     if ($table == 'blog_posts') {
         $this->load->model('blog_post');
         $post = new Blog_Post();
         $post->load($id);
         $post->delete();
         $edit = !isset($post->id) ? 'Post deleted!' : 'Problem deleting post.';
         $this->session->set_flashdata('edit', $edit);
     } else {
         if ($table == 'content_pages') {
             $this->load->model('content_page');
             if ($id > 7) {
                 $page = new Content_Page();
                 $page->load($id);
                 $page->delete();
                 $edit = !isset($page->id) ? 'Page deleted!' : 'Problem deleting page.';
             } else {
                 $edit = 'You may not delete this content.';
             }
             $this->session->set_flashdata('edit', $edit);
         } else {
             if ($table == 'admin_users') {
                 $this->load->model('admin_user');
                 $user = new Admin_User();
                 $user->load($id);
                 $user->delete();
                 $edit = !isset($page->id) ? 'User deleted!' : 'Problem deleting user.';
                 $this->session->set_flashdata('edit', $edit);
             }
         }
     }
     redirect('admin/' . $table);
 }
コード例 #7
0
 public function generate()
 {
     $this->params = Sitemap_Params::create();
     $this->xml = new DOMDocument();
     $this->xml->encoding = 'UTF-8';
     $this->urlset = $this->xml->createElement('urlset');
     $this->urlset->setAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
     $this->urlset->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
     $this->urlset->setAttribute('xsi:schemaLocation', 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd');
     try {
         $active_theme = false;
         if (Cms_Theme::is_theming_enabled()) {
             $active_theme = Cms_Theme::get_active_theme();
         }
         if ($this->params->include_navigation_hidden) {
             $page_list = Cms_Page::create()->where('is_published=1')->where('sitemap_visible=1')->where('security_mode_id <> "customers"');
         } else {
             $page_list = Cms_Page::create()->where('is_published=1')->where('sitemap_visible=1')->where('navigation_visible=1')->where('security_mode_id <> "customers"');
         }
         if ($active_theme) {
             $page_list->where('theme_id = ?', $active_theme->id);
         }
         $page_list = $page_list->find_all();
         if (count($page_list)) {
             foreach ($page_list as $page) {
                 $page_url = site_url($page->url);
                 if (substr($page_url, -1) != '/') {
                     $page_url .= '/';
                 }
                 $this->add_url_element($page_url, date('c', strtotime($page->updated_at ? $page->updated_at : $page->created_at)), 'weekly', '0.7');
             }
         }
         if ($this->url_count < self::max_urls && $this->params->include_categories) {
             if ($this->params->include_hidden_categories) {
                 $category_list = Shop_Category::create()->limit(self::max_generated)->order('shop_categories.updated_at desc')->find_all();
             } else {
                 $category_list = Shop_Category::create()->limit(self::max_generated)->order('shop_categories.updated_at desc')->where('category_is_hidden is not true')->find_all();
             }
             foreach ($category_list as $category) {
                 $category_url = site_url($category->page_url($this->params->categories_path));
                 if (substr($category_url, -1) != '/') {
                     $category_url .= '/';
                 }
                 $this->add_url_element($category_url, date('c', strtotime($category->updated_at ? $category->updated_at : $category->created_at)), $this->params->categories_changefreq, $this->params->categories_priority);
             }
         }
         if ($this->url_count < self::max_urls && $this->params->include_products) {
             $include_not_visible_catalog = $this->params->include_products_not_visible_catalog ? true : false;
             $include_not_visible_search = $this->params->include_products_not_visible_search ? true : false;
             if ($include_not_visible_catalog) {
                 //traceLog("include_not_visible_catalog = true");
             } else {
                 //traceLog("include_not_visible_catalog = false");
             }
             if ($include_not_visible_search) {
                 //traceLog("include_not_visible_search = true");
             } else {
                 //traceLog("include_not_visible_search = false");
             }
             $root_url = Phpr::$request->getRootUrl();
             $lssalestracking_installed = Core_ModuleManager::findById('lssalestracking');
             //$lssalestracking_installed = Db_DbHelper::scalar('select count(*) from core_install_history where moduleId = ?', 'lssalestracking');
             if ($lssalestracking_installed && class_exists('LsSalesTracking_ProductManager')) {
                 $product_list = new Shop_Product(null, array('no_column_init' => true, 'no_validation' => true));
                 $product_list = $product_list->apply_filters()->where('enabled=1');
                 if (!$include_not_visible_catalog) {
                     $product_list->where('visibility_catalog = 1');
                 }
                 if (!$include_not_visible_search) {
                     $product_list->where('visibility_search = 1');
                 }
                 $product_list->limit(self::max_generated)->order('shop_products.updated_at desc')->find_all();
             } else {
                 //traceLog("lssalestracking NOT installed");
                 $product_list_sql = 'select sp.url_name, sp.updated_at, sp.created_at, sp.id, p.url, p.is_published from shop_products sp left outer join pages p on (sp.page_id = p.id) where sp.enabled is true and (sp.grouped is null or sp.grouped = 0) ';
                 if (!$include_not_visible_catalog) {
                     $product_list_sql .= 'and visibility_catalog = 1 ';
                 }
                 if (!$include_not_visible_search) {
                     $product_list_sql .= 'and visibility_search = 1 ';
                 }
                 $product_list_sql .= 'order by updated_at limit ' . self::max_generated;
                 //traceLog($product_list_sql);
                 $product_list = Db_DbHelper::objectArray($product_list_sql);
             }
             foreach ($product_list as $product) {
                 if ($lssalestracking_installed && class_exists('LsSalesTracking_ProductManager')) {
                     $product_url = site_url($this->params->products_path . LsSalesTracking_ProductManager::get_marketplace_product_url($product));
                 } else {
                     //$product_url = $root_url.$product->page_url($this->params->products_path);
                     $product->url = $this->get_product_url($product->id, $product->url);
                     if ($product->url != '' && $product->is_published == 1) {
                         $page = $product->url;
                     } else {
                         $page = $this->params->products_path;
                     }
                     $product_url = site_url($page . '/' . $product->url_name);
                 }
                 if (substr($product_url, -1) != '/') {
                     $product_url .= '/';
                 }
                 $this->add_url_element($product_url, date('c', strtotime($product->updated_at ? $product->updated_at : $product->created_at)), $this->params->products_changefreq, $this->params->products_priority);
             }
         }
         if ($this->url_count < self::max_urls && $this->params->include_blogposts) {
             $blog_post_list = Blog_Post::create()->limit(self::max_generated)->order('blog_posts.updated_at desc')->find_all();
             foreach ($blog_post_list as $blog_post) {
                 $blogpost_url = site_url($this->params->blogposts_path . '/' . $blog_post->url_title);
                 if (substr($blogpost_url, -1) != '/') {
                     $blogpost_url .= '/';
                 }
                 $this->add_url_element($blogpost_url, date('c', strtotime($blog_post->published_date)), $this->params->blogposts_changefreq, $this->params->blogposts_priority);
             }
         }
         $wiki_installed = Core_ModuleManager::findById('wiki');
         if ($this->url_count < self::max_urls && $wiki_installed && $this->params->include_wiki && class_exists('Wiki_Page')) {
             $wiki_page_list = Wiki_Page::create()->limit(self::max_generated)->where('is_published=1')->order('wiki_pages.updated_at desc')->find_all();
             foreach ($wiki_page_list as $wiki_page) {
                 $wiki_url = site_url($this->params->wiki_path . '/' . $wiki_page->url_title);
                 if (substr($wiki_url, -1) != '/') {
                     $wiki_url .= '/';
                 }
                 $this->add_url_element($wiki_url, date('c', strtotime($wiki_page->updated_at ? $wiki_page->updated_at : $wiki_page->created_at)), $this->params->wiki_changefreq, $this->params->wiki_priority);
             }
         }
         Backend::$events->fireEvent('sitemap:onGenerateSitemap', $this, $this->params);
     } catch (Sitemap_Generator_Exception $ex) {
     }
     $this->xml->appendChild($this->urlset);
 }
コード例 #8
0
ファイル: blog_model.php プロジェクト: CodeWingX/sassculture
    public function readBlogTitles()
    {
        $sql = "SELECT title FROM blog_posts ORDER BY RAND() LIMIT 10";
        $result = readBlogPostQuery($sql);
        return $result;
    }
}
// get posted vars
if (!empty($_POST)) {
    $author_name = $_POST["author_name"];
    $author_img_url = $_POST['author_img_url'];
    $date_time_created = $_POST['date_time'];
    $title = $_POST['title'];
    $content = $_POST['content'];
    $date_time_edited = $_POST['date_time'];
    $blog_post = new Blog_Post();
    $blog_post->setBlogPostValues($title, $author_name, $author_img_url, $date_time_created, $date_time_edited, $content);
    $blog_post->insertBlogPost();
    $protocol = 'http';
    if (isset($_SERVER['HTTPS'])) {
        if (strtoupper($_SERVER['HTTPS']) == 'ON') {
            $protocol = 'https';
        }
    }
    header("location: {$protocol}://" . $_SERVER['HTTP_HOST'] . "/blog_view.php");
    exit;
}
//instanciate class object
?>