factory() public static méthode

Loads the handler specified by the given name.
public static factory ( $p_handlerName = null, $p_path = null ) : object
$p_handlerName
Résultat object
 /**
  */
 public function __construct()
 {
     parent::__construct();
     $config = CampSite::GetConfigInstance();
     $this->debugging = $config->getSetting('smarty.debugging');
     $this->force_compile = $config->getSetting('smarty.force_compile');
     $this->compile_check = $config->getSetting('smarty.compile_check');
     $this->use_sub_dirs = $config->getSetting('smarty.use_subdirs');
     // cache settings
     $preferencesService = \Zend_Registry::get('container')->getService('system_preferences_service');
     $this->useprotocol = $preferencesService->get('SmartyUseProtocol') === 'Y' ? 'true' : 'false';
     $this->templateCacheHandler = $preferencesService->TemplateCacheHandler;
     if ($this->templateCacheHandler) {
         $this->caching = 1;
         $this->caching_type = 'newscoop';
         CampTemplateCache::factory();
     } else {
         $this->caching = 0;
     }
     if (defined('APPLICATION_ENV') && APPLICATION_ENV == 'development') {
         $this->force_compile = true;
     }
     // define dynamic uncached block
     require_once APPLICATION_PATH . self::PLUGINS . '/block.dynamic.php';
     $this->registerPlugin('block', 'dynamic', 'smarty_block_dynamic', false);
     // define render function
     require_once APPLICATION_PATH . self::PLUGINS . '/function.render.php';
     $this->registerPlugin('function', 'render', 'smarty_function_render', false);
     // define translate modifier
     require_once APPLICATION_PATH . self::PLUGINS . '/modifier.translate.php';
     $this->registerPlugin('modifier', 'translate', 'smarty_modifier_translate', false);
     $this->left_delimiter = '{{';
     $this->right_delimiter = '}}';
     $this->auto_literal = false;
     $this->cache_dir = APPLICATION_PATH . '/../cache';
     $this->compile_dir = APPLICATION_PATH . '/../cache';
     $this->plugins_dir = array_merge((array) $this->plugins_dir, array(APPLICATION_PATH . self::PLUGINS), self::getPluginsPluginsDir());
     $this->setTemplateDir(array(APPLICATION_PATH . '/../themes/', APPLICATION_PATH . '/../themes/system_templates/', APPLICATION_PATH . self::SCRIPTS));
     $this->assign('view', \Zend_Registry::get('container')->get('view'));
     $this->assign('userindex', false);
     $this->assign('user', new MetaUser());
     $this->assign('siteinfo', array('title' => $preferencesService->SiteTitle, 'keywords' => $preferencesService->SiteMetaKeywords, 'description' => $preferencesService->SiteMetaDescription));
     $this->getTemplateTranslationsFiles();
 }
Exemple #2
0
 /**
  */
 public function __construct()
 {
     parent::__construct();
     $config = CampSite::GetConfigInstance();
     $this->debugging = $config->getSetting('smarty.debugging');
     $this->force_compile = $config->getSetting('smarty.force_compile');
     $this->compile_check = $config->getSetting('smarty.compile_check');
     $this->use_sub_dirs = $config->getSetting('smarty.use_subdirs');
     $this->allow_php_tag = true;
     // cache settings
     $cacheHandler = SystemPref::Get('TemplateCacheHandler');
     $auth = Zend_Auth::getInstance();
     if ($cacheHandler) {
         $this->caching = 1;
         $this->caching_type = 'newscoop';
         CampTemplateCache::factory();
     } else {
         $this->caching = 0;
     }
     if (self::isDevelopment()) {
         $this->force_compile = true;
     }
     // define dynamic uncached block
     require_once APPLICATION_PATH . self::PLUGINS . '/block.dynamic.php';
     $this->registerPlugin('block', 'dynamic', 'smarty_block_dynamic', false);
     // define render function
     require_once APPLICATION_PATH . self::PLUGINS . '/function.render.php';
     $this->registerPlugin('function', 'render', 'smarty_function_render', false);
     $this->left_delimiter = '{{';
     $this->right_delimiter = '}}';
     $this->auto_literal = false;
     $this->cache_dir = APPLICATION_PATH . '/../cache';
     $this->config_dir = APPLICATION_PATH . '/../configs';
     $this->compile_dir = APPLICATION_PATH . '/../cache';
     $this->plugins_dir = array_merge((array) $this->plugins_dir, array(APPLICATION_PATH . self::PLUGINS), self::getPluginsPluginsDir());
     $this->template_dir = array(APPLICATION_PATH . '/../themes/', APPLICATION_PATH . '/../themes/unassigned/system_templates/', APPLICATION_PATH . self::SCRIPTS);
     if (isset($GLOBALS['controller'])) {
         $this->assign('view', $GLOBALS['controller']->view);
     }
 }
Exemple #3
0
    /**
     * Set the article workflow on issue status change. Articles to be
     * published with the issue will be published on article publish.
     * Published articles are set to "publish with issue" on issue
     * unpublish.
     *
     * @param int $p_publicationId
     * @param int $p_languageId
     * @param int $p_issueNo
     * @param int $p_publish
     */
    public static function OnIssuePublish($p_publicationId, $p_languageId,
    $p_issueNo, $p_publish = true)
    {
        global $g_ado_db;

        settype($p_publicationId, 'integer');
        settype($p_languageId, 'integer');
        settype($p_issueNo, 'integer');

        $issueObj = new Issue($p_publicationId, $p_languageId, $p_issueNo);
        if (!$issueObj->exists()) {
            return false;
        }

        if (($issueObj->isPublished() && $p_publish)
        || (!$issueObj->isPublished() && !$p_publish)) {
            return false;
        }

        $fromState = $p_publish ? 'M' : 'Y';
        $toState = $p_publish ? 'Y' : 'M';

        $sql = "UPDATE Articles SET Published = '$toState' WHERE "
        . "IdPublication = $p_publicationId AND IdLanguage = $p_languageId"
        . " AND NrIssue = $p_issueNo AND Published = '$fromState'";
        $res = $g_ado_db->Execute($sql);

        CampCache::singleton()->clear('user');
        if (CampTemplateCache::factory()) {
            CampTemplateCache::factory()->update(array(
                'language' => $p_languageId,
                'publication' => $p_publicationId,
                'issue' => $p_issueNo,
                'section' => null,
                'article' => null,
            ));
        }
        return $res;
    }
Exemple #4
0
    ?>
"></a><?php 
}
// clear cache
$clearCache = Input::Get('clear_cache', 'string', 'no', true);
if ((CampCache::IsEnabled() || CampTemplateCache::factory()) && $clearCache == 'yes' && $g_user->hasPermission('ClearCache')) {
    // Clear cache engine's cache
    CampCache::singleton()->clear('user');
    CampCache::singleton()->clear();
    SystemPref::DeleteSystemPrefsFromCache();
    // Clear compiled templates
    require_once dirname(dirname(__FILE__)) . '/template_engine/classes/CampTemplate.php';
    CampTemplate::singleton()->clearCompiledTemplate();
    // Clear template cache storage
    if (CampTemplateCache::factory()) {
        CampTemplateCache::factory()->clean();
    }
    $actionMsg = getGS('Newscoop cache was cleaned up');
    $res = 'OK';
}
?>

<?php 
if (!empty($actionMsg)) {
    ?>
<script type="text/javascript">
$(function() {
    <?php 
    if ($res == 'OK') {
        ?>
    flashMessage('<?php 
Exemple #5
0
        $repository->flush();
    }
    $articleObj->setCommentsLocked($f_comment_status == "locked");
}
// Make sure that the time stamp is updated.
$articleObj->setProperty('time_updated', 'NOW()', true, true);
// Verify creation date is in the correct format.
// If not, dont change it.
if (preg_match("/\\d{4}-\\d{2}-\\d{2}/", $f_creation_date)) {
    $articleObj->setCreationDate($f_creation_date);
}
// Verify publish date is in the correct format.
// If not, dont change it.
if (preg_match("/\\d{4}-\\d{2}-\\d{2}/", $f_publish_date)) {
    $articleObj->setPublishDate($f_publish_date);
}
foreach ($articleFields as $dbColumnName => $text) {
    $articleTypeObj->setProperty($dbColumnName, $text);
}
Log::ArticleMessage($articleObj, $translator->trans('Content edited', array(), 'articles'), $g_user->getUserId(), 37);
ArticleIndex::RunIndexer(3, 10, true);
if (CampTemplateCache::factory()) {
    CampTemplateCache::factory()->update(array('language' => $articleObj->getLanguageId(), 'publication' => $articleObj->getPublicationId(), 'issue' => $articleObj->getIssueNumber(), 'section' => $articleObj->getSectionNumber(), 'article' => $articleObj->getArticleNumber()), !($articleObj->isPublished() || $articleObj->m_published));
}
$cacheService = \Zend_Registry::get('container')->getService('newscoop.cache');
$cacheService->clearNamespace('authors');
$cacheService->clearNamespace('article');
$cacheService->clearNamespace('article_type');
$cacheService->clearNamespace('boxarticles');
echo json_encode($data);
exit;
Exemple #6
0
    if (!$f_cache_engine || CampCache::IsSupported($f_cache_engine)) {
        SystemPref::Set('DBCacheEngine', $f_cache_engine);
        CampCache::singleton()->clear('user');
        CampCache::singleton()->clear();
    } else {
        $msg_ok = 0;
        camp_html_add_msg(getGS('Invalid: You need PHP $1 enabled in order to use the caching system.', $f_cache_engine));
    }
}

// Template Caching
if (SystemPref::Get('TemplateCacheHandler') != $f_template_cache_handler && $f_template_cache_handler) {
    $handler = CampTemplateCache::factory($f_template_cache_handler);
    if ($handler && CampTemplateCache::factory($f_template_cache_handler)->isSupported()) {
        SystemPref::Set('TemplateCacheHandler', $f_template_cache_handler);
        CampTemplateCache::factory($f_template_cache_handler)->clean();
    } else {
        $msg_ok = 0;
        camp_html_add_msg(getGS('Invalid: You need PHP $1 enabled in order to use the template caching system.'
            , $f_template_cache_handler));
    }
} else {
    SystemPref::Set('TemplateCacheHandler', $f_template_cache_handler);
}

// Image cache lifetime
SystemPref::Set('ImagecacheLifetime', $f_imagecache_lifetime);

// Secret key
SystemPref::Set('SiteSecretKey', $f_secret_key);
 /**
  * Sets templates caching.
  *
  * @param string                                   $cache_template Values 1 or 0
  * @param Symfony\Component\Translation\TranslatorInterface $translator     Translator
  *
  * @return void|RedirectResponse
  */
 private function templateCache($cache_template, $translator)
 {
     $preferencesService = $this->container->get('system_preferences_service');
     if ($preferencesService->TemplateCacheHandler != $cache_template && $cache_template) {
         $handler = \CampTemplateCache::factory($cache_template);
         if ($handler && \CampTemplateCache::factory($cache_template)->isSupported()) {
             $preferencesService->TemplateCacheHandler = $cache_template;
             \CampTemplateCache::factory($cache_template)->clean();
         } else {
             $this->get('session')->getFlashBag()->add('error', $translator->trans('newscoop.preferences.error.cache', array('%cache%' => $cache_template), 'system_pref'));
             return $this->redirect($this->generateUrl('newscoop_newscoop_systempref_index'));
         }
     } else {
         $preferencesService->TemplateCacheHandler = $cache_template;
     }
 }
Exemple #8
0
}

$menu_item =& DynMenuItem::Create(getGS('Change your password'),
    "/$ADMIN/users/edit.php?uType=Staff&User="******"/$ADMIN/articles/la_import.php",
            array("icon" => ''));
        $menu_actions->addItem($menu_item);
    }

    if ((CampCache::IsEnabled() || CampTemplateCache::factory()) && $g_user->hasPermission('ClearCache')) {
        $menu_item =& DynMenuItem::Create(getGS('Clear system cache'),
            "/$ADMIN/home.php?clear_cache=yes",
            array('icon' => ''));
        $menu_actions->addItem($menu_item);
    }

    if ($g_user->hasPermission('ManageBackup')) {
        $menu_item =& DynMenuItem::Create(getGS('Backup/Restore'),
            "/$ADMIN/backup.php",
            array('icon' => ''));
        $menu_actions->addItem($menu_item);
    }
}

// Creates the Configure menu