/** * autoThumb * * @param string $context * @param object $article * @param \JRegistry $params * * @return void */ public static function autoThumb($context, $article, $params = null) { \JHtmlBehavior::modal(); $minimal = 30; $es = \Ezset::getInstance(); include_once EZSET_ROOT . '/lib/dom/simple_html_dom.php'; $html = str_get_html($article->text); $imgs = $html->find('img'); foreach ($imgs as $img) { $classes = explode(' ', $img->class); $imgUrl = UriHelper::pathAddHost($img->src); // Has class nothumb, skip to next. if (in_array('nothumb', $classes)) { continue; } // If is anchor already, skip to next. if ($img->parent->tag == 'a') { continue; } // If img tag has no width and height attrs, skip. if (!$img->width && !$img->height) { continue; } // If not localhost image, skip. if (!strpos('-' . $imgUrl, \JURI::root()) && $es->params->get('onlyLocalhostThumb', 1)) { continue; } // Get img path and size $imgPath = \JPath::clean(str_replace(\JURI::root(), JPATH_ROOT . '/', $imgUrl)); $size = getimagesize($imgPath); // Manul size $imgW = $img->width; $imgH = $img->height; // Original size $oriW = $size[0]; $oriH = $size[1]; // If too small, skip. if ($oriW <= $minimal || $oriH <= $minimal) { continue; } // If large ten origin, skip. if ($oriW <= $imgW || $oriW <= $imgW) { continue; } // Get thumb url $thumb = new \Windwalker\Image\Thumb(); $img->src = $thumb->resize($imgUrl, $imgW, $imgH); $imgtext = $img->outertext; $imgtext = \JHtml::link($imgUrl, $imgtext, array('class' => 'modal')); $img->outertext = $imgtext; $classes = null; } $article->text = $html->save(); }
if (!$menu->link) { continue; } if (in_array($menu->type, array('alias', 'url'))) { continue; } // Fix URI bugs $uri = new JUri($menu->link); $uri->setVar('Itemid', $menu->id); if ($app->get('sef')) { $uri->setVar('layout', null); } $link = JRoute::_($uri->toString()); $host = str_replace('http://' . $_SERVER['HTTP_HOST'], '', JUri::root()); $link = str_replace($host, '', $link); $link = UriHelper::pathAddHost($link); // Set xml data $sitemap->addItem($link, '0.8', 'weekly', $date); $linkCache[] = $link; } // Build category map $query = $db->getQuery(true); $query->select("*")->from("#__categories")->where("id != 1")->where("published = 1")->where("access = 1")->where("extension = 'com_content'"); if ($locale) { $query->where($query->format('language IN (%q, %q)', $locale, '*')); } $db->setQuery($query); $cats = $db->loadObjectList(); foreach ($cats as $cat) { // Get category link $link = ArticleHelper::getCategoryLink($cat->id);
/** * The method to test UriHelper::pathAddHost. * * @param string $expected * @param string $path * * @return void * * @dataProvider pathDataProvider * @covers Windwalker\Helper\UriHelper::pathAddHost * @group pathAddHost */ public function testPathAddHost($expected, $path) { $this->assertSame($expected, UriHelper::pathAddHost($path)); }
/** * register * * @return void */ public static function register() { $easyset = \Ezset::getInstance(); $doc = \JFactory::getDocument(); if ($easyset->app->isAdmin() || $doc->getType() != 'html') { return; } /** @var $params \JRegistry */ $params = $easyset->params; $config = \JFactory::getConfig(); $siteName = $config->get('sitename'); $metaDesc = ''; if ($params->get('getMeta')) { if ($easyset->data->metaDesc) { $doc->setDescription($easyset->data->metaDesc); } } // SEO Title $easyset->call(array('Seo\\ContentSeo', 'setTitle')); if ($params->get('titleFix') && $easyset->data->siteTitle) { $doc->setTitle($easyset->data->siteTitle); } // Set Generator if ($generator = $params->get('generator')) { $doc->setGenerator($generator); } // Set Open Graph if ($params->get('openGraph', 1)) { $meta = array(); // Og:image if (\Ezset::isHome()) { if ($params->get('ogDefaultImage')) { $meta[] = '<meta property="og:image" content="' . UriHelper::pathAddHost($params->get('ogDefaultImage')) . '"/>'; } } elseif ($easyset->data->ogImages) { $count = $params->get('ogGetInnerPageImageCount', 1); foreach ($easyset->data->ogImages as $k => $image) { if ($k + 1 > $count) { break; } $meta[] = '<meta property="og:image" content="' . UriHelper::pathAddHost($image) . '"/>'; } } // Others $url = $doc->getBase() ?: \JUri::base(); $admin_id = $params->get('ogAdminId'); $page_id = $params->get('ogPageId'); $app_id = $params->get('ogAppId'); $title = $params->get('ogOnlyTitle', 1) && !\Ezset::isHome() ? $easyset->data->originTitle : $doc->getTitle(); $meta[] = '<meta property="og:title" content="' . $title . '"/>'; $meta[] = '<meta property="og:site_name" content="' . $siteName . '"/>'; if ($metaDesc) { $meta[] = '<meta property="og:description" content="' . $metaDesc . '"/>'; } $meta[] = '<meta property="og:url" content="' . $url . '"/>'; // Admin, page, user ids if ($admin_id) { $meta[] = '<meta property="fb:admins" content="' . $admin_id . '"/>'; } if ($page_id) { $meta[] = '<meta property="fb:page_id" content="' . $page_id . '"/>'; } if ($app_id) { $meta[] = '<meta property="fb:app_id" content="' . $app_id . '"/>'; } foreach ($meta as $v) { /** @var $doc \JDocumentHtml */ $doc->addCustomTag($v); } } }
/** * setOpenGraph * * @param string $context * @param object $article * * @return void */ public static function setOpenGraph($context, $article) { $es = \Ezset::getInstance(); $input = \JFactory::getApplication()->input; $view = $input->get('view'); if (empty($article->id)) { return; } if (!$es->params->get('ogGetInnerPageImage', 1)) { return; } if ('article' == $view) { $images = new \JRegistry($article->images); $ignoreFirst = false; $imgs = array(); $img = $images->get('image_fulltext', $images->get('image_intro')); if ($img) { $imgs[] = $img; } if ($imgs) { $ignoreFirst = true; } $dom = new Dom(); // If first image = main image, delete this paragraph. $dom->load($article->text); $images = $dom->find('img'); foreach ($images as $image) { if ($ignoreFirst) { continue; } $imgs[] = $image->src; } if (!$imgs && isset($article->catid)) { $cat = \JTable::getInstance('category'); $cat->load($article->catid); $cat->params = new \JRegistry($cat->params); $imgs[] = $cat->params->get('image'); } if (!$imgs && !$es->params->get('ogDefaultImageOnlyFrontPage', 1)) { $imgs[] = UriHelper::pathAddHost($es->params->get('ogDefaultImage')); } $es->data->ogImages = $imgs; } elseif ('category' == $view) { if (static::$once) { $cat = \JTable::getInstance('category'); $cat->load($input->get('id')); $cat->params = new \JRegistry($cat->params); $img = $cat->params->get('image'); if ($img) { $es->ogImage = $img; } elseif (!$es->params->get('ogDefaultImageOnlyFrontPage', 1)) { $es->ogImage = $es->params->get('ogDefaultImage'); } $es->ogImage = UriHelper::pathAddHost($es->data->ogImage); } static::$once = 0; } }