Example #1
0
 public function update($pkgHandle = false)
 {
     $tp = new TaskPermission();
     if ($tp->canInstallPackages()) {
         if ($pkgHandle) {
             $tests = Package::testForInstall($pkgHandle, false);
             if (is_array($tests)) {
                 $tests = Package::mapError($tests);
                 $this->set('error', $tests);
             } else {
                 $p = Package::getByHandle($pkgHandle);
                 try {
                     $p->upgradeCoreData();
                     $p->upgrade();
                     $this->set('message', t('The package has been updated successfully.'));
                 } catch (Exception $e) {
                     $this->set('error', $e);
                 }
             }
         } else {
             $mi = Marketplace::getInstance();
             if ($mi->isConnected()) {
                 Marketplace::checkPackageUpdates();
             }
         }
     }
 }
 public function execute(Batch $batch)
 {
     $keys = $batch->getObjectCollection('attribute_key');
     /**
      * @var AttributeKey
      */
     if (!$keys) {
         return;
     }
     foreach ($keys->getKeys() as $key) {
         if (!$key->getPublisherValidator()->skipItem()) {
             $pkg = null;
             if ($key->getPackage()) {
                 $pkg = \Package::getByHandle($key->getPackage());
             }
             $category = $key->getCategory();
             if (is_object($category)) {
                 $publisher = $category->getPublisher();
                 $o = $publisher->publish($key, $pkg);
                 $typePublisher = $key->getTypePublisher();
                 if (is_object($typePublisher)) {
                     $typePublisher->publish($key, $o);
                 }
             }
         }
     }
 }
Example #3
0
 public function view()
 {
     $uh = Loader::helper('concrete/urls');
     $bt = BlockType::getByHandle('switch_language');
     Loader::model('section', 'multilingual');
     $ml = MultilingualSection::getList();
     $c = Page::getCurrentPage();
     $al = MultilingualSection::getBySectionOfSite($c);
     $languages = array();
     $locale = ACTIVE_LOCALE;
     if (is_object($al)) {
         $locale = $al->getLanguage();
     }
     foreach ($ml as $m) {
         $languages[$m->getCollectionID()] = $m->getLanguageText($locale) . ' ' . (strlen($m->msIcon) ? '(' . $m->msIcon . ')' : '');
     }
     $this->set('languages', $languages);
     $this->set('languageSections', $ml);
     $this->set('action', $uh->getBlockTypeToolsURL($bt) . '/switch');
     if (is_object($al)) {
         $this->set('activeLanguage', $al->getCollectionID());
     }
     $pkg = Package::getByHandle('multilingual');
     $mdl = Loader::helper('default_language', 'multilingual');
     $this->set('defaultLanguage', $mdl->getSessionDefaultLocale());
     $this->set('cID', $c->getCollectionID());
 }
Example #4
0
 public function activate_files($ptID)
 {
     try {
         Loader::model("collection_types");
         $pt = PageTheme::getByID($ptID);
         $txt = Loader::helper('text');
         if (!is_array($this->post('pageTypes'))) {
             throw new Exception(t("You must specify at least one template to make into a page type."));
         }
         $pkg = false;
         $pkgHandle = $pt->getPackageHandle();
         if ($pkgHandle) {
             $pkg = Package::getByHandle($pkgHandle);
         }
         foreach ($this->post('pageTypes') as $ptHandle) {
             $data['ctName'] = $txt->unhandle($ptHandle);
             $data['ctHandle'] = $ptHandle;
             $ct = CollectionType::add($data, $pkg);
         }
         $this->set('message', t('Files in the theme were activated successfully.'));
     } catch (Exception $e) {
         $this->set('error', $e);
     }
     $this->view($ptID);
 }
	public function downloadUpdate() {
		// backup the old package
		$pkg = Package::getByHandle($this->getHandle());
		$r = $pkg->backup();
		if (is_array($r)) {
			return $r;
		}

		$fileURL = $this->getRemoteFileURL();
		if (empty($fileURL)) {
			return array(Package::E_PACKAGE_NOT_FOUND);
		}

		$file = Marketplace::downloadRemoteFile($this->getRemoteFileURL());
		if (empty($file) || $file == Package::E_PACKAGE_DOWNLOAD) {
			return array(Package::E_PACKAGE_DOWNLOAD);
		} else if ($file == Package::E_PACKAGE_SAVE) {
			return array($file);
		}
			
		try {
			Loader::model('package_archive');
			$am = new PackageArchive($this->getHandle());
			$am->install($file, true);
		} catch (Exception $e) {
			return array($e->getMessage());
		}

	}
Example #6
0
	public function do_update($pkgHandle = false) {
		$tp = new TaskPermission();
		if ($tp->canInstallPackages()) { 
			if ($pkgHandle) {
				$tests = Package::testForInstall($pkgHandle, false);
				if (is_array($tests)) {
					$tests = Package::mapError($tests);
					$this->set('error', $tests);
				} else {
					$p = Package::getByHandle($pkgHandle);
					$currentLocale = Localization::activeLocale();
					if ($currentLocale != 'en_US') {
						// Prevent the database records being stored in wrong language
						Localization::changeLocale('en_US');
					}
					try {
						$p->upgradeCoreData();
						if ($currentLocale != 'en_US') {
							Localization::changeLocale($currentLocale);
						}
						$p->upgrade();
						$this->set('message', t('The package has been updated successfully.'));
					} catch(Exception $e) {
						$this->set('error', $e);
					}
				}
			}
		}
		$this->view();
	}
 public function execute(Batch $batch)
 {
     $sets = $batch->getObjectCollection('attribute_set');
     if (!$sets) {
         return;
     }
     foreach ($sets->getSets() as $set) {
         $akc = Category::getByHandle($set->getCategory());
         if (!$set->getPublisherValidator()->skipItem()) {
             $pkg = null;
             if ($set->getPackage()) {
                 $pkg = \Package::getByHandle($set->getPackage());
             }
             $setObject = $akc->addSet($set->getHandle(), $set->getName(), $pkg, intval($set->getIsLocked()));
         } else {
             $setObject = \Concrete\Core\Attribute\Set::getByHandle($set->getHandle());
         }
         if (is_object($setObject)) {
             $attributes = $set->getAttributes();
             foreach ($attributes as $handle) {
                 $ak = $akc->getAttributeKeyByHandle($handle);
                 if (is_object($ak)) {
                     $setObject->addKey($ak);
                 }
             }
         }
     }
 }
Example #8
0
 public function upgrade()
 {
     parent::upgrade();
     $pkg = Package::getByHandle($this->pkgHandle);
     //@todo write conversion from lang to locale
     //1.0 - 1.1 changed languaage to locale
     $db = Loader::db();
     // update the MultilingualSections table
     $rows = $db->getAll("SELECT * FROM MultilingualSections");
     if (is_array($rows) && count($rows)) {
         foreach ($rows as $r) {
             if (strlen($r['msLanguage']) && !strlen($r['msLocale'])) {
                 $locale = $r['msLanguage'] . (strlen($r['msIcon']) ? "_" . $r['msIcon'] : "");
                 $db->query("UPDATE MultilingualSections SET msLocale = ? WHERE cID = ?", array($locale, $r['cID']));
             }
         }
     }
     // install job
     Loader::model('job');
     $jb = Job::installByPackage('generate_multilingual_sitemap', $pkg);
     // update the MultilingualPageRelations table
     $hasLocales = $db->getOne("SELECT COUNT(msLocale) FROM MultilingualSections WHERE LENGTH(msLocale)");
     if (!$hasLocales) {
         $query = "UPDATE MultilingualPageRelations mpr, MultilingualSections \n\t\t\t\tSET mpr.mpLocale = MultilingualSections.msLocale\n\t\t\t\tWHERE mpr.mpLanguage = MultilingualSections.msLanguage";
         $db->query($query);
     }
     // 1.1.2
     $ak = CollectionAttributeKey::getByHandle('multilingual_exclude_from_copy');
     if (!is_object($ak)) {
         CollectionAttributeKey::add('BOOLEAN', array('akHandle' => 'multilingual_exclude_from_copy', 'akName' => t('Exclude from Internationalization Copy'), 'akIsSearchable' => true), $pkg);
     }
 }
 public function view()
 {
     $pkg = Package::getByHandle('theme_creator');
     $html = loader::helper('html');
     $this->addHeaderItem($html->javascript('theme_creator', 'theme_creator'));
     $this->set('pkg', $pkg);
 }
 protected function installAttributeType($pkg)
 {
     $attributeHandle = 'related_pages';
     \Loader::model('attribute/categories/collection');
     AttributeType::add($attributeHandle, t('Related Pages'), \Package::getByHandle($this->pkgHandle));
     AttributeKeyCategory::getByHandle('collection')->associateAttributeKeyType(AttributeType::getByHandle($attributeHandle));
 }
Example #11
0
	protected static function getPackageObject($pkgHandle) {
		$pkg = false;
		if ($pkgHandle) {
			$pkg = Package::getByHandle($pkgHandle);
		}
		return $pkg;		
	}
Example #12
0
 function precheck()
 {
     $pk = Package::getByHandle('problog');
     if (!$pk) {
         throw new Exception(t('You must have <a href="http://www.concrete5.org/marketplace/addons/problog/">ProBlog</a> installed prior to installing this addon.'));
         exit;
     }
 }
 public function view()
 {
     $urls = Loader::helper('concrete/urls');
     $pkg = Package::getByHandle(FRONTEND_DEVELOPER_PACKAGE_HANDLE);
     $this->set("pkg", $pkg);
     $this->set("url", $urls);
     $this->set("bID", $this->bID);
     $this->set("filesets", $this->getBuildFileSets());
 }
 public function install()
 {
     $pkg = parent::install();
     $pkgh = Package::getByHandle('page_selector_attribute');
     Loader::model('attribute/categories/collection');
     $col = AttributeKeyCategory::getByHandle('collection');
     $pageselector = AttributeType::add('page_selector', t('Page Selector'), $pkgh);
     $col->associateAttributeKeyType(AttributeType::getByHandle('page_selector'));
 }
 protected static function getPackageObject($pkgHandle)
 {
     $pkg = null;
     if ($pkgHandle) {
         $pkgHandle = (string) $pkgHandle;
         $pkg = \Package::getByHandle($pkgHandle);
     }
     return $pkg;
 }
Example #16
0
 public function getPageLocale($page)
 {
     $ms = MultilingualSection::getByID($page->cID);
     if (is_object($ms)) {
         return $ms->getLocale();
     }
     $pkg = Package::getByHandle('multilingual');
     return $pkg->config('DEFAULT_LANGUAGE');
 }
 public function execute(Batch $batch)
 {
     $this->batch = $batch;
     // First, create the top level page for the batch.
     $batches = \Page::getByPath('/!import_batches');
     $type = Type::getByHandle('import_batch');
     $batchParent = $batches->add($type, array('cName' => $batch->getID(), 'cHandle' => $batch->getID(), 'pkgID' => \Package::getByHandle('migration_tool')->getPackageID()));
     $pages = $this->getPagesOrderedForImport($batch);
     if (!$pages) {
         return;
     }
     // Now loop through all pages, and build them
     foreach ($pages as $page) {
         $data = array();
         $ui = $this->getTargetItem('user', $page->getUser());
         if ($ui != '') {
             $data['uID'] = $ui->getUserID();
         } else {
             $data['uID'] = USER_SUPER_ID;
         }
         $cDatePublic = $page->getPublicDate();
         if ($cDatePublic) {
             $data['cDatePublic'] = $cDatePublic;
         }
         $type = $this->getTargetItem('page_type', $page->getType());
         if ($type) {
             $data['ptID'] = $type->getPageTypeID();
         }
         $template = $this->getTargetItem('page_template', $page->getTemplate());
         if (is_object($template)) {
             $data['pTemplateID'] = $template->getPageTemplateID();
         }
         if ($page->getPackage()) {
             $pkg = \Package::getByHandle($page->getPackage());
             if (is_object($pkg)) {
                 $data['pkgID'] = $pkg->getPackageID();
             }
         }
         // TODO exception if parent not found
         if ($page->getBatchPath() != '') {
             $lastSlash = strrpos($page->getBatchPath(), '/');
             $parentPath = substr($page->getBatchPath(), 0, $lastSlash);
             $data['cHandle'] = substr($page->getBatchPath(), $lastSlash + 1);
             if (!$parentPath) {
                 $parent = $batchParent;
             } else {
                 $parent = \Page::getByPath('/!import_batches/' . $this->batch->getID() . $parentPath);
             }
         } else {
             $parent = $batchParent;
         }
         $data['name'] = $page->getName();
         $data['cDescription'] = $page->getDescription();
         $parent->add($type, $data);
     }
 }
Example #18
0
 public function import_wordpress_xml()
 {
     if ($this->post('import-images') == 'on') {
         $this->importImages = true;
         $filesetname;
         $this->post('file-set-name') ? $this->filesetname = $this->post('file-set-name') : ($this->filesetname = t("Imported Wordpress Files"));
         $this->createFileSet = true;
     }
     $pages = array();
     if (intval($this->post('wp-file')) > 0) {
         Loader::model('file');
         $co = new Config();
         $pkg = Package::getByHandle('wordpress_site_importer');
         $co->setPackageObject($pkg);
         $co->save("WORDPRESS_IMPORT_FID", $this->post('wp-file'));
         $importFile = File::getByID($this->post('wp-file'));
         $nv = $importFile->getVersion();
         $fileUrl = $nv->getDownloadURL();
         $xml = @simplexml_load_file($fileUrl, "SimpleXMLElement", LIBXML_NOCDATA);
         $items = array();
         foreach ($xml->channel->item as $item) {
             $items[] = $item->asxml();
         }
         $db = Loader::db();
         $sql = $db->Prepare('insert into WordpressItems (wpItem) values(?)');
         foreach ($items as $item) {
             $db->Execute($sql, $item);
         }
         $categories = array();
         $namespaces = $xml->getDocNamespaces();
         foreach ($xml->xpath('/rss/channel/wp:category') as $term_arr) {
             $t = $term_arr->children($namespaces['wp']);
             $categories[] = array('term_id' => (int) $t->term_id, 'category_nicename' => (string) $t->category_nicename, 'category_parent' => (string) $t->category_parent, 'cat_name' => (string) $t->cat_name, 'category_description' => (string) $t->category_description);
         }
         Loader::model('attribute/categories/collection');
         $akt = CollectionAttributeKey::getByHandle("wordpress_category");
         for ($i = 0; $i < count($categories); $i++) {
             $opt = new SelectAttributeTypeOption(0, $categories[$i]['cat_name'], $i);
             $opt = $opt->saveOrCreate($akt);
         }
         foreach ($xml->xpath('/rss/channel/wp:tag') as $term_arr) {
             $t = $term_arr->children($namespaces['wp']);
             $tags[] = array('term_id' => (int) $t->term_id, 'tag_slug' => (string) $t->tag_slug, 'tag_name' => (string) $t->tag_name, 'tag_description' => (string) $t->tag_description);
         }
         $akt = CollectionAttributeKey::getByHandle("tags");
         for ($i = 0; $i < count($tags); $i++) {
             $opt = new SelectAttributeTypeOption(0, $tags[$i]['tag_name'], $i);
             $opt = $opt->saveOrCreate($akt);
         }
     } else {
         echo t("No file");
         exit;
     }
     $this->view();
 }
Example #19
0
 public function upgrade()
 {
     //		If you have an attribute type in your package that needs to
     //		update it's database table, you will need to run this:
     //
     //		$est = AttributeType::getByHandle('attribute_handle');
     //		$path = $est->getAttributeTypeFilePath(FILENAME_ATTRIBUTE_DB);
     //		Package::installDB($path);
     parent::upgrade();
     $pkg = Package::getByHandle($this->pkgHandle);
     $this->installAdditionalPageAttributes($pkg);
     $this->installJobs($pkg);
 }
Example #20
0
 public function install()
 {
     Loader::model('collection_types');
     $pkg = parent::install();
     PageTheme::add('casual', $pkg);
     $pagetypearray = array(array("left_sidebar", "Left Sidebar"), array("right_sidebar", "Right Sidebar"), array("full", "One Column"), array("three_column", "Three Column Layout"));
     foreach ($pagetypearray as $value) {
         $pageType = CollectionType::getByHandle($value[0]);
         if (!$pageType) {
             $pkg = Package::getByHandle('casual');
             $newPageType = CollectionType::add(array('ctHandle' => $value[0], 'ctName' => t($value[1])), $pkg);
         } else {
             $newPageType = $pageType;
         }
     }
 }
 public function execute(Batch $batch)
 {
     $types = $batch->getObjectCollection('page_type_publish_target_type');
     if (!$types) {
         return;
     }
     foreach ($types->getTypes() as $type) {
         if (!$type->getPublisherValidator()->skipItem()) {
             $pkg = false;
             if ($type->getPackage()) {
                 $pkg = \Package::getByHandle($type->getPackage());
             }
             Type::add($type->getHandle(), $type->getName(), $pkg);
         }
     }
 }
 public function execute(Batch $batch)
 {
     $templates = $batch->getObjectCollection('page_template');
     if (!$templates) {
         return;
     }
     foreach ($templates->getTemplates() as $template) {
         if (!$template->getPublisherValidator()->skipItem()) {
             $pkg = null;
             if ($template->getPackage()) {
                 $pkg = \Package::getByHandle($template->getPackage());
             }
             Template::add($template->getHandle(), $template->getName(), $template->getIcon(), $pkg, $template->getIsInternal());
         }
     }
 }
 public function execute(Batch $batch)
 {
     $categories = $batch->getObjectCollection('permission_key_category');
     if (!$categories) {
         return;
     }
     foreach ($categories->getCategories() as $category) {
         if (!$category->getPublisherValidator()->skipItem()) {
             $pkg = null;
             if ($category->getPackage()) {
                 $pkg = \Package::getByHandle($category->getPackage());
             }
             Category::add($category->getHandle(), $pkg);
         }
     }
 }
 public function execute(Batch $batch)
 {
     $types = $batch->getObjectCollection('workflow_progress_category');
     if (!$types) {
         return;
     }
     foreach ($types->getCategories() as $category) {
         if (!$category->getPublisherValidator()->skipItem()) {
             $pkg = null;
             if ($category->getPackage()) {
                 $pkg = \Package::getByHandle($category->getPackage());
             }
             \Concrete\Core\Workflow\Progress\Category::add($category->getHandle(), $pkg);
         }
     }
 }
Example #25
0
 public function view()
 {
     $pkg = Package::getByHandle('automobiles');
     $configs = Config::getListByPackage($pkg);
     $post = $this->post();
     if ($post) {
         if ($this->validate($post, $configs)) {
             $this->save($pkg, $post, $configs);
             $this->flash('Configuration saved!', 'success');
             $this->redirect('');
             //redirect to ourself
         } else {
             $this->set('error', 'Error: All configuration settings are required.');
         }
     }
     $this->set('configs', $configs);
     $this->addHeaderItem(Loader::helper('html')->css('dashboard.css', 'automobiles'));
 }
Example #26
0
 public function package()
 {
     Loader::model('file_set');
     $pl = new MootoolsPluginList();
     $package = $this->post("package");
     $fs = Fileset::getByName($package);
     $u = new User();
     $ui = UserInfo::getByID($u->getUserID());
     $username = $ui->getAttribute(MOOTOOLS_GITHUB_USER);
     $pkgHandle = FRONTEND_DEVELOPER_PACKAGE_HANDLE;
     $uID = $u->getUserID();
     $files = $pl->getMootoolsPluginFiles($fs);
     $filesets[$fs->getFileSetName()] = $files;
     $package = Package::getByHandle($pkgHandle);
     $path = $package->getPackagePath();
     include $path . "/elements/plugin_files.php";
     exit;
 }
 public function execute(Batch $batch)
 {
     $snippets = $batch->getObjectCollection('content_editor_snippet');
     if (!$snippets) {
         return;
     }
     foreach ($snippets->getSnippets() as $snippet) {
         if (!$snippet->getPublisherValidator()->skipItem()) {
             $pkg = null;
             if ($snippet->getPackage()) {
                 $pkg = \Package::getByHandle($snippet->getPackage());
             }
             $t = Snippet::add($snippet->getHandle(), $snippet->getNAme(), $pkg);
             if ($snippet->getIsActivated()) {
                 $t->activate();
             }
         }
     }
 }
 public function execute(Batch $batch)
 {
     $themes = $batch->getObjectCollection('theme');
     if (!$themes) {
         return;
     }
     foreach ($themes->getThemes() as $theme) {
         if (!$theme->getPublisherValidator()->skipItem()) {
             $pkg = null;
             if ($theme->getPackage()) {
                 $pkg = \Package::getByHandle($theme->getPackage());
             }
             $t = Theme::add($theme->getHandle(), $pkg);
             if ($theme->getIsActivated()) {
                 $t->applyToSite();
             }
         }
     }
 }
 public function execute(Batch $batch)
 {
     $libraries = $batch->getObjectCollection('captcha_library');
     if (!$libraries) {
         return;
     }
     foreach ($libraries->getLibraries() as $library) {
         if (!$library->getPublisherValidator()->skipItem()) {
             $pkg = null;
             if ($library->getPackage()) {
                 $pkg = \Package::getByHandle($library->getPackage());
             }
             $l = Library::add($library->getHandle(), $library->getName(), $pkg);
             if ($library->getIsActivated()) {
                 $l->activate();
             }
         }
     }
 }
 public function execute(Batch $batch)
 {
     $types = $batch->getObjectCollection('page_type');
     /**
      * @var \PortlandLabs\Concrete5\MigrationTool\Entity\Import\PageType\PageType
      */
     if (!$types) {
         return;
     }
     foreach ($types->getTypes() as $type) {
         if (!$type->getPublisherValidator()->skipItem()) {
             $pkg = null;
             if ($type->getPackage()) {
                 $pkg = \Package::getByHandle($type->getPackage());
             }
             $defaultTemplate = Template::getByHandle($type->getDefaultTemplate());
             $templates = array();
             if ($type->getAllowedTemplates() == 'C' || $type->getAllowedTemplates() == 'X') {
                 foreach ($type->getTemplates() as $templateHandle) {
                     $templates[] = Template::getByHandle($templateHandle);
                 }
             }
             $data = array('handle' => $type->getHandle(), 'name' => $type->getName(), 'defaultTemplate' => $defaultTemplate, 'allowedtempates' => $type->getAllowedTemplates(), 'internal' => $type->getIsInternal(), 'ptLaunchInComposer' => $type->getLaunchInComposer(), 'ptIsFrequentlyAdded' => $type->getIsFrequentlyAdded(), 'templates' => $templates);
             $pageType = \Concrete\Core\Page\Type\Type::add($data, $pkg);
             foreach ($type->getLayoutSets() as $set) {
                 $layoutSet = $pageType->addPageTypeComposerFormLayoutSet($set->getName(), $set->getDescription());
                 /**
                  * @var \PortlandLabs\Concrete5\MigrationTool\Entity\Import\PageType\ComposerFormLayoutSetControl
                  */
                 foreach ($set->getControls() as $controlEntity) {
                     $controlType = \Concrete\Core\Page\Type\Composer\Control\Type\Type::getByHandle($controlEntity->getHandle());
                     $control = $controlType->configureFromImportHandle($controlEntity->getItemIdentifier());
                     $setControl = $control->addToPageTypeComposerFormLayoutSet($layoutSet, true);
                     $setControl->updateFormLayoutSetControlRequired($controlEntity->getIsRequired());
                     $setControl->updateFormLayoutSetControlCustomTemplate($controlEntity->getCustomTemplate());
                     $setControl->updateFormLayoutSetControlCustomTemplate($controlEntity->getCustomLabel());
                     $setControl->updateFormLayoutSetControlDescription($controlEntity->getDescription());
                 }
             }
         }
     }
 }