function check() { //initialize $this->_error = null; $this->newurl = JString::trim($this->newurl); $this->metadesc = JString::trim($this->metadesc); $this->metakey = JString::trim($this->metakey); $this->metatitle = JString::trim($this->metatitle); $this->metalang = JString::trim($this->metalang); $this->metarobots = JString::trim($this->metarobots); // check for valid URLs if ($this->newurl == '') { $this->_error .= JText::_('COM_SH404SEF_EMPTYURL'); return false; } if (JString::substr($this->newurl, 0, 9) != 'index.php') { $this->_error .= JText::_('COM_SH404SEF_BADURL'); } if (is_null($this->_error)) { // check for existing URLS $this->_db->setQuery("SELECT id FROM #__sh404sef_metas WHERE `newurl` LIKE " . $this->_db->Quote($this->newurl)); $xid = intval($this->_db->loadResult()); if ($xid && $xid != intval($this->id)) { $this->_error = JText::_('COM_SH404SEF_URLEXIST'); return false; } return true; } else { return false; } }
/** * Returns an array of options * * @param string $sql SQL with ordering As value and 'name field' AS text * @param integer $chop The length of the truncated headline * * @return array An array of objects formatted for JHtml list processing * @since 11.1 */ public static function genericordering($sql, $chop = '30') { $db = JFactory::getDbo(); $options = array(); $db->setQuery($sql); $items = $db->loadObjectList(); // Check for a database error. if ($db->getErrorNum()) { JError::raiseNotice(500, $db->getErrorMsg()); return false; } if (empty($items)) { $options[] = JHtml::_('select.option', 1, JText::_('JOPTION_ORDER_FIRST')); return $options; } $options[] = JHtml::_('select.option', 0, '0 ' . JText::_('JOPTION_ORDER_FIRST')); for ($i = 0, $n = count($items); $i < $n; $i++) { $items[$i]->text = JText::_($items[$i]->text); if (JString::strlen($items[$i]->text) > $chop) { $text = JString::substr($items[$i]->text, 0, $chop) . "..."; } else { $text = $items[$i]->text; } $options[] = JHtml::_('select.option', $items[$i]->value, $items[$i]->value . '. ' . $text); } $options[] = JHtml::_('select.option', $items[$i - 1]->value + 1, $items[$i - 1]->value + 1 . ' ' . JText::_('JOPTION_ORDER_LAST')); return $options; }
public static function addCard(&$blog, $rawIntroText) { $cfg = EasyBlogHelper::getConfig(); // @rule: Check if user really wants to append the opengraph tags on the headers. if (!$cfg->get('main_twitter_cards')) { return false; } // Get the absolute permalink for this blog item. $url = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $blog->id, false, true); // Get the image of the blog post. $image = self::getImage($blog, $rawIntroText); // @task: Get Joomla's document object. $doc = JFactory::getDocument(); // Add card definition. $doc->addCustomTag('<meta property="twitter:card" content="summary" />'); $doc->addCustomTag('<meta property="twitter:url" content="' . $url . '" />'); $doc->addCustomTag('<meta property="twitter:title" content="' . $blog->title . '" />'); $text = EasyBlogHelper::stripEmbedTags($rawIntroText); $text = strip_tags($text); $text = str_ireplace("\r\n", "", $text); // Remove any " in the content as this would mess up the headers. $text = str_ireplace('"', '', $text); $maxLength = 137; if (!empty($maxLength)) { $text = JString::strlen($text) > $maxLength ? JString::substr($text, 0, $maxLength) . '...' : $text; } $text = EasyBlogStringHelper::escape($text); $doc->addCustomTag('<meta property="twitter:description" content="' . $text . '" />'); if ($image) { $doc->addCustomTag('<meta property="twitter:image" content="' . $image . '"/> '); } return true; }
/** * Generates the captcha image * * @since 4.0 * @access public * @param string * @return */ public function generate() { $id = $this->input->get('id', '', 'int'); // Load up the captcha object $captcha = EB::table('Captcha'); // Clear outdated keys $captcha->clear(); // load the captcha records. $captcha->load($id); if (!$captcha->id) { return false; } // @task: Generate a very random integer and take only 5 chars max. $hash = JString::substr(md5(rand(0, 9999)), 0, 5); $captcha->response = $hash; $captcha->store(); // Captcha width and height $width = 100; $height = 20; $image = ImageCreate($width, $height); $white = ImageColorAllocate($image, 255, 255, 255); $black = ImageColorAllocate($image, 0, 0, 0); $gray = ImageColorAllocate($image, 204, 204, 204); ImageFill($image, 0, 0, $white); ImageString($image, 5, 30, 3, $hash, $black); ImageRectangle($image, 0, 0, $width - 1, $height - 1, $gray); imageline($image, 0, $height / 2, $width, $height / 2, $gray); imageline($image, $width / 2, 0, $width / 2, $height, $gray); header('Content-type: image/jpeg'); ImageJpeg($image); ImageDestroy($image); exit; }
/** * Sanitize a value * * @param mixed Value to be sanitized * @return string */ protected function _sanitize($value) { $value = parent::_sanitize($value); $search_ignore = array(); // Limit term to 20 characters if (JString::strlen($value) > 20) { $value = JString::substr($value, 0, 19); } // Term must contain a minimum of 3 characters if ($value && JString::strlen($value) < 3) { $value = ''; } //Filter out search terms that are too small $words = explode(' ', JString::strtolower($value)); foreach ($words as $word) { if (JString::strlen($word) < 3) { $search_ignore[] = $word; } } if (count($words) > 1) { $pruned = array_diff($words, $search_ignore); $value = implode(' ', $pruned); } return $value; }
/** * Outputs the html code for Twitter button * * @since 4.0 * @access public * @param string * @return */ public function html() { // If this is a frontpage, ensure that show in frontpage is enabled if ($this->frontpage && !$this->config->get('main_twitter_button_frontpage', $this->config->get('social_show_frontpage'))) { return; } // Get the button size $size = $this->getButtonSize(); // Get the via text $via = $this->config->get('main_twitter_button_via_screen_name', ''); if ($via) { $via = JString::substr($via, 1); } // Get the absolute url to this blog post $url = $this->getUrl(); // Ge the formatted title to this blog post $title = $this->getTitle(); // Twitter's sharing shouldn't have urlencoded values $title = urldecode($title); // Remove unwanted character inside url to avoid incorrect url sharing $title = str_replace('"', '', $title); // Determines if we should track with analytics $tracking = $this->config->get('main_twitter_analytics'); $placeholder = $this->getPlaceholderId(); $theme = EB::template(); $theme->set('tracking', $tracking); $theme->set('size', $size); $theme->set('via', $via); $theme->set('placeholder', $placeholder); $theme->set('url', $url); $theme->set('title', $title); $output = $theme->output('site/socialbuttons/twitter'); return $output; }
function DefaultViewEventCatRowNew($view, $row, $args = "") { // I choost not to use $row->fgcolor() $fgcolor = "inherit"; $router = JRouter::getInstance("site"); $vars = $router->getVars(); $vars["catids"] = $row->catid(); if (array_key_exists("Itemid", $vars) && is_null($vars["Itemid"])) { $vars["Itemid"] = JRequest::getInt("Itemid", 0); } $eventlink = "index.php?"; foreach ($vars as $key => $val) { $eventlink .= $key . "=" . $val . "&"; } $eventlink = JString::substr($eventlink, 0, JString::strlen($eventlink) - 1); $eventlink = JRoute::_($eventlink); ?> <a class="ev_link_cat" href="<?php echo $eventlink; ?> " style="color:<?php echo $fgcolor; ?> ;" title="<?php echo JEventsHTML::special($row->catname()); ?> "><?php echo $row->catname(); ?> </a> <?php }
public function execute($item) { $model = FD::model('comments'); $users = $model->getParticipants($item->uid, $item->context_type); $users[] = $item->actor_id; $users = array_values(array_unique(array_diff($users, array(FD::user()->id)))); $names = FD::string()->namesToNotifications($users); $plurality = count($users) > 1 ? '_PLURAL' : '_SINGULAR'; $content = ''; if (count($users) == 1 && !empty($item->content)) { $content = JString::substr(strip_tags($item->content), 0, 30); if (JString::strlen($item->content) > 30) { $content .= JText::_('COM_EASYSOCIAL_ELLIPSES'); } } $item->content = $content; list($element, $group, $verb) = explode('.', $item->context_type); $streamItem = FD::table('streamitem'); $state = $streamItem->load(array('context_type' => $element, 'actor_type' => $group, 'verb' => $verb, 'context_id' => $item->uid)); if (!$state) { return; } $owner = $streamItem->actor_id; if ($item->target_type === SOCIAL_TYPE_USER && $item->target_id == $owner) { $item->title = JText::sprintf('APP_USER_ARTICLE_USER_COMMENTED_ON_YOUR_ITEM' . $plurality, $names); return $item; } if ($item->actor_id == $owner && count($users) == 1) { $item->title = JText::sprintf('APP_USER_ARTICLE_OWNER_COMMENTED_ON_ITEM' . FD::user($owner)->getGenderLang(), $names); return $item; } $item->title = JText::sprintf('APP_USER_ARTICLE_USER_COMMENTED_ON_USER_ITEM' . $plurality, $names, FD::user($owner)->getName()); return $item; }
function listDirectories($path, $regex = '.', $recurse = false) { $dirs = array(); // Make sure path is valid jimport('joomla.filesystem.path'); $path = JPath::clean($path); $root = strlen(JPATH_ROOT) ? JPATH_ROOT : DS; if (empty($path) || JString::strpos($path, $root) !== 0) { return $dirs; } // Find folders jimport('joomla.filesystem.folder'); $list = JFolder::folders($path, $regex, $recurse, true); if (empty($list)) { return $dirs; } // Create list of directories and the names foreach ($list as $path) { //$folder = JString::str_ireplace(JPATH_ROOT, '', $path); $folder = JString::substr($path, JString::strlen($root)); $folder = substr(str_replace(DS, '/', $folder), 1); $name = @explode('/', $folder); $name = array_pop($name); $dirs[] = array('folder' => $folder, 'name' => $name, 'path' => $path, 'path.64' => base64_encode($path)); } return $dirs; }
/** * Outputs the html code for Twitter button * * @since 4.0 * @access public * @param string * @return */ public function html() { if (!$this->isEnabled()) { return; } $this->addScript(); // Get the pinterest button style from the configuration $size = $this->getButtonSize(); $url = EBR::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $this->post->id, false, true); // Combine the introtext and the content $content = $this->post->intro . $this->post->content; // Get the media $media = $this->getMedia(); $contentLength = 350; $text = $this->post->intro . $this->post->content; $text = nl2br($text); $text = strip_tags($text); $text = trim(preg_replace('/\\s+/', ' ', $text)); $text = JString::strlen($text) > $contentLength ? JString::substr($text, 0, $contentLength) . '...' : $text; $title = $this->post->title; // Urlencode all the necessary properties. $url = urlencode($url); $text = urlencode($text); $media = urlencode($media); $placeholder = $this->getPlaceholderId(); $theme = EB::template(); $theme->set('size', $size); $theme->set('placeholder', $placeholder); $theme->set('url', $url); $theme->set('title', $title); $theme->set('media', $media); $theme->set('text', $text); $output = $theme->output('site/socialbuttons/pinterest'); return $output; }
function cutText($text, $limit_value, $limit_type, $at_end) { // solved problem from: https://www.gavick.com/support/forums/47/12309.html?p=57464#p57464 $cck_path = JPATH_BASE . DS . 'components' . DS . 'com_cck'; if (file_exists($cck_path)) { if (JComponentHelper::isEnabled('com_cck', true)) { // Force parsing plugin if SEBLOD is used if ($this->config['parse_plugins'] == FALSE) { $text = JHtml::_('content.prepare', $text); } $text = trim(substr(strip_tags($text, "<br /><br><strong></strong><p></p><i></i><b></b><span></span><ul></ul><li></li><blockquote></blockquote>"), 0)); } } if ($limit_type == 'words' && $limit_value > 0) { $temp = explode(' ', $text); if (count($temp) > $limit_value) { for ($i = 0; $i < $limit_value; $i++) { $cutted[$i] = $temp[$i]; } $cutted = implode(' ', $cutted); $text = $cutted . $at_end; } } elseif ($limit_type == 'words' && $limit_value == 0) { return ''; } else { if (JString::strlen($text) > $limit_value) { $text = JString::substr($text, 0, $limit_value) . $at_end; } } // replace unnecessary entities at end of the cutted text $toReplace = array('&&', '&a&', '&am&', '&&', '&q&', '&qu&', '&quo&', '"&', '&ap&', '&apo&', '&apos&'); $text = str_replace($toReplace, '&', $text); // return $text; }
function links($rows, $team) { ?> <ul class="eblog_entry_links_list"> <?php for ($i = 1; $i < count($rows); $i++) { ?> <?php $item = $rows[$i]; ?> <li> <a href="<?php echo EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $item->id); ?> "> <?php echo JString::strlen($item->title) > 30 ? JString::substr(strip_tags($item->title), 0, 30) . '...' : strip_tags($item->title); ?> </a> <span><?php echo JString::strlen($item->content) > 100 ? JString::substr(strip_tags($item->content), 0, 100) . '...' : strip_tags($item->content); ?> </span> </li> <?php } //end for ?> </ul> <?php }
function modChrome_ztxhtml($module, &$params, &$attribs) { $titles = JString::strpos($module->title, ' '); $title = $titles !== false ? JString::substr($module->title, 0, $titles) . '<span>' . JString::substr($module->title, $titles) . '</span>' : $module->title; if (!empty($module->content)) { ?> <div class="moduletable<?php echo $params->get('moduleclass_sfx'); ?> "> <div class="ztmodule"> <?php if ($module->showtitle != 0) { ?> <h3 class="moduletitle"><span class="title"><?php echo $title; ?> </span></h3> <?php } ?> <div class="modulecontent"> <?php echo $module->content; ?> </div> </div> </div> <?php } }
public function __construct(&$subject, $config) { parent::__construct($subject, $config); // Ensure that constructor is called one time self::$cookie = SID == ''; if (!self::$default_lang) { $app = JFactory::getApplication(); $router = $app->getRouter(); if ($app->isSite()) { // setup language data self::$mode_sef = $router->getMode() == JROUTER_MODE_SEF ? true : false; self::$sefs = JLanguageHelper::getLanguages('sef'); self::$lang_codes = JLanguageHelper::getLanguages('lang_code'); self::$default_lang = JComponentHelper::getParams('com_languages')->get('site', 'en-GB'); self::$default_sef = self::$lang_codes[self::$default_lang]->sef; $user = JFactory::getUser(); $levels = $user->getAuthorisedViewLevels(); foreach (self::$sefs as $sef => &$language) { if (isset($language->access) && $language->access && !in_array($language->access, $levels)) { unset(self::$sefs[$sef]); } } $app->setLanguageFilter(true); jimport('joomla.environment.uri'); $uri = JURI::getInstance(); if (self::$mode_sef) { // Get the route path from the request. $path = JString::substr($uri->toString(), JString::strlen($uri->base())); // Apache mod_rewrite is Off $path = JFactory::getConfig()->get('sef_rewrite') ? $path : JString::substr($path, 10); // Trim any spaces or slashes from the ends of the path and explode into segments. $path = JString::trim($path, '/ '); $parts = explode('/', $path); // The language segment is always at the beginning of the route path if it exists. $sef = $uri->getVar('lang'); if (!empty($parts) && empty($sef)) { $sef = reset($parts); } } else { $sef = $uri->getVar('lang'); } if (isset(self::$sefs[$sef])) { $lang_code = self::$sefs[$sef]->lang_code; // Create a cookie $conf = JFactory::getConfig(); $cookie_domain = $conf->get('config.cookie_domain', ''); $cookie_path = $conf->get('config.cookie_path', '/'); setcookie(JApplication::getHash('language'), $lang_code, $this->getLangCookieTime(), $cookie_path, $cookie_domain); $app->input->cookie->set(JApplication::getHash('language'), $lang_code); // set the request var $app->input->set('language', $lang_code); } } parent::__construct($subject, $config); // Detect browser feature if ($app->isSite()) { $app->setDetectBrowser($this->params->get('detect_browser', '1') == '1'); } } }
function fetchElement($name, $value, &$node, $control_name) { $db =& JFactory::getDBO(); $db->setQuery('SELECT * FROM #__mt_customfields WHERE published = 1'); $fields = $db->loadObjectList(); if (!is_array($value)) { $value = array($value); } $html = ''; foreach ($fields as $field) { $html .= '<div style="width:125px;float:left;padding: 4px 3px"><input type="checkbox"'; $html .= ' name="' . $control_name . '[' . $name . '][]' . '"'; $html .= ' id="' . $control_name . $name . $field->cf_id . '"'; $html .= ' value="' . $field->cf_id . '"'; if (in_array($field->cf_id, $value)) { $html .= ' checked'; } $html .= ' />'; $field->caption = stripslashes($field->caption); $html .= ' <label for="' . $control_name . $name . $field->cf_id . '" title="' . $field->caption . '">'; if (JString::strlen($field->caption) > $this->_max_caption_length - 3) { $html .= JString::substr($field->caption, 0, $this->_max_caption_length - 3); $html .= '...'; } else { $html .= $field->caption; } $html .= '</label>'; $html .= '</div>'; } return $html; }
/** * Generates a random captcha image * **/ function display($cachable = false, $urlparams = false) { // @TODO: Run some cleaning query here to clear the database. JTable::addIncludePath(DISCUSS_TABLES); $id = JRequest::getInt('captcha-id', ''); $captcha = DiscussHelper::getTable('Captcha'); // clearing the oudated keys. $captcha->clear(); // load the captcha records. $captcha->load($id); if (!$captcha->id) { return false; } // @task: Generate a very random integer and take only 5 chars max. $hash = JString::substr(md5(rand(0, 9999)), 0, 5); $captcha->response = $hash; $captcha->store(); // Captcha width and height $width = 100; $height = 20; $image = ImageCreate($width, $height); $white = ImageColorAllocate($image, 255, 255, 255); $black = ImageColorAllocate($image, 0, 0, 0); $gray = ImageColorAllocate($image, 204, 204, 204); ImageFill($image, 0, 0, $white); ImageString($image, 5, 30, 3, $hash, $black); ImageRectangle($image, 0, 0, $width - 1, $height - 1, $gray); imageline($image, 0, $height / 2, $width, $height / 2, $gray); imageline($image, $width / 2, 0, $width / 2, $height, $gray); header('Content-type: image/jpeg'); ImageJpeg($image); ImageDestroy($image); exit; }
public function getThumbnail($obj) { $config = CFactory::getConfig(); $file = $obj->thumb; // Site origin if (JString::substr($file, 0, 4) == 'http') { $uri = $file; return $uri; } // Remote storage if ($obj->storage != 'file') { $storage = CStorage::getStorage($obj->storage); $uri = $storage->getURI($file); return $uri; } // Default thumbnail if (empty($file) || !JFile::exists(JPATH_ROOT . '/' . $file)) { $template = new CTemplateHelper(); $asset = $template->getTemplateAsset('video_thumb.png', 'images'); $uri = $asset->url; return $uri; } // Strip cdn path if exists. // Note: At one point, cdn path was stored along with the thumbnail path // in the db which is the mistake we are trying to rectify here. $file = str_ireplace($config->get('videocdnpath'), '', $file); // CDN or local $baseUrl = $config->get('videobaseurl') or $baseUrl = JURI::root(); $uri = str_replace('\\', '/', rtrim($baseUrl, '/') . '/' . ltrim($file, '/')); return $uri; }
/** * Description * * @param string SQL with ordering As value and 'name field' AS text * @param integer The length of the truncated headline * @since 1.5 */ function genericordering($sql, $chop = '30') { $db =& JFactory::getDBO(); $order = array(); $db->setQuery($sql); if (!($orders = $db->loadObjectList())) { if ($db->getErrorNum()) { echo $db->stderr(); return false; } else { $order[] = JHTML::_('select.option', 1, JText::_('first')); return $order; } } $order[] = JHTML::_('select.option', 0, '0 ' . JText::_('first')); for ($i = 0, $n = count($orders); $i < $n; $i++) { if (JString::strlen($orders[$i]->text) > $chop) { $text = JString::substr($orders[$i]->text, 0, $chop) . "..."; } else { $text = $orders[$i]->text; } $order[] = JHTML::_('select.option', $orders[$i]->value, $orders[$i]->value . ' (' . $text . ')'); } $order[] = JHTML::_('select.option', $orders[$i - 1]->value + 1, $orders[$i - 1]->value + 1 . ' ' . JText::_('last')); return $order; }
/** * Get sub string (by words) * @param $text * @param $searchword * @return mixed|string */ public function smartSubstr($text, $searchword) { $length = self::MAX_LENGTH; $textlen = JString::strlen($text); $lsearchword = JString::strtolower($searchword); $wordfound = false; $pos = 0; $chunk = ''; while ($wordfound === false && $pos < $textlen) { if (($wordpos = @JString::strpos($text, ' ', $pos + $length)) !== false) { $chunk_size = $wordpos - $pos; } else { $chunk_size = $length; } $chunk = JString::substr($text, $pos, $chunk_size); $wordfound = JString::strpos(JString::strtolower($chunk), $lsearchword); if ($wordfound === false) { $pos += $chunk_size + 1; } } if ($wordfound !== false) { return ($pos > 0 ? '...' : '') . $chunk; } elseif (($wordpos = @JString::strpos($text, ' ', $length)) !== false) { return JString::substr($text, 0, $wordpos) . '...'; } else { return JString::substr($text, 0, $length); } }
/** * truncString. * * @param string $text Param * @param integer $max_chars Param * @param bool $withDots Param * * @return string */ public static function truncString($text, $max_chars, $withDots = null) { if ($withDots === null) { $withDots = !EParameter::getComponentParam(CAUTOTWEETNG, 'donot_add_dots'); } $length = JString::strlen($text); if ($length > $max_chars) { if ($withDots) { // -Dots // -2 Utf8 case $max_chars = $max_chars - 3 - 2; } $text = JString::substr($text, 0, $max_chars); // Yes, it can return more characters, but utf8_strlen($text) is Ok, so ... $l = $max_chars; // Strlen shorter than JString::strlen for UTF-8 - 2 char languages E.g. Hebrew while (strlen($text) > $max_chars) { $l--; $text = JString::substr($text, 0, $l); } if ($withDots) { $text = $text . '...'; } } return $text; }
function save($url = null) { if (!JSession::checkToken('post')) { $this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error'); $this->app->redirect(KunenaRoute::_($this->baseurl, false)); } $properties = $this->config->getProperties(); foreach (JRequest::get('post', JREQUEST_ALLOWHTML) as $postsetting => $postvalue) { if (JString::strpos($postsetting, 'cfg_') === 0) { //remove cfg_ and force lower case if (is_array($postvalue)) { $postvalue = implode(',', $postvalue); } $postname = JString::strtolower(JString::substr($postsetting, 4)); // No matter what got posted, we only store config parameters defined // in the config class. Anything else posted gets ignored. if (array_key_exists($postname, $properties)) { $this->config->set($postname, $postvalue); } } } $this->config->save(); $this->app->enqueueMessage(JText::_('COM_KUNENA_CONFIGSAVED')); if (empty($url)) { $this->app->redirect(KunenaRoute::_($this->kunenabaseurl, false)); } else { $this->app->redirect(KunenaRoute::_($url, false)); } }
public function getFieldHTML($field, $required) { $required = $field->required == 1 ? ' data-required="true"' : ''; //a fix for wrong data $field->value = JString::trim($field->value); if (JString::strrpos($field->value, ',') == JString::strlen($field->value) - 1) { $field->value = JString::substr($field->value, 0, -1); } $lists = explode(',', $field->value); //CFactory::load( 'helpers' , 'string' ); $html = '<select id="field' . $field->id . '" name="field' . $field->id . '[]" type="select-multiple" multiple="multiple" class="joms-select joms-select--multiple" title="' . CStringHelper::escape(JText::_($field->tips)) . '" ' . $required . '>'; $elementSelected = 0; foreach ($field->options as $option) { $selected = in_array($option, $lists) ? ' selected="selected"' : ''; if (empty($selected)) { $elementSelected++; } $html .= '<option value="' . $option . '"' . $selected . '>' . JText::_($option) . '</option>'; } if ($elementSelected == 0) { //if nothing is selected, we default the 1st option to be selected. $elementName = 'field' . $field->id; $html .= <<<HTML <script type='text/javascript'> var slt = document.getElementById('{$elementName}'); if(slt != null){ slt.options[0].selected = true; } </script> HTML; } $html .= '</select>'; return $html; }
public function execute($item, $calendar) { $model = FD::model('comments'); $users = $model->getParticipants($item->uid, $item->context_type); // Include the notification actor $users[] = $item->actor_id; // Exclude the current user $users = array_values(array_unique(array_diff($users, array(FD::user()->id)))); $names = FD::string()->namesToNotifications($users); $plurality = count($users) > 1 ? '_PLURAL' : '_SINGULAR'; $content = ''; if (count($users) == 1 && !empty($item->content)) { $content = JString::substr(strip_tags($item->content), 0, 30); if (JString::strlen($item->content) > 30) { $content .= JText::_('COM_EASYSOCIAL_ELLIPSES'); } } $item->content = $content; if ($calendar->user_id == $item->target_id && $item->target_type == SOCIAL_TYPE_USER) { $item->title = JText::sprintf('APP_USER_CALENDAR_USER_COMMENTED_ON_YOUR_EVENT' . $plurality, $names); return $item; } if ($calendar->user_id == $item->actor_id && count($users) == 1) { $item->title = JText::sprintf('APP_USER_CALENDAR_OWNER_COMMENTED_ON_EVENT' . FD::user($calendar->user_id)->getGendarLang(), $names); return $item; } $item->title = JText::sprintf('APP_USER_CALENDAR_USER_COMMENTED_ON_USER_EVENT' . $plurality, $names, FD::user($calendar->user_id)->getName()); return $item; }
function check() { //initialize $this->_error = null; $this->oldurl = JString::trim($this->oldurl); $this->newurl = JString::trim($this->newurl); // check for valid URLs if ($this->oldurl == '' || $this->newurl == '') { $this->_error .= JTExt::_('COM_SH404SEF_EMPTYURL'); return false; } if (JString::substr($this->oldurl, 0, 1) == '/') { $this->_error .= JText::_('COM_SH404SEF_NOLEADSLASH'); } if (JString::substr($this->newurl, 0, 9) != 'index.php') { $this->_error .= JText::_('COM_SH404SEF_BADURL'); } // V 1.2.4.t remove this check. We check for pre-existing non-sef instead of SEF if (is_null($this->_error)) { // check for existing URLS $this->_db->setQuery("SELECT id,oldurl FROM #__sh404sef_urls WHERE `newurl` LIKE " . $this->_db->Quote($this->newurl)); $xid = $this->_db->loadObject(); // V 1.3.1 don't raise error if both newurl and old url are same. It means we may have changed alias list if ($xid && $xid->id != intval($this->id)) { $this->_error = JText::_('COM_SH404SEF_URLEXIST'); return false; } $identical = $xid->id == intval($this->id) && $xid->oldurl == $this->oldurl; return $identical ? 'identical' : true; } else { return false; } }
protected function prepareGroupField() { $basetype = isset($this->element['basetype']) ? $this->element['basetype'] : 'text'; $basetype = (string) $basetype; $first_char = JString::substr($this->element['name'], 0, 1); $last_char = JString::substr($this->element['name'], JString::strlen($this->element['name']) - 1, 1); if ($basetype == 'group') { //If start or end of group if ($first_char == "{") { // Починаю нову групу (може бути будь-якого рівня вкладеності) $GLOBALS['variablefield']['output'] = false; $GLOBALS['variablefield']['current_group'][] = (string) $this->element['name'] . '}'; // Lower in the code I know, that last element of array $GLOBALS['variablefield']['current_group'] is always the current group. $this->groupstate = 'start'; $GLOBALS['variablefield']['fields'][] = clone $this; // I must clone } else { if ($last_char == "}") { $this->groupstate = 'end'; $GLOBALS['variablefield']['fields'][] = clone $this; array_pop($GLOBALS['variablefield']['current_group']); if (empty($GLOBALS['variablefield']['current_group'])) { $GLOBALS['variablefield']['output'] = true; } } } } else { if (!empty($GLOBALS['variablefield']['current_group'])) { // If in element from inside the group $this->groupstate = 'continue'; $this->defaultvalue = $this->value; $GLOBALS['variablefield']['fields'][] = clone $this; } } }
private function format(&$articles, $params) { if (!$articles) { return; } foreach ($articles as $article) { $category = JTable::getInstance('Category'); $category->load($article->catid); $article->category = $category; $article->permalink = ContentHelperRoute::getArticleRoute($article->id . ':' . $article->alias, $article->catid); $article->permalink = JRoute::_($article->permalink); $article->category->permalink = ContentHelperRoute::getCategoryRoute($category->id . ':' . $category->alias); $article->category->permalink = JRoute::_($article->category->permalink); $article->content = empty($article->introtext) ? $article->fulltext : $article->introtext; $titleLength = $params->get('title_length'); $contentLength = $params->get('content_length'); if ($titleLength) { $article->title = JString::substr($article->title, 0, $titleLength); } // Try to get image of the article $image = $this->processContentImage($article->content); if ($image) { $article->image = $image; } if ($contentLength) { $article->content = JString::substr(strip_tags($article->content), 0, $contentLength) . ' ...'; } else { $base = JURI::base(true) . '/'; $protocols = '[a-zA-Z0-9]+:'; //To check for all unknown protocals (a protocol must contain at least one alpahnumeric fillowed by : $regex = '#(src|href|poster)="(?!/|' . $protocols . '|\\#|\')([^"]*)"#m'; $article->content = preg_replace($regex, "\$1=\"{$base}\$2\"", $article->content); } } }
function fetchElement($name, $value, &$node, $control_name) { $size = $node->attributes('size') ? 'size="' . $node->attributes('size') . '"' : ''; $class = $node->attributes('class') ? 'class="' . $node->attributes('class') . '"' : 'class="text_area"'; if (empty($value) && !is_array($value)) { $value = array('', '=', ''); } $html = ''; $db =& JFactory::getDBO(); $db->setQuery('SELECT cf_id AS value, caption AS text FROM #__mt_customfields WHERE published = 1 AND iscore = 0'); $customfields[] = JHTML::_('select.option', '', JText::_('- Select a field -')); $customfields = array_merge($customfields, $db->loadObjectList()); // trim long caption $i = 0; foreach ($customfields as $customfield) { if (JString::strlen($customfields[$i]->text) > $this->_max_caption_length - 3) { $customfields[$i]->text = JString::substr($customfields[$i]->text, 0, $this->_max_caption_length - 3) . '...'; } $i++; } $html .= JHTML::_('select.genericlist', $customfields, $control_name . '[' . $name . '][]', 'class="inputbox"', 'value', 'text', $value[0], $control_name . $name); $operators[] = JHTML::_('select.option', '=', JText::_('is equal to')); $operators[] = JHTML::_('select.option', '!=', JText::_('is not equal to')); $operators[] = JHTML::_('select.option', '>', JText::_('is more than')); $operators[] = JHTML::_('select.option', '<', JText::_('is less than')); $html .= JHTML::_('select.genericlist', $operators, $control_name . '[' . $name . '][]', 'class="inputbox"', 'value', 'text', $value[1], $control_name . $name); $html .= '<input type="text" name="' . $control_name . '[' . $name . '][]" id="' . $control_name . $name . '" value="' . $value[2] . '" ' . $class . ' ' . $size . ' />'; return $html; }
function onActivityContentDisplay($args) { $model =& CFactory::getModel('Wall'); $wall =& JTable::getInstance('Wall', 'CTable'); $my = CFactory::getUser(); if (empty($args->content)) { return ''; } $wall->load($args->cid); CFactory::load('libraries', 'privacy'); CFactory::load('libraries', 'comment'); $comment = CComment::stripCommentData($wall->comment); $config = CFactory::getConfig(); $commentcut = false; if (strlen($comment) > $config->getInt('streamcontentlength')) { $origcomment = $comment; $comment = JString::substr($comment, 0, $config->getInt('streamcontentlength')) . ' ...'; $commentcut = true; } if (CPrivacy::isAccessAllowed($my->id, $args->target, 'user', 'privacyProfileView')) { CFactory::load('helpers', 'videos'); CFactory::load('libraries', 'videos'); CFactory::load('libraries', 'wall'); $videoContent = ''; $params = new CParameter($args->params); $videoLink = $params->get('videolink'); $image = $params->get('url'); // For older activities that does not have videoLink , we need to process it the old way. if (!$videoLink) { $html = CWallLibrary::_processWallContent($comment); $tmpl = new CTemplate(); $html = CStringHelper::escape($html); if ($commentcut) { //add read more/less link for content $html .= '<br /><br /><a href="javascript:void(0)" onclick="jQuery(\'#shortcomment_' . $args->cid . '\').hide(); jQuery(\'#origcomment_' . $args->cid . '\').show();" >' . JText::_('COM_COMMUNITY_READ_MORE') . '</a>'; $html = '<div id="shortcomment_' . $args->cid . '">' . $html . '</div>'; $html .= '<div id="origcomment_' . $args->cid . '" style="display:none;">' . $origcomment . '<br /><br /><a href="javascript:void(0);" onclick="jQuery(\'#shortcomment_' . $args->cid . '\').show(); jQuery(\'#origcomment_' . $args->cid . '\').hide();" >' . JText::_('COM_COMMUNITY_READ_LESS') . '</a></div>'; } $tmpl->set('comment', $html); $html = $tmpl->fetch('activity.wall.post'); } else { $html = '<ul class ="cDetailList clrfix">'; $html .= '<li>'; $image = !$image ? rtrim(JURI::root(), '/') . '/components/com_community/assets/playvideo.gif' : $image; $videoLib = new CVideoLibrary(); $provider = $videoLib->getProvider($videoLink); $html .= '<!-- avatar --><div class="avatarWrap"><a href="javascript:void(0);" onclick="joms.activities.showVideo(\'' . $args->id . '\');"><img width="64" src="' . $image . '" class="cAvatar"/></a></div><!-- avatar -->'; $videoPlayer = $provider->getViewHTML($provider->getId(), '300', '300'); $comment = CString::str_ireplace($videoLink, '', $comment); $html .= '<!-- details --><div class="detailWrap alpha">' . $comment . '</div><!-- details -->'; if (!empty($videoPlayer)) { $html .= '<div style="display: none;clear: both;padding-top: 5px;" class="video-object">' . $videoPlayer . '</div>'; } $html .= '</li>'; $html .= '</ul>'; } return $html; } }
public static function wordDelete($string, $length, $end = '...') { if (JString::strlen($string) < $length || JString::strlen($string) == $length) { return $string; } else { return JString::substr($string, 0, $length) . $end; } }
protected function getListQuery() { // TODO: filter deleted comments $query = $this->_db->getQuery(true); $reportsSubQuery = ', (SELECT COUNT(*) FROM ' . $this->_db->quoteName('#__jcomments_reports') . ' AS r WHERE r.commentid = jc.id) AS reports'; $query->select('jc.*' . $reportsSubQuery); $query->from($this->_db->quoteName('#__jcomments') . ' AS jc'); // Join over the objects $query->select('jo.title as object_title, jo.link as object_link'); $query->join('LEFT', $this->_db->quoteName('#__jcomments_objects') . ' AS jo ON jo.object_id = jc.object_id AND jo.object_group = jc.object_group AND jo.lang = jc.lang'); // Join over the users $query->select('u.name AS editor'); $query->join('LEFT', $this->_db->quoteName('#__users') . ' AS u ON u.id = jc.checked_out'); // Filter by published state $state = $this->getState('filter.state'); if (is_numeric($state)) { if ($state == 2) { $query->where('EXISTS (SELECT * FROM ' . $this->_db->quoteName('#__jcomments_reports') . ' AS jr WHERE jr.commentid = jc.id)'); } else { $query->where('jc.published = ' . (int) $state); } } // Filter by component (object group) $object_group = $this->getState('filter.object_group'); if ($object_group != '') { $query->where('jc.object_group = ' . $this->_db->Quote($this->_db->escape($object_group))); } // Filter by language $language = $this->getState('filter.language'); if ($language != '') { $query->where('jc.lang = ' . $this->_db->Quote($this->_db->escape($language))); } // Filter by search in name or email $search = $this->getState('filter.search'); if (!empty($search)) { if (stripos($search, 'id:') === 0) { $query->where('jc.id = ' . (int) substr($search, 3)); } else { if (stripos($search, 'user:'******'%' . $this->_db->escape(JString::substr($search, 5), true) . '%'); $query->where('(jc.email LIKE ' . $escaped . ' OR jc.name LIKE ' . $escaped . ' OR jc.username LIKE ' . $escaped . ')'); } else { if (stripos($search, 'object:') === 0) { $escaped = $this->_db->Quote('%' . $this->_db->escape(JString::substr($search, 7), true) . '%'); $query->where('jo.title LIKE ' . $escaped); } else { $search = $this->_db->Quote('%' . $this->_db->escape($search, true) . '%'); $query->where('(jc.comment LIKE ' . $search . ' OR jc.title LIKE ' . $search . ')'); } } } } $ordering = $this->state->get('list.ordering', 'jc.date'); $direction = $this->state->get('list.direction', 'DESC'); $query->order($this->_db->escape($ordering . ' ' . $direction)); // echo $query->__toString(); return $query; }