/** * The execute function will start the YDExecutor class and process the request. */ function execute() { // Do nothing if we already processed a request if (defined('YD_REQ_PROCESSED')) { return; } // Construct the name of the request class $clsName = basename($this->_file, YD_SCR_EXT); $this->clsInst = new $clsName(); // Check if the object a YDRequest object if (!YDObjectUtil::isSubClass($this->clsInst, 'YDRequest')) { $ancestors = YDObjectUtil::getAncestors($this->clsInst); trigger_error('Class "' . $clsName . '" should be derived from the YDRequest class. Currently, this class has the ' . 'following ancestors: ' . implode(' -> ', $ancestors), YD_ERROR); } // Check if the class is properly initialized if ($this->clsInst->isInitialized() != true) { trigger_error('Class "' . $clsName . '" is not initialized properly. Make sure loaded the base class YDRequest ' . 'and initialized it.', YD_ERROR); } // Only if authentication is required if ($this->clsInst->getRequiresAuthentication()) { $result = $this->clsInst->isAuthenticated(); if ($result) { $this->clsInst->authenticationSucceeded(); } else { $this->clsInst->authenticationFailed(); $this->finish(); } } // Get the action name $action = 'action' . $this->clsInst->getActionName(); // Check if the action exists if (!$this->clsInst->hasMethod($action)) { $this->clsInst->errorMissingAction($action); $this->finish(); } // Check if the current action is allowed or not and execute errorActionNotAllowed if failed if (!$this->clsInst->isActionAllowed()) { $this->clsInst->errorActionNotAllowed(); $this->finish(); } // Process the request $this->clsInst->process(); $this->finish(); }
/** * If sending an HTML message with embedded images, use this function * to add the image. * * @param $file The image file path. * @param $c_type (optional) The content type of the image or file. * @param $name (optional) The filename of the image. */ function addHTMLImage($file, $c_type = '', $name = '') { if (!YDObjectUtil::isSubClass($file, 'YDFSImage')) { $file = new YDFSImage($file); } $data = $file->getContents(); if (empty($name)) { $name = $file->getBaseName(); } if (empty($c_type)) { $c_type = $file->getMimeType(); } $this->_msg->addHTMLImage($data, $name, $c_type); }
/** * This function checks if this object instance is of a specific class or is based on a derived class of the * given class. The class name is case insensitive. * * @param $class The object type you want to check against. * * @returns Boolean indicating if this object is of the specified class. */ function isSubClass($class) { return YDObjectUtil::isSubClass($this, $class); }
/** * If sending an HTML message with embedded images, use this function * to add the image. * * @param $file The image file path. * @param $c_type (optional) The content type of the image or file. * @param $name (optional) The filename of the image. */ function addHTMLImage($file, $c_type = '', $name = '') { if (!YDObjectUtil::isSubClass($file, 'YDFSImage')) { $file = new YDFSImage($file); } if (empty($name)) { $name = $file->getBaseName(); } if (empty($c_type)) { $c_type = $file->getMimeType(); } $this->_msg->AddEmbeddedImage($file->getAbsolutePath(), $name, $name, 'base64', $c_type); }