Plog 1.0.1 > Class / Action / Admin / Adminaddblogtemplateaction.class.php

Questions? Need Help? Want to share? » PHP Forum
 
Script Name:
Plog 1.0.1

Download:
plog-1.0.1.zip

Category:
Blog

Archive Content:

Plog 1.0.1

Plog 1.0.1 > Class

Plog 1.0.1 > Class > Action

Plog 1.0.1 > Class > Action > Admin

Plog 1.0.1 > Class > Action

Plog 1.0.1 > Class > Bayesian

Plog 1.0.1 > Class > Config

Plog 1.0.1 > Class > Controller

Plog 1.0.1 > Class > Dao

Plog 1.0.1 > Class > Dao > Customfields

Plog 1.0.1 > Class > Dao

Plog 1.0.1 > Class > Dao > Status

Plog 1.0.1 > Class > Dao

Plog 1.0.1 > Class > Data

Plog 1.0.1 > Class > Data > Date

Plog 1.0.1 > Class > Data

Plog 1.0.1 > Class > Data > Forms

Plog 1.0.1 > Class > Data

Plog 1.0.1 > Class > Data > Pager

Plog 1.0.1 > Class > Data

Plog 1.0.1 > Class > Data > Validator

Plog 1.0.1 > Class > Data > Validator > Rules

Plog 1.0.1 > Class > Data > Validator

Plog 1.0.1 > Class > Database

Plog 1.0.1 > Class > Database > Adodb

Plog 1.0.1 > Class > Database > Adodb > Datadict

Plog 1.0.1 > Class > Database > Adodb > Docs

Plog 1.0.1 > Class > Database > Adodb > Drivers

Plog 1.0.1 > Class > Database > Adodb > Lang

Plog 1.0.1 > Class > Database > Adodb

Plog 1.0.1 > Class > Database > Adodb > Perf

Plog 1.0.1 > Class > Database > Adodb

Plog 1.0.1 > Class > Database

Plog 1.0.1 > Class

Plog 1.0.1 > Class > File

Plog 1.0.1 > Class > File > Finder

Plog 1.0.1 > Class > File > Unpacker

Plog 1.0.1 > Class > Gallery

Plog 1.0.1 > Class > Gallery > Dao

Plog 1.0.1 > Class > Gallery > Data

Plog 1.0.1 > Class > Gallery

Plog 1.0.1 > Class > Gallery > Getid3

Plog 1.0.1 > Class > Gallery > Helperapps

Plog 1.0.1 > Class > Gallery > Resizers

Plog 1.0.1 > Class > Gallery > Template

Plog 1.0.1 > Class > Locale

Plog 1.0.1 > Class > Logger

Plog 1.0.1 > Class > Logger > Appender

Plog 1.0.1 > Class > Logger > Config

Plog 1.0.1 > Class > Logger > Layout

Plog 1.0.1 > Class > Logger > Logger

Plog 1.0.1 > Class > Logger

Plog 1.0.1 > Class > Mail

Plog 1.0.1 > Class > Mail > Phpmailer

Plog 1.0.1 > Class > Mail > Phpmailer > Language

Plog 1.0.1 > Class > Mail > Phpmailer

Plog 1.0.1 > Class > Misc

Plog 1.0.1 > Class > Net

Plog 1.0.1 > Class > Net > Http

Plog 1.0.1 > Class > Net > Http > Phpsniff

Plog 1.0.1 > Class > Net > Http > Session

Plog 1.0.1 > Class > Net > Http

Plog 1.0.1 > Class > Net

Plog 1.0.1 > Class > Net > Xmlrpc

Plog 1.0.1 > Class > Net

Plog 1.0.1 > Class > Object

Plog 1.0.1 > Class > Plugin

Plog 1.0.1 > Class > Security

Plog 1.0.1 > Class > Summary

Plog 1.0.1 > Class > Summary > Action

Plog 1.0.1 > Class > Summary > Dao

Plog 1.0.1 > Class > Summary > Data

Plog 1.0.1 > Class > Summary > Data > Validator

Plog 1.0.1 > Class > Summary > Mail

Plog 1.0.1 > Class > Summary > View

Plog 1.0.1 > Class > Template

Plog 1.0.1 > Class > Template > Menu

Plog 1.0.1 > Class > Template > Smarty

Plog 1.0.1 > Class > Template > Smarty > Core

Plog 1.0.1 > Class > Template > Smarty

Plog 1.0.1 > Class > Template > Smarty > Plugins

Plog 1.0.1 > Class > Template > Smarty

Plog 1.0.1 > Class > Template

Plog 1.0.1 > Class > Template > Templatesets

Plog 1.0.1 > Class > Template

Plog 1.0.1 > Class > View

Plog 1.0.1 > Class > View > Admin

Plog 1.0.1 > Class > View

Plog 1.0.1 > Class > Xml

Plog 1.0.1 > Class > Xml > Parser

Plog 1.0.1 > Class > Xml

Plog 1.0.1 > Class > Xml > Rssparser

Plog 1.0.1 > Class > Xml > Rssparser > Magpierss

Plog 1.0.1 > Class > Xml > Rssparser > Magpierss > Extlib

Plog 1.0.1 > Class > Xml > Rssparser > Magpierss

Plog 1.0.1 > Class > Xml > Rssparser

Plog 1.0.1 > Class > Xml > Tree

Plog 1.0.1 > Class > Xml

Plog 1.0.1

Plog 1.0.1 > Config

Plog 1.0.1

Plog 1.0.1 > Gallery

Plog 1.0.1

Plog 1.0.1 > Imgs

Plog 1.0.1 > Imgs > .xvpics

Plog 1.0.1 > Imgs > Admin

Plog 1.0.1 > Imgs

Plog 1.0.1

Plog 1.0.1 > Install

Plog 1.0.1 > Js

Plog 1.0.1 > Js > Calendar

Plog 1.0.1 > Js > Editor

Plog 1.0.1 > Js > Htmlarea

Plog 1.0.1 > Js > Htmlarea > Docs

Plog 1.0.1 > Js > Htmlarea

Plog 1.0.1 > Js > Htmlarea > Images

Plog 1.0.1 > Js > Htmlarea > Lang

Plog 1.0.1 > Js > Htmlarea > Plugins

Plog 1.0.1 > Js > Htmlarea > Plugins > CharacterMap

Plog 1.0.1 > Js > Htmlarea > Plugins > CharacterMap > Img

Plog 1.0.1 > Js > Htmlarea > Plugins > CharacterMap > Lang

Plog 1.0.1 > Js > Htmlarea > Plugins > CharacterMap > Popups

Plog 1.0.1 > Js > Htmlarea > Plugins > ContextMenu

Plog 1.0.1 > Js > Htmlarea > Plugins > ContextMenu > Lang

Plog 1.0.1 > Js > Htmlarea > Plugins > ContextMenu

Plog 1.0.1 > Js > Htmlarea > Plugins > CSS

Plog 1.0.1 > Js > Htmlarea > Plugins > CSS > Lang

Plog 1.0.1 > Js > Htmlarea > Plugins > DynamicCSS

Plog 1.0.1 > Js > Htmlarea > Plugins > DynamicCSS > Lang

Plog 1.0.1 > Js > Htmlarea > Plugins > EnterParagraphs

Plog 1.0.1 > Js > Htmlarea > Plugins > EnterParagraphs > Lang

Plog 1.0.1 > Js > Htmlarea > Plugins > FullPage

Plog 1.0.1 > Js > Htmlarea > Plugins > FullPage > Img

Plog 1.0.1 > Js > Htmlarea > Plugins > FullPage > Lang

Plog 1.0.1 > Js > Htmlarea > Plugins > FullPage > Popups

Plog 1.0.1 > Js > Htmlarea > Plugins > FullPage

Plog 1.0.1 > Js > Htmlarea > Plugins > InsertSmiley

Plog 1.0.1 > Js > Htmlarea > Plugins > InsertSmiley > Emoticons

Plog 1.0.1 > Js > Htmlarea > Plugins > InsertSmiley > Img

Plog 1.0.1 > Js > Htmlarea > Plugins > InsertSmiley

Plog 1.0.1 > Js > Htmlarea > Plugins > InsertSmiley > Lang

Plog 1.0.1 > Js > Htmlarea > Plugins > InsertSmiley > Popups

Plog 1.0.1 > Js > Htmlarea > Plugins > ListType

Plog 1.0.1 > Js > Htmlarea > Plugins > ListType > Lang

Plog 1.0.1 > Js > Htmlarea > Plugins > ListType

Plog 1.0.1 > Js > Htmlarea > Plugins

Plog 1.0.1 > Js > Htmlarea > Plugins > TableOperations

Plog 1.0.1 > Js > Htmlarea > Plugins > TableOperations > Img

Plog 1.0.1 > Js > Htmlarea > Plugins > TableOperations > Lang

Plog 1.0.1 > Js > Htmlarea > Plugins > TableOperations

Plog 1.0.1 > Js > Htmlarea

Plog 1.0.1 > Js > Htmlarea > Popups

Plog 1.0.1 > Js > Htmlarea

Plog 1.0.1 > Js > Ie7

Plog 1.0.1 > Js > Ie7 > Src

Plog 1.0.1 > Js

Plog 1.0.1 > Js > Ui

Plog 1.0.1

Plog 1.0.1 > Locale

Plog 1.0.1 > Locale > Unsupport

Plog 1.0.1 > Plugins

Plog 1.0.1

Plog 1.0.1 > Styles

Plog 1.0.1

Plog 1.0.1 > Templates

Plog 1.0.1 > Templates > Admin

Plog 1.0.1 > Templates > Admin > Xml

Plog 1.0.1 > Templates > Blueish

Plog 1.0.1 > Templates > Grey

Plog 1.0.1 > Templates > Misc

Plog 1.0.1 > Templates > Rss

Plog 1.0.1 > Templates > Standard

Plog 1.0.1 > Templates > Standard > Imgs

Plog 1.0.1 > Templates > Standard

Plog 1.0.1 > Templates > Summary

Plog 1.0.1 > Templates > Summary > Rss

Plog 1.0.1 > Templates > Summary

Plog 1.0.1 > Templates > Wizard

Plog 1.0.1 > Tmp

Plog 1.0.1

Adminaddblogtemplateaction.class.php:


<?php

    
include_once( PLOG_CLASS_PATH."class/action/admin/blogowneradminaction.class.php" );
    include_once( 
PLOG_CLASS_PATH."class/action/admin/adminaddtemplateaction.class.php" );
    include_once( 
PLOG_CLASS_PATH."class/file/unpacker/unpacker.class.php" );
    include_once( 
PLOG_CLASS_PATH."class/view/admin/admintemplatedview.class.php" );
    include_once( 
PLOG_CLASS_PATH."class/view/admin/adminblogtemplatesetslistview.class.php" );
    include_once( 
PLOG_CLASS_PATH."class/template/templatesets/templatesetstorage.class.php" );
    include_once( 
PLOG_CLASS_PATH."class/template/templatesandbox.class.php" );
    include_once( 
PLOG_CLASS_PATH."class/file/fileuploads.class.php" );

    
/**
     * \ingroup Action
     * @private
     *
     * Shows a form to add a new locale file
     */
    
class AdminAddBlogTemplateAction extends BlogOwnerAdminAction
    
{

        var 
$_op;

        function 
AdminAddBlogTemplateAction$actionInfo,  $request )
        {
            
$this->BlogOwnerAdminAction$actionInfo,  $request );

            
// decide what to do based on which submit button was pressed
            
if( $this->_request->getValue"addBlogTemplate" ) != "" )
                
$this->_op "addBlogTemplate";
            else
                
$this->_op "scanBlogTemplates";
        }

        function 
validate()
        {
            
//
            // first of all,  let's make sure that users are allowed to
            // add new templates
            //
            
$config =& Config::getConfig();
            if( !
$config->getValue"users_can_add_templates" )) {
                
$this->_view = new AdminBlogTemplateSetsListView$this->_blogInfo );
                
$this->_view->setErrorMessage$this->_locale->tr("error_add_template_disabled"));
                
$this->setCommonData();

                return 
false;
            }

            return 
parent::validate();
        }

        function 
_performUploadTemplate()
        {
            
// get the temporary folder
            
$config =& Config::getConfig();
            
$tmpFolder $config->getValue"temp_folder" );

            
// move it to the temporary folder
            
$files    HttpVars::getFiles();

            if( 
count($files) == || $files["templateFile"]["name"] == "") {
                
$this->_view = new AdminTemplatedView$this->_blogInfo,  "newblogtemplate" );
                
$this->_view->setValue"templateFolder",  TemplateSetStorage::getBlogBaseTemplateFolder$this->_blogInfo->getId()));
                
$this->_view->setErrorMessage$this->_locale->tr("error_must_upload_file"));
                
$this->setCommonData();
                return 
false;
            }

            
$uploads  = new FileUploads$files );

            
$result $uploads->process$tmpFolder );
            if( 
$result ) {
                
$this->_view = new AdminBlogTemplateSetsListView$this->_blogInfo );
                
$this->_view->setErrorMessage$this->_locale->tr("error_uploads_disabled"));
                
$this->setCommonData();

                return 
false;
            }

            
$upload   = new FileUpload$files["templateFile"] );

            
// and make it go through the template sandbox to check if
            // we're dealing with a 'healthy' file
            
$templateSandbox = new TemplateSandbox();
            
$valid $templateSandbox->checkTemplateSet$upload->getFileName(),  $tmpFolder."/");

            if( 
$valid ) {
                
$this->_view = new AdminBlogTemplateSetsListView$this->_blogInfo );
                
$this->_view->setErrorMessageAdminAddTemplateAction::_checkTemplateSandboxResult$valid ));
                
$this->setCommonData();

                return 
false;
            }

            
//
            // :KLUDGE:
            //
            // maybe we should simply move the files rather than unpacking the whole
            // thing again,  but this indeed makes things easier! ;)
            //

            // since it is a local template,  the path has to be $template_folder/blog_x/$templateName
            
$ts = new TemplateSetStorage();
            
$blogTemplateFolder $ts->createBlogTemplateFolder$this->_blogInfo->getId());

            
// it should be there now... we can continue
            
$destFolder $blogTemplateFolder."/";

            
$unpacker = new Unpacker();
            if( !
$unpacker->unpack$tmpFolder."/".$upload->getFileName(),  $destFolder )) {
                
$this->_view = new AdminBlogTemplateSetsListView$this->_blogInfo );
                
$this->_view->setErrorMessage$this->_locale->tr("error_installing_template"));
                
$this->setCommonData();

                
// remove the file before returning!
                
File::delete$tmpFolder."/".$upload->getFileName());

                return 
false;
            }

            
// if the template set was installed ok in the template folder,  we can record
            // it as a valid set
            
$fileParts explode".",  $upload->getFileName());
            
$templateName $fileParts[0];
            
$ts->addTemplate$templateName,  $this->_blogInfo->getId());

            
// remove the file
            
File::delete$tmpFolder."/".$upload->getFileName());

            
$this->_view = new AdminBlogTemplateSetsListView$this->_blogInfo );
            
$this->_view->setSuccessMessage$this->_locale->pr("template_installed_ok",  $templateName));
            
$this->setCommonData();

            return 
true;
        }


        
/**
         * @private
         */
        
function _addTemplateCode$templateName )
        {
            
$config =& Config::getConfig();
            
$templateFolder $config->getValue"template_folder" );

            
$ts = new TemplateSetStorage();

            
$this->_view = new AdminBlogTemplateSetsListView$this->_blogInfo );

            
// make sure that the template is valid
            
$templateSandbox = new TemplateSandbox();
            
$valid $templateSandbox->checkTemplateFolder$templateName,  $ts->getBlogBaseTemplateFolder$this->_blogInfo->getId()));
            if( 
$valid ) {
                
$this->_errorMessage $this->_locale->pr'error_installing_template',  $templateName ).': '.AdminAddTemplateAction::_checkTemplateSandboxResult$valid ).'<br/>';
                
$result false;
            }
            else {
                
// otherwise,  we can add it without problems
                
$ts->addTemplate$templateName,  $this->_blogInfo->getId());
                
$this->_successMessage =  $this->_locale->pr"template_installed_ok",  $templateName );
                
$result true;
            }

            
$this->setCommonData();
            return 
$result;
        }
        
        
/**
         * scans the templates folder looking for new files
         *
         * @private
         */
        
function _performScanTemplateFolder()
        {
            
$this->_errorMessage "";
            
$this->_successMessage "";        
        
            
// set up the view
            
$this->_view = new AdminBlogTemplateSetsListView$this->_blogInfo );        
        
            
// and tell the template finder to find any new template file...
            
$tf = new TemplateFinderTemplateSetStorage::getBlogBaseTemplateFolder$this->_blogInfo->getId()));
            
$newTemplates $tf->findTemplateSets::getBlogTemplates$this->_blogInfo->getId()));
            
            
$this->_errorMessage "";
            
$this->_successMessage "";
            
            if( 
count($newTemplates) == ) {
                
// no new templates found
                
$this->_errorMessage $this->_locale->tr'error_no_new_templates_found' );
            }
            else {
                
// now add each one of the new ones
                
foreach( $newTemplates as $newTemplate ) {
                    
$this->_addTemplateCode$newTemplate );
                }
            }
            
            
// set the success and error messages,  if any
            
if( $this->_errorMessage != '' $this->_view->setErrorMessage$this->_errorMessage );
            if( 
$this->_successMessage != '' $this->_view->setSuccessMessage$this->_successMessage );
            
            
$this->setCommonData();
            
            return 
true;
        }        

        function 
perform()
        {
            if( 
$this->_op == "addBlogTemplate" ) {
                
$result $this->_performUploadTemplate();
            }
            elseif( 
$this->_op == "scanBlogTemplates" ) {
                
$result $this->_performScanTemplateFolder();
            }
            else {
                throw( new 
Exception"You shouldn't be seeing this!!! :)" ));
                die();
            }

            return 
$result;
        }
    }
?>


Other Blog Scripts:

WebMaster Resources Home

©RingsWorld.com