Exemplo n.º 1
0
 public function __construct($p_templateIdOrName = null, $p_themePath = null)
 {
     $this->m_properties = array();
     $this->m_customProperties['name'] = 'getValue';
     $this->m_customProperties['identifier'] = 'getId';
     $this->m_customProperties['type'] = 'getTemplateType';
     $this->m_customProperties['defined'] = 'defined';
     $this->m_customProperties['theme_dir'] = 'getThemeDir';
     $this->_map = array("frontPage" => "issue", "errorPage" => "default", "sectionPage" => "section", "issuePage" => "issue", "articlePage" => "article");
     if ((is_string($p_templateIdOrName) || is_int($p_templateIdOrName)) && !empty($p_templateIdOrName)) {
         $filePath = is_numeric($p_templateIdOrName) ? $p_templateIdOrName : $p_themePath . $p_templateIdOrName;
         $resourceId = new ResourceId('template_engine/metaclasses/MetaTemplate');
         /* @var $syncResourceService ISyncResourceService */
         $syncResourceService = $resourceId->getService(ISyncResourceService::NAME);
         $this->m_dbObject = $syncResourceService->findByPathOrId($filePath);
         if (is_null($this->m_dbObject)) {
             $pathRsc = new Resource();
             $pathRsc->setName('buildPage');
             $filePath = CS_PATH_TEMPLATES . DIR_SEP . $p_themePath . $p_templateIdOrName;
             if (!is_numeric($p_templateIdOrName) && !is_null($p_themePath) && file_exists($filePath)) {
                 $pathRsc->setPath($p_themePath . $p_templateIdOrName);
                 $this->m_dbObject = $syncResourceService->getSynchronized($pathRsc);
             } else {
                 $this->m_dbObject = $pathRsc;
             }
         }
     }
 }
Exemplo n.º 2
0
 public function indexAction()
 {
     $translator = \Zend_Registry::get('container')->getService('translator');
     $resource = new ResourceId(__CLASS__);
     $themeService = $resource->getService(IThemeService::NAME);
     // item action form
     $form = $this->getActionForm();
     $form->setMethod('post');
     $this->view->form = $form;
     try {
         // get items
         $path = $this->parsePath();
         $folders = $templates = array();
         foreach ($this->service->listItems($path) as $item) {
             $form->file->addMultioption($item->name, $item->name);
             // add possible files
             if (!isset($item->size)) {
                 $folders[] = $item;
                 continue;
             }
             if ($item->name == $themeService->themeConfigFileName) {
                 continue;
             }
             $templates[] = $item;
         }
     } catch (\InvalidArgumentException $e) {
         $this->_helper->flashMessenger(array('error', $e->getMessage()));
         $this->_helper->redirector('index');
     }
     $this->view->folders = $folders;
     $this->view->templates = $templates;
     $request = $this->getRequest();
     if ($request->isPost() && $form->isValid($_POST)) {
         $values = $form->getValues();
         $this->_forward($values['action']);
         return;
     }
     // set current path
     $this->view->path = $this->formatPath($path);
     // get parents
     $parents = explode('/', dirname($path));
     $this->view->parent = implode(self::SEPARATOR, $parents);
     // build breadcrubs for path
     $pages = array($this->buildBreadcrumbs(explode('/', $path)));
     $this->view->moveForm = $this->getMoveForm();
     if ($path == '') {
         $this->view->paths = $this->reqCachePaths;
         // don't move form here
         $this->view->doCache = true;
     }
     $this->view->nav = new Zend_Navigation($pages);
     $this->view->dateFormat = 'Y-m-d H:i';
     $this->view->separator = self::SEPARATOR;
     // redirect parameter in session
     $nextUrl = new Zend_Session_Namespace('upload-next');
     $nextUrl->setExpirationHops(7, 'next', true);
     $nextUrl->next = $this->_request->getParams();
     $this->view->actions = array(array('label' => $translator->trans('Upload', array(), 'themes'), 'module' => 'admin', 'controller' => 'template', 'action' => 'upload', 'class' => 'upload', 'reset_params' => false), array('label' => $translator->trans('Create folder', array(), 'themes'), 'uri' => '#create-folder', 'class' => 'add'), array('label' => $translator->trans('Create file', array(), 'themes'), 'uri' => '#create-file', 'class' => 'add'));
 }
Exemplo n.º 3
0
 /**
  * @param Newscoop\Storage $storage
  * @param Newscoop\Entity\Repository\TemplateRepository $repository
  */
 public function __construct(Storage $storage, TemplateRepository $repository)
 {
     $this->storage = $storage;
     $this->repository = $repository;
     $resourceId = new ResourceId('template_engine/metaclasses/MetaTemplate');
     /* @var $syncResourceService ISyncResourceService */
     $this->syncResServ = $resourceId->getService(ISyncResourceService::NAME);
 }
Exemplo n.º 4
0
 protected function getThemePath()
 {
     $resourceId = new ResourceId(__CLASS__);
     $outSetIssueService = $resourceId->getService(IOutputSettingIssueService::NAME);
     $outSets = $outSetIssueService->findByIssue($this->m_dbObject->getIssueId());
     if (count($outSets) == 0) {
         return null;
     }
     return $outSets[0]->getThemePath()->getPath();
 }
Exemplo n.º 5
0
 protected function getThemePath()
 {
     $resourceId = new ResourceId(__CLASS__);
     $themeService = $resourceId->getService(IThemeManagementService::NAME_1);
     $outSets = $themeService->getThemes($this->m_dbObject->getPublicationId());
     if (count($outSets) == 0) {
         return null;
     }
     return $outSets[0]->getPath();
 }
Exemplo n.º 6
0
if (empty($f_url_name)) {
    camp_html_add_msg($translator->trans('You must fill in the $1 field.', array('$1' => "'" . $translator->trans('URL Name') . "'")));
}
if (!camp_is_valid_url_name($f_url_name)) {
    camp_html_add_msg($translator->trans('The $1 field may only contain letters, digits and underscore (_) character.', array('$1' => "'" . $translator->trans('URL Name') . "'")));
}
if (camp_html_has_msgs()) {
    camp_html_goto_page($backLink);
}
$changed = true;
$changed &= $issueObj->setName($f_issue_name);
if ($issueObj->getWorkflowStatus() == 'Y') {
    $changed &= $issueObj->setPublicationDate($f_publication_date);
}
//@New theme management
$resourceId = new ResourceId('Publication/Edit');
$themeManagementService = $resourceId->getService(IThemeManagementService::NAME_1);
$outputSettingIssueService = $resourceId->getService(IOutputSettingIssueService::NAME);
$outputService = $resourceId->getService(IOutputService::NAME);
$issueService = $resourceId->getService(IIssueService::NAME);
$syncRsc = $resourceId->getService(ISyncResourceService::NAME);
$newOutputSetting = false;
$outSetIssues = $outputSettingIssueService->findByIssue($issueObj->getIssueId());
if (count($outSetIssues) > 0) {
    $outSetIssue = $outSetIssues[0];
} else {
    $outSetIssue = new OutputSettingsIssue();
    $outSetIssue->setOutput($outputService->findByName('Web'));
    $outSetIssue->setIssue($issueService->getById($issueObj->getIssueId()));
    $newOutputSetting = true;
}
Exemplo n.º 7
0
 /**
  * Sets the URI path and query values based on given parameters.
  *
  * @param array   $p_params
  *                           An array of valid URL parameters
  * @param boolean $p_preview
  *                           If true, will keep the preview parameters in the URL
  *
  * @return void
  */
 protected function buildURI(array &$p_params = array(), $p_preview = false)
 {
     if ($this->isValidCache()) {
         return;
     }
     $parameter = count($p_params) > 0 ? strtolower(array_shift($p_params)) : null;
     switch ($parameter) {
         case 'language':
         case 'publication':
             $this->m_buildPath = $this->getURILanguage();
             if ($p_preview) {
                 $this->m_buildQueryArray = $this->getQueryArray(CampURI::$m_previewParameters);
             } else {
                 $this->m_buildQueryArray = array();
             }
             $p_params = array();
             break;
         case 'issue':
             $this->m_buildPath = $this->getURIIssue();
             if ($p_preview) {
                 $this->m_buildQueryArray = $this->getQueryArray(CampURI::$m_previewParameters);
             } else {
                 $this->m_buildQueryArray = array();
             }
             $p_params = array();
             break;
         case 'section':
             $this->m_buildPath = $this->getURISection();
             if ($p_preview) {
                 $this->m_buildQueryArray = $this->getQueryArray(CampURI::$m_previewParameters);
             } else {
                 $this->m_buildQueryArray = array();
             }
             $p_params = array();
             break;
         case 'article':
             $this->m_buildPath = $this->getURIArticle();
             if ($p_preview) {
                 $this->m_buildQueryArray = $this->getQueryArray(CampURI::$m_previewParameters);
             } else {
                 $this->m_buildQueryArray = array();
             }
             $p_params = array();
             break;
         case 'template':
         case 'id':
             $option = isset($p_params[0]) ? array_shift($p_params) : null;
             if (is_null($option)) {
                 break;
             }
             if (is_null($this->_themePath)) {
                 $themesService = \Zend_Registry::get('container')->getService('newscoop_newscoop.themes_service');
                 $this->_themePath = $themesService->getThemePath();
             }
             $pathRsc = new Resource();
             $pathRsc->setName('buildPage');
             $pathRsc->setPath($this->_themePath . $option);
             $resourceId = new ResourceId('template_engine/classes/CampURIShortNames');
             $pathRsc = $resourceId->getService(ISyncResourceService::NAME)->getSynchronized($pathRsc);
             if (!is_null($pathRsc) && $pathRsc->exists()) {
                 $this->m_buildQueryArray[CampRequest::TEMPLATE_ID] = $pathRsc->getId();
             }
             break;
         default:
             if (!empty($parameter)) {
                 array_unshift($p_params, $parameter);
                 $count = count($p_params);
                 parent::buildURI($p_params, $p_preview);
                 if (count($p_params) == $count) {
                     array_shift($p_params);
                 }
             }
     }
     if (count($p_params) > 0) {
         $this->buildURI($p_params);
     }
     if (!is_null($this->m_language) && $this->m_language->defined() && is_null($this->m_buildPath)) {
         $this->m_buildPath = '/' . $this->m_language->code . '/';
         if (!is_null($this->m_issue) && $this->m_issue->defined()) {
             $this->m_buildPath .= $this->m_issue->url_name . '/';
             if (!is_null($this->m_section) && $this->m_section->defined()) {
                 $this->m_buildPath .= $this->m_section->url_name . '/';
                 if (!is_null($this->m_article) && $this->m_article->defined()) {
                     $this->m_buildPath = $this->getURIArticle();
                 }
             }
         }
     }
     if (is_null($this->m_buildQuery)) {
         $this->m_buildQuery = CampURI::QueryArrayToString($this->m_buildQueryArray);
     }
     $this->validateCache(true);
 }
Exemplo n.º 8
0
$excludeLanguageIds = DbObjectArray::GetColumn($issueTranslations, 'IdLanguage');
$allEvents = IssuePublish::GetIssueEvents($Pub, $Issue, $Language);
$publish_date = date("Y-m-d");
$publish_hour = date("H") + 1;
$publish_min = "00";
camp_html_content_top(getGS('Change issue details'), array('Pub' => $publicationObj, 'Issue' => $issueObj), true, true);
$url_args1 = "Pub={$Pub}";
$url_args2 = $url_args1 . "&Issue={$Issue}&Language={$Language}";
$url_args3 = "f_publication_id={$Pub}&f_issue_number={$Issue}&f_language_id={$Language}";
if (Issue::GetNumIssues($Pub) <= 0) {
    $url_add = "add_new.php";
} else {
    $url_add = "qadd.php";
}
//@New theme management
$resourceId = new ResourceId('Publication/Edit');
$themeManagementService = $resourceId->getService(IThemeManagementService::NAME_1);
$outputSettingIssueService = $resourceId->getService(IOutputSettingIssueService::NAME);
$outSetIssues = $outputSettingIssueService->findByIssue($issueObj->getIssueId());
$themePath = null;
$tplFrontPath = null;
$tplSectionPath = null;
$tplArticlePath = null;
if (count($outSetIssues) > 0) {
    $outSetIssue = $outSetIssues[0];
    $themePath = $outSetIssue->getThemePath()->getPath();
    if ($outSetIssue->getFrontPage() != null) {
        $tplFrontPath = $outSetIssue->getFrontPage()->getPath();
    }
    if ($outSetIssue->getSectionPage() != null) {
        $tplSectionPath = $outSetIssue->getSectionPage()->getPath();
Exemplo n.º 9
0
 public static function GetArticleTemplate($p_lngId, $p_pubId, $p_issNr, $p_sctNr)
 {
     global $g_ado_db;
     $cacheService = \Zend_Registry::get('container')->getService('newscoop.cache');
     $cacheKey = $cacheService->getCacheKey(array('GetArticleTemplate', $p_lngId, $p_pubId, $p_issNr, $p_sctNr), 'article');
     if ($cacheService->contains($cacheKey)) {
         return $cacheService->fetch($cacheKey);
     } else {
         $resourceId = new ResourceId('template_engine/classes/CampSystem');
         $outputService = $resourceId->getService(IOutputService::NAME);
         if (!\Zend_Registry::isRegistered('webOutput')) {
             $cacheKeyWebOutput = $cacheService->getCacheKey(array('OutputService', 'Web'), 'outputservice');
             if ($cacheService->contains($cacheKeyWebOutput)) {
                 \Zend_Registry::set('webOutput', $cacheService->fetch($cacheKeyWebOutput));
             } else {
                 $webOutput = $outputService->findByName('Web');
                 $cacheService->save($cacheKeyWebOutput, $webOutput);
                 \Zend_Registry::set('webOutput', $webOutput);
             }
         }
         $templateSearchService = $resourceId->getService(ITemplateSearchService::NAME);
         $sectionObj = new Section($p_pubId, $p_issNr, $p_lngId, $p_sctNr);
         $data = $templateSearchService->getArticlePage($sectionObj->getSectionId(), \Zend_Registry::get('webOutput'));
         if (empty($data)) {
             $data = self::GetInvalidURLTemplate($p_pubId, $p_issNr, $p_lngId);
         }
         $cacheService->save($cacheKey, $data);
         return $data;
     }
     // fn GetArticleTemplate
 }
Exemplo n.º 10
0
    camp_html_add_msg(getGS('You must fill in the $1 field.', '"' . getGS('Name') . '"'));
}
if ($cShortName == "") {
    camp_html_add_msg(getGS('You must fill in the $1 field.', '"' . getGS('URL Name') . '"'));
}
$isValidShortName = camp_is_valid_url_name($cShortName);
if (!$isValidShortName) {
    camp_html_add_msg(getGS('The $1 field may only contain letters, digits and underscore (_) character.', '"' . getGS('URL Name') . '"'));
}
$editUrl = "/{$ADMIN}/sections/edit.php?Pub={$Pub}&Issue={$Issue}&Language={$Language}&Section={$Section}";
if (!camp_html_has_msgs()) {
    $modified = true;
    $modified &= $sectionObj->setName($cName);
    $modified &= $sectionObj->setDescription($cDescription);
    //@New theme management
    $resourceId = new ResourceId('Section/Edit');
    $outputSettingSectionService = $resourceId->getService(IOutputSettingSectionService::NAME);
    $outputService = $resourceId->getService(IOutputService::NAME);
    $sectionService = $resourceId->getService(ISectionService::NAME);
    $syncRsc = $resourceId->getService(ISyncResourceService::NAME);
    $newOutputSetting = false;
    $dSection = $sectionService->getById($sectionObj->getSectionId());
    $outSetSections = $outputSettingSectionService->findBySection($dSection);
    if (count($outSetSections) > 0) {
        $outSetSection = $outSetSections[0];
    } else {
        $outSetSection = new OutputSettingsSection();
        $outSetSection->setOutput($outputService->findByName('Web'));
        $outSetSection->setSection($dSection);
        $newOutputSetting = true;
    }
Exemplo n.º 11
0
 public static function GetArticleTemplate($p_lngId, $p_pubId, $p_issNr, $p_sctNr)
 {
     global $g_ado_db;
     if (CampCache::IsEnabled()) {
         $paramString = $p_lngId . '_' . $p_pubId . '_' . $p_issNr . '_' . $p_sctNr;
         $cacheKey = __CLASS__ . '_ArticleTemplate_' . $paramString;
         $articleTemplate = CampCache::singleton()->fetch($cacheKey);
         if ($articleTemplate !== false && !empty($articleTemplate)) {
             return $articleTemplate;
         }
     }
     $resourceId = new ResourceId('template_engine/classes/CampSystem');
     /* @var $templateSearchService ITemplateSearchService */
     $templateSearchService = $resourceId->getService(ITemplateSearchService::NAME);
     $outputService = $resourceId->getService(IOutputService::NAME);
     $sectionObj = new Section($p_pubId, $p_issNr, $p_lngId, $p_sctNr);
     $data = $templateSearchService->getArticlePage($sectionObj->getSectionId(), $outputService->findByName('Web'));
     if (empty($data)) {
         $data = self::GetInvalidURLTemplate($p_pubId, $p_issNr, $p_lngId);
     }
     if (CampCache::IsEnabled()) {
         CampCache::singleton()->store($cacheKey, $data);
     }
     return $data;
 }
Exemplo n.º 12
0
<?php

use Newscoop\Service\Resource\ResourceId;
use Newscoop\Service\IThemeManagementService;
//@New theme management
$resourceId = new ResourceId('Publication/Edit');
$themeManagementService = $resourceId->getService(IThemeManagementService::NAME_1);
$themePath = $_REQUEST['themePath'];
if ($themePath != null && $themePath != '0') {
    $allTemplates = $themeManagementService->getTemplates($themePath);
} else {
    $allTemplates = array();
}
$ret = array();
foreach ($allTemplates as $template) {
    $ret[$template->getPath()] = $template->getName();
}
echo json_encode($ret);
exit;
Exemplo n.º 13
0
 /**
  * Returns whether the template name given is a valid template resource.
  *
  * @param string $p_templateName
  *                               The name of the template from the URI path
  *
  * @return boolean
  *                 true on success, false on failure
  */
 protected function isValidTemplate($p_templateName)
 {
     if (is_null($this->m_issue) || !$this->m_issue->defined()) {
         return false;
     }
     $resourceId = new ResourceId(__CLASS__);
     $syncResService = $resourceId->getService(ISyncResourceService::NAME);
     return !is_null($syncResService->findByPath($this->getThemePath() . $p_templateName));
 }