Exemple #1
0
 protected function _initFields()
 {
     parent::_initFields();
     $this->setCreateMissingRow(true);
     if (!$this->getClass()) {
         return;
     }
     $generators = Kwc_Abstract::getSetting($this->getClass(), 'generators');
     $classes = $generators['child']['component'];
     foreach ($classes as $key => $class) {
         if (!$class) {
             continue;
         }
         $form = Kwc_Abstract_Form::createChildComponentForm($this->getClass(), "-{$key}", $key);
         if ($form && count($form->fields)) {
             if ($this->_getIdTemplateForChild($key)) {
                 $form->setIdTemplate($this->_getIdTemplateForChild($key));
             }
             if (!$this->_createFieldsets || !Kwc_Abstract::hasSetting($class, 'componentName')) {
                 $this->add($form);
             } else {
                 $name = Kwf_Trl::getInstance()->trlStaticExecute(Kwc_Abstract::getSetting($class, 'componentName'));
                 $name = str_replace('.', ' ', $name);
                 $this->add(new Kwf_Form_Container_FieldSet($name))->setName($key)->add($form);
             }
         }
     }
 }
 public static function getChainedSettings($settings, $masterComponentClass, $prefix = 'Cc', $copySettings = array(), $copyFlags = array())
 {
     $ret = $settings;
     if (!$masterComponentClass) {
         throw new Kwf_Exception("This component requires a parameter");
     }
     $ret['masterComponentClass'] = $masterComponentClass;
     $ret['alternativeComponents'] = array();
     if (Kwc_Abstract::getFlag($masterComponentClass, 'hasAlternativeComponent')) {
         $masterCCCls = strpos($masterComponentClass, '.') ? substr($masterComponentClass, 0, strpos($masterComponentClass, '.')) : $masterComponentClass;
         $alternativeComponents = call_user_func(array($masterCCCls, 'getAlternativeComponents'), $masterComponentClass);
         foreach ($alternativeComponents as $acKey => $alternativeComponent) {
             $ret['alternativeComponents'][$acKey] = self::getChainedComponentClass($alternativeComponent, $prefix);
         }
     }
     $ret['generators'] = Kwc_Abstract::getSetting($masterComponentClass, 'generators');
     foreach ($ret['generators'] as $k => $g) {
         $ret['generators'][$k] = self::createChainedGenerator($masterComponentClass, $k, $prefix);
     }
     foreach ($copySettings as $i) {
         if (Kwc_Abstract::hasSetting($masterComponentClass, $i)) {
             $ret[$i] = Kwc_Abstract::getSetting($masterComponentClass, $i);
         }
     }
     foreach ($copyFlags as $f) {
         $flags = Kwc_Abstract::getSetting($masterComponentClass, 'flags', false);
         if (isset($flags[$f])) {
             $ret['flags'][$f] = $flags[$f];
         }
     }
     return $ret;
 }
 public static function getLanguages()
 {
     $config = Zend_Registry::get('config');
     $langs = array();
     if ($config->webCodeLanguage) {
         $langs[] = $config->webCodeLanguage;
     }
     $possibleUserLanguages = array();
     if ($config->languages) {
         foreach ($config->languages as $lang => $name) {
             $possibleUserLanguages[] = $lang;
         }
     }
     $userModel = Kwf_Registry::get('userModel');
     if (isset($userModel->getAuthedUser()->language) && $userModel->getAuthedUser()->language && in_array($userModel->getAuthedUser()->language, $possibleUserLanguages)) {
         $langs[] = $userModel->getAuthedUser()->language;
     }
     if (Kwf_Component_Data_Root::getComponentClass()) {
         $lngClasses = array();
         foreach (Kwc_Abstract::getComponentClasses() as $c) {
             if (Kwc_Abstract::hasSetting($c, 'baseProperties') && in_array('language', Kwc_Abstract::getSetting($c, 'baseProperties'))) {
                 $lngClasses[] = $c;
             }
         }
         $lngs = Kwf_Component_Data_Root::getInstance()->getComponentsBySameClass($lngClasses, array('ignoreVisible' => true));
         foreach ($lngs as $c) {
             if (Kwf_Registry::get('acl')->getComponentAcl()->isAllowed($userModel->getAuthedUser(), $c)) {
                 $langs[] = $c->getLanguage();
             }
         }
     }
     return array_unique($langs);
 }
 public function componentWithMaster(array $componentWithMaster)
 {
     $last = array_pop($componentWithMaster);
     $component = $last['data'];
     if ($last['type'] == 'master') {
         $innerComponent = $componentWithMaster[0]['data'];
         $vars = $component->getComponent()->getMasterTemplateVars($innerComponent, $this->_getRenderer());
         $vars['componentWithMaster'] = $componentWithMaster;
         if (Kwc_Abstract::hasSetting($component->componentClass, 'masterTemplate')) {
             $masterTemplate = Kwc_Abstract::getSetting($component->componentClass, 'masterTemplate');
         } else {
             $masterTemplate = $this->_getRenderer()->getTemplate($component, 'Master');
         }
         if (substr($masterTemplate, -4) == '.tpl') {
             $view = new Kwf_Component_View($this->_getRenderer());
             $view->assign($vars);
             $ret = $view->render($masterTemplate);
         } else {
             $twig = new Kwf_Component_Renderer_Twig_Environment($this->_getRenderer());
             $ret = $twig->render($masterTemplate, $vars);
         }
         $ret = $this->_replaceKwfUp($ret);
         return $ret;
     } else {
         if ($last['type'] == 'component') {
             $helper = new Kwf_Component_View_Helper_Component();
             $helper->setRenderer($this->_getRenderer());
             return '<div class="kwfMainContent">' . "\n    " . $helper->component($component) . "\n" . '</div>' . "\n";
         } else {
             throw new Kwf_Exception("invalid type");
         }
     }
 }
 public static function validateSettings($settings, $componentClass)
 {
     parent::validateSettings($settings, $componentClass);
     if (Kwc_Abstract::hasSetting($componentClass, 'dimensions')) {
         throw new Kwf_Exception("Setting 'dimensions' must NOT exist");
     }
 }
 public function __construct($resourceId, $menuConfig = null, $menuUrl = null, Kwf_Component_Data $component = null)
 {
     if ($resourceId instanceof Kwf_Component_Data) {
         $component = $resourceId;
         $resourceId = 'kwc_' . $component->dbId;
     } else {
         if (!$component) {
             throw new Kwf_Exception("component parameter is required");
         }
     }
     $this->_component = $component;
     if (!$menuConfig) {
         if (Kwc_Abstract::hasSetting($this->_class, 'componentNameShort')) {
             $name = Kwc_Abstract::getSetting($this->_class, 'componentNameShort');
         } else {
             $name = Kwc_Abstract::getSetting($this->_class, 'componentName');
         }
         $icon = Kwc_Abstract::getSetting($component->componentClass, 'componentIcon');
         $menuConfig = array('text' => trlKwfStatic('Edit {0}', $name), 'icon' => $icon);
     }
     if (!$menuUrl) {
         $menuUrl = Kwc_Admin::getInstance($component->componentClass)->getControllerUrl() . '?componentId=' . $component->dbId;
     }
     parent::__construct($resourceId, $menuConfig, $menuUrl);
 }
 public final function callModifyItemData(Kwf_Component_Data $item)
 {
     foreach (Kwc_Abstract::getChildComponentClasses($this->getData()->componentClass) as $c) {
         if (Kwc_Abstract::hasSetting($c, 'hasModifyItemData') && Kwc_Abstract::getSetting($c, 'hasModifyItemData')) {
             call_user_func(array(strpos($c, '.') ? substr($c, 0, strpos($c, '.')) : $c, 'modifyItemData'), $item, $c);
         }
     }
 }
 protected function _getConfig()
 {
     $componentList = array();
     $componentIcons = array();
     $categories = Kwc_Abstract::getSetting($this->_class, 'categories');
     foreach ($categories as $k => $i) {
         $categories[$k] = Kwf_Registry::get('trl')->trlStaticExecute($i);
         $componentList[$categories[$k] . '>>'] = array();
     }
     $components = $this->_getComponents();
     uasort($components, array('Kwc_Paragraphs_ExtConfig', '_sortByPriority'));
     foreach ($components as $component) {
         if (!Kwc_Abstract::hasSetting($component, 'componentName')) {
             continue;
         }
         $name = Kwc_Abstract::getSetting($component, 'componentName');
         $name = Kwf_Registry::get('trl')->trlStaticExecute($name);
         $icon = Kwc_Abstract::getSetting($component, 'componentIcon');
         if ($icon) {
             $icon = new Kwf_Asset($icon);
             $icon = $icon->__toString();
         }
         if ($name) {
             $cat = null;
             if (Kwc_Abstract::hasSetting($component, 'componentCategory')) {
                 $cat = Kwc_Abstract::getSetting($component, 'componentCategory');
                 if (isset($categories[$cat])) {
                     $cat = $categories[$cat];
                 }
             }
             if (!$cat) {
                 $cat = 'none';
             }
             if (substr($name, 0, strlen($cat) + 1) != $cat . '.') {
                 $name = $cat . '.' . $name;
             }
             $this->_componentNameToArray($name, $component, $componentList);
             $componentIcons[$component] = $icon;
         }
     }
     //move content and none to top level
     $componentList = array_merge($componentList['content>>'], $componentList['none>>'], $componentList);
     unset($componentList['content>>']);
     unset($componentList['none>>']);
     //remove empty categories
     foreach ($componentList as $k => $i) {
         if (!$i) {
             unset($componentList[$k]);
         }
     }
     $config = $this->_getStandardConfig('kwc.paragraphs');
     $config['showDeviceVisible'] = Kwc_Abstract::getSetting($this->_class, 'useMobileBreakpoints');
     $config['components'] = $componentList;
     $config['componentIcons'] = $componentIcons;
     $config['needsComponentPanel'] = true;
     return array('paragraphs' => $config);
 }
 protected function _getOptions()
 {
     $ret = array();
     if (Kwc_Abstract::hasSetting($this->_data->componentClass, 'lightboxOptions')) {
         $ret = Kwc_Abstract::getSetting($this->_data->componentClass, 'lightboxOptions');
     }
     $ret['width'] = $this->_data->getComponent()->getContentWidth();
     return $ret;
 }
 public function getSelect()
 {
     $class = $this->getData()->parent->parent->componentClass;
     $childReference = Kwc_Abstract::hasSetting($class, 'childReferenceName') ? Kwc_Abstract::getSetting($class, 'childReferenceName') : 'Categories';
     $select = parent::getSelect();
     $s = new Kwf_Model_Select();
     $s->whereEquals('category_id', $this->getData()->parent->id);
     $select->where(new Kwf_Model_Select_Expr_Child_Contains($childReference, $s));
     return $select;
 }
 /**
  * @internal
  */
 public static function _buildAll($componentClasses)
 {
     foreach ($componentClasses as $cmp) {
         if (Kwc_Abstract::hasSetting($cmp, 'layoutClass')) {
             self::$_supportedContexts[$cmp] = self::getInstance($cmp)->calcSupportedContexts();
             self::$_supportedChildContexts[$cmp] = self::getInstance($cmp)->calcSupportedChildContexts();
         }
     }
     $data = array('contexts' => self::$_supportedContexts, 'childContexts' => self::$_supportedChildContexts);
     file_put_contents('build/component/layoutcontexts', serialize($data));
 }
 /**
  * Returns all udpate tags used by this webs. They are usually set in config.ini
  **/
 public static function getUpdateTags()
 {
     if (!isset(self::$_updateTagsCache)) {
         self::$_updateTagsCache = Kwf_Registry::get('config')->server->updateTags->toArray();
         foreach (Kwf_Component_Abstract::getComponentClasses() as $class) {
             if (Kwc_Abstract::hasSetting($class, 'updateTags')) {
                 self::$_updateTagsCache = array_unique(array_merge(self::$_updateTagsCache, Kwc_Abstract::getSetting($class, 'updateTags')));
             }
         }
     }
     return self::$_updateTagsCache;
 }
 protected function _getRow($componentId)
 {
     if (!Kwc_Abstract::hasSetting($this->_class, 'tablename')) {
         return null;
     }
     $tablename = Kwc_Abstract::getSetting($this->_class, 'tablename');
     if ($tablename) {
         $table = new $tablename(array('componentClass' => $this->_class));
         return $table->find($componentId)->current();
     }
     return null;
 }
 /**
  * Set default vCard settings here or in Team_Component
  */
 protected function _getDefaultValues()
 {
     $teamComponent = $this->_data->chained->parent->parent->parent;
     if (Kwc_Abstract::hasSetting($teamComponent->componentClass, 'defaultVcardValues')) {
         $setting = Kwc_Abstract::getSetting($teamComponent->componentClass, 'defaultVcardValues');
     }
     if (isset($setting)) {
         return $setting;
     } else {
         return Kwc_Abstract::getSetting($this->_data->chained->componentClass, 'defaultVcardValues');
     }
 }
 public function getTemplate(Kwf_Component_Data $component, $type)
 {
     if ($type == 'Master') {
         if (Kwc_Abstract::hasSetting($component->componentClass, 'masterTemplate')) {
             return Kwc_Abstract::getSetting($component->componentClass, 'masterTemplate');
         }
     }
     $template = Kwc_Abstract::getTemplateFile($component->componentClass, $type);
     if (!$template) {
         throw new Kwf_Exception("No {$type}-Template found for '{$component->componentClass}'");
     }
     return $template;
 }
 public function delete($componentId)
 {
     parent::delete($componentId);
     $classes = Kwc_Abstract::getChildComponentClasses($this->_class, 'child');
     if (Kwc_Abstract::hasSetting($this->_class, 'tablename')) {
         //wenn komponente kein model hat unterkomponenten hier löschen
         //ansonsten erledigt das die row
         foreach ($classes as $k => $i) {
             Kwc_Admin::getInstance($i)->delete($componentId . '-' . $k);
         }
     }
     $where = array();
 }
 public static function getComponentsWithMasterTemplate($component)
 {
     $ret = array();
     $ret[] = array('type' => 'component', 'data' => $component);
     while ($component) {
         if (Kwc_Abstract::getTemplateFile($component->componentClass, 'Master') || Kwc_Abstract::hasSetting($component->componentClass, 'masterTemplate')) {
             $ret[] = array('type' => 'master', 'data' => $component);
         }
         if (Kwc_Abstract::getFlag($component->componentClass, 'resetMaster')) {
             break;
         }
         $component = $component->parent;
     }
     return $ret;
 }
 public function addResources(Kwf_Acl $acl)
 {
     $masterCls = $this->_getSetting('masterComponentClass');
     if (Kwc_Abstract::hasSetting($this->_class, 'componentNameShort')) {
         $name = Kwc_Abstract::getSetting($this->_class, 'componentNameShort');
     } else {
         $name = Kwc_Abstract::getSetting($this->_class, 'componentName');
     }
     $icon = Kwc_Abstract::getSetting($this->_class, 'componentIcon');
     // **** create dropdown
     $dropdownName = 'kwc_' . $masterCls;
     if (!$acl->has($dropdownName)) {
         $acl->addResource(new Kwf_Acl_Resource_MenuDropdown($dropdownName, array('text' => $name, 'icon' => $icon)), $this->_getParentResource($acl));
     }
     // **** modify master component
     $masterComponents = Kwf_Component_Data_Root::getInstance()->getComponentsBySameClass($masterCls, array('ignoreVisible' => true));
     //add language name to menu text
     foreach ($masterComponents as $c) {
         $resource = $acl->get('kwc_' . $c->dbId);
         $mc = $resource->getMenuConfig();
         $mc['text'] .= ' (' . $c->getBaseProperty('language') . ')';
         $resource->setMenuConfig($mc);
     }
     if (count($masterComponents) > 1) {
         //already in dropdown
     } else {
         if (count($masterComponents) == 1) {
             //just one, move into dropdown
             $c = $masterComponents[0];
             $resource = $acl->get('kwc_' . $c->dbId);
             $acl->remove($resource);
             $acl->addResource($resource, $dropdownName);
         }
     }
     // *** add own
     $components = Kwf_Component_Data_Root::getInstance()->getComponentsBySameClass($this->_class, array('ignoreVisible' => true));
     foreach ($components as $c) {
         $t = $c->getTitle();
         if (!$t) {
             $t = $name;
         }
         if ($domain = $c->getParentByClass('Kwc_Root_DomainRoot_Domain_Component')) {
             $t .= " ({$domain->name})";
         }
         $t .= ' (' . $c->getBaseProperty('language') . ')';
         $acl->add(new Kwf_Acl_Resource_Component_MenuUrl($c, array('text' => $t, 'icon' => $icon)), $dropdownName);
     }
 }
 public static final function getPartialClass($componentClass)
 {
     if (Kwc_Abstract::hasSetting($componentClass, 'partialClass')) {
         return Kwc_Abstract::getSetting($componentClass, 'partialClass');
     }
     $generators = Kwc_Abstract::getSetting($componentClass, 'generators');
     if (isset($generators['child']['component']['searchForm'])) {
         return 'Kwf_Component_Partial_Id';
     } else {
         if (isset($generators['child']['component']['paging']) && $generators['child']['component']['paging']) {
             return 'Kwf_Component_Partial_Paging';
         } else {
             return 'Kwf_Component_Partial_Stateless';
         }
     }
 }
 protected function _getOptions()
 {
     $options = array();
     if (Kwc_Abstract::hasSetting($this->_data->componentClass, 'lightboxOptions')) {
         $options = Kwc_Abstract::getSetting($this->_data->componentClass, 'lightboxOptions');
     }
     $dim = $this->_data->parent->getComponent()->getImageDimensions();
     $options['width'] = $dim['width'];
     $options['height'] = $dim['height'];
     if (!isset($options['style'])) {
         $options['style'] = 'CenterBox';
     }
     //default style
     $options['adaptHeight'] = true;
     return $options;
 }
 public function preDispatch()
 {
     if (!isset($this->_table) && !isset($this->_tableName)) {
         if (Kwc_Abstract::hasSetting($this->_getParam('class'), 'tablename')) {
             $tablename = Kwc_Abstract::getSetting($this->_getParam('class'), 'tablename');
             $this->_table = new $tablename(array('componentClass' => $this->_getParam('class')));
         } else {
             if (Kwc_Abstract::hasSetting($this->_getParam('class'), 'childModel')) {
                 $childModelName = Kwc_Abstract::getSetting($this->_getParam('class'), 'childModel');
                 $this->_model = new $childModelName(array('componentClass' => $this->_getParam('class')));
             } else {
                 throw new Kwf_Exception('No tablename in Setting defined: ' . $class);
             }
         }
     }
     parent::preDispatch();
 }
Exemple #22
0
 public function getListeners()
 {
     $ret = parent::getListeners();
     foreach (Kwc_Abstract::getComponentClasses() as $class) {
         if (is_instance_of($class, 'Kwc_Directories_Category_Directory_Component') && $this->_canCreateUsIndirectly($class)) {
             $childReference = Kwc_Abstract::hasSetting($class, 'childReferenceName') ? Kwc_Abstract::getSetting($class, 'childReferenceName') : 'Categories';
             foreach (call_user_func(array($this->_class, 'getItemDirectoryClasses'), $this->_class) as $dirCls) {
                 $dirModel = Kwc_Abstract::createChildModel($dirCls);
                 $relModel = $dirModel->getDependentModel($childReference);
                 $ret[] = array('class' => $relModel, 'event' => 'Kwf_Events_Event_Row_Updated', 'callback' => 'onUpdateRow');
                 $ret[] = array('class' => $relModel, 'event' => 'Kwf_Events_Event_Row_Inserted', 'callback' => 'onUpdateRow');
                 $ret[] = array('class' => $relModel, 'event' => 'Kwf_Events_Event_Row_Deleted', 'callback' => 'onUpdateRow');
             }
         }
     }
     return $ret;
 }
 public function jsonDataAction()
 {
     $showLogout = true;
     $acl = $this->_getAcl();
     $menus = $acl->getMenuConfig($this->_getAuthData());
     if (empty($menus) && $this->_getUserRole() == 'guest') {
         $menu = array();
         $menu['type'] = 'commandDialog';
         $menu['menuConfig']['text'] = trlKwf('Login');
         $menu['commandClass'] = 'Kwf.User.Login.Dialog';
         $menus[] = $menu;
         $showLogout = false;
     }
     $model = Kwf_Registry::get('userModel')->getEditModel();
     if ($this->_getAuthData() && $model->getRowByKwfUser($this->_getAuthData())) {
         foreach ($acl->getAllResources() as $resource) {
             if ($resource instanceof Kwf_Acl_Resource_UserSelf && $acl->isAllowedUser($this->_getAuthData(), $resource, 'view')) {
                 $this->view->userSelfControllerUrl = $resource->getControllerUrl();
                 break;
             }
         }
     }
     $authData = $this->_getAuthData();
     $this->view->menus = $menus;
     $this->view->showLogout = $showLogout;
     $this->view->userId = $authData ? $authData->id : null;
     $this->view->fullname = $authData ? $authData->__toString() : '';
     $role = Zend_Registry::get('userModel')->getAuthedChangedUserRole();
     $this->view->changeUser = $acl->isAllowed($role, 'kwf_user_changeuser', 'view');
     $this->view->frontendUrls = array();
     if (Kwf_Registry::get('acl')->has('kwf_component_pages')) {
         foreach (Kwc_Abstract::getComponentClasses() as $c) {
             if (Kwc_Abstract::hasSetting($c, 'baseProperties') && in_array('domain', Kwc_Abstract::getSetting($c, 'baseProperties'))) {
                 $domains = Kwf_Component_Data_Root::getInstance()->getComponentsBySameClass($c, array('ignoreVisible' => true));
                 foreach ($domains as $domain) {
                     if ($acl->getComponentAcl()->isAllowed($authData, $domain)) {
                         $this->view->frontendUrls[] = array('href' => Kwf_Setup::getBaseUrl() . '/admin/component/preview?url=' . urlencode($domain->getAbsoluteUrl(true)), 'text' => $domain->name);
                     }
                 }
             }
         }
         if (!$this->view->frontendUrls) {
             $this->view->frontendUrls[] = array('href' => Kwf_Setup::getBaseUrl() . '/admin/component/preview', 'text' => trlKwf('Frontend'));
         }
     }
 }
 public function getTemplateVars(Kwf_Component_Renderer_Abstract $renderer)
 {
     $ret = parent::getTemplateVars($renderer);
     $ret['categories'] = array();
     $itemDirectory = $this->_getItemDirectory();
     if ($itemDirectory) {
         $classes = Kwc_Abstract::getChildComponentClasses($itemDirectory->componentClass);
         foreach ($classes as $c) {
             if (Kwc_Abstract::hasSetting($c, 'categoryName')) {
                 $name = Kwc_Abstract::getSetting($c, 'categoryName');
                 $parent = $itemDirectory->getChildComponent(array('componentClass' => $c));
                 if ($parent) {
                     $ret['categories'][$name] = $this->_getMenuData($parent);
                 }
             }
         }
     }
     return $ret;
 }
 public final function onOwnRowUpdate(Kwf_Events_Event_Row_Abstract $event)
 {
     $cmps = Kwf_Component_Data_Root::getInstance()->getComponentsByDbId($event->row->component_id, array('ignoreVisible' => true));
     foreach ($cmps as $c) {
         if ($c->componentClass == $this->_class) {
             if ($c->isVisible()) {
                 $this->fireEvent(new Kwf_Component_Event_Component_ContentChanged($this->_class, $c));
                 if (Kwc_Abstract::hasSetting($this->_class, 'throwHasContentChangedOnRowColumnsUpdate')) {
                     if ($event->isDirty(Kwc_Abstract::getSetting($this->_class, 'throwHasContentChangedOnRowColumnsUpdate'))) {
                         $this->fireEvent(new Kwf_Component_Event_Component_HasContentChanged($this->_class, $c));
                     }
                 }
                 $this->_onOwnRowUpdate($c, $event);
                 $this->_onOwnRowUpdateNotVisible($c, $event);
             } else {
                 $this->_onOwnRowUpdateNotVisible($c, $event);
             }
         }
     }
 }
 public static function getDomains()
 {
     if (!Kwf_Component_Data_Root::getComponentClass()) {
         return null;
     }
     $domainComponentClasses = array();
     foreach (Kwc_Abstract::getComponentClasses() as $c) {
         if (Kwc_Abstract::hasSetting($c, 'baseProperties') && in_array('domain', Kwc_Abstract::getSetting($c, 'baseProperties'))) {
             $domainComponentClasses[] = $c;
         }
     }
     $domains = array();
     foreach (Kwf_Component_Data_Root::getInstance()->getComponentsBySameClass($domainComponentClasses, array('ignoreVisible' => true)) as $c) {
         $acl = Zend_Registry::get('acl');
         if ($acl->getComponentAcl()->isAllowed(Kwf_Registry::get('userModel')->getAuthedUser(), $c)) {
             $domains[$c->dbId] = $c->name;
         }
     }
     return $domains;
 }
Exemple #27
0
 private static function _getSubscribersFromComponent($componentClass)
 {
     $subscribers = array();
     $eventsClass = Kwc_Admin::getComponentClass($componentClass, 'Events');
     $subscribers[] = Kwf_Component_Abstract_Events::getInstance($eventsClass, array('componentClass' => $componentClass));
     foreach (Kwc_Abstract::getSetting($componentClass, 'generators') as $generatorKey => $null) {
         $generator = current(Kwf_Component_Generator_Abstract::getInstances($componentClass, array('generator' => $generatorKey)));
         $eventsClass = $generator->getEventsClass();
         if ($eventsClass) {
             $subscribers[] = Kwf_Component_Generator_Events::getInstance($eventsClass, array('componentClass' => $componentClass, 'generatorKey' => $generatorKey));
         }
     }
     if (Kwc_Abstract::hasSetting($componentClass, 'menuConfig')) {
         $mc = Kwf_Component_Abstract_MenuConfig_Abstract::getInstance($componentClass);
         $eventsClass = $mc->getEventsClass();
         if ($eventsClass) {
             $subscribers[] = Kwf_Component_Abstract_MenuConfig_Events::getInstance($eventsClass, array('componentClass' => $componentClass));
         }
     }
     return $subscribers;
 }
 public function addResources(Kwf_Acl $acl)
 {
     $components = Kwf_Component_Data_Root::getInstance()->getComponentsBySameClass($this->_class, array('ignoreVisible' => true));
     if (Kwc_Abstract::hasSetting($this->_class, 'componentNameShort')) {
         $name = Kwc_Abstract::getSetting($this->_class, 'componentNameShort');
     } else {
         $name = Kwc_Abstract::getSetting($this->_class, 'componentName');
     }
     $icon = Kwc_Abstract::getSetting($this->_class, 'componentIcon');
     foreach ($components as $c) {
         $t = $c->getTitle();
         if (!$t && $c->getPage()) {
             $t = $c->getPage()->name;
         }
         if ($domain = $c->getParentByClass('Kwc_Root_DomainRoot_Domain_Component')) {
             $t .= " - {$domain->name}";
         }
         $t = $name . ' (' . $t . ')';
         $menuUrl = Kwc_Admin::getInstance($c->componentClass)->getControllerUrl('Enquiries') . '?componentId=' . $c->dbId;
         $acl->addResource(new Kwf_Acl_Resource_Component_MenuUrl($c, array('text' => $t, 'icon' => $icon), $menuUrl), 'kwf_enquiries_dropdown');
     }
 }
 public static function modifyItemData(Kwf_Component_Data $item, $componentClass)
 {
     if (!Kwc_Abstract::hasSetting($componentClass, 'categoryToItemModelName') && Kwc_Abstract::hasSetting($componentClass, 'categoryToItemTableName')) {
         // setting has changed
         throw new Kwf_Exception("Setting 'categoryToItemTableName' has been renamed to 'categoryToItemModelName' and must be a Kwf_Model");
     }
     if (!($model = Kwc_Abstract::getSetting($componentClass, 'categoryToItemModelName'))) {
         throw new Kwf_Exception("Setting 'categoryToItemModelName' must be set in component '{$componentClass}'");
     }
     // getting the intersection rows
     $model = Kwf_Model_Abstract::getInstance($model);
     $itemRef = $model->getReference('Item');
     $catRef = $model->getReference('Category');
     $rows = $model->getRows($model->select()->whereEquals($itemRef['column'], $item->row->id));
     $item->categories = array();
     foreach ($rows as $row) {
         $cat = $item->parent->getChildComponent(array('componentClass' => $componentClass))->getChildComponent('_' . $row->{$catRef['column']});
         if ($cat) {
             $item->categories[] = $cat;
         }
     }
 }
 public function addResources(Kwf_Acl $acl)
 {
     $components = Kwf_Component_Data_Root::getInstance()->getComponentsBySameClass($this->_class, array('ignoreVisible' => true));
     if (Kwc_Abstract::hasSetting($this->_class, 'componentNameShort')) {
         $name = Kwc_Abstract::getSetting($this->_class, 'componentNameShort');
     } else {
         $name = Kwc_Abstract::getSetting($this->_class, 'componentName');
     }
     $icon = Kwc_Abstract::getSetting($this->_class, 'componentIcon');
     if (count($components)) {
         $dropdownName = 'kwc_' . $this->_class;
         if (!$acl->has($dropdownName)) {
             $dropDown = new Kwf_Acl_Resource_MenuDropdown($dropdownName, array('text' => $name, 'icon' => $icon));
             $dropDown->setCollapseIfSingleChild(true);
             $acl->add($dropDown, $this->_getParentResource($acl));
         }
         foreach ($components as $c) {
             $t = $this->_getResourceText($c);
             $acl->add(new Kwf_Acl_Resource_Component_MenuUrl($c, array('text' => $t, 'icon' => $icon)), $dropdownName);
         }
     }
 }