Пример #1
0
 /**
  * 
  * init by post data
  */
 public function initByPostData($postData, $sliderID, $imgSourceType = UniteFunctionsWPBiz::THUMB_MEDIUM, $ratio = 'none', $refresh = 'false')
 {
     $postID = $postData["ID"];
     $this->slideType = self::TYPE_POST;
     $this->id = $postID;
     $this->sliderID = $sliderID;
     $this->slideOrder = $postData["menu_order"];
     $params = array();
     $params["title"] = UniteFunctionsBiz::getVal($postData, "post_title");
     $params["alias"] = UniteFunctionsBiz::getVal($postData, "post_name");
     $params["slide_text"] = UniteFunctionsBiz::getVal($postData, "post_content");
     $params["link"] = get_permalink($postID);
     $postDate = UniteFunctionsBiz::getVal($postData, "post_date_gmt");
     $dateModified = UniteFunctionsBiz::getVal($postData, "post_modified");
     $params["date"] = UniteFunctionsWPBiz::convertPostDate($postDate);
     $params["date_modified"] = UniteFunctionsWPBiz::convertPostDate($dateModified);
     //add author name
     $authorID = UniteFunctionsBiz::getVal($postData, "post_author");
     $params["author_id"] = $authorID;
     $params["author_name"] = UniteFunctionsWPBiz::getUserDisplayName($authorID);
     $params["num_comments"] = UniteFunctionsBiz::getVal($postData, "comment_count");
     //get categories and tags
     $postCatsIDs = $postData["post_category"];
     $params["catlist"] = UniteFunctionsWPBiz::getCategoriesHtmlList($postCatsIDs);
     $params["taglist"] = UniteFunctionsWPBiz::getTagsHtmlList($postID);
     $status = $postData["post_status"];
     if ($status == "publish") {
         $params["state"] = "published";
     } else {
         $params["state"] = "unpublished";
     }
     //get wildcards settings
     $objWildcards = new ShowBizWildcards();
     $settings = $objWildcards->getWildcardsSettings(true);
     $settings->updateValuesFromPostMeta($postID);
     $arrWildcardsValues = $settings->getArrValues();
     $params = array_merge($params, $arrWildcardsValues);
     //get the excerpt:
     $customLimit = UniteFunctionsBiz::getVal($params, "showbiz_excerpt_limit");
     $customLimit = (int) $customLimit;
     if (!empty($customLimit)) {
         $excerpt_limit = $customLimit;
     } else {
         $excerpt_limit = $this->getSliderParam($sliderID, "excerpt_limit", 55, ShowBizSlider::VALIDATE_NUMERIC);
         $excerpt_limit = (int) $excerpt_limit;
     }
     $delimiter = $this->getSliderParam($sliderID, "word_end", ' ');
     if ($delimiter == '') {
         $delimiter = ' ';
     }
     $limit_type = $this->getSliderParam($sliderID, "limit_by_type", 'words');
     $params["excerpt"] = UniteFunctionsWPBiz::getExcerptById($postID, $excerpt_limit, $delimiter, $limit_type);
     $title_limit = $this->getSliderParam($sliderID, "title_limit", 99, ShowBizSlider::VALIDATE_NUMERIC);
     if ($limit_type == 'words') {
         $params["title"] = UniteFunctionsBiz::getTextIntro($params["title"], $title_limit, $delimiter);
     } else {
         $params["title"] = UniteFunctionsBiz::getTextIntroChar($params["title"], $title_limit);
     }
     //Lazy Load Settings
     $params["lazy_load"] = $this->getSliderParam($sliderID, "enable_lazy_load", 'off');
     $params["lazy_load_height"] = $this->getSliderParam($sliderID, "lazy_load_height", 100, ShowBizSlider::VALIDATE_NUMERIC);
     $params["lazy_load_image"] = $this->getSliderParam($sliderID, "lazy_load_image", '');
     //init image url
     $thumbID = UniteFunctionsWPBiz::getPostThumbID($postID);
     $this->initImageParams($thumbID, $imgSourceType, $ratio, $refresh);
     $this->params = $params;
     //dmp($this->params);exit();
 }