/** Executes the job. * @return string Returns a string describing the job result in case of success. * @throws Exception Throws an exception in case of errors. */ public function run() { Cache::disableCache(); Cache::disableLocalCache(); try { $db = Loader::db(); $instances = array( 'navigation' => Loader::helper('navigation'), 'dashboard' => Loader::helper('concrete/dashboard'), 'view_page' => PermissionKey::getByHandle('view_page') ); $rsPages = $db->query('SELECT cID FROM Pages WHERE (cID > 1) ORDER BY cID'); $relName = ltrim(SITEMAPXML_FILE, '\\/'); $osName = rtrim(DIR_BASE, '\\/') . '/' . $relName; $urlName = rtrim(BASE_URL . DIR_REL, '\\/') . '/' . $relName; if(!file_exists($osName)) { @touch($osName); } if(!is_writable($osName)) { throw new Exception(t('The file %s is not writable', $osName)); } if(!$hFile = fopen($osName, 'w')) { throw new Exception(t('Cannot open file %s', $osName)); } if(!@fprintf($hFile, '<?xml version="1.0" encoding="%s"?>' . self::EOL . '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">', APP_CHARSET)) { throw new Exception(t('Error writing header of %s', $osName)); } $addedPages = 0; if(self::AddPage($hFile, 1, $instances)) { $addedPages++; } while($rowPage = $rsPages->FetchRow()) { if(self::AddPage($hFile, intval($rowPage['cID']), $instances)) { $addedPages++; } } $rsPages->Close(); unset($rsPages); if(!@fwrite($hFile, self::EOL . '</urlset>')) { throw new Exception(t('Error writing footer of %s', $osName)); } @fflush($hFile); @fclose($hFile); unset($hFile); return t('%1$s file saved (%2$d pages).', $urlName, $addedPages); } catch(Exception $x) { if(isset($rsPages) && $rsPages) { $rsPages->Close(); $rsPages = null; } if(isset($hFile) && $hFile) { @fflush($hFile); @ftruncate($hFile, 0); @fclose($hFile); $hFile = null; } throw $x; } }
public function run() { Cache::disableCache(); Loader::library('database_indexed_search'); $is = new IndexedSearch(); if ($_GET['force'] == 1) { Loader::model('attribute/categories/collection'); Loader::model('attribute/categories/file'); Loader::model('attribute/categories/user'); $attributes = CollectionAttributeKey::getList(); $attributes = array_merge($attributes, FileAttributeKey::getList()); $attributes = array_merge($attributes, UserAttributeKey::getList()); foreach($attributes as $ak) { $ak->updateSearchIndex(); } $result = $is->reindexAll(true); } else { $result = $is->reindexAll(); } if ($result->count == 0) { return t('Indexing complete. Index is up to date'); } else { if ($result->count == $is->searchBatchSize) { return t('Index partially updated. %s pages indexed (maximum number.) Re-run this job to continue this process.', $result->count); } else { return t('Index updated. %s %s required reindexing.', $result->count, $result->count == 1 ? t('page') : t('pages')); } } }
public function getLatestAvailableVersionNumber() { if (defined('MULTI_SITE') && MULTI_SITE == 1) { $updates = Update::getLocalAvailableUpdates(); $multiSiteVersion = 0; foreach($updates as $up) { if (version_compare($up->getUpdateVersion(), $multiSiteVersion, '>')) { $multiSiteVersion = $up->getUpdateVersion(); } } Config::save('APP_VERSION_LATEST', $multiSiteVersion); return $multiSiteVersion; } $d = Loader::helper('date'); // first, we check session $queryWS = false; Cache::disableCache(); $vNum = Config::get('APP_VERSION_LATEST', true); Cache::enableCache(); if (is_object($vNum)) { $seconds = strtotime($vNum->timestamp); $version = $vNum->value; if (is_object($version)) { $versionNum = $version->version; } else { $versionNum = $version; } $diff = time() - $seconds; if ($diff > APP_VERSION_LATEST_THRESHOLD) { // we grab a new value from the service $queryWS = true; } } else { $queryWS = true; } if ($queryWS) { Loader::library('marketplace'); $mi = Marketplace::getInstance(); if ($mi->isConnected()) { Marketplace::checkPackageUpdates(); } $update = Update::getLatestAvailableUpdate(); $versionNum = $update->version; if ($versionNum) { Config::save('APP_VERSION_LATEST', $versionNum); if (version_compare($versionNum, APP_VERSION, '>')) { Loader::model('system_notification'); SystemNotification::add(SystemNotification::SN_TYPE_CORE_UPDATE, t('A new version of concrete5 is now available.'), '', $update->notes, View::url('/dashboard/system/update')); } } else { // we don't know so we're going to assume we're it Config::save('APP_VERSION_LATEST', APP_VERSION); } } return $versionNum; }
public function on_start() { $this->secCheck(); // if you just reverted, but didn't manually clear out your files - cache would be a prob here. $ca = new Cache(); $ca->flush(); Cache::disableCache(); Cache::disableLocalCache(); $this->site_version = Config::get('SITE_APP_VERSION'); Database::ensureEncoding(); }
public function on_start() { $cnt = Loader::controller('/dashboard/system/backup_restore/update'); $cnt->secCheck(); // if you just reverted, but didn't manually clear out your files - cache would be a prob here. $ca = new Cache(); $ca->flush(); Cache::disableCache(); Cache::disableLocalCache(); $this->site_version = Config::get('SITE_APP_VERSION'); Database::ensureEncoding(); }
/** * Testing */ public function on_start() { if (isset($_POST['locale']) && $_POST['locale']) { define("ACTIVE_LOCALE", $_POST['locale']); $this->set('locale', $_POST['locale']); } require DIR_BASE_CORE . '/config/file_types.php'; Cache::disableCache(); $this->setRequiredItems(); $this->setOptionalItems(); Loader::model('package/starting_point'); if (file_exists(DIR_CONFIG_SITE . '/site.php')) { throw new Exception(t('concrete5 is already installed.')); } }
/** Executes the job. * @return string Returns a string describing the job result in case of success. * @throws Exception Throws an exception in case of errors. */ public function run() { Cache::disableCache(); Cache::disableLocalCache(); try { $db = Loader::db(); $instances = array('navigation' => Loader::helper('navigation'), 'dashboard' => Loader::helper('concrete/dashboard'), 'view_page' => PermissionKey::getByHandle('view_page'), 'guestGroup' => Group::getByID(GUEST_GROUP_ID), 'now' => new DateTime('now'), 'ak_exclude_sitemapxml' => CollectionAttributeKey::getByHandle('exclude_sitemapxml'), 'ak_sitemap_changefreq' => CollectionAttributeKey::getByHandle('sitemap_changefreq'), 'ak_sitemap_priority' => CollectionAttributeKey::getByHandle('sitemap_priority')); $instances['guestGroupAE'] = array(GroupPermissionAccessEntity::getOrCreate($instances['guestGroup'])); $xmlDoc = new SimpleXMLElement('<' . '?xml version="1.0" encoding="' . APP_CHARSET . '"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" />'); $rs = Loader::db()->Query('SELECT cID FROM Pages'); while ($row = $rs->FetchRow()) { self::addPage($xmlDoc, intval($row['cID']), $instances); } $rs->Close(); Events::fire('on_sitemap_xml_ready', $xmlDoc); $dom = dom_import_simplexml($xmlDoc)->ownerDocument; $dom->formatOutput = true; $addedPages = count($xmlDoc->url); $relName = ltrim(SITEMAPXML_FILE, '\\/'); $osName = rtrim(DIR_BASE, '\\/') . '/' . $relName; $urlName = rtrim(BASE_URL . DIR_REL, '\\/') . '/' . $relName; if (!file_exists($osName)) { @touch($osName); } if (!is_writable($osName)) { throw new Exception(t('The file %s is not writable', $osName)); } if (!($hFile = @fopen($osName, 'w'))) { throw new Exception(t('Cannot open file %s', $osName)); } if (!@fwrite($hFile, $dom->saveXML())) { throw new Exception(t('Error writing to file %s', $osName)); } @fflush($hFile); @fclose($hFile); unset($hFile); return t('%1$s file saved (%2$d pages).', sprintf('<a href="%s" target="_blank">%s</a>', $urlName, preg_replace('/^https?:\\/\\//i', '', $urlName)), $addedPages); } catch (Exception $x) { if (isset($hFile) && $hFile) { @fflush($hFile); @ftruncate($hFile, 0); @fclose($hFile); $hFile = null; } throw $x; } }
/** * Testing */ public function on_start() { if (isset($_POST['locale']) && $_POST['locale']) { define("ACTIVE_LOCALE", $_POST['locale']); $this->set('locale', $_POST['locale']); } require(DIR_BASE_CORE . '/config/file_types.php'); Cache::disableCache(); Cache::disableLocalCache(); $this->setRequiredItems(); $this->setOptionalItems(); Loader::model('package/starting_point'); if (file_exists(DIR_CONFIG_SITE . '/site.php')) { throw new Exception(t('concrete5 is already installed.')); } if (!isset($_COOKIE['CONCRETE5_INSTALL_TEST'])) { setcookie('CONCRETE5_INSTALL_TEST', '1', 0, DIR_REL . '/'); } }
/** * handle detail request */ private function handleDetail() { $request = Request::getInstance(); $view = ViewManager::getInstance(); // process attachments $attachment = $this->getAttachment(); $attachment->handleHttpGetRequest(); // clear subtitle $view->setName(''); // check security if (!$request->exists('id')) { throw new Exception('Poll item is missing.'); } $id = intval($request->getValue('id')); $key = array('id' => $id, 'activated' => true); if (!$this->exists($key)) { throw new HttpException('404'); } $detail = $this->getDetail($key); // check if tree node of poll item is accessable $tree = $this->director->tree; if (!$tree->exists($detail['tree_id'])) { throw new HttpException('404'); } // process request $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile); $template->setPostfix($detail['tag']); // disable cache because we want to count visits $template->setCacheable(false); Cache::disableCache(); // update view counter $this->updateCount($key); // overwrite default naming $template->setVariable('pageTitle', $detail['name'], false); // add breadcrumb item $url = new Url(true); $url->clearParameter('id'); $breadcrumb = array('name' => $detail['name'], 'path' => $url->getUrl(true)); $this->director->theme->addBreadcrumb($breadcrumb); // check if template is in cache /* if(!$template->isCached()) { $template->setVariable('poll', $detail, false); } */ $template->setVariable('poll', $detail, false); $settings = $this->getPollSettings(); $treeSettings = $settings->getSettings($detail['tag'], $detail['tree_id']); $template->setVariable('newssettings', $treeSettings, false); // get settings if ($treeSettings['item']) { // process items $item = $this->getItem(); $item->handleHttpGetRequest(); } $url = new Url(true); $url->clearParameter('id'); $url->setParameter($view->getUrlId(), ViewManager::OVERVIEW); $template->setVariable('href_back', $url->getUrl(true), false); $this->template[$detail['tag']] = $template; }
/** * handle detail request */ private function handleDetail() { $request = Request::getInstance(); $view = ViewManager::getInstance(); // it makes no sense to have multiple tags for this plugin. // if someone did it, you get strange results and he probably can figure out why.. no multiple detail stuff in 1 page supported! // so take a shot and get the first tag to set the content $taglist = $this->plugin->getTagList(array('plugin_type' => News::TYPE_ARCHIVE)); if (!$taglist) { return; } $taginfo = current($taglist); // process attachments $attachment = $this->getAttachment(); $attachment->handleHttpGetRequest(); // clear subtitle $view->setName(''); if (!$request->exists('id')) { continue; } $id = intval($request->getValue('id')); $key = array('id' => $id, 'active' => true); $overview = $this->getNewsOverview(); if (!$overview->exists($key)) { throw new HttpException('404'); } $detail = $overview->getDetail($key); // check if tree node of news item is accessable $tree = $this->director->tree; if (!$tree->exists($detail['tree_id'])) { throw new HttpException('404'); } $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile); $template->setPostfix($detail['tag']); // disable cache because we want to count visits $template->setCacheable(false); Cache::disableCache(); // update view counter $overview->updateCount($key); // overwrite default naming $template->setVariable('pageTitle', $detail['name'], false); $template->setVariable('news', $detail, false); $url = new Url(true); $url->clearParameter('id'); $url->setParameter($view->getUrlId(), ViewManager::OVERVIEW); $template->setVariable('href_back', $url->getUrl(true), false); $breadcrumb = array('name' => $detail['name'], 'path' => $url->getUrl(true)); $this->director->theme->addBreadcrumb($breadcrumb); $this->template[$taginfo['tag']] = $template; }
/** * handle overview request */ private function handleGet() { $view = ViewManager::getInstance(); $request = Request::getInstance(); // disable caching of current page Cache::disableCache(); $tree = $this->director->tree; $taglist = $this->getTagList(); //if(!$taglist) return; //FIXME this is used by plugins that are connected on the fly (like the login plugin) ( check what means the following statement: either way it has a tree_id bug) //ORIGINAL COMMENT: FIXME check if this is used (i dont think so, but you never know) (either way it has a tree_id bug) if (!$taglist) { $taglist[] = array('tree_id' => $tree->currentIdExists(), 'tag' => $this->director->theme->getConfig()->main_tag); } $autentication = Authentication::getInstance(); $login = $autentication->isLogin(); foreach ($taglist as $item) { // clear login state if ($login && ($item['plugin_type'] == Login::TYPE_LOGINOUT || $item['plugin_type'] == Login::TYPE_LOGOUT)) { $autentication->logout(); header("Location: /"); exit; } $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile); $settings = $this->exists($key) ? $this->getDetail($key) : $this->getFields(SqlParser::MOD_INSERT); $template->setVariable('settings', $settings); $template->setVariable('tag', $item['tag']); $template->setVariable('referer', $request->getUrl()); $this->template[$item['tag']] = $template; } }
/** * handle activate request */ private function handleActivateGet() { $view = ViewManager::getInstance(); $request = Request::getInstance(); $systemUser = new SystemUser(); $loginRequest = new LoginRequest(); $view->setType(self::VIEW_ACTIVATE); if (!$request->exists('key')) { throw new Exception('Key is missing.'); } $key = $request->getValue('key'); if (!$key) { throw new Exception('Key is missing.'); } // delete expired requests $loginRequest->delete(array('expired' => true)); // get request details $requestKey = array('request_key' => $key); if (!$loginRequest->exists($requestKey)) { throw new Exception('Request does not exist.'); } $requestInfo = $loginRequest->getDetail($requestKey); // get user details $userKey = array('id' => $requestInfo['usr_id']); if (!$systemUser->exists($userKey)) { throw new Exception('Request does not exist.'); } $user = $systemUser->getDetail(array('id' => $requestInfo['usr_id'])); // disable caching of current page Cache::disableCache(); $taglist = $this->getTagList(); if (!$taglist) { return; } foreach ($taglist as $item) { $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile); $settingsKey = array('tag' => $item['tag'], 'tree_id' => $item['tree_id']); $settings = $this->getDetail($settingsKey); $template->setVariable('settings', $settings); $template->setVariable('userinfo', $user, false); $template->setVariable($requestInfo, NULL, false); $template->setVariable('tag', $item['tag']); $this->template[$item['tag']] = $template; } }
/** * handle detail request */ private function handleDetail() { $request = Request::getInstance(); $view = ViewManager::getInstance(); // process attachments $attachment = $this->plugin->getObject(Calendar::TYPE_ATTACHMENT); $attachment->handleHttpGetRequest(); // process images $image = $this->plugin->getObject(Calendar::TYPE_IMAGE); $image->handleHttpGetRequest(); // clear subtitle $view->setName(''); // check security if (!$request->exists('id')) { throw new Exception('Calendar id is missing.'); } $id = intval($request->getValue('id')); $key = array('id' => $id, 'activated' => $settings['history'] ? strftime('%Y-%m-%d', $settings['history']) : ''); if (!$this->exists($key)) { throw new HttpException('404'); } $detail = $this->getDetail($key); $objSettings = $this->plugin->getObject(Calendar::TYPE_SETTINGS); $settings = $objSettings->getSettings($detail['tree_id'], $detail['tag']); // check if tree node of cal item is accessable $tree = $this->director->tree; if (!$tree->exists($detail['tree_id'])) { throw new HttpException('404'); } if ($detail['thumbnail']) { $img = new Image($detail['thumbnail'], $this->plugin->getContentPath(true)); $detail['thumbnail'] = array('src' => $this->plugin->getContentPath(false) . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight()); } // process request $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile); $template->setPostfix($detail['tag']); // disable cache because we want to count visits $template->setCacheable(false); Cache::disableCache(); // update view counter $this->updateCount($key); // overwrite default naming $template->setVariable('pageTitle', $detail['name'], false); // add breadcrumb item $url = new Url(true); $url->clearParameter('id'); $breadcrumb = array('name' => $detail['name'], 'path' => $url->getUrl(true)); $this->director->theme->addBreadcrumb($breadcrumb); $template->setVariable('cal', $detail, false); $template->setVariable('settings', $settings); $template->setVariable('calsettings', $settings, false); // get settings if ($settings['comment']) { // process comments $comment = $this->plugin->getObject(Calendar::TYPE_COMMENT); $comment->setSettings($settings); $comment->handleHttpGetRequest(); } $url->setParameter($view->getUrlId(), ViewManager::OVERVIEW); $template->setVariable('href_back', $url->getUrl(true), false); $this->template[$detail['tag']] = $template; }
public function delete($cfKey, $pkgID = null) { if ($pkgID > 0) { unset($this->rows["{$cfKey}.{$pkgID}"]); $this->db->query( "delete from Config where cfKey = ? and pkgID = ?", array($cfKey, $pkgID) ); } else { foreach ($this->rows as $key => $row) { if ($row['cfKey'] == $cfKey) { unset($this->rows[$key]); } } $this->db->query( "delete from Config where cfKey = ?", array($cfKey) ); } if (defined('ENABLE_CACHE') && (!ENABLE_CACHE)) { // if cache has been explicitly disabled, we re-enable it anyway. Cache::enableCache(); } Cache::set('config_options', 'all', $this->rows); if (defined('ENABLE_CACHE') && (!ENABLE_CACHE)) { // if cache has been explicitly disabled, we re-enable it anyway. Cache::disableCache(); } }
/** * handle overview request */ private function handleOverview() { $request = Request::getInstance(); $view = ViewManager::getInstance(); // retrieve tags that are linked to this plugin $taglist = $this->plugin->getTagList(); if (!$taglist) { return; } foreach ($taglist as $tag) { $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile); $searchcriteria = array('tree_id' => $tag['tree_id'], 'tag' => $tag['tag'], 'current' => $request->exists("bnr{$tag['tag']}", Request::SESSION) ? $request->getValue("bnr{$tag['tag']}", Request::SESSION) : 0, 'activated' => true); // skip if no images available if (!$this->exists($searchcriteria)) { continue; } Cache::disableCache(); // get settings $settings = $this->getSettings($searchcriteria); $template->setVariable('settings', $settings, false); switch ($settings['display_order']) { case Banner::DISP_ORDER_LINEAR: $banner = $this->getLinear($searchcriteria); break; default: $banner = $this->getRandom($searchcriteria); } $template->setVariable('banner', $banner); // save current id in session for next banner retrieval $request->setValue("bnr{$banner['tag']}", $banner['id']); // register view $this->addView($banner); $theme = $this->director->theme; // add javascript start script // skip if transition speed is insane fast if ($settings['display'] != Banner::DISP_SINGLE && $banner['transition_speed'] > 1) { $theme->addJavascript(sprintf('setTimeout("getNextBanner(%d, %d, \'%s\', %d)", %d*1000);', $banner['id'], $banner['tree_id'], $banner['tag'], $banner['display_order'], $banner['transition_speed'])); } // parse unique stylesheet // retrieve tag to postfix scripts and stylesheets for uniqueness (there can be more than 1 banner in a single page) $parseFile = new ParseFile(); $parseFile->setVariable('banner', $banner, false); $parseFile->setSource($this->plugin->getHtdocsPath(true) . "css/banner.css.in"); //$parseFile->setDestination($this->plugin->getCachePath(true)."banner_{$tag['tree_id']}{$tag['tag']}.css"); //$parseFile->save(); $theme->addStylesheet($parseFile->fetch()); $this->template[$tag['tag']] = $template; } }
/** * handle detail request */ private function handleDetail() { $request = Request::getInstance(); $view = ViewManager::getInstance(); // it makes no sense to have multiple tags for this plugin. // if someone did it, you get strange results and he probably can figure out why.. no multiple detail stuff in 1 page supported! // so take a shot and get the first tag to set the content $taglist = $this->plugin->getTagList(array('plugin_type' => Calendar::TYPE_ARCHIVE)); if (!$taglist) { return; } $taginfo = current($taglist); // process attachments $attachment = $this->plugin->getObject(Calendar::TYPE_ATTACHMENT); $attachment->handleHttpGetRequest(); // process images $image = $this->plugin->getObject(Calendar::TYPE_IMAGE); $image->handleHttpGetRequest(); // clear subtitle $view->setName(''); if (!$request->exists('id')) { throw new Exception('Calendar id is missing.'); } $id = intval($request->getValue('id')); $key = array('id' => $id, 'active' => true, 'finished' => true); $overview = $this->plugin->getObject(Calendar::TYPE_DEFAULT); if (!$overview->exists($key)) { return; } $detail = $overview->getDetail($key); // check if tree node of cal item is accessable $tree = $this->director->tree; if (!$tree->exists($detail['tree_id'])) { throw new HttpException('404'); } $objSettings = $this->plugin->getObject(Calendar::TYPE_SETTINGS); $settings = $objSettings->getSettings($detail['tree_id'], $detail['tag']); if ($detail['thumbnail']) { $img = new Image($detail['thumbnail'], $this->plugin->getContentPath(true)); $detail['thumbnail'] = array('src' => $this->plugin->getContentPath(false) . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight()); } $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile); $template->setPostfix($detail['tag']); // disable cache because we want to count visits $template->setCacheable(false); Cache::disableCache(); // update view counter $overview->updateCount($key); // overwrite default naming $template->setVariable('pageTitle', $detail['name'], false); $url = new Url(true); $url->clearParameter('id'); $url->setParameter($view->getUrlId(), ViewManager::OVERVIEW); $template->setVariable('href_back', $url->getUrl(true), false); $breadcrumb = array('name' => $detail['name'], 'path' => $url->getUrl(true)); $this->director->theme->addBreadcrumb($breadcrumb); $template->setVariable('cal', $detail, false); $template->setVariable('settings', $settings); $template->setVariable('calsettings', $settings, false); // get settings if ($settings['comment']) { // process comments $comment = $this->plugin->getObject(Calendar::TYPE_COMMENT); $comment->setSettings($settings); $comment->handleHttpGetRequest(); } $this->template[$taginfo['tag']] = $template; }
<?php /** * * When this file is run it basically queries the database for site config items and sets those up, possibly overriding items in the base.php. * The hierarchy basically goes like this: * 1. Item defined in config/site.php? Then it will be used. * 2. Item saved in database? Then it will be used. * 3. Otherwise, we setup the defaults below. **/ defined('C5_EXECUTE') or die("Access Denied."); if (!defined('ENABLE_CACHE')) { Config::getOrDefine('ENABLE_CACHE', true); } if (!ENABLE_CACHE) { Cache::disableCache(); } if (ENABLE_CACHE) { Config::getOrDefine('FULL_PAGE_CACHE_GLOBAL', 'blocks'); } if (!defined('STATISTICS_TRACK_PAGE_VIEWS')) { Config::getOrDefine('STATISTICS_TRACK_PAGE_VIEWS', true); } Config::getOrDefine('FULL_PAGE_CACHE_LIFETIME', 'default'); # permissions model - valid options are 'advanced' or 'simple' if (!defined('PERMISSIONS_MODEL')) { Config::getOrDefine('PERMISSIONS_MODEL', 'simple'); } if (!defined('SITE')) { Config::getOrDefine('SITE', 'concrete5'); }
/** * handle overview request */ private function handleOverview() { $view = ViewManager::getInstance(); $taglist = $this->plugin->getTagList(array('plugin_type' => Gallery::TYPE_HEADLINES)); if (!$taglist) { return; } $tree = $this->director->tree; $url = new Url(true); //$url->setParameter($view->getUrlId(), Gallery::VIEW_DETAIL); // link to gallery tree nodes $treeRef = new GalleryTreeRef(); foreach ($taglist as $tag) { $key = array('tree_id' => $tag['tree_id'], 'tag' => $tag['tag']); $detail = $this->getDetail($key); $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile); $template->setPostfix($tag['tag']); $cacheable = $detail['display_order'] != Gallery::ORDER_RANDOM; $template->setCacheable($cacheable); if (!$cacheable) { Cache::disableCache(); } $template->setVariable($detail); // include lightbox if needed if ($detail['display'] == self::DISP_LIGHTBOX) { $theme = $this->director->theme; $theme->addHeader('<script type="text/javascript" src="' . DIF_VIRTUAL_WEB_ROOT . 'js/prototype.js"></script>'); $theme->addHeader('<script type="text/javascript" src="' . DIF_VIRTUAL_WEB_ROOT . 'js/scriptaculous.js"></script>'); $theme->addHeader('<script type="text/javascript" src="' . DIF_VIRTUAL_WEB_ROOT . 'js/lightbox.js"></script>'); $theme->addHeader('<link rel="stylesheet" href="' . DIF_VIRTUAL_WEB_ROOT . 'css/lightbox.css" type="text/css" media="screen" />'); } // check if template is in cache if (!$template->isCached()) { // get settings $settings = $this->getSettings(); $treeRefList = $treeRef->getList($key); $treeItemList = array(); foreach ($treeRefList['data'] as $treeRefItem) { if (!$tree->exists($treeRefItem['ref_tree_id'])) { continue; } $treeItemList[] = $treeRefItem['ref_tree_id']; } if (!$treeItemList) { continue; } $searchcriteria = array('activated' => true, 'tree_id' => $treeItemList); $overview = $this->getGalleryOverview(); $list = $overview->getList($searchcriteria, $detail['rows'], 1, $detail['display_order']); // skip if empty if ($list['totalItems'] < 1) { continue; } foreach ($list['data'] as &$item) { $url->setPath($tree->getPath($item['tree_id'])); // go to detail if requested if ($detail['display'] == self::DISP_DETAIL) { $url->setParameter('id', $item['id']); } $item['href_detail'] = $url->getUrl(true); if ($item['image']) { $img = new Image($item['image'], $this->plugin->getContentPath(true)); $item['image'] = array('src' => $this->plugin->getContentPath(false) . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight()); } if ($item['thumbnail']) { $img = new Image($item['thumbnail'], $this->plugin->getContentPath(true)); $item['thumbnail'] = array('src' => $this->plugin->getContentPath(false) . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight()); } } $template->setVariable('gallery', $list); } $this->template[$tag['tag']] = $template; } }
/** * Completely flushes the cache */ public function flush() { $cache = Cache::getLibrary(); $loc = CacheLocal::get(); $loc->cache = array(); if (!$cache) { return false; } $cache->setOption('caching', true); $cache->clean(Zend_Cache::CLEANING_MODE_ALL); if (!ENABLE_CACHE) { Cache::disableCache(); } return true; }
public function save() { session_write_close(); if ($this->isPost()) { if (intval($this->post('entryID')) > 0) { $entry = ComposerPage::getByID($this->post('entryID'), 'RECENT'); } if (!is_object($entry)) { $this->error->add(t('Invalid page.')); } else { $ct = CollectionType::getByID($entry->getCollectionTypeID()); } $valt = Loader::helper('validation/token'); $vtex = Loader::helper('validation/strings'); if (!$valt->validate('composer')) { $this->error->add($valt->getErrorMessage()); } if ($this->post("ccm-publish-draft")) { if (!$vtex->notempty($this->post('cName'))) { $this->error->add(t('You must provide a name for your page before you can publish it.')); } if ($entry->isComposerDraft()) { if ($ct->getCollectionTypeComposerPublishMethod() == 'CHOOSE' || $ct->getCollectionTypeComposerPublishMethod() == 'PAGE_TYPE') { $parent = Page::getByID($entry->getComposerDraftPublishParentID()); } else { if ($ct->getCollectionTypeComposerPublishMethod() == 'PARENT') { $parent = Page::getByID($ct->getCollectionTypeComposerPublishPageParentID()); } } if (!is_object($parent) || ($parent->isInTrash() || $parent->isError())) { $this->error->add(t('Invalid parent page.')); } else { $cp = new Permissions($parent); if (!$cp->canAddSubCollection($ct)) { $this->error->add(t('You do not have permissions to add this page type in that location.')); } } } } else { if ($this->post('ccm-submit-discard') && !$this->error->has()) { if ($entry->isComposerDraft()) { $entry->delete(); $this->redirect('/dashboard/composer/drafts', 'draft_discarded'); } else { // we just discard the most recent changes Events::fire('on_composer_delete_draft', $entry); $v = CollectionVersion::get($entry, 'RECENT'); $v->discard(); $this->redirect('?cID=' . $entry->getCollectionID()); } } } if (!$this->error->has()) { if ($this->post('cHandle')) { $handle = $this->post('cHandle'); } else { $handle = Loader::helper('text')->urlify($this->post('cName')); } $handle = str_replace('-', PAGE_PATH_SEPARATOR, $handle); $data = array(); $pk = PermissionKey::getByHandle('edit_page_properties'); $pk->setPermissionObject($entry); $asl = $pk->getMyAssignment(); if ($asl->allowEditName()) { $data['cName'] = $this->post('cName'); } if ($asl->allowEditDescription()) { $data['cDescription'] = $this->post('cDescription'); } if ($asl->allowEditPaths()) { $data['cHandle'] = $handle; } if ($asl->allowEditDateTime()) { $data['cDatePublic'] = Loader::helper('form/date_time')->translate('cDatePublic'); } $entry->getVersionToModify(); // this is a pain. we have to use composerpage::getbyid again because // getVersionToModify is hard-coded to return a page object $entry = ComposerPage::getByID($entry->getCollectionID(), 'RECENT'); $entry->update($data); $this->saveData($entry, $asl); $u = new User(); if ($this->post('ccm-publish-draft')) { Cache::disableCache(); Cache::disableLocalCache(); if ($entry->isComposerDraft()) { $entry->move($parent); } $v = CollectionVersion::get($entry, 'RECENT'); $pkr = new ApprovePagePageWorkflowRequest(); $pkr->setRequestedPage($entry); $pkr->setRequestedVersionID($v->getVersionID()); $pkr->setRequesterUserID($u->getUserID()); $pkr->trigger(); Events::fire('on_composer_publish', $entry); $entry->markComposerPageAsPublished(); $this->redirect('?cID=' . $entry->getCollectionID()); } else { if ($this->post('autosave')) { // this is done by javascript. we refresh silently and send a json success back Events::fire('on_composer_save_draft', $entry); $json = Loader::helper('json'); $obj = new stdClass(); $dh = Loader::helper('date'); $obj->error = false; $obj->time = $dh->formatTime('now', false); $obj->timestamp = date('m/d/Y g:i a'); print $json->encode($obj); exit; } else { $this->redirect('/dashboard/composer/write', 'edit', $entry->getCollectionID(), 'saved'); } } } else { if (is_object($entry)) { $this->edit($entry->getCollectionID()); } } } else { $this->redirect('/dashboard/composer'); } }