当前位置: 首页>>代码示例>>PHP>>正文


PHP Model\Document类代码示例

本文整理汇总了PHP中Pimcore\Model\Document的典型用法代码示例。如果您正苦于以下问题:PHP Document类的具体用法?PHP Document怎么用?PHP Document使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Document类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: codeAction

 public function codeAction()
 {
     $url = "";
     if ($this->getParam("name")) {
         $url = $this->getRequest()->getScheme() . "://" . $this->getRequest()->getHttpHost() . "/qr~-~code/" . $this->getParam("name");
     } elseif ($this->getParam("documentId")) {
         $doc = Document::getById($this->getParam("documentId"));
         $url = $this->getRequest()->getScheme() . "://" . $this->getRequest()->getHttpHost() . $doc->getFullPath();
     } elseif ($this->getParam("url")) {
         $url = $this->getParam("url");
     }
     $code = new \Endroid\QrCode\QrCode();
     $code->setText($url);
     $code->setPadding(0);
     $code->setSize(500);
     $hexToRGBA = function ($hex) {
         list($r, $g, $b) = sscanf($hex, "#%02x%02x%02x");
         return ["r" => $r, "g" => $g, "b" => $b, "a" => 0];
     };
     if (strlen($this->getParam("foreColor", "")) == 7) {
         $code->setForegroundColor($hexToRGBA($this->getParam("foreColor")));
     }
     if (strlen($this->getParam("backgroundColor", "")) == 7) {
         $code->setBackgroundColor($hexToRGBA($this->getParam("backgroundColor")));
     }
     header("Content-Type: image/png");
     if ($this->getParam("download")) {
         $code->setSize(4000);
         header('Content-Disposition: attachment;filename="qrcode-' . $this->getParam("name", "preview") . '.png"', true);
     }
     $code->render();
     exit;
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:33,代码来源:QrcodeController.php

示例2: sendEmail

 /**
  * @param object $participation
  * @return void
  * @throws \Exception
  */
 public function sendEmail($participation)
 {
     $email = $participation->getEmail();
     $emailDomain = trim(strtolower(preg_replace('/^[^@]+@/', '', $email)));
     $participation->setEmailDomain($emailDomain);
     $participation->save();
     $confirmationLink = $this->createConfirmationLink($participation->getConfirmationCode());
     $parameters = array('confirmationLink' => $confirmationLink, 'participationId' => $participation->getId());
     $emailDocumentPath = Plugin::getConfig()->get('emailDocumentPath');
     $emailDocument = DocumentModel::getByPath($emailDocumentPath);
     if (!$emailDocument instanceof EmailDocument) {
         throw new \Exception("Error: emailDocumentPath [{$emailDocumentPath}] " . "is not a valid email document.");
     }
     $mail = new Mail();
     $mail->addTo($email);
     if ($this->getSubject()) {
         $mail->setSubject($this->getSubject());
     }
     $mail->setDocument($emailDocumentPath);
     $mail->setParams($parameters);
     $mail->send();
     $note = new Note();
     $note->setElement($participation);
     $note->setDate(time());
     $note->setType("confirmation");
     $note->setTitle("Email sent");
     $note->addData("email", "text", $email);
     $note->setUser(0);
     $note->save();
 }
开发者ID:basilicom,项目名称:pimcore-plugin-participation,代码行数:35,代码来源:Confirmation.php

示例3: load

 /**
  * Loads a list of entries for the specicifies parameters, returns an array of Search\Backend\Data
  *
  * @return array
  */
 public function load()
 {
     $entries = array();
     $data = $this->db->fetchAll("SELECT * FROM search_backend_data" . $this->getCondition() . $this->getGroupBy() . $this->getOrder() . $this->getOffsetLimit(), $this->model->getConditionVariables());
     foreach ($data as $entryData) {
         if ($entryData['maintype'] == 'document') {
             $element = Document::getById($entryData['id']);
         } else {
             if ($entryData['maintype'] == 'asset') {
                 $element = Asset::getById($entryData['id']);
             } else {
                 if ($entryData['maintype'] == 'object') {
                     $element = Object::getById($entryData['id']);
                 } else {
                     \Logger::err("unknown maintype ");
                 }
             }
         }
         if ($element) {
             $entry = new Search\Backend\Data();
             $entry->setId(new Search\Backend\Data\Id($element));
             $entry->setFullPath($entryData['fullpath']);
             $entry->setType($entryData['type']);
             $entry->setSubtype($entryData['subtype']);
             $entry->setUserOwner($entryData['userowner']);
             $entry->setUserModification($entryData['usermodification']);
             $entry->setCreationDate($entryData['creationdate']);
             $entry->setModificationDate($entryData['modificationdate']);
             $entry->setPublished($entryData['published'] === 0 ? false : true);
             $entries[] = $entry;
         }
     }
     $this->model->setEntries($entries);
     return $entries;
 }
开发者ID:sfie,项目名称:pimcore,代码行数:40,代码来源:Dao.php

示例4: setDataFromEditmode

 /**
  * @see Document\Tag\TagInterface::setDataFromEditmode
  * @param mixed $data
  * @return void
  */
 public function setDataFromEditmode($data)
 {
     if (!is_array($data)) {
         $data = array();
     }
     if ($doc = Document::getByPath($data['path'])) {
         if ($doc instanceof Document) {
             $data['internal'] = true;
             $data['internalId'] = $doc->getId();
             $data['internalType'] = 'document';
         }
         //its an object?
     } else {
         if (strpos($data['path'], '::') !== FALSE) {
             $data['internal'] = true;
             $data['internalType'] = 'object';
         }
     }
     if (!$data['internal']) {
         if ($asset = Asset::getByPath($data['path'])) {
             if ($asset instanceof Asset) {
                 $data['internal'] = true;
                 $data['internalId'] = $asset->getId();
                 $data['internalType'] = 'asset';
             }
         }
     }
     $this->data = $data;
     return $this;
 }
开发者ID:dachcom-digital,项目名称:pimcore-toolbox,代码行数:35,代码来源:Globallink.php

示例5: setValuesToDocument

 protected function setValuesToDocument(Document\Link $link)
 {
     // data
     if ($this->getParam("data")) {
         $data = \Zend_Json::decode($this->getParam("data"));
         if (!empty($data["path"])) {
             if ($document = Document::getByPath($data["path"])) {
                 $data["linktype"] = "internal";
                 $data["internalType"] = "document";
                 $data["internal"] = $document->getId();
             } elseif ($asset = Asset::getByPath($data["path"])) {
                 $data["linktype"] = "internal";
                 $data["internalType"] = "asset";
                 $data["internal"] = $asset->getId();
             } else {
                 $data["linktype"] = "direct";
                 $data["direct"] = $data["path"];
             }
         } else {
             // clear content of link
             $data["linktype"] = "internal";
             $data["direct"] = "";
             $data["internalType"] = null;
             $data["internal"] = null;
         }
         unset($data["path"]);
         $link->setValues($data);
     }
     $this->addPropertiesToDocument($link);
 }
开发者ID:solverat,项目名称:pimcore,代码行数:30,代码来源:LinkController.php

示例6: subscribeAction

 public function subscribeAction()
 {
     $this->enableLayout();
     $newsletter = new Newsletter("person");
     // replace "crm" with the class name you have used for your class above (mailing list)
     $params = $this->getAllParams();
     $this->view->success = false;
     if ($newsletter->checkParams($params)) {
         try {
             $params["parentId"] = 1;
             // default folder (home) where we want to save our subscribers
             $newsletterFolder = Model\Object::getByPath("/crm/newsletter");
             if ($newsletterFolder) {
                 $params["parentId"] = $newsletterFolder->getId();
             }
             $user = $newsletter->subscribe($params);
             // user and email document
             // parameters available in the email: gender, firstname, lastname, email, token, object
             // ==> see mailing framework
             $newsletter->sendConfirmationMail($user, Model\Document::getByPath("/en/advanced-examples/newsletter/confirmation-email"), ["additional" => "parameters"]);
             // do some other stuff with the new user
             $user->setDateRegister(new \DateTime());
             $user->save();
             $this->view->success = true;
         } catch (\Exception $e) {
             echo $e->getMessage();
         }
     }
 }
开发者ID:solverat,项目名称:pimcore,代码行数:29,代码来源:NewsletterController.php

示例7: inotherlang

 /**
  * @param $document
  * @param null $language
  * @return Document|null
  */
 public function inotherlang($document, $language = null)
 {
     $documentInOtherLang = null;
     if (is_null($language)) {
         $language = CURRENT_LANGUAGE;
     }
     if ($document instanceof Document) {
         $id = $document->getId();
     } elseif (is_numeric($document)) {
         $id = $document;
     } else {
         $id = 0;
     }
     $otherLangId = null;
     try {
         if (class_exists('\\Multilingual\\Document')) {
             $otherLangId = \Multilingual\Document::getDocumentIdInOtherLanguage($id, $language);
         } else {
             $otherLangId = $id;
         }
     } catch (Exception $e) {
     }
     if ($otherLangId) {
         $documentInOtherLang = Document::getById($otherLangId);
     }
     return $documentInOtherLang;
 }
开发者ID:studioemma,项目名称:multilingual,代码行数:32,代码来源:inotherlang.php

示例8: doGetChildren

 private function doGetChildren(Document $document)
 {
     $children = $document->getChilds();
     foreach ($children as $child) {
         if ($child instanceof Document\Printpage) {
             $this->allChildren[] = $child;
         }
         if ($child instanceof Document\Folder || $child instanceof Document\Printcontainer) {
             $this->doGetChildren($child);
         }
         if ($child instanceof Document\Hardlink) {
             if ($child->getSourceDocument() instanceof Document\Printpage) {
                 $this->allChildren[] = $child;
             }
             $this->doGetChildren($child);
         }
     }
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:18,代码来源:Printcontainer.php

示例9: _handleError

 /**
  * @param \Zend_Controller_Request_Abstract $request
  * @throws mixed
  */
 protected function _handleError(\Zend_Controller_Request_Abstract $request)
 {
     // remove zend error handler
     $front = \Zend_Controller_Front::getInstance();
     $front->unregisterPlugin("Zend_Controller_Plugin_ErrorHandler");
     $response = $this->getResponse();
     if ($response->isException() && !$this->_isInsideErrorHandlerLoop) {
         // get errorpage
         try {
             // enable error handler
             $front->setParam('noErrorHandler', false);
             $errorPath = Config::getSystemConfig()->documents->error_pages->default;
             if (Site::isSiteRequest()) {
                 $site = Site::getCurrentSite();
                 $errorPath = $site->getErrorDocument();
             }
             if (empty($errorPath)) {
                 $errorPath = "/";
             }
             $document = Document::getByPath($errorPath);
             if (!$document instanceof Document\Page) {
                 // default is home
                 $document = Document::getById(1);
             }
             if ($document instanceof Document\Page) {
                 $params = Tool::getRoutingDefaults();
                 if ($module = $document->getModule()) {
                     $params["module"] = $module;
                 }
                 if ($controller = $document->getController()) {
                     $params["controller"] = $controller;
                     $params["action"] = "index";
                 }
                 if ($action = $document->getAction()) {
                     $params["action"] = $action;
                 }
                 $this->setErrorHandler($params);
                 $request->setParam("document", $document);
                 \Zend_Registry::set("pimcore_error_document", $document);
                 // ensure that a viewRenderer exists, and is enabled
                 if (!\Zend_Controller_Action_HelperBroker::hasHelper("viewRenderer")) {
                     $viewRenderer = new \Pimcore\Controller\Action\Helper\ViewRenderer();
                     \Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
                 }
                 $viewRenderer = \Zend_Controller_Action_HelperBroker::getExistingHelper("viewRenderer");
                 $viewRenderer->setNoRender(false);
                 if ($viewRenderer->view === null) {
                     $viewRenderer->initView(PIMCORE_WEBSITE_PATH . "/views");
                 }
             }
         } catch (\Exception $e) {
             \Logger::emergency("error page not found");
         }
     }
     // call default ZF error handler
     parent::_handleError($request);
 }
开发者ID:solverat,项目名称:pimcore,代码行数:61,代码来源:ErrorHandler.php

示例10: getDocumentTypesAction

 public function getDocumentTypesAction()
 {
     $documentTypes = Document::getTypes();
     $typeItems = [];
     foreach ($documentTypes as $documentType) {
         $typeItems[] = ["text" => $documentType];
     }
     $this->_helper->json($typeItems);
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:9,代码来源:ClassController.php

示例11: ruleGetAction

 public function ruleGetAction()
 {
     $target = Targeting\Rule::getById($this->getParam("id"));
     $redirectUrl = $target->getActions()->getRedirectUrl();
     if (is_numeric($redirectUrl)) {
         $doc = Document::getById($redirectUrl);
         if ($doc instanceof Document) {
             $target->getActions()->redirectUrl = $doc->getFullPath();
         }
     }
     $this->_helper->json($target);
 }
开发者ID:solverat,项目名称:pimcore,代码行数:12,代码来源:TargetingController.php

示例12: setValuesToDocument

 protected function setValuesToDocument(Document\Hardlink $link)
 {
     // data
     $data = \Zend_Json::decode($this->getParam("data"));
     $sourceId = null;
     if ($sourceDocument = Document::getByPath($data["sourcePath"])) {
         $sourceId = $sourceDocument->getId();
     }
     $link->setSourceId($sourceId);
     $link->setValues($data);
     $this->addPropertiesToDocument($link);
 }
开发者ID:Gerhard13,项目名称:pimcore,代码行数:12,代码来源:HardlinkController.php

示例13: getCondition

 protected function getCondition()
 {
     if ($cond = $this->model->getCondition()) {
         if (Document::doHideUnpublished() && !$this->model->getUnpublished()) {
             return " WHERE (" . $cond . ") AND published = 1";
         }
         return " WHERE " . $cond . " ";
     } elseif (Document::doHideUnpublished() && !$this->model->getUnpublished()) {
         return " WHERE published = 1";
     }
     return "";
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:12,代码来源:Dao.php

示例14: getErrorDocument

 private function getErrorDocument()
 {
     $config = Config::getSystemConfig();
     $errorDocPath = $config->documents->error_pages->default;
     if (Site::isSiteRequest()) {
         $site = Site::getCurrentSite();
         $errorDocPath = $site->getErrorDocument();
     }
     $errorDoc = Document::getByPath($errorDocPath);
     \Zend_Registry::set("pimcore_error_document", $errorDoc);
     return $errorDoc;
 }
开发者ID:shanky0110,项目名称:pimcore-plugin-subdomain-admin,代码行数:12,代码来源:FrontControllerPlugin.php

示例15: load

 /**
  * Loads a list of objects (all are an instance of Document) for the given parameters an return them
  *
  * @return array
  */
 public function load()
 {
     $documents = [];
     $select = (string) $this->getQuery(['id', "type"]);
     $documentsData = $this->db->fetchAll($select, $this->model->getConditionVariables());
     foreach ($documentsData as $documentData) {
         if ($documentData["type"]) {
             if ($doc = Document::getById($documentData["id"])) {
                 $documents[] = $doc;
             }
         }
     }
     $this->model->setDocuments($documents);
     return $documents;
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:20,代码来源:Dao.php


注:本文中的Pimcore\Model\Document类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。