Inheritance: extends Gc\Db\AbstractTable
Ejemplo n.º 1
0
 /**
  * Initialize General sub form
  *
  * @return Config
  */
 public function initGeneral()
 {
     //General settings
     $generalFieldset = new Fieldset('general');
     $generalFieldset->setLabel('General');
     $name = new Element\Text('site_name');
     $name->setLabel('Site name')->setLabelAttributes(array('class' => 'required control-label col-lg-2'))->setAttribute('id', 'site_name')->setAttribute('class', 'form-control');
     $generalFieldset->add($name);
     $this->getInputFilter()->add(array('name' => 'site_name', 'required' => true, 'validators' => array(array('name' => 'not_empty'))), 'site_name');
     $isOffline = new Element\Checkbox('site_is_offline');
     $isOffline->setLabel('Is offline')->setLabelAttributes(array('class' => 'required control-label col-lg-2'))->setAttribute('class', 'input-checkbox')->setAttribute('id', 'site-offiline')->setCheckedValue('1');
     $generalFieldset->add($isOffline);
     $this->getInputFilter()->add(array('name' => 'site_is_offline', 'required' => false), 'site_is_offline');
     $documentCollection = new Document\Collection();
     $documentCollection->load(0);
     $offlineDocument = new Element\Select('site_offline_document');
     $offlineDocument->setLabel('Offline document')->setLabelAttributes(array('class' => 'required control-label col-lg-2'))->setAttribute('class', 'form-control')->setAttribute('id', 'site_offline_document')->setValueOptions(array('Select document') + $documentCollection->getSelect());
     $generalFieldset->add($offlineDocument);
     $this->getInputFilter()->add(array('name' => 'site_offline_document', 'required' => true), 'site_offline_document');
     $layoutCollection = new Layout\Collection();
     $layoutNotFound = new Element\Select('site_404_layout');
     $layoutNotFound->setLabel('404 layout')->setLabelAttributes(array('class' => 'required control-label col-lg-2'))->setAttribute('class', 'form-control')->setAttribute('id', 'site_404_layout')->setValueOptions(array('Select document') + $layoutCollection->getSelect());
     $generalFieldset->add($layoutNotFound);
     $this->getInputFilter()->add(array('name' => 'site_404_layout', 'required' => true), 'site_404_layout');
     $layoutException = new Element\Select('site_exception_layout');
     $layoutException->setLabel('Exception layout')->setLabelAttributes(array('class' => 'required control-label col-lg-2'))->setAttribute('class', 'form-control')->setAttribute('id', 'site_exception_layout')->setValueOptions(array('Select document') + $layoutCollection->getSelect());
     $generalFieldset->add($layoutException);
     $this->getInputFilter()->add(array('name' => 'site_exception_layout', 'required' => true), 'site_exception_layout');
     $this->add($generalFieldset);
     return $this;
 }
Ejemplo n.º 2
0
 /**
  * Send a file to the browser
  *
  * @return \Zend\Stdlib\ResponseInterface
  */
 public function downloadAction()
 {
     $layoutId = $this->getRouteMatch()->getParam('id', null);
     if (!empty($layoutId)) {
         $layout = Layout\Model::fromId($layoutId);
         if (empty($layout)) {
             $this->flashMessenger()->addErrorMessage('This layout can not be download');
             return $this->redirect()->toRoute('development/layout/edit', array('id' => $layoutId));
         }
         $content = $layout->getContent();
         $filename = $layout->getIdentifier() . '.phtml';
     } else {
         $layouts = new Layout\Collection();
         $children = $layouts->getLayouts();
         $zip = new ZipArchive();
         $tmpFilename = tempnam(sys_get_temp_dir(), 'zip');
         $res = $zip->open($tmpFilename, ZipArchive::CREATE);
         if ($res === true) {
             foreach ($children as $child) {
                 $zip->addFromString($child->getIdentifier() . '.phtml', $child->getContent());
             }
             $zip->close();
             $content = file_get_contents($tmpFilename);
             $filename = 'layout.zip';
             unlink($tmpFilename);
         }
     }
     if (empty($content) or empty($filename)) {
         $this->flashMessenger()->addErrorMessage('Can not save layouts');
         return $this->redirect()->toRoute('development/layout');
     }
     $headers = new Headers();
     $headers->addHeaderLine('Pragma', 'public')->addHeaderLine('Cache-control', 'must-revalidate, post-check=0, pre-check=0')->addHeaderLine('Cache-control', 'private')->addHeaderLine('Expires', -1)->addHeaderLine('Content-Type', 'application/octet-stream')->addHeaderLine('Content-Transfer-Encoding', 'binary')->addHeaderLine('Content-Length', strlen($content))->addHeaderLine('Content-Disposition', 'attachment; filename=' . $filename);
     $response = $this->getResponse();
     $response->setHeaders($headers);
     $response->setContent($content);
     return $response;
 }
Ejemplo n.º 3
0
 /**
  * Load document form from DocumentModel
  *
  * @param DocumentModel $document Document model
  * @param array         $config   Configuration
  *
  * @return void
  */
 public function load(DocumentModel $document, array $config)
 {
     $this->get('document-name')->setValue($document->getName());
     $this->get('document-url_key')->setValue($document->getUrlKey());
     $status = new Element\Checkbox('document-status');
     $status->setLabel('Publish')->setValue($document->isPublished())->setAttribute('id', 'status')->setAttribute('class', 'input-checkbox')->setCheckedValue((string) DocumentModel::STATUS_ENABLE);
     $this->add($status);
     $showInNav = new Element\Checkbox('document-show_in_nav');
     $showInNav->setLabel('Show in nav')->setValue($document->showInNav())->setAttribute('id', 'show_in_nav')->setAttribute('class', 'input-checkbox')->setCheckedValue((string) DocumentModel::STATUS_ENABLE);
     $this->add($showInNav);
     $canBeCached = new Element\Checkbox('document-can_be_cached');
     $canBeCached->setLabel('Can be cached')->setValue($document->canBeCached())->setAttribute('id', 'can_be_cached')->setAttribute('class', 'input-checkbox')->setCheckedValue((string) DocumentModel::STATUS_ENABLE);
     $this->add($canBeCached);
     array_unshift($config['locales'], '-- Use parent configuration');
     $locale = new Element\Select('document-locale');
     $locale->setLabel('Locale')->setValueOptions($config['locales'])->setValue($document->getLocale())->setAttribute('id', 'locale')->setAttribute('class', 'form-control');
     $this->add($locale);
     $documentType = $document->getDocumentType();
     $viewsCollection = $documentType->getAvailableViews();
     $select = $viewsCollection->getSelect();
     $viewSelected = $document->getViewId();
     $viewModel = View\Model::fromId($document->getDocumentType()->getDefaultViewId());
     if (!empty($viewModel)) {
         $select = $select + array($viewModel->getId() => $viewModel->getName());
         if (empty($viewSelected)) {
             $viewSelected = $viewModel->getId();
         }
     }
     $view = new Element\Select('document-view');
     $view->setValueOptions($select)->setValue((string) $viewSelected)->setAttribute('id', 'view')->setAttribute('class', 'form-control')->setLabel('View');
     $inputFilterFactory = $this->getInputFilter();
     $inputFilterFactory->add(array('name' => 'document-view', 'required' => true, 'validators' => array(array('name' => 'not_empty'))), 'document-view');
     $this->add($view);
     $layoutsCollection = new Layout\Collection();
     $layout = new Element\Select('document-layout');
     $layout->setValueOptions($layoutsCollection->getSelect())->setValue((string) $document->getLayoutId())->setAttribute('id', 'layout')->setAttribute('class', 'form-control')->setLabel('Layout');
     $inputFilterFactory->add(array('name' => 'document-layout', 'required' => true, 'validators' => array(array('name' => 'not_empty'))), 'document-layout');
     $this->add($layout);
     $this->remove('document_type');
     $this->remove('parent');
     $moreInformation = new Element\Hidden('more_information');
     $moreInformation->setAttribute('content', '');
     $this->add($moreInformation);
     $this->parentId = $document->getParentId();
     $this->documentId = $document->getId();
     $this->loadValues($document);
 }
Ejemplo n.º 4
0
<?php

use Gc\Layout;
use Gc\Script;
use Gc\View;
echo 'Rename configuration file...' . PHP_EOL;
rename(GC_APPLICATION_PATH . '/config/autoload/global.php', GC_APPLICATION_PATH . '/config/autoload/local.php');
echo 'Update layouts...' . PHP_EOL;
$collection = new Layout\Collection();
foreach ($collection->getLayouts() as $layout) {
    $layout->save();
}
echo 'Done';
echo 'Update scripts...' . PHP_EOL;
$collection = new Script\Collection();
foreach ($collection->getScripts() as $script) {
    $script->save();
}
echo 'Done';
echo 'Update views...' . PHP_EOL;
$collection = new View\Collection();
foreach ($collection->getViews() as $view) {
    $view->save();
}
echo 'Done' . PHP_EOL;