Ejemplo n.º 1
0
 /**
  * Parse any media group placeholders
  *
  * @param  AbstractController $controller
  * @param  Application        $application
  * @return void
  */
 public static function parseMedia(AbstractController $controller, Application $application)
 {
     if ($controller->hasView() && ($controller instanceof \Phire\Categories\Controller\IndexController || $controller instanceof \Phire\Content\Controller\IndexController)) {
         $data = $controller->view()->getData();
         foreach ($data as $key => $value) {
             if (is_string($value)) {
                 $subIds = self::parseLibraryIds($value);
                 if (count($subIds) > 0) {
                     $media = new Model\Media();
                     foreach ($subIds as $sid) {
                         $view = new \Pop\View\View($value, ['media_' . $sid => $media->getAllByLibraryId($sid)]);
                         $controller->view()->{$key} = $view->render();
                     }
                 }
             }
         }
         $body = $controller->response()->getBody();
         $ids = self::parseLibraryIds($body);
         if (count($ids) > 0) {
             $media = new Model\Media();
             foreach ($ids as $id) {
                 $key = 'media_' . $id;
                 $controller->view()->{$key} = $media->getAllByLibraryId($id);
             }
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Parse calendar
  *
  * @param  AbstractController $controller
  * @param  Application        $application
  * @return void
  */
 public static function parse(AbstractController $controller, Application $application)
 {
     if (!$_POST && $controller->hasView() && $controller instanceof \Phire\Content\Controller\IndexController) {
         $body = $controller->response()->getBody();
         // Parse any calendar placeholders
         $calendars = [];
         $calendarIds = [];
         preg_match_all('/\\[\\{calendar.*\\}\\]/', $body, $calendars);
         if (isset($calendars[0]) && isset($calendars[0][0])) {
             foreach ($calendars[0] as $calendar) {
                 $id = substr($calendar, strpos($calendar, '[{calendar_') + 11);
                 if (strpos($id, '_') !== false) {
                     $id = substr($id, 0, strpos($id, '_'));
                     $replace = '[{calendar_' . $id . '_time}]';
                     $time = true;
                 } else {
                     $id = substr($id, 0, strpos($id, '}]'));
                     $replace = '[{calendar_' . $id . '}]';
                     $time = false;
                 }
                 $calendarIds[] = ['id' => $id, 'replace' => $replace, 'time' => $time];
             }
         }
         if (count($calendarIds) > 0) {
             $sess = $application->services()->get('session');
             $roleId = isset($sess->user) ? $sess->user->role_id : null;
             foreach ($calendarIds as $cal) {
                 $calendar = new Model\Calendar(['user_role_id' => $roleId, 'weekdays' => $application->module('phire-calendar')['weekdays'], 'range' => $application->module('phire-calendar')['range'], 'range_format' => $application->module('phire-calendar')['range_format'], 'day_format' => $application->module('phire-calendar')['day_format'], 'force_list' => $application->module('phire-calendar')['force_list'], 'force_list_mobile' => $application->module('phire-calendar')['force_list_mobile'], 'show_all' => $application->module('phire-calendar')['show_all'], 'date' => $controller->request()->getQuery('date')]);
                 $rendered = $calendar->getById($cal['id'], $cal['time']);
                 $body = str_replace($cal['replace'], $rendered, $body);
             }
             $controller->response()->setBody($body);
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * Parse view object
  *
  * @param  AbstractController $controller
  * @param  Application        $application
  * @return void
  */
 public static function parseSitemap(AbstractController $controller, Application $application)
 {
     if ($controller->hasView() && $controller instanceof \Phire\Content\Controller\IndexController) {
         $body = $controller->response()->getBody();
         if (strpos($body, '[{sitemap') !== false) {
             $sitemaps = [];
             preg_match_all('/\\[\\{sitemap.*\\}\\]/', $body, $sitemaps);
             if (isset($sitemaps[0]) && isset($sitemaps[0][0])) {
                 foreach ($sitemaps[0] as $sitemap) {
                     $node = 'nav';
                     $tid = substr($sitemap, strpos($sitemap, 'sitemap') + 7);
                     $tid = str_replace('}]', '', $tid);
                     if ($tid != '') {
                         if (substr($tid, 0, 1) == '_') {
                             $tid = substr($tid, 1);
                         }
                         if (strpos($tid, '_') !== false) {
                             $tidAry = explode('_', $tid);
                             $node = $tidAry[0];
                             $tid = $tidAry[1];
                         } else {
                             $node = $tid;
                             $tid = null;
                         }
                     } else {
                         $tid = null;
                     }
                     $siteMapObject = (new Model\Sitemap())->getSitemapObject($node, $tid);
                     $body = str_replace($sitemap, $siteMapObject, $body);
                 }
             }
             $controller->response()->setBody($body);
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * Parse social navigation
  *
  * @param  AbstractController $controller
  * @param  Application        $application
  * @return void
  */
 public static function parse(AbstractController $controller, Application $application)
 {
     if ($controller->hasView() && ($controller instanceof \Phire\Content\Controller\IndexController || $controller instanceof \Phire\Categories\Controller\IndexController)) {
         $body = $controller->response()->getBody();
         if (strpos($body, '[{social_nav') !== false) {
             $social = new Model\Social();
             $body = str_replace(['[{social_nav}]', '[{social_nav_styles}]'], [$social->buildNav(), $social->getStyles()], $body);
             $controller->response()->setBody($body);
         }
     }
 }
Ejemplo n.º 5
0
 /**
  * Parse SEO
  *
  * @param  AbstractController $controller
  * @param  Application        $application
  * @return void
  */
 public static function parse(AbstractController $controller, Application $application)
 {
     if ($controller->hasView() && ($controller instanceof \Phire\Content\Controller\IndexController || $controller instanceof \Phire\Categories\Controller\IndexController)) {
         $seo = new Model\Seo();
         $body = $controller->response()->getBody();
         if (strpos($body, '[{seo_meta_tags}]') !== false) {
             $body = str_replace('[{seo_meta_tags}]', $seo->buildMetaTags($controller->view()->description, $controller->view()->keywords), $body);
         }
         if (!empty($seo->tracking)) {
             $body = str_replace('</head>', $seo->tracking . PHP_EOL . PHP_EOL . '</head>', $body);
         }
         $controller->response()->setBody($body);
     }
 }
Ejemplo n.º 6
0
 /**
  * Parse maps navigation
  *
  * @param  AbstractController $controller
  * @param  Application        $application
  * @return void
  */
 public static function parse(AbstractController $controller, Application $application)
 {
     if ($controller->hasView() && ($controller instanceof \Phire\Content\Controller\IndexController || $controller instanceof \Phire\Categories\Controller\IndexController)) {
         $body = $controller->response()->getBody();
         if (strpos($body, '[{map_') !== false) {
             $ids = self::parseMapIds($body);
             if (count($ids) > 0) {
                 $map = new Model\Map();
                 foreach ($ids as $id) {
                     $body = str_replace('[{map_' . $id . '}]', $map->getMap($id), $body);
                 }
             }
             $controller->response()->setBody($body);
         }
     }
 }
Ejemplo n.º 7
0
 /**
  * Set the template for the content
  *
  * @param  AbstractController $controller
  * @param  Application        $application
  * @return void
  */
 public static function setTemplate(AbstractController $controller, Application $application)
 {
     $template = null;
     $themePath = null;
     $parentThemePath = null;
     $realThemePath = null;
     $theme = Table\Themes::findBy(['active' => 1]);
     if (isset($theme->id)) {
         $themePath = $_SERVER['DOCUMENT_ROOT'] . BASE_PATH . CONTENT_PATH . '/themes/' . $theme->folder . '/';
         if (null !== $theme->parent_id) {
             $parentTheme = Table\Themes::findById($theme->parent_id);
             if (isset($parentTheme->id)) {
                 $parentThemePath = $_SERVER['DOCUMENT_ROOT'] . BASE_PATH . CONTENT_PATH . '/themes/' . $parentTheme->folder . '/';
             }
         }
     }
     if ($application->isRegistered('phire-content') && $controller instanceof \Phire\Content\Controller\IndexController && $controller->hasView()) {
         if (null !== $controller->getTemplate()) {
             if (isset($theme->id)) {
                 $controller->view()->themePath = $themePath;
                 $controller->view()->parentThemePath = $parentThemePath;
                 if ($controller->getTemplate() == -1 && (file_exists($themePath . 'error.phtml') || file_exists($themePath . 'error.php'))) {
                     $template = file_exists($themePath . 'error.phtml') ? 'error.phtml' : 'error.php';
                 } else {
                     if ($controller->getTemplate() == -2 && (file_exists($themePath . 'date.phtml') || file_exists($themePath . 'date.php'))) {
                         $template = file_exists($themePath . 'date.phtml') ? 'date.phtml' : 'date.php';
                     } else {
                         if (file_exists($themePath . $controller->getTemplate())) {
                             $template = $controller->getTemplate();
                         }
                     }
                 }
                 $realThemePath = $themePath;
                 if (null === $template && null !== $parentThemePath) {
                     if ($controller->getTemplate() == -1 && (file_exists($parentThemePath . 'error.phtml') || file_exists($parentThemePath . 'error.php'))) {
                         $template = file_exists($parentThemePath . 'error.phtml') ? 'error.phtml' : 'error.php';
                     } else {
                         if ($controller->getTemplate() == -2 && (file_exists($parentThemePath . 'date.phtml') || file_exists($parentThemePath . 'date.php'))) {
                             $template = file_exists($parentThemePath . 'date.phtml') ? 'date.phtml' : 'date.php';
                         } else {
                             if (file_exists($parentThemePath . $controller->getTemplate())) {
                                 $template = $controller->getTemplate();
                             }
                         }
                     }
                     $realThemePath = $parentThemePath;
                 }
                 if (null !== $template && null !== $realThemePath) {
                     $device = self::getDevice($controller->request()->getQuery('mobile'));
                     if (null !== $device && file_exists($realThemePath . $device . '/' . $template)) {
                         $template = $device . '/' . $template;
                     }
                     $controller->view()->setTemplate($realThemePath . $template);
                 }
             }
         }
     }
 }
Ejemplo n.º 8
0
 /**
  * Add CAPTCHA image to form with a CAPTCHA field
  *
  * @param  AbstractController $controller
  * @param  Application        $application
  * @return void
  */
 public static function addCaptcha(AbstractController $controller, Application $application)
 {
     if ($controller->hasView() && null !== $controller->view()->form && $controller->view()->form !== false && $controller->view()->form instanceof \Pop\Form\Form && null !== $controller->view()->form->getElement('captcha')) {
         $captcha = new \Phire\Captcha\Model\Captcha($application->module('phire-captcha')['config']);
         $captcha->createToken();
         $controller->view()->form->getElement('captcha')->setToken($captcha->token, 'Enter Code');
     }
 }
Ejemplo n.º 9
0
 /**
  * Parse form object
  *
  * @param  AbstractController $controller
  * @param  Application        $application
  * @return void
  */
 public static function parseForms(AbstractController $controller, Application $application)
 {
     if ($controller->hasView() && ($application->isRegistered('phire-content') && $controller instanceof \Phire\Content\Controller\IndexController || $application->isRegistered('phire-categories') && $controller instanceof \Phire\Categories\Controller\IndexController)) {
         $body = $controller->response()->getBody();
         if (strpos($body, '[{form_') !== false) {
             // Parse any form placeholders
             $formIds = [];
             $forms = [];
             preg_match_all('/\\[\\{form.*\\}\\]/', $body, $forms);
             if (isset($forms[0]) && isset($forms[0][0])) {
                 foreach ($forms[0] as $form) {
                     $id = substr($form, strpos($form, 'form_') + 5);
                     $formIds[] = str_replace('}]', '', $id);
                 }
             }
             if (count($formIds) > 0) {
                 foreach ($formIds as $id) {
                     try {
                         $form = new \Phire\Forms\Form\Form($id);
                         if ($form->isSubmitted()) {
                             $values = $form->getMethod() == 'post' ? $_POST : $_GET;
                             if ($form->isFiltered()) {
                                 $form->addFilter('strip_tags');
                             }
                             $form->setFieldValues($values);
                             if ($form->isValid()) {
                                 $form->process();
                                 $body = str_replace('[{form_' . $id . '}]', $form->getMessage(), $body);
                             } else {
                                 $body = str_replace('[{form_' . $id . '}]', (string) $form, $body);
                             }
                         } else {
                             $body = str_replace('[{form_' . $id . '}]', (string) $form, $body);
                         }
                     } catch (\Exception $e) {
                         $body = str_replace('[{form_' . $id . '}]', '', $body);
                     }
                 }
             }
             $controller->response()->setBody($body);
         }
     }
 }
Ejemplo n.º 10
0
 /**
  * Constructor method to instantiate the user controller object
  *
  * @param  Request  $request
  * @param  Response $response
  * @param  Project  $project
  * @param  string   $viewPath
  * @return self
  */
 public function __construct(Request $request = null, Response $response = null, Project $project = null, $viewPath = null)
 {
     // Create the session object and get the user type
     $this->sess = Session::getInstance();
     $this->type = $project->getService('acl')->getType();
     if (null === $viewPath) {
         $cfg = $project->module('Phire')->asArray();
         $viewPath = __DIR__ . '/../../../../view/phire';
         if (isset($cfg['view'])) {
             $class = get_class($this);
             if (is_array($cfg['view']) && isset($cfg['view'][$class])) {
                 $viewPath = $cfg['view'][$class];
             } else {
                 if (is_array($cfg['view']) && isset($cfg['view']['*'])) {
                     $viewPath = $cfg['view']['*'];
                 } else {
                     if (is_string($cfg['view'])) {
                         $viewPath = $cfg['view'];
                     }
                 }
             }
         }
         // If it is not a user, or a user globally logged into another area
         if (strtolower($this->type->type) != 'user' && !$this->type->global_access || substr($_SERVER['REQUEST_URI'], 0, strlen(BASE_PATH . APP_URI)) != BASE_PATH . APP_URI) {
             $site = Table\Sites::getSite();
             $theme = Table\Extensions::findBy(array('type' => 0, 'active' => 1), null, 1);
             $themePath = $site->document_root . $site->base_path . CONTENT_PATH . DIRECTORY_SEPARATOR . 'extensions' . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . $this->type->type;
             $activeThemePath = null;
             if (isset($theme->rows[0])) {
                 $activeThemePath = $site->document_root . $site->base_path . CONTENT_PATH . DIRECTORY_SEPARATOR . 'extensions' . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . $theme->rows[0]->name . DIRECTORY_SEPARATOR . $this->type->type;
             }
             if (null !== $activeThemePath && file_exists($activeThemePath)) {
                 $viewPath = $activeThemePath;
             } else {
                 if (file_exists($themePath)) {
                     $viewPath = $themePath;
                 }
             }
         }
     }
     // Set the correct base path and user URI based on user type
     if (get_called_class() == 'Phire\\Controller\\Phire\\IndexController') {
         $basePath = strtolower($this->type->type) != 'user' ? BASE_PATH . '/' . strtolower($this->type->type) : BASE_PATH . APP_URI;
         $request = new Request(null, $basePath);
     }
     parent::__construct($request, $response, $project, $viewPath);
 }
Ejemplo n.º 11
0
 /**
  * Init the entity model and parse any entity placeholders
  *
  * @param  AbstractController $controller
  * @param  Application        $application
  * @return void
  */
 public static function init(AbstractController $controller, Application $application)
 {
     if ($application->isRegistered('phire-templates') && $controller->hasView() && $controller->view()->isStream()) {
         $ents = [];
         preg_match_all('/\\[\\{entity_.*\\}\\]/', $controller->view()->getTemplate()->getTemplate(), $ents);
         if (isset($ents[0]) && isset($ents[0][0])) {
             foreach ($ents[0] as $ent) {
                 $id = str_replace('}]', '', substr($ent, strpos($ent, '_') + 1));
                 $controller->view()->{'entity_' . $id} = (new Model\Entity())->getByType($id);
             }
         }
     }
     if ($controller->hasView()) {
         $controller->view()->phire->entity = new Model\Entity();
     }
 }
Ejemplo n.º 12
0
 /**
  * Save feed relationships
  *
  * @param  AbstractController $controller
  * @param  Application        $application
  * @return void
  */
 public static function save(AbstractController $controller, Application $application)
 {
     if ($_POST && $controller->hasView() && null !== $controller->view()->id && null !== $controller->view()->form && $controller->view()->form !== false && $controller->view()->form instanceof \Pop\Form\Form) {
         $id = $controller->view()->id;
         $feed = $controller->view()->form->feed;
         $type = $controller->view()->form->feed_type;
         if (null !== $feed && null !== $type) {
             if ($feed == '1') {
                 $f = Table\Feed::findById([$id, $type]);
                 if (!isset($f->id)) {
                     $feed = new Table\Feed(['id' => $id, 'type' => $type]);
                     $feed->save();
                 }
             } else {
                 if ($feed == '0') {
                     $f = Table\Feed::findById([$id, $type]);
                     if (isset($f->id)) {
                         $f->delete();
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 13
0
 /**
  * Parse view object
  *
  * @param  AbstractController $controller
  * @param  Application        $application
  * @return void
  */
 public static function parseViews(AbstractController $controller, Application $application)
 {
     if (!$controller instanceof \Phire\Content\Controller\ContentController && !$controller instanceof \Phire\Templates\Controller\IndexController && $controller->hasView()) {
         $body = $controller->response()->getBody();
         if (strpos($body, '[{view_') !== false) {
             // Parse any view placeholders
             $groupIds = [];
             $singleIds = [];
             $modelId = null;
             $views = [];
             $viewModel = new Model\View(['pagination' => $controller->config()->pagination]);
             preg_match_all('/\\[\\{view.*\\}\\]/', $body, $views);
             if (isset($views[0]) && isset($views[0][0])) {
                 foreach ($views[0] as $view) {
                     $id = substr($view, strpos($view, 'view_') + 5);
                     $id = str_replace('}]', '', $id);
                     if (strpos($id, '_') !== false) {
                         $idAry = explode('_', $id);
                         if (!empty($idAry[1])) {
                             $modelId = $idAry[1];
                         } else {
                             if (!empty($controller->view()->id)) {
                                 $modelId = $controller->view()->id;
                             }
                         }
                         $singleIds[] = ['view_id' => $idAry[0], 'model_id' => $modelId];
                     } else {
                         $groupIds[] = $id;
                     }
                 }
             }
             if (count($groupIds) > 0) {
                 foreach ($groupIds as $id) {
                     $body = str_replace('[{view_' . $id . '}]', $viewModel->renderPages($id) . PHP_EOL . $viewModel->render($id), $body);
                 }
             }
             if (count($singleIds) > 0) {
                 foreach ($singleIds as $id) {
                     if (null !== $id['model_id']) {
                         $body = str_replace('[{view_' . $id['view_id'] . '_' . $id['model_id'] . '}]', $viewModel->renderSingle($id['view_id'], $id['model_id']), $body);
                         $body = str_replace('[{view_' . $id['view_id'] . '_}]', $viewModel->renderSingle($id['view_id'], $id['model_id']), $body);
                     }
                 }
             }
             $controller->response()->setBody($body);
         }
     }
 }
Ejemplo n.º 14
0
 /**
  * Constructor method to instantiate the groups controller object
  *
  * @param  Request  $request
  * @param  Response $response
  * @param  Project  $project
  * @param  string   $viewPath
  * @return self
  */
 public function __construct(Request $request = null, Response $response = null, Project $project = null, $viewPath = null)
 {
     if (null === $viewPath) {
         $cfg = $project->module('Phire')->asArray();
         $viewPath = __DIR__ . '/../../../../../view/phire/structure';
         if (isset($cfg['view'])) {
             $class = get_class($this);
             if (is_array($cfg['view']) && isset($cfg['view'][$class])) {
                 $viewPath = $cfg['view'][$class];
             } else {
                 if (is_array($cfg['view']) && isset($cfg['view']['*'])) {
                     $viewPath = $cfg['view']['*'];
                 } else {
                     if (is_string($cfg['view'])) {
                         $viewPath = $cfg['view'];
                     }
                 }
             }
         }
     }
     parent::__construct($request, $response, $project, $viewPath);
 }
Ejemplo n.º 15
0
 /**
  * Set the search template
  *
  * @param  AbstractController $controller
  * @param  Application        $application
  * @return void
  */
 public static function setTemplate(AbstractController $controller, Application $application)
 {
     if ($application->isRegistered('phire-templates') && $controller instanceof \Phire\Search\Controller\IndexController && $controller->hasView()) {
         $template = \Phire\Templates\Table\Templates::findBy(['name' => 'Search']);
         if (isset($template->id)) {
             if (isset($template->id)) {
                 $device = \Phire\Templates\Event\Template::getDevice($controller->request()->getQuery('mobile'));
                 if (null !== $device && $template->device != $device) {
                     $childTemplate = \Phire\Templates\Table\Templates::findBy(['parent_id' => $template->id, 'device' => $device]);
                     if (isset($childTemplate->id)) {
                         $tmpl = $childTemplate->template;
                     } else {
                         $tmpl = $template->template;
                     }
                 } else {
                     $tmpl = $template->template;
                 }
                 $controller->view()->setTemplate(\Phire\Templates\Event\Template::parse($tmpl));
             }
         }
     } else {
         if ($application->isRegistered('phire-themes') && $controller instanceof \Phire\Search\Controller\IndexController && $controller->hasView()) {
             $theme = \Phire\Themes\Table\Themes::findBy(['active' => 1]);
             if (isset($theme->id)) {
                 $themePath = $_SERVER['DOCUMENT_ROOT'] . BASE_PATH . CONTENT_PATH . '/themes/' . $theme->folder . '/';
                 if (file_exists($themePath . 'search.phtml') || file_exists($themePath . 'search.php')) {
                     $template = file_exists($themePath . 'search.phtml') ? 'search.phtml' : 'search.php';
                     $device = \Phire\Themes\Event\Theme::getDevice($controller->request()->getQuery('mobile'));
                     if (null !== $device && file_exists($themePath . $device . '/' . $template)) {
                         $template = $device . '/' . $template;
                     }
                     $controller->view()->setTemplate($themePath . $template);
                 }
             }
         }
     }
 }
Ejemplo n.º 16
0
 /**
  * Prepare view
  *
  * @param  string $navigation
  * @return void
  */
 protected function prepareView($navigation)
 {
     $this->viewPath = __DIR__ . '/../../view';
     parent::prepareView($navigation);
 }
Ejemplo n.º 17
0
 /**
  * Prepare view
  *
  * @param  string $template
  * @return void
  */
 protected function prepareView($template)
 {
     $this->viewPath = __DIR__ . '/../../view';
     parent::prepareView($template);
     if (isset($this->sess->member)) {
         $this->view->member = $this->sess->member;
     }
     $this->view->memberName = $this->memberName;
     $this->view->member_name = $this->memberName;
     $this->view->memberUri = $this->memberUri;
     $this->view->member_uri = $this->memberUri;
     $this->view->memberPath = $this->memberUri;
     $this->view->member_path = $this->memberUri;
     $this->view->memberRoleId = $this->memberRoleId;
     $this->view->member_role_id = $this->memberRoleId;
 }
Ejemplo n.º 18
0
 /**
  * Save dynamic field values
  *
  * @param  AbstractController $controller
  * @param  Application        $application
  * @return void
  */
 public static function save(AbstractController $controller, Application $application)
 {
     if ($_POST && $controller->hasView() && null !== $controller->view()->id && null !== $controller->view()->form && $controller->view()->form !== false && $controller->view()->form instanceof \Pop\Form\Form) {
         $fields = $controller->view()->form->getFields();
         $modelId = $controller->view()->id;
         $model = str_replace('Form', 'Model', get_class($controller->view()->form));
         $uploadFolder = BASE_PATH . CONTENT_PATH . '/files';
         $mediaLibrary = $application->module('phire-fields')->config()['media_library'];
         // Remove any files
         foreach ($_POST as $key => $value) {
             if (substr($key, 0, 14) == 'rm_field_file_' && isset($value[0])) {
                 $fieldId = substr($key, 14);
                 if (strpos($fieldId, '_') !== false) {
                     $fieldId = substr($fieldId, 0, strpos($fieldId, '_'));
                 }
                 $field = Table\Fields::findById($fieldId);
                 if (isset($field->id)) {
                     if ($field->storage == 'eav') {
                         $fv = Table\FieldValues::findById([$fieldId, $modelId, $model]);
                         if (isset($fv->field_id)) {
                             $oldValue = json_decode($fv->value);
                             if (is_array($oldValue)) {
                                 if (array_search($value[0], $oldValue) !== false) {
                                     $k = array_search($value[0], $oldValue);
                                     if (file_exists($_SERVER['DOCUMENT_ROOT'] . $uploadFolder . '/' . $oldValue[$k])) {
                                         unlink($_SERVER['DOCUMENT_ROOT'] . $uploadFolder . '/' . $oldValue[$k]);
                                         if (null !== $mediaLibrary && $application->isRegistered('phire-media')) {
                                             $media = new \Phire\Media\Model\Media();
                                             $media->getByFile($oldValue[$k]);
                                             if (isset($media->id) && $media->library_folder == $mediaLibrary) {
                                                 $media->remove(['rm_media' => [$media->id]]);
                                             }
                                         }
                                     }
                                     unset($oldValue[$k]);
                                 }
                                 if (count($oldValue) == 0) {
                                     $fv->delete();
                                 } else {
                                     $oldValue = array_values($oldValue);
                                     $fv->value = json_encode($oldValue);
                                     $fv->save();
                                 }
                             } else {
                                 if (file_exists($_SERVER['DOCUMENT_ROOT'] . $uploadFolder . '/' . $oldValue)) {
                                     unlink($_SERVER['DOCUMENT_ROOT'] . $uploadFolder . '/' . $oldValue);
                                     if (null !== $mediaLibrary && $application->isRegistered('phire-media')) {
                                         $media = new \Phire\Media\Model\Media();
                                         $media->getByFile($oldValue);
                                         if (isset($media->id) && $media->library_folder == $mediaLibrary) {
                                             $media->remove(['rm_media' => [$media->id]]);
                                         }
                                     }
                                 }
                                 $fv->delete();
                             }
                         }
                     } else {
                         $fv = new Record();
                         $fv->setPrefix(DB_PREFIX)->setPrimaryKeys(['id'])->setTable('field_' . $field->name);
                         $fv->findRecordsBy(['model_id' => $modelId, 'model' => $model, 'value' => $value[0]]);
                         if (isset($fv->model_id)) {
                             if (file_exists($_SERVER['DOCUMENT_ROOT'] . $uploadFolder . '/' . $value[0])) {
                                 unlink($_SERVER['DOCUMENT_ROOT'] . $uploadFolder . '/' . $value[0]);
                                 if (null !== $mediaLibrary && $application->isRegistered('phire-media')) {
                                     $media = new \Phire\Media\Model\Media();
                                     $media->getByFile($value[0]);
                                     if (isset($media->id) && $media->library_folder == $mediaLibrary) {
                                         $media->remove(['rm_media' => [$media->id]]);
                                     }
                                 }
                             }
                             $fv = new Record();
                             $fv->setPrefix(DB_PREFIX)->setPrimaryKeys(['id'])->setTable('field_' . $field->name);
                             $fv->delete(['model_id' => $modelId, 'model' => $model, 'value' => $value[0]]);
                         }
                     }
                 }
             }
         }
         // Save field values
         foreach ($fields as $key => $value) {
             if (substr($key, 0, 6) == 'field_' && substr_count($key, '_') == 1) {
                 $fieldId = (int) substr($key, 6);
                 $field = Table\Fields::findById($fieldId);
                 if (isset($field->id)) {
                     if ($field->storage == 'eav') {
                         Value\Eav::save($application, $field, $value, $model, $modelId, $uploadFolder, $mediaLibrary);
                     } else {
                         Value\Table::save($application, $field, $value, $model, $modelId, $uploadFolder, $mediaLibrary);
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 19
0
 /**
  * Save category relationships
  *
  * @param  AbstractController $controller
  * @param  Application        $application
  * @return void
  */
 public static function save(AbstractController $controller, Application $application)
 {
     $type = null;
     $contentId = null;
     if ($_POST && $controller->hasView() && null !== $controller->view()->id && null !== $controller->view()->form && $controller->view()->form instanceof \Pop\Form\Form) {
         $categories = $controller->view()->form->categories;
         $type = $controller->view()->form->category_type;
         $contentId = $controller->view()->id;
         // Clear categories
         if (null !== $type && null !== $contentId) {
             if (!is_array($contentId)) {
                 $contentId = [$contentId];
             }
             foreach ($contentId as $id) {
                 $itemId = $type == 'media' ? 'media_id' : 'content_id';
                 $c2c = new Table\CategoryItems();
                 $c2c->delete([$itemId => $id]);
             }
             if (is_array($categories) && count($categories) > 0) {
                 foreach ($categories as $category) {
                     foreach ($contentId as $id) {
                         if ($type == 'media') {
                             $fields = ['category_id' => $category, 'content_id' => null, 'media_id' => $id, 'order' => (int) $_POST['category_order_' . $category]];
                         } else {
                             $fields = ['category_id' => $category, 'content_id' => $id, 'media_id' => null, 'order' => (int) $_POST['category_order_' . $category]];
                         }
                         $catItem = new Table\CategoryItems($fields);
                         $catItem->save();
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 20
0
 /**
  * Prepare view
  *
  * @param  string $search
  * @return void
  */
 protected function prepareView($search)
 {
     $this->viewPath = __DIR__ . '/../../view';
     parent::prepareView($search);
 }
Ejemplo n.º 21
0
 /**
  * Set the navigation objects
  *
  * @param  AbstractController $controller
  * @param  Application        $application
  * @return void
  */
 public static function getNavigation(AbstractController $controller, Application $application)
 {
     if ($application->isRegistered('phire-categories') && $controller instanceof \Phire\Categories\Controller\IndexController || $application->isRegistered('phire-content') && $controller instanceof \Phire\Content\Controller\IndexController && $controller->hasView()) {
         $navigation = Table\Navigation::findAll();
         foreach ($navigation->rows() as $nav) {
             $tree = (new Model\Navigation())->getTree($nav->id);
             $slug = Slug::filter($nav->title);
             $name = str_replace('-', '_', $slug);
             $topId = empty($nav->top_id) ? $slug : $nav->top_id;
             $config = [];
             if (!empty($nav->on_class)) {
                 $config['on'] = $nav->on_class;
             }
             if (!empty($nav->off_class)) {
                 $config['off'] = $nav->off_class;
             }
             $config['top'] = ['id' => $topId];
             if (!empty($nav->top_node)) {
                 $config['top']['node'] = $nav->top_node;
             }
             if (!empty($nav->top_class)) {
                 $config['top']['class'] = $nav->top_class;
             }
             if (!empty($nav->top_attributes)) {
                 $attribs = explode('" ', $nav->top_attributes);
                 $attribAry = [];
                 foreach ($attribs as $att) {
                     $val = explode('="', $att);
                     $attribAry[trim($val[0])] = trim($val[1]);
                 }
                 $config['top']['attributes'] = $attribAry;
             }
             if (!empty($nav->parent_node)) {
                 if (!isset($config['parent'])) {
                     $config['parent'] = [];
                 }
                 $config['parent']['node'] = $nav->parent_node;
             }
             if (!empty($nav->parent_id)) {
                 if (!isset($config['parent'])) {
                     $config['parent'] = [];
                 }
                 $config['parent']['id'] = $nav->parent_id;
             }
             if (!empty($nav->parent_class)) {
                 if (!isset($config['parent'])) {
                     $config['parent'] = [];
                 }
                 $config['parent']['class'] = $nav->parent_class;
             }
             if (!empty($nav->parent_attributes)) {
                 if (!isset($config['parent'])) {
                     $config['parent'] = [];
                 }
                 $attribs = explode('" ', $nav->parent_attributes);
                 $attribAry = [];
                 foreach ($attribs as $att) {
                     $val = explode('="', $att);
                     $attribAry[trim($val[0])] = trim($val[1]);
                 }
                 $config['parent']['attributes'] = $attribAry;
             }
             if (!empty($nav->child_node)) {
                 if (!isset($config['child'])) {
                     $config['child'] = [];
                 }
                 $config['child']['node'] = $nav->child_node;
             }
             if (!empty($nav->child_id)) {
                 if (!isset($config['child'])) {
                     $config['child'] = [];
                 }
                 $config['child']['id'] = $nav->child_id;
             }
             if (!empty($nav->child_class)) {
                 if (!isset($config['child'])) {
                     $config['child'] = [];
                 }
                 $config['child']['class'] = $nav->child_class;
             }
             if (!empty($nav->child_attributes)) {
                 if (!isset($config['child'])) {
                     $config['child'] = [];
                 }
                 $attribs = explode('" ', $nav->child_attributes);
                 $attribAry = [];
                 foreach ($attribs as $att) {
                     $val = explode('="', $att);
                     $attribAry[trim($val[0])] = trim($val[1]);
                 }
                 $config['child']['attributes'] = $attribAry;
             }
             if (!empty($nav->indent)) {
                 $config['indent'] = str_repeat(' ', (int) $nav->indent);
             }
             if ($application->isRegistered('phire-content')) {
                 $sess = $application->services()->get('session');
                 $roleId = isset($sess->user) && isset($sess->user->role_id) ? $sess->user->role_id : null;
                 self::checkTreeStatus($tree, $roleId);
             }
             $navObject = new Nav($tree, $config);
             $controller->view()->set($name, $navObject);
         }
     }
 }
Ejemplo n.º 22
0
 /**
  * Save tag relationships
  *
  * @param  AbstractController $controller
  * @param  Application        $application
  * @return void
  */
 public static function save(AbstractController $controller, Application $application)
 {
     $contentId = null;
     if ($_POST && $controller->hasView() && null !== $controller->view()->id && null !== $controller->view()->form && $controller->view()->form !== false && $controller->view()->form instanceof \Pop\Form\Form) {
         $tags = $controller->view()->form->content_tags;
         $contentId = $controller->view()->id;
         if (null !== $contentId) {
             $c2t = new Table\TagItems();
             $c2t->delete(['content_id' => $contentId]);
         }
         if (!empty($tags)) {
             $tags = explode(',', $tags);
             foreach ($tags as $tag) {
                 $tag = trim($tag);
                 $t = Table\Tags::findBy(['title' => $tag]);
                 if (!isset($t->id)) {
                     $t = new Table\Tags(['title' => $tag, 'slug' => Slug::filter($tag)]);
                     $t->save();
                 }
                 $c2t = new Table\TagItems(['content_id' => $contentId, 'tag_id' => $t->id]);
                 $c2t->save();
             }
         }
     }
 }
Ejemplo n.º 23
0
 /**
  * Initialize page editor
  *
  * @param  AbstractController $controller
  * @param  Application        $application
  * @return void
  */
 public static function initPageEditor(AbstractController $controller, Application $application)
 {
     if ($controller instanceof \Phire\Content\Controller\IndexController && $controller->hasView() && $controller->response()->getCode() == 200) {
         $sess = $application->services()->get('session');
         $acl = $application->services()->get('acl');
         if (isset($sess->user) && $acl->isAllowed($sess->user->role, 'content', 'in-edit') && $acl->isAllowed($sess->user->role, 'content', 'edit')) {
             $body = $controller->response()->getBody();
             $head = substr($body, strpos($body, '<head>'));
             $head = substr($head, 0, strpos($head, '</head>') + 7);
             $newHead = $head;
             $assets = '    <link type="text/css" rel="stylesheet" href="' . BASE_PATH . CONTENT_PATH . '/assets/' . $controller->config()->system_theme . '/css/font-awesome.min.css" />' . PHP_EOL;
             $assets .= '    <link type="text/css" rel="stylesheet" href="' . BASE_PATH . CONTENT_PATH . '/assets/phire-content/css/phire.content.edit.css" />' . PHP_EOL . PHP_EOL;
             if (strpos($newHead, 'jax.4.0.0.min.js') === false && strpos($newHead, 'jax.4.0.0.js') === false) {
                 if (strpos($newHead, '<script') !== false) {
                     $newHead1 = substr($newHead, 0, strpos($newHead, '<script'));
                     $newHead2 = substr($newHead, strpos($newHead, '<script'));
                     $newHead1 .= '<script type="text/javascript" src="' . BASE_PATH . CONTENT_PATH . '/assets/phire/js/jax.4.0.0.min.js"></script>' . PHP_EOL;
                     $newHead1 .= '    <script type="text/javascript">' . PHP_EOL;
                     $newHead1 .= '        jax.noConflict();' . PHP_EOL;
                     $newHead1 .= '    </script>' . PHP_EOL . '    ';
                     $newHead = $newHead1 . $newHead2;
                 } else {
                     $assets .= '    <script type="text/javascript" src="' . BASE_PATH . CONTENT_PATH . '/assets/phire/js/jax.4.0.0.min.js"></script>' . PHP_EOL;
                     $assets .= '    <script type="text/javascript">' . PHP_EOL;
                     $assets .= '        jax.noConflict();' . PHP_EOL;
                     $assets .= '    </script>' . PHP_EOL;
                 }
             }
             $assets .= '    <script type="text/javascript" src="' . BASE_PATH . CONTENT_PATH . '/assets/phire/js/phire.js"></script>' . PHP_EOL;
             $assets .= '    <script type="text/javascript" src="' . BASE_PATH . CONTENT_PATH . '/assets/phire-content/js/phire.content.edit.js"></script>' . PHP_EOL . PHP_EOL;
             $assets .= '</head>';
             $systemUri = BASE_PATH . APP_URI;
             if ($systemUri == '') {
                 $systemUri = '/';
             }
             $contentUri = BASE_PATH . APP_URI . '/content/edit/' . $controller->view()->type_id . '/' . $controller->view()->id . '?in_edit=1';
             $nav = PHP_EOL . '<nav id="phire-in-edit-nav">' . PHP_EOL;
             $nav .= '    <a href="' . $contentUri . '" title="Edit Page" onclick="phire.launchPageEditor(this.href); return false;"><span>Edit</span></a>' . PHP_EOL;
             $nav .= '    <a href="' . $systemUri . '" title="Dashboard"><span>Dashboard</span></a>' . PHP_EOL;
             $nav .= '</nav>' . PHP_EOL . PHP_EOL;
             $nav .= '</body>';
             $newHead = str_replace('</head>', $assets, $newHead);
             $body = str_replace($head, $newHead, $body);
             $body = str_replace('</body>', $nav, $body);
             $controller->response()->setBody($body);
         }
     }
 }
Ejemplo n.º 24
0
 /**
  * Init category nav and categories
  *
  * @param  AbstractController $controller
  * @param  Application        $application
  * @return void
  */
 public static function setTemplate(AbstractController $controller, Application $application)
 {
     if ($controller->hasView() && $controller instanceof \Phire\Members\Controller\IndexController) {
         $template = basename($controller->view()->getTemplate()->getTemplate());
         $memberName = $controller->view()->memberName;
         $memberUri = $controller->view()->memberUri;
         $templateName = null;
         if ($application->isRegistered('phire-templates')) {
             switch ($template) {
                 case 'login.phtml':
                     $templateName = $memberName . ' Login';
                     break;
                 case 'forgot.phtml':
                     $templateName = $memberName . ' Forgot';
                     break;
                 case 'index.phtml':
                     $templateName = $memberName . ' Index';
                     break;
                 case 'profile.phtml':
                     $templateName = $memberName . ' Profile';
                     break;
                 case 'register.phtml':
                     $templateName = $memberName . ' Register';
                     break;
                 case 'unsubscribe.phtml':
                     $templateName = $memberName . ' Unsubscribe';
                     break;
                 case 'verify.phtml':
                     $templateName = $memberName . ' Verify';
                     break;
             }
             if (null !== $templateName) {
                 $tmpl = \Phire\Templates\Table\Templates::findBy(['name' => $templateName]);
                 if (isset($tmpl->id)) {
                     $controller->view()->setTemplate($tmpl->template);
                 }
             }
         } else {
             if ($application->isRegistered('phire-themes')) {
                 switch ($template) {
                     case 'login.phtml':
                         $templateName = $memberUri . '/login';
                         break;
                     case 'forgot.phtml':
                         $templateName = $memberUri . '/forgot';
                         break;
                     case 'index.phtml':
                         $templateName = $memberUri . '/index';
                         break;
                     case 'profile.phtml':
                         $templateName = $memberUri . '/profile';
                         break;
                     case 'register.phtml':
                         $templateName = $memberUri . '/register';
                         break;
                     case 'unsubscribe.phtml':
                         $templateName = $memberUri . '/unsubscribe';
                         break;
                     case 'verify.phtml':
                         $templateName = $memberUri . '/verify';
                         break;
                 }
                 if (null !== $templateName) {
                     $theme = \Phire\Themes\Table\Themes::findBy(['active' => 1]);
                     if (isset($theme->id)) {
                         $templateName = $_SERVER['DOCUMENT_ROOT'] . BASE_PATH . CONTENT_PATH . '/themes/' . $theme->folder . $templateName;
                         $tmpl = null;
                         if (file_exists($templateName . '.phtml')) {
                             $tmpl = $templateName . '.phtml';
                         } else {
                             if (file_exists($templateName . '.php')) {
                                 $tmpl = $templateName . '.php';
                             }
                         }
                         if (null !== $tmpl) {
                             $controller->view()->setTemplate($tmpl);
                         }
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 25
0
 /**
  * Parse the body
  *
  * @param  AbstractController $controller
  * @param  Application        $application
  * @return void
  */
 public static function parseBody(AbstractController $controller, Application $application)
 {
     if ($controller->hasView() && ($application->isRegistered('phire-categories') && $controller instanceof \Phire\Categories\Controller\IndexController || $application->isRegistered('phire-content') && $controller instanceof \Phire\Content\Controller\IndexController)) {
         $controller->response()->setBody(self::parse($controller->response()->getBody()));
     }
 }
Ejemplo n.º 26
0
 /**
  * Prepare view
  *
  * @param  string $member
  * @return void
  */
 protected function prepareView($member)
 {
     $this->viewPath = __DIR__ . '/../../view';
     parent::prepareView($member);
 }
Ejemplo n.º 27
0
 /**
  * Login and track session
  *
  * @param  AbstractController $controller
  * @param  Application        $application
  * @return void
  */
 public static function login(AbstractController $controller, Application $application)
 {
     $sess = $application->getService('session');
     $userUri = APP_URI;
     $key = 'user';
     if (isset($sess->member) && $application->isRegistered('phire-members')) {
         $key = 'member';
         $memberAdmin = new \Phire\Members\Model\MembersAdmin();
         $memberAdmin->getByRoleId($sess->member->role_id);
         if (isset($memberAdmin->uri)) {
             $userUri = $memberAdmin->uri;
         }
     }
     $path = BASE_PATH . $userUri;
     if ($path == '') {
         $path = '/';
     }
     $cookie = Cookie::getInstance(['path' => $path]);
     $cookie->delete('phire_session_timeout');
     $cookie->delete('phire_session_path');
     // If login, validate and start new session
     if ($controller->request()->isPost() && substr($controller->request()->getRequestUri(), -6) == '/login') {
         // If the user successfully logged in
         if (isset($sess[$key])) {
             $config = Table\UserSessionConfig::findById($sess[$key]->role_id);
             $data = Table\UserSessionData::findById($sess[$key]->id);
             if (isset($config->role_id)) {
                 if (!self::validate($config, $sess[$key], $data)) {
                     if (isset($data->user_id)) {
                         $data->failed_attempts++;
                         $data->save();
                     } else {
                         $data = new Table\UserSessionData(['user_id' => $sess[$key]->id, 'logins' => null, 'failed_attempts' => 1]);
                         $data->save();
                     }
                     if (isset($config->role_id) && (int) $config->log_type > 0 && null !== $config->log_emails) {
                         self::log($config, $sess[$key], false);
                     }
                     $sess->kill();
                     Response::redirect(BASE_PATH . $userUri . '/login?failed=' . $data->failed_attempts);
                     exit;
                 } else {
                     if (isset($data->user_id)) {
                         $limit = (int) $application->module('phire-sessions')['login_limit'];
                         $logins = unserialize($data->logins);
                         if ($limit > 0 && count($logins) >= $limit) {
                             reset($logins);
                             unset($logins[key($logins)]);
                         }
                         $logins[time()] = ['ua' => $_SERVER['HTTP_USER_AGENT'], 'ip' => $_SERVER['REMOTE_ADDR']];
                         $data->total_logins++;
                         $data->failed_attempts = 0;
                         $data->logins = serialize($logins);
                         $data->save();
                     } else {
                         $data = new Table\UserSessionData(['user_id' => $sess[$key]->id, 'logins' => serialize([time() => ['ua' => $_SERVER['HTTP_USER_AGENT'], 'ip' => $_SERVER['REMOTE_ADDR']]]), 'total_logins' => 1, 'failed_attempts' => 0]);
                         $data->save();
                     }
                 }
                 $expire = (int) $config->session_expiration > 0 ? (int) $config->session_expiration : null;
                 $timeout = (int) $config->timeout_warning;
             } else {
                 $expire = null;
                 $timeout = false;
             }
             $lastLogin = null;
             $lastIp = null;
             // Check for the last login
             $data = Table\UserSessionData::findById($sess[$key]->id);
             if (isset($data->user_id)) {
                 $logins = null !== $data->logins ? unserialize($data->logins) : [];
                 if (count($logins) > 1) {
                     $keys = array_keys($logins);
                     $timestamp = isset($keys[count($keys) - 2]) ? $keys[count($keys) - 2] : null;
                     if (null !== $timestamp && isset($logins[$timestamp])) {
                         $lastLogin = $timestamp;
                         $lastIp = $logins[$timestamp]['ip'];
                     }
                 }
             }
             // Clear old sessions
             $clear = (int) $application->module('phire-sessions')['clear_sessions'];
             if ($clear > 0) {
                 $clear = time() - $clear;
                 $sql = Table\UserSessions::sql();
                 $sql->delete()->where(['start <= :start']);
                 Table\UserSessions::execute((string) $sql, ['start' => $clear]);
             }
             $session = new Table\UserSessions(['user_id' => $sess[$key]->id, 'ip' => $_SERVER['REMOTE_ADDR'], 'ua' => $_SERVER['HTTP_USER_AGENT'], 'start' => time()]);
             $session->save();
             $sess[$key]->session = new \ArrayObject(['id' => $session->id, 'start' => $session->start, 'last' => $session->start, 'expire' => $expire, 'timeout' => $timeout, 'last_login' => $lastLogin, 'last_ip' => $lastIp], \ArrayObject::ARRAY_AS_PROPS);
             if (isset($config->role_id) && (int) $config->log_type > 0 && null !== $config->log_emails) {
                 self::log($config, $sess[$key], true);
             }
             // Else, if the user login failed
         } else {
             if (null !== $controller->view()->form && $controller->view()->form !== false && null !== $controller->view()->form->username) {
                 $user = \Phire\Table\Users::findBy(['username' => $controller->view()->form->username]);
                 $config = Table\UserSessionConfig::findById($user->role_id);
                 if (isset($user->id)) {
                     $data = Table\UserSessionData::findById($user->id);
                     if (isset($data->user_id)) {
                         $data->failed_attempts++;
                         $data->save();
                     } else {
                         $data = new Table\UserSessionData(['user_id' => $user->id, 'logins' => null, 'failed_attempts' => 1]);
                         $data->save();
                     }
                     if (isset($config->role_id) && (int) $config->log_type > 0 && null !== $config->log_emails) {
                         self::log($config, $user, false);
                     }
                 }
             }
         }
         // Check existing session
     } else {
         if (isset($sess[$key]) && isset($sess[$key]->session)) {
             if (!isset(Table\UserSessions::findById((int) $sess[$key]->session->id)->id) || null !== $sess[$key]->session->expire && time() - $sess[$key]->session->last >= $sess[$key]->session->expire) {
                 $session = Table\UserSessions::findById((int) $sess[$key]->session->id);
                 if (isset($session->id)) {
                     $session->delete();
                 }
                 $sess->kill();
                 Response::redirect(BASE_PATH . $userUri . '/login?expired=1');
                 exit;
             } else {
                 if ($sess[$key]->session->timeout && null !== $sess[$key]->session->expire) {
                     $cookie->set('phire_session_timeout', $sess[$key]->session->expire - 30);
                     $cookie->set('phire_session_path', BASE_PATH . $userUri);
                 }
                 $sess[$key]->session->last = time();
             }
         }
     }
 }
Ejemplo n.º 28
0
 /**
  * Prepare view
  *
  * @param  string $category
  * @return void
  */
 protected function prepareView($category)
 {
     $this->viewPath = __DIR__ . '/../../view';
     parent::prepareView($category);
 }
Ejemplo n.º 29
0
 /**
  * Prepare view
  *
  * @param  string $template
  * @return void
  */
 protected function prepareView($template)
 {
     $this->viewPath = __DIR__ . '/../../view';
     parent::prepareView($template);
 }
Ejemplo n.º 30
0
 /**
  * Prepare view
  *
  * @param  string $category
  * @return void
  */
 protected function prepareView($category)
 {
     $this->viewPath = __DIR__ . '/../../view';
     parent::prepareView($category);
     $this->view->date_format = $this->application->module('phire-categories')['datetime_formats']['date_format'];
     $this->view->month_format = $this->application->module('phire-categories')['datetime_formats']['month_format'];
     $this->view->day_format = $this->application->module('phire-categories')['datetime_formats']['day_format'];
     $this->view->year_format = $this->application->module('phire-categories')['datetime_formats']['year_format'];
     $this->view->time_format = $this->application->module('phire-categories')['datetime_formats']['time_format'];
     $this->view->hour_format = $this->application->module('phire-categories')['datetime_formats']['hour_format'];
     $this->view->minute_format = $this->application->module('phire-categories')['datetime_formats']['minute_format'];
     $this->view->minute_format = $this->application->module('phire-categories')['datetime_formats']['minute_format'];
     $this->view->separator = $this->application->module('phire-categories')['separator'];
 }