Beispiel #1
0
 /**
  * Get internalization based on called controller
  * @param string $text
  * @param array $params
  * @return string
  */
 public function translate($text, array $params = [])
 {
     $index = null;
     $namespace = 'Apps\\Controller\\' . env_name . '\\';
     foreach (@debug_backtrace() as $caller) {
         if (isset($caller['class']) && Str::startsWith($namespace, $caller['class'])) {
             $index = Str::sub((string) $caller['class'], Str::length($namespace));
         }
     }
     return $this->get($index, $text, $params);
 }
Beispiel #2
0
 /**
  * Show scan results
  * @return string
  */
 public function actionAntivirusresults()
 {
     $response = null;
     if (!File::exist('/Private/Antivirus/Infected.json')) {
         $response = ['status' => 0];
     } else {
         $data = json_decode(File::read('/Private/Antivirus/Infected.json'));
         $compile = [];
         foreach ($data as $file => $sign) {
             $file = Str::replace('\\', '/', Str::sub($file, strlen(root)));
             $compile[$file][] = $sign;
         }
         $response = ['status' => 1, 'data' => $compile];
     }
     $this->setJsonHeader();
     return json_encode($response);
 }
Beispiel #3
0
 /**
  * Browse files from ckeditor
  * @param string $type
  * @throws NativeException
  * @throws \Ffcms\Core\Exception\SyntaxException
  */
 public function actionBrowse($type)
 {
     $files = null;
     $relative = null;
     // check if request type is defined
     if ($this->allowedExt[$type] === null || !Obj::isArray($this->allowedExt[$type])) {
         throw new NativeException('Hack attempt');
     }
     // list files in directory
     $files = File::listFiles('/upload/' . $type, $this->allowedExt[$type]);
     // absolute path to relative URI
     foreach ($files as $file) {
         $newName = Str::sub($file, Str::length(root) + 1);
         $relative[] = trim(Str::replace(DIRECTORY_SEPARATOR, '/', $newName), '/');
     }
     // generate response
     return App::$View->render('editor/browse', ['callbackName' => App::$Security->strip_tags(App::$Request->query->get('CKEditor')), 'callbackId' => (int) App::$Request->query->get('CKEditorFuncNum'), 'files' => $relative, 'type' => $type], __DIR__);
 }
Beispiel #4
0
echo $this->render('comments/_tabs');
?>

<h1><?php 
echo __('Delete comments and answers');
?>
</h1>
<hr />
<?php 
echo __('Are you sure to delete this comments or answers?');
?>

<?php 
$items = [];
foreach ($records as $item) {
    $message = Str::sub(\App::$Security->strip_tags($item->message), 0, 50);
    $author = Simplify::parseUserNick($item->user_id, $item->guest_name);
    if ((int) $item->user_id > 0) {
        $author = Url::link(['user/update', (int) $item->user_id], $author);
    }
    $items[] = [['text' => $item->id], ['text' => $message], ['text' => $author, 'html' => true], ['text' => Date::convertToDatetime($item->created_at, Date::FORMAT_TO_HOUR)]];
}
?>
<div class="table-responsive">
<?php 
echo Table::display(['table' => ['class' => 'table table-bordered'], 'thead' => ['titles' => [['text' => '#'], ['text' => __('Message')], ['text' => __('Author')], ['text' => __('Date')]]], 'tbody' => ['items' => $items]]);
?>
</div>


<?php 
Beispiel #5
0
 /**
  * Try to find exist viewer full path
  * @param string $path
  * @param string|null $source
  * @return null|string
  * @throws NativeException
  */
 private function findViewer($path, $source = null)
 {
     $tmpPath = null;
     // sounds like a relative path for current view theme
     if (Str::contains('/', $path)) {
         // lets try to get full path for current theme
         $tmpPath = $path;
         if (!Str::startsWith($this->themePath, $path)) {
             $tmpPath = Normalize::diskPath($this->themePath . '/' . $path . '.php');
         }
     } else {
         // sounds like a object-depended view call from controller or etc
         // get stack trace of callbacks
         $calledLog = debug_backtrace();
         $calledController = null;
         // lets try to find controller in backtrace
         foreach ($calledLog as $caller) {
             if (isset($caller['class']) && Str::startsWith('Apps\\Controller\\', $caller['class'])) {
                 $calledController = (string) $caller['class'];
             }
         }
         // depended controller is not founded? Let finish
         if ($calledController === null) {
             throw new NativeException('View render is failed: callback controller not founded! Call with relative path: ' . $path);
         }
         // get controller name
         $controllerName = Str::sub($calledController, Str::length('Apps\\Controller\\' . env_name . '\\'));
         $controllerName = Str::lowerCase($controllerName);
         // get full path
         $tmpPath = $this->themePath . DIRECTORY_SEPARATOR . $controllerName . DIRECTORY_SEPARATOR . $path . '.php';
     }
     // check if builded view full path is exist
     if (File::exist($tmpPath)) {
         return $tmpPath;
     }
     // hmm, not founded. Lets try to find in caller directory (for widgets, apps packages and other)
     if ($source !== null) {
         $tmpPath = Normalize::diskPath($source . DIRECTORY_SEPARATOR . $path . '.php');
         if (File::exist($tmpPath)) {
             // add notify for native views
             if (App::$Debug !== null) {
                 App::$Debug->addMessage('Render native viewer: ' . Str::replace(root, null, $tmpPath), 'info');
             }
             return $tmpPath;
         }
     }
     if (App::$Debug !== null) {
         App::$Debug->addMessage('Viewer not founded on rendering: ' . $path, 'warning');
     }
     return null;
 }
Beispiel #6
0
    ?>
                    <?php 
    foreach ($custom_fields as $cid => $value) {
        ?>
                        <?php 
        if (!Str::likeEmpty($value)) {
            ?>
                            <tr>
                                <td><?php 
            echo ProfileField::getNameById($cid);
            ?>
</td>
                                <td>
                                    <?php 
            if (ProfileField::getTypeById($cid) === 'link') {
                echo Url::link($value, Str::sub($value, 30));
            } else {
                echo \App::$Security->strip_tags($value);
            }
            ?>
                                </td>
                            </tr>
                        <?php 
        }
        ?>
                    <?php 
    }
    ?>
                <?php 
}
?>
Beispiel #7
0
 /**
  * Get base path from current environment without basePath of subdirectories
  * @return string
  */
 public function getInterfaceSlug()
 {
     $path = $this->getBasePath();
     $subDir = App::$Properties->get('basePath');
     if ($subDir !== '/') {
         $offset = (int) Str::length($subDir);
         $path = Str::sub($path, --$offset);
     }
     return $path;
 }
Beispiel #8
0
 /**
  * Cut text starting from $start pointer to $end pointer in UTF-8 mod
  * @param string $text
  * @param int $start
  * @param int $end
  * @return string
  */
 public static function cut($text, $start = 0, $end = 0)
 {
     return Str::sub($text, $start, $end);
 }
Beispiel #9
0
<?php 
if ($records === null || $records->count() < 1) {
    echo '<p class="alert alert-warning">' . __('Answers is not founded') . '</p>';
    return;
}
$items = [];
$moderateIsFound = false;
foreach ($records as $item) {
    $commentObject = $item->getCommentPost();
    $message = Text::cut(\App::$Security->strip_tags($item->message), 0, 75);
    $moderate = (bool) $item->moderate;
    if ($moderate) {
        $moderateIsFound = true;
    }
    $items[] = [1 => ['text' => $item->id], 2 => ['text' => ($moderate ? '<i class="fa fa-exclamation text-warning"></i> ' : null) . Url::link(['comments/read', $commentObject->id, null, ['#' => '#answer-' . $item->id]], $message), 'html' => true], 3 => ['text' => Simplify::parseUserLink((int) $item->user_id, $item->guest_name, 'user/update'), 'html' => true], 4 => ['text' => '<a href="' . App::$Alias->scriptUrl . $commentObject->pathway . '" target="_blank">' . Str::sub($commentObject->pathway, 0, 20) . '...</a>', 'html' => true], 5 => ['text' => Date::convertToDatetime($item->created_at, Date::FORMAT_TO_HOUR)], 6 => ['text' => Url::link(['comments/read', $commentObject->id], '<i class="fa fa-list fa-lg"></i>') . ' ' . Url::link(['comments/delete', 'answer', $item->id], '<i class="fa fa-trash-o fa-lg"></i>'), 'html' => true, 'property' => ['class' => 'text-center']], 'property' => ['class' => 'checkbox-row' . ($moderate !== false ? ' alert-warning' : null)]];
}
$moderateAccept = false;
if ($moderateIsFound) {
    $moderateAccept = ['type' => 'submit', 'class' => 'btn btn-warning', 'value' => __('Publish'), 'formaction' => Url::to('comments/publish', 'answer')];
}
?>

<div class="table-responsive">
<?php 
echo Table::display(['table' => ['class' => 'table table-bordered table-hover'], 'thead' => ['titles' => [['text' => '#'], ['text' => __('Answer')], ['text' => __('Author')], ['text' => __('Page')], ['text' => __('Date')], ['text' => __('Actions')]]], 'tbody' => ['items' => $items], 'selectableBox' => ['attachOrder' => 1, 'form' => ['method' => 'GET', 'class' => 'form-horizontal', 'action' => Url::to('comments/delete', 'answer')], 'selector' => ['type' => 'checkbox', 'name' => 'selected[]', 'class' => 'massSelectId'], 'buttons' => [['type' => 'submit', 'class' => 'btn btn-danger', 'value' => __('Delete selected'), 'formaction' => Url::to('comment/delete', 'answer')], $moderateAccept]]]);
?>
</div>

<div class="text-center">
    <?php 
Beispiel #10
0
// set meta keywords
if (Obj::isArray($model->metaKeywords) && count($model->metaKeywords) > 0) {
    $this->keywords = implode(', ', $model->metaKeywords);
}
// don't use breadcrumbs on injected pathway rule
if (!\App::$Request->isPathInjected() && (bool) $model->getCategory()->getProperty('showCategory')) {
    $breadcrumbs = [Url::to('/') => __('Home')];
    if (Obj::isArray($model->catNesting)) {
        foreach ($model->catNesting as $cat) {
            if (Str::likeEmpty($cat['path'])) {
                $breadcrumbs[Url::to('content/list', $cat['path'])] = __('Contents');
            } else {
                $breadcrumbs[Url::to('content/list', $cat['path'], null, [], false)] = $cat['name'];
            }
        }
        $breadcrumbs[] = __('Content') . ': ' . Str::sub($this->title, 0, 40);
    }
    $this->breadcrumbs = $breadcrumbs;
}
$properties = ['date' => (bool) $model->getCategory()->getProperty('showDate'), 'author' => (bool) $model->getCategory()->getProperty('showAuthor'), 'views' => (bool) $model->getCategory()->getProperty('showViews'), 'category' => (bool) $model->getCategory()->getProperty('showCategory'), 'rating' => (bool) $model->getCategory()->getProperty('showRating'), 'tags' => (bool) $model->getCategory()->getProperty('showTags')];
$showComments = (bool) $model->getCategory()->getProperty('showComments');
$showPoster = (bool) $model->getCategory()->getProperty('showPoster');
?>

<article class="article-item" itemscope="itemscope" itemtype="https://schema.org/NewsArticle">
    <h1><?php 
echo $model->title;
?>
</h1>
    <?php 
if (Arr::in(true, $properties)) {
Beispiel #11
0
 /**
  * Show gallery images from upload directory
  * @param int $id
  * @return string
  * @throws NotFoundException
  * @throws NativeException
  */
 public function actionGallerylist($id)
 {
     // check if id is passed
     if (Str::likeEmpty($id)) {
         throw new NativeException('Wrong input data');
     }
     // check if user have permission to access there
     if (!App::$User->isAuth() || !App::$User->identity()->getRole()->can('global/file')) {
         throw new NativeException('Permission denied');
     }
     $thumbDir = Normalize::diskFullPath('/upload/gallery/' . $id . '/orig/');
     if (!Directory::exist($thumbDir)) {
         throw new NotFoundException('Nothing found');
     }
     $files = Directory::scan($thumbDir, null, true);
     if ($files === false || !Obj::isArray($files) || count($files) < 1) {
         throw new NotFoundException('Nothing found');
     }
     $output = [];
     foreach ($files as $file) {
         $fileExt = Str::lastIn($file, '.');
         $fileName = Str::sub($file, 0, -Str::length($fileExt));
         $output[] = ['thumbnailUrl' => '/upload/gallery/' . $id . '/thumb/' . $fileName . '.jpg', 'url' => '/upload/gallery/' . $id . '/orig/' . $file, 'name' => $file, 'size' => File::size('/upload/gallery/' . $id . '/orig/' . $file)];
     }
     $this->setJsonHeader();
     return json_encode(['status' => 1, 'files' => $output]);
 }
Beispiel #12
0
if ($records->count() < 1) {
    echo '<p class="alert alert-warning">' . __('Content is not found') . '</p>';
    return;
}
$items = [];
$moderate = false;
foreach ($records as $content) {
    $frontLink = \App::$Alias->scriptUrl . '/content/read';
    $frontPath = null;
    if (!Str::likeEmpty($content->getCategory()->path)) {
        $frontLink .= '/' . $content->getCategory()->path;
        $frontPath .= '/' . $content->getCategory()->path;
    }
    $frontLink .= '/' . $content->path;
    $frontPath .= '/' . $content->path;
    $frontPath = Str::sub($frontPath, 0, 30);
    $actionIcons = '<a href="' . $frontLink . '" target="_blank"><i class="fa fa-eye fa-lg"></i></a> ';
    $actionIcons .= Url::link(['content/update', $content->id], '<i class="fa fa-pencil fa-lg"></i> ');
    if ($type === 'trash') {
        $actionIcons .= Url::link(['content/restore', $content->id], '<i class="fa fa-refresh fa-lg"></i>');
    } else {
        $actionIcons .= Url::link(['content/delete', $content->id], '<i class="fa fa-trash-o fa-lg"></i>');
    }
    if (!(bool) $content->display) {
        $moderate = true;
    }
    $items[] = ['property' => ['class' => 'checkbox-row' . (!(bool) $content->display ? ' alert-warning' : null)], 1 => ['text' => $content->id, 'html' => true, '!secure' => true], 2 => ['text' => (!(bool) $content->display ? '<i class="fa fa-exclamation text-warning"></i> ' : null) . Url::link(['content/update', $content->id], $content->getLocaled('title')), 'html' => true], 3 => ['text' => $content->getCategory()->getLocaled('title')], 4 => ['text' => '<a href="' . $frontLink . '" target="_blank">' . $frontPath . '</a>', 'html' => true], 5 => ['text' => Date::convertToDatetime($content->updated_at, Date::FORMAT_TO_SECONDS)], 6 => ['text' => $actionIcons, 'html' => true, 'property' => ['class' => 'text-center']]];
}
$selectBox = false;
if ($type !== 'trash') {
    $acceptButton = false;