本文整理汇总了PHP中common_Logger::w方法的典型用法代码示例。如果您正苦于以下问题:PHP common_Logger::w方法的具体用法?PHP common_Logger::w怎么用?PHP common_Logger::w使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common_Logger
的用法示例。
在下文中一共展示了common_Logger::w方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* Short description of method init
*
* @access public
* @author Sam
* @param array configuration
* @return boolean
*/
public function init($configuration)
{
parent::init($configuration);
$this->data = array();
$this->archivers = array();
if (isset($configuration['local_server_comment'])) {
$this->comment = strval($configuration['local_server_comment']);
}
foreach ($configuration['archivers'] as $archiverConfig) {
if (isset($archiverConfig['class'])) {
$classname = $archiverConfig['class'];
if (!class_exists($classname)) {
$classname = 'common_profiler_archiver_' . $classname;
}
if (class_exists($classname)) {
$archiver = new $classname();
try {
if ($archiver instanceof common_profiler_archiver_Archiver && !is_null($archiver) && $archiver->init($archiverConfig)) {
$this->archivers[] = $archiver;
}
} catch (InvalidArgumentException $e) {
common_Logger::w('archiver configuration issue: ' . $e->getMessage());
}
}
}
}
return true;
}
示例2: initElements
public function initElements()
{
$class = $this->data['class'];
if (!$class instanceof \core_kernel_classes_Class) {
throw new \common_Exception('missing class in simple delivery creation form');
}
$classUriElt = \tao_helpers_form_FormFactory::getElement('classUri', 'Hidden');
$classUriElt->setValue($class->getUri());
$this->form->addElement($classUriElt);
//create the element to select the import format
$formatElt = \tao_helpers_form_FormFactory::getElement('test', 'Combobox');
$formatElt->setDescription(__('Select the test you want to publish to the test-takers'));
$testClass = new \core_kernel_classes_Class(TAO_TEST_CLASS);
$options = array();
$testService = \taoTests_models_classes_TestsService::singleton();
foreach ($testClass->getInstances(true) as $test) {
try {
$testItems = $testService->getTestItems($test);
//Filter tests which has no items
if (!empty($testItems)) {
$options[$test->getUri()] = $test->getLabel();
}
} catch (\Exception $e) {
\common_Logger::w('Unable to load items for test ' . $test->getUri());
}
}
if (empty($options)) {
throw new NoTestsException();
}
$formatElt->setOptions($options);
$formatElt->addValidator(\tao_helpers_form_FormFactory::getValidator('NotEmpty'));
$this->form->addElement($formatElt);
}
示例3: login
/**
* Log in a user into Generis that has one of the provided $allowedRoles.
*
* @access public
* @author Jerome Bogaerts, <jerome@taotesting.com>
* @param string login The login of the user.
* @param string password the md5 hash of the password.
* @param allowedRoles A Role or an array of Roles that are allowed to be logged in. If the user has a Role that matches one or more Roles in this array, the login request will be accepted.
* @return boolean
*/
public function login(common_user_auth_Adapter $adapter, $allowedRoles = array())
{
$returnValue = (bool) false;
try {
$user = $adapter->authenticate();
if (!empty($allowedRoles)) {
// Role can be either a scalar value or a collection.
$allowedRoles = is_array($allowedRoles) ? $allowedRoles : array($allowedRoles);
$roles = array();
foreach ($allowedRoles as $r) {
$roles[] = $r instanceof core_kernel_classes_Resource ? $r->getUri() : $r;
}
unset($allowedRoles);
$intersect = array_intersect($roles, $user->getRoles());
if (empty($intersect)) {
common_Logger::w('User ' . $user->getIdentifier() . ' does not have the nescessary role');
return false;
}
}
$returnValue = $this->startSession($user);
} catch (common_user_auth_AuthFailedException $exception) {
// failed return false;
}
return (bool) $returnValue;
}
示例4: mapLTIRole2TaoRole
/**
* Maps a fuly qualified or abbreviated lti role
* to an existing tao role
*
* @param string $role
* @throws common_Exception
* @throws common_exception_Error
* @return core_kernel_classes_Resource the tao role or null
*/
public static function mapLTIRole2TaoRole($role)
{
$taoRole = null;
if (filter_var($role, FILTER_VALIDATE_URL)) {
// url found
$taoRole = new core_kernel_classes_Resource($role);
} else {
// if not fully qualified prepend LIS context role NS
if (strtolower(substr($role, 0, 4)) !== 'urn:') {
$role = self::LIS_CONTEXT_ROLE_NAMESPACE . $role;
}
list($prefix, $nid, $nss) = explode(':', $role, 3);
if ($nid != 'lti') {
common_Logger::w('Non LTI URN ' . $role . ' passed via LTI');
}
$urn = 'urn:' . strtolower($nid) . ':' . $nss;
// search for fitting role
$class = new core_kernel_classes_Class(CLASS_LTI_ROLES);
$cand = $class->searchInstances(array(PROPERTY_LTI_ROLES_URN => $urn));
if (count($cand) > 1) {
throw new common_exception_Error('Multiple instances share the URN ' . $urn);
}
if (count($cand) == 1) {
$taoRole = current($cand);
} else {
common_Logger::w('Unknown LTI role with urn: ' . $urn);
}
}
if (!is_null($taoRole) && $taoRole->exists()) {
return $taoRole->getUri();
} else {
return null;
}
}
示例5: importDelivery
public function importDelivery(core_kernel_classes_Class $deliveryClass, $archiveFile)
{
$folder = tao_helpers_File::createTempDir();
$zip = new ZipArchive();
if ($zip->open($archiveFile) !== true) {
return common_report_Report::createFailure(__('Unable to export Archive'));
}
$zip->extractTo($folder);
$zip->close();
$manifestPath = $folder . self::MANIFEST_FILE;
if (!file_exists($manifestPath)) {
return common_report_Report::createFailure(__('Manifest not found in assembly'));
}
$manifest = json_decode(file_get_contents($manifestPath), true);
try {
$this->importDeliveryFiles($deliveryClass, $manifest, $folder);
$delivery = $this->importDeliveryResource($deliveryClass, $manifest);
$report = common_report_Report::createSuccess(__('Delivery "%s" successfully imported', $delivery->getUri()), $delivery);
} catch (Exception $e) {
common_Logger::w($e->getMessage());
if (isset($delivery) && $delivery instanceof core_kernel_classes_Resource) {
$delivery->delete();
}
$report = common_report_Report::createFailure(__('Unkown error during impoort'));
}
return $report;
}
示例6: update
/**
*
* @param string $currentVersion
* @return string $versionUpdatedTo
*/
public function update($initialVersion)
{
$currentVersion = $initialVersion;
//migrate from 2.6 to 2.6.1
if ($currentVersion == '2.6') {
//data upgrade
OntologyUpdater::syncModels();
$currentVersion = '2.6.1';
}
if ($currentVersion == '2.6.1') {
$ext = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoDelivery');
$className = $ext->getConfig(\taoDelivery_models_classes_execution_ServiceProxy::CONFIG_KEY);
if (is_string($className)) {
$impl = null;
switch ($className) {
case 'taoDelivery_models_classes_execution_OntologyService':
$impl = new \taoDelivery_models_classes_execution_OntologyService();
break;
case 'taoDelivery_models_classes_execution_KeyValueService':
$impl = new \taoDelivery_models_classes_execution_KeyValueService(array(\taoDelivery_models_classes_execution_KeyValueService::OPTION_PERSISTENCE => 'deliveryExecution'));
break;
default:
\common_Logger::w('Unable to migrate custom execution service');
}
if (!is_null($impl)) {
$proxy = \taoDelivery_models_classes_execution_ServiceProxy::singleton();
$proxy->setImplementation($impl);
$currentVersion = '2.6.2';
}
}
}
return $currentVersion;
}
示例7: buildDirectory
public static function buildDirectory(core_kernel_classes_Resource $test, $lang, $relPath = '/', $depth = 1, $filters = array())
{
$baseDir = self::getBaseDir($test);
$path = $baseDir . ltrim($relPath, '/');
$data = array('path' => $relPath);
if ($depth > 0) {
$children = array();
if (is_dir($path)) {
foreach (new DirectoryIterator($path) as $fileinfo) {
if (!$fileinfo->isDot()) {
$subPath = rtrim($relPath, '/') . '/' . $fileinfo->getFilename();
if ($fileinfo->isDir()) {
$children[] = self::buildDirectory($test, $lang, $subPath, $depth - 1, $filters);
} else {
$file = self::buildFile($test, $lang, $subPath, $filters);
if (!is_null($file)) {
$children[] = $file;
}
}
}
}
} else {
common_Logger::w('"' . $path . '" is not a directory');
}
$data['children'] = $children;
} else {
$data['url'] = _url('files', 'TestContent', 'taoQtiTest', array('uri' => $test->getUri(), 'lang' => $lang, 'path' => $relPath));
}
return $data;
}
示例8: createFailure
/**
* Create a formatted failure report and log a warning
*
* @param $userMessage
* @param null $model
* @return Report
*/
private function createFailure($userMessage, $model = null)
{
$typeIdentifier = is_null($model) ? 'unknown type' : $model->getTypeIdentifier();
$message = 'The portable element cannot be registered "' . $typeIdentifier . '", reason: ' . $userMessage;
\common_Logger::w($message);
return Report::createFailure($message);
}
示例9: isDeliveryExecutionAllowed
public function isDeliveryExecutionAllowed(core_kernel_classes_Resource $delivery, User $user)
{
$userUri = $user->getIdentifier();
if (is_null($delivery)) {
common_Logger::w("Attempt to start the compiled delivery " . $delivery->getUri() . " related to no delivery");
return false;
}
//first check the user is assigned
if (!taoDelivery_models_classes_AssignmentService::singleton()->isUserAssigned($delivery, $user)) {
common_Logger::w("User " . $userUri . " attempts to start the compiled delivery " . $delivery->getUri() . " he was not assigned to.");
return false;
}
$settings = $this->getDeliverySettings($delivery);
//check Tokens
$usedTokens = count(taoDelivery_models_classes_execution_ServiceProxy::singleton()->getUserExecutions($delivery, $userUri));
if ($settings[TAO_DELIVERY_MAXEXEC_PROP] != 0 and $usedTokens >= $settings[TAO_DELIVERY_MAXEXEC_PROP]) {
common_Logger::d("Attempt to start the compiled delivery " . $delivery->getUri() . "without tokens");
return false;
}
//check time
$startDate = date_create('@' . $settings[TAO_DELIVERY_START_PROP]);
$endDate = date_create('@' . $settings[TAO_DELIVERY_END_PROP]);
if (!$this->areWeInRange($startDate, $endDate)) {
common_Logger::d("Attempt to start the compiled delivery " . $delivery->getUri() . " at the wrong date");
return false;
}
return true;
}
示例10: getDirectory
/**
* (non-PHPdoc)
* @see \oat\tao\model\media\MediaBrowser::getDirectory
*/
public function getDirectory($parentLink = '/', $acceptableMime = array(), $depth = 1)
{
$sysPath = $this->getSysPath($parentLink);
$label = substr($parentLink, strrpos($parentLink, '/') + 1);
if (!$label) {
$label = 'local';
}
$data = array('path' => $parentLink, 'label' => $label);
if ($depth > 0) {
$children = array();
if (is_dir($sysPath)) {
foreach (new DirectoryIterator($sysPath) as $fileinfo) {
if (!$fileinfo->isDot()) {
$subPath = rtrim($parentLink, '/') . '/' . $fileinfo->getFilename();
if ($fileinfo->isDir()) {
$children[] = $this->getDirectory($subPath, $acceptableMime, $depth - 1);
} else {
$file = $this->getFileInfo($subPath, $acceptableMime);
if (!is_null($file) && (count($acceptableMime) == 0 || in_array($file['mime'], $acceptableMime))) {
$children[] = $file;
}
}
}
}
} else {
common_Logger::w('"' . $sysPath . '" is not a directory');
}
$data['children'] = $children;
} else {
$data['url'] = _url('files', 'ItemContent', 'taoItems', array('uri' => $this->item->getUri(), 'lang' => $this->lang, 'path' => $parentLink));
}
return $data;
}
示例11: getStrings
public function getStrings($values)
{
$contentStrings = array();
$xmlTokenizer = new taoItems_models_classes_search_XmlItemContentTokenizer();
foreach ($values as $valueUri) {
$file = new core_kernel_file_File($valueUri);
try {
$content = file_get_contents($file->getAbsolutePath());
if ($content === false) {
common_Logger::w('File ' . $file->getAbsolutePath() . ' not found for item');
} else {
// Try to make it a DOM Document...
$dom = new DOMDocument('1.0', 'UTF-8');
if (@$dom->loadXML($content) === true) {
$contentStrings = array_merge($contentStrings, $xmlTokenizer->getStrings($dom));
unset($dom);
} else {
common_Logger::d('Skipped non XML content for ' . $file->getUri());
}
}
} catch (common_Exception $exc) {
common_Logger::w('Invalid file ' . $valueUri . ' for ItemContentTokenizer: ' . $exc->getMessage());
}
}
return $contentStrings;
}
示例12: getUncached
private function getUncached($property)
{
$value = array();
switch ($property) {
case PROPERTY_USER_DEFLG:
case PROPERTY_USER_UILG:
$resource = $this->getUserResource()->getOnePropertyValue(new \core_kernel_classes_Property($property));
if (!is_null($resource)) {
if ($resource instanceof \core_kernel_classes_Resource) {
return array($resource->getUniquePropertyValue(new \core_kernel_classes_Property(RDF_VALUE)));
} else {
common_Logger::w('Language ' . $resource . ' is not a resource');
return array(DEFAULT_LANG);
}
} else {
return array(DEFAULT_LANG);
}
break;
case PROPERTY_USER_ROLES:
return array("http://www.tao.lu/Ontologies/TAOItem.rdf#TestAuthor", "http://www.tao.lu/Ontologies/TAOItem.rdf#ItemAuthor");
case "http://www.tao.lu/Ontologies/TAO.rdf#FirstTimeInTao":
return array("http://www.tao.lu/Ontologies/generis.rdf#False");
case "http://www.tao.lu/Ontologies/TAO.rdf#LastExtensionUsed":
return array("tao/Main/index?structure=items&ext=taoItems");
default:
return $this->getUserResource()->getPropertyValues(new \core_kernel_classes_Property($property));
}
}
示例13: files
/**
* Returns a json encoded array describign a directory
*
* @throws common_exception_MissingParameter
* @return string
*/
public function files()
{
if (!$this->hasRequestParameter('uri')) {
throw new common_exception_MissingParameter('uri', __METHOD__);
}
$testUri = $this->getRequestParameter('uri');
$test = new core_kernel_classes_Resource($testUri);
if (!$this->hasRequestParameter('lang')) {
throw new common_exception_MissingParameter('lang', __METHOD__);
}
$testLang = $this->getRequestParameter('lang');
$subPath = $this->hasRequestParameter('path') ? $this->getRequestParameter('path') : '/';
$depth = $this->hasRequestParameter('depth') ? $this->getRequestParameter('depth') : 1;
//build filters
$filters = array();
if ($this->hasRequestParameter('filters')) {
$filterParameter = $this->getRequestParameter('filters');
if (!empty($filterParameter)) {
if (preg_match('/\\/\\*/', $filterParameter)) {
common_Logger::w('Stars mime type are not yet supported, filter "' . $filterParameter . '" will fail');
}
$filters = array_map('trim', explode(',', $filterParameter));
}
}
$data = taoQtiTest_helpers_ResourceManager::buildDirectory($test, $testLang, $subPath, $depth, $filters);
echo json_encode($data);
}
示例14: verifyResumeAuthorization
/**
* Verify that a given delivery execution is allowed to be executed
*
* @param DeliveryExecution $deliveryExecution
* @param User $user
* @throws \common_exception_Unauthorized
*/
public function verifyResumeAuthorization(DeliveryExecution $deliveryExecution, User $user)
{
$stateId = $deliveryExecution->getState()->getUri();
if (!in_array($stateId, $this->getResumableStates())) {
\common_Logger::w('Unexpected state "' . $stateId);
throw new \common_exception_Unauthorized();
}
}
示例15: getPersistence
public static function getPersistence($driverId)
{
$returnValue = common_persistence_Manager::getPersistence($driverId);
$class = get_called_class();
if (!$returnValue instanceof $class) {
common_Logger::w('Got a ', get_class($returnValue) . ' instead of ' . $class);
}
return $returnValue;
}