Inheritance: extends Frontend_Controller
Beispiel #1
0
 /**
  * @param string $namespace
  * @param array $pathList
  * @return Package
  */
 private function buildPackage($namespace, array $pathList)
 {
     $package = new Package();
     $package->setNamespace($namespace);
     $package->setPathList($pathList);
     return $package;
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     // validate class path
     if (empty($this->classPath)) {
         throw new UserInputException('classPath');
     }
     try {
         $package = new Package($this->packageID);
         if (!@file_exists(FileUtil::getRealPath(WCF_DIR . $package->getDir() . $this->classPath))) {
             throw new UserInputException('classPath', 'doesNotExist');
         }
     } catch (SystemException $e) {
         throw new UserInputException('classPath', 'doesNotExist');
     }
     try {
         CronjobEditor::validate($this->startMinute, $this->startHour, $this->startDom, $this->startMonth, $this->startDow);
     } catch (SystemException $e) {
         // extract field name
         $fieldName = '';
         if (preg_match("/cronjob attribute '(.*)'/", $e->getMessage(), $match)) {
             $fieldName = $match[1];
         }
         throw new UserInputException($fieldName, 'notValid');
     }
 }
Beispiel #3
0
 public function noticePackageUploaded(Package $pkg)
 {
     $app = $this->app;
     $package_url = mfwRequest::makeURL("/package?id={$pkg->getId()}");
     ob_start();
     include APP_ROOT . '/data/notice_mail_template.php';
     $body = ob_get_clean();
     $addresses = array();
     foreach ($this->rows as $r) {
         if ($r['notify']) {
             $addresses[] = $r['mail'];
         }
     }
     if (empty($addresses)) {
         return;
     }
     $subject = "New Package Uploaded to {$app->getTitle()}";
     $sender = Config::get('mail_sender');
     $to = $sender;
     $header = "From: {$sender}" . "\nBcc: " . implode(', ', $addresses);
     mb_language('uni');
     mb_internal_encoding('UTF-8');
     if (!mb_send_mail($to, $subject, $body, $header)) {
         throw new RuntimeException("mb_send_mail faild (pkg={$pkg->getId()}, {$pkg->getTitle()})");
     }
 }
 public function setPackage(Package $package)
 {
     if ($this->package !== $package) {
         $this->package = $package;
         $package->addVersion($this);
     }
 }
Beispiel #5
0
 public function run(array $arguments)
 {
     $json = $this->deps->nearestJson();
     $package = new Package(dirname($json));
     $porcelain = count($arguments) && $arguments[0] == 'porcelain';
     if (!$porcelain) {
         Terminal::info("From {$json}\n\n");
         Terminal::bold("* project name: " . $package->getName() . "\n");
     }
     $dependencies = $package->getDependencies();
     if ($porcelain) {
         echo implode(':', $dependencies) . "\n";
     } else {
         if ($dependencies) {
             Terminal::bold("* dependencies:\n");
             foreach ($dependencies as $dep) {
                 echo "  - {$dep} ";
                 if ($this->deps->hasPackage($dep)) {
                     Terminal::success("(installed)");
                 } else {
                     Terminal::warning("(not installed)");
                 }
                 echo "\n";
             }
         } else {
             Terminal::bold("* no dependencies\n");
         }
     }
 }
 public function process()
 {
     //if has a request from submit button, then capture it
     $client_data = NULL;
     //TEST($json_data);
     if (isset($_REQUEST['request'])) {
         $input = $_REQUEST['request'];
     } else {
         //else, get the json data from input
         $json_data = file_get_contents('php://input');
         //decode data into array
         $data = json_decode($json_data, true);
         //use a package to store the object
         $package = new Package();
         //data is in json encode form, so must decode it
         $package->get_data_from($data, true);
         // get request
         $input = $package->get_message();
         // get data of clients if available
         $client_data = $package->get_data();
     }
     //change value in $input into lower case
     $func = strtolower(trim(str_replace("/", "", $input)));
     //replace 'space' with '_'
     $func = str_replace(" ", "_", $func);
     //if the method exist, call it
     if ((int) method_exists($this, $func) > 0) {
         $this->{$func}($client_data);
     } else {
         $this->response('', 404);
     }
     // If the method not exist with in this class, response would be "Page not found".
 }
Beispiel #7
0
 public function testRegister()
 {
     $app = $this->app;
     $package = new Package();
     $package->register($app);
     $this->assertTrue($app->getContainer()->has(Storage\AccessToken::class));
 }
Beispiel #8
0
 public static function export(&$metadata)
 {
     $package = Doctrine::getTable('Package')->findOneByName($metadata['packageName']);
     if (!$package) {
         Package_Message::log('debug', 'Creating new package entry for ' . $metadata['packageName'] . '@' . $metadata['basedir']);
         $package = new Package();
     } else {
         Package_Message::log('debug', 'Updating package entry for ' . $metadata['packageName'] . '@' . $metadata['basedir'] . ' (' . $package['package_id'] . ')');
     }
     $registryIgnoreKeys = array_flip(array('packageName', 'displayName', 'version', 'packageStatus', 'directory', 'configure_instance', 'navStructures', 'datastore_id', 'type', 'upgrades', 'downgrades', 'basedir', 'status', 'models'));
     $package['name'] = $metadata['packageName'];
     $package['display_name'] = $metadata['displayName'];
     $package['version'] = $metadata['version'];
     $package['type'] = $metadata['type'];
     $package['status'] = $metadata['status'];
     $package['basedir'] = $metadata['basedir'];
     $package['navigation'] = $metadata['navStructures'];
     $package['registry'] = array_diff_key($metadata, $registryIgnoreKeys);
     $package->save();
     $metadata['datastore_id'] = $package['package_id'];
     if (!empty($metadata['models'])) {
         $models = Doctrine::loadModels($metadata['directory'] . '/models', Doctrine::MODEL_LOADING_CONSERVATIVE);
         self::integrateNumberType($models, $metadata['datastore_id']);
     }
 }
 public function testIssue9Failure()
 {
     $package = new Package();
     $package->setMessages(['FOO' => 'The text for "foo."', 'BAR' => 'The text for "bar."']);
     // $this->packages->set('Vendor.Package', 'en_UK', $package);
     // $this->setExpectedException('Exception');
     // $translator = $this->translators->get('Vendor.Package', 'en_UK');
 }
 /**
  * @test
  * @author Christopher Hlubek <*****@*****.**>
  * @author Robert Lemke <*****@*****.**>
  */
 public function getPackageMetaDataUsesMetaDataReader()
 {
     $mockMetaData = $this->getMock('F3\\FLOW3\\Package\\MetaDataInterface');
     $mockMetaDataReader = $this->getMock('F3\\FLOW3\\Package\\MetaData\\ReaderInterface');
     $package = new Package('FLOW3', FLOW3_PATH_FLOW3);
     $package->injectMetaDataReader($mockMetaDataReader);
     $mockMetaDataReader->expects($this->once())->method('readPackageMetaData')->will($this->returnValue($mockMetaData));
     $this->assertSame($mockMetaData, $package->getPackageMetaData());
 }
Beispiel #11
0
 private function getShipment()
 {
     $shipment = new Shipment();
     $shipment->setFromIsResidential(false)->setFromStateProvinceCode('IN')->setFromPostalCode('46205')->setFromCountryCode('US')->setToIsResidential(true)->setToPostalCode('20101')->setToCountryCode('US');
     $package = new Package();
     $package->setLength(12)->setWidth(4)->setHeight(3)->setWeight(3);
     $shipment->addPackage($package);
     return $shipment;
 }
Beispiel #12
0
 public static function getPackageInstallUsers(Package $pkg)
 {
     $sql = 'SELECT distinct(mail) FROM install_log WHERE package_id = ?';
     $rows = mfwDBIBase::getAll($sql, array($pkg->getId()));
     $mails = array();
     foreach ($rows as $r) {
         $mails[] = $r['mail'];
     }
     return $mails;
 }
function component_row(Package $package, $indentation, TableCreator $table_creator)
{
    $package->with('integration');
    $ret = $table_creator->row(array($package->full_name(), $package->integration == null ? 'Architettura del sistema' : $package->integration->public_id()));
    $nested = $package->with('packages')->packages;
    foreach ($nested as $nuc) {
        $ret .= component_row($nuc, $indentation + 1, $table_creator);
    }
    return $ret;
}
Beispiel #14
0
 /** Dodaje pakiet jako powiązany
  *
  * @param int|string $idPackage - id definicji we frontend
  */
 public function addIdPackage($idPackage)
 {
     if ($idPackage == '') {
         throw new Logger_Exception('Nie podano parametru $idPackage');
     }
     $this->packageId = $idPackage;
     $model = new Package();
     $row = $model->findOne($idPackage);
     $this->packageName = $row->name;
 }
 /**
  * Generates a manifest JSON file and returns the path.
  *
  * @param \JWage\APNS\Safari\Package $package
  * @return string $manifestJsonPath
  */
 public function createManifest(Package $package)
 {
     $manifestData = array();
     foreach (Package::$packageFiles as $rawFile) {
         $filePath = sprintf('%s/%s', $package->getPackageDir(), $rawFile);
         $manifestData[$rawFile] = sha1(file_get_contents($filePath));
     }
     $manifestJsonPath = sprintf('%s/manifest.json', $package->getPackageDir());
     $manifestJson = json_encode((object) $manifestData);
     file_put_contents($manifestJsonPath, $manifestJson);
     return $manifestJsonPath;
 }
Beispiel #16
0
 private function packageDetailsFromRow($row)
 {
     $package = new Package();
     $package->portletId = $row['portletId'];
     $package->sp_pkg_id = $row['sp_pkg_id'];
     $package->timestamp = $row['timestamp'];
     $package->promoid = $row['promoid'];
     $package->contentTypeMD5 = $row['contentTypeMD5'];
     if (!empty($row['contentFileURLMD5'])) {
         $package->contentFileURLMD5 = $row['contentFileURLMD5'];
     }
     $package->cft_thumbnail_img_browse = $row['cft_thumbnail_img_browse'];
     $package->cft_thumbnail_size = $row['cft_thumbnail_size'];
     $package->cm_title = $row['cm_title'];
     $package->cm_genre = $row['cm_genre'];
     if (!empty($row['genre'])) {
         $package->genre = $row['genre'];
     }
     if (!empty($row['searchKey'])) {
         $package->searchKey = $row['searchKey'];
     }
     if (!empty($row['cd_id'])) {
         $package->cd_id = $row['cd_id'];
     }
     if (!empty($row['cd_name'])) {
         $package->cd_name = $row['cd_name'];
     }
     if (!empty($row['parentId'])) {
         $package->parentId = $row['parentId'];
     }
     if (!empty($row['cf_cm_id'])) {
         $package->cf_cm_id = $row['cf_cm_id'];
     }
     if (!empty($row['cft_cm_id'])) {
         $package->cft_cm_id = $row['cft_cm_id'];
     }
     if (!empty($row['cg_images'])) {
         $package->cg_images = $row['cg_images'];
     }
     if (!empty($row['sp_jed_id'])) {
         $package->sp_jed_id = $row['sp_jed_id'];
     }
     $package->cm_streaming_url = $row['cm_streaming_url'];
     $package->cm_downloading_url = $row['cm_downloading_url'];
     $package->cd_id = $row['cd_id'];
     $package->cd_name = $row['cd_name'];
     if (!empty($row['cf_url'])) {
         $package->cf_url = $row['cf_url'];
     }
     $package->unsetValues(array('created_on', 'updated_on', 'created_by', 'updated_by'));
     return $package;
 }
 private function get_response_from_message($message, $json_data = NULL)
 {
     //set the url of the server we need to request
     $url = CONFIG_PATH('class') . 'Server.php';
     //put message request into package
     $package = new Package($message, $json_data);
     $options = array('http' => array('method' => 'POST', 'content' => $package->json_encode(), 'header' => "Content-Type: application/json\r\n" . "Accept: application/json\r\n" . "Connection: close\r\n"));
     $context = stream_context_create($options);
     $result = file_get_contents($url, false, $context);
     //if we need to get respone from server, return respone after get it
     $response = json_decode($result, true);
     return $response;
 }
Beispiel #18
0
 public static function getAllPackages()
 {
     $database = new DB();
     $sql = "SELECT * FROM packages";
     $results = $database->select($sql);
     $packages = array();
     foreach ($results as $result) {
         $pkg = new Package();
         $pkg->retrievePackage($result['pkg_id']);
         $packages[] = $pkg;
     }
     return $packages;
 }
 /**
  * @param Package $pkg
  * @return array
  */
 public static function getListByPackage($pkg)
 {
     $db = Loader::db();
     $upaIDs = $db->GetCol('select upaID from UserPointActions where pkgID = ? order by upaName asc', array($pkg->getPackageID()));
     $actions = array();
     foreach ($upaIDs as $upaID) {
         $action = static::getByID($upaID);
         if (is_object($action)) {
             $actions[] = $action;
         }
     }
     return $actions;
 }
function display_comp(Package $component, TableCreator $table_creator)
{
    $string = "";
    $component->with('classes');
    foreach ($component->classes as $class) {
        $string .= display_class($class, $table_creator);
    }
    $component->with('packages');
    $nested = $component->packages;
    foreach ($nested as $nuc) {
        $string .= display_comp($nuc, $table_creator);
    }
    return $string;
}
Beispiel #21
0
 /**
  * 
  * Returns a new Package instance.
  * 
  * @param array $info An array of package information with keys
  * 'formatter', 'fallback', and 'messages'. Typically read from an
  * `intl/xx_XX.php` file.
  * 
  * @return Package
  * 
  */
 public function newInstance(array $info)
 {
     $package = new Package();
     if (isset($info['fallback'])) {
         $package->setFallback($info['fallback']);
     }
     if (isset($info['formatter'])) {
         $package->setFormatter($info['formatter']);
     }
     if (isset($info['messages'])) {
         $package->setMessages($info['messages']);
     }
     return $package;
 }
Beispiel #22
0
 public function getPackageInstalledDate(Package $pkg, $format = null)
 {
     $appid = $pkg->getAppId();
     if (!isset($this->pkg_install_dates[$appid])) {
         $this->pkg_install_dates[$appid] = InstallLog::packageInstalledDates($this, $appid);
     }
     if (!isset($this->pkg_install_dates[$appid][$pkg->getId()])) {
         return null;
     }
     $date = $this->pkg_install_dates[$appid][$pkg->getId()];
     if ($format) {
         $date = date($format, strtotime($date));
     }
     return $date;
 }
 public function testCascadingInsert()
 {
     $package = new Package();
     $package->description = 'Package';
     $packageverison = new PackageVersion();
     $packageverison->description = 'Version';
     $packageverisonnotes = new PackageVersionNotes();
     $packageverisonnotes->description = 'Notes';
     $package->Version[0] = $packageverison;
     $package->Version[0]->Note[0] = $packageverisonnotes;
     $package->save();
     $this->assertNotNull($package->id);
     $this->assertNotNull($package->Version[0]->id);
     $this->assertNotNull($package->Version[0]->Note[0]->id);
 }
Beispiel #24
0
 public function testCreate()
 {
     $package = new Package();
     $package->setWeight(5);
     $package->setWidth(6);
     $package->setLength(7);
     $package->setHeight(8);
     $this->assertEquals(5, $package->getWeight());
     $this->assertEquals(6, $package->getWidth());
     $this->assertEquals(7, $package->getLength());
     $this->assertEquals(8, $package->getHeight());
 }
Beispiel #25
0
	public function module($module = null, $task = null) {
		Loader::model('dashboard/homepage');
		$dh = new DashboardHomepageView();

		$mod = $dh->getByHandle($module);
		if ($mod->pkgID > 0) {
			$pkg = Package::getByID($mod->pkgID);
			$class = Loader::dashboardModuleController($mod->dbhModule, $pkg);
		} else {
			$class = Loader::dashboardModuleController($mod->dbhModule);
		}
		
		$args = func_get_args();

		array_shift($args);
		array_shift($args); // no that's not a misprint
		
		if (method_exists($class, $task)) {
			try {
				$resp = call_user_func_array(array($class, $task), $args);
				if ($resp) {
					$this->set('message', $resp);
				}
			} catch(Exception $e) {
				$this->set('error', $e);
			}
		}
				
		print $this->view();
	}
 /**
  * Returns a list of all classes inside a given package
  *
  * @param   lang.reflect.Package 
  * @param   bool recursive whether to include subpackages
  * @return  lang.XPClass[]
  */
 protected static function testClassesIn(Package $package, $recursive)
 {
     $r = array();
     foreach ($package->getClasses() as $class) {
         if (!$class->isSubclassOf('unittest.TestCase') || Modifiers::isAbstract($class->getModifiers())) {
             continue;
         }
         $r[] = $class;
     }
     if ($recursive) {
         foreach ($package->getPackages() as $package) {
             $r = array_merge($r, self::testClassesIn($package, $recursive));
         }
     }
     return $r;
 }
Beispiel #27
0
 public function install()
 {
     $pkg = parent::install();
     Loader::model('single_page');
     $main = SinglePage::add('/dashboard/multisite', $pkg);
     $mainSites = SinglePage::add('/dashboard/multisite/sites', $pkg);
 }
 public function testGeneratesXml()
 {
     $package = Package::create(self::$name)->setAuthor('VikiJel')->addExtension('com_test', self::$archive_src)->addLanguage(self::$ini_src)->addUpdateServer('http://example.com', 'testserver')->setScriptfile(self::$php_src);
     $instance = Xml::create($package)->init();
     $simple_xml = simplexml_load_string((string) $instance);
     self::assertEquals('extension', (string) $simple_xml->getName());
     self::assertEquals('2.5', (string) $simple_xml->attributes()->version);
     self::assertEquals('upgrade', (string) $simple_xml->attributes()->method);
     self::assertEquals('package', (string) $simple_xml->attributes()->type);
     self::assertEquals('1.0.0', (string) $simple_xml->version);
     self::assertEquals(self::$name, (string) $simple_xml->name);
     self::assertEquals('package_test', (string) $simple_xml->packagename);
     self::assertEquals(date('Y-m-d'), (string) $simple_xml->creationDate);
     self::assertEquals('http://example.com', (string) $simple_xml->updateservers->server);
     self::assertEquals('testserver', (string) $simple_xml->updateservers->server->attributes()->name);
     self::assertEquals(1, (int) $simple_xml->updateservers->server->attributes()->priority);
     self::assertEquals('extension', (string) $simple_xml->updateservers->server->attributes()->type);
     self::assertEquals('com_test', (string) $simple_xml->files->file->attributes()->id);
     self::assertEquals('some_file.zip', (string) $simple_xml->files->file);
     self::assertEquals('en-GB.pkg_package_test.ini', (string) $simple_xml->languages->language);
     self::assertEquals('en-GB', (string) $simple_xml->languages->language->attributes()->tag);
     self::assertEquals('pkg_package_test.php', (string) $simple_xml->scriptfile);
     self::assertContains('VikiJel', (string) $simple_xml->copyright);
     self::assertContains(date('Y'), (string) $simple_xml->copyright);
     self::assertContains('VikiJel', (string) $simple_xml->packager);
     self::assertContains('vikijel', (string) $simple_xml->packagerurl);
 }
Beispiel #29
0
 /**
  *
  */
 public function action_index()
 {
     Package::load('oil');
     \Oil\Generate_Scaffold::forge(['page1', 'title:string', 'content:text'], "orm");
     $this->title = 'Backend Dashboard';
     $this->template->content = Presenter::forge('backend/page');
 }
 public function loadModel($id)
 {
     if (($model = Package::model()->findByPk($id)) === null) {
         throw new CHttpException(404, 'Страница не найдена');
     }
     return $model;
 }