Пример #1
0
 /**
  * Load language fixtures
  *
  * @author Etienne de Longeaux <*****@*****.**>
  * @since 2012-01-23
  */
 public function load(ObjectManager $manager)
 {
     $field1 = new Widget();
     $field1->setPlugin('content');
     $field1->setAction('-');
     $field1->setConfigCssClass('error');
     $field1->setCacheable(true);
     $field1->setLifetime("86400");
     $field1->setPublic(true);
     $field1->setEnabled(true);
     $manager->persist($field1);
     $manager->flush();
     $this->addReference('widget-error', $field1);
 }
Пример #2
0
 /**
  * Refresh the cache of a widget.
  *
  * @param Widget $widget Widget entity
  * @param string $lang   Lang value
  * 
  * @return void
  * @access public
  * @author Etienne de Longeaux <*****@*****.**>
  * @since  2014-04-08
  */
 public function cacheRefreshWidget(Widget $widget, $lang)
 {
     // we get the id of the widget.
     $id = $widget->getId();
     // we refesh only if the widget is in cash.
     $Etag_widget = 'widget:' . $id . ':' . $lang;
     // we refesh only if the widget is in cash.
     $this->cacheRefreshByname($Etag_widget);
     // we manage the "transwidget"
     $params_transwidget = json_encode(array('widget-id' => $id), JSON_UNESCAPED_UNICODE);
     $widget_translations = $this->getWidgetManager()->setWidgetTranslations($widget);
     if (is_array($widget_translations)) {
         foreach ($widget_translations as $translang => $translationWidget) {
             // we create the cache name of the transwidget
             $Etag_transwidget = 'transwidget:' . $translationWidget->getId() . ':' . $translang . ':' . $params_transwidget;
             // we refresh the cache of the transwidget
             $this->cacheRefreshByname($Etag_transwidget);
         }
     }
     // If the widget is a "content snippet"
     if ($widget->getPlugin() == 'content' && $widget->getAction() == 'snippet') {
         $xmlConfig = $widget->getConfigXml();
         // if the configXml field of the widget is configured correctly.
         try {
             $xmlConfig = new \Zend_Config_Xml($xmlConfig);
             if ($xmlConfig->widgets->get('content')) {
                 $id_snippet = $xmlConfig->widgets->content->id;
                 // we create the cache name of the snippet
                 $Etag_snippet = 'transwidget:' . $id_snippet . ':' . $lang . ':' . $params_transwidget;
                 // we refresh the cache of the snippet
                 $this->cacheRefreshByname($Etag_snippet);
             }
         } catch (\Exception $e) {
         }
     }
     // If the widget is a "gedmo snippet"
     if ($widget->getPlugin() == 'gedmo' && $widget->getAction() == 'snippet') {
         $xmlConfig = $widget->getConfigXml();
         $new_widget = null;
         // if the configXml field of the widget is configured correctly.
         try {
             $xmlConfig = new \Zend_Config_Xml($xmlConfig);
             if ($xmlConfig->widgets->get('gedmo')) {
                 $id = $xmlConfig->widgets->gedmo->id;
                 // we refesh only if the widget is in cash.
                 $Etag_widget = 'widget:' . $id . ':' . $lang;
                 // we refesh only if the widget is in cash.
                 $this->cacheRefreshByname($Etag_widget);
             }
         } catch (\Exception $e) {
         }
     }
     $path_json_file = $this->createJsonFileName('widget', $id, $lang);
     if (file_exists($path_json_file)) {
         $info = explode('|', file_get_contents($path_json_file));
         if (isset($info[1])) {
             $info[1] = \Sfynx\ToolBundle\Util\PiStringManager::cleanWhitespace($info[1]);
             $this->cacheRefreshByname($info[1]);
             //print_r($info[1]);
             //print_r('<br />');print_r('<br />');
         }
     }
     $path_json_file_history = $this->createJsonFileName('widget-history', $id, $lang);
     if (file_exists($path_json_file_history)) {
         $reading = fopen($path_json_file_history, 'r');
         while (!feof($reading)) {
             $info = explode('|', fgets($reading));
             if (isset($info[1])) {
                 $info[1] = \Sfynx\ToolBundle\Util\PiStringManager::cleanWhitespace($info[1]);
                 $this->cacheRefreshByname($info[1]);
                 //print_r($info[1]);
                 //print_r('<br />');print_r('<br />');
             }
         }
         fclose($reading);
     }
     $path_json_file = $this->createJsonFileName('esi', $id, $lang);
     if (file_exists($path_json_file)) {
         $reading = fopen($path_json_file, 'r');
         while (!feof($reading)) {
             $info = explode('|', fgets($reading));
             if (isset($info[1])) {
                 // we get the esi url
                 $info[1] = \Sfynx\ToolBundle\Util\PiStringManager::cleanWhitespace($info[1]);
                 // we delete the cache widget file
                 $this->container->get("sfynx.cache.filecache")->getClient()->setPath($this->createCacheWidgetRepository());
                 $this->container->get("sfynx.cache.filecache")->clear($info[1]);
                 //print_r($id);print_r($info[1]);
                 //print_r('<br />');print_r('<br />');
             }
         }
         fclose($reading);
     }
 }
Пример #3
0
 /**
  * Return if yes or no the widget given in param is supported.
  *
  * @param Widget $widget A Widget entity
  * 
  * @return boolean
  * @access protected
  * @author Etienne de Longeaux <*****@*****.**>
  */
 protected function isWidgetSupported(Widget $widget)
 {
     if (isset($GLOBALS['WIDGET'][strtoupper($widget->getPlugin())][strtolower($widget->getAction())])) {
         return true;
     } else {
         return false;
     }
 }
Пример #4
0
 /**
  * Sets the response to one widget.
  * 
  * @param Widget   $widget   A widget entity
  * @param Response $response The response instance
  *
  * @return void
  * @access private
  * @author Etienne de Longeaux <*****@*****.**>
  * @since  2012-01-31
  */
 private function setResponse($widget, Response $response)
 {
     $this->responses['widget'][$widget->getId()] = $response;
 }