Inherited by APIUpgradeManager, ActivityTrackerUpgradeManager, ArticleUpgradeManager, AttachmentUpgradeManager, AutoLoginUpgradeManager, BlogUpgradeManager, BookmarkUpgradeManager, CalendarUpgradeManager, ClassificationUpgradeManager, CommentUpgradeManager, ComponentUpgradeManager, ConnectableUpgradeManager, ContextHelpUpgradeManager, DataSyncUpgradeManager, DocumentUpgradeManager, EmailUpgradeManager, ErrorLogUpgradeManager, FileshareUpgradeManager, ForumUpgradeManager, GlossaryUpgradeManager, HtmlEditorUpgradeManager, ImageUpgradeManager, LinkLibraryUpgradeManager, LoginUpgradeManager, MenuUpgradeManager, ModuleUpgradeManager, OnlineHelpUpgradeManager, OpenDataUpgradeManager, PageUpgradeManager, ProcessUpgradeManager, QuestionnaireUpgradeManager, RatingUpgradeManager, RedirectUpgradeManager, ReportManagerUpgradeManager, RoleUpgradeManager, RssFeedUpgradeManager, ScheduledTaskUpgradeManager, ScrollUpgradeManager, SectionUpgradeManager, SessionPersistenceUpgradeManager, SettingsUpgradeManager, SharingUpgradeManager, SiteMapUpgradeManager, SiteUpgradeManager, SurveyUpgradeManager, SvgChartsUpgradeManager, TaxonomyUpgradeManager, TextLookupUpgradeManager, ToolHintsUpgradeManager, UserUpgradeManager, VersionedContentUpgradeManager, and VideoUpgradeManager.
|
| UpgradeManager () |
|
| upgrade ($upgrade_to="") |
|
| upgradeOneVersion ($version_number, $function) |
|
| executeVersionSql ($version_number) |
|
| parseSQLStatements ($lines) |
|
| executeSQLStatements ($sqlStatements) |
|
| log ($text) |
|
| executeVersionXML ($version) |
|
| recordUpdate ($version, $description) |
|
| saveLogFile ($version) |
|
| addSectionContent ($items, $section_name="/", $role="", $template="", $permissions="") |
| Utility function for use by calling classes to add an array of items of class Page, ComponentPage, Blog, ImageGallery, DocumentLibrary, Calendar to a section. More...
|
|
| addModuleToPages ($items, $module_name, $position='right', $sort_order=1) |
| Given an array of either identifiers that must be either CMS Page or ComponentPage identifiers or items that are of obj CMSPage, Blog, Calendar, etc., link each to the specified module. More...
|
|
| searchByIdentifier ($identifier) |
|
| addMenuItem ($item, $menu_identifier, $parent_identifier="", $title="", $section_name="", $sort_order=0) |
|
| reformatPhone (&$item, $field) |
|
| executeSQLFile ($sqlFile, $version_number) |
|
| dependsOn ($component, $version) |
|
Definition at line 191 of file upgrade_manager.inc.
◆ addMenuItem()
UpgradeManager::addMenuItem |
( |
|
$item, |
|
|
|
$menu_identifier, |
|
|
|
$parent_identifier = "" , |
|
|
|
$title = "" , |
|
|
|
$section_name = "" , |
|
|
|
$sort_order = 0 |
|
) |
| |
Definition at line 693 of file upgrade_manager.inc.
696 $menus = Query::create(
Menu,
"WHERE identifier=:identifier")
697 ->bind(
":identifier", $menu_identifier)
700 if(count($menus) == 0)
705 if(!is_object($item))
708 if(!
$page)
return false;
713 $found = Query::create(
MenuItem,
"WHERE (identifier=:identifier OR url like '%{$page->identifier}') AND menu_id=:menu_id")
714 ->bind(
":identifier",
$page->identifier,
":menu_id",
$menu->menu_id)
715 ->executeValue(
"COUNT(1)");
719 $this->
log .=
"Page identifier {$page->identifier} already linked to menu {$menu_identifier}\r\n";
725 if($parent_identifier)
727 $parents = Query::create(
MenuItem,
"WHERE identifier=:identifier")
728 ->bind(
":identifier", $parent_identifier)
731 if(count($parents) > 0)
737 $sort_order = (Query::create(
MenuItem,
"WHERE menu_id=:menu_id AND parent_id=:parent_id")
739 ->executeValue(
"MAX(sort_order)") + 1);
745 ->bind(
":identifier",
$page->identifier)
750 trace(
"UpgradeManager error: page {$page->identifier} is not in section content", 3);
754 $section_name =
$sections[0]->Section()->section;
769 $this->
log .=
$page->format(
"Adding menu item {identifier} to menu {$menu->name}\r\n");
searchByIdentifier($identifier)
◆ addModuleToPages()
UpgradeManager::addModuleToPages |
( |
|
$items, |
|
|
|
$module_name, |
|
|
|
$position = 'right' , |
|
|
|
$sort_order = 1 |
|
) |
| |
Given an array of either identifiers that must be either CMS Page or ComponentPage identifiers or items that are of obj CMSPage, Blog, Calendar, etc., link each to the specified module.
Definition at line 588 of file upgrade_manager.inc.
597 ->bind(
":title", $module_name)
607 if(!is_object($item))
610 if(!
$page)
return false;
619 $found = Query::create(
$xref_class,
"WHERE $pk=:$pk AND module_id=:module_id")
620 ->bind(
":$pk",
$page->$pk,
":module_id",
$module->module_id)
621 ->executeValue(
"COUNT(1)");
625 $xref->$pk =
$page->$pk;
626 $xref->module_id =
$module->module_id;
627 $xref->position = $position;
628 $xref->sort_order = $sort_order;
630 $this->
log .=
$page->format(
"Adding $xref_class record for page {identifier} to module {$module->title}\r\n");
634 $this->
log .=
"Page identifier $identifier already linked to module {$module->title}\r\n";
Defines the Module class.
◆ addSectionContent()
UpgradeManager::addSectionContent |
( |
|
$items, |
|
|
|
$section_name = "/" , |
|
|
|
$role = "" , |
|
|
|
$template = "" , |
|
|
|
$permissions = "" |
|
) |
| |
Utility function for use by calling classes to add an array of items of class Page, ComponentPage, Blog, ImageGallery, DocumentLibrary, Calendar to a section.
@items can be any of the following: 1) array of CMS Page, Component Page, Blog, ImageGallery, DocumentLibrary, or Calendar DataItem objects 2) a single DataItem obj of any of the above types 3) array of CMS Page or Component page identifiers 4) a single CMS Page or Component Page identifier
Alternatively, $items can be an array of identifiers or a single identifier as long as the identifiers are a CMS Page or Component Page.
We find the section based on the section name, and query the existing content to avoid adding the identifier twice.
If the page is found, its role and template, are updated, if an update is provided.
Definition at line 514 of file upgrade_manager.inc.
521 trace(
"No items found to add to section", 2);
526 ->bind(
":section", $section_name)
531 trace(
"UpgradeManager::addSectionContent - section $section_name not found", 3);
539 if (is_object($item))
541 $ident = $item->identifier;
549 $contents = Query::create(
SectionContent,
"WHERE identifier=:identifier AND section_id=:section_id")
550 ->bind(
":identifier", $ident,
":section_id",
$section->section_id)
553 $content = (count($contents) > 0) ? $contents[0] :
null;
563 $content->filter =
new InclusionFilter(
"template",
"role");
566 if(
$section->default_template != $template)
575 trace(
"Added $item to $section_name", 3);
Section DataItem, defining the data model for sections within a site.
if(array_key_exists("HTTP_IF_MODIFIED_SINCE", $_SERVER)) $content
◆ dependsOn()
UpgradeManager::dependsOn |
( |
|
$component, |
|
|
|
$version |
|
) |
| |
◆ executeSQLFile()
UpgradeManager::executeSQLFile |
( |
|
$sqlFile, |
|
|
|
$version_number |
|
) |
| |
Definition at line 816 of file upgrade_manager.inc.
818 trace(
"** Upgrade {$this->component_name} to version $version_number by executing file {$sqlFile}", 3);
822 trace(
"UpgradeManager:: sql file does not exists {$sqlFile}", 2);
830 trace(
"Error: executeVersionSql failed to open file", 3);
835 while(($buffer = fgets($fp)) !==
false)
838 if(trim($buffer) ==
"" || preg_match(
"/^--(.*?)\s/", $buffer))
843 if(count($lines) == 0)
845 trace(
"UpgradeManager:: no lines parsed in file {$sqlFile}", 3);
851 if(count($sqlStatements) == 0)
853 trace(
"UpgradeManager:: no query statements found in sql file {$sqlFile} for version $version_number", 3);
parseSQLStatements($lines)
executeSQLStatements($sqlStatements)
◆ executeSQLStatements()
UpgradeManager::executeSQLStatements |
( |
|
$sqlStatements | ) |
|
Definition at line 404 of file upgrade_manager.inc.
408 trace(
"Executing SQL Statements", 2);
410 $db = ConnectionManager::getConnection();
411 $db->beginTransaction();
413 foreach($sqlStatements as $sqlStatement)
415 trace($sqlStatement, 2);
416 $db->exec($sqlStatement);
422 catch(PDOException $e)
◆ executeVersionSql()
UpgradeManager::executeVersionSql |
( |
|
$version_number | ) |
|
Definition at line 300 of file upgrade_manager.inc.
305 if(!file_exists($this->sqlFile))
311 $fp = fopen($this->sqlFile,
'r');
312 $version_id = str_ireplace(
".",
"\\.",
"version " . $version_number);
313 trace(
"UpgradeManager::version id: $version_id file $this->sqlFile", 3);
321 while (($buffer = fgets($fp)) !==
false && !preg_match(
"/^--.*?\s+$version_id/i", $buffer))
325 if(preg_match(
"/^--\s*START\s*$version_id/i", $buffer))
327 while(($buffer = fgets($fp)) !==
false && !preg_match(
"/^--\s*END\s*$version_id/i", $buffer))
330 if (preg_match(
'/^--\s*Depends\s+On\s+([\w_]+)\s+(.*)/i', $buffer, $depends))
338 if(trim($buffer) ==
"" || preg_match(
"/^--(.*?)\s/", $buffer))
343 trace(
"** Upgrade has ".count($lines).
" lines", 3);
348 if(count($sqlStatements) == 0)
362 throw new FakoliException(
"Failed to upgrade {$this->component_name} to version $version_number - ". $e->getMessage());
static scanTrace($message, $level)
FakoliException is the base exception class for all Fakoli errors.
◆ executeVersionXML()
UpgradeManager::executeVersionXML |
( |
|
$version | ) |
|
Definition at line 440 of file upgrade_manager.inc.
446 if (preg_match(
"/\\b{$this->component_name}\\b/",
$config[
"ignore_xml_updates"]))
452 if (!is_dir($this->xmlDir))
454 throw new FakoliException(
"XML update directory does not exists for {$this->component_name}");
457 $file = $this->xmlDir . DIRECTORY_SEPARATOR . $this->component_name .
"_" . $version .
".xml";
459 if (!file_exists(
$file))
461 throw new FakoliException(
"No XML update for version $version of $this->component_name");
464 $xml = file_get_contents(
$file);
466 $mgr->importAll($xml);
SerializationManager handles import/export of DataItems via an XML file.
◆ log()
UpgradeManager::log |
( |
|
$text | ) |
|
Definition at line 432 of file upgrade_manager.inc.
434 if(preg_match(
"/(<br>|<br\/>)$/i",
$text))
435 $this->
log .= preg_replace(array(
"/<br>$/i",
"/<br\/>$/i"),
"\r\n",
$text);
◆ parseSQLStatements()
UpgradeManager::parseSQLStatements |
( |
|
$lines | ) |
|
Definition at line 370 of file upgrade_manager.inc.
372 if(count($lines) == 0)
376 foreach($lines as $line)
381 if (preg_match(
"/^\s*DELIMITER\s+(.*?)$/i", $line,
$d))
383 $delimiter = preg_quote(
$d[1]);
388 if(preg_match(
"/{$delimiter}\s*$/", $line))
390 $sqlStatement .= preg_replace(
"/{$delimiter}\s*$/",
"", $line);
391 $sqlStatements[] = $sqlStatement;
396 $sqlStatement .= $line;
400 trace(print_r($sqlStatements,
true), 3);
401 return $sqlStatements;
if(!checkRole($library->allow_access) &&! $library->allowAccess()) if(!checkRole($document->allow_access)) $d
◆ recordUpdate()
UpgradeManager::recordUpdate |
( |
|
$version, |
|
|
|
$description |
|
) |
| |
Definition at line 471 of file upgrade_manager.inc.
static recordUpdate($component, $version_number, $description="", $fileName)
◆ reformatPhone()
UpgradeManager::reformatPhone |
( |
& |
$item, |
|
|
|
$field |
|
) |
| |
Definition at line 782 of file upgrade_manager.inc.
784 $oldPhone = $item->$field;
789 $phone = preg_replace(
"/^1-/",
"", $oldPhone);
791 $phone = preg_replace(
"/\D/",
"", $phone);
793 if($phone != $oldPhone)
795 $item->$field = $phone;
797 $pk = $item->getPrimaryKey();
798 $this->
log($item->format(
"Setting {$item->table} {$pk} $field from {$oldPhone} to {$phone}"));
799 $item->filter =
new InclusionFilter(
$field);
◆ saveLogFile()
UpgradeManager::saveLogFile |
( |
|
$version | ) |
|
Definition at line 478 of file upgrade_manager.inc.
482 $fileName = $this->component_name .
"_" . $version .
".txt";
483 $fp = fopen($upgradePath . DIRECTORY_SEPARATOR . $fileName,
'w');
484 fwrite($fp, $this->
log);
static getValue($component, $name)
Retrieve the value of the specified Setting.
◆ searchByIdentifier()
UpgradeManager::searchByIdentifier |
( |
|
$identifier | ) |
|
Definition at line 645 of file upgrade_manager.inc.
647 $pages = Query::create(
Page,
"WHERE identifier=:identifier")
660 $this->
log .=
"Page identifier $identifier not found in Page or ComponentPage tables\r\n";
◆ upgrade()
UpgradeManager::upgrade |
( |
|
$upgrade_to = "" | ) |
|
Definition at line 226 of file upgrade_manager.inc.
234 ComponentManager::scanTrace(
"UpgradeManager:: upgrade: latest version in db for component {$this->component_name} is $latest_version", 3);
236 if(count($this->updateMap) > 0)
238 foreach($this->updateMap as $version_number =>
$handler)
242 if($latest_version < $version_number)
244 list($function, $description) = explode(
":",
$handler);
251 if ($upgrade_to !=
"" && $upgrade_to == $version_number)
break;
static setComponentVersion($component_name)
static getLatestVersion($component)
recordUpdate($version, $description)
upgradeOneVersion($version_number, $function)
◆ upgradeComponentToVersion()
static UpgradeManager::upgradeComponentToVersion |
( |
|
$component, |
|
|
|
$version |
|
) |
| |
|
static |
Definition at line 865 of file upgrade_manager.inc.
867 trace(
"Firing upgrade event to $component, target version $version", 3);
static fireEventTo($event, $component, $parameter=null)
Fire an event to the specificed component.
◆ UpgradeManager()
UpgradeManager::UpgradeManager |
( |
| ) |
|
Definition at line 204 of file upgrade_manager.inc.
209 $this->sqlFile =
$path . DIRECTORY_SEPARATOR . $this->component_name .
"_schema.sql";
210 $this->xmlDir =
$path . DIRECTORY_SEPARATOR .
"updates";
static findComponentPath($name)
Locate the component path for the named component using the standard precedence rules.
◆ upgradeOneVersion()
UpgradeManager::upgradeOneVersion |
( |
|
$version_number, |
|
|
|
$function |
|
) |
| |
Definition at line 271 of file upgrade_manager.inc.
273 if($function ==
"sql")
275 else if ($function ==
"xml")
277 elseif($function !=
"done")
279 $updater = array($this, $function);
280 return call_user_func($updater, $version_number);
executeVersionSql($version_number)
executeVersionXML($version)
◆ $component_name
UpgradeManager::$component_name |
◆ $log
◆ $sqlFile
◆ $xmlDir
The documentation for this class was generated from the following file: