Exemplo n.º 1
0
 public static function analysisKeyword_PrepareContents($text)
 {
     $keyCache1 = Utils::hashKey(array(__CLASS__ . __METHOD__, $text));
     $tmp = TempDataAndCacheFile::get_cache($keyCache1);
     if (null !== $tmp) {
         return $tmp;
     }
     $text = (array) $text;
     $text = implode(' ', $text);
     $text = self::decodeText($text);
     $text = strip_tags($text);
     //$text = PepVN_Data::strtolower($text);
     $text = self::analysisKeyword_RemovePunctuations($text);
     $text = Text::reduceSpace($text);
     TempDataAndCacheFile::set_cache($keyCache1, $text);
     return $text;
 }
Exemplo n.º 2
0
 private function _clean_terms($input_terms)
 {
     $keyCache1 = Utils::hashKey(array(__METHOD__, $input_terms));
     $resultData = TempDataAndCacheFile::get_cache($keyCache1);
     if (null !== $resultData) {
         return $resultData;
     }
     $input_terms = (array) $input_terms;
     $input_terms = implode(';', $input_terms);
     $input_terms = PepVN_Data::strtolower($input_terms);
     $input_terms = AnalyzeText::analysisKeyword_RemovePunctuations($input_terms, ';');
     $input_terms = Text::reduceSpace($input_terms);
     $input_terms = explode(';', $input_terms);
     $input_terms = PepVN_Data::cleanArray($input_terms);
     TempDataAndCacheFile::set_cache($keyCache1, $input_terms);
     return $input_terms;
 }
Exemplo n.º 3
0
 public function parse_custom_tag_of_image($input_parameters)
 {
     $keyCache1 = Utils::hashKey(array(__CLASS__, __METHOD__, $input_parameters));
     $input_raw_tag = TempDataAndCacheFile::get_cache($keyCache1);
     if (null === $input_raw_tag) {
         $input_raw_tag = '';
         if (isset($input_parameters['raw_tag']) && $input_parameters['raw_tag']) {
             $input_raw_tag = $input_parameters['raw_tag'];
             $input_raw_tag = (string) $input_raw_tag;
             $input_raw_tag = trim($input_raw_tag);
             $patterns = $this->_get_patterns_for_parse_custom_tag_of_image($input_parameters);
             if ($patterns && is_array($patterns)) {
                 if (!empty($patterns)) {
                     $input_raw_tag = str_replace(array_keys($patterns), array_values($patterns), $input_raw_tag);
                 }
             }
             $input_raw_tag = preg_replace('#[% \\s]+#is', ' ', $input_raw_tag);
             $input_raw_tag = Utils::removeQuotes($input_raw_tag);
             $input_raw_tag = preg_replace('#^[\\- \\s]+#is', '', $input_raw_tag);
             $input_raw_tag = preg_replace('#[\\- \\s]+$#is', '', $input_raw_tag);
             $input_raw_tag = preg_replace('#[\\-]+[\\s ]+[\\-]+#is', ' - ', $input_raw_tag);
             $input_raw_tag = Text::reduceSpace($input_raw_tag);
             $input_raw_tag = trim($input_raw_tag);
         }
         TempDataAndCacheFile::set_cache($keyCache1, $input_raw_tag);
     }
     return $input_raw_tag;
 }
Exemplo n.º 4
0
 public function parsePostData($post)
 {
     if (is_object($post)) {
         $post = (array) $post;
     }
     $post['ID'] = (int) $post['ID'];
     $keyCache1 = Utils::hashKey(array(__CLASS__, __METHOD__, $post['ID']));
     $tmp = PepVN_Data::$cacheObject->get_cache($keyCache1);
     if (null !== $tmp) {
         return $tmp;
     }
     if (!isset($post['post_excerpt']) || !$post['post_excerpt']) {
         $post['post_excerpt'] = $post['post_content'];
     }
     $post['post_excerpt'] = Text::removeShortcode($post['post_excerpt'], ' ');
     $post['post_excerpt'] = strip_tags($post['post_excerpt']);
     $post['post_excerpt'] = Text::removeLine($post['post_excerpt'], ' ');
     $post['post_excerpt'] = Text::reduceLine($post['post_excerpt'], ' ');
     $post['post_excerpt'] = explode(' ', $post['post_excerpt'], 250);
     if (isset($post['post_excerpt'][251])) {
         $post['post_excerpt'][251] = '...';
     }
     $post['post_excerpt'] = implode(' ', $post['post_excerpt']);
     $post['postPermalink'] = $this->get_permalink($post['ID']);
     $post['postImages'] = array();
     preg_match_all('#<img[^>]+src=(\'|\\")([^\'\\"]+)\\1[^>]+\\/?>#is', $post['post_content'], $matched1);
     if (isset($matched1[2]) && $matched1[2]) {
         foreach ($matched1[2] as $key1 => $value1) {
             $post['postImages'][] = array('src' => $value1);
         }
     }
     $post['postThumbnailId'] = 0;
     $post['postThumbnailUrl'] = '';
     $post_thumbnail_id = $this->get_post_thumbnail_id($post['ID']);
     if ($post_thumbnail_id) {
         $post['postThumbnailId'] = $post_thumbnail_id;
         $post_thumbnail_url = $this->wp_get_attachment_url($post_thumbnail_id);
         if ($post_thumbnail_url) {
             $post['postThumbnailUrl'] = $post_thumbnail_url;
             $post['postImages'][] = array('src' => $post_thumbnail_url);
         }
     }
     $post['postThumbnailId'] = (int) $post['postThumbnailId'];
     $post['postThumbnailUrl'] = trim($post['postThumbnailUrl']);
     $post['postAttachments'] = array();
     $attachments = get_posts(array('post_type' => 'attachment', 'posts_per_page' => -1, 'post_parent' => $post['ID']));
     if ($attachments) {
         foreach ($attachments as $key1 => $attachment) {
             unset($attachments[$key1]);
             $tmp = array('ID' => $attachment->ID, 'post_mime_type' => $attachment->post_mime_type, 'post_title' => $attachment->post_title);
             $tmp['attachment_url'] = $this->wp_get_attachment_url($attachment->ID);
             $tmp['metadata'] = wp_get_attachment_metadata($attachment->ID, true);
             $post['postAttachments'][$attachment->ID] = $tmp;
             unset($attachment, $tmp);
         }
     }
     $post['postContentRawText'] = $post['post_content'];
     $post['postContentRawText'] = strip_tags($post['postContentRawText']);
     $post['postContentRawText'] = Text::reduceLine($post['postContentRawText']);
     $post['postContentRawText'] = Text::reduceSpace($post['postContentRawText']);
     //unset($post['post_content']);
     PepVN_Data::$cacheObject->set_cache($keyCache1, $post);
     return $post;
 }