function selectSkin($blogid, $skinName) { $context = Model_Context::getInstance(); importlib('blogskin'); $blogid = getBlogId(); if (empty($skinName)) { return _t('실패했습니다.'); } if (strncmp($skinName, 'customize/', 10) == 0) { if (strcmp($skinName, "customize/{$blogid}") != 0) { return _t('실패 했습니다'); } } else { $skinName = Path::getBaseName($skinName); if ($skinName === '.' || $skinName === '..') { return _t('실패 했습니다'); } } if (file_exists(getSkinPath($skinName) . "/index.xml")) { $xml = file_get_contents(getSkinPath($skinName) . "/index.xml"); $xmls = new XMLStruct(); if (!$xmls->open($xml, $context->getProperty('service.encoding'))) { return _t('실패했습니다.'); } $assignments = array('skin' => $skinName); $value = $xmls->getValue('/skin/default/recentEntries'); if (!empty($value) || is_numeric($value)) { $assignments['entriesOnRecent'] = $value; } $value = $xmls->getValue('/skin/default/recentComments'); if (!empty($value) || is_numeric($value)) { $assignments['commentsOnRecent'] = $value; } $value = $xmls->getValue('/skin/default/itemsOnGuestbook'); if (!empty($value) || is_numeric($value)) { $assignments['commentsOnGuestbook'] = $value; } $value = $xmls->getValue('/skin/default/tagsInCloud'); if (!empty($value) || is_numeric($value)) { $assignments['tagsOnTagbox'] = $value; } $value = $xmls->getValue('/skin/default/sortInCloud'); if (!empty($value) || is_numeric($value)) { $assignments['tagboxAlign'] = $value; } $value = $xmls->getValue('/skin/default/recentTrackbacks'); if (!empty($value) || is_numeric($value)) { $assignments['trackbacksOnRecent'] = $value; } $value = $xmls->getValue('/skin/default/expandComment'); if (isset($value)) { $assignments['expandComment'] = $value ? '1' : '0'; } $value = $xmls->getValue('/skin/default/expandTrackback'); if (isset($value)) { $assignments['expandTrackback'] = $value ? '1' : '0'; } $value = $xmls->getValue('/skin/default/lengthOfRecentNotice'); if (!empty($value) || is_numeric($value)) { $assignments['recentNoticeLength'] = $value; } $value = $xmls->getValue('/skin/default/lengthOfRecentPage'); if (!empty($value) || is_numeric($value)) { $assignments['recentPageLength'] = $value; } $value = $xmls->getValue('/skin/default/lengthOfRecentEntry'); if (!empty($value) || is_numeric($value)) { $assignments['recentEntryLength'] = $value; } $value = $xmls->getValue('/skin/default/lengthOfRecentComment'); if (!empty($value) || is_numeric($value)) { $assignments['recentCommentLength'] = $value; } $value = $xmls->getValue('/skin/default/lengthOfRecentTrackback'); if (!empty($value) || is_numeric($value)) { $assignments['recentTrackbackLength'] = $value; } $value = $xmls->getValue('/skin/default/lengthOfLink'); if (!empty($value) || is_numeric($value)) { $assignments['linkLength'] = $value; } $value = $xmls->getValue('/skin/default/contentWidth'); if (!empty($value) || is_numeric($value)) { $assignments['contentWidth'] = $value; } $value = $xmls->getValue('/skin/default/showListOnCategory'); if (isset($value)) { $assignments['showListOnCategory'] = $value; } $value = $xmls->getValue('/skin/default/showListOnArchive'); if (isset($value)) { $assignments['showListOnArchive'] = $value; } $value = $xmls->getValue('/skin/default/showListOnTag'); if (isset($value)) { $assignments['showListOnTag'] = $value; } $value = $xmls->getValue('/skin/default/showListOnSearch'); if (isset($value)) { $assignments['showListOnSearch'] = $value; } $value = $xmls->getValue('/skin/default/showListOnAuthor'); if (isset($value)) { $assignments['showListOnAuthor'] = $value; } $value = $xmls->getValue('/skin/default/tree/color'); if (isset($value)) { $assignments['colorOnTree'] = $value; } $value = $xmls->getValue('/skin/default/tree/bgColor'); if (isset($value)) { $assignments['bgcolorOnTree'] = $value; } $value = $xmls->getValue('/skin/default/tree/activeColor'); if (isset($value)) { $assignments['activecolorOnTree'] = $value; } $value = $xmls->getValue('/skin/default/tree/activeBgColor'); if (isset($value)) { $assignments['activebgcolorOnTree'] = $value; } $value = $xmls->getValue('/skin/default/tree/labelLength'); if (!empty($value) || is_numeric($value)) { $assignments['labelLengthOnTree'] = $value; } $value = $xmls->getValue('/skin/default/tree/showValue'); if (isset($value)) { $assignments['showValueOnTree'] = $value ? '1' : '0'; } foreach ($assignments as $name => $value) { Setting::setSkinSetting($name, $value, $blogid); } if ($xmls->doesExist('/skin/support')) { foreach ($xmls->selectNodes('/skin/support') as $support) { if (!empty($support['.attributes']['mobile']) && $support['.attributes']['mobile'] == "yes") { /// Main skin supports mobile, too. Setting::setBlogSetting('useiPhoneUI', 0, true); } else { Setting::setBlogSetting('useiPhoneUI', 1, true); } } } else { Setting::setBlogSetting('useiPhoneUI', 1, true); } // none/single/multiple $value = $xmls->getValue('/skin/default/commentMessage/none'); if (is_null($value)) { Setting::setBlogSetting('noneCommentMessage', NULL, true); } else { Setting::setBlogSetting('noneCommentMessage', $value, true); } $value = $xmls->getValue('/skin/default/commentMessage/single'); if (is_null($value)) { Setting::setBlogSetting('singleCommentMessage', NULL, true); } else { Setting::setBlogSetting('singleCommentMessage', $value, true); } $value = $xmls->getValue('/skin/default/trackbackMessage/none'); if (is_null($value)) { Setting::setBlogSetting('noneTrackbackMessage', NULL, true); } else { Setting::setBlogSetting('noneTrackbackMessage', $value, true); } $value = $xmls->getValue('/skin/default/trackbackMessage/single'); if (is_null($value)) { Setting::setBlogSetting('singleTrackbackMessage', NULL, true); } else { Setting::setBlogSetting('singleTrackbackMessage', $value, true); } } else { Setting::setBlogSetting('noneCommentMessage', NULL, true); Setting::setBlogSetting('singleCommentMessage', NULL, true); Setting::setBlogSetting('noneTrackbackMessage', NULL, true); Setting::setBlogSetting('singleTrackbackMessage', NULL, true); Setting::setSkinSetting('skin', $skinName, $blogid); } Setting::removeBlogSetting("sidebarOrder", true); CacheControl::flushAll(); CacheControl::flushSkin(); Path::removeFiles(getSkinPath('customize/' . getBlogId()) . "/"); Setting::getSkinSettings($blogid, true); // refresh skin cache return true; }
function flushItemsByPlugin($pluginName) { global $databases; $xmls = new XMLStruct(); $manifest = @file_get_contents(ROOT . "/plugins/{$pluginName}/index.xml"); if ($manifest && $xmls->open($manifest)) { if ($xmls->doesExist('/plugin/binding/listener')) { //event listener가 있는 경우 foreach ($xmls->selectNodes('/plugin/binding/listener') as $listener) { if (!empty($listener['.attributes']['event']) && !empty($listener['.value'])) { // Event가 있는 경우 if (strpos(strtolower($listener['.attributes']['event']), 'view') !== false) { CacheControl::flushCategory(); } } } unset($listener); } if ($xmls->doesExist('/plugin/binding/tag')) { foreach ($xmls->selectNodes('/plugin/binding/tag') as $tag) { if (!empty($tag['.attributes']['name']) && !empty($tag['.attributes']['handler'])) { CacheControl::flushCategory(); CacheControl::flushTag(); } } unset($tag); } // if ($xmls->doesExist('/plugin/binding/sidebar')) { // TODO: 사이드바 캐시때 처리하도록 하지요. // } if ($xmls->doesExist('/plugin/binding/formatter[lang()]')) { CacheControl::flushCategory(); } } }
function getPluginInformation($plugin) { $xmls = new XMLStruct(); // Error checking routine if (!preg_match('@^[A-Za-z0-9 _-]+$@', $plugin)) { return false; } if (!file_exists(ROOT . "/plugins/{$plugin}/index.xml")) { return false; } if (!$xmls->open(file_get_contents(ROOT . "/plugins/{$plugin}/index.xml"))) { error_log("PLUGIN XML_PARSE_ERROR: " . $plugin . ": " . xml_error_string($xmls->error['code'])); return false; } else { // Determine plugin scopes. $scopeByXMLPath = array('admin' => '/plugin/binding/adminMenu', 'blog' => '/plugin/binding/tag', 'center' => '/plugin/binding/center', 'coverpage' => '/plugin/binding/coverpage', 'global' => '/plugin/binding/listener', 'sidebar' => '/plugin/binding/sidebar', 'editor' => '/plugin/binding/editor', 'formatter' => '/plugin/binding/formatter'); $pluginScope = array(); $scopeCount = 0; foreach ($scopeByXMLPath as $key => $value) { if ($xmls->doesExist($value)) { array_push($pluginScope, $key); $scopeCount = $scopeCount + 1; } } if ($scopeCount == 0) { array_push($pluginScope, 'none'); } // load plugin information. $maxVersion = max($xmls->getValue('/plugin/requirements/tattertools'), $xmls->getValue('/plugin/requirements/textcube')); $requiredVersion = empty($maxVersion) ? 0 : $maxVersion; $pluginInformation = array('link' => $xmls->getValue('/plugin/link[lang()]'), 'title' => $xmls->getValue('/plugin/title[lang()]'), 'version' => $xmls->getValue('/plugin/version[lang()]'), 'requirements' => $requiredVersion, 'scope' => $pluginScope, 'description' => $xmls->getValue('/plugin/description[lang()]'), 'authorLink' => $xmls->getAttribute('/plugin/author[lang()]', 'link'), 'author' => $xmls->getValue('/plugin/author[lang()]'), 'config' => $xmls->doesExist('/plugin/binding/config'), 'directory' => trim($plugin), 'width' => $xmls->getAttribute('/plugin/binding/config/window', 'width'), 'height' => $xmls->getAttribute('/plugin/binding/config/window', 'height'), 'privilege' => $xmls->getValue('/plugin/requirements/privilege')); return $pluginInformation; } return null; }
/// See the GNU General Public License for more details. (/documents/LICENSE, /documents/COPYRIGHT) $IV = array('GET' => array('Name' => array('string'), 'Tab' => array('string', 'default' => 'about'))); require ROOT . '/library/preprocessor.php'; $targetURL = $context->getProperty('uri.host') . preg_replace('/(currentSetting)$/', 'receiveConfig', $context->getProperty('uri.folder')); $pluginName = $_GET['Name']; $tabName = $_GET['Tab']; $active = in_array($pluginName, $activePlugins); $result = handleConfig($pluginName); if (is_null($result)) { Respond::NotFoundPage(); } $xmls = new XMLStruct(); if (!$xmls->open(file_get_contents(ROOT . "/plugins/{$pluginName}/index.xml"))) { Respond::NotFoundPage(); } else { $pluginAttrs = array("link" => $xmls->getValue('/plugin/link[lang()]'), "title" => htmlspecialchars($xmls->getValue('/plugin/title[lang()]')), "version" => htmlspecialchars($xmls->getValue('/plugin/version[lang()]')), "requirements" => $xmls->doesExist('/plugin/requirements/tattertools') ? $xmls->getValue('/plugin/requirements/tattertools') : $xmls->getValue('/plugin/requirements/textcube'), "description" => htmlspecialchars($xmls->getValue('/plugin/description[lang()]')), "authorLink" => $xmls->getAttribute('/plugin/author[lang()]', 'link'), "author" => htmlspecialchars($xmls->getValue('/plugin/author[lang()]')), "license" => htmlspecialchars($xmls->getValue('/plugin/license[lang()]')), "scope" => array()); if ($xmls->doesExist('/plugin/binding/adminMenu')) { array_push($pluginAttrs['scope'], '관리자'); } if ($xmls->doesExist('/plugin/binding/tag')) { array_push($pluginAttrs['scope'], '블로그'); } if ($xmls->doesExist('/plugin/binding/center')) { array_push($pluginAttrs['scope'], '대시보드'); } if ($xmls->doesExist('/plugin/binding/listener')) { array_push($pluginAttrs['scope'], '분류없음'); } if ($xmls->doesExist('/plugin/binding/sidebar')) { array_push($pluginAttrs['scope'], '사이드바'); }
function saveFeedItems($feedId, $xml) { global $database, $service; $xmls = new XMLStruct(); if (!$xmls->open($xml, $service['encoding'])) { return false; } if ($xmls->getAttribute('/rss', 'version')) { for ($i = 0; $link = $xmls->getValue("/rss/channel/item[{$i}]/link"); $i++) { $item = array('permalink' => rawurldecode($link)); if (!($item['author'] = $xmls->getValue("/rss/channel/item[{$i}]/author"))) { $item['author'] = $xmls->getValue("/rss/channel/item[{$i}]/dc:creator"); } $item['title'] = $xmls->getValue("/rss/channel/item[{$i}]/title"); if (!($item['description'] = $xmls->getValue("/rss/channel/item[{$i}]/content:encoded"))) { $item['description'] = $xmls->getValue("/rss/channel/item[{$i}]/description"); } $item['tags'] = array(); for ($j = 0; $tag = $xmls->getValue("/rss/channel/item[{$i}]/category[{$j}]"); $j++) { if (!empty($tag)) { array_push($item['tags'], $tag); } } for ($j = 0; $tag = $xmls->getValue("/rss/channel/item[{$i}]/subject[{$j}]"); $j++) { if (!empty($tag)) { array_push($item['tags'], $tag); } } $item['enclosures'] = array(); for ($j = 0; $url = $xmls->getAttribute("/rss/channel/item[{$i}]/enclosure[{$j}]", 'url'); $j++) { if (!empty($url)) { array_push($item['enclosures'], $url); } } if ($xmls->getValue("/rss/channel/item[{$i}]/pubDate")) { $item['written'] = parseDate($xmls->getValue("/rss/channel/item[{$i}]/pubDate")); } else { if ($xmls->getValue("/rss/channel/item[{$i}]/dc:date")) { $item['written'] = parseDate($xmls->getValue("/rss/channel/item[{$i}]/dc:date")); } else { $item['written'] = 0; } } saveFeedItem($feedId, $item); } } else { if ($xmls->doesExist('/feed')) { for ($i = 0; $link = $xmls->getValue("/feed/entry[{$i}]/id"); $i++) { for ($j = 0; $rel = $xmls->getAttribute("/feed/entry[{$i}]/link[{$j}]", 'rel'); $j++) { if ($rel == 'alternate') { $link = $xmls->getAttribute("/feed/entry[{$i}]/link[{$j}]", 'href'); break; } } $item = array('permalink' => rawurldecode($link)); $item['author'] = $xmls->getValue("/feed/entry[{$i}]/author/name"); $item['title'] = $xmls->getValue("/feed/entry[{$i}]/title"); if (!($item['description'] = $xmls->getValue("/feed/entry[{$i}]/content"))) { $item['description'] = $xmls->getValue("/feed/entry[{$i}]/summary"); } $item['tags'] = array(); for ($j = 0; $tag = $xmls->getValue("/feed/entry[{$i}]/dc:subject[{$j}]"); $j++) { if (!empty($tag)) { array_push($item['tags'], $tag); } } $item['enclosures'] = array(); for ($j = 0; $url = $xmls->getAttribute("/feed/entry[{$i}]/enclosure[{$j}]", 'url'); $j++) { if (!empty($url)) { array_push($item['enclosures'], $url); } } $item['written'] = parseDate($xmls->getValue("/feed/entry[{$i}]/issued")); saveFeedItem($feedId, $item); } } else { if ($xmls->getAttribute('/rdf:RDF', 'xmlns')) { for ($i = 0; $link = $xmls->getValue("/rdf:RDF/item[{$i}]/link"); $i++) { $item = array('permalink' => rawurldecode($link)); $item['author'] = $xmls->getValue("/rdf:RDF/item[{$i}]/dc:creator"); $item['title'] = $xmls->getValue("/rdf:RDF/item[{$i}]/title"); if (!($item['description'] = $xmls->getValue("/rdf:RDF/item[{$i}]/content:encoded"))) { $item['description'] = $xmls->getValue("/rdf:RDF/item[{$i}]/description"); } $item['tags'] = array(); $item['enclosures'] = array(); $item['written'] = parseDate($xmls->getValue("/rdf:RDF/item[{$i}]/dc:date")); saveFeedItem($feedId, $item); } } else { return false; } } } $deadLine = 0; $feedlife = POD::queryCell("SELECT feedlife FROM {$database['prefix']}FeedSettings"); if ($feedlife > 0) { $deadLine = gmmktime() - $feedlife * 86400; } if ($result = POD::queryAll("SELECT id FROM {$database['prefix']}FeedItems LEFT JOIN {$database['prefix']}FeedStarred ON id = item WHERE item IS NULL AND written < {$deadLine}")) { while (list($id) = array_shift($result)) { POD::query("DELETE FROM {$database['prefix']}FeedItems WHERE id = {$id}"); } } if ($result = POD::queryAll("SELECT blogid, item FROM {$database['prefix']}FeedReads LEFT JOIN {$database['prefix']}FeedItems ON id = item WHERE id IS NULL")) { while (list($readsOwner, $readsItem) = array_shift($result)) { POD::query("DELETE FROM {$database['prefix']}FeedReads WHERE blogid = {$readsOwner} AND item = {$readsItem}"); } } return true; }
if (version_compare($currentTextcubeVersion, $requiredMinVersion) < 0) { $disablePlugin = true; } } if (!is_null($requiredMaxVersion)) { if (version_compare($currentTextcubeVersion, $requiredMaxVersion) > 0) { $disablePlugin = true; } } if (!is_null($requiredTextcubeVersion)) { if (version_compare($currentTextcubeVersion, $requiredTextcubeVersion) < 0) { $disablePlugin = true; } } if ($disablePlugin == false) { if ($xmls->doesExist('/plugin/version')) { $version = $xmls->getValue('/plugin/version'); } if ($xmls->doesExist('/plugin/storage')) { foreach ($xmls->selectNodes('/plugin/storage/table') as $table) { $storageMappings = array(); $storageKeymappings = array(); if (empty($table['name'][0]['.value'])) { continue; } $tableName = htmlspecialchars($table['name'][0]['.value']); if (!empty($table['fields'][0]['field'])) { foreach ($table['fields'][0]['field'] as $field) { if (!isset($field['name'])) { continue; }
function getFeedItems($xml) { if (preg_match('/^<\?xml[^<]*\s+encoding=["\']?([\w-]+)["\']?/', $xml, $matches)) // kor env $encoding = $matches[1]; if (strcasecmp($encoding, 'euc-kr') == 0) { $xml = UTF8::bring($xml, $encoding); $xml = preg_replace('/^(<\?xml[^<]*\s+encoding=)["\']?[\w-]+["\']?/', '$1"utf-8"', $xml, 1); } $xmls=new XMLStruct(); if (!$xmls->open($xml)) return false; $items = array(); if ($xmls->getAttribute('/rss','version')){ // rss element must have version attribute for ($i=1;$link=$xmls->getValue("/rss/channel/item[$i]/link");$i++){ $item=array('permalink'=>rawurldecode($link)); if (!$item['author']=$xmls->getValue("/rss/channel/item[$i]/author")) $item['author']=$xmls->getValue("/rss/channel/item[$i]/dc:creator"); $item['title']=$xmls->getValue("/rss/channel/item[$i]/title"); if (!$item['description']=$xmls->getValue("/rss/channel/item[$i]/content:encoded")) $item['description']=htmlspecialchars_decode($xmls->getValue("/rss/channel/item[$i]/description")); $item['tags']=array(); for ($j=1;$tag=$xmls->getValue("/rss/channel/item[$i]/category[$j]");$j++) if (!empty($tag)) { // array_push($item['tags'],$tag); $tags = explode('/', $tag); // allblog, blogkorea types foreach($tags as $tag) { array_push($item['tags'], trim($tag)); } } for ($j=1;$tag=$xmls->getValue("/rss/channel/item[$i]/subject[$j]");$j++) if (!empty($tag)) array_push($item['tags'],$tag); if ($youtubeTags = $xmls->getValue("/rss/channel/item[$i]/media:category")) { // for Youtube,Flickr Feed array_push($item['tags'], ''); // blank. first tag not equals category foreach (explode(' ', $youtubeTags) as $tag) { $tag = trim($tag); if(!empty($tag)) array_push($item['tags'], $tag); } } $item['enclosures']=array(); for ($j=1;$result=$xmls->getAttributes("/rss/channel/item[$i]/enclosure[$j]",array('url','type'));$j++) { if (!empty($result)) { array_push($item['enclosures'],array('url'=>$result[0],'type'=>$result[1])); } } $flickrContent=$xmls->getAttributes("/rss/channel/item[$i]/media:content[$j]",array('url','type')); // for flickr feed if(!empty($flickrContent)) { array_push($item['enclosures'],array('url'=>$flickrContent[0],'type'=>$flickrContent[1])); } if ($xmls->getValue("/rss/channel/item[$i]/pubDate")) $item['written']=Feed::parseDate($xmls->getValue("/rss/channel/item[$i]/pubDate")); elseif ($xmls->getValue("/rss/channel/item[$i]/dc:date")) $item['written']=Feed::parseDate($xmls->getValue("/rss/channel/item[$i]/dc:date")); else $item['written']=0; if (!$item['generator']=$xmls->getValue("/rss/channel/generator")) { if (strpos($item['permalink'], 'tvpot.daum.net') !== false) $item['generator'] = 'Daum Tvpot'; else $item['generator'] = 'Unknown'; } if (!$item['guid']=$xmls->getValue("/rss/channel/item[$i]/guid")) $item['guid'] = $item['permalink']; array_push($items, $item); } } elseif ($xmls->doesExist('/feed')){ // atom 0.3 for ($i=1;$link=$xmls->getValue("/feed/entry[$i]/id");$i++){ $item['enclosures']=array(); for ($j=1;$rel=$xmls->getAttribute("/feed/entry[$i]/link[$j]",'rel');$j++){ if ($rel=='alternate'){ $link=$xmls->getAttribute("/feed/entry[$i]/link[$j]",'href'); } else if($rel=='enclosure' || $rel=='image') { $result = $xmls->getAttributes("/feed/entry[$i]/link[$j]",array('href','type')); if($result) { array_push($item['enclosures'],array('url'=>$result[0],'type'=>$result[1])); } } } $item=array('permalink'=>rawurldecode($link),'enclosures'=>$item['enclosures']); $item['author']=$xmls->getValue("/feed/entry[$i]/author/name"); $item['title']=$xmls->getValue("/feed/entry[$i]/title"); if (!$item['description']=htmlspecialchars_decode($xmls->getValue("/feed/entry[$i]/content"))) $item['description']=htmlspecialchars_decode($xmls->getValue("/feed/entry[$i]/summary")); $item['tags']=array(); for ($j=1;$tag=$xmls->getValue("/feed/entry[$i]/dc:subject[$j]");$j++) { if (!empty($tag)) array_push($item['tags'],trim($tag)); } for ($j=1;$tag=$xmls->getAttribute("/feed/entry[$i]/category[$j]", 'term');$j++) { if (!empty($tag)) array_push($item['tags'],trim($tag)); } if (!$item['written']= $xmls->getValue("/feed/entry[$i]/issued")) { if (!$item['written'] = $xmls->getValue("/feed/entry[$i]/published")) { $item['written'] = $xmls->getValue("/feed/entry[$i]/updated"); } } $item['written'] = Feed::parseDate($item['written']); if (!$item['generator'] = $xmls->getValue("/feed/generator")) $item['generator'] = 'Unknown'; array_push($items, $item); } } elseif ($xmls->getAttribute('/rdf:RDF','xmlns')){ // rss 1.0, rdf for ($i=1;$link=$xmls->getValue("/rdf:RDF/item[$i]/link");$i++){ $item=array('permalink'=>rawurldecode($link)); if (!$item['author']=$xmls->getValue("/rdf:RDF/item[$i]/dc:creator")) $item['author']=$xmls->getValue("/rdf:RDF/item[$i]/author"); // for NaverBlog rss 1.0 $item['title']=$xmls->getValue("/rdf:RDF/item[$i]/title"); if (!$item['description']=$xmls->getValue("/rdf:RDF/item[$i]/content:encoded")) $item['description']=htmlspecialchars_decode($xmls->getValue("/rdf:RDF/item[$i]/description")); $item['tags']=array(); $item['enclosures']=array(); $item['written']=Feed::parseDate($xmls->getValue("/rdf:RDF/item[$i]/dc:date")); array_push($items, $item); } } else return false; return $items; }
function createPluginTable($pluginName) { requireComponent('LZ.PHP.XMLStruct'); $xmls = new XMLStruct; if (!$xmls->openFile(ROOT . '/plugins/'. $pluginName .'/index.xml')) return ''; if ($xmls->doesExist('/plugin/storage')) { foreach ($xmls->selectNodes('/plugin/storage/table') as $table) { $storageMappings = array(); $storageKeymappings = array(); if(empty($table['name'][0]['.value'])) continue; $tableName = htmlspecialchars($table['name'][0]['.value']); if (!empty($table['fields'][0]['field'])) { foreach($table['fields'][0]['field'] as $field) { if (!isset($field['name'])) continue; // Error? maybe loading fail, so skipping is needed. $fieldName = $field['name'][0]['.value']; if (!isset($field['attribute'])) continue; // Error? maybe loading fail, so skipping is needed. $fieldAttribute = $field['attribute'][0]['.value']; $fieldLength = isset($field['length']) ? $field['length'][0]['.value'] : -1; $fieldIsNull = isset($field['isnull']) ? $field['isnull'][0]['.value'] : 1; $fieldDefault = isset($field['default']) ? $field['default'][0]['.value'] : null; $fieldAutoIncrement = isset($field['autoincrement']) ? $field['autoincrement'][0]['.value'] : 0; array_push($storageMappings, array('name' => $fieldName, 'attribute' => $fieldAttribute, 'length' => $fieldLength, 'isnull' => $fieldIsNull, 'default' => $fieldDefault, 'autoincrement' => $fieldAutoIncrement)); } } if (!empty($table['key'][0]['.value'])) { foreach($table['key'] as $key) { array_push($storageKeymappings, $key['.value']); } } plugin::treatPluginTable($pluginName, $tableName,$storageMappings,$storageKeymappings, $version); unset($tableName); unset($storageMappings); unset($storageKeymappings); } } }