function render()
 {
     $ts = new TemplateSets();
     // get all the template sets, without including the global ones
     $blogTemplateSets = $ts->getBlogTemplateSets($this->_blogInfo->getId(), false);
     $this->setValue("templates", $blogTemplateSets);
     parent::render();
 }
 function render()
 {
     $ts = new TemplateSets();
     // get a list with all the site template sets
     $globalTemplateSets = $ts->getGlobalTemplateSets();
     // get a list with all the blog template sets
     $blogTemplateSets = $ts->getBlogTemplateSets($this->_blogInfo->getId(), false);
     $this->setValue("globalTemplateSets", $globalTemplateSets);
     $this->setValue("blogTemplateSets", $blogTemplateSets);
     parent::render();
 }
 function render()
 {
     $this->setValue("blogsettings", $this->_blogInfo->getSettings());
     $ts = new TemplateSets();
     $templates = $ts->getBlogTemplateSets($this->_blogInfo->getId(), true);
     $this->setValue("templates", $templates);
     // loading all the locales from disk is a pretty heavy task but doing so, we'll get
     // nice Locale object with things like the encoding, the description, etc... which looks
     // waaaay nicer than just showing the locale code
     $this->setValue("locales", Locales::getLocales());
     parent::render();
 }
 function AdminEditSiteBlogView($blogInfo, $editBlogInfo = null)
 {
     // fetch information about the blog we're editing
     if ($editBlogInfo == null) {
         $this->_editBlogInfo = $this->getSessionValue('editBlogInfo');
     } else {
         $this->_editBlogInfo = $editBlogInfo;
     }
     // this stuff is a bit weird but I couldn't find a better way to do it!
     if ($this->_editBlogInfo) {
         $this->AdminTemplatedView($blogInfo, 'editblog');
         $this->_error = false;
         $this->setSessionValue('editBlogInfo', $this->_editBlogInfo);
         // ...
         // export data to the view
         $this->setValue('editblog', $this->_editBlogInfo);
         $this->setValue('editblogsettings', $this->_editBlogInfo->getSettings());
         // blog settings...
         $blogTemplateSet = $this->_editBlogInfo->getTemplateSet();
         $this->setValue('blogTemplate', $blogTemplateSet->getName());
         $ts = new TemplateSets();
         // get the blog template sets
         $this->setValue('templates', $ts->getBlogTemplateSets($this->_editBlogInfo->getId(), true));
         // and the list of locale availables
         $this->setValue('locales', Locales::getLocales());
         $this->setValue('blogStatus', $this->_editBlogInfo->getStatus());
         $this->setValue('blogStatusList', BlogStatus::getStatusList());
         $blogSettings = $this->_editBlogInfo->getSettings();
         $this->setValue('blogTimeOffset', $blogSettings->getValue('time_offset'));
         $this->setValue('blogOwner', $this->_editBlogInfo->getOwner());
         $this->setValue('blogName', $this->_editBlogInfo->getBlog());
         $this->setValue('blogLocale', $blogSettings->getValue("locale"));
         $this->setValue('blogResourcesQuota', $this->_editBlogInfo->getResourcesQuota());
         // get all the users
         $users = new Users();
         $siteUsers = $users->getAllUsers();
         $this->notifyEvent(EVENT_USERS_LOADED, array('users' => &$siteUsers));
         // set the blog users and the available users
         $blogUsers = $users->getBlogUsers($this->_editBlogInfo->getId(), false);
         $this->setValue('availableusers', $this->filterAvailableUsers($siteUsers, $blogUsers));
         $this->setValue('blogusers', $blogUsers);
         $this->setValue('siteusers', $siteUsers);
     } else {
         $this->AdminTemplatedView($blogInfo, 'error');
         $this->setValue('message', 'Unexpected error loading blog!');
         $this->_error = true;
     }
 }
 function render()
 {
     // get a list with all the global template sets
     $ts = new TemplateSets();
     $blogTemplateSets = $ts->getBlogTemplateSets($this->_blogInfo->getId(), false);
     // get a list with all the specific template files
     $ts = new TemplateSetStorage();
     $blogId = $this->_blogInfo->getId();
     $templateFolder = $ts->getTemplateFolder($this->_templateId, $blogId);
     $templateFolder = $templateFolder . $this->_subFolderId;
     // Get template files according extension
     $templateFiles = $this->getTemplateFiles($templateFolder);
     $this->setValue("currentTemplate", $this->_templateId);
     $this->setValue("currentSubFolder", $this->_subFolderId);
     $this->setValue("templateSets", $blogTemplateSets);
     $this->setValue("templateFiles", $templateFiles);
     parent::render();
 }
 function perform()
 {
     // get a list with all the global template sets
     if ($this->_type == 1) {
         $ts = new TemplateSets();
         $blogTemplateSets = $ts->getBlogTemplateSets($this->_blogInfo->getId(), false);
         foreach ($blogTemplateSets as $template) {
             if ($template->getName() == $this->_newTemplateId) {
                 $this->_view = new PluginBlogTemplateSetsListView($this->_blogInfo);
                 $this->_view->setErrorMessage($this->_locale->tr("error_duplicate_templateset_name"));
                 $this->setCommonData();
                 return false;
             }
         }
         $ts = new TemplateSetStorage();
         $blogId = $this->_blogInfo->getId();
         $sourceTemplateFolder = $ts->getTemplateFolder($this->_templateId);
         $newTemplateFolder = $ts->getBlogBaseTemplateFolder($blogId) . $this->_newTemplateId;
         if (MyFile::copyDir($sourceTemplateFolder, $newTemplateFolder)) {
             $ts->addTemplate($this->_newTemplateId, $blogId);
         } else {
             File::deleteDir($newTemplateFolder);
             $this->_view = new PluginBlogTemplateSetsListView($this->_blogInfo);
             $this->_view->setErrorMessage($this->_locale->tr("error_copying_templateset"));
             $this->setCommonData();
             return false;
         }
     } else {
         $ts = new TemplateSets();
         $blogTemplateSets = $ts->getBlogTemplateSets($this->_blogInfo->getId(), false);
         foreach ($blogTemplateSets as $template) {
             if ($template->getName() == $this->_newTemplateId) {
                 $this->_view = new PluginBlogTemplateSetsListView($this->_blogInfo);
                 $this->_view->setErrorMessage($this->_locale->tr("error_duplicate_templateset_name"));
                 $this->setCommonData();
                 return false;
             }
         }
         $ts = new TemplateSetStorage();
         $blogId = $this->_blogInfo->getId();
         $sourceTemplateFolder = $ts->getTemplateFolder($this->_templateId, $blogId);
         $newTemplateFolder = $ts->getBlogBaseTemplateFolder($blogId) . $this->_newTemplateId;
         if (MyFile::copyDir($sourceTemplateFolder, $newTemplateFolder)) {
             $ts->addTemplate($this->_newTemplateId, $blogId);
         } else {
             File::deleteDir($newTemplateFolder);
             $this->_view = new PluginBlogTemplateSetsListView($this->_blogInfo);
             $this->_view->setErrorMessage($this->_locale->tr("error_copying_templateset"));
             $this->setCommonData();
             return false;
         }
     }
     // if everything went ok...
     $this->_session->setValue("blogInfo", $this->_blogInfo);
     $this->saveSession();
     $this->_view = new PluginBlogTemplateSetsListView($this->_blogInfo);
     $this->_view->setSuccessMessage($this->_locale->tr("templateeditor_templateset_copyed_ok"));
     $this->setCommonData();
     // clear the cache
     CacheControl::resetBlogCache($this->_blogInfo->getId());
     return true;
 }