/** * Base index action */ public function indexAction() { $resources = Shineisp_Commons_Layout::getData("system", null); // log the data Shineisp_Commons_Utilities::log("ShineISP Cron started", 'cron.log'); // Get the cron default configuration $xmlobject = $resources->xpath("cron/execute"); if (count($xmlobject)) { foreach ($xmlobject as $cron) { // get the crontab from the first cron $crontime = (string) $cron['time']; // Check the crontab time set in the xml if ($this->is_time_cron(time(), $crontime)) { foreach ($cron as $code) { $class = (string) $code['class']; $method = (string) $code['method']; $params = json_decode((string) $code['params']); $log = (string) $code; Shineisp_Commons_Utilities::log($log, 'cron.log'); $this->execScript($class, $method, $params); } } else { //Shineisp_Commons_Utilities::log((string)$cron->script . " not executed", 'cron.log'); } } } Shineisp_Commons_Utilities::log("ShineISP Cron ended", 'cron.log'); }
/** * Load all the resources * @see Zend_Controller_Action::preDispatch() */ public function preDispatch() { $module = $this->getRequest()->getModuleName(); $controller = $this->getRequest()->getControllerName(); // Get all the resources set in the layout.xml file $css = Shineisp_Commons_Layout::getResources($module, $controller, "css", "base"); $js = Shineisp_Commons_Layout::getResources($module, $controller, "js", "base"); $template = Shineisp_Commons_Layout::getTemplate($module, $controller, "base"); $this->view->doctype('XHTML1_TRANSITIONAL'); $this->view->addBasePath(PUBLIC_PATH . "/skins/setup/base/"); $this->view->headTitle("ShineISP Setup"); $this->view->headMeta()->setName('robots', "INDEX, FOLLOW"); $this->view->headMeta()->setName('author', "Shine Software Company"); $this->view->headMeta()->setName('keywords', "shine software, isp software"); $this->view->headMeta()->setName('description', "This is the ShineISP setup configuration"); $this->view->headLink()->headLink(array('rel' => 'icon', 'type' => 'image/x-icon', 'href' => "/skins/{$module}/base/images/favicon.ico")); $this->view->headTitle()->setSeparator(' - '); foreach ($js as $item) { $this->view->headScript()->appendFile($item['resource']); } foreach ($css as $item) { $this->view->headLink()->appendStylesheet($item['resource']); } $this->getHelper('layout')->setLayout('1column'); $session = new Zend_Session_Namespace('setup'); Languages::setDefaultLanguage(PUBLIC_PATH, $session->locale); if (empty($session->db)) { $this->_helper->redirector('index', 'database', 'setup'); } if (empty($session->permissions) || $session->permissions == false) { $this->_helper->redirector('index', 'checker', 'setup'); } }
/** * showblock * Handle the XML Blocks * @param unknown_type $side */ public function showblock($side) { $ns = new Zend_Session_Namespace('Admin'); $languageID = Languages::get_language_id($ns->lang); $record = array(); $blocks = array(); // Get the main variables $module = Zend_Controller_Front::getInstance()->getRequest()->getModuleName(); $controller = Zend_Controller_Front::getInstance()->getRequest()->getControllerName(); $action = Zend_Controller_Front::getInstance()->getRequest()->getActionName(); $customskin = Settings::findbyParam('adminskin'); $skin = !empty($customskin) ? $customskin : "base"; // call the placeholder view helper for each side parsed echo $this->view->placeholder($side); // Get all the xml blocks $xmlblocks = Shineisp_Commons_Layout::getBlocks($module, $side, $controller, $skin); if (!empty($xmlblocks)) { $blocks['reference'] = $xmlblocks; } if (!empty($blocks['reference'])) { $blocks['reference'] = Shineisp_Commons_Utilities::columnSort($blocks['reference'], 'position'); } if (isset($blocks['reference']['block'])) { $this->Iterator($blocks['reference'], $side); } elseif (isset($blocks['reference'][0])) { foreach ($blocks['reference'] as $block) { $this->Iterator($block, $side); } } $this->view->module = $module; $this->view->controller = $controller; $this->view->action = $action; }
public function pageAction() { $var = $this->getRequest()->getParam('url'); $ns = new Zend_Session_Namespace(); $locale = $ns->lang; if (!empty($var)) { $page = CmsPages::findbyvar($var, $locale); if ($page['active'] == false) { return $this->_helper->redirector('index', 'index', 'default'); } // Set the Metatag information $this->view->headTitle(" | " . $page['title']); if (!empty($page['keywords'])) { $this->view->headMeta()->setName('keywords', $page['keywords']); } if (!empty($page['body'])) { $this->view->headMeta()->setName('description', $page['body'] ? Shineisp_Commons_Utilities::truncate(strip_tags($page['body'])) : '-'); } $this->view->headertitle = $page['title']; // Set the page content $this->view->data = $page; // Set the subheader $this->view->headerdata = $this->CreateSubHeader($page); } if (!empty($page['xmllayout'])) { Shineisp_Commons_Layout::updateLayout($this->view, $page['xmllayout']); } if (!empty($page['pagelayout'])) { $this->getHelper('layout')->setLayout("cms/" . $page['pagelayout']); } if (!empty($page['layout'])) { return $this->_helper->viewRenderer($page['layout']); } else { return $this->_helper->viewRenderer('1column'); } }
/** * (non-PHPdoc) * @see Zend_Controller_Action_Helper_Abstract::preDispatch() */ public function preDispatch() { $module = $this->getRequest()->getModuleName(); $controller = $this->getRequest()->getControllerName(); $keywords = Settings::findbyParam('default_html_keywords'); $description = Settings::findbyParam('default_html_description'); $copyright = Settings::findbyParam('default_copyright'); // Get the skin paramenter set in the Settings Table in the database if ($module == "default") { $customskin = Settings::findbyParam('skin'); $skin = !empty($customskin) && file_exists(PUBLIC_PATH . "/skins/{$module}/{$customskin}") ? $customskin : "blank"; } elseif ($module == "admin") { $customskin = Settings::findbyParam('adminskin'); $skin = !empty($customskin) && file_exists(PUBLIC_PATH . "/skins/{$module}/{$customskin}") ? $customskin : "blank"; } else { $customskin = ""; $skin = ""; } // Get all the resources set in the layout.xml file $css = Shineisp_Commons_Layout::getResources($module, $controller, "css", $skin); $js = Shineisp_Commons_Layout::getResources($module, $controller, "js", $skin); $template = Shineisp_Commons_Layout::getTemplate($module, $controller, $skin); // Setting up the HEAD Section $view = new Zend_View(); $view->doctype('XHTML1_TRANSITIONAL'); #$view->headMeta ()->appendHttpEquiv ( 'Content-Type', 'text/html;charset=utf-8' ); $view->headTitle(Settings::findbyParam('default_html_title')); $view->headMeta()->setName('robots', "INDEX, FOLLOW"); $view->headMeta()->setName('author', !empty($copyright) ? $copyright : "Shine Software Company"); $view->headMeta()->setName('keywords', !empty($keywords) ? $keywords : "shine software, isp software"); $view->headMeta()->setName('description', !empty($description) ? $description : "This is a Shine Software application"); $view->headTitle()->setSeparator(' / '); // Custom XML file inclusion of the js files if (!empty($js)) { // Fast including of the js file using the module name if (file_exists(PUBLIC_PATH . "/skins/{$module}/{$skin}/js/{$module}.js")) { $js[] = array('resource' => "/skins/{$module}/{$skin}/js/{$module}.js", 'position' => 'admin_endbody'); } // Fast including of the js file for the controller if (file_exists(PUBLIC_PATH . "/skins/{$module}/{$skin}/js/{$controller}.js")) { $js[] = array('resource' => "/skins/{$module}/{$skin}/js/{$controller}.js", "position" => 'admin_endbody'); } // Check the caches administrator preferences if (Settings::findbyParam('jscompression')) { @mkdir(PUBLIC_PATH . "/cache/"); // Create the JS Compressor object $compressor = new Shineisp_Commons_jsCompressor(); foreach ($js as $item) { $compressor->add(PUBLIC_PATH . $item['resource']); } // Compress and minify the javascript files $filecompressed = $compressor->simpleMode()->hideDebugInfo()->cacheDir(PUBLIC_PATH . "/cache/")->write(); $deferringjs = "<script>(function() { var s = document.createElement(\"script\"); s.type = \"text/javascript\"; s.async = true; s.src = \"/cache/{$filecompressed}\"; var x = document.getElementsByTagName(\"script\")[0]; x.parentNode.insertBefore(s, x) })();</script>"; // Add the compressed file in the deferring mode if ($module == "admin") { $view->placeholder("admin_htmlhead")->append($deferringjs); } elseif ($module == "default") { $view->placeholder("htmlhead")->append($deferringjs); } } else { foreach ($js as $item) { // check if the css or the js is a conditional item $conditional = !empty($item['conditional']) ? array('conditional' => $item['conditional']) : null; // check the position of the item in the page if (!empty($item['position'])) { $view->InlineScript()->setFile($item['resource'], 'text/javascript', $conditional)->toString(); $view->placeholder($item['position'])->append($view->InlineScript()->toString()); } else { $view->headScript()->setFile($item['resource'], 'text/javascript', $conditional); $view->placeholder("admin_endbody")->append($view->InlineScript()->toString()); } } } } // Custom XML file inclusion of the css files if (!empty($css)) { // Fast including of the css file using the module name if (file_exists(PUBLIC_PATH . "/skins/{$module}/{$skin}/css/{$module}.css")) { $css[]['resource'] = "/skins/{$module}/{$skin}/css/{$module}.css"; } // Fast including of the css file for the controller if (file_exists(PUBLIC_PATH . "/skins/{$module}/{$skin}/css/{$controller}.css")) { $css[]['resource'] = "/skins/{$module}/{$skin}/css/{$controller}.css"; } // Check the caches administrator preferences if (Settings::findbyParam('csscompression')) { @mkdir(PUBLIC_PATH . "/cache/"); // Create the JS Compressor object $compressor = new Shineisp_Commons_cssCompressor(); foreach ($css as $item) { $compressor->add(PUBLIC_PATH . $item['resource']); } // Compress and minify the stylesheet files $filecompressed = $compressor->cacheDir(PUBLIC_PATH . "/cache/")->write(); $view->headLink()->appendStylesheet("/cache/{$filecompressed}"); } else { foreach ($css as $item) { $conditional = !empty($item['conditional']) ? $item['conditional'] : null; $view->headLink()->appendStylesheet($item['resource'], 'screen', $conditional); } } } $customcss = Settings::findbyParam('css'); if ($customcss) { $view->placeholder("htmlhead")->append("<style>" . trim(preg_replace('/\\s\\s+/', ' ', $customcss)) . "</style>"); } // Enable and Add the RSS Shine Software reference $view->headLink()->appendAlternate('/rss/', 'application/rss+xml', 'RSS Feed'); $view->headLink()->headLink(array('rel' => 'icon', 'type' => 'image/x-icon', 'href' => "/skins/{$module}/{$skin}/images/favicon.ico")); $view->placeholder("endbody")->append(Settings::findbyParam('default_html_code')); $view->placeholder("htmlhead")->append(Settings::findbyParam('default_html_head')); $view->placeholder("endbody")->append(Settings::findbyParam('google_analytics_code')); // Change the default path script if (file_exists(APPLICATION_PATH . "/modules/{$module}/views/{$skin}/")) { $this->getActionController()->view->addBasePath(APPLICATION_PATH . "/modules/{$module}/views/{$skin}/"); } else { $this->getActionController()->view->addBasePath(APPLICATION_PATH . "/modules/{$module}/views/blank/"); } // Set the additional path for the layout templates if ($this->getActionController()->getHelper('viewRenderer')->getNoRender() == false) { if (file_exists(PUBLIC_PATH . "/skins/{$module}/{$skin}/")) { $this->getActionController()->view->addBasePath(PUBLIC_PATH . "/skins/{$module}/{$skin}/"); // Setting the Template to be used $this->getActionController()->getHelper('layout')->setLayout($template); } else { if ($module != "system") { // System module doesn't need the template folder throw new Exception("Template folder has not been found in: " . PUBLIC_PATH . "/skins/{$module}/{$skin}/"); } } } }
/** * get the blocks */ public static function getBlocks($module, $side, $controller = null, $skin = null) { $resources = self::getData($module, $skin); // Clear the array to avoid double results self::$blocks = array(); // Check the controller action xml blocks $action = $resources->xpath("{$module}/{$controller}/blocks/@action"); // Check if the controller needs to exclude the common blocks if (!empty($action[0]) && (string) $action[0] == "clearallblocks") { // Adding the controller blocks $xmlobject = $resources->xpath("{$module}/{$controller}/blocks"); self::getBlockItems($xmlobject); } else { // Adding all the commons blocks $xmlobject = $resources->xpath("{$module}/commons/blocks"); self::getBlockItems($xmlobject); // Adding the controller blocks $xmlobject = $resources->xpath("{$module}/{$controller}/blocks"); self::getBlockItems($xmlobject); } return self::$blocks; }
/** * showblock * Handle the Cms blocks and XML Blocks * @param unknown_type $side */ public function showblock($side) { $ns = new Zend_Session_Namespace(); $languageID = $ns->langid; $record = array(); $blocks = array(); // Get the main variables $module = Zend_Controller_Front::getInstance()->getRequest()->getModuleName(); $controller = Zend_Controller_Front::getInstance()->getRequest()->getControllerName(); $action = Zend_Controller_Front::getInstance()->getRequest()->getActionName(); $customskin = Settings::findbyParam('skin'); $skin = !empty($customskin) ? $customskin : "blank"; // call the placeholder view helper for each side parsed echo $this->view->placeholder($side); // Get all the xml blocks $xmlblocks = Shineisp_Commons_Layout::getBlocks($module, $side, $controller, $skin); // HOMEPAGE BLOCKS // If the controller called is the homepage, event detail page or a cms page ... // ################# if ($controller == "index") { $record = CmsPages::findbyvar('homepage', $ns->lang); $var = Zend_Controller_Front::getInstance()->getRequest()->getParam('url'); if (!empty($var)) { $record = CmsPages::findbyvar($var, $ns->lang); } } elseif ($controller == "cms") { $var = Zend_Controller_Front::getInstance()->getRequest()->getParam('url'); $record = CmsPages::findbyvar($var, $ns->lang); } // Load the xml found in the recordset if (!empty($record['blocks'])) { // Load the xml into an array $xmlobject = simplexml_load_string($record['blocks']); // Get the blocks from the xml structure if (count($xmlobject)) { $i = 0; foreach ($xmlobject as $block) { $blocks['reference'][$i]['block']['name'] = (string) $block; $blocks['reference'][$i]['side'] = (string) $block['side']; $blocks['reference'][$i]['position'] = (string) $block['position']; $i++; } } } // Join every block in one unique blocks structure if (!empty($xmlblocks)) { if (!empty($blocks['reference'])) { $blocks['reference'] = array_merge($xmlblocks, $blocks['reference']); } else { $blocks['reference'] = $xmlblocks; } } if (!empty($blocks['reference'])) { $blocks['reference'] = Shineisp_Commons_Utilities::columnSort($blocks['reference'], 'position'); } if (isset($blocks['reference']['block'])) { $this->Iterator($blocks['reference'], $side); } elseif (isset($blocks['reference'][0])) { foreach ($blocks['reference'] as $block) { $this->Iterator($block, $side); } } if (Settings::findbyParam('debug')) { echo "<div class=\"alert alert-info\"><h4>{$side} <small>({$skin})</small></h4>Path: {$module}/{$controller}/{$action}</div>"; } $this->view->module = $module; $this->view->controller = $controller; $this->view->action = $action; }