Example #1
0
 public function testAlertLevel()
 {
     $this->expectOutputString('alert: Message contents');
     $echo = new Adaptors\EchoAdaptor('debug', '{level}: {message}');
     $logger = new Logger($echo);
     $logger->alert('Message contents');
 }
Example #2
0
File: Dao.php Project: sfie/pimcore
 /**
  * Deletes from database
  *
  * @return void
  */
 public function delete()
 {
     if ($this->model->getId() instanceof Model\Search\Backend\Data\Id) {
         $this->db->delete("search_backend_data", "id='" . $this->model->getId()->getId() . "' AND maintype ='" . $this->model->getId()->getType() . "'");
     } else {
         \Logger::alert("Cannot delete Search\\Backend\\Data, ID is empty");
     }
 }
Example #3
0
 private static function existsByName($categoryData)
 {
     try {
         $result = VtexConnector::$ws->CategoryGetByName(array("nameCategory" => $categoryData->Name));
         return $result->CategoryGetByNameResult ? $result : null;
     } catch (SoapFault $e) {
         Logger::alert('Erro ao verificar se categoria existe.', $e, VtexConnector::$ws->__getLastRequest());
     }
 }
 public function getById($id, $orderKey = '', $orderSense = '')
 {
     global $wpdb;
     $entityRequest = $wpdb->prepare('SELECT * FROM ' . $this->table . ' WHERE id=%s', $id);
     $entity = $wpdb->get_row($entityRequest);
     if (!isset($entity) || empty($entity)) {
         Logger::alert('Entity : Not found row for request', [$entityRequest, $entity]);
         return 0;
     }
     $optionsRequest = $wpdb->prepare('SELECT options_id, value FROM ' . $wpdb->prefix . 'sm_entity_options WHERE entity_id = %s', $entity->id);
     $options = $wpdb->get_results($optionsRequest);
     $options = json_decode(json_encode($options), true);
     foreach ($options as $key => &$value) {
         $value = (object) $value;
     }
     $entity->options = $options;
     return $entity;
 }
 public function test_methods_Magento()
 {
     $CONFIG_FILE_NAME = __DIR__ . '/logging_exception.yaml';
     $LOGGER_NAME = 'defaultLoggerName';
     /**
      * Perform testing.
      */
     $log = new Logger($CONFIG_FILE_NAME, $LOGGER_NAME);
     $context = ['test' => true, 'env' => ['param1' => 'value1']];
     $log->debug('debug', $context);
     $log->info('info', $context);
     $log->notice('notice', $context);
     $log->warning('warning', $context);
     $log->error('error', $context);
     $log->alert('alert', $context);
     $log->critical('critical', $context);
     $log->emergency('emergency', $context);
 }
Example #6
0
 public function create()
 {
     self::getConnection();
     $values = get_object_vars($this);
     $has_many = self::checkRelationship("has_many", $values);
     //Logger::debug("db",self::$db);
     $result = self::$db->insert(static::$table, $values);
     if ($result) {
         $result = array('error' => 0, 'getID' => self::$db->getInsertedId(), 'message' => 'Objeto Creado');
         $this->id = $result["getID"];
     } else {
         $result = array('error' => 1, 'getID' => null, 'message' => self::$db->getError());
     }
     if ($has_many) {
         $rStatus = self::saveRelationships($has_many);
         if ($rStatus["error"]) {
             Logger::alert("Error saving relationships", $rStatus["trace"], "create");
         }
     }
     //Logger::debug("result",$result,"create");
     return $result;
 }
    /**
     * @param \Zend_Controller_Request_Abstract $request
     */
    public function postDispatch(\Zend_Controller_Request_Abstract $request)
    {
        $conf = Config::getSystemConfig();
        // add scripts to editmode
        if (\Pimcore\Tool\Admin::isExtJS6()) {
            $editmodeLibraries = array("/pimcore/static6/js/pimcore/namespace.js", "/pimcore/static6/js/lib/prototype-light.js", "/pimcore/static6/js/lib/jquery.min.js", "/pimcore/static6/js/lib/ext/ext-all.js", "/pimcore/static6/js/lib/ckeditor/ckeditor.js");
            $editmodeScripts = array("/pimcore/static6/js/pimcore/functions.js", "/pimcore/static6/js/pimcore/element/tag/imagehotspotmarkereditor.js", "/pimcore/static6/js/pimcore/element/tag/imagecropper.js", "/pimcore/static6/js/pimcore/document/edit/helper.js", "/pimcore/static6/js/pimcore/document/edit/dnd.js", "/pimcore/static6/js/pimcore/document/tag.js", "/pimcore/static6/js/pimcore/document/tags/block.js", "/pimcore/static6/js/pimcore/document/tags/date.js", "/pimcore/static6/js/pimcore/document/tags/href.js", "/pimcore/static6/js/pimcore/document/tags/multihref.js", "/pimcore/static6/js/pimcore/document/tags/checkbox.js", "/pimcore/static6/js/pimcore/document/tags/image.js", "/pimcore/static6/js/pimcore/document/tags/input.js", "/pimcore/static6/js/pimcore/document/tags/link.js", "/pimcore/static6/js/pimcore/document/tags/select.js", "/pimcore/static6/js/pimcore/document/tags/snippet.js", "/pimcore/static6/js/pimcore/document/tags/textarea.js", "/pimcore/static6/js/pimcore/document/tags/numeric.js", "/pimcore/static6/js/pimcore/document/tags/wysiwyg.js", "/pimcore/static6/js/pimcore/document/tags/renderlet.js", "/pimcore/static6/js/pimcore/document/tags/table.js", "/pimcore/static6/js/pimcore/document/tags/video.js", "/pimcore/static6/js/pimcore/document/tags/multiselect.js", "/pimcore/static6/js/pimcore/document/tags/areablock.js", "/pimcore/static6/js/pimcore/document/tags/area.js", "/pimcore/static6/js/pimcore/document/tags/pdf.js", "/pimcore/static6/js/pimcore/document/edit/helper.js");
            $editmodeStylesheets = array("/pimcore/static6/css/icons.css", "/pimcore/static6/css/editmode.css?_dc=" . time());
        } else {
            $editmodeLibraries = array("/pimcore/static/js/pimcore/namespace.js", "/pimcore/static/js/lib/prototype-light.js", "/pimcore/static/js/lib/jquery.min.js", "/pimcore/static/js/lib/ext/adapter/jquery/ext-jquery-adapter-debug.js", "/pimcore/static/js/lib/ext/ext-all-debug.js", "/pimcore/static/js/lib/ext-plugins/ux/Spinner.js", "/pimcore/static/js/lib/ext-plugins/ux/SpinnerField.js", "/pimcore/static/js/lib/ext-plugins/ux/MultiSelect.js", "/pimcore/static/js/lib/ext-plugins/GridRowOrder/roworder.js", "/pimcore/static/js/lib/ckeditor/ckeditor.js", "/pimcore/static/js/pimcore/libfixes.js");
            $editmodeScripts = array("/pimcore/static/js/pimcore/functions.js", "/pimcore/static/js/pimcore/element/tag/imagehotspotmarkereditor.js", "/pimcore/static/js/pimcore/element/tag/imagecropper.js", "/pimcore/static/js/pimcore/document/edit/helper.js", "/pimcore/static/js/pimcore/document/edit/dnd.js", "/pimcore/static/js/pimcore/document/tag.js", "/pimcore/static/js/pimcore/document/tags/block.js", "/pimcore/static/js/pimcore/document/tags/date.js", "/pimcore/static/js/pimcore/document/tags/href.js", "/pimcore/static/js/pimcore/document/tags/multihref.js", "/pimcore/static/js/pimcore/document/tags/checkbox.js", "/pimcore/static/js/pimcore/document/tags/image.js", "/pimcore/static/js/pimcore/document/tags/input.js", "/pimcore/static/js/pimcore/document/tags/link.js", "/pimcore/static/js/pimcore/document/tags/select.js", "/pimcore/static/js/pimcore/document/tags/snippet.js", "/pimcore/static/js/pimcore/document/tags/textarea.js", "/pimcore/static/js/pimcore/document/tags/numeric.js", "/pimcore/static/js/pimcore/document/tags/wysiwyg.js", "/pimcore/static/js/pimcore/document/tags/renderlet.js", "/pimcore/static/js/pimcore/document/tags/table.js", "/pimcore/static/js/pimcore/document/tags/video.js", "/pimcore/static/js/pimcore/document/tags/multiselect.js", "/pimcore/static/js/pimcore/document/tags/areablock.js", "/pimcore/static/js/pimcore/document/tags/area.js", "/pimcore/static/js/pimcore/document/tags/pdf.js", "/pimcore/static/js/pimcore/document/edit/helper.js");
            $editmodeStylesheets = array("/pimcore/static/css/icons.css", "/pimcore/static/css/editmode.css?asd=" . time());
        }
        //add plugin editmode JS and CSS
        try {
            $pluginConfigs = ExtensionManager::getPluginConfigs();
            $jsPaths = array();
            $cssPaths = array();
            if (!empty($pluginConfigs)) {
                //registering plugins
                foreach ($pluginConfigs as $p) {
                    $pluginJsPaths = array();
                    if (array_key_exists("pluginDocumentEditmodeJsPaths", $p['plugin']) && is_array($p['plugin']['pluginDocumentEditmodeJsPaths']) && isset($p['plugin']['pluginDocumentEditmodeJsPaths']['path'])) {
                        if (is_array($p['plugin']['pluginDocumentEditmodeJsPaths']['path'])) {
                            $pluginJsPaths = $p['plugin']['pluginDocumentEditmodeJsPaths']['path'];
                        } else {
                            if ($p['plugin']['pluginDocumentEditmodeJsPaths']['path'] != null) {
                                $pluginJsPaths[] = $p['plugin']['pluginDocumentEditmodeJsPaths']['path'];
                            }
                        }
                    }
                    //manipulate path for frontend
                    if (is_array($pluginJsPaths) and count($pluginJsPaths) > 0) {
                        for ($i = 0; $i < count($pluginJsPaths); $i++) {
                            if (is_file(PIMCORE_PLUGINS_PATH . $pluginJsPaths[$i])) {
                                $jsPaths[] = "/plugins" . $pluginJsPaths[$i];
                            }
                        }
                    }
                    $pluginCssPaths = array();
                    if (array_key_exists("pluginDocumentEditmodeCssPaths", $p['plugin']) && is_array($p['plugin']['pluginDocumentEditmodeCssPaths']) && isset($p['plugin']['pluginDocumentEditmodeCssPaths']['path'])) {
                        if (is_array($p['plugin']['pluginDocumentEditmodeCssPaths']['path'])) {
                            $pluginCssPaths = $p['plugin']['pluginDocumentEditmodeCssPaths']['path'];
                        } else {
                            if ($p['plugin']['pluginDocumentEditmodeCssPaths']['path'] != null) {
                                $pluginCssPaths[] = $p['plugin']['pluginDocumentEditmodeCssPaths']['path'];
                            }
                        }
                    }
                    //manipulate path for frontend
                    if (is_array($pluginCssPaths) and count($pluginCssPaths) > 0) {
                        for ($i = 0; $i < count($pluginCssPaths); $i++) {
                            if (is_file(PIMCORE_PLUGINS_PATH . $pluginCssPaths[$i])) {
                                $cssPaths[] = "/plugins" . $pluginCssPaths[$i];
                            }
                        }
                    }
                }
            }
            $editmodeScripts = array_merge($editmodeScripts, $jsPaths);
            $editmodeStylesheets = array_merge($editmodeStylesheets, $cssPaths);
        } catch (\Exception $e) {
            \Logger::alert("there is a problem with the plugin configuration");
            \Logger::alert($e);
        }
        $editmodeHeadHtml = "\n\n\n<!-- pimcore editmode -->\n";
        // include stylesheets
        foreach ($editmodeStylesheets as $sheet) {
            $editmodeHeadHtml .= '<link rel="stylesheet" type="text/css" href="' . $sheet . '?_dc=' . Version::$revision . '" />';
            $editmodeHeadHtml .= "\n";
        }
        $editmodeHeadHtml .= "\n\n";
        $editmodeHeadHtml .= '<script type="text/javascript">var jQueryPreviouslyLoaded = (typeof jQuery == "undefined") ? false : true;</script>' . "\n";
        // include script libraries
        foreach ($editmodeLibraries as $script) {
            $editmodeHeadHtml .= '<script type="text/javascript" src="' . $script . '?_dc=' . Version::$revision . '"></script>';
            $editmodeHeadHtml .= "\n";
        }
        // combine the pimcore scripts in non-devmode
        if ($conf->general->devmode) {
            foreach ($editmodeScripts as $script) {
                $editmodeHeadHtml .= '<script type="text/javascript" src="' . $script . '?_dc=' . Version::$revision . '"></script>';
                $editmodeHeadHtml .= "\n";
            }
        } else {
            $scriptContents = "";
            foreach ($editmodeScripts as $scriptUrl) {
                $scriptContents .= file_get_contents(PIMCORE_DOCUMENT_ROOT . $scriptUrl) . "\n\n\n";
            }
            $editmodeHeadHtml .= '<script type="text/javascript" src="' . \Pimcore\Tool\Admin::getMinimizedScriptPath($scriptContents) . '?_dc=' . Version::$revision . '"></script>' . "\n";
        }
        $user = \Pimcore\Tool\Authentication::authenticateSession();
        $lang = $user->getLanguage();
        $editmodeHeadHtml .= '<script type="text/javascript" src="/admin/misc/json-translations-system/language/' . $lang . '/?_dc=' . Version::$revision . '"></script>' . "\n";
        $editmodeHeadHtml .= '<script type="text/javascript" src="/admin/misc/json-translations-admin/language/' . $lang . '/?_dc=' . Version::$revision . '"></script>' . "\n";
        $editmodeHeadHtml .= "\n\n";
        // set var for editable configurations which is filled by Document\Tag::admin()
        $editmodeHeadHtml .= '<script type="text/javascript">
            var editableConfigurations = new Array();
            var pimcore_document_id = ' . $request->getParam("document")->getId() . ';

            if(jQueryPreviouslyLoaded) {
                jQuery.noConflict( true );
            }
        </script>';
        $editmodeHeadHtml .= "\n\n<!-- /pimcore editmode -->\n\n\n";
        // add scripts in html header for pages in editmode
        if ($this->controller->editmode && Document\Service::isValidType($this->controller->document->getType())) {
            //ckogler
            include_once "simple_html_dom.php";
            $body = $this->getResponse()->getBody();
            $html = str_get_html($body);
            if ($html) {
                $htmlElement = $html->find("html", 0);
                $head = $html->find("head", 0);
                $bodyElement = $html->find("body", 0);
                // if there's no head and no body, create a wrapper including these elements
                // add html headers for snippets in editmode, so there is no problem with javascript
                if (!$head && !$bodyElement && !$htmlElement) {
                    $body = "<!DOCTYPE html>\n<html>\n<head></head><body>" . $body . "</body></html>";
                    $html = str_get_html($body);
                    // get them again with the updated html markup
                    $htmlElement = $html->find("html", 0);
                    $head = $html->find("head", 0);
                    $bodyElement = $html->find("body", 0);
                }
                if ($head && $bodyElement && $htmlElement) {
                    $head->innertext = $head->innertext . "\n\n" . $editmodeHeadHtml;
                    $bodyElement->onunload = "pimcoreOnUnload();";
                    if (\Pimcore\Tool\Admin::isExtJS6()) {
                        $bodyElement->innertext = $bodyElement->innertext . "\n\n" . '<script type="text/javascript" src="/pimcore/static6/js/pimcore/document/edit/startup.js?_dc=' . Version::$revision . '"></script>' . "\n\n";
                    } else {
                        $bodyElement->innertext = $bodyElement->innertext . "\n\n" . '<script type="text/javascript" src="/pimcore/static/js/pimcore/document/edit/startup.js?_dc=' . Version::$revision . '"></script>' . "\n\n";
                    }
                    $body = $html->save();
                    $this->getResponse()->setBody($body);
                } else {
                    $this->getResponse()->setBody('<div style="font-size:30px; font-family: Arial; font-weight:bold; color:red; text-align: center; margin: 40px 0">You have to define a &lt;html&gt;, &lt;head&gt;, &lt;body&gt;<br />HTML-tag in your view/layout markup!</div>');
                }
                $html->clear();
                unset($html);
            }
        }
        // IE compatibility
        //$this->getResponse()->setHeader("X-UA-Compatible", "IE=8; IE=9", true);
    }
 public function manageMessages($entity)
 {
     $requester = new Requester();
     $publisher = new Publisher();
     $entityObject = new Entity();
     $downloader = new FileDownloader();
     $published = new Published();
     $summary = '';
     $title = '';
     $readmoreLabel = '';
     // get author id
     $author = $entity->author_id;
     // The entity is not active
     if (!$entity->activate) {
         return 0;
     }
     // Retrieve the entity categories
     $entityListCategory = [];
     $readmoreLabel = '';
     foreach ($entity->options as $key => $value) {
         if ($value->options_id == 1) {
             $entityListCategory[] = $value->value;
         }
         if ($value->options_id == 2) {
             $entityDisplayType = $value->value;
         }
         if ($value->options_id == 3) {
             $entityPublishType = $value->value;
         }
         if ($value->options_id == 5) {
             $entityImage = $value->value;
         }
         if ($value->options_id == 6) {
             $readmoreLabel = $value->value;
         }
     }
     // Try request to sociallymap on response
     try {
         if ($_ENV['ENVIRONNEMENT'] === 'dev') {
             $requester = new MockRequester();
             $jsonData = $requester->getMessages();
         } else {
             $_POST['entityId'] = esc_html($_POST['entityId']);
             $_POST['token'] = esc_html($_POST['token']);
             $_POST['environment'] = esc_html($_POST['environment']);
             $jsonData = $requester->launch($_POST['entityId'], $_POST['token'], $_POST['environment']);
         }
         if (empty($jsonData)) {
             throw new Exception('No data returned from request', 1);
             exit;
         }
         Logger::messageReceive('See return data', $jsonData);
         foreach ($jsonData as $key => $value) {
             $summary = '';
             $contentArticle = '';
             $readmore = '';
             // Check Link object existing
             if (isset($value->link)) {
                 // Check if Title existing
                 if (!empty($value->link->title)) {
                     $title = $value->link->title;
                 }
                 if (!empty($value->link->summary)) {
                     $summary = $value->link->summary;
                 }
                 // Check if Link URL existing
                 if (!empty($value->link->url)) {
                     $readmoreLabel = stripslashes($readmoreLabel);
                     $readmore = $this->templater->loadReadMore($value->link->url, $entityDisplayType, $entity->id, $readmoreLabel);
                 } else {
                     Logger::alert('This article not contain url');
                 }
             }
             $contentArticle = $summary;
             // add readmore to content if $readmore is not empty
             if ($readmore != '') {
                 $contentArticle .= $readmore;
             }
             $imageTag = '';
             $imageSrc = '';
             // Check if article posted
             $canBePublish = true;
             $messageId = $value->guid;
             if ($published->isPublished($messageId)) {
                 $contextMessageId = '(id message=' . $messageId . ')';
                 Logger::alert('Message of sociallymap existing, so he is not publish', $contextMessageId);
                 $canBePublish = false;
                 continue;
             }
             $pathTempory = plugin_dir_path(__FILE__) . 'tmp/';
             // Check if Media object exist
             if (isset($value->media) && $value->media->type == 'photo') {
                 try {
                     $returnDownload = $downloader->download($value->media->url, $pathTempory);
                     $filename = $returnDownload['filename'];
                     $fileExtension = $returnDownload['extension'];
                     $mediaManager = new MediaWordpressManager();
                     $imageSrc = $mediaManager->integrateMediaToWordpress($filename, $fileExtension);
                 } catch (fileDownloadException $e) {
                     Logger::error('error download' . $e);
                 }
                 // WHEN NO ERROR : FORMAT
                 if (gettype($imageSrc) == 'string') {
                     $imageTag = '<img class="aligncenter" src="' . $imageSrc . '" alt="">';
                 } else {
                     $imageTag = '';
                 }
             } elseif (isset($value->link) && !empty($value->link->thumbnail) && $value->link->thumbnail != ' ') {
                 // Check if Image thumbnail existing
                 try {
                     $returnDownload = $downloader->download($value->link->thumbnail, $pathTempory);
                     $filename = $returnDownload['filename'];
                     $fileExtension = $returnDownload['extension'];
                 } catch (fileDownloadException $e) {
                     Logger::error('error download' . $e);
                 }
                 $mediaManager = new MediaWordpressManager();
                 $imageSrc = $mediaManager->integrateMediaToWordpress($filename, $fileExtension);
                 // Create the img tag
                 if (gettype($imageSrc) == 'string') {
                     $imageTag = '<img class="aligncenter" src="' . $imageSrc . '" alt="">';
                 } else {
                     $imageTag = '';
                 }
             }
             // check if video exist
             $downloadVideo = false;
             if (isset($value->media) && $value->media->type == 'video') {
                 $returnDownload = $downloader->download($value->media->url, $pathTempory);
                 $filename = $returnDownload['filename'];
                 $fileExtension = $returnDownload['extension'];
                 $mediaManager = new MediaWordpressManager();
                 $videoSrc = $mediaManager->integrateMediaToWordpress($filename, $fileExtension);
                 $mediaVideo = '<video class="sm-video-display" controls>
                 <source src="' . $videoSrc . '" type="video/mp4">
                 <div class="sm-video-nosupport"></div>
                 </video>';
                 $contentArticle .= $mediaVideo;
                 Logger::info('download VIDEO', $videoSrc);
             }
             // If imageTag is '' so is false else $isDownload is true
             $isDownloaded = $imageTag !== '';
             // Attach image accordingly to options
             $imageAttachment = '';
             if ($isDownloaded) {
                 // Add image in the post content
                 if (in_array($entityImage, ['content', 'both'])) {
                     $contentArticle = $imageTag . $contentArticle;
                 }
                 // Add image as featured image
                 if (in_array($entityImage, ['thumbnail', 'both'])) {
                     $imageAttachment = $imageSrc;
                 }
             }
             // Publish the post
             $title = $value->content;
             if ($canBePublish == true) {
                 $dataPublish = [$title, $contentArticle, $author, $imageAttachment, $entityListCategory, $entityPublishType];
                 Logger::info('Try publish : ', $dataPublish);
                 $contentArticle = $this->prePosting($contentArticle);
                 $articlePublished = $publisher->publish($title, $contentArticle, $author, $imageAttachment, $entityListCategory, $entityPublishType);
                 if (!$articlePublished) {
                     // throw new Exception('Error from post publish', 1);
                     Logger::error('Error from post publish', [$title]);
                 } else {
                     $entityObject->updateHistoryPublisher($entity->id, $entity->counter);
                     // save published article
                     $published->add($messageId, $entity->id, $articlePublished);
                 }
             }
         }
     } catch (Exception $e) {
         Logger::alert('Error exeption', $e->getMessage());
     }
     return true;
 }
Example #9
0
 /**
  *
  */
 public static function initPlugins()
 {
     // add plugin include paths
     $autoloader = \Zend_Loader_Autoloader::getInstance();
     try {
         $pluginConfigs = ExtensionManager::getPluginConfigs();
         if (!empty($pluginConfigs)) {
             $includePaths = array(get_include_path());
             //adding plugin include paths and namespaces
             if (count($pluginConfigs) > 0) {
                 foreach ($pluginConfigs as $p) {
                     if (!ExtensionManager::isEnabled("plugin", $p["plugin"]["pluginName"])) {
                         continue;
                     }
                     if (is_array($p['plugin']['pluginIncludePaths']['path'])) {
                         foreach ($p['plugin']['pluginIncludePaths']['path'] as $path) {
                             $includePaths[] = PIMCORE_PLUGINS_PATH . $path;
                         }
                     } else {
                         if ($p['plugin']['pluginIncludePaths']['path'] != null) {
                             $includePaths[] = PIMCORE_PLUGINS_PATH . $p['plugin']['pluginIncludePaths']['path'];
                         }
                     }
                     if (is_array($p['plugin']['pluginNamespaces']['namespace'])) {
                         foreach ($p['plugin']['pluginNamespaces']['namespace'] as $namespace) {
                             $autoloader->registerNamespace($namespace);
                         }
                     } else {
                         if ($p['plugin']['pluginNamespaces']['namespace'] != null) {
                             $autoloader->registerNamespace($p['plugin']['pluginNamespaces']['namespace']);
                         }
                     }
                 }
             }
             set_include_path(implode(PATH_SEPARATOR, $includePaths));
             $broker = \Pimcore\API\Plugin\Broker::getInstance();
             //registering plugins
             foreach ($pluginConfigs as $p) {
                 if (!ExtensionManager::isEnabled("plugin", $p["plugin"]["pluginName"])) {
                     continue;
                 }
                 $jsPaths = array();
                 $isExtJs5 = \Pimcore\Tool\Admin::isExtJS5();
                 if ($isExtJs5 && is_array($p['plugin']['pluginJsPaths-extjs5']) && isset($p['plugin']['pluginJsPaths-extjs5']['path']) && is_array($p['plugin']['pluginJsPaths-extjs5']['path'])) {
                     $jsPaths = $p['plugin']['pluginJsPaths-extjs5']['path'];
                 } else {
                     if ($isExtJs5 && is_array($p['plugin']['pluginJsPaths-extjs5']) && $p['plugin']['pluginJsPaths-extjs5']['path'] != null) {
                         $jsPaths[0] = $p['plugin']['pluginJsPaths-extjs5']['path'];
                     } else {
                         if (is_array($p['plugin']['pluginJsPaths']) && isset($p['plugin']['pluginJsPaths']['path']) && is_array($p['plugin']['pluginJsPaths']['path'])) {
                             $jsPaths = $p['plugin']['pluginJsPaths']['path'];
                         } else {
                             if (is_array($p['plugin']['pluginJsPaths']) && $p['plugin']['pluginJsPaths']['path'] != null) {
                                 $jsPaths[0] = $p['plugin']['pluginJsPaths']['path'];
                             }
                         }
                     }
                 }
                 //manipulate path for frontend
                 if (is_array($jsPaths) and count($jsPaths) > 0) {
                     for ($i = 0; $i < count($jsPaths); $i++) {
                         if (is_file(PIMCORE_PLUGINS_PATH . $jsPaths[$i])) {
                             $jsPaths[$i] = "/plugins" . $jsPaths[$i];
                         }
                     }
                 }
                 $cssPaths = array();
                 if ($isExtJs5 && is_array($p['plugin']['pluginCssPaths-extjs5']) && isset($p['plugin']['pluginCssPaths-extjs5']['path']) && is_array($p['plugin']['pluginCssPaths-extjs5']['path'])) {
                     $cssPaths = $p['plugin']['pluginCssPaths-extjs5']['path'];
                 } else {
                     if ($isExtJs5 && is_array($p['plugin']['pluginCssPaths-extjs5']) && $p['plugin']['pluginCssPaths-extjs5']['path'] != null) {
                         $cssPaths[0] = $p['plugin']['pluginCssPaths-extjs5']['path'];
                     } else {
                         if (is_array($p['plugin']['pluginCssPaths']) && isset($p['plugin']['pluginCssPaths']['path']) && is_array($p['plugin']['pluginCssPaths']['path'])) {
                             $cssPaths = $p['plugin']['pluginCssPaths']['path'];
                         } else {
                             if (is_array($p['plugin']['pluginCssPaths']) && $p['plugin']['pluginCssPaths']['path'] != null) {
                                 $cssPaths[0] = $p['plugin']['pluginCssPaths']['path'];
                             }
                         }
                     }
                 }
                 //manipulate path for frontend
                 if (is_array($cssPaths) and count($cssPaths) > 0) {
                     for ($i = 0; $i < count($cssPaths); $i++) {
                         if (is_file(PIMCORE_PLUGINS_PATH . $cssPaths[$i])) {
                             $cssPaths[$i] = "/plugins" . $cssPaths[$i];
                         }
                     }
                 }
                 try {
                     $className = $p['plugin']['pluginClassName'];
                     if (!empty($className) && Tool::classExists($className)) {
                         $plugin = new $className($jsPaths, $cssPaths);
                         if ($plugin instanceof \Pimcore\API\Plugin\AbstractPlugin) {
                             $broker->registerPlugin($plugin);
                         }
                     }
                 } catch (\Exception $e) {
                     \Logger::err("Could not instantiate and register plugin [" . $p['plugin']['pluginClassName'] . "]");
                 }
             }
             \Zend_Registry::set("Pimcore_API_Plugin_Broker", $broker);
         }
     } catch (\Exception $e) {
         \Logger::alert("there is a problem with the plugin configuration");
         \Logger::alert($e);
     }
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $newsletter = Model\Tool\Newsletter\Config::getByName($input->getArgument("id"));
     if ($newsletter) {
         $pidFile = $newsletter->getPidFile();
         if (file_exists($pidFile)) {
             \Logger::alert("Cannot send newsletters because there's already one active sending process");
             exit;
         }
         $elementsPerLoop = 10;
         $objectList = "\\Pimcore\\Model\\Object\\" . ucfirst($newsletter->getClass()) . "\\Listing";
         $list = new $objectList();
         $conditions = array("(newsletterActive = 1 AND newsletterConfirmed = 1)");
         if ($newsletter->getObjectFilterSQL()) {
             $conditions[] = $newsletter->getObjectFilterSQL();
         }
         if ($newsletter->getPersonas()) {
             $class = Model\Object\ClassDefinition::getByName($newsletter->getClass());
             if ($class && $class->getFieldDefinition("persona")) {
                 $personas = array();
                 $p = explode(",", $newsletter->getPersonas());
                 if ($class->getFieldDefinition("persona") instanceof \Pimcore\Model\Object\ClassDefinition\Data\Persona) {
                     foreach ($p as $value) {
                         if (!empty($value)) {
                             $personas[] = $list->quote($value);
                         }
                     }
                     $conditions[] = "persona IN (" . implode(",", $personas) . ")";
                 } else {
                     if ($class->getFieldDefinition("persona") instanceof \Pimcore\Model\Object\ClassDefinition\Data\Personamultiselect) {
                         $personasCondition = array();
                         foreach ($p as $value) {
                             $personasCondition[] = "persona LIKE " . $list->quote("%," . $value . ",%");
                         }
                         $conditions[] = "(" . implode(" OR ", $personasCondition) . ")";
                     }
                 }
             }
         }
         $list->setCondition(implode(" AND ", $conditions));
         $list->setOrderKey("email");
         $list->setOrder("ASC");
         $elementsTotal = $list->getTotalCount();
         $count = 0;
         $pidContents = array("start" => time(), "lastUpdate" => time(), "newsletter" => $newsletter->getName(), "total" => $elementsTotal, "current" => $count);
         $this->writePid($pidFile, $pidContents);
         for ($i = 0; $i < ceil($elementsTotal / $elementsPerLoop); $i++) {
             $list->setLimit($elementsPerLoop);
             $list->setOffset($i * $elementsPerLoop);
             $objects = $list->load();
             foreach ($objects as $object) {
                 try {
                     $count++;
                     \Logger::info("Sending newsletter " . $count . " / " . $elementsTotal . " [" . $newsletter->getName() . "]");
                     \Pimcore\Tool\Newsletter::sendMail($newsletter, $object, null, $input->getArgument("hostUrl"));
                     $note = new Model\Element\Note();
                     $note->setElement($object);
                     $note->setDate(time());
                     $note->setType("newsletter");
                     $note->setTitle("sent newsletter: '" . $newsletter->getName() . "'");
                     $note->setUser(0);
                     $note->setData(array());
                     $note->save();
                     \Logger::info("Sent newsletter to: " . $this->obfuscateEmail($object->getEmail()) . " [" . $newsletter->getName() . "]");
                 } catch (\Exception $e) {
                     \Logger::err($e);
                 }
             }
             // check if pid exists
             if (!file_exists($pidFile)) {
                 \Logger::alert("Newsletter PID not found, cancel sending process");
                 exit;
             }
             // update pid
             $pidContents["lastUpdate"] = time();
             $pidContents["current"] = $count;
             $this->writePid($pidFile, $pidContents);
             \Pimcore::collectGarbage();
         }
         // remove pid
         @unlink($pidFile);
     } else {
         \Logger::emerg("Newsletter '" . $input->getArgument("id") . "' doesn't exist");
     }
 }
                $note = new Model\Element\Note();
                $note->setElement($object);
                $note->setDate(time());
                $note->setType("newsletter");
                $note->setTitle("sent newsletter: '" . $newsletter->getName() . "'");
                $note->setUser(0);
                $note->setData(array());
                $note->save();
                \Logger::info("Sent newsletter to: " . obfuscateEmail($object->getEmail()) . " [" . $newsletter->getName() . "]");
            } catch (\Exception $e) {
                \Logger::err($e);
            }
        }
        // check if pid exists
        if (!file_exists($pidFile)) {
            \Logger::alert("Newsletter PID not found, cancel sending process");
            exit;
        }
        // update pid
        $pidContents["lastUpdate"] = time();
        $pidContents["current"] = $count;
        writePid($pidFile, $pidContents);
        \Pimcore::collectGarbage();
    }
    // remove pid
    @unlink($pidFile);
} else {
    \Logger::emerg("Newsletter '" . $argv[1] . "' doesn't exist");
}
function obfuscateEmail($email)
{
Example #12
0
 /**
  * @param  string[] $validLinkRegexes
  * @param  string[] $invalidLinkRegexes
  * @return void
  */
 public function __construct($validLinkRegexes, $invalidLinkRegexes, $maxRedirects = 10, $timeout = 30, $searchStartIndicator = null, $searchEndIndicator = null, $maxThreads = 20, $maxLinkDepth = 15)
 {
     $this->validLinkRegexes = $validLinkRegexes;
     $this->invalidLinkRegexes = $invalidLinkRegexes;
     $this->maxRedirects = $maxRedirects;
     $this->timeout = $timeout;
     $this->searchEndIndicator = $searchEndIndicator;
     $this->searchStartIndicator = $searchStartIndicator;
     $this->maxThreads = $maxThreads;
     $this->maxLinkDepth = $maxLinkDepth;
     $db = Pimcore_Resource_Mysql::get();
     $this->db = $db;
     $db->query("DROP TABLE IF EXISTS `plugin_searchphp_contents_temp`;");
     $db->query("CREATE TABLE `plugin_searchphp_contents_temp` (\r\n                `id` VARCHAR(255) NOT NULL,\r\n                `uri` TEXT NOT NULL,\r\n                `host` VARCHAR(255) NOT NULL,\r\n                `content` LONGTEXT NOT NULL ,\r\n                `html` LONGTEXT NOT NULL ,\r\n                      PRIMARY KEY  (`id`)\r\n                    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
     $db->query("DROP TABLE IF EXISTS `plugin_searchphp_frontend_crawler_todo`;");
     $db->query("CREATE TABLE `plugin_searchphp_frontend_crawler_todo` (\r\n                        `id` VARCHAR(255) NOT NULL,\r\n                        `uri` TEXT NOT NULL,\r\n                        `depth` int(11) unsigned,\r\n                        `cookiejar` TEXT,\r\n                              PRIMARY KEY  (`id`)\r\n                            ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
     $db->query("DROP TABLE IF EXISTS `plugin_searchphp_frontend_crawler_noindex`;");
     $db->query("CREATE TABLE `plugin_searchphp_frontend_crawler_noindex` (\r\n                                `id` VARCHAR(255) NOT NULL,\r\n                                `uri` TEXT NOT NULL,\r\n                                      PRIMARY KEY  (`id`)\r\n                                    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
     $db->query("DROP TABLE IF EXISTS `plugin_searchphp_indexer_todo`;");
     $db->query("CREATE TABLE `plugin_searchphp_indexer_todo` (\r\n                        `id` int(11) unsigned NOT NULL AUTO_INCREMENT,\r\n                        `content` LONGTEXT NOT NULL,\r\n                              PRIMARY KEY  (`id`)\r\n                            ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
     $result = null;
     try {
         $result = $db->describeTable("plugin_searchphp_contents_temp");
         $this->readyToCrawl = !empty($result);
     } catch (Zend_Db_Statement_Exception $e) {
         Logger::alert(get_class($this) . ": could not set up table for crawler contents.", Zend_Log::ERR);
         $this->readyToCrawl = false;
     }
 }
 /**
  * Action must be taken immediately.
  *
  * Example: Entire website down, database unavailable, etc. This should
  * trigger the SMS alerts and wake you up.
  *
  * @param string $message
  * @param array $context
  *
  * @return null
  */
 public function alert($message, array $context = array())
 {
     \Logger::alert($message);
 }
Example #14
0
  public function postDispatch(Zend_Controller_Request_Abstract $request)
  {
      // add scripts to editmode
      $editmodeLibraries = array("/pimcore/static/js/pimcore/namespace.js", "/pimcore/static/js/lib/prototype-light.js", "/pimcore/static/js/lib/jquery-1.4.2.min.js", "/pimcore/static/js/lib/ext/adapter/jquery/ext-jquery-adapter-debug.js", "/pimcore/static/js/lib/ext/ext-all-debug.js", "/pimcore/static/js/lib/ext-plugins/ux/Spinner.js", "/pimcore/static/js/lib/ext-plugins/ux/SpinnerField.js", "/pimcore/static/js/lib/ext-plugins/ux/MultiSelect.js", "/pimcore/static/js/lib/ext-plugins/ux/Portal.js", "/pimcore/static/js/lib/ext-plugins/ux/PortalColumn.js", "/pimcore/static/js/lib/ext-plugins/ux/Portlet.js", "/pimcore/static/js/lib/ext-plugins/GridRowOrder/roworder.js", "/pimcore/static/js/lib/ckeditor/ckeditor.js", "/pimcore/static/js/pimcore/libfixes.js");
      $editmodeScripts = array("/pimcore/static/js/pimcore/functions.js", "/pimcore/static/js/pimcore/document/edit/helper.js", "/pimcore/static/js/pimcore/document/edit/dnd.js", "/pimcore/static/js/pimcore/document/tag.js", "/pimcore/static/js/pimcore/document/tags/block.js", "/pimcore/static/js/pimcore/document/tags/date.js", "/pimcore/static/js/pimcore/document/tags/href.js", "/pimcore/static/js/pimcore/document/tags/multihref.js", "/pimcore/static/js/pimcore/document/tags/checkbox.js", "/pimcore/static/js/pimcore/document/tags/image.js", "/pimcore/static/js/pimcore/document/tags/input.js", "/pimcore/static/js/pimcore/document/tags/link.js", "/pimcore/static/js/pimcore/document/tags/select.js", "/pimcore/static/js/pimcore/document/tags/snippet.js", "/pimcore/static/js/pimcore/document/tags/textarea.js", "/pimcore/static/js/pimcore/document/tags/numeric.js", "/pimcore/static/js/pimcore/document/tags/wysiwyg.js", "/pimcore/static/js/pimcore/document/tags/renderlet.js", "/pimcore/static/js/pimcore/document/tags/table.js", "/pimcore/static/js/pimcore/document/tags/video.js", "/pimcore/static/js/pimcore/document/tags/multiselect.js", "/pimcore/static/js/pimcore/document/tags/areablock.js", "/pimcore/static/js/pimcore/document/edit/helper.js");
      $conf = Pimcore_Config::getSystemConfig();
      $themeUrl = "/pimcore/static/js/lib/ext/resources/css/xtheme-blue.css";
      if ($conf->general->theme) {
          $themeUrl = $conf->general->theme;
      }
      $editmodeStylesheets = array("/pimcore/static/js/lib/ext/resources/css/ext-all.css", $themeUrl, "/pimcore/static/css/icons.css", "/pimcore/static/css/editmode.css", "/pimcore/static/js/lib/ext-plugins/ux/css/Spinner.css", "/pimcore/static/js/lib/ext-plugins/ux/css/MultiSelect.css", "/pimcore/static/js/lib/ext-plugins/ux/css/Portal.css");
      //add plugin editmode JS and CSS
      try {
          $pluginConfigs = Pimcore_ExtensionManager::getPluginConfigs();
          $jsPaths = array();
          $cssPaths = array();
          if (!empty($pluginConfigs)) {
              //registering plugins
              foreach ($pluginConfigs as $p) {
                  if (is_array($p['plugin']['pluginDocumentEditmodeJsPaths']['path'])) {
                      $jsPaths = $p['plugin']['pluginDocumentEditmodeJsPaths']['path'];
                  } else {
                      if ($p['plugin']['pluginDocumentEditmodeJsPaths']['path'] != null) {
                          $jsPaths[0] = $p['plugin']['pluginDocumentEditmodeJsPaths']['path'];
                      }
                  }
                  //manipulate path for frontend
                  if (is_array($jsPaths) and count($jsPaths) > 0) {
                      for ($i = 0; $i < count($jsPaths); $i++) {
                          if (is_file(PIMCORE_PLUGINS_PATH . $jsPaths[$i])) {
                              $jsPaths[$i] = "/plugins" . $jsPaths[$i];
                          }
                      }
                  }
                  if (is_array($p['plugin']['pluginDocumentEditmodeCssPaths']['path'])) {
                      $cssPaths = $p['plugin']['pluginDocumentEditmodeCssPaths']['path'];
                  } else {
                      if ($p['plugin']['pluginDocumentEditmodeCssPaths']['path'] != null) {
                          $cssPaths[0] = $p['plugin']['pluginDocumentEditmodeCssPaths']['path'];
                      }
                  }
                  //manipulate path for frontend
                  if (is_array($cssPaths) and count($cssPaths) > 0) {
                      for ($i = 0; $i < count($cssPaths); $i++) {
                          if (is_file(PIMCORE_PLUGINS_PATH . $cssPaths[$i])) {
                              $cssPaths[$i] = "/plugins" . $cssPaths[$i];
                          }
                      }
                  }
              }
          }
          $editmodeScripts = array_merge($editmodeScripts, $jsPaths);
          $editmodeStylesheets = array_merge($editmodeStylesheets, $cssPaths);
      } catch (Exception $e) {
          Logger::alert("there is a problem with the plugin configuration");
          Logger::alert($e);
      }
      $editmodeHeadHtml = "\n\n\n<!-- pimcore editmode -->\n";
      // include stylesheets
      foreach ($editmodeStylesheets as $sheet) {
          $editmodeHeadHtml .= '<link rel="stylesheet" type="text/css" href="' . $sheet . '?_dc=' . Pimcore_Version::$revision . '" />';
          $editmodeHeadHtml .= "\n";
      }
      // include script libraries
      foreach ($editmodeLibraries as $script) {
          $editmodeHeadHtml .= '<script type="text/javascript" src="' . $script . '?_dc=' . Pimcore_Version::$revision . '"></script>';
          $editmodeHeadHtml .= "\n";
      }
      // combine the pimcore scripts in non-devmode
      if ($conf->general->devmode) {
          foreach ($editmodeScripts as $script) {
              $editmodeHeadHtml .= '<script type="text/javascript" src="' . $script . '?_dc=' . Pimcore_Version::$revision . '"></script>';
              $editmodeHeadHtml .= "\n";
          }
      } else {
          $scriptContents = "";
          foreach ($editmodeScripts as $scriptUrl) {
              $scriptContents .= file_get_contents(PIMCORE_DOCUMENT_ROOT . $scriptUrl) . "\n\n\n";
          }
          $editmodeHeadHtml .= '<script type="text/javascript" src="' . Pimcore_Tool_Admin::getMinimizedScriptPath($scriptContents) . '?_dc=' . Pimcore_Version::$revision . '"></script>' . "\n";
      }
      $ns = new Zend_Session_Namespace("pimcore_admin");
      $user = User::getById($ns->user->getId());
      $lang = $user->getLanguage();
      $editmodeHeadHtml .= '<script type="text/javascript" src="/admin/misc/json-translations-system/language/' . $lang . '/?_dc=' . Pimcore_Version::$revision . '"></script>' . "\n";
      $editmodeHeadHtml .= '<script type="text/javascript" src="/admin/misc/json-translations-admin/language/' . $lang . '/?_dc=' . Pimcore_Version::$revision . '"></script>' . "\n";
      $editmodeHeadHtml .= "\n\n";
      // set var for editable configurations which is filled by Document_Tag::admin()
      $editmodeHeadHtml .= '<script type="text/javascript">
          var editableConfigurations = new Array();
          var pimcore_document_id = ' . $request->getParam("document")->getId() . ';
      </script>';
      $editmodeHeadHtml .= "\n\n<!-- /pimcore editmode -->\n\n\n";
      // add html headers for snippets in editmode, so there is no problem with javascript
      $body = $this->getResponse()->getBody();
      if ($this->controller->editmode && strpos($body, "</body>") === false && !$request->getParam("blockAutoHtml")) {
          $body = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
	<html xmlns="http://www.w3.org/1999/xhtml">
	<head></head><body>' . $body . "</body></html>";
          $this->getResponse()->setBody($body);
      }
      // add scripts in html header for pages in editmode
      if ($this->controller->editmode && ($this->controller->document->getType() == "page" || $this->controller->document->getType() == "snippet")) {
          include_once "simple_html_dom.php";
          $body = $this->getResponse()->getBody();
          $html = str_get_html($body);
          if ($html) {
              if ($head = $html->find("head", 0)) {
                  $head->innertext = $head->innertext . "\n\n" . $editmodeHeadHtml;
                  $bodyElement = $html->find("body", 0);
                  $bodyElement->onunload = "pimcoreOnUnload();";
                  $bodyElement->innertext = $bodyElement->innertext . "\n\n" . '<script type="text/javascript" src="/pimcore/static/js/pimcore/document/edit/startup.js?_dc=' . Pimcore_Version::$revision . '"></script>' . "\n\n";
                  $body = $html->save();
                  $this->getResponse()->setBody($body);
              }
          }
      }
  }
Example #15
0
 private static function getSkuByRefId($ref)
 {
     try {
         return VtexConnector::$ws->StockKeepingUnitGetByRefId(array('refId' => $ref));
     } catch (Exception $e) {
         Logger::alert('Falha ao recuperar sku pela referencia', $e, VtexConnector::$ws->__getLastRequest());
     }
 }
 public function testAlert()
 {
     $this->object->alert('message');
 }