public static function get_slides($args) { $args = su_parse_args($args, array('source' => 'none', 'limit' => 20, 'offset' => 0, 'gallery' => null, 'type' => '', 'order' => '', 'order_by' => 'desc', 'link' => 'attachment')); // Prepare empty array for slides $slides = array(); // Loop through source types foreach (array('media', 'posts', 'category', 'k2-category') as $type) { if (strpos(trim($args['source']), $type . ':') === 0) { $args['source'] = array('type' => $type, 'val' => (string) trim(str_replace(array($type . ':', ' '), '', $args['source']), ',')); break; } } // Source is not parsed correctly, return empty array if (!is_array($args['source'])) { return $slides; } // Source: media if ($args['source']['type'] === 'media') { $images = (array) explode(',', $args['source']['val']); foreach ($images as $post) { $slide = array('image' => $post, 'link' => $post, 'url' => $post, 'title' => '', 'text' => $post); if ($args['link'] === 'image') { $slide['link'] = $slide['image']; } $slides[] = $slide; } return $slides; } elseif ($args['source']['type'] === 'category') { $catid = (array) explode(',', $args['source']['val']); $order = $args['order']; // title/created/ordering/hits $order_by = $args['order_by']; // asc/desc if ($order == '') { $orderby = ''; } else { if ($order == 'title') { $orderby = 'a.title ' . $order_by . ' '; } else { if ($order == 'created') { $orderby = 'a.created ' . $order_by . ' '; } else { if ($order == 'modified') { $orderby = 'a.modified ' . $order_by . ' '; } else { if ($order == 'publish_up') { $orderby = 'a.publish_up ' . $order_by . ' '; } else { if ($order == 'ordering') { $orderby = 'a.ordering ' . $order_by . ' '; } else { if ($order == 'hits') { $orderby = 'a.hits ' . $order_by . ' '; } } } } } } } $results = self::getArticles($catid, $order, $orderby, $args['limit'], $args['offset']); } elseif ($args['source']['type'] === 'k2-category') { $catid = (array) explode(',', $args['source']['val']); $order = $args['order']; // title/created/ordering/hits $order_by = $args['order_by']; // asc/desc if ($order == '') { $orderby = ''; } else { if ($order == 'title') { $orderby = 'a.title ' . $order_by . ' '; } else { if ($order == 'created') { $orderby = 'a.created ' . $order_by . ' '; } else { if ($order == 'modified') { $orderby = 'a.modified ' . $order_by . ' '; } else { if ($order == 'publish_up') { $orderby = 'a.publish_up ' . $order_by . ' '; } else { if ($order == 'ordering') { $orderby = 'a.ordering ' . $order_by . ' '; } else { if ($order == 'hits') { $orderby = 'a.hits ' . $order_by . ' '; } } } } } } } $results = self::get_k2_Articles($catid, $order, $orderby, $args['limit'], $args['offset']); } // Loop through posts if (is_array($results)) { foreach ($results as $post) { // Get post thumbnail ID if ($args['source']['type'] === 'k2-category') { $k2_img = JPATH_SITE . '/media/k2/items/cache/' . md5("Image" . $post->id) . '_XL.jpg'; if (file_exists($k2_img)) { $thumb = 'media/k2/items/cache/' . md5("Image" . $post->id) . '_XL.jpg'; } else { $thumb = null; } $link = K2HelperRoute::getItemRoute($post->id . ':' . urlencode($post->alias), $post->catid . ':' . urlencode($post->categoryalias)); } elseif ($args['source']['type'] === 'category') { $thumb = get_post_image($post); $slug = $post->id . ':' . $post->alias; $catslug = $post->catid . ':' . $post->category_alias; $link = JRoute::_(ContentHelperRoute::getArticleRoute($slug, $catslug)); } elseif ($args['source']['type'] === 'media') { $thumb = $post->id; $link = $slide['image']; } else { $thumb = null; } // post array $slide = array('id' => $post->id, 'alias' => $post->alias, 'created_by' => $post->created_by, 'category' => $post->category_title, 'title' => $post->title, 'introtext' => $post->introtext, 'fulltext' => $post->fulltext, 'image' => $thumb, 'link' => $link, 'created' => $post->created, 'hits' => $post->hits); $slides[] = $slide; } } // Return slides return $slides; }
public static function textarea($id, $field) { $field = su_parse_args($field, array('rows' => 3, 'default' => '')); $return = '<textarea name="' . $id . '" id="su-generator-attr-' . $id . '" rows="' . $field['rows'] . '" class="su-generator-attr">' . esc_textarea($field['default']) . '</textarea>'; return $return; }