상속: extends Gc\Db\AbstractTable, implements Gc\Component\IterableInterface
예제 #1
0
파일: Documents.php 프로젝트: gotcms/gotcms
 /**
  * Returns documents
  * $data can be mixed
  * if data is an array, return all documents
  * if data is numeric, return all documents with parent_id equal to $data
  * if data is string, return all documents with parent's url key equal to $data
  *
  * @param mixed $data Data
  *
  * @return array \Gc\Document\Model
  */
 public function __invoke($data = null)
 {
     $elements = array();
     $documents = new DocumentCollection();
     if (empty($data)) {
         $elements = $documents->load(0)->getDocuments();
     } else {
         if (is_numeric($data)) {
             $elements = $documents->load($data)->getDocuments();
         } elseif (is_string($data)) {
             $document = DocumentModel::fromUrlKey($data);
             $elements = $document->getChildren();
         } elseif (is_array($data)) {
             foreach ($data as $documentId) {
                 if (empty($documentId)) {
                     continue;
                 }
                 $document = $this->getView()->document($documentId);
                 if (!empty($document)) {
                     $elements[] = $document;
                 }
             }
         }
     }
     return $elements;
 }
예제 #2
0
파일: Config.php 프로젝트: gotcms/gotcms
 /**
  * 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;
 }
예제 #3
0
 /**
  * Constructor, initialize documents
  *
  * @param integer $documentId   Document id
  * @param boolean $activeBranch Use active branch or not
  */
 public function __construct($documentId = 0, $activeBranch = false)
 {
     $documents = new Document\Collection();
     $documents->load($documentId);
     $this->documents = $documents->getDocuments();
     $this->requestUri = Registry::get('Application')->getRequest()->getUri()->getPath();
     $this->useActiveBranch = (bool) $activeBranch;
 }
예제 #4
0
파일: Sitemap.php 프로젝트: gotcms/gotcms
 /**
  * Generate Xml accessor
  *
  * @param Request $request Request
  *
  * @return string
  */
 public function generate(Request $request)
 {
     $collection = new DocumentCollection();
     $documents = array();
     $rows = $collection->getAvailableDocuments();
     foreach ($rows as $row) {
         $documents[] = DocumentModel::fromArray((array) $row);
     }
     return $this->generateXml($documents, $request);
 }
예제 #5
0
 /**
  * Initialize Document Controller
  *
  * @return void
  */
 public function init()
 {
     $documents = new DocumentCollection();
     $documents->load(0);
     $this->layout()->setVariable('treeview', Component\TreeView::render(array($documents)));
     $routes = array('edit' => 'content/document/edit', 'new' => 'content/document/create', 'delete' => 'content/document/delete', 'copy' => 'content/document/copy', 'cut' => 'content/document/cut', 'paste' => 'content/document/paste', 'publish' => 'content/document/publish', 'unpublish' => 'content/document/unpublish', 'refresh' => 'content/document/refresh-treeview');
     $arrayRoutes = array();
     foreach ($routes as $key => $route) {
         $arrayRoutes[$key] = $this->url()->fromRoute($route, array('id' => 'itemId'));
     }
     $this->layout()->setVariable('routes', Json::encode($arrayRoutes));
 }
예제 #6
0
 /**
  * Display dashboard
  *
  * @return array
  */
 public function indexAction()
 {
     $data = array();
     $data['version'] = Version::VERSION;
     $data['versionIsLatest'] = Version::isLatest();
     $data['versionLatest'] = Version::getLatest();
     $documents = new Collection();
     $contentStats = array();
     $contentStats['online_documents'] = array('count' => count($documents->getAvailableDocuments()), 'label' => 'Online documents', 'route' => 'content');
     $contentStats['total_documents'] = array('count' => count($documents->select()->toArray()), 'label' => 'Total documents', 'route' => 'content');
     $data['contentStats'] = $contentStats;
     $visitorModel = new Visitor();
     $data['userStats'] = array('total_visitors' => array('count' => $visitorModel->getTotalVisitors(), 'label' => 'Total visitors', 'route' => 'statistics'), 'total_visits' => array('count' => $visitorModel->getTotalPageViews(), 'label' => 'Total page views', 'route' => 'statistics'));
     $coreConfig = $this->getServiceLocator()->get('CoreConfig');
     $widgets = @unserialize($coreConfig->getValue('dashboard_widgets'));
     $data['dashboardSortable'] = !empty($widgets['sortable']) ? Json::encode($widgets['sortable']) : '{}';
     $data['dashboardWelcome'] = !empty($widgets['welcome']);
     $data['customeWidgets'] = array();
     $this->events()->trigger(__CLASS__, 'dashboard', $this, array('widgets' => &$data['customeWidgets']));
     return $data;
 }
예제 #7
0
파일: TabsTest.php 프로젝트: gotcms/gotcms
 /**
  * Test
  *
  * @return void
  */
 public function testRenderWithIterableInterface()
 {
     $view = ViewModel::fromArray(array('name' => 'View Name', 'identifier' => 'View identifier', 'description' => 'View Description', 'content' => 'View Content'));
     $view->save();
     $layout = LayoutModel::fromArray(array('name' => 'Layout Name', 'identifier' => 'Layout identifier', 'description' => 'Layout Description', 'content' => 'Layout Content'));
     $layout->save();
     $user = UserModel::fromArray(array('lastname' => 'User test', 'firstname' => 'User test', 'email' => '*****@*****.**', 'login' => 'test', 'user_acl_role_id' => 1));
     $user->setPassword('test');
     $user->save();
     $documentType = DocumentTypeModel::fromArray(array('name' => 'Document Type Name', 'description' => 'Document Type description', 'icon_id' => 1, 'defaultview_id' => $view->getId(), 'user_id' => $user->getId()));
     $documentType->save();
     $document = DocumentModel::fromArray(array('name' => 'Document name', 'url_key' => 'url-key', 'status' => DocumentModel::STATUS_ENABLE, 'show_in_nav' => true, 'user_id' => $user->getId(), 'document_type_id' => $documentType->getId(), 'view_id' => $view->getId(), 'layout_id' => $layout->getId(), 'parent_id' => 0));
     $document->save();
     $collection = new DocumentCollection();
     $collection->load(0);
     $this->assertEquals(sprintf('<ul><li><a href="#tabs-%d">Document name</a></li></ul>', $document->getId()), $this->object->render($collection->getChildren()));
     $document->delete();
     $documentType->delete();
     $layout->delete();
     $view->delete();
     $user->delete();
 }
예제 #8
0
 /**
  * Test
  *
  * @return void
  */
 public function testGetEditUrl()
 {
     $this->assertNull($this->object->getEditUrl());
 }
예제 #9
0
 /**
  * Test
  *
  * @return void
  */
 public function testRender()
 {
     Registry::get('Application')->getRequest()->getUri()->setPath($this->documentChildren->getEditUrl());
     $collection = new DocumentCollection();
     $collection->load(0);
     $array = array_merge(array($collection), array('test' => 'value'));
     $this->assertTrue(strlen($this->object->render($array)) > 0);
 }
예제 #10
0
파일: Model.php 프로젝트: gotcms/gotcms
 /** (non-PHPdoc)
  *
  * @see include \Gc\Component\IterableInterface#getChildren()
  * @return array
  */
 public function getChildren()
 {
     if ($this->getData('children') === null) {
         $children = new Collection();
         $children->load($this->getId());
         $this->setData('children', $children->getChildren());
     }
     return $this->getData('children');
 }
예제 #11
0
파일: Content.php 프로젝트: gotcms/gotcms
 /**
  * Load Document data
  *
  * @return string
  */
 public function createDocument()
 {
     $documents = new Document\Collection();
     $rows = $documents->fetchAll($documents->select(function ($select) {
         $select->order('sort_order ASC');
         $select->order('created_at ASC');
     }));
     if (empty($rows)) {
         return '';
     }
     $documentArray = array();
     foreach ($rows as $row) {
         $documentArray[] = Document\Model::fromArray((array) $row);
     }
     $propertiyCollection = new Property\Collection();
     foreach ($documentArray as $document) {
         $array = array();
         $properties = $propertiyCollection->load(null, null, $document->getId())->getProperties();
         foreach ($properties as $property) {
             $value = $property->getValueModel()->getValue();
             $property->getValueModel()->setValue(base64_encode($value));
             $array[] = $property->getValueModel();
         }
         $document->setProperties($array);
     }
     return $documents->toXml($documentArray, 'documents');
 }
예제 #12
0
 /**
  * Refresh treeview
  *
  * @return \Zend\View\Model\ViewModel
  */
 public function refreshTreeviewAction()
 {
     $documentId = $this->getRouteMatch()->getParam('id', 0);
     if (empty($documentId)) {
         $documents = new DocumentCollection();
         $documents->load($documentId);
         $documentsList = $documents->getChildren();
     } else {
         $documents = DocumentModel::fromId($documentId);
         $documentsList = $documents->getChildren();
     }
     return $this->returnJson(array('treeview' => Component\TreeView::render($documentsList, false)));
 }