public function configAction() { $request = $this->getRequest(); $this->view->moduleName = Gio_Core_Widget::getIntance()->getModuleName(); $this->view->widgetName = Gio_Core_Widget::getIntance()->getWidgetName(); $this->view->widgetIndex = $request->getParam('widget_index'); }
/** * @return Gio_Core_Widget */ public static function getIntance() { if (null == self::$_instance) { self::$_instance = new self(); } return self::$_instance; }
/** * @param string $key Key to translate * @param string $module Widget module name (since 2.1.0) * @param string $widgetName Widget name (since 2.1.0) * * @return string */ public function widget($key, $module = null, $widgetName = null, $lang = null) { $lang = $lang ? $lang : self::_getLang(); if ($module == null || $widgetName == null) { $widget = Gio_Core_Widget::getIntance(); /** * Get current widget instance which have been set in * __call() of Tomato_Widget */ if (!$widget->getModuleName() || !$widget->getWidgetName()) { return $key; } /** * If we want to use the file in languages directory * $file = ROOT_DIR . DS . 'languages' . DS . $lang . DS . 'modules' . DS . strtolower($widget->getModule()) . DS . 'widgets' . DS . strtolower($widget->getName()) . DS . 'lang.' . $lang . '.ini'; */ $file = ROOT_DIR . DS . 'modules' . DS . strtolower($widget->getModuleName()) . DS . 'widgets' . DS . strtolower($widget->getWidgetName()) . DS . 'lang.' . $lang . '.ini'; } else { $file = ROOT_DIR . DS . 'modules' . DS . strtolower($module) . DS . 'widgets' . DS . strtolower($widgetName) . DS . 'lang.' . $lang . '.ini'; } if (file_exists($file)) { $iniArray = @parse_ini_file($file); return isset($iniArray[$key]) ? $iniArray[$key] : $key; } return $key; }
public function configAction() { $limit = $this->getParam('limit', 5); $this->view->limit = $limit; $this->view->moduleName = Gio_Core_Widget::getIntance()->getModuleName(); $this->view->widgetName = Gio_Core_Widget::getIntance()->getWidgetName(); $this->view->widgetIndex = $this->getParam('widget_index'); }
public function configAction() { $localeType = $this->getParam('locale_type', 'full'); $this->view->localeType = $localeType; $this->view->moduleName = Gio_Core_Widget::getIntance()->getModuleName(); $this->view->widgetName = Gio_Core_Widget::getIntance()->getWidgetName(); $this->view->widgetIndex = $this->getParam('widget_index'); }
public function configAction() { $pageId = $this->getParam('page_id'); $this->view->pageId = $pageId; $this->view->moduleName = Gio_Core_Widget::getIntance()->getModuleName(); $this->view->widgetName = Gio_Core_Widget::getIntance()->getWidgetName(); $this->view->widgetIndex = $this->getParam('widget_index'); }
public function configAction() { $zones = Modules_Ad_Services_Zone::getAllZones(true); $this->view->zones = $zones; $this->view->zoneId = $this->getParam('zone_id'); $this->view->moduleName = Gio_Core_Widget::getIntance()->getModuleName(); $this->view->widgetName = Gio_Core_Widget::getIntance()->getWidgetName(); $this->view->widgetIndex = $this->getParam('widget_index'); }
public function configAction() { $menuId = $this->getParam('menu_id'); $this->view->menuId = $menuId; $menus = Modules_Menu_Services_Menu::getAllMenus(); $this->view->menus = $menus; $this->view->moduleName = Gio_Core_Widget::getIntance()->getModuleName(); $this->view->widgetName = Gio_Core_Widget::getIntance()->getWidgetName(); $this->view->widgetIndex = $this->getParam('widget_index'); }
public function configAction() { $userId = $this->getParam('user_id'); $this->view->user_id = $userId; $width = $this->getParam('width'); $this->view->width = $width; $align = $this->getParam('align'); $this->view->align = $align; $this->view->moduleName = Gio_Core_Widget::getIntance()->getModuleName(); $this->view->widgetName = Gio_Core_Widget::getIntance()->getWidgetName(); $this->view->widgetIndex = $this->getParam('widget_index'); }
public function configAction() { $limit = $this->getParam('limit', 5); $this->view->limit = $limit; $categoryId = $this->getParam('category_id'); $categories = Modules_Category_Services_Category::getTree(null, 'news'); $this->view->categories = $categories; $this->view->categoryId = $categoryId; $style = $this->getParam('style'); $this->view->style = $style; $this->view->moduleName = Gio_Core_Widget::getIntance()->getModuleName(); $this->view->widgetName = Gio_Core_Widget::getIntance()->getWidgetName(); $this->view->widgetIndex = $this->getParam('widget_index'); }
public function configAction() { $request = $this->getRequest(); $route = $request->getParam('route'); $data = explode('_', $route); $module = null; $controller = null; $action = null; if (count($data) == 3) { $module = $data[0]; $controller = $data[1]; $action = $data[2]; } $this->view->contentModule = $module; $this->view->contentController = $controller; $this->view->contentAction = $action; $this->view->route = $route; $this->view->moduleName = Gio_Core_Widget::getIntance()->getModuleName(); $this->view->widgetName = Gio_Core_Widget::getIntance()->getWidgetName(); $this->view->widgetIndex = $request->getParam('widget_index'); }
public static function load($module, $name, $action, $params = array(), $cacheEnable = false, $cacheTimeout = 0) { $configs = Gio_Core_Config_Xml::getConfig('web'); $widgetContent = Gio_Core_Widget::getIntance()->setTemplate($configs->template)->setModuleName($module)->setWidgetName($name)->setActionName($action)->setCacheEnable($cacheEnable)->setCacheTimeout($cacheTimeout)->setParams($params)->dispatch(); $view = Gio_Core_View::getInstance(); $return = array('title' => '', 'cssFiles' => array(), 'jsFiles' => array(), 'jsScripts' => array(), 'content' => ''); $search = array('{APP_WEB_URL}', '{APP_STATIC_SERVER}', '{WIDGET_URL}'); $replace = array($view->APP_WEB_URL, $view->APP_STATIC_SERVER, $view->APP_STATIC_SERVER . '/modules/' . strtolower($module) . '/widgets/' . strtolower($name)); if ($action != 'config') { /** * Gets widget resources that are defined in widget information file */ $file = ROOT_DIR . DS . 'modules' . DS . strtolower($module) . DS . 'widgets' . DS . strtolower($name) . DS . 'about.xml'; if (file_exists($file)) { $config = @simplexml_load_file($file); if ($resources = $config->resources) { if ($resources = $resources->resource) { foreach ($resources as $resource) { $attr = $resource->attributes(); switch ((string) $attr['type']) { case 'css': $return['cssFiles'][] = str_replace($search, $replace, (string) $attr['src']); break; case 'javascript': $return['jsFiles'][] = str_replace($search, $replace, (string) $attr['src']); break; } } } } } } $return['content'] = $widgetContent; $pattern = '/<script[^>]*>(.*)<\\/script>$/is'; if (preg_match_all($pattern, $widgetContent, $matches)) { $return['jsScripts'] = $matches[1]; $return['content'] = str_replace($matches[1], '', $widgetContent); } return $return; }
public function fetch($file) { if (!file_exists($file)) { throw new Exception($file . ': File not found', 3); } foreach ($this->_blocks as $index => $block) { if (!in_array($block->block_name, $this->_blocksName)) { $blockName = $block->block_name; $type = $block->type == 'widget' ? 'widgets' . DS . $block->name : $block->name; switch ($block->type) { case 'widget': $widgetContent = Gio_Core_Widget::getIntance()->setModuleName($block->module)->setWidgetName($block->name)->setActionName($block->action)->dispatch(); $this->{$blockName} = $widgetContent; break; default: $blockViewFile = TEMPLATE_DIR . DS . 'default' . DS . 'modules' . DS . $block->module . DS . $type . DS . $block->action . '.phtml'; $blockContent = $this->render($blockViewFile); $this->{$blockName} = $blockContent; break; } } } echo $this->render($file); }
public function dispatch() { $this->view = Gio_Core_View::getInstance(); $controllerFront = Gio_Core_Controller::getIntance(); /** * XML */ $xmlFilename = array($this->_module, $this->_controller, $this->_action); $xmlFilename = implode('_', $xmlFilename); $blocksData = array(); $xmlFile = TEMPLATE_DIR . DS . $this->view->APP_TEMPLATE . DS . 'data' . DS . $xmlFilename . '.xml'; if ($this->view->getAdminSection()) { $xmlFile = TEMPLATE_DIR . DS . $this->view->APP_TEMPLATE . DS . 'data' . DS . $this->view->APP_TEMPLATE . '.xml'; } if (file_exists($xmlFile)) { $xmlData = simplexml_load_file($xmlFile); $blocksData = $xmlData->block; } /** * Check file html cache */ $globalConfig = Gio_Core_Config_Xml::getConfig(); $configs = Gio_Core_Config_Xml::getConfig('cache'); $checkCache = false; if ($configs->enable == 'true' && !$this->view->getAdminSection()) { $cacheName = $xmlFilename; $postParams = $this->_request->getPostParams(); $getParams = $this->_request->getParams(); $json = new Services_JSON(); $cacheParams = !empty($postParams) ? base64_encode($json->encodeUnsafe($postParams)) : null; $cacheParams .= !empty($getParams) ? base64_encode($json->encodeUnsafe($getParams)) : null; $cacheKey = md5($cacheName . $this->view->APP_TEMPLATE . $cacheParams . base64_encode($json->encodeUnsafe($globalConfig))); $cacheType = 'actions'; $cacheTimeout = isset($configs->timeout) ? $configs->timeout : 3600; if ($blocksData) { foreach ($blocksData as $index => $block) { if ($block->block_name == 'MAIN_CONTENT' && isset($block->cache->enable) && $block->cache->enable == 'true') { $cacheTimeout = isset($block->cache->timeout) ? $block->cache->timeout : 3600; /** * Create html file cache */ if ($checkCache = Gio_Core_Cache::isCached($cacheType, $cacheKey, $cacheTimeout)) { $html = $this->view->render(Gio_Core_Cache::_generateFileName($cacheType, $cacheKey)); return $html; } } } } } $ucfModule = ucfirst($this->_module); $ucfController = ucfirst($this->_controller); $controllerClassName = array('Modules', $ucfModule, 'Controllers', $ucfController); $controllerClassName = implode('_', $controllerClassName); if (!class_exists($controllerClassName)) { Modules_Core_Services_Exception::error('CLASS_NOT_FOUND', $controllerClassName); } $controllerClass = new $controllerClassName(); /** * Call init function */ if (method_exists($controllerClass, 'init')) { $controllerClass->init(); } self::$_instance = $controllerClass; if (!method_exists($controllerClass, $this->_action . 'Action')) { Modules_Core_Services_Exception::error('ACTION_NOT_FOUND', $controllerClassName . '::' . $this->_action . 'Action'); return; } call_user_func(array($controllerClass, $this->_action . 'Action')); $actionCache = array('enable' => false, 'timeout' => 0); if (!Gio_Core_Controller::getIntance()->getDisableLayout()) { $widgetObject = Gio_Core_Widget::getIntance(); if ($blocksData) { foreach ($blocksData as $index => $block) { if (!isset($block->visible) || (string) $block->visible != 'false') { if ($block->type == 'widget') { /** * Set Widget User Params */ $userParams = isset($block->params) ? (array) $block->params : null; $paramString = null; if ($userParams) { $request = $widgetObject->getRequest(); foreach ($userParams as $paramIndex => $param) { switch ($param) { case 'GLOBAL': $userParams[$paramIndex] = $request->getParam($paramIndex); $param = $request->getParam($paramIndex); break; default: //$request->setParam($paramIndex, $param); break; } $paramString .= $paramString ? '|' : null; $paramString .= $paramIndex . '=' . $param; } } $userParams['module'] = $block->module; $userParams['widget'] = $block->name; if (isset($block->load) && $block->load == 'ajax') { $this->view->module = $block->module; $this->view->widget = $block->name; $this->view->action = $block->action; $this->view->cacheEnable = isset($block->cache->enable) && $block->cache->enable == 'true' ? true : false; $this->view->cacheTimeout = isset($block->cache->timeout) && $block->cache->timeout > 0 ? $block->cache->timeout : 3600; $this->view->params = $paramString; $this->view->uuid = uniqid(); /** * Loading Js & Css */ $widgetViewFile = TEMPLATE_DIR . DS . $this->view->APP_TEMPLATE . DS . 'modules' . DS . $block->module . DS . 'widgets' . DS . $block->name . DS . $block->action . '.phtml'; if (file_exists($widgetViewFile)) { $jsCss = $this->view->render($widgetViewFile); } /** * Render Ajax Script */ $widgetViewFile = ROOT_DIR . DS . 'modules' . DS . 'core' . DS . 'views' . DS . 'core' . DS . 'widgets' . DS . 'ajax.phtml'; $this->view->{$block->block_name} = $this->view->render($widgetViewFile); } else { $cacheEnable = isset($block->cache->enable) && $block->cache->enable == 'true' ? true : false; $cacheTimeout = isset($block->cache->timeout) && $block->cache->timeout > 0 ? $block->cache->timeout : 0; $widgetObject->setTemplate($this->view->APP_TEMPLATE)->setModuleName($block->module)->setWidgetName($block->name)->setActionName($block->action)->setCacheEnable($cacheEnable)->setCacheTimeout($cacheTimeout)->setParams($userParams); $this->view->{$block->block_name} = $widgetObject->dispatch(); } } elseif ($block->block_name == 'MAIN_CONTENT') { $actionCache['enable'] = isset($block->cache->enable) && $block->cache->enable == 'true' ? true : false; $actionCache['timeout'] = isset($block->cache->timeout) && $block->cache->timeout > 0 ? $block->cache->timeout : 0; } } } } } $actionViewFile = TEMPLATE_DIR . DS . $this->view->APP_TEMPLATE . DS . 'modules' . DS . $this->_module . DS . $this->_controller . DS . $this->_action . '.phtml'; if (!file_exists($actionViewFile)) { /** * Default action view file */ $actionViewFile = ROOT_DIR . DS . 'modules' . DS . $this->_module . DS . 'views' . DS . $this->_controller . DS . $this->_action . '.phtml'; } if (!Gio_Core_Controller::getIntance()->getNoRender()) { $content = $controllerClass->view->render($actionViewFile); $this->view->MAIN_CONTENT = $content; } if (!Gio_Core_Controller::getIntance()->getDisableLayout()) { $xmlFilename = isset($this->view->APP_LAYOUT) && $this->view->APP_LAYOUT ? $this->view->APP_LAYOUT : $xmlFilename; $layoutFile = TEMPLATE_DIR . DS . $this->view->APP_TEMPLATE . DS . 'layouts' . DS . $xmlFilename . '.phtml'; if ($this->view->getAdminSection()) { $layoutFile = TEMPLATE_DIR . DS . $this->view->APP_TEMPLATE . DS . 'layouts' . DS . $this->view->APP_TEMPLATE . '.phtml'; } /** * Check param __GIOCMS_ERROR__ */ if (Gio_Core_Request::getInstance()->getParam('__GIOCMS_ERROR__') == true) { $layoutFile = TEMPLATE_DIR . DS . $this->_template . DS . 'layouts' . DS . $this->_layout . '.phtml'; } $return = $this->view->render($layoutFile); if (!$checkCache && $configs->enable == 'true' && !$this->view->getAdminSection() && $actionCache['enable'] == true) { $cacheCompress = isset($configs->compress) && $configs->compress == 'true' ? true : false; $cacheContent = $this->view->generateTitle() . $this->view->generateScripts() . $this->view->generateStyles() . $return; Gio_Core_Cache::cache($cacheType, $cacheKey, $cacheContent, $cacheCompress); } return $return; } elseif (!Gio_Core_Controller::getIntance()->getNoRender()) { return $content; } }