/** * Handles a single upload by given CUploadedFile and returns an array * of informations. * * The 'error' attribute of the array, indicates there was an error. * * Informations on error: * - error: true * - errorMessage: some message * - name: name of the file * - size: file size * * Informations on success: * - error: false * - name: name of the uploaded file * - size: file size * - guid: of the file * - url: url to the file * - thumbnailUrl: url to the thumbnail if exists * * @param type $cFile * @return Array Informations about the uploaded file */ protected function handleFileUpload($cFile) { $output = array(); // Set some basic information $output['name'] = $cFile->getName(); $output['size'] = $cFile->getSize(); // Received a file? if ($cFile == null) { $output['error'] = true; $output['errorMessage'] = Yii::t('FileModule.controllers_FileController', 'No file received!'); return $output; } // Maximum File Size if ($cFile->getSize() > HSetting::Get('maxFileSize', 'file')) { $output['error'] = true; $output['errorMessage'] = Yii::t('FileModule.controllers_FileController', 'Maximum file size has been {maxFileSize} reached!', array("{maxFileSize}" => Yii::app()->format->formatSize(HSetting::Get('maxFileSize', 'file')))); return $output; } if (!File::HasValidExtension($cFile->getName())) { $output['error'] = true; $output['errorMessage'] = Yii::t('FileModule.controllers_FileController', 'This file type is not allowed!'); return $output; } // Store File $file = File::store($cFile); // Check File Storage if ($file == null) { $output['state'] = 'error'; $output['errorMessage'] = Yii::t('FileModule.controllers_FileController', 'Internal Error: Could not store file!'); return $output; } // Write successful array $output['error'] = false; $output['guid'] = $file->guid; $output['name'] = $file->file_name; $output['title'] = $file->title; $output['url'] = ""; $output['thumbnailUrl'] = ""; $output['size'] = $file->size; $output['deleteUrl'] = ""; $output['deleteType'] = ""; $output['mimeIcon'] = $file->getMimeIconClass(); return $output; }
/** * * @param type $item * @return \ifirma\InvoicePosition */ protected function createInvoicePosition($item) { $invoicePosition = new ifirma\InvoicePosition(); $invoicePosition->{ifirma\InvoicePosition::KEY_JEDNOSTKA} = self::DEFAULT_UNIT_NAME; $invoicePosition->{ifirma\InvoicePosition::KEY_STAWKA_VAT} = sprintf("%.2f", $item->getTaxPercent() / 100); $invoicePosition->{ifirma\InvoicePosition::KEY_ILOSC} = $item->getQtyOrdered(); $invoicePosition->{ifirma\InvoicePosition::KEY_CENA_JEDNOSTKOWA} = $this->roundPrice($item->getPriceInclTax()); $invoicePosition->{ifirma\InvoicePosition::KEY_NAZWA_PELNA} = $item->getName(); $invoicePosition->{ifirma\InvoicePosition::KEY_TYP_STAWKI_VAT} = ifirma\InvoicePosition::DEFAULT_VALUE_TYP_STAWKI_VAT; return $invoicePosition; }
/** * Run the analysis * * @return \Puml\Model\Object * @since 0.1 */ public function run() { $this->reflectedObject = new \ReflectionClass($this->objectName); $this->object->setName($this->reflectedObject->getName()); /* Analyse its properties */ $this->extractProperties($this->reflectedObject, $this->object); /* Analyse its methods */ $this->extractMethods($this->reflectedObject, $this->object); /* Analyse its parents */ $this->determineParent($this->reflectedObject, $this->object); return $this->object; }
/** * will download a zip file with the same name as the item name, * if the item exists, then will exit. * * @param type $item */ private function _downloadEmptyItem($item) { ob_start(); $this->disableView(); if (isset($item) && $item instanceof ItemDao) { $name = $item->getName(); } else { $name = 'No_item_selected'; } $name = substr($name, 0, 50); if (headers_sent()) { echo $name; // this is used in testing mode since we cannot send headers from ZipStream return; } $zip = new \ZipStream\ZipStream($name . '.zip'); $zip->finish(); exit; }
/** * Create one element * * @param type $node */ private function _generateElement($node) { if (!$node->isAllow()) { return; } $cssClasses = array(); $cssActive = ''; if ($node->isActive()) { $cssActive = 'class="active"'; } if (!is_null($node->getClass())) { $cssClasses[] = $node->getClass(); } $class = count($cssClasses) > 0 ? " class='" . implode(',', $cssClasses) . "'" : ''; $id = !is_null($node->getId()) ? " id='" . $node->getId() . "'" : ''; $target = !is_null($node->getTarget()) ? " target='" . $node->getTarget() . "'" : ''; $this->html .= "\t\t" . '<li ' . $cssActive . '>' . PHP_EOL; if (!$node->hasChilds()) { $this->html .= "\t\t\t" . '<a href="' . $node->getUrl() . '" ' . $target . ' class="nav-header" ><span' . $class . '></span> ' . $this->_translate($node->getName()) . "</a>" . PHP_EOL; } //generate childs if ($node->hasChilds()) { //$this->html .= "\t\t<div class='dropdown'>" . PHP_EOL; $this->html .= '<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">' . $this->_translate($node->getName()) . ' <span class="caret"></span></a>' . PHP_EOL; $this->html .= "\t\t<ul class=\"dropdown-menu\">" . PHP_EOL; $this->_generateChilds($node->getChilds()); $this->html .= "\t\t</ul>" . PHP_EOL; //$this->html .= "\t\t</div>" . PHP_EOL; } $this->html .= "\t\t</li>" . PHP_EOL; }
/** * * @param type $original_field * @param type $newfield */ private function isDifferent($original_field, $newfield) { $check = array("type" => array("setter" => "setType", "getter" => "getType"), "default" => array("setter" => "setDefault", "getter" => "getDefault"), "extra" => array("setter" => "setExtra", "getter" => "getExtra"), "key" => array("setter" => "setKey", "getter" => "getKey"), "nullable" => array("setter" => "setNullable", "getter" => "getNullable")); $diverso = false; foreach ($check as $nome => $metodi) { $getter = $metodi["getter"]; if (trim(strtolower($original_field->{$getter}())) != trim(strtolower($newfield->{$getter}()))) { $diverso = true; } } if ($diverso) { $this->diversi[$original_field->getName()] = $newfield; } }
/** * Get a clean name of an element. to be used for Ids * @param type $element * @return type */ public function getCleanName($element) { return str_replace(array('[', ']'), '', $element->getName()); }
/** * Create one element * * @param type $node */ private function _generateElement($node) { $cssClasses = array(); if ($node->isActive()) { $cssClasses[] = 'active'; } if (!is_null($node->getClass())) { $cssClasses[] = $node->getClass(); } $class = count($cssClasses) > 0 ? " class='" . implode(',', $cssClasses) . "'" : ''; $id = !is_null($node->getId()) ? " id='" . $node->getId() . "'" : ''; $target = !is_null($node->getTarget()) ? " target='" . $node->getTarget() . "'" : ''; $this->html .= "\t\t<li{$class} {$id}>" . PHP_EOL; $this->html .= "\t\t\t<a title='" . $this->_translate($node->getName()) . "' href='" . $node->getUrl() . "' {$target}>" . $this->_translate($node->getName()) . "</a>" . PHP_EOL; //generate childs if ($node->hasChilds()) { $this->html .= "\t\t<div class='dropdown'>" . PHP_EOL; $this->html .= "\t\t<ul>" . PHP_EOL; $this->_generateChilds($node->getChilds()); $this->html .= "\t\t</ul>" . PHP_EOL; $this->html .= "\t\t</div>" . PHP_EOL; } $this->html .= "\t\t</li>" . PHP_EOL; }
/** * Dynamically assign "protect" right when needed * @global type $wgTitle * @global type $wgProtectOwnDoProtect * @param type $user * @param type $aRights * @return type */ function poUserGetRights($user, &$aRights) { // When updating title's restriction, "protect" and user's group rights are needed // so when flushing rights (in Form() code), the next lines grant the rights. // Activated by setting $wgProtectOwnDoProtect to true. global $wgProtectOwnDoProtect, $wgTitle; if ($wgProtectOwnDoProtect) { wfDebugLog('ProtectOwn', 'UserGetRights: GRANT "protect"' . ' to ' . $user->getName() . '"[' . $user->getID() . ']'); $aRights[] = 'protect'; $aRights = array_unique($aRights); } poGrantProtectionRights($wgTitle, $user, $aRights); return true; // don't stop hook processing }