Version Notes
Upgraded for Magento 1.5.1
Download this release
Release Info
Developer | Magento Core Team |
Extension | Fishpigs_Wordpress_Integration |
Version | 0.8.8 |
Comparing to | |
See all releases |
Version 0.8.8
- app/code/community/Fishpig/Wordpress/Block/Abstract.php +18 -0
- app/code/community/Fishpig/Wordpress/Block/Adminhtml/Autologin.php +25 -0
- app/code/community/Fishpig/Wordpress/Block/Adminhtml/Autologin/Form.php +19 -0
- app/code/community/Fishpig/Wordpress/Block/Adminhtml/Autologin/Tab/Form.php +51 -0
- app/code/community/Fishpig/Wordpress/Block/Adminhtml/Autologin/Tabs.php +24 -0
- app/code/community/Fishpig/Wordpress/Block/Adminhtml/Catalog/Product/Edit/Tab/Category/Grid.php +66 -0
- app/code/community/Fishpig/Wordpress/Block/Adminhtml/Catalog/Product/Edit/Tab/Grid/Abstract.php +80 -0
- app/code/community/Fishpig/Wordpress/Block/Adminhtml/Catalog/Product/Edit/Tab/Post/Grid.php +68 -0
- app/code/community/Fishpig/Wordpress/Block/Adminhtml/Support.php +21 -0
- app/code/community/Fishpig/Wordpress/Block/Adminhtml/Support/Form.php +19 -0
- app/code/community/Fishpig/Wordpress/Block/Adminhtml/Support/Tab/Form/Abstract.php +7 -0
- app/code/community/Fishpig/Wordpress/Block/Adminhtml/Support/Tab/RequestForm.php +66 -0
- app/code/community/Fishpig/Wordpress/Block/Adminhtml/Support/Tabs.php +54 -0
- app/code/community/Fishpig/Wordpress/Block/Adminhtml/System/Config/Test/Results/Column/Result.php +21 -0
- app/code/community/Fishpig/Wordpress/Block/Adminhtml/System/Config/Test/Results/Grid.php +76 -0
- app/code/community/Fishpig/Wordpress/Block/Adminhtml/System/Config/Wrapper.php +44 -0
- app/code/community/Fishpig/Wordpress/Block/Adminhtml/Template.php +38 -0
- app/code/community/Fishpig/Wordpress/Block/Archive/List.php +38 -0
- app/code/community/Fishpig/Wordpress/Block/Archive/View.php +42 -0
- app/code/community/Fishpig/Wordpress/Block/Author/View.php +42 -0
- app/code/community/Fishpig/Wordpress/Block/Category/List.php +51 -0
- app/code/community/Fishpig/Wordpress/Block/Category/View.php +62 -0
- app/code/community/Fishpig/Wordpress/Block/Feed/Rss2.php +54 -0
- app/code/community/Fishpig/Wordpress/Block/Homepage.php +40 -0
- app/code/community/Fishpig/Wordpress/Block/Post/Associated/Products.php +12 -0
- app/code/community/Fishpig/Wordpress/Block/Post/List.php +142 -0
- app/code/community/Fishpig/Wordpress/Block/Post/List/Associated.php +61 -0
- app/code/community/Fishpig/Wordpress/Block/Post/List/Pager.php +39 -0
- app/code/community/Fishpig/Wordpress/Block/Post/List/Recent.php +51 -0
- app/code/community/Fishpig/Wordpress/Block/Post/List/Wrapper/Abstract.php +147 -0
- app/code/community/Fishpig/Wordpress/Block/Post/View.php +52 -0
- app/code/community/Fishpig/Wordpress/Block/Post/View/Abstract.php +66 -0
- app/code/community/Fishpig/Wordpress/Block/Post/View/Comment/Form.php +72 -0
- app/code/community/Fishpig/Wordpress/Block/Post/View/Comments.php +82 -0
- app/code/community/Fishpig/Wordpress/Block/Tag/List.php +15 -0
- app/code/community/Fishpig/Wordpress/Block/Tag/View.php +55 -0
- app/code/community/Fishpig/Wordpress/Controller/Abstract.php +258 -0
- app/code/community/Fishpig/Wordpress/Controller/Adminhtml/Abstract.php +29 -0
- app/code/community/Fishpig/Wordpress/Controller/Router.php +347 -0
- app/code/community/Fishpig/Wordpress/Docs/Example-XML-Blocks.xml +205 -0
- app/code/community/Fishpig/Wordpress/Docs/readme.txt +24 -0
- app/code/community/Fishpig/Wordpress/Helper/Abstract.php +283 -0
- app/code/community/Fishpig/Wordpress/Helper/Adminhtml.php +32 -0
- app/code/community/Fishpig/Wordpress/Helper/Catalog/Product.php +67 -0
- app/code/community/Fishpig/Wordpress/Helper/Curl.php +75 -0
- app/code/community/Fishpig/Wordpress/Helper/Data.php +36 -0
- app/code/community/Fishpig/Wordpress/Helper/Db.php +179 -0
- app/code/community/Fishpig/Wordpress/Helper/Debug.php +163 -0
- app/code/community/Fishpig/Wordpress/Helper/Debug/EnvironmentReport.php +124 -0
- app/code/community/Fishpig/Wordpress/Helper/Debug/Test.php +65 -0
- app/code/community/Fishpig/Wordpress/Helper/Debug/Test/Abstract.php +83 -0
- app/code/community/Fishpig/Wordpress/Helper/Debug/Test/BlogRoute.php +62 -0
- app/code/community/Fishpig/Wordpress/Helper/Debug/Test/Connection.php +22 -0
- app/code/community/Fishpig/Wordpress/Helper/Debug/Test/Query.php +26 -0
- app/code/community/Fishpig/Wordpress/Helper/Debug/Test/ResultCollection.php +14 -0
- app/code/community/Fishpig/Wordpress/Helper/Debug/Test/WpUrls.php +56 -0
- app/code/community/Fishpig/Wordpress/Helper/Filter.php +73 -0
- app/code/community/Fishpig/Wordpress/Helper/Filter/Abstract.php +147 -0
- app/code/community/Fishpig/Wordpress/Helper/Filter/AutoParagraph.php +64 -0
- app/code/community/Fishpig/Wordpress/Helper/Filter/RemoveHtml.php +15 -0
- app/code/community/Fishpig/Wordpress/Helper/Filter/Shortcode/Abstract.php +12 -0
- app/code/community/Fishpig/Wordpress/Helper/Filter/Shortcode/AssociatedProducts.php +50 -0
- app/code/community/Fishpig/Wordpress/Helper/Filter/Shortcode/Caption.php +35 -0
- app/code/community/Fishpig/Wordpress/Helper/Filter/Shortcode/Product.php +56 -0
- app/code/community/Fishpig/Wordpress/Helper/Filter/Shortcode/SyntaxHighlighter.php +43 -0
- app/code/community/Fishpig/Wordpress/Helper/Filter/Shortcode/Youtube.php +41 -0
- app/code/community/Fishpig/Wordpress/Helper/Filter/Shortcodes.php +51 -0
- app/code/community/Fishpig/Wordpress/Helper/Object.php +105 -0
- app/code/community/Fishpig/Wordpress/Helper/Plugin/Abstract.php +6 -0
- app/code/community/Fishpig/Wordpress/Helper/Plugin/AllInOneSeo.php +30 -0
- app/code/community/Fishpig/Wordpress/Helper/Post.php +225 -0
- app/code/community/Fishpig/Wordpress/Helper/Post/Content/Shortcode/Abstract.php +61 -0
- app/code/community/Fishpig/Wordpress/Helper/Post/Content/Shortcode/Caption.php +31 -0
- app/code/community/Fishpig/Wordpress/Model/Abstract.php +82 -0
- app/code/community/Fishpig/Wordpress/Model/Admin/User.php +35 -0
- app/code/community/Fishpig/Wordpress/Model/Archive.php +50 -0
- app/code/community/Fishpig/Wordpress/Model/Category/Abstract.php +78 -0
- app/code/community/Fishpig/Wordpress/Model/Image.php +66 -0
- app/code/community/Fishpig/Wordpress/Model/Link.php +7 -0
- app/code/community/Fishpig/Wordpress/Model/Link/Category.php +13 -0
- app/code/community/Fishpig/Wordpress/Model/Mysql4/Abstract.php +107 -0
- app/code/community/Fishpig/Wordpress/Model/Mysql4/Admin/User.php +37 -0
- app/code/community/Fishpig/Wordpress/Model/Mysql4/Admin/User/Collection.php +10 -0
- app/code/community/Fishpig/Wordpress/Model/Mysql4/Category/Abstract.php +23 -0
- app/code/community/Fishpig/Wordpress/Model/Mysql4/Category/Collection/Abstract.php +66 -0
- app/code/community/Fishpig/Wordpress/Model/Mysql4/Collection/Abstract.php +64 -0
- app/code/community/Fishpig/Wordpress/Model/Mysql4/Image.php +10 -0
- app/code/community/Fishpig/Wordpress/Model/Mysql4/Image/Collection.php +16 -0
- app/code/community/Fishpig/Wordpress/Model/Mysql4/Link.php +9 -0
- app/code/community/Fishpig/Wordpress/Model/Mysql4/Link/Category.php +9 -0
- app/code/community/Fishpig/Wordpress/Model/Mysql4/Link/Category/Collection.php +12 -0
- app/code/community/Fishpig/Wordpress/Model/Mysql4/Link/Collection.php +19 -0
- app/code/community/Fishpig/Wordpress/Model/Mysql4/Option.php +9 -0
- app/code/community/Fishpig/Wordpress/Model/Mysql4/Option/Collection.php +10 -0
- app/code/community/Fishpig/Wordpress/Model/Mysql4/Page.php +32 -0
- app/code/community/Fishpig/Wordpress/Model/Mysql4/Page/Collection.php +48 -0
- app/code/community/Fishpig/Wordpress/Model/Mysql4/Post.php +51 -0
- app/code/community/Fishpig/Wordpress/Model/Mysql4/Post/Attachment/Abstract.php +6 -0
- app/code/community/Fishpig/Wordpress/Model/Mysql4/Post/Attachment/Collection/Abstract.php +16 -0
- app/code/community/Fishpig/Wordpress/Model/Mysql4/Post/Category.php +10 -0
- app/code/community/Fishpig/Wordpress/Model/Mysql4/Post/Category/Collection.php +9 -0
- app/code/community/Fishpig/Wordpress/Model/Mysql4/Post/Collection.php +165 -0
- app/code/community/Fishpig/Wordpress/Model/Mysql4/Post/Collection/Abstract.php +102 -0
- app/code/community/Fishpig/Wordpress/Model/Mysql4/Post/Comment.php +10 -0
- app/code/community/Fishpig/Wordpress/Model/Mysql4/Post/Comment/Collection.php +29 -0
- app/code/community/Fishpig/Wordpress/Model/Mysql4/Post/Tag.php +10 -0
- app/code/community/Fishpig/Wordpress/Model/Mysql4/Post/Tag/Collection.php +20 -0
- app/code/community/Fishpig/Wordpress/Model/Mysql4/User.php +9 -0
- app/code/community/Fishpig/Wordpress/Model/Mysql4/User/Collection.php +9 -0
- app/code/community/Fishpig/Wordpress/Model/Observer/Abstract.php +58 -0
- app/code/community/Fishpig/Wordpress/Model/Observer/Adminhtml/Catalog/Product/SaveAssociations.php +114 -0
- app/code/community/Fishpig/Wordpress/Model/Observer/Adminhtml/System/Config/SaveAfter.php +26 -0
- app/code/community/Fishpig/Wordpress/Model/Observer/DatabaseSetup.php +70 -0
- app/code/community/Fishpig/Wordpress/Model/Option.php +15 -0
- app/code/community/Fishpig/Wordpress/Model/Page.php +10 -0
- app/code/community/Fishpig/Wordpress/Model/Post.php +109 -0
- app/code/community/Fishpig/Wordpress/Model/Post/Abstract.php +102 -0
- app/code/community/Fishpig/Wordpress/Model/Post/Attachment/Abstract.php +31 -0
- app/code/community/Fishpig/Wordpress/Model/Post/Category.php +68 -0
- app/code/community/Fishpig/Wordpress/Model/Post/Comment.php +56 -0
- app/code/community/Fishpig/Wordpress/Model/Post/Tag.php +60 -0
- app/code/community/Fishpig/Wordpress/Model/System/Config/Backend/Encrypted.php +19 -0
- app/code/community/Fishpig/Wordpress/Model/System/Config/Source/Database/Location.php +13 -0
- app/code/community/Fishpig/Wordpress/Model/System/Config/Source/Filters/Content.php +16 -0
- app/code/community/Fishpig/Wordpress/Model/System/Config/Source/Filters/Excerpt.php +16 -0
- app/code/community/Fishpig/Wordpress/Model/System/Config/Source/Integration.php +12 -0
- app/code/community/Fishpig/Wordpress/Model/System/Config/Source/Shortcodes.php +17 -0
- app/code/community/Fishpig/Wordpress/Model/System/Config/Source/SyntaxHighlighter/Theme.php +19 -0
- app/code/community/Fishpig/Wordpress/Model/User.php +25 -0
- app/code/community/Fishpig/Wordpress/controllers/Adminhtml/DebugController.php +45 -0
- app/code/community/Fishpig/Wordpress/controllers/Adminhtml/RedirectController.php +123 -0
- app/code/community/Fishpig/Wordpress/controllers/Adminhtml/SupportController.php +106 -0
- app/code/community/Fishpig/Wordpress/controllers/Adminhtml/WpAdminController.php +49 -0
- app/code/community/Fishpig/Wordpress/controllers/Archive/ViewController.php +51 -0
- app/code/community/Fishpig/Wordpress/controllers/AuthorController.php +44 -0
- app/code/community/Fishpig/Wordpress/controllers/CategoryController.php +51 -0
- app/code/community/Fishpig/Wordpress/controllers/FeedController.php +21 -0
- app/code/community/Fishpig/Wordpress/controllers/HomepageController.php +37 -0
- app/code/community/Fishpig/Wordpress/controllers/PageController.php +20 -0
- app/code/community/Fishpig/Wordpress/controllers/Post/View/CommentController.php +84 -0
- app/code/community/Fishpig/Wordpress/controllers/Post/ViewController.php +65 -0
- app/code/community/Fishpig/Wordpress/controllers/RedirectController.php +21 -0
- app/code/community/Fishpig/Wordpress/controllers/SitemapController.php +34 -0
- app/code/community/Fishpig/Wordpress/controllers/TagController.php +69 -0
- app/code/community/Fishpig/Wordpress/etc/adminhtml.xml +51 -0
- app/code/community/Fishpig/Wordpress/etc/config.xml +374 -0
- app/code/community/Fishpig/Wordpress/etc/system.xml +385 -0
- app/code/community/Fishpig/Wordpress/sql/wordpress_setup/mysql4-install-0.1.0.php +19 -0
- app/code/community/Fishpig/Wordpress/sql/wordpress_setup/mysql4-upgrade-0.3.2-0.3.3.php +22 -0
- app/design/adminhtml/default/default/layout/wordpress.xml +55 -0
- app/design/adminhtml/default/default/template/wordpress/admin-links-js.phtml +51 -0
- app/design/adminhtml/default/default/template/wordpress/config/js.phtml +39 -0
- app/design/adminhtml/default/default/template/wordpress/config/test/results.phtml +30 -0
- app/design/adminhtml/default/default/template/wordpress/support/index.phtml +38 -0
- app/design/adminhtml/default/default/template/wordpress/support/js.phtml +75 -0
- app/design/adminhtml/default/default/template/wordpress/support/tab/complete.phtml +46 -0
- app/design/adminhtml/default/default/template/wordpress/support/tab/debug-info.phtml +39 -0
- app/design/adminhtml/default/default/template/wordpress/support/tab/logs.phtml +23 -0
- app/design/frontend/base/default/layout/wordpress.xml +125 -0
- app/design/frontend/base/default/template/wordpress/archive/list.phtml +27 -0
- app/design/frontend/base/default/template/wordpress/archive/view.phtml +13 -0
- app/design/frontend/base/default/template/wordpress/author/view.phtml +13 -0
- app/design/frontend/base/default/template/wordpress/category/list.phtml +28 -0
- app/design/frontend/base/default/template/wordpress/category/view.phtml +16 -0
- app/design/frontend/base/default/template/wordpress/feed/rss2.phtml +48 -0
- app/design/frontend/base/default/template/wordpress/homepage.phtml +9 -0
- app/design/frontend/base/default/template/wordpress/links.phtml +17 -0
- app/design/frontend/base/default/template/wordpress/page/list.phtml +27 -0
- app/design/frontend/base/default/template/wordpress/page/view.phtml +47 -0
- app/design/frontend/base/default/template/wordpress/post/associated.phtml +15 -0
- app/design/frontend/base/default/template/wordpress/post/associated/list.phtml +15 -0
- app/design/frontend/base/default/template/wordpress/post/associated/product/list.phtml +28 -0
- app/design/frontend/base/default/template/wordpress/post/featured.phtml +17 -0
- app/design/frontend/base/default/template/wordpress/post/list.phtml +53 -0
- app/design/frontend/base/default/template/wordpress/post/recent.phtml +11 -0
- app/design/frontend/base/default/template/wordpress/post/recent/list.phtml +15 -0
- app/design/frontend/base/default/template/wordpress/post/syntaxhighlighter/trigger.phtml +46 -0
- app/design/frontend/base/default/template/wordpress/post/view.phtml +52 -0
- app/design/frontend/base/default/template/wordpress/post/view/comment/form.phtml +58 -0
- app/design/frontend/base/default/template/wordpress/post/view/comments.phtml +33 -0
- app/design/frontend/base/default/template/wordpress/shortcode/associated-products.phtml +28 -0
- app/design/frontend/base/default/template/wordpress/shortcode/product.phtml +16 -0
- app/design/frontend/base/default/template/wordpress/shortcode/youtube-video.phtml +14 -0
- app/design/frontend/base/default/template/wordpress/tag/list.phtml +19 -0
- app/design/frontend/base/default/template/wordpress/tag/view.phtml +16 -0
- app/etc/modules/Fishpig_Wordpress.xml +9 -0
- js/fishpig/wordpress/comments.js +37 -0
- package.xml +18 -0
app/code/community/Fishpig/Wordpress/Block/Abstract.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
abstract class Fishpig_Wordpress_Block_Abstract extends Mage_Core_Block_Template
|
4 |
+
{
|
5 |
+
public function _helper($helper = null)
|
6 |
+
{
|
7 |
+
if ($helper != null) {
|
8 |
+
$helper = '/' . $helper;
|
9 |
+
}
|
10 |
+
|
11 |
+
return Mage::helper('wordpress' . $helper);
|
12 |
+
}
|
13 |
+
|
14 |
+
public function getParam($key, $default = null)
|
15 |
+
{
|
16 |
+
return Mage::app()->getRequest()->getParam($key, $default);
|
17 |
+
}
|
18 |
+
}
|
app/code/community/Fishpig/Wordpress/Block/Adminhtml/Autologin.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Fishpig_Wordpress_Block_Adminhtml_Autologin extends Mage_Adminhtml_Block_Widget_Form_Container
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
|
9 |
+
$this->_objectId = 'id';
|
10 |
+
$this->_blockGroup = 'wordpress';
|
11 |
+
$this->_controller = 'adminhtml_autologin';
|
12 |
+
$this->_buttons = array();
|
13 |
+
|
14 |
+
$this->_addButton('save', array(
|
15 |
+
'label' => Mage::helper('adminhtml')->__('Save'),
|
16 |
+
'onclick' => 'editForm.submit();',
|
17 |
+
'class' => 'save',
|
18 |
+
), 1);
|
19 |
+
}
|
20 |
+
|
21 |
+
public function getHeaderText()
|
22 |
+
{
|
23 |
+
return $this->__('1-Click WordPress Login');
|
24 |
+
}
|
25 |
+
}
|
app/code/community/Fishpig/Wordpress/Block/Adminhtml/Autologin/Form.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Fishpig_Wordpress_Block_Adminhtml_Autologin_Form extends Mage_Adminhtml_Block_Widget_Form
|
4 |
+
{
|
5 |
+
protected function _prepareForm()
|
6 |
+
{
|
7 |
+
$adminUser = Mage::registry('wordpress_admin_user');
|
8 |
+
$form = new Varien_Data_Form(array(
|
9 |
+
'id' => 'edit_form',
|
10 |
+
'action' => $this->getUrl('*/*/save', array('id' => ($adminUser) ? $adminUser->getId() : null)),
|
11 |
+
'method' => 'post',
|
12 |
+
'enctype' => 'multipart/form-data'
|
13 |
+
));
|
14 |
+
|
15 |
+
$form->setUseContainer(true);
|
16 |
+
$this->setForm($form);
|
17 |
+
return parent::_prepareForm();
|
18 |
+
}
|
19 |
+
}
|
app/code/community/Fishpig/Wordpress/Block/Adminhtml/Autologin/Tab/Form.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Fishpig_Wordpress_Block_Adminhtml_Autologin_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
4 |
+
{
|
5 |
+
|
6 |
+
protected function _prepareForm()
|
7 |
+
{
|
8 |
+
$form = new Varien_Data_Form();
|
9 |
+
|
10 |
+
$this->setForm($form);
|
11 |
+
|
12 |
+
$fieldset = $form->addFieldset('autologin_form', array('legend'=>' '));
|
13 |
+
|
14 |
+
$fieldset->addField('username', 'text', array(
|
15 |
+
'label' => 'Username',
|
16 |
+
'class' => 'required-entry',
|
17 |
+
'required' => true,
|
18 |
+
'name' => 'username',
|
19 |
+
));
|
20 |
+
|
21 |
+
$fieldset->addField('password', 'password', array(
|
22 |
+
'label' => 'Password',
|
23 |
+
'class' => 'required-entry',
|
24 |
+
'required' => true,
|
25 |
+
'name' => 'password',
|
26 |
+
));
|
27 |
+
|
28 |
+
$configUrl = $this->getUrl($this->helper('wordpress/adminhtml')->getWordpressConfigPath());
|
29 |
+
|
30 |
+
$text = new Varien_Data_Form_Element_Note();
|
31 |
+
$text->setText('
|
32 |
+
<input type="hidden" name="redirect_to" value="'.$this->_getRedirectTo().'"/>
|
33 |
+
<p style="font-weight:bold; padding:10px 5px;">
|
34 |
+
Before you attempt to use this feature it is recommended that you pass all integration tests in the <a href="'.$configUrl.'" style="text-decoration:none;">Magento/WordPress configuration</a> section
|
35 |
+
</p>
|
36 |
+
');
|
37 |
+
|
38 |
+
$fieldset->addElement($text);
|
39 |
+
|
40 |
+
if (Mage::registry('wordpress_admin_user')) {
|
41 |
+
$form->setValues(Mage::registry('wordpress_admin_user')->getData());
|
42 |
+
}
|
43 |
+
|
44 |
+
return parent::_prepareForm();
|
45 |
+
}
|
46 |
+
|
47 |
+
protected function _getRedirectTo()
|
48 |
+
{
|
49 |
+
return Mage::app()->getRequest()->getParam('redirect_to');
|
50 |
+
}
|
51 |
+
}
|
app/code/community/Fishpig/Wordpress/Block/Adminhtml/Autologin/Tabs.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Fishpig_Wordpress_Block_Adminhtml_Autologin_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
4 |
+
{
|
5 |
+
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
parent::__construct();
|
9 |
+
$this->setId('autologin_tabs');
|
10 |
+
$this->setDestElementId('edit_form');
|
11 |
+
$this->setTitle($this->__('WP Admin Login'));
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _beforeToHtml()
|
15 |
+
{
|
16 |
+
$this->addTab('form_section', array(
|
17 |
+
'label' => $this->__('Login Information'),
|
18 |
+
'title' => $this->__('Login Information'),
|
19 |
+
'content' => $this->getLayout()->createBlock('wordpress/adminhtml_autologin_tab_form')->toHtml(),
|
20 |
+
));
|
21 |
+
|
22 |
+
return parent::_beforeToHtml();
|
23 |
+
}
|
24 |
+
}
|
app/code/community/Fishpig/Wordpress/Block/Adminhtml/Catalog/Product/Edit/Tab/Category/Grid.php
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Fishpig_Wordpress_Block_Adminhtml_Catalog_Product_Edit_Tab_Category_Grid extends Fishpig_Wordpress_Block_Adminhtml_Catalog_Product_Edit_Tab_Grid_Abstract
|
4 |
+
{
|
5 |
+
protected $_constructData = array('id' => 'wpCategoryGrid', 'default_sort' => 'name', 'default_dir' => 'asc');
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Prepare the collection of posts to display
|
9 |
+
*/
|
10 |
+
protected function _prepareCollection()
|
11 |
+
{
|
12 |
+
$collection = Mage::getResourceModel('wordpress/post_category_collection');
|
13 |
+
$collection->getSelect()->order('name ASC');
|
14 |
+
|
15 |
+
$this->setCollection($collection);
|
16 |
+
|
17 |
+
return parent::_prepareCollection();
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Prepares the columns of the grid
|
22 |
+
*/
|
23 |
+
protected function _prepareColumns()
|
24 |
+
{
|
25 |
+
$this->addColumn('term_id', array(
|
26 |
+
'type' => 'checkbox',
|
27 |
+
'field_name' => 'wp_category_id[]',
|
28 |
+
'align' => 'center',
|
29 |
+
'index' => 'term_id',
|
30 |
+
'header' => ' ',
|
31 |
+
'values' => $this->_getSelectedWpItems('category'),
|
32 |
+
));
|
33 |
+
|
34 |
+
$this->addColumn('name', array(
|
35 |
+
'header'=> 'Name',
|
36 |
+
'index' => 'name',
|
37 |
+
));
|
38 |
+
|
39 |
+
$this->addColumn('slug', array(
|
40 |
+
'header'=> 'Slug',
|
41 |
+
'index' => 'slug',
|
42 |
+
));
|
43 |
+
|
44 |
+
return parent::_prepareColumns();
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Retrieve the label used for the tab relating to this block
|
49 |
+
*
|
50 |
+
* @return string
|
51 |
+
*/
|
52 |
+
public function getTabLabel()
|
53 |
+
{
|
54 |
+
return $this->__('Associated Blog Categories');
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Retrieve the title used by this tab
|
59 |
+
*
|
60 |
+
* @return string
|
61 |
+
*/
|
62 |
+
public function getTabTitle()
|
63 |
+
{
|
64 |
+
return $this->__('Associate WordPress blog categories (and children posts) with this product');
|
65 |
+
}
|
66 |
+
}
|
app/code/community/Fishpig/Wordpress/Block/Adminhtml/Catalog/Product/Edit/Tab/Grid/Abstract.php
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
abstract class Fishpig_Wordpress_Block_Adminhtml_Catalog_Product_Edit_Tab_Grid_Abstract extends Mage_Adminhtml_Block_Widget_Grid
|
4 |
+
implements Mage_Adminhtml_Block_Widget_Tab_Interface
|
5 |
+
{
|
6 |
+
/**
|
7 |
+
* Setup the grid
|
8 |
+
*/
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
$this->setId($this->_constructData['id']);
|
13 |
+
$this->setDefaultSort($this->_constructData['default_sort']);
|
14 |
+
$this->setDefaultDir($this->_constructData['default_dir']);
|
15 |
+
$this->setSaveParametersInSession(true);
|
16 |
+
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Returns an array of all of the product's currently associated post ID's
|
21 |
+
*
|
22 |
+
* @param string $type must be either post or category
|
23 |
+
* @return array
|
24 |
+
*/
|
25 |
+
protected function _getSelectedWpItems($type)
|
26 |
+
{
|
27 |
+
$postIds = array();
|
28 |
+
$productId = $this->_getProduct()->getId();
|
29 |
+
if ($productId) {
|
30 |
+
$table = Mage::getSingleton('core/resource')->getTableName('wordpress_product_'.$type);
|
31 |
+
$sql = "SELECT {$type}_id FROM {$table} WHERE product_id = {$productId}";
|
32 |
+
$results = Mage::getSingleton('core/resource')->getConnection('core_read')->fetchAll($sql);
|
33 |
+
|
34 |
+
foreach($results as $result) {
|
35 |
+
$postIds[] = $result[$type.'_id'];
|
36 |
+
}
|
37 |
+
}
|
38 |
+
|
39 |
+
return $postIds;
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Returns the current product model
|
44 |
+
*
|
45 |
+
* @return Mage_Catalog_Model_Product
|
46 |
+
*/
|
47 |
+
protected function _getProduct()
|
48 |
+
{
|
49 |
+
return Mage::registry('product');
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Displays the tab if integration is valid
|
54 |
+
*
|
55 |
+
* @return true
|
56 |
+
*/
|
57 |
+
public function canShowTab()
|
58 |
+
{
|
59 |
+
try {
|
60 |
+
Mage::getSingleton('core/resource')
|
61 |
+
->getConnection('wordpress_read')
|
62 |
+
->query("SELECT ID from " . $this->helper('wordpress/db')->getTableName('posts') . " LIMIT 1");
|
63 |
+
|
64 |
+
return true;
|
65 |
+
}
|
66 |
+
catch (Exception $e) {
|
67 |
+
return false;
|
68 |
+
}
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Stops the tab being hidden
|
73 |
+
*
|
74 |
+
* @return bool
|
75 |
+
*/
|
76 |
+
public function isHidden()
|
77 |
+
{
|
78 |
+
return false;
|
79 |
+
}
|
80 |
+
}
|
app/code/community/Fishpig/Wordpress/Block/Adminhtml/Catalog/Product/Edit/Tab/Post/Grid.php
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Fishpig_Wordpress_Block_Adminhtml_Catalog_Product_Edit_Tab_Post_Grid extends Fishpig_Wordpress_Block_Adminhtml_Catalog_Product_Edit_Tab_Grid_Abstract
|
4 |
+
{
|
5 |
+
protected $_constructData = array('id' => 'wpPostGrid', 'default_sort' => 'post_date', 'default_dir' => 'desc');
|
6 |
+
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Prepare the collection of posts to display
|
10 |
+
*/
|
11 |
+
protected function _prepareCollection()
|
12 |
+
{
|
13 |
+
$collection = Mage::getResourceModel('wordpress/post_collection')
|
14 |
+
->addIsPublishedFilter();
|
15 |
+
$this->setCollection($collection);
|
16 |
+
|
17 |
+
return parent::_prepareCollection();
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Prepares the columns of the grid
|
22 |
+
*/
|
23 |
+
protected function _prepareColumns()
|
24 |
+
{
|
25 |
+
$this->addColumn('ID', array(
|
26 |
+
'type' => 'checkbox',
|
27 |
+
'field_name' => 'wp_post_id[]',
|
28 |
+
'align' => 'center',
|
29 |
+
'index' => 'ID',
|
30 |
+
'header' => ' ',
|
31 |
+
'values' => $this->_getSelectedWpItems('post'),
|
32 |
+
));
|
33 |
+
|
34 |
+
$this->addColumn('post_title', array(
|
35 |
+
'header'=> 'Post Title',
|
36 |
+
'index' => 'post_title',
|
37 |
+
));
|
38 |
+
|
39 |
+
$this->addColumn('post_date', array(
|
40 |
+
'header'=> 'Post Date',
|
41 |
+
'index' => 'post_date',
|
42 |
+
'type' => 'date',
|
43 |
+
'format' => 'd MMMM YYYY',
|
44 |
+
));
|
45 |
+
|
46 |
+
return parent::_prepareColumns();
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Retrieve the label used for the tab relating to this block
|
51 |
+
*
|
52 |
+
* @return string
|
53 |
+
*/
|
54 |
+
public function getTabLabel()
|
55 |
+
{
|
56 |
+
return $this->__('Associated Blog Posts');
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Retrieve the title used by this tab
|
61 |
+
*
|
62 |
+
* @return string
|
63 |
+
*/
|
64 |
+
public function getTabTitle()
|
65 |
+
{
|
66 |
+
return $this->__('Associate WordPress blog posts with this product');
|
67 |
+
}
|
68 |
+
}
|
app/code/community/Fishpig/Wordpress/Block/Adminhtml/Support.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Fishpig_Wordpress_Block_Adminhtml_Support extends Mage_Adminhtml_Block_Widget_Form_Container
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
|
9 |
+
$this->_objectId = 'id';
|
10 |
+
$this->_blockGroup = 'wordpress';
|
11 |
+
$this->_controller = 'adminhtml_support';
|
12 |
+
$this->_buttons = array();
|
13 |
+
}
|
14 |
+
|
15 |
+
public function getHeaderText()
|
16 |
+
{
|
17 |
+
return 'Fishpig\'s Magento WordPress Integration Extension';
|
18 |
+
}
|
19 |
+
|
20 |
+
|
21 |
+
}
|
app/code/community/Fishpig/Wordpress/Block/Adminhtml/Support/Form.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Fishpig_Wordpress_Block_Adminhtml_Support_Form extends Mage_Adminhtml_Block_Widget_Form
|
4 |
+
{
|
5 |
+
protected function _prepareForm()
|
6 |
+
{
|
7 |
+
$form = new Varien_Data_Form(array(
|
8 |
+
'id' => 'edit_form',
|
9 |
+
'action' => $this->getUrl('*/*/send', array('id' => $this->getRequest()->getParam('id'))),
|
10 |
+
'method' => 'post',
|
11 |
+
// 'enctype' => 'multipart/form-data'
|
12 |
+
));
|
13 |
+
|
14 |
+
$form->setUseContainer(true);
|
15 |
+
$this->setForm($form);
|
16 |
+
|
17 |
+
return parent::_prepareForm();
|
18 |
+
}
|
19 |
+
}
|
app/code/community/Fishpig/Wordpress/Block/Adminhtml/Support/Tab/Form/Abstract.php
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
abstract class Fishpig_Wordpress_Block_Adminhtml_Support_Tab_Form_Abstract extends Mage_Adminhtml_Block_Widget_Form
|
4 |
+
{
|
5 |
+
|
6 |
+
|
7 |
+
}
|
app/code/community/Fishpig/Wordpress/Block/Adminhtml/Support/Tab/RequestForm.php
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Fishpig_Wordpress_Block_Adminhtml_Support_Tab_RequestForm extends Fishpig_Wordpress_Block_Adminhtml_Support_Tab_Form_Abstract
|
4 |
+
{
|
5 |
+
protected function _prepareForm()
|
6 |
+
{
|
7 |
+
$form = new Varien_Data_Form();
|
8 |
+
|
9 |
+
$this->setForm($form);
|
10 |
+
$fieldset = $form->addFieldset('question_form', array('legend'=>'<span class="enquirytype">Support Ticket</span> Details'));
|
11 |
+
|
12 |
+
$fieldset->addField('sender_name', 'text', array(
|
13 |
+
'label' => 'Your Name',
|
14 |
+
'name' => 'sender_name',
|
15 |
+
'required' => true,
|
16 |
+
));
|
17 |
+
|
18 |
+
$fieldset->addField('sender_email', 'text', array(
|
19 |
+
'label' => 'Email Address',
|
20 |
+
'name' => 'sender_email',
|
21 |
+
'class' => 'validate-email',
|
22 |
+
'required' => true,
|
23 |
+
));
|
24 |
+
|
25 |
+
$fieldset->addField('enquiry_type', 'select', array(
|
26 |
+
'label' => 'Enquiry Type',
|
27 |
+
'name' => 'enquiry_type',
|
28 |
+
'required' => 'true',
|
29 |
+
'values' => $this->_getEnquiryTypeOptions(),
|
30 |
+
));
|
31 |
+
|
32 |
+
$fieldset->addField('subject', 'text', array(
|
33 |
+
'label' => 'Subject',
|
34 |
+
'name' => 'subject',
|
35 |
+
'required' => true,
|
36 |
+
));
|
37 |
+
|
38 |
+
$fieldset->addField('content', 'textarea', array(
|
39 |
+
'label' => 'Details',
|
40 |
+
'name' => 'content',
|
41 |
+
'required' => true,
|
42 |
+
));
|
43 |
+
|
44 |
+
$fieldset->addField('buttons', 'note', array(
|
45 |
+
'text' => '<div style="height:1%;overflow:hidden;"><button type="button" class="scalable back left support-previous" id="content_previous"><span>' . $this->__('Previous') . '</span></button><button type="button" class="scalable add right support-next" id="content_next"><span>' . $this->__('Next') . '</span></button></div>',
|
46 |
+
));
|
47 |
+
|
48 |
+
if ($supportData = Mage::getSingleton('adminhtml/session')->getSupportData()) {
|
49 |
+
$form->setValues($supportData);
|
50 |
+
}
|
51 |
+
|
52 |
+
return parent::_prepareForm();
|
53 |
+
}
|
54 |
+
|
55 |
+
|
56 |
+
protected function _getEnquiryTypeOptions()
|
57 |
+
{
|
58 |
+
$options = array();
|
59 |
+
|
60 |
+
foreach(array($this->__('Support Ticket'), $this->__('Bug Report')) as $value) {
|
61 |
+
$options[] = array('value' => $value, 'label' => $this->__($value));
|
62 |
+
}
|
63 |
+
|
64 |
+
return $options;
|
65 |
+
}
|
66 |
+
}
|
app/code/community/Fishpig/Wordpress/Block/Adminhtml/Support/Tabs.php
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Fishpig_Wordpress_Block_Adminhtml_Support_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
4 |
+
{
|
5 |
+
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
parent::__construct();
|
9 |
+
$this->setId('support_tabs');
|
10 |
+
$this->setDestElementId('edit_form');
|
11 |
+
$this->setTitle($this->_wrapEnquiryType('Support Ticket'));
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _beforeToHtml()
|
15 |
+
{
|
16 |
+
$this->addTab('dashboard', array(
|
17 |
+
'label' => $this->_wrapEnquiryType('Support Ticket'),
|
18 |
+
'title' => 'Enquiry Type',
|
19 |
+
'content' => $this->getLayout()->createBlock('wordpress/adminhtml_template')->setTemplate('wordpress/support/index.phtml')->toHtml(),
|
20 |
+
));
|
21 |
+
|
22 |
+
$this->addTab('content', array(
|
23 |
+
'label' => $this->__('Details'),
|
24 |
+
'title' => $this->__('Details'),
|
25 |
+
'content' => $this->getLayout()->createBlock('wordpress/adminhtml_support_tab_requestForm')->toHtml(),
|
26 |
+
));
|
27 |
+
|
28 |
+
$this->addTab('debug', array(
|
29 |
+
'label' => $this->__('System Information'),
|
30 |
+
'title' => '- '.$this->__('System Information'),
|
31 |
+
'content' => $this->getLayout()->createBlock('wordpress/adminhtml_template')->setTemplate('wordpress/support/tab/debug-info.phtml')->toHtml(),
|
32 |
+
));
|
33 |
+
|
34 |
+
$this->addTab('log_files', array(
|
35 |
+
'label' => $this->__('Log Files'),
|
36 |
+
'title' => $this->__('Log Files'),
|
37 |
+
'content' => $this->getLayout()->createBlock('wordpress/adminhtml_template')->setTemplate('wordpress/support/tab/logs.phtml')->toHtml(),
|
38 |
+
));
|
39 |
+
|
40 |
+
$this->addTab('complete', array(
|
41 |
+
'label' => $this->__('Send Your ').$this->_wrapEnquiryType('Support Ticket'),
|
42 |
+
'title' => $this->__('Send'),
|
43 |
+
'content' => $this->getLayout()->createBlock('wordpress/adminhtml_template')->setTemplate('wordpress/support/tab/complete.phtml')->toHtml(),
|
44 |
+
));
|
45 |
+
|
46 |
+
return parent::_beforeToHtml();
|
47 |
+
}
|
48 |
+
|
49 |
+
protected function _wrapEnquiryType($text)
|
50 |
+
{
|
51 |
+
return '<span class="enquirytype" style="background:none; display:inline;padding:0;">'.$this->__($text).'</span>';
|
52 |
+
}
|
53 |
+
|
54 |
+
}
|
app/code/community/Fishpig/Wordpress/Block/Adminhtml/System/Config/Test/Results/Column/Result.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class FIshpig_Wordpress_Block_Adminhtml_System_Config_Test_Results_Column_Result extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
|
7 |
+
public function _getValue(Varien_Object $row)
|
8 |
+
{
|
9 |
+
$data = parent::_getValue($row);
|
10 |
+
$styles = array(
|
11 |
+
'background-color:transparent',
|
12 |
+
'background-position:3px 1px',
|
13 |
+
'border:0px solid', 'display:block',
|
14 |
+
'width:23px',
|
15 |
+
);
|
16 |
+
|
17 |
+
return '<span class="'.$data.'" style="'.implode(' !important;', $styles).'"> </span>';
|
18 |
+
}
|
19 |
+
|
20 |
+
|
21 |
+
}
|
app/code/community/Fishpig/Wordpress/Block/Adminhtml/System/Config/Test/Results/Grid.php
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Fishpig_Wordpress_Block_Adminhtml_System_Config_Test_Results_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
4 |
+
{
|
5 |
+
protected function _afterToHtml($html)
|
6 |
+
{
|
7 |
+
if (Mage::helper('wordpress/debug_test')->hasResults()) {
|
8 |
+
return $html;
|
9 |
+
}
|
10 |
+
}
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Prepare the collection of posts to display
|
14 |
+
*/
|
15 |
+
protected function _prepareCollection()
|
16 |
+
{
|
17 |
+
$collection = $this->_getResultCollection();
|
18 |
+
$this->setCollection($collection);
|
19 |
+
|
20 |
+
return parent::_prepareCollection();
|
21 |
+
}
|
22 |
+
|
23 |
+
protected function _getResultCollection()
|
24 |
+
{
|
25 |
+
return Mage::helper('wordpress/debug_test')->performIntegrationTests();
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Prepares the columns of the grid
|
30 |
+
*/
|
31 |
+
protected function _prepareColumns()
|
32 |
+
{
|
33 |
+
$this->addResultColumn();
|
34 |
+
|
35 |
+
$this->addColumn('title', array(
|
36 |
+
'header'=> 'Test Title',
|
37 |
+
'index' => 'title',
|
38 |
+
'width' => '260px',
|
39 |
+
));
|
40 |
+
|
41 |
+
$this->addColumn('response', array(
|
42 |
+
'header'=> 'Server Response',
|
43 |
+
'index' => 'response',
|
44 |
+
));
|
45 |
+
|
46 |
+
return parent::_prepareColumns();
|
47 |
+
}
|
48 |
+
|
49 |
+
protected function addResultColumn()
|
50 |
+
{
|
51 |
+
$column = $this->addColumn('result', array('header'=> ' ', 'index' => 'result', 'width' => '23px'))->getColumn('result');
|
52 |
+
$render = $this->getLayout()->createBlock('wordpress/adminhtml_system_config_test_results_column_result')->setColumn($column);
|
53 |
+
$column->setRenderer($render);
|
54 |
+
|
55 |
+
return $this;
|
56 |
+
}
|
57 |
+
|
58 |
+
protected function _prepareLayout()
|
59 |
+
{
|
60 |
+
$result = parent::_prepareLayout();
|
61 |
+
|
62 |
+
$this->unsetChild('reset_filter_button');
|
63 |
+
$this->unsetChild('search_button');
|
64 |
+
$this->unsetChild('export_button');
|
65 |
+
|
66 |
+
$this->_pagerVisibility = false;
|
67 |
+
$this->_filterVisibility = false;
|
68 |
+
|
69 |
+
// $this->setGridHeader('WordPress Integration Results');
|
70 |
+
|
71 |
+
return $result;
|
72 |
+
}
|
73 |
+
|
74 |
+
|
75 |
+
|
76 |
+
}
|
app/code/community/Fishpig/Wordpress/Block/Adminhtml/System/Config/Wrapper.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Fishpig_Wordpress_Block_Adminhtml_System_Config_Wrapper extends Fishpig_Wordpress_Block_Adminhtml_Template
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Used to ensure ACL message is only displayed once
|
7 |
+
*
|
8 |
+
* @var int
|
9 |
+
*/
|
10 |
+
static protected $_aclNoticeIssued = 0;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Message to display when ACL isn't correct
|
14 |
+
*
|
15 |
+
* @var const string
|
16 |
+
*/
|
17 |
+
const _ACTION_MSG = 'To finish installing Fishpig\'s Magento WordPress integration extension, log out of Magento and log back in.';
|
18 |
+
|
19 |
+
/**
|
20 |
+
* This adds a message to the settings page if the 'Access denied' message is displayed
|
21 |
+
*/
|
22 |
+
public function __construct()
|
23 |
+
{
|
24 |
+
parent::__construct();
|
25 |
+
|
26 |
+
if (!$this->isAclValid()) {
|
27 |
+
if (self::$_aclNoticeIssued < 2) {
|
28 |
+
Mage::getSingleton('adminhtml/session')->addNotice(self::_ACTION_MSG);
|
29 |
+
self::$_aclNoticeIssued = (self::$_aclNoticeIssued + 1);
|
30 |
+
}
|
31 |
+
}
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Returns true if the ACL is registered correctly
|
36 |
+
*
|
37 |
+
* @return bool
|
38 |
+
*/
|
39 |
+
public function isAclValid()
|
40 |
+
{
|
41 |
+
return $this->_helper('debug')->isAclValid();
|
42 |
+
}
|
43 |
+
|
44 |
+
}
|
app/code/community/Fishpig/Wordpress/Block/Adminhtml/Template.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Fishpig_Wordpress_Block_Adminhtml_Template extends Mage_Adminhtml_Block_Template
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Returns true if this is the WordPress section
|
7 |
+
*
|
8 |
+
* @return bool
|
9 |
+
*/
|
10 |
+
public function isWordpressSection()
|
11 |
+
{
|
12 |
+
return strtolower(trim($this->getParam('section'))) == 'wordpress';
|
13 |
+
}
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Gets the Adminhtml session
|
17 |
+
* @return Mage_Adminhtml_Model_Session
|
18 |
+
*/
|
19 |
+
public function getSession()
|
20 |
+
{
|
21 |
+
return Mage::getSingleton('adminhtml/session');
|
22 |
+
}
|
23 |
+
|
24 |
+
public function getParam($param, $default = null)
|
25 |
+
{
|
26 |
+
return Mage::app()->getRequest()->getParam($param, $default);
|
27 |
+
}
|
28 |
+
|
29 |
+
public function _helper($helper = null)
|
30 |
+
{
|
31 |
+
if ($helper != null) {
|
32 |
+
$helper = '/' . $helper;
|
33 |
+
}
|
34 |
+
|
35 |
+
return Mage::helper('wordpress' . $helper);
|
36 |
+
}
|
37 |
+
|
38 |
+
}
|
app/code/community/Fishpig/Wordpress/Block/Archive/List.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Fishpig_Wordpress_Block_Archive_List extends Fishpig_Wordpress_Block_Abstract
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Cache for archive collection
|
7 |
+
*
|
8 |
+
* @var null|Varien_Data_Collection
|
9 |
+
*/
|
10 |
+
protected $_archiveCollection = null;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Returns a collection of valid archive dates
|
14 |
+
*
|
15 |
+
* @return Varien_Data_Collection
|
16 |
+
*/
|
17 |
+
public function getArchives()
|
18 |
+
{
|
19 |
+
if (is_null($this->_archiveCollection)) {
|
20 |
+
$sql = "SELECT COUNT(ID) AS post_count, CONCAT(SUBSTRING(post_date, 1, 4), '/', SUBSTRING(post_date, 6, 2)) as archive_date"
|
21 |
+
. Mage::getResourceModel('wordpress/post_collection')->addIsPublishedFilter()->getSelect()->setPart('columns', array())
|
22 |
+
. " GROUP BY archive_date";
|
23 |
+
$dates = $this->_helper('db')->getWordpressRead()->fetchAll($sql);
|
24 |
+
$collection = new Varien_Data_Collection();
|
25 |
+
|
26 |
+
foreach($dates as $date) {
|
27 |
+
$obj = Mage::getModel('wordpress/archive')->load($date['archive_date']);
|
28 |
+
$obj->setPostCount($date['post_count']);
|
29 |
+
$collection->addItem($obj);
|
30 |
+
}
|
31 |
+
|
32 |
+
$this->_archiveCollection = $collection;
|
33 |
+
}
|
34 |
+
|
35 |
+
return $this->_archiveCollection;
|
36 |
+
}
|
37 |
+
|
38 |
+
}
|
app/code/community/Fishpig/Wordpress/Block/Archive/View.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Fishpig_Wordpress_Block_Archive_View extends Fishpig_Wordpress_Block_Post_List_Wrapper_Abstract
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Caches and returns the archive model
|
7 |
+
*
|
8 |
+
* @return Fishpig_Wordpress_Model_Archive
|
9 |
+
*/
|
10 |
+
public function getArchive()
|
11 |
+
{
|
12 |
+
if (!$this->hasData('archive')) {
|
13 |
+
$this->setData('archive', Mage::registry('wordpress_archive'));
|
14 |
+
}
|
15 |
+
|
16 |
+
return $this->getData('archive');
|
17 |
+
}
|
18 |
+
|
19 |
+
public function getArchiveId()
|
20 |
+
{
|
21 |
+
if ($archive = $this->getArchive()) {
|
22 |
+
return $archive->getId();
|
23 |
+
}
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Generates and returns the collection of posts
|
28 |
+
*
|
29 |
+
* @return Fishpig_Wordpress_Model_Mysql4_Post_Collection
|
30 |
+
*/
|
31 |
+
protected function _getPostCollection()
|
32 |
+
{
|
33 |
+
if (is_null($this->_postCollection)) {
|
34 |
+
$this->_postCollection = parent::_getPostCollection()
|
35 |
+
->addArchiveDateFilter($this->getArchiveId());
|
36 |
+
}
|
37 |
+
|
38 |
+
return $this->_postCollection;
|
39 |
+
}
|
40 |
+
|
41 |
+
|
42 |
+
}
|
app/code/community/Fishpig/Wordpress/Block/Author/View.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Fishpig_Wordpress_Block_Author_View extends Fishpig_Wordpress_Block_Post_List_Wrapper_Abstract
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Caches and returns the current category
|
7 |
+
*
|
8 |
+
* @return Fishpig_Wordpress_Model_User
|
9 |
+
*/
|
10 |
+
public function getAuthor()
|
11 |
+
{
|
12 |
+
if (!$this->hasData('wordpress_author')) {
|
13 |
+
$this->setData('wordpress_author', Mage::registry('wordpress_author'));
|
14 |
+
}
|
15 |
+
|
16 |
+
return $this->getData('wordpress_author');
|
17 |
+
}
|
18 |
+
|
19 |
+
public function getAuthorId()
|
20 |
+
{
|
21 |
+
if ($author = $this->getAuthor()) {
|
22 |
+
return $author->getId();
|
23 |
+
}
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Generates and returns the collection of posts
|
28 |
+
*
|
29 |
+
* @return Fishpig_Wordpress_Model_Mysql4_Post_Collection
|
30 |
+
*/
|
31 |
+
protected function _getPostCollection()
|
32 |
+
{
|
33 |
+
if (is_null($this->_postCollection)) {
|
34 |
+
$this->_postCollection = parent::_getPostCollection()
|
35 |
+
->addAuthorIdFilter($this->getAuthorId());
|
36 |
+
}
|
37 |
+
|
38 |
+
return $this->_postCollection;
|
39 |
+
}
|
40 |
+
|
41 |
+
|
42 |
+
}
|
app/code/community/Fishpig/Wordpress/Block/Category/List.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Fishpig_Wordpress_Block_Category_List extends Fishpig_Wordpress_Block_Abstract
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Cache for category collection
|
7 |
+
*
|
8 |
+
* @var Fishpig_Wordpress_Model_Mysql4_Category_Collection $_categoryCollection
|
9 |
+
*/
|
10 |
+
protected $_categoryCollection = null;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Returns the current category collection
|
14 |
+
*/
|
15 |
+
public function getCategories()
|
16 |
+
{
|
17 |
+
if (is_null($this->_categoryCollection)) {
|
18 |
+
$collection = Mage::getResourceModel('wordpress/post_category_collection')
|
19 |
+
->addParentIdFilter($this->getParentId());
|
20 |
+
|
21 |
+
$collection->getSelect()->order('name ASC');
|
22 |
+
|
23 |
+
$this->setCollection($collection);
|
24 |
+
}
|
25 |
+
|
26 |
+
return $this->_categoryCollection;
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Manually set the category collection
|
31 |
+
*
|
32 |
+
* @param Fishpig_Wordpress_Model_Mysql4_Category_Collection $collection
|
33 |
+
*/
|
34 |
+
public function setCollection(Fishpig_Wordpress_Model_Mysql4_Category_Collection_Abstract $collection)
|
35 |
+
{
|
36 |
+
$this->_categoryCollection = $collection;
|
37 |
+
return $this;
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Returns the parent ID used to display categories
|
42 |
+
* If parent_id is not set, 0 will be returned and root categories displayed
|
43 |
+
*
|
44 |
+
* @return int
|
45 |
+
*/
|
46 |
+
public function getParentId()
|
47 |
+
{
|
48 |
+
return number_format($this->getData('parent_id'), 0, '', '');
|
49 |
+
}
|
50 |
+
|
51 |
+
}
|
app/code/community/Fishpig/Wordpress/Block/Category/View.php
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Fishpig_Wordpress_Block_Category_View extends Fishpig_Wordpress_Block_Post_List_Wrapper_Abstract
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Returns the current Wordpress category
|
7 |
+
* This is just a wrapper for getCurrentCategory()
|
8 |
+
*
|
9 |
+
* @return Fishpig_Wordpress_Model_Post_Categpry
|
10 |
+
*/
|
11 |
+
public function getCategory()
|
12 |
+
{
|
13 |
+
return $this->getCurrentCategory();
|
14 |
+
}
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Caches and returns the current category
|
18 |
+
*
|
19 |
+
* @return Fishpig_Wordpress_Model_Post_Categpry
|
20 |
+
*/
|
21 |
+
public function getCurrentCategory()
|
22 |
+
{
|
23 |
+
if (!$this->hasData('wordpress_category')) {
|
24 |
+
if ($categoryId = $this->getData('category_id')) {
|
25 |
+
$category = Mage::getModel('wordpress/post_category')->load($categoryId);
|
26 |
+
|
27 |
+
if ($category->getId() == $categoryId) {
|
28 |
+
$this->setData('category', $category);
|
29 |
+
}
|
30 |
+
}
|
31 |
+
else {
|
32 |
+
$this->setData('category', Mage::registry('wordpress_category'));
|
33 |
+
}
|
34 |
+
}
|
35 |
+
|
36 |
+
return $this->getData('category');
|
37 |
+
}
|
38 |
+
|
39 |
+
public function getCurrentCategoryId()
|
40 |
+
{
|
41 |
+
if ($category = $this->getCurrentCategory()) {
|
42 |
+
return $category->getId();
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Generates and returns the collection of posts
|
48 |
+
*
|
49 |
+
* @return Fishpig_Wordpress_Model_Mysql4_Post_Collection
|
50 |
+
*/
|
51 |
+
protected function _getPostCollection()
|
52 |
+
{
|
53 |
+
if (is_null($this->_postCollection)) {
|
54 |
+
$this->_postCollection = parent::_getPostCollection()
|
55 |
+
->addCategoryIdFilter($this->getCurrentCategoryId());
|
56 |
+
}
|
57 |
+
|
58 |
+
return $this->_postCollection;
|
59 |
+
}
|
60 |
+
|
61 |
+
|
62 |
+
}
|
app/code/community/Fishpig/Wordpress/Block/Feed/Rss2.php
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Fishpig_Wordpress_Block_Feed_Rss2 extends Fishpig_Wordpress_Block_Abstract
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
$this->setTemplate('wordpress/feed/rss2.phtml');
|
8 |
+
}
|
9 |
+
|
10 |
+
public function getPosts()
|
11 |
+
{
|
12 |
+
$collection = Mage::getResourceModel('wordpress/post_collection')
|
13 |
+
->addIsPublishedFilter()
|
14 |
+
->setOrderByPostDate()
|
15 |
+
->setPageSize($this->_helper()->getCachedWpOption('posts_per_rss', 10));
|
16 |
+
|
17 |
+
return $collection;
|
18 |
+
}
|
19 |
+
|
20 |
+
public function getDocType()
|
21 |
+
{
|
22 |
+
return '<?xml version="1.0" encoding="'.$this->getBlogCharset().'"?>'."\n";
|
23 |
+
}
|
24 |
+
|
25 |
+
public function getBlogCharset()
|
26 |
+
{
|
27 |
+
return $this->_helper()->getCachedWpOption('blog_charset');
|
28 |
+
}
|
29 |
+
|
30 |
+
public function getRssTitle()
|
31 |
+
{
|
32 |
+
return $this->decode($this->_helper()->getCachedWpOption('blogname'));
|
33 |
+
}
|
34 |
+
|
35 |
+
public function getFeedUrl()
|
36 |
+
{
|
37 |
+
return $this->_helper()->getUrl('feed');
|
38 |
+
}
|
39 |
+
|
40 |
+
public function getRssLanguage()
|
41 |
+
{
|
42 |
+
return $this->_helper()->getCachedWpOption('rss_language');
|
43 |
+
}
|
44 |
+
|
45 |
+
public function displayExceprt()
|
46 |
+
{
|
47 |
+
return $this->_helper()->getCachedWpOption('rss_use_excerpt');
|
48 |
+
}
|
49 |
+
|
50 |
+
public function decode($value)
|
51 |
+
{
|
52 |
+
return html_entity_decode($value, ENT_NOQUOTES, $this->getBlogCharset());
|
53 |
+
}
|
54 |
+
}
|
app/code/community/Fishpig/Wordpress/Block/Homepage.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Fishpig_Wordpress_Block_Homepage extends Fishpig_Wordpress_Block_Post_List_Wrapper_Abstract
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Get's the blog title
|
7 |
+
*
|
8 |
+
* @return string
|
9 |
+
*/
|
10 |
+
public function getBlogTitle()
|
11 |
+
{
|
12 |
+
return $this->_helper()->getCachedWpOption('blogname');
|
13 |
+
}
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Returns the blog homepage URL
|
17 |
+
*
|
18 |
+
* @return string
|
19 |
+
*/
|
20 |
+
public function getBlogHomepageUrl()
|
21 |
+
{
|
22 |
+
return $this->_helper()->getUrl();
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Generates and returns the collection of posts
|
27 |
+
*
|
28 |
+
* @return Fishpig_Wordpress_Model_Mysql4_Post_Collection
|
29 |
+
*/
|
30 |
+
protected function _getPostCollection()
|
31 |
+
{
|
32 |
+
if (is_null($this->_postCollection)) {
|
33 |
+
$this->_postCollection = parent::_getPostCollection();
|
34 |
+
}
|
35 |
+
|
36 |
+
return $this->_postCollection;
|
37 |
+
}
|
38 |
+
|
39 |
+
|
40 |
+
}
|
app/code/community/Fishpig/Wordpress/Block/Post/Associated/Products.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Fishpig_Wordpress_Block_Post_Associated_Products extends Fishpig_Wordpress_Block_Post_View_Abstract
|
4 |
+
{
|
5 |
+
public function getProducts($attributes = '*')
|
6 |
+
{
|
7 |
+
return $this->_helper('catalog_product')
|
8 |
+
->getAssociatedProducts($this->getPost())
|
9 |
+
->addAttributeToSelect($attributes)
|
10 |
+
->load();
|
11 |
+
}
|
12 |
+
}
|
app/code/community/Fishpig/Wordpress/Block/Post/List.php
ADDED
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Fishpig_Wordpress_Block_Post_List extends Fishpig_Wordpress_Block_Abstract
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Cache for post collection
|
7 |
+
*
|
8 |
+
* @var Fishpig_Wordpress_Model_Mysql4_Post_Collection
|
9 |
+
*/
|
10 |
+
protected $_postCollection = null;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Block wrapper (category, tag, author etc)
|
14 |
+
*
|
15 |
+
* @var Fishpig_Wordpress_Block_Post_List_Abstract
|
16 |
+
*/
|
17 |
+
protected $_wrapperBlock = null;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Amount of posts to display on a page
|
21 |
+
* If this is left null then this value is taken form the WP-Admin config
|
22 |
+
*
|
23 |
+
* @var int
|
24 |
+
*/
|
25 |
+
protected $_pagerLimit = null;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Name of the pager block
|
29 |
+
*
|
30 |
+
* @var string
|
31 |
+
*/
|
32 |
+
protected $_pagerBlockName = 'wordpress_post_list_pager';
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Returns the collection of posts
|
36 |
+
*
|
37 |
+
* @return Fishpig_Wordpress_Model_Mysql4_Post_Collection
|
38 |
+
*/
|
39 |
+
public function getPosts()
|
40 |
+
{
|
41 |
+
return $this->_getPostCollection();
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Generates and returns the collection of posts
|
46 |
+
*
|
47 |
+
* @return Fishpig_Wordpress_Model_Mysql4_Post_Collection
|
48 |
+
*/
|
49 |
+
protected function _getPostCollection()
|
50 |
+
{
|
51 |
+
if (is_null($this->_postCollection)) {
|
52 |
+
if (is_null($this->getWrapperBlock()) == false) {
|
53 |
+
$this->_postCollection = $this->getWrapperBlock()->getPostCollection();
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
return $this->_postCollection;
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Sets the parent block of this block
|
62 |
+
* This block can be used to auto generate the post list
|
63 |
+
*
|
64 |
+
* @param Fishpig_Wordpress_Block_Post_List_Wrapper_Abstract $wrapper
|
65 |
+
*/
|
66 |
+
public function setWrapperBlock(Fishpig_Wordpress_Block_Post_List_Wrapper_Abstract $wrapper)
|
67 |
+
{
|
68 |
+
$this->_wrapperBlock = $wrapper;
|
69 |
+
return $this;
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Returns the block wrapper object
|
74 |
+
*
|
75 |
+
* @return Fishpig_Wordpress_Block_Post_List_Wrapper_Abstract
|
76 |
+
*/
|
77 |
+
public function getWrapperBlock()
|
78 |
+
{
|
79 |
+
return $this->_wrapperBlock;
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Get the pager block
|
84 |
+
* If the block isn't set in the layout XML, it will be created and will use the default template
|
85 |
+
*
|
86 |
+
* @return Fishpig_Wordpress_Post_List_Pager
|
87 |
+
*/
|
88 |
+
public function getPagerBlock()
|
89 |
+
{
|
90 |
+
$pagerBlock = $this->getChild($this->_pagerBlockName);
|
91 |
+
|
92 |
+
if (!$pagerBlock) {
|
93 |
+
$pagerBlock = $this->getLayout()
|
94 |
+
->createBlock('wordpress/post_list_pager', $this->_pagerBlockName.microtime().rand(1,9999));
|
95 |
+
}
|
96 |
+
|
97 |
+
$pagerBlock->setLimit($this->_getPagerLimit())
|
98 |
+
->setPageVarName('page')
|
99 |
+
->setAvailableLimit($this->_getPagerAvailableLimit());
|
100 |
+
|
101 |
+
$pagerBlock->setCollection($this->_getPostCollection());
|
102 |
+
|
103 |
+
return $pagerBlock;
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Get the HTML for the pager block
|
108 |
+
*
|
109 |
+
* @return string
|
110 |
+
*/
|
111 |
+
public function getPagerHtml()
|
112 |
+
{
|
113 |
+
return $this->getPagerBlock()->toHtml();
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Gets the posts per page limit
|
118 |
+
*
|
119 |
+
* @return int
|
120 |
+
*/
|
121 |
+
protected function _getPagerLimit()
|
122 |
+
{
|
123 |
+
if (is_null($this->_pagerLimit)) {
|
124 |
+
$this->_pagerLimit = $this->getParam('limit', $this->_helper()->getCachedWpOption('posts_per_page', 10));
|
125 |
+
}
|
126 |
+
|
127 |
+
return (int)$this->_pagerLimit;
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Returns the available limits for the pager
|
132 |
+
* As Wordpress uses a fixed page size limit, this returns only 1 limit (the value set in WP admin)
|
133 |
+
* This effectively hides the 'Show 4/Show 10' drop down
|
134 |
+
*
|
135 |
+
* @return array
|
136 |
+
*/
|
137 |
+
protected function _getPagerAvailableLimit()
|
138 |
+
{
|
139 |
+
return array($this->_getPagerLimit() => $this->_getPagerLimit());
|
140 |
+
}
|
141 |
+
|
142 |
+
}
|
app/code/community/Fishpig/Wordpress/Block/Post/List/Associated.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Fishpig_Wordpress_Block_Post_List_Associated extends Fishpig_Wordpress_Block_Post_List_Wrapper_Abstract
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Set the number of posts to display to 5
|
7 |
+
* This can be overridden using self::setPostCount($postCount)
|
8 |
+
*/
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
$this->_pagerLimit = 5;
|
13 |
+
$this->setPostListTemplate('wordpress/post/associated/list.phtml');
|
14 |
+
$this->setTitle('Blog Posts Associated With This Product');
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Sets the number of posts to display
|
19 |
+
*
|
20 |
+
* @param string $postCount
|
21 |
+
*/
|
22 |
+
public function setPostCount($postCount = 5)
|
23 |
+
{
|
24 |
+
$this->_pagerLimit = $postCount;
|
25 |
+
return $this;
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Adds on cateogry/author ID filters
|
30 |
+
*
|
31 |
+
* @return Fishpig_Wordpress_Model_Mysql4_Post_Collection
|
32 |
+
*/
|
33 |
+
protected function _getPostCollection()
|
34 |
+
{
|
35 |
+
$collection = $this->_helper('catalog_product')
|
36 |
+
->getAssociatedPosts($this->getProduct())
|
37 |
+
->setCurPage(1);
|
38 |
+
|
39 |
+
return $collection;
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Get's the current product if 1 hasn't been set
|
44 |
+
*
|
45 |
+
* @return Mage_Catalog_Model_Product
|
46 |
+
*/
|
47 |
+
public function getProduct()
|
48 |
+
{
|
49 |
+
if (!$this->hasData('product')) {
|
50 |
+
if (!$this->hasData('product_id')) {
|
51 |
+
$this->setData('product', Mage::Registry('product'));
|
52 |
+
}
|
53 |
+
else {
|
54 |
+
$this->setData('product', Mage::getModel('catalog/product')->load($this->getData('product_id')));
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
return $this->getData('product');
|
59 |
+
}
|
60 |
+
|
61 |
+
}
|
app/code/community/Fishpig/Wordpress/Block/Post/List/Pager.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Fishpig_Wordpress_Block_Post_List_Pager extends Mage_Page_Block_Html_Pager
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Return the URL for a certain page of the collection
|
7 |
+
*
|
8 |
+
* @return string
|
9 |
+
*/
|
10 |
+
public function getPagerUrl($params=array())
|
11 |
+
{
|
12 |
+
$pathInfo = explode('/', $this->_getPathInfo());
|
13 |
+
$parts = array();
|
14 |
+
|
15 |
+
for ($it = 1; $it < count($pathInfo); $it = $it+2) {
|
16 |
+
if (isset($pathInfo[$it+1])) {
|
17 |
+
$key = (binary) $pathInfo[$it];
|
18 |
+
$parts[$key] = $pathInfo[$it+1];
|
19 |
+
}
|
20 |
+
}
|
21 |
+
|
22 |
+
foreach($params as $key => $param) {
|
23 |
+
$parts[$key] = $param;
|
24 |
+
}
|
25 |
+
|
26 |
+
return Mage::helper('wordpress')->getUrl(null, $parts);
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Gets the path info from the request object
|
31 |
+
*
|
32 |
+
* @return string
|
33 |
+
*/
|
34 |
+
protected function _getPathInfo()
|
35 |
+
{
|
36 |
+
return trim(Mage::app()->getRequest()->getPathInfo(), '/');;
|
37 |
+
}
|
38 |
+
|
39 |
+
}
|
app/code/community/Fishpig/Wordpress/Block/Post/List/Recent.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Fishpig_Wordpress_Block_Post_List_Recent extends Fishpig_Wordpress_Block_Post_List_Wrapper_Abstract
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Set the number of posts to display to 5
|
7 |
+
* This can be overridden using self::setPostCount($postCount)
|
8 |
+
*/
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
$this->_pagerLimit = 5;
|
13 |
+
$this->setPostListTemplate('wordpress/post/recent/list.phtml');
|
14 |
+
$this->setTitle('Recent Posts');
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Sets the number of posts to display
|
19 |
+
*
|
20 |
+
* @param string $postCount
|
21 |
+
*/
|
22 |
+
public function setPostCount($postCount = 5)
|
23 |
+
{
|
24 |
+
$this->_pagerLimit = $postCount;
|
25 |
+
return $this;
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Adds on cateogry/author ID filters
|
30 |
+
*
|
31 |
+
* @return Fishpig_Wordpress_Model_Mysql4_Post_Collection
|
32 |
+
*/
|
33 |
+
protected function _getPostCollection()
|
34 |
+
{
|
35 |
+
$collection = parent::_getPostCollection()
|
36 |
+
->setPageSize($this->_pagerLimit)
|
37 |
+
->setCurPage(1);
|
38 |
+
|
39 |
+
|
40 |
+
if ($categoryId = $this->getData('category_id')) {
|
41 |
+
$collection->addCategoryIdFilter($categoryId);
|
42 |
+
}
|
43 |
+
|
44 |
+
if ($authorId = $this->getData('author_id')) {
|
45 |
+
$collection->addAuthorIdFilter($authorId);
|
46 |
+
}
|
47 |
+
|
48 |
+
return $collection;
|
49 |
+
}
|
50 |
+
|
51 |
+
}
|
app/code/community/Fishpig/Wordpress/Block/Post/List/Wrapper/Abstract.php
ADDED
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Fishpig_Wordpress_Block_Post_List_Wrapper_Abstract extends Fishpig_Wordpress_Block_Abstract
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Cache for post collection
|
7 |
+
*
|
8 |
+
* @var Fishpig_Wordpress_Model_Mysql4_Post_Collection
|
9 |
+
*/
|
10 |
+
protected $_postCollection = null;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Block name for the post list block
|
14 |
+
*
|
15 |
+
* @var string
|
16 |
+
*/
|
17 |
+
protected $_postListBlockName = 'wordpress_post_list';
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Instructs whether to set pagination and page size automatically
|
21 |
+
* collection size is set in the Wordpress Admin
|
22 |
+
* Page ID will be taken from the URL
|
23 |
+
*
|
24 |
+
* @var bool
|
25 |
+
*/
|
26 |
+
protected $_autoPaginate = false;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Constructor
|
30 |
+
* This sets the default template for listing the posts
|
31 |
+
* This is not the template for this (wrapper)
|
32 |
+
*
|
33 |
+
*/
|
34 |
+
public function __construct()
|
35 |
+
{
|
36 |
+
parent::__construct();
|
37 |
+
// Set the default template to list the posts
|
38 |
+
$this->setPostListTemplate('wordpress/post/list.phtml');
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Returns the collection of posts
|
43 |
+
*
|
44 |
+
* @return Fishpig_Wordpress_Model_Mysql4_Post_Collection
|
45 |
+
*/
|
46 |
+
public function getPostCollection()
|
47 |
+
{
|
48 |
+
return $this->_getPostCollection();
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Generates and returns the collection of posts
|
53 |
+
*
|
54 |
+
* @return Fishpig_Wordpress_Model_Mysql4_Post_Collection
|
55 |
+
*/
|
56 |
+
protected function _getPostCollection()
|
57 |
+
{
|
58 |
+
$collection = Mage::getResourceModel('wordpress/post_collection')
|
59 |
+
->addIsPublishedFilter()
|
60 |
+
->setPostsPerPage()
|
61 |
+
->setPageFromUrl()
|
62 |
+
->setOrderByPostDate();
|
63 |
+
|
64 |
+
return $collection;
|
65 |
+
}
|
66 |
+
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Returns the HTML for the post collection
|
70 |
+
*
|
71 |
+
* @return string
|
72 |
+
*/
|
73 |
+
public function getPostListHtml()
|
74 |
+
{
|
75 |
+
return $this->getPostListBlock()->toHtml();
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Gets the post list block
|
80 |
+
*
|
81 |
+
* @return Fishpig_Wordpress_Block_Post_List
|
82 |
+
*/
|
83 |
+
public function getPostListBlock()
|
84 |
+
{
|
85 |
+
if (!$this->hasData('post_list_block')) {
|
86 |
+
if ($block = $this->getChild($this->_postListBlockName)) {
|
87 |
+
$this->setData('post_list_block', $block->setWrapperBlock($this));
|
88 |
+
}
|
89 |
+
else {
|
90 |
+
$this->setData('post_list_block', $this->_createPostListBlock());
|
91 |
+
}
|
92 |
+
}
|
93 |
+
|
94 |
+
return $this->getData('post_list_block');
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Dynamically create the post list block
|
99 |
+
*
|
100 |
+
* @return Fishpig_Wordpress_Block_Post_List
|
101 |
+
*/
|
102 |
+
protected function _createPostListBlock()
|
103 |
+
{
|
104 |
+
return $this->getLayout()
|
105 |
+
->createBlock('wordpress/post_list', $this->_postListBlockName.microtime().rand(1, 999))
|
106 |
+
->setTemplate($this->getPostListTemplate())
|
107 |
+
->setWrapperBlock($this);
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Enables auto pagination
|
112 |
+
*/
|
113 |
+
public function enableAutoPagination()
|
114 |
+
{
|
115 |
+
$this->_autoPaginate = true;
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Disables auto pagination
|
120 |
+
*/
|
121 |
+
public function disableAutoPagination()
|
122 |
+
{
|
123 |
+
$this->_autoPaginate = false;
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Returns true if auto pagination set
|
128 |
+
*
|
129 |
+
* @return bool
|
130 |
+
*/
|
131 |
+
public function isAutoPaginationEnabled()
|
132 |
+
{
|
133 |
+
return $this->_autoPaginate;
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Sets the name of the child block that contains the post list
|
138 |
+
*
|
139 |
+
* @param string $blockName
|
140 |
+
*/
|
141 |
+
public function setPostListBlockName($blockName)
|
142 |
+
{
|
143 |
+
$this->_postListBlockName = $blockName;
|
144 |
+
return $this;
|
145 |
+
}
|
146 |
+
|
147 |
+
}
|
app/code/community/Fishpig/Wordpress/Block/Post/View.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Fishpig_Wordpress_Block_Post_View extends Fishpig_Wordpress_Block_Post_View_Abstract
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* The block name for the comments block
|
7 |
+
*
|
8 |
+
* @var string
|
9 |
+
*/
|
10 |
+
protected $_commentsBlockName = 'wordpress_post_comments';
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Returns the HTML for the comments block
|
14 |
+
*
|
15 |
+
* @return string
|
16 |
+
*/
|
17 |
+
public function getCommentsHtml()
|
18 |
+
{
|
19 |
+
return $this->getCommentsBlock()->toHtml();
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Gets the comments block
|
24 |
+
*
|
25 |
+
* @return Fishpig_Wordpress_Block_Post_View_Comments
|
26 |
+
*/
|
27 |
+
public function getCommentsBlock()
|
28 |
+
{
|
29 |
+
if (!$this->hasData('post_comments')) {
|
30 |
+
if ($block = $this->getChild($this->_commentsBlockName)) {
|
31 |
+
$this->setData('post_comments', $block->setPost($this->getPost()));
|
32 |
+
}
|
33 |
+
else {
|
34 |
+
$this->setData('post_comments', $this->_createCommentsBlock());
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
return $this->getData('post_comments');
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Dynamically create the comments block
|
43 |
+
*
|
44 |
+
* @return Fishpig_Wordpress_Block_Post_View_Comments
|
45 |
+
*/
|
46 |
+
protected function _createCommentsBlock()
|
47 |
+
{
|
48 |
+
return $this->getLayout()
|
49 |
+
->createBlock('wordpress/post_view_comments', microtime().rand(1, 9999))
|
50 |
+
->setPost($this->getPost());
|
51 |
+
}
|
52 |
+
}
|
app/code/community/Fishpig/Wordpress/Block/Post/View/Abstract.php
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
abstract class Fishpig_Wordpress_Block_Post_View_Abstract extends Fishpig_Wordpress_Block_Abstract
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Returns the currently loaded post model
|
7 |
+
*
|
8 |
+
* @return Fishpig_Wordpress_Model_Post
|
9 |
+
*/
|
10 |
+
public function getPost($d = false)
|
11 |
+
{
|
12 |
+
if (!$this->hasData('post')) {
|
13 |
+
if ($postId = $this->getData('post_id')) {
|
14 |
+
$post = Mage::getModel('wordpress/post')->load($postId);
|
15 |
+
|
16 |
+
if ($post->getId() == $postId) {
|
17 |
+
$this->setData('post', $post);
|
18 |
+
}
|
19 |
+
}
|
20 |
+
else {
|
21 |
+
$this->setData('post', Mage::registry('wordpress_post'));
|
22 |
+
}
|
23 |
+
}
|
24 |
+
|
25 |
+
return $this->getData('post');
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Sets the current post object
|
30 |
+
*
|
31 |
+
* @param Fishpig_Wordpress_Model_Post $post
|
32 |
+
* @param bool $replaceIfExists
|
33 |
+
*/
|
34 |
+
public function setPost(Fishpig_Wordpress_Model_Post $post, $replaceIfExists = true)
|
35 |
+
{
|
36 |
+
if (!$this->hasData('post') || $replaceIfExists) {
|
37 |
+
$this->setData('post', $post);
|
38 |
+
}
|
39 |
+
|
40 |
+
return $this;
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Returns the ID of the currently loaded post
|
45 |
+
*
|
46 |
+
* @return int
|
47 |
+
*/
|
48 |
+
public function getPostId()
|
49 |
+
{
|
50 |
+
if ($post = $this->getPost()) {
|
51 |
+
return $post->getId();
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Returns true if comments are enabled for this post
|
57 |
+
*/
|
58 |
+
protected function canComment()
|
59 |
+
{
|
60 |
+
if ($post = $this->getPost()) {
|
61 |
+
return $post->getCommentStatus() == 'open';
|
62 |
+
}
|
63 |
+
|
64 |
+
return false;
|
65 |
+
}
|
66 |
+
}
|
app/code/community/Fishpig/Wordpress/Block/Post/View/Comment/Form.php
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Fishpig_Wordpress_Block_Post_View_Comment_Form extends Fishpig_Wordpress_Block_Post_View_Abstract
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
$this->setTemplate('wordpress/post/view/comment/form.phtml');
|
9 |
+
}
|
10 |
+
|
11 |
+
public function getCommentFormAction()
|
12 |
+
{
|
13 |
+
return $this->_helper()->getBaseUrl('wp-comments-post.php');
|
14 |
+
return $this->getUrl('wordpress/post_view_comment/post');
|
15 |
+
return $this->_helper()->getBaseUrl('wp-comments-post.php');
|
16 |
+
}
|
17 |
+
|
18 |
+
public function getCustomerName()
|
19 |
+
{
|
20 |
+
if ($customer = Mage::getSingleton('customer/session')->getCustomer()) {
|
21 |
+
return $customer->getName();
|
22 |
+
}
|
23 |
+
}
|
24 |
+
|
25 |
+
public function getCustomerEmail()
|
26 |
+
{
|
27 |
+
if ($customer = Mage::getSingleton('customer/session')->getCustomer()) {
|
28 |
+
return $customer->getEmail();
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
public function getRedirectTo()
|
33 |
+
{
|
34 |
+
return $this->hasData('redirect_to') ? $this->getData('redirect_to') : $this->getPost()->getPermalink();
|
35 |
+
}
|
36 |
+
|
37 |
+
public function getSuccessUrl()
|
38 |
+
{
|
39 |
+
if (!$this->hasData('success_url')) {
|
40 |
+
$permalink = $this->getPost()->getPermalink();
|
41 |
+
|
42 |
+
if (strpos($permalink, '?') === false) {
|
43 |
+
$permalink .= '?';
|
44 |
+
}
|
45 |
+
else {
|
46 |
+
$permalink = rtrim($permalink, '&') . '&';
|
47 |
+
}
|
48 |
+
|
49 |
+
$this->setSuccessUrl($permalink . 'cy='.rand(1111, 9999));
|
50 |
+
}
|
51 |
+
|
52 |
+
return $this->getData('success_url');
|
53 |
+
}
|
54 |
+
|
55 |
+
public function getErrorUrl()
|
56 |
+
{
|
57 |
+
if (!$this->hasData('error_url')) {
|
58 |
+
$permalink = $this->getPost()->getPermalink();
|
59 |
+
|
60 |
+
if (strpos($permalink, '?') === false) {
|
61 |
+
$permalink .= '?';
|
62 |
+
}
|
63 |
+
else {
|
64 |
+
$permalink = rtrim($permalink, '&') . '&';
|
65 |
+
}
|
66 |
+
|
67 |
+
$this->setErrorUrl($permalink . 'cx='.rand(1111, 9999));
|
68 |
+
}
|
69 |
+
|
70 |
+
return $this->getData('error_url');
|
71 |
+
}
|
72 |
+
}
|
app/code/community/Fishpig/Wordpress/Block/Post/View/Comments.php
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|