コード例 #1
0
ファイル: index.php プロジェクト: precurse/netharbour
					<div id='title' class='portlet-header'>";
			echo $title;
			echo "<div class='minimize'></div></div>
					<div id='information' class='portlet-content'>";
			echo $widget->get_content();
			echo  "</div>
				   </div>";
		}
	}
}
echo "</div>";*/
print "<script language='javascript'>\n\$(function() {";
foreach ($userWidgets as $widgetID => $userID) {
    $curWidgetInfo = new Widgets($widgetID);
    $widgetClass = $curWidgetInfo->get_class_name();
    $phpFile = $curWidgetInfo->get_filename();
    $fh = fopen($phpFile, 'r');
    $data = fread($fh, filesize($phpFile));
    fclose($fh);
    if (!preg_match("/echo /i", $data) && !preg_match("/print /i", $data)) {
        //	if (preg_match
        if (class_exists($widgetClass)) {
            $widget = new $widgetClass();
        } else {
            print "\$(\"#id" . $widgetID . "\").html(\"Your class, \"" . $widgetClass . "\", taken from the database does not exist in your php file\");";
        }
        if (method_exists($widget, 'get_content')) {
            if ($widget->get_content() != '') {
                echo "\$(\"#id" . $widgetID . "\").load(\"loadPortlet.php?widget=" . $widgetID . "\");";
            }
        } else {
コード例 #2
0
ファイル: loadPortlet.php プロジェクト: precurse/netharbour
<?php

include_once "sessionCheck.php";
include_once "classes/Widgets.php";
$userID = $_SESSION['userid'];
$curUser = new DashboardUsers($userID);
$userWidgets = $curUser->get_users_widgets();
if ($userWidgets != '') {
    foreach ($userWidgets as $widgetID => $userID) {
        if ($_GET['widget'] == $widgetID) {
            $curWidgetInfo = new Widgets($widgetID);
            $filename = $curWidgetInfo->get_filename();
            if (file_exists($filename)) {
                include_once $filename;
                $widgetClass = $curWidgetInfo->get_class_name();
                if (class_exists($widgetClass)) {
                    $widget = new $widgetClass();
                    if (method_exists($widget, 'get_content')) {
                        echo $widget->get_content();
                    } else {
                        echo "No Content to retrieve";
                    }
                }
            }
        }
    }
}
コード例 #3
0
function checkDirForWidget($dir)
{
    $process = true;
    $error;
    if (is_dir($dir)) {
        if ($dh = opendir($dir)) {
            $index = 0;
            while (($file = readdir($dh)) !== false) {
                if (!preg_match("/\\./", $file)) {
                    //checkDirForWidget($dir.$file."/");
                    $filename = $dir . $file . "/widget.php";
                    $configPath = $dir . $file . "/config.xml";
                    $xml = simplexml_load_file($configPath);
                    $className = $xml->className;
                    $name = $xml->name;
                    $description = $xml->description;
                    $version = $xml->version;
                    $title = $xml->title;
                    if (isset($className) && $className != "") {
                        $allWidgets = Widgets::get_widgets();
                        $exists = false;
                        foreach ($allWidgets as $id => $value) {
                            $tempWidget = new Widgets($id);
                            if ($tempWidget->get_filename() == $filename) {
                                $exists = true;
                                $widget = new Widgets($id);
                            }
                        }
                        if (!$exists) {
                            $widget = new Widgets();
                        }
                        $widget->set_name($name);
                        $widget->set_description($description);
                        $widget->set_filename($filename);
                        $widget->set_class_name($className);
                        $widget->set_conf_path($configPath);
                        $widget->set_version($version);
                        if (!$exists) {
                            if ($widget->insert_widget()) {
                                $process = true;
                            } else {
                                $error = $widget->get_error();
                                $process = false;
                                break;
                            }
                        } else {
                            if ($widget->update_widget()) {
                                $process = true;
                            } else {
                                $error = $widget->get_error();
                                $process = false;
                                break;
                            }
                        }
                    }
                }
                if ($index > 9999) {
                    break;
                }
            }
            closedir($dh);
        }
    }
    if ($process) {
        return true;
    } else {
        return $error;
    }
}