Beispiel #1
0
 public function handle()
 {
     $priorityLast = WP_PEPVN_PRIORITY_LAST;
     $moduleBackend = $this->di->get('moduleBackend');
     $hook = $this->di->getShared('hook');
     $register_admin_page = array();
     if ($hook->has_filter('register_admin_page')) {
         $register_admin_page = $hook->apply_filters('register_admin_page', $register_admin_page);
     }
     $register_admin_page = (array) $register_admin_page;
     $page = '';
     if (isset($_GET['page']) && $_GET['page']) {
         $page = $_GET['page'];
         $page = str_replace(WP_OPTIMIZE_BY_XTRAFFIC_PLUGIN_NS_SHORT . '_', '', $page);
         $page = trim($page);
     }
     if ($page) {
         $page = Text::camelize($page);
         if (isset($register_admin_page[$page])) {
             echo $moduleBackend->router_handle($page, $register_admin_page[$page])->getContent();
         } else {
             echo $moduleBackend->router_handle($page)->getContent();
         }
     }
     unset($register_admin_page);
 }
Beispiel #2
0
 /**
  * Gets a value from the internal related entity or from the default value
  *
  * @param string name
  * @return mixed
  */
 public function getValue($name)
 {
     $entity = $this->_entity;
     $data = $this->_data;
     /**
      * Check if form has a getter
      */
     if (method_exists($this, "getCustomValue")) {
         return $this->{"getCustomValue"}($name, $entity, $data);
     }
     if (is_object($entity)) {
         /**
          * Check if the entity has a getter
          */
         $method = "get" . Text::camelize($name);
         if (method_exists($entity, $method)) {
             return $entity->{$method}();
         }
         /**
          * Check if the entity has a public property
          */
         if (isset($entity->{$name})) {
             return $entity->{$name};
         }
     }
     if (is_array($data)) {
         /**
          * Check if the data is in the data array
          */
         if (isset($data[$name])) {
             return $value;
         }
     }
     /**
      * Check if form has a getter
      */
     $method = "get" . Text::camelize($name);
     if (method_exists($this, $method)) {
         return $this->{$method}();
     }
     return null;
 }
Beispiel #3
0
 public function handle($uri = null)
 {
     if (null === $uri) {
         $uri = isset($_GET[$this->_get_uri_key]) ? $_GET[$this->_get_uri_key] : null;
     }
     if (null !== $uri) {
         $uri = rtrim($uri, '/');
         $uri = filter_var($uri, FILTER_SANITIZE_URL);
         $this->_uri = explode('/', $uri);
         $this->_requestMethod = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET';
         $this->_requestMethod = strtoupper($this->_requestMethod);
         if (isset($this->_uri[0]) && !empty($this->_uri[0])) {
             $this->_activeControllerName = $this->_uri[0];
         } else {
             $this->_activeControllerName = $this->_defaultController;
         }
         $this->_activeControllerName = Text::camelize($this->_activeControllerName);
         if (isset($this->_uri[1]) && !empty($this->_uri[1])) {
             $this->_activeActionName = $this->_uri[1];
         } else {
             $this->_activeActionName = $this->_defaultAction;
         }
         $this->_activeActionName = Text::camelize($this->_activeActionName);
         if (isset($this->_uri[2])) {
             $this->_activeParams = $this->_uri;
             unset($this->_activeParams[0]);
             unset($this->_activeParams[1]);
             $this->_activeParams = array_values($this->_activeParams);
         }
         $this->run();
     }
 }
Beispiel #4
0
 public static function cleanRawTextForProcessSearch($input_text)
 {
     $input_text = (array) $input_text;
     $input_text = implode(' ', $input_text);
     $input_text = self::decodeText($input_text);
     $input_text = strip_tags($input_text);
     $input_text = PepVN_Data::strtolower($input_text);
     $input_text = self::analysisKeyword_RemovePunctuations($input_text);
     $input_text = Text::replaceSpecialChar($input_text);
     $input_text = PepVN_Data::reduceSpace($input_text);
     return $input_text;
 }
Beispiel #5
0
 public static function safeFileName($filename)
 {
     $pathInfo = pathinfo($filename);
     if (isset($pathInfo['extension']) && isset($pathInfo['filename'])) {
         $pathInfo['filename'] = preg_replace('#[\\.]+#i', ' ', $pathInfo['filename']);
         $pathInfo['extension'] = preg_replace('#[\\.]+#i', '.', $pathInfo['extension']);
         $pathInfo['filename'] = Text::toSlug($pathInfo['filename']);
         if (isset($pathInfo['dirname'])) {
             $filename = $pathInfo['dirname'] . DIRECTORY_SEPARATOR . $pathInfo['filename'] . '.' . $pathInfo['extension'];
         } else {
             $filename = $pathInfo['filename'] . '.' . $pathInfo['extension'];
         }
     } else {
         $filename = Text::toSlug($filename);
     }
     return $filename;
 }
Beispiel #6
0
    {
        $pattern = '`~!@#$%^&*()-_=+{}[]\\\\|;:\'",.<>/?+';
        if (!empty($input_except)) {
            $pattern = preg_replace('#[' . preg_quote($input_except, '#') . ']+#is', '', $pattern);
        }
        return preg_replace('#[' . preg_quote($pattern, '#') . ']+#is', $input_replace_char, $input_text);
    }
    public static function removeShortcode($string, $replace = '')
    {
        $string = preg_replace('#\\[([a-z0-9\\_]+)[^\\]]*\\](\\[/\\1\\])?#is', $replace, $string);
        $string = trim($string);
        return $string;
    }
    public static function removeVietnameseMark($text)
    {
        foreach (self::$defaultParams['vietnamese_chars'] as $key1 => $value1) {
            $text = str_replace($value1['mark'], $value1['unmark'], $text);
            unset($key1, $value1);
        }
        reset(self::$defaultParams['vietnamese_chars']);
        return $text;
    }
    public static function decodeText($input_text)
    {
        $input_text = rawurldecode($input_text);
        $input_text = html_entity_decode($input_text, ENT_QUOTES, 'UTF-8');
        return $input_text;
    }
}
Text::setDefaultParams();
Beispiel #7
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;
 }
 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;
 }
Beispiel #9
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;
 }