/**
  * Reload the REST information.
  * This is only a empty placeholder. The child class can override it.
  *
  * @author David Pauli <*****@*****.**>
  * @since 0.0.0
  * @since 0.0.1 Use HTTPRequestMethod enum.
  * @since 0.1.0 Use a default Locale.
  * @since 0.1.1 Unstatic every attributes.
  */
 private function load()
 {
     // if the REST path empty -> this is the not the implementation or can't get something else
     if (InputValidator::isEmpty(self::RESTPATH) || !RESTClient::setRequestMethod(HTTPRequestMethod::GET)) {
         return;
     }
     $content = RESTClient::sendWithLocalization(self::RESTPATH, Locales::getLocale());
     // if respond is empty
     if (InputValidator::isEmpty($content)) {
         return;
     }
     // reset values
     $this->resetValues();
     if (!InputValidator::isEmptyArrayKey($content, "name")) {
         $this->NAME = $content["name"];
     }
     if (!InputValidator::isEmptyArrayKey($content, "navigationCaption")) {
         $this->NAVIGATIONCAPTION = $content["navigationCaption"];
     }
     if (!InputValidator::isEmptyArrayKey($content, "description")) {
         $this->DESCRIPTION = $content["description"];
     }
     // update timestamp when make the next request
     $timestamp = (int) (microtime(true) * 1000);
     $this->NEXT_REQUEST_TIMESTAMP = $timestamp + RESTClient::$NEXT_RESPONSE_WAIT_TIME;
 }
 /**
  * Loads the current locale. It works so that it tries to fetch the parameter "lang" from the
  * request. If it's not available, then it will try to look for it in the session. If it is not
  * there either, it will try to guess the most prefered language according to what the User Agent 
  * included in the HTTP_ACCEPT_LANGUAGE string sent with the request. If none matches available 
  * languages we have to use the value of "default_locale" and display the default language.
  *
  * @private
  * @return Returns a reference to a Locale object
  */
 function &_loadLocale()
 {
     $requestLocale =& $this->_request->getValue("lang");
     $localeCode = "";
     $serverVars =& HttpVars::getServer();
     // check if there's something in the request...
     // if not, check the session or at least try to
     // guess the apropriate languege from the http_accept_lnaguage string
     if ($requestLocale) {
         // check if it's a valid one
         if (Locales::isValidLocale($requestLocale)) {
             $localeCode = $requestLocale;
         }
     } else {
         $sessionLocale =& SessionManager::getSessionValue("summaryLang");
         if ($sessionLocale) {
             $localeCode = $sessionLocale;
         } elseif ($this->_config->getValue("use_http_accept_language_detection", HTTP_ACCEPT_LANGUAGE_DETECTION) == 1) {
             $localeCode =& $this->_matchHttpAcceptLanguages($serverVars['HTTP_ACCEPT_LANGUAGE']);
         }
     }
     // check if the locale code is correct
     // and as a valid resort, use the default one if the locale ist not valid or 'false'
     if ($localeCode === false || !Locales::isValidLocale($localeCode)) {
         $localeCode = $this->_config->getValue("default_locale");
     }
     // now put whatever locale value back to the session
     SessionManager::setSessionValue("summaryLang", $localeCode);
     // load the correct locale
     $locale =& Locales::getLocale($localeCode);
     return $locale;
 }
 /**
  * Performs the action.
  */
 function perform()
 {
     // fetch the articles for the given blog
     $articles = new Articles();
     $blogSettings = $this->_blogInfo->getSettings();
     $localeCode = $blogSettings->getValue("locale");
     // fetch the default profile as chosen by the administrator
     $defaultProfile = $this->_config->getValue("default_rss_profile");
     if ($defaultProfile == "" || $defaultProfile == null) {
         $defaultProfile = DEFAULT_PROFILE;
     }
     // fetch the profile
     // if the profile specified by the user is not valid, then we will
     // use the default profile as configured
     $profile = $this->_request->getValue("profile");
     if ($profile == "") {
         $profile = $defaultProfile;
     }
     // fetch the category, or set it to '0' otherwise, which will mean
     // fetch all the most recent posts from any category
     $categoryId = $this->_request->getValue("categoryId");
     if (!is_numeric($categoryId)) {
         $categoryId = 0;
     }
     // check if the template is available
     $this->_view = new RssView($this->_blogInfo, $profile, array("profile" => $profile, "categoryId" => $categoryId));
     // do nothing if the view was already cached
     if ($this->_view->isCached()) {
         return true;
     }
     // create an instance of a locale object
     $locale = Locales::getLocale($localeCode);
     // fetch the posts, though we are going to fetch the same amount in both branches
     $amount = $blogSettings->getValue("recent_posts_max", 15);
     $t = new Timestamp();
     if ($blogSettings->getValue('show_future_posts_in_calendar')) {
         $blogArticles = $articles->getBlogArticles($this->_blogInfo->getId(), -1, $amount, $categoryId, POST_STATUS_PUBLISHED, 0);
     } else {
         $today = $t->getTimestamp();
         $blogArticles = $articles->getBlogArticles($this->_blogInfo->getId(), -1, $amount, $categoryId, POST_STATUS_PUBLISHED, 0, $today);
     }
     $pm =& PluginManager::getPluginManager();
     $pm->setBlogInfo($this->_blogInfo);
     $pm->setUserInfo($this->_userInfo);
     $result = $pm->notifyEvent(EVENT_POSTS_LOADED, array('articles' => &$blogArticles));
     $articles = array();
     foreach ($blogArticles as $article) {
         $postText = $article->getIntroText();
         $postExtendedText = $article->getExtendedText();
         $pm->notifyEvent(EVENT_TEXT_FILTER, array("text" => &$postText));
         $pm->notifyEvent(EVENT_TEXT_FILTER, array("text" => &$postExtendedText));
         $article->setIntroText($postText);
         $article->setExtendedText($postExtendedText);
         array_push($articles, $article);
     }
     $this->_view->setValue("locale", $locale);
     $this->_view->setValue("posts", $articles);
     $this->setCommonData();
     return true;
 }
 /**
  * shortuct for formatting the date in the same way that it is expected by
  * the "date picker" javascript calendar
  *
  *�@return a string
  */
 function getDateFormatted()
 {
     include_once PLOG_CLASS_PATH . "class/locale/locales.class.php";
     $locale = Locales::getLocale("en_UK");
     $dateFormatted = $locale->formatDate($this->getDateObject(), "%d/%m/%Y %H:%M");
     return $dateFormatted;
 }
 function AdminArticleCommentsListView($blogInfo, $params = array())
 {
     $this->AdminTemplatedView($blogInfo, "editcomments");
     $blogSettings = $blogInfo->getSettings();
     $this->_locale =& Locales::getLocale($blogSettings->getValue("locale"), "en_UK");
     $this->_setParameters($params);
     $this->_page = $this->getCurrentPageFromRequest();
 }
 /**
  * @private
  */
 function _getLocale()
 {
     // load the Locale object from the view context or initialize it now
     if ($this->_params->keyExists("locale")) {
         $this->_locale = $this->_params->getValue("locale");
     } else {
         $config =& Config::getConfig();
         $this->_locale =& Locales::getLocale($config->getValue("default_locale"));
     }
 }
 /**
  * Carries out the specified action
  */
 function perform()
 {
     $this->_view = new AdminHelpView($this->_blogInfo);
     $blogSettings = $this->_blogInfo->getSettings();
     $locale =& Locales::getLocale($blogSettings->getValue("locale"));
     $this->_view->setValue("help", $locale->tr($this->_helpId));
     $this->setCommonData();
     // better to return true if everything fine
     return true;
 }
 function sendUncachedOutput()
 {
     //$templateService = new TemplateService();
     //$template = $templateService->Template( $this->_profile, "summary/rss" );
     $config =& Config::getConfig();
     $this->_locale =& Locales::getLocale($config->getValue("default_locale"));
     $this->_params->setValue("version", new Version());
     $this->_params->setValue("locale", $this->_locale);
     $this->_template->assign($this->_params->getAsArray());
     print $this->_template->fetch($this->_viewId);
 }
 /**
  * Constructor. If nothing else, it also has to call the constructor of the parent
  * class, BlogAction with the same parameters
  */
 function AdminLoginAction($actionInfo, $request)
 {
     $this->Action($actionInfo, $request);
     $this->_config =& Config::getConfig();
     $this->_locale =& Locales::getLocale($this->_config->getValue("default_locale"));
     // data validation
     $this->registerFieldValidator("userName", new StringValidator());
     $this->registerFieldValidator("userPassword", new StringValidator());
     $view = new AdminDefaultView();
     $view->setErrorMessage($this->_locale->tr("error_incorrect_username_or_password"));
     $this->setValidationErrorView($view);
 }
 function renderBodyTemplate($templateid, $templateFolder)
 {
     // create a new template service
     $ts = new TemplateService();
     $messageTemplate = $ts->Template($templateid, $templateFolder);
     $messageTemplate->assign("username", $this->username);
     $messageTemplate->assign("activeCode", $this->activeCode);
     $messageTemplate->assign("activeLink", $this->activeLink);
     // FIXME: use which locale?
     $locale =& Locales::getLocale();
     $messageTemplate->assign("locale", $locale);
     // render and return the contents
     return $messageTemplate->fetch();
 }
 /**
  * Reload the REST information.
  *
  * @author David Pauli <*****@*****.**>
  * @since 0.0.0
  * @since 0.0.1 Use HTTPRequestMethod enum.
  * @since 0.1.0 Use a default Locale.
  */
 private static function load()
 {
     // if request method is blocked
     if (!RESTClient::setRequestMethod(HTTPRequestMethod::GET)) {
         return;
     }
     $content = RESTClient::sendWithLocalization(self::$RESTPATH, Locales::getLocale());
     // if respond is empty
     if (InputValidator::isEmpty($content)) {
         return;
     }
     // reset values
     self::resetValues();
     if (!InputValidator::isEmptyArrayKey($content, "name")) {
         self::$NAME = $content["name"];
     }
     if (!InputValidator::isEmptyArrayKey($content, "title")) {
         self::$TITLE = $content["title"];
     }
     if (!InputValidator::isEmptyArrayKey($content, "navigationCaption")) {
         self::$NAVIGATIONCAPTION = $content["navigationCaption"];
     }
     if (!InputValidator::isEmptyArrayKey($content, "shortDescription")) {
         self::$SHORTDESCRIPTION = $content["shortDescription"];
     }
     if (!InputValidator::isEmptyArrayKey($content, "description")) {
         self::$DESCRIPTION = $content["description"];
     }
     if (!InputValidator::isEmptyArrayKey($content, "company")) {
         self::$COMPANY = $content["company"];
     }
     if (!InputValidator::isEmptyArrayKey($content, "contactPerson")) {
         self::$CONTACTPERSON = $content["contactPerson"];
     }
     if (!InputValidator::isEmptyArrayKey($content, "contactPersonJobTitle")) {
         self::$CONTACTPERSONJOBTITLE = $content["contactPersonJobTitle"];
     }
     if (!InputValidator::isEmptyArrayKey($content, "address")) {
         self::$ADDRESS = $content["address"];
     }
     if (!InputValidator::isEmptyArrayKey($content, "phone")) {
         self::$PHONE = $content["phone"];
     }
     if (!InputValidator::isEmptyArrayKey($content, "email")) {
         self::$EMAIL = $content["email"];
     }
     // update timestamp when make the next request
     $timestamp = (int) (microtime(true) * 1000);
     self::$NEXT_REQUEST_TIMESTAMP = $timestamp + RESTClient::NEXT_RESPONSE_WAIT_TIME;
 }
 /**
  * Renders the view. It simply gets all the parameters we've been adding to it
  * and puts them in the context of the template renderer so that they can be accessed
  * as normal parameters from within the template
  */
 function render()
 {
     parent::render();
     // to find the template we need, we can use the TemplateService
     $ts = new TemplateService();
     $template = $ts->AdminTemplate(ADMINLOGIN_TEMPLATE);
     // load the default locale
     $config =& Config::getConfig();
     $locale =& Locales::getLocale($config->getValue("default_locale"));
     $this->setValue("locale", $locale);
     // assign all the values
     $template->assign($this->_params->getAsArray());
     // and send the results
     print $template->fetch();
 }
 /**
  * Initializes the renderer
  *
  * @param menu A vaid Menu object
  * @param blogInfo A reference to a BlogInfo object containing information of the blog for whom
  * we are going to render this menu tree.
  * @param userInfo A reference to a UserInfo object containing information of the user for whom
  * we are going to render this menu tree, because we need to know which options he/she is allowed
  * to see and which not.
  */
 function MenuRenderer($menu, $blogInfo, $userInfo)
 {
     $this->Object();
     $this->_menu = $menu;
     $this->_blogInfo = $blogInfo;
     $this->_userInfo = $userInfo;
     $config =& Config::getConfig();
     // load the right locale
     if ($blogInfo != null) {
         $this->_locale =& $blogInfo->getLocale();
     } else {
         $localeCode = $config->getValue("default_locale");
         $this->_locale =& Locales::getLocale($localeCode);
     }
 }
 function perform()
 {
     // fetch the validated data
     $this->_blogName = Textfilter::filterAllHTML($this->_request->getValue("blogName"));
     $this->_ownerId = $this->_request->getValue("blogOwner");
     $this->_blogProperties = $this->_request->getValue("properties");
     // check that the user really exists
     $users = new Users();
     $userInfo = $users->getUserInfoFromId($this->_ownerId);
     if (!$userInfo) {
         $this->_view = new AdminCreateBlogView($this->_blogInfo);
         $this->_form->setFieldValidationStatus("blogOwner", false);
         $this->setCommonData(true);
         return false;
     }
     // now that we have validated the data, we can proceed to create the user, making
     // sure that it doesn't already exists
     $blogs = new Blogs();
     $blog = new BlogInfo($this->_blogName, $this->_ownerId, "", "");
     $blog->setProperties($this->_blogProperties);
     $this->notifyEvent(EVENT_PRE_BLOG_ADD, array("blog" => &$blog));
     $newBlogId = $blogs->addBlog($blog);
     if (!$newBlogId) {
         $this->_view = new AdminCreateBlogView($this->_blogInfo);
         $this->_form->setFieldValidationStatus("blogName", false);
         $this->setCommonData();
         return false;
     }
     // add a default category and a default post
     $articleCategories = new ArticleCategories();
     $articleCategory = new ArticleCategory("General", "", $newBlogId, true);
     $catId = $articleCategories->addArticleCategory($articleCategory);
     $config =& Config::getConfig();
     $locale =& Locales::getLocale($config->getValue("default_locale"));
     $articleTopic = $locale->tr("register_default_article_topic");
     $articleText = $locale->tr("register_default_article_text");
     $article = new Article($articleTopic, $articleText, array($catId), $this->_ownerId, $newBlogId, POST_STATUS_PUBLISHED, 0, array(), "welcome");
     $t = new Timestamp();
     $article->setDateObject($t);
     $articles = new Articles();
     $articles->addArticle($article);
     // and inform everyone that everything went ok
     $this->notifyEvent(EVENT_POST_BLOG_ADD, array("blog" => &$blog));
     $this->_view = new AdminSiteBlogsListView($this->_blogInfo);
     $this->_view->setSuccessMessage($this->_locale->pr("blog_added_ok", $blog->getBlog()));
     $this->setCommonData();
     return true;
 }
 /**
  * Renders the view. It simply gets all the parameters we've been adding to it
  * and puts them in the context of the template renderer so that they can be accessed
  * as normal parameters from within the template
  */
 function render()
 {
     // set the view character set based on the default locale
     $config =& Config::getConfig();
     $locale =& Locales::getLocale($config->getValue("default_locale"));
     $this->setCharset($locale->getCharset());
     parent::render();
     // to find the template we need, we can use the TemplateService
     $ts = new TemplateService();
     $template = $ts->AdminTemplate("dashboard");
     $this->setValue("locale", $locale);
     // assign all the values
     $template->assign($this->_params->getAsArray());
     // and send the results
     print $template->fetch();
 }
 function render()
 {
     // set the view character set based on the default locale
     $config =& Config::getConfig();
     $locale =& Locales::getLocale($config->getValue("default_locale"));
     $this->setValue('version', Version::getVersion());
     $this->setCharset($locale->getCharset());
     parent::render();
     // load the contents into the template context
     $ts = new TemplateService();
     $template = $ts->Template(ADMINSIMPLEMESSAGE_TEMPLATE, "admin");
     $this->setValue("locale", $locale);
     // and pass the values to the template
     $template->assign($this->_params->getAsArray());
     // finally, send the results
     print $template->fetch();
 }
 /**
  * Carries out the specified action
  */
 function perform()
 {
     $this->_view = new AdminDefaultView();
     $this->notifyEvent(EVENT_PRE_LOGOUT);
     // remove all the information from the session
     $session = HttpVars::getSession();
     $session["SessionInfo"] = null;
     unset($session["SessionInfo"]);
     $session = array();
     HttpVars::setSession($session);
     session_destroy();
     // and pass the locale to the template
     $config =& Config::getConfig();
     $locale =& Locales::getLocale($config->getValue("default_locale"));
     $url =& $this->_blogInfo->getBlogRequestGenerator();
     $blogTitle = $this->_blogInfo->getBlog();
     $logoutMessage = $this->_locale->tr("logout_message") . "<br/>" . $locale->pr("logout_message_2", $url->blogLink(), $blogTitle);
     $this->_view->setSuccessMessage($logoutMessage);
     $this->notifyEvent(EVENT_POST_LOGOUT);
     // better to return true if everything fine
     return true;
 }
 /**
  * Constructor.
  *
  * @param dayPosts An array indexed from 1 to as many days as the month where
  * every position tells how many posts were made that day.
  * @param localeCode A code specifying the locale we want to use. If empty, the default
  * one specified in the configuration file will be used.
  */
 function PlogCalendar($dayPosts = null, $blogInfo = null, $localeCode = null)
 {
     $this->Calendar();
     if ($localeCode == null) {
         $config = Config::getConfig();
         //$locale = new Locale( $config->getValue( "default_locale" ));
         $locale = Locales::getLocale($config->getValue("default_locale"));
     } else {
         //$locale = new Locale( $localeCode );
         $locale = Locales::getLocale($localeCode);
     }
     $this->_dayPosts = $dayPosts;
     $this->_blogInfo = $blogInfo;
     // set the first day of the week according to our locale
     $this->startDay = $locale->firstDayOfWeek();
     //array_push( $this->monthsNames, $locale->tr("January"));
     $this->monthNames = $locale->getMonthNames();
     // abbreviations of the days of the week
     $this->dayNamesShort = $locale->getDayNamesShort();
     // full names of the days of the week
     $this->dayNames = $locale->getDayNames();
     $this->rg = RequestGenerator::getRequestGenerator($blogInfo);
 }
예제 #19
0
 /**
  * Returns configured Locale.
  *
  * @author David Pauli <*****@*****.**>
  * @return String|null The Locale which is configured for REST calls.
  * @since 0.1.0
  * @since 0.1.2 Add error reporting.
  */
 public function getUsedLocale()
 {
     self::errorReset();
     return Locales::getLocale();
 }
예제 #20
0
 function perform()
 {
     // retrieve the values from the view
     $this->_blogName = $this->_request->getValue("blogName");
     $this->_ownerId = $this->_request->getValue("ownerid");
     $this->_blogProperties = $this->_request->getValue("properties");
     $this->_blogTemplate = $this->_request->getValue("blogTemplate");
     $this->_blogLocale = $this->_request->getValue("blogLocale");
     // configure the blog
     $blogs = new Blogs();
     $blog = new BlogInfo($this->_blogName, $this->_ownerId, "", "");
     $blog->setProperties($this->_blogProperties);
     $blog->setStatus(BLOG_STATUS_ACTIVE);
     $blogSettings = $blog->getSettings();
     $blogSettings->setValue("locale", $this->_blogLocale);
     $blogSettings->setValue("template", $this->_blogTemplate);
     $blog->setSettings($blogSettings);
     // and now save it to the database
     $newblogId = $blogs->addBlog($blog);
     if (!$newblogId) {
         $this->_view = new WizardView("step4");
         $this->_view->setValue("siteLocales", Locales::getLocales());
         $ts = new TemplateSets();
         $this->_view->setValue("siteTemplates", $ts->getGlobalTemplateSets());
         $this->_view->setErrorMessage("There was an error creating the new blog");
         $this->setCommonData(true);
         return false;
     }
     // if the blog was created, we can add some basic information
     // add a category
     $articleCategories = new ArticleCategories();
     $articleCategory = new ArticleCategory("General", "", $newblogId, true);
     $catId = $articleCategories->addArticleCategory($articleCategory);
     // load the right locale
     $locale =& Locales::getLocale($this->_blogLocale);
     // and load the right text
     $articleTopic = $locale->tr("register_default_article_topic");
     $articleText = $locale->tr("register_default_article_text");
     $article = new Article($articleTopic, $articleText, array($catId), $this->_ownerId, $newblogId, POST_STATUS_PUBLISHED, 0, array(), "welcome");
     $t = new Timestamp();
     $article->setDateObject($t);
     $articles = new Articles();
     $articles->addArticle($article);
     // save a few things in the default configuration
     $config =& Config::getConfig();
     // default blog id
     $config->saveValue("default_blog_id", (int) $newblogId);
     // default locale
     $config->saveValue("default_locale", $this->_blogLocale);
     // and finally, the default template
     $config->saveValue("default_template", $this->_blogTemplate);
     //
     // detect wether we have GD available and set the blog to use it
     //
     if (GdDetector::detectGd()) {
         $config->saveValue("thumbnail_method", "gd");
         $message = "GD has been detected and set as the backend for dealing with images.";
     } else {
         $pathToConvert = $config->getValue("path_to_convert");
         if ($pathToConvert) {
             $config->saveValue("thumbnail_method", "imagemagick");
             $message = "ImageMagick has been detected and set as the backend for dealing with images.";
         } else {
             // nothing was found, so we'll have to do away with the 'null' resizer...
             $config->saveValue("thumbnail_method", "null");
             $message = "Neither GD nor ImageMagick have been detected in this host so it will not be possible to generate thumbnails from images.";
         }
     }
     $this->_view = new WizardView("step5");
     $this->_view->setValue("message", $message);
     return true;
 }
 /**
  * sets the default locale, in case we want to send localized messages to the user.
  * @private
  */
 function &getLocale()
 {
     // don't like this so much...
     if ($this->_blogInfo != "") {
         $this->_blogSettings = $this->_blogInfo->getSettings();
         //$locale =& Locales::getLocale( $this->_blogSettings->getValue("locale"));
         $locale =& $this->_blogInfo->getLocale();
     } else {
         $locale =& Locales::getLocale($this->_config->getValue("default_locale"));
     }
     return $locale;
 }
 /**
  * create the blog
  */
 function createBlog($userId)
 {
     $this->blogName = stripslashes($this->_request->getValue("blogName"));
     $this->blogLocale = $this->_request->getValue("blogLocale");
     $this->templateId = $this->_request->getValue("templateId");
     // get the default locale configured for the site
     $blogs = new Blogs();
     $blogInfo = new BlogInfo($this->blogName, $userId, "", "");
     if ($this->need_confirm == 1) {
         $blogInfo->setStatus(BLOG_STATUS_UNCONFIRMED);
     } else {
         $blogInfo->setStatus(BLOG_STATUS_ACTIVE);
     }
     $locale = Locales::getLocale($this->blogLocale);
     $blogInfo->setLocale($locale);
     $blogInfo->setTemplate($this->templateId);
     $newblogId = $blogs->addBlog($blogInfo);
     if (!$newblogId) {
         $this->_view = new SummaryView("registererror");
         $this->_view->setErrorMessage($this->_locale->tr("error_creating_blog"));
         return false;
     }
     // get info about the blog
     $blogInfo = $blogs->getBlogInfo($newblogId);
     $this->_blogInfo = $blogInfo;
     // if the blog was created, we can add some basic information
     // add a category
     $articleCategories = new ArticleCategories();
     $articleCategory = new ArticleCategory($locale->tr("register_default_category"), "", $newblogId, true);
     $catId = $articleCategories->addArticleCategory($articleCategory);
     // add an article based on that category
     $articleTopic = $locale->tr("register_default_article_topic");
     $articleText = $locale->tr("register_default_article_text");
     $article = new Article($articleTopic, $articleText, array($catId), $userId, $newblogId, POST_STATUS_PUBLISHED, 0, array(), "welcome");
     $article->setDateObject(new Timestamp());
     // set it to the current date
     $article->setCommentsEnabled(true);
     // enable comments
     $articles = new Articles();
     $articles->addArticle($article);
     return true;
 }
예제 #23
0
 /**
  * This function returns the parameter as string.
  *
  * @author David Pauli <*****@*****.**>
  * @since 0.0.0
  * @since 0.1.0 Use a default Locale and Currency.
  * @api
  * @return String The parameter build with this product filter.
  */
 private function getParameter()
 {
     $parameter = array();
     array_push($parameter, "locale=" . Locales::getLocale());
     array_push($parameter, "currency=" . Currencies::getCurrency());
     if (!InputValidator::isEmpty($this->page)) {
         array_push($parameter, "page=" . $this->page);
     }
     if (!InputValidator::isEmpty($this->resultsPerPage)) {
         array_push($parameter, "resultsPerPage=" . $this->resultsPerPage);
     }
     if (!InputValidator::isEmpty($this->direction)) {
         array_push($parameter, "direction=" . $this->direction);
     }
     if (!InputValidator::isEmpty($this->sort)) {
         array_push($parameter, "sort=" . $this->sort);
     }
     if (!InputValidator::isEmpty($this->q)) {
         array_push($parameter, "q=" . $this->q);
     }
     if (!InputValidator::isEmpty($this->categoryID)) {
         array_push($parameter, "categoryId=" . $this->categoryID);
     }
     foreach ($this->IDs as $number => $id) {
         array_push($parameter, "id=" . $id);
     }
     return implode("&", $parameter);
 }
예제 #24
0
 /**
  * Returns configured Locale.
  *
  * @api
  * @author David Pauli <*****@*****.**>
  * @since 0.1.0
  * @return String|null The Locale which is configured for REST calls.
  */
 public function getLocale()
 {
     return Locales::getLocale();
 }
예제 #25
0
 /**
  * Loads the order.
  *
  * @author David Pauli <*****@*****.**>
  * @since 0.1.3
  * @since 0.2.1 Implement REST client fixes.
  */
 private function load()
 {
     // if parameter is wrong or GET is blocked
     if (!RESTClient::setRequestMethod(HTTPRequestMethod::GET)) {
         self::errorSet("RESTC-9");
         return;
     }
     RESTClient::sendWithLocalization(self::RESTPATH . "/" . $this->orderId, Locales::getLocale());
     $content = RESTClient::getJSONContent();
     // if respond is empty
     if (InputValidator::isEmpty($content)) {
         self::errorSet("OF-1");
         return;
     }
     $this->parseData($content);
     // update timestamp when make the next request
     $timestamp = (int) (microtime(true) * 1000);
     $this->NEXT_REQUEST_TIMESTAMP = $timestamp + RESTClient::$NEXT_RESPONSE_WAIT_TIME;
 }
예제 #26
0
 /**
  * returns the right locale object for the blog
  *
  * @param a Locale object
  */
 function &getLocale()
 {
     if ($this->_locale == null) {
         include_once PLOG_CLASS_PATH . "class/locale/locales.class.php";
         $this->_locale =& Locales::getLocale($this->_settings->getValue("locale"), "en_UK");
     }
     return $this->_locale;
 }
예제 #27
0
 /**
  * This function returns the parameter as string.
  *
  * @author David Pauli <*****@*****.**>
  * @return String The parameter build with this order filter.
  * @since 0.1.3
  * @since 0.2.1 Update build of parameter
  */
 private function getParameter()
 {
     $parameter = array();
     array_push($parameter, "locale=" . Locales::getLocale());
     array_push($parameter, "currency=" . Currencies::getCurrency());
     if (!InputValidator::isEmpty($this->createdAfterDate)) {
         array_push($parameter, "createdAfter=" . $this->createdAfterDate->asReadable());
     }
     if (!InputValidator::isEmpty($this->createdBeforeDate)) {
         array_push($parameter, "createdBefore=" . $this->createdBeforeDate->asReadable());
     }
     if (!InputValidator::isEmpty($this->customerId)) {
         array_push($parameter, "customerId=" . $this->customerId);
     }
     if (!InputValidator::isEmpty($this->isArchived)) {
         array_push($parameter, "archivedOn=" . $this->isArchived);
     }
     if (!InputValidator::isEmpty($this->isClosed)) {
         array_push($parameter, "closedOn=" . $this->isClosed);
     }
     if (!InputValidator::isEmpty($this->isDelivered)) {
         array_push($parameter, "deliveredOn=" . $this->isDelivered);
     }
     if (!InputValidator::isEmpty($this->isDispatched)) {
         array_push($parameter, "dispatchedOn=" . $this->isDispatched);
     }
     if (!InputValidator::isEmpty($this->isInvoiced)) {
         array_push($parameter, "invoicedOn=" . $this->isInvoiced);
     }
     if (!InputValidator::isEmpty($this->isPaid)) {
         array_push($parameter, "paidOn=" . $this->isPaid);
     }
     if (!InputValidator::isEmpty($this->isPending)) {
         array_push($parameter, "pendingOn=" . $this->isPending);
     }
     if (!InputValidator::isEmpty($this->isRejected)) {
         array_push($parameter, "rejectedOn=" . $this->isRejected);
     }
     if (!InputValidator::isEmpty($this->isReturned)) {
         array_push($parameter, "returnedOn=" . $this->isReturned);
     }
     if (!InputValidator::isEmpty($this->isViewed)) {
         array_push($parameter, "viewedOn=" . $this->isViewed);
     }
     if (!InputValidator::isEmpty($this->updatedFromDate)) {
         array_push($parameter, "updatedFrom=" . $this->updatedFromDate->asReadable());
     }
     if (!InputValidator::isEmpty($this->page)) {
         array_push($parameter, "page=" . $this->page);
     }
     if (!InputValidator::isEmpty($this->productId)) {
         array_push($parameter, "productId=" . $this->productId);
     }
     if (!InputValidator::isEmpty($this->resultsPerPage)) {
         array_push($parameter, "resultsPerPage=" . $this->resultsPerPage);
     }
     if (!InputValidator::isEmpty($this->sortLastUpdate)) {
         array_push($parameter, "sortLastUpdate=" . $this->sortLastUpdate);
     }
     return implode("&", $parameter);
 }
 /**
  * Carries out the specified action
  */
 function perform()
 {
     // fetch the settings from the db and update them accordingly
     $blogs = new Blogs();
     $blogSettings = $blogs->getBlogSettings($this->_blogInfo->getId());
     $blogSettings->setValue("locale", $this->_request->getValue("blogLocale"));
     $blogSettings->setValue("show_posts_max", $this->_request->getValue("blogMaxMainPageItems"));
     $blogSettings->setValue("recent_posts_max", $this->_request->getValue("blogMaxRecentItems"));
     $blogSettings->setValue("template", $this->_request->getValue("blogTemplate"));
     $blogSettings->setValue("time_offset", $this->_request->getValue("blogTimeOffset"));
     $blogSettings->setValue("categories_order", $this->_request->getValue("blogCategoriesOrder"));
     $blogSettings->setValue("link_categories_order", $this->_request->getValue("blogLinkCategoriesOrder"));
     $blogSettings->setValue("show_more_enabled", Textfilter::checkboxToBoolean($this->_request->getValue("blogShowMoreEnabled")));
     $blogSettings->setValue("htmlarea_enabled", Textfilter::checkboxToBoolean($this->_request->getValue("blogEnableHtmlarea")));
     $blogSettings->setValue("comments_enabled", Textfilter::checkboxToBoolean($this->_request->getValue("blogCommentsEnabled")));
     $blogSettings->setValue("show_future_posts_in_calendar", Textfilter::checkboxToBoolean($this->_request->getValue("blogShowFuturePosts")));
     $blogSettings->setValue("new_drafts_autosave_enabled", Textfilter::checkboxToBoolean($this->_request->getValue("blogEnableAutosaveDrafts")));
     $blogSettings->setValue("comments_order", $this->_request->getValue("blogCommentsOrder"));
     $this->_blogInfo->setAbout(Textfilter::filterAllHTML($this->_request->getValue("blogAbout")));
     $this->_blogInfo->setBlog(Textfilter::filterAllHTML($this->_request->getValue("blogName")));
     $this->_blogInfo->setSettings($blogSettings);
     $this->_blogInfo->setProperties($this->_request->getValue("properties"));
     $this->_blogInfo->setMangledBlog(Textfilter::urlize($this->_blogInfo->getBlog()));
     // and now update the settings in the database
     $blogs = new Blogs();
     // and now we can proceed...
     $this->notifyEvent(EVENT_PRE_BLOG_UPDATE, array("blog" => &$this->_blogInfo));
     if (!$blogs->updateBlog($this->_blogInfo->getId(), $this->_blogInfo)) {
         $this->_view = new AdminBlogSettingsView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_updating_settings"));
         $this->setCommonData();
         return false;
     }
     // do it again, baby :)))
     $this->_blogInfo->setAbout(Textfilter::filterAllHTML(stripslashes($this->_request->getValue("blogAbout"))));
     $this->_blogInfo->setBlog(Textfilter::filterAllHTML(stripslashes($this->_request->getValue("blogName"))));
     $this->_blogInfo->setSettings($blogSettings);
     $this->_blogInfo->setProperties($this->_blogProperties);
     $this->_session->setValue("blogInfo", $this->_blogInfo);
     $this->saveSession();
     $this->notifyEvent(EVENT_POST_BLOG_UPDATE, array("blog" => &$this->_blogInfo));
     $this->_view = new AdminBlogSettingsView($this->_blogInfo);
     $this->_locale =& Locales::getLocale($blogSettings->getValue("locale"));
     $this->_view->setSuccessMessage($this->_locale->pr("blog_settings_updated_ok", $this->_blogInfo->getBlog()));
     $this->setCommonData();
     // clear the cache
     CacheControl::resetBlogCache($this->_blogInfo->getId());
     // better to return true if everything fine
     return true;
 }