コード例 #1
0
 /**
  * Render the admin form of a widget, if present.
  *
  * @param CmsBlock $block Block Entity
  * @return string Rendered HTML
  */
 public function renderBlockAdminForm(CmsBlock $block)
 {
     $widget = WidgetFactory::factory($block);
     $widget->adminForm();
     $adminFormElement = 'Cms.Design/default_admin_form';
     if ($this->_View->elementExists($widget->getViewFolderPath() . 'admin_form')) {
         $adminFormElement = $widget->getViewFolderPath() . 'admin_form';
     }
     $viewVars = Hash::merge(['widget' => $widget, 'block' => $block], $widget->viewVars);
     return $this->_View->element($adminFormElement, $viewVars);
 }
コード例 #2
0
 /**
  * Builds asset file path based off url
  *
  * @param string $url Asset URL
  * @return string Absolute path for asset file
  */
 protected function _getAssetFile($url)
 {
     $pattern = '/^cms\\/widget\\/([a-z\\.]+)\\/(.*)$/i';
     if (preg_match($pattern, $url, $matches)) {
         $widgetIdentifier = $matches[1];
         $assetPath = $matches[2];
         if (!WidgetManager::widgetExists($widgetIdentifier)) {
             throw new \Cake\Network\Exception\NotFoundException("Widget {$widgetIdentifier} could not be found");
         }
         $widget = WidgetFactory::identifierFactory($widgetIdentifier);
         $assetFile = $widget->getWebrootPath() . $assetPath;
         return $assetFile;
     }
 }
コード例 #3
0
 /**
  * Dialog for editing a block
  *
  * @param string $id Entity ID
  * @return void
  */
 public function edit($id = null)
 {
     $cmsBlock = $this->CmsBlocks->get($id);
     $widget = WidgetFactory::factory($cmsBlock);
     if ($widget->getFullIdentifier() == 'App.FileDownload') {
         $this->eventManager()->off($this->Csrf);
     }
     if ($this->request->is(['patch', 'post', 'put'])) {
         $cmsBlock = $this->CmsBlocks->patchEntity($cmsBlock, $this->request->data);
         if ($this->CmsBlocks->save($cmsBlock)) {
             $this->FrontendBridge->setJson('success', true);
         } else {
             $this->Flash->error(__('forms.data_not_saved'));
         }
     }
     $this->set(compact('cmsBlock', 'widget'));
     $this->FrontendBridge->setJson(compact('cmsBlock'));
 }
コード例 #4
0
 /**
  * Returns an array, indexed by widget identifier with title and description
  * for the widgets
  *
  * @return array
  */
 public static function getWidgetList()
 {
     $availableWidgets = self::getAvailableWidgets();
     $widgetList = [];
     foreach ($availableWidgets as $widgetIdentifier) {
         $widget = WidgetFactory::identifierFactory($widgetIdentifier);
         $widgetList[$widgetIdentifier] = ['title' => $widget->config('title') ? $widget->config('title') : $widgetIdentifier, 'description' => $widget->config('description')];
     }
     return $widgetList;
 }
コード例 #5
0
ファイル: CmsBlock.php プロジェクト: scherersoftware/cake-cms
 /**
  * Render the block
  *
  * @param Request $request Request
  * @param View $view Optional View Instance for rendering.
  * @return string Rendered HTML
  */
 public function render(Request $request, View $view = null)
 {
     $widget = WidgetFactory::factory($this);
     return $widget->render($request, $view);
 }