public static function getModule($module) { $auth = new Auth(); $mod = new Module(); $url = new URL(); $config = new Config(); $pm = new PageManager(); if ($url->getRequestedFunction() == 'angular') { if (!isset($mod->moduleRegister[$module]) && !is_file(realpath(root . DS . "views" . DS) . "/" . $module . ".php") && !$pm->isPage($module)) { return 'error'; } else { if (!$auth->isAdmin() && (isset($mod->moduleRegister[$module][1]) && $mod->moduleRegister[$module][1] == 'admin')) { return 'login'; } else { if (is_file(realpath(root . DS . "views" . DS) . "/" . $module . ".php")) { return $module; } else { if ($pm->isPage($module)) { return $pm->deaultPage; } } } } } else { if (!isset($mod->moduleRegister[$module]) && !is_file(realpath(root . DS . "views" . DS) . "/" . $module . ".php")) { return 'index'; } else { if (isset($mod->moduleRegister[$module]) && !isset($mod->moduleRegister[$module][1])) { return 'index'; } else { if (!$auth->isAdmin() && isset($mod->moduleRegister[$module][1]) && $mod->moduleRegister[$module][1] == 'admin') { if ($auth->isItAuthUser()) { return 'error'; } else { header("Location:" . $config->site_address . "login"); return 'login'; } } else { if ($auth->isItAuthUser() && (isset($mod->moduleRegister[$module][1]) && ($mod->moduleRegister[$module][1] == 'auth' || $mod->moduleRegister[$module][1] == 'admin'))) { return 'dashboard'; } else { if (is_file(realpath(root . DS . "views" . DS) . "/" . $module . ".php")) { return $module; } } } } } } return $mod->moduleRegister[$module][0]; }
/** * Singleton pattern */ public static function get_instance() { if (!self::$instance) { self::$instance = new self(); } return self::$instance; }
public function view() { $params = array('{$today}', '{$current-time}', '{$this-year}', '{$this-month}', '{$this-day}', '{$timezone}', '{$website-name}', '{$page-title}', '{$root}', '{$workspace}', '{$root-page}', '{$current-page}', '{$current-page-id}', '{$current-path}', '{$current-query-string}', '{$current-url}', '{$cookie-username}', '{$cookie-pass}', '{$page-types}', '{$upload-limit}'); // Get page parameters $pages = PageManager::fetch(true, array('params')); foreach ($pages as $key => $pageparams) { if (empty($pageparams['params'])) { continue; } $pageparams = explode('/', $pageparams['params']); foreach ($pageparams as $pageparam) { $param = '{$' . $pageparam . '}'; if (!in_array($param, $params)) { $params[] = $param; } } } // Get Data Sources output parameters $datasources = DatasourceManager::listAll(); foreach ($datasources as $datasource) { $current = DatasourceManager::create($datasource['handle'], array(), false); $prefix = '{$ds-' . Lang::createHandle($datasource['name']) . '.'; $suffix = '}'; // Get parameters if (is_array($current->dsParamPARAMOUTPUT)) { foreach ($current->dsParamPARAMOUTPUT as $id => $param) { $params[] = $prefix . $param . $suffix; } } } sort($params); $this->_Result = json_encode($params); }
public function execute(&$param_pool) { $result = new XMLElement($this->dsParamROOTELEMENT); $type_sql = $parent_sql = null; if (trim($this->dsParamFILTERS['type']) != '') { $type_sql = $this->__processNavigationTypeFilter($this->dsParamFILTERS['type'], $this->__determineFilterType($this->dsParamFILTERS['type'])); } if (trim($this->dsParamFILTERS['parent']) != '') { $parent_sql = $this->__processNavigationParentFilter($this->dsParamFILTERS['parent']); } // Build the Query appending the Parent and/or Type WHERE clauses $pages = Symphony::Database()->fetch(sprintf("\n\t\t\t\t\tSELECT DISTINCT p.id, p.title, p.handle, (SELECT COUNT(id) FROM `tbl_pages` WHERE parent = p.id) AS children\n\t\t\t\t\tFROM `tbl_pages` AS p\n\t\t\t\t\tLEFT JOIN `tbl_pages_types` AS pt ON (p.id = pt.page_id)\n\t\t\t\t\tWHERE 1 = 1\n\t\t\t\t\t%s\n\t\t\t\t\t%s\n\t\t\t\t\tORDER BY p.`sortorder` ASC\n\t\t\t\t", !is_null($parent_sql) ? $parent_sql : " AND p.parent IS NULL ", !is_null($type_sql) ? $type_sql : "")); if (!is_array($pages) || empty($pages)) { if ($this->dsParamREDIRECTONEMPTY == 'yes') { throw new FrontendPageNotFoundException(); } $result->appendChild($this->__noRecordsFound()); } else { // Build an array of all the types so that the page's don't have to do // individual lookups. $page_types = PageManager::fetchAllPagesPageTypes(); foreach ($pages as $page) { $result->appendChild($this->__buildPageXML($page, $page_types)); } } return $result; }
public function get_events() { $pages = PageManager::get(); foreach ($pages as $page) { if ($page['is_event'] == TRUE) { $this->add(new Page($page["title"], $page["content"], $page["date"], $page["id"], $page["author"], $page['is_event'])); } } }
function showIndex() { $pager = new fvPager(PageManager::getInstance()); $this->__assign('Pages', $pager->paginate(null, "IF (page_parent_id = 0, id*100000, page_parent_id*100000 + id)")); $request = fvRequest::getInstance(); if (!($Page = PageManager::getInstance()->getByPk($request->getRequestParameter('id')))) { $Page = new Page(); } $this->__assign(array('Page' => $Page, 'PageManager' => PageManager::getInstance(), 'metaManager' => MetaManager::getInstance())); return $this->__display('page_list.tpl'); }
public function delete() { if ($this->image) { @unlink($this->getImageRealPath()); } $childPages = PageManager::getInstance()->getByPageParentId($this->getPk()); foreach ($childPages as $childPage) { $childPage->page_parent_id = 0; $childPage->save(); } return parent::delete(); }
public function view() { if (!($prototype_id = (int) $_GET['prototype_id'])) { $this->_status = self::STATUS_BAD; $this->_Result = json_encode(array('status' => __('Missing or wrong parameter.'))); return; } $fields = PageManager::fetchPageByID($prototype_id); // return datasources and events as arrays $fields['data_sources'] = explode(',', $fields['data_sources']); $fields['events'] = explode(',', $fields['events']); // remove "prototype" from the type array and reorder $fields['type'] = array_values(array_diff($fields['type'], array('prototype'))); $this->_Result = json_encode($fields); }
public function grab(&$param_pool = null) { $result = new XMLElement('plh-page'); $langs = FLang::getLangs(); $fields = array('id', 'handle', 'parent'); foreach ($langs as $lc) { $fields[] = "`plh_t-{$lc}`"; $fields[] = "`plh_h-{$lc}`"; } $pages = array(); foreach (PageManager::fetch(null, $fields) as $page) { $pages[$page['id']] = $page; } $this->appendPage($pages, $this->_env['param']['current-page-id'], $langs, $result); return $result; }
function __construct() { $currentUrl = fvRoute::getInstance()->getModuleName(); list($p) = (array) PageManager::getInstance()->getByPageUrl($currentUrl); if (is_object($p)) { $this->_pageInstance = $p; } else { fvDispatcher::redirect(fvSite::$fvConfig->get('page_404', 0, 404)); } $this->_domInstance = new DOMDocument(); if (!$this->_domInstance->loadXML($this->_pageInstance->getPageContent())) { fvDispatcher::redirect(fvSite::$fvConfig->get('page_error', 0, 302)); } $this->setMeta($this->_pageInstance->getMeta()); fvSite::$Template->assign("Lang", fvLang::getInstance()); parent::__construct("main.tpl"); }
function executeDelete() { $request = fvRequest::getInstance(); if (!($Page = PageManager::getInstance()->getByPk($request->getRequestParameter('id')))) { $this->setFlash("Ошибка при удалении.", self::$FLASH_ERROR); } else { $Page->getMeta()->delete(); $Page->delete(); $this->setFlash("Данные успешно удалены", self::$FLASH_SUCCESS); } fvResponce::getInstance()->setHeader('redirect', fvSite::$fvConfig->get('dir_web_root') . $request->getRequestParameter('module') . "/"); if (fvRequest::getInstance()->isXmlHttpRequest()) { return self::$FV_NO_LAYOULT; } else { return self::$FV_OK; } }
private function __getPageParams() { $params = array(); $pages = PageManager::fetch(true, array('params')); foreach ($pages as $key => $pageparams) { if (empty($pageparams['params'])) { continue; } $pageparams = explode('/', $pageparams['params']); foreach ($pageparams as $pageparam) { $param = sprintf($this->template, $pageparam); if (!in_array($param, $params)) { $params[] = $param; } } } return $params; }
public function view() { $items = $_REQUEST['items']; if (!is_array($items) || empty($items)) { return; } $destination = self::kREORDER_UNKNOWN; if ($this->_context[0] == 'blueprints' && $this->_context[1] == 'pages') { $destination = self::kREORDER_PAGES; } elseif ($this->_context[0] == 'blueprints' && $this->_context[1] == 'sections') { $destination = self::kREORDER_SECTIONS; } elseif ($this->_context[0] == 'extensions') { $destination = self::kREORDER_EXTENSION; } switch ($destination) { case self::kREORDER_PAGES: foreach ($items as $id => $position) { if (!PageManager::edit($id, array('sortorder' => $position))) { $this->setHttpStatus(self::HTTP_STATUS_ERROR); $this->_Result->setValue(__('A database error occurred while attempting to reorder.')); break; } } break; case self::kREORDER_SECTIONS: foreach ($items as $id => $position) { if (!SectionManager::edit($id, array('sortorder' => $position))) { $this->setHttpStatus(self::HTTP_STATUS_ERROR); $this->_Result->setValue(__('A database error occurred while attempting to reorder.')); break; } } break; case self::kREORDER_EXTENSION: // TODO break; case self::kREORDER_UNKNOWN: default: $this->setHttpStatus(self::HTTP_STATUS_BAD_REQUEST); break; } }
public function route(Zend_Controller_Request_Abstract $request) { // Let the Rewrite router route the request first $request = parent::route($request); logFire("ROUTE", $request->getParam('controller')); if ($request->getParam('controller') == '') { // If the page param isn't set, route to default page and controller $defaultPage = PageManager::getInstance()->getDefaultPage(); $request->setControllerName($defaultPage->pageType->controller); $request->setParam('controller', $defaultPage->page); $request->setParam('action', 'index'); } else { // Route to current page's controller $controller = PageManager::getInstance()->getPage($request->getParam('controller')); $request->setControllerName($controller->pageType->controller); $request->setActionName('index'); } $request->setParam('controller', 'search'); $request->setParam('action', 'search'); return $request; }
/** * * Method called by Symphony in order to build the * @param $param_pool * @return XMLElement */ public function grab(&$param_pool) { // get the current page id $current_page_id = (int) $this->_env['param']['current-page-id']; // prepare output $result = new XMLElement($this->dsParamROOTELEMENT); // if multilangual extensions are enabled if ($this->isMultiLangual) { // current language $lang = LanguageRedirect::instance()->getLanguageCode(); } // get current page title including all parents $titles = PageManager::resolvePage($current_page_id, isset($lang) ? 'page_lhandles_t_' . $lang : 'title'); // get current page path including all parents $handles = PageManager::resolvePage($current_page_id, isset($lang) ? 'page_lhandles_h_' . $lang : 'handle'); // generate the output foreach ($titles as $key => $title) { $path = implode('/', array_slice($handles, 0, $key + 1)); $result->appendChild(new XMLElement('page', $title, array('path' => $path))); } // return xml result set return $result; }
private function buildTree($parent = null, $indent = 0) { if ($parent == null) { $results = PageManager::fetch(true, array(), array('`parent` IS NULL'), '`sortorder` ASC'); } else { $results = PageManager::fetch(true, array(), array('`parent` = ' . $parent), '`sortorder` ASC'); } $tree = array(); foreach ($results as $result) { // Check if the page should be shown: if (!in_array('ck_hide', $result['type'])) { $prefix = ''; $info = array('handle' => $result['handle'], 'path' => $result['path']); if ($result['path'] == null) { $info['url'] = '/' . $result['handle'] . '/'; $info['title'] = $result['title']; } else { $info['url'] = '/' . $result['path'] . '/' . $result['handle'] . '/'; for ($i = 0; $i < $indent; $i++) { $prefix .= ' '; // Please note: this might look like an empty space (nbsp) but it's an em space (emsp). // This was necessary because kept showing as plain text in the dropdown. } $info['title'] = $prefix . ' › ' . General::sanitize($result['title']); } $tree[] = $info; // Check if there are templates for this page: $tree = array_merge($tree, $this->checkTemplates($result['id'], $prefix . ' ')); // also an emsp // Get the children: $children = $this->buildTree($result['id'], $indent + 1); // Join arrays: $tree = array_merge($tree, $children); } } return $tree; }
/** * Append presets * @param $context */ public function appendPresets($context) { Symphony::Engine()->Page->addScriptToHead(URL . '/extensions/ckeditor/assets/preferences.js', 4676); $wrapper = $context['wrapper']; $fieldset = new XMLElement('fieldset', '', array('class' => 'settings')); $fieldset->appendChild(new XMLElement('legend', __('CKEditor File Browser'))); $sectionManager = new SectionManager($this); $sections = $sectionManager->fetch(); // Check which sections are allowed: $data = Symphony::Configuration()->get('sections', 'ckeditor'); $checkedSections = $data != false ? explode(',', $data) : array(); // If there are no sections found: if ($sections) { $options = array(); foreach ($sections as $section) { $options[] = array($section->get('id'), in_array($section->get('id'), $checkedSections), $section->get('name')); } $label = Widget::Label(__('Permitted sections for the file browser:')); $label->appendChild(Widget::Select('ckeditor_sections[]', $options, array('multiple' => 'multiple'))); $fieldset->appendChild($label); } // Link templates for CKEditor: $sections = SectionManager::fetch(); $dbpages = PageManager::fetch(); $pages = array(); // Filter out the ck_hide: foreach ($dbpages as $page) { $types = PageManager::fetchPageTypes($page['id']); if (!in_array('ck_hide', $types)) { $pages[] = $page; } } // Adjust page title: foreach ($pages as &$_page) { $p = $_page; $title = $_page['title']; while (!is_null($p['parent'])) { $p = PageManager::fetch(false, array(), array('id' => $p['parent'])); $title = $p['title'] . ' : ' . $title; } $_page['title'] = $title; } // Sort the array: $titles = array(); foreach ($pages as $key => $row) { $titles[$key] = strtolower($row['title']); } array_multisort($titles, SORT_ASC, $pages); $this->sections = array(); foreach ($sections as $s) { $a = array('id' => $s->get('id'), 'name' => $s->get('name'), 'fields' => array()); $fields = FieldManager::fetch(null, $s->get('id')); foreach ($fields as $field) { // For now, only allow fields of the type 'input' to be used as a handle: if ($field->get('type') == 'input') { $a['fields'][] = array('id' => $field->get('id'), 'label' => $field->get('label'), 'element_name' => $field->get('element_name')); } } $this->sections[] = $a; } $fieldset->appendChild(new XMLElement('p', __('Link templates:'), array('class' => 'label'))); $ol = new XMLElement('ol'); $ol->setAttribute('class', 'ckeditor-duplicator'); $templates = Symphony::Database()->fetch('SELECT * FROM `tbl_ckeditor_link_templates`;'); if (!is_array($pages)) { $pages = array($pages); } foreach ($pages as $page) { foreach ($templates as $template) { if ($template['page_id'] != $page['id']) { continue; } $duplicator = $this->__buildDuplicatorItem($page, $template); $ol->appendChild($duplicator); } $duplicator = $this->__buildDuplicatorItem($page, NULL); $ol->appendChild($duplicator); } $fieldset->appendChild($ol); $wrapper->appendChild($fieldset); }
public function __formAction() { $fields = $_POST['fields']; $this->_errors = array(); $providers = Symphony::ExtensionManager()->getProvidersOf(iProvider::DATASOURCE); $providerClass = null; if (trim($fields['name']) == '') { $this->_errors['name'] = __('This is a required field'); } if ($fields['source'] == 'static_xml') { if (trim($fields['static_xml']) == '') { $this->_errors['static_xml'] = __('This is a required field'); } else { $xml_errors = null; include_once TOOLKIT . '/class.xsltprocess.php'; General::validateXML($fields['static_xml'], $xml_errors, false, new XsltProcess()); if (!empty($xml_errors)) { $this->_errors['static_xml'] = __('XML is invalid.'); } } } elseif (is_numeric($fields['source'])) { if (strlen(trim($fields['max_records'])) == 0 || is_numeric($fields['max_records']) && $fields['max_records'] < 1) { if ($fields['paginate_results'] === 'yes') { $this->_errors['max_records'] = __('A result limit must be set'); } } elseif (!self::__isValidPageString($fields['max_records'])) { $this->_errors['max_records'] = __('Must be a valid number or parameter'); } if (strlen(trim($fields['page_number'])) == 0 || is_numeric($fields['page_number']) && $fields['page_number'] < 1) { if ($fields['paginate_results'] === 'yes') { $this->_errors['page_number'] = __('A page number must be set'); } } elseif (!self::__isValidPageString($fields['page_number'])) { $this->_errors['page_number'] = __('Must be a valid number or parameter'); } // See if a Provided Datasource is saved } elseif (!empty($providers)) { foreach ($providers as $providerClass => $provider) { if ($fields['source'] == call_user_func(array($providerClass, 'getSource'))) { call_user_func_array(array($providerClass, 'validate'), array(&$fields, &$this->_errors)); break; } unset($providerClass); } } $classname = Lang::createHandle($fields['name'], 255, '_', false, true, array('@^[^a-z\\d]+@i' => '', '/[^\\w-\\.]/i' => '')); $rootelement = str_replace('_', '-', $classname); // Check to make sure the classname is not empty after handlisation. if (empty($classname) && !isset($this->_errors['name'])) { $this->_errors['name'] = __('Please ensure name contains at least one Latin-based character.', array($classname)); } $file = DATASOURCES . '/data.' . $classname . '.php'; $isDuplicate = false; $queueForDeletion = null; if ($this->_context[0] == 'new' && is_file($file)) { $isDuplicate = true; } elseif ($this->_context[0] == 'edit') { $existing_handle = $this->_context[1]; if ($classname != $existing_handle && is_file($file)) { $isDuplicate = true; } elseif ($classname != $existing_handle) { $queueForDeletion = DATASOURCES . '/data.' . $existing_handle . '.php'; } } // Duplicate if ($isDuplicate) { $this->_errors['name'] = __('A Data source with the name %s already exists', array('<code>' . $classname . '</code>')); } if (empty($this->_errors)) { $filters = array(); $elements = null; $source = $fields['source']; $params = array('rootelement' => $rootelement); $about = array('name' => $fields['name'], 'version' => 'Symphony ' . Symphony::Configuration()->get('version', 'symphony'), 'release date' => DateTimeObj::getGMT('c'), 'author name' => Symphony::Author()->getFullName(), 'author website' => URL, 'author email' => Symphony::Author()->get('email')); // If there is a provider, get their template if ($providerClass) { $dsShell = file_get_contents(call_user_func(array($providerClass, 'getTemplate'))); } else { $dsShell = file_get_contents($this->getTemplate('blueprints.datasource')); } // Author metadata self::injectAboutInformation($dsShell, $about); // Do dependencies, the template file must have <!-- CLASS NAME --> $dsShell = str_replace('<!-- CLASS NAME -->', $classname, $dsShell); // If there is a provider, let them do the prepartion work if ($providerClass) { $dsShell = call_user_func(array($providerClass, 'prepare'), $fields, $params, $dsShell); } else { switch ($source) { case 'authors': $extends = 'AuthorDatasource'; if (isset($fields['filter']['author'])) { $filters = $fields['filter']['author']; } $elements = $fields['xml_elements']; $params['order'] = $fields['order']; $params['redirectonempty'] = $fields['redirect_on_empty']; $params['redirectonforbidden'] = $fields['redirect_on_forbidden']; $params['redirectonrequired'] = $fields['redirect_on_required']; $params['requiredparam'] = trim($fields['required_url_param']); $params['negateparam'] = trim($fields['negate_url_param']); $params['paramoutput'] = $fields['param']; $params['sort'] = $fields['sort']; break; case 'navigation': $extends = 'NavigationDatasource'; if (isset($fields['filter']['navigation'])) { $filters = $fields['filter']['navigation']; } $params['order'] = $fields['order']; $params['redirectonempty'] = $fields['redirect_on_empty']; $params['redirectonforbidden'] = $fields['redirect_on_forbidden']; $params['redirectonrequired'] = $fields['redirect_on_required']; $params['requiredparam'] = trim($fields['required_url_param']); $params['negateparam'] = trim($fields['negate_url_param']); break; case 'static_xml': $extends = 'StaticXMLDatasource'; $fields['static_xml'] = trim($fields['static_xml']); if (preg_match('/^<\\?xml/i', $fields['static_xml']) == true) { // Need to remove any XML declaration $fields['static_xml'] = preg_replace('/^<\\?xml[^>]+>/i', null, $fields['static_xml']); } $params['static'] = sprintf('%s', trim($fields['static_xml'])); break; default: $extends = 'SectionDatasource'; $elements = $fields['xml_elements']; if (is_array($fields['filter']) && !empty($fields['filter'])) { $filters = array(); foreach ($fields['filter'] as $f) { foreach ($f as $key => $val) { $filters[$key] = $val; } } } $params['order'] = $fields['order']; $params['group'] = $fields['group']; $params['paginateresults'] = $fields['paginate_results']; $params['limit'] = $fields['max_records']; $params['startpage'] = $fields['page_number']; $params['redirectonempty'] = $fields['redirect_on_empty']; $params['redirectonforbidden'] = $fields['redirect_on_forbidden']; $params['redirectonrequired'] = $fields['redirect_on_required']; $params['requiredparam'] = trim($fields['required_url_param']); $params['negateparam'] = trim($fields['negate_url_param']); $params['paramoutput'] = $fields['param']; $params['sort'] = $fields['sort']; $params['htmlencode'] = $fields['html_encode']; $params['associatedentrycounts'] = $fields['associated_entry_counts']; break; } $this->__injectVarList($dsShell, $params); $this->__injectIncludedElements($dsShell, $elements); self::injectFilters($dsShell, $filters); if (preg_match_all('@(\\$ds-[0-9a-z_\\.\\-]+)@i', $dsShell, $matches)) { $dependencies = General::array_remove_duplicates($matches[1]); $dsShell = str_replace('<!-- DS DEPENDENCY LIST -->', "'" . implode("', '", $dependencies) . "'", $dsShell); } $dsShell = str_replace('<!-- CLASS EXTENDS -->', $extends, $dsShell); $dsShell = str_replace('<!-- SOURCE -->', $source, $dsShell); } if ($this->_context[0] == 'new') { /** * Prior to creating the Datasource, the file path where it will be written to * is provided and well as the contents of that file. * * @delegate DatasourcePreCreate * @since Symphony 2.2 * @param string $context * '/blueprints/datasources/' * @param string $file * The path to the Datasource file * @param string $contents * The contents for this Datasource as a string passed by reference * @param array $params * An array of all the `$dsParam*` values * @param array $elements * An array of all the elements included in this datasource * @param array $filters * An associative array of all the filters for this datasource with the key * being the `field_id` and the value the filter. * @param array $dependencies * An array of dependencies that this datasource has */ Symphony::ExtensionManager()->notifyMembers('DatasourcePreCreate', '/blueprints/datasources/', array('file' => $file, 'contents' => &$dsShell, 'params' => $params, 'elements' => $elements, 'filters' => $filters, 'dependencies' => $dependencies)); } else { /** * Prior to editing a Datasource, the file path where it will be written to * is provided and well as the contents of that file. * * @delegate DatasourcePreEdit * @since Symphony 2.2 * @param string $context * '/blueprints/datasources/' * @param string $file * The path to the Datasource file * @param string $contents * The contents for this Datasource as a string passed by reference * @param array $dependencies * An array of dependencies that this datasource has * @param array $params * An array of all the `$dsParam*` values * @param array $elements * An array of all the elements included in this datasource * @param array $filters * An associative array of all the filters for this datasource with the key * being the `field_id` and the value the filter. */ Symphony::ExtensionManager()->notifyMembers('DatasourcePreEdit', '/blueprints/datasources/', array('file' => $file, 'contents' => &$dsShell, 'dependencies' => $dependencies, 'params' => $params, 'elements' => $elements, 'filters' => $filters)); } // Remove left over placeholders $dsShell = preg_replace(array('/<!--[\\w ]++-->/', '/(\\t+[\\r\\n]){2,}/', '/(\\r\\n){2,}/'), '$1', $dsShell); // Write the file if (!is_writable(dirname($file)) || !General::writeFile($file, $dsShell, Symphony::Configuration()->get('write_mode', 'file'), 'w', true)) { $this->pageAlert(__('Failed to write Data source to disk.') . ' ' . __('Please check permissions on %s.', array('<code>/workspace/data-sources</code>')), Alert::ERROR); // Write successful } else { if (function_exists('opcache_invalidate')) { opcache_invalidate($file, true); } // Attach this datasources to pages $connections = $fields['connections']; ResourceManager::setPages(ResourceManager::RESOURCE_TYPE_DS, is_null($existing_handle) ? $classname : $existing_handle, $connections); // If the datasource has been updated and the name changed, then adjust all the existing pages that have the old datasource name if ($queueForDeletion) { General::deleteFile($queueForDeletion); // Update pages that use this DS $pages = PageManager::fetch(false, array('data_sources', 'id'), array("\n `data_sources` REGEXP '[[:<:]]" . $existing_handle . "[[:>:]]'\n ")); if (is_array($pages) && !empty($pages)) { foreach ($pages as $page) { $page['data_sources'] = preg_replace('/\\b' . $existing_handle . '\\b/i', $classname, $page['data_sources']); PageManager::edit($page['id'], $page); } } } if ($this->_context[0] == 'new') { /** * After creating the Datasource, the path to the Datasource file is provided * * @delegate DatasourcePostCreate * @since Symphony 2.2 * @param string $context * '/blueprints/datasources/' * @param string $file * The path to the Datasource file */ Symphony::ExtensionManager()->notifyMembers('DatasourcePostCreate', '/blueprints/datasources/', array('file' => $file)); } else { /** * After editing the Datasource, the path to the Datasource file is provided * * @delegate DatasourcePostEdit * @since Symphony 2.2 * @param string $context * '/blueprints/datasources/' * @param string $file * The path to the Datasource file * @param string $previous_file * The path of the previous Datasource file in the case where a Datasource may * have been renamed. To get the handle from this value, see * `DatasourceManager::__getHandleFromFilename` */ Symphony::ExtensionManager()->notifyMembers('DatasourcePostEdit', '/blueprints/datasources/', array('file' => $file, 'previous_file' => $queueForDeletion ? $queueForDeletion : null)); } redirect(SYMPHONY_URL . '/blueprints/datasources/edit/' . $classname . '/' . ($this->_context[0] == 'new' ? 'created' : 'saved') . '/'); } } }
/** * This function is called from the resources index when a user uses the * With Selected, or Apply, menu. The type of resource is given by * `$resource_type`. At this time the only two valid values, * `RESOURCE_TYPE_EVENT` or `RESOURCE_TYPE_DATASOURCE`. * * The function handles 'delete', 'attach', 'detach', 'attach all', * 'detach all' actions. * * @param integer $resource_type * Either `RESOURCE_TYPE_EVENT` or `RESOURCE_TYPE_DATASOURCE` * @throws Exception */ public function __actionIndex($resource_type) { $manager = ResourceManager::getManagerFromType($resource_type); $checked = is_array($_POST['items']) ? array_keys($_POST['items']) : null; $context = Administration::instance()->getPageCallback(); if (isset($_POST['action']) && is_array($_POST['action'])) { /** * Extensions can listen for any custom actions that were added * through `AddCustomPreferenceFieldsets` or `AddCustomActions` * delegates. * * @delegate CustomActions * @since Symphony 2.3.2 * @param string $context * '/blueprints/datasources/' or '/blueprints/events/' * @param array $checked * An array of the selected rows. The value is usually the ID of the * the associated object. */ Symphony::ExtensionManager()->notifyMembers('CustomActions', $context['pageroot'], array('checked' => $checked)); if (is_array($checked) && !empty($checked)) { if ($_POST['with-selected'] == 'delete') { $canProceed = true; foreach ($checked as $handle) { $path = call_user_func(array($manager, '__getDriverPath'), $handle); // Don't allow Extension resources to be deleted. RE: #2027 if (stripos($path, EXTENSIONS) === 0) { continue; } elseif (!General::deleteFile($path)) { $folder = str_replace(DOCROOT, '', $path); $folder = str_replace('/' . basename($path), '', $folder); $this->pageAlert(__('Failed to delete %s.', array('<code>' . basename($path) . '</code>')) . ' ' . __('Please check permissions on %s', array('<code>' . $folder . '</code>')), Alert::ERROR); $canProceed = false; } else { $pages = ResourceManager::getAttachedPages($resource_type, $handle); foreach ($pages as $page) { ResourceManager::detach($resource_type, $handle, $page['id']); } } } if ($canProceed) { redirect(Administration::instance()->getCurrentPageURL()); } } elseif (preg_match('/^(at|de)?tach-(to|from)-page-/', $_POST['with-selected'])) { if (substr($_POST['with-selected'], 0, 6) == 'detach') { $page = str_replace('detach-from-page-', '', $_POST['with-selected']); foreach ($checked as $handle) { ResourceManager::detach($resource_type, $handle, $page); } } else { $page = str_replace('attach-to-page-', '', $_POST['with-selected']); foreach ($checked as $handle) { ResourceManager::attach($resource_type, $handle, $page); } } if ($canProceed) { redirect(Administration::instance()->getCurrentPageURL()); } } elseif (preg_match('/^(at|de)?tach-all-pages$/', $_POST['with-selected'])) { $pages = PageManager::fetch(false, array('id')); if (substr($_POST['with-selected'], 0, 6) == 'detach') { foreach ($checked as $handle) { foreach ($pages as $page) { ResourceManager::detach($resource_type, $handle, $page['id']); } } } else { foreach ($checked as $handle) { foreach ($pages as $page) { ResourceManager::attach($resource_type, $handle, $page['id']); } } } redirect(Administration::instance()->getCurrentPageURL()); } } } }
/** * Given the `$page_id`, return the complete path to the * current page. * * @deprecated This function will be removed in Symphony 2.4. Use * `PageManager::resolvePagePath` instead. * @param mixed $page_id * The ID of the Page that currently being viewed, or the handle of the * current Page * @return string * The complete path to the current Page including any parent * Pages, ie. /articles/read */ public function resolvePagePath($page_id) { return PageManager::resolvePage($page_id, 'handle'); }
function editPage() { global $mainframe, $option; $db =& JFactory::getDBO(); $user =& JFactory::getUser(); $cid = JRequest::getVar('cid', array(0), '', 'array'); $option = JRequest::getCmd('option'); $uid = (int) @$cid[0]; $row =& JTable::getInstance('flippingpage', 'Table'); $row->load($uid); $query = 'SELECT id FROM #__flippingbook_books'; $db->setQuery($query); if (count($db->loadObjectList()) < 1) { $msg = JText::_('CREATE A BOOK FIRST'); $link = 'index.php?option=com_flippingbook&task=book_manager'; $mainframe->redirect($link, $msg); return; } $query = 'SELECT id, title FROM #__flippingbook_books ORDER BY title'; $db->setQuery($query); $book_rows = $db->loadObjectList(); $book_filter[] = JHTML::_('select.option', -1, '- ' . JText::_('Select Book') . ' -'); foreach ($book_rows as $book_row) { $book_option[] = JHTML::_('select.option', $book_row->id, $book_row->title); } $lists['books'] = JHTML::_('select.genericlist', $book_option, 'book_id', 'class="inputbox" size="1"', 'value', 'text', $row->book_id); $lists['files'] = $this->getFilesSelectBox('file', $row->file, 0, 'jpg|jpeg|swf|JPG|JPEG|SWF', ''); $lists['zoomed_image'] = $this->getFilesSelectBox('zoom_url', $row->zoom_url, 1, 'jpg|jpeg|swf|JPG|JPEG|SWF', 'onchange="update_fields_state();"'); require_once JPATH_COMPONENT . DS . 'views' . DS . 'page_manager.php'; PageManager::editPage($row, $lists); }
require_once 'install/upgradestep.class.php'; $page = 'upgrade'; if (Kit::GetParam('includes', _POST, _BOOL)) { $upgradeFrom = Kit::GetParam('upgradeFrom', _POST, _INT); $upgradeTo = Kit::GetParam('upgradeTo', _POST, _INT); for ($i = $upgradeFrom + 1; $i <= $upgradeTo; $i++) { if (file_exists('install/database/' . $i . '.php')) { include_once 'install/database/' . $i . '.php'; } } } } // Create a Session $session = new Session(); // Work out the location of this service $serviceLocation = Kit::GetXiboRoot(); // OAuth require_once 'lib/oauth.inc.php'; // Assign the page name to the session $session->set_page(session_id(), $page); // Create a user $user = new User($db); // Create Page try { $pageManager = new PageManager($db, $user, $page); $pageManager->Authenticate(); $pageManager->Render(); } catch (Exception $e) { trigger_error($e->getMessage(), E_USER_ERROR); } die;
/** * Given the `$page_id`, return the complete path to the * current page. Each part of the Page's path will be * separated by '/'. * * @param mixed $page_id * The ID of the Page that currently being viewed, or the handle of the * current Page * @return string * The complete path to the current Page including any parent * Pages, ie. /articles/read */ public static function resolvePagePath($page_id) { $path = PageManager::resolvePage($page_id, 'handle'); return implode('/', $path); }
<?php /* * WolfPanel (c) 2015 by Fursystems.de (Marcel Kallen) * * WolfPanel is licensed under a * Creative Commons Attribution-NonCommercial 4.0 International License. * * You should have received a copy of the license along with this * work. If not, see <http://creativecommons.org/licenses/by-nc/4.0/>. */ include "../core.php"; // Admin Check $user = UserManager::getLocalUser(); if (!$user->isAdmin()) { PageManager::displayErrorPage("access"); return; } $customers = UserManager::getAllCustomers(); if ($customers != false) { $smarty->assign("AllUsers", UserManager::getAllCustomers()); } $smarty->display("ajax/getCustomerList.tpl");
require_once '../common/php/Utils.php'; $document_root = Utils::getDocumentRoot(); require_once $document_root . '/common/php/UserManager.php'; require_once $document_root . '/common/php/ApplicationManager.php'; require_once $document_root . '/common/php/PageManager.php'; require_once $document_root . '/common/php/MenuManager.php'; Utils::startSession(); $user_mgr = new UserManager(); $is_login = $user_mgr->isLogin(); if (!$is_login) { //ログインページに遷移する header("Location: /login/login.php"); exit; } $user = $user_mgr->getUser(); $page_mgr = new PageManager(PageManager::PAGE_PROSPECT); $menu_mgr = new MenuManager(); $title = $page_mgr->getTitle(); $organ_id = $user['organ_id']; $user_id = $user['user_id']; $tag_options = array('mycss' => true, 'angularjs' => true, 'ngroute' => true, 'nganimate' => true, 'nggrid' => true, 'uirouter' => true, 'jquery1' => true, 'jqueryuilatest' => true, 'jquerydatepicker' => true, 'jquerydatetimepicker' => true, 'jquerymultiselect' => true, 'jquerycookie' => true, 'ngfileupload' => true, 'uplogiccommon' => true, 'list' => true, 'search' => true, 'import' => true, 'activity_history' => true, 'item_setting' => true, 'ngdialog' => true, 'exclusion_smart_admin' => true); ?> <!DOCTYPE html> <html lang="ja" ng-app="myApp"> <head> <?php echo $page_mgr->getHeader($tag_options); ?> <?php echo $page_mgr->getScriptTags($tag_options); ?>
<?php $pm = new PageManager(); $list = $pm->getPageList(); $yt = new YouTube(); ?> var app = angular.module("WomenLine",['ngRoute']).config(function($routeProvider, $locationProvider){ $routeProvider .when('/', { templateUrl : 'home/angular', controller : 'WomenLineController' }).when('/home', { templateUrl : 'home/angular', controller : 'WomenLineController' }) .when('/gallery', { templateUrl : 'gallery/angular', controller : 'galleryController' }) .when('/volunteers', { templateUrl : 'volunteers/angular', controller : 'volunteerController' }) .when('/partners', { templateUrl : 'partners/angular', controller : 'partnerController' }) .when('/sponcer-a-girl', { templateUrl : 'sponcer-a-girl/angular', controller : 'sponcerAGirlController' })
public function __formAction() { $fields = $_POST['fields']; $this->_errors = array(); $providers = Symphony::ExtensionManager()->getProvidersOf(iProvider::EVENT); $providerClass = null; if (trim($fields['name']) == '') { $this->_errors['name'] = __('This is a required field'); } if (trim($fields['source']) == '') { $this->_errors['source'] = __('This is a required field'); } $filters = isset($fields['filters']) ? $fields['filters'] : array(); // See if a Provided Datasource is saved if (!empty($providers)) { foreach ($providers as $providerClass => $provider) { if ($fields['source'] == call_user_func(array($providerClass, 'getSource'))) { call_user_func_array(array($providerClass, 'validate'), array(&$fields, &$this->_errors)); break; } unset($providerClass); } } $classname = Lang::createHandle($fields['name'], 255, '_', false, true, array('@^[^a-z\\d]+@i' => '', '/[^\\w-\\.]/i' => '')); $rootelement = str_replace('_', '-', $classname); $extends = 'SectionEvent'; // Check to make sure the classname is not empty after handlisation. if (empty($classname) && !isset($this->_errors['name'])) { $this->_errors['name'] = __('Please ensure name contains at least one Latin-based character.', array($classname)); } $file = EVENTS . '/event.' . $classname . '.php'; $isDuplicate = false; $queueForDeletion = null; if ($this->_context[0] == 'new' && is_file($file)) { $isDuplicate = true; } elseif ($this->_context[0] == 'edit') { $existing_handle = $this->_context[1]; if ($classname != $existing_handle && is_file($file)) { $isDuplicate = true; } elseif ($classname != $existing_handle) { $queueForDeletion = EVENTS . '/event.' . $existing_handle . '.php'; } } // Duplicate if ($isDuplicate) { $this->_errors['name'] = __('An Event with the name %s already exists', array('<code>' . $classname . '</code>')); } if (empty($this->_errors)) { $multiple = in_array('expect-multiple', $filters); $elements = null; $placeholder = '<!-- GRAB -->'; $source = $fields['source']; $params = array('rootelement' => $rootelement); $about = array('name' => $fields['name'], 'version' => 'Symphony ' . Symphony::Configuration()->get('version', 'symphony'), 'release date' => DateTimeObj::getGMT('c'), 'author name' => Symphony::Author()->getFullName(), 'author website' => URL, 'author email' => Symphony::Author()->get('email')); // If there is a provider, get their template if ($providerClass) { $eventShell = file_get_contents(call_user_func(array($providerClass, 'getTemplate'))); } else { $eventShell = file_get_contents($this->getTemplate('blueprints.event')); $about['trigger condition'] = $rootelement; } $this->__injectAboutInformation($eventShell, $about); // Replace the name $eventShell = str_replace('<!-- CLASS NAME -->', $classname, $eventShell); // Build the templates if ($providerClass) { $eventShell = call_user_func(array($providerClass, 'prepare'), $fields, $params, $eventShell); } else { $this->__injectFilters($eventShell, $filters); // Add Documentation require_once CONTENT . '/content.ajaxeventdocumentation.php'; $ajaxEventDoc = new contentAjaxEventDocumentation(); $documentation = null; $doc_parts = array(); // Add Documentation (Success/Failure) $ajaxEventDoc->addEntrySuccessDoc($doc_parts, $rootelement, $fields['source'], $filters); $ajaxEventDoc->addEntryFailureDoc($doc_parts, $rootelement, $fields['source'], $filters); // Filters $ajaxEventDoc->addDefaultFiltersDoc($doc_parts, $rootelement, $fields['source'], $filters); // Frontend Markup $ajaxEventDoc->addFrontendMarkupDoc($doc_parts, $rootelement, $fields['source'], $filters); $ajaxEventDoc->addSendMailFilterDoc($doc_parts, $rootelement, $fields['source'], $filters); /** * Allows adding documentation for new filters. A reference to the $documentation * array is provided, along with selected filters * @delegate AppendEventFilterDocumentation * @param string $context * '/blueprints/events/(edit|new|info)/' * @param array $selected * An array of all the selected filters for this Event * @param array $documentation * An array of all the documentation XMLElements, passed by reference */ Symphony::ExtensionManager()->notifyMembers('AppendEventFilterDocumentation', '/blueprints/events/' . $rootelement . '/', array('selected' => $filters, 'documentation' => &$doc_parts)); $documentation = join(PHP_EOL, array_map(create_function('$x', 'return rtrim($x->generate(true, 4));'), $doc_parts)); $documentation = str_replace('\'', '\\\'', $documentation); $eventShell = str_replace('<!-- CLASS EXTENDS -->', $extends, $eventShell); $eventShell = str_replace('<!-- DOCUMENTATION -->', General::tabsToSpaces($documentation, 4), $eventShell); } $eventShell = str_replace('<!-- ROOT ELEMENT -->', $rootelement, $eventShell); $eventShell = str_replace('<!-- CLASS NAME -->', $classname, $eventShell); $eventShell = str_replace('<!-- SOURCE -->', $source, $eventShell); // Remove left over placeholders $eventShell = preg_replace(array('/<!--[\\w ]++-->/'), '', $eventShell); if ($this->_context[0] == 'new') { /** * Prior to creating an Event, the file path where it will be written to * is provided and well as the contents of that file. * * @delegate EventsPreCreate * @since Symphony 2.2 * @param string $context * '/blueprints/events/' * @param string $file * The path to the Event file * @param string $contents * The contents for this Event as a string passed by reference * @param array $filters * An array of the filters attached to this event */ Symphony::ExtensionManager()->notifyMembers('EventPreCreate', '/blueprints/events/', array('file' => $file, 'contents' => &$eventShell, 'filters' => $filters)); } else { /** * Prior to editing an Event, the file path where it will be written to * is provided and well as the contents of that file. * * @delegate EventPreEdit * @since Symphony 2.2 * @param string $context * '/blueprints/events/' * @param string $file * The path to the Event file * @param string $contents * The contents for this Event as a string passed by reference * @param array $filters * An array of the filters attached to this event */ Symphony::ExtensionManager()->notifyMembers('EventPreEdit', '/blueprints/events/', array('file' => $file, 'contents' => &$eventShell, 'filters' => $filters)); } // Write the file if (!is_writable(dirname($file)) || !($write = General::writeFile($file, $eventShell, Symphony::Configuration()->get('write_mode', 'file')))) { $this->pageAlert(__('Failed to write Event to disk.') . ' ' . __('Please check permissions on %s.', array('<code>/workspace/events</code>')), Alert::ERROR); // Write successful } else { if (function_exists('opcache_invalidate')) { opcache_invalidate($file, true); } // Attach this event to pages $connections = $fields['connections']; ResourceManager::setPages(RESOURCE_TYPE_EVENT, is_null($existing_handle) ? $classname : $existing_handle, $connections); if ($queueForDeletion) { General::deleteFile($queueForDeletion); $pages = PageManager::fetch(false, array('events', 'id'), array("\n `events` REGEXP '[[:<:]]" . $existing_handle . "[[:>:]]'\n ")); if (is_array($pages) && !empty($pages)) { foreach ($pages as $page) { $page['events'] = preg_replace('/\\b' . $existing_handle . '\\b/i', $classname, $page['events']); PageManager::edit($page['id'], $page); } } } if ($this->_context[0] == 'new') { /** * After creating the Event, the path to the Event file is provided * * @delegate EventPostCreate * @since Symphony 2.2 * @param string $context * '/blueprints/events/' * @param string $file * The path to the Event file */ Symphony::ExtensionManager()->notifyMembers('EventPostCreate', '/blueprints/events/', array('file' => $file)); } else { /** * After editing the Event, the path to the Event file is provided * * @delegate EventPostEdit * @since Symphony 2.2 * @param string $context * '/blueprints/events/' * @param string $file * The path to the Event file * @param string $previous_file * The path of the previous Event file in the case where an Event may * have been renamed. To get the handle from this value, see * `EventManager::__getHandleFromFilename` */ Symphony::ExtensionManager()->notifyMembers('EventPostEdit', '/blueprints/events/', array('file' => $file, 'previous_file' => $queueForDeletion ? $queueForDeletion : null)); } redirect(SYMPHONY_URL . '/blueprints/events/edit/' . $classname . '/' . ($this->_context[0] == 'new' ? 'created' : 'saved') . '/'); } } }
/** * Given a resource type, a handle and a page, this function detaches * the given handle (which represents either a datasource or event) to that page. * * @param integer $type * The resource type, either `RESOURCE_TYPE_EVENT` or `RESOURCE_TYPE_DS` * @param string $r_handle * The handle of the resource. * @param integer $page_id * The ID of the page. */ public static function detach($type, $r_handle, $page_id) { $col = self::getColumnFromType($type); $pages = PageManager::fetch(false, array($col), array(sprintf('`id` = %d', $page_id))); if (is_array($pages) && count($pages) == 1) { $result = $pages[0][$col]; $values = explode(',', $result); $idx = array_search($r_handle, $values, false); if ($idx !== false) { array_splice($values, $idx, 1); $result = implode(',', $values); return PageManager::edit($page_id, array($col => MySQL::cleanValue($result))); } } return false; }
<?php $config = new Config(); $ne = new NewsAndEvent(); $news = $ne->getNEList('news'); $events = $ne->getNEList('event'); $client = new Clients(); $clients = $client->getClinets(); $sponcer = new Sponcer(); $sponcers = $sponcer->getSponcer('sponcer-girl'); $pm = new PageManager(); ?> <!-- Start main-content --> <div class="main-content"> <!-- Section: home --> <section> <div class="container pb-0"> <div class="section-title text-center mb-0"> <div class="row"> <div class="col-md-12"> <h3 class="text-uppercase mt-0">WomenLine</h3> <div class="title-icon"> <i class="flaticon-hand221"></i> </div> <div class="col-lg-10 col-md-9 col-sm-6 text-left"> <p><?php echo substr(strip_tags($pm->setPage('introduction')->getPageInfo('page-content')), 0, 250); ?> ...</p> </div> <div class="col-lg-2 col-md-3 col-sm-6">
<?php /** * Plugin Name: Moxie Movies * Description: This plugin adds a JSON API from a custom post type(movies) and displays it as a frontpage. * Version: 1.0.0 * Author: Wenceslao Negrete * Author URI: http://github.com/vampaynani */ include_once 'src/moxiemovies.class.php'; include_once 'src/pagemanager.class.php'; include_once 'src/urlhandler.class.php'; $url_handler = URLHandler::get_instance(); $page_manager = PageManager::get_instance(); $mox_movies = MoxieMovies::get_instance(); $url_handler->set_callback(array($mox_movies, 'show_cached_json_data'));