Пример #1
0
 private function welcome()
 {
     if (LOGGED) {
         return false;
     }
     $tags = Tag::select('name')->limit(30)->findArray();
     View::set('tags', $tags);
     View::set('welcome', 1);
 }
Пример #2
0
 /**
  * Get all distinct tags attached to all posts by author.
  * Can't use hasManyThrough on ManyToMany relationships, so we do this instead.
  *
  * @return array
  */
 public function tags()
 {
     $tags = array();
     $rows = Tag::select('tags.id', 'tags.name')->join('post_tag', 'tags.id', '=', 'post_tag.tag_id')->join('posts', 'post_tag.post_id', '=', 'posts.id')->where('posts.author_id', $this->id)->groupBy('tags.id')->orderBy('tags.name')->get();
     foreach ($rows as $row) {
         $tags[] = $row;
     }
     return $tags;
 }
Пример #3
0
 private function explore()
 {
     // Get some tags to show as options
     $tags = Tag::select('name')->limit(30)->findArray();
     View::set('tags', $tags);
     // No tags selected
     if (empty($_GET['t']) || !Validate::tags($_GET['t'])) {
         $rows = Playlist::join('user', 'user_id = u.id', 'u')->selectMany('playlist.*', 'username')->where('published', 1)->paginate();
         Base::eagerLoadingPlaylistTags($rows);
         View::set('playlists', $rows);
         View::show('explore');
     }
     // Separate tags by spaces
     $tags = trim($_GET['t']);
     $tags = explode('/', $tags, 4);
     $tags = array_slice($tags, 0, 3);
     // Url for selected tags
     $selectedTagsUrl = implode('/', $tags);
     // Beautifys the title Tags
     $selectedTags = array();
     foreach ($tags as $key => $item) {
         // Removes empty tags
         if (empty($item)) {
             unset($tags[$key]);
             continue;
         }
         $aux = array();
         $aux['name'] = $item;
         // When one clicked will remove that tag from the query
         unset($tags[$key]);
         $aux['href'] = '/' . implode('/', $tags);
         $tags[$key] = $item;
         $selectedTags[] = $aux;
     }
     $playlists = Playlist::filter('byTags', $tags)->join('user', 'p.user_id = u.id', 'u')->selectMany('p.*', 'username');
     $count = $playlists->countDistinct('p.id');
     $playlists = $playlists->groupBy('p.id')->paginate($count);
     Base::eagerLoadingPlaylistTags($playlists);
     // View preparations
     View::set('playlists', $playlists);
     View::set('selectedTags', $selectedTags);
     View::set('selectedTagsUrl', $selectedTagsUrl);
     View::show('explore');
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $log = new Process();
     $log->name = "make-history";
     $log->status = "running";
     $log->save();
     $today = Carbon::today();
     $topToday = array();
     $newspapers = Newspaper::select('id')->get();
     $tags = Tag::select('id')->get();
     foreach ($newspapers as $key => $n) {
         $top = $this->getTopLink($today, $n->id, false);
         if ($top) {
             $topToday[] = $top;
         }
     }
     foreach ($tags as $key => $t) {
         $top = $this->getTopLink($today, false, $t->id);
         if ($top) {
             $topToday[] = $top;
         }
     }
     $topToday = array_unique($topToday);
     //Remove links for today
     History::where('date', '=', $today)->delete();
     //Save history
     foreach ($topToday as $key => $t) {
         $this->info($t->title);
         try {
             $h = new History();
             $h->id_ref = $t->id;
             unset($t->id);
             $h->fill($t->toArray());
             $h->date = $today;
             $h->save();
         } catch (Exception $e) {
         }
     }
     $log->status = "finished";
     $log->save();
 }
Пример #5
0
 public function manage()
 {
     $query = Tag::select('tag_id', 'tag', 'pull_from_ig', 'status')->get();
     return View::make('manage')->with(array('querys' => $query));
 }
Пример #6
0
 function _eager_load_tags($data)
 {
     $ids = array();
     foreach ($data as $content) {
         $ids[] = $content->id;
     }
     $db_config = Shutter::get_db_configuration();
     switch ($this->model) {
         case 'text':
             $join_table = $db_config['prefix'] . 'join_tags_text';
             break;
         case 'content':
             $join_table = $db_config['prefix'] . 'join_content_tags';
             break;
         case 'album':
             $join_table = $db_config['prefix'] . 'join_albums_tags';
             break;
     }
     $join_field = $this->model . '_id';
     $tag = new Tag();
     $tag->select($db_config['prefix'] . 'tags.*, ' . $join_table . '.' . $this->model . '_id as ' . $join_field)->where_related($this->model, 'id', $ids)->order_by('name ASC')->get_iterated();
     $tag_map = array();
     $tag_cache = array();
     foreach ($tag as $t) {
         if (isset($tag_cache[$t->name])) {
             $tag_as_array = $tag_cache[$t->name];
         } else {
             $tag_as_array = $t->_tag_for_output($this->model);
             $tag_cache[$t->name] = $tag_as_array;
         }
         $key = 'c' . $t->{$join_field};
         if (isset($tag_map[$key])) {
             $tag_map[$key][] = $tag_as_array;
         } else {
             $tag_map[$key] = array($tag_as_array);
         }
     }
     return $tag_map;
 }
Пример #7
0
 /**
  * Edit a playlist
  */
 private function edit()
 {
     Base::requireLogged();
     if (LOGGED !== $this->playlist->user_id) {
         Base::requireAdmin();
     }
     // Set page title
     View::set('page_title', 'Edit playlist');
     // Set playlist
     $playlist = $this->playlist->asArray();
     $playlist['tracks'] = $this->playlist->tracks();
     $tags = $this->playlist->tags();
     if ($tags) {
         $playlist['tags'] = implode(', ', $tags);
     }
     View::set('playlist', $playlist);
     // Not submitted
     if (!isset($_POST['playlist']) && !isset($_POST['draft'])) {
         View::show('playlist/edit');
     }
     /**
      * Add playlist title and playlist description
      */
     if (!Validate::len($_POST['title'], 2, 64)) {
         $error = 'Playlist title must be between 2 and 64 chars';
     } elseif (!Validate::len($_POST['description'], 0, 512)) {
         $error = 'Playlist description must be lesser than 512 chars';
     }
     if ($error) {
         View::error('playlist/edit', $error);
     }
     // Raw HTML may enter the db but it's automatically
     // encoded at output by Mustache
     $this->playlist->title = $_POST['title'];
     $this->playlist->description = $_POST['description'];
     /**
      * Uploads cover image
      */
     if (!empty($_FILES['cover']) && $_FILES['cover']['size'] > 0) {
         Base::uploadImage($_FILES['cover'], $cover, $error);
         if ($error) {
             View::error('playlist/edit', $error);
         }
         $this->playlist->cover = $cover;
     }
     /**
      * Inserts tags into database
      */
     if (!empty($_POST['tags'])) {
         // Separates tags by commas
         $tags = strtolower($_POST['tags']);
         $tags = explode(',', $tags, 6);
         // Tag limit
         $tags = array_slice($tags, 0, 5);
         // Filter tags
         foreach ($tags as $k => &$tag) {
             if (!ADMIN && $tag === 'staff') {
                 continue;
             }
             $tag = preg_replace('/[^a-z]+/', ' ', $tag);
             $tag = trim($tag, ' ');
             // Tag must have at least 2 chars
             // And it must be lesser than 32 chars
             if (!Validate::len($tag, 1, 32)) {
                 unset($tags[$k]);
             }
         }
         if (!empty($tags)) {
             // Remove tags from PlaylistTag
             PlaylistTag::where('playlist_id', $this->playlist->id)->deleteMany();
             // Insert tags
             $sql = str_repeat(',(?)', count($tags));
             $sql[0] = ' ';
             Tag::rawExecute("INSERT IGNORE INTO tag(name) VALUES {$sql}", $tags);
             // Get inserted tags ids and point them to the new playlist
             $tags = Tag::select('id')->whereIn('name', $tags)->findMany();
             foreach ($tags as $tag) {
                 $link = PlaylistTag::create();
                 $link->playlist_id = $this->playlist->id;
                 $link->tag_id = $tag->id;
                 $link->save();
             }
         }
     }
     // Published status
     $this->playlist->published = isset($_POST['playlist']);
     /**
      * Add tracks into db
      */
     if (!isset($_POST['tracks'])) {
         $error = 'You can\'t publish without any tracks';
         $this->playlist->published = 0;
     } else {
         if (is_array($_POST['tracks'])) {
             $max = Base::$g['playlist_max_tracks'];
             $min = Base::$g['playlist_min_tracks'];
             $tracks = $_POST['tracks'];
             if (!isset($tracks[$min - 1])) {
                 $error = "You can't publish without at least {$min} tracks";
                 $this->playlist->published = 0;
             } elseif (isset($track[$max])) {
                 $error = "You can't have more than {$max} tracks in a playlist";
                 $tracks = array_slice($tracks, 0, $max);
             }
             /**
              * Check for haxing
              */
             foreach ($tracks as $k => &$item) {
                 $item = Validate::int($item);
                 if ($item === false) {
                     unset($tracks[$k]);
                 }
             }
             // Also get duration
             $row = Track::whereIn('id', $tracks)->selectExpr('COUNT(id)', 'count')->selectExpr('SUM(duration)', 'duration')->findOne();
             if ($row->count != count(array_unique($tracks))) {
                 View::error('playlist/edit', 'Massive error 2. Contact the admin');
             }
             // Store duration in minutes
             $this->playlist->tracks_count = $row->count;
             $this->playlist->duration = $row->duration / 60;
             // Delete the ones already in
             PlaylistTrack::where('playlist_id', $this->playlist->id)->deleteMany();
             // Add new ones
             foreach ($tracks as $track) {
                 $table = PlaylistTrack::create();
                 $table->playlist_id = $this->playlist->id;
                 $table->track_id = $track;
                 $table->save();
             }
         } else {
             View::error('playlist/edit', 'Massive error. Contact the admin');
         }
     }
     /**
      * Update playlist in database
      */
     $this->playlist->save();
     $msg = $error ?: 'Playlist succesfully edited';
     Base::redirect('/' . $this->playlist->id, $msg);
 }
Пример #8
0
 *   NOALYSS is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with NOALYSS; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
// Copyright Author Dany De Bontridder danydb@aevalys.eu
if (!defined('ALLOWED')) {
    die('Appel direct ne sont pas permis');
}
require_once NOALYSS_INCLUDE . '/class_tag.php';
ob_start();
$tag = new Tag($cn);
$tag->select();
//------------------- Propose to add a tag
$js = sprintf("onclick=\"show_tag('%s','%s','%s','j')\"", Dossier::id(), '', '-1');
echo HtmlInput::button("tag_add", _("Ajout d'un tag"), $js);
$response = ob_get_clean();
$html = escape_xml($response);
header('Content-type: text/xml; charset=UTF-8');
echo <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<data>
<ctl></ctl>
<code>{$html}</code>
</data>
EOF;
exit;
Пример #9
0
 public function getSuggestedTags()
 {
     $keyword = Input::get('keyword');
     $tags = Tag::select('id', 'tag')->orderBy('tag', 'asc')->where('tag', 'LIKE', '%' . $keyword . '%')->get();
     return Response::json(array('tags' => $tags));
 }
Пример #10
0
echo Tag::pre(Tag::code('Tag::$codeFormat = true; // default'));
echo Tag::h2('1. Html4 tags.');
$plain = TagNodes::create();
foreach ($html4_tags as $tag_name => $flg) {
    $plain->append(Tag::create($tag_name, 'contents'));
}
echo Tag::pre(Tag::code(htmlspecialchars($plain)));
echo Tag::h2('2. Table.');
$plain = Tag::table(Tag::tr(Tag::td(), Tag::td()), Tag::tr(Tag::td(), Tag::td()));
echo Tag::pre(Tag::code(htmlspecialchars($plain)));
echo Tag::h2('3. List.');
$plain = Tag::ul(Tag::li(), Tag::li());
echo Tag::pre(Tag::code(htmlspecialchars($plain)));
$plain = Tag::ul(Tag::li('aaa'), Tag::li('bbb'));
echo Tag::pre(Tag::code(htmlspecialchars($plain)));
echo Tag::h2('4. Block and inline.');
$plain = Tag::div(Tag::div(), Tag::div());
echo Tag::pre(Tag::code(htmlspecialchars($plain)));
$plain = Tag::div(Tag::span(), Tag::span());
echo Tag::pre(Tag::code(htmlspecialchars($plain)));
$plain = Tag::span(Tag::span(), Tag::span());
echo Tag::pre(Tag::code(htmlspecialchars($plain)));
$plain = Tag::span(Tag::span(), Tag::br());
echo Tag::pre(Tag::code(htmlspecialchars($plain)));
$plain = Tag::select(Tag::option('a'), Tag::option('b'), Tag::option('c'));
echo Tag::pre(Tag::code(htmlspecialchars($plain)));
echo Tag::h2('5. Style and script.');
$plain = Tag::head(Tag::style('a { color: red; }'), Tag::script('function(){
    alert("warning!");
}'));
echo Tag::pre(Tag::code(htmlspecialchars($plain)));
Пример #11
0
 /**
  * Get the query object to be processed by datatables.
  *
  * @return \Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder
  */
 public function query()
 {
     $articles = Tag::select('articles.*', 'categories.title as category_title')->join('categories', 'categories.id', '=', 'articles.category_id');
     return $this->applyScopes($articles);
 }
 public function stringToIdTags($string)
 {
     $string = preg_replace('/\\s\\s+/', ' ', $this->strtolower_utf8(trim($string)));
     $array_string = explode(' ', $string);
     $array_tags_id = array();
     $index = 0;
     foreach ($array_string as $key => $value) {
         $array_id = Tag::select('id')->distinct()->where("mo_ta_tags", "like", $value . "%")->orWhere("mo_ta_tags", "like", "%" . $value)->orWhere("mo_ta_tags", "like", "%" . $value . "%")->get();
         if (count($array_id) != 0) {
             foreach ($array_id as $id) {
                 $array_tags_id[$index++] = $id->id;
             }
         }
     }
     return array_unique($array_tags_id);
 }
Пример #13
0
<div>
    <label for="product_types_id">Product Type</label>
    <?php 
echo Tag::select(array("product_types_id", $productTypes, "using" => array("id", "name"), "useDummy" => true));
?>
</div>

 public function getTags()
 {
     return Response::json(Tag::select('id', 'name', 'color')->orderBy('name', 'ASC')->get());
 }