getDb(); $defaultItemId = $config->sobi2Itemid; // define ItemId for which you will execute mambots if ( isset($_REQUEST['Itemid']) ) { $n_ItemId = $_REQUEST['Itemid']; } else { $n_ItemId = $defaultItemId; } //prepare content: set $row main text variable; $row =& new stdClass(); $row->text = $text; //initialize $params variable $menu =& sobi2bridge::jMenu( $database ); $menu->load( $n_ItemId ); $params =& sobi2bridge::jParams( $menu->params ); $_MAMBOTS->loadBotGroup("content"); //call on function onPrepareContent of all mambots in the group content //pass parameters '1'=published, $row, $params to those functions $args = array( 1, &$row, &$params ); $_MAMBOTS->trigger( 'onPrepareContent', $args, false ); //store parsed content in the original variable; $text = $row->text; return $text; } /** * executing Joomla 1.5 plugins for a field * @author Radek Suski * @param string $text * @return string */ function execJPlugins( $text ) { $row =& new stdClass(); $row->text = $text; JPluginHelper::importPlugin( 'content' ); $dispatcher =& JDispatcher::getInstance(); $mainframe =& JFactory::getApplication( 'site' ); $params =& $mainframe->getParams( 'com_content' ); $results = $dispatcher->trigger( 'onPrepareContent', array ( &$row, & $params, 0 ) ); $text = $row->text; return $text; } /** * Returning array or string of selected categories * * @param sobi2 $mySobi * @return array */ function getMyCategories( $mySobi, $string = false, $wholePath = false ) { $config =& sobi2Config::getInstance(); $database = &$config->getDb(); if( $wholePath && $string ) { sobi2Config::import( "category.class" ); $catSep = $config->key( "frontpage", "entry_show_cat_func_cat_sep", "
" ); $pathSep = $config->key( "frontpage", "entry_show_cat_func_path_sep", " >> " ); $catsString = null; $mySobiCategories = array_flip( $mySobi->myCategories ); foreach ( $mySobiCategories as $cid ) { $cats = array(); $config->getParentCats( $cid, $cats ); if( is_array( $cats ) && !empty( $cats ) ) { $catParts = array(); foreach ( $cats as $catid ) { $category = new sobi2Category( $catid ); $url = sobi2Config::sef( "index.php?option=com_sobi2&catid={$category->catid}&Itemid={$config->sobi2Itemid}" ); $catParts[] = "name}\">{$category->name}"; } $catParts = array_reverse( $catParts ); $catsString .= implode( $pathSep, $catParts ); } $catsString .= $catSep; } return $catsString; } else { $cids = is_array( $mySobi->myCategories ) && !empty( $mySobi->myCategories ) ? implode(" , ", array_flip( $mySobi->myCategories ) ) : null; if( !$cids ) { return null; } $selectedCats = array(); $catsString = array(); $query = "SELECT name, icon, catid, introtext FROM `#__sobi2_categories` AS cat WHERE catid IN ({$cids}) AND cat.published = 1"; $database->setQuery($query); $database->query(); $categories = $database->loadObjectList(); if ($database->getErrorNum()) { trigger_error("HTML_SOBI::getMyCategories(): DB reports: ".$database->stderr(), E_USER_WARNING); } foreach ($categories as $category) { if($category->icon) { $img = "liveSite}{$config->catImagesFolder}{$category->icon}\" alt=\"{$category->name}\" title=\"{$category->introtext}\" />"; } else { $img = null; } $href = sobi2Config::sef("index.php?option=com_sobi2&catid={$category->catid}&Itemid={$config->sobi2Itemid}"); $selectedCats[] = array('name' => $category->name, 'href' => $href, 'icon' => $img, 'introtext' => $category->introtext); $catsString[] = "introtext}\">{$category->name}"; } if(!$string) { return $selectedCats; } return implode( " | ", $catsString ); } } /** * displaying hits * * @param sobi2Config $config * @param sobi2 $mySobi */ function showHits($config,$mySobi) { if($config->showHits) { if( $config->key( "details_view", "show_hits_label", true ) ) { echo _SOBI2_HITS." ".$mySobi->hits; } else { echo $mySobi->hits; } } } /** * displaying added date * * @param sobi2Config $config * @param sobi2 $mySobi */ function addedDate($config,$mySobi) { if($config->showAddedDate) { $date = date( $config->key( "details_view", "added_date_format", "F j, Y, g:i a" ), strtotime( $mySobi->publish_up ) ); if( $config->key( "details_view", "show_added_date_label", true ) ) { echo _SOBI2_DATE_ADDED." ".$date; } else { echo $date; } } } /** * displaying selected tags for an entry * * @param array $metaKeys * @param int $count * @return string */ function showTags($metaKeys, $count = 5) { $config =& sobi2Config::getInstance(); if( is_a( $metaKeys, "sobi2" ) ) { $metaKeys = $metaKeys->metakey; } if(!$metaKeys || empty($metaKeys)) { return null; } $tags = explode(",",$metaKeys); if( $config->key( "details_view", "show_tagged_label", true ) ) { $string = _SOBI2_ENTRY_TAGGED_WITH; } else { $string = null; } for ($i = 0; $i < $count; $i++) { if(isset($tags[$i]) && !empty($tags[$i])) { $tag = trim($tags[$i]); $href = sobi2Config::sef("index.php?option=com_sobi2&tag={$tag}&Itemid={$config->sobi2Itemid}"); $title = _SOBI2_ENTRIES_TAGGED_WITH." '{$tag}'"; $string .= "{$tag}"; if($i != $count && isset($tags[$i + 1]) && !empty($tags[$i +1 ])) { $string .= ",  "; } } else { break; } } return $string; } /** * @param sobi2 $mySobi * @param int $days */ function newLabel( $mySobi, $days = 3 ) { if(strtotime($mySobi->publish_up) > mktime() - ($days * 86400)) { return ''._SOBI2_NEW_LABEL.''; } } /** * @param sobi2 $mySobi * @param int $days */ function updatedLabel( $mySobi, $days = 3 ) { if(strtotime($mySobi->lastUpdate) > mktime() - ($days * 86400)) { return ''._SOBI2_UPDATED_LABEL.''; } } /** * @param sobi2 $mySobi * @param int $hits */ function hotLabel( $mySobi, $hits = 500 ) { if($mySobi->hits > $hits) { return ''._SOBI2_HOT_LABEL.''; } } /** * @param sobi2 $mySobi * @param string $name */ function userHref( $mySobi, $name = "real" ) { if(!$mySobi->owner) { return null; } $config =& sobi2Config::getInstance(); $db =& $config->getDb(); $user =& sobi2bridge::jUser( $db ); $user->load( $mySobi->owner ); $userLink = "index.php?option=com_sobi2&sobi2Task=usersListing&uid={$mySobi->owner}&Itemid={$config->sobi2Itemid}"; $userLink = sobi2Config::sef( $userLink ); if( $name == 'real' ) { $uname = $user->name; } else { $uname = $user->username; } $title = str_replace( array( "%username%" ,"%name%" ), array( $user->username, $user->name ), _SOBI2_USER_OWN_LISTING ); $userLink = "{$uname}"; return $userLink; } /** * @param sobi2 $mySobi * @param string $name */ function userCBHref( $mySobi, $name = "real" ) { if(!$mySobi->owner) { return null; } if( !sobi2Config::translatePath( "components|com_comprofiler|comprofiler", "root" ) ) { trigger_error( "Community Builder seems not to be installed.", E_USER_WARNING ); return self::userHref( $mySobi, $name ); } $config =& sobi2Config::getInstance(); $db =& $config->getDb(); $user =& sobi2bridge::jUser( $db ); $user->load( $mySobi->owner ); if( !( class_exists( 'JFactory' ) ) ) { $query = "SELECT `id` FROM `#__menu` WHERE `link` LIKE '%index.php?option=com_comprofiler%' AND `type` = 'components' AND `published` = '1' LIMIT 1"; } else { $query = "SELECT `id` FROM `#__menu` WHERE `link` LIKE '%index.php?option=com_comprofiler%' AND `type` = 'component' AND `published` = '1' LIMIT 1"; } $db->setQuery( $query ); $mid = $db->loadResult(); if( $mid && is_int( $mid ) ) { $mid = "&Itemid={$mid}"; } else { $mid = null; } $userLink = "index.php?option=com_comprofiler&task=userProfile&user={$user->id}{$mid}"; $userLink = sobi2Config::sef( $userLink ); if( $name == "real") { $uname = $user->name; } else { $uname = $user->username; } $title = str_replace( array( "%username%" ,"%name%" ), array( $user->username, $user->name ), _SOBI2_USER_OWN_LISTING ); $userLink = "{$uname}"; return $userLink; } /** * Enter description here... * * @param string $txt */ function replace( $txt, $key = null ) { static $def = array(); if( empty( $def ) ) { $config =& sobi2Config::getInstance(); if( $file = sobi2Config::translatePath( $config->key( "string", "replace_definion", null ), "front", true, ".ini" ) ) { $def = parse_ini_file( $file ); } else { trigger_error( "Cannot find replace definition file", E_USER_WARNING ); return $txt; } } if( !$key ) { foreach ( $def as $replace => $with ) { $txt = ereg_replace( "[[:<:]]{$replace}[[:>:]]", $with, $txt ); } } else { if( key_exists( $key, $def ) ) { $txt = ereg_replace( "[[:<:]]{$def[$key]}[[:>:]]", $with, $txt ); } else { trigger_error( "Replacement key '{$key}' does not exist ", E_USER_WARNING ); } } return $txt; } function addedDateOnly($config,$mySobi) { if($config->showAddedDate) { echo _SOBI2_DATE_ADDED." ".date("j.n.Y",strtotime ($mySobi->publish_up)); } } /** * Enter description here... * * @param sobiField $field * @param sobi2 $mySobi */ function countClick( $field, $mySobi, $showCounter = true ) { $config =& sobi2Config::getInstance(); $database =& $config->getDb(); $value = null; $count = null; static $script = false; if( $field->isUrl && strlen( $field->data ) ) { $onclick = "onclick=\"SobiCC( {$mySobi->id}, {$field->fieldid} );\""; $field->data_int = $field->data_int ? $field->data_int : 0; if( $showCounter ) { $count = str_replace( '%count%', $field->data_int, _CCOUNT_VISITED ); } if( $field->isUrl == 1 ) { $value = "data}\" {$onclick} title=\"{$mySobi->title}\" target=\"_blank\">{$field->label}{$count}"; } elseif( $field->isUrl == 2 ) { $value = "data}\" {$onclick} title=\"{$mySobi->title}\" target=\"_blank\">{$field->label}{$count}"; } } if( !$script ) { $script = true; $config->addCustomScript( 'function SobiCC( sid, fid ) { url = "index2.php?option=com_sobi2&no_html=1&sobi2&sobi2Task=countVisit&fid="+fid+"&sid="+sid+"&Itemid='.$config->sobi2Itemid.'"; if ( window.XMLHttpRequest ) { SCCReq = new XMLHttpRequest(); if ( SCCReq.overrideMimeType ) { SCCReq.overrideMimeType( "text/xml" ); } } else if ( window.ActiveXObject ) { try { SCCReq = new ActiveXObject( "Msxml2.XMLHTTP" ); } catch ( e ) { try { SCCReq = new ActiveXObject( "Microsoft.XMLHTTP" ); } catch ( e ) {} } } SCCReq.open( "GET",url , true ); SCCReq.setRequestHeader( "Content-type", "application/x-www-form-urlencoded" ); SCCReq.setRequestHeader( "Connection", "close" ); SCCReq.send( null ); } ' ); } return $value; } /** * Enter description here... * * @param sobiField $field * @param sobi2 $mySobi */ function toQuickEdit( $field, $mySobi ) { $config =& sobi2Config::getInstance(); $database = &$config->getDb(); $sobi2Frontend = &$config->getFrontend(); $my =& $config->getUser(); static $loaded = false; static $admFields = array(); $onclick = null; $data = $field->data; if( ( ($my->id != 0 && $my->id == $mySobi->owner && $config->allowUserToEditEntry ) || $config->checkPerm() ) && $config->key( "details_view", "allow_quick_edit" ) ) { if( !$config->checkPerm() && !$loaded ) { $query = "SELECT fieldid FROM `#__sobi2_fields` WHERE displayed = 1"; $database->setQuery( $query ); $admFields = $database->loadResultArray(); if ($database->getErrorNum()) { trigger_error("DB reports: ".$database->stderr(), E_USER_WARNING); } $fieldsIgnore = $config->key("details_view","quickedit_fields_ignore"); if( strlen($fieldsIgnore) ) { // $fieldsIgnore = explode(",", $fieldsIgnore ); array_push($admFields,$fieldsIgnore); } } if( !in_array( $field->fieldid, $admFields ) ) { $t = _JS_SOBI2_QFIELD_DBL_CLK_TO_EDIT; $onclick = "ondblclick=\"sobiEditField('sobi2Details_{$field->fieldname}', {$field->fieldid})\" title=\"{$t}\""; } } $data = "\n\t\tfieldname}\">{$data}"; return $data; } /** * PHP Function to Locally store website images from http://www.thumshots.org * Code is free. No guarantees or warranties. * Based on code by Daniel Schulman * @param string $url * @param string $alt * @param string $style * @param string $params * @return string */ function getThumbshotsOrg( $url, $alt = '', $style = 'border-style:none;', $params = null ) { $config =& sobi2Config::getInstance(); //EDITABLE PARAMETERS //Where Thumbnail images are stored locally $subDir = $config->key( "thumshots.org", "subdir_name", "thumbs" ); $defImg = $config->key( "thumshots.org", "no_thumb" ); $defImg = $config->key( "thumshots.org", "days_to_keep", 60 ); $local_thumb_dir = sobi2Config::translateDirPath( "{$config->imagesFolder}|{$subDir}", "root", false ); //How many days till check if new thumbnail $days_to_keep = 60; //To use if no thumbnail exists $return_img = sobi2Config::translatePath( "{$config->imagesFolder}|{$subDir}|{$defImg}", "root", false, '' ); //END EDITABLE if( !file_exists( $local_thumb_dir ) ) { sobi2Config::sobiMakePath( $local_thumb_dir ); } if ( substr( $url, 0, 4 ) != 'http' ) { $url = 'http://' . $url; //Make sure URL proper } $url = urlencode( $url ); $fname = str_replace( array( '%3A', '%2F', '%3F', '%3D', '%26' ), '_', $url ); $full_img_path = sobi2Config::translatePath( "{$config->imagesFolder}|{$subDir}|{$fname}", "root", false, '.jpg' ); if( file_exists( $full_img_path ) ) { //check age $diff =( time() - filemtime( $full_img_path) ) /60 /60 /24 ; if ( $diff > $days_to_keep ) { unlink( $full_img_path ); } else { $return_img = "{$config->liveSite}/{$config->imagesFolder}/{$subDir}/{$fname}.jpg"; } } if( !file_exists( $full_img_path ) ) { //get from thumbshots.org $buff = file_get_contents( "http://open.thumbshots.org/image.pxf?url={$url}" ); if( strlen( $buff ) ) { $fp = fopen( $full_img_path, "wb" ); fwrite( $fp,$buff ); fclose( $fp ); $return_img = "{$config->liveSite}/{$config->imagesFolder}/{$subDir}/{$fname}.jpg"; } } $html = "\"{$alt}\""; return $html; } function createWaySearchUrl( $sobi2Id ) { $config =& sobi2Config::getInstance(); if(!$config->useWaySearch) { return null; } $waySearchLink = $config->waySearchUrl; $fields = array(); $counter = 0; sobi2Config::import("field.class"); foreach ( $config->waySearchFields as $k => $fid ) { if( $fid ) { $field = new sobiField( $fid, $sobi2Id ); $fields[ $k ] = urlencode( $config->getSobiStr( $field->data ) ); if( !empty( $field->data ) ) { $counter++; } } } if( $counter < $config->key( "url", "way_search_min_fields", 2 ) ) { return null; } $WSstreet = isset($fields['STREET']) ? $fields['STREET'] : null; $WScity = isset($fields['CITY']) ? $fields['CITY'] : null; $WSpostcode = isset($fields['ZIPCODE']) ? $fields['ZIPCODE'] : null; $WScounty = isset($fields['COUNTY']) ? $fields['COUNTY'] : null; $WSfstate = isset($fields['FEDSTATE']) ? $fields['FEDSTATE'] : null; $WScountry = isset($fields['COUNTRY']) ? $fields['COUNTRY'] : null; $waySearchLink = str_replace( array( "STREET", "CITY", "ZIPCODE", "COUNTY", "FEDSTATE", "COUNTRY" ), array( $WSstreet, $WScity, $WSpostcode, $WScounty, $WSfstate, $WScountry ), $waySearchLink ); $waySearchLink = str_replace('&', '&', $waySearchLink ); $waySearchLink = str_replace('\\', null, $waySearchLink ); $waySearchLink = html_entity_decode( $waySearchLink ); $waySearchLink = "{$config->waySearchLabel}"; return $waySearchLink; } /** * * @param sobi2 $mySobi * @param sobi2config $config * @return string */ function showGoogleMaps($mySobi, $config) { if( !$config->useGoogleMaps || !isset( $config->googleMapsApiKey ) ) { return null; } $map_url = "http://api-maps.yandex.ru"; $map_api_version = "1.1"; $title = $config->jsAddSlashes( $mySobi->title ); $GeoPos = $config->getGeoPosition( $mySobi->id ); //if( $GeoPos['lat'] && $GeoPos['long'] && is_numeric( $GeoPos['lat'] ) && is_numeric( $GeoPos['lat'] ) ) { //Добавленная строка $fieldsObjects =& $mySobi->myFields; ?>
useWaySearch) { echo $waySearchLink; } } } ?>