コード例 #1
0
ファイル: menu.php プロジェクト: jinshana/tangocms
    /**
     * Deletes a menu item, and all items under it.
     *
     * @param int $id
     * @return bool
     */
    public function deleteItem($id)
    {
        $item = $this->getItem($id);
        // Get all menu item IDs to delete ACL resources and cache later on
        $itemIds = $this->_sql->query('SELECT id, heading_id FROM {PREFIX}mod_menu
											WHERE id = ' . (int) $item['id'] . ' OR heading_id = ' . (int) $item['id'])->fetchAll(PDO::FETCH_ASSOC);
        // Remove all menu items
        $pdoSt = $this->_sql->prepare('DELETE FROM {PREFIX}mod_menu WHERE id = :id OR heading_id = :id');
        $pdoSt->execute(array(':id' => $item['id']));
        if ($pdoSt->rowCount()) {
            $aclResources = array();
            $cacheKeys = array('menu_items_' . $item['cat_id']);
            foreach ($itemIds as $tmpItem) {
                $aclResources[] = 'menu-item-' . $tmpItem['id'];
                $cacheKeys[] = 'menu_child_items_' . $tmpItem['heading_id'];
            }
            $this->_acl->deleteResource($aclResources);
            $this->_cache->delete($cacheKeys);
            Hooks::notifyAll('menu_delete_item', $item['id'], $item);
            return true;
        } else {
            return false;
        }
    }
コード例 #2
0
ファイル: Rss.php プロジェクト: jinshana/tangocms
 /**
  * Delete
  *  - Delete the given item from a feed
  *    if no item is given, the feed is deleted
  *
  * @param string $id
  * @return bool
  */
 public function delete($id = null)
 {
     if ($this->isRemote) {
         throw new Rss_RemoteFeed();
     }
     if (is_null($id)) {
         if (zula_is_deletable($this->rssDir . $this->name)) {
             // Call hooks
             Hooks::notifyAll('rss_feed_delete', $this->rssDir, $this->name);
             return unlink($this->rssDir . $this->name);
         }
         $this->_log->message('Unable to delete RSS Feed "' . $this->name . '".', LOG::L_WARNING);
         return false;
     }
     $channels = $this->feed->getElementsByTagName('channel');
     if ($channels->length == 0) {
         throw new Rss_NoFeedInfo();
     }
     $channel = $channels->item(0);
     // Find element to delete
     $node = $this->feed->getElementById($id);
     if (is_null($node)) {
         return false;
     }
     $channel->removeChild($node);
     unset($this->items[$id]);
     Hooks::notifyAll('rss_item_delete', $this->name, $id);
     return true;
 }
コード例 #3
0
ファイル: aliases.php プロジェクト: jinshana/tangocms
 /**
  * Deletes 1 or more URL alias by ID
  *
  * @param int|array $alias
  * @return bool
  */
 public function delete($alias)
 {
     $pdoSt = $this->_sql->prepare('DELETE FROM {PREFIX}mod_aliases WHERE id = ?');
     $delCount = 0;
     foreach ((array) $alias as $id) {
         $pdoSt->execute(array($id));
         if ($pdoSt->rowCount()) {
             ++$delCount;
             Hooks::notifyAll('aliases_delete', (int) $id);
         }
     }
     if ($delCount) {
         $this->_cache->delete('aliases');
         return true;
     } else {
         return false;
     }
 }
コード例 #4
0
ファイル: Module.php プロジェクト: jinshana/tangocms
 /**
  * Loads a specified controller and section if it exists. The resulting
  * output will be returned, a long with the title set by the controller
  * as an array.
  *
  * @param string $cntrlr
  * @param string $sec
  * @param array $config
  * @param string $sector
  * @return array
  */
 public function loadController($cntrlr = 'index', $sec = 'index', array $config = array(), $sector = null)
 {
     $cntrlr = trim($cntrlr) ? $cntrlr : 'index';
     $sec = trim($sec) ? $sec : 'index';
     // Ensure no other controller/module is being loaded currently
     $this->_log->message(sprintf('attempting to load controller "%s::%s::%s"', $this->name, $cntrlr, $sec), Log::L_DEBUG);
     if (self::$currentMcs !== false) {
         throw new Module_UnableToLoad('unable to load new module, a module is already loading');
     } else {
         if ($this->disabled === true) {
             $lMsg = 'unable to load controller, parent module "' . $this->name . '" is currently disabled';
             $this->_log->message($lMsg, Log::L_NOTICE);
             throw new Module_Disabled($lMsg);
         } else {
             if (_ACL_ENABLED) {
                 $resource = $this->name . '_global';
                 if (!$this->_acl->check($resource)) {
                     throw new Module_NoPermission($resource);
                 }
             }
         }
     }
     if (!$this->controllerExists($cntrlr)) {
         throw new Module_ControllerNoExist('controller "' . $cntrlr . '" does not exist');
     }
     /**
      * Create some details for the controller, create a new
      * instance of it and identify it with the details needed.
      */
     $class = $this->name . '_controller_' . $cntrlr;
     $method = $sec . 'Section';
     try {
         self::$currentCntrlrObj = new $class($this->getDetails(), $config, $sector);
         if (self::$currentCntrlrObj instanceof Zula_ControllerBase) {
             if (!is_callable(array(self::$currentCntrlrObj, $method), false, $callableName)) {
                 throw new Module_ControllerNoExist('controller section/method "' . $callableName . '" is not callable');
             }
             // Store MCS details
             self::$currentMcs = array('module' => $this->name, 'cntrlr' => $cntrlr, 'section' => $sec);
             $details = array('cntrlr' => self::$currentCntrlrObj, 'ident' => $this->name . '::' . $cntrlr . '::' . $sec, 'output' => self::$currentCntrlrObj->{$method}(), 'outputType' => self::$currentCntrlrObj->getOutputType(), 'title' => self::$currentCntrlrObj->getTitle());
             /**
              * Trigger output hooks. Listeners should return a string with the
              * html they want to add to the controllers output.
              */
             if (!is_bool($details['output'])) {
                 $ota = Hooks::notifyAll('module_output_top', self::getLoading(), $details['outputType'], $sector, $details['title']);
                 $outputTop = count($ota) > 0 ? implode("\n", $ota) : '';
                 $oba = Hooks::notifyAll('module_output_bottom', self::getLoading(), $details['outputType'], $sector, $details['title']);
                 $outputBottom = count($oba) > 0 ? implode("\n", $oba) : '';
                 $details['output'] = $outputTop . $details['output'] . $outputBottom;
             }
             Hooks::notifyAll('module_controller_loaded', self::getLoading(), $details['outputType'], $sector, $details['title']);
             // Reset MCS details and restore i18n domain
             self::$currentMcs = false;
             self::$currentCntrlrObj = false;
             $this->_i18n->textDomain(I18n::_DTD);
             return $details;
         } else {
             throw new Module_ControllerNoExist('controller "' . $class . '" must extend Zula_ControllerBase');
         }
     } catch (Exception $e) {
         // Catch any exceptions throw to reset the MCS details, then re-throw
         $this->_i18n->textDomain(I18n::_DTD);
         self::$currentMcs = false;
         self::$currentCntrlrObj = false;
         throw $e;
     }
 }
コード例 #5
0
ファイル: File.php プロジェクト: jinshana/tangocms
 /**
  * Purge all cache files
  *
  * @return bool
  */
 public function purge()
 {
     try {
         foreach (new DirectoryIterator($this->cacheDir) as $file) {
             if (!$file->isDot() && strpos($file->getFilename(), '.') !== 0) {
                 unlink($file->getPathname());
             }
         }
         Hooks::notifyAll('cache_purge', 'file');
         return true;
     } catch (Exception $e) {
         return false;
     }
 }
コード例 #6
0
ファイル: page.php プロジェクト: jinshana/tangocms
 /**
  * Removes a page and all children under it, by ID
  *
  * @param int $pid
  * @return int
  */
 public function delete($pid)
 {
     $page = $this->getPage($pid);
     // Get all of the IDs of pages to delete
     $pageIds = array($page['id']);
     foreach ($this->getChildren($page['id'], true, array(), false) as $child) {
         $pageIds[] = $child['id'];
     }
     // Remove the needed ACL resources and SQL entries
     $pdoSt = $this->_sql->prepare('DELETE FROM {PREFIX}mod_page WHERE id = ?');
     $aclResources = array();
     $delCount = 0;
     foreach ($pageIds as $id) {
         $pdoSt->execute(array($id));
         if ($pdoSt->rowCount()) {
             $aclResources[] = 'page-view_' . $id;
             $aclResources[] = 'page-edit_' . $id;
             $aclResources[] = 'page-manage_' . $id;
             ++$delCount;
         }
     }
     $pdoSt->closeCursor();
     $this->_acl->deleteResource($aclResources);
     Hooks::notifyAll('page_delete', $delCount, $pageIds);
     return $delCount;
 }
コード例 #7
0
ファイル: Url.php プロジェクト: jinshana/tangocms
 /**
  * Builds up a string request path to be used
  *
  * @param string $separator
  * @param string $type
  * @param bool $noBase
  * @return string
  */
 public function make($separator = '&', $type = null, $noBase = false)
 {
     $data = array();
     foreach ($this->parsed as $key => $val) {
         if ($key == 'arguments' || $key == 'siteType' && $val == $this->_router->getDefaultSiteType()) {
             continue;
         } else {
             if ($key != 'siteType' && $val == null) {
                 $val = 'index';
             }
         }
         $data[$key] = $val;
     }
     $arguments = $this->parsed['arguments'];
     $argString = '';
     if (empty($arguments)) {
         // No need to keep empty parts on
         while (end($data) == 'index') {
             array_pop($data);
         }
     } else {
         foreach ($arguments as $key => $val) {
             $argString .= '/' . $key . '/' . $val;
         }
     }
     $requestPath = trim(implode('/', $data), '/') . $argString;
     # hook event: router_make_url
     $tmpRp = Hooks::notifyAll('router_make_url', $requestPath);
     if (is_array($tmpRp)) {
         $requestPath = trim(end($tmpRp), '/');
     }
     $requestPath = zula_htmlspecialchars($requestPath);
     // Create the correct URL based upon router type
     if (!$type) {
         $type = $this->_router->getType();
     }
     unset($this->queryStringArgs['url']);
     if ($type == 'standard') {
         // Add in the 'url' query string needed, force it to be first index
         if ($requestPath) {
             $this->queryStringArgs = array_merge(array('url' => $requestPath), $this->queryStringArgs);
         }
         if ($this->_input->has('get', 'ns')) {
             $this->queryStringArgs['ns'] = '';
         }
         $url = $noBase ? 'index.php' : _BASE_DIR . 'index.php';
     } else {
         $url = $noBase ? $requestPath : _BASE_DIR . $requestPath;
     }
     if (!empty($this->queryStringArgs)) {
         $url .= '?' . str_replace('%2F', '/', http_build_query($this->queryStringArgs, null, $separator));
     }
     return $this->fragment ? $url . '#' . $this->fragment : $url;
 }
コード例 #8
0
ファイル: article.php プロジェクト: jinshana/tangocms
 /**
  * Delete an article part of an article if it exists
  *
  * @param int $pid
  * @return bool
  */
 public function deletePart($pid)
 {
     $part = $this->getPart($pid);
     $query = $this->_sql->query('DELETE FROM {PREFIX}mod_article_parts WHERE id = ' . (int) $part['id']);
     $query->closeCursor();
     if ($query->rowCount() > 0) {
         Hooks::notifyAll('article_delete_part', $part['id'], $part);
         return true;
     } else {
         return false;
     }
 }
コード例 #9
0
ファイル: Ugmanager.php プロジェクト: jinshana/tangocms
    /**
     * Deletes a user and all meta data related to it
     *
     * @param int $uid
     * @return bool
     */
    public function deleteUser($uid)
    {
        $user = $this->getUser($uid);
        if ($user['id'] == self::_ROOT_ID || $user['id'] == self::_GUEST_ID) {
            throw new Ugmanager_InvalidUser('root or guest user can not be deleted');
        }
        $result = $this->_sql->exec('DELETE u, m FROM {PREFIX}users AS u
											LEFT JOIN {PREFIX}users_meta AS m ON m.uid = u.id
											WHERE u.id = ' . (int) $user['id']);
        if ($result) {
            if (isset($this->userCount['*'])) {
                --$this->userCount['*'];
            }
            if (isset($this->userCount[$user['group']])) {
                --$this->userCount[$user['group']];
            }
            $this->_cache->delete('ugmanager_users');
            Hooks::notifyAll('ugmanager_user_delete', $user);
            return true;
        } else {
            return false;
        }
    }
コード例 #10
0
ファイル: Disabled.php プロジェクト: jinshana/tangocms
 /**
  * Purges all cached items
  *
  * @return bool
  */
 public function purge()
 {
     Hooks::notifyAll('cache_purge', 'disabled');
     return true;
 }
コード例 #11
0
ファイル: Form.php プロジェクト: jinshana/tangocms
 /**
  * Sets the content URL that this form is adding/editing
  *
  * @param string $url
  * @return bool
  */
 public function setContentUrl($url)
 {
     $this->contentUrl = (string) $url;
     Hooks::notifyAll('view_form_set_content_url', Module::getLoading(), $url);
     return true;
 }
コード例 #12
0
ファイル: Layout.php プロジェクト: jinshana/tangocms
 /**
  * Edit details of an existing controller. The 'mod' value can never change
  * by this method.
  *
  * @param int $id
  * @param array $details
  * @return bool
  */
 public function editController($id, array $details)
 {
     $cntrlr = $this->getControllerDetails($id);
     $details['mod'] = $cntrlr['mod'];
     if (empty($details['sector'])) {
         $details['sector'] = $cntrlr['sector'];
     }
     if ($this->detachController($id)) {
         $this->addController($details['sector'], $details, $id);
         Hooks::notifyAll('layout_edit_cntrlr', $id, $details);
         return $id;
     } else {
         return false;
     }
 }
コード例 #13
0
ファイル: edit.php プロジェクト: jinshana/tangocms
 /**
  * Gets the display mode configuration details from the hooks
  * of the correct module.
  *
  * @return string|bool
  */
 public function modeConfigSection()
 {
     try {
         $hook = $this->_router->getArgument('module') . '_display_mode_config';
         $data = Hooks::notifyAll($hook, $this->_router->getArgument('mode'));
         return $data ? implode("\n", $data) : false;
     } catch (Router_ArgNoExist $e) {
         return false;
     }
 }
コード例 #14
0
ファイル: listeners.php プロジェクト: jinshana/tangocms
 /**
  * Add in the right RSS feed to the HTML head
  *
  * @param array $rData
  * @return array
  */
 public function hookCntrlrPreDispatch($rData)
 {
     if (Registry::has('theme')) {
         if ($rData['module'] != 'rss' && $rData['controller'] != 'feed') {
             // Get the default feed
             try {
                 $defFeed = array();
                 $defFeed[] = $this->_config->get('rss/default_feed');
                 if (!Rss::feedExists($defFeed[0])) {
                     unset($defFeed[0]);
                 }
             } catch (Config_KeyNoExist $e) {
                 $this->_log->message('RSS config key "rss/default_feed" does not exist, unable to add default feed to head.', Log::L_WARNING);
             }
             // Find all the RSS feeds for the current page
             $feeds = Hooks::notifyAll('rss_insert_head', $rData['module'], $rData['controller'], $rData['section']);
             if (is_array($feeds)) {
                 foreach (array_filter(array_merge($defFeed, $feeds)) as $feed) {
                     // Add all found feeds to head
                     $rss = new Rss($feed);
                     if ($rss->hasFeedInfo()) {
                         $details = array('rel' => 'alternate', 'type' => 'application/rss+xml', 'href' => $this->_router->makeFullUrl('rss', 'feed', $feed), 'title' => $rss->getFeedInfo('title'));
                         $this->_theme->addHead('link', $details);
                     } else {
                         $this->_log->message('Feed "' . $feed . '" does not have feed info set.', Log::L_WARNING);
                     }
                 }
             }
         }
     }
     return $rData;
 }
コード例 #15
0
ファイル: Base.php プロジェクト: jinshana/tangocms
 /**
  * Purges all cached items
  *
  * @return bool
  */
 public function purge()
 {
     Hooks::notifyAll('cache_purge', null);
     return true;
 }
コード例 #16
0
ファイル: Eaccelerator.php プロジェクト: jinshana/tangocms
 /**
  * Purges all cached items
  *
  * @return bool
  */
 public function purge()
 {
     Hooks::notifyAll('cache_purge', 'eaccelerator');
     return true;
 }
コード例 #17
0
ファイル: bootstrap.php プロジェクト: jinshana/tangocms
            $theme->loadLayout($layout);
            $output = $theme;
        }
    } catch (Theme_NoExist $e) {
        Registry::get('log')->message($e->getMessage(), Log::L_WARNING);
        trigger_error('required theme "' . $themeName . '" does not exist', E_USER_WARNING);
        $output = $dispatcher->dispatch($requestedUrl, $dispatchConfig);
    }
} else {
    $output = $dispatcher->dispatch($requestedUrl, $dispatchConfig);
    if ($zula->getMode() == 'cli') {
        // Display a friendly message to stdout
        switch ($dispatcher->getStatusCode()) {
            case 200:
                if (!is_bool($output)) {
                    $output .= "\n";
                }
                break;
            case 403:
                $output = sprintf(t('---- Permission denied to "%s"', I18n::_DTD), $input->cli('r')) . "\n";
                $zula->setExitCode(5);
                break;
            case 404:
                $output = sprintf(t('---- The request path "%s" does not exist', I18n::_DTD), $input->cli('r')) . "\n";
                $zula->setExitCode(4);
                break;
        }
    }
}
Hooks::notifyAll('bootstrap_loaded', isset($output) && $output instanceof Theme, $dispatcher->getStatusCode(), $dispatcher->getDispatchData());
return is_bool($output) ? true : (print $output);
コード例 #18
0
ファイル: contact.php プロジェクト: jinshana/tangocms
 /**
  * Deletes a contact form and all fields under it
  *
  * @param int $fid
  * @return bool
  */
 public function deleteForm($fid)
 {
     $form = $this->getForm($fid);
     $query = $this->_sql->query('DELETE FROM {PREFIX}mod_contact WHERE id = ' . (int) $form['id']);
     $query->closeCursor();
     if ($query->rowCount()) {
         $this->_acl->deleteResource('contact-form-' . $form['id']);
         $query = $this->_sql->query('DELETE FROM {PREFIX}mod_contact_fields WHERE form_id = ' . (int) $form['id']);
         $query->closeCursor();
         // Remove all cache
         $this->_cache->delete(array('contact_forms', 'contact_form_' . $form['identifier'], 'contact_fields_' . $form['id']));
         Hooks::notifyAll('contact_delete_form', $form['id']);
     } else {
         return false;
     }
 }
コード例 #19
0
ファイル: Apc.php プロジェクト: jinshana/tangocms
 /**
  * Purges all cached items
  *
  * @return bool
  */
 public function purge()
 {
     Hooks::notifyAll('cache_purge', 'apc');
     return apc_clear_cache();
 }
コード例 #20
0
ファイル: listeners.php プロジェクト: jinshana/tangocms
 /**
  * Updates an article feed item body, from the article part
  *
  * @param int $pid
  * @param array $partDetails
  * @return bool
  */
 public function hookArticleEditPart($pid, $partDetails)
 {
     if ($partDetails['order'] == 1) {
         try {
             $article = $this->_model()->getArticle($partDetails['article_id']);
             $cat = $this->_model()->getCategory($article['cat_id']);
             $item = array('id' => 'article-' . $partDetails['article_id'], 'title' => null, 'url' => null, 'desc' => $partDetails['body']);
             Hooks::notifyAll('rssmod_edit', array('article-latest', 'article-' . $cat['identifier']), $item);
         } catch (Article_CatNoExist $e) {
             return false;
         } catch (Article_NoExist $e) {
             return false;
         }
     }
 }
コード例 #21
0
ファイル: Tmp.php プロジェクト: jinshana/tangocms
 /**
  * Purges all cached items
  *
  * @return bool
  */
 public function purge()
 {
     $this->cached = array();
     Hooks::notifyAll('cache_purge', 'tmp');
     return true;
 }
コード例 #22
0
ファイル: Wincache.php プロジェクト: jinshana/tangocms
 /**
  * Purges all cached items
  *
  * @return bool
  */
 public function purge()
 {
     Hooks::notifyAll('cache_purge', 'wincache');
     return wincache_ucache_clear();
 }