Example #1
2
 /**
  * Display a page with this order of priority (based on the provided page name) :
  *  1. Does the page exist into local/pages/{lang}/ (this allows you to overwrite default pages)?
  *  2. Does the page exist into the views available in views/pages/ folder?
  * Pages are not public and we take into account the language of the connected user.
  * If the page name contains the keyword export, then we don't output the default template.
  * @param string $page Name of the view (and of the corresponding PHP file)
  * @author Benjamin BALET <benjamin.balet@gmail.com>
  */
 public function view($page = 'home')
 {
     $data = getUserContext($this);
     $trans = array("-" => " ", "_" => " ", "." => " ");
     $data['title'] = ucfirst(strtr($page, $trans));
     // Capitalize the first letter
     //The page containing export in their name are returning another MIMETYPE
     if (strpos($page, 'export') === FALSE) {
         //Don't include header and menu
         $this->load->view('templates/header', $data);
         $this->load->view('menu/index', $data);
     }
     $view = 'pages/' . $this->language_code . '/' . $page . '.php';
     $pathCI = APPPATH . 'views/';
     $pathLocal = FCPATH . 'local/';
     //Check if we have a user-defined view
     if (file_exists($pathLocal . $view)) {
         $this->load->customView($pathLocal, $view, $data);
     } else {
         //Load the page from the default location (CI views folder)
         if (!file_exists($pathCI . $view)) {
             redirect('notfound');
         }
         $this->load->view($view, $data);
     }
     if (strpos($page, 'export') === FALSE) {
         $this->load->view('templates/footer', $data);
     }
 }
Example #2
1
 /**
  *   
  * Factory method to create Tag Handlers
  *
  * $type = namespace eg. <flexy:toJavascript loads Flexy.php
  * the default is this... (eg. Tag)
  * 
  * 
  * @param   string    Namespace handler for element.
  * @param   object   HTML_Template_Flexy_Compiler  
  * 
  *
  * @return    object    tag compiler
  * @access   public
  */
 function &factory($type, &$compiler)
 {
     if (!$type) {
         $type = 'Tag';
     }
     $class = 'HTML_Template_Flexy_Compiler_Flexy_' . $type;
     if (class_exists($class)) {
         $ret = new $class();
         $ret->compiler =& $compiler;
         return $ret;
     }
     $filename = 'HTML/Template/Flexy/Compiler/Flexy/' . ucfirst(strtolower($type)) . '.php';
     if (!HTML_Template_Flexy_Compiler_Flexy_Tag::fileExistsInPath($filename)) {
         $ret = HTML_Template_Flexy_Compiler_Flexy_Tag::factory('Tag', $compiler);
         return $ret;
     }
     // if we dont have a handler - just use the basic handler.
     if (!file_exists(dirname(__FILE__) . '/' . ucfirst(strtolower($type)) . '.php')) {
         $type = 'Tag';
     }
     include_once 'HTML/Template/Flexy/Compiler/Flexy/' . ucfirst(strtolower($type)) . '.php';
     $class = 'HTML_Template_Flexy_Compiler_Flexy_' . $type;
     if (!class_exists($class)) {
         $ret = false;
         return $ret;
     }
     $ret = HTML_Template_Flexy_Compiler_Flexy_Tag::factory($type, $compiler);
     return $ret;
 }
Example #3
1
 public function __get($name)
 {
     $method = 'get' . ucfirst($name);
     if (method_exists($this, $method)) {
         return $this->{$method}();
     }
 }
 /**
  * Processes this test, when one of its tokens is encountered.
  *
  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
  * @param int                  $stackPtr  The position of the current token in the
  *                                        stack passed in $tokens.
  *
  * @return void
  */
 public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
 {
     $tokens = $phpcsFile->getTokens();
     // Make sure this is the first PHP open tag so we don't process
     // the same file twice.
     $prevOpenTag = $phpcsFile->findPrevious(T_OPEN_TAG, $stackPtr - 1);
     if ($prevOpenTag !== false) {
         return;
     }
     $fileName = $phpcsFile->getFileName();
     $extension = substr($fileName, strrpos($fileName, '.'));
     $nextClass = $phpcsFile->findNext(array(T_CLASS, T_INTERFACE), $stackPtr);
     if ($extension === '.php') {
         if ($nextClass !== false) {
             $error = '%s found in ".php" file; use ".inc" extension instead';
             $data = array(ucfirst($tokens[$nextClass]['content']));
             $phpcsFile->addError($error, $stackPtr, 'ClassFound', $data);
         }
     } else {
         if ($extension === '.inc') {
             if ($nextClass === false) {
                 $error = 'No interface or class found in ".inc" file; use ".php" extension instead';
                 $phpcsFile->addError($error, $stackPtr, 'NoClass');
             }
         }
     }
 }
Example #5
1
 public function load(TemplateReferenceInterface $template)
 {
     if (method_exists($this, $method = 'get' . ucfirst($template->get('name')) . 'Template')) {
         return new StringStorage($this->{$method}());
     }
     return false;
 }
 /**
  * getFullClassName()
  *
  * @param string $localClassName
  * @param string $classContextName
  */
 public function getFullClassName($localClassName, $classContextName = null)
 {
     // find the ApplicationDirectory OR ModuleDirectory
     $currentResource = $this->_resource;
     do {
         $resourceName = $currentResource->getName();
         if ($resourceName == 'ApplicationDirectory' || $resourceName == 'ModuleDirectory') {
             $containingResource = $currentResource;
             break;
         }
     } while ($currentResource instanceof Zend_Tool_Project_Profile_Resource && ($currentResource = $currentResource->getParentResource()));
     $fullClassName = '';
     // go find the proper prefix
     if (isset($containingResource)) {
         if ($containingResource->getName() == 'ApplicationDirectory') {
             $prefix = $containingResource->getAttribute('classNamePrefix');
             $fullClassName = $prefix;
         } elseif ($containingResource->getName() == 'ModuleDirectory') {
             $filter = new Zend_Filter_Word_DashToCamelCase();
             $prefix = $filter->filter(ucfirst($containingResource->getAttribute('moduleName'))) . '_';
             $fullClassName = $prefix;
         }
     }
     if ($classContextName) {
         $fullClassName .= rtrim($classContextName, '_') . '_';
     }
     $fullClassName .= $localClassName;
     return $fullClassName;
 }
Example #7
1
 /**
  * 工厂, 创建操作各种数据库的对象.
  *
  * @param string|null $db_type 数据库类型, 如果传递 null 或者不传递则默认为 local RThink_Config 的
  *            db_type
  * @param array $options 数据库配置参数
  * @return object 操作相应数据库的对象
  * @throws em_db_exception
  */
 public static function factory($options, $db_type)
 {
     $adapter_name = ucfirst($db_type) . 'Adapter';
     $class_name = 'RThink_Db_' . $adapter_name;
     class_exists($class_name, false) || (require 'RThink/Db/' . $adapter_name . '.php');
     return new $class_name($options);
 }
Example #8
1
 /**
  * Generate Class
  *
  * @param string $className
  * @return string
  * @throws \Magento\Framework\Exception
  * @throws \InvalidArgumentException
  */
 public function generateClass($className)
 {
     // check if source class a generated entity
     $entity = null;
     $entityName = null;
     foreach ($this->_generatedEntities as $entityType => $generatorClass) {
         $entitySuffix = ucfirst($entityType);
         // if $className string ends on $entitySuffix substring
         if (strrpos($className, $entitySuffix) === strlen($className) - strlen($entitySuffix)) {
             $entity = $entityType;
             $entityName = rtrim(substr($className, 0, -1 * strlen($entitySuffix)), \Magento\Framework\Autoload\IncludePath::NS_SEPARATOR);
             break;
         }
     }
     if (!$entity || !$entityName) {
         return self::GENERATION_ERROR;
     }
     // check if file already exists
     $autoloader = $this->_autoloader;
     if ($autoloader::getFile($className)) {
         return self::GENERATION_SKIP;
     }
     if (!isset($this->_generatedEntities[$entity])) {
         throw new \InvalidArgumentException('Unknown generation entity.');
     }
     $generatorClass = $this->_generatedEntities[$entity];
     $generator = new $generatorClass($entityName, $className, $this->_ioObject);
     if (!$generator->generate()) {
         $errors = $generator->getErrors();
         throw new \Magento\Framework\Exception(implode(' ', $errors));
     }
     return self::GENERATION_SUCCESS;
 }
 /**
  * Interface with the Module Loader.
  *
  * @param string $key
  * @return string
  */
 public function render($key)
 {
     $getter = 'get' . ucfirst($key);
     /** @var \Fab\Vidi\Module\ModuleLoader $moduleLoader */
     $moduleLoader = $this->objectManager->get('Fab\\Vidi\\Module\\ModuleLoader');
     return $moduleLoader->{$getter}();
 }
 /**
  * Method to get the list of database options.
  *
  * This method produces a drop down list of available databases supported
  * by JDatabaseDriver classes that are also supported by the application.
  *
  * @return  array  The field option objects.
  *
  * @since   11.3
  * @see     JDatabaseDriver::getConnectors()
  */
 protected function getOptions()
 {
     // This gets the connectors available in the platform and supported by the server.
     $available = JDatabaseDriver::getConnectors();
     /**
      * This gets the list of database types supported by the application.
      * This should be entered in the form definition as a comma separated list.
      * If no supported databases are listed, it is assumed all available databases
      * are supported.
      */
     $supported = $this->element['supported'];
     if (!empty($supported)) {
         $supported = explode(',', $supported);
         foreach ($supported as $support) {
             if (in_array($support, $available)) {
                 $options[$support] = JText::_(ucfirst($support));
             }
         }
     } else {
         foreach ($available as $support) {
             $options[$support] = JText::_(ucfirst($support));
         }
     }
     // This will come into play if an application is installed that requires
     // a database that is not available on the server.
     if (empty($options)) {
         $options[''] = JText::_('JNONE');
     }
     return $options;
 }
 /**
  * @param \Symfony\Component\Console\Input\InputInterface $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  * @return int|void
  * @throws \InvalidArgumentException
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $subCommandFactory = $this->createSubCommandFactory($input, $output, 'N98\\Magento\\Command\\Developer\\Module\\Create\\SubCommand');
     $configBag = $subCommandFactory->getConfig();
     if (!$input->getOption('modman')) {
         $this->detectMagento($output);
     }
     $configBag->setBool('isModmanMode', $input->getOption('modman'));
     $configBag->setString('magentoRootFolder', $this->_magentoRootFolder);
     $this->initConfigBagDefaultValues($configBag);
     if ($input->getOption('add-all')) {
         $configBag->setBool('shouldAddBlocks', true);
         $configBag->setBool('shouldAddHelpers', true);
         $configBag->setBool('shouldAddModels', true);
         $configBag->setBool('shouldAddSetup', true);
     }
     if ($input->getOption('add-blocks')) {
         $configBag->setBool('shouldAddBlocks', true);
     }
     if ($input->getOption('add-helpers')) {
         $configBag->setBool('shouldAddHelpers', true);
     }
     if ($input->getOption('add-models')) {
         $configBag->setBool('shouldAddModels', true);
     }
     if ($input->getOption('add-setup')) {
         $configBag->setBool('shouldAddSetup', true);
     }
     if ($input->getOption('enable')) {
         $configBag->setBool('shouldEnableModule', true);
     }
     $configBag->setString('baseFolder', __DIR__ . '/../../../../../../res/module/create');
     $configBag->setString('vendorNamespace', ucfirst($input->getArgument('vendorNamespace')));
     $configBag->setString('moduleName', ucfirst($input->getArgument('moduleName')));
     $this->initView($input, $configBag);
     $subCommandFactory->create('CreateModuleFolders')->execute();
     $subCommandFactory->create('CreateModuleRegistrationFiles')->execute();
     if (!$input->getOption('minimal')) {
         $subCommandFactory->create('CreateModuleConfigFile')->execute();
         $subCommandFactory->create('CreateModuleDiFile')->execute();
         $subCommandFactory->create('CreateModuleEventsFile')->execute();
         $subCommandFactory->create('CreateModuleCrontabFile')->execute();
     }
     $subCommandFactory->create('EnableModule')->execute();
     if ($input->getOption('add-readme')) {
         $subCommandFactory->create('CreateReadmeFile')->execute();
     }
     if ($input->getOption('modman')) {
         $subCommandFactory->create('CreateModmanFile')->execute();
     }
     if ($input->getOption('add-composer')) {
         $subCommandFactory->create('CreateComposerFile')->execute();
     }
     if ($input->getOption('add-setup')) {
         $subCommandFactory->create('CreateSetupFiles')->execute();
     }
     if (!$input->getOption('minimal')) {
         $subCommandFactory->create('CreateAdditionalFiles')->execute();
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function listItems(InputInterface $input, \Reflector $reflector = null, $target = null)
 {
     // only list constants when no Reflector is present.
     //
     // TODO: make a NamespaceReflector and pass that in for commands like:
     //
     //     ls --constants Foo
     //
     // ... for listing constants in the Foo namespace
     if ($reflector !== null || $target !== null) {
         return;
     }
     // only list constants if we are specifically asked
     if (!$input->getOption('constants')) {
         return;
     }
     $category = $input->getOption('user') ? 'user' : $input->getOption('category');
     $label = $category ? ucfirst($category) . ' Constants' : 'Constants';
     $constants = $this->prepareConstants($this->getConstants($category));
     if (empty($constants)) {
         return;
     }
     $ret = array();
     $ret[$label] = $constants;
     return $ret;
 }
Example #13
0
 /**
  * @param $test
  * @param $expected
  *
  * @dataProvider providerPlurals
  */
 public function testAutomaticCasing($test, $expected)
 {
     $test = ucfirst($test);
     $expected = ucfirst($expected);
     $pluralize = new Pluralize();
     $this->assertEquals($expected, $pluralize->fix($test));
 }
Example #14
0
 /**
  * Writes given message to a log file in the logs directory.
  *
  * @param string $type Type of log, becomes part of the log's filename
  * @param string $msg  Message to log
  * @return boolean Success
  */
 function write($type, $msg)
 {
     $filename = LOGS . $type . '.log';
     $output = date('Y-m-d H:i:s') . ' ' . ucfirst($type) . ': ' . $msg . "\n";
     $log = new File($filename);
     return $log->append($output);
 }
Example #15
0
 public function formatTokens($content)
 {
     $upperCaseModelName = ucfirst($this->modelName);
     $field_name = snake_case($this->modelName) . '_name';
     $modelId = $this->formatInstanceVariable() . '->id';
     $modelAttribute = $this->formatInstanceVariable() . '->' . $field_name;
     $createdAt = $this->formatInstanceVariable() . '->created_at';
     $modelRoute = '/' . $this->folderName;
     $dtTableName = snake_case($this->modelName) . '_table';
     $masterPage = $this->masterPage;
     $modelName = $this->modelName;
     $modelsUpperCase = ucwords(str_plural($this->modelName));
     $folderName = $this->folderName;
     $gridName = $this->formatVueGridName() . '-grid';
     $endGridName = '/' . $this->formatVueGridName() . '-grid';
     $vueApiRoute = 'api/' . $this->folderName . '-vue';
     $parent = $this->parent;
     $parentInstance = $this->formatParentInstanceVariable($this->parent);
     $parentInstances = $this->formatParents($this->parent);
     $parent_id = strtolower(snake_case($this->parent)) . '_id';
     $parentFieldName = strtolower(snake_case($this->parent)) . '_name';
     $child = $this->child;
     $slug = $this->slug;
     //create token array using compact
     $tokens = compact('upperCaseModelName', 'field_name', 'modelId', 'modelAttribute', 'createdAt', 'modelRoute', 'dtTableName', 'masterPage', 'modelName', 'modelsUpperCase', 'folderName', 'gridName', 'endGridName', 'vueApiRoute', 'parent', 'parentInstance', 'parentInstances', 'parent_id', 'parentFieldName', 'child', 'slug');
     $content = $this->insertTokensInContent($content, $tokens);
     return $content;
 }
Example #16
0
 /**
  * Tries to create a new router object for given component, returns NULL
  * if object not supported
  * 
  * @staticvar JComponentRouterInterface[] $cache
  * @param string $component Component name in format "com_xxx"
  * @return \JComponentRouterInterface
  */
 protected static function getComponentRouter($component)
 {
     static $cache = array();
     if (!array_key_exists($component, $cache)) {
         $router = null;
         $compName = ucfirst(substr($component, 4));
         $class = $compName . 'Router';
         if (class_exists($class)) {
             // Check if it supports the Joomla router interface, because
             // some components use classes with the same name causing
             // fatal error then (eg. EasyBlog)
             $reflection = new ReflectionClass($class);
             if (in_array('JComponentRouterInterface', $reflection->getInterfaceNames())) {
                 // Create the router object
                 $app = JFactory::getApplication();
                 $menu = $app->getMenu('site');
                 $router = new $class($app, $menu);
             }
         }
         // If router class not supported, create legacy router object (Joomla 3)
         if (!$router && class_exists('JComponentRouterLegacy')) {
             $router = new JComponentRouterLegacy($compName);
         }
         // Cache the router object
         $cache[$component] = $router;
     }
     return $cache[$component];
 }
 /**
  * {@inheritDoc}
  */
 public function getLabel($label, $context = '', $type = '')
 {
     if ($context == 'breadcrumb') {
         return sprintf('%s.%s_%s', $context, $type, strtolower($label));
     }
     return ucfirst(strtolower($label));
 }
 /**
  * 工厂加载方法
  * 
  * @param string $section
  * @return object
  */
 public static function factory($section = 'sphinx')
 {
     static $instances = array();
     if ($section === 'all_instances') {
         return $instances;
     }
     $config = self::config($section);
     if (is_string($config)) {
         $section = $config;
         $config = self::config($section);
     }
     if (is_null($config)) {
         throw new InvalidArgumentException('search node [' . $section . '] not found', 101);
     }
     if (!isset($instances[$section]) || $instances[$section] === null) {
         if (isset($config['className'])) {
             $class = $config['className'];
         } else {
             $class = __CLASS__ . '_' . ucfirst($section);
         }
         $instances[$section] = new $class();
         if (isset($config['option'])) {
             return $instances[$section]->init($config['option']);
         }
     }
     return false;
 }
Example #19
0
 /**
  * Command configure method
  */
 protected function configure()
 {
     $this->setName('wurst:print')->addArgument('type', null, sprintf('Which type of würst you want (%s)?', implode(', ', $this->wurstTypes)), 'classic')->setHelp('Please ask your local curry würst retailer.');
     foreach ($this->sides as $side) {
         $this->addOption('mit-' . $side, null, InputOption::VALUE_NONE, sprintf('Mit %s?', ucfirst($side)));
     }
 }
Example #20
0
 function loadController()
 {
     $controller = ucfirst($this->request->controller) . 'Controller';
     if ($this->request->prefix == COCKPIT) {
         if (!file_exists(ROOT . DS . CONTROLLER . DS . BACKEND . DS . $controller . '.php')) {
             if (!file_exists(ROOT . DS . CONTROLLER . DS . BACKEND . DS . 'extends' . DS . $controller . '.php')) {
                 $this->error();
             } else {
                 $file = ROOT . DS . CONTROLLER . DS . BACKEND . DS . 'extends' . DS . $controller . '.php';
             }
         } else {
             $file = ROOT . DS . CONTROLLER . DS . BACKEND . DS . $controller . '.php';
         }
     } else {
         if (!file_exists(ROOT . DS . CONTROLLER . DS . FRONTEND . DS . $controller . '.php')) {
             if (!file_exists(ROOT . DS . CONTROLLER . DS . FRONTEND . DS . 'extends' . DS . $controller . '.php')) {
                 $this->error();
             } else {
                 $file = ROOT . DS . CONTROLLER . DS . FRONTEND . DS . 'extends' . DS . $controller . '.php';
             }
         } else {
             $file = ROOT . DS . CONTROLLER . DS . FRONTEND . DS . $controller . '.php';
         }
     }
     require $file;
     return new $controller($this->request);
 }
Example #21
0
 public function getModelForBean(OODBBean $bean)
 {
     $model = $bean->getMeta("type");
     $prefix = $this->defaultNamespace;
     $typeMap = $this->typeMap;
     if (isset($typeMap[$model])) {
         $modelName = $typeMap[$model];
     } else {
         if (strpos($model, '_') !== FALSE) {
             $modelParts = explode('_', $model);
             $modelName = '';
             foreach ($modelParts as $part) {
                 $modelName .= ucfirst($part);
             }
             $modelName = $prefix . $modelName;
             if (!class_exists($modelName)) {
                 //second try
                 $modelName = $prefix . ucfirst($model);
                 if (!class_exists($modelName)) {
                     return NULL;
                 }
             }
         } else {
             $modelName = $prefix . ucfirst($model);
             if (!class_exists($modelName)) {
                 return NULL;
             }
         }
     }
     $obj = self::factory($modelName);
     $obj->loadBean($bean);
     return $obj;
 }
 /**
  * @Template("CommentsBundle::comment.html.twig")
  */
 public function initAction(string $type, Request $request, int $context_id = 0)
 {
     $checker = $this->container->get('security.authorization_checker');
     $comment_form = null;
     $is_logged = false;
     $this->getRepository($type);
     if ($checker->isGranted('IS_AUTHENTICATED_FULLY') && $checker->isGranted('ROLE_USER')) {
         $user = $this->get('security.token_storage')->getToken()->getUser();
         $is_logged = true;
         $entity = ucfirst($type) . "Comment";
         $comment_type = "Calculus\\CommentsBundle\\Entity\\" . $entity;
         $context = $this->repository->getContext($context_id);
         $comment_obj = new $comment_type();
         $comment_obj->setUser($user);
         $comment_obj->setPubdate(new Datetime(date('Y-m-d H:i:s')));
         $comment_obj->setContext($context);
         $comment_form = $this->createForm(CommentType::class, $comment_obj);
         $comment_form->handleRequest($request);
         if ($comment_form->isSubmitted() && $comment_form->isValid()) {
             $action_type = $comment_form->get('action_type')->getData() . 'Action';
             $this->{$action_type}($comment_obj);
             $refreshed_comment = clone $comment_obj;
             $refreshed_form = $this->createForm(CommentType::class, $refreshed_comment);
             $params['comment_form'] = $refreshed_form->createView();
         } else {
             $params['comment_form'] = $comment_form->createView();
         }
     }
     $comments = $this->repository->getAll($context_id);
     $params['comments'] = $comments;
     $params['is_logged'] = $is_logged;
     return $params;
 }
Example #23
0
 public static function getFields()
 {
     $result = array();
     $sep = " ";
     $ignore = array('id', 'category_id', 'user_id', 'editor_id', 'name', 'keywords', 'url_title', 'status', 'deleted', 'completion', 'created_at', 'updated_at');
     foreach (self::$_properties as $key => $property) {
         $labelArray = array();
         if (is_array($property)) {
             if (!in_array($key, $ignore)) {
                 $labelArray = explode("_", $key);
             }
         } else {
             if (!in_array($property, $ignore)) {
                 $labelArray = explode("_", $property);
             }
         }
         $label = "";
         $countlabelArray = count($labelArray);
         if ($countlabelArray >= 1) {
             for ($i = 0; $i < $countlabelArray; $i++) {
                 if ($i != 0) {
                     $label .= $sep;
                 }
                 $label .= ucfirst($labelArray[$i]);
             }
             $result[$property] = $label;
         }
     }
     return $result;
 }
Example #24
0
 public function run(CantigaController $controller, $id, $customDataGenerator = null)
 {
     try {
         $repository = $this->info->getRepository();
         $fetch = $this->fetch;
         $item = $fetch($repository, $id);
         $nameProperty = 'get' . ucfirst($this->info->getItemNameProperty());
         $name = $item->{$nameProperty}();
         $customData = null;
         if (is_callable($customDataGenerator)) {
             $customData = $customDataGenerator($item);
         }
         $vars = $this->getVars();
         $vars['pageTitle'] = $this->info->getPageTitle();
         $vars['pageSubtitle'] = $this->info->getPageSubtitle();
         $vars['item'] = $item;
         $vars['name'] = $name;
         $vars['custom'] = $customData;
         $vars['indexPage'] = $this->info->getIndexPage();
         $vars['infoPage'] = $this->info->getInfoPage();
         $vars['insertPage'] = $this->info->getInsertPage();
         $vars['editPage'] = $this->info->getEditPage();
         $vars['removePage'] = $this->info->getRemovePage();
         $controller->breadcrumbs()->link($name, $this->info->getInfoPage(), $this->slugify(['id' => $id]));
         return $controller->render($this->info->getTemplateLocation() . $this->info->getInfoTemplate(), $vars);
     } catch (ItemNotFoundException $exception) {
         return $this->onError($controller, $controller->trans($this->info->getItemNotFoundErrorMessage()));
     } catch (ModelException $exception) {
         return $this->onError($controller, $controller->trans($exception->getMessage()));
     }
 }
Example #25
0
 /**
  * Tests invalid data.
  */
 public function testInvalidDates()
 {
     $composer = new Composer();
     // Invalid date/time parts
     $units = array('second' => array(-1, 61, '-1', '61'), 'minute' => array(-1, 61, '-1', '61'), 'hour' => array(-1, 24, '-1', '24'), 'day' => array(0, 32, '0', '32'), 'month' => array(0, 13, '0', '13'), 'year' => array(1901, 2038, '1901', '2038'));
     foreach ($units as $unit => $tests) {
         foreach ($tests as $test) {
             try {
                 $composer->{'set' . ucfirst($unit)}($test);
             } catch (\Exception $e) {
                 $this->assertInstanceOf('\\Jyxo\\Time\\ComposerException', $e);
                 $this->assertSame(constant('\\Jyxo\\Time\\ComposerException::' . strtoupper($unit)), $e->getCode(), sprintf('Failed test for unit %s and value %s.', $unit, $test));
             }
         }
     }
     // Incomplete date
     try {
         $date = $composer->getTime();
     } catch (\Exception $e) {
         $this->assertInstanceOf('\\Jyxo\\Time\\ComposerException', $e);
         $this->assertSame(ComposerException::NOT_COMPLETE, $e->getCode());
     }
     // Invalid dates
     $tests = array('2002-04-31', '2003-02-29', '2004-02-30', '2005-06-31', '2006-09-31', '2007-11-31');
     foreach ($tests as $test) {
         try {
             list($year, $month, $day) = explode('-', $test);
             $composer->setDay($day)->setMonth($month)->setYear($year);
             $time = $composer->getTime();
         } catch (\Exception $e) {
             $this->assertInstanceOf('\\Jyxo\\Time\\ComposerException', $e);
             $this->assertSame(ComposerException::INVALID, $e->getCode(), sprintf('Failed test for %s.', $test));
         }
     }
 }
Example #26
0
	function displayLayout($layout=null, $tpl = null) {
		if ($layout) $this->setLayout ($layout);
		$viewName = ucfirst($this->getName ());
		$layoutName = ucfirst($this->getLayout ());

		KUNENA_PROFILER ? $this->profiler->start("display {$viewName}/{$layoutName}") : null;

		if (isset($this->common)) {
			if ($this->config->board_offline && ! $this->me->isAdmin ()) {
				// Forum is offline
				$this->common->header = JText::_('COM_KUNENA_FORUM_IS_OFFLINE');
				$this->common->body = $this->config->offline_message;
				$this->common->display('default');
				KUNENA_PROFILER ? $this->profiler->start("display {$viewName}/{$layoutName}") : null;
				return;
			} elseif ($this->config->regonly && ! $this->me->exists()) {
				// Forum is for registered users only
				$this->common->header = JText::_('COM_KUNENA_LOGIN_NOTIFICATION');
				$this->common->body = JText::_('COM_KUNENA_LOGIN_FORUM');
				$this->common->display('default');
				KUNENA_PROFILER ? $this->profiler->start("display {$viewName}/{$layoutName}") : null;
				return;
			}
		}

		$this->assignRef ( 'state', $this->get ( 'State' ) );
		$layoutFunction = 'display'.$layoutName;
		if (method_exists($this, $layoutFunction)) {
			$contents = $this->$layoutFunction ($tpl);
		} else {
			$contents = $this->display($tpl);
		}
		KUNENA_PROFILER ? $this->profiler->stop("display {$viewName}/{$layoutName}") : null;
		return $contents;
	}
 /**
  * Load the datagrids
  *
  * @return  void
  */
 private function loadDataGrids()
 {
     // load all categories that are in use
     $categories = BackendSlideshowModel::getActiveCategories(true);
     // run over categories and create datagrid for each one
     foreach ($categories as $categoryId => $categoryTitle) {
         // create datagrid
         $dataGrid = new BackendDataGridDB(BackendSlideshowModel::QRY_DATAGRID_BROWSE, array(BL::getWorkingLanguage(), $categoryId));
         // disable paging
         $dataGrid->setPaging(false);
         // set colum URLs
         $dataGrid->setColumnURL('title', BackendModel::createURLForAction('Edit') . '&amp;id=[id]');
         // set column functions
         $dataGrid->setColumnFunction(array(new BackendDataGridFunctions(), 'getLongDate'), array('[publish_on]'), 'publish_on', true);
         $dataGrid->setColumnFunction(array(new BackendDataGridFunctions(), 'getUser'), array('[user_id]'), 'user_id', true);
         // set headers
         $dataGrid->setHeaderLabels(array('user_id' => \SpoonFilter::ucfirst(BL::lbl('Author')), 'publish_on' => \SpoonFilter::ucfirst(BL::lbl('PublishedOn'))));
         // enable drag and drop
         $dataGrid->enableSequenceByDragAndDrop();
         // our JS needs to know an id, so we can send the new order
         $dataGrid->setRowAttributes(array('id' => '[id]'));
         $dataGrid->setAttributes(array('data-action' => "GallerySequence"));
         // create a column #images
         $dataGrid->addColumn('images', ucfirst(BL::lbl('Images')));
         $dataGrid->setColumnFunction(array('Backend\\Modules\\Slideshow\\Engine\\Model', 'getImagesByGallery'), array('[id]', true), 'images', true);
         // hide columns
         $dataGrid->setColumnsHidden(array('category_id', 'sequence', 'filename'));
         // add edit column
         $dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('Edit') . '&amp;id=[id]', BL::lbl('Edit'));
         // set column order
         $dataGrid->setColumnsSequence('dragAndDropHandle', 'title', 'images', 'user_id', 'publish_on', 'edit');
         // add dataGrid to list
         $this->dataGrids[] = array('id' => $categoryId, 'title' => $categoryTitle, 'content' => $dataGrid->getContent());
     }
 }
Example #28
0
 public function logincheck()
 {
     $username = $this->input->post('username');
     $password = $this->input->post('password');
     $this->load->model('users1');
     $result = $this->users1->login($username, $password);
     $this->form_validation->set_rules('username', 'Username', 'required');
     $this->form_validation->set_rules('password', 'Password', 'required');
     if ($this->form_validation->run() == FALSE) {
         //Field validation failed.  User redirected to login page
         $page = 'login';
         $data['title'] = ucfirst($page);
         $data['username'] = $this->session->userdata('username');
         $this->load->view('templates/header', $data);
         $this->load->view('users/login');
         $this->load->view('templates/footer');
     } else {
         //Go to private area
         if ($result) {
             foreach ($result as $row) {
                 $userdata = array('id' => $result[0]->id, 'username' => $result[0]->username, 'email' => $result[0]->email);
                 $this->session->set_userdata('logged_in', $userdata);
             }
             redirect('pages', 'refresh');
         } else {
             redirect('users/login', 'refresh');
         }
     }
 }
Example #29
0
 /**
  * Get identificator
  *
  * @return string
  */
 public function getIdentificator($ucfirst = false)
 {
     if ($ucfirst) {
         return ucfirst($this->identificator);
     }
     return $this->identificator;
 }
Example #30
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     foreach ($this->dropOrder as $option) {
         if ($input->getOption($option)) {
             $drop[] = $option;
         }
     }
     // Default to the full drop order if no options were specified
     $drop = empty($drop) ? $this->dropOrder : $drop;
     $class = $input->getOption('class');
     $sm = $this->getSchemaManager();
     $isErrored = false;
     foreach ($drop as $option) {
         try {
             if (isset($class)) {
                 $this->{'processDocument' . ucfirst($option)}($sm, $class);
             } else {
                 $this->{'process' . ucfirst($option)}($sm);
             }
             $output->writeln(sprintf('Dropped <comment>%s%s</comment> for <info>%s</info>', $option, isset($class) ? self::INDEX === $option ? '(es)' : '' : (self::INDEX === $option ? 'es' : 's'), isset($class) ? $class : 'all classes'));
         } catch (\Exception $e) {
             $output->writeln('<error>' . $e->getMessage() . '</error>');
             $isErrored = true;
         }
     }
     return $isErrored ? 255 : 0;
 }