示例#1
0
 /**
  * Takes data from editmode and convert it to internal objects
  *
  * @param mixed $data
  * @return void
  */
 public function setDataFromEditmode($data)
 {
     // IMPORTANT: if you use this method be sure that the type of the property is already set
     if ($this->type == "document") {
         $this->data = Document::getByPath($data);
     } else {
         if ($this->type == "asset") {
             $this->data = Asset::getByPath($data);
         } else {
             if ($this->type == "object") {
                 $this->data = Object_Abstract::getByPath($data);
             } else {
                 if ($this->type == "date") {
                     $this->data = new Zend_Date($data);
                 } else {
                     if ($this->type == "bool") {
                         $this->data = false;
                         if (!empty($data)) {
                             $this->data = true;
                         }
                     } else {
                         // plain text
                         $this->data = $data;
                     }
                 }
             }
         }
     }
 }
示例#2
0
 public function subscribeAction()
 {
     // init
     $status = array('message' => 'error', 'success' => false);
     $newsletter = new Pimcore_Tool_Newsletter('customer');
     $params = $this->getAllParams();
     //
     if ($newsletter->checkParams($params)) {
         try {
             $params["parent"] = Object_Abstract::getByPath("/newsletter/subscribers");
             $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, Document::getByPath('/en/emails/newsletter-confirmation'));
             // do some other stuff with the new user
             //$user->setSomeCustomField(true);
             //$user->save();
             $status['success'] = true;
             $status['message'] = "";
         } catch (\Exception $e) {
             $status['message'] = $e->getMessage();
         }
     }
     // its a ajax request?
     if ($this->getRequest()->isXmlHttpRequest()) {
         $this->_helper->viewRenderer->setNoRender(true);
         $this->getResponse()->setHeader('Content-Type', 'application/json');
         echo Zend_Json::encode($status);
     } else {
         $this->view->status = $status;
     }
 }
示例#3
0
文件: Item.php 项目: ngocanh/pimcore
 public function restore()
 {
     $raw = file_get_contents($this->getStoreageFile());
     $element = Pimcore_Tool_Serialize::unserialize($raw);
     // check for element with the same name
     if ($element instanceof Document) {
         $indentElement = Document::getByPath($element->getFullpath());
         if ($indentElement) {
             $element->setKey($element->getKey() . "_restore");
         }
     } else {
         if ($element instanceof Asset) {
             $indentElement = Asset::getByPath($element->getFullpath());
             if ($indentElement) {
                 $element->setFilename($element->getFilename() . "_restore");
             }
         } else {
             if ($element instanceof Object_Abstract) {
                 $indentElement = Object_Abstract::getByPath($element->getFullpath());
                 if ($indentElement) {
                     $element->setKey($element->getKey() . "_restore");
                 }
             }
         }
     }
     $this->restoreChilds($element);
     $this->delete();
 }
示例#4
0
 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);
 }
示例#5
0
文件: Import.php 项目: jv10/pimpon
 private function documentSave(&$document)
 {
     try {
         $document->save();
     } catch (Exception $ex) {
         if ($this->getAllowReplace() === true && self::isDuplicateException($ex) === true) {
             $documentHinder = Document::getByPath($document->getFullPath());
             $documentHinder->delete();
             $document->save();
         } else {
             self::l($ex->getMessage());
             throw $ex;
         }
     }
 }
示例#6
0
 /**
  * @static
  * @return mixed|Zend_Config
  */
 public static function getWebsiteConfig()
 {
     try {
         $config = Zend_Registry::get("pimcore_config_website");
     } catch (Exception $e) {
         $cacheKey = "website_config";
         if (!($config = Pimcore_Model_Cache::load($cacheKey))) {
             $websiteSettingFile = PIMCORE_CONFIGURATION_DIRECTORY . "/website.xml";
             $settingsArray = array();
             if (is_file($websiteSettingFile)) {
                 $rawConfig = new Zend_Config_Xml($websiteSettingFile);
                 $arrayData = $rawConfig->toArray();
                 foreach ($arrayData as $key => $value) {
                     $s = null;
                     if ($value["type"] == "document") {
                         $s = Document::getByPath($value["data"]);
                     } else {
                         if ($value["type"] == "asset") {
                             $s = Asset::getByPath($value["data"]);
                         } else {
                             if ($value["type"] == "object") {
                                 $s = Object_Abstract::getByPath($value["data"]);
                             } else {
                                 if ($value["type"] == "bool") {
                                     $s = (bool) $value["data"];
                                 } else {
                                     if ($value["type"] == "text") {
                                         $s = (string) $value["data"];
                                     }
                                 }
                             }
                         }
                     }
                     if ($s) {
                         $settingsArray[$key] = $s;
                     }
                 }
             }
             $config = new Zend_Config($settingsArray, true);
             Pimcore_Model_Cache::save($config, $cacheKey, array("websiteconfig", "system", "config"), null, 998);
         }
         self::setWebsiteConfig($config);
     }
     return $config;
 }
示例#7
0
 /**
  * this is used to get childs below a hardlink by a path
  * for example: the requested path is /de/service/contact but /de/service is a hardlink to /en/service
  * then $hardlink would be /en/service and $path /de/service/contact and this function returns then /en/service/contact
  * @static
  * @param Document_Hardlink $hardlink
  * @param $path
  */
 public static function getChildByPath(Document_Hardlink $hardlink, $path)
 {
     if ($hardlink->getChildsFromSource() && $hardlink->getSourceDocument()) {
         $hardlinkRealPath = preg_replace("@^" . preg_quote($hardlink->getRealFullPath()) . "@", $hardlink->getSourceDocument()->getFullpath(), $path);
         $hardLinkedDocument = Document::getByPath($hardlinkRealPath);
         if ($hardLinkedDocument instanceof Document) {
             $hardLinkedDocument = Document_Hardlink_Service::wrap($hardLinkedDocument);
             $hardLinkedDocument->setHardLinkSource($hardlink);
             $_path = $path != "/" ? $_path = dirname($path) : $path;
             $_path = str_replace("\\", "/", $_path);
             // windows patch
             $_path .= $_path != "/" ? "/" : "";
             $hardLinkedDocument->setPath($_path);
             return $hardLinkedDocument;
         }
     }
     return null;
 }
 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);
             $siteKey = Pimcore_Tool_Frontend::getSiteKey();
             $errorPath = Pimcore_Config::getSystemConfig()->documents->error_pages->{$siteKey};
             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 = Pimcore_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);
             }
         } catch (Exception $e) {
             Logger::emergency("error page not found");
         }
     }
     // call default ZF error handler
     parent::_handleError($request);
 }
示例#9
0
 protected function setValuesToDocument(Document_Link $link)
 {
     // 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();
         } else {
             if ($asset = Asset::getByPath($data["path"])) {
                 $data["linktype"] = "internal";
                 $data["internalType"] = "asset";
                 $data["internal"] = $asset->getId();
             } else {
                 $data["linktype"] = "direct";
                 $data["direct"] = $data["path"];
             }
         }
     }
     unset($data["path"]);
     $link->setValues($data);
     $this->addPropertiesToDocument($link);
 }
示例#10
0
文件: Link.php 项目: ngocanh/pimcore
 /**
  * @see Document_Tag_Interface::setDataFromEditmode
  * @param mixed $data
  * @return void
  */
 public function setDataFromEditmode($data)
 {
     if ($doc = Document::getByPath($data["path"])) {
         if ($doc instanceof Document) {
             $data["internal"] = true;
             $data["internalId"] = $doc->getId();
             $data["internalType"] = "document";
         }
     }
     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;
 }
示例#11
0
 public function setPath($path)
 {
     if (!empty($path)) {
         if ($document = Document::getByPath($path)) {
             $this->linktype = "internal";
             $this->internalType = "document";
             $this->internal = $document->getId();
         } else {
             if ($asset = Asset::getByPath($path)) {
                 $this->linktype = "internal";
                 $this->internalType = "asset";
                 $this->internal = $asset->getId();
             } else {
                 $this->linktype = "direct";
                 $this->direct = $path;
             }
         }
     }
 }
示例#12
0
文件: Href.php 项目: ngocanh/pimcore
 /**
  * fills object field data values from CSV Import String
  * @abstract
  * @param string $importValue
  * @param Object_Abstract $abstract
  * @return Object_Class_Data
  */
 public function getFromCsvImport($importValue)
 {
     $value = null;
     $values = explode(":", $importValue);
     if (count($values) == 2) {
         $type = $values[0];
         $path = $values[1];
         $value = Element_Service::getElementByPath($type, $path);
     } else {
         //fallback for old export files
         if ($el = Asset::getByPath($importValue)) {
             $value = $el;
         } else {
             if ($el = Document::getByPath($importValue)) {
                 $value = $el;
             } else {
                 if ($el = Object_Abstract::getByPath($importValue)) {
                     $value = $el;
                 }
             }
         }
     }
     return $value;
 }
示例#13
0
 /**
  * @static
  * @param  string $type
  * @param  string $path
  * @return Element_Interface
  */
 public static function getElementByPath($type, $path)
 {
     if ($type == "asset") {
         $element = Asset::getByPath($path);
     } else {
         if ($type == "object") {
             $element = Object_Abstract::getByPath($path);
         } else {
             if ($type == "document") {
                 $element = Document::getByPath($path);
             }
         }
     }
     return $element;
 }
示例#14
0
 public function glossaryAction()
 {
     if ($this->_getParam("data")) {
         if ($this->getUser()->isAllowed("glossary")) {
             Pimcore_Model_Cache::clearTag("glossary");
             if ($this->_getParam("xaction") == "destroy") {
                 $id = Zend_Json::decode($this->_getParam("data"));
                 $glossary = Glossary::getById($id);
                 $glossary->delete();
                 $this->_helper->json(array("success" => true, "data" => array()));
             } else {
                 if ($this->_getParam("xaction") == "update") {
                     $data = Zend_Json::decode($this->_getParam("data"));
                     // save glossary
                     $glossary = Glossary::getById($data["id"]);
                     if ($data["link"]) {
                         if ($doc = Document::getByPath($data["link"])) {
                             $tmpLink = $data["link"];
                             $data["link"] = $doc->getId();
                         }
                     }
                     $glossary->setValues($data);
                     $glossary->save();
                     if ($link = $glossary->getLink()) {
                         if (intval($link) > 0) {
                             if ($doc = Document::getById(intval($link))) {
                                 $glossary->setLink($doc->getFullPath());
                             }
                         }
                     }
                     $this->_helper->json(array("data" => $glossary, "success" => true));
                 } else {
                     if ($this->_getParam("xaction") == "create") {
                         $data = Zend_Json::decode($this->_getParam("data"));
                         unset($data["id"]);
                         // save glossary
                         $glossary = new Glossary();
                         if ($data["link"]) {
                             if ($doc = Document::getByPath($data["link"])) {
                                 $tmpLink = $data["link"];
                                 $data["link"] = $doc->getId();
                             }
                         }
                         $glossary->setValues($data);
                         $glossary->save();
                         if ($link = $glossary->getLink()) {
                             if (intval($link) > 0) {
                                 if ($doc = Document::getById(intval($link))) {
                                     $glossary->setLink($doc->getFullPath());
                                 }
                             }
                         }
                         $this->_helper->json(array("data" => $glossary, "success" => true));
                     }
                 }
             }
         } else {
             Logger::err("user [" . $this->getUser()->getId() . "] attempted to modify static routes, but has no permission to do so.");
         }
     } else {
         // get list of routes
         $list = new Glossary_List();
         $list->setLimit($this->_getParam("limit"));
         $list->setOffset($this->_getParam("start"));
         if ($this->_getParam("sort")) {
             $list->setOrderKey($this->_getParam("sort"));
             $list->setOrder($this->_getParam("dir"));
         }
         if ($this->_getParam("filter")) {
             $list->setCondition("`text` LIKE " . $list->quote("%" . $this->_getParam("filter") . "%"));
         }
         $list->load();
         $glossaries = array();
         foreach ($list->getGlossary() as $glossary) {
             if ($link = $glossary->getLink()) {
                 if (intval($link) > 0) {
                     if ($doc = Document::getById(intval($link))) {
                         $glossary->setLink($doc->getFullPath());
                     }
                 }
             }
             $glossaries[] = $glossary;
         }
         $this->_helper->json(array("data" => $glossaries, "success" => true, "total" => $list->getTotalCount()));
     }
     $this->_helper->json(false);
 }
示例#15
0
 /**
  * Returns a uniqe key for the document in the $target-Path (recursive)
  * @param Element_Interface $element
  */
 protected function getSaveCopyName($element, $key, $path)
 {
     if ($element instanceof Object_Abstract) {
         $equal = Object_Abstract::getByPath($path . "/" . $key);
     } else {
         if ($element instanceof Document) {
             $equal = Document::getByPath($path . "/" . $key);
         } else {
             if ($element instanceof Asset) {
                 $equal = Asset::getByPath($path . "/" . $key);
             }
         }
     }
     if ($equal) {
         $key .= "_WScopy";
         return $this->getSaveCopyName($element, $key, $path);
     }
     return $key;
 }
示例#16
0
 public function readGoogleResponse($googleResponse)
 {
     $this->setRaw($googleResponse);
     $this->setTotal(intval($googleResponse["searchInformation"]["totalResults"]));
     $items = array();
     if (array_key_exists("items", $googleResponse) && is_array($googleResponse["items"])) {
         foreach ($googleResponse["items"] as $item) {
             // check for relation to document or asset
             // first check for an image
             if (array_key_exists("pagemap", $item) && is_array($item["pagemap"])) {
                 if (array_key_exists("cse_image", $item["pagemap"]) && is_array($item["pagemap"]["cse_image"])) {
                     if ($item["pagemap"]["cse_image"][0]) {
                         // try to get the asset id
                         if (preg_match("/thumb_([0-9]+)__/", $item["pagemap"]["cse_image"][0]["src"], $matches)) {
                             $test = $matches;
                             if ($matches[1]) {
                                 if ($image = Asset::getById($matches[1])) {
                                     if ($image instanceof Asset_Image) {
                                         $item["image"] = $image;
                                     }
                                 }
                             }
                         }
                         if (!array_key_exists("image", $item)) {
                             $item["image"] = $item["pagemap"]["cse_image"][0]["src"];
                         }
                     }
                 }
             }
             // now a document
             $urlParts = parse_url($item["link"]);
             if ($document = Document::getByPath($urlParts["path"])) {
                 $item["document"] = $document;
             }
             $items[] = new Pimcore_Google_Cse_Item($item);
         }
     }
     $this->setResults($items);
 }
$configFile = PIMCORE_CONFIGURATION_DIRECTORY . "/website.xml";
$configFileNew = PIMCORE_CONFIGURATION_DIRECTORY . "/website-legacy.xml";
$rawConfig = new Zend_Config_Xml($configFile);
$arrayData = $rawConfig->toArray();
$data = array();
foreach ($arrayData as $key => $value) {
    $setting = new WebsiteSetting();
    $setting->setName($key);
    $type = $value["type"];
    $setting->setType($type);
    $data = $value["data"];
    if ($type == "bool") {
        $data = (bool) $data;
    } else {
        if ($type == "document") {
            $data = Document::getByPath($value["data"]);
        } else {
            if ($type == "asset") {
                $data = Asset::getByPath($value["data"]);
            } else {
                if ($type == "object") {
                    $data = Object_Abstract::getByPath($value["data"]);
                }
            }
        }
    }
    if ($data instanceof Element_Interface) {
        $data = $data->getId();
    }
    $setting->setData($data);
    $siteId = $value["siteId"] > 0 ? (int) $value["siteId"] : null;
示例#18
0
 /**
  * includes a document
  *
  * @param $include
  * @param array $params
  * @return string
  */
 public function inc($include, $params = array())
 {
     $editmodeBackup = Zend_Registry::get("pimcore_editmode");
     Zend_Registry::set("pimcore_editmode", false);
     $includeBak = $include;
     if (is_string($include)) {
         try {
             $include = Document::getByPath($include);
         } catch (Exception $e) {
             $include = $includeBak;
         }
     } else {
         if (is_numeric($include)) {
             try {
                 $include = Document::getById($include);
             } catch (Exception $e) {
                 $include = $includeBak;
             }
         }
     }
     $params = array_merge($params, array("document" => $include));
     $content = "";
     if ($include instanceof Document_PageSnippet && $include->isPublished()) {
         if ($include->getAction() && $include->getController()) {
             $content = $this->action($include->getAction(), $include->getController(), $include->getModule(), $params);
         } else {
             if ($include->getTemplate()) {
                 $content = $this->action("default", "default", null, $params);
             }
         }
         // in editmode add events at hover an click to be able to edit the included document
         if ($this->editmode) {
             include_once "simple_html_dom.php";
             $class = " pimcore_editable pimcore_tag_inc ";
             // this is if the content if the include does already contain markup/html
             if ($html = str_get_html($content)) {
                 $childs = $html->find("*");
                 if (is_array($childs)) {
                     foreach ($childs as $child) {
                         $child->class = $child->class . $class;
                         $child->pimcore_type = $include->getType();
                         $child->pimcore_id = $include->getId();
                     }
                 }
                 $content = $html->save();
             } else {
                 // add a div container if the include doesn't contain markup/html
                 $content = '<div class="' . $class . '">' . $content . '</div>';
             }
         }
     }
     Zend_Registry::set("pimcore_editmode", $editmodeBackup);
     return $content;
 }
 public function abSaveAction()
 {
     // source-page
     $sourceDoc = Document::getById($this->_getParam("documentId"));
     $goalDoc = Document::getByPath($this->_getParam("conversionPage"));
     if (!$sourceDoc || !$goalDoc) {
         exit;
     }
     // clean properties
     $sourceDoc = $this->clearProperties($sourceDoc);
     $goalDoc = $this->clearProperties($goalDoc);
     // google stuff
     $credentials = $this->getAnalyticsCredentials();
     $config = Pimcore_Google_Analytics::getSiteConfig($site);
     $gdata = $this->getService();
     // create new experiment
     $entryResult = $gdata->insertEntry("\r\n            <entry xmlns='http://www.w3.org/2005/Atom'\r\n                   xmlns:gwo='http://schemas.google.com/analytics/websiteoptimizer/2009'\r\n                   xmlns:app='http://www.w3.org/2007/app'\r\n                   xmlns:gd='http://schemas.google.com/g/2005'>\r\n                <title>" . $this->_getParam("name") . "</title>\r\n                <gwo:analyticsAccountId>" . $config->accountid . "</gwo:analyticsAccountId>\r\n                <gwo:experimentType>AB</gwo:experimentType>\r\n                <gwo:status>Running</gwo:status>\r\n                <link rel='gwo:testUrl' type='text/html' href='http://" . Pimcore_Tool::getHostname() . $sourceDoc->getFullPath() . "' />\r\n                <link rel='gwo:goalUrl' type='text/html' href='http://" . Pimcore_Tool::getHostname() . $goalDoc->getFullPath() . "' />\r\n            </entry>\r\n        ", "https://www.google.com/analytics/feeds/websiteoptimizer/experiments");
     $e = $entryResult->getExtensionElements();
     $data = array();
     foreach ($e as $a) {
         $data[$a->rootElement] = $a->getText();
     }
     // get tracking code
     $d = preg_match("/_getTracker\\(\"(.*)\"\\)/", $data["trackingScript"], $matches);
     $trackingId = $matches[1];
     // get test id
     $d = preg_match("/_trackPageview\\(\"\\/([0-9]+)/", $data["trackingScript"], $matches);
     $testId = $matches[1];
     // set original page
     $entryResult = $gdata->insertEntry("\r\n            <entry xmlns='http://www.w3.org/2005/Atom'\r\n                   xmlns:gwo='http://schemas.google.com/analytics/websiteoptimizer/2009'\r\n                   xmlns:app='http://www.w3.org/2007/app'\r\n                   xmlns:gd='http://schemas.google.com/g/2005'>\r\n            <title>Original</title>\r\n            <content>http://" . Pimcore_Tool::getHostname() . $sourceDoc->getFullPath() . "</content>\r\n            </entry>\r\n        ", "https://www.google.com/analytics/feeds/websiteoptimizer/experiments/" . $data["experimentId"] . "/abpagevariations");
     // set testing pages
     for ($i = 1; $i < 100; $i++) {
         if ($this->_getParam("page_name_" . $i)) {
             $pageUrl = "";
             if ($this->_getParam("page_url_" . $i)) {
                 if ($variantDoc = Document::getByPath($this->_getParam("page_url_" . $i))) {
                     $pageUrl = $this->getRequest()->getScheme() . "://" . Pimcore_Tool::getHostname() . $variantDoc->getFullPath();
                     // add properties to variant page
                     $variantDoc = $this->clearProperties($variantDoc);
                     $variantDoc->setProperty("google_website_optimizer_test_id", "text", $testId);
                     $variantDoc->setProperty("google_website_optimizer_track_id", "text", $trackingId);
                     $variantDoc->save();
                 } else {
                     Logger::warn("Added a invalid URL to A/B test.");
                     exit;
                 }
             }
             /*if($this->_getParam("page_version_".$i)) {
                   $pageUrl = "http://" . Pimcore_Tool::getHostname() . $sourceDoc->getFullPath() . "?v=" . $this->_getParam("page_version_".$i);
               }
               */
             if ($pageUrl) {
                 try {
                     $entryResult = $gdata->insertEntry("\r\n                        <entry xmlns='http://www.w3.org/2005/Atom'\r\n                               xmlns:gwo='http://schemas.google.com/analytics/websiteoptimizer/2009'\r\n                               xmlns:app='http://www.w3.org/2007/app'\r\n                               xmlns:gd='http://schemas.google.com/g/2005'>\r\n                        <title>" . $this->_getParam("page_name_" . $i) . "</title>\r\n                        <content>" . $pageUrl . "</content>\r\n                        </entry>\r\n                    ", "https://www.google.com/analytics/feeds/websiteoptimizer/experiments/" . $data["experimentId"] . "/abpagevariations");
                 } catch (Exception $e) {
                     Logger::err($e);
                 }
             }
         } else {
             break;
         }
     }
     // @todo START EXPERIMENT HERE
     //$entryResult = $gdata->getEntry("https://www.google.com/analytics/feeds/websiteoptimizer/experiments/" . $data["experimentId"]);
     //$gdata->updateEntry($entryResult->getXml(),"https://www.google.com/analytics/feeds/websiteoptimizer/experiments/" . $data["experimentId"]);
     /*$gdata->updateEntry("
           <entry xmlns='http://www.w3.org/2005/Atom'
                  xmlns:gwo='http://schemas.google.com/analytics/websiteoptimizer/2009'
                  xmlns:app='http://www.w3.org/2007/app'
                  xmlns:gd='http://schemas.google.com/g/2005'>
           <gwo:status>Running</gwo:status>
           </entry>
       ","https://www.google.com/analytics/feeds/websiteoptimizer/experiments/" . $data["experimentId"]);
       */
     // source-page
     $sourceDoc->setProperty("google_website_optimizer_test_id", "text", $testId);
     $sourceDoc->setProperty("google_website_optimizer_track_id", "text", $trackingId);
     $sourceDoc->setProperty("google_website_optimizer_original_page", "bool", true);
     $sourceDoc->save();
     // conversion-page
     $goalDoc->setProperty("google_website_optimizer_test_id", "text", $testId);
     $goalDoc->setProperty("google_website_optimizer_track_id", "text", $trackingId);
     $goalDoc->setProperty("google_website_optimizer_conversion_page", "bool", true);
     $goalDoc->save();
     // clear output cache
     Pimcore_Model_Cache::clearTag("output");
     Pimcore_Model_Cache::clearTag("properties");
     $this->_helper->json(array("success" => true));
 }
示例#20
0
 public function navigationAction()
 {
     $config = Pimcore_Google_Analytics::getSiteConfig($this->getSite());
     $startDate = date("Y-m-d", time() - 86400 * 31);
     $endDate = date("Y-m-d");
     if ($this->_getParam("dateFrom") && $this->_getParam("dateTo")) {
         $startDate = date("Y-m-d", strtotime($this->_getParam("dateFrom")));
         $endDate = date("Y-m-d", strtotime($this->_getParam("dateTo")));
     }
     // all pageviews
     $query0 = $this->getQuery($this->getSite());
     $query0->addDimension(Zend_Gdata_Analytics_DataQuery::DIMENSION_PAGE_PATH)->addMetric(Zend_Gdata_Analytics_DataQuery::METRIC_PAGEVIEWS)->setStartDate($startDate)->setEndDate($endDate)->setSort(Zend_Gdata_Analytics_DataQuery::METRIC_PAGEVIEWS, true)->setMaxResults(1);
     if ($config->advanced) {
         if ($this->_getParam("id") && $this->_getParam("type")) {
             $url = "/pimcoreanalytics/" . $this->_getParam("type") . "/" . $this->_getParam("id");
             $query0->setFilter(Zend_Gdata_Analytics_DataQuery::DIMENSION_PAGE_PATH . "==" . $url);
         }
     } else {
         if ($this->_getParam("path")) {
             $query0->setFilter(Zend_Gdata_Analytics_DataQuery::DIMENSION_PAGE_PATH . "==" . $this->_getParam("path"));
         }
     }
     $result0 = $this->getService()->getDataFeed($query0);
     $totalViews = (int) $result0[0]->getMetric(Zend_Gdata_Analytics_DataQuery::METRIC_PAGEVIEWS)->getValue();
     // ENTRANCES
     $query1 = $this->getQuery($this->getSite());
     $query1->addDimension(Zend_Gdata_Analytics_DataQuery::DIMENSION_PREV_PAGE_PATH)->addMetric(Zend_Gdata_Analytics_DataQuery::METRIC_PAGEVIEWS)->setStartDate($startDate)->setEndDate($endDate)->setSort(Zend_Gdata_Analytics_DataQuery::METRIC_PAGEVIEWS, true)->setMaxResults(10);
     if ($config->advanced) {
         if ($this->_getParam("id") && $this->_getParam("type")) {
             $url = "/pimcoreanalytics/" . $this->_getParam("type") . "/" . $this->_getParam("id");
             $query1->setFilter(Zend_Gdata_Analytics_DataQuery::DIMENSION_PAGE_PATH . "==" . $url);
         }
     } else {
         if ($this->_getParam("path")) {
             $query1->setFilter(Zend_Gdata_Analytics_DataQuery::DIMENSION_PAGE_PATH . "==" . $this->_getParam("path"));
         }
     }
     $result1 = $this->getService()->getDataFeed($query1);
     $prev = array();
     foreach ($result1 as $row) {
         $d = array("path" => $this->formatDimension(Zend_Gdata_Analytics_DataQuery::DIMENSION_PREV_PAGE_PATH, (string) $row->getDimension(Zend_Gdata_Analytics_DataQuery::DIMENSION_PREV_PAGE_PATH)), "pageviews" => (double) $row->getMetric(Zend_Gdata_Analytics_DataQuery::METRIC_PAGEVIEWS)->getValue());
         $document = Document::getByPath((string) $row->getDimension(Zend_Gdata_Analytics_DataQuery::DIMENSION_PREV_PAGE_PATH));
         if ($document) {
             $d["id"] = $document->getId();
         }
         $d["percent"] = round($d["pageviews"] / $totalViews * 100);
         $d["weight"] = 100;
         if ($prev[0]["weight"]) {
             $d["weight"] = round($d["percent"] / $prev[0]["percent"] * 100);
         }
         $prev[] = $d;
     }
     // EXITS
     $query2 = $this->getQuery($this->getSite());
     $query2->addDimension(Zend_Gdata_Analytics_DataQuery::DIMENSION_PAGE_PATH)->addMetric(Zend_Gdata_Analytics_DataQuery::METRIC_PAGEVIEWS)->setStartDate($startDate)->setEndDate($endDate)->setSort(Zend_Gdata_Analytics_DataQuery::METRIC_PAGEVIEWS, true)->setMaxResults(10);
     if ($config->advanced) {
         if ($this->_getParam("id") && $this->_getParam("type")) {
             $url = "/pimcoreanalytics/" . $this->_getParam("type") . "/" . $this->_getParam("id");
             $query2->setFilter(Zend_Gdata_Analytics_DataQuery::DIMENSION_PREV_PAGE_PATH . "==" . $url);
         }
     } else {
         if ($this->_getParam("path")) {
             $query2->setFilter(Zend_Gdata_Analytics_DataQuery::DIMENSION_PREV_PAGE_PATH . "==" . $this->_getParam("path"));
         }
     }
     $result2 = $this->getService()->getDataFeed($query2);
     $next = array();
     foreach ($result2 as $row) {
         $d = array("path" => $this->formatDimension(Zend_Gdata_Analytics_DataQuery::DIMENSION_PAGE_PATH, (string) $row->getDimension(Zend_Gdata_Analytics_DataQuery::DIMENSION_PAGE_PATH)), "pageviews" => (double) $row->getMetric(Zend_Gdata_Analytics_DataQuery::METRIC_PAGEVIEWS)->getValue());
         $document = Document::getByPath((string) $row->getDimension(Zend_Gdata_Analytics_DataQuery::DIMENSION_PAGE_PATH));
         if ($document) {
             $d["id"] = $document->getId();
         }
         $d["percent"] = round($d["pageviews"] / $totalViews * 100);
         $d["weight"] = 100;
         if ($next[0]["weight"]) {
             $d["weight"] = round($d["percent"] / $next[0]["percent"] * 100);
         }
         $next[] = $d;
     }
     $this->view->next = $next;
     $this->view->prev = $prev;
     $this->view->path = $this->_getParam("path");
     $this->getResponse()->setHeader("Content-Type", "application/xml", true);
 }
 public function navigationAction()
 {
     $config = Pimcore_Google_Analytics::getSiteConfig($this->getSite());
     $startDate = date("Y-m-d", time() - 86400 * 31);
     $endDate = date("Y-m-d");
     if ($this->_getParam("dateFrom") && $this->_getParam("dateTo")) {
         $startDate = date("Y-m-d", strtotime($this->_getParam("dateFrom")));
         $endDate = date("Y-m-d", strtotime($this->_getParam("dateTo")));
     }
     // all pageviews
     if ($config->advanced) {
         if ($this->_getParam("id") && $this->_getParam("type")) {
             $url = "/pimcoreanalytics/" . $this->_getParam("type") . "/" . $this->_getParam("id");
             $filters[] = "ga:pagePath==" . $url;
         }
     } else {
         if ($this->_getParam("path")) {
             $filters[] = "ga:pagePath==" . $this->_getParam("path");
         }
     }
     $opts = array("dimensions" => "ga:pagePath", "max-results" => 1, "sort" => "-ga:pageViews");
     if (!empty($filters)) {
         $opts["filters"] = implode(";", $filters);
     }
     $result0 = $this->service->data_ga->get("ga:" . $config->profile, $startDate, $endDate, "ga:pageViews", $opts);
     $totalViews = (int) $result0["totalsForAllResults"]["ga:pageviews"];
     // ENTRANCES
     $opts = array("dimensions" => "ga:previousPagePath", "max-results" => 10, "sort" => "-ga:pageViews");
     if (!empty($filters)) {
         $opts["filters"] = implode(";", $filters);
     }
     $result1 = $this->service->data_ga->get("ga:" . $config->profile, $startDate, $endDate, "ga:pageViews", $opts);
     $prev = array();
     foreach ($result1["rows"] as $row) {
         $d = array("path" => $this->formatDimension("ga:previousPagePath", $row[0]), "pageviews" => $row[1]);
         $document = Document::getByPath($row[0]);
         if ($document) {
             $d["id"] = $document->getId();
         }
         $d["percent"] = round($d["pageviews"] / $totalViews * 100);
         $d["weight"] = 100;
         if ($prev[0]["weight"]) {
             $d["weight"] = round($d["percent"] / $prev[0]["percent"] * 100);
         }
         $prev[] = $d;
     }
     // EXITS
     $opts = array("dimensions" => "ga:pagePath", "max-results" => 10, "sort" => "-ga:pageViews");
     if (!empty($filters)) {
         $opts["filters"] = implode(";", $filters);
     }
     $result2 = $this->service->data_ga->get("ga:" . $config->profile, $startDate, $endDate, "ga:pageViews", $opts);
     $next = array();
     foreach ($result2["rows"] as $row) {
         $d = array("path" => $this->formatDimension("ga:previousPagePath", $row[0]), "pageviews" => $row[1]);
         $document = Document::getByPath($row[0]);
         if ($document) {
             $d["id"] = $document->getId();
         }
         $d["percent"] = round($d["pageviews"] / $totalViews * 100);
         $d["weight"] = 100;
         if ($next[0]["weight"]) {
             $d["weight"] = round($d["percent"] / $next[0]["percent"] * 100);
         }
         $next[] = $d;
     }
     $this->view->next = $next;
     $this->view->prev = $prev;
     $this->view->path = $this->_getParam("path");
     $this->getResponse()->setHeader("Content-Type", "application/xml", true);
 }
 public function getIdForPathAction()
 {
     if ($doc = Document::getByPath($this->_getParam("path"))) {
         $this->_helper->json(array("id" => $doc->getId(), "type" => $doc->getType()));
     } else {
         $this->_helper->json(false);
     }
     $this->removeViewRenderer();
 }
示例#23
0
 /**
  * fills object field data values from CSV Import String
  * @abstract
  * @param string $importValue
  * @param Object_Abstract $abstract
  * @return Object_Class_Data
  */
 public function getFromCsvImport($importValue)
 {
     $values = explode(",", $importValue);
     $value = array();
     foreach ($values as $element) {
         $tokens = explode(":", $element);
         if (count($tokens) == 2) {
             $type = $tokens[0];
             $path = $tokens[1];
             $value[] = Element_Service::getElementByPath($type, $path);
         } else {
             //fallback for old export files
             if ($el = Asset::getByPath($element)) {
                 $value[] = $el;
             } else {
                 if ($el = Document::getByPath($element)) {
                     $value[] = $el;
                 } else {
                     if ($el = Object_Abstract::getByPath($element)) {
                         $value[] = $el;
                     }
                 }
             }
         }
     }
     return $value;
 }
示例#24
0
 /**
  * Sets the email document
  *
  * @param Document_Email $document
  * @throws Exception
  */
 public function setDocument($document)
 {
     if ($document instanceof Document) {
         //document passed
         $this->document = $document;
     } elseif ((int) $document > 0) {
         //id of document passed
         $this->setDocument(Document::getById($document));
     } elseif (is_string($document) && $document != "") {
         //path of document passed
         $this->setDocument(Document::getByPath($document));
     } else {
         throw new Exception('$document is not an instance of Document_Email or at least Document');
     }
     return $this;
 }
示例#25
0
 /**
  * @param string $path
  * @return void
  */
 protected function getNearestDocumentByPath($path, $ignoreHardlinks = false)
 {
     if ($this->nearestDocumentByPath instanceof Document) {
         $document = $this->nearestDocumentByPath;
     } else {
         $pathes = array();
         $pathes[] = "/";
         $pathParts = explode("/", $path);
         $tmpPathes = array();
         foreach ($pathParts as $pathPart) {
             $tmpPathes[] = $pathPart;
             $t = implode("/", $tmpPathes);
             if (!empty($t)) {
                 $pathes[] = $t;
             }
         }
         $pathes = array_reverse($pathes);
         foreach ($pathes as $p) {
             if ($document = Document::getByPath($p)) {
                 $this->nearestDocumentByPath = $document;
                 break;
             }
         }
     }
     if ($document) {
         if (!$ignoreHardlinks) {
             if ($document instanceof Document_Hardlink) {
                 if ($hardLinkedDocument = Document_Hardlink_Service::getChildByPath($document, $path)) {
                     $document = $hardLinkedDocument;
                 } else {
                     $document = Document_Hardlink_Service::wrap($document);
                 }
             }
         }
         return $document;
     }
     return null;
 }
示例#26
0
 public function correctPath()
 {
     // set path
     if ($this->getId() != 1) {
         // not for the root node
         $parent = Document::getById($this->getParentId());
         if ($parent) {
             $this->setPath(str_replace("//", "/", $parent->getFullPath() . "/"));
         } else {
             // parent document doesn't exist anymore, so delete this document
             //$this->delete();
             // parent document doesn't exist anymore, set the parent to to root
             $this->setParentId(1);
             $this->setPath("/");
         }
     }
     if (Document_Service::pathExists($this->getFullPath())) {
         $duplicate = Document::getByPath($this->getFullPath());
         if ($duplicate instanceof Document and $duplicate->getId() != $this->getId()) {
             throw new Exception("Duplicate full path [ " . $this->getFullPath() . " ] - cannot create document");
         }
     }
 }
示例#27
0
 /**
  * @param string $path
  * @return void
  */
 protected function getNearestDocumentByPath($path)
 {
     if ($this->nearestDocumentByPath instanceof Document) {
         return $this->nearestDocumentByPath;
     }
     $pathes = array();
     $pathes[] = "/";
     $pathParts = explode("/", $path);
     $tmpPathes = array();
     foreach ($pathParts as $pathPart) {
         $tmpPathes[] = $pathPart;
         $t = implode("/", $tmpPathes);
         if (!empty($t)) {
             $pathes[] = $t;
         }
     }
     $pathes = array_reverse($pathes);
     foreach ($pathes as $p) {
         if ($document = Document::getByPath($p)) {
             $this->nearestDocumentByPath = $document;
             return $document;
         }
     }
     return null;
 }