private function sendToImportObjects($fileUrl) { foreach ($this->importObjects as $importObject) { if ($this->isPending($importObject->get(Gpf_Db_Table_ImportExports::CODE), $this->_('Import') . ' ' . $this->_localize($importObject->get(Gpf_Db_Table_ImportExports::NAME)))) { $this->logger->debug(strtoupper($this->_localize($importObject->get(Gpf_Db_Table_ImportExports::NAME))) . ' STARTED'); $objectImportExport = Gpf::newObj($importObject->get(Gpf_Db_Table_ImportExports::CLASS_NAME)); $params = new Gpf_Rpc_Params(); $params->add("fileUrl", $fileUrl); $params->add("delimiter", $this->delimiter); $params->add('startTime', $this->getStartTime()); if (in_array($importObject->get(Gpf_Db_Table_ImportExports::CODE), $this->codes)) { $params->add("delete", 'Y'); } try { $objectImportExport->importData($params); } catch (Gpf_Tasks_LongTaskInterrupt $e) { $this->logger->debug('IMPORT INTERRUPTED'); $this->createOutputMessage($importObject, $objectImportExport->getOutputMessage()); $this->interrupt(); } catch (Exception $e) { $this->logger->error($e->getMessage()); $this->createOutputMessage($importObject, $objectImportExport->getOutputMessage()); $objectImportExport->forceFinishTask(); throw $e; } $this->logger->debug(strtoupper($this->_localize($importObject->get(Gpf_Db_Table_ImportExports::NAME))) . ' ENDED'); $this->createOutputMessage($importObject, $objectImportExport->getOutputMessage()); $this->setDone(); } } }
protected function createConstructorInstance() { $reflectionClass = new ReflectionClass($this->className); $constructor = $reflectionClass->getConstructor(); if (is_object($constructor) && !$constructor->isPublic()) { throw new Gpf_Exception('Constructor of class ' . $this->className . ' is not public'); } $this->serviceObj = Gpf::newObj($this->className); }
protected function importClass($classname) { $fileName = Gpf::existsClass($classname); if (!$fileName) { echo "Class '{$classname}' was not found<br>"; return; } $this->processClass($fileName, $classname); }
private function executePhp($className) { include_once $this->file->getFileName(); if (!class_exists($className, false)) { throw new Gpf_Exception($className . " " . $this->_("doesnt exist's")); } $dbFile = Gpf::newObj($className); $dbFile->execute(); }
protected function createAuthUser() { if (!$this->existsVar(self::AUTH_USER)) { $authUser = Gpf::newObj(Gpf_Application::getInstance()->getAuthClass()); $this->authUser = $authUser->createAnonym(); $this->save($this->authUser); } else { $this->authUser = $this->getVar(self::AUTH_USER); } }
/** * @service * @anonym * * @param $gridcode */ public function getViews(Gpf_Rpc_Params $params) { $gridCode = $params->get("gridcode"); $viewsTable = Gpf_Db_Table_Views::getInstance(); $viewColumnsTable = Gpf_Db_Table_ViewColumns::getInstance(); $viewGrid = Gpf::newObj($gridCode); $views = $viewsTable->getAllViews($gridCode); $views->addColumn("columns"); $views->addColumn("defaultview"); $hasDefaultView = false; foreach ($views as $view) { $columns = $viewGrid->getAllViewColumns(); $viewColumnsTable->fillViewColumns($columns, $view->get('id')); $view->set('columns', $columns->toObject()); if (($view->get(Gpf_Db_Table_Views::NAME) == self::DEFAULT_VIEW_NAME) && ($view->get(Gpf_Db_Table_Views::ACCOUNTUSERID)=='')) { $hasDefaultView = true; $view->set('defaultview', Gpf::YES); } } if ($views->getSize() == 0) { $views->setHeader(array("id", "name", "rowsperpage", "columns", "defaultview")); } if (!$hasDefaultView) { $view = $views->createRecord(); $view->set('id', self::DEFAULT_VIEW_ID); $view->set('name', $this->_(self::DEFAULT_VIEW_NAME)); $view->set('rowsperpage', 30); $view->set('columns', $viewGrid->getDefaultViewColumns()->toObject()); $view->set('defaultview', Gpf::YES); $views->add($view); } return $views; }
public function executeTask() { $quickTaskId = $_GET['quicktask']; if (!$this->existQuickTask($quickTaskId)) { $this->output($this->_('Task does not exist!')); return; } $quickTask = $this->getQuickTask($quickTaskId); if (!$quickTask->isValid()) { $this->output($this->_('Task is not valid!')); return; } $authUser = Gpf::newObj(Gpf_Application::getInstance()->getAuthClass()); Gpf_Session::getInstance()->save($authUser->createPrivilegedUser()); try { $method = new Gpf_Tasks_QuickTaskRunner_ServiceMethod($quickTask->getRequest()); $response = $method->execute(); } catch (Gpf_Exception $e) { $this->output($e->getMessage()); return; } $this->output($response->toText()); Gpf_Db_Table_QuickTasks::getInstance()->removeTasksAfterExecute($quickTask); }
/** * * @return Gpf_Auth_User */ protected function loadUser(Gpf_Auth_Info $authInfo) { $authUser = Gpf::newObj(Gpf_Application::getInstance()->getAuthClass()); return $authUser->load($authInfo); }
/** * * @param unknown_type $path * @return Gpf_Plugins_Definition */ private function createPlugin($path) { $className = ''; while (basename($path) != rtrim(Gpf_Paths::PLUGINS_DIR, '/') && basename($path) != 'include') { $className = basename($path) . '_' . $className; $path = dirname($path); } $className .= 'Definition'; if (Gpf::existsClass($className) === false) { throw new Gpf_Exception("Plugin definition class is missing in directory '{$path}'"); } return new $className(); }
protected function createLongTaskObject($className) { return Gpf::newObj($className); }
/** * Delete pending background task if it is allowed * * @service tasks delete * @param $params * @return Gpf_Rpc_Action */ public function deleteTask(Gpf_Rpc_Params $params) { $action = new Gpf_Rpc_Action($params); $dbTask = new Gpf_Db_Task(); try { $dbTask->setId($action->getParam('taskid')); $dbTask->load(); } catch (Gpf_Exception $e) { $action->addError(); $action->setErrorMessage($this->_('Failed to delete task.')); return $action; } if ($dbTask->isExecuting()) { $action->addError(); $action->setErrorMessage($this->_('It is not possible to delete running task.')); return $action; } try { $longTask = Gpf::newObj($dbTask->getClassName()); if (!$longTask->canUserDeleteTask()) { $action->addError(); $action->setErrorMessage($this->_('This type of task is not allowed to be deleted.')); return $action; } } catch (Gpf_Exception $e) { } $dbTask->delete(); $action->addOk(); $action->setInfoMessage($this->_('Task deleted.')); return $action; }
/** * @return Gpf_BarCode_Type_BarCode * @throws Gpf_Exception */ private function createBarCode() { if (!preg_match('/^\\d{2,10}$/', $this->code)) { throw new Gpf_BarCode_Exception('Code is not valid'); } if (array_key_exists($this->type, self::$barCodes)) { return Gpf::newObj(self::$barCodes[$this->type], $this->width, $this->height, $this->style, $this->code); } throw new Gpf_BarCode_Exception('Bar code object not exist'); }
<?php require_once 'bootstrap.php'; if(! (isset($argv[1])) ) { echo ("usage is $argv[0] Gpf_Benchmark arguments \n "); exit(); } $benchmark = Gpf::newObj($argv[1], $argv); $benchmark->run(); ?>
function Pap_Banners_BannerPopUpUnder() { $this->db = $this->createDatabase(); $this->bannerFactory = Gpf::newObj('Pap_Banners_BannerFactory'); }
function _papAutoload($class = null){ if ($class == '') { return; } Gpf::includeClass($class); }
private function renderPrivileges($className, $privilegeList, $privilegeTypes, $hasParentClass) { if ($fileName = Gpf::existsClass($className)) { $file = new Gpf_Io_File($fileName); $file->setFileMode('r'); $content = $file->getContents(); $file->close(); if (($pos = strpos($content, self::TAG)) === false) { throw new Gpf_Exception('Missing tag ' . self::TAG . ' in privileges class ' . $className . ' !'); } $file = new Gpf_Io_File($fileName); $file->open('w'); $file->write(substr($content, 0, $pos + strlen(self::TAG)) . "\n\n"); $file->write("\t// Privilege types\n"); foreach ($privilegeTypes as $privilege) { $file->write("\t" . 'const ' . $this->formatPrivilegeType($privilege) . ' = "' . $privilege . '";' . "\n"); } $file->write("\n"); $file->write("\t// Privilege objects\n"); foreach ($privilegeList as $object => $privileges) { ksort($privileges); $privilegeTypeComments = '// '; foreach ($privileges as $privilege) { $privilegeTypeComments .= $this->formatPrivilegeType($privilege) . ', '; } $privilegeTypeComments = rtrim($privilegeTypeComments, ", "); $file->write("\t" . 'const ' . strtoupper($object) . ' = "' . $object . '"; ' . $privilegeTypeComments . "\n"); } $file->write("\t\n\n\tprotected function initObjectRelation() {\n\t\t"); if ($hasParentClass) { $file->write('$objectRelation = array_merge_recursive(parent::initObjectRelation(), array('); } else { $file->write('return array('); } $comma = "\n\t\t"; foreach ($privilegeList as $object => $privileges) { $file->write($comma . "self::" . strtoupper($object) . "=>array("); ksort($privileges); $privilegeTypes = ''; foreach ($privileges as $privilege) { $privilegeTypes .= 'self::' . $this->formatPrivilegeType($privilege) . ', '; } $file->write(rtrim($privilegeTypes, ", ") . ")"); $comma = ",\n\t\t"; } $file->write("\n\t\t)" . ($hasParentClass ? ");\r\r\t\tforeach (\$objectRelation as \$key => \$value) {\r\t\t\t\$objectRelation[\$key] = array_unique(\$value);\r\t\t}\r\t\treturn \$objectRelation;" : ';') . "\r\t}\n"); $file->write("\n}\n?>"); } }
/** * @param string $url * @return Gpf_Gadget */ public function downloadGadget($url) { if (strpos($url, self::CONTENT_PREFFIX) === 0) { Gpf_Log::debug($this->_sys("Adding content gadget: %s", $url)); $gadget = new Gpf_Gadget_Content(); $gadget->setUrl($url); $gadget->loadConfiguration(""); return $gadget; } else { Gpf_Log::debug($this->_sys("Downloading gadget: %s", $url)); $request = new Gpf_Net_Http_Request(); $request->setUrl($url); $client = new Gpf_Net_Http_Client(); $response = $client->execute($request); $gadgetContent = $response->getBody(); foreach ($this->gadgetTypes as $className) { $gadget = Gpf::newObj($className); $gadget->setUrl($url); try { $gadget->loadConfiguration($gadgetContent); return $gadget; } catch (Gpf_Exception $e) { } } throw new Gpf_Exception($this->_("Unsupported gadget")); } }
private function createWidget($className) { if (Gpf::existsClass($className)) { $class = new ReflectionClass($className); $widget = $class->newInstance(Gpf_Ui_Controller_Main::getController()); return $widget; } throw new Gpf_Templates_NoWidget(); }