예제 #1
0
	/**
	 * This function sets the right template on the view
	 * @author Max Milbers
	 */
	static function setVmTemplate ($view, $catTpl = 0, $prodTpl = 0, $catLayout = 0, $prodLayout = 0) {

		//Lets get here the template set in the shopconfig, if there is nothing set, get the joomla standard
		$template = VmConfig::get( 'vmtemplate', 0 );
		$db = JFactory::getDBO();
		//Set specific category template
		if(!empty($catTpl) && empty($prodTpl)) {
			if(is_Int( $catTpl )) {
				$q = 'SELECT `category_template` FROM `#__virtuemart_categories` WHERE `virtuemart_category_id` = "'.(int)$catTpl.'" ';
				$db->setQuery( $q );
				$temp = $db->loadResult();
				if(!empty($temp)) $template = $temp;
			} else {
				$template = $catTpl;
			}
		}

		//Set specific product template
		if(!empty($prodTpl)) {
			if(is_Int( $prodTpl )) {
				$q = 'SELECT `product_template` FROM `#__virtuemart_products` WHERE `virtuemart_product_id` = "'.(int)$prodTpl.'" ';
				$db->setQuery( $q );
				$temp = $db->loadResult();
				if(!empty($temp)) $template = $temp;
			} else {
				$template = $prodTpl;
			}
		}

		if( (!empty($template) and $template!='default') or JFactory::getApplication()->isAdmin()){
			self::setTemplate( $template );
		}

		//Lets get here the layout set in the shopconfig, if there is nothing set, get the joomla standard
		if(vRequest::getCmd( 'view' ) == 'virtuemart') {
			$layout = VmConfig::get( 'vmlayout', 'default' );
			$view->setLayout( strtolower( $layout ) );
		} else {

			if(empty($catLayout) and empty($prodLayout)) {
				$catLayout = VmConfig::get( 'productlayout', 'default' );
			}

			//Set specific category layout
			if(!empty($catLayout) && empty($prodLayout)) {
				if(is_Int( $catLayout )) {
					$q = 'SELECT `layout` FROM `#__virtuemart_categories` WHERE `virtuemart_category_id` = "'.(int)$catLayout.'" ';
					$db->setQuery( $q );
					$temp = $db->loadResult();
					if(!empty($temp)) $layout = $temp;
				} else {
					$layout = $catLayout;
				}
			}

			//Set specific product layout
			if(!empty($prodLayout)) {
				if(is_Int( $prodLayout )) {
					$q = 'SELECT `layout` FROM `#__virtuemart_products` WHERE `virtuemart_product_id` = "'.(int)$prodLayout.'" ';
					$db->setQuery( $q );
					$temp = $db->loadResult();
					if(!empty($temp)) $layout = $temp;
				} else {
					$layout = $prodLayout;
				}
			}

		}

		if(!empty($layout)) {
			$view->setLayout( strtolower( $layout ) );
		}

	}
예제 #2
0
파일: index.php 프로젝트: ljarray/dbpedia
function calcConnectionDirectConnection($first, $second, $startlimit, $maxdepth, $depth, $ignoredObjects, $ignoredPredicates, $fullconnection)
{
    $time = microtime(true);
    mysql_connect($GLOBALS['host'], $GLOBALS['user'], $GLOBALS['password']);
    mysql_select_db($GLOBALS['db']);
    //fuer alte Links
    if (isset($_GET['maxdepth'])) {
        $maxdepth = $_GET['maxdepth'] + 1;
    }
    $foundconnection = false;
    $limit = $startlimit;
    $idcounter = 0;
    $htmlcounter = 0;
    $saveRow = array();
    //ignorierte Objekte/Praedikate kommen als Array an => Umrechnung in String fuer URL
    for ($i = 0; $i < count($ignoredObjects); $i++) {
        $permalinkIgnoreObjects .= '&amp;ignoreObject_' . $i . '=' . $ignoredObjects[$i];
    }
    for ($i = 0; $i < count($ignoredPredicates); $i++) {
        $permalinkIgnorePredicates .= '&amp;ignorePredicate_' . $i . '=' . $ignoredPredicates[$i];
    }
    //Ueberpruefung, ob gegebene Anfrage schon gespeichert ist
    include "queries.inc.php";
    $savedIndex = isSaved($first, $second, $limit, $maxdepth, $depth, $ignoredObjects, $ignoredPredicates);
    //Falls gegebene Anfrage schon gespeichert ist=> Ausgeben
    if (is_int($savedIndex)) {
        $lastdepth = -1;
        for ($i = 0; $i < count($queries[$savedIndex]['savedResult']['row']); $i++) {
            echo $lastdepth != $queries[$savedIndex]['savedResult']['depth'][$i] ? '<table style="border:solid 1px #FF8040;margin-left:2px;"><tr><td style="background-color:#e4e4e4;border:1px solid #CFCFCF;">Distance: ' . ($queries[$savedIndex]['savedResult']['depth'][$i] + 1) . '</td></tr>' : '';
            printResults($queries[$savedIndex]['savedResult']['row'][$i], $htmlcounter, $idcounter, $first, $second);
            echo $queries[$savedIndex]['savedResult']['depth'][$i] != $queries[$savedIndex]['savedResult']['depth'][$i + 1] || !isset($queries[$savedIndex]['savedResult']['depth'][$i + 1]) ? '</table><br>' : '';
            $lastdepth = $queries[$savedIndex]['savedResult']['depth'][$i];
        }
        echo 'This is a cached result. It was saved on ' . date('r', $queries[$savedIndex]['saveTime']) . '.<br>';
        $queries[$savedIndex]['clickCount']++;
        file_put_contents('queries.inc.php', "<?\n\$queries=" . var_export($queries, true) . ";\n?>");
    } else {
        if ($GLOBALS['usingClusterTable'] == true && $fullconnection == false) {
            $clusterConSwitch = calcConnectionCluster($first, $second, $maxdepth);
            if (is_Int($clusterConSwitch)) {
                $depth = $clusterConSwitch;
                echo 'We are now searching the complete data set for connections. Meanwhile, you may have a look at a preview result <a href="#" onclick="loadClusterConnection(\'ajax.php?f=6&amp;first=' . str_replace("%", "__perc__", $first) . '&amp;second=' . str_replace("%", "__perc__", $second) . $permalinkIgnoreObjects . $permalinkIgnorePredicates . '\')" title="Load Cluster Connection">here</a>.<br><br>';
                echo '<div id="clusterCon" style="display:none;"></div>';
                echo '<div id="ib_1000" style="position:absolute;top:500px;left:20%;width:200px;height:100px;"></div>';
                #echo ', or maybe you want to <a href="'.substr($_SERVER['PHP_SELF'],0,-strlen($_SERVER['SCRIPT_NAME'])).'index.php?firstObject='.$first.'&amp;secondObject='.$second.'&amp;limit='.$startlimit.'&amp;maxdistance='.$maxdepth.$permalinkIgnoreObjects.$permalinkIgnorePredicates.'&amp;fullc=true&amp;saved=saved">load the full Results</a>?<br><br>';
                $fullconnection = true;
            } else {
                if ($clusterConSwitch == 'notenoughdistance') {
                    echo 'For a Preview Result click <a href="#" onclick="loadClusterConnection(\'ajax.php?f=6&amp;first=' . str_replace("%", "__perc__", $first) . '&amp;second=' . str_replace("%", "__perc__", $second) . $permalinkIgnoreObjects . $permalinkIgnorePredicates . '\')" title="Load Cluster Connection">here</a>.<br>';
                    echo '<div id="clusterCon" style="display:none;"></div>';
                    echo '<div id="ib_0" style="position:absolute;top:500px;left:20%;width:200px;height:100px;"></div>';
                }
            }
        }
        if ($fullconnection == true || $GLOBALS['usingClusterTable'] == false) {
            ob_flush();
            flush();
            do {
                //Berechnung der Verbindung, falls dieses moeglich ist
                $res = mysql_query(getQuery($depth, $first, $second, $limit, $ignoredObjects, $ignoredPredicates)) or die(mysql_error());
                if (mysql_num_rows($res) > 0) {
                    $limit = $limit - mysql_num_rows($res);
                    $foundconnection = true;
                    echo '<table style="border:solid 1px #FF8040;margin-left:2px;"><tr><td style="background-color:#e4e4e4;border:1px solid #CFCFCF;">Distance: ' . ($depth + 1) . '</td></tr>';
                    while ($row = mysql_fetch_row($res)) {
                        printResults($row, $htmlcounter, $idcounter, $first, $second);
                        $saveRow['row'][] = $row;
                        $saveRow['depth'][] = $depth;
                    }
                    echo '</table><br>';
                } else {
                    if ($depth == $maxdepth - 1) {
                        echo "No Connection Found at max. Distance {$maxdepth} !<br><br>";
                        //f�r maximale Tiefe Fehlschlag ausgeben
                        #if ($GLOBALS['usingClusterTable']==true)
                        #calcConnectionCluster($first,$second,$maxdepth,true);
                    }
                }
                $depth++;
            } while ($depth < $maxdepth && $limit > 0);
            if ($foundconnection == true) {
                //Queries koennen abgespeichert werden, wenn eine Verbindung gefunden wurde
                echo '<span style="padding-left:2px;">Would you like to <a href="#" title="save Query" onmousedown="saveQuery(\'ajax.php?f=3&amp;first=' . str_replace("%", "__perc__", $first) . '&amp;second=' . str_replace("%", "__perc__", $second) . '&amp;limit=' . $startlimit . '&amp;maxdepth=' . $maxdepth . $permalinkIgnoreObjects . $permalinkIgnorePredicates . '&amp;depth=' . $depth . '\',\'' . str_replace('%', '__perc__', str_replace('"', '__quot__', serialize($saveRow))) . '\');">save</a> your query?</span><br>';
                echo '<span style="padding-left:2px;"><div id="save">&nbsp;</div></span><br>';
            }
        }
    }
    echo 'Result obtained in ' . round(microtime(true) - $time, 3) . ' seconds.<br>';
}