public function create()
 {
     $view = $this->getView();
     $m = new NavigationModel();
     $form = Form::BuildFromModel($m);
     $form->set('callsmethod', 'NavigationController::_SaveHandler');
     // I only want non-fuzzy pages to display.
     //$views = PageModel::GetPagesAsOptions("fuzzy = 0");
     $views = PageModel::GetPagesAsOptions();
     $view->mastertemplate = 'admin';
     $view->title = 'New Navigation Menu';
     $view->templatename = '/pages/navigation/create.tpl';
     $view->assignVariable('model', $m);
     $view->assignVariable('form', $form);
     $view->assignVariable('pages', $views);
     $view->addControl('Navigation Listings', '/Navigation', 'directory');
 }
예제 #2
0
 /**
  * Get the rendered HTML template for the advlink plugin.
  *
  * This needs to be a full controller because it requires some of core+'s functionality to determine pages.
  *
  * @deprecated v4.1.0
  */
 public function link()
 {
     $view = $this->getView();
     // Since this will deal with mainly frontend data, it's doubtful that the admin would want to list admin pages.
     $pages = PageModel::GetPagesAsOptions('admin = 0');
     // For each page, resolve the url to a full url for this site.  Useful because I cannot guarantee correct
     // resolution after it goes through tinyMCE's logic.
     $pagesresolved = array();
     foreach ($pages as $url => $title) {
         $pagesresolved[\Core\resolve_link($url)] = $title;
     }
     $tplname = Template::ResolveFile('pages/tinymce/link.phtml');
     $view->overrideTemplate(new Core\Templates\Backends\PHTML());
     $view->mastertemplate = false;
     $view->templatename = $tplname;
     $view->assign('pages', $pagesresolved);
 }
예제 #3
0
	public function testBug(){
		$selectablepage = PageModel::Find(['selectable' => 1], null);
		$notselectablepage = PageModel::Find(['selectable' => 0], null);

		// Both of these should return an array!
		$this->assertNotEmpty($selectablepage);
		$this->assertNotEmpty($notselectablepage);

		// And this needs to be an array too.
		$pagearray = PageModel::GetPagesAsOptions();
		$this->assertNotEmpty($pagearray);

		// Run through each selectable page and make sure that it displays in the list.
		foreach($selectablepage as $page){
			$this->assertInstanceOf('PageModel', $page);
			$this->assertArrayHasKey($page->get('baseurl'), $pagearray);
		}

		foreach($notselectablepage as $page){
			$this->assertInstanceOf('PageModel', $page);
			$this->assertArrayNotHasKey($page->get('baseurl'), $pagearray);
		}
	}
예제 #4
0
	public function  __construct($atts = null) {
		error_log(__CLASS__ . ' is candidate for immediate removal, please change this code!', E_USER_DEPRECATED);

		// Defaults
		$this->_attributes['name']    = 'page';

		if ($atts instanceof PageModel) {
			parent::__construct(array('name' => 'page'));

			$page = $atts;
		}
		else {
			if(isset($atts['model']) && $atts['model'] instanceof PageModel){
				// Everything is based off the page.
				$page = $atts['model'];
				unset($atts['model']);

				parent::__construct($atts);
			}
			else{
				parent::__construct($atts);

				// BaseURL needs to be set for this to work.
				//if(!$this->get('baseurl')) return null;

				// Everything is based off the page.
				$page = new PageModel($this->get('baseurl'));
			}
		}

		$this->_attributes['baseurl'] = $page->get('baseurl');
		$name = $this->_attributes['name'];

		// I need to get a list of pages to offer as a dropdown for selecting the "parent" page.
		$f = new ModelFactory('PageModel');
		if ($this->get('baseurl')) $f->where('baseurl != ' . $this->get('baseurl'));
		$opts = PageModel::GetPagesAsOptions($f, '-- No Parent Page --');

		$this->addElement(
			'pageparentselect',
			array(
				'name'    => $name . "[parenturl]",
				'title'   => 'Parent Page',
				'value'   => strtolower($page->get('parenturl')),
				'options' => $opts
			)
		);

		// Title
		$this->addElement(
			'text', array(
				      'name'        => $name . "[title]",
				      'title'       => 'Title',
				      'value'       => $page->get('title'),
				      'description' => 'Every page needs a title to accompany it, this should be short but meaningful.',
				      'required'    => true
			      )
		);

		// Rewrite url.
		$this->addElement(
			'pagerewriteurl', array(
				                'name'        => $name . "[rewriteurl]",
				                'title'       => 'Page URL',
				                'value'       => $page->get('rewriteurl'),
				                'description' => 'Starts with a "/", omit ' . ROOT_URL,
				                'required'    => true
			                )
		);

		$this->addElement(
			'access', array(
				        'name'  => $name . "[access]",
				        'title' => 'Access Permissions',
				        'value' => $page->get('access')
			        )
		);

		$this->addElement(
			'pagemetas',
			array(
				'name' => $name . '_meta',
				'model' => $page,
			)
		);

		// Give me all the skins available on the current theme.
		$skins = array('' => '-- Site Default Skin --');
		foreach(ThemeHandler::GetTheme(null)->getSkins() as $s){
			$n = ($s['title']) ? $s['title'] : $s['file'];
			if($s['default']) $n .= ' (default)';
			$skins[$s['file']] = $n;
		}
		if(sizeof($skins) > 2){
			$this->addElement(
				'select', array(
					        'name'    => $name . "[theme_template]",
					        'title'   => 'Theme Skin',
					        'value'   => $page->get('theme_template'),
					        'options' => $skins
				        )
			);
		}
	}
예제 #5
0
	/**
	 * Display a listing of all pages registered in the system.
	 */
	public function pages(){
		$view = $this->getView();
		$request = $this->getPageRequest();

		if(!\Core\user()->checkAccess('p:/core/pages/view')){
			return View::ERROR_ACCESSDENIED;
		}

		// Build a list of create pages for all registered components.
		$components = Core::GetComponents();
		$links = [];
		$componentopts = ['' => '-- ' . t('STRING_VIEW_ALL_COMPONENTS') . ' --'];
		foreach($components as $c){
			/** @var Component_2_1 $c */
			foreach($c->getXML()->getElements('/pages/pagecreate') as $node){
				/** @var DOMElement $node */
				$links[] = ['baseurl' => $node->getAttribute('baseurl'), 'title' => $node->getAttribute('title')];
			}

			$componentopts[$c->getKeyName()] = $c->getName();
		}
		// Sort them by name!
		asort($componentopts);

		$pageschema = PageModel::GetSchema();

		$table = new Core\ListingTable\Table();

		$table->setLimit(20);

		// Set the model that this table will be pulling data from.
		$table->setModelName('PageModel');

		// Gimme filters!
		$table->addFilter(
			'text',
			[
				'name' => 'title',
				'title' => t('STRING_TITLE'),
				'link' => FilterForm::LINK_TYPE_CONTAINS,
			]
		);

		$table->addFilter(
			'text',
			[
				'name' => 'rewriteurl',
				'title' => t('STRING_URL'),
				'link' => FilterForm::LINK_TYPE_CONTAINS,
			]
		);

		$table->addFilter(
			'text',
			[
				'name' => 'parenturl',
				'title' => t('STRING_PARENT_URL'),
				'link' => FilterForm::LINK_TYPE_STARTSWITH,
			]
		);

		$table->addFilter(
			'select',
			[
				'name' => 'component',
				'title' => t('STRING_COMPONENT'),
				'options' => $componentopts,
				'link' => FilterForm::LINK_TYPE_STANDARD,
			]
		);

		$table->addFilter(
			'select',
			[
				'name' => 'page_types',
				'title' => t('STRING_INCLUDE_ADMIN_PAGES'),
				'options' => ['all' => t('STRING_VIEW_ALL_PAGES'), 'no_admin' => t('STRING_EXCLUDE_ADMIN_PAGES')],
				'value' => 'no_admin',
			]
		);

		// Add in all the columns for this listing table.
		if(Core::IsComponentAvailable('multisite') && MultiSiteHelper::IsEnabled() && \Core\user()->checkAccess('g:admin')){
			$table->addColumn('Site', 'site', false);
			$ms = true;
		}
		else{
			$ms = false;
		}
		$table->addColumn(t('STRING_TITLE'), 'title');
		$table->addColumn(t('STRING_URL'), 'rewriteurl');
		$table->addColumn(t('STRING_VIEWS'), 'pageviews', false);
		$table->addColumn(t('STRING_SCORE'), 'popularity');
		$table->addColumn(t('STRING_CACHE'), 'expires');
		$table->addColumn(t('STRING_CREATED'), 'created', false);
		$table->addColumn(t('STRING_LAST_UPDATED'), 'updated', false);
		$table->addColumn(t('STRING_STATUS'));
		$table->addColumn(t('STRING_PUBLISHED'), 'published');
		$table->addColumn(t('STRING_EXPIRES'), 'published_expires');
		$table->addColumn(t('STRING_SEO_TITLE'));
		$table->addColumn(t('STRING_SEO_DESCRIPTION'), null, false);
		$table->addColumn(t('STRING_ACCESS'), 'access');
		$table->addColumn(t('STRING_COMPONENT'), 'component', false);

		// This page will also feature a quick-edit feature.
		//$table->setEditFormCaller('AdminController::PagesSave');

		$table->loadFiltersFromRequest();

		if($table->getFilterValue('page_types') == 'no_admin'){
			$table->getModelFactory()->where('admin = 0');
			$table->getModelFactory()->where('selectable = 1');
		}



		$view->title = 't:STRING_ALL_PAGES';
		//$view->assign('filters', $filters);
		//$view->assign('listings', $listings);
		$view->assign('links', $links);

		$view->assign('multisite', $ms);
		$view->assign('listing', $table);
		$view->assign('page_opts', PageModel::GetPagesAsOptions(false, '-- Select Parent URL --'));
		$view->assign('expire_opts', $pageschema['expires']['form']['options']);
	}
예제 #6
0
    public static function IncludeTinyMCE()
    {
        \ComponentHandler::LoadScriptLibrary('jquery');
        /** @var \View $view */
        $view = \Core\view();
        /** @var \UserModel $user */
        $user = \Core\user();
        // I need to include both versions of TinyMCE so that
        // 1) the tinymce object is visible in the global scope at the time of execution and
        // 2) so I can target all inputs by their class name instead of the ID.
        $view->addScript('js/tinymce/tinymce.min.js');
        $view->addScript('js/tinymce/jquery.tinymce.min.js');
        $view->addStylesheet('css/tinymce/overrides.css');
        // Yes, the string needs quotes inside of quotes!  It's to be read by javascript after all.
        $browsable = \Core::IsComponentAvailable('media-manager') && $user->checkAccess('p:/mediamanager/browse');
        $filebrowsercallback = $browsable ? "Core.TinyMCE.FileBrowserCallback" : 'null';
        $loc = \Core\resolve_asset('js/tinymce/tinymce.min.js');
        $content = \Core\resolve_asset('css/tinymce/content.css');
        $pages = \PageModel::GetPagesAsOptions();
        $links = [];
        foreach ($pages as $url => $title) {
            // Trim off the "(...)" at the end of the title.
            // Core adds that as a benefit for knowing
            $links[] = ['title' => html_entity_decode(preg_replace('/(.*) \\([^\\)]*\\)/', '$1', $title)), 'value' => \Core\resolve_link($url)];
        }
        // And json the data.
        $links = json_encode($links);
        // Create the list of plugins
        // Start with standard and tack on any custom ones.
        $plugins = ['advlist', 'anchor', 'autolink', 'charmap', 'code', 'colorpicker', 'contextmenu', 'fullscreen', 'hr', 'image', 'imagetools', 'insertdatetime', 'link', 'lists', 'media', 'pagebreak', 'paste', 'preview', 'searchreplace', 'table', 'textcolor', 'visualblocks', 'visualchars', 'wordcount'];
        $customIncludes = '';
        foreach (self::$CustomPlugins as $name => $src) {
            // The "-" is required to inform TinyMCE not to load the plugin again.
            // It'll be loaded manually via the .load() method as it has a custom URL.
            $plugins[] = '-' . $name;
            // Resolve this src to an absolute URL
            $src = \Core\resolve_asset($src);
            $customIncludes .= 'tinymce.PluginManager.load("' . $name . '", "' . $src . '");';
        }
        // And make them something that javascript can understand.
        $plugins = json_encode($plugins);
        $script = <<<EOD
<script type="text/javascript">

\tCore.TinyMCEDefaults = {
\t\t// Location of TinyMCE script
\t\tscript_url : '{$loc}',

\t\t// General options

\t\tplugins: {$plugins},
\t    toolbar: "undo redo | styleselect | forecolor backcolor bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",

\t\ttheme : "modern",

\t\t// Required to not mungle links.
\t\tconvert_urls: false,

\t\t// Requires to support <script/> tags.
\t\textended_valid_elements : "script[language|type|src]",

\t\t// Core Media Manager integration
\t\tfile_browser_callback: {$filebrowsercallback},

\t\t// Example content CSS (should be your site CSS)
\t\tcontent_css : "{$content}",

\t\t// Drop lists for link/image/media/template dialogs
\t\t//template_external_list_url : "lists/template_list.js",
\t\t//external_link_list_url : "lists/link_list.js",
\t\t//external_image_list_url : "lists/image_list.js",
\t\t//media_external_list_url : "lists/media_list.js",
\t\t link_list: {$links},

\t\t// Replace values for the template plugin
\t\t//template_replace_values : {
\t\t//\tusername : "******",
\t\t//\tstaffid : "991234"
\t\t//}

\t\t__dummy: null
\t};

\t\$(function(){
\t\t{$customIncludes}
\t\t\$('textarea.tinymce').tinymce(Core.TinyMCEDefaults);
\t});
</script>\t
EOD;
        // Add the necessary script
        $view->addScript('assets/js/tinymce/coreplus_functions.js', 'head');
        $view->addScript($script, 'foot');
        // IMPORTANT!  Tells the script that the include succeeded!
        return true;
    }