コード例 #1
0
ファイル: postprocessor.php プロジェクト: nibble-arts/oliv
 public function process($page)
 {
     global $_PLUGIN;
     //echoall($page);
     // call plugins
     //		$pageXml = olivxml_create($page,"page");
     if ($page) {
         $pageXml = OLIVPlugin::call(new simpleXmlElement($page), "render");
         //------------------------------------------------------------------------------
         // convert page xml to html
         if (sessionfile_exists(system::OLIV_TEMPLATE_PATH() . "post.xslt")) {
             $postStylesheet = sessionxml_load_file(system::OLIV_TEMPLATE_PATH() . "post.xslt");
         } else {
             OLIVError::fire("postprocessor.php::process - post.xslt file not found");
             die;
         }
         $htmlProcessor = new XSLTProcessor();
         $htmlProcessor->importStylesheet($postStylesheet);
         $pageString = $htmlProcessor->transformToXML($pageXml);
         //echoall($pageXml->asXML());
         //------------------------------------------------------------------------------
         // run markup parser
         $pageString = $this->markup($pageString);
         return $pageString;
     }
 }
コード例 #2
0
ファイル: search.php プロジェクト: nibble-arts/oliv
 public function __construct()
 {
     global $_INDEX;
     // check for index
     if (!OLIVIndex::is_index()) {
         OLIVError::fire("search.php - no index found");
     }
 }
コード例 #3
0
ファイル: olivscript.php プロジェクト: nibble-arts/oliv
 public function __construct()
 {
     global $_OSCODE;
     if (olivfile_exists(system::OLIV_OLIVSCRIPT() . "define.xml")) {
         $_OSCODE = olivxml_load_file(system::OLIV_OLIVSCRIPT() . "define.xml");
     } else {
         OLIVError::fire("OLIVScript::construct - olivscript definition not found");
     }
 }
コード例 #4
0
ファイル: template.php プロジェクト: nibble-arts/oliv
 public static function link_css($name)
 {
     $path = pathinfo($name);
     $cssPath = $path['dirname'] . "/";
     $cssName = $path['filename'] . ".css";
     if (!sessionfile_exists($cssPath . $cssName)) {
         $cssName = "default.css";
         // default.css class
     }
     // css file found
     if (sessionfile_exists($cssPath)) {
         echo "<link href='" . session_path($cssPath . $cssName) . "' rel='stylesheet' type='text/css'>";
         // link css to site
     } else {
         OLIVError::warning("template::link_css.php - no stylesheet found");
     }
 }
コード例 #5
0
ファイル: module.php プロジェクト: nibble-arts/oliv
 private function scan($path)
 {
     $modules = array();
     $cnt = 0;
     if ($modDir = olivopendir($path)) {
         while ($file = readdir($modDir)) {
             if (olivis_dir($path . $file) and $file != "." and $file != "..") {
                 $filePath = "{$file}/";
                 // get modules define.xml
                 if (olivfile_exists($path . $filePath)) {
                     // load module information
                     $xml = olivxml_load_file($path . $filePath . "define.xml");
                     //------------------------------------------------------------------------------
                     // check for session directory
                     $sessionDir = system::oliv_module_path() . $filePath;
                     if (sessionfile_exists($sessionDir)) {
                         $contentPath = $xml->content;
                         $templatePath = $xml->template;
                         // write directory permissions to module header
                         $xml->content['permission'] = get_permission(session_path($sessionDir) . $contentPath);
                         $xml->template['permission'] = get_permission(session_path($sessionDir) . $templatePath);
                     } else {
                         // session directory don't exist
                         $xml->status = "NO_SESSION_DIR";
                         $xml->permission = 0;
                     }
                     //------------------------------------------------------------------------------
                     // save module metadata
                     $modules[(string) $xml->name] = $xml;
                     $cnt++;
                 }
             }
         }
         closedir($modDir);
         system::set("modules", $modules);
         return $cnt;
     } else {
         OLIVError::fire("module::scan - directory {$path} not found");
     }
     return FALSE;
 }
コード例 #6
0
ファイル: preprocessor.php プロジェクト: nibble-arts/oliv
 public function process($page, $stylesheet, $templatePath)
 {
     $i = 0;
     $templates = array();
     $xmlString = "";
     $templArray = array();
     $linkArray = array();
     //------------------------------------------------------------------------------
     // parse site
     if (count($page->structure())) {
         $areas = $page->structure()->children();
         if (count($areas)) {
             foreach ($areas as $entry) {
                 // check for read access rights
                 // if not, clear node to hide from rendering
                 if (OLIVRight::r($entry)) {
                     if ($mod = $entry->attributes()->mod) {
                         $script = OLIVModule::getModuleByName($mod);
                         $originScript = $script;
                         //------------------------------------------------------------------------------
                         // script found
                         if (isset($script->script)) {
                             // insert parameters
                             olivxml_insert($script, OLIVPreprocessor::parse_param((string) $entry), "ALL");
                             // create paths for module, content, template, image
                             $script->path = system::OLIV_MODULE_PATH() . (string) $script->name . "/";
                             // insert script access rights
                             $script->access->r = OLIVRight::r($entry);
                             $script->access->w = OLIVRight::w($entry);
                             $script->access->x = OLIVRight::x($entry);
                             //------------------------------------------------------------------------------
                             // load module script
                             $this->loadScript($script->script->main, system::OLIV_MODULE_PATH() . $script->name . "/");
                             //------------------------------------------------------------------------------
                             // call module class and merge template and content
                             if ($script->script->main) {
                                 $tempArray = explode(".", $script->script->main);
                                 $class = $tempArray[0];
                                 if (class_exists($class)) {
                                     //------------------------------------------------------------------------------
                                     //------------------------------------------------------------------------------
                                     // create and execute module class
                                     $module = new $class($script);
                                     //------------------------------------------------------------------------------
                                     //------------------------------------------------------------------------------
                                     if (is_object($module)) {
                                         if (!method_exists($module, "template")) {
                                             OLIVError::fire("preprocessor.php::process - module '" . $script->name . "' don't extend OLIVModule");
                                         } else {
                                             $tempTemplate = $module->template();
                                             // set path to insert module-template-link stylesheet
                                             // link only if template and content found
                                             if ($module->template() and $module->content()) {
                                                 if (is_object($module->content())) {
                                                     //TODO register template
                                                     // load template array
                                                     array_push($linkArray, array("module" => (string) $mod, "area" => $entry->getName(), "content" => $module->content()->getName(), "templatePath" => $tempTemplate));
                                                     $templates[$entry->getName() . "::" . $module->content()->getName()] = $tempTemplate;
                                                 }
                                             }
                                             //------------------------------------------------------------------------------
                                             // module didn't return content and template
                                             // clear content entry
                                             if (!$module->content() and !$module->template()) {
                                                 $page->clear($entry->getName());
                                             }
                                             // insert module content in page content
                                             $page->insert($module->content(), $entry->getName());
                                         }
                                     } else {
                                         $page->clear($entry->getName());
                                     }
                                     // destroy module object
                                     //									unset($module);
                                 }
                             } else {
                                 OLIVError::fire("render::callModule - no main script declared");
                             }
                         } else {
                             OLIVError::warning("processor::process - required module '" . $mod . "' not found");
                         }
                     }
                     //------------------------------------------------------------------------------
                 } else {
                     $page->clear($entry->getName());
                 }
             }
             //echoall($page->structure());
         } else {
             OLIVError::fire("processor::process - page is empty");
         }
     }
     //------------------------------------------------------------------------------
     // include module templates in page template
     // create temporary xslt for include process
     $tempXsl = new XSLTProcessor();
     $tempXsl->registerPHPFunctions();
     // include page template
     if (sessionfile_exists($templatePath . ".xslt")) {
         $xmlString = "<xsl:include href='" . session_path($templatePath) . ".xslt'/>";
         OLIVTemplate::link_css($templatePath);
     } else {
         OLIVError::fire("preprocessor.php::process - no page template found");
     }
     //		status::set("debug",$linkArray);
     //------------------------------------------------------------------------------
     // create module link templates
     foreach ($linkArray as $entry) {
         // create stylesheet to link module template to page area
         $tempString = "<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>";
         $tempString .= "<xsl:template match='" . $entry['area'] . "'>";
         $tempString .= "<xsl:apply-templates select='" . $entry['content'] . "'/>";
         $tempString .= "</xsl:template>";
         $tempString .= "</xsl:stylesheet>";
         $tempXsl = new simpleXmlElement($tempString);
         $fileName = explode("/", $entry['templatePath']);
         array_pop($fileName);
         $fileName = implode("/", $fileName);
         $filePath = session_path($fileName) . "/link_" . $entry['area'] . "_to_" . $entry['content'] . ".xslt";
         // write link file to disk
         $fileHandle = fopen($filePath, "w");
         if ($fileHandle) {
             fputs($fileHandle, $tempXsl->asXML());
             fclose($fileHandle);
         }
         //------------------------------------------------------------------------------
         // insert link template
         $xmlString .= "<xsl:include href='" . $filePath . "'/>";
         //------------------------------------------------------------------------------
         // insert module template only once
         if (!array_key_exists($entry['templatePath'], $templArray)) {
             $templArray[$entry['templatePath']] = $filePath;
             if (sessionfile_exists($entry['templatePath'] . ".xslt")) {
                 // insert module template
                 $xmlString .= "<xsl:include href='" . session_path($entry['templatePath']) . ".xslt'/>";
                 // link css file
                 OLIVTemplate::link_css($entry['templatePath']);
             }
         }
     }
     //------------------------------------------------------------------------------
     // create temporary include template
     $xmlString = "<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>" . $xmlString . "</xsl:stylesheet>";
     $tempXml = new simpleXmlElement($xmlString);
     $stylesheet->importStylesheet($tempXml);
     //echoall($tempXml->children('http://www.w3.org/1999/XSL/Transform')->asXML());
     //status::set("debug",$page->structure());
 }
コード例 #7
0
ファイル: plugin.php プロジェクト: nibble-arts/oliv
 private static function scan($path)
 {
     global $_PLUGIN;
     //    $_PLUGIN = new simpleXmlElement("<plugin></plugin>");
     $_PLUGIN = new simpleXmlElement("<plugins></plugins>");
     if ($pluginDir = olivopendir($path)) {
         $cnt = 0;
         while ($file = readdir($pluginDir)) {
             if (olivis_dir($path . $file) and $file != "." and $file != "..") {
                 $file .= "/";
                 // get define.xml
                 if (olivfile_exists($path . $file . "define.xml")) {
                     $xml = olivxml_load_file($path . $file . "define.xml");
                     //TODO include plugin script
                     // get type of plugin
                     olivxml_insert($_PLUGIN, $xml, "ALL");
                 }
             }
         }
         closedir($pluginDir);
         return $cnt;
     } else {
         OLIVError::fire("plugin::scan - directory {$path} not found");
     }
     return FALSE;
 }
コード例 #8
0
ファイル: error.php プロジェクト: nibble-arts/oliv
 public static function fire($text)
 {
     echo OLIVError::renderError($text);
 }
コード例 #9
0
ファイル: xml.php プロジェクト: nibble-arts/oliv
function olivini_writeFile($iniArray, $path, $file, $lang)
{
    $headerString = "; creaded by oliv\n";
    $headerString .= "; timestamp " . time() . "\n";
    $headerString .= "; user " . status::OLIV_USER() . "\n";
    // convert array to string
    $iniString = olivini_array2string($iniArray);
    // create file name
    $file = "{$lang}.{$file}.ini";
    // get complete path to session
    $path = session_path($path . $file);
    // write string to file
    if ($iniString) {
        if (!($handle = fopen($path, 'w'))) {
            OLIVError::fire("olivini_writeFile -> can't open {$path} to write");
            return FALSE;
        }
        // insert header
        fwrite($handle, $headerString);
        if (!fwrite($handle, $iniString)) {
            OLIVError::fire("olivini_writeFile -> can't write to {$path}");
            return FALSE;
        } else {
            fclose($handle);
        }
        return TRUE;
    }
    return FALSE;
}
コード例 #10
0
ファイル: core.php プロジェクト: nibble-arts/oliv
 public static function loadScript($file, $path = "")
 {
     $path = system::OLIV_CORE_PATH() . $path;
     // redirect to core root directory
     if (file_exists($path . $file)) {
         // check for filetype
         $fileInfo = pathInfo($file);
         // debug
         // print_r("load script " . $path . $file . "<br>");
         switch ($fileInfo['extension']) {
             case 'php':
                 include_once $path . $file;
                 break;
             case 'js':
                 echo "<script type='text/javascript' src='{$path}{$file}'></script >";
                 break;
             default:
                 OLIVError::fire("core::loadScript - script {$path}{$file} unknown filetype");
                 return FALSE;
         }
         return $file;
     } else {
         OLIVError::fire("core::loadScript - script {$path}{$file} not found");
     }
     return FALSE;
 }
コード例 #11
0
ファイル: index.php プロジェクト: nibble-arts/oliv
 public function insertText($text, $url = "", $lang = "")
 {
     // remove punctuation marks in text
     $text = preg_replace("![\\.\\,\\;\\:\\(\\)\\[\\]\\{\\}\\-\\_\\/]!", " ", strtolower($text));
     // extract words
     $wordArray = explode(" ", $text);
     $wordArray = array_unique($wordArray);
     foreach ($wordArray as $word) {
         //	 		$word = strtolower(Normalizer::normalize($word,Normalizer::FORM_C));
         $word = strtolower($word);
         //TODO replace all special characters with root
         $specialChar = array("ä", "ö");
         $replaceChar = array();
         $word = OLIVText::remove_accents($word);
         //			$this->insertWord($word,$word);
         $suffArray = $this->makeSuffArray($word);
         foreach ($suffArray as $suffix) {
             $this->insertWord($suffix, status::url() . ":" . $url . ":{$lang}:{$word}", $lang);
         }
     }
     global $_INDEX;
     //echoall($_INDEX);
     // write index to disk
     $path = session_path("");
     $name = "index.idx";
     if (file_exists($path)) {
         $fh = fopen($path . $name, "w");
         if ($fh) {
             fwrite($fh, $_INDEX->asXML());
             fclose($fh);
         } else {
             OLIVError::fire("index.php - no write permission");
         }
     } else {
         OLIVError::fire("index.php - directory {$path} don't exist");
     }
 }
コード例 #12
0
ファイル: database.php プロジェクト: nibble-arts/oliv
 private function query($lang, $func, $table, $field = "", $where = "", $data = "", $sort = "")
 {
     $queryString = "";
     $tableArray = array($table);
     $fieldArray = array();
     $filterArray = array();
     $queryTable = "";
     $queryField = "";
     $queryWhere = "";
     /*echoall("lang: $lang, func: $func, table: $table, field: $field");
     echoall($where);
     echoall("data: $data, sort: $sort");*/
     //------------------------------------------------------------------------------
     // create relation table list
     foreach ($this->relation->children() as $entry) {
         array_push($tableArray, (string) $entry->attributes()->table);
     }
     $queryTable = implode(",", $tableArray);
     //------------------------------------------------------------------------------
     //TODO insert prefix to all table names
     //------------------------------------------------------------------------------
     // create where relation list
     if (is_array($where)) {
         // loop over all where clauses
         foreach ($where as $entry) {
             $whereField = (string) $entry->attributes()->field;
             $whereValue = (string) $entry->attributes()->value;
             $whereOp = (string) $entry->attributes()->operator;
             // relation field definition found
             if ($this->relation->{$whereField}) {
                 $relTableName = (string) $this->relation->{$whereField}->attributes()->table;
                 $relTableId = (string) $this->relation->{$whereField}->attributes()->id;
                 $relTableDisplay = (string) $this->relation->{$whereField}->attributes()->display;
                 array_push($filterArray, "{$relTableName}.content{$whereOp}'{$whereValue}' and {$table}.{$whereField}={$relTableName}.{$relTableId}");
             } else {
                 array_push($filterArray, "{$table}.{$whereField}{$whereOp}{$whereValue}");
             }
         }
         $idFilter = implode(" and ", $filterArray);
     }
     //------------------------------------------------------------------------------
     // create field relation list
     // get field list
     $fieldList = mysql_list_fields($this->name, $table);
     // loop fields
     if ($fieldList) {
         for ($x = 0; $x < mysql_num_fields($fieldList); $x++) {
             //TODO look if field defined or all fields
             $fieldName = mysql_field_name($fieldList, $x);
             // relation field found
             if ($this->relation->{$fieldName}) {
                 $relationId = $this->relation->{$fieldName}->attributes()->id;
                 $relationTable = $this->relation->{$fieldName}->attributes()->table;
                 // insert alias for relation
                 array_push($fieldArray, $relationTable . ".content AS " . $fieldName);
                 array_push($fieldArray, $relationTable . ".lang AS " . $fieldName . "_lang");
                 // language referenz
                 // insert filter parameters for relation
                 array_push($filterArray, "{$relationTable}.{$relationId}={$table}.{$fieldName}");
                 //------------------------------------------------------------------------------
                 // check for language
                 // filter string for entry filtering
                 $filterString = "{$relationTable}.{$relationId}={$table}.{$fieldName} and " . $idFilter;
                 // create where clause for language check
                 if ($filterString) {
                     // get database entry default language
                     $langQuery = "SELECT {$table}.lang FROM {$table},{$relationTable} WHERE {$filterString}";
                     // and lang='{$lang}'";
                     $langRes = mysql_query($langQuery);
                     if ($langRes) {
                         $defaultLang = mysql_fetch_array($langRes);
                         $defaultLang = $defaultLang['lang'];
                         // check if lang entry is present
                         // if not use entry default language
                         $langQuery = "SELECT {$table}.lang FROM {$table},{$relationTable} WHERE {$filterString} and {$relationTable}.lang='{$lang}'";
                         $langRes = mysql_query($langQuery);
                         // load current language
                         if (mysql_num_rows($langRes)) {
                             array_push($filterArray, "{$relationTable}.lang='{$lang}'");
                         } else {
                             array_push($filterArray, "{$relationTable}.lang='{$defaultLang}'");
                         }
                     } else {
                         OLIVError::fire("OLIVDatabase::query - no valid resource from query call");
                     }
                 }
             } else {
                 array_push($fieldArray, $table . "." . $fieldName . " AS " . $fieldName);
             }
         }
         $queryField = implode(",", $fieldArray);
     }
     //------------------------------------------------------------------------------
     // recreate where clause for query
     if ($filterArray) {
     }
     $queryWhere = implode(" and ", $filterArray);
     //echoall($queryWhere);
     //------------------------------------------------------------------------------
     // parse command
     if ($queryWhere) {
         $queryWhere = "WHERE " . $queryWhere;
     }
     switch (strtolower($func)) {
         case 'select':
             $queryString = "SELECT {$queryField} FROM {$queryTable} {$queryWhere} {$sort}";
             break;
         case 'insert':
             $queryString = "INSERT INTO {$queryTable} SET {$data}";
             break;
         case 'update':
             $queryString = "UPDATE {$queryTable} SET {$data} WHERE {$queryWhere}";
             break;
         case 'delete':
             $queryString = "DELETE FROM {$queryTable} WHERE {$queryWhere}";
             break;
     }
     if ($queryString) {
         //echoall($queryString);
         //------------------------------------------------------------------------------
         //------------------------------------------------------------------------------
         // mysql query call
         $this->sqlResource = mysql_query($queryString);
         $this->insertId = mysql_insert_id($this->dbResource);
         //------------------------------------------------------------------------------
         //------------------------------------------------------------------------------
     }
 }
コード例 #13
0
ファイル: page.php プロジェクト: nibble-arts/oliv
 public static function _load($pageName)
 {
     $xml = "";
     if (!$pageName) {
         $url = status::url();
         // if no url defined, user OLIV_INDEX_PAGE
         if (!$url) {
             $url = system::OLIV_INDEX_PAGE();
         }
         $pageName = strtolower($url);
         // set to lowercase
     }
     // create content path
     $path = system::OLIV_PAGE_PATH() . $pageName . "/" . $pageName . ".xml";
     if (sessionfile_exists($path)) {
         // load content xml
         $xml = sessionxml_load_file($path);
         //------------------------------------------------------------------------------
         // search for plugins and call methods
         if ($xml->content->include) {
             OLIVPlugin::call($xml->content, "page");
         }
         //------------------------------------------------------------------------------
         return $xml;
     } else {
         OLIVError::fire("page::load - page not found");
     }
     return FALSE;
 }
コード例 #14
0
ファイル: route.php プロジェクト: nibble-arts/oliv
 public function scan($lang)
 {
     $path = system::OLIV_PAGE_PATH() . "page.xml";
     if (sessionfile_exists($path)) {
         $pageXml = sessionxml_load_file($path);
         status::set("pages", $pageXml->define);
         status::set("pagestructure", $pageXml->structure);
         OLIVText::writeSource(status::pages(), $path);
     } else {
         OLIVError::fire("page::scan - page.xml not found -> rescan");
     }
 }