本文整理汇总了PHP中PartKeepr\PartKeepr::i18n方法的典型用法代码示例。如果您正苦于以下问题:PHP PartKeepr::i18n方法的具体用法?PHP PartKeepr::i18n怎么用?PHP PartKeepr::i18n使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PartKeepr\PartKeepr
的用法示例。
在下文中一共展示了PartKeepr::i18n方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setPackagingUnit
/**
* Sets the packaging unit for a specific distributor.
*
* For example, some distributors only sell resistors in packs of 100, so you can't order just one. We use the
* packagingUnit to calculate how many pieces will be delivered once ordered. So if your stock level falls below
* the minimum (example: you would need to order 10 resistors), we suggest that you only order one resistor pack
* instead of 10.
*
* @param int $packagingUnit The amount of items in one package
* @throws \PartKeepr\Part\OutOfRangeException When the packaging unit is less than 1
*/
public function setPackagingUnit($packagingUnit)
{
$packagingUnit = intval($packagingUnit);
if ($packagingUnit < 1) {
$exception = new OutOfRangeException(PartKeepr::i18n("Packaging Unit is out of range"));
$exception->setDetail(PartKeepr::i18n("The packaging unit must be 1 or higher"));
throw $exception;
}
$this->packagingUnit = $packagingUnit;
}
示例2: uploadCam
/**
* Processes data via HTTP POST. Reads php://input and creates a temporary image out of it.
*/
public function uploadCam()
{
$tempFile = tempnam("/tmp", "PWC") . ".jpg";
$result = file_put_contents($tempFile, file_get_contents('php://input'));
$image = new TempUploadedFile();
$image->replace($tempFile);
$image->setOriginalFilename(sprintf(PartKeepr::i18n("Cam photo of %s"), date("Y-m-d H:i:s")) . ".jpg");
PartKeepr::getEM()->persist($image);
PartKeepr::getEM()->flush();
return array("id" => $image->getId(), "extension" => $image->getExtension(), "size" => $image->getSize(), "originalFilename" => $image->getOriginalFilename());
}
示例3: decode
/**
* Method decodes the incoming string and returns the JSON decoded array if
* everything was fine. If a syntax error was detected, it throws an exception.
*
* @param string $string
* @throws InvalidArgumentException
*/
public static function decode($string)
{
$jsonDecoded = json_decode(trim($string), true);
if ($jsonDecoded === null) {
if (strlen($string) == 0) {
$jsonDecoded = array();
} else {
throw new InvalidArgumentException(PartKeepr::i18n('Extended rendering configuration contains an error!'));
}
}
return $jsonDecoded;
}
示例4: changePassword
public function changePassword()
{
if (Configuration::getOption("partkeepr.frontend.allow_password_change", true) === false) {
throw new \Exception("Password changing has been disabled on this server");
}
if (!$this->getUser()->compareHashedPassword($this->getParameter("oldpassword"))) {
throw new \Exception("Invalid Password");
} else {
$this->getUser()->setHashedPassword($this->getParameter("newpassword"));
}
return array("data" => PartKeepr::i18n("Password changed successfully"));
}
示例5: deleteFootprint
/**
* Deletes the footprint with the given id.
*
* @param int $id The footprint id to delete
* @throws \PartKeepr\Util\SerializableException
*/
public function deleteFootprint($id)
{
$footprint = Footprint::loadById($id);
try {
PartKeepr::getEM()->remove($footprint);
PartKeepr::getEM()->flush();
} catch (\PDOException $e) {
if ($e->getCode() == "23000") {
$exception = new SerializableException(sprintf(PartKeepr::i18n("Footprint %s is in use by some parts!"), $footprint->getName()));
$exception->setDetail(sprintf(PartKeepr::i18n("You tried to delete the footprint %s, but there are parts which use this footprint."), $footprint->getName()));
throw $exception;
}
}
}
示例6: massCreate
/**
* Creates multiple storage locations at once.
*
* Requires that the parameter "storageLocations" is set to an array with the names of the storage locations.
* Returns all error messages as "data" index in the result array.
*/
public function massCreate()
{
$this->requireParameter("storageLocations");
$aMessages = array();
foreach ($this->getParameter("storageLocations") as $storageLocation) {
try {
$obj = StorageLocationManager::getInstance()->getStorageLocationByName($storageLocation);
$aMessages[] = sprintf(PartKeepr::i18n("Storage Location %s already exists"), $storageLocation);
} catch (\Exception $e) {
$obj = new StorageLocation();
$obj->setName($storageLocation);
PartKeepr::getEM()->persist($obj);
}
}
PartKeepr::getEM()->flush();
return array("data" => $aMessages);
}
示例7: run
/**
* Sets up the default part unit if none exists
*/
public function run()
{
$dql = "SELECT COUNT(p) FROM PartKeepr\\Part\\PartUnit p WHERE p.is_default = :default";
$query = $this->entityManager->createQuery($dql);
$query->setParameter("default", true);
if ($query->getSingleScalarResult() == 0) {
$partUnit = new PartUnit();
$partUnit->setName(PartKeepr::i18n("Pieces"));
$partUnit->setShortName(PartKeepr::i18n("pcs"));
$partUnit->setDefault(true);
$this->entityManager->persist($partUnit);
$this->entityManager->flush();
$this->logMessage("Added default part unit");
} else {
$this->logMessage("Skipped adding default part unit, because a default part unit already exists");
}
}
示例8: deleteCategory
/**
* Deletes the given category ID.
* @param $id int The category id to delete
* @throws CategoryNotFoundException If the category wasn't found
*/
public function deleteCategory($id)
{
$category = $this->getCategory($id);
try {
if ($category->hasChildren()) {
$exception = new SerializableException(sprintf(PartKeepr::i18n("Category '%s' contains other categories."), $category->getNode()->getName()));
$exception->setDetail(sprintf(PartKeepr::i18n("You tried to delete the category '%s', but it still contains other categories. Please move the categories or delete them first."), $category->getNode()->getName()));
throw $exception;
}
parent::deleteCategory($id);
} catch (\PDOException $e) {
if ($e->getCode() == "23000") {
$exception = new SerializableException(sprintf(PartKeepr::i18n("Category '%s' contains parts."), $category->getNode()->getName()));
$exception->setDetail(sprintf(PartKeepr::i18n("You tried to delete the category '%s', but it still contains parts. Please move the parts to another category."), $category->getNode()->getName()));
throw $exception;
} else {
throw $e;
}
}
}
示例9: __construct
public function __construct()
{
parent::__construct(PartKeepr::i18n("Username or Password wrong."));
}
示例10: checkPermissions
/**
* Checks if the path where the file should be stored has sufficient permissions to do so.
*
* @throws SerializableException
*/
public function checkPermissions()
{
if (!is_writable($this->getFilePath())) {
throw new SerializableException(sprintf(PartKeepr::i18n("Unable to write to directory %s"), $this->getFilePath()));
}
}
示例11: doVersionCheck
/**
* Checks against the versions at partkeepr.org.
*
* If a newer version was found, create a system notice entry.
*/
public static function doVersionCheck()
{
$data = file_get_contents("http://www.partkeepr.org/versions.json");
$versions = json_decode($data, true);
if (PartKeeprVersion::PARTKEEPR_VERSION == "{V_GIT}") {
return;
}
if (substr(PartKeeprVersion::PARTKEEPR_VERSION, 0, 17) == "partkeepr-nightly") {
return;
}
if (version_compare(PartKeepr::getVersion(), $versions[0]["version"], '<')) {
SystemNoticeManager::getInstance()->createUniqueSystemNotice("PARTKEEPR_VERSION_" . $versions[0]["version"], sprintf(PartKeepr::i18n("New PartKeepr Version %s available"), $versions[0]["version"]), sprintf(PartKeepr::i18n("PartKeepr Version %s changelog:"), $versions[0]["version"]) . "\n\n" . $versions[0]["changelog"]);
}
}
示例12: __construct
/**
* Constructs the exception
* @param BaseEntity $entity
*/
public function __construct(Part $part)
{
parent::__construct(PartKeepr::i18n("Part %s has no category assigned", $part));
}
示例13: array
$aPreferences = array();
foreach ($user->getPreferences() as $result) {
$aPreferences[] = $result->serialize();
}
$aParameters["userPreferences"] = array("response" => array("data" => $aPreferences));
}
\Twig_Autoloader::register();
$loader = new \Twig_Loader_Filesystem(dirname(__FILE__) . '/templates/');
$twig = new \Twig_Environment($loader);
/* Information about maximum upload sizes */
$maxPostSize = PartKeepr::getBytesFromHumanReadable(ini_get("post_max_size"));
$maxFileSize = PartKeepr::getBytesFromHumanReadable(ini_get("upload_max_filesize"));
$aParameters["maxUploadSize"] = min($maxPostSize, $maxFileSize);
if (!class_exists("Imagick")) {
$template = $twig->loadTemplate("error.tpl");
echo $template->render(array("title" => PartKeepr::i18n("ImageMagick is not installed"), "error" => PartKeepr::i18n("You are missing the ImageMagick extension. Please install it and restart the setup to verify that the library was installed correctly.")));
exit;
}
/* ImageMagick formats */
$imagick = new \Imagick();
$aParameters["availableImageFormats"] = $imagick->queryFormats();
/* Automatic Login */
if (Configuration::getOption("partkeepr.frontend.autologin.enabled", false) === true) {
$aParameters["autoLoginUsername"] = Configuration::getOption("partkeepr.frontend.autologin.username");
$aParameters["autoLoginPassword"] = Configuration::getOption("partkeepr.frontend.autologin.password");
}
if (Configuration::getOption("partkeepr.frontend.motd", false) !== false) {
$aParameters["motd"] = Configuration::getOption("partkeepr.frontend.motd");
}
/* Load and render the template */
$template = $twig->loadTemplate("index.tpl");
示例14: __construct
public function __construct($username)
{
parent::__construct(sprintf(PartKeepr::i18n("The user %s doesn't exist. Maybe the user was already deleted."), $username));
}
示例15: testAPC
/**
* Tests for APC. Throws an exception if APC is missing or not active.
* @throws \Exception
*/
public function testAPC()
{
if (!extension_loaded("apc")) {
throw new \Exception(PartKeepr::i18n("The extension 'apc' is not loaded. Make sure that it is installed (see http://php.net/manual/en/apc.installation.php) and that it is enabled (set apc.enabled=1 in your php.ini)."));
}
}