/**
  * Extracts the keywords or tags from the articles. The tags are used if the parameter "tags" is entered in the syntax call.
  *
  * @param array $articles - Array of possible articles
  *
  * @return array $keyword_list - List of allowed keywords
  */
 private function keywordsData($articles)
 {
     $keywords_list = array();
     foreach ($articles as $article) {
         if (empty($this->eks_parameters['tags'])) {
             if (!empty($article->metakey)) {
                 $metakey_array = array_map('trim', explode(',', $article->metakey));
                 foreach ($metakey_array as $metakey) {
                     $keywords_list[String::ucfirst($metakey)][] = $article;
                 }
             }
         } else {
             $tags_helper = new JHelperTags();
             $tags = $tags_helper->getItemTags('com_content.article', $article->id);
             if (!empty($tags)) {
                 foreach ($tags as $tag) {
                     $keywords_list[String::ucfirst($tag->title)][] = $article;
                 }
             }
         }
     }
     ksort($keywords_list);
     if (!empty($this->eks_parameters['keyword'])) {
         foreach ($keywords_list as $key => $value) {
             if (is_array($this->eks_parameters['keyword'])) {
                 if (!in_array(String::strtolower($key), $this->eks_parameters['keyword'])) {
                     unset($keywords_list[$key]);
                     continue;
                 }
             } else {
                 if (String::strtolower($key) != String::strtolower($this->eks_parameters['keyword'])) {
                     unset($keywords_list[$key]);
                     continue;
                 }
             }
         }
     } elseif (!empty($this->eks_parameters['nokeyword'])) {
         foreach ($keywords_list as $key => $value) {
             if (is_array($this->eks_parameters['nokeyword'])) {
                 if (in_array(String::strtolower($key), $this->eks_parameters['nokeyword'])) {
                     unset($keywords_list[$key]);
                     continue;
                 }
             } else {
                 if (String::strtolower($key) == String::strtolower($this->eks_parameters['nokeyword'])) {
                     unset($keywords_list[$key]);
                     continue;
                 }
             }
         }
     }
     return $keywords_list;
 }
예제 #2
0
 /**
  * Method to instantiate the form field object.
  *
  * @param   Form  $form  The form to attach to the form field object.
  *
  * @since   1.0
  */
 public function __construct(Form $form = null)
 {
     // If there is a form passed into the constructor set the form and form control properties.
     if ($form instanceof Form) {
         $this->form = $form;
         $this->formControl = $form->getFormControl();
     }
     // Detect the field type if not set
     if (!isset($this->type)) {
         $parts = Normalise::fromCamelCase(get_called_class(), true);
         if ($parts[0] == 'J') {
             $this->type = String::ucfirst($parts[count($parts) - 1], '_');
         } else {
             $this->type = String::ucfirst($parts[0], '_') . String::ucfirst($parts[count($parts) - 1], '_');
         }
     }
 }
 /**
  * Load a class for one of the form's entities of a particular type.
  * Currently, it makes sense to use this method for the "field" and "rule" entities
  * (but you can support more entities in your subclass).
  *
  * @param   string  $entity  One of the form entities (field or rule).
  * @param   string  $type    Type of an entity.
  *
  * @return  mixed  Class name on success or false otherwise.
  *
  * @since   11.1
  */
 protected static function loadClass($entity, $type)
 {
     if (strpos($type, '.')) {
         list($prefix, $type) = explode('.', $type);
     } else {
         $prefix = 'J';
     }
     $class = String::ucfirst($prefix, '_') . 'Form' . String::ucfirst($entity, '_') . String::ucfirst($type, '_');
     if (class_exists($class)) {
         return $class;
     }
     // Get the field search path array.
     $paths = self::addPath($entity);
     // If the type is complex, add the base type to the paths.
     if ($pos = strpos($type, '_')) {
         // Add the complex type prefix to the paths.
         for ($i = 0, $n = count($paths); $i < $n; $i++) {
             // Derive the new path.
             $path = $paths[$i] . '/' . strtolower(substr($type, 0, $pos));
             // If the path does not exist, add it.
             if (!in_array($path, $paths)) {
                 $paths[] = $path;
             }
         }
         // Break off the end of the complex type.
         $type = substr($type, $pos + 1);
     }
     // Try to find the class file.
     $type = strtolower($type) . '.php';
     foreach ($paths as $path) {
         if ($file = Path::find($path, $type)) {
             require_once $file;
             if (class_exists($class)) {
                 break;
             }
         }
     }
     // Check for all if the class exists.
     return class_exists($class) ? $class : false;
 }